Debian Codegraph @

avogadro/qtgui/layermodel.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_QTGUI_LAYERMODEL_H
7 #define AVOGADRO_QTGUI_LAYERMODEL_H
8
9 #include "avogadroqtguiexport.h"
10 #include "rwlayermanager.h"
11
12 #include <Eigen/Geometry>
13 #include <QtCore/QAbstractItemModel>
14 #include <QtGui/QIcon>
15
16 namespace Avogadro {
17 namespace QtGui {
18
19 class Molecule;
20 class RWMolecule;
21
22 /**
23 * @class LayerModel layermodel.h <avogadro/qtgui/layermodel.h>
24 * @brief UI for the layer dock.
25 */
26 class AVOGADROQTGUI_EXPORT LayerModel : public QAbstractItemModel,
27 public QtGui::RWLayerManager
28 {
29 Q_OBJECT
30 public:
31 enum ColumnType
32 {
33 Name = 0,
34 Menu = 1,
35 Visible = 2,
36 Lock = 3,
37 Remove = 5
38 };
39
40 explicit LayerModel(QObject* p = nullptr);
41
42 void loadIcons(bool darkMode);
43
44 QModelIndex parent(const QModelIndex& child) const override;
45 int rowCount(const QModelIndex& parent) const override;
46 int columnCount(const QModelIndex& parent) const override;
47
48 Qt::ItemFlags flags(const QModelIndex& index) const override;
49
50 bool setData(const QModelIndex& index, const QVariant& value,
51 int role) override;
52 QVariant data(const QModelIndex& index, int role) const override;
53
54 QModelIndex index(int row, int column,
55 const QModelIndex& parent = QModelIndex()) const override;
56
57 void addItem();
58 void addLayer(RWMolecule* rwmolecule);
59 void addMolecule(const Molecule* mol);
60 void setActiveLayer(int index, RWMolecule* rwmolecule);
61 void removeItem(int row, RWMolecule* rwmolecule);
62
63 size_t items() const;
64
65 void flipVisible(size_t row);
66 void flipLocked(size_t row);
67 size_t layerCount() const;
68
69 public slots:
70 void updateRows();
71
72 private:
73 QString getTranslatedName(const std::string& name) const;
74 size_t m_item;
75
76 QIcon m_plusIcon;
77 QIcon m_dotsIcon;
78 QIcon m_previewIcon;
79 QIcon m_previewDashedIcon;
80 QIcon m_lockIcon;
81 QIcon m_openLockIcon;
82 QIcon m_removeIcon;
83 };
84
85 } // namespace QtGui
86 } // namespace Avogadro
87
88 #endif // AVOGADRO_QTGUI_LAYERMODEL_H