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