mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5100 AppFwk : ListEditor : Use timer locally to trigger scrollTo
This commit is contained in:
parent
f1b57f3920
commit
9d061e2a5a
@ -68,21 +68,6 @@ caf::PdmUiFormLayoutObjectEditor::~PdmUiFormLayoutObjectEditor()
|
||||
CAF_ASSERT(m_fieldViews.size() == 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::PdmUiFormLayoutObjectEditor::slotScrollToSelectedItemsInFieldEditors() const
|
||||
{
|
||||
for (auto fieldView : m_fieldViews)
|
||||
{
|
||||
auto listEditor = dynamic_cast<PdmUiListEditor*>(fieldView.second);
|
||||
if (listEditor)
|
||||
{
|
||||
listEditor->scrollToSelectedItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -66,9 +66,6 @@ public:
|
||||
PdmUiFormLayoutObjectEditor();
|
||||
~PdmUiFormLayoutObjectEditor() override;
|
||||
|
||||
public slots:
|
||||
void slotScrollToSelectedItemsInFieldEditors() const;
|
||||
|
||||
protected:
|
||||
/// When overriding this function, use findOrCreateGroupBox() or findOrCreateFieldEditor() for detailed control
|
||||
/// Use recursivelyConfigureAndUpdateUiItemsInGridLayoutColumn() for automatic layout of group and field widgets
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include <QListView>
|
||||
#include <QListView>
|
||||
#include <QStringListModel>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
|
||||
@ -150,21 +151,6 @@ PdmUiListEditor::~PdmUiListEditor()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiListEditor::scrollToSelectedItem() const
|
||||
{
|
||||
if (m_isScrollToItemAllowed)
|
||||
{
|
||||
QModelIndex mi = m_listView->currentIndex();
|
||||
if (mi.isValid())
|
||||
{
|
||||
m_listView->scrollTo(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -294,7 +280,7 @@ void PdmUiListEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
m_listView->selectionModel()->blockSignals(false);
|
||||
}
|
||||
|
||||
//ensureCurrentItemIsVisible();
|
||||
QTimer::singleShot(150, this, SLOT(slotScrollToSelectedItem()));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -406,6 +392,21 @@ void PdmUiListEditor::slotListItemEdited(const QModelIndex&, const QModelIndex&)
|
||||
trimAndSetValuesToField(uiList);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiListEditor::slotScrollToSelectedItem() const
|
||||
{
|
||||
if (m_isScrollToItemAllowed)
|
||||
{
|
||||
QModelIndex mi = m_listView->currentIndex();
|
||||
if (mi.isValid())
|
||||
{
|
||||
m_listView->scrollTo(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -83,7 +83,6 @@ public:
|
||||
PdmUiListEditor();
|
||||
~PdmUiListEditor() override;
|
||||
|
||||
void scrollToSelectedItem() const;
|
||||
|
||||
protected:
|
||||
QWidget* createEditorWidget(QWidget * parent) override;
|
||||
@ -95,6 +94,7 @@ protected:
|
||||
protected slots:
|
||||
void slotSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
|
||||
void slotListItemEdited(const QModelIndex&, const QModelIndex&);
|
||||
void slotScrollToSelectedItem() const;
|
||||
|
||||
private:
|
||||
QString contentAsString() const;
|
||||
|
@ -192,23 +192,10 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object)
|
||||
|
||||
m_defaultObjectEditor->setPdmObject(object);
|
||||
|
||||
QObject::connect(m_defaultObjectEditor, SIGNAL(uiUpdated()), this, SLOT(slotScheduleScrollToSelectedItemsInFieldEditors()));
|
||||
|
||||
m_defaultObjectEditor->updateUi(m_uiConfigName);
|
||||
m_scrollArea->updateGeometry();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiPropertyView::slotScheduleScrollToSelectedItemsInFieldEditors()
|
||||
{
|
||||
if (m_defaultObjectEditor)
|
||||
{
|
||||
QTimer::singleShot(150, m_defaultObjectEditor, SLOT(slotScrollToSelectedItemsInFieldEditors()));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -85,7 +85,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void showProperties(caf::PdmObjectHandle* object); // Signal/Slot system needs caf:: prefix in some cases
|
||||
void slotScheduleScrollToSelectedItemsInFieldEditors();
|
||||
|
||||
private:
|
||||
PdmUiDefaultObjectEditor* m_defaultObjectEditor;
|
||||
|
Loading…
Reference in New Issue
Block a user