mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
#1883 AppFwk : Move UiFieldEditorHelper to separate file
This commit is contained in:
@@ -42,18 +42,17 @@
|
|||||||
#include "cafPdmProxyValueField.h"
|
#include "cafPdmProxyValueField.h"
|
||||||
#include "cafPdmUiCheckBoxEditor.h"
|
#include "cafPdmUiCheckBoxEditor.h"
|
||||||
#include "cafPdmUiComboBoxEditor.h"
|
#include "cafPdmUiComboBoxEditor.h"
|
||||||
|
#include "cafPdmUiDateEditor.h"
|
||||||
#include "cafPdmUiFieldEditorHandle.h"
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
#include "cafPdmUiFieldEditorHelper.h"
|
||||||
#include "cafPdmUiLineEditor.h"
|
#include "cafPdmUiLineEditor.h"
|
||||||
#include "cafPdmUiListEditor.h"
|
#include "cafPdmUiListEditor.h"
|
||||||
#include "cafPdmUiOrdering.h"
|
#include "cafPdmUiOrdering.h"
|
||||||
#include "cafPdmUiDateEditor.h"
|
|
||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "cafPdmUiDefaultObjectEditor.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ set( PROJECT_FILES
|
|||||||
cafPdmUiTreeSelectionEditor.cpp
|
cafPdmUiTreeSelectionEditor.cpp
|
||||||
cafPdmUiTreeSelectionQModel.h
|
cafPdmUiTreeSelectionQModel.h
|
||||||
cafPdmUiTreeSelectionQModel.cpp
|
cafPdmUiTreeSelectionQModel.cpp
|
||||||
|
cafPdmUiFieldEditorHelper.h
|
||||||
|
cafPdmUiFieldEditorHelper.cpp
|
||||||
|
|
||||||
# object editors
|
# object editors
|
||||||
cafPdmUiDefaultObjectEditor.cpp
|
cafPdmUiDefaultObjectEditor.cpp
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
//
|
//
|
||||||
//##################################################################################################
|
//##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
#include "cafPdmUiDefaultObjectEditor.h"
|
#include "cafPdmUiDefaultObjectEditor.h"
|
||||||
|
|
||||||
#include "cafPdmProxyValueField.h"
|
#include "cafPdmProxyValueField.h"
|
||||||
@@ -215,50 +214,5 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector<P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
caf::PdmUiFieldEditorHandle* PdmUiFieldEditorHelper::fieldEditorForField(PdmUiFieldHandle* field, const QString& uiConfigName)
|
|
||||||
{
|
|
||||||
caf::PdmUiFieldEditorHandle* fieldEditor = NULL;
|
|
||||||
|
|
||||||
// If editor type is specified, find in factory
|
|
||||||
if (!field->uiEditorTypeName(uiConfigName).isEmpty())
|
|
||||||
{
|
|
||||||
fieldEditor = caf::Factory<PdmUiFieldEditorHandle, QString>::instance()->create(field->uiEditorTypeName(uiConfigName));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Find the default field editor
|
|
||||||
QString fieldTypeName = qStringTypeName(*(field->fieldHandle()));
|
|
||||||
|
|
||||||
if (fieldTypeName.indexOf("PdmPtrField") != -1)
|
|
||||||
{
|
|
||||||
fieldTypeName = caf::PdmUiComboBoxEditor::uiEditorTypeName();
|
|
||||||
}
|
|
||||||
else if (fieldTypeName.indexOf("PdmPtrArrayField") != -1)
|
|
||||||
{
|
|
||||||
fieldTypeName = caf::PdmUiListEditor::uiEditorTypeName();
|
|
||||||
}
|
|
||||||
else if (field->toUiBasedQVariant().type() != QVariant::List)
|
|
||||||
{
|
|
||||||
// Handle a single value field with valueOptions: Make a combobox
|
|
||||||
|
|
||||||
bool useOptionsOnly = true;
|
|
||||||
QList<PdmOptionItemInfo> options = field->valueOptions(&useOptionsOnly);
|
|
||||||
CAF_ASSERT(useOptionsOnly); // Not supported
|
|
||||||
|
|
||||||
if (!options.empty())
|
|
||||||
{
|
|
||||||
fieldTypeName = caf::PdmUiComboBoxEditor::uiEditorTypeName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldEditor = caf::Factory<PdmUiFieldEditorHandle, QString>::instance()->create(fieldTypeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fieldEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace caf
|
} // end namespace caf
|
||||||
|
|||||||
@@ -40,24 +40,18 @@
|
|||||||
#include "cafPdmUiWidgetBasedObjectEditor.h"
|
#include "cafPdmUiWidgetBasedObjectEditor.h"
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
class QGridLayout;
|
class QGridLayout;
|
||||||
|
class QString;
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
|
|
||||||
class PdmUiFieldEditorHandle;
|
class PdmUiFieldEditorHandle;
|
||||||
class PdmUiItem;
|
class PdmUiItem;
|
||||||
class PdmUiGroup;
|
class PdmUiGroup;
|
||||||
|
|
||||||
|
|
||||||
class PdmUiFieldEditorHelper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static PdmUiFieldEditorHandle* fieldEditorForField(PdmUiFieldHandle* fieldHandle, const QString& uiConfigName);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// The default editor for PdmObjects. Manages the field editors in a gridlayout vertically
|
/// The default editor for PdmObjects. Manages the field editors in a gridlayout vertically
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2017 Ceetron Solutions AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
#include "cafPdmUiFieldEditorHelper.h"
|
||||||
|
|
||||||
|
#include "cafClassTypeName.h"
|
||||||
|
|
||||||
|
#include "cafPdmUiComboBoxEditor.h"
|
||||||
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
#include "cafPdmUiFieldHandle.h"
|
||||||
|
#include "cafPdmUiListEditor.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
caf::PdmUiFieldEditorHandle* caf::PdmUiFieldEditorHelper::fieldEditorForField(caf::PdmUiFieldHandle* field, const QString& uiConfigName)
|
||||||
|
{
|
||||||
|
caf::PdmUiFieldEditorHandle* fieldEditor = NULL;
|
||||||
|
|
||||||
|
// If editor type is specified, find in factory
|
||||||
|
if (!field->uiEditorTypeName(uiConfigName).isEmpty())
|
||||||
|
{
|
||||||
|
fieldEditor = caf::Factory<PdmUiFieldEditorHandle, QString>::instance()->create(field->uiEditorTypeName(uiConfigName));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Find the default field editor
|
||||||
|
QString fieldTypeName = qStringTypeName(*(field->fieldHandle()));
|
||||||
|
|
||||||
|
if (fieldTypeName.indexOf("PdmPtrField") != -1)
|
||||||
|
{
|
||||||
|
fieldTypeName = caf::PdmUiComboBoxEditor::uiEditorTypeName();
|
||||||
|
}
|
||||||
|
else if (fieldTypeName.indexOf("PdmPtrArrayField") != -1)
|
||||||
|
{
|
||||||
|
fieldTypeName = caf::PdmUiListEditor::uiEditorTypeName();
|
||||||
|
}
|
||||||
|
else if (field->toUiBasedQVariant().type() != QVariant::List)
|
||||||
|
{
|
||||||
|
// Handle a single value field with valueOptions: Make a combobox
|
||||||
|
|
||||||
|
bool useOptionsOnly = true;
|
||||||
|
QList<PdmOptionItemInfo> options = field->valueOptions(&useOptionsOnly);
|
||||||
|
CAF_ASSERT(useOptionsOnly); // Not supported
|
||||||
|
|
||||||
|
if (!options.empty())
|
||||||
|
{
|
||||||
|
fieldTypeName = caf::PdmUiComboBoxEditor::uiEditorTypeName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldEditor = caf::Factory<PdmUiFieldEditorHandle, QString>::instance()->create(fieldTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fieldEditor;
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2017 Ceetron Solutions AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class QString;
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
class PdmUiFieldEditorHandle;
|
||||||
|
class PdmUiFieldHandle;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class PdmUiFieldEditorHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static PdmUiFieldEditorHandle* fieldEditorForField(PdmUiFieldHandle* fieldHandle, const QString& uiConfigName);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // end namespace caf
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
#include "cafPdmObject.h"
|
#include "cafPdmObject.h"
|
||||||
#include "cafPdmUiComboBoxEditor.h"
|
#include "cafPdmUiComboBoxEditor.h"
|
||||||
#include "cafPdmUiCommandSystemProxy.h"
|
#include "cafPdmUiCommandSystemProxy.h"
|
||||||
#include "cafPdmUiDefaultObjectEditor.h"
|
#include "cafPdmUiFieldEditorHelper.h"
|
||||||
#include "cafPdmUiLineEditor.h"
|
#include "cafPdmUiLineEditor.h"
|
||||||
#include "cafPdmUiTableItemEditor.h"
|
#include "cafPdmUiTableItemEditor.h"
|
||||||
#include "cafSelectionManager.h"
|
#include "cafSelectionManager.h"
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
#include "cafPdmObjectHandle.h"
|
#include "cafPdmObjectHandle.h"
|
||||||
#include "cafPdmUiFieldEditorHandle.h"
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
#include "cafPdmUiFieldEditorHelper.h"
|
||||||
|
#include "cafPdmUiFieldHandle.h"
|
||||||
#include "cafPdmUiObjectHandle.h"
|
#include "cafPdmUiObjectHandle.h"
|
||||||
#include "cafPdmUiOrdering.h"
|
#include "cafPdmUiOrdering.h"
|
||||||
#include "cafPdmXmlObjectHandle.h"
|
#include "cafPdmXmlObjectHandle.h"
|
||||||
@@ -47,8 +49,6 @@
|
|||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include "cafPdmUiFieldHandle.h"
|
|
||||||
#include "cafPdmUiDefaultObjectEditor.h"
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user