~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/lib/accountlistmodel.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 *   Copyright (C) 2009-2014 by Savoir-Faire Linux                          *
 
3
 *   Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>          *
 
4
 *            Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
 
5
 *                                                                          *
 
6
 *   This library is free software; you can redistribute it and/or          *
 
7
 *   modify it under the terms of the GNU Lesser General Public             *
 
8
 *   License as published by the Free Software Foundation; either           *
 
9
 *   version 2.1 of the License, or (at your option) any later version.     *
 
10
 *                                                                          *
 
11
 *   This library is distributed in the hope that it will be useful,        *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
 
14
 *   Lesser General Public License for more details.                        *
 
15
 *                                                                          *
 
16
 *   You should have received a copy of the GNU General Public License      *
 
17
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 
18
 ***************************************************************************/
 
19
 
 
20
#ifndef ACCOUNT_LIST_H
 
21
#define ACCOUNT_LIST_H
 
22
 
 
23
 
 
24
#include <QtCore/QVector>
 
25
#include <QtCore/QStringList>
 
26
#include <QtCore/QAbstractListModel>
 
27
 
 
28
#include "account.h"
 
29
#include "typedefs.h"
 
30
// #include "dbus/metatypes.h"
 
31
 
 
32
class AccountListColorVisitor;
 
33
 
 
34
///AccountList: List of all daemon accounts
 
35
class LIB_EXPORT AccountListModel : public QAbstractListModel {
 
36
   #pragma GCC diagnostic push
 
37
   #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
 
38
   Q_OBJECT
 
39
   #pragma GCC diagnostic pop
 
40
 
 
41
public:
 
42
   friend class Account;
 
43
   //Static getter and destructor
 
44
   static AccountListModel* instance();
 
45
   static void destroy();
 
46
 
 
47
   //Getters
 
48
   const QVector<Account*>&    getAccounts            (                         );
 
49
   QVector<Account*>           getAccountsByState     ( const QString& state    );
 
50
   Q_INVOKABLE Account*        getAccountById         ( const QString& id       ) const;
 
51
   Q_INVOKABLE QList<Account*> getAccountsByHostNames (const QString& hostName  ) const;
 
52
   int                         size                   (                         ) const;
 
53
   Account*                    firstRegisteredAccount (                         ) const;
 
54
   Account*                    getDefaultAccount      (                         ) const;
 
55
   static Account*             currentAccount         (                         );
 
56
   Account*                    getAccountByModelIndex ( const QModelIndex& item ) const;
 
57
   static QString              getSimilarAliasIndex   ( const QString& alias    );
 
58
   AccountListColorVisitor*    colorVisitor           (                         );
 
59
 
 
60
   //Abstract model accessors
 
61
   QVariant      data     ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
 
62
   int           rowCount ( const QModelIndex& parent = QModelIndex()            ) const;
 
63
   Qt::ItemFlags flags    ( const QModelIndex& index                             ) const;
 
64
 
 
65
   //Setters
 
66
   void setPriorAccount          ( const Account*                                           );
 
67
   virtual bool setData          ( const QModelIndex& index, const QVariant &value, int role);
 
68
   void         setColorVisitor  ( AccountListColorVisitor* visitor                         );
 
69
   void         setDefaultAccount(Account* a);
 
70
 
 
71
   //Mutators
 
72
   Q_INVOKABLE Account* addAccount          ( const QString & alias );
 
73
   Q_INVOKABLE void     removeAccount       ( Account* account      );
 
74
   void                 removeAccount       ( QModelIndex index     );
 
75
   void                 save                (                       );
 
76
   Q_INVOKABLE bool     accountUp           ( int index             );
 
77
   Q_INVOKABLE bool     accountDown         ( int index             );
 
78
   Q_INVOKABLE void     cancel              (                       );
 
79
 
 
80
   //Operators
 
81
   Account*       operator[] (int            i)      ;
 
82
   Account*       operator[] (const QString& i)      ;
 
83
   const Account* operator[] (int            i) const;
 
84
 
 
85
private:
 
86
   //Constructors & Destructors
 
87
   explicit AccountListModel();
 
88
   void init();
 
89
   ~AccountListModel();
 
90
   void setupRoleName();
 
91
 
 
92
   //Attributes
 
93
   QVector<Account*>        m_lAccounts       ;
 
94
   static AccountListModel* m_spAccountList   ;
 
95
   static Account*          m_spPriorAccount  ;
 
96
   Account*                 m_pDefaultAccount ;
 
97
   AccountListColorVisitor* m_pColorVisitor   ;
 
98
   QStringList              m_lDeletedAccounts;
 
99
 
 
100
public Q_SLOTS:
 
101
   void update        ();
 
102
   void updateAccounts();
 
103
   void registerAllAccounts();
 
104
 
 
105
private Q_SLOTS:
 
106
   void accountChanged(const QString& account,const QString& state, int code);
 
107
   void accountChanged(Account* a);
 
108
   void slotVoiceMailNotify( const QString& accountID , int count );
 
109
 
 
110
Q_SIGNALS:
 
111
   ///The account list changed
 
112
   void accountListUpdated();
 
113
   ///Emitted when an account state change
 
114
   void accountStateChanged  ( Account* account, QString state);
 
115
   ///Emitted when an account enable attribute change
 
116
   void accountEnabledChanged( Account* source                );
 
117
   ///Emitted when the default account change
 
118
   void defaultAccountChanged( Account* a                     );
 
119
   ///Emitted when the default account change
 
120
   void priorAccountChanged  ( Account* a                     );
 
121
   ///Emitted when one account registration state change
 
122
   void accountRegistrationChanged(Account* a, bool registration);
 
123
   ///Emitted when the network is down
 
124
   void badGateway();
 
125
   ///Emitted when a new voice mail is available
 
126
   void voiceMailNotify(Account* account, int count);
 
127
};
 
128
Q_DECLARE_METATYPE(AccountListModel*)
 
129
 
 
130
class LIB_EXPORT AccountListNoCheckProxyModel : public QAbstractListModel
 
131
{
 
132
public:
 
133
   virtual QVariant data(const QModelIndex& index,int role = Qt::DisplayRole ) const;
 
134
   virtual bool setData( const QModelIndex& index, const QVariant &value, int role);
 
135
   virtual Qt::ItemFlags flags (const QModelIndex& index) const;
 
136
   virtual int rowCount(const QModelIndex& parent = QModelIndex() ) const;
 
137
};
 
138
 
 
139
#endif