LibrePCB Developers Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
filesystemmodel.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_FILESYSTEMMODEL_H
21#define LIBREPCB_EDITOR_FILESYSTEMMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class Workspace;
38
39namespace editor {
40
41class QuickAccessModel;
42
43/*******************************************************************************
44 * Class FileSystemModel
45 ******************************************************************************/
46
50class FileSystemModel : public QObject,
51 public slint::Model<ui::TreeViewItemData> {
52 Q_OBJECT
53
54public:
55 // Constructors / Destructor
56 FileSystemModel() = delete;
57 FileSystemModel(const FileSystemModel& other) = delete;
58 explicit FileSystemModel(const Workspace& ws, const FilePath& root,
59 const QString& settingsPrefix,
60 QuickAccessModel* quickAccessModel = nullptr,
61 QObject* parent = nullptr) noexcept;
62 virtual ~FileSystemModel() noexcept;
63
64 // Implementations
65 std::size_t row_count() const override;
66 std::optional<ui::TreeViewItemData> row_data(std::size_t i) const override;
67 void set_row_data(std::size_t i,
68 const ui::TreeViewItemData& data) noexcept override;
69
70 // Operator Overloadings
71 FileSystemModel& operator=(const FileSystemModel& rhs) = delete;
72
73signals:
74 void actionTriggered(const FilePath& fp, ui::Action a); // Internal signal.
75 void pinningRequested(const FilePath& fp, bool pin); // Internal signal.
76 void openFileTriggered(const FilePath& fp);
78
79private:
80 void expandDir(const FilePath& fp, std::size_t index, int level) noexcept;
81 void collapseDir(const FilePath& fp, std::size_t index, int level) noexcept;
82 void directoryChanged(const QString& dir) noexcept;
83 void favoriteProjectChanged(const FilePath& fp, bool favorite) noexcept;
84 void handleAction(const FilePath& fp, ui::Action a) noexcept;
85 void removeFileOrDirectory(const FilePath& fp) noexcept;
86
89 const QString mSettingsPrefix;
91 std::vector<ui::TreeViewItemData> mItems;
92 QFileSystemWatcher mWatcher;
94};
95
96/*******************************************************************************
97 * End of File
98 ******************************************************************************/
99
100} // namespace editor
101} // namespace librepcb
102
103#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The FileSystemModel class.
Definition filesystemmodel.h:51
QPointer< QuickAccessModel > mQuickAccess
Definition filesystemmodel.h:90
QSet< FilePath > mExpandedDirs
Definition filesystemmodel.h:93
void directoryChanged(const QString &dir) noexcept
Definition filesystemmodel.cpp:231
void expandDir(const FilePath &fp, std::size_t index, int level) noexcept
Definition filesystemmodel.cpp:140
std::optional< ui::TreeViewItemData > row_data(std::size_t i) const override
Definition filesystemmodel.cpp:110
FileSystemModel(const FileSystemModel &other)=delete
void openFileTriggered(const FilePath &fp)
void handleAction(const FilePath &fp, ui::Action a) noexcept
Definition filesystemmodel.cpp:264
void removeFileOrDirectory(const FilePath &fp) noexcept
Definition filesystemmodel.cpp:283
const QString mSettingsPrefix
Definition filesystemmodel.h:89
const Workspace & mWorkspace
Definition filesystemmodel.h:87
std::size_t row_count() const override
Definition filesystemmodel.cpp:106
void pinningRequested(const FilePath &fp, bool pin)
void newProjectTriggered(const FilePath &fp)
void collapseDir(const FilePath &fp, std::size_t index, int level) noexcept
Definition filesystemmodel.cpp:206
void set_row_data(std::size_t i, const ui::TreeViewItemData &data) noexcept override
Definition filesystemmodel.cpp:115
QFileSystemWatcher mWatcher
Definition filesystemmodel.h:92
void favoriteProjectChanged(const FilePath &fp, bool favorite) noexcept
Definition filesystemmodel.cpp:251
const FilePath mRoot
Definition filesystemmodel.h:88
void actionTriggered(const FilePath &fp, ui::Action a)
std::vector< ui::TreeViewItemData > mItems
Definition filesystemmodel.h:91
The QuickAccessModel class.
Definition quickaccessmodel.h:49
Definition occmodel.cpp:77
Definition uuid.h:186