QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
projectdatabase.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2021 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
27class Element;
28class QETProject;
29class Diagram;
30class sqlite3;
31
39class projectDataBase : public QObject
40{
41 Q_OBJECT
42
43 public:
44 projectDataBase(QETProject *project, QObject *parent = nullptr);
45 virtual ~projectDataBase() override;
46
47 void updateDB();
48 QETProject *project() const;
49 QSqlQuery newQuery(const QString &query = QString());
50
51 void addElement (Element *element);
52 void removeElement (Element *element);
53 void elementInfoChanged (Element *element);
54 void elementInfoChanged (QList<Element *> elements);
55
56 void addDiagram (Diagram *diagram);
57 void removeDiagram (Diagram *diagram);
58 void diagramInfoChanged (Diagram *diagram);
60
61 signals:
63
64 private:
65 bool createDataBase();
67 void createSummaryView();
72 void prepareQuery();
73 static QHash<QString, QString> elementInfoToString(
74 Element *elmt);
75 void bindDiagramInfoValues(QSqlQuery &query, Diagram *diagram);
76
77 private:
78 QPointer<QETProject> m_project;
79 QSqlDatabase m_data_base;
90
91#ifdef QET_EXPORT_PROJECT_DB
92 public:
93 static sqlite3 *sqliteHandle(QSqlDatabase *db);
94 static void exportDb(projectDataBase *db,
95 QWidget *parent = nullptr,
96 const QString &caption = QString(),
97 const QString &dir = QString());
98#endif
99};
100
101#endif // PROJECTDATABASE_H
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:56
Definition element.h:43
Definition qetproject.h:62
The projectDataBase class This class wraps a sqlite data base where you can find several things about...
Definition projectdatabase.h:40
QSqlQuery m_diagram_info_order_changed
Definition projectdatabase.h:89
QSqlQuery newQuery(const QString &query=QString())
projectDataBase::newQuery
Definition projectdatabase.cpp:107
void populateDiagramInfoTable()
Definition projectdatabase.cpp:464
QSqlQuery m_update_diagram_info_query
Definition projectdatabase.h:87
QSqlQuery m_insert_diagram_query
Definition projectdatabase.h:84
void addElement(Element *element)
projectDataBase::addElement
Definition projectdatabase.cpp:115
QSqlQuery m_remove_diagram_query
Definition projectdatabase.h:85
void createSummaryView()
projectDataBase::createSummaryView
Definition projectdatabase.cpp:367
void bindDiagramInfoValues(QSqlQuery &query, Diagram *diagram)
Definition projectdatabase.cpp:574
void createElementNomenclatureView()
projectDataBase::createElementNomenclatureView
Definition projectdatabase.cpp:331
void populateElementTable()
projectDataBase::populateElementTable Populate the element table
Definition projectdatabase.cpp:406
void populateDiagramTable()
Definition projectdatabase.cpp:387
QSqlDatabase m_data_base
Definition projectdatabase.h:79
void addDiagram(Diagram *diagram)
Definition projectdatabase.cpp:190
void removeElement(Element *element)
projectDataBase::removeElement
Definition projectdatabase.cpp:146
QSqlQuery m_insert_elements_query
Definition projectdatabase.h:80
QSqlQuery m_remove_element_query
Definition projectdatabase.h:82
void elementInfoChanged(Element *element)
projectDataBase::elementInfoChanged
Definition projectdatabase.cpp:160
void diagramInfoChanged(Diagram *diagram)
Definition projectdatabase.cpp:228
void removeDiagram(Diagram *diagram)
Definition projectdatabase.cpp:218
QSqlQuery m_insert_element_info_query
Definition projectdatabase.h:81
static QHash< QString, QString > elementInfoToString(Element *elmt)
projectDataBase::elementInfoToString
Definition projectdatabase.cpp:558
QPointer< QETProject > m_project
Definition projectdatabase.h:78
void populateElementInfoTable()
projectDataBase::populateElementInfoTable Populate the element info table
Definition projectdatabase.cpp:435
QSqlQuery m_insert_diagram_info_query
Definition projectdatabase.h:86
QSqlQuery m_diagram_order_changed
Definition projectdatabase.h:88
void updateDB()
projectDataBase::updateDB Up to date the content of the data base. Emit the signal dataBaseUpdated
Definition projectdatabase.cpp:84
QETProject * project() const
projectDataBase::project
Definition projectdatabase.cpp:97
void dataBaseUpdated()
bool createDataBase()
projectDataBase::createDataBase Create the data base
Definition projectdatabase.cpp:248
void prepareQuery()
Definition projectdatabase.cpp:479
void diagramOrderChanged()
Definition projectdatabase.cpp:239
QSqlQuery m_update_element_query
Definition projectdatabase.h:83
virtual ~projectDataBase() override
projectDataBase::~projectDataBase Destructor
Definition projectdatabase.cpp:74