locationpickerservice/src/locationpickersearchview.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 18 Aug 2010 09:43:18 +0300
changeset 35 59575560d1e6
parent 31 8db05346071b
child 41 b3dd5ec3089d
permissions -rw-r--r--
Revision: 201031 Kit: 201033
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: LocationPickerSearchView implementation
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include <HbListViewItem>
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <QStandardItemModel>
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <HbSearchPanel>
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <HbListView>
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    22
#include <HbTextItem>
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    23
#include <HbDocumentLoader>
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    24
#include <QGraphicsLinearLayout>
30
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    25
#include <HbMenu>
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    26
#include <HbAction>
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "locationpickerproxymodel.h"
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "locationpickersearchview.h"
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include "locationpickerdatamanager.h"
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
// ======== MEMBER FUNCTIONS ========
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
// ----------------------------------------------------
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
// LocationPickerSearchView::LocationPickerSearchView()
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
// ----------------------------------------------------
20
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    37
LocationPickerSearchView::LocationPickerSearchView( HbDocumentLoader &aLoader )
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    38
    :mProxyModel(NULL),
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    39
    mModel(NULL),
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    40
    mListView(NULL),
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    41
    mSearchPanel(NULL),
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    42
    mEmptyLabel(NULL),
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    43
    mVerticalLayout(NULL),
30
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    44
    mDocumentLoader(aLoader),
31
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
    45
	mLongPressMenu(NULL),
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
    46
	mSelectAction(NULL)
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    47
{
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    48
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    49
}
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    50
// ----------------------------------------------------
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    51
// LocationPickerSearchView::~LocationPickerSearchView()
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    52
// ----------------------------------------------------
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    53
LocationPickerSearchView::~LocationPickerSearchView()
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    54
{
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    55
    delete mProxyModel;
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    56
    delete mEmptyLabel;
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    57
}
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    59
// ----------------------------------------------------
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    60
// LocationPickerSearchView::init()
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    61
// ----------------------------------------------------
20
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    62
void LocationPickerSearchView::init( QStandardItemModel *aModel )
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    63
{   
20
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    64
    mModel = aModel;
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    65
    //get listview from docml
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    66
    mListView = qobject_cast<HbListView*>(
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    67
            mDocumentLoader.findObject(QString("SearchListView")));
30
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    68
    if(!mListView)
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    69
    {
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    70
        qFatal("Error Reading Docml");   
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    71
    }
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    72
    //get search panel from docml
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    73
    mSearchPanel = qobject_cast<HbSearchPanel*>(
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    74
            mDocumentLoader.findObject(QString("searchPanel")));
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    75
    //conect to respective slots
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    76
    connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(handleActivated
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    77
    (const QModelIndex &)));
