Start to revamp the code about formula and label of elements and conductors

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4791 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-11-24 16:45:55 +00:00
parent 543c7b6b3e
commit 60c7b9302e
11 changed files with 174 additions and 71 deletions

View File

@@ -75,7 +75,20 @@ void ElementInfoWidget::setElement(Element *element)
void ElementInfoWidget::apply()
{
if (QUndoCommand *undo = associatedUndo())
{
m_element -> diagram() -> undoStack().push(undo);
ElementInfoPartWidget *f = infoPartWidgetForKey("formula");
ElementInfoPartWidget *l = infoPartWidgetForKey("label");
if (f && l)
{
if (f->text().isEmpty())
l->setEnabled(true);
else
l->setDisabled(true);
}
}
}
/**
@@ -176,6 +189,22 @@ void ElementInfoWidget::buildInterface()
ui->scroll_vlayout->addStretch();
}
/**
* @brief ElementInfoWidget::infoPartWidgetForKey
* @param key
* @return the ElementInfoPartWidget with key @key, if not found return nullptr;
*/
ElementInfoPartWidget *ElementInfoWidget::infoPartWidgetForKey(const QString &key) const
{
foreach (ElementInfoPartWidget *eipw, m_eipw_list)
{
if (eipw->key() == key)
return eipw;
}
return nullptr;
}
/**
* @brief ElementInfoWidget::updateUi
* fill information fetch in m_element_info to the
@@ -203,6 +232,17 @@ void ElementInfoWidget::updateUi()
eipw->setHideShow(true);
}
ElementInfoPartWidget *f = infoPartWidgetForKey("formula");
ElementInfoPartWidget *l = infoPartWidgetForKey("label");
if (f && l)
{
if (f->text().isEmpty())
l->setEnabled(true);
else
l->setDisabled(true);
}
if (m_live_edit) enableLiveEdit();
}