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:
blacksun
2014-08-04 16:12:59 +00:00
parent f918917c7a
commit 824e4315aa
7 changed files with 250 additions and 95 deletions

View File

@@ -134,7 +134,7 @@ void ConductorAutoNumerotation::numerateNewConductor() {
if (!conductor_ || m_diagram->conductorsAutonumName().isEmpty()) return;
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());
m_diagram->project()->addConductorAutoNum(name, ncc.next());
}

View File

@@ -16,11 +16,12 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "numerotationcontextcommands.h"
#include "diagram.h"
/**
* @brief Constructor
*/
NumerotationContextCommands::NumerotationContextCommands(Diagram *d, const NumerotationContext &nc):
NumerotationContextCommands::NumerotationContextCommands(const NumerotationContext &nc, Diagram *d):
diagram_ (d),
context_ (nc),
strategy_ (NULL)
@@ -48,6 +49,21 @@ NumerotationContext NumerotationContextCommands::next() {
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
* @return the string represented by the numerotation context
@@ -62,7 +78,8 @@ QString NumerotationContextCommands::toRepresentedString() {
}
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);
}
/**
* @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
*/
@@ -150,6 +179,14 @@ NumerotationContext UnitNum::next (const NumerotationContext &nc, const int i) c
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
*/
@@ -176,6 +213,14 @@ NumerotationContext TenNum::next (const NumerotationContext &nc, const int i) co
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
*/
@@ -207,6 +252,14 @@ NumerotationContext HundredNum::next (const NumerotationContext &nc, const int 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
*/
@@ -230,6 +283,14 @@ NumerotationContext StringNum::next (const NumerotationContext &nc, const int 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
@@ -255,3 +316,11 @@ NumerotationContext FolioNum::next (const NumerotationContext &nc, const int 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));
}

View File

@@ -19,9 +19,9 @@
#define NUMEROTATIONCONTEXTCOMMANDS_H
#include "numerotationcontext.h"
#include "diagram.h"
class NumStrategy;
class Diagram;
/**
* this class provide methods to handle content of NumerotationContext.
@@ -29,9 +29,10 @@ class NumStrategy;
class NumerotationContextCommands
{
public:
NumerotationContextCommands (Diagram *, const NumerotationContext &);
NumerotationContextCommands (const NumerotationContext &, Diagram * = nullptr);
~NumerotationContextCommands ();
NumerotationContext next ();
NumerotationContext previous ();
QString toRepresentedString ();
private:
@@ -45,14 +46,16 @@ class NumerotationContextCommands
class NumStrategy
{
public:
NumStrategy (Diagram *);
NumStrategy (Diagram * = nullptr);
virtual ~NumStrategy ();
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:
NumerotationContext nextString (const NumerotationContext &, const int) const;
NumerotationContext nextNumber (const NumerotationContext &, const int) const;
NumerotationContext previousNumber (const NumerotationContext &, const int) const;
Diagram *diagram_;
};
@@ -62,7 +65,8 @@ class UnitNum: public NumStrategy
public:
UnitNum (Diagram *);
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
@@ -70,7 +74,8 @@ class TenNum: public NumStrategy
public:
TenNum (Diagram *);
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
@@ -78,7 +83,8 @@ class HundredNum: public NumStrategy
public:
HundredNum (Diagram *);
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
@@ -86,7 +92,8 @@ class StringNum: public NumStrategy
public:
StringNum (Diagram *);
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
@@ -94,7 +101,8 @@ class FolioNum: public NumStrategy
public:
FolioNum (Diagram *);
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

View File

@@ -6,99 +6,101 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>259</width>
<height>42</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<widget class="QComboBox" name="type_combo">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<widget class="QComboBox" name="type_combo">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Chiffre 1</string>
</property>
</item>
<item>
<property name="text">
<string>Chiffre 01</string>
</property>
</item>
<item>
<property name="text">
<string>Chiffre 001</string>
</property>
</item>
<item>
<property name="text">
<string>Texte</string>
</property>
</item>
<item>
<property name="text">
<string>N° folio</string>
</property>
</item>
</widget>
<property name="text">
<string>Chiffre 1</string>
</property>
</item>
<item>
<widget class="QLineEdit" name="value_field">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<property name="text">
<string>Chiffre 01</string>
</property>
</item>
<item>
<widget class="QSpinBox" name="increase_spinBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
<property name="text">
<string>Chiffre 001</string>
</property>
</item>
</layout>
<item>
<property name="text">
<string>Texte</string>
</property>
</item>
<item>
<property name="text">
<string>N° folio</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="value_field">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="increase_spinBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>

View File

@@ -20,6 +20,7 @@
#include "numparteditorw.h"
#include <QMessageBox>
#include "qdebug.h"
#include "numerotationcontextcommands.h"
/**
* Constructor
@@ -134,7 +135,6 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
case QDialogButtonBox::HelpRole:
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"
"-Chaque Folio poss\350de sa propre m\351thode de num\351rotation.\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"
"-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
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());
}

View File

@@ -52,6 +52,10 @@ class SelectAutonumW : public QWidget
void applyEnable (bool = true);
//ATTRIBUTS
void on_m_next_pb_clicked();
void on_m_previous_pb_clicked();
private:
Ui::SelectAutonumW *ui;
QList <NumPartEditorW *> num_part_list_;

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>432</width>
<height>273</height>
</rect>
</property>
<property name="windowTitle">
@@ -25,6 +25,19 @@
<property name="spacing">
<number>0</number>
</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>
<widget class="QPushButton" name="remove_button">
<property name="toolTip">
@@ -59,6 +72,47 @@
</property>
</widget>
</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>
</item>
<item>