mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Diagram editor : add dock widget for edit the current selection.
For the moment only work with element git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3943 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -61,6 +61,8 @@ DEFINES += QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
|
||||
######################################################################
|
||||
|
||||
include(sources/PropertiesEditor/PropertiesEditor.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
DEPENDPATH += .
|
||||
INCLUDEPATH += sources \
|
||||
|
||||
10
sources/PropertiesEditor/PropertiesEditor.pri
Executable file
10
sources/PropertiesEditor/PropertiesEditor.pri
Executable file
@@ -0,0 +1,10 @@
|
||||
FORMS += \
|
||||
$$PWD/propertieseditordockwidget.ui
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/propertieseditordockwidget.h \
|
||||
$$PWD/propertieseditorwidget.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/propertieseditordockwidget.cpp \
|
||||
$$PWD/propertieseditorwidget.cpp
|
||||
160
sources/PropertiesEditor/propertieseditordockwidget.cpp
Normal file
160
sources/PropertiesEditor/propertieseditordockwidget.cpp
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
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 "propertieseditordockwidget.h"
|
||||
#include "ui_propertieseditordockwidget.h"
|
||||
#include "propertieseditorwidget.h"
|
||||
|
||||
#include <QAbstractButton>
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::PropertiesEditorDockWidget
|
||||
* Constructor
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
PropertiesEditorDockWidget::PropertiesEditorDockWidget(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::PropertiesEditorDockWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_main_vlayout->setAlignment(ui->buttonBox, Qt::AlignBottom);
|
||||
ui->buttonBox->setDisabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::~PropertiesEditorDockWidget
|
||||
* Destructor
|
||||
*/
|
||||
PropertiesEditorDockWidget::~PropertiesEditorDockWidget()
|
||||
{
|
||||
clear();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::clear
|
||||
* Remove all editor present in this dock and delete it.
|
||||
* They also disabled the button box at the bottom of this dock
|
||||
*/
|
||||
void PropertiesEditorDockWidget::clear()
|
||||
{
|
||||
foreach (PropertiesEditorWidget *editor, m_editor_list)
|
||||
{
|
||||
m_editor_list.removeOne(editor);
|
||||
ui->m_main_vlayout->removeWidget(editor);
|
||||
editor->deleteLater();
|
||||
}
|
||||
|
||||
m_editor_list.clear();
|
||||
|
||||
ui->buttonBox->setDisabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::apply
|
||||
* Call the apply method for each editor present in this dock
|
||||
*/
|
||||
void PropertiesEditorDockWidget::apply()
|
||||
{
|
||||
foreach(PropertiesEditorWidget *editor, m_editor_list)
|
||||
editor->apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::reset
|
||||
* Call the reset method for each editor present in this widget
|
||||
*/
|
||||
void PropertiesEditorDockWidget::reset()
|
||||
{
|
||||
foreach(PropertiesEditorWidget *editor, m_editor_list)
|
||||
editor->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::addEditor
|
||||
* Add an @editor in this dock at @index in the main vertical layout (note the button box
|
||||
* are displayed at bottom of this layout by default)
|
||||
* When an editor is added, we enable the button box
|
||||
* @param editor : editor to add;
|
||||
* @param index : index of editor in the layout
|
||||
* @return true if was added (or already add) or false if can't be add (editor = nullptr)
|
||||
*/
|
||||
bool PropertiesEditorDockWidget::addEditor(PropertiesEditorWidget *editor, int index)
|
||||
{
|
||||
if (!editor) return false;
|
||||
if (m_editor_list.contains(editor)) return true;
|
||||
|
||||
ui -> m_main_vlayout -> insertWidget(index, editor);
|
||||
m_editor_list << editor;
|
||||
setEnabledButtonBox(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::removeEditor
|
||||
* Remove @editor from this dock. The editor wasn't delete a the end of this method
|
||||
* If the editor was the last on this widget, we disabled the button box
|
||||
* @param editor : editor to remove
|
||||
* @return true on success, else false
|
||||
*/
|
||||
bool PropertiesEditorDockWidget::removeEditor(PropertiesEditorWidget *editor)
|
||||
{
|
||||
bool result = m_editor_list.removeOne(editor);
|
||||
if (result)
|
||||
ui -> m_main_vlayout -> removeWidget(editor);
|
||||
|
||||
if (m_editor_list.isEmpty())
|
||||
setDisabledButtonBox(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::setDisabledButtonBox
|
||||
* Disabled the button box at bottom of dock
|
||||
* @param b
|
||||
*/
|
||||
void PropertiesEditorDockWidget::setDisabledButtonBox(bool b) {
|
||||
ui -> buttonBox -> setDisabled(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::setEnabledButtonBox
|
||||
* Enabled button box at bottom of dock
|
||||
* @param b
|
||||
*/
|
||||
void PropertiesEditorDockWidget::setEnabledButtonBox(bool b) {
|
||||
ui -> buttonBox -> setEnabled(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PropertiesEditorDockWidget::on_buttonBox_clicked
|
||||
* Action when button box button is clciked.
|
||||
* If button is ApplyRole : call the apply() method
|
||||
* If button is ResetRole : call the reset() method
|
||||
* @param button
|
||||
*/
|
||||
void PropertiesEditorDockWidget::on_buttonBox_clicked(QAbstractButton *button)
|
||||
{
|
||||
int answer = ui->buttonBox->buttonRole(button);
|
||||
|
||||
switch (answer)
|
||||
{
|
||||
case QDialogButtonBox::ApplyRole: apply(); break;
|
||||
case QDialogButtonBox::ResetRole: reset(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
57
sources/PropertiesEditor/propertieseditordockwidget.h
Normal file
57
sources/PropertiesEditor/propertieseditordockwidget.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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 SELECTIONPROPERTIESDOCKWIDGET_H
|
||||
#define SELECTIONPROPERTIESDOCKWIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
class PropertiesEditorWidget;
|
||||
class QAbstractButton;
|
||||
|
||||
namespace Ui {
|
||||
class PropertiesEditorDockWidget;
|
||||
}
|
||||
|
||||
class PropertiesEditorDockWidget : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PropertiesEditorDockWidget(QWidget *parent = 0);
|
||||
~PropertiesEditorDockWidget();
|
||||
|
||||
virtual void clear();
|
||||
virtual void apply();
|
||||
virtual void reset();
|
||||
bool addEditor (PropertiesEditorWidget *editor, int index = 0);
|
||||
bool removeEditor (PropertiesEditorWidget *editor);
|
||||
void setDisabledButtonBox(bool b = true);
|
||||
void setEnabledButtonBox (bool b = true);
|
||||
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
|
||||
protected:
|
||||
QList <PropertiesEditorWidget *> m_editor_list;
|
||||
|
||||
private:
|
||||
Ui::PropertiesEditorDockWidget *ui;
|
||||
};
|
||||
|
||||
#endif // SELECTIONPROPERTIESDOCKWIDGET_H
|
||||
52
sources/PropertiesEditor/propertieseditordockwidget.ui
Normal file
52
sources/PropertiesEditor/propertieseditordockwidget.ui
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PropertiesEditorDockWidget</class>
|
||||
<widget class="QDockWidget" name="PropertiesEditorDockWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Propriété de la séléction</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="m_main_vlayout">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::RestoreDefaults</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "dveventaddshape.h"
|
||||
#include "dveventaddtext.h"
|
||||
#include "reportproperties.h"
|
||||
#include "diagrampropertieseditordockwidget.h"
|
||||
|
||||
#include "ui/dialogautonum.h"
|
||||
|
||||
@@ -82,6 +83,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
||||
|
||||
setUpElementsPanel();
|
||||
setUpUndoStack();
|
||||
setUpSelectionPropertiesEditor();
|
||||
setUpActions();
|
||||
setUpToolBar();
|
||||
setUpMenu();
|
||||
@@ -172,6 +174,17 @@ void QETDiagramEditor::setUpUndoStack() {
|
||||
addDockWidget(Qt::LeftDockWidgetArea, qdw_undo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QETDiagramEditor::setUpSelectionPropertiesEditor
|
||||
* Setup the dock for edit the current selection
|
||||
*/
|
||||
void QETDiagramEditor::setUpSelectionPropertiesEditor()
|
||||
{
|
||||
m_selection_properties_editor = new DiagramPropertiesEditorDockWidget(this);
|
||||
m_selection_properties_editor -> setObjectName("diagram_properties_editor_dock_widget");
|
||||
addDockWidget(Qt::RightDockWidgetArea, m_selection_properties_editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QETDiagramEditor::setUpActions
|
||||
* Set up all Qaction
|
||||
@@ -727,7 +740,7 @@ bool QETDiagramEditor::openProject() {
|
||||
bool QETDiagramEditor::closeProject(ProjectView *project_view) {
|
||||
if (project_view) {
|
||||
activateProject(project_view);
|
||||
if (QMdiSubWindow *sub_window = subWindowForWidget(project_view)) {
|
||||
if (QMdiSubWindow *sub_window = subWindowForWidget(project_view)){
|
||||
return(sub_window -> close());
|
||||
}
|
||||
}
|
||||
@@ -1961,7 +1974,7 @@ void QETDiagramEditor::removeDiagramFromProject() {
|
||||
*/
|
||||
void QETDiagramEditor::diagramWasAdded(DiagramView *dv)
|
||||
{
|
||||
connect(dv, SIGNAL(selectionChanged()), this, SLOT(slot_updateComplexActions()));
|
||||
connect(dv, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
||||
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
|
||||
connect(dv, SIGNAL(itemAdded()), this, SLOT(addItemFinish()));
|
||||
}
|
||||
@@ -2071,6 +2084,19 @@ void QETDiagramEditor::subWindowActivated(QMdiSubWindow *subWindows)
|
||||
slot_updateWindowsMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QETDiagramEditor::selectionChanged
|
||||
* This slot is called when a diagram selection was changed.
|
||||
*/
|
||||
void QETDiagramEditor::selectionChanged()
|
||||
{
|
||||
slot_updateComplexActions();
|
||||
|
||||
DiagramView *dv = currentDiagram();
|
||||
if (dv && dv->diagram())
|
||||
m_selection_properties_editor->setDiagram(dv->diagram());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QETDiagramEditor::activeUndoStackCleanChanged
|
||||
* Enable the QAction save_file when @clean is set to false
|
||||
|
||||
@@ -30,6 +30,7 @@ class Element;
|
||||
class ElementsPanelWidget;
|
||||
class ElementsLocation;
|
||||
class RecentFiles;
|
||||
class DiagramPropertiesEditorDockWidget;
|
||||
/**
|
||||
This class represents the main window of the QElectroTech diagram editor and,
|
||||
ipso facto, the most important part of the QElectroTech user interface.
|
||||
@@ -48,6 +49,7 @@ class QETDiagramEditor : public QETMainWindow {
|
||||
private:
|
||||
void setUpElementsPanel ();
|
||||
void setUpUndoStack ();
|
||||
void setUpSelectionPropertiesEditor();
|
||||
void setUpActions ();
|
||||
void setUpToolBar ();
|
||||
void setUpMenu ();
|
||||
@@ -161,6 +163,7 @@ class QETDiagramEditor : public QETMainWindow {
|
||||
void subWindowActivated(QMdiSubWindow *subWindows);
|
||||
|
||||
private slots:
|
||||
void selectionChanged();
|
||||
void activeUndoStackCleanChanged (bool clean);
|
||||
|
||||
// attributes
|
||||
@@ -225,6 +228,7 @@ class QETDiagramEditor : public QETMainWindow {
|
||||
QDockWidget *qdw_pa;
|
||||
/// Dock for the undo list
|
||||
QDockWidget *qdw_undo;
|
||||
DiagramPropertiesEditorDockWidget *m_selection_properties_editor;
|
||||
/// Elements panel
|
||||
ElementsPanelWidget *pa;
|
||||
QMenu *windows_menu;
|
||||
|
||||
88
sources/ui/diagrampropertieseditordockwidget.cpp
Normal file
88
sources/ui/diagrampropertieseditordockwidget.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
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 "diagrampropertieseditordockwidget.h"
|
||||
#include "elementpropertieswidget.h"
|
||||
#include "diagram.h"
|
||||
#include "element.h"
|
||||
|
||||
/**
|
||||
* @brief DiagramPropertiesEditorDockWidget::DiagramPropertiesEditorDockWidget
|
||||
* Constructor
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
DiagramPropertiesEditorDockWidget::DiagramPropertiesEditorDockWidget(QWidget *parent) :
|
||||
PropertiesEditorDockWidget(parent),
|
||||
m_diagram(nullptr)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief DiagramPropertiesEditorDockWidget::setDiagram
|
||||
* Set the diagram to edit the selection.
|
||||
* Connect the diagram signal selectionChanged() to this slot selectionChanged();
|
||||
* If diagram = nullptr, we just disconnect all signal and remove editor.
|
||||
* @param diagram
|
||||
* @param diagram
|
||||
*/
|
||||
void DiagramPropertiesEditorDockWidget::setDiagram(Diagram *diagram)
|
||||
{
|
||||
if (m_diagram == diagram) return;
|
||||
clear();
|
||||
|
||||
if (m_diagram)
|
||||
{
|
||||
disconnect(m_diagram, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
||||
disconnect(m_diagram, SIGNAL(destroyed()), this, SLOT(diagramWasDeleted()));
|
||||
}
|
||||
|
||||
if (diagram)
|
||||
{
|
||||
m_diagram = diagram;
|
||||
connect(m_diagram, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
||||
connect(m_diagram, SIGNAL(destroyed()), this, SLOT(diagramWasDeleted()));
|
||||
selectionChanged();
|
||||
}
|
||||
else
|
||||
m_diagram = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DiagramPropertiesEditorDockWidget::selectionChanged
|
||||
* The current selection of diagram was changed.
|
||||
* We fill the dock with the appropriate ElementPropertiesWidget of the current selection.
|
||||
*/
|
||||
void DiagramPropertiesEditorDockWidget::selectionChanged()
|
||||
{
|
||||
if (!m_diagram) return;
|
||||
clear();
|
||||
if (m_diagram->selectedItems().size() == 1)
|
||||
{
|
||||
QGraphicsItem *item = m_diagram->selectedItems().first();
|
||||
if (Element *elmt = dynamic_cast<Element*>(item))
|
||||
addEditor(new ElementPropertiesWidget(elmt, this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DiagramPropertiesEditorDockWidget::diagramWasDeleted
|
||||
* Remove current editor and set m_diagram to nullptr.
|
||||
*/
|
||||
void DiagramPropertiesEditorDockWidget::diagramWasDeleted()
|
||||
{
|
||||
m_diagram = nullptr;
|
||||
clear();
|
||||
}
|
||||
42
sources/ui/diagrampropertieseditordockwidget.h
Normal file
42
sources/ui/diagrampropertieseditordockwidget.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 DIAGRAMPROPERTIESEDITORDOCKWIDGET_H
|
||||
#define DIAGRAMPROPERTIESEDITORDOCKWIDGET_H
|
||||
|
||||
#include "PropertiesEditor/propertieseditordockwidget.h"
|
||||
|
||||
class Diagram;
|
||||
|
||||
class DiagramPropertiesEditorDockWidget : public PropertiesEditorDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DiagramPropertiesEditorDockWidget(QWidget *parent = nullptr);
|
||||
|
||||
void setDiagram(Diagram *diagram);
|
||||
|
||||
private slots:
|
||||
void selectionChanged();
|
||||
void diagramWasDeleted();
|
||||
|
||||
private:
|
||||
Diagram *m_diagram;
|
||||
};
|
||||
|
||||
#endif // DIAGRAMPROPERTIESEDITORDOCKWIDGET_H
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include "diagramcontext.h"
|
||||
#include "propertieseditorwidget.h"
|
||||
#include "PropertiesEditor/propertieseditorwidget.h"
|
||||
|
||||
class Element;
|
||||
class QUndoCommand;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef ELEMENTPROPERTIESWIDGET_H
|
||||
#define ELEMENTPROPERTIESWIDGET_H
|
||||
|
||||
#include "propertieseditorwidget.h"
|
||||
#include "PropertiesEditor/propertieseditorwidget.h"
|
||||
|
||||
class Element;
|
||||
class Diagram;
|
||||
|
||||
@@ -62,10 +62,15 @@ ElementSelectorWidget::~ElementSelectorWidget()
|
||||
* @param elmt
|
||||
*/
|
||||
void ElementSelectorWidget::showElement(Element *elmt) {
|
||||
if (showed_element) showed_element->setHighlighted(false);
|
||||
if (showed_element)
|
||||
{
|
||||
disconnect(showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
|
||||
showed_element->setHighlighted(false);
|
||||
}
|
||||
elmt->diagram()->showMe();
|
||||
elmt->setHighlighted(true);
|
||||
showed_element = elmt;
|
||||
connect(showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,6 +229,14 @@ void ElementSelectorWidget::showElementFromList(const int i) {
|
||||
showElement(elements_list.at(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementSelectorWidget::showedElementWasDeleted
|
||||
* Set to nullptr the current showed element when he was deleted
|
||||
*/
|
||||
void ElementSelectorWidget::showedElementWasDeleted() {
|
||||
showed_element = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementSelectorWidget::filter
|
||||
* @return A stringlist with all available value
|
||||
|
||||
@@ -57,6 +57,7 @@ class ElementSelectorWidget : public QWidget
|
||||
private slots:
|
||||
void setSelectedElement (const int i) {selected_element = elements_list.at(i);}
|
||||
void showElementFromList (const int i);
|
||||
void showedElementWasDeleted ();
|
||||
|
||||
|
||||
///Attributes
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef LINKSINGLEELEMENTWIDGET_H
|
||||
#define LINKSINGLEELEMENTWIDGET_H
|
||||
|
||||
#include "propertieseditorwidget.h"
|
||||
#include "PropertiesEditor/propertieseditorwidget.h"
|
||||
#include "element.h"
|
||||
|
||||
class Diagram;
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
|
||||
PropertiesEditorWidget(parent),
|
||||
ui(new Ui::MasterPropertiesWidget),
|
||||
element_(elmt)
|
||||
element_(elmt),
|
||||
m_showed_element (nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
buildInterface();
|
||||
@@ -47,7 +48,8 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
|
||||
*/
|
||||
MasterPropertiesWidget::~MasterPropertiesWidget()
|
||||
{
|
||||
foreach(Element *elmt, lwi_hash.values()) elmt->setHighlighted(false);
|
||||
if (m_showed_element) m_showed_element->setHighlighted(false);
|
||||
//foreach(Element *elmt, lwi_hash.values()) elmt->setHighlighted(false);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -184,9 +186,24 @@ void MasterPropertiesWidget::on_unlink_button_clicked() {
|
||||
* Show the element corresponding to the given QListWidgetItem
|
||||
* @param lwi
|
||||
*/
|
||||
void MasterPropertiesWidget::showElementFromLWI(QListWidgetItem *lwi) {
|
||||
foreach(Element *elmt, lwi_hash.values()) elmt->setHighlighted(false);
|
||||
Element *elmt = lwi_hash[lwi];
|
||||
elmt->diagram()->showMe();
|
||||
elmt->setHighlighted(true);
|
||||
void MasterPropertiesWidget::showElementFromLWI(QListWidgetItem *lwi)
|
||||
{
|
||||
if (m_showed_element)
|
||||
{
|
||||
disconnect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
|
||||
m_showed_element -> setHighlighted(false);
|
||||
}
|
||||
|
||||
m_showed_element = lwi_hash[lwi];
|
||||
m_showed_element->diagram()->showMe();
|
||||
m_showed_element->setHighlighted(true);
|
||||
connect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MasterPropertiesWidget::showedElementWasDeleted
|
||||
* Set to nullptr the current showed element when he was deleted
|
||||
*/
|
||||
void MasterPropertiesWidget::showedElementWasDeleted() {
|
||||
m_showed_element = nullptr;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHash>
|
||||
#include <propertieseditorwidget.h>
|
||||
#include "PropertiesEditor/propertieseditorwidget.h"
|
||||
|
||||
class QListWidgetItem;
|
||||
class Element;
|
||||
@@ -56,11 +56,13 @@ class MasterPropertiesWidget : public PropertiesEditorWidget
|
||||
void on_link_button_clicked();
|
||||
void on_unlink_button_clicked();
|
||||
void showElementFromLWI(QListWidgetItem *lwi);
|
||||
void showedElementWasDeleted ();
|
||||
|
||||
private:
|
||||
Ui::MasterPropertiesWidget *ui;
|
||||
Element *element_;
|
||||
QHash <QListWidgetItem *, Element *> lwi_hash;
|
||||
Element *m_showed_element;
|
||||
};
|
||||
|
||||
#endif // MASTERPROPERTIESWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user