summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateu Batle <mateu.batle@collabora.co.uk>2011-06-30 00:41:04 -0500
committerMateu Batle <mateu.batle@collabora.co.uk>2011-06-30 00:41:04 -0500
commit997d188dd136880821f08500178b4b907e758698 (patch)
treebf67677f6a3d283c5035aee245d9586a8243906c
parent4079eaa9fff727ed5ff8332bf4837124a7f09024 (diff)
Add processing for onHierarchicalDataCahnged signal coming from Tpy::AccountsModel for expensive operations
-rw-r--r--TelepathyQt4Yell/Models/flat-model-proxy.cpp22
-rw-r--r--TelepathyQt4Yell/Models/flat-model-proxy.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/TelepathyQt4Yell/Models/flat-model-proxy.cpp b/TelepathyQt4Yell/Models/flat-model-proxy.cpp
index 86d21e5..dae0341 100644
--- a/TelepathyQt4Yell/Models/flat-model-proxy.cpp
+++ b/TelepathyQt4Yell/Models/flat-model-proxy.cpp
@@ -21,6 +21,7 @@
#include <TelepathyQt4Yell/Models/FlatModelProxy>
#include "TelepathyQt4Yell/Models/_gen/flat-model-proxy.moc.hpp"
+#include <TelepathyQt4Yell/Models/AccountsModel>
namespace Tpy
{
@@ -66,6 +67,13 @@ FlatModelProxy::FlatModelProxy(QAbstractItemModel *source)
connect(source,
SIGNAL(dataChanged(QModelIndex,QModelIndex)),
SLOT(onDataChanged(QModelIndex,QModelIndex)));
+
+ Tpy::AccountsModel *accountsModel = qobject_cast<Tpy::AccountsModel *> (source);
+ if (accountsModel) {
+ connect(accountsModel,
+ SIGNAL(hierarchicalDataChanged(QModelIndex,QModelIndex)),
+ SLOT(onHierarchicalDataChanged(QModelIndex,QModelIndex)));
+ }
}
FlatModelProxy::~FlatModelProxy()
@@ -175,4 +183,18 @@ void FlatModelProxy::onDataChanged(const QModelIndex &first, const QModelIndex &
}
}
+void FlatModelProxy::onHierarchicalDataChanged(const QModelIndex &first, const QModelIndex &last)
+{
+ if (!first.parent().isValid() && !last.parent().isValid()) {
+ int firstOffset = mPriv->offsetOf(this, first.row());
+ int lastOffset = mPriv->offsetOf(this, last.row() + 1) - 1;
+ QModelIndex firstIndex = createIndex(firstOffset, 0, first.row());
+ QModelIndex lastIndex = createIndex(lastOffset, 0, last.row());
+ emit dataChanged(firstIndex, lastIndex);
+ } else {
+ // do not do normal dataChanged, since dataChanged it was already triggered separately
+ //onDataChanged(first, last);
+ }
+}
+
}
diff --git a/TelepathyQt4Yell/Models/flat-model-proxy.h b/TelepathyQt4Yell/Models/flat-model-proxy.h
index 116bea0..e926d41 100644
--- a/TelepathyQt4Yell/Models/flat-model-proxy.h
+++ b/TelepathyQt4Yell/Models/flat-model-proxy.h
@@ -60,6 +60,7 @@ private Q_SLOTS:
void onRowsAboutToBeRemoved(const QModelIndex &index, int first, int last);
void onRowsRemoved(const QModelIndex &index, int first, int last);
void onDataChanged(const QModelIndex &first, const QModelIndex &last);
+ void onHierarchicalDataChanged(const QModelIndex &fisrt, const QModelIndex &last);
private:
struct Private;