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;
40
41namespace editor {
42
43class LibraryEditor;
44class RuleCheckMessagesModel;
45class UndoStack;
46
47/*******************************************************************************
48 * Class LibraryEditorTab
49 ******************************************************************************/
50
55 Q_OBJECT
56
57public:
58 // Constructors / Destructor
59 LibraryEditorTab() = delete;
60 LibraryEditorTab(const LibraryEditorTab& other) = delete;
61 explicit LibraryEditorTab(LibraryEditor& editor,
62 QObject* parent = nullptr) noexcept;
63 virtual ~LibraryEditorTab() noexcept;
64
65 // General Methods
66 virtual FilePath getDirectoryPath() const noexcept = 0;
67
68 // Operator Overloadings
69 LibraryEditorTab& operator=(const LibraryEditorTab& rhs) = delete;
70
71protected:
72 bool isPathOutsideLibDir() const noexcept;
73 bool hasUnsavedChanges() const noexcept;
74 void scheduleChecks() noexcept;
75 void runChecks() noexcept;
76 virtual std::optional<std::pair<RuleCheckMessageList, QSet<SExpression>>>
78 virtual bool autoFixImpl(const std::shared_ptr<const RuleCheckMessage>& msg,
79 bool checkOnly) = 0;
80 virtual void messageApprovalChanged(const SExpression& approval,
81 bool approved) noexcept = 0;
82 virtual void notifyDerivedUiDataChanged() noexcept = 0;
83 QString getWorkspaceSettingsUserName() const noexcept;
84
85private:
86 bool autoFixHandler(const std::shared_ptr<const RuleCheckMessage>& msg,
87 bool checkOnly) noexcept;
88
89protected:
91 std::unique_ptr<UndoStack> mUndoStack;
93
94 // Rule check
98 slint::SharedString mCheckError;
100};
101
102/*******************************************************************************
103 * End of File
104 ******************************************************************************/
105
106} // namespace editor
107} // namespace librepcb
108
109#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
The LibraryEditor class.
Definition libraryeditor.h:57
Specialized base class for all library editor tabs.
Definition libraryeditortab.h:54
virtual bool autoFixImpl(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly)=0
LibraryEditor & mEditor
Definition libraryeditortab.h:90
bool isPathOutsideLibDir() const noexcept
Definition libraryeditortab.cpp:89
virtual void notifyDerivedUiDataChanged() noexcept=0
QSet< SExpression > mDisappearedApprovals
Definition libraryeditortab.h:96
std::unique_ptr< UndoStack > mUndoStack
Definition libraryeditortab.h:91
LibraryEditorTab(const LibraryEditorTab &other)=delete
std::shared_ptr< RuleCheckMessagesModel > mCheckMessages
Definition libraryeditortab.h:97
bool mManualModificationsMade
Definition libraryeditortab.h:92
QSet< SExpression > mSupportedApprovals
Definition libraryeditortab.h:95
virtual void messageApprovalChanged(const SExpression &approval, bool approved) noexcept=0
void runChecks() noexcept
Definition libraryeditortab.cpp:103
virtual FilePath getDirectoryPath() const noexcept=0
bool autoFixHandler(const std::shared_ptr< const RuleCheckMessage > &msg, bool checkOnly) noexcept
Definition libraryeditortab.cpp:140
QString getWorkspaceSettingsUserName() const noexcept
Definition libraryeditortab.cpp:125
QTimer mRuleCheckDelayTimer
Definition libraryeditortab.h:99
bool hasUnsavedChanges() const noexcept
Definition libraryeditortab.cpp:95
void scheduleChecks() noexcept
Definition libraryeditortab.cpp:99
slint::SharedString mCheckError
Definition libraryeditortab.h:98
virtual std::optional< std::pair< RuleCheckMessageList, QSet< SExpression > > > runChecksImpl()=0
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:51
Definition occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition rulecheckmessage.h:104
Definition uuid.h:186