Merge branch 'master' of ssh://git.tuxfamily.org/gitroot/qet/qet

This commit is contained in:
pavelfric 2020-11-02 22:04:40 +01:00
commit a97ee8ddba
12 changed files with 248 additions and 115 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
---
BasedOnStyle: LLVM
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlines: Right
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllArgumentsOnNextLine: 'false'
AllowAllConstructorInitializersOnNextLine: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: 'true'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'true'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakAfterJavaFieldAnnotations: 'true'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: 'false'
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: 'true'
ColumnLimit: '80'
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
Cpp11BracedListStyle: 'true'
FixNamespaceComments: 'true'
IncludeBlocks: Regroup
IndentCaseLabels: 'false'
IndentPPDirectives: AfterHash
IndentWidth: '4'
JavaScriptWrapImports: 'true'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'true'
SpaceAfterLogicalNot: 'true'
SpaceAfterTemplateKeyword: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Always
...

Binary file not shown.

View File

@ -1625,7 +1625,7 @@ Bemærk: Disse muligheder VIL IKKE tillade eller blokere autonummereringer, kun
<location filename="../sources/elementdialog.cpp" line="62"/>
<source>Ouvrir un élément</source>
<comment>dialog title</comment>
<translation>Åbne symbol</translation>
<translation>Åbn symbol</translation>
</message>
<message>
<location filename="../sources/elementdialog.cpp" line="63"/>
@ -1649,7 +1649,7 @@ Bemærk: Disse muligheder VIL IKKE tillade eller blokere autonummereringer, kun
<location filename="../sources/elementdialog.cpp" line="70"/>
<source>Ouvrir une catégorie</source>
<comment>dialog title</comment>
<translation>Åbne kategori</translation>
<translation>Åbn kategori</translation>
</message>
<message>
<location filename="../sources/elementdialog.cpp" line="71"/>
@ -2111,7 +2111,7 @@ Bemærk: Disse muligheder VIL IKKE tillade eller blokere autonummereringer, kun
<message>
<location filename="../sources/dataBase/ui/elementquerywidget.ui" line="330"/>
<source>Ouvrir la configuration sélectionné</source>
<translation>Åbne valgt konfiguration</translation>
<translation>Åbn valgt konfiguration</translation>
</message>
<message>
<location filename="../sources/dataBase/ui/elementquerywidget.ui" line="357"/>
@ -2287,7 +2287,7 @@ Bemærk: Disse muligheder VIL IKKE tillade eller blokere autonummereringer, kun
<message>
<location filename="../sources/ElementsCollection/elementscollectionwidget.cpp" line="145"/>
<source>Ouvrir le dossier correspondant</source>
<translation>Åbne mappe</translation>
<translation>Åbn mappe</translation>
</message>
<message>
<location filename="../sources/ElementsCollection/elementscollectionwidget.cpp" line="147"/>
@ -2488,7 +2488,7 @@ Alle symboler og fil indhold bliver slettet.</translation>
<message>
<location filename="../sources/elementspanelwidget.cpp" line="53"/>
<source>Ouvrir le dossier correspondant</source>
<translation>Åbne mappe</translation>
<translation>Åbn mappe</translation>
</message>
<message>
<location filename="../sources/elementspanelwidget.cpp" line="54"/>
@ -5629,7 +5629,7 @@ Kommandovalg:
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="817"/>
<source>Affiche ou non le panel d&apos;appareils</source>
<translation>Vise eller skjule symbol panel</translation>
<translation>Vis eller skjul symbol panel</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="550"/>
@ -5840,7 +5840,7 @@ Kommandovalg:
<location filename="../sources/qetdiagrameditor.cpp" line="534"/>
<source>Ouvre un projet existant</source>
<comment>status bar tip</comment>
<translation>Åbne eksisterende projekt</translation>
<translation>Åbn eksisterende projekt</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="535"/>
@ -6017,12 +6017,12 @@ Kommandovalg:
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="523"/>
<source>&amp;Ouvrir</source>
<translation>&amp;Åbne</translation>
<translation>&amp;Åbn</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="974"/>
<source>Ouvrir un fichier</source>
<translation>Åbne fil</translation>
<translation>Åbn fil</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="618"/>
@ -6092,17 +6092,17 @@ Kommandovalg:
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="814"/>
<source>Affiche ou non la barre d&apos;outils principale</source>
<translation>Vise eller skjule værktøjslinje</translation>
<translation>Vis eller skjul værktøjslinje</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="815"/>
<source>Affiche ou non la barre d&apos;outils Affichage</source>
<translation>Vise eller skjule værktøjslinjen Vise</translation>
<translation>Vis eller skjul værktøjslinjen Vis</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="816"/>
<source>Affiche ou non la barre d&apos;outils Schéma</source>
<translation>Vise eller skjule værktøjslinjen Diagram</translation>
<translation>Vis eller skjul værktøjslinjen Diagram</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="696"/>
@ -6127,7 +6127,7 @@ Kommandovalg:
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="818"/>
<source>Affiche ou non la liste des modifications</source>
<translation>Vise eller skjule gendan liste</translation>
<translation>Vis eller skjul gendan liste</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="572"/>
@ -6159,7 +6159,7 @@ Kommandovalg:
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="676"/>
<source>Chercher/remplacer</source>
<translation>Søge/erstatte</translation>
<translation>Søg/erstat</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="752"/>
@ -6169,7 +6169,7 @@ Kommandovalg:
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="764"/>
<source>&amp;Récemment ouverts</source>
<translation>&amp;Seneste åbnet</translation>
<translation>&amp;Senest åbnet</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="903"/>
@ -6367,7 +6367,7 @@ Kommandovalg:
<location filename="../sources/qetdiagrameditor.cpp" line="464"/>
<source>Présente les différents projets ouverts dans des sous-fenêtres</source>
<comment>status bar tip</comment>
<translation>Vise åbne projekter i vinduer</translation>
<translation>Vis åbne projekter i vinduer</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="420"/>
@ -6378,7 +6378,7 @@ Kommandovalg:
<location filename="../sources/qetdiagrameditor.cpp" line="459"/>
<source>Présente les différents projets ouverts des onglets</source>
<comment>status bar tip</comment>
<translation>Vise åbne projekter i faneblade</translation>
<translation>Vis åbne projekter i faneblade</translation>
</message>
<message>
<location filename="../sources/qetdiagrameditor.cpp" line="483"/>
@ -6541,7 +6541,7 @@ Kommandovalg:
<message>
<location filename="../sources/editor/qetelementeditor.cpp" line="142"/>
<source>&amp;Ouvrir</source>
<translation>&amp;Åbne</translation>
<translation>&amp;Åbn</translation>
</message>
<message>
<location filename="../sources/editor/qetelementeditor.cpp" line="145"/>
@ -6687,7 +6687,7 @@ Kommandovalg:
<message>
<location filename="../sources/editor/qetelementeditor.cpp" line="143"/>
<source>&amp;Ouvrir depuis un fichier</source>
<translation>&amp;Åbne fra fil</translation>
<translation>&amp;Åbn fra fil</translation>
</message>
<message>
<location filename="../sources/editor/qetelementeditor.cpp" line="147"/>
@ -6855,7 +6855,7 @@ Gør den kørbar: chmod +x ./DXFtoQET
<message>
<location filename="../sources/editor/qetelementeditor.cpp" line="382"/>
<source>&amp;Récemment ouverts</source>
<translation>&amp;Seneste åbnet</translation>
<translation>&amp;Senest åbnet</translation>
</message>
<message>
<location filename="../sources/editor/qetelementeditor.cpp" line="394"/>
@ -7102,7 +7102,7 @@ betingelser ikke gyldig</translation>
<location filename="../sources/editor/qetelementeditor.cpp" line="1596"/>
<source>Ouvrir un fichier</source>
<comment>dialog title</comment>
<translation>Åbne fil</translation>
<translation>Åbn fil</translation>
</message>
<message>
<location filename="../sources/editor/qetelementeditor.cpp" line="1598"/>
@ -7437,13 +7437,13 @@ Hvad skal ske?</translation>
<location filename="../sources/titleblock/qettemplateeditor.cpp" line="368"/>
<source>&amp;Ouvrir</source>
<comment>menu entry</comment>
<translation>&amp;Åbne</translation>
<translation>&amp;Åbn</translation>
</message>
<message>
<location filename="../sources/titleblock/qettemplateeditor.cpp" line="369"/>
<source>Ouvrir depuis un fichier</source>
<comment>menu entry</comment>
<translation>Åbne fra fil</translation>
<translation>Åbn fra fil</translation>
</message>
<message>
<location filename="../sources/titleblock/qettemplateeditor.cpp" line="370"/>
@ -8591,27 +8591,27 @@ Voulez-vous la remplacer ?</source>
<message>
<location filename="../sources/SearchAndReplace/searchandreplaceworker.cpp" line="55"/>
<source>Chercher/remplacer les propriétés de folio</source>
<translation>Søge/erstatte ark egenskaber</translation>
<translation>Søg/erstat ark egenskaber</translation>
</message>
<message>
<location filename="../sources/SearchAndReplace/searchandreplaceworker.cpp" line="119"/>
<source>Chercher/remplacer les propriétés d&apos;éléments.</source>
<translation>Søge/erstatte symbol egenskaber.</translation>
<translation>Søg/erstat symbol egenskaber.</translation>
</message>
<message>
<location filename="../sources/SearchAndReplace/searchandreplaceworker.cpp" line="211"/>
<source>Chercher/remplacer les propriétés de conducteurs.</source>
<translation>Søge/erstatte ledere egenskaber.</translation>
<translation>Søg/erstat ledere egenskaber.</translation>
</message>
<message>
<location filename="../sources/SearchAndReplace/searchandreplaceworker.cpp" line="298"/>
<source>Rechercher / remplacer avancé</source>
<translation>Søge/erstatte avanceret</translation>
<translation>Søg/erstat avanceret</translation>
</message>
<message>
<location filename="../sources/SearchAndReplace/searchandreplaceworker.cpp" line="171"/>
<source>Chercher/remplacer des textes independants</source>
<translation>Søge/erstatte uafhængige tekste</translation>
<translation>Søg/erstat uafhængige tekste</translation>
</message>
<message>
<location filename="../sources/qetinformation.cpp" line="67"/>
@ -9999,13 +9999,13 @@ De andre felter anvendes ikke.</translation>
<location filename="../sources/editor/styleeditor.cpp" line="55"/>
<source>Pink : HotPink</source>
<comment>element part color</comment>
<translation type="unfinished"></translation>
<translation>Lyserød : Varm lyserød</translation>
</message>
<message>
<location filename="../sources/editor/styleeditor.cpp" line="56"/>
<source>Pink : DeepPink</source>
<comment>element part color</comment>
<translation type="unfinished"></translation>
<translation>Lyserød : Dyb lyserød</translation>
</message>
<message>
<location filename="../sources/editor/styleeditor.cpp" line="57"/>
@ -10017,13 +10017,13 @@ De andre felter anvendes ikke.</translation>
<location filename="../sources/editor/styleeditor.cpp" line="58"/>
<source>Pink : MediumVioletRed</source>
<comment>element part color</comment>
<translation type="unfinished"></translation>
<translation>Lyserød : Mellem violet rød</translation>
</message>
<message>
<location filename="../sources/editor/styleeditor.cpp" line="59"/>
<source>Red : LightSalmon</source>
<comment>element part color</comment>
<translation type="unfinished"></translation>
<translation>Rød : Lys laks</translation>
</message>
<message>
<location filename="../sources/editor/styleeditor.cpp" line="60"/>
@ -10035,7 +10035,7 @@ De andre felter anvendes ikke.</translation>
<location filename="../sources/editor/styleeditor.cpp" line="61"/>
<source>Red : DarkSalmon</source>
<comment>element part color</comment>
<translation type="unfinished"></translation>
<translation>Rød : Mørk laks</translation>
</message>
<message>
<location filename="../sources/editor/styleeditor.cpp" line="62"/>
@ -10047,7 +10047,7 @@ De andre felter anvendes ikke.</translation>
<location filename="../sources/editor/styleeditor.cpp" line="63"/>
<source>Red : IndianRed</source>
<comment>element part color</comment>
<translation type="unfinished"></translation>
<translation>Rød : Indianer rød</translation>
</message>
<message>
<location filename="../sources/editor/styleeditor.cpp" line="64"/>
@ -10060,7 +10060,7 @@ De andre felter anvendes ikke.</translation>
<location filename="../sources/editor/styleeditor.cpp" line="65"/>
<source>Red : Firebrick</source>
<comment>element part color</comment>
<translation type="unfinished"></translation>
<translation>Rød : Ild fast sten</translation>
</message>
<message>
<location filename="../sources/editor/styleeditor.cpp" line="66"/>
@ -11898,7 +11898,7 @@ De andre felter anvendes ikke.</translation>
<message>
<location filename="../sources/dataBase/ui/summaryquerywidget.ui" line="51"/>
<source>Information à afficher</source>
<translation>Vise information</translation>
<translation>Vis information</translation>
</message>
<message>
<location filename="../sources/dataBase/ui/summaryquerywidget.ui" line="145"/>
@ -13122,7 +13122,7 @@ Maksimum længde: %2piksel
<message>
<location filename="../sources/SearchAndReplace/ui/replaceadvanceddialog.ui" line="14"/>
<source>Rechercher/Remplacer avancé</source>
<translation>Søge/erstatte avanceret</translation>
<translation>Søg/erstat avanceret</translation>
</message>
<message>
<location filename="../sources/SearchAndReplace/ui/replaceadvanceddialog.ui" line="27"/>

