aboutsummaryrefslogtreecommitdiff
path: root/demos/widgetsgallery
diff options
context:
space:
mode:
authorStanislav Ionascu <stanislav.ionascu@nokia.com>2010-09-01 14:21:10 +0300
committerStanislav Ionascu <stanislav.ionascu@nokia.com>2010-09-06 12:36:59 +0300
commit169938af2d2e82b31101800d186a2c48ae8661e2 (patch)
tree6172180fe6c3fba521c866d4d8f7d96ebe73a39c /demos/widgetsgallery
parentbee52e95be0d78fce220a31efcbbdf3894c8b9b2 (diff)
Changes: Emit list item long tapped signal base on item events not handling the events.
RevBy: Sergiy Dubovik Details: Handling of the tap and hold events is moved away from the list, and the list now processes the signals comming from the items.
Diffstat (limited to 'demos/widgetsgallery')
-rw-r--r--demos/widgetsgallery/mlistpage.cpp31
-rw-r--r--demos/widgetsgallery/mlistpage.h5
2 files changed, 28 insertions, 8 deletions
diff --git a/demos/widgetsgallery/mlistpage.cpp b/demos/widgetsgallery/mlistpage.cpp
index 91d66e0b..a4132aa3 100644
--- a/demos/widgetsgallery/mlistpage.cpp
+++ b/demos/widgetsgallery/mlistpage.cpp
@@ -38,6 +38,8 @@
#include <MAction>
#include <MSortFilterProxyModel>
#include <MDialog>
+#include <MSceneManager>
+#include <MObjectMenu>
#include <MComboBox>
#include <MDebug>
@@ -61,6 +63,8 @@ MListPage::MListPage()
proxyModel(NULL),
imageLoader(NULL),
comboListMode(NULL),
+ objectMenu(NULL),
+ objectMenuHolder(NULL),
actionAdvancedConfiguration(NULL),
dialogAdvancedConfiguration(NULL),
list(NULL),
@@ -495,9 +499,19 @@ void MListPage::itemClick(const QModelIndex &index)
mDebug("MListPage::itemClick") << "Row was clicked: " << index.row();
}
-void MListPage::itemLongTapped(const QModelIndex &index)
+void MListPage::itemLongTapped(const QModelIndex &index, const QPointF &position)
{
- mDebug("MListPage::itemLongTapped") << "Row was long tapped: " << index.row();
+ objectMenu->setCursorPosition(position);
+ if (index.parent().isValid()) {
+ mDebug("MListPage::itemLongTapped") << "Row: " << index.row() << " Group: " << index.parent().row();
+ sceneManager()->appearSceneWindow(objectMenu);
+ }
+ else if (model->hasChildren(index) > 0)
+ mDebug("MListPage::itemLongTapped") << "Group: " << index.row();
+ else {
+ mDebug("MListPage::itemLongTapped") << "Row: " << index.row();
+ sceneManager()->appearSceneWindow(objectMenu);
+ }
longTappedIndex = index;
}
@@ -630,17 +644,20 @@ void MListPage::createContent()
panel->setLayout(layout);
list = new MList(panel);
+ objectMenuHolder = new MWidget(panel);
+
+ objectMenu = new MObjectMenu(objectMenuHolder);
//% "Remove"
- MAction *action = new MAction(qtTrId("xx_listpage_list_remove"), list);
+ MAction *action = new MAction(qtTrId("xx_listpage_list_remove"), objectMenuHolder);
action->setLocation(MAction::ObjectMenuLocation);
- list->addAction(action);
+ objectMenuHolder->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(removeListItem()));
//% "Edit"
- action = new MAction(qtTrId("xx_listpage_list_edit"), list);
+ action = new MAction(qtTrId("xx_listpage_list_edit"), objectMenuHolder);
action->setLocation(MAction::ObjectMenuLocation);
- list->addAction(action);
+ objectMenuHolder->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(editListItem()));
setPlainListModel();
@@ -648,7 +665,7 @@ void MListPage::createContent()
layout->addItem(list);
connect(list, SIGNAL(itemClicked(QModelIndex)), this, SLOT(itemClick(QModelIndex)));
- connect(list, SIGNAL(itemLongTapped(QModelIndex)), this, SLOT(itemLongTapped(QModelIndex)));
+ connect(list, SIGNAL(itemLongTapped(QModelIndex,QPointF)), this, SLOT(itemLongTapped(QModelIndex,QPointF)));
retranslateUi();
}
diff --git a/demos/widgetsgallery/mlistpage.h b/demos/widgetsgallery/mlistpage.h
index 3745d42a..c59abfb1 100644
--- a/demos/widgetsgallery/mlistpage.h
+++ b/demos/widgetsgallery/mlistpage.h
@@ -39,6 +39,7 @@ class MList;
class MComboBox;
class MListContentItemCreator;
class MAbstractItemModel;
+class MObjectMenu;
class MListPage: public TemplatePage
{
@@ -82,7 +83,7 @@ public slots:
void scrollToTop();
void itemClick(const QModelIndex &index);
- void itemLongTapped(const QModelIndex &index);
+ void itemLongTapped(const QModelIndex &index, const QPointF &position);
void removeListItem();
void editListItem();
@@ -108,6 +109,8 @@ private:
PhoneBookImageLoader *imageLoader;
MComboBox *comboListMode;
+ MObjectMenu *objectMenu;
+ MWidget *objectMenuHolder;
MAction *actionAdvancedConfiguration;
QPointer<MDialog> dialogAdvancedConfiguration;