mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-10 16:19:59 +01:00
Fix indentation code
This commit is contained in:
@@ -105,9 +105,9 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
|
||||
updateQueryLine();
|
||||
});
|
||||
|
||||
setUpItems();
|
||||
createDataBase();
|
||||
fillSavedQuery();
|
||||
setUpItems();
|
||||
createDataBase();
|
||||
fillSavedQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,8 +115,8 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
|
||||
*/
|
||||
BOMExportDialog::~BOMExportDialog()
|
||||
{
|
||||
delete ui;
|
||||
m_data_base.close();
|
||||
delete ui;
|
||||
m_data_base.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,39 +126,39 @@ BOMExportDialog::~BOMExportDialog()
|
||||
*/
|
||||
int BOMExportDialog::exec()
|
||||
{
|
||||
int r = QDialog::exec();
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
//save in csv file
|
||||
QString file_name = tr("nomenclature_") + QString(m_project ->title() + ".csv");
|
||||
// if (!file_name.endsWith(".csv")) {
|
||||
// file_name += ".csv";
|
||||
// }
|
||||
QString file_path = QFileDialog::getSaveFileName(this, tr("Enregister sous... "), file_name, tr("Fichiers csv (*.csv)"));
|
||||
QFile file(file_path);
|
||||
if (!file_path.isEmpty())
|
||||
{
|
||||
if (QFile::exists(file_path ))
|
||||
{
|
||||
// if file already exist -> delete it
|
||||
if (!QFile::remove(file_path) )
|
||||
{
|
||||
QMessageBox::critical(this, tr("Erreur"),
|
||||
tr("Impossible de remplacer le fichier!\n\n")+
|
||||
"Destination : "+file_path+"\n");
|
||||
}
|
||||
}
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QTextStream stream(&file);
|
||||
int r = QDialog::exec();
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
//save in csv file
|
||||
QString file_name = tr("nomenclature_") + QString(m_project ->title() + ".csv");
|
||||
// if (!file_name.endsWith(".csv")) {
|
||||
// file_name += ".csv";
|
||||
// }
|
||||
QString file_path = QFileDialog::getSaveFileName(this, tr("Enregister sous... "), file_name, tr("Fichiers csv (*.csv)"));
|
||||
QFile file(file_path);
|
||||
if (!file_path.isEmpty())
|
||||
{
|
||||
if (QFile::exists(file_path ))
|
||||
{
|
||||
// if file already exist -> delete it
|
||||
if (!QFile::remove(file_path) )
|
||||
{
|
||||
QMessageBox::critical(this, tr("Erreur"),
|
||||
tr("Impossible de remplacer le fichier!\n\n")+
|
||||
"Destination : "+file_path+"\n");
|
||||
}
|
||||
}
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QTextStream stream(&file);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
|
||||
stream << getBom() << endl;
|
||||
stream << getBom() << endl;
|
||||
#else
|
||||
stream << getBom() << &Qt::endl(stream);
|
||||
stream << getBom() << &Qt::endl(stream);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ int BOMExportDialog::exec()
|
||||
*/
|
||||
QStringList BOMExportDialog::selectedKeys() const
|
||||
{
|
||||
//Made a string list with the colomns (keys) choosen by the user
|
||||
//Made a string list with the colomns (keys) choosen by the user
|
||||
QStringList keys;
|
||||
int row = 0;
|
||||
while (auto *item = ui->m_choosen_list->item(row))
|
||||
@@ -176,7 +176,7 @@ QStringList BOMExportDialog::selectedKeys() const
|
||||
keys.append(item->data(Qt::UserRole).toString());
|
||||
++row;
|
||||
}
|
||||
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
@@ -205,14 +205,14 @@ QString BOMExportDialog::translatedKeys(const QString &key) const
|
||||
*/
|
||||
void BOMExportDialog::setUpItems()
|
||||
{
|
||||
for(QString key : QETApp::elementInfoKeys())
|
||||
{
|
||||
for(QString key : QETApp::elementInfoKeys())
|
||||
{
|
||||
auto item = new QListWidgetItem(QETApp::elementTranslatedInfoKey(key), ui->m_var_list);
|
||||
item->setData(Qt::UserRole+1, key); //We store the real key before replace "-" by "_" to easily retrieve it in the element information
|
||||
item->setData(Qt::UserRole, key.replace("-", "_")); //We must to replace "-" by "_" because "-" is a sql keyword.
|
||||
m_items_list << item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (auto key : m_export_info.keys())
|
||||
{
|
||||
auto item = new QListWidgetItem(m_export_info.value(key), ui->m_var_list);
|
||||
@@ -227,11 +227,11 @@ void BOMExportDialog::setUpItems()
|
||||
*/
|
||||
void BOMExportDialog::on_m_add_pb_clicked()
|
||||
{
|
||||
if (auto *item = ui->m_var_list->takeItem(ui->m_var_list->currentRow())) {
|
||||
ui->m_choosen_list->addItem(item);
|
||||
}
|
||||
|
||||
updateQueryLine();
|
||||
if (auto *item = ui->m_var_list->takeItem(ui->m_var_list->currentRow())) {
|
||||
ui->m_choosen_list->addItem(item);
|
||||
}
|
||||
|
||||
updateQueryLine();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,11 +239,11 @@ void BOMExportDialog::on_m_add_pb_clicked()
|
||||
*/
|
||||
void BOMExportDialog::on_m_remove_pb_clicked()
|
||||
{
|
||||
if (auto *item = ui->m_choosen_list->takeItem(ui->m_choosen_list->currentRow())) {
|
||||
ui->m_var_list->addItem(item);
|
||||
}
|
||||
|
||||
updateQueryLine();
|
||||
if (auto *item = ui->m_choosen_list->takeItem(ui->m_choosen_list->currentRow())) {
|
||||
ui->m_var_list->addItem(item);
|
||||
}
|
||||
|
||||
updateQueryLine();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,16 +251,16 @@ void BOMExportDialog::on_m_remove_pb_clicked()
|
||||
*/
|
||||
void BOMExportDialog::on_m_up_pb_clicked()
|
||||
{
|
||||
auto row = ui->m_choosen_list->currentRow();
|
||||
if(row <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto *item = ui->m_choosen_list->takeItem(row);
|
||||
ui->m_choosen_list->insertItem(row-1, item);
|
||||
ui->m_choosen_list->setCurrentItem(item);
|
||||
|
||||
updateQueryLine();
|
||||
auto row = ui->m_choosen_list->currentRow();
|
||||
if(row <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto *item = ui->m_choosen_list->takeItem(row);
|
||||
ui->m_choosen_list->insertItem(row-1, item);
|
||||
ui->m_choosen_list->setCurrentItem(item);
|
||||
|
||||
updateQueryLine();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,20 +268,20 @@ void BOMExportDialog::on_m_up_pb_clicked()
|
||||
*/
|
||||
void BOMExportDialog::on_m_down_pb_clicked()
|
||||
{
|
||||
auto row = ui->m_choosen_list->currentRow();
|
||||
if (row == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto *item = ui->m_choosen_list->takeItem(row);
|
||||
ui->m_choosen_list->insertItem(row+1, item);
|
||||
ui->m_choosen_list->setCurrentItem(item);
|
||||
|
||||
updateQueryLine();
|
||||
auto row = ui->m_choosen_list->currentRow();
|
||||
if (row == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto *item = ui->m_choosen_list->takeItem(row);
|
||||
ui->m_choosen_list->insertItem(row+1, item);
|
||||
ui->m_choosen_list->setCurrentItem(item);
|
||||
|
||||
updateQueryLine();
|
||||
}
|
||||
|
||||
void BOMExportDialog::on_m_save_name_le_textChanged(const QString &arg1) {
|
||||
ui->m_save_current_conf_pb->setDisabled(arg1.isEmpty());
|
||||
ui->m_save_current_conf_pb->setDisabled(arg1.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,17 +291,17 @@ void BOMExportDialog::on_m_save_name_le_textChanged(const QString &arg1) {
|
||||
*/
|
||||
QString BOMExportDialog::getBom()
|
||||
{
|
||||
QString data; //The string to be returned
|
||||
if (ui->m_include_header_cb->isChecked()) {
|
||||
data = headers();
|
||||
QString data; //The string to be returned
|
||||
if (ui->m_include_header_cb->isChecked()) {
|
||||
data = headers();
|
||||
data += "\n";
|
||||
}
|
||||
|
||||
QSqlQuery query (queryStr() , m_data_base);
|
||||
if (!query.exec()) {
|
||||
qDebug() << "Query error : " << query.lastError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QSqlQuery query (queryStr() , m_data_base);
|
||||
if (!query.exec()) {
|
||||
qDebug() << "Query error : " << query.lastError();
|
||||
}
|
||||
|
||||
QStringList record;
|
||||
while (query.next())
|
||||
{
|
||||
@@ -321,13 +321,13 @@ QString BOMExportDialog::getBom()
|
||||
record << sql_record.value(key).toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data += record.join(";") + "\n";
|
||||
record.clear();
|
||||
}
|
||||
|
||||
m_data_base.close();
|
||||
return data;
|
||||
|
||||
m_data_base.close();
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,10 +336,10 @@ QString BOMExportDialog::getBom()
|
||||
*/
|
||||
QString BOMExportDialog::headers() const
|
||||
{
|
||||
QString header_string;
|
||||
|
||||
if (!ui->m_edit_sql_query_cb->isChecked())
|
||||
{
|
||||
QString header_string;
|
||||
|
||||
if (!ui->m_edit_sql_query_cb->isChecked())
|
||||
{
|
||||
for (auto key : selectedKeys())
|
||||
{
|
||||
if (!header_string.isEmpty()) {
|
||||
@@ -347,32 +347,32 @@ QString BOMExportDialog::headers() const
|
||||
}
|
||||
header_string += translatedKeys(key);
|
||||
}
|
||||
|
||||
header_string += "\n";
|
||||
}
|
||||
else if (!queryStr().isEmpty()) //Try to retreive the header according to the sql query
|
||||
{
|
||||
if (queryStr().startsWith("SELECT ") && queryStr().contains("FROM"))
|
||||
{
|
||||
auto header = queryStr();
|
||||
header.remove(0, 7); //Remove SELECT from the string;
|
||||
header.truncate(header.indexOf("FROM")); //Now we only have the string between SELECT and FROM
|
||||
header.replace(" ", ""); //remove white space
|
||||
QStringList list = header.split(",");
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
for (int i=0 ; i<list.size() ; i++)
|
||||
{
|
||||
if(!header_string.isEmpty()) {
|
||||
header_string += ";";
|
||||
}
|
||||
header_string += QETApp::elementTranslatedInfoKey(list.at(i));
|
||||
}
|
||||
header_string += "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return header_string;
|
||||
|
||||
header_string += "\n";
|
||||
}
|
||||
else if (!queryStr().isEmpty()) //Try to retreive the header according to the sql query
|
||||
{
|
||||
if (queryStr().startsWith("SELECT ") && queryStr().contains("FROM"))
|
||||
{
|
||||
auto header = queryStr();
|
||||
header.remove(0, 7); //Remove SELECT from the string;
|
||||
header.truncate(header.indexOf("FROM")); //Now we only have the string between SELECT and FROM
|
||||
header.replace(" ", ""); //remove white space
|
||||
QStringList list = header.split(",");
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
for (int i=0 ; i<list.size() ; i++)
|
||||
{
|
||||
if(!header_string.isEmpty()) {
|
||||
header_string += ";";
|
||||
}
|
||||
header_string += QETApp::elementTranslatedInfoKey(list.at(i));
|
||||
}
|
||||
header_string += "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return header_string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,58 +381,58 @@ QString BOMExportDialog::headers() const
|
||||
*/
|
||||
bool BOMExportDialog::createDataBase()
|
||||
{
|
||||
//Create a sqlite data base to sort the bom
|
||||
//Create a sqlite data base to sort the bom
|
||||
m_data_base = QSqlDatabase::addDatabase("QSQLITE", "bill_of_material");
|
||||
if (!m_data_base.open())
|
||||
{
|
||||
m_data_base.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
//Create the table:
|
||||
QStringList keys;
|
||||
auto row = 0;
|
||||
while (ui->m_var_list->item(row))
|
||||
{
|
||||
keys << ui->m_var_list->item(row)->data(Qt::UserRole).toString();
|
||||
++row;
|
||||
}
|
||||
keys << "element_type" << "element_subtype";
|
||||
if (!m_data_base.open())
|
||||
{
|
||||
m_data_base.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
//Create the table:
|
||||
QStringList keys;
|
||||
auto row = 0;
|
||||
while (ui->m_var_list->item(row))
|
||||
{
|
||||
keys << ui->m_var_list->item(row)->data(Qt::UserRole).toString();
|
||||
++row;
|
||||
}
|
||||
keys << "element_type" << "element_subtype";
|
||||
keys.removeAll("designation_qty");
|
||||
|
||||
QString table("CREATE TABLE bom(");
|
||||
bool first = true;
|
||||
for (auto string : keys)
|
||||
{
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
table += ",";
|
||||
|
||||
QString table("CREATE TABLE bom(");
|
||||
bool first = true;
|
||||
for (auto string : keys)
|
||||
{
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
table += ",";
|
||||
}
|
||||
|
||||
|
||||
table += string += " VARCHAR(512)";
|
||||
}
|
||||
table += ");";
|
||||
m_data_base.exec(table);
|
||||
|
||||
QStringList bind_values;
|
||||
for (auto key : keys) {
|
||||
bind_values << key.prepend(":");
|
||||
}
|
||||
|
||||
//Prepare the query used for insert new record
|
||||
QString insert("INSERT INTO bom (" +
|
||||
keys.join(", ") +
|
||||
") VALUES (" +
|
||||
bind_values.join(", ") +
|
||||
")");
|
||||
|
||||
m_insert_query = QSqlQuery(m_data_base);
|
||||
m_insert_query.prepare(insert);
|
||||
|
||||
populateDataBase();
|
||||
|
||||
return true;
|
||||
}
|
||||
table += ");";
|
||||
m_data_base.exec(table);
|
||||
|
||||
QStringList bind_values;
|
||||
for (auto key : keys) {
|
||||
bind_values << key.prepend(":");
|
||||
}
|
||||
|
||||
//Prepare the query used for insert new record
|
||||
QString insert("INSERT INTO bom (" +
|
||||
keys.join(", ") +
|
||||
") VALUES (" +
|
||||
bind_values.join(", ") +
|
||||
")");
|
||||
|
||||
m_insert_query = QSqlQuery(m_data_base);
|
||||
m_insert_query.prepare(insert);
|
||||
|
||||
populateDataBase();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,30 +441,30 @@ bool BOMExportDialog::createDataBase()
|
||||
*/
|
||||
void BOMExportDialog::populateDataBase()
|
||||
{
|
||||
for (auto *diagram : m_project->diagrams())
|
||||
{
|
||||
ElementProvider ep(diagram);
|
||||
QList<Element *> elements_list = ep.find(Element::Simple | Element::Terminale | Element::Master);
|
||||
|
||||
//Insert all value into the database
|
||||
for (auto elmt : elements_list)
|
||||
{
|
||||
auto hash = elementInfoToString(elmt);
|
||||
for (auto key : hash.keys())
|
||||
{
|
||||
QString value = hash.value(key);
|
||||
QString bind = key.prepend(":");
|
||||
m_insert_query.bindValue(bind, value);
|
||||
}
|
||||
|
||||
m_insert_query.bindValue(":element_type", elmt->linkTypeToString());
|
||||
m_insert_query.bindValue(":element_subtype", elmt->kindInformations()["type"].toString());
|
||||
|
||||
if (!m_insert_query.exec()) {
|
||||
qDebug() << "BOMExportDialog::populateDataBase insert error : " << m_insert_query.lastError();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto *diagram : m_project->diagrams())
|
||||
{
|
||||
ElementProvider ep(diagram);
|
||||
QList<Element *> elements_list = ep.find(Element::Simple | Element::Terminale | Element::Master);
|
||||
|
||||
//Insert all value into the database
|
||||
for (auto elmt : elements_list)
|
||||
{
|
||||
auto hash = elementInfoToString(elmt);
|
||||
for (auto key : hash.keys())
|
||||
{
|
||||
QString value = hash.value(key);
|
||||
QString bind = key.prepend(":");
|
||||
m_insert_query.bindValue(bind, value);
|
||||
}
|
||||
|
||||
m_insert_query.bindValue(":element_type", elmt->linkTypeToString());
|
||||
m_insert_query.bindValue(":element_subtype", elmt->kindInformations()["type"].toString());
|
||||
|
||||
if (!m_insert_query.exec()) {
|
||||
qDebug() << "BOMExportDialog::populateDataBase insert error : " << m_insert_query.lastError();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -474,39 +474,39 @@ void BOMExportDialog::populateDataBase()
|
||||
*/
|
||||
QHash<QString, QString> BOMExportDialog::elementInfoToString(Element *elmt) const
|
||||
{
|
||||
QHash<QString, QString> keys_hash; //Use to get the element info according to the database columns name
|
||||
int row = 0;
|
||||
while (auto *item = ui->m_var_list->item(row))
|
||||
{
|
||||
keys_hash.insert(item->data(Qt::UserRole).toString(),
|
||||
item->data(Qt::UserRole+1).toString());
|
||||
++row;
|
||||
}
|
||||
|
||||
QHash<QString, QString> hash; //Store the value for each columns
|
||||
for (auto key : keys_hash.keys())
|
||||
{
|
||||
if (key == "pos") {
|
||||
hash.insert(key, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
|
||||
}
|
||||
else if (key == "folio_title") {
|
||||
hash.insert(key, elmt->diagram()->title());
|
||||
}
|
||||
else if (key == "folio_pos") {
|
||||
hash.insert(key, QString::number(elmt->diagram()->folioIndex() + 1));
|
||||
}
|
||||
else if (key == "folio_num") {
|
||||
QHash<QString, QString> keys_hash; //Use to get the element info according to the database columns name
|
||||
int row = 0;
|
||||
while (auto *item = ui->m_var_list->item(row))
|
||||
{
|
||||
keys_hash.insert(item->data(Qt::UserRole).toString(),
|
||||
item->data(Qt::UserRole+1).toString());
|
||||
++row;
|
||||
}
|
||||
|
||||
QHash<QString, QString> hash; //Store the value for each columns
|
||||
for (auto key : keys_hash.keys())
|
||||
{
|
||||
if (key == "pos") {
|
||||
hash.insert(key, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
|
||||
}
|
||||
else if (key == "folio_title") {
|
||||
hash.insert(key, elmt->diagram()->title());
|
||||
}
|
||||
else if (key == "folio_pos") {
|
||||
hash.insert(key, QString::number(elmt->diagram()->folioIndex() + 1));
|
||||
}
|
||||
else if (key == "folio_num") {
|
||||
hash.insert(key, elmt->diagram()->border_and_titleblock.finalfolio());
|
||||
}
|
||||
else if (key == "label") {
|
||||
hash.insert(key, elmt->actualLabel());
|
||||
}
|
||||
else {
|
||||
hash.insert(key, elmt->elementInformations()[keys_hash.value(key)].toString());
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
else if (key == "label") {
|
||||
hash.insert(key, elmt->actualLabel());
|
||||
}
|
||||
else {
|
||||
hash.insert(key, elmt->elementInformations()[keys_hash.value(key)].toString());
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -515,33 +515,33 @@ QHash<QString, QString> BOMExportDialog::elementInfoToString(Element *elmt) cons
|
||||
*/
|
||||
QString BOMExportDialog::queryStr() const
|
||||
{
|
||||
//User define is own query
|
||||
if (ui->m_edit_sql_query_cb->isChecked()) {
|
||||
return ui->m_sql_query->text();
|
||||
}
|
||||
//Made a string list with the colomns (keys) choosen by the user
|
||||
//User define is own query
|
||||
if (ui->m_edit_sql_query_cb->isChecked()) {
|
||||
return ui->m_sql_query->text();
|
||||
}
|
||||
//Made a string list with the colomns (keys) choosen by the user
|
||||
QStringList keys = selectedKeys();
|
||||
keys.removeAll("designation_qty");
|
||||
|
||||
QString select ="SELECT ";
|
||||
QString order_by = " ORDER BY ";
|
||||
|
||||
QString column;
|
||||
bool first = true;
|
||||
for (auto key: keys) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
column += ", ";
|
||||
order_by += ", ";
|
||||
}
|
||||
column += key;
|
||||
order_by += key;
|
||||
}
|
||||
|
||||
QString from = " FROM bom";
|
||||
|
||||
QString select ="SELECT ";
|
||||
QString order_by = " ORDER BY ";
|
||||
|
||||
QString column;
|
||||
bool first = true;
|
||||
for (auto key: keys) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
column += ", ";
|
||||
order_by += ", ";
|
||||
}
|
||||
column += key;
|
||||
order_by += key;
|
||||
}
|
||||
|
||||
QString from = " FROM bom";
|
||||
QString count = ui->m_format_as_bom_rb->isChecked() ? QString(", COUNT(*) AS designation_qty ") : QString();
|
||||
QString where;
|
||||
QString where;
|
||||
if (ui->m_all_cb->checkState() == Qt::PartiallyChecked)
|
||||
{
|
||||
if (ui->m_terminal_cb->isChecked()) {
|
||||
@@ -564,24 +564,24 @@ QString BOMExportDialog::queryStr() const
|
||||
where += str;
|
||||
}
|
||||
}
|
||||
QString where_bom;
|
||||
if(ui->m_format_as_bom_rb->isChecked())
|
||||
{
|
||||
if (where.isEmpty()) {
|
||||
where = " WHERE designation IS NOT NULL";
|
||||
} else {
|
||||
where.append(" AND designation IS NOT NULL");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString group_by = ui->m_format_as_bom_rb->isChecked() ? " GROUP BY designation" : "";
|
||||
QString where_bom;
|
||||
if(ui->m_format_as_bom_rb->isChecked())
|
||||
{
|
||||
if (where.isEmpty()) {
|
||||
where = " WHERE designation IS NOT NULL";
|
||||
} else {
|
||||
where.append(" AND designation IS NOT NULL");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString group_by = ui->m_format_as_bom_rb->isChecked() ? " GROUP BY designation" : "";
|
||||
QString q(select + column + count + from + where + where_bom + group_by + order_by);
|
||||
return q;
|
||||
return q;
|
||||
}
|
||||
|
||||
void BOMExportDialog::updateQueryLine() {
|
||||
ui->m_sql_query->setText(queryStr());
|
||||
ui->m_sql_query->setText(queryStr());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -590,16 +590,16 @@ void BOMExportDialog::updateQueryLine() {
|
||||
*/
|
||||
void BOMExportDialog::fillSavedQuery()
|
||||
{
|
||||
QFile file(QETApp::configDir() + "/bill_of_materials.json");
|
||||
if (file.open(QFile::ReadOnly))
|
||||
{
|
||||
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
|
||||
QJsonObject jso = jsd.object();
|
||||
|
||||
for (auto it = jso.begin() ; it != jso.end() ; ++it) {
|
||||
ui->m_conf_cb->addItem(it.key());
|
||||
}
|
||||
}
|
||||
QFile file(QETApp::configDir() + "/bill_of_materials.json");
|
||||
if (file.open(QFile::ReadOnly))
|
||||
{
|
||||
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
|
||||
QJsonObject jso = jsd.object();
|
||||
|
||||
for (auto it = jso.begin() ; it != jso.end() ; ++it) {
|
||||
ui->m_conf_cb->addItem(it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BOMExportDialog::on_m_format_as_nomenclature_rb_toggled(bool checked) {
|
||||
@@ -613,20 +613,20 @@ void BOMExportDialog::on_m_format_as_nomenclature_rb_toggled(bool checked) {
|
||||
*/
|
||||
void BOMExportDialog::on_m_edit_sql_query_cb_clicked()
|
||||
{
|
||||
ui->m_sql_query->setEnabled(ui->m_edit_sql_query_cb->isChecked());
|
||||
ui->m_info_widget->setDisabled(ui->m_edit_sql_query_cb->isChecked());
|
||||
ui->m_parametre_widget->setDisabled(ui->m_edit_sql_query_cb->isChecked());
|
||||
ui->m_sql_query->setEnabled(ui->m_edit_sql_query_cb->isChecked());
|
||||
ui->m_info_widget->setDisabled(ui->m_edit_sql_query_cb->isChecked());
|
||||
ui->m_parametre_widget->setDisabled(ui->m_edit_sql_query_cb->isChecked());
|
||||
ui->m_format_as_gb->setDisabled(ui->m_edit_sql_query_cb->isChecked());
|
||||
|
||||
if (ui->m_edit_sql_query_cb->isChecked() && !m_custom_query.isEmpty())
|
||||
{
|
||||
ui->m_sql_query->setText(m_custom_query);
|
||||
}
|
||||
else if (!ui->m_edit_sql_query_cb->isChecked())
|
||||
{
|
||||
m_custom_query = ui->m_sql_query->text();
|
||||
updateQueryLine();
|
||||
}
|
||||
|
||||
if (ui->m_edit_sql_query_cb->isChecked() && !m_custom_query.isEmpty())
|
||||
{
|
||||
ui->m_sql_query->setText(m_custom_query);
|
||||
}
|
||||
else if (!ui->m_edit_sql_query_cb->isChecked())
|
||||
{
|
||||
m_custom_query = ui->m_sql_query->text();
|
||||
updateQueryLine();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -635,24 +635,24 @@ void BOMExportDialog::on_m_edit_sql_query_cb_clicked()
|
||||
*/
|
||||
void BOMExportDialog::on_m_save_current_conf_pb_clicked()
|
||||
{
|
||||
QFile file(QETApp::configDir() + "/bill_of_materials.json");
|
||||
|
||||
if (file.open(QFile::ReadWrite))
|
||||
{
|
||||
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
|
||||
QJsonObject root_object;
|
||||
|
||||
if (!jsd.isEmpty())
|
||||
{
|
||||
root_object = jsd.object();
|
||||
if (root_object.contains(ui->m_save_name_le->text())) {
|
||||
root_object.remove(ui->m_save_name_le->text());
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap vm;
|
||||
QFile file(QETApp::configDir() + "/bill_of_materials.json");
|
||||
|
||||
if (file.open(QFile::ReadWrite))
|
||||
{
|
||||
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
|
||||
QJsonObject root_object;
|
||||
|
||||
if (!jsd.isEmpty())
|
||||
{
|
||||
root_object = jsd.object();
|
||||
if (root_object.contains(ui->m_save_name_le->text())) {
|
||||
root_object.remove(ui->m_save_name_le->text());
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap vm;
|
||||
vm.insert("user query", ui->m_edit_sql_query_cb->isChecked());
|
||||
|
||||
|
||||
if (ui->m_edit_sql_query_cb->isChecked()) {
|
||||
vm.insert("query", ui->m_sql_query->text());
|
||||
}
|
||||
@@ -660,13 +660,13 @@ void BOMExportDialog::on_m_save_current_conf_pb_clicked()
|
||||
{
|
||||
vm.insert("header", ui->m_include_header_cb->isChecked());
|
||||
vm.insert("format as bill of material", ui->m_format_as_bom_rb->isChecked());
|
||||
|
||||
|
||||
QJsonArray keys_array;
|
||||
for (auto key : selectedKeys()) {
|
||||
keys_array.append(QJsonValue(key));
|
||||
}
|
||||
vm.insert("selected infos", keys_array);
|
||||
|
||||
|
||||
QJsonArray selected_elements_array;
|
||||
for (auto button : m_button_group.buttons())
|
||||
{
|
||||
@@ -677,14 +677,14 @@ void BOMExportDialog::on_m_save_current_conf_pb_clicked()
|
||||
}
|
||||
vm.insert("selected elements", selected_elements_array);
|
||||
}
|
||||
|
||||
|
||||
root_object[ui->m_save_name_le->text()] = QJsonObject::fromVariantMap(vm);
|
||||
|
||||
|
||||
jsd.setObject(root_object);
|
||||
file.resize(0);
|
||||
file.write(jsd.toJson());
|
||||
}
|
||||
|
||||
|
||||
jsd.setObject(root_object);
|
||||
file.resize(0);
|
||||
file.write(jsd.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -697,20 +697,20 @@ void BOMExportDialog::on_m_load_pb_clicked()
|
||||
if (name.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QFile file(QETApp::configDir() + "/bill_of_materials.json");
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QJsonDocument jsd(QJsonDocument::fromJson(file.readAll()));
|
||||
QJsonObject jso = jsd.object();
|
||||
|
||||
|
||||
auto value = jso.value(name);
|
||||
if (!value.isObject()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
auto value_object = value.toObject();
|
||||
if (value_object["user query"].toBool())
|
||||
{
|
||||
@@ -722,13 +722,13 @@ void BOMExportDialog::on_m_load_pb_clicked()
|
||||
ui->m_edit_sql_query_cb->setChecked(false);
|
||||
ui->m_include_header_cb->setChecked(value_object["header"].toBool());
|
||||
ui->m_format_as_bom_rb->setChecked(value_object["format as bill of material"].toBool());
|
||||
|
||||
|
||||
//Ugly hack to force to remove all selected infos
|
||||
|
||||
|
||||
//Ugly hack to force to remove all selected infos
|
||||
while (auto item = ui->m_choosen_list->takeItem(0)) {
|
||||
ui->m_var_list->addItem(item);
|
||||
}
|
||||
|
||||
|
||||
QVariantList vl = value_object["selected infos"].toArray().toVariantList();
|
||||
for (auto variant : vl)
|
||||
{
|
||||
@@ -741,16 +741,16 @@ void BOMExportDialog::on_m_load_pb_clicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QJsonArray selected_elements_array = value_object["selected elements"].toArray();
|
||||
for (int id=0 ; id<selected_elements_array.size() ; ++id)
|
||||
{
|
||||
QJsonObject obj = selected_elements_array[id].toObject();
|
||||
m_button_group.button(obj["ID"].toInt())->setChecked(obj["checked"].toBool());
|
||||
}
|
||||
|
||||
|
||||
updateQueryLine();
|
||||
}
|
||||
|
||||
|
||||
on_m_edit_sql_query_cb_clicked(); //Force to update dialog
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
if(tabbed)
|
||||
ui->m_use_tab_mode_rb->setChecked(true);
|
||||
else
|
||||
ui->m_use_windows_mode_rb->setChecked(true);
|
||||
ui->m_use_windows_mode_rb->setChecked(true);
|
||||
ui->m_zoom_out_beyond_folio->setChecked(settings.value("diagrameditor/zoom-out-beyond-of-folio", false).toBool());
|
||||
ui->m_use_gesture_trackpad->setChecked(settings.value("diagramview/gestures", false).toBool());
|
||||
ui->m_save_label_paste->setChecked(settings.value("diagramcommands/erase-label-on-copy", true).toBool());
|
||||
@@ -57,8 +57,8 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
ui->m_autosave_sb->setValue(settings.value("diagrameditor/autosave-interval", 0).toInt());
|
||||
|
||||
QString fontInfos = settings.value("diagramitemfont").toString() + " " +
|
||||
settings.value("diagramitemsize").toString() + " (" +
|
||||
settings.value("diagramitemstyle").toString() + ")";
|
||||
settings.value("diagramitemsize").toString() + " (" +
|
||||
settings.value("diagramitemstyle").toString() + ")";
|
||||
ui->m_font_pb->setText(fontInfos);
|
||||
|
||||
|
||||
@@ -309,9 +309,9 @@ void GeneralConfigurationPage::on_m_font_pb_clicked()
|
||||
settings.setValue("diagramitemweight", font.weight());
|
||||
settings.setValue("diagramitemstyle", font.styleName());
|
||||
QString fontInfos = settings.value("diagramitemfont").toString() + " " +
|
||||
settings.value("diagramitemsize").toString() + " (" +
|
||||
settings.value("diagramitemstyle").toString() + ")";
|
||||
ui->m_font_pb->setText(fontInfos);
|
||||
settings.value("diagramitemsize").toString() + " (" +
|
||||
settings.value("diagramitemstyle").toString() + ")";
|
||||
ui->m_font_pb->setText(fontInfos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ void GeneralConfigurationPage::on_m_dyn_text_font_pb_clicked()
|
||||
|
||||
void GeneralConfigurationPage::on_m_common_elmt_path_cb_currentIndexChanged(int index)
|
||||
{
|
||||
if (index == 1)
|
||||
if (index == 1)
|
||||
{
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin de la collection commune"), QDir::homePath());
|
||||
if (!path.isEmpty()) {
|
||||
@@ -353,7 +353,7 @@ void GeneralConfigurationPage::on_m_common_elmt_path_cb_currentIndexChanged(int
|
||||
|
||||
void GeneralConfigurationPage::on_m_custom_elmt_path_cb_currentIndexChanged(int index)
|
||||
{
|
||||
if (index == 1)
|
||||
if (index == 1)
|
||||
{
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin de la collection utilisateur"), QDir::homePath());
|
||||
if (!path.isEmpty()) {
|
||||
@@ -367,7 +367,7 @@ void GeneralConfigurationPage::on_m_custom_elmt_path_cb_currentIndexChanged(int
|
||||
|
||||
void GeneralConfigurationPage::on_m_custom_tbt_path_cb_currentIndexChanged(int index)
|
||||
{
|
||||
if (index == 1)
|
||||
if (index == 1)
|
||||
{
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin des cartouches utilisateur"), QDir::homePath());
|
||||
if (!path.isEmpty()) {
|
||||
|
||||
@@ -37,92 +37,92 @@ class DynamicElementTextModel : public QStandardItemModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ValueType {
|
||||
textFrom =1,
|
||||
userText,
|
||||
infoText,
|
||||
compositeText,
|
||||
txtAlignment,
|
||||
size,
|
||||
font,
|
||||
color,
|
||||
pos,
|
||||
frame,
|
||||
rotation,
|
||||
textWidth,
|
||||
grpAlignment,
|
||||
grpPos,
|
||||
grpRotation,
|
||||
grpVAdjust,
|
||||
grpName,
|
||||
grpHoldBottom,
|
||||
grpFrame
|
||||
};
|
||||
|
||||
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
|
||||
~DynamicElementTextModel() override;
|
||||
|
||||
bool indexIsInGroup(const QModelIndex &index) const;
|
||||
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
|
||||
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
|
||||
QModelIndex indexFromText(DynamicElementTextItem *text) const;
|
||||
QUndoCommand *undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo = nullptr) const;
|
||||
QUndoCommand *undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo = nullptr) const;
|
||||
|
||||
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
|
||||
ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
|
||||
QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
|
||||
bool indexIsText(const QModelIndex &index) const;
|
||||
bool indexIsGroup(const QModelIndex &index) const;
|
||||
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
QStringList mimeTypes() const override;
|
||||
|
||||
enum ValueType {
|
||||
textFrom =1,
|
||||
userText,
|
||||
infoText,
|
||||
compositeText,
|
||||
txtAlignment,
|
||||
size,
|
||||
font,
|
||||
color,
|
||||
pos,
|
||||
frame,
|
||||
rotation,
|
||||
textWidth,
|
||||
grpAlignment,
|
||||
grpPos,
|
||||
grpRotation,
|
||||
grpVAdjust,
|
||||
grpName,
|
||||
grpHoldBottom,
|
||||
grpFrame
|
||||
};
|
||||
|
||||
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
|
||||
~DynamicElementTextModel() override;
|
||||
|
||||
bool indexIsInGroup(const QModelIndex &index) const;
|
||||
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
|
||||
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
|
||||
QModelIndex indexFromText(DynamicElementTextItem *text) const;
|
||||
QUndoCommand *undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo = nullptr) const;
|
||||
QUndoCommand *undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo = nullptr) const;
|
||||
|
||||
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
|
||||
ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
|
||||
QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
|
||||
bool indexIsText(const QModelIndex &index) const;
|
||||
bool indexIsGroup(const QModelIndex &index) const;
|
||||
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
QStringList mimeTypes() const override;
|
||||
|
||||
signals:
|
||||
void dataChanged();
|
||||
|
||||
private:
|
||||
QList<QStandardItem *> itemsForText(DynamicElementTextItem *deti);
|
||||
void addText(DynamicElementTextItem *deti);
|
||||
void removeText(DynamicElementTextItem *deti);
|
||||
void addGroup(ElementTextItemGroup *group);
|
||||
void removeGroup(ElementTextItemGroup *group);
|
||||
void addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
|
||||
void removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
|
||||
void enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf );
|
||||
void enableGroupRotationAndPos(ElementTextItemGroup *group);
|
||||
void itemDataChanged(QStandardItem *qsi);
|
||||
void setConnection(DynamicElementTextItem *deti, bool set);
|
||||
void setConnection(ElementTextItemGroup *group, bool set);
|
||||
void updateDataFromText(DynamicElementTextItem *deti, DynamicElementTextModel::ValueType type);
|
||||
void updateDataFromGroup(ElementTextItemGroup *group, DynamicElementTextModel::ValueType type);
|
||||
|
||||
void dataChanged();
|
||||
|
||||
private:
|
||||
QPointer<Element> m_element;
|
||||
QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list;
|
||||
QHash <ElementTextItemGroup *, QStandardItem *> m_groups_list;
|
||||
QHash <DynamicElementTextItem *, QList<QMetaObject::Connection>> m_hash_text_connect;
|
||||
QHash <ElementTextItemGroup *, QList<QMetaObject::Connection>> m_hash_group_connect;
|
||||
bool m_block_dataChanged = false;
|
||||
QList<QStandardItem *> itemsForText(DynamicElementTextItem *deti);
|
||||
void addText(DynamicElementTextItem *deti);
|
||||
void removeText(DynamicElementTextItem *deti);
|
||||
void addGroup(ElementTextItemGroup *group);
|
||||
void removeGroup(ElementTextItemGroup *group);
|
||||
void addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
|
||||
void removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group);
|
||||
void enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf );
|
||||
void enableGroupRotationAndPos(ElementTextItemGroup *group);
|
||||
void itemDataChanged(QStandardItem *qsi);
|
||||
void setConnection(DynamicElementTextItem *deti, bool set);
|
||||
void setConnection(ElementTextItemGroup *group, bool set);
|
||||
void updateDataFromText(DynamicElementTextItem *deti, DynamicElementTextModel::ValueType type);
|
||||
void updateDataFromGroup(ElementTextItemGroup *group, DynamicElementTextModel::ValueType type);
|
||||
|
||||
private:
|
||||
QPointer<Element> m_element;
|
||||
QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list;
|
||||
QHash <ElementTextItemGroup *, QStandardItem *> m_groups_list;
|
||||
QHash <DynamicElementTextItem *, QList<QMetaObject::Connection>> m_hash_text_connect;
|
||||
QHash <ElementTextItemGroup *, QList<QMetaObject::Connection>> m_hash_group_connect;
|
||||
bool m_block_dataChanged = false;
|
||||
};
|
||||
|
||||
class DynamicTextItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
|
||||
public:
|
||||
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
||||
private:
|
||||
QStringList availableInfo(DynamicElementTextItem *deti) const;
|
||||
QStringList availableInfo(DynamicElementTextItem *deti) const;
|
||||
};
|
||||
|
||||
#endif // DYNAMICELEMENTTEXTMODEL_H
|
||||
|
||||
@@ -220,10 +220,10 @@ void LinkSingleElementWidget::buildTree()
|
||||
QStringList search_list;
|
||||
QStringList str_list;
|
||||
|
||||
str_list << elmt->actualLabel();
|
||||
if(!str_list.last().isEmpty()) {
|
||||
search_list << str_list.last();
|
||||
}
|
||||
str_list << elmt->actualLabel();
|
||||
if(!str_list.last().isEmpty()) {
|
||||
search_list << str_list.last();
|
||||
}
|
||||
|
||||
str_list << elmt->elementInformations()["comment"].toString();
|
||||
if (!str_list.last().isEmpty())
|
||||
@@ -254,7 +254,7 @@ void LinkSingleElementWidget::buildTree()
|
||||
m_qtwi_strl_hash.insert(qtwi, search_list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
QVariant v = settings.value("link-element-widget/slave-state");
|
||||
if(!v.isNull())
|
||||
ui->m_tree_widget->header()->restoreState(v.toByteArray());
|
||||
@@ -319,7 +319,7 @@ void LinkSingleElementWidget::buildTree()
|
||||
if(!v.isNull())
|
||||
ui->m_tree_widget->header()->restoreState(v.toByteArray());
|
||||
}
|
||||
|
||||
|
||||
setUpCompleter();
|
||||
}
|
||||
|
||||
@@ -347,10 +347,10 @@ bool LinkSingleElementWidget::setLiveEdit(bool live_edit)
|
||||
QList <Element *> LinkSingleElementWidget::availableElements()
|
||||
{
|
||||
QList <Element *> elmt_list;
|
||||
//if element isn't free and unlink isn't pressed, return an empty list
|
||||
//if element isn't free and unlink isn't pressed, return an empty list
|
||||
if (!m_element->isFree() && !m_unlink)
|
||||
return elmt_list;
|
||||
|
||||
|
||||
if (!m_element->diagram() || !m_element->diagram()->project()) return elmt_list;
|
||||
|
||||
ElementProvider ep(m_element->diagram()->project());
|
||||
@@ -359,9 +359,9 @@ QList <Element *> LinkSingleElementWidget::availableElements()
|
||||
else
|
||||
elmt_list = ep.find(m_filter);
|
||||
|
||||
//If element is linked, remove is parent from the list
|
||||
//If element is linked, remove is parent from the list
|
||||
if(!m_element->isFree()) elmt_list.removeAll(m_element->linkedElements().first());
|
||||
|
||||
|
||||
return elmt_list;
|
||||
}
|
||||
|
||||
@@ -445,8 +445,8 @@ void LinkSingleElementWidget::setUpHeaderLabels()
|
||||
*/
|
||||
void LinkSingleElementWidget::diagramWasRemovedFromProject()
|
||||
{
|
||||
//We use a timer because if the removed diagram contain the master element linked to the edited element
|
||||
//we must to wait for this elements be unlinked, else the list of available master isn't up to date
|
||||
//We use a timer because if the removed diagram contain the master element linked to the edited element
|
||||
//we must to wait for this elements be unlinked, else the list of available master isn't up to date
|
||||
QTimer::singleShot(10, this, SLOT(updateUi()));
|
||||
}
|
||||
|
||||
@@ -473,8 +473,8 @@ void LinkSingleElementWidget::linkTriggered()
|
||||
}
|
||||
else
|
||||
{
|
||||
//In no live edit mode, we set the background of the qtwi green, to inform the user
|
||||
//which element will be linked when he press the apply button
|
||||
//In no live edit mode, we set the background of the qtwi green, to inform the user
|
||||
//which element will be linked when he press the apply button
|
||||
if (m_pending_qtwi)
|
||||
{
|
||||
for(int i=0 ; i<6 ; i++)
|
||||
@@ -559,13 +559,13 @@ void LinkSingleElementWidget::on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem
|
||||
elmt->setHighlighted(true);
|
||||
m_showed_element = elmt;
|
||||
connect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LinkSingleElementWidget::on_m_tree_widget_customContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
//add the size of the header to display the topleft of the QMenu at the position of the mouse.
|
||||
//See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea
|
||||
//add the size of the header to display the topleft of the QMenu at the position of the mouse.
|
||||
//See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea
|
||||
QPoint point = pos;
|
||||
point.ry()+=ui->m_tree_widget->header()->height();
|
||||
point = ui->m_tree_widget->mapToGlobal(point);
|
||||
@@ -606,7 +606,7 @@ void LinkSingleElementWidget::on_m_show_this_pb_clicked()
|
||||
*/
|
||||
void LinkSingleElementWidget::on_m_search_field_textEdited(const QString &arg1)
|
||||
{
|
||||
//Show all items if arg1 is empty, if not hide all items
|
||||
//Show all items if arg1 is empty, if not hide all items
|
||||
foreach(QTreeWidgetItem *qtwi, m_qtwi_elmt_hash.keys())
|
||||
qtwi->setHidden(!arg1.isEmpty());
|
||||
|
||||
@@ -624,7 +624,7 @@ void LinkSingleElementWidget::on_m_search_field_textEdited(const QString &arg1)
|
||||
}
|
||||
}
|
||||
|
||||
//Show items which match with arg1
|
||||
//Show items which match with arg1
|
||||
foreach(QTreeWidgetItem *qtwi, qtwi_list)
|
||||
qtwi->setHidden(false);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class NewConductorPotentialSelector : public AbstractPotentialSelector
|
||||
seq_num = conductor_in_potential->sequenceNum();
|
||||
number = conductor_in_potential->relatedPotentialConductors().size()+1; //We add +1 because conductor_in_potential isn't count by relatedPotentialConductors
|
||||
|
||||
c_list = conductor_in_potential->relatedPotentialConductors().values();
|
||||
c_list = conductor_in_potential->relatedPotentialConductors().values();
|
||||
c_list.append(conductor_in_potential);
|
||||
foreach(Conductor *c, c_list)
|
||||
properties_list.append(c->properties());
|
||||
|
||||
Reference in New Issue
Block a user