[qet] [2114] Prepare: On changeCurrentTitleBlockTemplate combobox load the fields of the template to additional_fields_

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


Revision: 2114
Author:   cfdev
Date:     2013-04-15 22:44:19 +0200 (Mon, 15 Apr 2013)
Log Message:
-----------
Prepare: On changeCurrentTitleBlockTemplate combobox load the fields of the template to additional_fields_

Modified Paths:
--------------
    trunk/sources/titleblockpropertieswidget.cpp
    trunk/sources/titleblockpropertieswidget.h
    trunk/sources/titleblocktemplate.cpp
    trunk/sources/titleblocktemplate.h

Modified: trunk/sources/titleblockpropertieswidget.cpp
===================================================================
--- trunk/sources/titleblockpropertieswidget.cpp	2013-04-15 19:51:39 UTC (rev 2113)
+++ trunk/sources/titleblockpropertieswidget.cpp	2013-04-15 20:44:19 UTC (rev 2114)
@@ -19,6 +19,8 @@
 #include "diagramcontextwidget.h"
 #include "qeticons.h"
 #include "templatescollection.h"
+#include "titleblocktemplate.h"
+
 /**
 	Constructeur
 	@param titleblock TitleBlockProperties a afficher
@@ -249,6 +251,26 @@
 }
 
 /**
+ * @brief changeCurrentTitleBlockTemplate load the fields of the template to additional_fields_
+ * @param text
+ */
+void TitleBlockPropertiesWidget::changeCurrentTitleBlockTemplate(QString text) {
+	// delete all entry
+	additional_fields_ -> clear() ;
+	// get template
+	TitleBlockTemplate *tpl = tbt_collection_ -> getTemplate( text );
+	if(tpl != 0) {
+		// get all template fields
+		QStringList fields = tpl -> listOfVariables();
+		// set fields to additional_fields_ widget
+		DiagramContext templateContext;
+		for(int i =0; i<fields.count(); i++)
+			templateContext.addValue(fields.at(i), "");
+		setDiagramContext(templateContext);
+	}
+}
+
+/**
 	Builds the various child widgets for this widget
 */
 void TitleBlockPropertiesWidget::initWidgets(const TitleBlockProperties &titleblock) {
@@ -267,6 +289,7 @@
 	// widgets
 	titleblock_template_label = new QLabel(tr("Mod\350le :"), this);
 	titleblock_template_name = new QComboBox(this);
+	connect(titleblock_template_name, SIGNAL(currentIndexChanged(QString)),this, SLOT(changeCurrentTitleBlockTemplate(QString)) );
 	titleblock_template_button_ = new QPushButton(QET::Icons::TitleBlock, QString());
 	titleblock_template_button_ -> setMenu(titleblock_template_menu_);
 

Modified: trunk/sources/titleblockpropertieswidget.h
===================================================================
--- trunk/sources/titleblockpropertieswidget.h	2013-04-15 19:51:39 UTC (rev 2113)
+++ trunk/sources/titleblockpropertieswidget.h	2013-04-15 20:44:19 UTC (rev 2114)
@@ -52,6 +52,7 @@
 	void updateTemplateList();
 	void editCurrentTitleBlockTemplate();
 	void duplicateCurrentTitleBlockTemplate();
+	void changeCurrentTitleBlockTemplate(QString text);
 	void setDate_now();
 
 	private:

Modified: trunk/sources/titleblocktemplate.cpp
===================================================================
--- trunk/sources/titleblocktemplate.cpp	2013-04-15 19:51:39 UTC (rev 2113)
+++ trunk/sources/titleblocktemplate.cpp	2013-04-15 20:44:19 UTC (rev 2114)
@@ -1330,6 +1330,24 @@
 }
 
 /**
+	@brief Get list of variables
+	@return The list of string with variables
+*/
+QStringList TitleBlockTemplate::listOfVariables() {
+	QStringList list;
+	// run through each individual cell
+	for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
+		for (int i = 0 ; i < columns_width_.count() ; ++ i) {
+			if (cells_[i][j] -> spanner_cell || cells_[i][j] -> cell_type == TitleBlockCell::EmptyCell) continue;
+			// TODO: not works on all cases...
+			list << cells_[i][j] -> value.name().replace("%","");
+		}	
+	}
+	qDebug() << list;
+	return list;
+}
+
+/**
 	This method uses a \a painter to render the \a text of a \a cell
 	into the \a cell_rect rectangle.
 	The alignment, font_size and other cell parameters are taken into account

Modified: trunk/sources/titleblocktemplate.h
===================================================================
--- trunk/sources/titleblocktemplate.h	2013-04-15 19:51:39 UTC (rev 2113)
+++ trunk/sources/titleblocktemplate.h	2013-04-15 20:44:19 UTC (rev 2114)
@@ -106,6 +106,7 @@
 	void applyCellSpan(TitleBlockCell *);
 	void applyRowColNums();
 	void rowColsChanged();
+	QStringList listOfVariables();
 	
 	protected:
 	void loadInformation(const QDomElement &);


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