mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
caf: Use caf::Factory macro for factory registration in field editors. Removed obsolete code
This commit is contained in:
@@ -58,8 +58,13 @@
|
|||||||
|
|
||||||
#define CAF_UNIQUE_COMPILE_UNIT_VAR_NAME(foo) CAF_FACTORY_CONCATENATE_STRINGS(foo, __LINE__)
|
#define CAF_UNIQUE_COMPILE_UNIT_VAR_NAME(foo) CAF_FACTORY_CONCATENATE_STRINGS(foo, __LINE__)
|
||||||
|
|
||||||
|
/// Macros to simplify registering entries in a factory
|
||||||
|
/// There are two, to make it possible to use two registrations in one macro
|
||||||
|
|
||||||
#define CAF_FACTORY_REGISTER(BaseType, TypeToCreate, KeyType, key) \
|
#define CAF_FACTORY_REGISTER(BaseType, TypeToCreate, KeyType, key) \
|
||||||
static bool CAF_UNIQUE_COMPILE_UNIT_VAR_NAME(my##TypeToCreate) = caf::Factory<BaseType, KeyType>::instance()->registerCreator<TypeToCreate>(key)
|
static bool CAF_UNIQUE_COMPILE_UNIT_VAR_NAME(my##TypeToCreate) = caf::Factory<BaseType, KeyType>::instance()->registerCreator<TypeToCreate>(key)
|
||||||
|
#define CAF_FACTORY_REGISTER2(BaseType, TypeToCreate, KeyType, key) \
|
||||||
|
static bool CAF_UNIQUE_COMPILE_UNIT_VAR_NAME(my2##TypeToCreate) = caf::Factory<BaseType, KeyType>::instance()->registerCreator<TypeToCreate>(key)
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,8 +33,6 @@
|
|||||||
// for more details.
|
// for more details.
|
||||||
//
|
//
|
||||||
//##################################################################################################
|
//##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cafFactory.h"
|
#include "cafFactory.h"
|
||||||
@@ -49,20 +47,6 @@
|
|||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
|
||||||
|
|
||||||
// Taken from gtest.h
|
|
||||||
//
|
|
||||||
// Due to C++ preprocessor weirdness, we need double indirection to
|
|
||||||
// concatenate two tokens when one of them is __LINE__. Writing
|
|
||||||
//
|
|
||||||
// foo ## __LINE__
|
|
||||||
//
|
|
||||||
// will result in the token foo__LINE__, instead of foo followed by
|
|
||||||
// the current line number. For more details, see
|
|
||||||
// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
|
|
||||||
#define PDM_FIELD_EDITOR_STRING_CONCATENATE(foo, bar) PDM_FIELD_EDITOR_STRING_CONCATENATE_IMPL_(foo, bar)
|
|
||||||
#define PDM_FIELD_EDITOR_STRING_CONCATENATE_IMPL_(foo, bar) foo ## bar
|
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -70,23 +54,26 @@ namespace caf
|
|||||||
/// Macros helping in development of PDM UI editors
|
/// Macros helping in development of PDM UI editors
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
||||||
/// CAF_PDM_UI_EDITOR_HEADER_INIT assists the factory used when creating editors
|
/// CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT assists the factory used when creating editors
|
||||||
/// Place this in the header file inside the class definition of your PdmUiEditor
|
/// Place this in the header file inside the class definition of your PdmUiEditor
|
||||||
|
|
||||||
#define CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT \
|
#define CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT \
|
||||||
public: \
|
public: \
|
||||||
static QString uiEditorTypeName()
|
static QString uiEditorTypeName()
|
||||||
|
|
||||||
/// CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT implements editorTypeName() and registers the field editor in the field editor factory
|
/// CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT implements editorTypeName() and registers the field editor in the field editor factory
|
||||||
/// Place this in the cpp file, preferably above the constructor
|
/// Place this in the cpp file, preferably above the constructor
|
||||||
|
|
||||||
#define CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(EditorClassName) \
|
#define CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(EditorClassName) \
|
||||||
QString EditorClassName::uiEditorTypeName() { return #EditorClassName; } \
|
QString EditorClassName::uiEditorTypeName() { return #EditorClassName; } \
|
||||||
static bool PDM_FIELD_EDITOR_STRING_CONCATENATE(my##EditorClassName, __LINE__) = caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<EditorClassName>(EditorClassName::uiEditorTypeName())
|
CAF_FACTORY_REGISTER(caf::PdmUiFieldEditorHandle, EditorClassName, QString, EditorClassName::uiEditorTypeName())
|
||||||
|
|
||||||
|
/// CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR registers what default editor to use with a field of a certain type
|
||||||
|
/// Place this in the cpp file, preferably above the constructor
|
||||||
|
|
||||||
#define CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(EditorClassName, TypeName) \
|
#define CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(EditorClassName, TypeName) \
|
||||||
static bool PDM_FIELD_EDITOR_STRING_CONCATENATE(myField##EditorClassName, __LINE__) = caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<EditorClassName>(qStringTypeName(caf::PdmField<TypeName>)); \
|
CAF_FACTORY_REGISTER(caf::PdmUiFieldEditorHandle, EditorClassName, QString, qStringTypeName(caf::PdmField<TypeName>)); \
|
||||||
static bool PDM_FIELD_EDITOR_STRING_CONCATENATE(myProxyField##EditorClassName, __LINE__) = caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<EditorClassName>(qStringTypeName(caf::PdmProxyValueField<TypeName>))
|
CAF_FACTORY_REGISTER2(caf::PdmUiFieldEditorHandle, EditorClassName, QString, qStringTypeName(caf::PdmProxyValueField<TypeName>) )
|
||||||
|
|
||||||
class PdmUiGroup;
|
class PdmUiGroup;
|
||||||
class PdmUiFieldHandle;
|
class PdmUiFieldHandle;
|
||||||
@@ -124,7 +111,7 @@ protected: // Virtual interface to override
|
|||||||
void updateLabelFromField(QLabel* label, const QString& uiConfigName = "") const;
|
void updateLabelFromField(QLabel* label, const QString& uiConfigName = "") const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void customMenuRequested(QPoint pos);
|
void customMenuRequested(QPoint pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QWidget> m_combinedWidget;
|
QPointer<QWidget> m_combinedWidget;
|
||||||
|
|||||||
Reference in New Issue
Block a user