[qet] [2117] Add the removeDiagramFromProject methode for autonum (beta)

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


Revision: 2117
Author:   cfdev
Date:     2013-04-18 10:00:09 +0200 (Thu, 18 Apr 2013)
Log Message:
-----------
Add the removeDiagramFromProject methode for autonum (beta)

Modified Paths:
--------------
    trunk/sources/conductorautonumerotation.cpp
    trunk/sources/conductorautonumerotation.h
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/ui/dialogconductorautonum.cpp
    trunk/sources/ui/dialogconductorautonum.h
    trunk/sources/ui/dialogconductorautonum.ui

Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp	2013-04-16 12:36:24 UTC (rev 2116)
+++ trunk/sources/conductorautonumerotation.cpp	2013-04-18 08:00:09 UTC (rev 2117)
@@ -4,6 +4,7 @@
 #include "qetdiagrameditor.h"
 #include "QGraphicsView"
 #include "diagramcommands.h"
+#include "qetapp.h"
 
 /**
  * Constructor
@@ -83,6 +84,24 @@
 
 
 /**
+ * @brief ConductorAutoNumerotation::removeNum_ofDiagram
+ * @param dg the diagram to remove text of Conductor
+ */
+void ConductorAutoNumerotation::removeNum_ofDiagram(Diagram *dg) {
+	// Setting of application
+	QSettings &qet_settings = QETApp::settings();
+	// Get the default text of conductor from conf file
+	QString Conductor_DefaultText = qet_settings.value("defaultconductortext", "_").toString();
+	// Get all conductors presents in diagram
+	QList<Conductor *> Conductors = dg -> content().conductors();
+	// Browse all conductors and set the default value
+	for (int i=0; i<Conductors.count(); i++) {
+		Conductors.at(i) -> setText( Conductor_DefaultText );
+	}
+}
+
+
+/**
  * Constructor
  */
 NumStrategy::NumStrategy (Conductor *c):

Modified: trunk/sources/conductorautonumerotation.h
===================================================================
--- trunk/sources/conductorautonumerotation.h	2013-04-16 12:36:24 UTC (rev 2116)
+++ trunk/sources/conductorautonumerotation.h	2013-04-18 08:00:09 UTC (rev 2117)
@@ -19,7 +19,8 @@
 	void setConductor(Conductor *);
 	void numerate();
 	void setText(QString);
-
+	void removeNum_ofDiagram(Diagram *);
+	
 	protected:
 	//methods
 	void setNumStrategy ();

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2013-04-16 12:36:24 UTC (rev 2116)
+++ trunk/sources/qetdiagrameditor.cpp	2013-04-18 08:00:09 UTC (rev 2117)
@@ -1712,8 +1712,7 @@
  * @brief launch AutoNumConductor dialog
  */
 void QETDiagramEditor::conductorAutoNumProject() {
-	//TODO: Test dialog autonum CYRIL F.
-	DialogConductorAutoNum *dg = new DialogConductorAutoNum();
+	DialogConductorAutoNum *dg = new DialogConductorAutoNum(currentDiagram()->diagram(), this);
 	dg->setModal(true);
 	dg->exec();
 	

Modified: trunk/sources/ui/dialogconductorautonum.cpp
===================================================================
--- trunk/sources/ui/dialogconductorautonum.cpp	2013-04-16 12:36:24 UTC (rev 2116)
+++ trunk/sources/ui/dialogconductorautonum.cpp	2013-04-18 08:00:09 UTC (rev 2117)
@@ -2,15 +2,49 @@
 #include "ui_dialogconductorautonum.h"
 
 #include "conductorautonumerotation.h"
+#include "qetmessagebox.h"
 
-DialogConductorAutoNum::DialogConductorAutoNum(QWidget *parent) :
+DialogConductorAutoNum::DialogConductorAutoNum(Diagram *dg, QWidget *parent) :
 	QDialog(parent),
 	ui(new Ui::DialogConductorAutoNum)
 {
 	ui->setupUi(this);
+	dg_ = dg;
 }
 
 DialogConductorAutoNum::~DialogConductorAutoNum()
 {
 	delete ui;
 }
+
+/**
+ * @brief DialogConductorAutoNum::on_pushButton_delete_clicked
+ */
+void DialogConductorAutoNum::on_pushButton_delete_clicked() {
+	// TODO check if project or diagram
+	// ...
+	// Ask if user is sure to delete the conductor numerotation
+	QMessageBox::StandardButton answer = QET::MessageBox::critical(
+		this,
+		tr("Suppression des annotations conducteurs", "Attention"),
+		QString(
+			tr("Voulez vraiment supprimer les annotations conducteurs de\n%1 ?")
+		).arg(dg_ -> title()),
+		QMessageBox::Yes | QMessageBox::No,
+		QMessageBox::No
+	);
+	
+	// if yes remove all
+	if( answer ==  QMessageBox::Yes) {
+		ConductorAutoNumerotation ConductorNum;
+		ConductorNum.removeNum_ofDiagram( dg_ );
+	}
+}
+
+/**
+ * @brief Close the dialog
+ */
+void DialogConductorAutoNum::on_pushButton_close_clicked() {
+	close();
+}
+

Modified: trunk/sources/ui/dialogconductorautonum.h
===================================================================
--- trunk/sources/ui/dialogconductorautonum.h	2013-04-16 12:36:24 UTC (rev 2116)
+++ trunk/sources/ui/dialogconductorautonum.h	2013-04-18 08:00:09 UTC (rev 2117)
@@ -3,6 +3,8 @@
 
 #include <QDialog>
 
+#include "diagram.h"
+
 namespace Ui {
 	class DialogConductorAutoNum;
 }
@@ -12,11 +14,17 @@
 	Q_OBJECT
 	
 	public:
-	explicit DialogConductorAutoNum(QWidget *parent = 0);
+	explicit DialogConductorAutoNum(Diagram *dg, QWidget *parent = 0);
 	~DialogConductorAutoNum();
 	
+	private slots:
+	void on_pushButton_delete_clicked();
+	
+	void on_pushButton_close_clicked();
+	
 	private:
 	Ui::DialogConductorAutoNum *ui;
+	Diagram *dg_;
 };
 
 #endif // DIALOGCONDUCTORAUTONUM_H

