radioapp/radiowidgets/src/radiofrequencystrip.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 18:12:57 +0300
changeset 32 189d20c34778
parent 28 075425b8d9a4
child 33 11b6825f0862
permissions -rw-r--r--
Revision: 201023 Kit: 2010125
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
*
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
*
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
* Contributors:
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
*
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
* Description:
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
*
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
*/
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
// System includes
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
#include <QPainter>
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#include <QStringListModel>
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include <QGraphicsSceneResizeEvent>
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include <QPen>
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include <HbPushButton>
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#include <QTimer>
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#include <HbColorScheme>
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include <HbEvent>
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
#include <HbSwipeGesture>
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
#include "radiofrequencystrip.h"
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
#include "radiofrequencyitem.h"
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
#include "radiouiengine.h"
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
#include "radiostation.h"
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
#include "radiostationmodel.h"
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    34
#include "radioutil.h"
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    35
#include "radiouiloader.h"
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
#include "radiologger.h"
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
// Frequency lines
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    39
const int TAB_HEIGHT_SMALL = 10;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    40
const int TAB_HEIGHT_BIG = 15;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    41
const int PEN_WIDTH_FAVORITE = 4;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    42
const qreal INDICATOR_WIDTH = 2.0;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    43
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    44
const qreal ROUNDER = 0.5;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    45
const int SELECTOR_WIDTH = 2;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    46
const int SELECTOR_Z_POS = 100;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    48
const int HALF_HERTZ = ONE_HERTZ / 2;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    49
const int ONE_TAB_DISTANCE = 20;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    50
const uint ONE_TAB_IN_HZ = uint( 0.2 * ONE_HERTZ );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    51
const qreal PIXEL_IN_HZ = ONE_TAB_IN_HZ / ONE_TAB_DISTANCE;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    52
const qreal PIXMAP_OVERLAP = qreal( ONE_TAB_DISTANCE ) / 2;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    53
const int ITEM_WIDTH = ONE_TAB_DISTANCE * 5;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    54
const int PIXMAP_WIDTH = ITEM_WIDTH + (int)PIXMAP_OVERLAP;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    55
const int STRIP_HEIGHT = 50;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    57
const uint ONE_HUNDRED_KHZ = 100000;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    58
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    59
const char* DECIMAL_TEXT = ".0";
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    61
#ifdef BUILD_WIN32
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    62
    const int FREQUENCY_FONT_SIZE = 12;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    63
    const int DECIMAL_FONT_SIZE = 8;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    64
#else
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    65
    const int FREQUENCY_FONT_SIZE = 6;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    66
    const int DECIMAL_FONT_SIZE = 4;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    67
#endif // BUILD_WIN32
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    69
const QFont FREQUENCY_FONT( "", FREQUENCY_FONT_SIZE );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    70
const QFont DECIMAL_FONT( "", DECIMAL_FONT_SIZE );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    71
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    72
const char* SLIDE_TO_LEFT       = "SlideToLeft";
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    73
const char* SLIDE_FROM_LEFT     = "SlideFromLeft";
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    74
const char* SLIDE_TO_RIGHT      = "SlideToRight";
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    75
const char* SLIDE_FROM_RIGHT    = "SlideFromRight";
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
const char* LEFT_BUTTON         = "tv:left_button";
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
const char* RIGHT_BUTTON        = "tv:right_button";
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
const char* TEXT_COLOR_ATTRIBUTE = "text";
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    80
const int MANUALSEEK_START_TIMEOUT = 400;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    81
const int MANUALSEEK_END_TIMEOUT = 2000;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    82
const int MANUALSEEK_SIGNAL_DELAY = 300;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
static QLineF makeTab( qreal pos, int height )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    89
    return QLineF( pos, STRIP_HEIGHT - height, pos, STRIP_HEIGHT );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
