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

Nepomuk-Core

  • KTp
  • Models
rooms-model.h
Go to the documentation of this file.
1 /*
2  * Rooms Model - A model of chatrooms.
3  * Copyright (C) 2012 Dominik Cermak <d.cermak@arcor.de>
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 Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef ROOMS_MODEL_H
21 #define ROOMS_MODEL_H
22 
23 #include <QtCore/QAbstractListModel>
24 #include <TelepathyQt/Types>
25 
26 #include <KTp/ktp-export.h>
27 
28 namespace KTp {
29 
30 class KTP_EXPORT RoomsModel : public QAbstractListModel
31 {
32  Q_OBJECT
33 
34 public:
35  // TODO: find a suitable icon and add an invitation column
36  enum Column {
37  PasswordColumn=0,
38  MembersColumn,
39  NameColumn,
40  DescriptionColumn
41  };
42 
43  enum Roles {
44  HandleNameRole = Qt::UserRole
45  };
46 
47  explicit RoomsModel(QObject *parent = 0);
48  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
49  virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
50  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
51  virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
52 
58  void addRooms(const Tp::RoomInfoList newRoomList);
59 
63  void clearRoomInfoList();
64 
65 private:
66  Tp::RoomInfoList m_roomInfoList;
67 };
68 
69 class KTP_EXPORT FavoriteRoomsModel : public QAbstractListModel
70 {
71  Q_OBJECT
72 
73 public:
74  enum Column {
75  NameColumn = 0,
76  HandleNameColumn,
77  AccountIdentifierColumn
78  };
79 
80  enum Roles {
81  HandleNameRole = Qt::UserRole,
82  FavoriteRoomRole
83  };
84 
85  explicit FavoriteRoomsModel(QObject *parent = 0);
86  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
87  virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
88  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
89 
95  void addRooms(const QList<QVariantMap> newRoomList);
96 
102  void addRoom(const QVariantMap &room);
103 
109  void removeRoom(const QVariantMap &room);
110 
118  bool containsRoom(const QString &handle, const QString &account) const;
119 
127  int countForAccount(const QString &account) const;
128 
129 private:
130  QList<QVariantMap> m_favoriteRoomsList;
131 };
132 
133 } // namespace KTp
134 
135 #endif // ROOMS_MODEL_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