VPTissue Reference Manual
CheckableTreeModel.h
Go to the documentation of this file.
1 #ifndef GUI_QTMODEL_CHECKABLETREEMODEL_H_INCLUDED
2 #define GUI_QTMODEL_CHECKABLETREEMODEL_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include <boost/property_tree/ptree.hpp>
23 #include <QAbstractItemModel>
24 #include <vector>
25 
26 namespace SimShell {
27 namespace Gui {
28 
34 {
35  Q_OBJECT
36 public:
65  CheckableTreeModel(const boost::property_tree::ptree& tree, QObject* parent = nullptr);
66 
67  virtual ~CheckableTreeModel();
68 
70  virtual int columnCount(QModelIndex const&) const;
71 
73  virtual QVariant data(const QModelIndex& index, int role) const;
74 
76  virtual Qt::ItemFlags flags(const QModelIndex& index) const;
77 
79  virtual QVariant headerData(int section, Qt::Orientation o, int role) const;
80 
82  virtual QModelIndex index(int row, int column, QModelIndex const& parent) const;
83 
85  virtual QModelIndex parent(QModelIndex const& index) const;
86 
88  virtual int rowCount(QModelIndex const& parent) const;
89 
91  virtual bool setData(QModelIndex const& index, const QVariant& value, int role);
92 
97  boost::property_tree::ptree ToPTree();
98 
99 private:
103  struct Item {
104  ~Item();
105 
106  Item* parent;
107  std::vector<Item*> children;
108  QString data;
109  bool checked;
110  };
111 
112  Item* m_root;
113 };
114 
115 } // namespace
116 } // namespace
117 
118 #endif // end_of_inclde_guard
virtual QVariant headerData(int section, Qt::Orientation o, int role) const
see the online Qt documentation
virtual int columnCount(QModelIndex const &) const
virtual QVariant data(const QModelIndex &index, int role) const
virtual bool setData(QModelIndex const &index, const QVariant &value, int role)
virtual int rowCount(QModelIndex const &parent) const
virtual QModelIndex parent(QModelIndex const &index) const
virtual QModelIndex index(int row, int column, QModelIndex const &parent) const
CheckableTreeModel(const boost::property_tree::ptree &tree, QObject *parent=nullptr)
Create model.
boost::property_tree::ptree ToPTree()
Get checked/unchecked state of items, represented by a ptree of the form discussed in the constructor...
virtual Qt::ItemFlags flags(const QModelIndex &index) const
see the online Qt documentation
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32
A hierarchical tree-like model of checkable items.