mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-21 22:13:25 -06:00
#1867 AppFwk : Add PdmUiFieldEditorHandle::updateLabelFromField
This commit is contained in:
parent
72a1a69547
commit
2f22f82ba1
@ -79,7 +79,8 @@ protected: // Interface to override:
|
|||||||
protected:
|
protected:
|
||||||
/// This needs to be called from subclass when connecting to a PdmField or Object
|
/// This needs to be called from subclass when connecting to a PdmField or Object
|
||||||
void bindToPdmItem(PdmUiItem* item);
|
void bindToPdmItem(PdmUiItem* item);
|
||||||
PdmUiItem* pdmItem() { return m_pdmItem; }
|
PdmUiItem* pdmItem() { return m_pdmItem; }
|
||||||
|
const PdmUiItem* pdmItem() const { return m_pdmItem; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend PdmUiItem::~PdmUiItem();
|
friend PdmUiItem::~PdmUiItem();
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "cafPdmUiFieldHandle.h"
|
#include "cafPdmUiFieldHandle.h"
|
||||||
#include "cafPdmUiCommandSystemProxy.h"
|
#include "cafPdmUiCommandSystemProxy.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
@ -100,6 +101,31 @@ void PdmUiFieldEditorHandle::setValueToField(const QVariant& newUiValue)
|
|||||||
PdmUiCommandSystemProxy::instance()->setUiValueToField(field(), newUiValue);
|
PdmUiCommandSystemProxy::instance()->setUiValueToField(field(), newUiValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiFieldEditorHandle::updateLabelFromField(QLabel* label, const QString& uiConfigName) const
|
||||||
|
{
|
||||||
|
CAF_ASSERT(label);
|
||||||
|
|
||||||
|
const PdmUiFieldHandle* fieldHandle = dynamic_cast<const PdmUiFieldHandle*>(pdmItem());
|
||||||
|
if (fieldHandle)
|
||||||
|
{
|
||||||
|
QIcon ic = fieldHandle->uiIcon(uiConfigName);
|
||||||
|
if (!ic.isNull())
|
||||||
|
{
|
||||||
|
label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString uiName = fieldHandle->uiName(uiConfigName);
|
||||||
|
label->setText(uiName);
|
||||||
|
}
|
||||||
|
|
||||||
|
label->setEnabled(!fieldHandle->isUiReadOnly(uiConfigName));
|
||||||
|
label->setToolTip(fieldHandle->uiToolTip(uiConfigName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} //End of namespace caf
|
} //End of namespace caf
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
|
|
||||||
// Taken from gtest.h
|
// Taken from gtest.h
|
||||||
//
|
//
|
||||||
@ -118,6 +120,8 @@ protected: // Virtual interface to override
|
|||||||
|
|
||||||
void setValueToField(const QVariant& value);
|
void setValueToField(const QVariant& value);
|
||||||
|
|
||||||
|
void updateLabelFromField(QLabel* label, const QString& uiConfigName = "") const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QWidget> m_combinedWidget;
|
QPointer<QWidget> m_combinedWidget;
|
||||||
QPointer<QWidget> m_editorWidget;
|
QPointer<QWidget> m_editorWidget;
|
||||||
|
@ -263,7 +263,7 @@ bool PdmUiItem::isUiTreeChildrenHidden(QString uiConfigName) const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool PdmUiItem::isUiReadOnly(QString uiConfigName /*= ""*/)
|
bool PdmUiItem::isUiReadOnly(QString uiConfigName /*= ""*/) const
|
||||||
{
|
{
|
||||||
const PdmUiItemInfo* conInfo = configInfo(uiConfigName);
|
const PdmUiItemInfo* conInfo = configInfo(uiConfigName);
|
||||||
const PdmUiItemInfo* defInfo = defaultInfo();
|
const PdmUiItemInfo* defInfo = defaultInfo();
|
||||||
|
@ -217,7 +217,7 @@ public:
|
|||||||
bool isUiTreeChildrenHidden(QString uiConfigName = "") const;
|
bool isUiTreeChildrenHidden(QString uiConfigName = "") const;
|
||||||
void setUiTreeChildrenHidden(bool isTreeChildrenHidden, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isTreeChildrenHidden = isTreeChildrenHidden; }
|
void setUiTreeChildrenHidden(bool isTreeChildrenHidden, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isTreeChildrenHidden = isTreeChildrenHidden; }
|
||||||
|
|
||||||
bool isUiReadOnly(QString uiConfigName = "");
|
bool isUiReadOnly(QString uiConfigName = "") const;
|
||||||
void setUiReadOnly(bool isReadOnly, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isReadOnly = isReadOnly; }
|
void setUiReadOnly(bool isReadOnly, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isReadOnly = isReadOnly; }
|
||||||
|
|
||||||
PdmUiItemInfo::LabelPosType
|
PdmUiItemInfo::LabelPosType
|
||||||
|
Loading…
Reference in New Issue
Block a user