mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
Element info widget : fix wrong behavior with cursor when use the live edit mode
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4002 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -59,12 +59,12 @@ void ElementInfoWidget::setElement(Element *element)
|
|||||||
if (m_element == element) return;
|
if (m_element == element) return;
|
||||||
|
|
||||||
if (m_element)
|
if (m_element)
|
||||||
disconnect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::updateUi);
|
disconnect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::elementInfoChange);
|
||||||
|
|
||||||
m_element = element;
|
m_element = element;
|
||||||
updateUi();
|
updateUi();
|
||||||
|
|
||||||
connect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::updateUi);
|
connect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::elementInfoChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,18 +87,9 @@ void ElementInfoWidget::apply()
|
|||||||
*/
|
*/
|
||||||
QUndoCommand* ElementInfoWidget::associatedUndo() const
|
QUndoCommand* ElementInfoWidget::associatedUndo() const
|
||||||
{
|
{
|
||||||
DiagramContext new_info;
|
DiagramContext new_info = currentInfo();
|
||||||
DiagramContext old_info = m_element -> elementInformations();
|
DiagramContext old_info = m_element -> elementInformations();
|
||||||
|
|
||||||
foreach (ElementInfoPartWidget *eipw, m_eipw_list)
|
|
||||||
{
|
|
||||||
//add value only if they're something to store
|
|
||||||
if (!eipw->text().isEmpty())
|
|
||||||
new_info.addValue(eipw->key(),
|
|
||||||
eipw->text(),
|
|
||||||
eipw->mustShow());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (old_info != new_info)
|
if (old_info != new_info)
|
||||||
return (new ChangeElementInformationCommand(m_element, old_info, new_info));
|
return (new ChangeElementInformationCommand(m_element, old_info, new_info));
|
||||||
|
|
||||||
@@ -214,6 +205,21 @@ void ElementInfoWidget::updateUi()
|
|||||||
if (m_live_edit) enableLiveEdit();
|
if (m_live_edit) enableLiveEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementInfoWidget::currentInfo
|
||||||
|
* @return the info currently edited
|
||||||
|
*/
|
||||||
|
DiagramContext ElementInfoWidget::currentInfo() const
|
||||||
|
{
|
||||||
|
DiagramContext info_;
|
||||||
|
|
||||||
|
foreach (ElementInfoPartWidget *eipw, m_eipw_list)
|
||||||
|
if (!eipw->text().isEmpty()) //add value only if they're something to store
|
||||||
|
info_.addValue(eipw->key(), eipw->text(), eipw->mustShow());
|
||||||
|
|
||||||
|
return info_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementInfoWidget::firstActivated
|
* @brief ElementInfoWidget::firstActivated
|
||||||
* Slot activated when this widget is show.
|
* Slot activated when this widget is show.
|
||||||
@@ -222,3 +228,13 @@ void ElementInfoWidget::updateUi()
|
|||||||
void ElementInfoWidget::firstActivated() {
|
void ElementInfoWidget::firstActivated() {
|
||||||
m_eipw_list.first() -> setFocusTolineEdit();
|
m_eipw_list.first() -> setFocusTolineEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementInfoWidget::elementInfoChange
|
||||||
|
* This slot is called when m_element::elementInformation change.
|
||||||
|
*/
|
||||||
|
void ElementInfoWidget::elementInfoChange()
|
||||||
|
{
|
||||||
|
if(currentInfo() != m_element->elementInformations())
|
||||||
|
updateUi();
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "abstractelementpropertieseditorwidget.h"
|
#include "abstractelementpropertieseditorwidget.h"
|
||||||
|
#include "diagramcontext.h"
|
||||||
|
|
||||||
class Element;
|
class Element;
|
||||||
class QUndoCommand;
|
class QUndoCommand;
|
||||||
@@ -49,6 +50,8 @@ class ElementInfoWidget : public AbstractElementPropertiesEditorWidget
|
|||||||
QString title() const {return tr("Informations");}
|
QString title() const {return tr("Informations");}
|
||||||
bool setLiveEdit(bool live_edit);
|
bool setLiveEdit(bool live_edit);
|
||||||
virtual void updateUi();
|
virtual void updateUi();
|
||||||
|
DiagramContext currentInfo() const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool event(QEvent *event);
|
virtual bool event(QEvent *event);
|
||||||
@@ -60,6 +63,7 @@ class ElementInfoWidget : public AbstractElementPropertiesEditorWidget
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void firstActivated();
|
void firstActivated();
|
||||||
|
void elementInfoChange();
|
||||||
|
|
||||||
//ATTRIBUTES
|
//ATTRIBUTES
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user