caf: Use caf::Factory macro for factory registration in field editors. Removed obsolete code

This commit is contained in:
Jacob Støren
2018-08-16 15:33:40 +02:00
parent 1e77c9308a
commit 096536a341
2 changed files with 15 additions and 23 deletions

View File

@@ -58,8 +58,13 @@
#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) \
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
{

View File

@@ -33,8 +33,6 @@
// for more details.
//
//##################################################################################################
#pragma once
#include "cafFactory.h"
@@ -49,20 +47,6 @@
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
{
@@ -70,23 +54,26 @@ namespace caf
/// 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
#define CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT \
public: \
static QString uiEditorTypeName()
/// 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
/// 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
#define CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(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) \
static bool PDM_FIELD_EDITOR_STRING_CONCATENATE(myField##EditorClassName, __LINE__) = caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<EditorClassName>(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_REGISTER(caf::PdmUiFieldEditorHandle, EditorClassName, QString, qStringTypeName(caf::PdmField<TypeName>)); \
CAF_FACTORY_REGISTER2(caf::PdmUiFieldEditorHandle, EditorClassName, QString, qStringTypeName(caf::PdmProxyValueField<TypeName>) )
class PdmUiGroup;
class PdmUiFieldHandle;
@@ -124,7 +111,7 @@ protected: // Virtual interface to override
void updateLabelFromField(QLabel* label, const QString& uiConfigName = "") const;
private slots:
void customMenuRequested(QPoint pos);
void customMenuRequested(QPoint pos);
private:
QPointer<QWidget> m_combinedWidget;