QElectroTech  0.70
projectview.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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 <QWidget>
22 
23 #include "templatelocation.h"
24 #include "qetresult.h"
25 
26 class QETProject;
27 class DiagramView;
28 class Diagram;
29 class ElementsLocation;
30 class QTabWidget;
31 class QLabel;
32 class QVBoxLayout;
33 
38 class ProjectView : public QWidget
39 {
40  Q_OBJECT
41 
42  // constructors, destructor
43  public:
44  ProjectView(QETProject *, QWidget * = nullptr);
45  ~ProjectView() override;
46  private:
47  ProjectView(const ProjectView &);
48 
49  // methods
50  public:
52  void setProject(QETProject *);
53  QList<DiagramView *> diagram_views() const;
54  DiagramView *currentDiagram() const;
55  void closeEvent(QCloseEvent *) override;
56  void changeTabUp();
57  void changeTabDown();
58  void changeFirstTab();
59  void changeLastTab();
60 
61  public slots:
62  void addNewDiagram();
64  void addDiagram(DiagramView *);
65  void removeDiagram(DiagramView *);
66  void removeDiagram(Diagram *);
67  void showDiagram(DiagramView *);
68  void showDiagram(Diagram *);
69  void editProjectProperties();
73  void moveDiagramUp(DiagramView *);
74  void moveDiagramUp(Diagram *);
76  void moveDiagramDown(Diagram *);
78  void moveDiagramUpTop(Diagram *);
80  void moveDiagramUpx10(Diagram *);
83  void printProject();
84  void exportProject();
85  QETResult save();
86  QETResult saveAs();
87  QETResult doSave();
88  int cleanProject();
89  void updateWindowTitle();
91  void updateAllTabsTitle();
92  void tabMoved(int, int);
93 
94  signals:
95  void diagramAdded(DiagramView *);
98  void projectClosed(ProjectView *);
99  void errorEncountered(const QString &);
100  // relayed signals
103 
104  private:
105  void initActions();
106  void initWidgets();
107  void initLayout();
108  void loadDiagrams();
114  void rebuildDiagramsMap();
115  bool tryClosing();
117  int tryClosingDiagrams();
118  QString askUserForFilePath(bool = true);
119  QETResult noProjectResult() const;
120 
121  private slots:
122  void tabChanged(int);
123  void tabDoubleClicked(int);
124  void setDisplayFallbackWidget(bool);
125  void adjustReadOnlyState();
126 
127  // attributes
128  private:
131  QVBoxLayout *layout_;
134  QTabWidget *m_tab;
135  QMap<int, DiagramView *> m_diagram_ids;
137  QList<DiagramView *> m_diagram_view_list;
138 };
139 
140 #endif
QETResult doSave()
void changeFirstTab()
change current diagramview to first tab
void diagramRemoved(DiagramView *)
void editProjectProperties()
void updateAllTabsTitle()
ProjectView::updateAllTabsTitle Update all tabs title.
void projectClosed(ProjectView *)
void changeTabDown()
change current diagramview to next folio
void rebuildDiagramsMap()
QList< DiagramView * > m_diagram_view_list
Definition: projectview.h:137
QETResult saveAs()
QETResult noProjectResult() const
void updateTabTitle(DiagramView *)
ProjectView::updateTabTitle Update the title of the tab which display the diagram view ...
void updateWindowTitle()
ProjectView::updateWindowTitle Update the project view title.
QETProject * m_project
Definition: projectview.h:130
void addNewDiagram()
ProjectView::addNewDiagram Add new diagram to project view.
void initActions()
void closeEvent(QCloseEvent *) override
void tabDoubleClicked(int)
void changeTabUp()
change current diagramview to previous tab
void initLayout()
void diagramActivated(DiagramView *)
DiagramView * firstDiagram()
void addNewDiagramFolioList()
ProjectView::addNewDiagramFolioList Add new diagram folio list to project.
void addDiagram(DiagramView *)
ProjectView::addDiagram Add diagram view to this project view.
int tryClosingDiagrams()
ProjectView::tryClosingDiagrams try to close this project, if diagram or project option are changed a...
void errorEncountered(const QString &)
QString askUserForFilePath(bool=true)
DiagramView * previousDiagram()
void setDisplayFallbackWidget(bool)
void exportProject()
void findElementRequired(const ElementsLocation &)
void moveDiagramUpTop(DiagramView *)
void setProject(QETProject *)
Definition: projectview.cpp:78
void adjustReadOnlyState()
DiagramView * nextDiagram()
void moveDiagramUpx10(DiagramView *)
void changeLastTab()
change current diagramview to last tab
QETResult save()
QWidget * fallback_widget_
Definition: projectview.h:132
DiagramView * currentDiagram() const
ProjectView::currentDiagram.
int cleanProject()
QETProject * project()
Definition: projectview.cpp:69
~ProjectView() override
Definition: projectview.cpp:58
void showDiagram(DiagramView *)
void loadDiagrams()
ProjectView::loadDiagrams Load diagrams of project. We create a diagram view for each diagram...
void initWidgets()
void removeDiagram(DiagramView *)
ProjectView::removeDiagram Remove a diagram (folio) of the project.
QList< DiagramView * > diagram_views() const
Definition: projectview.cpp:93
bool tryClosing()
QVBoxLayout * layout_
Definition: projectview.h:131
void printProject()
QTabWidget * m_tab
Definition: projectview.h:134
bool tryClosingElementEditors()
DiagramView * findDiagram(Diagram *)
void editCurrentDiagramProperties()
void editDiagramProperties(DiagramView *)
ProjectView(QETProject *, QWidget *=nullptr)
Definition: projectview.cpp:43
void moveDiagramUp(DiagramView *)
QLabel * fallback_label_
Definition: projectview.h:133
QMap< int, DiagramView * > m_diagram_ids
Definition: projectview.h:135
void editElementRequired(const ElementsLocation &)
DiagramView * lastDiagram()
void tabMoved(int, int)
QAction * add_new_diagram_
Definition: projectview.h:129
void moveDiagramDownx10(DiagramView *)
void diagramAdded(DiagramView *)
void tabChanged(int)
ProjectView::tabChanged Manage the tab change. If tab_id == -1 (there is no diagram opened)...
int m_previous_tab_index
Definition: projectview.h:136
void moveDiagramDown(DiagramView *)