mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3353 AppFwk: TableViewEditor: Support pr cell tooltip.
Use ForegroundRole text color for highlighted cells also. Use PdmUiItem::uiContentTextColor as ForegroundRoleText
This commit is contained in:
parent
10b031fa6d
commit
e55fc4990d
@ -112,6 +112,22 @@ bool PdmUiTableViewDelegate::isEditorOpen() const
|
||||
return m_activeEditorCount > 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTableViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QStyleOptionViewItemV4 viewItemOption(option);
|
||||
|
||||
QVariant fgText = index.data(Qt::ForegroundRole);
|
||||
|
||||
if (fgText.canConvert<QColor>()){
|
||||
viewItemOption.palette.setColor(QPalette::Active, QPalette::HighlightedText, qvariant_cast<QColor>(fgText));
|
||||
viewItemOption.palette.setColor(QPalette::Inactive, QPalette::HighlightedText, qvariant_cast<QColor>(fgText));
|
||||
}
|
||||
|
||||
this->QStyledItemDelegate::paint(painter, viewItemOption, index);
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
|
@ -63,9 +63,12 @@ public:
|
||||
|
||||
bool isEditorOpen() const;
|
||||
|
||||
protected slots:
|
||||
protected slots:
|
||||
void slotEditorDestroyed(QObject* obj);
|
||||
|
||||
protected:
|
||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
PdmUiTableViewQModel* m_model;
|
||||
|
||||
|
@ -173,14 +173,27 @@ bool PdmUiTableViewQModel::setData(const QModelIndex &index, const QVariant &val
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QVariant PdmUiTableViewQModel::data(const QModelIndex &index, int role /*= Qt::DisplayRole */) const
|
||||
{
|
||||
if (role == Qt::TextColorRole)
|
||||
if (role == Qt::ForegroundRole)
|
||||
{
|
||||
PdmFieldHandle* fieldHandle = getField(index);
|
||||
if (fieldHandle && fieldHandle->uiCapability())
|
||||
{
|
||||
QColor textColor = fieldHandle->uiCapability()->uiContentTextColor(m_currentConfigName);
|
||||
|
||||
if (fieldHandle->uiCapability()->isUiReadOnly(m_currentConfigName))
|
||||
{
|
||||
return Qt::lightGray;
|
||||
if (textColor.isValid())
|
||||
{
|
||||
return textColor.lighter(150);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Qt::lightGray;
|
||||
}
|
||||
}
|
||||
else if (textColor.isValid())
|
||||
{
|
||||
return textColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -317,7 +330,18 @@ QVariant PdmUiTableViewQModel::data(const QModelIndex &index, int role /*= Qt::D
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if ( role == Qt::ToolTipRole )
|
||||
{
|
||||
PdmUiFieldHandle* uiFieldHandle = getField(index)->uiCapability();
|
||||
if ( uiFieldHandle )
|
||||
{
|
||||
return uiFieldHandle->uiToolTip();
|
||||
}
|
||||
else
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user