From 62333506f10dfdf9f9853eda7ff25c0dbf5633e2 Mon Sep 17 00:00:00 2001 From: Claveau Joshua Date: Mon, 2 Nov 2020 19:13:56 +0100 Subject: [PATCH] Improve update of the project database --- sources/dataBase/projectdatabase.cpp | 15 +++++++++++++-- sources/dataBase/ui/summaryquerywidget.cpp | 5 ++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sources/dataBase/projectdatabase.cpp b/sources/dataBase/projectdatabase.cpp index d4dbd8e10..d234acbe5 100644 --- a/sources/dataBase/projectdatabase.cpp +++ b/sources/dataBase/projectdatabase.cpp @@ -182,9 +182,20 @@ void projectDataBase::addDiagram(Diagram *diagram) if (!m_insert_diagram_info_query.exec()) { qDebug() << "projectDataBase::addDiagram insert info error : " << m_insert_diagram_info_query.lastError(); - } else { - emit dataBaseUpdated(); } + + //The information "folio" of other existing diagram can have the variable %total, + //so when a new diagram is added this variable change. + //We need to update this information in the database. + for (auto diagram : project()->diagrams()) + { + m_diagram_info_order_changed.bindValue(":folio", diagram->border_and_titleblock.titleblockInformation().value("folio")); + m_diagram_info_order_changed.bindValue(":uuid", diagram->uuid()); + if (!m_diagram_info_order_changed.exec()) { + qDebug() << "projectDataBase::addDiagram update diagram infp order error : " << m_diagram_info_order_changed.lastError(); + } + } + emit dataBaseUpdated(); } void projectDataBase::removeDiagram(Diagram *diagram) diff --git a/sources/dataBase/ui/summaryquerywidget.cpp b/sources/dataBase/ui/summaryquerywidget.cpp index 6c54dedc9..3fc7e5b72 100644 --- a/sources/dataBase/ui/summaryquerywidget.cpp +++ b/sources/dataBase/ui/summaryquerywidget.cpp @@ -61,6 +61,7 @@ QString SummaryQueryWidget::queryStr() const QStringList keys = selectedKeys(); QString select ="SELECT "; + QString order_by = " ORDER BY "; QString column; bool first = true; @@ -69,13 +70,15 @@ QString SummaryQueryWidget::queryStr() const first = false; } else { column += ", "; + order_by +=", "; } column += key; + order_by += key; } QString from = " FROM project_summary_view"; - QString q(select + column + from); + QString q(select + column + from + order_by); return q; }