From e7ac7c9c403e424cd6ba71acd3caa4ac5413c4fc Mon Sep 17 00:00:00 2001 From: cfdev Date: Mon, 15 Apr 2013 20:44:19 +0000 Subject: [PATCH] Prepare: On changeCurrentTitleBlockTemplate combobox load the fields of the template to additional_fields_ git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2114 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/titleblockpropertieswidget.cpp | 23 +++++++++++++++++++++++ sources/titleblockpropertieswidget.h | 1 + sources/titleblocktemplate.cpp | 18 ++++++++++++++++++ sources/titleblocktemplate.h | 1 + 4 files changed, 43 insertions(+) diff --git a/sources/titleblockpropertieswidget.cpp b/sources/titleblockpropertieswidget.cpp index 5635e3951..5fbceac65 100644 --- a/sources/titleblockpropertieswidget.cpp +++ b/sources/titleblockpropertieswidget.cpp @@ -19,6 +19,8 @@ #include "diagramcontextwidget.h" #include "qeticons.h" #include "templatescollection.h" +#include "titleblocktemplate.h" + /** Constructeur @param titleblock TitleBlockProperties a afficher @@ -248,6 +250,26 @@ void TitleBlockPropertiesWidget::duplicateCurrentTitleBlockTemplate() { emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), true)); } +/** + * @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 setMenu(titleblock_template_menu_); diff --git a/sources/titleblockpropertieswidget.h b/sources/titleblockpropertieswidget.h index 14fe51de2..3d01842f3 100644 --- a/sources/titleblockpropertieswidget.h +++ b/sources/titleblockpropertieswidget.h @@ -52,6 +52,7 @@ class TitleBlockPropertiesWidget : public QWidget { void updateTemplateList(); void editCurrentTitleBlockTemplate(); void duplicateCurrentTitleBlockTemplate(); + void changeCurrentTitleBlockTemplate(QString text); void setDate_now(); private: diff --git a/sources/titleblocktemplate.cpp b/sources/titleblocktemplate.cpp index 66352b459..3e6129321 100644 --- a/sources/titleblocktemplate.cpp +++ b/sources/titleblocktemplate.cpp @@ -1329,6 +1329,24 @@ QString TitleBlockTemplate::interpreteVariables(const QString &string, const Dia return(interpreted_string); } +/** + @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. diff --git a/sources/titleblocktemplate.h b/sources/titleblocktemplate.h index 77c455d99..9dee14917 100644 --- a/sources/titleblocktemplate.h +++ b/sources/titleblocktemplate.h @@ -106,6 +106,7 @@ class TitleBlockTemplate : public QObject { void applyCellSpan(TitleBlockCell *); void applyRowColNums(); void rowColsChanged(); + QStringList listOfVariables(); protected: void loadInformation(const QDomElement &);