From 5c6f556ad3b21ff827d3a11fb1eb383858ca7e59 Mon Sep 17 00:00:00 2001 From: Claveau Joshua Date: Thu, 9 Apr 2020 16:58:05 +0200 Subject: [PATCH] Minor revamp Remove unused include. QETproject : Default titleblock are set in the default constructor instead of set by qetdiagrameditor. conductor, border, report and xref propertie are now set in the header of QETProject instead of set by the qetdiagrameditor just after the creation of a new project. --- sources/qetdiagrameditor.cpp | 41 ++++++------------------------------ sources/qetproject.cpp | 9 ++++---- sources/qetproject.h | 9 ++++---- 3 files changed, 16 insertions(+), 43 deletions(-) diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 9d26a479d..2a73f032c 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -16,25 +16,12 @@ along with QElectroTech. If not, see . */ #include "qetdiagrameditor.h" -#include "qetapp.h" -#include "diagramcontent.h" #include "diagramview.h" -#include "diagram.h" -#include "qetgraphicsitem/element.h" #include "elementspanelwidget.h" -#include "conductorpropertieswidget.h" -#include "qetproject.h" -#include "projectview.h" #include "recentfiles.h" #include "qeticons.h" -#include "qetelementeditor.h" #include "qetmessagebox.h" -#include "qetresult.h" -#include "genericpanel.h" -#include "nomenclature.h" #include "diagramfoliolist.h" -#include "qetshapeitem.h" -#include "reportproperties.h" #include "diagrampropertieseditordockwidget.h" #include "diagrameventaddshape.h" #include "diagrameventaddimage.h" @@ -50,14 +37,10 @@ #include "addelementtextcommand.h" #include "conductornumexport.h" #include "qetgraphicstableitem.h" - -#include -#include -#include - -#include "elementscollectionmodel.h" #include "bomexportdialog.h" +#include + /** * @brief QETDiagramEditor::QETDiagramEditor @@ -889,24 +872,14 @@ void QETDiagramEditor::saveAs() { /** * @brief QETDiagramEditor::newProject - * Create an empty project + * Create a new project with an empty diagram * @return */ -bool QETDiagramEditor::newProject() { - // create new project without diagram - QETProject *new_project = new QETProject(this); - - // Set default properties for new diagram - new_project -> setDefaultBorderProperties (BorderProperties:: defaultProperties()); - new_project -> setDefaultConductorProperties (ConductorProperties:: defaultProperties()); - new_project -> setDefaultTitleBlockProperties (TitleBlockProperties::defaultProperties()); - new_project -> setDefaultReportProperties (ReportProperties:: defaultProperties()); - new_project -> setDefaultXRefProperties (XRefProperties:: defaultProperties()); - - // add new diagram +bool QETDiagramEditor::newProject() +{ + auto new_project = new QETProject(this); new_project -> addNewDiagram(); - - return(addProject(new_project)); + return addProject(new_project); } /** diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index edd7ce22d..d919a4aac 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -25,7 +25,6 @@ #include "titleblocktemplate.h" #include "ui/dialogwaiting.h" #include "numerotationcontext.h" -#include "reportproperties.h" #include "integrationmovetemplateshandler.h" #include "xmlelementcollection.h" #include "importelementdialog.h" @@ -48,6 +47,8 @@ QETProject::QETProject(QObject *parent) : QObject (parent), m_titleblocks_collection(this) { + setDefaultTitleBlockProperties(TitleBlockProperties::defaultProperties()); + m_elements_collection = new XmlElementCollection(this); init(); } @@ -438,12 +439,10 @@ void QETProject::setDefaultTitleBlockProperties(const TitleBlockProperties &titl case QET::Embedded : //Titleblock is already embedded to project return; - default: - return; } - QScopedPointer m(new IntegrationMoveTitleBlockTemplatesHandler); - integrateTitleBlockTemplate(collection -> location(titleblock.template_name), m.data()); + IntegrationMoveTitleBlockTemplatesHandler m_; + integrateTitleBlockTemplate(collection -> location(titleblock.template_name), &m_); } emit defaultTitleBlockPropertiesChanged(); } diff --git a/sources/qetproject.h b/sources/qetproject.h index 52887d189..21b2b80c5 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -25,6 +25,7 @@ #include "titleblockproperties.h" #include "templatescollection.h" #include "properties/xrefproperties.h" +#include "reportproperties.h" class Diagram; class ElementsLocation; @@ -234,15 +235,15 @@ class QETProject : public QObject /// Filepath for which this project is considered read only QString read_only_file_path_; /// Default dimensions and properties for new diagrams created within the project - BorderProperties default_border_properties_; + BorderProperties default_border_properties_ = BorderProperties::defaultProperties(); /// Default conductor properties for new diagrams created within the project - ConductorProperties default_conductor_properties_; + ConductorProperties default_conductor_properties_ = ConductorProperties::defaultProperties(); /// Default title block properties for new diagrams created within the project TitleBlockProperties default_titleblock_properties_; /// Default report properties - QString m_default_report_properties; + QString m_default_report_properties = ReportProperties::defaultProperties(); /// Default xref properties - QHash m_default_xref_properties; + QHash m_default_xref_properties = XRefProperties::defaultProperties(); /// Embedded title block templates collection TitleBlockTemplatesProjectCollection m_titleblocks_collection; /// project-wide variables that will be made available to child diagrams