[qet] [1883] The TitleBlockPropertiesWidget class was unable to load a diagram context apart from the one passed to the constructor . |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] [1883] The TitleBlockPropertiesWidget class was unable to load a diagram context apart from the one passed to the constructor .
- From: subversion@xxxxxxxxxxxxx
- Date: Fri, 29 Jun 2012 07:21:44 +0200
Revision: 1883
Author: xavier
Date: 2012-06-29 07:21:43 +0200 (Fri, 29 Jun 2012)
Log Message:
-----------
The TitleBlockPropertiesWidget class was unable to load a diagram context apart from the one passed to the constructor.
Modified Paths:
--------------
trunk/sources/titleblockpropertieswidget.cpp
trunk/sources/titleblockpropertieswidget.h
Modified: trunk/sources/titleblockpropertieswidget.cpp
===================================================================
--- trunk/sources/titleblockpropertieswidget.cpp 2012-06-29 05:21:41 UTC (rev 1882)
+++ trunk/sources/titleblockpropertieswidget.cpp 2012-06-29 05:21:43 UTC (rev 1883)
@@ -125,9 +125,35 @@
titleblock_template_name -> setCurrentIndex(matching_index);
}
}
+
+ setDiagramContext(titleblock.context);
}
/**
+ Clear the custom variables list.
+*/
+void TitleBlockPropertiesWidget::clearDiagramContext() {
+ additional_fields_table -> clearContents();
+ for (int i = 1 ; i < additional_fields_table -> rowCount() ; ++ i) {
+ additional_fields_table -> removeRow(i);
+ }
+}
+
+/**
+ Clear the custom variables table then add the key/value pairs from \a context to it.
+*/
+void TitleBlockPropertiesWidget::setDiagramContext(const DiagramContext &context) {
+ clearDiagramContext();
+ int i = 0;
+ foreach (QString key, context.keys()) {
+ additional_fields_table -> setItem(i, 0, new QTableWidgetItem(key));
+ additional_fields_table -> setItem(i, 1, new QTableWidgetItem(context[key].toString()));
+ ++ i;
+ }
+ checkTableRows();
+}
+
+/**
@return true si le widget affiche la proposition "Date courante", false sinon
*/
bool TitleBlockPropertiesWidget::displayCurrentDate() const {
@@ -348,17 +374,12 @@
additional_fields_format_label -> setWordWrap(true);
additional_fields_format_label -> setAlignment(Qt::AlignJustify);
- int num_rows = titleblock.context.keys().count() + 1;
- additional_fields_table = new QTableWidget(num_rows, 2);
+ additional_fields_table = new QTableWidget(0, 2);
+ additional_fields_table -> setSelectionMode(QAbstractItemView::SingleSelection);
additional_fields_table -> setHorizontalHeaderLabels(QStringList() << tr("Nom") << tr("Valeur"));
additional_fields_table -> horizontalHeader() -> setStretchLastSection(true);
- int i = 0;
- foreach (QString key, titleblock.context.keys()) {
- additional_fields_table -> setItem(i, 0, new QTableWidgetItem(key));
- additional_fields_table -> setItem(i, 1, new QTableWidgetItem(titleblock.context[key].toString()));
- ++ i;
- }
+ setDiagramContext(titleblock.context);
refreshFieldsFormatLabel();
connect(additional_fields_table, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(checkTableRows()));
Modified: trunk/sources/titleblockpropertieswidget.h
===================================================================
--- trunk/sources/titleblockpropertieswidget.h 2012-06-29 05:21:41 UTC (rev 1882)
+++ trunk/sources/titleblockpropertieswidget.h 2012-06-29 05:21:43 UTC (rev 1883)
@@ -37,6 +37,8 @@
public:
TitleBlockProperties titleBlockProperties() const;
void setTitleBlockProperties(const TitleBlockProperties &);
+ void clearDiagramContext();
+ void setDiagramContext(const DiagramContext &);
bool displayCurrentDate() const;
bool isReadOnly() const;
void setReadOnly(bool);