mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3037 AppFwk : Implement and use createLabelWidget()
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
||||
namespace caf
|
||||
@@ -53,7 +53,7 @@ namespace caf
|
||||
PdmUiTableView::PdmUiTableView(QWidget* parent, Qt::WindowFlags f)
|
||||
: QWidget (parent, f)
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
|
||||
@@ -61,8 +61,15 @@ PdmUiTableView::PdmUiTableView(QWidget* parent, Qt::WindowFlags f)
|
||||
|
||||
m_listViewEditor = new PdmUiTableViewEditor();
|
||||
|
||||
{
|
||||
QWidget* widget = m_listViewEditor->createLabelWidget(this);
|
||||
layout->addWidget(widget);
|
||||
}
|
||||
|
||||
{
|
||||
QWidget* widget = m_listViewEditor->createEditorWidget(this);
|
||||
layout->addWidget(widget);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -143,19 +143,36 @@ QWidget* PdmUiTableViewEditor::createEditorWidget(QWidget* parent)
|
||||
|
||||
updateContextMenuSignals();
|
||||
|
||||
m_layout->addWidget(m_tableView);
|
||||
|
||||
return m_mainWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiTableViewEditor::createLabelWidget(QWidget * parent)
|
||||
{
|
||||
if (m_tableHeading.isNull())
|
||||
{
|
||||
m_tableHeading = new QLabel(parent);
|
||||
}
|
||||
|
||||
if (m_tableHeadingIcon.isNull())
|
||||
{
|
||||
m_tableHeadingIcon = new QLabel(parent);
|
||||
}
|
||||
|
||||
QHBoxLayout* layoutForIconLabel = new QHBoxLayout();
|
||||
m_tableHeading = new QLabel(m_mainWidget);
|
||||
m_tableHeadingIcon = new QLabel(m_mainWidget);
|
||||
layoutForIconLabel->addWidget(m_tableHeadingIcon);
|
||||
layoutForIconLabel->addSpacing(5);
|
||||
layoutForIconLabel->addWidget(m_tableHeading);
|
||||
layoutForIconLabel->addStretch();
|
||||
|
||||
m_layout->addItem(layoutForIconLabel);
|
||||
QWidget* widget = new QWidget(parent);
|
||||
widget->setLayout(layoutForIconLabel);
|
||||
|
||||
m_layout->addWidget(m_tableView);
|
||||
|
||||
return m_mainWidget;
|
||||
return widget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -81,6 +81,7 @@ public:
|
||||
PdmObjectHandle* pdmObjectFromModelIndex(const QModelIndex& mi);
|
||||
|
||||
QWidget* createEditorWidget(QWidget * parent) override;
|
||||
QWidget* createLabelWidget(QWidget * parent) override;
|
||||
|
||||
QTableView* tableView();
|
||||
|
||||
@@ -110,8 +111,9 @@ private:
|
||||
|
||||
QPointer<QWidget> m_mainWidget;
|
||||
QLayout* m_layout;
|
||||
QLabel* m_tableHeading;
|
||||
QLabel* m_tableHeadingIcon;
|
||||
|
||||
QPointer<QLabel> m_tableHeading;
|
||||
QPointer<QLabel> m_tableHeadingIcon;
|
||||
|
||||
QTableView* m_tableView;
|
||||
PdmUiTableViewQModel* m_tableModelPdm;
|
||||
|
||||
Reference in New Issue
Block a user