flat_merge_proxy_model.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2017, Bielefeld University
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Bielefeld University nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Robert Haschke */
36 
37 #pragma once
38 
39 #include <QAbstractItemModel>
40 #include <QStringList>
41 
42 namespace moveit_rviz_plugin {
43 namespace utils {
44 
45 class FlatMergeProxyModelPrivate;
52 class FlatMergeProxyModel : public QAbstractItemModel
53 {
54  Q_OBJECT
55  Q_DECLARE_PRIVATE(FlatMergeProxyModel)
56  FlatMergeProxyModelPrivate* d_ptr;
57 
58 protected:
60  virtual void onRemoveModel(QAbstractItemModel* model);
61 
62 public:
63  FlatMergeProxyModel(QObject* parent = nullptr);
64  ~FlatMergeProxyModel() override;
65 
67  size_t modelCount() const;
69  bool isToplevel(const QModelIndex& index) const;
70 
71  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
72 
73  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
74  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
75 
76  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
77  QModelIndex parent(const QModelIndex& index) const override;
78 
79  QModelIndex mapToSource(const QModelIndex& proxy_index) const;
80  QModelIndex mapFromSource(const QModelIndex& src_index) const;
81 
82  Qt::ItemFlags flags(const QModelIndex& index) const override;
83  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
84  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
85 
86  void setMimeTypes(const QStringList& mime_types);
87  QStringList mimeTypes() const override;
88  bool dropMimeData(const QMimeData* mime, Qt::DropAction action, int row, int column,
89  const QModelIndex& parent) override;
90 
91  bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
92 
94  bool insertModel(QAbstractItemModel* model, int pos = -1);
95 
97  std::pair<QAbstractItemModel*, QModelIndex> getModel(const QModelIndex& index) const;
98 
99 public Q_SLOTS:
101  bool removeModel(QAbstractItemModel* model);
103  bool removeModel(int pos);
104 
105 private:
106  Q_PRIVATE_SLOT(d_func(), void _q_sourceDestroyed(QObject*))
107  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(QModelIndex, int, int))
108  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(QModelIndex, int, int))
109  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(QModelIndex, int, int))
110  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(QModelIndex, int, int))
111  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int))
112  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex, int, int, QModelIndex, int))
113  Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex, QModelIndex, QVector<int>))
114 };
115 } // namespace utils
116 } // namespace moveit_rviz_plugin
moveit_rviz_plugin::utils::FlatMergeProxyModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: flat_merge_proxy_model.cpp:380
moveit_rviz_plugin::utils::FlatMergeProxyModel::dropMimeData
bool dropMimeData(const QMimeData *mime, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Definition: flat_merge_proxy_model.cpp:422
moveit_rviz_plugin::utils::FlatMergeProxyModel::mapToSource
QModelIndex mapToSource(const QModelIndex &proxy_index) const
Definition: flat_merge_proxy_model.cpp:371
moveit_rviz_plugin::utils::FlatMergeProxyModel::mimeTypes
QStringList mimeTypes() const override
Definition: flat_merge_proxy_model.cpp:418
moveit_rviz_plugin::utils::FlatMergeProxyModel::_q_sourceRowsAboutToBeInserted
void _q_sourceRowsAboutToBeInserted(QModelIndex, int, int)) Q_PRIVATE_SLOT(d_func()
moveit_rviz_plugin::utils::FlatMergeProxyModel::FlatMergeProxyModel
FlatMergeProxyModel(QObject *parent=nullptr)
Definition: flat_merge_proxy_model.cpp:297
moveit_rviz_plugin::utils::FlatMergeProxyModel::setMimeTypes
void setMimeTypes(const QStringList &mime_types)
Definition: flat_merge_proxy_model.cpp:414
moveit_rviz_plugin::utils::FlatMergeProxyModel::_q_sourceRowsRemoved
void void void void _q_sourceRowsRemoved(QModelIndex, int, int)) Q_PRIVATE_SLOT(d_func()
moveit_rviz_plugin::utils::FlatMergeProxyModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: flat_merge_proxy_model.cpp:405
moveit_rviz_plugin::utils::FlatMergeProxyModel::_q_sourceRowsMoved
void void void void void void _q_sourceRowsMoved(QModelIndex, int, int, QModelIndex, int)) Q_PRIVATE_SLOT(d_func()
moveit_rviz_plugin::utils::FlatMergeProxyModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: flat_merge_proxy_model.cpp:325
moveit_rviz_plugin::utils::FlatMergeProxyModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: flat_merge_proxy_model.cpp:337
moveit_rviz_plugin::utils::FlatMergeProxyModel::mapFromSource
QModelIndex mapFromSource(const QModelIndex &src_index) const
Definition: flat_merge_proxy_model.cpp:376
moveit_rviz_plugin::utils::FlatMergeProxyModel::parent
QModelIndex parent(const QModelIndex &index) const override
Definition: flat_merge_proxy_model.cpp:362
moveit_rviz_plugin::utils::FlatMergeProxyModel::_q_sourceRowsInserted
void void _q_sourceRowsInserted(QModelIndex, int, int)) Q_PRIVATE_SLOT(d_func()
moveit_rviz_plugin::utils::FlatMergeProxyModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: flat_merge_proxy_model.cpp:313
moveit_rviz_plugin::utils::FlatMergeProxyModel::insertModel
bool insertModel(QAbstractItemModel *model, int pos=-1)
insert a new sub model, pos is relative to modelCount()
Definition: flat_merge_proxy_model.cpp:470
moveit_rviz_plugin
moveit_rviz_plugin::utils::FlatMergeProxyModel::isToplevel
bool isToplevel(const QModelIndex &index) const
return true if this index corresponds to a top-level item of an embedded model
Definition: flat_merge_proxy_model.cpp:309
moveit_rviz_plugin::utils::FlatMergeProxyModel::~FlatMergeProxyModel
~FlatMergeProxyModel() override
Definition: flat_merge_proxy_model.cpp:301
moveit_rviz_plugin::utils::FlatMergeProxyModel::d_ptr
FlatMergeProxyModelPrivate * d_ptr
Definition: flat_merge_proxy_model.h:120
moveit_rviz_plugin::utils::FlatMergeProxyModel::removeModel
bool removeModel(QAbstractItemModel *model)
remove (first) matching model
Definition: flat_merge_proxy_model.cpp:528
moveit_rviz_plugin::utils::FlatMergeProxyModel::getModel
std::pair< QAbstractItemModel *, QModelIndex > getModel(const QModelIndex &index) const
retrieve model corresponding to given index
Definition: flat_merge_proxy_model.cpp:516
moveit_rviz_plugin::utils::FlatMergeProxyModel::_q_sourceRowsAboutToBeRemoved
void void void _q_sourceRowsAboutToBeRemoved(QModelIndex, int, int)) Q_PRIVATE_SLOT(d_func()
moveit_rviz_plugin::utils::FlatMergeProxyModel::onRemoveModel
virtual void onRemoveModel(QAbstractItemModel *model)
method called when a model is removed
Definition: flat_merge_proxy_model.cpp:547
moveit_rviz_plugin::utils::FlatMergeProxyModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: flat_merge_proxy_model.cpp:389
moveit_rviz_plugin::utils::FlatMergeProxyModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: flat_merge_proxy_model.cpp:397
moveit_rviz_plugin::utils::FlatMergeProxyModel::modelCount
size_t modelCount() const
number of embedded models
Definition: flat_merge_proxy_model.cpp:305
moveit_rviz_plugin::utils::FlatMergeProxyModel::removeRows
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
Definition: flat_merge_proxy_model.cpp:433
moveit_rviz_plugin::utils::FlatMergeProxyModel::_q_sourceRowsAboutToBeMoved
void void void void void _q_sourceRowsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int)) Q_PRIVATE_SLOT(d_func()
moveit_rviz_plugin::utils::FlatMergeProxyModel::Q_PRIVATE_SLOT
Q_PRIVATE_SLOT(d_func(), void _q_sourceDestroyed(QObject *)) Q_PRIVATE_SLOT(d_func()


visualization
Author(s): Robert Haschke
autogenerated on Sat May 3 2025 02:40:38