summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Klapetek <martin.klapetek@gmail.com>2011-04-12 15:38:04 -0700
committerGustavo Pichorim Boiko <gustavo.boiko@collabora.co.uk>2011-04-13 07:31:34 -0700
commit162324756560f32617ea68782cfdd54d822d0dec (patch)
tree1696201a262bc79c239ba39808a6d3f629e57b36
parente09615162161de13f6897f72516efc3670adc5fc (diff)
This commit adds another new method contactForIndex(QModelIndex), which is very handy for context menus (several operations on contact as well as getting contact info).
-rw-r--r--TelepathyQt4Yell/Models/accounts-model.cpp11
-rw-r--r--TelepathyQt4Yell/Models/accounts-model.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/TelepathyQt4Yell/Models/accounts-model.cpp b/TelepathyQt4Yell/Models/accounts-model.cpp
index 88bf94a..a855bf2 100644
--- a/TelepathyQt4Yell/Models/accounts-model.cpp
+++ b/TelepathyQt4Yell/Models/accounts-model.cpp
@@ -253,6 +253,17 @@ Tp::AccountPtr AccountsModel::accountForContactIndex(const QModelIndex &index) c
}
}
+Tp::ContactPtr AccountsModel::contactForIndex(const QModelIndex& index) const
+{
+ TreeNode *contactNode = mPriv->node(index);
+ ContactModelItem *item = qobject_cast<ContactModelItem *>(contactNode);
+ if (item) {
+ return item->contact();
+ } else {
+ return Tp::ContactPtr();
+ }
+}
+
Qt::ItemFlags AccountsModel::flags(const QModelIndex &index) const
{
if (index.isValid()) {
diff --git a/TelepathyQt4Yell/Models/accounts-model.h b/TelepathyQt4Yell/Models/accounts-model.h
index 906ef5e..39421c4 100644
--- a/TelepathyQt4Yell/Models/accounts-model.h
+++ b/TelepathyQt4Yell/Models/accounts-model.h
@@ -106,6 +106,7 @@ public:
virtual QVariant data(const QModelIndex &index, int role) const;
Tp::AccountPtr accountForIndex(const QModelIndex &index) const;
Tp::AccountPtr accountForContactIndex(const QModelIndex &index) const;
+ Tp::ContactPtr contactForIndex(const QModelIndex &index) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);