[Merge] lp:~ken-vandine/history-service/model_tweaks into lp:history-service
Renato Araujo Oliveira Filho
renato.filho at canonical.com
Wed Jun 18 19:43:21 UTC 2014
Diff comments:
> === modified file 'Ubuntu/History/historyeventmodel.cpp'
> --- Ubuntu/History/historyeventmodel.cpp 2014-05-05 16:54:15 +0000
> +++ Ubuntu/History/historyeventmodel.cpp 2014-06-18 13:21:57 +0000
> @@ -199,6 +199,7 @@
> beginInsertRows(QModelIndex(), mEvents.count(), mEvents.count() + events.count() - 1);
> mEvents << events;
> endInsertRows();
> + Q_EMIT countChanged(this->rowCount());
> }
> }
>
> @@ -408,6 +409,7 @@
> beginInsertRows(QModelIndex(), mEvents.count(), mEvents.count() + filteredEvents.count() - 1);
> mEvents << filteredEvents;
> endInsertRows();
> + Q_EMIT countChanged(this->rowCount());
> }
>
> void HistoryEventModel::onEventsModified(const History::Events &events)
> @@ -444,6 +446,7 @@
> endRemoveRows();
> }
> }
> + Q_EMIT countChanged(this->rowCount());
>
> // FIXME: there is a corner case here: if an event was not loaded yet, but was already
> // removed by another client, it will still show up when a new page is requested. Maybe it
> @@ -471,3 +474,19 @@
> fetchMore(QModelIndex());
> }
> }
> +
> +QVariant HistoryEventModel::at(int row) const
> +{
> + if (row >= this->rowCount() || row < 0)
> + return QVariant();
> +
> + QMap<QString, QVariant> eventData;
You can use QVariantMap instead of QMap<QString, QVariant>
> + QHashIterator<int, QByteArray> hashItr(this->roleNames());
> +
> + while(hashItr.hasNext())
> + {
> + hashItr.next();
> + eventData.insert(hashItr.value(), QVariant(this->data(index(row), hashItr.key())));
> + }
> + return QVariant(eventData);
> +}
>
> === modified file 'Ubuntu/History/historyeventmodel.h'
> --- Ubuntu/History/historyeventmodel.h 2014-05-05 16:54:15 +0000
> +++ Ubuntu/History/historyeventmodel.h 2014-06-18 13:21:57 +0000
> @@ -29,6 +29,7 @@
> class HistoryEventModel : public QAbstractListModel
> {
> Q_OBJECT
> + Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
> Q_PROPERTY(HistoryQmlFilter *filter READ filter WRITE setFilter NOTIFY filterChanged)
> Q_PROPERTY(HistoryQmlSort *sort READ sort WRITE setSort NOTIFY sortChanged)
> Q_PROPERTY(HistoryThreadModel::EventType type READ type WRITE setType NOTIFY typeChanged)
> @@ -56,7 +57,7 @@
>
> explicit HistoryEventModel(QObject *parent = 0);
>
> - int rowCount(const QModelIndex &parent) const;
> + int rowCount(const QModelIndex &parent = QModelIndex()) const;
> QVariant data(const QModelIndex &index, int role) const;
>
> bool canFetchMore(const QModelIndex &parent) const;
> @@ -83,8 +84,10 @@
> Q_INVOKABLE bool markEventAsRead(const QString &accountId, const QString &threadId, const QString &eventId, int eventType);
>
> Q_INVOKABLE bool removeEventAttachment(const QString &accountId, const QString &threadId, const QString &eventId, int eventType, const QString &attachmentId);
> + Q_INVOKABLE QVariant at(int row) const;
>
> Q_SIGNALS:
> + void countChanged(int);
> void filterChanged();
> void sortChanged();
> void typeChanged();
>
--
https://code.launchpad.net/~ken-vandine/history-service/model_tweaks/+merge/223554
Your team Ubuntu Phablet Team is requested to review the proposed merge of lp:~ken-vandine/history-service/model_tweaks into lp:history-service.
More information about the Ubuntu-reviews
mailing list