mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
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.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4848 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
63
sources/ui/formulaassistantdialog.cpp
Normal file
63
sources/ui/formulaassistantdialog.cpp
Normal file
@@ -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);
|
||||||
|
}
|
||||||
50
sources/ui/formulaassistantdialog.h
Normal file
50
sources/ui/formulaassistantdialog.h
Normal file
@@ -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
|
||||||
91
sources/ui/formulaassistantdialog.ui
Normal file
91
sources/ui/formulaassistantdialog.ui
Normal file
@@ -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>
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "element.h"
|
#include "element.h"
|
||||||
#include "reportelement.h"
|
#include "reportelement.h"
|
||||||
#include "assignvariables.h"
|
#include "assignvariables.h"
|
||||||
|
#include "formulaassistantdialog.h"
|
||||||
|
|
||||||
//### BEGIN PRIVATE CLASS ###//
|
//### BEGIN PRIVATE CLASS ###//
|
||||||
|
|
||||||
@@ -251,6 +252,7 @@ void PotentialSelectorDialog::buildWidget()
|
|||||||
rb2->setChecked(true);
|
rb2->setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PotentialSelectorDialog::on_buttonBox_accepted
|
* @brief PotentialSelectorDialog::on_buttonBox_accepted
|
||||||
@@ -291,8 +293,42 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
|
|||||||
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo);
|
new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo);
|
||||||
new QPropertyUndoCommand(cond, "properties", old_value, new_value, 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)
|
else if (m_conductor)
|
||||||
|
|||||||
Reference in New Issue
Block a user