QElectroTech  0.70
diagrampropertiesdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
19 #include "borderpropertieswidget.h"
22 #include "diagramcommands.h"
24 #include "diagram.h"
26 
34  QDialog (parent),
35  m_diagram (diagram)
36 {
37  bool diagram_is_read_only = diagram -> isReadOnly();
38 
39  // Get some properties of edited diagram
40  TitleBlockProperties titleblock = diagram -> border_and_titleblock.exportTitleBlock();
41  BorderProperties border = diagram -> border_and_titleblock.exportBorder();
42  ConductorProperties conductors = diagram -> defaultConductorProperties;
43 
44  setWindowModality(Qt::WindowModal);
45 #ifdef Q_OS_MAC
46  setWindowFlags(Qt::Sheet);
47 #endif
48 
49  setWindowTitle(tr("Propriétés du folio", "window title"));
50 
51  //Border widget
52  BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, this);
53  border_infos -> setReadOnly(diagram_is_read_only);
54 
55  //Title block widget
56  TitleBlockPropertiesWidget *titleblock_infos;
57 
58  if (QETProject *parent_project = diagram -> project())
59  titleblock_infos = new TitleBlockPropertiesWidget(parent_project -> embeddedTitleBlockTemplatesCollection(), titleblock, false, diagram->project(), this);
60  else
61  titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, diagram->project(), this);
62 
63  titleblock_infos -> setReadOnly(diagram_is_read_only);
64  connect(titleblock_infos,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(editAutoFolioNum()));
65  //titleblock_infos->setMinimumSize(590,480); //Minimum Size needed for correct display
66 
67  //Conductor widget
68  m_cpw = new ConductorPropertiesWidget(conductors, this);
69  m_cpw -> setReadOnly(diagram_is_read_only);
70 
71  QComboBox *autonum_combobox = m_cpw->autonumComboBox();
72  autonum_combobox->addItems(diagram->project()->conductorAutoNum().keys());
73  autonum_combobox->setCurrentIndex(autonum_combobox->findText(diagram->conductorsAutonumName()));
74 
75  connect(m_cpw->editAutonumPushButton(), &QPushButton::clicked, this, &DiagramPropertiesDialog::editAutonum);
76 
77  // Buttons
78  QDialogButtonBox boutons(diagram_is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
79  connect(&boutons, SIGNAL(accepted()), this, SLOT(accept()));
80  connect(&boutons, SIGNAL(rejected()), this, SLOT(reject()));
81 
82  QGridLayout *glayout = new QGridLayout;
83  glayout->addWidget(border_infos,0,0);
84  glayout->addWidget(titleblock_infos, 1, 0);
85  glayout->addWidget(m_cpw, 0, 1, 0, 1);
86 
87  QVBoxLayout vlayout(this);
88  vlayout.addLayout(glayout);
89  vlayout.addWidget(&boutons);
90 
91  // if dialog is accepted
92  if (this -> exec() == QDialog::Accepted && !diagram_is_read_only)
93  {
94  TitleBlockProperties new_titleblock = titleblock_infos -> properties();
95  BorderProperties new_border = border_infos -> properties();
96  ConductorProperties new_conductors = m_cpw -> properties();
97 
98  // Title block have change
99  if (new_titleblock != titleblock) {
100  diagram -> undoStack().push(new ChangeTitleBlockCommand(diagram, titleblock, new_titleblock));
101  }
102 
103  // Border have change
104  if (new_border != border) {
105  diagram -> undoStack().push(new ChangeBorderCommand(diagram, border, new_border));
106  }
107 
108  // Conducteur have change
109  if (new_conductors != conductors) {
111  diagram -> defaultConductorProperties = new_conductors;
112  }
113 
114  // Conductor autonum name
115  if (autonum_combobox->currentText() != diagram->conductorsAutonumName())
116  {
117  diagram->setConductorsAutonumName (autonum_combobox->currentText());
118  diagram->project()->conductorAutoNumChanged();
119  }
120  }
121 }
122 
130  DiagramPropertiesDialog dialog(diagram, parent);
131 }
132 
138 {
141  ppd.exec();
142  m_cpw->autonumComboBox()->clear();
143  m_cpw->autonumComboBox()->addItems(m_diagram->project()->conductorAutoNum().keys());
144 }
145 
153  ppd.changeToFolio();
154  ppd.exec();
155 }
The ProjectPropertiesDialog class this class builds a dialog to edit whole properties of a project...
ConductorPropertiesWidget * m_cpw
void setConductorsAutonumName(const QString &name)
Diagram::setConductorsAutonumName.
Definition: diagram.cpp:496
QHash< QString, NumerotationContext > conductorAutoNum() const
QETProject::conductorAutoNum.
Definition: qetproject.cpp:494
The BorderPropertiesWidget class this widget edit the properties of a border.
The DiagramPropertiesDialog class This dialog open a windows for edit properties of a diagram...
DiagramPropertiesDialog(Diagram *diagram, QWidget *parent=nullptr)
DiagramPropertiesDialog::DiagramPropertiesDialog Deafult constructor.
The ChangeTitleBlockCommand class This command changes the title block properties for a particular di...
QString conductorsAutonumName() const
Diagram::conductorsAutonumName.
Definition: diagram.cpp:488
void editAutoFolioNum()
DiagramPropertiesDialog::editAutonum Open folio autonum editor.
QIcon tr
Definition: qeticons.cpp:204
static void diagramPropertiesDialog(Diagram *diagram, QWidget *parent=nullptr)
DiagramPropertiesDialog::diagramPropertiesDialog Static method to get a DiagramPropertiesDialog.
void editAutonum()
DiagramPropertiesDialog::editAutonum Open conductor autonum editor.
QPushButton * editAutonumPushButton() const
void conductorAutoNumChanged()
void setCurrentPage(ProjectPropertiesDialog::Page)
ProjectPropertiesDialog::setCurrentPage Change the current displayed page by p.
QIcon Cancel
Definition: qeticons.cpp:34
QETProject * project() const
Definition: diagram.cpp:1716