LibrePCB Developers Documentation
Loading...
Searching...
No Matches
libraryeditortab.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_LIBRARYEDITORTAB_H
21#define LIBREPCB_EDITOR_LIBRARYEDITORTAB_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../windowtab.h"
27
29
30#include <QtCore>
31
32#include <optional>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class SExpression;
40class TransactionalDirectory;
41
42namespace editor {
43
44class LibraryEditor;
45class RuleCheckMessagesModel;
46class UndoStack;
47
48/*******************************************************************************
49 * Class LibraryEditorTab
50 ******************************************************************************/
51
56 Q_OBJECT
57
58public:
59 // Constructors / Destructor
60 LibraryEditorTab() = delete;
61 LibraryEditorTab(const LibraryEditorTab& other) = delete;
62 explicit LibraryEditorTab(LibraryEditor& editor,
63 QObject* parent = nullptr) noexcept;
64 virtual ~LibraryEditorTab() noexcept;
65
66 // General Methods
67 virtual FilePath getDirectoryPath() const noexcept = 0;
68
69 // Operator Overloadings
70 LibraryEditorTab& operator=(const LibraryEditorTab& rhs) = delete;
71
72protected:
73 bool isPathOutsideLibDir() const noexcept;
74 bool hasUnsavedChanges() const noexcept;
76 const QSet<QString>& filenames) noexcept;
77 virtual void watchedFilesModifiedChanged() noexcept {}
78 virtual void reloadFromDisk() {}
79 void scheduleChecks() noexcept;
80 void runChecks() noexcept;
81 virtual std::optional<std::pair<RuleCheckMessageList, QSet<SExpression>>>
83 virtual bool autoFixImpl(const std::shared_ptr<const RuleCheckMessage>& msg,
84 bool checkOnly) = 0;
85 virtual void messageApprovalChanged(const SExpression& approval,
86 bool approved) noexcept = 0;
87 virtual void notifyDerivedUiDataChanged() noexcept = 0;
88 QString getWorkspaceSettingsUserName() const noexcept;
89
90private:
91 bool autoFixHandler(const std::shared_ptr<const RuleCheckMessage>& msg,
92 bool checkOnly) noexcept;
93 void watchedFileChanged(const QString& path) noexcept;
95
96protected:
98 std::unique_ptr<UndoStack> mUndoStack;
100
101 // Rule check
105 slint::SharedString mCheckError;
107
108 // Monitoring of file modifications
109 QFileSystemWatcher mFileSystemWatcher;
110 QHash<FilePath, QByteArray> mWatchedFileHashes;
114};
115
116/*******************************************************************************
117 * End of File
118 ******************************************************************************/
119
120} // namespace editor
121} // namespace librepcb
122
123#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The RuleCheckMessage class.
Definition rulecheckmessage.h:45
The SExpression class.
Definition sexpression.h:69
Helper class to access a subdirectory of TransactionalFileSystem.
Definition transactionaldirectory.h:51
The LibraryEditor class.
Definition libraryeditor.h:56
Specialized base class for all library editor tabs.
Definition libraryeditortab.h:55
virtual bool autoFixImpl(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly)=0
LibraryEditor & mEditor
Definition libraryeditortab.h:97
QFileSystemWatcher mFileSystemWatcher
Definition libraryeditortab.h:109
bool isPathOutsideLibDir() const noexcept
Definition libraryeditortab.cpp:99
virtual void notifyDerivedUiDataChanged() noexcept=0
QSet< SExpression > mDisappearedApprovals
Definition libraryeditortab.h:103
std::unique_ptr< UndoStack > mUndoStack
Definition libraryeditortab.h:98
bool mAutoReloadOnFileModifications
Set by derived classes.
Definition libraryeditortab.h:112
void setWatchedFiles(const TransactionalDirectory &dir, const QSet< QString > &filenames) noexcept
Definition libraryeditortab.cpp:109
LibraryEditorTab(const LibraryEditorTab &other)=delete
std::shared_ptr< RuleCheckMessagesModel > mCheckMessages
Definition libraryeditortab.h:104
void watchedFilesModifiedTimerElapsed() noexcept
Definition libraryeditortab.cpp:230
bool mManualModificationsMade
Definition libraryeditortab.h:99
QSet< SExpression > mSupportedApprovals
Definition libraryeditortab.h:102
virtual void messageApprovalChanged(const SExpression &approval, bool approved) noexcept=0
void runChecks() noexcept
Definition libraryeditortab.cpp:153
virtual FilePath getDirectoryPath() const noexcept=0
bool autoFixHandler(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly) noexcept
Definition libraryeditortab.cpp:190
QString getWorkspaceSettingsUserName() const noexcept
Definition libraryeditortab.cpp:175
QTimer mRuleCheckDelayTimer
Definition libraryeditortab.h:106
bool hasUnsavedChanges() const noexcept
Definition libraryeditortab.cpp:105
QSet< FilePath > mModifiedWatchedFiles
Modified, but not reloaded yet.
Definition libraryeditortab.h:111
virtual void reloadFromDisk()
Definition libraryeditortab.h:78
QHash< FilePath, QByteArray > mWatchedFileHashes
To detect modifications.
Definition libraryeditortab.h:110
void watchedFileChanged(const QString &path) noexcept
Definition libraryeditortab.cpp:203
virtual void watchedFilesModifiedChanged() noexcept
Definition libraryeditortab.h:77
void scheduleChecks() noexcept
Definition libraryeditortab.cpp:149
slint::SharedString mCheckError
Definition libraryeditortab.h:105
virtual std::optional< std::pair< RuleCheckMessageList, QSet< SExpression > > > runChecksImpl()=0
QTimer mWatchedFilesTimer
To delay/aggregate the notification & reload.
Definition libraryeditortab.h:113
The RuleCheckMessagesModel class.
Definition rulecheckmessagesmodel.h:46
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
The WindowTab class.
Definition windowtab.h:52
Definition occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition rulecheckmessage.h:104
Definition uuid.h:186