LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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 openFileTriggered(const FilePath& fp);
76
77private:
78 void expandDir(const FilePath& fp, std::size_t index, int level) noexcept;
79 void collapseDir(const FilePath& fp, std::size_t index, int level) noexcept;
80 void directoryChanged(const QString& dir) noexcept;
81 void favoriteProjectChanged(const FilePath& fp, bool favorite) noexcept;
82 void trigger(const FilePath& fp, ui::TreeViewItemAction a) noexcept;
83 void removeFileOrDirectory(const FilePath& fp) noexcept;
84
87 const QString mSettingsPrefix;
89 std::vector<ui::TreeViewItemData> mItems;
90 QFileSystemWatcher mWatcher;
92};
93
94/*******************************************************************************
95 * End of File
96 ******************************************************************************/
97
98} // namespace editor
99} // namespace librepcb
100
101#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:88
QSet< FilePath > mExpandedDirs
Definition filesystemmodel.h:91
void directoryChanged(const QString &dir) noexcept
Definition filesystemmodel.cpp:237
void expandDir(const FilePath &fp, std::size_t index, int level) noexcept
Definition filesystemmodel.cpp:146
std::optional< ui::TreeViewItemData > row_data(std::size_t i) const override
Definition filesystemmodel.cpp:104
FileSystemModel(const FileSystemModel &other)=delete
void openFileTriggered(const FilePath &fp)
void removeFileOrDirectory(const FilePath &fp) noexcept
Definition filesystemmodel.cpp:290
const QString mSettingsPrefix
Definition filesystemmodel.h:87
const Workspace & mWorkspace
Definition filesystemmodel.h:85
std::size_t row_count() const override
Definition filesystemmodel.cpp:100
void newProjectTriggered(const FilePath &fp)
void collapseDir(const FilePath &fp, std::size_t index, int level) noexcept
Definition filesystemmodel.cpp:212
void set_row_data(std::size_t i, const ui::TreeViewItemData &data) noexcept override
Definition filesystemmodel.cpp:109
QFileSystemWatcher mWatcher
Definition filesystemmodel.h:90
void favoriteProjectChanged(const FilePath &fp, bool favorite) noexcept
Definition filesystemmodel.cpp:257
const FilePath mRoot
Definition filesystemmodel.h:86
std::vector< ui::TreeViewItemData > mItems
Definition filesystemmodel.h:89
void trigger(const FilePath &fp, ui::TreeViewItemAction a) noexcept
Definition filesystemmodel.cpp:270
The QuickAccessModel class.
Definition quickaccessmodel.h:49
Definition occmodel.cpp:77
Definition uuid.h:186