--- a/locationpickerservice/src/locationpickersearchview.cpp Fri Jun 11 13:33:47 2010 +0300
+++ b/locationpickerservice/src/locationpickersearchview.cpp Wed Jun 23 18:07:15 2010 +0300
@@ -22,6 +22,8 @@
#include <HbTextItem>
#include <HbDocumentLoader>
#include <QGraphicsLinearLayout>
+#include <HbMenu>
+#include <HbAction>
#include "locationpickerproxymodel.h"
#include "locationpickersearchview.h"
@@ -39,7 +41,8 @@
mSearchPanel(NULL),
mEmptyLabel(NULL),
mVerticalLayout(NULL),
- mDocumentLoader(aLoader)
+ mDocumentLoader(aLoader),
+ mLongPressMenu(NULL)
{
}
@@ -50,6 +53,7 @@
{
delete mProxyModel;
delete mEmptyLabel;
+ delete mLongPressMenu;
}
// ----------------------------------------------------
@@ -61,20 +65,18 @@
//get listview from docml
mListView = qobject_cast<HbListView*>(
mDocumentLoader.findObject(QString("SearchListView")));
- if(mListView == NULL)
+ if(!mListView)
{
qFatal("Error Reading Docml");
}
//get search panel from docml
mSearchPanel = qobject_cast<HbSearchPanel*>(
mDocumentLoader.findObject(QString("searchPanel")));
- if(mListView == NULL)
- {
- qFatal("Error Reading Docml");
- }
//conect to respective slots
connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(handleActivated
(const QModelIndex &)));
+ connect(mListView,SIGNAL(longPressed(HbAbstractViewItem*, const QPointF &)),this,
+ SLOT(launchPopUpMenu(HbAbstractViewItem*, const QPointF &)));
connect(mSearchPanel, SIGNAL(exitClicked()),this, SLOT(handleExit()));
connect(mSearchPanel,SIGNAL(criteriaChanged(QString)),this,SLOT(doSearch(QString)));
@@ -120,12 +122,8 @@
{
QGraphicsWidget *widget = NULL;
widget = mDocumentLoader.findWidget(QString("container"));
- if(widget == NULL)
- {
- qFatal("Error Reading Docml");
- }
mVerticalLayout = static_cast<QGraphicsLinearLayout*>(widget->layout());
- if(mVerticalLayout == NULL)
+ if(!widget || !mVerticalLayout)
{
qFatal("Error Reading Docml");
}
@@ -173,3 +171,26 @@
QVariant var = item->data( Qt::UserRole );
aValue = var.toUInt();
}
+
+
+// -----------------------------------------------------------------------------
+// LocationPickerSearchView::launchPopUpMenu()
+// -----------------------------------------------------------------------------
+void LocationPickerSearchView::launchPopUpMenu(HbAbstractViewItem *aItem, const QPointF &aPoint)
+{
+ mLongPressMenu = new HbMenu();
+ mLongPressMenu->setTimeout(HbMenu::NoTimeout);
+ HbAction* selectAction = mLongPressMenu->addAction(hbTrId("Select"));
+ mIndex = aItem->modelIndex();
+ connect(selectAction, SIGNAL(triggered()),this, SLOT(handleLongPress()));
+ mLongPressMenu->setPreferredPos(aPoint);
+ mLongPressMenu->open();
+}
+
+// -----------------------------------------------------------------------------
+// LocationPickerSearchView::handleLongPress()
+// -----------------------------------------------------------------------------
+void LocationPickerSearchView::handleLongPress()
+{
+ handleActivated(mIndex);
+}