From kde-commits Tue Nov 30 23:23:21 2010 From: Marco Martin Date: Tue, 30 Nov 2010 23:23:21 +0000 To: kde-commits Subject: playground/base/plasma/shells/mobile/containments/mobilelauncher Message-Id: <20101130232321.8872DAC8A3 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129115945205510 SVN commit 1202460 by mart: paged navigation lmost work M +1 -0 models/krunnermodel.cpp M +4 -0 models/krunnermodel.h M +3 -3 models/pagedproxymodel.cpp M +22 -22 qml/view.qml --- trunk/playground/base/plasma/shells/mobile/containments/mobilelauncher/models/krunnermodel.cpp #1202459:1202460 @@ -181,6 +181,7 @@ } sort(0, Qt::DescendingOrder); + emit rowCountChanged(); } Qt::ItemFlags KRunnerModel::flags(const QModelIndex &index) const --- trunk/playground/base/plasma/shells/mobile/containments/mobilelauncher/models/krunnermodel.h #1202459:1202460 @@ -42,6 +42,7 @@ { Q_OBJECT Q_PROPERTY(QString defaultQuery READ defaultQuery WRITE setDefaultQuery) + Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged) public: KRunnerModel(QObject *parent); @@ -54,6 +55,7 @@ virtual QMimeData *mimeData(const QModelIndexList &indexes) const; static Plasma::RunnerManager *runnerManager(); + int rowCount() const {return QStandardItemModel::rowCount();} private: void timerEvent(QTimerEvent * event); @@ -66,11 +68,13 @@ Q_SIGNALS: void resultsAvailable(); + void rowCountChanged(); private: class Private; Private * const d; QString m_defaultQuery; + int m_totalItems; }; #endif // KRUNNERMODEL_H --- trunk/playground/base/plasma/shells/mobile/containments/mobilelauncher/models/pagedproxymodel.cpp #1202459:1202460 @@ -23,7 +23,7 @@ PagedProxyModel::PagedProxyModel(QObject *parent) : QProxyModel(parent), - m_pageSize(10), + m_pageSize(16), m_currentPage(0) { } @@ -73,11 +73,11 @@ void PagedProxyModel::setSourceModel(QObject *source) { - kWarning()<<"AAAA"<(source); if (!model) { return; } + setRoleNames(model->roleNames()); setModel(model); } @@ -89,7 +89,7 @@ int PagedProxyModel::rowCount(const QModelIndex &parent) const { - return QProxyModel::rowCount(parent)/m_pageSize; + return qMin(m_pageSize, (QProxyModel::rowCount(parent)-m_currentPage*m_pageSize)); } QVariant PagedProxyModel::data(const QModelIndex &index, int role) const --- trunk/playground/base/plasma/shells/mobile/containments/mobilelauncher/qml/view.qml #1202459:1202460 @@ -1,6 +1,7 @@ import Qt 4.7 import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets import org.kde.plasma.core 0.1 as PlasmaCore +import MobileLauncher 1.0 Rectangle { id: main @@ -70,41 +71,37 @@ } } } - GridView { + ListView { id: appsView objectName: "appsView" width: mainFlickable.width height: mainFlickable.height - model: myModel - flow: GridView.TopToBottom - snapMode: GridView.SnapOneRow - cellWidth: width/6 - cellHeight: 64+32 + model: Math.ceil(myModel.rowCount/18.0) + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + clip: true signal clicked - onWidthChanged : { - if (width > 600) { - cellWidth = width/6 - } else { - cellWidth = width/4 - } - } - /*onHeightChanged : { - if (height > 600) { - cellHeight = height/6 - } else { - cellHeight = height/3 + delegate: Item { + width: appsView.width + height: appsView.height + Grid { + anchors.horizontalCenter: parent.horizontalCenter + rows: 3 + Repeater { + model: PagedProxyModel { + sourceModel: myModel + currentPage: index + pageSize: 18 } - }*/ - delegate: Component { Item { id: wrapper - width: wrapper.GridView.view.cellWidth - height: wrapper.GridView.view.cellHeight + width: 100 + height: 100 property string urlText: url PlasmaWidgets.IconWidget { @@ -138,3 +135,6 @@ } } } + } + } +}