RadioFrequencyStrip::RadioFrequencyStrip() :
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
    RadioStripBase(),
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
    mUiEngine( NULL ),
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
    mMinFrequency( 87500000 ),
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
    mMaxFrequency( 108000000 ),
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
    mFrequencyStepSize( 100000 ),
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
    mFrequency( 87500000 ),
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
    mSelectorImage( new QGraphicsPixmapItem( this ) ),
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
    mSeparatorPos( 0.0 ),
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
    mMaxWidth( 0 ),
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
    mSelectorPos( 0.0 ),
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   106
    mLeftButton( 0 ),
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   107
    mRightButton( 0 ),
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   108
    mManualSeekTimer( NULL ),
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   109
    mManualSeekMode( false ),
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   110
    mLastReportedFrequency( 0 ),
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   111
    mManualSeekTimerId( 0 ),
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
    mForegroundColor( Qt::white )//HbColorScheme::color( TEXT_COLOR_ATTRIBUTE ) )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   114
    RadioUtil::setFrequencyStrip( this );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   116
    setScrollingStyle( HbScrollArea::PanWithFollowOn );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   117
    setItemSize( QSizeF( ITEM_WIDTH + PIXMAP_OVERLAP / 2, STRIP_HEIGHT ) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   118
    setOverlap( PIXMAP_OVERLAP / 2 );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
    initModel();
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
    initSelector();
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   124
    initEmptyItems();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   126
    initPositions();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
    mFrequency = RadioUiEngine::lastTunedFrequency();
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
 */
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   134
void RadioFrequencyStrip::init( RadioUiEngine* engine, RadioUiLoader& uiLoader )
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
    mUiEngine = engine;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
    mMinFrequency       = mUiEngine->minFrequency();
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
    mMaxFrequency       = mUiEngine->maxFrequency();
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
    mFrequencyStepSize  = mUiEngine->frequencyStepSize();
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   140
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   141
    mLeftButton = uiLoader.findWidget<HbPushButton>( DOCML::MV_NAME_PREV_BUTTON );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   142
    mRightButton = uiLoader.findWidget<HbPushButton>( DOCML::MV_NAME_NEXT_BUTTON );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   143
    initButtons();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   145
    mManualSeekTimer = new QTimer( this );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   146
    mManualSeekTimer->setInterval( MANUALSEEK_START_TIMEOUT );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   147
    mManualSeekTimer->setSingleShot( true );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   148
    Radio::connect( mManualSeekTimer,   SIGNAL(timeout()),
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   149
                    this,               SLOT(toggleManualSeek()) );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   151
    Radio::connect( mLeftButton,    SIGNAL(clicked()),
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
                    this,           SLOT(handleLeftButton()) );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   153
    Radio::connect( mRightButton,   SIGNAL(clicked()),
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
                    this,           SLOT(handleRightButton()) );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   155
    Radio::connect( mLeftButton,    SIGNAL(longPress(QPointF)),
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
                    this,           SLOT(handleLongLeftButton()) );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   157
    Radio::connect( mRightButton,   SIGNAL(longPress(QPointF)),
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   158
                    this,           SLOT(handleLongRightButton()) );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   159
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   160
    Radio::connect( this,           SIGNAL(scrollingEnded()),
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   161
                    this,           SLOT(handleScrollingEnd()) );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   162
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
    grabGesture( Qt::SwipeGesture );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
    //TODO: Remove. Stepsize hardcoded to 100 Khz in europe region during demo
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   166
    if ( mFrequencyStepSize < ONE_HUNDRED_KHZ ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   167
        mFrequencyStepSize = ONE_HUNDRED_KHZ;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
    RadioStationModel* stationModel = &mUiEngine->stationModel();
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   171
    Radio::connect( stationModel,   SIGNAL(rowsInserted(QModelIndex,int,int)),
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
                    this,           SLOT(updateStation(QModelIndex,int,int)) );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   173
    Radio::connect( stationModel,   SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   174
                    this,           SLOT(removeStation(QModelIndex,int,int)) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   175
    Radio::connect( stationModel,   SIGNAL(modelReset()),
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
                    this,           SLOT(initEmptyItems()) );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   178
    updateAllItems();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   180
    showButtons();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
 */
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   186
void RadioFrequencyStrip::setFrequency( const uint frequency, int reason, Scroll::Direction direction )
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   188
    Q_UNUSED( reason );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
    LOG_FORMAT( "RadioFrequencyStrip::setFrequency, frequency: %d, reason: %d", frequency, reason );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   190
    if ( mFrequencies.contains( frequency ) ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   191
        if ( frequency != mFrequency || reason == TuneReason::Skip ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   192
            scrollToFrequency( frequency, direction, mAutoScrollTime, RadioUtil::tuneReason( reason ) );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
        }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
uint RadioFrequencyStrip::frequency() const
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   201
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
    return mFrequency;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   203
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   204
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
/*!
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   206
 *
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   207
 */
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   208
bool RadioFrequencyStrip::isInManualSeekMode() const
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   209
{
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   210
    return mManualSeekMode;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   211
}
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   212
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   213
/*!
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   214
 *
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   215
 */
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   216
void RadioFrequencyStrip::cancelManualSeek()
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   217
{
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   218
    mManualSeekTimer->stop();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   219
    if ( mManualSeekMode ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   220
        toggleManualSeek();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   221
    }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   222
}
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   223
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   224
/*!
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   225
 *
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   226
 */
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   227
void RadioFrequencyStrip::addScannedStation( const RadioStation& station )
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   228
{
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   229
    FrequencyPos pos = mFrequencies.value( station.frequency() );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   230
    updateItem( pos.mItem, station.frequency() );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   231
}
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   232
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   233
/*!
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
void RadioFrequencyStrip::updateFavorite( const RadioStation& station )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
    LOG_SLOT_CALLER;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
    FrequencyPos pos = mFrequencies.value( station.frequency() );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   240
    updateItem( pos.mItem );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
 * Public slot
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
void RadioFrequencyStrip::setScanningMode( bool isScanning )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   249
    mManualSeekTimer->stop();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
    if ( isScanning ) {
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   251
        initEmptyItems();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
        hideButtons();
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   253
        scrollToFrequency( mMinFrequency, Scroll::Shortest, mAutoScrollTime );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
    } else {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   255
        showButtons();
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
    setEnabled( !isScanning );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
 * Private slot
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   262
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   263
 */
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   264
void RadioFrequencyStrip::removeStation( const QModelIndex& parent, int first, int last )
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   265
{
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   266
    Q_UNUSED( parent );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   267
    updateStationsInRange( first, last, true );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   268
}
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   269
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   270
/*!
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   271
 * Private slot
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   272
 *
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   273
 */
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
void RadioFrequencyStrip::updateStation( const QModelIndex& parent, int first, int last )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
    Q_UNUSED( parent );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   277
    updateStationsInRange( first, last );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
 * Private slot
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
void RadioFrequencyStrip::initEmptyItems()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
    LOG_METHOD;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   287
    //TODO: Remove the weird hack of checking the sender
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   288
    if ( !sender() || RadioUtil::scanStatus() != Scan::ScanningInMainView ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   289
        QList<RadioStation> emptyList;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   290
        foreach ( RadioFrequencyItem* item, mFrequencyItems ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   291
            QPixmap pixmap = drawPixmap( item->frequency(), emptyList, item );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   292
            item->setPixmap( pixmap );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   293
        }
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
 * Private slot
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
void RadioFrequencyStrip::handleLeftButton()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
    emit skipRequested( StationSkip::PreviousFavorite );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   303
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
 * Private slot
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
void RadioFrequencyStrip::handleLongLeftButton()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   309
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   310
    emit seekRequested( Seek::Down );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   311
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   312
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   313
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   314
 * Private slot
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
void RadioFrequencyStrip::handleRightButton()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
    emit skipRequested( StationSkip::NextFavorite );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   322
 * Private slot
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   323
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
void RadioFrequencyStrip::handleLongRightButton()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   326
    emit seekRequested( Seek::Up );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   330
 * Private slot
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   331
 *
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
 */
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   333
void RadioFrequencyStrip::toggleManualSeek()
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   334
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   335
    mManualSeekMode = !mManualSeekMode;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   336
    emit manualSeekChanged( mManualSeekMode );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   337
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   338
    if ( mManualSeekMode ) {
32
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   339
        grabMouse();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
        hideButtons();
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   341
        mManualSeekTimerId = startTimer( MANUALSEEK_SIGNAL_DELAY );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
    } else {
32
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   343
        ungrabMouse();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
        showButtons();
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   345
        killTimer( mManualSeekTimerId );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   346
        mManualSeekTimerId = 0;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   347
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   348
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   349
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
 * Private slot
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
 */
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   353
void RadioFrequencyStrip::handleScrollingEnd()
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   354
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
    // Check if the selector is in the invalid area where the strip loops around
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
    const int selectorPosition = selectorPos();
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   357
    if ( mManualSeekMode ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   358
        if ( !mPositions.contains( selectorPosition ) ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   359
            if ( selectorPosition < mMaxWidth - ITEM_WIDTH + mSeparatorPos ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   360
                scrollToFrequency( mMaxFrequency, Scroll::Shortest, 500 );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   361
                emit frequencyChanged( mMaxFrequency, TuneReason::ManualSeekUpdate, Scroll::Shortest );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   362
            } else {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   363
                scrollToFrequency( mMinFrequency, Scroll::Shortest, 500 );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   364
                emit frequencyChanged( mMinFrequency, TuneReason::ManualSeekUpdate, Scroll::Shortest );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   365
            }
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   366
        }
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   367
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   368
        mManualSeekTimer->start( MANUALSEEK_END_TIMEOUT );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   372
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
 * \reimp
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   374
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   375
void RadioFrequencyStrip::updateItemPrimitive( QGraphicsItem* itemToUpdate, int itemIndex )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   376
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   377
    QGraphicsPixmapItem* item = static_cast<QGraphicsPixmapItem*>( itemToUpdate );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   378
    if ( itemIndex < mFrequencyItems.count() ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   379
        item->setPixmap( mFrequencyItems.at( itemIndex )->updatePrimitive( item ) );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   380
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   381
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   382
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   383
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   384
 * \reimp
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   385
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   386
QGraphicsItem* RadioFrequencyStrip::createItemPrimitive( QGraphicsItem* parent )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   387
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   388
    return new QGraphicsPixmapItem( parent );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   389
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   390
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   391
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   392
 * \reimp
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   393
 */
32
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   394
void RadioFrequencyStrip::scrollPosChanged()
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   395
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   396
    if ( mManualSeekMode ) {
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   397
        const int pos = selectorPos();
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   398
        const uint frequency = mPositions.value( pos );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   399
        if ( frequency > 0 ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   400
            mFrequency = mPositions.value( pos );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   401
            emit frequencyChanged( mFrequency, TuneReason::ManualSeekUpdate, Scroll::Shortest );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   402
        }
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   403
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   404
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   405
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   406
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   407
 * \reimp
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   408
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   409
void RadioFrequencyStrip::resizeEvent ( QGraphicsSceneResizeEvent* event )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   410
{
32
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   411
    LOG_METHOD;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   412
    RadioStripBase::resizeEvent( event );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   413
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   414
    const qreal height = event->newSize().height();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   415
    const qreal width = event->newSize().width();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   416
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   417
    mSelectorPos = width / 2;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   418
    mSelectorImage->setOffset( mSelectorPos - (INDICATOR_WIDTH / 2), 0.0 );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   419
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   420
    if ( mLeftButton && mRightButton ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   421
        mLeftButton->resize( height, height );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   422
        mRightButton->resize( height, height );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   423
        mRightButton->setPos( QPointF( width - height, 0 ) );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   424
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   425
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   426
    scrollToFrequency( mFrequency );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   427
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   428
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   429
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   430
 * \reimp
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   431
 */
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   432
//void RadioFrequencyStrip::showEvent( QShowEvent* event )
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   433
//{
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   434
//    RadioStripBase::showEvent( event );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   435
//    scrollToFrequency( mFrequency );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   436
//}
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   437
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   438
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   439
 * \reimp
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   440
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   441
void RadioFrequencyStrip::changeEvent( QEvent* event )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   442
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   443
    if ( event->type() == HbEvent::ThemeChanged ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   444
        // Update the foreground color and redraw each item
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   445
        mForegroundColor = Qt::white;// HbColorScheme::color( TEXT_COLOR_ATTRIBUTE );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   446
        updateAllItems();
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   447
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   448
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   449
    return RadioStripBase::changeEvent(event);
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   450
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   451
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   452
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   453
 * \reimp
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   454
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   455
void RadioFrequencyStrip::mousePressEvent( QGraphicsSceneMouseEvent* event )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   456
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   457
    RadioStripBase::mousePressEvent( event );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   458
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   459
    mManualSeekTimer->stop();
32
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   460
    if ( mManualSeekMode ) {
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   461
        const bool insideStrip = rect().contains( event->pos() );
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   462
        if ( !insideStrip ) {
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   463
            toggleManualSeek();
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   464
        }
189d20c34778 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 28
diff changeset
   465
    } else {
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   466
        mManualSeekTimer->start( MANUALSEEK_START_TIMEOUT );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   467
    }
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   468
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   469
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   470
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   471
 * \reimp
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   472
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   473
void RadioFrequencyStrip::mouseReleaseEvent( QGraphicsSceneMouseEvent* event )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   474
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   475
    RadioStripBase::mouseReleaseEvent( event );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   476
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   477
    mManualSeekTimer->stop();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   478
    if ( mManualSeekMode && !isScrolling() ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   479
        mManualSeekTimer->start( MANUALSEEK_END_TIMEOUT );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   480
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   481
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   482
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   483
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   484
 * \reimp
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   485
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   486
void RadioFrequencyStrip::gestureEvent( QGestureEvent* event )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   487
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   488
    HbSwipeGesture* swipeGesture = static_cast<HbSwipeGesture*>( event->gesture( Qt::SwipeGesture ) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   489
    if ( swipeGesture && !mManualSeekMode ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   490
        if ( swipeGesture->state() == Qt::GestureFinished ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   491
            if ( swipeGesture->horizontalDirection() == QSwipeGesture::Left ) {
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   492
                emit skipRequested( StationSkip::Next );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   493
            } else if ( swipeGesture->horizontalDirection() == QSwipeGesture::Right ) {
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   494
                emit skipRequested( StationSkip::Previous );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   495
            }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   496
        }
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   497
    } else if ( mManualSeekMode ) {
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   498
        RadioStripBase::gestureEvent( event );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   499
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   500
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   501
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   502
/*!
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   503
 * \reimp
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   504
 */
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   505
void RadioFrequencyStrip::timerEvent( QTimerEvent* event )
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   506
{
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   507
    Q_UNUSED( event );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   508
    if ( mLastReportedFrequency != mFrequency ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   509
        mLastReportedFrequency = mFrequency;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   510
        emit frequencyChanged( mFrequency, TuneReason::ManualSeekTune, Scroll::Shortest );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   511
    }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   512
}
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   513
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   514
/*!
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   515
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   516
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   517
void RadioFrequencyStrip::initModel()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   518
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   519
    const uint minFreq = uint( qreal(mMinFrequency) / ONE_HERTZ + ROUNDER );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   520
    const uint maxFreq = uint( qreal(mMaxFrequency) / ONE_HERTZ + 0.9 ); // always round up
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   521
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   522
    QStringList list;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   523
    QString freqText;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   524
    for ( uint i = minFreq; i <= maxFreq; ++i ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   525
        freqText = QString::number( i );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   526
        list.append( freqText );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   527
        mFrequencyItems.append( new RadioFrequencyItem( freqText ) );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   528
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   529
    mFrequencyItems.append( new RadioFrequencyItem( "" ) );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   530
    list.append( "" );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   531
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   532
    mMaxWidth = list.count() * ITEM_WIDTH;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   533
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   534
    mSeparatorPos = qreal(ITEM_WIDTH) / 2;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   535
    const uint minDrawableFreq = minFreq * ONE_HERTZ - HALF_HERTZ;;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   536
    const uint maxDrawableFreq = maxFreq * ONE_HERTZ + HALF_HERTZ;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   537
    mSeparatorPos += qreal( ( mMinFrequency  - minDrawableFreq ) / 2 ) / PIXEL_IN_HZ;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   538
    mSeparatorPos -= qreal( ( maxDrawableFreq - mMaxFrequency ) / 2 ) / PIXEL_IN_HZ;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   539
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   540
    setModel( new QStringListModel( list, this ) );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   541
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   542
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   543
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   544
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   545
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   546
void RadioFrequencyStrip::initSelector()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   547
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   548
    QPixmap selectorPixmap = QPixmap( QSize( SELECTOR_WIDTH, STRIP_HEIGHT ) );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   549
    selectorPixmap.fill( Qt::red );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   550
    mSelectorImage->setPixmap( selectorPixmap );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   551
    mSelectorImage->setZValue( SELECTOR_Z_POS );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   552
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   553
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   554
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   555
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   556
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   557
void RadioFrequencyStrip::initPositions()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   558
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   559
    int prevPos = 0;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   560
    int nextPos = 0;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   561
    const int lastPos = mFrequencies.value( mMaxFrequency ).mPosition;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   562
    for ( int i = mFrequencies.value( mMinFrequency ).mPosition; i < lastPos; ++i ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   563
        if ( mPositions.contains( i ) ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   564
            prevPos = i;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   565
            const uint freq = mPositions.value( prevPos ) + mFrequencyStepSize;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   566
            if ( mFrequencies.contains( freq ) ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   567
                nextPos = mFrequencies.value( freq ).mPosition;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   568
            } else {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   569
                nextPos = prevPos;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   570
            }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   571
        } else {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   572
            const int nearestHit = ( i - prevPos ) < ( nextPos - i ) ? prevPos : nextPos;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   573
            mPositions.insert( i, mPositions.value( nearestHit ) );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   574
        }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   575
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   576
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   577
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   578
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   579
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   580
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   581
void RadioFrequencyStrip::initButtons()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   582
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   583
    mLeftButton->setZValue( SELECTOR_Z_POS );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   584
    mLeftButton->setObjectName( LEFT_BUTTON );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   585
    mRightButton->setZValue( SELECTOR_Z_POS );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   586
    mRightButton->setObjectName( RIGHT_BUTTON );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   587
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   588
    const qreal height = size().height();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   589
    const qreal width = size().width();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   590
    mLeftButton->resize( height, height );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   591
    mRightButton->resize( height, height );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   592
    mRightButton->setPos( QPointF( width - height, 0 ) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   593
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   594
    QEffectList effectList;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   595
    effectList.append( EffectInfo( mLeftButton, ":/effects/slide_to_left.fxml", SLIDE_TO_LEFT ) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   596
    effectList.append( EffectInfo( mLeftButton, ":/effects/slide_from_left.fxml", SLIDE_FROM_LEFT ) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   597
    effectList.append( EffectInfo( mRightButton, ":/effects/slide_to_right.fxml", SLIDE_TO_RIGHT ) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   598
    effectList.append( EffectInfo( mRightButton, ":/effects/slide_from_right.fxml", SLIDE_FROM_RIGHT ) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   599
    RadioUtil::addEffects( effectList );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   600
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   601
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   602
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   603
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   604
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   605
void RadioFrequencyStrip::addFrequencyPos( int pos, uint frequency, RadioFrequencyItem* item )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   606
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   607
    mFrequencies.insert( frequency, FrequencyPos( pos, item ) );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   608
    mPositions.insert( pos, frequency );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   609
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   610
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   611
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   612
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   613
 */
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   614
void RadioFrequencyStrip::updateStationsInRange( int first, int last, bool stationRemoved )
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   615
{
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   616
    if ( RadioUtil::scanStatus() != Scan::ScanningInMainView ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   617
        RadioStationModel& model = mUiEngine->stationModel();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   618
        uint frequency = 0;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   619
        for ( int i = first; i <= last; ++i ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   620
            frequency = model.data( model.index( i, 0, QModelIndex() ),
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   621
                                    RadioRole::RadioStationRole ).value<RadioStation>().frequency();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   622
            if ( mFrequencies.contains( frequency ) ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   623
                FrequencyPos pos = mFrequencies.value( frequency );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   624
                updateItem( pos.mItem, 0, stationRemoved ? frequency : 0 );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   625
            }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   626
        }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   627
    }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   628
}
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   629
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   630
/*!
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   631
 *
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   632
 */
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   633
void RadioFrequencyStrip::updateItem( RadioFrequencyItem* item, uint upperRange, uint ignoredFrequency )
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   634
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   635
    if ( item ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   636
        uint frequency = item->frequency();
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   637
        QList<RadioStation> stations;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   638
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   639
        if ( upperRange == 0 ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   640
            upperRange = frequency + HALF_HERTZ;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   641
        }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   642
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   643
        if ( mUiEngine ) {
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   644
            stations = mUiEngine->stationsInRange( frequency - HALF_HERTZ, upperRange );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   645
            for ( int i = stations.count() - 1; ignoredFrequency > 0 && i >= 0; --i ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   646
                if ( stations[i].frequency() == ignoredFrequency ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   647
                    stations.removeAt( i );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   648
                    break;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   649
                }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   650
            }
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   651
        }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   652
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   653
        QPixmap pixmap = drawPixmap( frequency, stations, item );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   654
        item->setPixmap( pixmap );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   655
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   656
        foreach ( const RadioStation& station, stations ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   657
            frequency = station.frequency();
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   658
            FrequencyPos pos = mFrequencies.value( frequency );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   659
            mFrequencies.insert( frequency, pos );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   660
        }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   661
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   662
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   663
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   664
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   665
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   666
 */
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   667
void RadioFrequencyStrip::updateAllItems()
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   668
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   669
    foreach ( RadioFrequencyItem* item, mFrequencyItems ) {
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   670
        updateItem( item );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   671
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   672
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   673
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   674
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   675
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   676
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   677
QPixmap RadioFrequencyStrip::drawPixmap( uint frequency, QList<RadioStation> stations, RadioFrequencyItem* item )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   678
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   679
    QPixmap pixmap( PIXMAP_WIDTH, STRIP_HEIGHT );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   680
    pixmap.fill( Qt::transparent );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   681
    QPainter painter( &pixmap );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   682
    QPen normalPen = painter.pen();
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   683
    QPen favoritePen = normalPen;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   684
    normalPen.setColor( mForegroundColor );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   685
    painter.setPen( normalPen );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   686
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   687
    if ( frequency == 0 ) {
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   688
        painter.drawLine( makeTab( mSeparatorPos - 1 + ROUNDER, STRIP_HEIGHT ) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   689
        painter.drawLine( makeTab( mSeparatorPos + ROUNDER, STRIP_HEIGHT ) );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   690
        return pixmap;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   691
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   692
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   693
    const QString itemText = QString::number( frequency / ONE_HERTZ );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   694
    const uint startFrequency = frequency - HALF_HERTZ;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   695
    const uint endFrequency = startFrequency + ONE_HERTZ;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   696
    const uint  roundedMin = int( qreal(mMinFrequency) / ONE_HERTZ + ROUNDER );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   697
    const uint freq = frequency / ONE_HERTZ;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   698
    const int diff = freq - roundedMin;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   699
    const qreal startPixel = diff * ITEM_WIDTH;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   700
    qreal pixels = 0.0;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   701
    const qreal leftOverlap = PIXMAP_OVERLAP / 2;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   702
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   703
    for ( uint frequency = startFrequency; frequency <= endFrequency; frequency += mFrequencyStepSize ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   704
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   705
        if ( frequency < mMinFrequency || frequency > mMaxFrequency ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   706
            continue;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   707
        }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   708
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   709
        pixels = qreal( frequency - startFrequency ) / PIXEL_IN_HZ;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   710
        if ( frequency % ONE_HERTZ == 0 ) {
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   711
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   712
            // Draw the high frequency tab and the frequency text for the even number
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   713
            painter.drawLine( makeTab( pixels + leftOverlap, TAB_HEIGHT_BIG ) );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   714
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   715
            // Draw the frequency text and its 00 decimals
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   716
            painter.setFont( DECIMAL_FONT );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   717
            const int decimalWidth = painter.fontMetrics().width( DECIMAL_TEXT );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   718
            const int decimalSpace = painter.fontMetrics().leftBearing( '.' );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   719
            painter.setFont( FREQUENCY_FONT );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   720
            const int frequencyWidth = painter.fontMetrics().width( itemText );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   721
            const int textPosX = int( pixels + leftOverlap - ( frequencyWidth + decimalSpace + decimalWidth ) / 2 );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   722
            painter.drawText( QPoint( textPosX, 20 ), itemText );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   723
            painter.setFont( DECIMAL_FONT );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   724
            painter.drawText( QPoint( textPosX + frequencyWidth + decimalSpace, 20 ), DECIMAL_TEXT );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   725
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   726
        } else if ( frequency % ONE_TAB_IN_HZ == 0 ) {
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   727
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   728
            // Draw the low frequency tab for the uneven number
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   729
            painter.drawLine( makeTab( pixels + leftOverlap, TAB_HEIGHT_SMALL ) );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   730
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   731
        }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   732
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   733
        addFrequencyPos( int( startPixel + pixels + ROUNDER ), frequency, item );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   734
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   735
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   736
    // Draw favorites and local stations
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   737
    favoritePen.setColor( Qt::yellow );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   738
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   739
    const int markerYPos = STRIP_HEIGHT - 20;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   740
    foreach ( const RadioStation& station, stations ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   741
        const uint frequency = station.frequency();
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   742
        pixels = qreal( frequency - startFrequency ) / PIXEL_IN_HZ;
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   743
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   744
        if ( station.isFavorite() ) {
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   745
            favoritePen.setWidth( PEN_WIDTH_FAVORITE );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   746
            painter.setPen( favoritePen );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   747
            painter.drawEllipse( int( pixels + leftOverlap - 3 ), markerYPos - 3, 6, 6 );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   748
//            painter.drawPixmap( pixels - 10, 20, 20, 20, mFavoriteIcon.pixmap() );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   749
        } else if ( station.isType( RadioStation::LocalStation ) ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   750
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   751
            favoritePen.setWidth( 1 );
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   752
            painter.setPen( favoritePen );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   753
            painter.drawEllipse( int( pixels + leftOverlap - 4 ), markerYPos - 4, 8, 8 );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   754
        }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   755
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   756
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   757
    return pixmap;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   758
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   759
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   760
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   761
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   762
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   763
void RadioFrequencyStrip::emitFrequencyChanged( uint frequency )
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   764
{
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   765
    if ( frequency > 0 && frequency != mFrequency ) {
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   766
        mFrequency = frequency;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   767
        //TOD: Get direction
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   768
        emit frequencyChanged( frequency, TuneReason::FrequencyStrip, Scroll::Shortest );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   769
    }
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   770
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   771
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   772
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   773
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   774
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   775
int RadioFrequencyStrip::selectorPos() const
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   776
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   777
    const int pos = int( -contentWidget()->x() + mSelectorPos + ROUNDER );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   778
    return pos % mMaxWidth;
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   779
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   780
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   781
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   782
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   783
 */
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   784
void RadioFrequencyStrip::scrollToFrequency( uint frequency, Scroll::Direction direction, int time, TuneReason::Reason reason )
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   785
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   786
    int targetFreqPos = mFrequencies.value( frequency ).mPosition;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   787
    const int currentFreqPos = mFrequencies.value( mFrequency ).mPosition;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   788
    const int currentPos = int( -contentWidget()->x() + mSelectorPos + ROUNDER );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   789
    const bool isInSecondHalf = currentPos >= mMaxWidth - ITEM_WIDTH + mSeparatorPos;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   790
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   791
    // Special case: When there is only one favorite and the user presses skip
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   792
    // the strip must scroll around to the same frequency.
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   793
    if ( mFrequency == frequency && reason == TuneReason::Skip ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   794
        if ( direction == Scroll::Left ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   795
            targetFreqPos += mMaxWidth;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   796
        } else {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   797
        targetFreqPos -= mMaxWidth;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   798
        }
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   799
    }
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   800
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   801
    mFrequency = frequency;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   802
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   803
    qreal newPos = targetFreqPos;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   804
    if ( direction == Scroll::Left ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   805
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   806
        if ( currentFreqPos > targetFreqPos ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   807
            newPos += mMaxWidth;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   808
        }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   809
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   810
    } else if ( direction == Scroll::Right ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   811
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   812
        if ( currentFreqPos < targetFreqPos ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   813
            newPos -= mMaxWidth;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   814
        }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   815
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   816
    }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   817
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   818
    if ( isInSecondHalf ) {
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   819
        newPos += mMaxWidth;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   820
    }
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   821
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   822
    newPos -= mSelectorPos - ROUNDER;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   823
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   824
    scrollContentsTo( QPointF( newPos, 0 ), time );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   825
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   826
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   827
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   828
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   829
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   830
void RadioFrequencyStrip::hideButtons()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   831
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   832
    HbEffect::start( mLeftButton, SLIDE_TO_LEFT );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   833
    HbEffect::start( mRightButton, SLIDE_TO_RIGHT );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   834
}
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   835
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   836
/*!
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   837
 *
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   838
 */
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   839
void RadioFrequencyStrip::showButtons()
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   840
{
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   841
    HbEffect::start( mLeftButton, SLIDE_FROM_LEFT );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   842
    HbEffect::start( mRightButton, SLIDE_FROM_RIGHT );
24
6df133bd92e1 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   843
}