mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-03 19:10:53 +01:00
Nomenclature now use properly the element type 'thumbnail'
Use function provided by ElementData to check element type and master type instead of use plain text (code is more strong)
This commit is contained in:
@@ -411,16 +411,17 @@ void projectDataBase::populateElementTable()
|
||||
|
||||
for (auto diagram : m_project->diagrams())
|
||||
{
|
||||
ElementProvider ep(diagram);
|
||||
QList<Element *> elements_list = ep.find(Element::Simple | Element::Terminale | Element::Master | Element::Thumbnail);
|
||||
const ElementProvider ep(diagram);
|
||||
const auto elmt_vector = ep.find(ElementData::Simple | ElementData::Terminale | ElementData::Master | ElementData::Thumbnail);
|
||||
//Insert all value into the database
|
||||
for (auto elmt : elements_list)
|
||||
for (const auto &elmt : elmt_vector)
|
||||
{
|
||||
const auto elmt_data = elmt->elementData();
|
||||
m_insert_elements_query.bindValue(":uuid", elmt->uuid().toString());
|
||||
m_insert_elements_query.bindValue(":diagram_uuid", diagram->uuid().toString());
|
||||
m_insert_elements_query.bindValue(":pos", diagram->convertPosition(elmt->scenePos()).toString());
|
||||
m_insert_elements_query.bindValue(":type", elmt->linkTypeToString());
|
||||
m_insert_elements_query.bindValue(":sub_type", elmt->kindInformations()["type"].toString());
|
||||
m_insert_elements_query.bindValue(":type", elmt_data.typeToString());
|
||||
m_insert_elements_query.bindValue(":sub_type", elmt_data.masterTypeToString());
|
||||
if (!m_insert_elements_query.exec()) {
|
||||
qDebug() << "projectDataBase::populateElementTable insert error : " << m_insert_elements_query.lastError();
|
||||
}
|
||||
@@ -435,22 +436,22 @@ void projectDataBase::populateElementTable()
|
||||
void projectDataBase::populateElementInfoTable()
|
||||
{
|
||||
QSqlQuery query(m_data_base);
|
||||
query.exec("DELETE FROM element_info");
|
||||
query.exec(QStringLiteral("DELETE FROM element_info"));
|
||||
|
||||
for (auto *diagram : m_project->diagrams())
|
||||
for (const auto &diagram : m_project->diagrams())
|
||||
{
|
||||
ElementProvider ep(diagram);
|
||||
QList<Element *> elements_list = ep.find(Element::Simple | Element::Terminale | Element::Master | Element::Thumbnail);
|
||||
const ElementProvider ep(diagram);
|
||||
const auto elmt_vector = ep.find(ElementData::Simple | ElementData::Terminale | ElementData::Master | ElementData::Thumbnail);
|
||||
|
||||
//Insert all value into the database
|
||||
for (auto elmt : elements_list)
|
||||
for (const auto &elmt : elmt_vector)
|
||||
{
|
||||
m_insert_element_info_query.bindValue(":uuid", elmt->uuid().toString());
|
||||
auto hash = elementInfoToString(elmt);
|
||||
for (auto key : hash.keys())
|
||||
m_insert_element_info_query.bindValue(QStringLiteral(":uuid"), elmt->uuid().toString());
|
||||
const auto hash = elementInfoToString(elmt);
|
||||
for (const auto &key : hash.keys())
|
||||
{
|
||||
QString value = hash.value(key);
|
||||
QString bind = key.prepend(":");
|
||||
QString bind = QStringLiteral(":") + key;
|
||||
m_insert_element_info_query.bindValue(bind, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
#include "elementquerywidget.h"
|
||||
|
||||
#include "../../properties/elementdata.h"
|
||||
#include "../../qetapp.h"
|
||||
#include "../../qetinformation.h"
|
||||
#include "ui_elementquerywidget.h"
|
||||
@@ -166,28 +167,27 @@ void ElementQueryWidget::setQuery(const QString &query)
|
||||
where.remove(str_type);
|
||||
|
||||
int c=0;
|
||||
ui->m_simple_cb->setChecked (str_type.contains("Simple") ? true : false);
|
||||
ui->m_simple_cb->setChecked (str_type.contains(ElementData::typeToString(ElementData::Simple)) ? true : false);
|
||||
if (ui->m_simple_cb->isChecked()) {
|
||||
++c;
|
||||
}
|
||||
ui->m_terminal_cb->setChecked (str_type.contains("Terminale") ? true : false);
|
||||
ui->m_terminal_cb->setChecked (str_type.contains(ElementData::typeToString(ElementData::Terminale)) ? true : false);
|
||||
if (ui->m_terminal_cb->isChecked()) {
|
||||
++c;
|
||||
}
|
||||
ui->m_coil_cb->setChecked (str_type.contains("coil") ? true : false);
|
||||
ui->m_coil_cb->setChecked (str_type.contains(ElementData::masterTypeToString(ElementData::Coil)) ? true : false);
|
||||
if (ui->m_coil_cb->isChecked()) {
|
||||
++c;
|
||||
}
|
||||
ui->m_button_cb->setChecked (str_type.contains("commutator") ? true : false);
|
||||
ui->m_button_cb->setChecked (str_type.contains(ElementData::masterTypeToString(ElementData::Commutator)) ? true : false);
|
||||
if (ui->m_button_cb->isChecked()) {
|
||||
++c;
|
||||
}
|
||||
ui->m_protection_cb->setChecked(str_type.contains("protection") ? true : false);
|
||||
ui->m_protection_cb->setChecked(str_type.contains(ElementData::masterTypeToString(ElementData::Protection)) ? true : false);
|
||||
if (ui->m_protection_cb) {
|
||||
++c;
|
||||
}
|
||||
|
||||
ui->m_thumbnail_cb->setChecked (str_type.contains("Thumbnail") ? true : false);
|
||||
ui->m_thumbnail_cb->setChecked (str_type.contains(ElementData::typeToString(ElementData::Thumbnail)) ? true : false);
|
||||
if (ui->m_thumbnail_cb->isChecked()) {
|
||||
++c;
|
||||
}
|
||||
@@ -340,32 +340,32 @@ QString ElementQueryWidget::queryStr() const
|
||||
bool b = false;
|
||||
if (ui->m_terminal_cb->isChecked()) {
|
||||
if (b) where +=" OR";
|
||||
where += " element_type = 'Terminale'";
|
||||
where += QStringLiteral(" element_type = '") += ElementData::typeToString(ElementData::Terminale) += "'";
|
||||
b = true;
|
||||
}
|
||||
if (ui->m_thumbnail_cb->isChecked()) {
|
||||
if (b) where +=" OR";
|
||||
where += " element_type = 'Thumbnail'";
|
||||
where += QStringLiteral(" element_type = '") += ElementData::typeToString(ElementData::Thumbnail) += "'";
|
||||
b = true;
|
||||
}
|
||||
if (ui->m_simple_cb->isChecked()) {
|
||||
if (b) where +=" OR";
|
||||
where += " element_type = 'Simple'";
|
||||
where += QStringLiteral(" element_type = '") += ElementData::typeToString(ElementData::Simple) += "'";
|
||||
b = true;
|
||||
}
|
||||
if (ui->m_button_cb->isChecked()) {
|
||||
if (b) where +=" OR";
|
||||
where += " element_sub_type = 'commutator'";
|
||||
where += QStringLiteral(" element_sub_type = '") += ElementData::masterTypeToString(ElementData::Commutator) += "'";
|
||||
b = true;
|
||||
}
|
||||
if (ui->m_coil_cb->isChecked()) {
|
||||
if (b) where +=" OR";
|
||||
where += " element_sub_type = 'coil'";
|
||||
where += QStringLiteral(" element_sub_type = '") += ElementData::masterTypeToString(ElementData::Coil) += "'";
|
||||
b = true;
|
||||
}
|
||||
if (ui->m_protection_cb->isChecked()) {
|
||||
if (b) where +=" OR";
|
||||
where += " element_sub_type = 'protection'";
|
||||
where += QStringLiteral(" element_sub_type = '") += ElementData::masterTypeToString(ElementData::Protection) += "'";
|
||||
}
|
||||
where.append(")");
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>341</width>
|
||||
<height>557</height>
|
||||
<width>738</width>
|
||||
<height>534</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -272,16 +272,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="m_coil_cb">
|
||||
<property name="text">
|
||||
<string>Contacteurs et relais</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="m_button_cb">
|
||||
<property name="text">
|
||||
@@ -312,6 +302,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="m_coil_cb">
|
||||
<property name="text">
|
||||
<string>Contacteurs et relais</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user