mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1365 AppFwk : Allow list widgets to fill available height
This commit is contained in:
@@ -85,6 +85,45 @@ private:
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
/// Helper class used to control height of size hint
|
||||
//==================================================================================================
|
||||
class QListViewHeightHint : public QListView
|
||||
{
|
||||
public:
|
||||
explicit QListViewHeightHint(QWidget *parent = 0)
|
||||
: m_heightHint(-1)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
virtual QSize sizeHint() const override
|
||||
{
|
||||
QSize mySize = QListView::sizeHint();
|
||||
|
||||
if (m_heightHint > 0)
|
||||
{
|
||||
mySize.setHeight(m_heightHint);
|
||||
}
|
||||
|
||||
return mySize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void setHeightHint(int heightHint)
|
||||
{
|
||||
m_heightHint = heightHint;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_heightHint;
|
||||
};
|
||||
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@@ -151,6 +190,7 @@ void PdmUiListEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
myPalette.setColor(QPalette::Base, attributes.m_baseColor);
|
||||
|
||||
m_listView->setPalette(myPalette);
|
||||
m_listView->setHeightHint(attributes.m_heightHint);
|
||||
}
|
||||
|
||||
MyStringListModel* strListModel = dynamic_cast<MyStringListModel*>(m_model.data());
|
||||
@@ -230,13 +270,12 @@ void PdmUiListEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiListEditor::createEditorWidget(QWidget * parent)
|
||||
{
|
||||
m_listView = new QListView(parent);
|
||||
m_listView = new QListViewHeightHint(parent);
|
||||
|
||||
m_model = new MyStringListModel(m_listView);
|
||||
m_listView->setModel(m_model);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
class QGridLayout;
|
||||
class QStringListModel;
|
||||
class QItemSelection;
|
||||
class QListView;
|
||||
class QListViewHeightHint;
|
||||
class QLabel;
|
||||
class QModelIndex;
|
||||
|
||||
@@ -56,7 +56,7 @@ class PdmUiListEditorAttribute : public PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
PdmUiListEditorAttribute()
|
||||
: m_baseColor(Qt::white)
|
||||
: m_heightHint(2000)
|
||||
{
|
||||
QPalette myPalette;
|
||||
|
||||
@@ -64,7 +64,8 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
QColor m_baseColor;
|
||||
QColor m_baseColor;
|
||||
int m_heightHint;
|
||||
};
|
||||
|
||||
|
||||
@@ -95,15 +96,12 @@ private:
|
||||
void pasteFromString(const QString& content);
|
||||
|
||||
private:
|
||||
QPointer<QListView> m_listView;
|
||||
QPointer<QListViewHeightHint> m_listView;
|
||||
QPointer<QLabel> m_label;
|
||||
QPointer<QStringListModel> m_model;
|
||||
|
||||
QList<PdmOptionItemInfo> m_options;
|
||||
bool m_optionsOnly;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user