LibrePCB Developers Documentation
recentprojectsmodel.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_RECENTPROJECTSMODEL_H
21 #define LIBREPCB_EDITOR_RECENTPROJECTSMODEL_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 RecentProjectsModel
42  ******************************************************************************/
43 
47 class RecentProjectsModel : public QAbstractListModel {
48  Q_OBJECT
49 
50 public:
51  // Constructors / Destructor
52  RecentProjectsModel() = delete;
53  RecentProjectsModel(const RecentProjectsModel& other) = delete;
54  explicit RecentProjectsModel(const Workspace& workspace) noexcept;
55  ~RecentProjectsModel() noexcept;
56 
57  // General Methods
58  void setLastRecentProject(const FilePath& filepath) noexcept;
59  void updateVisibleProjects() noexcept;
60 
61  // Operator Overloadings
63 
64 private:
65  void save() noexcept;
66  int rowCount(const QModelIndex& parent = QModelIndex()) const;
67  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
68 
69  // Attributes
72  QList<FilePath> mAllProjects;
73  QList<FilePath> mVisibleProjects;
74 };
75 
76 /*******************************************************************************
77  * End of File
78  ******************************************************************************/
79 
80 } // namespace editor
81 } // namespace librepcb
82 
83 #endif
~RecentProjectsModel() noexcept
Definition: recentprojectsmodel.cpp:62
Definition: occmodel.cpp:76
FilePath mFilePath
Definition: recentprojectsmodel.h:71
void setLastRecentProject(const FilePath &filepath) noexcept
Definition: recentprojectsmodel.cpp:69
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: recentprojectsmodel.cpp:115
QList< FilePath > mVisibleProjects
Definition: recentprojectsmodel.h:73
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: recentprojectsmodel.cpp:122
void save() noexcept
Definition: recentprojectsmodel.cpp:100
The RecentProjectsModel class.
Definition: recentprojectsmodel.h:47
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
const Workspace & mWorkspace
Definition: recentprojectsmodel.h:70
QList< FilePath > mAllProjects
Definition: recentprojectsmodel.h:72
void updateVisibleProjects() noexcept
Definition: recentprojectsmodel.cpp:83
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:54
RecentProjectsModel & operator=(const RecentProjectsModel &rhs)=delete