QtPdCom  1.0.0
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 
42  public QObject
43 {
44  Q_OBJECT
45 
46  friend class MessageModel;
47  friend class Message;
48 
49  public:
50  Impl(MessageModel *);
51  ~Impl();
52 
53  struct MessageItem;
54 
55  void insertItem(MessageItem *);
56  void addProcessMessage(const PdCom::Message &);
57  void addHistoricMessage(const PdCom::Message &,
58  const PdCom::Message &);
59 
60  static QString wrapText(const QString &, unsigned int = 78);
61 
62  private:
64 
65  // Map of message[path][index]
66  typedef QHash<int, Message *> MessageHash;
67  typedef QMap<QString, MessageHash> MessageMap;
69 
70  typedef QList<MessageItem *> MessageItemList;
72 
73  typedef QHash<Message::Type, QIcon> IconHash;
79  typedef QHash<Message::Type, QString> IconPathHash;
82 
84  QString lang;
86  int rowLimit;
88  uint32_t historicSeqNo;
89 
91  void getHistoryMessage();
92 
93  bool (*lessThan)(const MessageItem *, const MessageItem *);
94 
96  QList<PdCom::Message> resetMessagesList;
97 
98  Process *process = nullptr;
99 
100  private slots:
101  void stateChanged();
102  void processMessage(PdCom::Message message);
103  void getMessageReply(PdCom::Message message);
104  void activeMessagesReply(std::vector<PdCom::Message>);
105  void processReset();
106  void reloadActiveMessages();
107 };
108 
109 /****************************************************************************/
110 
111 }
112 
113 #endif
114 
115 /****************************************************************************/
Definition: MessageManager.h:69
Definition: MessageModelImpl.h:43
void reloadActiveMessages()
Definition: MessageModelImpl.cpp:482
QString lang
Definition: MessageModelImpl.h:84
QHash< Message::Type, QIcon > IconHash
Icon hash type.
Definition: MessageModelImpl.h:73
void getHistoryMessage()
Spin up a FutureWatcher and connect its signals.
Definition: MessageModelImpl.cpp:238
MessageManager * messageManager
Definition: MessageModelImpl.h:85
QHash< Message::Type, QString > IconPathHash
Icon hash type (with path).
Definition: MessageModelImpl.h:79
void addHistoricMessage(const PdCom::Message &, const PdCom::Message &)
Called from the PdCom interface, if a historic message appears via getMessageReply().
Definition: MessageModelImpl.cpp:187
QMap< QString, MessageHash > MessageMap
Definition: MessageModelImpl.h:67
static QString wrapText(const QString &, unsigned int=78)
Returns a wrapped version of a string.
Definition: MessageModelImpl.cpp:213
void insertItem(MessageItem *)
Insert a message item.
Definition: MessageModelImpl.cpp:59
int rowLimit
Definition: MessageModelImpl.h:86
void processMessage(PdCom::Message message)
Definition: MessageModelImpl.cpp:315
IconHash iconHash
Icons for message types.
Definition: MessageModelImpl.h:75
Impl(MessageModel *)
Constructor.
Definition: MessageModelImpl.cpp:36
MessageModel *const parent
Definition: MessageModelImpl.h:63
QList< PdCom::Message > resetMessagesList
list of history messages that were reset
Definition: MessageModelImpl.h:96
void getMessageReply(PdCom::Message message)
Definition: MessageModelImpl.cpp:335
bool canFetchMore
Definition: MessageModelImpl.h:87
~Impl()
Destructor.
Definition: MessageModelImpl.cpp:51
IconPathHash iconPathHash
Icons for message types (with path).
Definition: MessageModelImpl.h:81
void stateChanged()
Reacts on process values changes of all messages to watch.
Definition: MessageModelImpl.cpp:269
void activeMessagesReply(std::vector< PdCom::Message >)
Definition: MessageModelImpl.cpp:403
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:116
MessageItem * announcedMessageItem
Recently announced message.
Definition: MessageModelImpl.h:83
void processReset()
Definition: MessageModelImpl.cpp:445
MessageMap messageMap
Definition: MessageModelImpl.h:68
uint32_t historicSeqNo
Definition: MessageModelImpl.h:88
MessageItemList messageItemList
Definition: MessageModelImpl.h:71
bool(* lessThan)(const MessageItem *, const MessageItem *)
Definition: MessageModelImpl.h:93
Process * process
Definition: MessageModelImpl.h:98
QHash< int, Message * > MessageHash
Definition: MessageModelImpl.h:66
QList< MessageItem * > MessageItemList
Definition: MessageModelImpl.h:70
List of Messages.
Definition: MessageModel.h:44
Process message.
Definition: Message.h:39
PdCom::Process implementation for Qt.
Definition: Process.h:62
Definition: BroadcastModel.h:32
Definition: MessageItem.h:38