30
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    78
    connect(mListView,SIGNAL(longPressed(HbAbstractViewItem*, const QPointF &)),this,
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
    79
                SLOT(launchPopUpMenu(HbAbstractViewItem*, const QPointF &)));
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    80
    connect(mSearchPanel, SIGNAL(exitClicked()),this, SLOT(handleExit()));
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    81
    connect(mSearchPanel,SIGNAL(criteriaChanged(QString)),this,SLOT(doSearch(QString)));
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
    //Set graphics size for the list items.
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
    HbListViewItem *hbListItem = new HbListViewItem();
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
    hbListItem->setGraphicsSize(HbListViewItem::Thumbnail);
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    mListView->setItemPrototype( hbListItem );
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    // Create the proxy model.
31
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
    89
    mProxyModel = new LocationPickerProxyModel();
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    mProxyModel->setSourceModel(mModel);
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    mListView->setModel(mProxyModel);
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    // set filter properties
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    mProxyModel->setDynamicSortFilter(TRUE);
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    mProxyModel->setSortRole(Qt::DisplayRole);
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
    mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    97
    // sort 
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    98
    mProxyModel->sort(0, Qt::AscendingOrder);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    99
}
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
// ----------------------------------------------------
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   102
// LocationPickerSearchView::handleExit()
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
// ----------------------------------------------------
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   104
void LocationPickerSearchView::handleExit()
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   105
{   
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   106
    //emit signal to switch the current view
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   107
    emit switchView();
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
}
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
// ----------------------------------------------------
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
// LocationPickerSearchView::doSearch()
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
// ----------------------------------------------------
20
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   113
void LocationPickerSearchView::doSearch( QString aCriteria )
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
{
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    // use the string to search
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
    mProxyModel->filterParameterChanged(aCriteria);
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    mProxyModel->setFilterFixedString(aCriteria);
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   118
    //if no entries presentdisplay empty text item
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   119
    if (!mProxyModel->rowCount() )
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   120
    {
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   121
        if(!mEmptyLabel)
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   122
        {    
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   123
            QGraphicsWidget *widget = NULL;
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   124
            widget = mDocumentLoader.findWidget(QString("container"));
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   125
            mVerticalLayout = static_cast<QGraphicsLinearLayout*>(widget->layout());
30
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   126
            if(!widget || !mVerticalLayout)
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   127
            {
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   128
                qFatal("Error Reading Docml"); 
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   129
            }
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   130
            mVerticalLayout->removeItem(mListView);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   131
            mListView->setVisible(false);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   132
            mEmptyLabel = new HbTextItem(hbTrId("txt_lint_list_no_results"));
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   133
            mEmptyLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   134
            mEmptyLabel->setFontSpec(HbFontSpec(HbFontSpec::Primary));
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   135
            mEmptyLabel->setAlignment(Qt::AlignCenter);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   136
            mVerticalLayout->insertItem(0, mEmptyLabel);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   137
            mEmptyLabel->setVisible(true);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   138
        }
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   139
    }
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   140
    //else display the result
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   141
    else if (mEmptyLabel)
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   142
    {   
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   143
        mVerticalLayout->removeItem(mEmptyLabel);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   144
        mEmptyLabel->setVisible(false);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   145
        delete mEmptyLabel;
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   146
        mEmptyLabel=NULL;
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   147
        mVerticalLayout->insertItem(0, mListView);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   148
        mListView->setVisible(true);
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   149
    }
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
}
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
// ----------------------------------------------------
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
// LocationPickerSearchView::handleActivated()
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
// ----------------------------------------------------
20
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   155
void LocationPickerSearchView::handleActivated( const QModelIndex &aIndex )
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
{
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    QModelIndex index = mProxyModel->mapToSource(aIndex);
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    quint32 lm = 0;
20
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   159
    getData( index, lm );
17
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   160
    //emit item is selectedsignal
0f22fb80ebba Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   161
    emit selectItem( lm );
15
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
}
13ae750350c9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
20
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   164
// ----------------------------------------------------------------------------
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   165
// LocationPickerSearchView::getData()
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   166
// ----------------------------------------------------------------------------
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   167
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   168
void LocationPickerSearchView::getData( QModelIndex aIndex, quint32& aValue )
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   169
{
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   170
    QStandardItem* item = mModel->item( aIndex.row(), aIndex.column() );
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   171
    QVariant var = item->data( Qt::UserRole );
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   172
    aValue = var.toUInt();
cd10d5b85554 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   173
}
30
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   174
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   175
// -----------------------------------------------------------------------------
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   176
// LocationPickerSearchView::launchPopUpMenu()
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   177
// -----------------------------------------------------------------------------
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   178
void LocationPickerSearchView::launchPopUpMenu(HbAbstractViewItem *aItem, const QPointF &aPoint)
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   179
{
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   180
    mLongPressMenu = new HbMenu();
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   181
    mLongPressMenu->setTimeout(HbMenu::NoTimeout);
35
59575560d1e6 Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 31
diff changeset
   182
    mSelectAction  = mLongPressMenu->addAction(hbTrId("txt_lint_list_select"));
30
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   183
    mIndex = aItem->modelIndex();
31
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   184
    connect(mSelectAction, SIGNAL(triggered()),this, SLOT(handleLongPress()));
30
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   185
    mLongPressMenu->setPreferredPos(aPoint);
31
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   186
    connect(mLongPressMenu,SIGNAL(aboutToClose ()),this,SLOT(deleteMenu()));
30
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   187
    mLongPressMenu->open();
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   188
}
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   189
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   190
// -----------------------------------------------------------------------------
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   191
// LocationPickerSearchView::handleLongPress()
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   192
// -----------------------------------------------------------------------------
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   193
void LocationPickerSearchView::handleLongPress()
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   194
{
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   195
    handleActivated(mIndex);
96df3ab41000 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 20
diff changeset
   196
}
31
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   197
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   198
// -----------------------------------------------------------------------------
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   199
// LocationPickerSearchView::deleteMenu()
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   200
// -----------------------------------------------------------------------------
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   201
void LocationPickerSearchView::deleteMenu()
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   202
{
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   203
    mLongPressMenu->deleteLater();
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   204
    mLongPressMenu = NULL;
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   205
    mSelectAction->deleteLater();
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   206
    mSelectAction = NULL;
8db05346071b Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 30
diff changeset
   207
}