mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Create a common widget to edit propertie
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3930 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
a30f51f2ce
commit
b7031a0009
@ -22,7 +22,7 @@
|
||||
#include "elementtextitem.h"
|
||||
#include "diagramcommands.h"
|
||||
#include <QtDebug>
|
||||
#include <ui/elementpropertieswidget.h>
|
||||
#include <elementpropertiesdialog.h>
|
||||
#include "elementprovider.h"
|
||||
#include "diagramposition.h"
|
||||
#include "terminal.h"
|
||||
@ -51,7 +51,7 @@ Element::~Element() {
|
||||
void Element::editProperty() {
|
||||
if (diagram())
|
||||
if(!diagram()->isReadOnly()){
|
||||
elementpropertieswidget epw (this, diagram()->views().first());
|
||||
ElementPropertiesDialog epw (this, diagram()->views().first());
|
||||
connect(&epw, SIGNAL(editElementRequired(ElementsLocation)), diagram(), SIGNAL(editElementRequired(ElementsLocation)));
|
||||
connect(&epw, SIGNAL(findElementRequired(ElementsLocation)), diagram(), SIGNAL(findElementRequired(ElementsLocation)));
|
||||
epw.exec();
|
||||
|
@ -30,7 +30,7 @@
|
||||
* @param parent parent widget
|
||||
*/
|
||||
ElementInfoWidget::ElementInfoWidget(Element *elmt, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
PropertiesEditorWidget(parent),
|
||||
ui(new Ui::ElementInfoWidget),
|
||||
element_(elmt),
|
||||
elmt_info(elmt->elementInformations()),
|
||||
@ -55,14 +55,11 @@ ElementInfoWidget::~ElementInfoWidget()
|
||||
* @brief ElementInfoWidget::apply
|
||||
* Apply the new information with a new undo command (got with method associatedUndo)
|
||||
* pushed to the stack of element project.
|
||||
* Return true if new info change, else false.
|
||||
*/
|
||||
bool ElementInfoWidget::apply() {
|
||||
if (QUndoCommand *undo = associatedUndo()) {
|
||||
void ElementInfoWidget::apply()
|
||||
{
|
||||
if (QUndoCommand *undo = associatedUndo())
|
||||
element_ -> diagram() -> undoStack().push(undo);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include "diagramcontext.h"
|
||||
#include "propertieseditorwidget.h"
|
||||
|
||||
class Element;
|
||||
class QUndoCommand;
|
||||
@ -34,7 +35,8 @@ namespace Ui {
|
||||
* @brief The ElementInfoWidget class
|
||||
* this class is a widget to edit an element informations.
|
||||
*/
|
||||
class ElementInfoWidget : public QWidget {
|
||||
class ElementInfoWidget : public PropertiesEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
//METHODS
|
||||
@ -42,7 +44,7 @@ class ElementInfoWidget : public QWidget {
|
||||
explicit ElementInfoWidget(Element *elmt, QWidget *parent = 0);
|
||||
~ElementInfoWidget();
|
||||
|
||||
bool apply();
|
||||
void apply();
|
||||
QUndoCommand* associatedUndo () const;
|
||||
|
||||
protected:
|
||||
|
@ -15,7 +15,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "elementpropertieswidget.h"
|
||||
#include "elementpropertiesdialog.h"
|
||||
#include "ghostelement.h"
|
||||
#include "qeticons.h"
|
||||
#include "diagramposition.h"
|
||||
@ -25,12 +25,12 @@
|
||||
#include "linksingleelementwidget.h"
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::elementpropertieswidget
|
||||
* @brief ElementPropertiesDialog::ElementPropertiesDialog
|
||||
* default constructor
|
||||
* @param elmt
|
||||
* @param parent
|
||||
*/
|
||||
elementpropertieswidget::elementpropertieswidget(Element *elmt, QWidget *parent) :
|
||||
ElementPropertiesDialog::ElementPropertiesDialog(Element *elmt, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
element_ (elmt),
|
||||
diagram_ (elmt->diagram())
|
||||
@ -42,11 +42,11 @@ elementpropertieswidget::elementpropertieswidget(Element *elmt, QWidget *parent)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::generalWidget
|
||||
* @brief ElementPropertiesDialog::generalWidget
|
||||
* build the widget for the tab général
|
||||
* @return
|
||||
*/
|
||||
QWidget* elementpropertieswidget::generalWidget() {
|
||||
QWidget* ElementPropertiesDialog::generalWidget() {
|
||||
CustomElement *custom_element = qobject_cast<CustomElement *>(element_);
|
||||
GhostElement *ghost_element = qobject_cast<GhostElement *>(element_);
|
||||
|
||||
@ -102,11 +102,11 @@ QWidget* elementpropertieswidget::generalWidget() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::buildInterface
|
||||
* @brief ElementPropertiesDialog::buildInterface
|
||||
*build the interface of this dialog, the main tab can have
|
||||
*different tab according to the edited element
|
||||
*/
|
||||
void elementpropertieswidget::buildInterface() {
|
||||
void ElementPropertiesDialog::buildInterface() {
|
||||
|
||||
setWindowTitle(tr("Propriétés de l'élément"));
|
||||
tab_ = new QTabWidget(this);
|
||||
@ -154,12 +154,12 @@ void elementpropertieswidget::buildInterface() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::standardButtonClicked
|
||||
* @brief ElementPropertiesDialog::standardButtonClicked
|
||||
* apply action when click in the dialog standard button box
|
||||
* @param button
|
||||
* the cliked button
|
||||
*/
|
||||
void elementpropertieswidget::standardButtonClicked(QAbstractButton *button) {
|
||||
void ElementPropertiesDialog::standardButtonClicked(QAbstractButton *button) {
|
||||
int answer = dbb -> buttonRole(button);
|
||||
bool accept = false;
|
||||
|
||||
@ -204,10 +204,10 @@ void elementpropertieswidget::standardButtonClicked(QAbstractButton *button) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::findInPanel
|
||||
* @brief ElementPropertiesDialog::findInPanel
|
||||
* Slot
|
||||
*/
|
||||
void elementpropertieswidget::findInPanel() {
|
||||
void ElementPropertiesDialog::findInPanel() {
|
||||
if (CustomElement *custom_element = qobject_cast<CustomElement *>(element_)) {
|
||||
emit findElementRequired(custom_element->location());
|
||||
}
|
||||
@ -215,10 +215,10 @@ void elementpropertieswidget::findInPanel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::editElement
|
||||
* @brief ElementPropertiesDialog::editElement
|
||||
* Slot
|
||||
*/
|
||||
void elementpropertieswidget::editElement() {
|
||||
void ElementPropertiesDialog::editElement() {
|
||||
if (CustomElement *custom_element = qobject_cast<CustomElement *>(element_)) {
|
||||
emit findElementRequired(custom_element->location());
|
||||
emit editElementRequired(custom_element->location());
|
@ -30,11 +30,11 @@ class QAbstractButton;
|
||||
class QDialogButtonBox;
|
||||
class QTabWidget;
|
||||
|
||||
class elementpropertieswidget : public QDialog {
|
||||
class ElementPropertiesDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit elementpropertieswidget(Element *elmt, QWidget *parent = 0);
|
||||
explicit ElementPropertiesDialog(Element *elmt, QWidget *parent = 0);
|
||||
|
||||
private:
|
||||
QWidget* generalWidget();
|
@ -31,7 +31,7 @@
|
||||
* @param parent
|
||||
*/
|
||||
MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
PropertiesEditorWidget(parent),
|
||||
ui(new Ui::MasterPropertiesWidget),
|
||||
element_(elmt)
|
||||
{
|
||||
@ -58,12 +58,9 @@ MasterPropertiesWidget::~MasterPropertiesWidget()
|
||||
* pushed to the stack of element project.
|
||||
* Return true if link change, else false
|
||||
*/
|
||||
bool MasterPropertiesWidget::apply() {
|
||||
if (QUndoCommand *undo = associatedUndo()) {
|
||||
void MasterPropertiesWidget::apply() {
|
||||
if (QUndoCommand *undo = associatedUndo())
|
||||
element_ -> diagram() -> undoStack().push(undo);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHash>
|
||||
#include <propertieseditorwidget.h>
|
||||
|
||||
class QListWidgetItem;
|
||||
class Element;
|
||||
@ -35,7 +36,7 @@ namespace Ui {
|
||||
* This class embenddedthe undo/redo command when apply new connection.
|
||||
*/
|
||||
|
||||
class MasterPropertiesWidget : public QWidget
|
||||
class MasterPropertiesWidget : public PropertiesEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -43,7 +44,7 @@ class MasterPropertiesWidget : public QWidget
|
||||
explicit MasterPropertiesWidget(Element *elmt, QWidget *parent = 0);
|
||||
~MasterPropertiesWidget();
|
||||
|
||||
bool apply();
|
||||
void apply();
|
||||
void reset();
|
||||
QUndoCommand* associatedUndo() const;
|
||||
|
||||
|
37
sources/ui/propertieseditorwidget.cpp
Normal file
37
sources/ui/propertieseditorwidget.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2006-2015 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 "propertieseditorwidget.h"
|
||||
#include <QUndoCommand>
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorWidget::PropertiesEditorWidget
|
||||
* Constructor
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
PropertiesEditorWidget::PropertiesEditorWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorWidget::assosiatedUndo
|
||||
* By default, return an empty undo command
|
||||
* @return an empty undo command
|
||||
*/
|
||||
QUndoCommand *PropertiesEditorWidget::assosiatedUndo() {
|
||||
return new QUndoCommand();
|
||||
}
|
41
sources/ui/propertieseditorwidget.h
Normal file
41
sources/ui/propertieseditorwidget.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2006-2015 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 PROPERTIESEDITORWIDGET_H
|
||||
#define PROPERTIESEDITORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QUndoCommand;
|
||||
|
||||
/**
|
||||
* @brief The PropertiesEditorWidget class
|
||||
* This class extend QWidget method for have common way
|
||||
* to edit propertie.
|
||||
*/
|
||||
class PropertiesEditorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PropertiesEditorWidget(QWidget *parent = 0);
|
||||
|
||||
void apply() {}
|
||||
void reset() {}
|
||||
virtual QUndoCommand *assosiatedUndo ();
|
||||
};
|
||||
|
||||
#endif // PROPERTIESEDITORWIDGET_H
|
Loading…
x
Reference in New Issue
Block a user