--- a/locationpickerservice/src/locationpickerpotraitview.cpp Fri Jun 11 13:33:47 2010 +0300
+++ b/locationpickerservice/src/locationpickerpotraitview.cpp Wed Jun 23 18:07:15 2010 +0300
@@ -22,8 +22,9 @@
#include <HbListView>
#include <HbListViewItem>
#include <HbAction>
-#include <QTimer>
+#include <HbMenu>
#include <HbToolBar>
+#include <QGraphicsLinearLayout>
#include "locationpickerproxymodel.h"
#include "locationpickerdatamanager.h"
@@ -47,7 +48,10 @@
mDescendingAction(NULL),
mListView(NULL),
mCollectionContent(NULL),
- mViewType(ELocationPickerContent)
+ mViewType(ELocationPickerContent),
+ mLinerLayout(NULL),
+ mColllabel(NULL),
+ mLongPressMenu(NULL)
{
// create back action
mPotraitBackAction = new HbAction(Hb::BackNaviAction);
@@ -73,6 +77,7 @@
delete mAscendingAction;
delete mDescendingAction;
delete mListView;
+ delete mLongPressMenu;
}
// ----------------------------------------------------------------------------
@@ -91,6 +96,13 @@
//complete the service
emit completeService();
}
+ if (mLinerLayout && mColllabel)
+ {
+ mColllabel->setPlainText("");
+ mLinerLayout->removeItem(mColllabel);
+ mLinerLayout->updateGeometry();
+ update();
+ }
}
@@ -140,6 +152,8 @@
{
qFatal("Error Reading Docml");
}
+
+ mColllabel = new HbLabel();
//connect to slots
connect(mAscendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
@@ -152,8 +166,13 @@
SLOT(searchTabTriggered()));
// connect the signal of the list activated to a slot.
connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(handleActivated(const QModelIndex &)));
+ connect(mListView,SIGNAL(longPressed(HbAbstractViewItem*, const QPointF &)),this,
+ SLOT(launchPopUpMenu(HbAbstractViewItem*, const QPointF &)));
}
+// ----------------------------------------------------
+// LocationPickerPotraitView::manageListView()
+// ----------------------------------------------------
void LocationPickerPotraitView::manageListView()
{
//set the appropriate model
@@ -174,6 +193,11 @@
mListView->setModel(mLocationPickerCollectionListContent->getStandardModel(),mListItem);
mCollectionAction->setChecked(true);
mAllAction->setChecked(false);
+ if(mAscendingAction->isEnabled())
+ {
+ mAscendingAction->setDisabled(true);
+ mDescendingAction->setDisabled(true);
+ }
mViewType = ELocationPickerCollectionListContent;
}
break;
@@ -190,7 +214,9 @@
}
}
-
+// -----------------------------------------------------------------------------
+// LocationPickerPotraitView::disableTabs()
+// -----------------------------------------------------------------------------
void LocationPickerPotraitView::disableTabs( QStandardItemModel *aModel )
{
//if no location entries present
@@ -203,19 +229,10 @@
}
// -----------------------------------------------------------------------------
-// LocationPickerView::handleActivated()
+// LocationPickerPotraitView::handleActivated()
// -----------------------------------------------------------------------------
void LocationPickerPotraitView::handleActivated(const QModelIndex &aIndex)
{
- mIndex = aIndex;
- QTimer::singleShot(0, this, SLOT(changeModel()));
-}
-
-// -----------------------------------------------------------------------------
-// LocationPickerPotraitView::changeModel()
-// -----------------------------------------------------------------------------
-void LocationPickerPotraitView::changeModel()
-{
//handle the activated signal according to model set
switch(mViewType)
{
@@ -226,7 +243,7 @@
break;
}
QModelIndex index = mProxyModel->mapToSource(
- mIndex);
+ aIndex);
quint32 lm = 0;
QStandardItem* item = mModel->item( index.row(), index.column() );
QVariant var = item->data( Qt::UserRole );
@@ -238,7 +255,7 @@
case ELocationPickerCollectionListContent:
{
mLocationPickerCollectionListContent->getData(
- mIndex, mCategoryId );
+ aIndex, mCategoryId );
mViewType = ELocationPickerCollectionContent;
//send categoryID to set the collection content
emit sendCategoryID(mCategoryId);
@@ -251,7 +268,7 @@
break;
}
QModelIndex index = mCollectionContent->getProxyModel()->mapToSource(
- mIndex);
+ aIndex);
quint32 lm = 0;
mCollectionContent->getData(index, lm);
//item selected, complete request
@@ -300,6 +317,13 @@
// -----------------------------------------------------------------------------
void LocationPickerPotraitView::allTabTriggered()
{
+ if (mLinerLayout && mColllabel)
+ {
+ mColllabel->setPlainText("");
+ mLinerLayout->removeItem(mColllabel);
+ mLinerLayout->updateGeometry();
+ update();
+ }
//execute only if tab is not pressed
if (mAllAction->isChecked())
{
@@ -337,6 +361,13 @@
// -----------------------------------------------------------------------------
void LocationPickerPotraitView::colectionTabTriggered()
{
+ if (mLinerLayout && (mViewType != ELocationPickerCollectionContent) && mColllabel )
+ {
+ mColllabel->setPlainText("");
+ mLinerLayout->removeItem(mColllabel);
+ mLinerLayout->updateGeometry();
+ update();
+ }
//execute only if tab is not pressed
if (mCollectionAction->isChecked())
{
@@ -367,7 +398,19 @@
// -----------------------------------------------------------------------------
void LocationPickerPotraitView::setCollectionData( quint32 acategoryId )
{
+ QString categoryname;
+ switch(acategoryId)
+ {
+
+ case 1: categoryname = "Landmarks";
+ break;
+ case 8: categoryname = "Contacts";
+ break;
+ case 9: categoryname = "Calender";
+ break;
+
+ }
if(!mCollectionContent)
{
mCollectionContent
@@ -388,6 +431,15 @@
mViewType = ELocationPickerCollectionContent;
mCollectionAction->setChecked(true);
+ mLinerLayout = static_cast<QGraphicsLinearLayout*>(widget()->layout());
+
+ if(mColllabel)
+ {
+ mLinerLayout->insertItem(0,mColllabel);
+ mColllabel->setPlainText(categoryname);
+ mLinerLayout->updateGeometry();
+ update();
+ }
}
// -----------------------------------------------------------------------------
@@ -427,3 +479,24 @@
}
}
+// -----------------------------------------------------------------------------
+// LocationPickerPotraitView::launchPopUpMenu()
+// -----------------------------------------------------------------------------
+void LocationPickerPotraitView::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();
+}
+
+// -----------------------------------------------------------------------------
+// LocationPickerPotraitView::handleLongPress()
+// -----------------------------------------------------------------------------
+void LocationPickerPotraitView::handleLongPress()
+{
+ handleActivated(mIndex);
+}