QtPdCom  1.2.0
MessageModel.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_MESSAGEMODEL_H
23#define QTPDCOM_MESSAGEMODEL_H
24
25#include "Message.h"
26
27#include <QAbstractTableModel>
28#include <QIcon>
29
30#include <memory>
31
32namespace QtPdCom {
33
34class Process;
35
36/****************************************************************************/
37
43 public QAbstractTableModel
44{
45 Q_OBJECT
46 Q_PROPERTY(int rowLimit READ getRowLimit WRITE setRowLimit)
47 Q_PROPERTY(QtPdCom::Process * process READ getProcess WRITE connect)
48
49 friend class Message::Impl;
50
51 public:
52 MessageModel(QObject *parent = nullptr);
53 ~MessageModel();
54
55 void load(const QString &, const QString & = QString(),
56 const QString & = QString());
57 Q_INVOKABLE void clear();
58
59 void setRowLimit(int);
60 int getRowLimit() const;
61
62 void connect(QtPdCom::Process *);
63 QtPdCom::Process *getProcess() const;
64 Q_INVOKABLE void translate(const QString &);
65
66 void setIcon(Message::Type, const QIcon &);
67 const QIcon &getIcon(Message::Type) const;
68 void setIconPath(Message::Type, const QString &);
69
70 enum Roles {
71 DecorationPathRole = Qt::UserRole + 1,
72 TimeStringRole = Qt::UserRole + 2,
73 ResetTimeStringRole = Qt::UserRole + 3,
74 MessageTypeRole = Qt::UserRole + 4,
75 };
76 Q_ENUM(Roles)
77
78 // from QAbstractItemModel
79 virtual int rowCount(const QModelIndex &) const override;
80 virtual int columnCount(const QModelIndex &) const override;
81 virtual QVariant data(const QModelIndex &, int) const override;
82 virtual QVariant headerData(int, Qt::Orientation, int) const override;
83 virtual Qt::ItemFlags flags(const QModelIndex &) const override;
84 virtual QHash<int, QByteArray> roleNames() const override;
85 virtual bool canFetchMore(const QModelIndex &) const override;
86 virtual void fetchMore(const QModelIndex &) override;
87
90 struct Exception {
93 Exception(const QString &msg): msg(msg) {}
94 QString msg;
95 };
96
97 signals:
108 void currentMessage(const QtPdCom::Message *message);
109
116 void anyMessage(const QtPdCom::Message *message);
117
118 protected:
119 bool event(QEvent *) override;
120
121 private:
122 class Q_DECL_HIDDEN Impl;
123 std::unique_ptr<Impl> impl;
124};
125
126/****************************************************************************/
127
128} // namespace
129
130#endif
#define QTPDCOM_PUBLIC
Definition: Export.h:30
Definition: MessageModelImpl.h:42
List of Messages.
Definition: MessageModel.h:44
void currentMessage(const QtPdCom::Message *message)
Emitted, when a new message gets active.
void anyMessage(const QtPdCom::Message *message)
Emitted, when a new message gets active.
Roles
Definition: MessageModel.h:70
std::unique_ptr< Impl > impl
Definition: MessageModel.h:123
Process message.
Definition: Message.h:39
PdCom::Process implementation for Qt.
Definition: Process.h:62
Definition: BroadcastModel.h:32
Exception type.
Definition: MessageModel.h:90
Exception(const QString &msg)
Constructor.
Definition: MessageModel.h:93
QString msg
Exception message.
Definition: MessageModel.h:94