LibrePCB Developers Documentation
Loading...
Searching...
No Matches
libraryeditor.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_LIBRARYEDITOR_H
21#define LIBREPCB_EDITOR_LIBRARYEDITOR_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27
30
31#include <QtCore>
32
33#include <memory>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class Library;
41class Workspace;
42
43namespace editor {
44
45class GuiApplication;
46class LibraryEditorLegacy;
47class LibraryEditorTab;
48class UndoStack;
49
50/*******************************************************************************
51 * Class LibraryEditor
52 ******************************************************************************/
53
57class LibraryEditor final : public QObject {
58 Q_OBJECT
59
60public:
61 // Signals
63
64 // Constructors / Destructor
65 LibraryEditor() = delete;
66 LibraryEditor(const LibraryEditor& other) = delete;
67 LibraryEditor(GuiApplication& app, std::unique_ptr<Library> lib, int uiIndex,
68 QObject* parent = nullptr) noexcept;
69 ~LibraryEditor() noexcept;
70
71 // General Methods
72 GuiApplication& getApp() noexcept { return mApp; }
73 Workspace& getWorkspace() noexcept { return mWorkspace; }
74 FilePath getFilePath() const noexcept;
75 Library& getLibrary() noexcept { return *mLibrary; }
76 UndoStack& getUndoStack() noexcept { return *mUndoStack; }
77 bool isWritable() const noexcept;
78 int getUiIndex() const noexcept { return mUiIndex; }
79 void setUiIndex(int index) noexcept;
80 ui::LibraryData getUiData() const noexcept;
81 void setUiData(const ui::LibraryData& data) noexcept;
82
95 bool requestClose() noexcept;
96
97 bool hasUnsavedChanges() const noexcept;
98
102 void setManualModificationsMade() noexcept;
103
109 bool save() noexcept;
110
111 void registerTab(LibraryEditorTab& tab) noexcept;
112 void unregisterTab(LibraryEditorTab& tab) noexcept;
113
114 void forceClosingTabs(const QSet<FilePath>& fp) noexcept;
115
116 // Legacy editors
117 void openLegacyPackageEditor(const FilePath& fp) noexcept;
118 void openLegacyComponentEditor(const FilePath& fp) noexcept;
119 void openLegacyDeviceEditor(const FilePath& fp) noexcept;
120 void duplicateInLegacyPackageEditor(const FilePath& fp) noexcept;
121 void duplicateInLegacyComponentEditor(const FilePath& fp) noexcept;
122 void duplicateInLegacyDeviceEditor(const FilePath& fp) noexcept;
123
124 // Operator Overloadings
125 LibraryEditor& operator=(const LibraryEditor& rhs) = delete;
126
127signals:
131
132private:
135 std::unique_ptr<Library> mLibrary;
138
141
143
145};
146
147/*******************************************************************************
148 * End of File
149 ******************************************************************************/
150
151} // namespace editor
152} // namespace librepcb
153
154#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The Library class represents a library directory.
Definition library.h:46
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The GuiApplication class.
Definition guiapplication.h:61
The LibraryEditor class.
Definition libraryeditor.h:57
bool save() noexcept
Save the library to the harddisc.
Definition libraryeditor.cpp:158
Signal< LibraryEditor > onUiDataChanged
Definition libraryeditor.h:62
std::unique_ptr< UndoStack > mUndoStack
Definition libraryeditor.h:137
void duplicateInLegacyPackageEditor(const FilePath &fp) noexcept
Definition libraryeditor.cpp:216
QVector< QPointer< LibraryEditorTab > > mRegisteredTabs
Definition libraryeditor.h:142
Library & getLibrary() noexcept
Definition libraryeditor.h:75
bool mManualModificationsMade
Modifications bypassing the undo stack.
Definition libraryeditor.h:140
void openLegacyPackageEditor(const FilePath &fp) noexcept
Definition libraryeditor.cpp:195
Workspace & getWorkspace() noexcept
Definition libraryeditor.h:73
void unregisterTab(LibraryEditorTab &tab) noexcept
Definition libraryeditor.cpp:180
UndoStack & getUndoStack() noexcept
Definition libraryeditor.h:76
int mUiIndex
Definition libraryeditor.h:136
void setManualModificationsMade() noexcept
Set the flag that manual modifications (no undo stack) are made.
Definition libraryeditor.cpp:151
void openLegacyDeviceEditor(const FilePath &fp) noexcept
Definition libraryeditor.cpp:209
GuiApplication & getApp() noexcept
Definition libraryeditor.h:72
ui::LibraryData getUiData() const noexcept
Definition libraryeditor.cpp:97
void setUiIndex(int index) noexcept
Definition libraryeditor.cpp:90
std::unique_ptr< LibraryEditorLegacy > mLegacyEditor
Definition libraryeditor.h:144
std::unique_ptr< Library > mLibrary
Definition libraryeditor.h:135
FilePath getFilePath() const noexcept
Definition libraryeditor.cpp:82
bool hasUnsavedChanges() const noexcept
Definition libraryeditor.cpp:147
int getUiIndex() const noexcept
Definition libraryeditor.h:78
void forceClosingTabs(const QSet< FilePath > &fp) noexcept
Definition libraryeditor.cpp:185
Workspace & mWorkspace
Definition libraryeditor.h:134
void registerTab(LibraryEditorTab &tab) noexcept
Definition libraryeditor.cpp:175
LibraryEditor(const LibraryEditor &other)=delete
void duplicateInLegacyDeviceEditor(const FilePath &fp) noexcept
Definition libraryeditor.cpp:232
bool requestClose() noexcept
Request to close the library.
Definition libraryeditor.cpp:110
bool isWritable() const noexcept
Definition libraryeditor.cpp:86
void openLegacyComponentEditor(const FilePath &fp) noexcept
Definition libraryeditor.cpp:202
void duplicateInLegacyComponentEditor(const FilePath &fp) noexcept
Definition libraryeditor.cpp:224
GuiApplication & mApp
Definition libraryeditor.h:133
void setUiData(const ui::LibraryData &data) noexcept
Definition libraryeditor.cpp:106
The LibraryEditorLegacy class.
Definition libraryeditorlegacy.h:63
Specialized base class for all library editor tabs.
Definition libraryeditortab.h:54
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
Definition occmodel.cpp:77
Definition uuid.h:186