View File

@ -282,9 +282,8 @@ void FileElementCollectionItem::setUpData()
ElementsLocation loc(collectionPath());
DiagramContext context = loc.elementInformations();
QStringList search_list;
for (QString key : context.keys()) {
search_list.append(context.value(key).toString());
}
for (QString& key : context.keys())
{ search_list.append(context.value(key).toString()); }
search_list.append(localName(loc));
setData(search_list.join(" "));
}
@ -352,8 +351,8 @@ void FileElementCollectionItem::populate(bool set_data, bool hide_element)
QDir dir (fileSystemPath());
//Get all directory in this directory.
for(auto str : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot,
QDir::Name))
for (auto& str :
dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
{
FileElementCollectionItem *feci = new FileElementCollectionItem();
appendRow(feci);
@ -367,8 +366,8 @@ void FileElementCollectionItem::populate(bool set_data, bool hide_element)
//Get all elmt file in this directory
dir.setNameFilters(QStringList() << "*.elmt");
for(auto str : dir.entryList(QDir::Files | QDir::NoDotAndDotDot,
QDir::Name))
for (auto& str :
dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
{
FileElementCollectionItem *feci = new FileElementCollectionItem();
appendRow(feci);

View File

@ -229,28 +229,25 @@ bool NamesList::operator==(const NamesList &nl) const
}
/**
Return the adequate name regarding the current system locale.
By order of preference, this function chooses:
- the name in the system language
- the English name
- the provided fallback name if non-empty
- the first language encountered in the list
- an empty string
@param fallback_name name to be returned when no adequate name has been found
@return The adequate name regarding the current system locale.
*/
* @brief NamesList::name
* Return the adequate name regarding the current system locale.
* By order of preference, this function chooses:
* - the name in the system language
* - the English name
* - the provided fallback name if non-empty
* - the first language encountered in the list
* - an empty string
* @param fallback_name
* name to be returned when no adequate name has been found
* @return The adequate name regarding the current system locale.
*/
QString NamesList::name(const QString &fallback_name) const
{
QString system_language = QETApp::langFromSetting();
QString returned_name;
if (!hash_names[system_language].isEmpty()) {
returned_name = hash_names[system_language];
} else if (!hash_names["en"].isEmpty()) {
returned_name = hash_names["en"];
} else if (!fallback_name.isEmpty()) {
returned_name = fallback_name;
} else if (hash_names.count()) {
returned_name = hash_names.value(hash_names.keys().first());
}
return(returned_name);
if (! hash_names[system_language].isEmpty())
return (hash_names[system_language]);
if (! hash_names["en"].isEmpty()) return (hash_names["en"]);
if (! fallback_name.isEmpty()) return (fallback_name);
if (hash_names.count()) return (hash_names.begin().value());
return (QString(""));
}

View File

@ -1,4 +1,4 @@
/*
/*
Copyright 2006-2020 QElectroTech Team
This file is part of QElectroTech.
@ -42,6 +42,28 @@ projectDataBase::projectDataBase(QETProject *project, QObject *parent) :
m_project(project)
{
createDataBase();
connect(m_project, &QETProject::diagramAdded, [this](QETProject *, Diagram *diagram) {
this->addDiagram(diagram);
});
connect(m_project, &QETProject::diagramRemoved, [this](QETProject *, Diagram *diagram) {
this->removeDiagram(diagram);
});
connect(m_project, &QETProject::projectDiagramsOrderChanged, [this]()
{
for (auto diagram : m_project->diagrams())
{
m_diagram_order_changed.bindValue(":pos", m_project->folioIndex(diagram)+1);
m_diagram_order_changed.bindValue(":uuid", diagram->uuid());
m_diagram_order_changed.exec();
m_diagram_info_order_changed.bindValue(":folio", diagram->border_and_titleblock.titleblockInformation().value("folio"));
m_diagram_info_order_changed.bindValue(":uuid", diagram->uuid());
m_diagram_info_order_changed.exec();
}
emit dataBaseUpdated();
});
}
/**
@ -151,33 +173,29 @@ void projectDataBase::elementInfoChanged(Element *element)
void projectDataBase::addDiagram(Diagram *diagram)
{
m_insert_diagram_query.bindValue(":uuid", diagram->uuid().toString());
m_insert_diagram_query.bindValue(":pos", m_project->folioIndex(diagram));
m_insert_diagram_query.bindValue(":pos", m_project->folioIndex(diagram)+1);
if(!m_insert_diagram_query.exec()) {
qDebug() << "projectDataBase::addDiagram insert error : " << m_insert_diagram_query.lastError();
}
m_insert_diagram_info_query.bindValue(":uuid", diagram->uuid());
auto infos = diagram->border_and_titleblock.titleblockInformation();
for (auto key : QETApp::diagramInfoKeys())
{
if (key == "date")
{
m_insert_diagram_info_query.bindValue( ":date",
QLocale::system().toDate(infos.value("date").toString(),
QLocale::ShortFormat));
} else {
auto value = infos.value(key);
auto bind = key.prepend(":");
m_insert_diagram_info_query.bindValue(bind, value);
}
}
bindDiagramInfoValues(m_insert_diagram_info_query, 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)
@ -190,6 +208,21 @@ void projectDataBase::removeDiagram(Diagram *diagram)
}
}
void projectDataBase::diagramInfoChanged(Diagram *diagram)
{
bindDiagramInfoValues(m_update_diagram_info_query, diagram);
if (!m_update_diagram_info_query.exec()) {
qDebug() << "projectDataBase::diagramInfoChanged update error : " << m_update_diagram_info_query.lastError();
} else {
emit dataBaseUpdated();
}
}
void projectDataBase::diagramOrderChanged()
{
}
/**
@brief projectDataBase::createDataBase
Create the data base
@ -342,7 +375,7 @@ void projectDataBase::populateDiagramTable()
for (auto diagram : m_project->diagrams())
{
m_insert_diagram_query.bindValue(":uuid", diagram->uuid().toString());
m_insert_diagram_query.bindValue(":pos", m_project->folioIndex(diagram));
m_insert_diagram_query.bindValue(":pos", m_project->folioIndex(diagram)+1);
if(!m_insert_diagram_query.exec()) {
qDebug() << "projectDataBase::populateDiagramTable insert error : " << m_insert_diagram_query.lastError();
}
@ -417,21 +450,7 @@ void projectDataBase::populateDiagramInfoTable()
for (auto *diagram : m_project->diagrams())
{
m_insert_diagram_info_query.bindValue(":uuid", diagram->uuid());
auto infos = diagram->border_and_titleblock.titleblockInformation();
for (auto key : QETApp::diagramInfoKeys())
{
if (key == "date") {
m_insert_diagram_info_query.bindValue( ":date",
QLocale::system().toDate(infos.value("date").toString(),
QLocale::ShortFormat));
} else {
auto value = infos.value(key);
auto bind = key.prepend(":");
m_insert_diagram_info_query.bindValue(bind, value);
}
}
bindDiagramInfoValues(m_insert_diagram_info_query, diagram);
if (!m_insert_diagram_info_query.exec()) {
qDebug() << "projectDataBase::populateDiagramInfoTable insert error : " << m_insert_diagram_info_query.lastError();
@ -462,6 +481,22 @@ void projectDataBase::prepareQuery()
")");
m_insert_diagram_info_query.prepare(insert_diag_info);
//UPDATE DIAGRAM INFO
QString update_diagram_str("UPDATE diagram_info SET ");
for (auto str : QETApp::diagramInfoKeys()) {
update_diagram_str.append(str + " = :" + str + ", ");
}
update_diagram_str.remove(update_diagram_str.length()-2, 2); //Remove the last ", "
update_diagram_str.append(" WHERE diagram_uuid = :uuid");
m_update_diagram_info_query = QSqlQuery(m_data_base);
m_update_diagram_info_query.prepare(update_diagram_str);
//UPDATE DIAGRAM ORDER
m_diagram_order_changed = QSqlQuery(m_data_base);
m_diagram_order_changed.prepare("UPDATE diagram SET pos = :pos WHERE uuid = :uuid");
m_diagram_info_order_changed = QSqlQuery(m_data_base);
m_diagram_info_order_changed.prepare("UPDATE diagram_info SET folio = :folio WHERE diagram_uuid = :uuid");
//INSERT ELEMENT
QString insert_element_query("INSERT INTO element (uuid, diagram_uuid, pos, type, sub_type) VALUES (:uuid, :diagram_uuid, :pos, :type, :sub_type)");
m_insert_elements_query = QSqlQuery(m_data_base);
@ -518,6 +553,25 @@ QHash<QString, QString> projectDataBase::elementInfoToString(Element *elmt)
return hash;
}
void projectDataBase::bindDiagramInfoValues(QSqlQuery &query, Diagram *diagram)
{
query.bindValue(":uuid", diagram->uuid());
auto infos = diagram->border_and_titleblock.titleblockInformation();
for (auto key : QETApp::diagramInfoKeys())
{
if (key == "date") {
query.bindValue( ":date",
QLocale::system().toDate(infos.value("date").toString(),
QLocale::ShortFormat));
} else {
auto value = infos.value(key);
auto bind = key.prepend(":");
query.bindValue(bind, value);
}
}
}
#ifdef QET_EXPORT_PROJECT_DB
/**
@brief projectDataBase::sqliteHandle

View File

@ -47,11 +47,15 @@ class projectDataBase : public QObject
void updateDB();
QETProject *project() const;
QSqlQuery newQuery(const QString &query = QString());
void addElement(Element *element);
void removeElement(Element *element);
void elementInfoChanged(Element *element);
void addDiagram(Diagram *diagram);
void removeDiagram(Diagram *diagram);
void addElement (Element *element);
void removeElement (Element *element);
void elementInfoChanged (Element *element);
void addDiagram (Diagram *diagram);
void removeDiagram (Diagram *diagram);
void diagramInfoChanged (Diagram *diagram);
void diagramOrderChanged();
signals:
void dataBaseUpdated();
@ -67,6 +71,7 @@ class projectDataBase : public QObject
void prepareQuery();
static QHash<QString, QString> elementInfoToString(
Element *elmt);
void bindDiagramInfoValues(QSqlQuery &query, Diagram *diagram);
private:
QPointer<QETProject> m_project;
@ -77,7 +82,10 @@ class projectDataBase : public QObject
m_update_element_query,
m_insert_diagram_query,
m_remove_diagram_query,
m_insert_diagram_info_query;
m_insert_diagram_info_query,
m_update_diagram_info_query,
m_diagram_order_changed,
m_diagram_info_order_changed;
#ifdef QET_EXPORT_PROJECT_DB
public:

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

View File

@ -1650,6 +1650,8 @@ void Diagram::setTitleBlockTemplate(const QString &template_name)
if (template_name != current_name)
emit(usedTitleBlockTemplateChanged(template_name));
project()->dataBase()->diagramInfoChanged(this);
}
/**

View File

@ -441,5 +441,7 @@ void QetGraphicsHeaderItem::adjustSize()
void QetGraphicsHeaderItem::modelReseted()
{
setUpMinimumSectionsSize();
m_current_sections_width.clear();
m_current_sections_width.resize(m_sections_minimum_width.size());
adjustSize();
}

View File

@ -1015,12 +1015,13 @@ bool Element::fromXml(
if(deti->textFrom()== DynamicElementTextItem::ElementInfo
&& deti->infoName() == "label")
{
qDebug() << "see 'Mod overlapping comparisons' in git";
qreal rotation = deti->rotation();
//Create the comment item
DynamicElementTextItem *comment_text = nullptr;
if (m_link_type !=PreviousReport
|| m_link_type !=NextReport)
if (m_link_type != PreviousReport
&& m_link_type != NextReport)
{
m_state = QET::GIOK;
return(true);
@ -1041,7 +1042,8 @@ bool Element::fromXml(
}
//create the location item
DynamicElementTextItem *location_text = nullptr;
if (m_link_type !=PreviousReport || m_link_type !=NextReport)
if (m_link_type != PreviousReport
&& m_link_type != NextReport)
{
m_state = QET::GIOK;
return(true);
@ -1061,8 +1063,8 @@ bool Element::fromXml(
}
QPointF pos = deti->pos();
if (m_link_type !=PreviousReport
|| m_link_type !=NextReport)
if (m_link_type != PreviousReport
&& m_link_type != NextReport)
{
m_state = QET::GIOK;
return(true);

View File

@ -1221,7 +1221,6 @@ void QETProject::removeDiagram(Diagram *diagram)
if (m_diagrams_list.removeAll(diagram))
{
m_data_base.removeDiagram(diagram);
emit(diagramRemoved(this, diagram));
diagram->deleteLater();
}
@ -1652,7 +1651,7 @@ void QETProject::addDiagram(Diagram *diagram, int pos)
} else {
m_diagrams_list.insert(pos, diagram);
}
m_data_base.addDiagram(diagram);
updateDiagramsFolioData();
}