diff --git a/sources/diagramview.h b/sources/diagramview.h index e616a9a5e..439bf7c2d 100644 --- a/sources/diagramview.h +++ b/sources/diagramview.h @@ -120,8 +120,6 @@ class DiagramView : public QGraphicsView void findElementRequired(const ElementsLocation &); /// Signal emitted when users wish to edit an element from the diagram void editElementRequired(const ElementsLocation &); - /// Signal emitted when users want to edit and/or duplicate an existing title block template - void editTitleBlockTemplate(const QString &, bool); /// Signal emmitted when diagram must be show void showDiagram (Diagram *); diff --git a/sources/projectconfigpages.h b/sources/projectconfigpages.h index 501dcfe41..a1fbd84a6 100644 --- a/sources/projectconfigpages.h +++ b/sources/projectconfigpages.h @@ -1,5 +1,3 @@ - - /* Copyright 2006-2016 The QElectroTech Team This file is part of QElectroTech. @@ -20,13 +18,11 @@ #ifndef PROJECTCONFIGPAGES_H #define PROJECTCONFIGPAGES_H #include "configpage.h" -#include class QLabel; class QLineEdit; class QETProject; class BorderPropertiesWidget; -class TitleBlockPropertiesWidget; class ConductorPropertiesWidget; class DiagramContextWidget; class ReportPropertieWidget; @@ -37,6 +33,8 @@ class QPushButton; class FolioAutonumberingW; class ElementAutonumberingW; class AutoNumberingManagementW; +class QTabWidget; +class QScrollArea; /** This class, derived from ConfigPage, aims at providing the basic skeleton diff --git a/sources/projectview.cpp b/sources/projectview.cpp index b75183431..d4c7bc151 100644 --- a/sources/projectview.cpp +++ b/sources/projectview.cpp @@ -89,7 +89,7 @@ void ProjectView::setProject(QETProject *project) { @return la liste des schemas ouverts dans le projet */ QList ProjectView::diagrams() const { - return(diagrams_); + return(m_diagram_view_list); } /** @@ -406,27 +406,26 @@ void ProjectView::addNewDiagramFolioList() { * @param front: true add page at front * false add page at back */ -void ProjectView::addDiagram(DiagramView *diagram) { - if (!diagram) return; +void ProjectView::addDiagram(DiagramView *diagram_view) { + if (!diagram_view) return; // check diagram isn't present in the project - if (diagram_ids_.values().contains(diagram)) return; + if (diagram_ids_.values().contains(diagram_view)) return; // Add new tab for the diagram - m_tab -> addTab(diagram, QET::Icons::Diagram, diagram -> title()); - diagram -> setFrameStyle(QFrame::Plain | QFrame::NoFrame); + m_tab -> addTab(diagram_view, QET::Icons::Diagram, diagram_view -> title()); + diagram_view -> setFrameStyle(QFrame::Plain | QFrame::NoFrame); - diagrams_ << diagram; + m_diagram_view_list << diagram_view; rebuildDiagramsMap(); - connect(diagram, SIGNAL(showDiagram(Diagram*)), this, SLOT(showDiagram(Diagram*))); - connect(diagram, SIGNAL(titleChanged(DiagramView *, const QString &)), this, SLOT(updateTabTitle(DiagramView *, const QString &))); - connect(diagram, SIGNAL(findElementRequired(const ElementsLocation &)), this, SIGNAL(findElementRequired(const ElementsLocation &))); - connect(diagram, SIGNAL(editElementRequired(const ElementsLocation &)), this, SIGNAL(editElementRequired(const ElementsLocation &))); - connect(diagram, SIGNAL(editTitleBlockTemplate(const QString &, bool)), this, SLOT(editTitleBlockTemplateRequired(const QString &, bool))); + connect(diagram_view, SIGNAL(showDiagram(Diagram*)), this, SLOT(showDiagram(Diagram*))); + connect(diagram_view, SIGNAL(titleChanged(DiagramView *, const QString &)), this, SLOT(updateTabTitle(DiagramView *, const QString &))); + connect(diagram_view, SIGNAL(findElementRequired(const ElementsLocation &)), this, SIGNAL(findElementRequired(const ElementsLocation &))); + connect(diagram_view, SIGNAL(editElementRequired(const ElementsLocation &)), this, SIGNAL(editElementRequired(const ElementsLocation &))); // signal diagram was added - emit(diagramAdded(diagram)); + emit(diagramAdded(diagram_view)); } /** @@ -456,7 +455,7 @@ void ProjectView::removeDiagram(DiagramView *diagram_view) { // enleve le DiagramView des onglets int diagram_tab_id = diagram_ids_.key(diagram_view); m_tab -> removeTab(diagram_tab_id); - diagrams_.removeAll(diagram_view); + m_diagram_view_list.removeAll(diagram_view); rebuildDiagramsMap(); // supprime le DiagramView, puis le Diagram @@ -961,22 +960,6 @@ void ProjectView::tabMoved(int from, int to) { emit(diagramOrderChanged(this, from, to)); } -/** - Require the edition of the \a template_name title blocke template. - @param template_name Name of the tempalte to be edited - @param duplicate If true, this methd will ask the user for a template name - in order to duplicate the \a template_name template -*/ -void ProjectView::editTitleBlockTemplateRequired(const QString &template_name, bool duplicate) { - if (!m_project) return; - emit( - editTitleBlockTemplate( - m_project -> embeddedTitleBlockTemplatesCollection() -> location(template_name), - duplicate - ) - ); -} - /** @param diagram Schema a trouver @return le DiagramView correspondant au schema passe en parametre, ou 0 si @@ -998,7 +981,7 @@ void ProjectView::rebuildDiagramsMap() { // vide la map diagram_ids_.clear(); - foreach(DiagramView *diagram_view, diagrams_) { + foreach(DiagramView *diagram_view, m_diagram_view_list) { int dv_idx = m_tab -> indexOf(diagram_view); if (dv_idx == -1) continue; diagram_ids_.insert(dv_idx, diagram_view); diff --git a/sources/projectview.h b/sources/projectview.h index 7bbb4ef17..26b61d7fc 100644 --- a/sources/projectview.h +++ b/sources/projectview.h @@ -99,7 +99,6 @@ class ProjectView : public QWidget { void updateWindowTitle(); void updateTabTitle(DiagramView *, const QString &); void tabMoved(int, int); - void editTitleBlockTemplateRequired(const QString &, bool); signals: void diagramAdded(DiagramView *); @@ -111,7 +110,6 @@ class ProjectView : public QWidget { // relayed signals void findElementRequired(const ElementsLocation &); void editElementRequired(const ElementsLocation &); - void editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool); private: void initActions(); @@ -145,7 +143,7 @@ class ProjectView : public QWidget { QLabel *fallback_label_; QTabWidget *m_tab; QMap diagram_ids_; - QList diagrams_; + QList m_diagram_view_list; }; Q_DECLARE_OPERATORS_FOR_FLAGS(ProjectView::ProjectSaveOptions) #endif diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index fc2ec490a..4d130b27e 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -1194,6 +1194,7 @@ void QETApp::configureQET() { // cree le dialogue ConfigDialog cd; cd.setWindowTitle(tr("Configurer QElectroTech", "window title")); + cd.setWindowModality(Qt::WindowModal); cd.addPage(new GeneralConfigurationPage()); cd.addPage(new NewDiagramPage()); cd.addPage(new ExportConfigPage()); diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index e820ea47b..488095678 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -1501,7 +1501,6 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view) //Manage request for edit or find element and titleblock connect(project_view, SIGNAL(findElementRequired(const ElementsLocation &)), this, SLOT(findElementInPanel(const ElementsLocation &))); connect(project_view, SIGNAL(editElementRequired(const ElementsLocation &)), this, SLOT(editElementInEditor(const ElementsLocation &))); - connect(project_view, SIGNAL(editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool)), QETApp::instance(), SLOT(openTitleBlockTemplate(TitleBlockTemplateLocation, bool))); // display error messages sent by the project view connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &))); diff --git a/sources/ui/diagrampropertiesdialog.cpp b/sources/ui/diagrampropertiesdialog.cpp index 20883ead5..eb1e4e8af 100644 --- a/sources/ui/diagrampropertiesdialog.cpp +++ b/sources/ui/diagrampropertiesdialog.cpp @@ -54,15 +54,15 @@ DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *pare //Title block widget TitleBlockPropertiesWidget *titleblock_infos; - if (QETProject *parent_project = diagram -> project()) { - titleblock_infos = new TitleBlockPropertiesWidget(parent_project -> embeddedTitleBlockTemplatesCollection(), titleblock, false, diagram->project(), this); - connect(titleblock_infos, SIGNAL(editTitleBlockTemplate(QString, bool)), diagram->views().first(), SIGNAL(editTitleBlockTemplate(QString, bool))); - } + + if (QETProject *parent_project = diagram -> project()) + titleblock_infos = new TitleBlockPropertiesWidget(parent_project -> embeddedTitleBlockTemplatesCollection(), titleblock, false, diagram->project(), this); else - titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, diagram->project(), this); + titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, diagram->project(), this); + titleblock_infos -> setReadOnly(diagram_is_read_only); - connect(titleblock_infos,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(editAutoFolioNum())); - titleblock_infos->setMinimumSize(590,480); //Minimum Size needed for correct display + connect(titleblock_infos,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(editAutoFolioNum())); + titleblock_infos->setMinimumSize(590,480); //Minimum Size needed for correct display //Conductor widget ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(conductors, this); diff --git a/sources/ui/projectpropertiesdialog.cpp b/sources/ui/projectpropertiesdialog.cpp index c8152182f..d9d43259d 100644 --- a/sources/ui/projectpropertiesdialog.cpp +++ b/sources/ui/projectpropertiesdialog.cpp @@ -54,6 +54,7 @@ ProjectPropertiesDialog::~ProjectPropertiesDialog () { * execute this dialog. */ void ProjectPropertiesDialog::exec() { + m_properties_dialog->setWindowModality(Qt::WindowModal); m_properties_dialog -> exec(); } diff --git a/sources/ui/titleblockpropertieswidget.cpp b/sources/ui/titleblockpropertieswidget.cpp index 911283c3e..105ef08e1 100644 --- a/sources/ui/titleblockpropertieswidget.cpp +++ b/sources/ui/titleblockpropertieswidget.cpp @@ -20,6 +20,7 @@ #include "templatescollection.h" #include "qeticons.h" #include "titleblocktemplate.h" +#include "qetapp.h" #include /** @@ -216,6 +217,20 @@ TitleBlockProperties TitleBlockPropertiesWidget::propertiesAutoNum(QString autoN return prop; } +TitleBlockTemplateLocation TitleBlockPropertiesWidget::currentTitleBlockLocation() const +{ + QET::QetCollection qc = m_map_index_to_collection_type.at(ui->m_tbt_cb->currentIndex()); + TitleBlockTemplatesCollection *collection = nullptr; + foreach (TitleBlockTemplatesCollection *c, m_tbt_collection_list) + if (c -> collection() == qc) + collection = c; + + if (!collection) + return TitleBlockTemplateLocation(); + + return collection->location(currentTitleBlockTemplateName()); +} + /** * @brief TitleBlockPropertiesWidget::setTitleBlockTemplatesVisible * if true, title block template combo box and menu button is visible @@ -313,11 +328,11 @@ int TitleBlockPropertiesWidget::getIndexFor(const QString &tbt_name, const QET:: } void TitleBlockPropertiesWidget::editCurrentTitleBlockTemplate() { - emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), false)); + QETApp::instance()->openTitleBlockTemplate(currentTitleBlockLocation(), false); } void TitleBlockPropertiesWidget::duplicateCurrentTitleBlockTemplate() { - emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), true)); + QETApp::instance()->openTitleBlockTemplate(currentTitleBlockLocation(), true); } /** diff --git a/sources/ui/titleblockpropertieswidget.h b/sources/ui/titleblockpropertieswidget.h index 2ffb1b48f..55ebb2925 100644 --- a/sources/ui/titleblockpropertieswidget.h +++ b/sources/ui/titleblockpropertieswidget.h @@ -47,6 +47,7 @@ class TitleBlockPropertiesWidget : public QWidget void setProperties(const TitleBlockProperties &properties); TitleBlockProperties properties() const; TitleBlockProperties propertiesAutoNum(QString autoNum) const; + TitleBlockTemplateLocation currentTitleBlockLocation () const; void setPropertiesWithAutoNum(const TitleBlockProperties &properties, QString autoNum); void setTitleBlockTemplatesVisible(const bool &visible); @@ -67,7 +68,6 @@ class TitleBlockPropertiesWidget : public QWidget void on_m_edit_autofolionum_pb_clicked(); signals: - void editTitleBlockTemplate(const QString &, bool); void set_auto_page_num() const; void openAutoNumFolioEditor (QString);