QtPdCom  1.3.3
MessageModelImpl.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2009 - 2022 Florian Pose <fp@igh.de>
4  *
5  * This file is part of the QtPdCom library.
6  *
7  * The QtPdCom library is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * The QtPdCom library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with the QtPdCom Library. If not, see <http://www.gnu.org/licenses/>.
19  *
20  ****************************************************************************/
21 
22 #ifndef QTPDCOM_MESSAGE_MODEL_IMPL
23 #define QTPDCOM_MESSAGE_MODEL_IMPL
24 
25 #include "MessageModel.h"
26 #include "MessageManager.h"
27 
28 #include <pdcom5/MessageManagerBase.h>
29 
30 #include <QObject>
31 #include <QSet>
32 
33 /****************************************************************************/
34 
35 namespace QtPdCom {
36 
37 class Process;
38 
39 /****************************************************************************/
40 
41 class MessageModel::Impl: public QObject
42 {
43  Q_OBJECT
44 
45  friend class MessageModel;
46  friend class Message;
47 
48  public:
49  Impl(MessageModel *);
50  ~Impl();
51 
52  struct MessageItem;
53 
54  void insertItem(MessageItem *);
55  void addProcessMessage(const PdCom::Message &);
56  void
57  addHistoricMessage(const PdCom::Message &, const PdCom::Message &);
58 
59  static QString wrapText(const QString &, unsigned int = 78);
60 
61  private:
63 
64  // Map of message[path][index]
65  typedef QHash<int, Message *> MessageHash;
66  typedef QMap<QString, MessageHash> MessageMap;
68 
69  typedef QList<MessageItem *> MessageItemList;
71 
72  typedef QHash<Message::Type, QIcon> IconHash;
78  typedef QHash<Message::Type, QString> IconPathHash;
81 
83  QString lang;
85  int rowLimit;
87  uint32_t historicSeqNo;
88 
90  void getHistoryMessage();
91 
93  void announce();
94 
95  bool (*lessThan)(const MessageItem *, const MessageItem *);
96 
98  QList<PdCom::Message> resetMessagesList;
99 
100  Process *process = nullptr;
101 
102  private slots:
103  void stateChanged();
104  void processMessage(PdCom::Message message);
105  void getMessageReply(PdCom::Message message);
106  void activeMessagesReply(std::vector<PdCom::Message>);
107  void processReset();
108  void reloadActiveMessages();
109 };
110 
111 /****************************************************************************/
112 
113 } // namespace QtPdCom
114 
115 #endif
116 
117 /****************************************************************************/
QList< PdCom::Message > resetMessagesList
list of history messages that were reset
Definition: MessageModelImpl.h:98
QList< MessageItem * > MessageItemList
Definition: MessageModelImpl.h:69
List of Messages.
Definition: MessageModel.h:42
QHash< Message::Type, QIcon > IconHash
Icon hash type.
Definition: MessageModelImpl.h:72
MessageModel *const parent
Definition: MessageModelImpl.h:62
Process * process
Definition: MessageModelImpl.h:100
Impl(MessageModel *)
Constructor.
Definition: MessageModelImpl.cpp:36
uint32_t historicSeqNo
Definition: MessageModelImpl.h:87
MessageManager * messageManager
Definition: MessageModelImpl.h:84
PdCom::Process implementation for Qt.
Definition: Process.h:70
QMap< QString, MessageHash > MessageMap
Definition: MessageModelImpl.h:66
MessageMap messageMap
Definition: MessageModelImpl.h:67
void stateChanged()
Reacts on process values changes of all messages to watch.
Definition: MessageModelImpl.cpp:329
MessageItemList messageItemList
Definition: MessageModelImpl.h:70
Definition: BroadcastModel.h:32
bool(* lessThan)(const MessageItem *, const MessageItem *)
Definition: MessageModelImpl.h:95
MessageItem * announcedMessageItem
Recently announced message.
Definition: MessageModelImpl.h:82
static QString wrapText(const QString &, unsigned int=78)
Returns a wrapped version of a string.
Definition: MessageModelImpl.cpp:221
void announce()
Announce next best message as current message.
Definition: MessageModelImpl.cpp:275
void addProcessMessage(const PdCom::Message &)
Called from the PdCom interface, if a new message appears via processMessage() or in context of activ...
Definition: MessageModelImpl.cpp:112
Definition: MessageItem.h:37
Process message.
Definition: Message.h:37
bool canFetchMore
Definition: MessageModelImpl.h:86
void getHistoryMessage()
Spin up a FutureWatcher and connect its signals.
Definition: MessageModelImpl.cpp:248
int rowLimit
Definition: MessageModelImpl.h:85
void processMessage(PdCom::Message message)
Definition: MessageModelImpl.cpp:385
QString lang
Definition: MessageModelImpl.h:83
QHash< Message::Type, QString > IconPathHash
Icon hash type (with path).
Definition: MessageModelImpl.h:78
IconHash iconHash
Icons for message types.
Definition: MessageModelImpl.h:74
~Impl()
Destructor.
Definition: MessageModelImpl.cpp:50
Definition: MessageManager.h:66
void activeMessagesReply(std::vector< PdCom::Message >)
Definition: MessageModelImpl.cpp:465
void processReset()
Definition: MessageModelImpl.cpp:504
void addHistoricMessage(const PdCom::Message &, const PdCom::Message &)
Called from the PdCom interface, if a historic message appears via getMessageReply().
Definition: MessageModelImpl.cpp:196
Definition: MessageModelImpl.h:41
void getMessageReply(PdCom::Message message)
Definition: MessageModelImpl.cpp:401
IconPathHash iconPathHash
Icons for message types (with path).
Definition: MessageModelImpl.h:80
void insertItem(MessageItem *)
Insert a message item.
Definition: MessageModelImpl.cpp:57
void reloadActiveMessages()
Definition: MessageModelImpl.cpp:544
QHash< int, Message * > MessageHash
Definition: MessageModelImpl.h:65