labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

AspectTreeModel.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : AspectTreeModel.h
3  Project : LabPlot
4  Description : Represents a tree of AbstractAspect objects as a Qt item model.
5  --------------------------------------------------------------------
6  Copyright : (C) 2007-2009 by Knut Franke (knut.franke@gmx.de)
7  Copyright : (C) 2007-2009 by Tilman Benkert (thzs@gmx.net)
8  Copyright : (C) 2011-2016 Alexander Semke (alexander.semke@web.de)
9 
10  ***************************************************************************/
11 
12 /***************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the Free Software *
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
27  * Boston, MA 02110-1301 USA *
28  * *
29  ***************************************************************************/
30 #ifndef ASPECT_TREE_MODEL_H
31 #define ASPECT_TREE_MODEL_H
32 
33 #include <QAbstractItemModel>
34 
35 enum class AspectType : quint64;
36 class AbstractAspect;
37 
38 class AspectTreeModel : public QAbstractItemModel {
39  Q_OBJECT
40 
41 public:
42  explicit AspectTreeModel(AbstractAspect* root, QObject* parent=nullptr);
43 
44  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
45  QModelIndex parent(const QModelIndex &index) const override;
46  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
47  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
48  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
49  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
50  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
51  Qt::ItemFlags flags(const QModelIndex &index) const override;
53  QModelIndex modelIndexOfAspect(const AbstractAspect*, int column=0) const;
54  QModelIndex modelIndexOfAspect(const QString& path, int column=0) const;
55 
56  void setReadOnly(bool);
57  void enablePlottableColumnsOnly(bool);
58  void enableNumericColumnsOnly(bool);
60  void enableShowPlotDesignation(bool);
61  void setFilterString(const QString&);
62  void setFilterCaseSensitivity(Qt::CaseSensitivity);
63  void setFilterMatchCompleteWord(bool);
64 
65 private slots:
67  void aspectAboutToBeAdded(const AbstractAspect* parent, const AbstractAspect* before, const AbstractAspect* child);
68  void aspectAdded(const AbstractAspect* parent);
70  void aspectRemoved();
75  void renameRequestedSlot();
76 
77 private:
79  bool m_readOnly{false};
80  bool m_folderSelectable{true};
81  bool m_plottableColumnsOnly{false};
82  bool m_numericColumnsOnly{false};
83  bool m_nonEmptyNumericColumnsOnly{false};
84  bool m_showPlotDesignation{false};
86 
87  QString m_filterString;
88  Qt::CaseSensitivity m_filterCaseSensitivity{Qt::CaseInsensitive};
89  bool m_matchCompleteWord{false};
90  bool containsFilterString(const AbstractAspect*) const;
91 
92 signals:
93  void renameRequested(const QModelIndex&);
94  void indexSelected(const QModelIndex&);
95  void indexDeselected(const QModelIndex&);
97  void statusInfo(const QString&);
98 };
99 
100 #endif // ifndef ASPECT_TREE_MODEL_H
AspectType
Base class of all persistent objects in a Project.
void aspectAdded(const AbstractAspect *)
Emitted after a new Aspect has been added to the tree.
void aspectHiddenAboutToChange(const AbstractAspect *)
Emitted before the hidden attribute is changed.
void aspectDescriptionChanged(const AbstractAspect *)
Emitted after the name, comment or caption spec have changed.
AbstractAspect * parent(AspectType type) const
In the parent-child hierarchy, return the first parent of type.
void aspectAboutToBeRemoved(const AbstractAspect *)
Emitted before an aspect is removed from its parent.
void aspectHiddenChanged(const AbstractAspect *)
Emitted after the hidden attribute has changed.
void aspectAboutToBeAdded(const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
Emitted before a new child is inserted.
void aspectRemoved(const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
Emitted from the parent after removing a child.
Represents a tree of AbstractAspect objects as a Qt item model.
void aspectSelectedInView(const AbstractAspect *)
void setFilterMatchCompleteWord(bool)
void setFilterString(const QString &)
Qt::ItemFlags flags(const QModelIndex &index) const override
void setFilterCaseSensitivity(Qt::CaseSensitivity)
bool containsFilterString(const AbstractAspect *) const
void indexSelected(const QModelIndex &)
void statusInfo(const QString &)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void setSelectableAspects(const QList< AspectType > &)
AbstractAspect * m_root
void hiddenAspectSelected(const AbstractAspect *)
QList< AspectType > m_selectableAspects
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void enableNumericColumnsOnly(bool)
void enableShowPlotDesignation(bool)
void indexDeselected(const QModelIndex &)
void enableNonEmptyNumericColumnsOnly(bool)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setReadOnly(bool)
QModelIndex modelIndexOfAspect(const AbstractAspect *, int column=0) const
Convenience wrapper around QAbstractItemModel::createIndex().
void enablePlottableColumnsOnly(bool)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void aspectDeselectedInView(const AbstractAspect *)
void renameRequested(const QModelIndex &)
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QString m_filterString
AspectTreeModel(AbstractAspect *root, QObject *parent=nullptr)