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

« back to all changes in this revision

Viewing changes to kde/src/lib/presencestatusmodel.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) 2013-2014 by Savoir-Faire Linux                          *
 
3
 *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
 
4
 *                                                                          *
 
5
 *   This library is free software; you can redistribute it and/or          *
 
6
 *   modify it under the terms of the GNU Lesser General Public             *
 
7
 *   License as published by the Free Software Foundation; either           *
 
8
 *   version 2.1 of the License, or (at your option) any later version.     *
 
9
 *                                                                          *
 
10
 *   This library is distributed in the hope that it will be useful,        *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
 
13
 *   Lesser General Public License for more details.                        *
 
14
 *                                                                          *
 
15
 *   You should have received a copy of the GNU General Public License      *
 
16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 
17
 ***************************************************************************/
 
18
#ifndef PRESENCESTATUSMODEL_H
 
19
#define PRESENCESTATUSMODEL_H
 
20
#include "typedefs.h"
 
21
 
 
22
//Qt
 
23
#include <QtCore/QString>
 
24
#include <QtCore/QAbstractTableModel>
 
25
 
 
26
class PresenceSerializationVisitor;
 
27
 
 
28
///CredentialModel: A model for account credentials
 
29
class LIB_EXPORT PresenceStatusModel : public QAbstractTableModel {
 
30
   #pragma GCC diagnostic push
 
31
   #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
 
32
   Q_OBJECT
 
33
   #pragma GCC diagnostic pop
 
34
public:
 
35
 
 
36
   //Internal representation
 
37
   struct StatusData {
 
38
      QString  name         ;
 
39
      QString  message      ;
 
40
      QVariant color        ;
 
41
      bool     status       ;
 
42
      bool     defaultStatus;
 
43
   };
 
44
 
 
45
   //Table columns
 
46
   enum class Columns {
 
47
      Name    = 0,
 
48
      Message = 1,
 
49
      Color   = 2,
 
50
      Status  = 3,
 
51
      Default = 4,
 
52
   };
 
53
 
 
54
   //Methods
 
55
   void addStatus(StatusData* status);
 
56
   void setPresenceVisitor(PresenceSerializationVisitor* visitor);
 
57
 
 
58
   //Properties
 
59
   Q_PROPERTY( QString     customMessage     READ customMessage    WRITE  setCustomMessage              NOTIFY customMessageChanged(QString)     )
 
60
   Q_PROPERTY( bool        useCustomStatus   READ useCustomStatus  WRITE  setUseCustomStatus            NOTIFY useCustomStatusChanged(bool)      )
 
61
   Q_PROPERTY( bool        customStatus      READ customStatus     WRITE  setCustomStatus               NOTIFY customStatusChanged(bool)         )
 
62
   Q_PROPERTY( bool        currentStatus     READ currentStatus    NOTIFY currentStatusChanged(bool)                                             )
 
63
   Q_PROPERTY( QString     currentMessage    READ currentMessage   NOTIFY currentMessageChanged(QString)                                         )
 
64
   Q_PROPERTY( QModelIndex defaultStatus     READ defaultStatus    WRITE  setDefaultStatus              NOTIFY defaultStatusChanged(QModelIndex) )
 
65
   Q_PROPERTY( QString     currentName       READ currentName      NOTIFY currentNameChanged(QString)                                            )
 
66
 
 
67
   //Constructor
 
68
   explicit PresenceStatusModel(QObject* parent = nullptr);
 
69
   virtual ~PresenceStatusModel();
 
70
 
 
71
   //Abstract model members
 
72
   virtual QVariant      data       (const QModelIndex& index, int role = Qt::DisplayRole                 ) const;
 
73
   virtual int           rowCount   (const QModelIndex& parent = QModelIndex()                            ) const;
 
74
   virtual int           columnCount(const QModelIndex& parent = QModelIndex()                            ) const;
 
75
   virtual Qt::ItemFlags flags      (const QModelIndex& index                                             ) const;
 
76
   virtual bool          setData    (const QModelIndex& index, const QVariant &value, int role            )      ;
 
77
   virtual QVariant      headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
 
78
 
 
79
   //Singleton
 
80
   static PresenceStatusModel* instance();
 
81
 
 
82
   //Setters
 
83
   void setDefaultStatus( const QModelIndex& idx );
 
84
 
 
85
   //Getters
 
86
   QString     customMessage   () const;
 
87
   bool        useCustomStatus () const;
 
88
   bool        customStatus    () const;
 
89
   bool        currentStatus   () const;
 
90
   QString     currentMessage  () const;
 
91
   QString     currentName     () const;
 
92
   QModelIndex defaultStatus   () const;
 
93
 
 
94
private:
 
95
 
 
96
   //Attributes
 
97
   QVector<StatusData*> m_lStatuses        ;
 
98
   QString              m_CustomMessage    ;
 
99
   bool                 m_UseCustomStatus  ;
 
100
   bool                 m_CustomStatus     ;
 
101
   StatusData*          m_pCurrentStatus   ;
 
102
   StatusData*          m_pDefaultStatus   ;
 
103
   PresenceSerializationVisitor* m_pVisitor;
 
104
 
 
105
   //Singleton
 
106
   static PresenceStatusModel* m_spInstance;
 
107
 
 
108
public Q_SLOTS:
 
109
   void addRow            (                          );
 
110
   void removeRow         ( const QModelIndex& index );
 
111
   void save              (                          );
 
112
   void moveUp            ( const QModelIndex& index );
 
113
   void moveDown          ( const QModelIndex& index );
 
114
   void setUseCustomStatus( bool useCustom           );
 
115
   void setCustomStatus   ( bool status              );
 
116
   void setCurrentIndex   ( const QModelIndex& index );
 
117
   void setCustomMessage  ( const QString& message   );
 
118
 
 
119
Q_SIGNALS:
 
120
   void currentIndexChanged   ( const QModelIndex& current   );
 
121
   void currentNameChanged    ( const QString&     name      );
 
122
   void useCustomStatusChanged( bool               useCustom );
 
123
   void customMessageChanged  ( const QString&     message   );
 
124
   void customStatusChanged   ( bool               status    );
 
125
   void defaultStatusChanged  ( const QModelIndex& def       );
 
126
   void currentMessageChanged ( const QString&     message   );
 
127
   void currentStatusChanged  ( bool               status    );
 
128
 
 
129
};
 
130
 
 
131
Q_DECLARE_METATYPE( PresenceStatusModel* )
 
132
 
 
133
#endif