SILICON
Loading...
Searching...
No Matches
projectDocumentController.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 */
9
10#pragma once
11
12#include <optional>
13#include <string>
14#include <vector>
15
16#include <QObject>
17#include <QString>
18
21#include <ui/shell/uiUtils.hpp>
22
23class QWidget;
24class QUndoStack;
25class QPoint;
26
27namespace SILICON::ui {
28
30class EditorWorkspace;
31struct ProjectSession;
32class ProjectTree;
33
35class ProjectDocumentController : public QObject, public DocumentNavigator {
36 Q_OBJECT
37
38public:
41 QUndoStack& undoStack, QWidget* dialogParent);
42
43 [[nodiscard]] const std::string& currentDocumentPath() const noexcept override;
44 bool activateDocument(const std::string& path) override;
45 bool switchToDocument(const std::string& path, bool selectInTree);
46 void selectDocument(const std::string& path);
47 void rebuildTree();
48
56
57 void restoreProjectDocuments(const std::vector<SILICON::project::Document>& documents,
58 const std::string& activePath);
59 void removeDocument(const std::string& path);
61 std::optional<std::ptrdiff_t> insertAt, bool activate);
62 void showArchitectureTabContextMenu(const QPoint& position);
63 void createCircuit();
64 void createCodeFile();
65 void createBinaryFile();
66 void createArchitecture();
72
73signals:
83 void activeDocumentChanged(const QString& path,
85
89
90private:
93 const QString& commandText);
94 void pushDocumentSnapshotCommand(QString commandText,
95 std::vector<SILICON::project::Document> before,
96 std::string beforeActive,
97 std::vector<SILICON::project::Document> after,
98 std::string afterActive);
99 void renameArchitecture(const std::string& name);
100 void deleteArchitecture(const std::string& name);
101 void deleteArchitectureComponent(const std::string& path);
102 void removeProjectDocuments(const std::vector<std::string>& paths,
103 const QString& commandText);
104 void commitDocumentChanges(std::vector<SILICON::project::Document> documents,
105 const std::string& sourcePath,
106 const std::string& activatePath, const QString& commandText,
107 const QString& errorTitle);
109
111 void reportLoadFailure(SILICON::project::DocumentType type, const std::string& reason);
112
117 QUndoStack* undoStack;
118 QWidget* dialogParent;
119};
120
121} // namespace SILICON::ui
Selects and hosts editors while preserving detached document preparation.
void notifyActiveDocumentActivated()
Publishes the active document to observers.
void pushCreateDocumentCommand(SILICON::project::Document document, const QString &commandText)
ProjectDocumentController(ProjectSession &session, EditorWorkspace &workspace, ProjectTree &tree, ComponentCatalogOverlay &catalog, QUndoStack &undoStack, QWidget *dialogParent)
const std::string & currentDocumentPath() const noexcept override
void insertDocument(SILICON::project::Document document, std::optional< std::ptrdiff_t > insertAt, bool activate)
void showArchitectureTabContextMenu(const QPoint &position)
void reportLoadFailure(SILICON::project::DocumentType type, const std::string &reason)
Reports a rejected document activation to the user.
void pushDocumentSnapshotCommand(QString commandText, std::vector< SILICON::project::Document > before, std::string beforeActive, std::vector< SILICON::project::Document > after, std::string afterActive)
void convertActiveDocumentTo(SILICON::project::DocumentType target)
void createDocument(SILICON::project::DocumentType type)
bool switchToDocument(const std::string &path, bool selectInTree)
void commitDocumentChanges(std::vector< SILICON::project::Document > documents, const std::string &sourcePath, const std::string &activatePath, const QString &commandText, const QString &errorTitle)
void projectDocumentsChanged()
Emitted when the set of project documents was added to, changed, or removed.
void activeDocumentChanged(const QString &path, SILICON::project::DocumentCategory category)
Emitted after a document was loaded and made visible.
bool activateDocument(const std::string &path) override
void deleteArchitectureComponent(const std::string &path)
void restoreProjectDocuments(const std::vector< SILICON::project::Document > &documents, const std::string &activePath)
void removeProjectDocuments(const std::vector< std::string > &paths, const QString &commandText)
Project document navigator used by the SILICON editor.