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

« back to all changes in this revision

Viewing changes to kde/src/lib/abstractbookmarkmodel.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 ABSTRACTBOOKMARKMODEL_H
 
19
#define ABSTRACTBOOKMARKMODEL_H
 
20
 
 
21
#include <QtCore/QAbstractItemModel>
 
22
#include <QtCore/QHash>
 
23
#include <QtCore/QStringList>
 
24
#include <QtCore/QDateTime>
 
25
 
 
26
//SFLPhone
 
27
#include "../lib/typedefs.h"
 
28
#include "../lib/contact.h"
 
29
#include "../lib/call.h"
 
30
class ContactBackend;
 
31
class NumberTreeBackend;
 
32
 
 
33
class LIB_EXPORT AbstractBookmarkModel :  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 NumberTreeBackend;
 
41
   //Constructor
 
42
   virtual ~AbstractBookmarkModel() {}
 
43
   explicit AbstractBookmarkModel(QObject* parent);
 
44
 
 
45
   //Setters
 
46
   void setRole(int role);
 
47
   void setShowAll(bool showAll);
 
48
 
 
49
   //Model implementation
 
50
   virtual bool          setData     ( const QModelIndex& index, const QVariant &value, int role   );
 
51
   virtual QVariant      data        ( const QModelIndex& index, int role = Qt::DisplayRole        ) const;
 
52
   virtual int           rowCount    ( const QModelIndex& parent = QModelIndex()                   ) const;
 
53
   virtual Qt::ItemFlags flags       ( const QModelIndex& index                                    ) const;
 
54
   virtual int           columnCount ( const QModelIndex& parent = QModelIndex()                   ) const;
 
55
   virtual QModelIndex   parent      ( const QModelIndex& index                                    ) const;
 
56
   virtual QModelIndex   index       ( int row, int column, const QModelIndex& parent=QModelIndex()) const;
 
57
   virtual QVariant      headerData  ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
 
58
   virtual QStringList   mimeTypes   (                                                             ) const;
 
59
   virtual QMimeData*    mimeData    ( const QModelIndexList &indexes                              ) const;
 
60
   virtual bool          removeRows  ( int row, int count, const QModelIndex & parent = QModelIndex() );
 
61
 
 
62
   //Management
 
63
   void         remove(const QModelIndex& idx                         );
 
64
   virtual void addBookmark   (PhoneNumber* number, bool trackPresence = false) = 0;
 
65
   virtual void removeBookmark(PhoneNumber* number                            ) = 0;
 
66
 
 
67
   //Getters
 
68
   int acceptedPayloadTypes();
 
69
 
 
70
protected:
 
71
   virtual bool                  displayFrequentlyUsed() const;
 
72
   virtual QVector<PhoneNumber*> bookmarkList         () const;
 
73
 
 
74
   //Helpers
 
75
   static QVector<PhoneNumber*> serialisedToList(const QStringList& list);
 
76
 
 
77
private:
 
78
   ///Top level bookmark item
 
79
   class TopLevelItem : public CategorizedCompositeNode {
 
80
      friend class AbstractBookmarkModel;
 
81
      public:
 
82
         virtual QObject* getSelf() const;
 
83
         int m_Row;
 
84
      private:
 
85
         explicit TopLevelItem(QString name);
 
86
         QList<NumberTreeBackend*> m_lChildren;
 
87
         QString m_Name;
 
88
         bool m_MostPopular;
 
89
   };
 
90
 
 
91
   //Attributes
 
92
   QList<TopLevelItem*>         m_lCategoryCounter ;
 
93
   QHash<QString,TopLevelItem*> m_hCategories      ;
 
94
   QStringList                  m_lMimes           ;
 
95
 
 
96
   //Getters
 
97
   QModelIndex getContactIndex(Contact* ct) const;
 
98
 
 
99
   //Helpers
 
100
   QVariant commonCallInfo(NumberTreeBackend* call, int role = Qt::DisplayRole) const;
 
101
   QString category(NumberTreeBackend* number) const;
 
102
 
 
103
private Q_SLOTS:
 
104
   void slotRequest(const QString& uri);
 
105
   void slotIndexChanged(const QModelIndex& idx);
 
106
 
 
107
public Q_SLOTS:
 
108
   void reloadCategories();
 
109
};
 
110
 
 
111
class BookmarkItemNode : public QObject //TODO remove this once Qt4 support is dropped
 
112
{
 
113
   Q_OBJECT
 
114
public:
 
115
   BookmarkItemNode(AbstractBookmarkModel* m, PhoneNumber* n, NumberTreeBackend* backend);
 
116
private:
 
117
   PhoneNumber* m_pNumber;
 
118
   NumberTreeBackend* m_pBackend;
 
119
   AbstractBookmarkModel* m_pModel;
 
120
private Q_SLOTS:
 
121
   void slotNumberChanged();
 
122
Q_SIGNALS:
 
123
   void changed(const QModelIndex& idx);
 
124
};
 
125
 
 
126
#endif