LibrePCB Developers Documentation
categorytreemodel.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_LIBRARY_CATEGORYTREEMODEL_H
21 #define LIBREPCB_LIBRARY_CATEGORYTREEMODEL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "categorytreeitem.h"
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 namespace librepcb {
34 namespace workspace {
35 
36 class WorkspaceLibraryDb;
37 
38 /*******************************************************************************
39  * Class CategoryTreeModel
40  ******************************************************************************/
41 
45 template <typename ElementType>
46 class CategoryTreeModel final : public QAbstractItemModel {
47 public:
48  // Constructors / Destructor
49  CategoryTreeModel() = delete;
50  CategoryTreeModel(const CategoryTreeModel& other) = delete;
51  explicit CategoryTreeModel(const WorkspaceLibraryDb& library,
52  const QStringList& localeOrder,
53  CategoryTreeFilter::Flags filter) noexcept;
54  ~CategoryTreeModel() noexcept;
55 
56  // Getters
57  CategoryTreeItem<ElementType>* getItem(const QModelIndex& index) const;
58 
59  // Inherited Methods
60  virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
61  virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
62  virtual QModelIndex index(int row, int column,
63  const QModelIndex& parent = QModelIndex()) const;
64  virtual QModelIndex parent(const QModelIndex& index) const;
65  virtual QVariant headerData(int section, Qt::Orientation orientation,
66  int role = Qt::DisplayRole) const;
67  virtual QVariant data(const QModelIndex& index,
68  int role = Qt::DisplayRole) const;
69 
70  // Operator Overloadings
71  CategoryTreeModel& operator=(const CategoryTreeModel& rhs) = delete;
72 
73 private:
74  // Attributes
75  QScopedPointer<CategoryTreeItem<ElementType>> mRootItem;
76 };
77 
81 
82 /*******************************************************************************
83  * End of File
84  ******************************************************************************/
85 
86 } // namespace workspace
87 } // namespace librepcb
88 
89 #endif // LIBREPCB_LIBRARY_CATEGORYTREEMODEL_H
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: categorytreemodel.cpp:81
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: categorytreemodel.cpp:114
virtual QModelIndex parent(const QModelIndex &index) const
Definition: categorytreemodel.cpp:101
CategoryTreeModel< library::ComponentCategory > ComponentCategoryTreeModel
Definition: categorytreemodel.h:79
Definition: alignment.cpp:30
QScopedPointer< CategoryTreeItem< ElementType > > mRootItem
Definition: categorytreemodel.h:75
The CategoryTreeModel class.
Definition: categorytreemodel.h:46
~CategoryTreeModel() noexcept
Definition: categorytreemodel.cpp:51
The CategoryTreeItem class.
Definition: categorytreeitem.h:67
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: categorytreemodel.cpp:87
CategoryTreeModel< library::PackageCategory > PackageCategoryTreeModel
Definition: categorytreemodel.h:80
The WorkspaceLibraryDb class.
Definition: workspacelibrarydb.h:52
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: categorytreemodel.cpp:74
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: categorytreemodel.cpp:127
CategoryTreeModel & operator=(const CategoryTreeModel &rhs)=delete
CategoryTreeItem< ElementType > * getItem(const QModelIndex &index) const
Definition: categorytreemodel.cpp:59