mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Add option to switch between Qtxml or pugi xml. Add dialog to display the elpsaed time of collection loading.
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsCollectionModel::ElementsCollectionModel
|
* @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)
|
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));
|
QStandardItem *qsi = itemFromIndex(parent.child(row, column));
|
||||||
if (!qsi)
|
if (!qsi)
|
||||||
@@ -242,14 +243,16 @@ void ElementsCollectionModel::loadCollections(bool common_collection, bool custo
|
|||||||
list.append(projectItems(project));
|
list.append(projectItems(project));
|
||||||
}
|
}
|
||||||
|
|
||||||
QFutureWatcher<void> watcher;
|
QTime t;
|
||||||
|
t.start();
|
||||||
QFuture<void> futur = QtConcurrent::map(list, setUpData);
|
QFuture<void> futur = QtConcurrent::map(list, setUpData);
|
||||||
watcher.setFuture(futur);
|
|
||||||
emit loadingMaxValue(futur.progressMaximum());
|
emit loadingMaxValue(futur.progressMaximum());
|
||||||
while (futur.isRunning()) {
|
while (futur.isRunning()) {
|
||||||
emit loadingProgressValue(futur.progressValue());
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2019 The QElectroTech Team
|
Copyright 2006-2019 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -495,7 +495,14 @@ NamesList ElementsLocation::nameList()
|
|||||||
NamesList nl;
|
NamesList nl;
|
||||||
|
|
||||||
if (isElement())
|
if (isElement())
|
||||||
|
{
|
||||||
|
QSettings set;
|
||||||
|
if (set.value("use_pugixml").toBool()) {
|
||||||
nl.fromXml(pugiXml());
|
nl.fromXml(pugiXml());
|
||||||
|
} else {
|
||||||
|
nl.fromXml(xml());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isDirectory())
|
if (isDirectory())
|
||||||
{
|
{
|
||||||
@@ -666,19 +673,13 @@ bool ElementsLocation::setXml(const QDomDocument &xml_document) const
|
|||||||
*/
|
*/
|
||||||
QUuid ElementsLocation::uuid() const
|
QUuid ElementsLocation::uuid() const
|
||||||
{
|
{
|
||||||
// //Get the uuid of element
|
|
||||||
// QList<QDomElement> list_ = QET::findInDomElement(xml(), "uuid");
|
|
||||||
|
|
||||||
// if (!list_.isEmpty())
|
|
||||||
// return QUuid(list_.first().attribute("uuid"));
|
|
||||||
|
|
||||||
// return QUuid();
|
|
||||||
//Get the uuid of element
|
|
||||||
|
|
||||||
if (!isElement()) {
|
if (!isElement()) {
|
||||||
return QUuid();
|
return QUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSettings set;
|
||||||
|
if(set.value("use_pugixml").toBool())
|
||||||
|
{
|
||||||
pugi::xml_node uuid_node = pugiXml().document_element().child("uuid");
|
pugi::xml_node uuid_node = pugiXml().document_element().child("uuid");
|
||||||
if (uuid_node.empty()) {
|
if (uuid_node.empty()) {
|
||||||
return QUuid();
|
return QUuid();
|
||||||
@@ -686,6 +687,16 @@ QUuid ElementsLocation::uuid() const
|
|||||||
return QUuid(uuid_node.attribute("uuid").as_string());
|
return QUuid(uuid_node.attribute("uuid").as_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get the uuid of element
|
||||||
|
QList<QDomElement> list_ = QET::findInDomElement(xml(), "uuid");
|
||||||
|
|
||||||
|
if (!list_.isEmpty())
|
||||||
|
return QUuid(list_.first().attribute("uuid"));
|
||||||
|
|
||||||
|
return QUuid();
|
||||||
|
//Get the uuid of element
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementLocation::icon
|
* @brief ElementLocation::icon
|
||||||
* @return The icon of the represented element.
|
* @return The icon of the represented element.
|
||||||
@@ -714,8 +725,14 @@ QIcon ElementsLocation::icon() const
|
|||||||
QString ElementsLocation::name() const
|
QString ElementsLocation::name() const
|
||||||
{
|
{
|
||||||
NamesList nl;
|
NamesList nl;
|
||||||
// nl.fromXml(xml());
|
|
||||||
|
QSettings set;
|
||||||
|
if(set.value("use_pugixml").toBool()) {
|
||||||
nl.fromXml(pugiXml().document_element());
|
nl.fromXml(pugiXml().document_element());
|
||||||
|
} else {
|
||||||
|
nl.fromXml(xml());
|
||||||
|
}
|
||||||
|
|
||||||
return nl.name(fileName());
|
return nl.name(fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
|||||||
ui->m_custom_tbt_path_cb->blockSignals(false);
|
ui->m_custom_tbt_path_cb->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->m_use_pugi_xml->setChecked(settings.value("use_pugixml").toBool());
|
||||||
|
|
||||||
fillLang();
|
fillLang();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,6 +236,8 @@ void GeneralConfigurationPage::applyConf()
|
|||||||
if (path != settings.value("elements-collections/custom-tbt-path").toString()) {
|
if (path != settings.value("elements-collections/custom-tbt-path").toString()) {
|
||||||
QETApp::resetUserElementsDir();
|
QETApp::resetUserElementsDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings.setValue("use_pugixml", ui->m_use_pugi_xml->isChecked()? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_3">
|
<widget class="QWidget" name="tab_3">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -325,6 +325,13 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="m_use_pugi_xml">
|
||||||
|
<property name="text">
|
||||||
|
<string>Utiliser pugi xml pour le chargement des collections.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_6">
|
<widget class="QWidget" name="tab_6">
|
||||||
|
|||||||
Reference in New Issue
Block a user