Home · All Classes · All Namespaces · Modules · Functions · Files

accounts-model.h

00001 /*
00002  * This file is part of TelepathyQt4Yell Models
00003  *
00004  * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #ifndef _TelepathyQt4Yell_Models_accounts_model_h_HEADER_GUARD_
00022 #define _TelepathyQt4Yell_Models_accounts_model_h_HEADER_GUARD_
00023 
00024 #ifndef IN_TELEPATHY_QT4_YELL_MODELS_HEADER
00025 #error IN_TELEPATHY_QT4_YELL_MODELS_HEADER
00026 #endif
00027 
00028 #include <TelepathyQt4Yell/Models/AccountsModelItem>
00029 
00030 #include <TelepathyQt4/Account>
00031 #include <TelepathyQt4/AccountManager>
00032 #include <TelepathyQt4/TextChannel>
00033 #include <TelepathyQt4/Types>
00034 
00035 #include <QAbstractListModel>
00036 
00037 namespace Tpy
00038 {
00039 
00040 class TELEPATHY_QT4_YELL_MODELS_EXPORT AccountsModel : public QAbstractItemModel
00041 {
00042     Q_OBJECT
00043     Q_DISABLE_COPY(AccountsModel)
00044     Q_PROPERTY(int accountCount READ accountCount NOTIFY accountCountChanged)
00045     Q_ENUMS(Role)
00046 
00047 public:
00048     enum Role {
00049         // general roles
00050         ItemRole = Qt::UserRole,
00051         AvatarRole,
00052         IdRole,
00053 
00054         // account roles
00055         ValidRole,
00056         EnabledRole,
00057         ConnectionManagerNameRole,
00058         ProtocolNameRole,
00059         DisplayNameRole,
00060         IconRole,
00061         NicknameRole,
00062         ConnectsAutomaticallyRole,
00063         ChangingPresenceRole,
00064         AutomaticPresenceRole,
00065         AutomaticPresenceTypeRole,
00066         AutomaticPresenceStatusMessageRole,
00067         CurrentPresenceRole,
00068         CurrentPresenceTypeRole,
00069         CurrentPresenceStatusMessageRole,
00070         RequestedPresenceRole,
00071         RequestedPresenceTypeRole,
00072         RequestedPresenceStatusMessageRole,
00073         ConnectionStatusRole,
00074         ConnectionStatusReasonRole,
00075         ContactListStateRole,
00076 
00077         // contact roles
00078         AliasRole,
00079         PresenceStatusRole,
00080         PresenceTypeRole,
00081         PresenceMessageRole,
00082         SubscriptionStateRole,
00083         PublishStateRole,
00084         BlockedRole,
00085         GroupsRole,
00086         TextChatCapabilityRole,
00087         StreamedMediaCallCapabilityRole,
00088         StreamedMediaAudioCallCapabilityRole,
00089         StreamedMediaVideoCallCapabilityRole,
00090         StreamedMediaVideoCallWithAudioCapabilityRole,
00091         StreamedMediaUpgradeCallCapabilityRole,
00092         MediaCallCapabilityRole,
00093         AudioCallCapabilityRole,
00094         VideoCallCapabilityRole,
00095         VideoCallWithAudioCapabilityRole,
00096         UpgradeCallCapabilityRole,
00097         FileTransferCapabilityRole,
00098 
00099         CustomRole // a placemark for custom roles in inherited models
00100     };
00101 
00102     explicit AccountsModel(const Tp::AccountManagerPtr &am, QObject *parent = 0);
00103     virtual ~AccountsModel();
00104 
00105     virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
00106     virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
00107     virtual QVariant data(const QModelIndex &index, int role) const;
00108     Tp::AccountPtr accountForIndex(const QModelIndex &index) const;
00109     Tp::AccountPtr accountForContactIndex(const QModelIndex &index) const;
00110     Tp::ContactPtr contactForIndex(const QModelIndex &index) const;
00111 
00112     virtual Qt::ItemFlags flags(const QModelIndex &index) const;
00113     virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00114     virtual QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
00115     virtual QModelIndex index(TreeNode *node) const;
00116     virtual QModelIndex parent(const QModelIndex &index) const;
00117 
00118     int accountCount() const;
00119     Q_INVOKABLE QObject *accountItemForId(const QString &id) const;
00120     Q_INVOKABLE QObject *contactItemForId(const QString &accountId, const QString &contactId) const;
00121 
00122 Q_SIGNALS:
00123     void accountCountChanged();
00124     void accountConnectionStatusChanged(const QString &accountId, int status);
00125 
00126 protected Q_SLOTS:
00127     void onNewAccount(const Tp::AccountPtr &account);
00128     void onItemChanged(TreeNode *node);
00129     void onItemsAdded(TreeNode *parent, const QList<TreeNode *> &nodes);
00130     void onItemsRemoved(TreeNode *parent, int first, int last);
00131 
00132 private:
00133     struct Private;
00134     friend struct Private;
00135     Private *mPriv;
00136 };
00137 
00138 }
00139 
00140 #endif // _TelepathyQt4Yell_Models_accounts_model_h_HEADER_GUARD_


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4-Yell 0.1.6