mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-24 05:49:59 +01:00
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:
@@ -99,3 +99,23 @@ void ElementInfoPartWidget::setHideShow(const bool &hide) {
|
||||
void ElementInfoPartWidget::setFocusTolineEdit() {
|
||||
ui->line_edit->setFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementInfoPartWidget::setEnabled
|
||||
* enable the line edit
|
||||
* @param e
|
||||
*/
|
||||
void ElementInfoPartWidget::setEnabled(bool e)
|
||||
{
|
||||
ui->line_edit->setEnabled(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementInfoPartWidget::setDisabled
|
||||
* disable the line edit
|
||||
* @param d
|
||||
*/
|
||||
void ElementInfoPartWidget::setDisabled(bool d)
|
||||
{
|
||||
ui->line_edit->setDisabled(d);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ class ElementInfoPartWidget : public QWidget
|
||||
void setShow (const bool &);
|
||||
void setHideShow (const bool &);
|
||||
void setFocusTolineEdit();
|
||||
void setEnabled(bool e);
|
||||
void setDisabled(bool d);
|
||||
|
||||
signals:
|
||||
void textEdited (const QString & text);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ class ElementInfoWidget : public AbstractElementPropertiesEditorWidget
|
||||
|
||||
private:
|
||||
void buildInterface();
|
||||
ElementInfoPartWidget *infoPartWidgetForKey(const QString &key) const;
|
||||
|
||||
private slots:
|
||||
void firstActivated();
|
||||
|
||||
Reference in New Issue
Block a user