Improve update of the project database

This commit is contained in:
Claveau Joshua
2020-11-02 19:13:56 +01:00
parent 98de247a4d
commit 62333506f1
2 changed files with 17 additions and 3 deletions

View File

@@ -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)

View File

@@ -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;
}