LibrePCB Developers Documentation
favoriteprojectsmodel.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_EDITOR_FAVORITEPROJECTSMODEL_H
21 #define LIBREPCB_EDITOR_FAVORITEPROJECTSMODEL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 namespace librepcb {
34 
35 class Version;
36 class Workspace;
37 
38 namespace editor {
39 
40 /*******************************************************************************
41  * Class FavoriteProjectsModel
42  ******************************************************************************/
43 
47 class FavoriteProjectsModel : public QAbstractListModel {
48  Q_OBJECT
49 
50 public:
51  // Constructors / Destructor
52  FavoriteProjectsModel() = delete;
53  FavoriteProjectsModel(const FavoriteProjectsModel& other) = delete;
54  explicit FavoriteProjectsModel(const Workspace& workspace) noexcept;
55  ~FavoriteProjectsModel() noexcept;
56 
57  // General Methods
58  bool isFavoriteProject(const FilePath& filepath) const noexcept;
59  void addFavoriteProject(const FilePath& filepath) noexcept;
60  void removeFavoriteProject(const FilePath& filepath) noexcept;
61  void updateVisibleProjects() noexcept;
62 
63  // Operator Overloadings
65 
66 private:
67  void save() noexcept;
68  int rowCount(const QModelIndex& parent = QModelIndex()) const;
69  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
70 
71  // Attributes
74  QList<FilePath> mAllProjects;
75  QList<FilePath> mVisibleProjects;
76 };
77 
78 /*******************************************************************************
79  * End of File
80  ******************************************************************************/
81 
82 } // namespace editor
83 } // namespace librepcb
84 
85 #endif
FavoriteProjectsModel & operator=(const FavoriteProjectsModel &rhs)=delete
const Workspace & mWorkspace
Definition: favoriteprojectsmodel.h:72
bool isFavoriteProject(const FilePath &filepath) const noexcept
Definition: favoriteprojectsmodel.cpp:70
Definition: occmodel.cpp:76
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: favoriteprojectsmodel.cpp:130
~FavoriteProjectsModel() noexcept
Definition: favoriteprojectsmodel.cpp:63
void save() noexcept
Definition: favoriteprojectsmodel.cpp:108
The FavoriteProjectsModel class.
Definition: favoriteprojectsmodel.h:47
QList< FilePath > mVisibleProjects
Definition: favoriteprojectsmodel.h:75
void removeFavoriteProject(const FilePath &filepath) noexcept
Definition: favoriteprojectsmodel.cpp:84
void updateVisibleProjects() noexcept
Definition: favoriteprojectsmodel.cpp:92
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: favoriteprojectsmodel.cpp:123
FilePath mFilePath
Definition: favoriteprojectsmodel.h:73
QList< FilePath > mAllProjects
Definition: favoriteprojectsmodel.h:74
void addFavoriteProject(const FilePath &filepath) noexcept
Definition: favoriteprojectsmodel.cpp:75
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:54