titleblockpropertieswidget : edit and duplicate titleblock work in every case.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4618 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-08-10 06:55:16 +00:00
parent 74553c4093
commit 8780b6c489
10 changed files with 44 additions and 51 deletions

View File

@@ -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 *);

View File

@@ -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 <QtWidgets>
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

View File

@@ -89,7 +89,7 @@ void ProjectView::setProject(QETProject *project) {
@return la liste des schemas ouverts dans le projet
*/
QList<DiagramView *> 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);

View File

@@ -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<int, DiagramView *> diagram_ids_;
QList<DiagramView *> diagrams_;
QList<DiagramView *> m_diagram_view_list;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(ProjectView::ProjectSaveOptions)
#endif

View File

@@ -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());

View File

@@ -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 &)));

View File

@@ -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);

View File

@@ -54,6 +54,7 @@ ProjectPropertiesDialog::~ProjectPropertiesDialog () {
* execute this dialog.
*/
void ProjectPropertiesDialog::exec() {
m_properties_dialog->setWindowModality(Qt::WindowModal);
m_properties_dialog -> exec();
}

View File

@@ -20,6 +20,7 @@
#include "templatescollection.h"
#include "qeticons.h"
#include "titleblocktemplate.h"
#include "qetapp.h"
#include <QMenu>
/**
@@ -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);
}
/**

View File

@@ -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);