mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Diagram properties dialog: add button to open the conductor autonumérotation editor.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3274 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
f7a142bf4a
commit
bb7fbfca61
@ -52,7 +52,7 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
|
||||
// connexion signaux / slots
|
||||
connect(buttons, SIGNAL(accepted()), this, SLOT(applyConf()));
|
||||
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect(pages_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
|
||||
connect(pages_list, SIGNAL(currentRowChanged(int)), pages_widget, SLOT(setCurrentIndex(int)));
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
if (parent) {
|
||||
@ -65,14 +65,6 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
|
||||
ConfigDialog::~ConfigDialog() {
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les changements de page dans le dialogue de configuration
|
||||
*/
|
||||
void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) {
|
||||
if (!current) current = previous;
|
||||
pages_widget -> setCurrentIndex(pages_list -> row(current));
|
||||
}
|
||||
|
||||
/**
|
||||
Construit la liste des pages sur la gauche
|
||||
*/
|
||||
@ -113,3 +105,12 @@ void ConfigDialog::addPage(ConfigPage *page) {
|
||||
pages_widget -> addWidget(page);
|
||||
addPageToList(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ConfigDialog::setCurrentPage
|
||||
* Set the current index to @index
|
||||
* @param index
|
||||
*/
|
||||
void ConfigDialog::setCurrentPage(const int index) {
|
||||
pages_list->setCurrentRow(index);
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ class ConfigDialog : public QDialog {
|
||||
|
||||
// methods
|
||||
public slots:
|
||||
void changePage(QListWidgetItem *, QListWidgetItem *);
|
||||
void applyConf();
|
||||
void addPage(ConfigPage *);
|
||||
void setCurrentPage(const int index);
|
||||
|
||||
private:
|
||||
void buildPagesList();
|
||||
|
@ -17,9 +17,7 @@
|
||||
*/
|
||||
#include "projectview.h"
|
||||
#include "qetproject.h"
|
||||
#include "configdialog.h"
|
||||
#include "closediagramsdialog.h"
|
||||
#include "projectconfigpages.h"
|
||||
#include "diagramview.h"
|
||||
#include "diagram.h"
|
||||
#include "diagramprintdialog.h"
|
||||
@ -36,6 +34,7 @@
|
||||
#include "qettabbar.h"
|
||||
#include "qettemplateeditor.h"
|
||||
#include "diagramfoliolist.h"
|
||||
#include "projectpropertiesdialog.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@ -444,13 +443,8 @@ void ProjectView::showDiagram(Diagram *diagram) {
|
||||
*/
|
||||
void ProjectView::editProjectProperties() {
|
||||
if (!project_) return;
|
||||
|
||||
ConfigDialog properties_dialog(parentWidget());
|
||||
properties_dialog.setWindowTitle(tr("Propri\351t\351s du projet", "window title"));
|
||||
properties_dialog.addPage(new ProjectMainConfigPage (project_));
|
||||
properties_dialog.addPage(new ProjectNewDiagramConfigPage (project_));
|
||||
properties_dialog.addPage(new ProjectAutoNumConfigPage (project_));
|
||||
properties_dialog.exec();
|
||||
ProjectPropertiesDialog dialog(project_, parentWidget());
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,40 +18,25 @@
|
||||
#include "autonumselectorwidget.h"
|
||||
#include "ui_autonumselectorwidget.h"
|
||||
|
||||
/**
|
||||
* @brief AutonumSelectorWidget::AutonumSelectorWidget
|
||||
* default constructor
|
||||
* @param parent, parent widget
|
||||
*/
|
||||
AutonumSelectorWidget::AutonumSelectorWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AutonumSelectorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_edit_autonum_pb->setDisabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AutonumSelectorWidget::AutonumSelectorWidget
|
||||
* Constructor with texts to fill the combo box
|
||||
* @param text, texts for fill the combo box
|
||||
* @param items, items for fill the combo box
|
||||
* @param parent, parent widget
|
||||
*/
|
||||
AutonumSelectorWidget::AutonumSelectorWidget(const QList <QString> &text, QWidget *parent) :
|
||||
AutonumSelectorWidget::AutonumSelectorWidget(const QStringList &items, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AutonumSelectorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui -> m_available_autonum_cb -> addItems(text);
|
||||
ui->m_edit_autonum_pb->setDisabled(true);
|
||||
ui -> m_available_autonum_cb -> addItems(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AutonumSelectorWidget::~AutonumSelectorWidget
|
||||
* Destructor
|
||||
*/
|
||||
AutonumSelectorWidget::~AutonumSelectorWidget()
|
||||
{
|
||||
AutonumSelectorWidget::~AutonumSelectorWidget() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -59,10 +44,21 @@ AutonumSelectorWidget::~AutonumSelectorWidget()
|
||||
* @brief AutonumSelectorWidget::setCurrentItem
|
||||
* Set the combo box current index by text.
|
||||
* If text doesn't exist, set current index -1
|
||||
* @param text, text of index
|
||||
* @param item, item of index
|
||||
*/
|
||||
void AutonumSelectorWidget::setCurrentItem(const QString &text) {
|
||||
ui -> m_available_autonum_cb -> setCurrentIndex( ui -> m_available_autonum_cb -> findText(text));
|
||||
void AutonumSelectorWidget::setCurrentItem(const QString &item) {
|
||||
ui -> m_available_autonum_cb -> setCurrentIndex( ui -> m_available_autonum_cb -> findText(item));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AutonumSelectorWidget::setItems
|
||||
* Populate this widget with the content of @items
|
||||
* Previous items is clear.
|
||||
* @param items
|
||||
*/
|
||||
void AutonumSelectorWidget::setItems(const QStringList &items) {
|
||||
ui -> m_available_autonum_cb -> clear();
|
||||
ui -> m_available_autonum_cb -> addItems(items);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,3 +68,12 @@ void AutonumSelectorWidget::setCurrentItem(const QString &text) {
|
||||
QString AutonumSelectorWidget::text() const {
|
||||
return ui -> m_available_autonum_cb -> currentText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AutonumSelectorWidget::on_m_edit_autonum_pb_clicked
|
||||
* Just emit the signal openAutonumEditor.
|
||||
* The owner of AutonumSelectorWidget need to connect the signal.
|
||||
*/
|
||||
void AutonumSelectorWidget::on_m_edit_autonum_pb_clicked() {
|
||||
emit openAutonumEditor();
|
||||
}
|
||||
|
@ -35,12 +35,18 @@ class AutonumSelectorWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AutonumSelectorWidget(QWidget *parent = 0);
|
||||
explicit AutonumSelectorWidget(const QList <QString> &text, QWidget *parent = 0);
|
||||
explicit AutonumSelectorWidget(const QStringList &items, QWidget *parent = 0);
|
||||
~AutonumSelectorWidget();
|
||||
|
||||
void setCurrentItem (const QString &text);
|
||||
QString text() const;
|
||||
void setCurrentItem (const QString &item);
|
||||
void setItems (const QStringList &items);
|
||||
QString text () const;
|
||||
|
||||
signals:
|
||||
void openAutonumEditor ();
|
||||
|
||||
private slots:
|
||||
void on_m_edit_autonum_pb_clicked();
|
||||
|
||||
private:
|
||||
Ui::AutonumSelectorWidget *ui;
|
||||
|
@ -42,6 +42,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_edit_autonum_pb">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>éditer les numérotations</string>
|
||||
</property>
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include "diagramcommands.h"
|
||||
#include "autonumselectorwidget.h"
|
||||
#include "projectpropertiesdialog.h"
|
||||
#include "diagram.h"
|
||||
|
||||
/**
|
||||
* @brief DiagramPropertiesDialog::DiagramPropertiesDialog
|
||||
@ -29,7 +31,8 @@
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *parent) :
|
||||
QDialog (parent)
|
||||
QDialog (parent),
|
||||
m_diagram (diagram)
|
||||
{
|
||||
bool diagram_is_read_only = diagram -> isReadOnly();
|
||||
|
||||
@ -64,9 +67,10 @@ DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *pare
|
||||
cpw -> setReadOnly(diagram_is_read_only);
|
||||
|
||||
//Conductor autonum
|
||||
AutonumSelectorWidget *asw = new AutonumSelectorWidget(diagram -> project() -> conductorAutoNum().keys(), this);
|
||||
asw -> setCurrentItem(diagram -> conductorsAutonumName());
|
||||
cpw->addAutonumWidget(asw);
|
||||
m_asw = new AutonumSelectorWidget(diagram -> project() -> conductorAutoNum().keys(), this);
|
||||
m_asw -> setCurrentItem(diagram -> conductorsAutonumName());
|
||||
connect (m_asw, SIGNAL(openAutonumEditor()), this, SLOT(editAutonum()));
|
||||
cpw->addAutonumWidget(m_asw);
|
||||
|
||||
// Buttons
|
||||
QDialogButtonBox boutons(diagram_is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
@ -102,8 +106,8 @@ DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *pare
|
||||
}
|
||||
|
||||
// Conductor autonum name
|
||||
if (asw -> text() != diagram -> conductorsAutonumName()) {
|
||||
diagram -> setConductorsAutonumName (asw -> text());
|
||||
if (m_asw -> text() != diagram -> conductorsAutonumName()) {
|
||||
diagram -> setConductorsAutonumName (m_asw -> text());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,3 +121,14 @@ DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *pare
|
||||
void DiagramPropertiesDialog::diagramPropertiesDialog(Diagram *diagram, QWidget *parent) {
|
||||
DiagramPropertiesDialog dialog(diagram, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DiagramPropertiesDialog::editAutonum
|
||||
* Open the autonum editor
|
||||
*/
|
||||
void DiagramPropertiesDialog::editAutonum() {
|
||||
ProjectPropertiesDialog ppd (m_diagram->project(), this);
|
||||
ppd.setCurrentPage(ProjectPropertiesDialog::Autonum);
|
||||
ppd.exec();
|
||||
m_asw -> setItems (m_diagram -> project() -> conductorAutoNum().keys());
|
||||
}
|
||||
|
@ -18,18 +18,29 @@
|
||||
#ifndef DIAGRAMPROPERTIESDIALOG_H
|
||||
#define DIAGRAMPROPERTIESDIALOG_H
|
||||
|
||||
#include "diagram.h"
|
||||
#include "qdialog.h"
|
||||
|
||||
class Diagram;
|
||||
class AutonumSelectorWidget;
|
||||
|
||||
/**
|
||||
* @brief The DiagramPropertiesDialog class
|
||||
* This dialog open a windows for edit properties of a diagram.
|
||||
*/
|
||||
class DiagramPropertiesDialog : public QDialog
|
||||
{
|
||||
class DiagramPropertiesDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DiagramPropertiesDialog(Diagram *diagram, QWidget *parent = 0);
|
||||
|
||||
static void diagramPropertiesDialog(Diagram *diagram, QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void editAutonum ();
|
||||
|
||||
private:
|
||||
Diagram *m_diagram;
|
||||
AutonumSelectorWidget *m_asw;
|
||||
};
|
||||
|
||||
#endif // DIAGRAMPROPERTIESDIALOG_H
|
||||
|
59
sources/ui/projectpropertiesdialog.cpp
Normal file
59
sources/ui/projectpropertiesdialog.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
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 "projectpropertiesdialog.h"
|
||||
#include "configdialog.h"
|
||||
#include "projectconfigpages.h"
|
||||
#include <QObject>
|
||||
|
||||
/**
|
||||
* @brief ProjectPropertiesDialog::ProjectPropertiesDialog
|
||||
* Default constructor
|
||||
* @param project : project to edit properties
|
||||
* @param parent : parent widget of this dialog
|
||||
*/
|
||||
ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *parent) {
|
||||
m_properties_dialog = new ConfigDialog (parent);
|
||||
m_properties_dialog -> setWindowTitle(QObject::tr("Propri\351t\351s du projet", "window title"));
|
||||
m_properties_dialog -> addPage(new ProjectMainConfigPage (project));
|
||||
m_properties_dialog -> addPage(new ProjectNewDiagramConfigPage (project));
|
||||
m_properties_dialog -> addPage(new ProjectAutoNumConfigPage (project));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ProjectPropertiesDialog::~ProjectPropertiesDialog
|
||||
*/
|
||||
ProjectPropertiesDialog::~ProjectPropertiesDialog () {
|
||||
delete m_properties_dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ProjectPropertiesDialog::exec
|
||||
* execute this dialog.
|
||||
*/
|
||||
void ProjectPropertiesDialog::exec() {
|
||||
m_properties_dialog -> exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ProjectPropertiesDialog::setCurrentPage
|
||||
* Change the current displayed page by p.
|
||||
* @param p : page to display
|
||||
*/
|
||||
void ProjectPropertiesDialog::setCurrentPage(ProjectPropertiesDialog::Page p) {
|
||||
m_properties_dialog -> setCurrentPage(static_cast <int> (p));
|
||||
}
|
47
sources/ui/projectpropertiesdialog.h
Normal file
47
sources/ui/projectpropertiesdialog.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
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 PROJECTPROPERTIESDIALOG_H
|
||||
#define PROJECTPROPERTIESDIALOG_H
|
||||
|
||||
class QETProject;
|
||||
class QWidget;
|
||||
class ConfigDialog;
|
||||
|
||||
/**
|
||||
* @brief The ProjectPropertiesDialog class
|
||||
* this class builds a dialog to edit whole properties of a project
|
||||
*/
|
||||
class ProjectPropertiesDialog
|
||||
{
|
||||
public:
|
||||
enum Page {
|
||||
Main = 0,
|
||||
Diagram = 1,
|
||||
Autonum = 2
|
||||
};
|
||||
|
||||
ProjectPropertiesDialog(QETProject *project, QWidget *parent = 0);
|
||||
~ProjectPropertiesDialog();
|
||||
void exec();
|
||||
void setCurrentPage(ProjectPropertiesDialog::Page);
|
||||
|
||||
private:
|
||||
ConfigDialog *m_properties_dialog;
|
||||
};
|
||||
|
||||
#endif // PROJECTPROPERTIESDIALOG_H
|
Loading…
x
Reference in New Issue
Block a user