QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
projectview.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef PROJECT_VIEW_H
19#define PROJECT_VIEW_H
20
21#include "qetresult.h"
23
24#include <QCloseEvent>
25#include <QTabBar>
26#include <QWidget>
27#include <QtWidgets>
28
29#ifdef Q_OS_MACOS
30
31class WheelEnabledTabBar : public QTabWidget
32{
33public:
34 WheelEnabledTabBar(QWidget *parent = nullptr)
35 : QTabWidget(parent)
36 {}
37
38 double temp_index = 0;
39
40 void wheelEvent(QWheelEvent *event) override
41 {
42 int index = currentIndex();
43 double delta = 0;
44 double scale_factor = 0.005; // Decrease or increase speed of mouse wheel (0.04 = decrease)
45 if (event->modifiers() & Qt::ControlModifier) {
46 if (index != -1) {
47 delta = event->delta() * scale_factor; // Read and scale the scroll value
48 if (delta > 0 && (temp_index > -1)) temp_index = temp_index - abs(delta);
49 if (delta < 0 && (temp_index < count())) temp_index = temp_index + abs(delta);
50
51 index = int (temp_index);
52 qDebug() << "index" << index << "temp_index" << temp_index << " " << event->delta() << delta;
53
54 if (index >= 0 && index < count())
55 setCurrentIndex(index);
56
57 // qDebug() << currentIndex();
58 }
59 }
60 }
61};
62#endif
63
64
65class QETProject;
66class DiagramView;
67class Diagram;
69class QTabWidget;
70class QLabel;
71class QVBoxLayout;
72
73
79class ProjectView : public QWidget
80{
81 Q_OBJECT
82
83 // constructors, destructor
84 public:
85 ProjectView(QETProject *, QWidget * = nullptr);
86 ~ProjectView() override;
87 private:
89
90 //Method related to construction of this class
92
93
94
95 // methods
96 public:
98 QList<DiagramView *> diagram_views() const;
100 void closeEvent(QCloseEvent *) override;
101 void changeTabUp();
102 void changeTabDown();
103 void changeFirstTab();
104 void changeLastTab();
105
106 public slots:
108 void removeDiagram(Diagram *);
109 void showDiagram(DiagramView *);
110 void showDiagram(Diagram *);
116 void moveDiagramUp(Diagram *);
118 void moveDiagramDown(Diagram *);
125 void exportProject();
126 QETResult save();
129 int cleanProject();
130 void updateWindowTitle();
132 void updateAllTabsTitle();
133 void tabMoved(int, int);
134
135 signals:
140 void errorEncountered(const QString &);
141 // relayed signals
143
144 private:
145 void initActions();
146 void initWidgets();
147 void initLayout();
148 void loadDiagrams();
154 void rebuildDiagramsMap();
155 bool tryClosing();
157 int tryClosingDiagrams();
158 QString askUserForFilePath(bool = true);
160
161 private slots:
162 void tabChanged(int);
163 void tabDoubleClicked(int);
164 void setDisplayFallbackWidget(bool);
165 void adjustReadOnlyState();
166 void diagramAdded(Diagram *diagram);
167
168 // attributes
169 private:
174 QVBoxLayout *layout_;
177
178#ifdef Q_OS_MACOS
179 WheelEnabledTabBar *m_tab;
180#else
181 QTabWidget *m_tab;
182#endif
183
184 QMap<int, DiagramView *> m_diagram_ids;
186 QList<DiagramView *> m_diagram_view_list;
187};
188
189
190#endif
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:56
Definition diagramview.h:39
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition elementslocation.h:47
The ProjectView class This class provides a widget displaying the diagrams of a particular project us...
Definition projectview.h:80
DiagramView * firstDiagram()
Definition projectview.cpp:209
void updateTabTitle(DiagramView *)
ProjectView::updateTabTitle Update the title of the tab which display the diagram view.
Definition projectview.cpp:917
QList< DiagramView * > m_diagram_view_list
Definition projectview.h:186
void removeDiagram(DiagramView *)
ProjectView::removeDiagram Remove a diagram (folio) of the project.
Definition projectview.cpp:371
QAction * m_add_new_diagram
Definition projectview.h:170
void closeEvent(QCloseEvent *) override
Definition projectview.cpp:120
void rebuildDiagramsMap()
Definition projectview.cpp:992
ProjectView(const ProjectView &)
void adjustReadOnlyState()
Definition projectview.cpp:871
~ProjectView() override
Definition projectview.cpp:57
void setDisplayFallbackWidget(bool)
Definition projectview.cpp:1047
QList< DiagramView * > diagram_views() const
Definition projectview.cpp:99
QLabel * fallback_label_
Definition projectview.h:176
int tryClosingDiagrams()
ProjectView::tryClosingDiagrams try to close this project, if diagram or project option are changed a...
Definition projectview.cpp:298
DiagramView * currentDiagram() const
ProjectView::currentDiagram.
Definition projectview.cpp:108
DiagramView * findDiagram(Diagram *)
Definition projectview.cpp:980
void editCurrentDiagramProperties()
Definition projectview.cpp:453
void moveDiagramDown(DiagramView *)
Definition projectview.cpp:498
void moveDiagramDownx10(DiagramView *)
Definition projectview.cpp:563
void changeFirstTab()
change current diagramview to first tab
Definition projectview.cpp:200
void editProjectProperties()
Definition projectview.cpp:443
void moveDiagramUp(DiagramView *)
Definition projectview.cpp:477
void setProject(QETProject *project)
ProjectView::setProject Set the project display by the project view.
Definition projectview.cpp:76
void diagramActivated(DiagramView *)
QMap< int, DiagramView * > m_diagram_ids
Definition projectview.h:184
void updateWindowTitle()
ProjectView::updateWindowTitle Update the project view title.
Definition projectview.cpp:856
QVBoxLayout * layout_
Definition projectview.h:174
QWidget * fallback_widget_
Definition projectview.h:175
void moveDiagramUpx10(DiagramView *)
Definition projectview.cpp:542
void changeTabDown()
change current diagramview to next folio
Definition projectview.cpp:133
bool tryClosing()
Definition projectview.cpp:223
int cleanProject()
Definition projectview.cpp:653
DiagramView * nextDiagram()
Definition projectview.cpp:145
void showDiagram(DiagramView *)
Definition projectview.cpp:423
void diagramAdded(DiagramView *)
void changeTabUp()
change current diagramview to previous tab
Definition projectview.cpp:158
void initActions()
Definition projectview.cpp:714
DiagramView * previousDiagram()
Definition projectview.cpp:170
void initLayout()
Definition projectview.cpp:787
bool tryClosingElementEditors()
Definition projectview.cpp:273
void loadDiagrams()
ProjectView::loadDiagrams Load diagrams of project. We create a diagram view for each diagram,...
Definition projectview.cpp:810
void errorEncountered(const QString &)
void exportProject()
Definition projectview.cpp:584
QTabWidget * m_tab
Definition projectview.h:181
QETResult save()
Definition projectview.cpp:601
QETProject * project()
Definition projectview.cpp:66
void projectClosed(ProjectView *)
void tabMoved(int, int)
Definition projectview.cpp:959
void editDiagramProperties(DiagramView *)
Definition projectview.cpp:461
void moveDiagramUpTop(DiagramView *)
Definition projectview.cpp:519
DiagramView * lastDiagram()
Definition projectview.cpp:192
void updateAllTabsTitle()
ProjectView::updateAllTabsTitle Update all tabs title.
Definition projectview.cpp:949
void tabChanged(int)
ProjectView::tabChanged Manage the tab change. If tab_id == -1 (there is no diagram opened),...
Definition projectview.cpp:1011
void tabDoubleClicked(int)
Definition projectview.cpp:1033
void initWidgets()
Definition projectview.cpp:729
QETProject * m_project
Definition projectview.h:173
QETResult doSave()
Definition projectview.cpp:628
QETResult saveAs()
Definition projectview.cpp:613
int m_previous_tab_index
Definition projectview.h:185
void changeLastTab()
change current diagramview to last tab
Definition projectview.cpp:183
QAction * m_first_view
Definition projectview.h:171
void diagramRemoved(DiagramView *)
QString askUserForFilePath(bool=true)
Definition projectview.cpp:330
void findElementRequired(const ElementsLocation &)
QETResult noProjectResult() const
Definition projectview.cpp:360
QAction * m_end_view
Definition projectview.h:172
Definition qetproject.h:62
Definition qetresult.h:26