From 3598d349e72a15a81bfb92dc2dac047d1b97d996 Mon Sep 17 00:00:00 2001 From: blacksun Date: Thu, 9 Apr 2015 09:39:34 +0000 Subject: [PATCH] Add possibility to choose the default title block for a new project (User title block isn't supported yet) git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3901 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/configpages.cpp | 4 ++-- sources/qetproject.cpp | 18 +++++++++++++----- sources/titleblockproperties.cpp | 11 +++++++---- sources/ui/titleblockpropertieswidget.cpp | 2 ++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/sources/configpages.cpp b/sources/configpages.cpp index 1180f9eee..e0f34923c 100644 --- a/sources/configpages.cpp +++ b/sources/configpages.cpp @@ -42,9 +42,9 @@ NewDiagramPage::NewDiagramPage(QETProject *project, QWidget *parent) : //By default we set the global default properties // dimensions by default for diagram - bpw = new BorderPropertiesWidget(BorderProperties::defaultProperties()); + bpw = new BorderPropertiesWidget(BorderProperties::defaultProperties()); // default titleblock properties - ipw = new TitleBlockPropertiesWidget(TitleBlockProperties::defaultProperties(), true); + ipw = new TitleBlockPropertiesWidget(QETApp::commonTitleBlockTemplatesCollection(), TitleBlockProperties::defaultProperties(), true); // default conductor properties cpw = new ConductorPropertiesWidget(ConductorProperties::defaultProperties()); // default propertie of report label diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index 0119a7885..9c9053168 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -31,6 +31,7 @@ #include "ui/dialogwaiting.h" #include "numerotationcontext.h" #include "reportproperties.h" +#include "integrationmovetemplateshandler.h" #include @@ -445,12 +446,18 @@ TitleBlockProperties QETProject::defaultTitleBlockProperties() const { } /** - Permet de specifier le cartouche par defaut utilise lors de la creation - d'un nouveau schema dans ce projet. - @param titleblock Cartouche d'un schema -*/ + * @brief QETProject::setDefaultTitleBlockProperties + * Specify the title block to be used at the creation of a new diagram for this project + * @param titleblock + */ void QETProject::setDefaultTitleBlockProperties(const TitleBlockProperties &titleblock) { default_titleblock_properties_ = titleblock; + //Integrate the title block in this project + if (!titleblock.template_name.isEmpty()) + { + QScopedPointer m(new IntegrationMoveTitleBlockTemplatesHandler); + integrateTitleBlockTemplate(QETApp::commonTitleBlockTemplatesCollection()->location(titleblock.template_name), m.data()); + } } /** @@ -843,7 +850,8 @@ QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation // check whether a TBT having the same name already exists within this project QString target_name = dst_tbt.name(); - while (titleblocks_.templates().contains(target_name)) { + while (titleblocks_.templates().contains(target_name)) + { QET::Action action = handler -> templateAlreadyExists(src_tbt, dst_tbt); if (action == QET::Retry) { continue; diff --git a/sources/titleblockproperties.cpp b/sources/titleblockproperties.cpp index b3cfd6c56..ca28afd30 100644 --- a/sources/titleblockproperties.cpp +++ b/sources/titleblockproperties.cpp @@ -108,10 +108,11 @@ void TitleBlockProperties::fromXml(const QDomElement &e) { } /** - Exporte le cartouche dans une configuration. - @param settings Parametres a ecrire - @param prefix prefixe a ajouter devant les noms des parametres -*/ + * @brief TitleBlockProperties::toSettings + * Export the TitleBlockProperties into a QSettings + * @param settings : setting to use + * @param prefix : name to use as prefix for this property + */ void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix) const { settings.setValue(prefix + "title", title); settings.setValue(prefix + "author", author); @@ -119,6 +120,7 @@ void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix settings.setValue(prefix + "folio", folio); settings.setValue(prefix + "date", exportDate()); settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right")); + settings.setValue(prefix + "titleblocktemplate", template_name.isEmpty()? QString() : template_name); context.toSettings(settings, prefix + "properties"); } @@ -134,6 +136,7 @@ void TitleBlockProperties::fromSettings(QSettings &settings, const QString &pref folio = settings.value(prefix + "folio", "%id/%total").toString(); setDateFromString(settings.value(prefix + "date").toString()); display_at = (settings.value(prefix + "displayAt", QVariant("bottom")).toString() == "bottom" ? Qt::BottomEdge : Qt::RightEdge); + template_name = settings.value(prefix + "titleblocktemplate").toString(); context.fromSettings(settings, prefix + "properties"); } diff --git a/sources/ui/titleblockpropertieswidget.cpp b/sources/ui/titleblockpropertieswidget.cpp index 505d8bfa3..ae4d46259 100644 --- a/sources/ui/titleblockpropertieswidget.cpp +++ b/sources/ui/titleblockpropertieswidget.cpp @@ -143,7 +143,9 @@ TitleBlockProperties TitleBlockPropertiesWidget::properties() const { } if (!currentTitleBlockTemplateName().isEmpty()) + { prop.template_name = currentTitleBlockTemplateName(); + } prop.context = m_dcw -> context();