2 * Accounts and contacts model
3 * This file is based on TelepathyQt4Yell Models
5 * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
6 * Copyright (C) 2011 Martin Klapetek <martin dot klapetek at gmail dot com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef TELEPATHY_ACCOUNTS_MODEL_H
24 #define TELEPATHY_ACCOUNTS_MODEL_H
26 #include <QAbstractListModel>
28 #include <TelepathyQt4/Account>
29 #include <TelepathyQt4/AccountManager>
30 #include <TelepathyQt4/TextChannel>
31 #include <TelepathyQt4/Types>
33 #include "accounts-model-item.h"
34 #include "makneto-backend.h"
37 namespace MaknetoBackend
{
39 class MAKNETO_EXPORT AccountsModel
: public QAbstractItemModel
{
42 Q_DISABLE_COPY(AccountsModel
)
43 Q_PROPERTY(int accountCount READ accountCount NOTIFY accountCountChanged
)
49 ItemRole
= Qt::UserRole
,
56 ConnectionManagerNameRole
,
61 ConnectsAutomaticallyRole
,
63 AutomaticPresenceRole
,
64 AutomaticPresenceTypeRole
,
65 AutomaticPresenceStatusMessageRole
,
67 CurrentPresenceTypeRole
,
68 CurrentPresenceStatusMessageRole
,
69 RequestedPresenceRole
,
70 RequestedPresenceTypeRole
,
71 RequestedPresenceStatusMessageRole
,
73 ConnectionStatusReasonRole
,
81 SubscriptionStateRole
,
85 TextChatCapabilityRole
,
86 MediaCallCapabilityRole
,
87 AudioCallCapabilityRole
,
88 VideoCallCapabilityRole
,
89 UpgradeCallCapabilityRole
,
90 FileTransferCapabilityRole
,
92 CustomRole
// a placemark for custom roles in inherited models
95 explicit AccountsModel(const Tp::AccountManagerPtr
&am
, QObject
*parent
= 0);
96 virtual ~AccountsModel();
98 virtual int rowCount(const QModelIndex
&parent
= QModelIndex()) const;
99 virtual int columnCount(const QModelIndex
&parent
= QModelIndex()) const;
100 virtual QVariant
data(const QModelIndex
&index
, int role
) const;
101 Q_INVOKABLE QVariant
data(int row
, int role
); // ivokable, for QML
102 Tp::AccountPtr
accountForIndex(const QModelIndex
&index
) const;
103 Tp::ContactPtr
contactForIndex(const QModelIndex
&index
) const;
105 Tp::AccountPtr
accountForContactIndex(const QModelIndex
&index
) const;
107 virtual Qt::ItemFlags
flags(const QModelIndex
&index
) const;
108 virtual bool setData(const QModelIndex
&index
, const QVariant
&value
, int role
= Qt::EditRole
);
109 virtual QModelIndex
index(int row
, int column
= 0, const QModelIndex
&parent
= QModelIndex()) const;
110 virtual QModelIndex
index(TreeNode
*node
) const;
111 virtual QModelIndex
parent(const QModelIndex
&index
) const;
113 int accountCount() const;
114 Q_INVOKABLE QObject
*accountItemForId(const QString
&id
) const;
115 Q_INVOKABLE QObject
*contactItemForId(const QString
&accountId
, const QString
&contactId
) const;
116 Q_INVOKABLE QModelIndex
contactIndexForId(const QString
&accountId
, const QString
&contactId
) const;
119 void accountCountChanged();
120 void accountConnectionStatusChanged(const Tp::AccountPtr
&account
, Tp::ConnectionStatus status
);
124 void onNewAccount(const Tp::AccountPtr
&account
);
125 void onItemChanged(TreeNode
*node
);
126 void onItemsAdded(TreeNode
*parent
, const QList
<TreeNode
*> &nodes
);
127 void onItemsRemoved(TreeNode
*parent
, int first
, int last
);
131 friend struct Private
;
137 #endif // TELEPATHY_ACCOUNTS_MODEL_H