mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +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)
|
||||
disconnect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::updateUi);
|
||||
disconnect(m_element, &Element::elementInfoChange, this, &ElementInfoWidget::elementInfoChange);
|
||||
|
||||
m_element = element;
|
||||
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
|
||||
{
|
||||
DiagramContext new_info;
|
||||
DiagramContext new_info = currentInfo();
|
||||
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)
|
||||
return (new ChangeElementInformationCommand(m_element, old_info, new_info));
|
||||
|
||||
@@ -214,6 +205,21 @@ void ElementInfoWidget::updateUi()
|
||||
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
|
||||
* Slot activated when this widget is show.
|
||||
@@ -222,3 +228,13 @@ void ElementInfoWidget::updateUi()
|
||||
void ElementInfoWidget::firstActivated() {
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user