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

Nepomuk-Core

  • KTp
  • Declarative
messages-model.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 Lasath Fernando <kde@lasath.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 
20 #ifndef MESSAGES_MODEL_H
21 #define MESSAGES_MODEL_H
22 
23 #include <QAbstractItemModel>
24 
25 #include <TelepathyQt/Types>
26 #include <TelepathyQt/ReceivedMessage>
27 
28 #include "conversation-queue-manager.h"
29 
30 
31 class MessagesModel : public QAbstractListModel, public Queueable
32 {
33  Q_OBJECT
34  Q_ENUMS(MessageType)
35  Q_PROPERTY(bool visibleToUser READ isVisibleToUser WRITE setVisibleToUser NOTIFY visibleToUserChanged)
36  Q_PROPERTY(int unreadCount READ unreadCount NOTIFY unreadCountChanged)
37  Q_PROPERTY(bool shouldStartOpened READ shouldStartOpened CONSTANT)
38 
39  public:
40  MessagesModel(const Tp::AccountPtr &account, QObject *parent = 0);
41  virtual ~MessagesModel();
42 
43  enum Roles {
44  UserRole = Qt::UserRole,
45  TextRole,
46  TypeRole,
47  TimeRole
48  };
49 
50  enum MessageType {
51  MessageTypeIncoming,
52  MessageTypeOutgoing,
53  MessageTypeAction,
54  MessageTypeNotice
55  };
56 
57  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
58  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
59 
60  Tp::TextChannelPtr textChannel() const;
61  void setTextChannel(Tp::TextChannelPtr channel);
62 
63  bool isVisibleToUser() const;
64  void setVisibleToUser(bool visible);
65 
66  int unreadCount() const;
67  void acknowledgeAllMessages();
68 
69  bool shouldStartOpened() const;
70 
71  Q_SIGNALS:
72  void visibleToUserChanged(bool visible);
73 
74  void unreadCountChanged(int unreadMesssagesCount);
75  void popoutRequested();
76 
77  public Q_SLOTS:
78  void sendNewMessage(const QString &message);
79 
80  private Q_SLOTS:
81  void onMessageReceived(const Tp::ReceivedMessage &message);
82  void onMessageSent(const Tp::Message &message, Tp::MessageSendingFlags flags, const QString &messageToken);
83  void onPendingMessageRemoved();
84  bool verifyPendingOperation(Tp::PendingOperation *op);
85 
86  private:
87  void setupChannelSignals(const Tp::TextChannelPtr &channel);
88  void removeChannelSignals(const Tp::TextChannelPtr &channel);
89  virtual void selfDequeued();
90 
91  class MessagesModelPrivate;
92  MessagesModelPrivate *d;
93 };
94 
95 #endif // CONVERSATION_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