[qet] [3252] Editor autonum dialog: add next/previous button

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 3252
Author:   blacksun
Date:     2014-08-04 18:12:59 +0200 (Mon, 04 Aug 2014)
Log Message:
-----------
Editor autonum dialog: add next/previous button

Modified Paths:
--------------
    trunk/sources/conductorautonumerotation.cpp
    trunk/sources/numerotationcontextcommands.cpp
    trunk/sources/numerotationcontextcommands.h
    trunk/sources/ui/numparteditorw.ui
    trunk/sources/ui/selectautonumw.cpp
    trunk/sources/ui/selectautonumw.h
    trunk/sources/ui/selectautonumw.ui

Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp	2014-08-04 14:39:57 UTC (rev 3251)
+++ trunk/sources/conductorautonumerotation.cpp	2014-08-04 16:12:59 UTC (rev 3252)
@@ -134,7 +134,7 @@
 	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());
 }

Modified: trunk/sources/numerotationcontextcommands.cpp
===================================================================
--- trunk/sources/numerotationcontextcommands.cpp	2014-08-04 14:39:57 UTC (rev 3251)
+++ trunk/sources/numerotationcontextcommands.cpp	2014-08-04 16:12:59 UTC (rev 3252)
@@ -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)
@@ -49,6 +50,21 @@
 }
 
 /**
+ * @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 @@
 		}
 		return num;
 	}
-	return (diagram_ -> defaultConductorProperties.text);
+	if (diagram_) return (diagram_ -> defaultConductorProperties.text);
+	return QString();
 }
 
 /**
@@ -128,6 +145,18 @@
 }
 
 /**
+ * @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
  */
 UnitNum::UnitNum(Diagram *d):
@@ -151,6 +180,14 @@
 }
 
 /**
+ * @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
  */
 TenNum::TenNum (Diagram *d):
@@ -177,6 +214,14 @@
 }
 
 /**
+ * @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
  */
 HundredNum::HundredNum (Diagram *d):
@@ -208,6 +253,14 @@
 }
 
 /**
+ * @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
  */
 StringNum::StringNum (Diagram *d):
@@ -230,7 +283,15 @@
 	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 @@
 	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));
+}
+

Modified: trunk/sources/numerotationcontextcommands.h
===================================================================
--- trunk/sources/numerotationcontextcommands.h	2014-08-04 14:39:57 UTC (rev 3251)
+++ trunk/sources/numerotationcontextcommands.h	2014-08-04 16:12:59 UTC (rev 3252)
@@ -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 NumerotationContextCommands
 {
 	public:
-	NumerotationContextCommands (Diagram *, const NumerotationContext &);
+	NumerotationContextCommands (const NumerotationContext &, Diagram * = nullptr);
 	~NumerotationContextCommands ();
 	NumerotationContext next ();
+	NumerotationContext previous ();
 	QString toRepresentedString ();
 
 	private:
@@ -45,14 +46,16 @@
 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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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

Modified: trunk/sources/ui/numparteditorw.ui
===================================================================
--- trunk/sources/ui/numparteditorw.ui	2014-08-04 14:39:57 UTC (rev 3251)
+++ trunk/sources/ui/numparteditorw.ui	2014-08-04 16:12:59 UTC (rev 3252)
@@ -6,100 +6,102 @@
    <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>
  <resources/>

Modified: trunk/sources/ui/selectautonumw.cpp
===================================================================
--- trunk/sources/ui/selectautonumw.cpp	2014-08-04 14:39:57 UTC (rev 3251)
+++ trunk/sources/ui/selectautonumw.cpp	2014-08-04 16:12:59 UTC (rev 3252)
@@ -20,6 +20,7 @@
 #include "numparteditorw.h"
 #include <QMessageBox>
 #include "qdebug.h"
+#include "numerotationcontextcommands.h"
 
 /**
  * Constructor
@@ -134,7 +135,6 @@
 		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 @@
 	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());
+}

Modified: trunk/sources/ui/selectautonumw.h
===================================================================
--- trunk/sources/ui/selectautonumw.h	2014-08-04 14:39:57 UTC (rev 3251)
+++ trunk/sources/ui/selectautonumw.h	2014-08-04 16:12:59 UTC (rev 3252)
@@ -52,6 +52,10 @@
 		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_;

Modified: trunk/sources/ui/selectautonumw.ui
===================================================================
--- trunk/sources/ui/selectautonumw.ui	2014-08-04 14:39:57 UTC (rev 3251)
+++ trunk/sources/ui/selectautonumw.ui	2014-08-04 16:12:59 UTC (rev 3252)
@@ -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">
@@ -26,6 +26,19 @@
          <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">
            <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Supprimer une variable de numérotation&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@@ -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>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/