mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1830 AppFwk : Add heading concept
This commit is contained in:
parent
71db603e11
commit
aef886a26e
@ -67,6 +67,16 @@ PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText, caf::PdmObje
|
||||
m_value = QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(obj));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmOptionItemInfo PdmOptionItemInfo::createHeader(const QString& anOptionUiText, bool anIsDimmed /*= false*/, QIcon anIcon /*= QIcon()*/)
|
||||
{
|
||||
PdmOptionItemInfo header(anOptionUiText, QVariant(), anIsDimmed, anIcon);
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -99,6 +109,14 @@ bool PdmOptionItemInfo::isDimmed() const
|
||||
return m_isDimmed;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool PdmOptionItemInfo::isHeading() const
|
||||
{
|
||||
return !m_value.isValid();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -89,11 +89,14 @@ public:
|
||||
PdmOptionItemInfo(const QString& anOptionUiText, const QVariant& aValue, bool anIsDimmed = false, QIcon anIcon = QIcon());
|
||||
PdmOptionItemInfo(const QString& anOptionUiText, caf::PdmObjectHandle* obj, bool anIsDimmed = false, QIcon anIcon = QIcon());
|
||||
|
||||
static PdmOptionItemInfo createHeader(const QString& anOptionUiText, bool anIsDimmed = false, QIcon anIcon = QIcon());
|
||||
|
||||
void setLevel(int level);
|
||||
|
||||
const QString optionUiText() const;
|
||||
const QVariant value() const;
|
||||
bool isDimmed() const;
|
||||
bool isHeading() const;
|
||||
const QIcon icon() const;
|
||||
int level() const;
|
||||
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
m_proxyDoubleField = 0;
|
||||
if (!(m_proxyDoubleField == 3)) { std::cout << "Double is not 3 " << std::endl; }
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_multiSelectList, "SelectedItems", " ", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_multiSelectList, "SelectedItems", "Multi Select Field", "", "", "");
|
||||
m_multiSelectList.xmlCapability()->setIOReadable(false);
|
||||
m_multiSelectList.xmlCapability()->setIOWritable(false);
|
||||
m_multiSelectList.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
||||
@ -122,8 +122,7 @@ public:
|
||||
options.push_back(caf::PdmOptionItemInfo(text, text));
|
||||
|
||||
text = "Second";
|
||||
options.push_back(caf::PdmOptionItemInfo(text, text));
|
||||
|
||||
options.push_back(caf::PdmOptionItemInfo::createHeader(text));
|
||||
|
||||
{
|
||||
text = "Second_a";
|
||||
@ -139,6 +138,7 @@ public:
|
||||
options.push_back(itemInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
static int s_additionalSubItems = 0;
|
||||
s_additionalSubItems++;
|
||||
for (auto i = 0; i < s_additionalSubItems; i++)
|
||||
@ -148,6 +148,7 @@ public:
|
||||
itemInfo.setLevel(1);
|
||||
options.push_back(itemInfo);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
int additionalSubItems = 0;
|
||||
|
@ -80,7 +80,17 @@ void caf::PdmUiTreeSelectionQModel::setOptions(caf::PdmUiFieldEditorHandle* fiel
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Qt::ItemFlags caf::PdmUiTreeSelectionQModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable;
|
||||
if (index.isValid())
|
||||
{
|
||||
int optionItemIndex = toOptionItemIndex(index);
|
||||
|
||||
if (!m_options[optionItemIndex].isHeading())
|
||||
{
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable;
|
||||
}
|
||||
}
|
||||
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -148,11 +158,13 @@ QVariant caf::PdmUiTreeSelectionQModel::data(const QModelIndex &index, int role
|
||||
{
|
||||
CAF_ASSERT(index.internalId() < m_options.size());
|
||||
|
||||
int optionItemIndex = toOptionItemIndex(index);
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return m_options[toOptionItemIndex(index)].optionUiText();
|
||||
return m_options[optionItemIndex].optionUiText();
|
||||
}
|
||||
else if (role == Qt::CheckStateRole)
|
||||
else if (role == Qt::CheckStateRole && !m_options[optionItemIndex].isHeading())
|
||||
{
|
||||
CAF_ASSERT(m_uiFieldHandle);
|
||||
|
||||
@ -162,7 +174,7 @@ QVariant caf::PdmUiTreeSelectionQModel::data(const QModelIndex &index, int role
|
||||
for (QVariant v : valuesSelectedInField)
|
||||
{
|
||||
int indexInField = v.toInt();
|
||||
if (indexInField == toOptionItemIndex(index))
|
||||
if (indexInField == optionItemIndex)
|
||||
{
|
||||
return Qt::Checked;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user