QtPdCom  1.5.0
MessageModelUnion.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2009 - 2025 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 #pragma once
23 
24 #include "Export.h"
25 
26 #include <QAbstractTableModel>
27 
28 #include <memory>
29 
30 namespace QtPdCom {
31 
32 class MessageModel;
33 class MessageModelFilter;
34 class Message;
35 
36 /****************************************************************************/
37 
41 class QTPDCOM_PUBLIC MessageModelUnion: public QAbstractTableModel
42 {
43  Q_OBJECT
44 
45  public:
46  enum Columns {
47  TextColumn = 0,
50  SourceColumn
51  };
52  Q_ENUM(Columns)
53 
54  explicit MessageModelUnion(QObject *parent = nullptr);
55  virtual ~MessageModelUnion();
56 
57  void addSourceModel(QAbstractItemModel *, QString = QString());
58  void removeSourceModel(QAbstractItemModel *);
59 
60  void clearSourceModels();
61 
62  // from QAbstractItemModel
63  virtual int rowCount(const QModelIndex &) const override;
64  virtual int columnCount(const QModelIndex &) const override;
65  virtual QVariant data(const QModelIndex &, int) const override;
66  virtual QVariant headerData(int, Qt::Orientation, int) const override;
67  virtual Qt::ItemFlags flags(const QModelIndex &) const override;
68  virtual bool canFetchMore(const QModelIndex &) const override;
69  virtual void fetchMore(const QModelIndex &) override;
70 
71  signals:
84  void currentMessage(const QtPdCom::Message *message);
85 
86  private:
87  struct Q_DECL_HIDDEN Impl;
88  std::unique_ptr<Impl> impl;
89 };
90 
91 /****************************************************************************/
92 
93 } // namespace QtPdCom
Definition: MessageModelUnion.cpp:37
Definition: MessageModelUnion.h:48
Definition: BroadcastModel.h:32
Process message.
Definition: Message.h:37
Definition: MessageModelUnion.h:49
#define QTPDCOM_PUBLIC
Definition: Export.h:30
std::unique_ptr< Impl > impl
Definition: MessageModelUnion.h:88
Columns
Definition: MessageModelUnion.h:46
Table model that combines the rows of multiple MessageModels or MessageModelFilters.
Definition: MessageModelUnion.h:41