• Skip to content
  • Skip to link menu
  • KDE API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • KTp
  • Declarative
pinned-contacts-model.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Aleix Pol <aleixpol@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef PINNEDCONTACTSMODEL_H
20 #define PINNEDCONTACTSMODEL_H
21 
22 #include <QModelIndex>
23 #include <QVector>
24 
25 #include <KTp/types.h>
26 #include <KTp/persistent-contact.h>
27 
28 class ConversationsModel;
29 class PinnedContactsModelPrivate;
30 
31 class PinnedContactsModel : public QAbstractListModel
32 {
33  Q_OBJECT
34 
35  Q_PROPERTY(ConversationsModel *conversations READ conversationsModel WRITE setConversationsModel)
36  Q_PROPERTY(Tp::AccountManagerPtr accountManager READ accountManager WRITE setAccountManager)
37  Q_PROPERTY(QStringList state READ state WRITE setState)
38  Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
39 
40  public:
41  explicit PinnedContactsModel(QObject *parent = 0);
42  virtual ~PinnedContactsModel();
43 
44  enum role {
45  PresenceIconRole = Qt::UserRole + 1,
46  AvailabilityRole,
47  ContactRole,
48  AccountRole,
49  AlreadyChattingRole
50  };
51 
52  virtual QVariant data(const QModelIndex &index, int role) const;
53  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
54 
55  Q_SLOT void setPinning(const Tp::AccountPtr &account, const KTp::ContactPtr &contact, bool newState);
56 
57  QModelIndex indexForContact(const KTp::ContactPtr &contact) const;
58 
59  ConversationsModel* conversationsModel() const;
60  void setConversationsModel(ConversationsModel *model);
61 
62  Tp::AccountManagerPtr accountManager() const;
63  void setAccountManager(const Tp::AccountManagerPtr &accounts);
64 
65  QStringList state() const;
66  void setState(const QStringList &s);
67 
68  private Q_SLOTS:
69  void contactDataChanged();
70  void contactChanged(const KTp::ContactPtr &contact);
71  void conversationsStateChanged(const QModelIndex &parent, int start, int end);
72  void onAccountManagerReady();
73 
74  Q_SIGNALS:
75  void countChanged();
76 
77  private:
78  void appendContactPin(const KTp::PersistentContactPtr &pin);
79  void removeContactPin(const KTp::PersistentContactPtr &pin);
80  PinnedContactsModelPrivate * const d;
81 };
82 
83 #endif // PINNEDCONTACTSMODEL_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Fri Mar 22 2013 10:58:52 by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ktp-common-internals API Reference

Skip menu "ktp-common-internals API Reference"
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal