summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Pichorim Boiko <gustavo.boiko@collabora.co.uk>2011-05-04 06:35:14 -0700
committerGustavo Pichorim Boiko <gustavo.boiko@collabora.co.uk>2011-05-04 06:35:30 -0700
commiteed7c4aa0157a3f49cfc1d032175c9c91c2cc7bc (patch)
treec772dba21f90f2eb0c5ae3927dc086ec22adbbc0
parent235467d79626164a102492e130f08f3416d2ca0a (diff)
parentbafe57ebdbef2a66dce77d9e86d7da82c314caec (diff)
Merge remote branch 'mbatle/remove'
Reviewed by: Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk> Reviewed by: Gustavo Pichorim Boiko <gustavo.boiko@collabora.co.uk>
-rw-r--r--NEWS1
-rw-r--r--TelepathyQt4Yell/Models/abstract-conversation-model.cpp15
-rw-r--r--TelepathyQt4Yell/Models/abstract-conversation-model.h2
3 files changed, 17 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 37c284e..b91b293 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ telepathy-qt4-yell 0.1.4 (UNRELEASED)
The "..." release.
Enhancements:
+ * Implement removeRows method in AbstractConversationModel
* ...
Fixes:
diff --git a/TelepathyQt4Yell/Models/abstract-conversation-model.cpp b/TelepathyQt4Yell/Models/abstract-conversation-model.cpp
index 468b91c..35ec4d5 100644
--- a/TelepathyQt4Yell/Models/abstract-conversation-model.cpp
+++ b/TelepathyQt4Yell/Models/abstract-conversation-model.cpp
@@ -245,10 +245,23 @@ void AbstractConversationModel::insertItems(QList<const EventItem *> items, int
beginInsertRows(QModelIndex(), index, index + items.count() - 1);
const Tpy::EventItem *item;
int i = 0;
- foreach(item, items) {
+ foreach (item, items) {
mPriv->mItems.insert(index + i++, item);
}
endInsertRows();
}
+bool AbstractConversationModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ if (row >= 0 && count > 0 && (row + count) <= mPriv->mItems.count()) {
+ beginRemoveRows(parent, row, row + count - 1);
+ while (count-- > 0) {
+ mPriv->mItems.removeAt(row);
+ }
+ endRemoveRows();
+ return true;
+ }
+ return false;
+}
+
}
diff --git a/TelepathyQt4Yell/Models/abstract-conversation-model.h b/TelepathyQt4Yell/Models/abstract-conversation-model.h
index fb18811..7413606 100644
--- a/TelepathyQt4Yell/Models/abstract-conversation-model.h
+++ b/TelepathyQt4Yell/Models/abstract-conversation-model.h
@@ -70,6 +70,8 @@ public:
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role) const;
+ virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+
void addItem(const EventItem *item);
void insertItems(QList<const EventItem *> items, int index = 0);
bool deleteItem(const EventItem *item);