[qet] qet/qet: [4848] Add a dialog to change the formula when two potentials is linked by a folio report , and the new potential have incompatible variables like %id. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] qet/qet: [4848] Add a dialog to change the formula when two potentials is linked by a folio report , and the new potential have incompatible variables like %id.
- From: subversion@xxxxxxxxxxxxx
- Date: Sun, 15 Jan 2017 13:23:06 +0100
Revision: 4848
Author: blacksun
Date: 2017-01-15 13:23:05 +0100 (Sun, 15 Jan 2017)
Log Message:
-----------
Add a dialog to change the formula when two potentials is linked by a folio report, and the new potential have incompatible variables like %id.
Modified Paths:
--------------
trunk/sources/ui/potentialselectordialog.cpp
Added Paths:
-----------
trunk/sources/ui/formulaassistantdialog.cpp
trunk/sources/ui/formulaassistantdialog.h
trunk/sources/ui/formulaassistantdialog.ui
Added: trunk/sources/ui/formulaassistantdialog.cpp
===================================================================
--- trunk/sources/ui/formulaassistantdialog.cpp (rev 0)
+++ trunk/sources/ui/formulaassistantdialog.cpp 2017-01-15 12:23:05 UTC (rev 4848)
@@ -0,0 +1,63 @@
+/*
+ Copyright 2006-2017 The 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 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 <http://www.gnu.org/licenses/>.
+*/
+#include "formulaassistantdialog.h"
+#include "ui_formulaassistantdialog.h"
+
+#include <QPushButton>
+
+FormulaAssistantDialog::FormulaAssistantDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::FormulaAssistantDialog)
+{
+ ui->setupUi(this);
+}
+
+FormulaAssistantDialog::~FormulaAssistantDialog()
+{
+ delete ui;
+}
+
+void FormulaAssistantDialog::setForbiddenVariables(QStringList list)
+{
+ m_rx.setPattern(list.join("|"));
+}
+
+void FormulaAssistantDialog::setText(QString text)
+{
+ ui->m_label->setText(text);
+}
+
+void FormulaAssistantDialog::setFormula(QString text)
+{
+ ui->m_line_edit->setText(text);
+}
+
+QString FormulaAssistantDialog::formula() const
+{
+ return ui->m_line_edit->text();
+}
+
+void FormulaAssistantDialog::on_m_line_edit_textChanged(const QString &arg1)
+{
+ QPushButton *b = ui->m_button_box->button(QDialogButtonBox::Ok);
+
+ if (arg1.contains(m_rx))
+ b->setDisabled(true);
+ else
+ b->setEnabled(true);
+}
Added: trunk/sources/ui/formulaassistantdialog.h
===================================================================
--- trunk/sources/ui/formulaassistantdialog.h (rev 0)
+++ trunk/sources/ui/formulaassistantdialog.h 2017-01-15 12:23:05 UTC (rev 4848)
@@ -0,0 +1,50 @@
+/*
+ Copyright 2006-2017 The 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 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 <http://www.gnu.org/licenses/>.
+*/
+#ifndef FORMULAASSISTANTDIALOG_H
+#define FORMULAASSISTANTDIALOG_H
+
+#include <QDialog>
+#include <QRegularExpression>
+
+namespace Ui {
+ class FormulaAssistantDialog;
+}
+
+class FormulaAssistantDialog : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ FormulaAssistantDialog(QWidget *parent = 0);
+ ~FormulaAssistantDialog();
+
+ void setForbiddenVariables(QStringList list);
+ void setText(QString text);
+ void setFormula(QString text);
+ QString formula() const;
+
+ private slots:
+ void on_m_line_edit_textChanged(const QString &arg1);
+
+ private:
+ Ui::FormulaAssistantDialog *ui;
+ QRegularExpression m_rx;
+ QString m_formula;
+};
+
+#endif // FORMULAASSISTANTDIALOG_H
Added: trunk/sources/ui/formulaassistantdialog.ui
===================================================================
--- trunk/sources/ui/formulaassistantdialog.ui (rev 0)
+++ trunk/sources/ui/formulaassistantdialog.ui 2017-01-15 12:23:05 UTC (rev 4848)
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FormulaAssistantDialog</class>
+ <widget class="QDialog" name="FormulaAssistantDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>184</width>
+ <height>94</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Assistant de formule</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="m_label">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="m_line_edit">
+ <property name="placeholderText">
+ <string>Formule</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="m_button_box">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>m_button_box</sender>
+ <signal>accepted()</signal>
+ <receiver>FormulaAssistantDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_button_box</sender>
+ <signal>rejected()</signal>
+ <receiver>FormulaAssistantDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Modified: trunk/sources/ui/potentialselectordialog.cpp
===================================================================
--- trunk/sources/ui/potentialselectordialog.cpp 2017-01-14 17:45:46 UTC (rev 4847)
+++ trunk/sources/ui/potentialselectordialog.cpp 2017-01-15 12:23:05 UTC (rev 4848)
@@ -25,6 +25,7 @@
#include "element.h"
#include "reportelement.h"
#include "assignvariables.h"
+#include "formulaassistantdialog.h"
//### BEGIN PRIVATE CLASS ###//
@@ -251,6 +252,7 @@
rb2->setChecked(true);
}
}
+#include <QDebug>
/**
* @brief PotentialSelectorDialog::on_buttonBox_accepted
@@ -291,8 +293,42 @@
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo);
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
}
+
+ //Check if formula of the new potential have incompatible variable with folio report
+ QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM");
+ foreach(ConductorProperties cp, m_properties_list)
+ {
+ if (cp.m_formula.contains(rx))
+ {
+ QStringList forbidden_str;
+ forbidden_str << "%sequf_" << "%seqtf_" << "%seqhf_" << "%id" << "%F" << "%M" << "%LM";
+
+ QString text(tr("La formule du nouveau potentiel contient des variables incompatible avec les reports de folio.\n"
+ "Veuillez saisir une formule compatible pour ce potentiel.\n"
+ "Les variables suivante sont incompatible :\n"
+ "%sequf_ %seqtf_ %seqhf_ %id %F %M %LM"));
+ FormulaAssistantDialog fag(this);
+ fag.setForbiddenVariables(forbidden_str);
+ fag.setText(text);
+ fag.setFormula(cp.m_formula);
+ fag.exec();
+
+ QString new_formula = fag.formula();
+ QSet <Conductor *> c_list = m_report->conductors().first()->relatedPotentialConductors();
+ c_list.insert(m_report->conductors().first());
+ foreach(Conductor *cond, c_list)
+ {
+ old_value.setValue(cond->properties());
+ ConductorProperties new_properties = cond->properties();
+ new_properties.m_formula = new_formula;
+ new_value.setValue(new_properties);
+ new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
+ }
+
+ break;
+ }
+ }
}
-
}
else if (m_conductor)