mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Remove padding to the left in TreeSelectionEditor if the tree doesn't have grand children.
This commit is contained in:
@@ -76,6 +76,18 @@ public:
|
||||
return m_childItems.value(row);
|
||||
}
|
||||
|
||||
bool hasGrandChildren() const
|
||||
{
|
||||
for (auto child : m_childItems)
|
||||
{
|
||||
if (child->childCount() != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int childCount() const
|
||||
{
|
||||
return m_childItems.count();
|
||||
|
||||
@@ -332,6 +332,8 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the tree doesn't have grand children we treat this as a straight list
|
||||
m_treeView->setRootIsDecorated(m_model->hasGrandChildren());
|
||||
|
||||
m_model->resetUiValueCache();
|
||||
}
|
||||
|
||||
@@ -218,6 +218,14 @@ bool caf::PdmUiTreeSelectionQModel::isChecked(const QModelIndex& index) const
|
||||
return data(index, Qt::CheckStateRole).toBool();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Checks if this is a real tree with grand children or just a list of children.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::PdmUiTreeSelectionQModel::hasGrandChildren() const
|
||||
{
|
||||
return m_tree && m_tree->hasGrandChildren();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
bool isReadOnly(const QModelIndex& index) const;
|
||||
bool isChecked(const QModelIndex& index) const;
|
||||
|
||||
bool hasGrandChildren() const;
|
||||
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
@@ -83,8 +85,8 @@ public:
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
|
||||
// Consider moving these functions to PdmUiFieldHandle
|
||||
static bool isSingleValueField(const QVariant& fieldValue);
|
||||
static bool isMultipleValueField(const QVariant& fieldValue);
|
||||
static bool isSingleValueField(const QVariant& fieldValue);
|
||||
static bool isMultipleValueField(const QVariant& fieldValue);
|
||||
|
||||
private:
|
||||
typedef caf::UiTreeItem<int> TreeItemType;
|
||||
|
||||
Reference in New Issue
Block a user