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

« back to all changes in this revision

Viewing changes to kde/src/lib/contactproxymodel.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 CONTACT_PROXY_MODEL_H
 
19
#define CONTACT_PROXY_MODEL_H
 
20
 
 
21
#include <QtCore/QHash>
 
22
#include <QtCore/QStringList>
 
23
#include <QtCore/QAbstractItemModel>
 
24
 
 
25
//SFLPhone
 
26
#include "../lib/typedefs.h"
 
27
#include "../lib/contact.h"
 
28
class AbstractContactBackend;
 
29
class ContactTreeNode;
 
30
class TopLevelItem;
 
31
class ContactTreeBinder;
 
32
 
 
33
class LIB_EXPORT ContactProxyModel :  public QAbstractItemModel
 
34
{
 
35
   #pragma GCC diagnostic push
 
36
   #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
 
37
   Q_OBJECT
 
38
   #pragma GCC diagnostic pop
 
39
public:
 
40
   friend class AbstractContactBackend;
 
41
   friend class ContactTreeNode;
 
42
   friend class ContactTreeBinder;
 
43
   explicit ContactProxyModel(AbstractContactBackend* parent,int role = Qt::DisplayRole, bool showAll = false);
 
44
   virtual ~ContactProxyModel();
 
45
 
 
46
   //Setters
 
47
   void setRole(int role);
 
48
   void setShowAll(bool showAll);
 
49
 
 
50
   //Model implementation
 
51
   virtual bool          setData     ( const QModelIndex& index, const QVariant &value, int role   );
 
52
   virtual QVariant      data        ( const QModelIndex& index, int role = Qt::DisplayRole        ) const;
 
53
   virtual int           rowCount    ( const QModelIndex& parent = QModelIndex()                   ) const;
 
54
   virtual Qt::ItemFlags flags       ( const QModelIndex& index                                    ) const;
 
55
   virtual int           columnCount ( const QModelIndex& parent = QModelIndex()                   ) const;
 
56
   virtual QModelIndex   parent      ( const QModelIndex& index                                    ) const;
 
57
   virtual QModelIndex   index       ( int row, int column, const QModelIndex& parent=QModelIndex()) const;
 
58
   virtual QVariant      headerData  ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
 
59
   virtual QStringList   mimeTypes   (                                                             ) const;
 
60
   virtual QMimeData*    mimeData    ( const QModelIndexList &indexes                              ) const;
 
61
   virtual bool dropMimeData         ( const QMimeData*, Qt::DropAction, int, int, const QModelIndex& );
 
62
 
 
63
   //Getter
 
64
   static int acceptedPayloadTypes();
 
65
 
 
66
private:
 
67
 
 
68
   //Helpers
 
69
   QString category(Contact* ct) const;
 
70
 
 
71
   //Attributes
 
72
   QHash<Contact*, time_t>      m_hContactByDate   ;
 
73
   AbstractContactBackend*      m_pModel           ;
 
74
   QVector<TopLevelItem*>       m_lCategoryCounter ;
 
75
   QHash<QString,TopLevelItem*> m_hCategories      ;
 
76
   int                          m_Role             ;
 
77
   bool                         m_ShowAll          ;
 
78
   QStringList                  m_lMimes           ;
 
79
 
 
80
   //Helper
 
81
   TopLevelItem* getTopLevelItem(const QString& category);
 
82
 
 
83
private Q_SLOTS:
 
84
   void reloadCategories();
 
85
   void slotContactAdded(Contact* c);
 
86
};
 
87
 
 
88
class ContactTreeBinder : public QObject { //FIXME Qt5 remove when dropping Qt4
 
89
   Q_OBJECT
 
90
public:
 
91
   ContactTreeBinder(ContactProxyModel* m,ContactTreeNode* n);
 
92
private:
 
93
   ContactTreeNode* m_pTreeNode;
 
94
   ContactProxyModel* m_pModel;
 
95
private Q_SLOTS:
 
96
   void slotContactChanged();
 
97
   void slotStatusChanged();
 
98
   void slotPhoneNumberCountChanged(int,int);
 
99
   void slotPhoneNumberCountAboutToChange(int,int);
 
100
};
 
101
 
 
102
#endif