SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
projectTree.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
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#include <optional>
21
#include <span>
22
#include <string>
23
#include <string_view>
24
25
#include <QTreeWidget>
26
27
#include <
core/serialization/projectFile.hpp
>
28
29
namespace
SILICON::ui
{
30
32
enum class
ProjectTreeItemKind
{
Project
,
Section
,
Document
,
Architecture
};
33
34
struct
ProjectTreeDocumentSelection
{
35
project::DocumentType
type
;
36
std::string
path
;
37
};
38
40
class
ProjectTree
:
public
QTreeWidget {
41
Q_OBJECT
42
43
public
:
44
explicit
ProjectTree
(QWidget* parent =
nullptr
);
45
46
void
rebuild
(
const
project::ProjectInfo
&
project
,
47
std::span<const project::Document> documents,
48
std::string_view activeDocumentPath = {});
49
50
void
selectDocument
(std::string_view path);
51
void
clearDocumentSelection
();
52
53
[[nodiscard]] QTreeWidgetItem*
selectedProjectItem
()
const
;
54
[[nodiscard]] std::optional<ProjectTreeDocumentSelection>
selectedDocument
()
const
;
55
56
[[nodiscard]]
static
ProjectTreeItemKind
itemKind
(
const
QTreeWidgetItem* item);
57
[[nodiscard]]
static
std::optional<project::DocumentType>
58
itemDocumentType
(
const
QTreeWidgetItem* item);
59
[[nodiscard]]
static
std::optional<project::DocumentCategory>
60
itemDocumentCategory
(
const
QTreeWidgetItem* item);
61
[[nodiscard]]
static
std::string
documentPath
(
const
QTreeWidgetItem* item);
62
[[nodiscard]]
static
std::string
architectureName
(
const
QTreeWidgetItem* item);
63
64
private
:
65
void
addSection
(QTreeWidgetItem* projectItem,
project::DocumentCategory
category,
66
std::span<const project::Document> documents);
67
void
addDocument
(QTreeWidgetItem* parent,
const
project::Document
& document);
68
};
69
70
}
// namespace SILICON::ui
SILICON::project::Document
Definition
projectDocument.hpp:109
SILICON::ui::Document
Definition
projectDocument.hpp:109
SILICON::ui::ProjectTree::itemDocumentType
static std::optional< project::DocumentType > itemDocumentType(const QTreeWidgetItem *item)
Definition
projectTree.cpp:188
SILICON::ui::ProjectTree::architectureName
static std::string architectureName(const QTreeWidgetItem *item)
Definition
projectTree.cpp:210
SILICON::ui::ProjectTree::addSection
void addSection(QTreeWidgetItem *projectItem, project::DocumentCategory category, std::span< const project::Document > documents)
Definition
projectTree.cpp:217
SILICON::ui::ProjectTree::itemKind
static ProjectTreeItemKind itemKind(const QTreeWidgetItem *item)
Definition
projectTree.cpp:182
SILICON::ui::ProjectTree::rebuild
void rebuild(const project::ProjectInfo &project, std::span< const project::Document > documents, std::string_view activeDocumentPath={})
Definition
projectTree.cpp:97
SILICON::ui::ProjectTree::documentPath
static std::string documentPath(const QTreeWidgetItem *item)
Definition
projectTree.cpp:205
SILICON::ui::ProjectTree::selectDocument
void selectDocument(std::string_view path)
Definition
projectTree.cpp:121
SILICON::ui::ProjectTree::selectedProjectItem
QTreeWidgetItem * selectedProjectItem() const
Definition
projectTree.cpp:159
SILICON::ui::ProjectTree::addDocument
void addDocument(QTreeWidgetItem *parent, const project::Document &document)
Definition
projectTree.cpp:262
SILICON::ui::ProjectTree::clearDocumentSelection
void clearDocumentSelection()
Definition
projectTree.cpp:153
SILICON::ui::ProjectTree::itemDocumentCategory
static std::optional< project::DocumentCategory > itemDocumentCategory(const QTreeWidgetItem *item)
Definition
projectTree.cpp:197
SILICON::ui::ProjectTree::ProjectTree
ProjectTree(QWidget *parent=nullptr)
Definition
projectTree.cpp:89
SILICON::ui::ProjectTree::selectedDocument
std::optional< ProjectTreeDocumentSelection > selectedDocument() const
Definition
projectTree.cpp:165
SILICON::project
Definition
circuitDependencyGraph.cpp:30
SILICON::project::DocumentCategory
DocumentCategory
Definition
projectDocument.hpp:39
SILICON::project::DocumentType
DocumentType
Definition
projectDocument.hpp:37
SILICON::ui
Definition
actionGroups.hpp:14
SILICON::ui::ProjectTreeItemKind
ProjectTreeItemKind
Semantic role of an item shown in the project tree.
Definition
projectTree.hpp:32
SILICON::ui::ProjectTreeItemKind::Architecture
@ Architecture
Definition
projectTree.hpp:32
SILICON::ui::ProjectTreeItemKind::Project
@ Project
Definition
projectTree.hpp:32
SILICON::ui::ProjectTreeItemKind::Section
@ Section
Definition
projectTree.hpp:32
projectFile.hpp
SILICON::project::ProjectInfo
Project-level data stored in project.json.
Definition
projectFile.hpp:80
SILICON::ui::ProjectTreeDocumentSelection
Definition
projectTree.hpp:34
SILICON::ui::ProjectTreeDocumentSelection::path
std::string path
Definition
projectTree.hpp:36
SILICON::ui::ProjectTreeDocumentSelection::type
project::DocumentType type
Definition
projectTree.hpp:35
src
ui
project
projectTree.hpp
Generated by
1.17.0