mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Diagram properties dialog: the dialog is not built in DiagramView anymore, but a class itself
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3222 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#include "qetgraphicsitem/elementtextitem.h"
|
||||
#include "qetgraphicsitem/independenttextitem.h"
|
||||
#include "qetgraphicsitem/diagramimageitem.h"
|
||||
#include "titleblockpropertieswidget.h"
|
||||
#include "templatelocation.h"
|
||||
#include "qetapp.h"
|
||||
#include "qetproject.h"
|
||||
@@ -42,7 +41,7 @@
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include "factory/elementfactory.h"
|
||||
#include "ui/borderpropertieswidget.h"
|
||||
#include "diagrampropertiesdialog.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -625,83 +624,11 @@ QString DiagramView::title() const {
|
||||
}
|
||||
|
||||
/**
|
||||
Edite les informations du schema.
|
||||
* @brief DiagramView::editDiagramProperties
|
||||
* Edit the properties of the viewed digram
|
||||
*/
|
||||
void DiagramView::editDiagramProperties() {
|
||||
bool diagram_is_read_only = scene -> isReadOnly();
|
||||
|
||||
// recupere le cartouche et les dimensions du schema
|
||||
TitleBlockProperties titleblock = scene -> border_and_titleblock.exportTitleBlock();
|
||||
BorderProperties border = scene -> border_and_titleblock.exportBorder();
|
||||
ConductorProperties conductors = scene -> defaultConductorProperties;
|
||||
|
||||
// construit le dialogue
|
||||
QDialog popup(diagramEditor());
|
||||
popup.setWindowModality(Qt::WindowModal);
|
||||
#ifdef Q_WS_MAC
|
||||
popup.setWindowFlags(Qt::Sheet);
|
||||
#endif
|
||||
|
||||
popup.setWindowTitle(tr("Propri\351t\351s du sch\351ma", "window title"));
|
||||
|
||||
BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, &popup);
|
||||
border_infos -> setReadOnly(diagram_is_read_only);
|
||||
|
||||
TitleBlockPropertiesWidget *titleblock_infos;
|
||||
if (QETProject *parent_project = scene -> project()) {
|
||||
titleblock_infos = new TitleBlockPropertiesWidget(parent_project -> embeddedTitleBlockTemplatesCollection(), titleblock, false, &popup);
|
||||
connect(titleblock_infos, SIGNAL(editTitleBlockTemplate(QString, bool)), this, SIGNAL(editTitleBlockTemplate(QString, bool)));
|
||||
}
|
||||
else
|
||||
titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, &popup);
|
||||
|
||||
titleblock_infos -> setReadOnly(diagram_is_read_only);
|
||||
|
||||
ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(conductors);
|
||||
cpw -> setReadOnly(diagram_is_read_only);
|
||||
|
||||
// boutons
|
||||
QDialogButtonBox boutons(diagram_is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(&boutons, SIGNAL(accepted()), &popup, SLOT(accept()));
|
||||
connect(&boutons, SIGNAL(rejected()), &popup, SLOT(reject()));
|
||||
|
||||
QGridLayout glayout(&popup);
|
||||
glayout.addWidget(border_infos,0,0);
|
||||
glayout.addWidget(titleblock_infos, 1, 0);
|
||||
glayout.addWidget(cpw, 0, 1, 0 ,1, Qt::AlignTop);
|
||||
glayout.addWidget(&boutons, 2, 1);
|
||||
|
||||
// if dialog is accepted
|
||||
if (popup.exec() == QDialog::Accepted && !diagram_is_read_only) {
|
||||
TitleBlockProperties new_titleblock = titleblock_infos -> properties();
|
||||
BorderProperties new_border = border_infos -> properties();
|
||||
ConductorProperties new_conductors = cpw -> properties();
|
||||
|
||||
bool adjust_scene = false;
|
||||
|
||||
// s'il y a des modifications au cartouche
|
||||
if (new_titleblock != titleblock) {
|
||||
scene -> undoStack().push(new ChangeTitleBlockCommand(scene, titleblock, new_titleblock));
|
||||
adjust_scene = true;
|
||||
}
|
||||
|
||||
// s'il y a des modifications aux dimensions du schema
|
||||
if (new_border != border) {
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, border, new_border));
|
||||
adjust_scene = true;
|
||||
}
|
||||
|
||||
// if modifcations have been made to the conductors properties
|
||||
if (new_conductors != conductors) {
|
||||
/// TODO implement an undo command to allow the user to undo/redo this action
|
||||
scene -> defaultConductorProperties = new_conductors;
|
||||
}
|
||||
// adjustSceneRect shall be called whenever the user accepts the dialog
|
||||
// even if no changes have been made.
|
||||
// Added so that diagram refreshes after back-ground color change.
|
||||
//if (adjust_scene)
|
||||
adjustSceneRect();
|
||||
}
|
||||
DiagramPropertiesDialog::diagramPropertiesDialog(scene, diagramEditor());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
108
sources/ui/diagrampropertiesdialog.cpp
Normal file
108
sources/ui/diagrampropertiesdialog.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "diagrampropertiesdialog.h"
|
||||
#include "borderpropertieswidget.h"
|
||||
#include "titleblockpropertieswidget.h"
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include "diagramcommands.h"
|
||||
|
||||
/**
|
||||
* @brief DiagramPropertiesDialog::DiagramPropertiesDialog
|
||||
* Deafult constructor
|
||||
* @param diagram : diagram to edit properties
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *parent) :
|
||||
QDialog (parent)
|
||||
{
|
||||
bool diagram_is_read_only = diagram -> isReadOnly();
|
||||
|
||||
// Get some properties of edited diagram
|
||||
TitleBlockProperties titleblock = diagram -> border_and_titleblock.exportTitleBlock();
|
||||
BorderProperties border = diagram -> border_and_titleblock.exportBorder();
|
||||
ConductorProperties conductors = diagram -> defaultConductorProperties;
|
||||
|
||||
setWindowModality(Qt::WindowModal);
|
||||
#ifdef Q_WS_MAC
|
||||
setWindowFlags(Qt::Sheet);
|
||||
#endif
|
||||
|
||||
setWindowTitle(tr("Propri\351t\351s du sch\351ma", "window title"));
|
||||
|
||||
//Border widget
|
||||
BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, this);
|
||||
border_infos -> setReadOnly(diagram_is_read_only);
|
||||
|
||||
//Title block widget
|
||||
TitleBlockPropertiesWidget *titleblock_infos;
|
||||
if (QETProject *parent_project = diagram -> project()) {
|
||||
titleblock_infos = new TitleBlockPropertiesWidget(parent_project -> embeddedTitleBlockTemplatesCollection(), titleblock, false, this);
|
||||
connect(titleblock_infos, SIGNAL(editTitleBlockTemplate(QString, bool)), diagram->views().first(), SIGNAL(editTitleBlockTemplate(QString, bool)));
|
||||
}
|
||||
else
|
||||
titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, this);
|
||||
titleblock_infos -> setReadOnly(diagram_is_read_only);
|
||||
|
||||
//Conductor widget
|
||||
ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(conductors, this);
|
||||
cpw -> setReadOnly(diagram_is_read_only);
|
||||
|
||||
// Buttons
|
||||
QDialogButtonBox boutons(diagram_is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(&boutons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(&boutons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
//Layout
|
||||
QGridLayout glayout(this);
|
||||
glayout.addWidget(border_infos,0,0);
|
||||
glayout.addWidget(titleblock_infos, 1, 0);
|
||||
glayout.addWidget(cpw, 0, 1, 0 ,1, Qt::AlignTop);
|
||||
glayout.addWidget(&boutons, 2, 1);
|
||||
|
||||
// if dialog is accepted
|
||||
if (this -> exec() == QDialog::Accepted && !diagram_is_read_only) {
|
||||
TitleBlockProperties new_titleblock = titleblock_infos -> properties();
|
||||
BorderProperties new_border = border_infos -> properties();
|
||||
ConductorProperties new_conductors = cpw -> properties();
|
||||
|
||||
// Title block have change
|
||||
if (new_titleblock != titleblock) {
|
||||
diagram -> undoStack().push(new ChangeTitleBlockCommand(diagram, titleblock, new_titleblock));
|
||||
}
|
||||
|
||||
// Border have change
|
||||
if (new_border != border) {
|
||||
diagram -> undoStack().push(new ChangeBorderCommand(diagram, border, new_border));
|
||||
}
|
||||
|
||||
// Conducteur have change
|
||||
if (new_conductors != conductors) {
|
||||
/// TODO implement an undo command to allow the user to undo/redo this action
|
||||
diagram -> defaultConductorProperties = new_conductors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DiagramPropertiesDialog::diagramPropertiesDialog
|
||||
* Static method to get a DiagramPropertiesDialog.
|
||||
* @param diagram : diagram to edit properties
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
void DiagramPropertiesDialog::diagramPropertiesDialog(Diagram *diagram, QWidget *parent) {
|
||||
DiagramPropertiesDialog dialog(diagram, parent);
|
||||
}
|
||||
35
sources/ui/diagrampropertiesdialog.h
Normal file
35
sources/ui/diagrampropertiesdialog.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright 2006-2014 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef DIAGRAMPROPERTIESDIALOG_H
|
||||
#define DIAGRAMPROPERTIESDIALOG_H
|
||||
|
||||
#include "diagram.h"
|
||||
|
||||
/**
|
||||
* @brief The DiagramPropertiesDialog class
|
||||
* This dialog open a windows for edit properties of a diagram.
|
||||
*/
|
||||
class DiagramPropertiesDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
DiagramPropertiesDialog(Diagram *diagram, QWidget *parent = 0);
|
||||
|
||||
static void diagramPropertiesDialog(Diagram *diagram, QWidget *parent = 0);
|
||||
};
|
||||
|
||||
#endif // DIAGRAMPROPERTIESDIALOG_H
|
||||
Reference in New Issue
Block a user