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 
00076         // contact roles
00077         AliasRole,
00078         PresenceStatusRole,
00079         PresenceTypeRole,
00080         PresenceMessageRole,
00081         SubscriptionStateRole,
00082         PublishStateRole,
00083         BlockedRole,
00084         GroupsRole,
00085         TextChatCapabilityRole,
00086         StreamedMediaCallCapabilityRole,
00087         StreamedMediaAudioCallCapabilityRole,
00088         StreamedMediaVideoCallCapabilityRole,
00089         StreamedMediaVideoCallWithAudioCapabilityRole,
00090         StreamedMediaUpgradeCallCapabilityRole,
00091         MediaCallCapabilityRole,
00092         AudioCallCapabilityRole,
00093         VideoCallCapabilityRole,
00094         VideoCallWithAudioCapabilityRole,
00095         UpgradeCallCapabilityRole,
00096         FileTransferCapabilityRole,
00097 
00098         CustomRole // a placemark for custom roles in inherited models
00099     };
00100 
00101     explicit AccountsModel(const Tp::AccountManagerPtr &am, QObject *parent = 0);
00102     virtual ~AccountsModel();
00103 
00104     virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
00105     virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
00106     virtual QVariant data(const QModelIndex &index, int role) const;
00107     Tp::AccountPtr accountForIndex(const QModelIndex &index) const;
00108     Tp::AccountPtr accountForContactIndex(const QModelIndex &index) const;
00109     Tp::ContactPtr contactForIndex(const QModelIndex &index) const;
00110 
00111     virtual Qt::ItemFlags flags(const QModelIndex &index) const;
00112     virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00113     virtual QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
00114     virtual QModelIndex index(TreeNode *node) const;
00115     virtual QModelIndex parent(const QModelIndex &index) const;
00116 
00117     int accountCount() const;
00118     Q_INVOKABLE QObject *accountItemForId(const QString &id) const;
00119     Q_INVOKABLE QObject *contactItemForId(const QString &accountId, const QString &contactId) const;
00120 
00121 Q_SIGNALS:
00122     void accountCountChanged();
00123     void accountConnectionStatusChanged(const QString &accountId, int status);
00124 
00125 protected Q_SLOTS:
00126     void onNewAccount(const Tp::AccountPtr &account);
00127     void onItemChanged(TreeNode *node);
00128     void onItemsAdded(TreeNode *parent, const QList<TreeNode *> &nodes);
00129     void onItemsRemoved(TreeNode *parent, int first, int last);
00130 
00131 private:
00132     struct Private;
00133     friend struct Private;
00134     Private *mPriv;
00135 };
00136 
00137 }
00138 
00139 #endif // _TelepathyQt4Yell_Models_accounts_model_h_HEADER_GUARD_


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