aboutsummaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorSergiy Dubovik <sergiy.dubovik@nokia.com>2010-07-13 15:22:01 +0300
committerSergiy Dubovik <sergiy.dubovik@nokia.com>2010-07-14 13:34:52 +0300
commitb77d0bb5de582e56f3fb49369f4e0da84dd4beac (patch)
treea695bb0ab5bfaf86358fd268de0c0e4db5eea64c /demos
parent456696dfeece2924cbb257c8e60181447dd8061e (diff)
Changes: Adding possibility to specify identifier when item is recycled.
RevBy: Tomas, Stanislav Details: Currently MWidgetRecycler uses class name as an identifier to recycle&restore objects. Sometimes it's not very convinient. Same class may implement different layouts and reinitialization those layouts can make performance worse. With this patch developer could assign custom identifier for 2 and more groups of objects with same class name and keep the performance.
Diffstat (limited to 'demos')
-rw-r--r--demos/widgetsgallery/mlistpage.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/demos/widgetsgallery/mlistpage.cpp b/demos/widgetsgallery/mlistpage.cpp
index 0637b25e..9d06b335 100644
--- a/demos/widgetsgallery/mlistpage.cpp
+++ b/demos/widgetsgallery/mlistpage.cpp
@@ -112,10 +112,10 @@ class MListContentItemCreator : public MAbstractCellCreator<PhoneBookCell>
public:
MListContentItemCreator() : amountOfColumns(1), highlightText("") {
}
-
+
MWidget *createCell(const QModelIndex &index, MWidgetRecycler &recycler) const
{
- // FIXME: It's a workaround against a bug, that if the layout is created and
+ // FIXME: It's a workaround against a bug, that if the layout is created and
// set in constructor then the pixmaps are properly loaded.
PhoneBookCell *cell = dynamic_cast<PhoneBookCell *>(recycler.take(PhoneBookCell::staticMetaObject.className()));
if (cell == NULL) {
@@ -124,12 +124,12 @@ public:
updateCell(index, cell);
return cell;
}
-
+
void updateCell(const QModelIndex &index, MWidget *cell) const {
PhoneBookCell *listCell = qobject_cast<PhoneBookCell*>(cell);
if (listCell == NULL) // TODO This is shouldn't happen, list must know what it doing, but with multiple columns it happens sometimes
return;
-
+
QVariant data = index.data(Qt::DisplayRole);
PhoneBookEntry *entry = static_cast<PhoneBookEntry *>(data.value<void *>());
@@ -150,7 +150,7 @@ public:
updateContentItemMode(index, listCell);
}
-
+
void updateContentItemMode(const QModelIndex &index, MListItem *contentItem) const {
int flatRow = index.row();
int row = flatRow / amountOfColumns;
@@ -238,13 +238,13 @@ void MListPage::setPlainListModel()
list->setCellCreator(cellCreator);
model = new PhoneBookModel();
-
+
proxyModel = new MSortFilterProxyModel();
proxyModel->setSortRole(PhoneBookModel::PhoneBookSortRole);
proxyModel->setFilterRole(PhoneBookModel::PhoneBookFilterRole);
proxyModel->setSourceModel(model);
-
-
+
+
list->setItemModel(proxyModel);
imageLoader = new PhoneBookImageLoader;
@@ -393,7 +393,7 @@ void MListPage::changeListMode(int index)
case Grouped:
list->setShowGroups(true);
- model->setGrouped(true);
+ model->setGrouped(true);
break;
}
@@ -458,11 +458,11 @@ void MListPage::changeLiveFilteringMode(int index)
list->filtering()->setEnabled(true);
list->filtering()->setFilterRole(PhoneBookModel::PhoneBookFilterRole);
list->filtering()->editor()->setVisible(false);
- connect(list->filtering(), SIGNAL(listPannedUpFromTop()), this, SLOT(filteringVKB()));
- connect(list->filtering()->editor(), SIGNAL(textChanged()), this, SLOT(liveFilteringTextChanged()));
+ connect(list->filtering(), SIGNAL(listPannedUpFromTop()), this, SLOT(filteringVKB()));
+ connect(list->filtering()->editor(), SIGNAL(textChanged()), this, SLOT(liveFilteringTextChanged()));
} else {
- disconnect(list->filtering(), SIGNAL(listPannedUpFromTop()), this, SLOT(filteringVKB()));
- disconnect(list->filtering()->editor(), SIGNAL(textChanged()), this, SLOT(liveFilteringTextChanged()));
+ disconnect(list->filtering(), SIGNAL(listPannedUpFromTop()), this, SLOT(filteringVKB()));
+ disconnect(list->filtering()->editor(), SIGNAL(textChanged()), this, SLOT(liveFilteringTextChanged()));
list->filtering()->setEnabled(false);
showTextEdit(false);
}