QElectroTech  0.8-dev
projectdatabase.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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 PROJECTDATABASE_H
19 #define PROJECTDATABASE_H
20 
21 #include <QObject>
22 #include <QSqlDatabase>
23 #include <QSqlQuery>
24 #include <QPointer>
25 #include <QFileDialog>
26 
27 class Element;
28 class QETProject;
29 class Diagram;
30 
38 class projectDataBase : public QObject
39 {
40  Q_OBJECT
41 
42  public:
43  projectDataBase(QETProject *project, QObject *parent = nullptr);
44  private:
46  const QString &connection_name,
47  const QString &path,
48  QObject *parent = nullptr);
49  public:
50  virtual ~projectDataBase() override;
51 
52  void updateDB();
53  QETProject *project() const;
54  QSqlQuery newQuery(const QString &query = QString());
55  void addElement(Element *element);
56  void removeElement(Element *element);
57  void elementInfoChanged(Element *element);
58  void addDiagram(Diagram *diagram);
59  void removeDiagram(Diagram *diagram);
60 
61  signals:
63 
64  private:
65  bool createDataBase(const QString &connection_name= QString(),
66  const QString &name = QString());
68  void createSummaryView();
69  void populateDiagramTable();
70  void populateElementTable();
73  void prepareQuery();
74  static QHash<QString, QString> elementInfoToString(
75  Element *elmt);
76 
77  private:
78  QPointer<QETProject> m_project;
79  QSqlDatabase m_data_base;
87 
88  public:
89  static void exportDb(projectDataBase *db,
90  QWidget *parent = nullptr,
91  const QString &caption = QString(),
92  const QString &dir = QString());
93 };
94 
95 #endif // PROJECTDATABASE_H
Element::Terminale
@ Terminale
Definition: element.h:57
projectDataBase::project
QETProject * project() const
projectDataBase::project
Definition: projectdatabase.cpp:74
projectDataBase::newQuery
QSqlQuery newQuery(const QString &query=QString())
projectDataBase::newQuery
Definition: projectdatabase.cpp:83
projectDataBase::~projectDataBase
virtual ~projectDataBase() override
projectDataBase::~projectDataBase Destructor
Definition: projectdatabase.cpp:52
projectDataBase::createDataBase
bool createDataBase(const QString &connection_name=QString(), const QString &name=QString())
projectDataBase::createDataBase Create the data base
Definition: projectdatabase.cpp:194
BorderTitleBlock::titleblockInformation
DiagramContext titleblockInformation() const
BorderTitleBlock::titleblockInformation.
Definition: bordertitleblock.cpp:99
ElementProvider
Definition: elementprovider.h:37
Element::elementInformations
DiagramContext elementInformations() const
Definition: element.h:97
QetGraphicsItem::diagram
Diagram * diagram() const
Definition: qetgraphicsitem.cpp:40
projectDataBase::populateDiagramInfoTable
void populateDiagramInfoTable()
Definition: projectdatabase.cpp:426
Element::uuid
QUuid uuid() const
Element::uuid.
Definition: element.h:250
projectDataBase::m_project
QPointer< QETProject > m_project
Definition: projectdatabase.h:78
Element::linkTypeToString
QString linkTypeToString() const
Definition: element.cpp:1520
diagramposition.h
ElementProvider::find
QList< Element * > find(const int filter) const
ElementProvider::find Search and return the asked element corresponding with the given filter.
Definition: elementprovider.cpp:96
Element::actualLabel
QString actualLabel()
Element::actualLabel Always return the current label to be displayed. This function is usefull when l...
Definition: element.cpp:1738
QETApp::elementInfoKeys
static QStringList elementInfoKeys()
QETApp::elementInfoKeys.
Definition: qetapp.cpp:366
projectDataBase::m_insert_elements_query
QSqlQuery m_insert_elements_query
Definition: projectdatabase.h:80
Element::Simple
@ Simple
Definition: element.h:51
projectDataBase::m_insert_element_info_query
QSqlQuery m_insert_element_info_query
Definition: projectdatabase.h:81
Diagram::border_and_titleblock
BorderTitleBlock border_and_titleblock
Diagram dimensions and title block.
Definition: diagram.h:83
projectDataBase::m_data_base
QSqlDatabase m_data_base
Definition: projectdatabase.h:79
qetapp.h
Diagram
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition: diagram.h:56
Element::kindInformations
DiagramContext kindInformations() const
Definition: element.h:100
projectDataBase::addElement
void addElement(Element *element)
projectDataBase::addElement
Definition: projectdatabase.cpp:91
elementprovider.h
projectDataBase::m_remove_diagram_query
QSqlQuery m_remove_diagram_query
Definition: projectdatabase.h:85
projectDataBase::dataBaseUpdated
void dataBaseUpdated()
projectDataBase::exportDb
static void exportDb(projectDataBase *db, QWidget *parent=nullptr, const QString &caption=QString(), const QString &dir=QString())
projectDataBase::exportDb
Definition: projectdatabase.cpp:539
projectDataBase::m_update_element_query
QSqlQuery m_update_element_query
Definition: projectdatabase.h:83
projectDataBase::populateDiagramTable
void populateDiagramTable()
Definition: projectdatabase.cpp:350
Element::Master
@ Master
Definition: element.h:55
Diagram::convertPosition
DiagramPosition convertPosition(const QPointF &)
Diagram::convertPosition.
Definition: diagram.cpp:2223
QETApp::diagramInfoKeys
static QStringList diagramInfoKeys()
QETApp::diagramInfoKeys.
Definition: qetapp.cpp:480
QETProject::filePath
QString filePath()
Definition: qetproject.cpp:250
projectDataBase::elementInfoChanged
void elementInfoChanged(Element *element)
projectDataBase::elementInfoChanged
Definition: projectdatabase.cpp:136
element.h
projectDataBase::populateElementInfoTable
void populateElementInfoTable()
projectDataBase::populateElementsTable Populate the elements table
Definition: projectdatabase.cpp:397
Element
Definition: element.h:41
projectDataBase::removeElement
void removeElement(Element *element)
projectDataBase::removeElement
Definition: projectdatabase.cpp:122
qetproject.h
projectDataBase::createSummaryView
void createSummaryView()
projectDataBase::createSummaryView
Definition: projectdatabase.cpp:330
DiagramPosition::toString
QString toString()
Definition: diagramposition.cpp:59
projectDataBase::updateDB
void updateDB()
projectDataBase::updateDB Up to date the content of the data base. Emit the signal dataBaseUpdated
Definition: projectdatabase.cpp:61
QETProject
Definition: qetproject.h:51
projectDataBase::projectDataBase
projectDataBase(QETProject *project, QObject *parent=nullptr)
projectDataBase::projectDataBase Default constructor
Definition: projectdatabase.cpp:34
projectDataBase::populateElementTable
void populateElementTable()
projectDataBase::populateElementTable Populate the element table
Definition: projectdatabase.cpp:369
projectDataBase::m_insert_diagram_info_query
QSqlQuery m_insert_diagram_info_query
Definition: projectdatabase.h:86
QETProject::uuid
QUuid uuid() const
QETProject::uuid.
Definition: qetproject.cpp:132
Diagram::uuid
QUuid uuid()
Diagram::uuid.
Definition: diagram.cpp:519
projectDataBase::elementInfoToString
static QHash< QString, QString > elementInfoToString(Element *elmt)
projectDataBase::elementInfoToString
Definition: projectdatabase.cpp:516
projectDataBase::createElementNomenclatureView
void createElementNomenclatureView()
projectDataBase::createElementNomenclatureView
Definition: projectdatabase.cpp:291
projectDataBase::removeDiagram
void removeDiagram(Diagram *diagram)
Definition: projectdatabase.cpp:179
projectDataBase
The projectDataBase class This class wrap a sqlite data base where you can find several thing about t...
Definition: projectdatabase.h:39
projectDataBase::prepareQuery
void prepareQuery()
Definition: projectdatabase.cpp:453
projectDataBase::addDiagram
void addDiagram(Diagram *diagram)
Definition: projectdatabase.cpp:150
projectDataBase::m_insert_diagram_query
QSqlQuery m_insert_diagram_query
Definition: projectdatabase.h:84
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
projectdatabase.h
diagram.h
projectDataBase::m_remove_element_query
QSqlQuery m_remove_element_query
Definition: projectdatabase.h:82