From 27472bdd8b2cb3d71b92176605aeb5fb514da3ea Mon Sep 17 00:00:00 2001 From: Claveau Joshua Date: Fri, 29 May 2020 20:54:50 +0200 Subject: [PATCH] Nomenclature model don't save header data "display role" The model doesn't save anymore the header data with role Qt::displayRole. The header display role is now generated in the fly, by concequent the header displayed texts are always in the current local --- .../ViewItem/nomenclaturemodel.cpp | 35 +++++++++++-------- .../ViewItem/nomenclaturemodel.h | 2 +- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.cpp b/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.cpp index da3f5a745..39ecdf704 100644 --- a/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.cpp +++ b/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.cpp @@ -1,19 +1,19 @@ /* - Copyright 2006-2020 QElectroTech Team - This file is part of QElectroTech. + Copyright 2006-2020 QElectroTech Team + This file is part of QElectroTech. - QElectroTech is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + QElectroTech is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. - QElectroTech is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + QElectroTech is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with QElectroTech. If not, see . + You should have received a copy of the GNU General Public License + along with QElectroTech. If not, see . */ #include "nomenclaturemodel.h" #include "qetapp.h" @@ -238,8 +238,14 @@ QDomElement NomenclatureModel::toXml(QDomDocument &document) const //header data QHash> horizontal_; - for (auto key : m_header_data.keys()) { - horizontal_.insert(key, m_header_data.value(key).keys()); } + for (auto key : m_header_data.keys()) + { + //We save all data except the display role, because he was generated in the fly + auto list = m_header_data.value(key).keys(); + list.removeAll(Qt::DisplayRole); + + horizontal_.insert(key, list); + } dom_element.appendChild(QETXML::modelHeaderDataToXml(document, this, horizontal_, QHash>())); @@ -257,6 +263,7 @@ void NomenclatureModel::fromXml(const QDomElement &element) return; query(element.firstChildElement("query").text()); + autoHeaders(); //Index 0,0 auto index_00 = element.firstChildElement("index00"); diff --git a/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.h b/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.h index 2581966af..98bdaa8cf 100644 --- a/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.h +++ b/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.h @@ -61,7 +61,7 @@ class NomenclatureModel : public QAbstractTableModel QPointer m_project; QString m_query; QVector m_record; - QHash> m_header_data; + QHash> m_header_data; //First int = section, second int = Qt::role, QVariant = value QHash m_index_0_0_data; };