#1867 AppFwk : Use updateLabelFromField from field editors

This commit is contained in:
Magne Sjaastad 2017-09-07 09:08:11 +02:00
parent 2f22f82ba1
commit a0a28fee36
13 changed files with 20 additions and 167 deletions

View File

@ -72,22 +72,14 @@ void PdmUiCheckBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
if (attributes.m_useNativeCheckBoxLabel)
{
m_checkBox->setText(field()->uiName(uiConfigName));
}
else
{
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
}
else
{
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
}
m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_checkBox->setToolTip(field()->uiToolTip(uiConfigName));

View File

@ -28,20 +28,7 @@ void PdmUiCheckBoxTristateEditor::configureAndUpdateUi(const QString& uiConfigNa
CAF_ASSERT(!m_checkBox.isNull());
CAF_ASSERT(!m_label.isNull());
{
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_checkBox->setToolTip(field()->uiToolTip(uiConfigName));

View File

@ -46,12 +46,12 @@
#include "cafFactory.h"
#include <QLineEdit>
#include <QLabel>
#include <QColor>
#include <QHBoxLayout>
#include <QToolButton>
#include <QColorDialog>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QToolButton>
namespace caf
@ -67,7 +67,6 @@ PdmUiColorEditor::PdmUiColorEditor()
m_color = QColor::Invalid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -75,17 +74,7 @@ void PdmUiColorEditor::configureAndUpdateUi(const QString& uiConfigName)
{
CAF_ASSERT(!m_label.isNull());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
caf::PdmUiObjectHandle* uiObject = uiObj(field()->fieldHandle()->ownerObject());
if (uiObject)
@ -97,7 +86,6 @@ void PdmUiColorEditor::configureAndUpdateUi(const QString& uiConfigName)
setColor(col);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -135,7 +123,6 @@ QWidget* PdmUiColorEditor::createLabelWidget(QWidget * parent)
return m_label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -154,7 +141,6 @@ void PdmUiColorEditor::colorSelectionClicked()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -60,16 +60,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
{
if (!m_label.isNull())
{
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
}
if (!m_comboBox.isNull())

View File

@ -71,17 +71,7 @@ void PdmUiDateEditor::configureAndUpdateUi(const QString& uiConfigName)
{
CAF_ASSERT(!m_dateEdit.isNull());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
m_dateEdit->setEnabled(!field()->isUiReadOnly(uiConfigName));

View File

@ -95,17 +95,7 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
{
CAF_ASSERT(!m_lineEdit.isNull());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_slider->setEnabled(!field()->isUiReadOnly(uiConfigName));

View File

@ -69,18 +69,7 @@ void PdmUiFilePathEditor::configureAndUpdateUi(const QString& uiConfigName)
CAF_ASSERT(!m_lineEdit.isNull());
CAF_ASSERT(!m_label.isNull());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_lineEdit->setToolTip(field()->uiToolTip(uiConfigName));

View File

@ -161,20 +161,8 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName)
{
if (!m_label.isNull())
{
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
}
if (!m_lineEdit.isNull())
{

View File

@ -162,19 +162,7 @@ void PdmUiListEditor::configureAndUpdateUi(const QString& uiConfigName)
CAF_ASSERT(!m_label.isNull());
CAF_ASSERT(m_listView->selectionModel());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
QString uiName = field()->uiName(uiConfigName);
m_label->setText(uiName);
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
m_listView->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_listView->setToolTip(field()->uiToolTip(uiConfigName));

View File

@ -62,22 +62,11 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName)
CAF_ASSERT(!m_pushButton.isNull());
CAF_ASSERT(!m_label.isNull());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
m_pushButton->setCheckable(true);
//m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_pushButton->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_pushButton->setToolTip(field()->uiToolTip(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
PdmUiPushButtonEditorAttribute attributes;
caf::PdmUiObjectHandle* uiObject = uiObj(field()->fieldHandle()->ownerObject());
@ -115,7 +104,6 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -140,14 +128,12 @@ QWidget* PdmUiPushButtonEditor::createLabelWidget(QWidget * parent)
//--------------------------------------------------------------------------------------------------
void PdmUiPushButtonEditor::slotClicked(bool checked)
{
if (field() && dynamic_cast<PdmField<bool> *> (field()->fieldHandle()))
{
QVariant v;
v = checked;
this->setValueToField(v);
}
}

View File

@ -63,18 +63,7 @@ void PdmUiSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
{
CAF_ASSERT(!m_spinBox.isNull());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
m_spinBox->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_spinBox->setToolTip(field()->uiToolTip(uiConfigName));

View File

@ -84,18 +84,7 @@ void PdmUiTextEditor::configureAndUpdateUi(const QString& uiConfigName)
CAF_ASSERT(!m_textEdit.isNull());
CAF_ASSERT(!m_label.isNull());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
m_label->setText(field()->uiName(uiConfigName));
}
//m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
m_textEdit->setReadOnly(field()->isUiReadOnly(uiConfigName));
//m_textEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); // Neccesary ?

View File

@ -77,19 +77,7 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
// Label
CAF_ASSERT(!m_label.isNull());
QIcon ic = field()->uiIcon(uiConfigName);
if (!ic.isNull())
{
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
}
else
{
QString uiName = field()->uiName(uiConfigName);
m_label->setText(uiName);
}
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
m_label->setToolTip(field()->uiToolTip(uiConfigName));
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
// Tree view