Modified: trunk/sources/ui/dialogconductorautonum.ui
===================================================================
--- trunk/sources/ui/dialogconductorautonum.ui	2013-04-16 12:36:24 UTC (rev 2116)
+++ trunk/sources/ui/dialogconductorautonum.ui	2013-04-18 08:00:09 UTC (rev 2117)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>523</width>
-    <height>313</height>
+    <width>482</width>
+    <height>245</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -29,16 +29,19 @@
         <item>
          <layout class="QVBoxLayout" name="verticalLayout_3">
           <item>
-           <widget class="QRadioButton" name="radioButton">
+           <widget class="QRadioButton" name="radioButton_Diagram">
             <property name="text">
-             <string>RadioButton</string>
+             <string>Numéroter le schéma actif</string>
             </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
            </widget>
           </item>
           <item>
-           <widget class="QRadioButton" name="radioButton_2">
+           <widget class="QRadioButton" name="radioButton_Project">
             <property name="text">
-             <string>RadioButton</string>
+             <string>Numéroter le projet actif entier</string>
             </property>
            </widget>
           </item>
@@ -56,11 +59,18 @@
         <item>
          <layout class="QVBoxLayout" name="verticalLayout_5">
           <item>
-           <widget class="QCheckBox" name="checkBox">
-            <property name="text">
-             <string>CheckBox</string>
-            </property>
-           </widget>
+           <layout class="QGridLayout" name="gridLayout">
+            <item row="0" column="1">
+             <widget class="QLineEdit" name="lineEdit"/>
+            </item>
+            <item row="0" column="0">
+             <widget class="QLabel" name="label_format">
+              <property name="text">
+               <string>Format : </string>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
          </layout>
         </item>
@@ -89,6 +99,10 @@
        <property name="text">
         <string>Annotation</string>
        </property>
+       <property name="icon">
+        <iconset resource="../../qelectrotech.qrc">
+         <normaloff>:/ico/16x16/edit-select-all.png</normaloff>:/ico/16x16/edit-select-all.png</iconset>
+       </property>
       </widget>
      </item>
      <item>
@@ -96,6 +110,10 @@
        <property name="text">
         <string>Supprimer l'annotation</string>
        </property>
+       <property name="icon">
+        <iconset resource="../../qelectrotech.qrc">
+         <normaloff>:/ico/16x16/edit-delete.png</normaloff>:/ico/16x16/edit-delete.png</iconset>
+       </property>
       </widget>
      </item>
      <item>


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