[qet] [3932] Use PropertiesEditorWidget instead of QWidget for some widget ( widget used to edit propertie of element) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3932
Author: blacksun
Date: 2015-05-03 19:32:28 +0200 (Sun, 03 May 2015)
Log Message:
-----------
Use PropertiesEditorWidget instead of QWidget for some widget (widget used to edit propertie of element)
Modified Paths:
--------------
trunk/sources/ui/elementinfowidget.h
trunk/sources/ui/elementpropertiesdialog.cpp
trunk/sources/ui/elementpropertiesdialog.h
trunk/sources/ui/linksingleelementwidget.cpp
trunk/sources/ui/linksingleelementwidget.h
trunk/sources/ui/masterpropertieswidget.h
trunk/sources/ui/propertieseditorwidget.cpp
trunk/sources/ui/propertieseditorwidget.h
Added Paths:
-----------
trunk/sources/ui/elementpropertieswidget.cpp
trunk/sources/ui/elementpropertieswidget.h
Modified: trunk/sources/ui/elementinfowidget.h
===================================================================
--- trunk/sources/ui/elementinfowidget.h 2015-05-03 15:31:19 UTC (rev 3931)
+++ trunk/sources/ui/elementinfowidget.h 2015-05-03 17:32:28 UTC (rev 3932)
@@ -45,7 +45,8 @@
~ElementInfoWidget();
void apply();
- QUndoCommand* associatedUndo () const;
+ QUndoCommand *associatedUndo () const;
+ QString title() const {return tr("Informations");}
protected:
virtual bool event(QEvent *event);
Modified: trunk/sources/ui/elementpropertiesdialog.cpp
===================================================================
--- trunk/sources/ui/elementpropertiesdialog.cpp 2015-05-03 15:31:19 UTC (rev 3931)
+++ trunk/sources/ui/elementpropertiesdialog.cpp 2015-05-03 17:32:28 UTC (rev 3932)
@@ -16,14 +16,11 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementpropertiesdialog.h"
-#include "ghostelement.h"
-#include "qeticons.h"
-#include "diagramposition.h"
-#include "diagram.h"
-#include "elementinfowidget.h"
-#include "masterpropertieswidget.h"
-#include "linksingleelementwidget.h"
+#include "elementpropertieswidget.h"
+#include <QDialogButtonBox>
+#include <QVBoxLayout>
+
/**
* @brief ElementPropertiesDialog::ElementPropertiesDialog
* default constructor
@@ -32,123 +29,18 @@
*/
ElementPropertiesDialog::ElementPropertiesDialog(Element *elmt, QWidget *parent) :
QDialog(parent),
- element_ (elmt),
- diagram_ (elmt->diagram())
+ element_ (elmt)
{
- eiw_ = 0;
- mpw_ = 0;
- lsew_ = 0;
- buildInterface();
-}
+ m_editor = new ElementPropertiesWidget(elmt, this);
-/**
- * @brief ElementPropertiesDialog::generalWidget
- * build the widget for the tab général
- * @return
- */
-QWidget* ElementPropertiesDialog::generalWidget() {
- CustomElement *custom_element = qobject_cast<CustomElement *>(element_);
- GhostElement *ghost_element = qobject_cast<GhostElement *>(element_);
+ connect(m_editor, SIGNAL(editElementRequired(ElementsLocation)), this , SLOT(editElement(ElementsLocation)));
+ connect(m_editor, SIGNAL(findElementRequired(ElementsLocation)), this, SLOT(findInPanel(ElementsLocation)));
- // type de l'element
- QString description_string;
- if (ghost_element) {
- description_string += tr("Élément manquant");
- } else {
- description_string += tr("Élément");
- }
- description_string += "\n";
-
- // some element characteristic
- description_string += QString(tr("Nom : %1\n")).arg(element_ -> name());
- int folio_index = diagram_ -> folioIndex();
- if (folio_index != -1) {
- description_string += QString(tr("Folio : %1\n")).arg(folio_index + 1);
- }
- description_string += QString(tr("Position : %1\n")).arg(diagram_ -> convertPosition(element_ -> scenePos()).toString());
- description_string += QString(tr("Dimensions : %1*%2\n")).arg(element_ -> size().width()).arg(element_ -> size().height());
- description_string += QString(tr("Bornes : %1\n")).arg(element_ -> terminals().count());
- description_string += QString(tr("Champs de texte : %1\n")).arg(element_ -> texts().count());
-
- if (custom_element) {
- description_string += QString(tr("Emplacement : %1\n")).arg(custom_element -> location().toString());
- }
-
- // widget himself
- QWidget *general_widget = new QWidget (tab_);
- QVBoxLayout *vlayout_ = new QVBoxLayout (general_widget);
- general_widget -> setLayout(vlayout_);
-
- //widget for the text
- vlayout_->addWidget(new QLabel (description_string, general_widget));
-
- //widget for the pixmap
- QLabel *pix = new QLabel(general_widget);
- pix->setPixmap(element_->pixmap());
- vlayout_->addWidget(pix, 0, Qt::AlignHCenter);
- vlayout_ -> addStretch();
-
- //button widget
- find_in_panel = new QPushButton(QET::Icons::ZoomDraw, tr("Retrouver dans le panel"), general_widget);
- connect(find_in_panel, SIGNAL(clicked()), this, SLOT(findInPanel()));
- edit_element = new QPushButton(QET::Icons::ElementEdit, tr("Éditer l'élément"), general_widget);
- connect(edit_element, SIGNAL(clicked()), this, SLOT(editElement()));
- QHBoxLayout *hlayout_ = new QHBoxLayout;
- hlayout_->addWidget(find_in_panel);
- hlayout_->addWidget(edit_element);
-
- vlayout_->addLayout(hlayout_);
- return general_widget;
-}
-
-/**
- * @brief ElementPropertiesDialog::buildInterface
- *build the interface of this dialog, the main tab can have
- *different tab according to the edited element
- */
-void ElementPropertiesDialog::buildInterface() {
-
- setWindowTitle(tr("Propriétés de l'élément"));
- tab_ = new QTabWidget(this);
-
- //Add tab according to the element
- switch (element_ -> linkType()) {
- case Element::Simple:
- eiw_ = new ElementInfoWidget(element_, this);
- tab_ -> addTab(eiw_, tr("Information"));
- break;
- case Element::NextReport:
- lsew_ = new LinkSingleElementWidget(element_, this);
- tab_ -> addTab(lsew_, tr("Report de folio"));
- break;
- case Element::PreviousReport:
- lsew_ = new LinkSingleElementWidget(element_, this);
- tab_ -> addTab(lsew_, tr("Report de folio"));
- break;
- case Element::Master:
- mpw_ = new MasterPropertiesWidget(element_, this);
- tab_ -> addTab(mpw_, tr("Référence croisée (maitre)"));
- eiw_ = new ElementInfoWidget(element_, this);
- tab_ -> addTab(eiw_, tr("Informations"));
- break;
- case Element::Slave:
- lsew_ = new LinkSingleElementWidget(element_, this);
- tab_ -> addTab(lsew_, tr("Référence croisée (esclave)"));
- break;
- case Element::Terminale:
- break;
- default:
- break;
- }
-
- tab_ -> addTab(generalWidget(), tr("Général"));
-
- dbb = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Reset,
- Qt::Horizontal, this);
+ dbb = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Reset, Qt::Horizontal, this);
connect(dbb, SIGNAL(clicked(QAbstractButton*)), this, SLOT(standardButtonClicked(QAbstractButton*)));
QVBoxLayout *main_layout = new QVBoxLayout(this);
- main_layout -> addWidget(tab_);
+ main_layout -> addWidget(m_editor);
main_layout -> addWidget(dbb);
setLayout(main_layout);
}
@@ -161,56 +53,28 @@
*/
void ElementPropertiesDialog::standardButtonClicked(QAbstractButton *button) {
int answer = dbb -> buttonRole(button);
- bool accept = false;
switch (answer) {
case QDialogButtonBox::ResetRole:
- if (mpw_) mpw_->reset();
+ m_editor->reset();
break;
case QDialogButtonBox::ApplyRole:
- accept = true;
+ m_editor->apply();
+ accept();
break;
- case QDialogButtonBox::RejectRole:
- this -> reject();
- break;
default:
- this -> reject();
+ reject();
break;
}
-
- if (accept) {
- QUndoCommand *a = nullptr;
- QUndoCommand *b = nullptr;
-
- if (eiw_) a = eiw_ -> associatedUndo();
- if (mpw_) b = mpw_ -> associatedUndo();
- if (lsew_) lsew_ -> apply();
-
- //If two undo, we push it in a macro
- if (a && b) {
- QUndoStack &stack = element_ -> diagram() -> undoStack();
- stack.beginMacro(a -> text() + " + " + b -> text());
- stack.push(a);
- stack.push(b);
- stack.endMacro();
- }
- else {
- if (a) element_ -> diagram() -> undoStack().push(a);
- if (b) element_ -> diagram() -> undoStack().push(b);
- }
-
- this -> accept();
- }
}
/**
* @brief ElementPropertiesDialog::findInPanel
* Slot
*/
-void ElementPropertiesDialog::findInPanel() {
- if (CustomElement *custom_element = qobject_cast<CustomElement *>(element_)) {
- emit findElementRequired(custom_element->location());
- }
+void ElementPropertiesDialog::findInPanel(const ElementsLocation &location)
+{
+ emit findElementRequired(location);
reject();
}
@@ -218,10 +82,9 @@
* @brief ElementPropertiesDialog::editElement
* Slot
*/
-void ElementPropertiesDialog::editElement() {
- if (CustomElement *custom_element = qobject_cast<CustomElement *>(element_)) {
- emit findElementRequired(custom_element->location());
- emit editElementRequired(custom_element->location());
- }
+void ElementPropertiesDialog::editElement(const ElementsLocation &location)
+{
+ emit findElementRequired(location);
+ emit editElementRequired(location);
reject();
}
Modified: trunk/sources/ui/elementpropertiesdialog.h
===================================================================
--- trunk/sources/ui/elementpropertiesdialog.h 2015-05-03 15:31:19 UTC (rev 3931)
+++ trunk/sources/ui/elementpropertiesdialog.h 2015-05-03 17:32:28 UTC (rev 3932)
@@ -15,31 +15,28 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef ELEMENTPROPERTIESWIDGET_H
-#define ELEMENTPROPERTIESWIDGET_H
+#ifndef ELEMENTPROPERTIESDIALOG_H
+#define ELEMENTPROPERTIESDIALOG_H
#include <QDialog>
-class Diagram;
class Element;
class ElementsLocation;
-class ElementInfoWidget;
-class MasterPropertiesWidget;
-class LinkSingleElementWidget;
class QAbstractButton;
class QDialogButtonBox;
-class QTabWidget;
+class ElementPropertiesWidget;
-class ElementPropertiesDialog : public QDialog {
+/**
+ * @brief The ElementPropertiesDialog class
+ * Display the element properties widget in a QDialog
+ */
+class ElementPropertiesDialog : public QDialog
+{
Q_OBJECT
public:
explicit ElementPropertiesDialog(Element *elmt, QWidget *parent = 0);
- private:
- QWidget* generalWidget();
- void buildInterface();
-
signals:
/// Signal emitted when users wish to locate an element from the diagram within elements collection
void findElementRequired(const ElementsLocation &);
@@ -48,19 +45,13 @@
public slots:
void standardButtonClicked (QAbstractButton *);
- void findInPanel ();
- void editElement ();
+ void findInPanel (const ElementsLocation &);
+ void editElement (const ElementsLocation &);
private:
Element *element_;
- Diagram *diagram_;
- QTabWidget *tab_;
- QPushButton *find_in_panel,
- *edit_element;
QDialogButtonBox *dbb;
- ElementInfoWidget *eiw_;
- MasterPropertiesWidget *mpw_;
- LinkSingleElementWidget *lsew_;
+ ElementPropertiesWidget *m_editor;
};
-#endif // ELEMENTPROPERTIESWIDGET_H
+#endif // ELEMENTPROPERTIESDIALOG_H
Added: trunk/sources/ui/elementpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/elementpropertieswidget.cpp (rev 0)
+++ trunk/sources/ui/elementpropertieswidget.cpp 2015-05-03 17:32:28 UTC (rev 3932)
@@ -0,0 +1,203 @@
+/*
+ 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 "elementpropertieswidget.h"
+#include "element.h"
+#include "elementinfowidget.h"
+#include "masterpropertieswidget.h"
+#include "linksingleelementwidget.h"
+#include "ghostelement.h"
+#include "diagram.h"
+#include "diagramposition.h"
+#include "qeticons.h"
+
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QUndoStack>
+
+/**
+ * @brief ElementPropertiesWidget::ElementPropertiesWidget
+ * Default constructor
+ * @param elmt
+ * @param parent
+ */
+ElementPropertiesWidget::ElementPropertiesWidget(Element *elmt, QWidget *parent) :
+ PropertiesEditorWidget (parent),
+ m_element (elmt),
+ m_diagram (elmt->diagram()),
+ m_tab (nullptr)
+{
+ buildGui();
+}
+
+/**
+ * @brief ElementPropertiesWidget::apply
+ * Apply the new properties by pushing an undo command
+ * to the parent project's undo stack of element
+ */
+void ElementPropertiesWidget::apply()
+{
+ QList <QUndoCommand *> undo_list;
+
+ foreach (PropertiesEditorWidget *pew, m_list_editor)
+ if (pew->associatedUndo())
+ undo_list << pew->associatedUndo();
+
+ if (undo_list.isEmpty()) return;
+
+ QString str;
+ foreach(QUndoCommand *uc, undo_list) str += uc->text() += " ";
+
+ QUndoStack &stack = m_element -> diagram() -> undoStack();
+ stack.beginMacro(str);
+ foreach(QUndoCommand *uc, undo_list) stack.push(uc);
+ stack.endMacro();
+}
+
+/**
+ * @brief ElementPropertiesWidget::reset
+ * Reset the edited properties
+ */
+void ElementPropertiesWidget::reset() {
+ foreach (PropertiesEditorWidget *pew, m_list_editor) pew->reset();
+}
+
+/**
+ * @brief ElementPropertiesWidget::findInPanel
+ * If m_element is a custom element, emit findElementRequired
+ */
+void ElementPropertiesWidget::findInPanel()
+{
+ if (CustomElement *custom_element = qobject_cast<CustomElement *>(m_element))
+ emit findElementRequired(custom_element->location());
+}
+
+/**
+ * @brief ElementPropertiesWidget::editElement
+ * If m_element is a custom element, emit findElementRequired and editElementRequired
+ */
+void ElementPropertiesWidget::editElement()
+{
+ if (CustomElement *custom_element = qobject_cast<CustomElement *>(m_element))
+ {
+ emit findElementRequired(custom_element->location());
+ emit editElementRequired(custom_element->location());
+ }
+}
+
+/**
+ * @brief ElementPropertiesWidget::build
+ * Build the content of this widget
+ */
+void ElementPropertiesWidget::buildGui()
+{
+ m_tab = new QTabWidget(this);
+
+ //Add tab according to the element
+ switch (m_element -> linkType())
+ {
+ case Element::Simple:
+ m_list_editor << new ElementInfoWidget(m_element, this);
+ break;
+ case Element::NextReport:
+ m_list_editor << new LinkSingleElementWidget(m_element, this);
+ break;
+ case Element::PreviousReport:
+ m_list_editor << new LinkSingleElementWidget(m_element, this);
+ break;
+ case Element::Master:
+ m_list_editor << new MasterPropertiesWidget(m_element, this);
+ m_list_editor << new ElementInfoWidget(m_element, this);
+ break;
+ case Element::Slave:
+ m_list_editor << new LinkSingleElementWidget(m_element, this);
+ break;
+ case Element::Terminale:
+ break;
+ default:
+ break;
+ }
+
+ foreach (PropertiesEditorWidget *pew, m_list_editor) m_tab->addTab(pew, pew->title());
+ m_tab -> addTab(generalWidget(), tr("Général"));
+
+ QVBoxLayout *main_layout = new QVBoxLayout(this);
+ main_layout -> addWidget(m_tab);
+ setLayout(main_layout);
+}
+
+/**
+ * @brief ElementPropertiesWidget::generalWidget
+ * @return build and return the "general" widget
+ */
+QWidget *ElementPropertiesWidget::generalWidget()
+{
+ CustomElement *custom_element = qobject_cast<CustomElement *>(m_element);
+ GhostElement *ghost_element = qobject_cast<GhostElement *>(m_element);
+
+ // type de l'element
+ QString description_string;
+ if (ghost_element) {
+ description_string += tr("Élément manquant");
+ } else {
+ description_string += tr("Élément");
+ }
+ description_string += "\n";
+
+ // some element characteristic
+ description_string += QString(tr("Nom : %1\n")).arg(m_element -> name());
+ int folio_index = m_diagram -> folioIndex();
+ if (folio_index != -1) {
+ description_string += QString(tr("Folio : %1\n")).arg(folio_index + 1);
+ }
+ description_string += QString(tr("Position : %1\n")).arg(m_diagram -> convertPosition(m_element -> scenePos()).toString());
+ description_string += QString(tr("Dimensions : %1*%2\n")).arg(m_element -> size().width()).arg(m_element -> size().height());
+ description_string += QString(tr("Bornes : %1\n")).arg(m_element -> terminals().count());
+ description_string += QString(tr("Champs de texte : %1\n")).arg(m_element -> texts().count());
+
+ if (custom_element) {
+ description_string += QString(tr("Emplacement : %1\n")).arg(custom_element -> location().toString());
+ }
+
+ // widget himself
+ QWidget *general_widget = new QWidget (m_tab);
+ QVBoxLayout *vlayout_ = new QVBoxLayout (general_widget);
+ general_widget -> setLayout(vlayout_);
+
+ //widget for the text
+ QLabel *label = new QLabel (description_string, general_widget);
+ label->setWordWrap(true);
+ vlayout_->addWidget(label);
+
+ //widget for the pixmap
+ QLabel *pix = new QLabel(general_widget);
+ pix->setPixmap(m_element->pixmap());
+ vlayout_->addWidget(pix, 0, Qt::AlignHCenter);
+ vlayout_ -> addStretch();
+
+ //button widget
+ QPushButton *find_in_panel = new QPushButton(QET::Icons::ZoomDraw, tr("Retrouver dans le panel"), general_widget);
+ connect(find_in_panel, SIGNAL(clicked()), this, SLOT(findInPanel()));
+ QPushButton *edit_element = new QPushButton(QET::Icons::ElementEdit, tr("Éditer l'élément"), general_widget);
+ connect(edit_element, SIGNAL(clicked()), this, SLOT(editElement()));
+ QHBoxLayout *hlayout_ = new QHBoxLayout;
+ hlayout_->addWidget(find_in_panel);
+ hlayout_->addWidget(edit_element);
+
+ vlayout_->addLayout(hlayout_);
+ return general_widget;
+}
Added: trunk/sources/ui/elementpropertieswidget.h
===================================================================
--- trunk/sources/ui/elementpropertieswidget.h (rev 0)
+++ trunk/sources/ui/elementpropertieswidget.h 2015-05-03 17:32:28 UTC (rev 3932)
@@ -0,0 +1,59 @@
+/*
+ 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 ELEMENTPROPERTIESWIDGET_H
+#define ELEMENTPROPERTIESWIDGET_H
+
+#include "propertieseditorwidget.h"
+
+class Element;
+class Diagram;
+class QTabWidget;
+class ElementsLocation;
+
+
+class ElementPropertiesWidget : public PropertiesEditorWidget
+{
+ Q_OBJECT
+
+ public:
+ explicit ElementPropertiesWidget(Element *elmt, QWidget *parent = 0);
+ void apply();
+ void reset();
+
+ public slots:
+ void findInPanel ();
+ void editElement ();
+
+ private:
+ void buildGui();
+ QWidget *generalWidget();
+
+ signals:
+ /// Signal emitted when users wish to locate an element from the diagram within elements collection
+ void findElementRequired(const ElementsLocation &);
+ /// Signal emitted when users wish to edit an element from the diagram
+ void editElementRequired(const ElementsLocation &);
+
+ private:
+ Element *m_element;
+ Diagram *m_diagram;
+ QTabWidget *m_tab;
+ QList <PropertiesEditorWidget *> m_list_editor;
+};
+
+#endif // ELEMENTPROPERTIESWIDGET_H
Modified: trunk/sources/ui/linksingleelementwidget.cpp
===================================================================
--- trunk/sources/ui/linksingleelementwidget.cpp 2015-05-03 15:31:19 UTC (rev 3931)
+++ trunk/sources/ui/linksingleelementwidget.cpp 2015-05-03 17:32:28 UTC (rev 3932)
@@ -31,7 +31,7 @@
* the parent widget
*/
LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent) :
- QWidget(parent),
+ PropertiesEditorWidget(parent),
ui(new Ui::LinkSingleElementWidget),
element_(elmt),
esw_(0),
@@ -67,12 +67,34 @@
* Apply the new property of the edited element
*/
void LinkSingleElementWidget::apply() {
+ QUndoCommand *undo = associatedUndo();
+ if (undo)
+ element_->diagram()->undoStack().push(undo);
+}
+
+/**
+ * @brief LinkSingleElementWidget::associatedUndo
+ * @return the undo command associated to the current edition
+ * if there isn't change, return nulptr
+ */
+QUndoCommand *LinkSingleElementWidget::associatedUndo() const
+{
if (esw_->selectedElement())
- element_->diagram()->undoStack().push(new LinkElementsCommand(element_, esw_->selectedElement()));
+ return new LinkElementsCommand(element_, esw_->selectedElement());
else if (unlink_)
- element_->diagram()->undoStack().push(new unlinkElementsCommand(element_));
+ return new unlinkElementsCommand(element_);
+
+ return nullptr;
}
+QString LinkSingleElementWidget::title() const
+{
+ if (element_->linkType() == Element::AllReport)
+ return tr("Report de folio");
+ else
+ return tr("Référence croisée (esclave)");
+}
+
/**
* @brief LinkSingleElementWidget::buildInterface
* Build the interface of this widget
Modified: trunk/sources/ui/linksingleelementwidget.h
===================================================================
--- trunk/sources/ui/linksingleelementwidget.h 2015-05-03 15:31:19 UTC (rev 3931)
+++ trunk/sources/ui/linksingleelementwidget.h 2015-05-03 17:32:28 UTC (rev 3932)
@@ -18,7 +18,7 @@
#ifndef LINKSINGLEELEMENTWIDGET_H
#define LINKSINGLEELEMENTWIDGET_H
-#include <QWidget>
+#include "propertieseditorwidget.h"
#include "element.h"
class Diagram;
@@ -39,16 +39,19 @@
* If the element is already linked, the widget ask user to unlink.
* This widget embedded the diagram command for undo/redo the action
*/
-class LinkSingleElementWidget : public QWidget
+class LinkSingleElementWidget : public PropertiesEditorWidget
{
Q_OBJECT
///Methods
public:
- explicit LinkSingleElementWidget(Element *elmt, QWidget *parent = 0);
- ~LinkSingleElementWidget();
- void apply();
+ explicit LinkSingleElementWidget(Element *elmt, QWidget *parent = 0);
+ ~LinkSingleElementWidget();
+ void apply();
+ QUndoCommand *associatedUndo() const;
+ QString title() const;
+
private:
void buildInterface();
void buildList();
Modified: trunk/sources/ui/masterpropertieswidget.h
===================================================================
--- trunk/sources/ui/masterpropertieswidget.h 2015-05-03 15:31:19 UTC (rev 3931)
+++ trunk/sources/ui/masterpropertieswidget.h 2015-05-03 17:32:28 UTC (rev 3932)
@@ -46,7 +46,8 @@
void apply();
void reset();
- QUndoCommand* associatedUndo() const;
+ QUndoCommand *associatedUndo () const;
+ QString title() const {return tr("Référence croisée (maitre)");}
private:
void buildInterface();
Modified: trunk/sources/ui/propertieseditorwidget.cpp
===================================================================
--- trunk/sources/ui/propertieseditorwidget.cpp 2015-05-03 15:31:19 UTC (rev 3931)
+++ trunk/sources/ui/propertieseditorwidget.cpp 2015-05-03 17:32:28 UTC (rev 3932)
@@ -28,10 +28,19 @@
{}
/**
- * @brief PropertiesEditorWidget::assosiatedUndo
- * By default, return an empty undo command
- * @return an empty undo command
+ * @brief PropertiesEditorWidget::associatedUndo
+ * By default, return a nullptr
+ * @return nullptr
*/
-QUndoCommand *PropertiesEditorWidget::assosiatedUndo() {
- return new QUndoCommand();
+QUndoCommand *PropertiesEditorWidget::associatedUndo() const{
+ return nullptr;
}
+
+/**
+ * @brief PropertiesEditorWidget::title
+ * @return the title of this editor
+ */
+QString PropertiesEditorWidget::title() const
+{
+ return QString();
+}
Modified: trunk/sources/ui/propertieseditorwidget.h
===================================================================
--- trunk/sources/ui/propertieseditorwidget.h 2015-05-03 15:31:19 UTC (rev 3931)
+++ trunk/sources/ui/propertieseditorwidget.h 2015-05-03 17:32:28 UTC (rev 3932)
@@ -33,9 +33,10 @@
public:
explicit PropertiesEditorWidget(QWidget *parent = 0);
- void apply() {}
- void reset() {}
- virtual QUndoCommand *assosiatedUndo ();
+ virtual void apply() {}
+ virtual void reset() {}
+ virtual QUndoCommand *associatedUndo () const;
+ virtual QString title() const;
};
#endif // PROPERTIESEDITORWIDGET_H