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 LibraryEditorTab;
47class UndoStack;
48
49/*******************************************************************************
50 * Class LibraryEditor
51 ******************************************************************************/
52
56class LibraryEditor final : public QObject {
57 Q_OBJECT
58
59public:
60 // Signals
62
63 // Constructors / Destructor
64 LibraryEditor() = delete;
65 LibraryEditor(const LibraryEditor& other) = delete;
66 LibraryEditor(GuiApplication& app, std::unique_ptr<Library> lib, int uiIndex,
67 QObject* parent = nullptr) noexcept;
68 ~LibraryEditor() noexcept;
69
70 // General Methods
71 GuiApplication& getApp() noexcept { return mApp; }
72 Workspace& getWorkspace() noexcept { return mWorkspace; }
73 FilePath getFilePath() const noexcept;
74 Library& getLibrary() noexcept { return *mLibrary; }
75 UndoStack& getUndoStack() noexcept { return *mUndoStack; }
76 bool isWritable() const noexcept;
77 int getUiIndex() const noexcept { return mUiIndex; }
78 void setUiIndex(int index) noexcept;
79 ui::LibraryData getUiData() const noexcept;
80 void setUiData(const ui::LibraryData& data) noexcept;
81
94 bool requestClose() noexcept;
95
96 bool hasUnsavedChanges() const noexcept;
97
101 void setManualModificationsMade() noexcept;
102
108 bool save() noexcept;
109
110 void registerTab(LibraryEditorTab& tab) noexcept;
111 void unregisterTab(LibraryEditorTab& tab) noexcept;
112
113 void forceClosingTabs(const QSet<FilePath>& fp) noexcept;
114
115 // Operator Overloadings
116 LibraryEditor& operator=(const LibraryEditor& rhs) = delete;
117
118signals:
122
123private:
126 std::unique_ptr<Library> mLibrary;
129
132
134};
135
136/*******************************************************************************
137 * End of File
138 ******************************************************************************/
139
140} // namespace editor
141} // namespace librepcb
142
143#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:75
The LibraryEditor class.
Definition libraryeditor.h:56
bool save() noexcept
Save the library to the harddisc.
Definition libraryeditor.cpp:150
Signal< LibraryEditor > onUiDataChanged
Definition libraryeditor.h:61
std::unique_ptr< UndoStack > mUndoStack
Definition libraryeditor.h:128
QVector< QPointer< LibraryEditorTab > > mRegisteredTabs
Definition libraryeditor.h:133
Library & getLibrary() noexcept
Definition libraryeditor.h:74
bool mManualModificationsMade
Modifications bypassing the undo stack.
Definition libraryeditor.h:131
Workspace & getWorkspace() noexcept
Definition libraryeditor.h:72
void unregisterTab(LibraryEditorTab &tab) noexcept
Definition libraryeditor.cpp:172
UndoStack & getUndoStack() noexcept
Definition libraryeditor.h:75
int mUiIndex
Definition libraryeditor.h:127
void setManualModificationsMade() noexcept
Set the flag that manual modifications (no undo stack) are made.
Definition libraryeditor.cpp:143
GuiApplication & getApp() noexcept
Definition libraryeditor.h:71
ui::LibraryData getUiData() const noexcept
Definition libraryeditor.cpp:94
void setUiIndex(int index) noexcept
Definition libraryeditor.cpp:87
std::unique_ptr< Library > mLibrary
Definition libraryeditor.h:126
FilePath getFilePath() const noexcept
Definition libraryeditor.cpp:79
bool hasUnsavedChanges() const noexcept
Definition libraryeditor.cpp:139
int getUiIndex() const noexcept
Definition libraryeditor.h:77
void forceClosingTabs(const QSet< FilePath > &fp) noexcept
Definition libraryeditor.cpp:177
Workspace & mWorkspace
Definition libraryeditor.h:125
void registerTab(LibraryEditorTab &tab) noexcept
Definition libraryeditor.cpp:167
LibraryEditor(const LibraryEditor &other)=delete
bool requestClose() noexcept
Request to close the library.
Definition libraryeditor.cpp:107
bool isWritable() const noexcept
Definition libraryeditor.cpp:83
GuiApplication & mApp
Definition libraryeditor.h:124
void setUiData(const ui::LibraryData &data) noexcept
Definition libraryeditor.cpp:103
Specialized base class for all library editor tabs.
Definition libraryeditortab.h:55
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
Definition occmodel.cpp:77
Definition uuid.h:186