mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-21 22:13:25 -06:00
#2361 AppFwk : cafPdmuiListEditor : Refactor setting of strings to field
This commit is contained in:
parent
3786adc9b7
commit
90f9b63b44
@ -371,15 +371,7 @@ void PdmUiListEditor::slotListItemEdited(const QModelIndex&, const QModelIndex&)
|
||||
|
||||
QStringList uiList = m_model->stringList();
|
||||
|
||||
// Remove dummy elements specifically at the end of list.
|
||||
|
||||
QStringList result;
|
||||
foreach (const QString &str, uiList)
|
||||
{
|
||||
if (str != "" && str != " ") result += str;
|
||||
}
|
||||
|
||||
this->setValueToField(result);
|
||||
trimAndSetValuesToField(uiList);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -406,7 +398,21 @@ void PdmUiListEditor::pasteFromString(const QString& content)
|
||||
{
|
||||
QStringList strList = content.split("\n");
|
||||
|
||||
this->setValueToField(strList);
|
||||
trimAndSetValuesToField(strList);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiListEditor::trimAndSetValuesToField(const QStringList& stringList)
|
||||
{
|
||||
QStringList result;
|
||||
for (const auto& str : stringList)
|
||||
{
|
||||
if (str != "" && str != " ") result += str;
|
||||
}
|
||||
|
||||
this->setValueToField(result);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -458,14 +464,7 @@ bool PdmUiListEditor::eventFilter(QObject* object, QEvent * event)
|
||||
{
|
||||
QStringList uiList = m_model->stringList();
|
||||
|
||||
// Remove dummy elements specifically at the end of list.
|
||||
|
||||
QStringList result;
|
||||
foreach (const QString &str, uiList)
|
||||
{
|
||||
if (str != "" && str != " ") result += str;
|
||||
}
|
||||
this->setValueToField(result);
|
||||
trimAndSetValuesToField(uiList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -39,11 +39,12 @@
|
||||
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
|
||||
class QStringListModel;
|
||||
class QItemSelection;
|
||||
class QListViewHeightHint;
|
||||
class QLabel;
|
||||
class QListViewHeightHint;
|
||||
class QModelIndex;
|
||||
class QStringList;
|
||||
class QStringListModel;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -94,6 +95,8 @@ private:
|
||||
QString contentAsString() const;
|
||||
void pasteFromString(const QString& content);
|
||||
|
||||
void trimAndSetValuesToField(const QStringList& stringList);
|
||||
|
||||
private:
|
||||
QPointer<QListViewHeightHint> m_listView;
|
||||
QPointer<QLabel> m_label;
|
||||
|
Loading…
Reference in New Issue
Block a user