locationpickerservice/src/locationpickersearchview.cpp
changeset 31 8db05346071b
parent 30 96df3ab41000
child 35 59575560d1e6
equal deleted inserted replaced
30:96df3ab41000 31:8db05346071b
    40     mListView(NULL),
    40     mListView(NULL),
    41     mSearchPanel(NULL),
    41     mSearchPanel(NULL),
    42     mEmptyLabel(NULL),
    42     mEmptyLabel(NULL),
    43     mVerticalLayout(NULL),
    43     mVerticalLayout(NULL),
    44     mDocumentLoader(aLoader),
    44     mDocumentLoader(aLoader),
    45 	mLongPressMenu(NULL)
    45 	mLongPressMenu(NULL),
       
    46 	mSelectAction(NULL)
    46 {
    47 {
    47 
    48 
    48 }
    49 }
    49 // ----------------------------------------------------
    50 // ----------------------------------------------------
    50 // LocationPickerSearchView::~LocationPickerSearchView()
    51 // LocationPickerSearchView::~LocationPickerSearchView()
    51 // ----------------------------------------------------
    52 // ----------------------------------------------------
    52 LocationPickerSearchView::~LocationPickerSearchView()
    53 LocationPickerSearchView::~LocationPickerSearchView()
    53 {
    54 {
    54     delete mProxyModel;
    55     delete mProxyModel;
    55     delete mEmptyLabel;
    56     delete mEmptyLabel;
    56     delete mLongPressMenu;
       
    57 }
    57 }
    58 
    58 
    59 // ----------------------------------------------------
    59 // ----------------------------------------------------
    60 // LocationPickerSearchView::init()
    60 // LocationPickerSearchView::init()
    61 // ----------------------------------------------------
    61 // ----------------------------------------------------
    84     HbListViewItem *hbListItem = new HbListViewItem();
    84     HbListViewItem *hbListItem = new HbListViewItem();
    85     hbListItem->setGraphicsSize(HbListViewItem::Thumbnail);
    85     hbListItem->setGraphicsSize(HbListViewItem::Thumbnail);
    86     mListView->setItemPrototype( hbListItem );
    86     mListView->setItemPrototype( hbListItem );
    87 
    87 
    88     // Create the proxy model.
    88     // Create the proxy model.
    89     mProxyModel = new LocationPickerProxyModel( Qt ::Vertical );
    89     mProxyModel = new LocationPickerProxyModel();
    90     mProxyModel->setSourceModel(mModel);
    90     mProxyModel->setSourceModel(mModel);
    91     mListView->setModel(mProxyModel);
    91     mListView->setModel(mProxyModel);
    92 
    92 
    93     // set filter properties
    93     // set filter properties
    94     mProxyModel->setDynamicSortFilter(TRUE);
    94     mProxyModel->setDynamicSortFilter(TRUE);
   170     QStandardItem* item = mModel->item( aIndex.row(), aIndex.column() );
   170     QStandardItem* item = mModel->item( aIndex.row(), aIndex.column() );
   171     QVariant var = item->data( Qt::UserRole );
   171     QVariant var = item->data( Qt::UserRole );
   172     aValue = var.toUInt();
   172     aValue = var.toUInt();
   173 }
   173 }
   174 
   174 
   175 
       
   176 // -----------------------------------------------------------------------------
   175 // -----------------------------------------------------------------------------
   177 // LocationPickerSearchView::launchPopUpMenu()
   176 // LocationPickerSearchView::launchPopUpMenu()
   178 // -----------------------------------------------------------------------------
   177 // -----------------------------------------------------------------------------
   179 void LocationPickerSearchView::launchPopUpMenu(HbAbstractViewItem *aItem, const QPointF &aPoint)
   178 void LocationPickerSearchView::launchPopUpMenu(HbAbstractViewItem *aItem, const QPointF &aPoint)
   180 {
   179 {
   181     mLongPressMenu = new HbMenu();
   180     mLongPressMenu = new HbMenu();
   182     mLongPressMenu->setTimeout(HbMenu::NoTimeout);
   181     mLongPressMenu->setTimeout(HbMenu::NoTimeout);
   183     HbAction* selectAction  = mLongPressMenu->addAction(hbTrId("Select"));
   182     mSelectAction  = mLongPressMenu->addAction(hbTrId("Select"));
   184     mIndex = aItem->modelIndex();
   183     mIndex = aItem->modelIndex();
   185     connect(selectAction, SIGNAL(triggered()),this, SLOT(handleLongPress()));
   184     connect(mSelectAction, SIGNAL(triggered()),this, SLOT(handleLongPress()));
   186     mLongPressMenu->setPreferredPos(aPoint);
   185     mLongPressMenu->setPreferredPos(aPoint);
       
   186     connect(mLongPressMenu,SIGNAL(aboutToClose ()),this,SLOT(deleteMenu()));
   187     mLongPressMenu->open();
   187     mLongPressMenu->open();
   188 }
   188 }
   189 
   189 
   190 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   191 // LocationPickerSearchView::handleLongPress()
   191 // LocationPickerSearchView::handleLongPress()
   192 // -----------------------------------------------------------------------------
   192 // -----------------------------------------------------------------------------
   193 void LocationPickerSearchView::handleLongPress()
   193 void LocationPickerSearchView::handleLongPress()
   194 {
   194 {
   195     handleActivated(mIndex);
   195     handleActivated(mIndex);
   196 }
   196 }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // LocationPickerSearchView::deleteMenu()
       
   200 // -----------------------------------------------------------------------------
       
   201 void LocationPickerSearchView::deleteMenu()
       
   202 {
       
   203     mLongPressMenu->deleteLater();
       
   204     mLongPressMenu = NULL;
       
   205     mSelectAction->deleteLater();
       
   206     mSelectAction = NULL;
       
   207 }