mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Editor autonum dialog: add next/previous button
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3252 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -134,7 +134,7 @@ void ConductorAutoNumerotation::numerateNewConductor() {
|
|||||||
if (!conductor_ || m_diagram->conductorsAutonumName().isEmpty()) return;
|
if (!conductor_ || m_diagram->conductorsAutonumName().isEmpty()) return;
|
||||||
|
|
||||||
QString name = m_diagram -> conductorsAutonumName();
|
QString name = m_diagram -> conductorsAutonumName();
|
||||||
NumerotationContextCommands ncc (m_diagram, m_diagram->project()->conductorAutoNum(name));
|
NumerotationContextCommands ncc (m_diagram->project()->conductorAutoNum(name), m_diagram);
|
||||||
applyText(ncc.toRepresentedString());
|
applyText(ncc.toRepresentedString());
|
||||||
m_diagram->project()->addConductorAutoNum(name, ncc.next());
|
m_diagram->project()->addConductorAutoNum(name, ncc.next());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,12 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "numerotationcontextcommands.h"
|
#include "numerotationcontextcommands.h"
|
||||||
|
#include "diagram.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*/
|
*/
|
||||||
NumerotationContextCommands::NumerotationContextCommands(Diagram *d, const NumerotationContext &nc):
|
NumerotationContextCommands::NumerotationContextCommands(const NumerotationContext &nc, Diagram *d):
|
||||||
diagram_ (d),
|
diagram_ (d),
|
||||||
context_ (nc),
|
context_ (nc),
|
||||||
strategy_ (NULL)
|
strategy_ (NULL)
|
||||||
@@ -48,6 +49,21 @@ NumerotationContext NumerotationContextCommands::next() {
|
|||||||
return contextnum;
|
return contextnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief NumerotationContextCommands::previous
|
||||||
|
* @return the previous numerotation context
|
||||||
|
*/
|
||||||
|
NumerotationContext NumerotationContextCommands::previous() {
|
||||||
|
NumerotationContext contextnum;
|
||||||
|
|
||||||
|
for (int i=0; i<context_.size(); ++i) {
|
||||||
|
QStringList str = context_.itemAt(i);
|
||||||
|
setNumStrategy(str.at(0));
|
||||||
|
contextnum << strategy_ -> previous(context_, i);
|
||||||
|
}
|
||||||
|
return contextnum;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief NumerotationContextCommands::toFinalString
|
* @brief NumerotationContextCommands::toFinalString
|
||||||
* @return the string represented by the numerotation context
|
* @return the string represented by the numerotation context
|
||||||
@@ -62,7 +78,8 @@ QString NumerotationContextCommands::toRepresentedString() {
|
|||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
return (diagram_ -> defaultConductorProperties.text);
|
if (diagram_) return (diagram_ -> defaultConductorProperties.text);
|
||||||
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,6 +144,18 @@ NumerotationContext NumStrategy::nextNumber (const NumerotationContext &nc, cons
|
|||||||
return (newnc);
|
return (newnc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief NumStrategy::previousNumber
|
||||||
|
* @return the previous value of @nc at position @i
|
||||||
|
*/
|
||||||
|
NumerotationContext NumStrategy::previousNumber(const NumerotationContext &nc, const int i) const {
|
||||||
|
QStringList strl = nc.itemAt(i);
|
||||||
|
NumerotationContext newnc;
|
||||||
|
QString value = QString::number( (strl.at(1).toInt()) - (strl.at(2).toInt()) );
|
||||||
|
newnc.addValue(strl.at(0), value, strl.at(2).toInt());
|
||||||
|
return (newnc);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
@@ -150,6 +179,14 @@ NumerotationContext UnitNum::next (const NumerotationContext &nc, const int i) c
|
|||||||
return (nextNumber(nc, i));
|
return (nextNumber(nc, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief UnitNum::previous
|
||||||
|
* @return the previous NumerotationContext nc at posiiton i
|
||||||
|
*/
|
||||||
|
NumerotationContext UnitNum::previous(const NumerotationContext &nc, const int i) const {
|
||||||
|
return (previousNumber(nc, i));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
@@ -176,6 +213,14 @@ NumerotationContext TenNum::next (const NumerotationContext &nc, const int i) co
|
|||||||
return (nextNumber(nc, i));
|
return (nextNumber(nc, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TenNum::previous
|
||||||
|
* @return the previous NumerotationContext nc at posiiton i
|
||||||
|
*/
|
||||||
|
NumerotationContext TenNum::previous(const NumerotationContext &nc, const int i) const {
|
||||||
|
return (previousNumber(nc, i));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
@@ -207,6 +252,14 @@ NumerotationContext HundredNum::next (const NumerotationContext &nc, const int i
|
|||||||
return (nextNumber(nc, i));
|
return (nextNumber(nc, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HundredNum::previous
|
||||||
|
* @return the previous NumerotationContext nc at posiiton i
|
||||||
|
*/
|
||||||
|
NumerotationContext HundredNum::previous(const NumerotationContext &nc, const int i) const {
|
||||||
|
return (previousNumber(nc, i));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
@@ -230,6 +283,14 @@ NumerotationContext StringNum::next (const NumerotationContext &nc, const int i)
|
|||||||
return (nextString(nc, i));
|
return (nextString(nc, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief StringNum::previous
|
||||||
|
* @return the previous NumerotationContext nc at posiiton i
|
||||||
|
*/
|
||||||
|
NumerotationContext StringNum::previous(const NumerotationContext &nc, const int i) const {
|
||||||
|
return (nextString(nc, i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -255,3 +316,11 @@ NumerotationContext FolioNum::next (const NumerotationContext &nc, const int i)
|
|||||||
return (nextString(nc, i));
|
return (nextString(nc, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FolioNum::previous
|
||||||
|
* @return the previous NumerotationContext nc at posiiton i
|
||||||
|
*/
|
||||||
|
NumerotationContext FolioNum::previous(const NumerotationContext &nc, const int i) const {
|
||||||
|
return (nextString(nc, i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
#define NUMEROTATIONCONTEXTCOMMANDS_H
|
#define NUMEROTATIONCONTEXTCOMMANDS_H
|
||||||
|
|
||||||
#include "numerotationcontext.h"
|
#include "numerotationcontext.h"
|
||||||
#include "diagram.h"
|
|
||||||
|
|
||||||
class NumStrategy;
|
class NumStrategy;
|
||||||
|
class Diagram;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this class provide methods to handle content of NumerotationContext.
|
* this class provide methods to handle content of NumerotationContext.
|
||||||
@@ -29,9 +29,10 @@ class NumStrategy;
|
|||||||
class NumerotationContextCommands
|
class NumerotationContextCommands
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NumerotationContextCommands (Diagram *, const NumerotationContext &);
|
NumerotationContextCommands (const NumerotationContext &, Diagram * = nullptr);
|
||||||
~NumerotationContextCommands ();
|
~NumerotationContextCommands ();
|
||||||
NumerotationContext next ();
|
NumerotationContext next ();
|
||||||
|
NumerotationContext previous ();
|
||||||
QString toRepresentedString ();
|
QString toRepresentedString ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -45,14 +46,16 @@ class NumerotationContextCommands
|
|||||||
class NumStrategy
|
class NumStrategy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NumStrategy (Diagram *);
|
NumStrategy (Diagram * = nullptr);
|
||||||
virtual ~NumStrategy ();
|
virtual ~NumStrategy ();
|
||||||
virtual QString toRepresentedString (const QString) const = 0;
|
virtual QString toRepresentedString (const QString) const = 0;
|
||||||
virtual NumerotationContext next (const NumerotationContext &, const int) const = 0;
|
virtual NumerotationContext next (const NumerotationContext &, const int) const = 0;
|
||||||
|
virtual NumerotationContext previous (const NumerotationContext &, const int) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NumerotationContext nextString (const NumerotationContext &, const int) const;
|
NumerotationContext nextString (const NumerotationContext &, const int) const;
|
||||||
NumerotationContext nextNumber (const NumerotationContext &, const int) const;
|
NumerotationContext nextNumber (const NumerotationContext &, const int) const;
|
||||||
|
NumerotationContext previousNumber (const NumerotationContext &, const int) const;
|
||||||
|
|
||||||
Diagram *diagram_;
|
Diagram *diagram_;
|
||||||
};
|
};
|
||||||
@@ -63,6 +66,7 @@ class UnitNum: public NumStrategy
|
|||||||
UnitNum (Diagram *);
|
UnitNum (Diagram *);
|
||||||
QString toRepresentedString(const QString) const;
|
QString toRepresentedString(const QString) const;
|
||||||
NumerotationContext next (const NumerotationContext &, const int) const;
|
NumerotationContext next (const NumerotationContext &, const int) const;
|
||||||
|
NumerotationContext previous (const NumerotationContext &, const int) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TenNum: public NumStrategy
|
class TenNum: public NumStrategy
|
||||||
@@ -71,6 +75,7 @@ class TenNum: public NumStrategy
|
|||||||
TenNum (Diagram *);
|
TenNum (Diagram *);
|
||||||
QString toRepresentedString(const QString) const;
|
QString toRepresentedString(const QString) const;
|
||||||
NumerotationContext next (const NumerotationContext &, const int) const;
|
NumerotationContext next (const NumerotationContext &, const int) const;
|
||||||
|
NumerotationContext previous (const NumerotationContext &, const int) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HundredNum: public NumStrategy
|
class HundredNum: public NumStrategy
|
||||||
@@ -79,6 +84,7 @@ class HundredNum: public NumStrategy
|
|||||||
HundredNum (Diagram *);
|
HundredNum (Diagram *);
|
||||||
QString toRepresentedString(const QString) const;
|
QString toRepresentedString(const QString) const;
|
||||||
NumerotationContext next (const NumerotationContext &, const int) const;
|
NumerotationContext next (const NumerotationContext &, const int) const;
|
||||||
|
NumerotationContext previous (const NumerotationContext &, const int) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StringNum: public NumStrategy
|
class StringNum: public NumStrategy
|
||||||
@@ -87,6 +93,7 @@ class StringNum: public NumStrategy
|
|||||||
StringNum (Diagram *);
|
StringNum (Diagram *);
|
||||||
QString toRepresentedString(const QString) const;
|
QString toRepresentedString(const QString) const;
|
||||||
NumerotationContext next (const NumerotationContext &, const int) const;
|
NumerotationContext next (const NumerotationContext &, const int) const;
|
||||||
|
NumerotationContext previous (const NumerotationContext &, const int) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FolioNum: public NumStrategy
|
class FolioNum: public NumStrategy
|
||||||
@@ -95,6 +102,7 @@ class FolioNum: public NumStrategy
|
|||||||
FolioNum (Diagram *);
|
FolioNum (Diagram *);
|
||||||
QString toRepresentedString(const QString) const;
|
QString toRepresentedString(const QString) const;
|
||||||
NumerotationContext next (const NumerotationContext &, const int) const;
|
NumerotationContext next (const NumerotationContext &, const int) const;
|
||||||
|
NumerotationContext previous (const NumerotationContext &, const int) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NUMEROTATIONCONTEXTCOMMANDS_H
|
#endif // NUMEROTATIONCONTEXTCOMMANDS_H
|
||||||
|
|||||||
@@ -6,16 +6,20 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>259</width>
|
||||||
<height>300</height>
|
<height>42</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<property name="leftMargin">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="type_combo">
|
<widget class="QComboBox" name="type_combo">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -99,8 +103,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "numparteditorw.h"
|
#include "numparteditorw.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "qdebug.h"
|
#include "qdebug.h"
|
||||||
|
#include "numerotationcontextcommands.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -134,7 +135,6 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
|
|||||||
case QDialogButtonBox::HelpRole:
|
case QDialogButtonBox::HelpRole:
|
||||||
QMessageBox::information (this, tr("Autonum\351rotation", "title window"),
|
QMessageBox::information (this, tr("Autonum\351rotation", "title window"),
|
||||||
tr("C'est ici que vous pouvez d\351finir la mani\350re dont sera num\351rot\351 les nouveaux conducteurs.\n"
|
tr("C'est ici que vous pouvez d\351finir la mani\350re dont sera num\351rot\351 les nouveaux conducteurs.\n"
|
||||||
"-Chaque Folio poss\350de sa propre m\351thode de num\351rotation.\n"
|
|
||||||
"-Une num\351rotation est compos\351e d'une variable minimum.\n"
|
"-Une num\351rotation est compos\351e d'une variable minimum.\n"
|
||||||
"-Vous pouvez ajouter ou supprimer une variable de num\351rotation par le biais des boutons - et +.\n"
|
"-Vous pouvez ajouter ou supprimer une variable de num\351rotation par le biais des boutons - et +.\n"
|
||||||
"-Une variable de num\351rotation comprant: un type, une valeur et une incr\351mentation.\n"
|
"-Une variable de num\351rotation comprant: un type, une valeur et une incr\351mentation.\n"
|
||||||
@@ -171,3 +171,21 @@ void SelectAutonumW::applyEnable(bool b) {
|
|||||||
else
|
else
|
||||||
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
|
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SelectAutonumW::on_m_next_pb_clicked
|
||||||
|
* Increase NumerotationContext
|
||||||
|
*/
|
||||||
|
void SelectAutonumW::on_m_next_pb_clicked() {
|
||||||
|
NumerotationContextCommands ncc (toNumContext());
|
||||||
|
setContext(ncc.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SelectAutonumW::on_m_previous_pb_clicked
|
||||||
|
* Decrease NumerotationContext
|
||||||
|
*/
|
||||||
|
void SelectAutonumW::on_m_previous_pb_clicked() {
|
||||||
|
NumerotationContextCommands ncc (toNumContext());
|
||||||
|
setContext(ncc.previous());
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ class SelectAutonumW : public QWidget
|
|||||||
void applyEnable (bool = true);
|
void applyEnable (bool = true);
|
||||||
|
|
||||||
//ATTRIBUTS
|
//ATTRIBUTS
|
||||||
|
void on_m_next_pb_clicked();
|
||||||
|
|
||||||
|
void on_m_previous_pb_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SelectAutonumW *ui;
|
Ui::SelectAutonumW *ui;
|
||||||
QList <NumPartEditorW *> num_part_list_;
|
QList <NumPartEditorW *> num_part_list_;
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>432</width>
|
||||||
<height>300</height>
|
<height>273</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -25,6 +25,19 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="remove_button">
|
<widget class="QPushButton" name="remove_button">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@@ -59,6 +72,47 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="m_previous_pb">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Précédent</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qelectrotech.qrc">
|
||||||
|
<normaloff>:/ico/16x16/arrow-left.png</normaloff>:/ico/16x16/arrow-left.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="m_next_pb">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Suivant</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qelectrotech.qrc">
|
||||||
|
<normaloff>:/ico/16x16/arrow-right.png</normaloff>:/ico/16x16/arrow-right.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
Reference in New Issue
Block a user