mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Dock properties editor : when selection change dock try to stay in the same tab with the new selection (if possible)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3990 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -104,6 +104,14 @@ bool PropertiesEditorDockWidget::addEditor(PropertiesEditorWidget *editor, int i
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PropertiesEditorDockWidget::editors
|
||||||
|
* @return all editor used in this dock
|
||||||
|
*/
|
||||||
|
QList<PropertiesEditorWidget *> PropertiesEditorDockWidget::editors() const {
|
||||||
|
return m_editor_list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PropertiesEditorDockWidget::removeEditor
|
* @brief PropertiesEditorDockWidget::removeEditor
|
||||||
* Remove @editor from this dock. The editor wasn't delete a the end of this method
|
* Remove @editor from this dock. The editor wasn't delete a the end of this method
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class PropertiesEditorDockWidget : public QDockWidget
|
|||||||
virtual void apply();
|
virtual void apply();
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
bool addEditor (PropertiesEditorWidget *editor, int index = 0);
|
bool addEditor (PropertiesEditorWidget *editor, int index = 0);
|
||||||
|
QList<PropertiesEditorWidget *> editors() const;
|
||||||
bool removeEditor (PropertiesEditorWidget *editor);
|
bool removeEditor (PropertiesEditorWidget *editor);
|
||||||
void setDisabledButtonBox(bool b = true);
|
void setDisabledButtonBox(bool b = true);
|
||||||
void setEnabledButtonBox (bool b = true);
|
void setEnabledButtonBox (bool b = true);
|
||||||
|
|||||||
23
sources/ui/abstractelementpropertieseditorwidget.cpp
Normal file
23
sources/ui/abstractelementpropertieseditorwidget.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
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 "abstractelementpropertieseditorwidget.h"
|
||||||
|
|
||||||
|
AbstractElementPropertiesEditorWidget::AbstractElementPropertiesEditorWidget(QWidget *parent) :
|
||||||
|
PropertiesEditorWidget(parent),
|
||||||
|
m_element (nullptr)
|
||||||
|
{}
|
||||||
42
sources/ui/abstractelementpropertieseditorwidget.h
Normal file
42
sources/ui/abstractelementpropertieseditorwidget.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
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 ABSTRACTELEMENTPROPERTIESEDITORWIDGET_H
|
||||||
|
#define ABSTRACTELEMENTPROPERTIESEDITORWIDGET_H
|
||||||
|
|
||||||
|
#include "PropertiesEditor/propertieseditorwidget.h"
|
||||||
|
|
||||||
|
class Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The AbstractElementPropertiesEditorWidget class
|
||||||
|
* This class provide common method for all widget used to edit some properties of an element
|
||||||
|
*/
|
||||||
|
class AbstractElementPropertiesEditorWidget : public PropertiesEditorWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit AbstractElementPropertiesEditorWidget(QWidget *parent = 0);
|
||||||
|
virtual void setElement(Element *element) =0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Element *m_element;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ABSTRACTELEMENTPROPERTIESEDITORWIDGET_H
|
||||||
@@ -29,7 +29,8 @@
|
|||||||
*/
|
*/
|
||||||
DiagramPropertiesEditorDockWidget::DiagramPropertiesEditorDockWidget(QWidget *parent) :
|
DiagramPropertiesEditorDockWidget::DiagramPropertiesEditorDockWidget(QWidget *parent) :
|
||||||
PropertiesEditorDockWidget(parent),
|
PropertiesEditorDockWidget(parent),
|
||||||
m_diagram(nullptr)
|
m_diagram(nullptr),
|
||||||
|
m_edited_qgi_type(UnknowQGIType)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,7 +44,6 @@ DiagramPropertiesEditorDockWidget::DiagramPropertiesEditorDockWidget(QWidget *pa
|
|||||||
void DiagramPropertiesEditorDockWidget::setDiagram(Diagram *diagram)
|
void DiagramPropertiesEditorDockWidget::setDiagram(Diagram *diagram)
|
||||||
{
|
{
|
||||||
if (m_diagram == diagram) return;
|
if (m_diagram == diagram) return;
|
||||||
clear();
|
|
||||||
|
|
||||||
if (m_diagram)
|
if (m_diagram)
|
||||||
{
|
{
|
||||||
@@ -59,7 +59,10 @@ void DiagramPropertiesEditorDockWidget::setDiagram(Diagram *diagram)
|
|||||||
selectionChanged();
|
selectionChanged();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_diagram = nullptr;
|
m_diagram = nullptr;
|
||||||
|
clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,17 +73,37 @@ void DiagramPropertiesEditorDockWidget::setDiagram(Diagram *diagram)
|
|||||||
void DiagramPropertiesEditorDockWidget::selectionChanged()
|
void DiagramPropertiesEditorDockWidget::selectionChanged()
|
||||||
{
|
{
|
||||||
if (!m_diagram) return;
|
if (!m_diagram) return;
|
||||||
clear();
|
|
||||||
|
|
||||||
if (m_diagram->selectedItems().size() == 1)
|
if (m_diagram->selectedItems().size() == 1) //We can open an editor only when there is one selected item
|
||||||
{
|
{
|
||||||
QGraphicsItem *item = m_diagram->selectedItems().first();
|
QGraphicsItem *item = m_diagram->selectedItems().first();
|
||||||
|
|
||||||
if (Element *elmt = dynamic_cast<Element*>(item))
|
if (Element *elmt = dynamic_cast<Element*>(item))
|
||||||
|
{
|
||||||
|
if (m_edited_qgi_type == ElementQGIType && editors().size() == 1)
|
||||||
|
{
|
||||||
|
ElementPropertiesWidget *epw = dynamic_cast<ElementPropertiesWidget*>(editors().first());
|
||||||
|
if (epw) //In this case we only update each editor widget with the new element instead of create new widget.
|
||||||
|
{
|
||||||
|
epw->setElement(elmt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clear();
|
||||||
|
m_edited_qgi_type = ElementQGIType;
|
||||||
addEditor(new ElementPropertiesWidget(elmt, this));
|
addEditor(new ElementPropertiesWidget(elmt, this));
|
||||||
|
}
|
||||||
else if (DiagramImageItem *image = dynamic_cast<DiagramImageItem *>(item))
|
else if (DiagramImageItem *image = dynamic_cast<DiagramImageItem *>(item))
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
m_edited_qgi_type = ImageQGIType;
|
||||||
addEditor(new ImagePropertiesWidget(image, this));
|
addEditor(new ImagePropertiesWidget(image, this));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
clear();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "PropertiesEditor/propertieseditordockwidget.h"
|
#include "PropertiesEditor/propertieseditordockwidget.h"
|
||||||
|
|
||||||
class Diagram;
|
class Diagram;
|
||||||
|
class QGraphicsItem;
|
||||||
|
|
||||||
class DiagramPropertiesEditorDockWidget : public PropertiesEditorDockWidget
|
class DiagramPropertiesEditorDockWidget : public PropertiesEditorDockWidget
|
||||||
{
|
{
|
||||||
@@ -36,7 +37,9 @@ class DiagramPropertiesEditorDockWidget : public PropertiesEditorDockWidget
|
|||||||
void diagramWasDeleted();
|
void diagramWasDeleted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum EditedQGIType {UnknowQGIType, ElementQGIType, ImageQGIType};
|
||||||
Diagram *m_diagram;
|
Diagram *m_diagram;
|
||||||
|
EditedQGIType m_edited_qgi_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIAGRAMPROPERTIESEDITORDOCKWIDGET_H
|
#endif // DIAGRAMPROPERTIESEDITORDOCKWIDGET_H
|
||||||
|
|||||||
@@ -30,15 +30,13 @@
|
|||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
ElementInfoWidget::ElementInfoWidget(Element *elmt, QWidget *parent) :
|
ElementInfoWidget::ElementInfoWidget(Element *elmt, QWidget *parent) :
|
||||||
PropertiesEditorWidget(parent),
|
AbstractElementPropertiesEditorWidget(parent),
|
||||||
ui(new Ui::ElementInfoWidget),
|
ui(new Ui::ElementInfoWidget),
|
||||||
element_(elmt),
|
|
||||||
elmt_info(elmt->elementInformations()),
|
|
||||||
m_first_activation (false)
|
m_first_activation (false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
buildInterface();
|
buildInterface();
|
||||||
fillInfo();
|
setElement(elmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +49,19 @@ ElementInfoWidget::~ElementInfoWidget()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementInfoWidget::setElement
|
||||||
|
* Set @element to be the edited element
|
||||||
|
* @param element
|
||||||
|
*/
|
||||||
|
void ElementInfoWidget::setElement(Element *element)
|
||||||
|
{
|
||||||
|
if (m_element == element) return;
|
||||||
|
m_element = element;
|
||||||
|
m_element_info = m_element->elementInformations();
|
||||||
|
fillInfo();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementInfoWidget::apply
|
* @brief ElementInfoWidget::apply
|
||||||
* Apply the new information with a new undo command (got with method associatedUndo)
|
* Apply the new information with a new undo command (got with method associatedUndo)
|
||||||
@@ -59,7 +70,7 @@ ElementInfoWidget::~ElementInfoWidget()
|
|||||||
void ElementInfoWidget::apply()
|
void ElementInfoWidget::apply()
|
||||||
{
|
{
|
||||||
if (QUndoCommand *undo = associatedUndo())
|
if (QUndoCommand *undo = associatedUndo())
|
||||||
element_ -> diagram() -> undoStack().push(undo);
|
m_element -> diagram() -> undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +82,7 @@ void ElementInfoWidget::apply()
|
|||||||
*/
|
*/
|
||||||
QUndoCommand* ElementInfoWidget::associatedUndo() const {
|
QUndoCommand* ElementInfoWidget::associatedUndo() const {
|
||||||
DiagramContext new_info;
|
DiagramContext new_info;
|
||||||
DiagramContext old_info = element_ -> elementInformations();
|
DiagramContext old_info = m_element -> elementInformations();
|
||||||
|
|
||||||
foreach (ElementInfoPartWidget *eipw, eipw_list) {
|
foreach (ElementInfoPartWidget *eipw, eipw_list) {
|
||||||
//add value only if they're something to store
|
//add value only if they're something to store
|
||||||
@@ -82,7 +93,7 @@ QUndoCommand* ElementInfoWidget::associatedUndo() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (old_info != new_info) {
|
if (old_info != new_info) {
|
||||||
return (new ChangeElementInformationCommand(element_, old_info, new_info));
|
return (new ChangeElementInformationCommand(m_element, old_info, new_info));
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -122,19 +133,19 @@ void ElementInfoWidget::buildInterface() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementInfoWidget::fillInfo
|
* @brief ElementInfoWidget::fillInfo
|
||||||
* fill information fetch in elmt_info to the
|
* fill information fetch in m_element_info to the
|
||||||
* corresponding line edit
|
* corresponding line edit
|
||||||
*/
|
*/
|
||||||
void ElementInfoWidget::fillInfo() {
|
void ElementInfoWidget::fillInfo() {
|
||||||
foreach (ElementInfoPartWidget *eipw, eipw_list) {
|
foreach (ElementInfoPartWidget *eipw, eipw_list) {
|
||||||
|
|
||||||
eipw -> setText (elmt_info[eipw->key()].toString());
|
eipw -> setText (m_element_info[eipw->key()].toString());
|
||||||
eipw -> setShow (elmt_info.keyMustShow(eipw->key()));
|
eipw -> setShow (m_element_info.keyMustShow(eipw->key()));
|
||||||
|
|
||||||
//If the current eipw is for label or comment and the text is empty
|
//If the current eipw is for label or comment and the text is empty
|
||||||
//we force the checkbox to ckecked
|
//we force the checkbox to ckecked
|
||||||
if (eipw -> key() == "label" || eipw -> key() == "comment") {
|
if (eipw -> key() == "label" || eipw -> key() == "comment") {
|
||||||
if (elmt_info[eipw->key()].toString().isEmpty())
|
if (m_element_info[eipw->key()].toString().isEmpty())
|
||||||
eipw->setShow(true);
|
eipw->setShow(true);
|
||||||
}
|
}
|
||||||
else //< for other eipw we hide the checkbox
|
else //< for other eipw we hide the checkbox
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
#include "PropertiesEditor/propertieseditorwidget.h"
|
#include "abstractelementpropertieseditorwidget.h"
|
||||||
|
|
||||||
class Element;
|
class Element;
|
||||||
class QUndoCommand;
|
class QUndoCommand;
|
||||||
@@ -35,7 +35,7 @@ namespace Ui {
|
|||||||
* @brief The ElementInfoWidget class
|
* @brief The ElementInfoWidget class
|
||||||
* this class is a widget to edit an element informations.
|
* this class is a widget to edit an element informations.
|
||||||
*/
|
*/
|
||||||
class ElementInfoWidget : public PropertiesEditorWidget
|
class ElementInfoWidget : public AbstractElementPropertiesEditorWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -44,6 +44,7 @@ class ElementInfoWidget : public PropertiesEditorWidget
|
|||||||
explicit ElementInfoWidget(Element *elmt, QWidget *parent = 0);
|
explicit ElementInfoWidget(Element *elmt, QWidget *parent = 0);
|
||||||
~ElementInfoWidget();
|
~ElementInfoWidget();
|
||||||
|
|
||||||
|
void setElement(Element *element);
|
||||||
void apply();
|
void apply();
|
||||||
QUndoCommand *associatedUndo () const;
|
QUndoCommand *associatedUndo () const;
|
||||||
QString title() const {return tr("Informations");}
|
QString title() const {return tr("Informations");}
|
||||||
@@ -61,8 +62,7 @@ class ElementInfoWidget : public PropertiesEditorWidget
|
|||||||
//ATTRIBUTES
|
//ATTRIBUTES
|
||||||
private:
|
private:
|
||||||
Ui::ElementInfoWidget *ui;
|
Ui::ElementInfoWidget *ui;
|
||||||
Element *element_;
|
DiagramContext m_element_info;
|
||||||
DiagramContext elmt_info;
|
|
||||||
QList <ElementInfoPartWidget *> eipw_list;
|
QList <ElementInfoPartWidget *> eipw_list;
|
||||||
bool m_first_activation;
|
bool m_first_activation;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,12 +36,40 @@
|
|||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
ElementPropertiesWidget::ElementPropertiesWidget(Element *elmt, QWidget *parent) :
|
ElementPropertiesWidget::ElementPropertiesWidget(Element *elmt, QWidget *parent) :
|
||||||
PropertiesEditorWidget (parent),
|
AbstractElementPropertiesEditorWidget (parent),
|
||||||
m_element (elmt),
|
|
||||||
m_diagram (elmt->diagram()),
|
m_diagram (elmt->diagram()),
|
||||||
m_tab (nullptr)
|
m_tab (nullptr),
|
||||||
|
m_general_widget(nullptr)
|
||||||
{
|
{
|
||||||
buildGui();
|
buildGui();
|
||||||
|
setElement(elmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementPropertiesWidget::setElement
|
||||||
|
* Set @element to be the edited element
|
||||||
|
* @param element
|
||||||
|
*/
|
||||||
|
void ElementPropertiesWidget::setElement(Element *element)
|
||||||
|
{
|
||||||
|
if (m_element == element) return;
|
||||||
|
Element *previous_element = m_element;
|
||||||
|
m_element = element;
|
||||||
|
|
||||||
|
if (previous_element)
|
||||||
|
{
|
||||||
|
//If previous element is same type as new element we just call setElement for each editor
|
||||||
|
if(previous_element->linkType() == m_element->linkType())
|
||||||
|
{
|
||||||
|
foreach (AbstractElementPropertiesEditorWidget *aepew, m_list_editor)
|
||||||
|
{
|
||||||
|
aepew->setElement(m_element);
|
||||||
|
addGeneralWidget();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,6 +137,26 @@ void ElementPropertiesWidget::editElement()
|
|||||||
void ElementPropertiesWidget::buildGui()
|
void ElementPropertiesWidget::buildGui()
|
||||||
{
|
{
|
||||||
m_tab = new QTabWidget(this);
|
m_tab = new QTabWidget(this);
|
||||||
|
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||||
|
main_layout -> addWidget(m_tab);
|
||||||
|
setLayout(main_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementPropertiesWidget::updateUi
|
||||||
|
* Update the content of this widget
|
||||||
|
*/
|
||||||
|
void ElementPropertiesWidget::updateUi()
|
||||||
|
{
|
||||||
|
//We keep the current title of the tab, to return to the same tab
|
||||||
|
//if possible, at the end of this method
|
||||||
|
QString tab_text;
|
||||||
|
tab_text = m_tab->tabText(m_tab->currentIndex());
|
||||||
|
|
||||||
|
//Purge the tab widget and delete all widget
|
||||||
|
m_tab->clear();
|
||||||
|
qDeleteAll(m_list_editor); m_list_editor.clear();
|
||||||
|
if(m_general_widget) delete m_general_widget; m_general_widget = nullptr;
|
||||||
|
|
||||||
//Add tab according to the element
|
//Add tab according to the element
|
||||||
switch (m_element -> linkType())
|
switch (m_element -> linkType())
|
||||||
@@ -136,11 +184,36 @@ void ElementPropertiesWidget::buildGui()
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (PropertiesEditorWidget *pew, m_list_editor) m_tab->addTab(pew, pew->title());
|
foreach (PropertiesEditorWidget *pew, m_list_editor) m_tab->addTab(pew, pew->title());
|
||||||
m_tab -> addTab(generalWidget(), tr("Général"));
|
addGeneralWidget();
|
||||||
|
|
||||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
if (!tab_text.isEmpty())
|
||||||
main_layout -> addWidget(m_tab);
|
{
|
||||||
setLayout(main_layout);
|
for(int i=0 ; i<m_tab->count() ; ++i)
|
||||||
|
{
|
||||||
|
if (tab_text == m_tab->tabBar()->tabText(i))
|
||||||
|
{
|
||||||
|
m_tab->setCurrentIndex(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementPropertiesWidget::addGeneralWidget
|
||||||
|
* Add or update the general widget on this tab widget
|
||||||
|
*/
|
||||||
|
void ElementPropertiesWidget::addGeneralWidget()
|
||||||
|
{
|
||||||
|
int index = m_tab->currentIndex();
|
||||||
|
if (m_general_widget)
|
||||||
|
{
|
||||||
|
m_tab->removeTab(m_tab->indexOf(m_general_widget));
|
||||||
|
delete m_general_widget;
|
||||||
|
}
|
||||||
|
m_general_widget = generalWidget();
|
||||||
|
m_tab -> addTab(m_general_widget, tr("Général"));
|
||||||
|
m_tab->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#ifndef ELEMENTPROPERTIESWIDGET_H
|
#ifndef ELEMENTPROPERTIESWIDGET_H
|
||||||
#define ELEMENTPROPERTIESWIDGET_H
|
#define ELEMENTPROPERTIESWIDGET_H
|
||||||
|
|
||||||
#include "PropertiesEditor/propertieseditorwidget.h"
|
#include "abstractelementpropertieseditorwidget.h"
|
||||||
|
|
||||||
class Element;
|
class Element;
|
||||||
class Diagram;
|
class Diagram;
|
||||||
@@ -26,12 +26,13 @@ class QTabWidget;
|
|||||||
class ElementsLocation;
|
class ElementsLocation;
|
||||||
|
|
||||||
|
|
||||||
class ElementPropertiesWidget : public PropertiesEditorWidget
|
class ElementPropertiesWidget : public AbstractElementPropertiesEditorWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ElementPropertiesWidget(Element *elmt, QWidget *parent = 0);
|
explicit ElementPropertiesWidget(Element *elmt, QWidget *parent = 0);
|
||||||
|
void setElement(Element *element);
|
||||||
void apply();
|
void apply();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
@@ -41,6 +42,8 @@ class ElementPropertiesWidget : public PropertiesEditorWidget
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void buildGui();
|
void buildGui();
|
||||||
|
void updateUi();
|
||||||
|
void addGeneralWidget();
|
||||||
QWidget *generalWidget();
|
QWidget *generalWidget();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -50,10 +53,10 @@ class ElementPropertiesWidget : public PropertiesEditorWidget
|
|||||||
void editElementRequired(const ElementsLocation &);
|
void editElementRequired(const ElementsLocation &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Element *m_element;
|
|
||||||
Diagram *m_diagram;
|
Diagram *m_diagram;
|
||||||
QTabWidget *m_tab;
|
QTabWidget *m_tab;
|
||||||
QList <PropertiesEditorWidget *> m_list_editor;
|
QList <AbstractElementPropertiesEditorWidget *> m_list_editor;
|
||||||
|
QWidget *m_general_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ELEMENTPROPERTIESWIDGET_H
|
#endif // ELEMENTPROPERTIESWIDGET_H
|
||||||
|
|||||||
@@ -31,9 +31,8 @@
|
|||||||
* the parent widget
|
* the parent widget
|
||||||
*/
|
*/
|
||||||
LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent) :
|
LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent) :
|
||||||
PropertiesEditorWidget(parent),
|
AbstractElementPropertiesEditorWidget(parent),
|
||||||
ui(new Ui::LinkSingleElementWidget),
|
ui(new Ui::LinkSingleElementWidget),
|
||||||
m_element(nullptr),
|
|
||||||
esw_(0),
|
esw_(0),
|
||||||
unlink_widget(0),
|
unlink_widget(0),
|
||||||
unlink_(false),
|
unlink_(false),
|
||||||
|
|||||||
@@ -18,8 +18,9 @@
|
|||||||
#ifndef LINKSINGLEELEMENTWIDGET_H
|
#ifndef LINKSINGLEELEMENTWIDGET_H
|
||||||
#define LINKSINGLEELEMENTWIDGET_H
|
#define LINKSINGLEELEMENTWIDGET_H
|
||||||
|
|
||||||
#include "PropertiesEditor/propertieseditorwidget.h"
|
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
|
#include "abstractelementpropertieseditorwidget.h"
|
||||||
|
|
||||||
|
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
@@ -39,7 +40,7 @@ namespace Ui {
|
|||||||
* If the element is already linked, the widget ask user to unlink.
|
* If the element is already linked, the widget ask user to unlink.
|
||||||
* This widget embedded the diagram command for undo/redo the action
|
* This widget embedded the diagram command for undo/redo the action
|
||||||
*/
|
*/
|
||||||
class LinkSingleElementWidget : public PropertiesEditorWidget
|
class LinkSingleElementWidget : public AbstractElementPropertiesEditorWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -72,7 +73,6 @@ class LinkSingleElementWidget : public PropertiesEditorWidget
|
|||||||
///Attributes
|
///Attributes
|
||||||
private:
|
private:
|
||||||
Ui::LinkSingleElementWidget *ui;
|
Ui::LinkSingleElementWidget *ui;
|
||||||
Element *m_element;
|
|
||||||
ElementSelectorWidget *esw_;
|
ElementSelectorWidget *esw_;
|
||||||
QList <Diagram *> diagram_list;
|
QList <Diagram *> diagram_list;
|
||||||
QWidget *unlink_widget;
|
QWidget *unlink_widget;
|
||||||
|
|||||||
@@ -31,22 +31,15 @@
|
|||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
|
MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
|
||||||
PropertiesEditorWidget(parent),
|
AbstractElementPropertiesEditorWidget(parent),
|
||||||
ui(new Ui::MasterPropertiesWidget),
|
ui(new Ui::MasterPropertiesWidget),
|
||||||
m_element(elmt),
|
|
||||||
m_showed_element (nullptr),
|
m_showed_element (nullptr),
|
||||||
m_project(nullptr)
|
m_project(nullptr)
|
||||||
{
|
{
|
||||||
if(Q_LIKELY(elmt->diagram() && elmt->diagram()->project()))
|
|
||||||
{
|
|
||||||
m_project = elmt->diagram()->project();
|
|
||||||
connect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(diagramWasdeletedFromProject()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(ui->free_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showElementFromLWI(QListWidgetItem*)));
|
connect(ui->free_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showElementFromLWI(QListWidgetItem*)));
|
||||||
connect(ui->linked_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showElementFromLWI(QListWidgetItem*)));
|
connect(ui->linked_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showElementFromLWI(QListWidgetItem*)));
|
||||||
buildInterface();
|
setElement(elmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,6 +61,15 @@ void MasterPropertiesWidget::setElement(Element *element)
|
|||||||
{
|
{
|
||||||
if (m_element == element) return;
|
if (m_element == element) return;
|
||||||
if (m_showed_element) {m_showed_element->setHighlighted(false); m_showed_element = nullptr;}
|
if (m_showed_element) {m_showed_element->setHighlighted(false); m_showed_element = nullptr;}
|
||||||
|
if (m_project) disconnect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(diagramWasdeletedFromProject()));
|
||||||
|
|
||||||
|
if(Q_LIKELY(element->diagram() && element->diagram()->project()))
|
||||||
|
{
|
||||||
|
m_project = element->diagram()->project();
|
||||||
|
connect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(diagramWasdeletedFromProject()));
|
||||||
|
}
|
||||||
|
else m_project = nullptr;
|
||||||
|
|
||||||
m_element = element;
|
m_element = element;
|
||||||
buildInterface();
|
buildInterface();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include "PropertiesEditor/propertieseditorwidget.h"
|
#include "abstractelementpropertieseditorwidget.h"
|
||||||
|
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
class Element;
|
class Element;
|
||||||
@@ -38,7 +38,7 @@ namespace Ui {
|
|||||||
* This class embenddedthe undo/redo command when apply new connection.
|
* This class embenddedthe undo/redo command when apply new connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class MasterPropertiesWidget : public PropertiesEditorWidget
|
class MasterPropertiesWidget : public AbstractElementPropertiesEditorWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -62,7 +62,6 @@ class MasterPropertiesWidget : public PropertiesEditorWidget
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MasterPropertiesWidget *ui;
|
Ui::MasterPropertiesWidget *ui;
|
||||||
Element *m_element;
|
|
||||||
QHash <QListWidgetItem *, Element *> lwi_hash;
|
QHash <QListWidgetItem *, Element *> lwi_hash;
|
||||||
Element *m_showed_element;
|
Element *m_showed_element;
|
||||||
QETProject *m_project;
|
QETProject *m_project;
|
||||||
|
|||||||
Reference in New Issue
Block a user