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

« back to all changes in this revision

Viewing changes to kde/src/lib/numbercompletionmodel.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 NUMBERCOMPLETIONMODEL_H
 
19
#define NUMBERCOMPLETIONMODEL_H
 
20
 
 
21
#include <QtCore/QAbstractTableModel>
 
22
#include "typedefs.h"
 
23
#include "phonedirectorymodel.h"
 
24
 
 
25
 
 
26
class PhoneNumber;
 
27
class Call;
 
28
 
 
29
class LIB_EXPORT NumberCompletionModel : public QAbstractTableModel {
 
30
   Q_OBJECT
 
31
 
 
32
public:
 
33
 
 
34
   //Properties
 
35
   Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
 
36
 
 
37
   enum Role {
 
38
      ALTERNATE_ACCOUNT= 100,
 
39
      FORCE_ACCOUNT    = 101,
 
40
      ACCOUNT          = 102,
 
41
   };
 
42
 
 
43
   NumberCompletionModel();
 
44
   virtual ~NumberCompletionModel();
 
45
 
 
46
   //Abstract model member
 
47
   QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;
 
48
   int rowCount(const QModelIndex& parent = QModelIndex()             ) const;
 
49
   Qt::ItemFlags flags(const QModelIndex& index                       ) const;
 
50
   virtual bool setData(const QModelIndex& index, const QVariant &value, int role);
 
51
   virtual int columnCount(const QModelIndex& parent = QModelIndex()  ) const;
 
52
   virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
 
53
 
 
54
   //Setters
 
55
   void setCall(Call* call);
 
56
   void setUseUnregisteredAccounts(bool value);
 
57
 
 
58
   //Getters
 
59
   Call* call() const;
 
60
   PhoneNumber* number(const QModelIndex& idx) const;
 
61
   bool isUsingUnregisteredAccounts();
 
62
   QString prefix() const;
 
63
 
 
64
protected:
 
65
   //Helper
 
66
   void getRange(QMap<QString,PhoneDirectoryModel::NumberWrapper*> map, const QString& prefix, QSet<PhoneNumber*>& set) const;
 
67
 
 
68
private:
 
69
   enum class Columns {
 
70
      CONTENT = 0,
 
71
      NAME    = 1,
 
72
      ACCOUNT = 2,
 
73
      WEIGHT  = 3,
 
74
   };
 
75
 
 
76
   //Methods
 
77
   void updateModel();
 
78
 
 
79
   //Helper
 
80
   void locateNameRange  (const QString& prefix, QSet<PhoneNumber*>& set);
 
81
   void locateNumberRange(const QString& prefix, QSet<PhoneNumber*>& set);
 
82
   uint getWeight(PhoneNumber* number);
 
83
 
 
84
   //Attributes
 
85
   QMultiMap<int,PhoneNumber*> m_hNumbers              ;
 
86
   QString                     m_Prefix                ;
 
87
   Call*                       m_pCall                 ;
 
88
   bool                        m_Enabled               ;
 
89
   bool                        m_UseUnregisteredAccount;
 
90
 
 
91
 
 
92
public Q_SLOTS:
 
93
   void setPrefix(const QString& str);
 
94
 
 
95
Q_SIGNALS:
 
96
   void enabled(bool);
 
97
 
 
98
};
 
99
 
 
100
#endif