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();
|
QStringList uiList = m_model->stringList();
|
||||||
|
|
||||||
// Remove dummy elements specifically at the end of list.
|
trimAndSetValuesToField(uiList);
|
||||||
|
|
||||||
QStringList result;
|
|
||||||
foreach (const QString &str, uiList)
|
|
||||||
{
|
|
||||||
if (str != "" && str != " ") result += str;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->setValueToField(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -406,7 +398,21 @@ void PdmUiListEditor::pasteFromString(const QString& content)
|
|||||||
{
|
{
|
||||||
QStringList strList = content.split("\n");
|
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();
|
QStringList uiList = m_model->stringList();
|
||||||
|
|
||||||
// Remove dummy elements specifically at the end of list.
|
trimAndSetValuesToField(uiList);
|
||||||
|
|
||||||
QStringList result;
|
|
||||||
foreach (const QString &str, uiList)
|
|
||||||
{
|
|
||||||
if (str != "" && str != " ") result += str;
|
|
||||||
}
|
|
||||||
this->setValueToField(result);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,12 @@
|
|||||||
|
|
||||||
#include "cafPdmUiFieldEditorHandle.h"
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
|
||||||
class QStringListModel;
|
|
||||||
class QItemSelection;
|
class QItemSelection;
|
||||||
class QListViewHeightHint;
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QListViewHeightHint;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
class QStringList;
|
||||||
|
class QStringListModel;
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
@ -93,6 +94,8 @@ protected slots:
|
|||||||
private:
|
private:
|
||||||
QString contentAsString() const;
|
QString contentAsString() const;
|
||||||
void pasteFromString(const QString& content);
|
void pasteFromString(const QString& content);
|
||||||
|
|
||||||
|
void trimAndSetValuesToField(const QStringList& stringList);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QListViewHeightHint> m_listView;
|
QPointer<QListViewHeightHint> m_listView;
|
||||||
|
Loading…
Reference in New Issue
Block a user