[qet] [1480] Title block properties dialog: the templates list is now dynamically updated. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 1480
Author: xavier
Date: 2012-01-25 19:02:17 +0100 (Wed, 25 Jan 2012)
Log Message:
-----------
Title block properties dialog: the templates list is now dynamically updated.
Also, it is now possible to edit and/or duplicate the default template.
Modified Paths:
--------------
branches/0.3/sources/diagramview.cpp
branches/0.3/sources/titleblock/qettemplateeditor.cpp
branches/0.3/sources/titleblockpropertieswidget.cpp
branches/0.3/sources/titleblockpropertieswidget.h
Modified: branches/0.3/sources/diagramview.cpp
===================================================================
--- branches/0.3/sources/diagramview.cpp 2012-01-25 07:29:50 UTC (rev 1479)
+++ branches/0.3/sources/diagramview.cpp 2012-01-25 18:02:17 UTC (rev 1480)
@@ -469,7 +469,7 @@
TitleBlockPropertiesWidget *titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, &popup);
if (QETProject *parent_project = scene -> project()) {
- titleblock_infos -> setTitleBlockTemplatesList(parent_project -> embeddedTitleBlockTemplates());
+ titleblock_infos -> setTitleBlockTemplatesCollection(parent_project -> embeddedTitleBlockTemplatesCollection());
titleblock_infos -> setTitleBlockTemplatesVisible(true);
// we have to parse again the TitleBlockProperties object, since the
// first parsing did not know of our templates
Modified: branches/0.3/sources/titleblock/qettemplateeditor.cpp
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.cpp 2012-01-25 07:29:50 UTC (rev 1479)
+++ branches/0.3/sources/titleblock/qettemplateeditor.cpp 2012-01-25 18:02:17 UTC (rev 1480)
@@ -111,7 +111,7 @@
*/
bool QETTitleBlockTemplateEditor::event(QEvent *event) {
if (first_activation_ && event -> type() == QEvent::WindowActivate) {
- if (duplicate_ && !opened_from_file_ && location_.isValid()) {
+ if (duplicate_ && !opened_from_file_ && location_.parentCollection()) {
// this editor is supposed to duplicate its current location
QTimer::singleShot(250, this, SLOT(duplicateCurrentLocation()));
}
@@ -139,13 +139,20 @@
// this method does not work for templates edited from the filesystem
if (opened_from_file_) return;
+ QString proposed_name;
+ if (location_.name().isEmpty()) {
+ proposed_name = tr("nouveau_modele", "template name suggestion when duplicating the default one");
+ } else {
+ proposed_name = QString("%1_copy").arg(location_.name());
+ }
+
bool accepted = false;
QString new_template_name = QInputDialog::getText(
this,
tr("Dupliquer un mod\350le de cartouche", "input dialog title"),
tr("Pour dupliquer ce mod\350le, entrez le nom voulu pour sa copie", "input dialog text"),
QLineEdit::Normal,
- QString("%1_copy").arg(location_.name()),
+ proposed_name,
&accepted
);
if (accepted) {
Modified: branches/0.3/sources/titleblockpropertieswidget.cpp
===================================================================
--- branches/0.3/sources/titleblockpropertieswidget.cpp 2012-01-25 07:29:50 UTC (rev 1479)
+++ branches/0.3/sources/titleblockpropertieswidget.cpp 2012-01-25 18:02:17 UTC (rev 1480)
@@ -17,6 +17,7 @@
*/
#include "titleblockpropertieswidget.h"
#include "qeticons.h"
+#include "templatescollection.h"
/**
Constructeur
@@ -26,7 +27,8 @@
*/
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current, QWidget *parent) :
QWidget(parent),
- display_current_date(false)
+ display_current_date(false),
+ tbt_collection_(0)
{
initWidgets(titleblock);
initLayouts();
@@ -168,6 +170,21 @@
}
/**
+ @param tbt_collection Collection from which title block templates should be read.
+*/
+void TitleBlockPropertiesWidget::setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *tbt_collection) {
+ if (!tbt_collection) return;
+ if (tbt_collection_ && tbt_collection != tbt_collection_) {
+ // forget any connection with the previous collection
+ disconnect(tbt_collection_, 0, this, 0);
+ }
+
+ tbt_collection_ = tbt_collection;
+ updateTemplateList();
+ connect(tbt_collection_, SIGNAL(changed(TitleBlockTemplatesCollection*, QString)), this, SLOT(updateTemplateList()));
+}
+
+/**
@param visible true to display the title block templates list, false to
hide it.
*/
@@ -189,6 +206,17 @@
}
/**
+ Set the currently selected title block template.
+ @param template_name Template to be selected
+*/
+void TitleBlockPropertiesWidget::setCurrentTitleBlockTemplateName(const QString &template_name) {
+ int matching_index = titleblock_template_name -> findData(template_name);
+ if (matching_index != -1) {
+ titleblock_template_name -> setCurrentIndex(matching_index);
+ }
+}
+
+/**
Adds a row in the additional fields table if needed.
*/
void TitleBlockPropertiesWidget::checkTableRows() {
@@ -201,12 +229,21 @@
}
/**
+ Update the title block templates list.
+*/
+void TitleBlockPropertiesWidget::updateTemplateList() {
+ if (!tbt_collection_) return;
+
+ QString current_template_name = currentTitleBlockTemplateName();
+ setTitleBlockTemplatesList(tbt_collection_ -> templates());
+ setCurrentTitleBlockTemplateName(current_template_name);
+}
+
+/**
Edit the currently selected title block template
*/
void TitleBlockPropertiesWidget::editCurrentTitleBlockTemplate() {
- QString current_template_name = currentTitleBlockTemplateName();
- if (current_template_name.isEmpty()) return;
- emit(editTitleBlockTemplate(current_template_name, false));
+ emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), false));
}
/**
@@ -214,9 +251,7 @@
for a name), then edit it.
*/
void TitleBlockPropertiesWidget::duplicateCurrentTitleBlockTemplate() {
- QString current_template_name = currentTitleBlockTemplateName();
- if (current_template_name.isEmpty()) return;
- emit(editTitleBlockTemplate(current_template_name, true));
+ emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), true));
}
/**
Modified: branches/0.3/sources/titleblockpropertieswidget.h
===================================================================
--- branches/0.3/sources/titleblockpropertieswidget.h 2012-01-25 07:29:50 UTC (rev 1479)
+++ branches/0.3/sources/titleblockpropertieswidget.h 2012-01-25 18:02:17 UTC (rev 1480)
@@ -19,6 +19,7 @@
#define TITLEBLOCK_PROPERTIES_WIDGET_H
#include <QtGui>
#include "titleblockproperties.h"
+class TitleBlockTemplatesCollection;
/**
Ce widget permet d'editer un objet TitleBlockProperties, c'est-a-dire les
valeurs affichees par le cartouche d'un schema.
@@ -40,12 +41,15 @@
bool isReadOnly() const;
void setReadOnly(bool);
void setTitleBlockTemplatesList(const QList<QString> &);
+ void setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *);
void setTitleBlockTemplatesVisible(bool);
QString currentTitleBlockTemplateName() const;
+ void setCurrentTitleBlockTemplateName(const QString &);
// slots:
private slots:
void checkTableRows();
+ void updateTemplateList();
void editCurrentTitleBlockTemplate();
void duplicateCurrentTitleBlockTemplate();
@@ -80,5 +84,6 @@
QLabel *additional_fields_label;
QTableWidget *additional_fields_table;
QTabBar *tabbar;
+ TitleBlockTemplatesCollection *tbt_collection_;
};
#endif