diff --git a/sources/ElementsCollection/elementscollectionmodel.cpp b/sources/ElementsCollection/elementscollectionmodel.cpp index e87e61afe..a2f537413 100644 --- a/sources/ElementsCollection/elementscollectionmodel.cpp +++ b/sources/ElementsCollection/elementscollectionmodel.cpp @@ -26,6 +26,7 @@ #include #include +#include /** * @brief ElementsCollectionModel::ElementsCollectionModel @@ -149,7 +150,7 @@ bool ElementsCollectionModel::canDropMimeData(const QMimeData *data, Qt::DropAct */ bool ElementsCollectionModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { - Q_UNUSED(action); + Q_UNUSED(action) QStandardItem *qsi = itemFromIndex(parent.child(row, column)); if (!qsi) @@ -242,14 +243,16 @@ void ElementsCollectionModel::loadCollections(bool common_collection, bool custo list.append(projectItems(project)); } -QFutureWatcher watcher; - + QTime t; + t.start(); QFuture futur = QtConcurrent::map(list, setUpData); - watcher.setFuture(futur); emit loadingMaxValue(futur.progressMaximum()); while (futur.isRunning()) { emit loadingProgressValue(futur.progressValue()); } + int ms = t.elapsed(); + + QMessageBox::about(nullptr, tr("Chargement collection d'élément"), tr("Le chargement de la collection d'éléments à été éffectué en %1 ms").arg(ms)); } /** diff --git a/sources/ElementsCollection/elementslocation.cpp b/sources/ElementsCollection/elementslocation.cpp index 775dead99..bec5d5ec5 100644 --- a/sources/ElementsCollection/elementslocation.cpp +++ b/sources/ElementsCollection/elementslocation.cpp @@ -1,4 +1,4 @@ -/* +/* Copyright 2006-2019 The QElectroTech Team This file is part of QElectroTech. @@ -495,7 +495,14 @@ NamesList ElementsLocation::nameList() NamesList nl; if (isElement()) - nl.fromXml(pugiXml()); + { + QSettings set; + if (set.value("use_pugixml").toBool()) { + nl.fromXml(pugiXml()); + } else { + nl.fromXml(xml()); + } + } if (isDirectory()) { @@ -666,24 +673,28 @@ bool ElementsLocation::setXml(const QDomDocument &xml_document) const */ QUuid ElementsLocation::uuid() const { -// //Get the uuid of element -// QList list_ = QET::findInDomElement(xml(), "uuid"); - -// if (!list_.isEmpty()) -// return QUuid(list_.first().attribute("uuid")); - -// return QUuid(); - //Get the uuid of element - if (!isElement()) { return QUuid(); } - pugi::xml_node uuid_node = pugiXml().document_element().child("uuid"); - if (uuid_node.empty()) { - return QUuid(); + QSettings set; + if(set.value("use_pugixml").toBool()) + { + pugi::xml_node uuid_node = pugiXml().document_element().child("uuid"); + if (uuid_node.empty()) { + return QUuid(); + } + return QUuid(uuid_node.attribute("uuid").as_string()); } - return QUuid(uuid_node.attribute("uuid").as_string()); + + //Get the uuid of element + QList list_ = QET::findInDomElement(xml(), "uuid"); + + if (!list_.isEmpty()) + return QUuid(list_.first().attribute("uuid")); + + return QUuid(); + //Get the uuid of element } /** @@ -714,8 +725,14 @@ QIcon ElementsLocation::icon() const QString ElementsLocation::name() const { NamesList nl; -// nl.fromXml(xml()); - nl.fromXml(pugiXml().document_element()); + + QSettings set; + if(set.value("use_pugixml").toBool()) { + nl.fromXml(pugiXml().document_element()); + } else { + nl.fromXml(xml()); + } + return nl.name(fileName()); } diff --git a/sources/ui/configpage/generalconfigurationpage.cpp b/sources/ui/configpage/generalconfigurationpage.cpp index 720312a44..3efcf6bd7 100644 --- a/sources/ui/configpage/generalconfigurationpage.cpp +++ b/sources/ui/configpage/generalconfigurationpage.cpp @@ -126,6 +126,8 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) : ui->m_custom_tbt_path_cb->setItemData(1, path, Qt::DisplayRole); ui->m_custom_tbt_path_cb->blockSignals(false); } + + ui->m_use_pugi_xml->setChecked(settings.value("use_pugixml").toBool()); fillLang(); } @@ -234,6 +236,8 @@ void GeneralConfigurationPage::applyConf() if (path != settings.value("elements-collections/custom-tbt-path").toString()) { QETApp::resetUserElementsDir(); } + + settings.setValue("use_pugixml", ui->m_use_pugi_xml->isChecked()? true : false); } /** diff --git a/sources/ui/configpage/generalconfigurationpage.ui b/sources/ui/configpage/generalconfigurationpage.ui index 781ba5636..24b11d972 100644 --- a/sources/ui/configpage/generalconfigurationpage.ui +++ b/sources/ui/configpage/generalconfigurationpage.ui @@ -17,7 +17,7 @@ - 1 + 0 @@ -325,6 +325,13 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments + + + + Utiliser pugi xml pour le chargement des collections. + + +