diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,10 @@ -cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) +if(EXISTS "/usr/lib/qt5/qml/Sailfish/Silica/SilicaGridView.qml") #SailfishOS + cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR) +else() + cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) +endif() + + project(KProperty) # ECM setup @@ -25,21 +31,28 @@ include(MacroLogFeature) include(KPropertyMacros) +simple_option(KPROPERTY_WIDGETS "Build the QtWidget components of KProperty" ON) + set(KPROPERTY_VERSION "2.96.0") # Update this # Dependencies set(REQUIRED_QT_VERSION "5.2.0") -# Required components to build this framework -find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets) -find_package(KF5 5.7.0 REQUIRED Config CoreAddons WidgetsAddons GuiAddons) -#TODO KIO +find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core) + +if(KPROPERTY_WIDGETS) + find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Widgets) + find_package(KF5 5.7.0 REQUIRED Config CoreAddons WidgetsAddons GuiAddons) + + #TODO KIO + get_git_revision_and_branch() + add_tests() + add_examples() +endif() -get_git_revision_and_branch() -add_tests() -add_examples() add_unfinished_features_option() -add_pc_file() +add_pc_file(KPropertyCore) +add_pc_file(KPropertyWidgets) add_subdirectory(src) diff --git a/KProperty.pc.cmake b/KPropertyCore.pc.cmake rename from KProperty.pc.cmake rename to KPropertyCore.pc.cmake --- a/KProperty.pc.cmake +++ b/KPropertyCore.pc.cmake @@ -3,10 +3,10 @@ libdir=${exec_prefix}/lib includedir=${prefix}/include -Name: KProperty -Description: A property editing framework with editor +Name: KPropertyCore +Description: A property editing framework with editor (core) Version: @KPROPERTY_VERSION@ URL: https://community.kde.org/KProperty -Requires: Qt5Core Qt5Gui KF5WidgetsAddons KF5GuiAddons +Requires: Qt5Core Libs: -L${libdir} Cflags: -I${includedir} diff --git a/KProperty.pc.cmake b/KPropertyWidgets.pc.cmake rename from KProperty.pc.cmake rename to KPropertyWidgets.pc.cmake --- a/KProperty.pc.cmake +++ b/KPropertyWidgets.pc.cmake @@ -3,10 +3,10 @@ libdir=${exec_prefix}/lib includedir=${prefix}/include -Name: KProperty -Description: A property editing framework with editor +Name: KPropertyWidgets +Description: A property editing framework with edito (widgets) Version: @KPROPERTY_VERSION@ URL: https://community.kde.org/KProperty -Requires: Qt5Core Qt5Gui KF5WidgetsAddons KF5GuiAddons +Requires: KPropertyCore Qt5Core Qt5Gui KF5WidgetsAddons KF5GuiAddons Libs: -L${libdir} Cflags: -I${includedir} diff --git a/cmake/modules/KPropertyMacros.cmake b/cmake/modules/KPropertyMacros.cmake --- a/cmake/modules/KPropertyMacros.cmake +++ b/cmake/modules/KPropertyMacros.cmake @@ -90,12 +90,12 @@ "Include unfinished features (useful for testing but may confuse end-user)" OFF) endmacro() -# Adds commands that generate ${PROJECT_NAME}.pc file out of ${PROJECT_NAME}.pc.cmake file +# Adds commands that generate ${PKGCONFIG_FILE_NAME}.pc file out of ${PKGCONFIG_FILE_NAME}.pc.cmake file # and install the .pc file to ${LIB_INSTALL_DIR}/pkgconfig. These commands are not executed for WIN32. -# ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.pc.cmake should exist. -macro(add_pc_file) +# ${CMAKE_SOURCE_DIR}/${PKGCONFIG_FILE_NAME}.pc.cmake should exist. +macro(add_pc_file PKGCONFIG_FILE_NAME) if (NOT WIN32) - configure_file(${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.pc.cmake ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY) - install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) + configure_file(${CMAKE_SOURCE_DIR}/${PKGCONFIG_FILE_NAME}.pc.cmake ${CMAKE_BINARY_DIR}/${PKGCONFIG_FILE_NAME}.pc @ONLY) + install(FILES ${CMAKE_BINARY_DIR}/${PKGCONFIG_FILE_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) endif() endmacro() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -10,4 +10,4 @@ set(kpropertyexample_SRCS main.cpp window.cpp) add_executable(kpropertyexample ${kpropertyexample_SRCS}) -target_link_libraries(kpropertyexample Qt5::Widgets KProperty) +target_link_libraries(kpropertyexample Qt5::Widgets KPropertyWidgets) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,159 +1,246 @@ # Options # simple_option(KPROPERTY_...... "....." OFF) - configure_file(config-kproperty.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kproperty.h) -add_subdirectory(editors) - -set(libkpropertyeditors_SRCS - editors/utils.cpp - editors/booledit.cpp - editors/coloredit.cpp - editors/combobox.cpp - editors/cursoredit.cpp - editors/dateedit.cpp - editors/datetimeedit.cpp -# editors/dummywidget.cpp - editors/fontedit.cpp - editors/pixmapedit.cpp - editors/pointedit.cpp - editors/pointfedit.cpp - editors/rectedit.cpp - editors/sizeedit.cpp - editors/sizefedit.cpp - editors/sizepolicyedit.cpp - editors/spinbox.cpp - editors/KPropertyStringEditor.cpp - editors/linestyleedit.cpp -# editors/stringlistedit.cpp -# editors/symbolcombo.cpp - editors/timeedit.cpp -#TODO editors/urledit.cpp -) - -set(kproperty_LIB_SRCS - kproperty_debug.cpp +set(kpropertycore_LIB_SRCS KProperty.cpp KPropertySet.cpp - KPropertyFactory.cpp - KDefaultPropertyFactory.cpp - KPropertyEditorView.cpp - KPropertyEditorDataModel.cpp - KPropertyUtils.cpp KPropertyUnit_p.cpp - KPropertyLineStyleSelector_p.cpp - KPropertyLineStyleModel_p.cpp - KPropertyLineStyleItemDelegate_p.cpp - ${libkpropertyeditors_SRCS} + KPropertyFactory.cpp + kproperty_debug.cpp ) -ecm_create_qm_loader(kproperty_LIB_SRCS kproperty_qt) - -add_library(KProperty SHARED ${kproperty_LIB_SRCS}) - -generate_export_header(KProperty) +if(KPROPERTY_WIDGETS) + add_subdirectory(editors) + + set(libkpropertyeditors_SRCS + editors/utils.cpp + editors/booledit.cpp + editors/coloredit.cpp + editors/combobox.cpp + editors/cursoredit.cpp + editors/dateedit.cpp + editors/datetimeedit.cpp + # editors/dummywidget.cpp + editors/fontedit.cpp + editors/pixmapedit.cpp + editors/pointedit.cpp + editors/pointfedit.cpp + editors/rectedit.cpp + editors/sizeedit.cpp + editors/sizefedit.cpp + editors/sizepolicyedit.cpp + editors/spinbox.cpp + editors/KPropertyStringEditor.cpp + editors/linestyleedit.cpp + # editors/stringlistedit.cpp + # editors/symbolcombo.cpp + editors/timeedit.cpp + #TODO editors/urledit.cpp + ) + + set(kpropertywidgets_LIB_SRCS + ${libkpropertyeditors_SRCS} + kpropertywidgets_debug.cpp + KPropertyWidgetsFactory.cpp + KDefaultPropertyFactory.cpp + KPropertyEditorView.cpp + KPropertyEditorDataModel.cpp + KPropertyUtils.cpp + KPropertyLineStyleSelector_p.cpp + KPropertyLineStyleModel_p.cpp + KPropertyLineStyleItemDelegate_p.cpp + ) +endif() set(kproperty_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/kproperty ${CMAKE_CURRENT_BINARY_DIR}/editors ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/editors ) -target_include_directories(KProperty - PUBLIC "$" - INTERFACE "$" - PRIVATE editors +ecm_create_qm_loader(kpropertycore_LIB_SRCS kpropertycore_qt) + +add_library(KPropertyCore SHARED ${kpropertycore_LIB_SRCS}) +target_link_libraries(KPropertyCore + Qt5::Core ) +generate_export_header(KPropertyCore) -target_link_libraries(KProperty - KF5::WidgetsAddons - KF5::GuiAddons - #TODO KF5::KIOWidgets +target_include_directories(KPropertyCore + PUBLIC "$" + INTERFACE "$" + PRIVATE editors ) -set_target_properties(KProperty +set_target_properties(KPropertyCore PROPERTIES VERSION 1.0 SOVERSION 1.0.0 - EXPORT_NAME KProperty + EXPORT_NAME KPropertyCore ) +if(KPROPERTY_WIDGETS) + add_library(KPropertyWidgets SHARED ${kpropertywidgets_LIB_SRCS}) + target_link_libraries(KPropertyWidgets + KPropertyCore + KF5::WidgetsAddons + KF5::GuiAddons + ) + generate_export_header(KPropertyWidgets) + target_include_directories(KPropertyWidgets + PUBLIC "$" + INTERFACE "$" + PRIVATE editors + ) + + set_target_properties(KPropertyWidgets + PROPERTIES VERSION 1.0 + SOVERSION 1.0.0 + EXPORT_NAME KPropertyWidgets + ) +endif() + # Create a Config.cmake and a ConfigVersion.cmake file and install them -set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KProperty") +set(CMAKECONFIG_CORE_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KPropertyCore") # A place for KProperty plugins set(KPROPERTY_PLUGIN_INSTALL_DIR ${PLUGIN_INSTALL_DIR}/kproperty) ecm_setup_version(${KPROPERTY_VERSION} VARIABLE_PREFIX KPROPERTY VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kproperty_version.h" - PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KPropertyConfigVersion.cmake" + PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KPropertyCoreConfigVersion.cmake" ) ecm_configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/KPropertyConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/KPropertyConfig.cmake" - INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/KPropertyCoreConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/KPropertyCoreConfig.cmake" + INSTALL_DESTINATION "${CMAKECONFIG_CORE_INSTALL_DIR}" ) install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/KPropertyConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/KPropertyConfigVersion.cmake" - DESTINATION "${CMAKECONFIG_INSTALL_DIR}" - COMPONENT Devel) - -install(TARGETS KProperty - EXPORT KPropertyTargets - ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) - -install(EXPORT KPropertyTargets - DESTINATION "${CMAKECONFIG_INSTALL_DIR}" - FILE KPropertyTargets.cmake) + "${CMAKE_CURRENT_BINARY_DIR}/KPropertyCoreConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/KPropertyCoreConfigVersion.cmake" + DESTINATION "${CMAKECONFIG_CORE_INSTALL_DIR}" + COMPONENT Devel) + +install(TARGETS KPropertyCore + EXPORT KPropertyCoreTargets + ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + +install(EXPORT KPropertyCoreTargets + DESTINATION "${CMAKECONFIG_CORE_INSTALL_DIR}" + FILE KPropertyCoreTargets.cmake) + +if(KPROPERTY_WIDGETS) + set(CMAKECONFIG_WIDGETS_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KPropertyWidgets") + + ecm_setup_version(${KPROPERTY_VERSION} + VARIABLE_PREFIX KPROPERTY + VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kproperty_version.h" + PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KPropertyWidgetsConfigVersion.cmake" + ) + ecm_configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/KPropertyWidgetsConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/KPropertyWidgetsConfig.cmake" + INSTALL_DESTINATION "${CMAKECONFIG_WIDGETS_INSTALL_DIR}" + ) + + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/KPropertyWidgetsConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/KPropertyWidgetsConfigVersion.cmake" + DESTINATION "${CMAKECONFIG_WIDGETS_INSTALL_DIR}" + COMPONENT Devel) + + install(TARGETS KPropertyWidgets + EXPORT KPropertyWidgetsTargets + ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + + install(EXPORT KPropertyWidgetsTargets + DESTINATION "${CMAKECONFIG_WIDGETS_INSTALL_DIR}" + FILE KPropertyWidgetsTargets.cmake) + +endif() + +install(FILES ${PRI_FILENAME} + DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) ecm_generate_pri_file( - BASE_NAME KProperty - LIB_NAME KProperty - DEPS "widgets" + BASE_NAME KPropertyCore + LIB_NAME KPropertyCore + DEPS "core" FILENAME_VAR PRI_FILENAME - INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR}/KProperty + INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR}/KPropertyCore ) - -install(FILES ${PRI_FILENAME} - DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) + +if(KPROPERTY_WIDGETS) + ecm_generate_pri_file( + BASE_NAME KPropertyWidgets + LIB_NAME KPropertyWidgets + DEPS "" + FILENAME_VAR PRI_FILENAME + INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR}/KPropertyWidgets + ) +endif() #ecm_install_icons(${DATA_INSTALL_DIR}/kproperty/icons) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kproperty_version.h" DESTINATION "${INCLUDE_INSTALL_DIR}" COMPONENT Devel) -ecm_generate_headers(kproperty_FORWARDING_HEADERS - REQUIRED_HEADERS kproperty_HEADERS +ecm_generate_headers(kpropertycore_FORWARDING_HEADERS + REQUIRED_HEADERS kpropertycore_HEADERS ORIGINAL CAMELCASE HEADER_NAMES - KPropertyFactory KProperty KPropertySet - KPropertyUtils KPropertyFactory - KPropertyEditorView - KPropertyEditorDataModel ) install( FILES - ${kproperty_HEADERS} - DESTINATION ${INCLUDE_INSTALL_DIR}/KProperty + ${kpropertycore_HEADERS} + DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyCore COMPONENT Devel ) install( FILES - ${kproperty_FORWARDING_HEADERS} - ${PROJECT_BINARY_DIR}/src/kproperty_export.h + ${kpropertycore_FORWARDING_HEADERS} + ${PROJECT_BINARY_DIR}/src/kpropertycore_export.h ${PROJECT_BINARY_DIR}/src/config-kproperty.h - DESTINATION ${INCLUDE_INSTALL_DIR}/KProperty + DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyCore COMPONENT Devel ) +if(KPROPERTY_WIDGETS) + ecm_generate_headers(kpropertywidgets_FORWARDING_HEADERS + REQUIRED_HEADERS kpropertywidgets_HEADERS + ORIGINAL CAMELCASE + HEADER_NAMES + KPropertyWidgetsFactory + KPropertyUtils + KPropertyEditorView + KPropertyEditorDataModel + ) + + install( + FILES + ${kpropertywidgets_HEADERS} + DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyWidgets + COMPONENT Devel + ) + + install( + FILES + ${kpropertywidgets_FORWARDING_HEADERS} + ${PROJECT_BINARY_DIR}/src/kpropertywidgets_export.h + ${PROJECT_BINARY_DIR}/src/config-kproperty.h + DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyWidgets + COMPONENT Devel + ) +endif() + enable_testing() diff --git a/src/KDefaultPropertyFactory.h b/src/KDefaultPropertyFactory.h --- a/src/KDefaultPropertyFactory.h +++ b/src/KDefaultPropertyFactory.h @@ -20,9 +20,9 @@ #ifndef KDEFAULTPROPERTYFACTORY_H #define KDEFAULTPROPERTYFACTORY_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" -class KDefaultPropertyFactory : public KPropertyFactory +class KDefaultPropertyFactory : public KPropertyWidgetsFactory { public: KDefaultPropertyFactory(); diff --git a/src/KDefaultPropertyFactory.cpp b/src/KDefaultPropertyFactory.cpp --- a/src/KDefaultPropertyFactory.cpp +++ b/src/KDefaultPropertyFactory.cpp @@ -18,6 +18,7 @@ */ #include "KDefaultPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include "KProperty.h" /* #include "customproperty.h"*/ @@ -45,7 +46,7 @@ // #include "urledit.h" KDefaultPropertyFactory::KDefaultPropertyFactory() - : KPropertyFactory() + : KPropertyWidgetsFactory() { addEditor( KProperty::Bool, new KPropertyBoolDelegate ); addEditor( KProperty::Cursor, new KPropertyCursorDelegate ); diff --git a/src/KProperty.h b/src/KProperty.h --- a/src/KProperty.h +++ b/src/KProperty.h @@ -27,7 +27,7 @@ #include #include -#include "kproperty_export.h" +#include "kpropertycore_export.h" /*! \brief Namespace for a set of classes implementing generic properties framework. @@ -53,7 +53,7 @@ class KPropertySet; /*! Data container for properties of list type. */ -class KPROPERTY_EXPORT KPropertyListData +class KPROPERTYCORE_EXPORT KPropertyListData { public: /*! Data container for list-value property. @@ -128,7 +128,7 @@ \author Alexander Dymo \author Jarosław Staniek */ -class KPROPERTY_EXPORT KProperty +class KPROPERTYCORE_EXPORT KProperty { public: /*! Defines types of properties. @@ -441,10 +441,10 @@ friend class KPropertySet; friend class KPropertyBuffer; friend class KComposedPropertyInterface; - friend KPROPERTY_EXPORT QDebug operator<<(QDebug dbg, const KProperty &p); + friend KPROPERTYCORE_EXPORT QDebug operator<<(QDebug dbg, const KProperty &p); }; //! qDebug() stream operator. Writes property @a p to the debug output in a nicely formatted way. -KPROPERTY_EXPORT QDebug operator<<(QDebug dbg, const KProperty &p); +KPROPERTYCORE_EXPORT QDebug operator<<(QDebug dbg, const KProperty &p); #endif diff --git a/src/KProperty.cpp b/src/KProperty.cpp --- a/src/KProperty.cpp +++ b/src/KProperty.cpp @@ -26,7 +26,10 @@ #include "kproperty_debug.h" #include + +#ifdef KPROPERTY_WIDGET #include +#endif //! @internal class KProperty::Private @@ -359,8 +362,10 @@ ch = static_cast(currentValue.toDouble() * factor) != static_cast(value.toDouble() * factor); } else if (t == QVariant::Invalid && newt == QVariant::Invalid) { ch = false; +#ifdef KPROPERTY_WIDGET } else if (t == QVariant::SizePolicy) { ch = (currentValue.value() != value.value()); +#endif } else { ch = (currentValue != value); @@ -764,7 +769,7 @@ kprDebug() << *this; } -KPROPERTY_EXPORT QDebug operator<<(QDebug dbg, const KProperty &p) +KPROPERTYCORE_EXPORT QDebug operator<<(QDebug dbg, const KProperty &p) { dbg.nospace() << "KProperty(" << "NAME=" << p.name(); diff --git a/src/KPropertyConfig.cmake.in b/src/KPropertyCoreConfig.cmake.in rename from src/KPropertyConfig.cmake.in rename to src/KPropertyCoreConfig.cmake.in --- a/src/KPropertyConfig.cmake.in +++ b/src/KPropertyCoreConfig.cmake.in @@ -14,9 +14,8 @@ @PACKAGE_INIT@ find_dependency(Qt5Core @REQUIRED_QT_VERSION@) -find_dependency(Qt5Widgets @REQUIRED_QT_VERSION@) -include("${CMAKE_CURRENT_LIST_DIR}/KPropertyTargets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/KPropertyCoreTargets.cmake") # "public" variables: # TODO diff --git a/src/KPropertyEditorDataModel.h b/src/KPropertyEditorDataModel.h --- a/src/KPropertyEditorDataModel.h +++ b/src/KPropertyEditorDataModel.h @@ -20,17 +20,18 @@ #ifndef KPROPERTY_EDITORDATAMODEL_H #define KPROPERTY_EDITORDATAMODEL_H +#include "kpropertywidgets_export.h" +#include "KPropertySet.h" + #include #include -#include "KPropertySet.h" - class KProperty; /*! @short A data model for using Set objects within the Qt's model/view API. @see KPropertyEditorView */ -class KPROPERTY_EXPORT KPropertyEditorDataModel : public QAbstractItemModel +class KPROPERTYWIDGETS_EXPORT KPropertyEditorDataModel : public QAbstractItemModel { Q_OBJECT diff --git a/src/KPropertyEditorDataModel.cpp b/src/KPropertyEditorDataModel.cpp --- a/src/KPropertyEditorDataModel.cpp +++ b/src/KPropertyEditorDataModel.cpp @@ -18,7 +18,7 @@ */ #include "KPropertyEditorDataModel.h" -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include "KProperty.h" #include "kproperty_debug.h" @@ -128,7 +128,7 @@ return prop->value(); } else if (role == Qt::DisplayRole) { - return KPropertyFactoryManager::self()->convertValueToText(prop); + return KPropertyWidgetsFactoryManager::self()->convertValueToText(prop); } } return QVariant(); diff --git a/src/KPropertyEditorView.h b/src/KPropertyEditorView.h --- a/src/KPropertyEditorView.h +++ b/src/KPropertyEditorView.h @@ -20,7 +20,7 @@ #ifndef KPROPERTY_EDITORVIEW_H #define KPROPERTY_EDITORVIEW_H -#include "kproperty_export.h" +#include "kpropertywidgets_export.h" #include @@ -57,7 +57,7 @@ */ -class KPROPERTY_EXPORT KPropertyEditorView : public QTreeView +class KPROPERTYWIDGETS_EXPORT KPropertyEditorView : public QTreeView { Q_OBJECT public: diff --git a/src/KPropertyEditorView.cpp b/src/KPropertyEditorView.cpp --- a/src/KPropertyEditorView.cpp +++ b/src/KPropertyEditorView.cpp @@ -21,7 +21,7 @@ #include "KPropertyEditorDataModel.h" #include "KProperty.h" #include "KPropertySet.h" -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include "kproperty_debug.h" #include @@ -143,7 +143,7 @@ KProperty *property = editorModel->propertyForItem(index); const int t = typeForProperty( property ); bool useQItemDelegatePaint = true; // ValueDisplayInterface is used by default - if (index.column() == 1 && KPropertyFactoryManager::self()->paint(t, painter, alteredOption, index)) { + if (index.column() == 1 && KPropertyWidgetsFactoryManager::self()->paint(t, painter, alteredOption, index)) { useQItemDelegatePaint = false; } if (useQItemDelegatePaint) { @@ -201,7 +201,7 @@ KProperty *property = editorModel->propertyForItem(index); int t = typeForProperty(property); alteredOption.rect.setHeight(alteredOption.rect.height()+3); - QWidget *w = KPropertyFactoryManager::self()->createEditor(t, parent, alteredOption, index); + QWidget *w = KPropertyWidgetsFactoryManager::self()->createEditor(t, parent, alteredOption, index); if (w) { if (-1 != w->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("commitData(QWidget*)").constData()) && property && !property->children()) diff --git a/src/KPropertyFactory.h b/src/KPropertyFactory.h --- a/src/KPropertyFactory.h +++ b/src/KPropertyFactory.h @@ -25,18 +25,15 @@ #include #include #include -#include -#include -#include //! An interface for for composed property handlers /*! You have to subclass KComposedPropertyInterface to override the behaviour of a property type.\n In the constructor, you should create the child properties (if needed). Then, you need to implement the functions concerning values.\n Example implementation of composed properties can be found in editors/ directory. */ -class KPROPERTY_EXPORT KComposedPropertyInterface +class KPROPERTYCORE_EXPORT KComposedPropertyInterface { public: explicit KComposedPropertyInterface(KProperty *parent); @@ -66,7 +63,7 @@ bool m_childValueChangedEnabled : 1; }; -class KPROPERTY_EXPORT KComposedPropertyCreatorInterface +class KPROPERTYCORE_EXPORT KComposedPropertyCreatorInterface { public: KComposedPropertyCreatorInterface(); @@ -76,114 +73,9 @@ virtual KComposedPropertyInterface* createComposedProperty(KProperty *parent) const = 0; }; -//! An interface for editor widget creators. -/*! Options can be set in the options attribute in order to customize - widget creation process. Do this in the EditorCreatorInterface constructor. -*/ -class KPROPERTY_EXPORT KPropertyEditorCreatorInterface -{ -public: - KPropertyEditorCreatorInterface(); - - virtual ~KPropertyEditorCreatorInterface(); - - virtual QWidget * createEditor( int type, QWidget *parent, - const QStyleOptionViewItem & option, const QModelIndex & index ) const = 0; - - /*! Options for altering the editor widget creation process, - used by KPropertyFactoryManager::createEditor(). */ - class Options { - public: - Options(); - /*! In order to have better look of the widget within the property editor view, - we usually remove borders from the widget (see FactoryManager::createEditor()). - and adding 1 pixel 'gray border' on the top. Default value is true. */ - bool removeBorders; - }; - - //! Options for altering the editor widget creation process - Options options; -}; - -class KPROPERTY_EXPORT KPropertyValuePainterInterface -{ -public: - KPropertyValuePainterInterface(); - virtual ~KPropertyValuePainterInterface(); - virtual void paint( QPainter * painter, - const QStyleOptionViewItem & option, const QModelIndex & index ) const = 0; -}; - -class KPROPERTY_EXPORT KPropertyValueDisplayInterface -{ -public: - KPropertyValueDisplayInterface(); - virtual ~KPropertyValueDisplayInterface(); - virtual QString displayTextForProperty( const KProperty* property ) const - { return displayText(property->value()); } - virtual QString displayText( const QVariant& value ) const - { return value.toString(); } -}; - -//! Label widget that can be used for displaying text-based read-only items -//! Used in LabelCreator. -class KPROPERTY_EXPORT KPropertyLabel : public QLabel -{ - Q_OBJECT - Q_PROPERTY(QVariant value READ value WRITE setValue USER true) -public: - KPropertyLabel(QWidget *parent, const KPropertyValueDisplayInterface *iface); - QVariant value() const; -Q_SIGNALS: - void commitData( QWidget * editor ); -public Q_SLOTS: - void setValue(const QVariant& value); - -protected: - virtual void paintEvent( QPaintEvent * event ); - -private: - const KPropertyValueDisplayInterface *m_iface; - QVariant m_value; -}; - -//! Creator returning editor -template -class KPROPERTY_EXPORT KPropertyEditorCreator : public KPropertyEditorCreatorInterface, - public KPropertyValueDisplayInterface, - public KPropertyValuePainterInterface -{ -public: - KPropertyEditorCreator() : KPropertyEditorCreatorInterface() {} - - virtual ~KPropertyEditorCreator() {} - - virtual QWidget * createEditor( int type, QWidget *parent, - const QStyleOptionViewItem & option, const QModelIndex & index ) const - { - Q_UNUSED(type); - Q_UNUSED(option); - Q_UNUSED(index); - return new Widget(parent, this); - } - - virtual void paint( QPainter * painter, - const QStyleOptionViewItem & option, const QModelIndex & index ) const - { - painter->save(); - QRect r(option.rect); - r.setLeft(r.left()+1); - painter->drawText( r, Qt::AlignLeft | Qt::AlignVCenter, - displayText( index.data(Qt::EditRole) ) ); - painter->restore(); - } -}; - -typedef KPropertyEditorCreator KPropertyLabelCreator; - //! Creator returning composed property object template -class KPROPERTY_EXPORT KComposedPropertyCreator : public KComposedPropertyCreatorInterface +class KPROPERTYCORE_EXPORT KComposedPropertyCreator : public KComposedPropertyCreatorInterface { public: KComposedPropertyCreator() : KComposedPropertyCreatorInterface() {} @@ -195,76 +87,33 @@ } }; -class KPROPERTY_EXPORT KPropertyFactory +class KPROPERTYCORE_EXPORT KPropertyFactory { public: KPropertyFactory(); virtual ~KPropertyFactory(); QHash composedPropertyCreators() const; - QHash editorCreators() const; - QHash valuePainters() const; - QHash valueDisplays() const; - - //! Adds editor creator @a creator for type @a type. - //! The creator becomes owned by the factory. - void addEditor(int type, KPropertyEditorCreatorInterface *creator); - void addComposedPropertyCreator( int type, KComposedPropertyCreatorInterface* creator ); - void addPainter(int type, KPropertyValuePainterInterface *painter); - - void addDisplay(int type, KPropertyValueDisplayInterface *display); - - static void paintTopGridLine(QWidget *widget); - static void setTopAndBottomBordersUsingStyleSheet(QWidget *widget, QWidget* parent, - const QString& extraStyleSheet = QString()); - protected: - void addEditorInternal(int type, KPropertyEditorCreatorInterface *editor, bool own = true); - void addComposedPropertyCreatorInternal(int type, KComposedPropertyCreatorInterface* creator, bool own = true); - - //! Adds value painter @a painter for type @a type. - //! The painter becomes owned by the factory. - void addPainterInternal(int type, KPropertyValuePainterInterface *painter, bool own = true); - - //! Adds value-to-text converted @a painter for type @a type. - //! The converter becomes owned by the factory. - void addDisplayInternal(int type, KPropertyValueDisplayInterface *display, bool own = true); - + class Private; Private * const d; }; class KProperty; class KCustomProperty; -class KPROPERTY_EXPORT KPropertyFactoryManager : public QObject +class KPROPERTYCORE_EXPORT KPropertyFactoryManager : public QObject { Q_OBJECT public: bool isEditorForTypeAvailable( int type ) const; - - QWidget * createEditor( - int type, - QWidget *parent, - const QStyleOptionViewItem & option, - const QModelIndex & index ) const; - - bool paint( int type, - QPainter * painter, - const QStyleOptionViewItem & option, - const QModelIndex & index ) const; - + KComposedPropertyInterface* createComposedProperty(KProperty *parent); - bool canConvertValueToText( int type ) const; - - bool canConvertValueToText( const KProperty* property ) const; - - QString convertValueToText( const KProperty* property ) const; - //! Registers factory @a factory. It becomes owned by the manager. void registerFactory(KPropertyFactory *factory); diff --git a/src/KPropertyFactory.cpp b/src/KPropertyFactory.cpp --- a/src/KPropertyFactory.cpp +++ b/src/KPropertyFactory.cpp @@ -19,35 +19,6 @@ #include "KPropertyFactory.h" -#include "KDefaultPropertyFactory.h" -#include "KPropertyEditorView.h" -#include "KPropertyEditorDataModel.h" - -KPropertyLabel::KPropertyLabel(QWidget *parent, const KPropertyValueDisplayInterface *iface) - : QLabel(parent) - , m_iface(iface) -{ - setAutoFillBackground(true); - setContentsMargins(0,1,0,0); - setIndent(1); -} - -QVariant KPropertyLabel::value() const -{ - return m_value; -} - -void KPropertyLabel::setValue(const QVariant& value) -{ - setText( m_iface->displayText(value) ); - m_value = value; -} - -void KPropertyLabel::paintEvent( QPaintEvent * event ) -{ - QLabel::paintEvent(event); - KPropertyFactory::paintTopGridLine(this); -} //--------------- @@ -65,9 +36,6 @@ QSet factories; QHash composedPropertyCreators; - QHash editorCreators; - QHash valuePainters; - QHash valueDisplays; }; Q_GLOBAL_STATIC(KPropertyFactoryManager, _self) @@ -81,19 +49,10 @@ } ~Private() { - qDeleteAll(editorCreatorsSet); - qDeleteAll(valuePaintersSet); - qDeleteAll(valueDisplaysSet); } QHash composedPropertyCreators; - QHash editorCreators; - QHash valuePainters; - QHash valueDisplays; QSet composedPropertyCreatorsSet; - QSet editorCreatorsSet; - QSet valuePaintersSet; - QSet valueDisplaysSet; }; KPropertyFactory::KPropertyFactory() @@ -111,6 +70,7 @@ return d->composedPropertyCreators; } +#ifdef KPROPERTY_WIDGET QHash KPropertyFactory::editorCreators() const { return d->editorCreators; @@ -140,56 +100,11 @@ addDisplayInternal( type, dynamic_cast(creator), false/* !own*/ ); } } +#endif void KPropertyFactory::addComposedPropertyCreator( int type, KComposedPropertyCreatorInterface* creator ) { addComposedPropertyCreatorInternal( type, creator, true ); - if (dynamic_cast(creator)) { - addEditorInternal( type, dynamic_cast(creator), false/* !own*/ ); - } - if (dynamic_cast(creator)) { - addPainterInternal( type, dynamic_cast(creator), false/* !own*/ ); - } - if (dynamic_cast(creator)) { - addDisplayInternal( type, dynamic_cast(creator), false/* !own*/ ); - } -} - -void KPropertyFactory::addPainter(int type, KPropertyValuePainterInterface *painter) -{ - addPainterInternal(type, painter, true); - if (dynamic_cast(painter)) { - addComposedPropertyCreatorInternal( type, - dynamic_cast(painter), false/* !own*/ ); - } - if (dynamic_cast(painter)) { - addEditorInternal( type, dynamic_cast(painter), false/* !own*/ ); - } - if (dynamic_cast(painter)) { - addDisplayInternal( type, dynamic_cast(painter), false/* !own*/ ); - } -} - -void KPropertyFactory::addDisplay(int type, KPropertyValueDisplayInterface *display) -{ - addDisplayInternal(type, display, true); - if (dynamic_cast(display)) { - addComposedPropertyCreatorInternal( type, - dynamic_cast(display), false/* !own*/ ); - } - if (dynamic_cast(display)) { - addEditorInternal( type, dynamic_cast(display), false/* !own*/ ); - } - if (dynamic_cast(display)) { - addDisplayInternal( type, dynamic_cast(display), false/* !own*/ ); - } -} - -void KPropertyFactory::addEditorInternal(int type, KPropertyEditorCreatorInterface *editor, bool own) -{ - if (own) - d->editorCreatorsSet.insert(editor); - d->editorCreators.insert(type, editor); } void KPropertyFactory::addComposedPropertyCreatorInternal(int type, KComposedPropertyCreatorInterface* creator, bool own) @@ -199,52 +114,15 @@ d->composedPropertyCreators.insert(type, creator); } -void KPropertyFactory::addPainterInternal(int type, KPropertyValuePainterInterface *painter, bool own) -{ - if (own) - d->valuePaintersSet.insert(painter); - d->valuePainters.insert(type, painter); -} - -void KPropertyFactory::addDisplayInternal(int type, KPropertyValueDisplayInterface *display, bool own) -{ - if (own) - d->valueDisplaysSet.insert(display); - d->valueDisplays.insert(type, display); -} - -//static -void KPropertyFactory::paintTopGridLine(QWidget *widget) -{ - // paint top grid line - QPainter p(widget); - QColor gridLineColor( dynamic_cast(widget->parentWidget()) ? - dynamic_cast(widget->parentWidget())->gridLineColor() - : KPropertyEditorView::defaultGridLineColor() ); - p.setPen(QPen( QBrush(gridLineColor), 1)); - p.drawLine(0, 0, widget->width()-1, 0); -} - -//static -void KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(QWidget *widget, QWidget* parent, const QString& extraStyleSheet) -{ - QColor gridLineColor( dynamic_cast(parent) ? - dynamic_cast(parent)->gridLineColor() - : KPropertyEditorView::defaultGridLineColor() ); - widget->setStyleSheet( - QString::fromLatin1("%1 { border-top: 1px solid %2;border-bottom: 1px solid %2; } %3") - .arg(QLatin1String(widget->metaObject()->className())) - .arg(gridLineColor.name()).arg(extraStyleSheet)); -} - //------------ KPropertyFactoryManager::KPropertyFactoryManager() : QObject(0) , d(new Private) { setObjectName(QLatin1String("KPropertyFactoryManager")); - registerFactory(new KDefaultPropertyFactory); + //TODO ??? registerFactory(new KDefaultPropertyFactory); + } KPropertyFactoryManager::~KPropertyFactoryManager() @@ -267,95 +145,6 @@ { d->composedPropertyCreators.insert(it.key(), it.value()); } - QHash::ConstIterator editorCreatorsItEnd - = factory->editorCreators().constEnd(); - for (QHash::ConstIterator it( factory->editorCreators().constBegin() ); - it != editorCreatorsItEnd; ++it) - { - d->editorCreators.insert(it.key(), it.value()); - } - QHash::ConstIterator valuePaintersItEnd - = factory->valuePainters().constEnd(); - for (QHash::ConstIterator it( factory->valuePainters().constBegin() ); - it != valuePaintersItEnd; ++it) - { - d->valuePainters.insert(it.key(), it.value()); - } - QHash::ConstIterator valueDisplaysItEnd - = factory->valueDisplays().constEnd(); - for (QHash::ConstIterator it( factory->valueDisplays().constBegin() ); - it != valueDisplaysItEnd; ++it) - { - d->valueDisplays.insert(it.key(), it.value()); - } -} - -bool KPropertyFactoryManager::isEditorForTypeAvailable( int type ) const -{ - return d->editorCreators.value(type); -} - -QWidget * KPropertyFactoryManager::createEditor( - int type, QWidget *parent, - const QStyleOptionViewItem & option, const QModelIndex & index ) const -{ - const KPropertyEditorCreatorInterface *creator = d->editorCreators.value(type); - if (!creator) - return 0; - QWidget *w = creator->createEditor(type, parent, option, index); - if (w) { - const KPropertyEditorDataModel *editorModel - = dynamic_cast(index.model()); - KProperty *property = editorModel->propertyForItem(index); - w->setObjectName(QLatin1String(property->name())); - if (creator->options.removeBorders) { -//! @todo get real border color from the palette - QColor gridLineColor( dynamic_cast(parent) ? - dynamic_cast(parent)->gridLineColor() - : KPropertyEditorView::defaultGridLineColor() ); - QString cssClassName = QLatin1String(w->metaObject()->className()); - cssClassName.replace(QLatin1String("KProperty"), QString()); //!< @todo - QString css = - QString::fromLatin1("%1 { border-top: 1px solid %2; } ") - .arg(cssClassName).arg(gridLineColor.name()); -// kprDebug() << css; - w->setStyleSheet(css); - } - } - return w; -} - -bool KPropertyFactoryManager::paint( int type, QPainter * painter, - const QStyleOptionViewItem & option, const QModelIndex & index ) const -{ - const KPropertyValuePainterInterface *_painter = d->valuePainters.value(type); - if (!_painter) - return false; - QStyleOptionViewItem realOption(option); - if (option.state & QStyle::State_Selected) { - // paint background because there may be editor widget with no autoFillBackground set - realOption.palette.setBrush(QPalette::Text, realOption.palette.highlightedText()); - painter->fillRect(realOption.rect, realOption.palette.highlight()); - } - painter->setPen(realOption.palette.text().color()); - _painter->paint(painter, realOption, index); - return true; -} - -bool KPropertyFactoryManager::canConvertValueToText( int type ) const -{ - return d->valueDisplays.value(type) != 0; -} - -bool KPropertyFactoryManager::canConvertValueToText( const KProperty* property ) const -{ - return d->valueDisplays.value( property->type() ) != 0; -} - -QString KPropertyFactoryManager::convertValueToText( const KProperty* property ) const -{ - const KPropertyValueDisplayInterface *display = d->valueDisplays.value( property->type() ); - return display ? display->displayTextForProperty( property ) : property->value().toString(); } KComposedPropertyInterface* KPropertyFactoryManager::createComposedProperty(KProperty *parent) @@ -415,32 +204,3 @@ KComposedPropertyCreatorInterface::~KComposedPropertyCreatorInterface() { } - -KPropertyEditorCreatorInterface::KPropertyEditorCreatorInterface() -{ -} - -KPropertyEditorCreatorInterface::~KPropertyEditorCreatorInterface() -{ -} - -KPropertyEditorCreatorInterface::Options::Options() - : removeBorders(true) -{ -} - -KPropertyValuePainterInterface::KPropertyValuePainterInterface() -{ -} - -KPropertyValuePainterInterface::~KPropertyValuePainterInterface() -{ -} - -KPropertyValueDisplayInterface::KPropertyValueDisplayInterface() -{ -} - -KPropertyValueDisplayInterface::~KPropertyValueDisplayInterface() -{ -} diff --git a/src/KPropertyLineStyleSelector_p.h b/src/KPropertyLineStyleSelector_p.h --- a/src/KPropertyLineStyleSelector_p.h +++ b/src/KPropertyLineStyleSelector_p.h @@ -20,14 +20,14 @@ #ifndef KPROPERTYLINESTYLESELECTOR_H #define KPROPERTYLINESTYLESELECTOR_H -#include "kproperty_export.h" +#include "kpropertywidgets_export.h" #include /** * A custom combobox widget for selecting line styles. */ -class KPROPERTY_EXPORT KPropertyLineStyleSelector : public QComboBox +class KPROPERTYWIDGETS_EXPORT KPropertyLineStyleSelector : public QComboBox { Q_OBJECT public: diff --git a/src/KPropertySet.h b/src/KPropertySet.h --- a/src/KPropertySet.h +++ b/src/KPropertySet.h @@ -30,7 +30,7 @@ //! An interface for functor selecting properties. /*! Used in Iterator. */ -class KPROPERTY_EXPORT KPropertySelector +class KPROPERTYCORE_EXPORT KPropertySelector { public: KPropertySelector(); @@ -52,7 +52,7 @@ Usage with selector: @code for (Set::Iterator it(set, MySelector()); it.current(); ++it) { .... } @endcode */ -class KPROPERTY_EXPORT KPropertySetIterator +class KPROPERTYCORE_EXPORT KPropertySetIterator { public: //! Creates iterator for @a set set of properties. @@ -108,7 +108,7 @@ \author Alexander Dymo \author Jarosław Staniek */ -class KPROPERTY_EXPORT KPropertySet : public QObject +class KPROPERTYCORE_EXPORT KPropertySet : public QObject { Q_OBJECT @@ -310,15 +310,15 @@ }; //! qDebug() stream operator. Writes this set to the debug output in a nicely formatted way. -KPROPERTY_EXPORT QDebug operator<<(QDebug dbg, const KPropertySet &set); +KPROPERTYCORE_EXPORT QDebug operator<<(QDebug dbg, const KPropertySet &set); /*! A property buffer \author Cedric Pasteur \author Alexander Dymo \author Adam Treat @todo Find a better name to show it's a set that doesn't own property */ -class KPROPERTY_EXPORT KPropertyBuffer : public KPropertySet +class KPROPERTYCORE_EXPORT KPropertyBuffer : public KPropertySet { Q_OBJECT diff --git a/src/KPropertySet.cpp b/src/KPropertySet.cpp --- a/src/KPropertySet.cpp +++ b/src/KPropertySet.cpp @@ -581,7 +581,7 @@ kprDebug() << *this; } -KPROPERTY_EXPORT QDebug operator<<(QDebug dbg, const KPropertySet &set) +KPROPERTYCORE_EXPORT QDebug operator<<(QDebug dbg, const KPropertySet &set) { dbg.nospace() << "KPropertySet("; if (!set.typeName().isEmpty()) { diff --git a/src/KPropertyUnit_p.h b/src/KPropertyUnit_p.h --- a/src/KPropertyUnit_p.h +++ b/src/KPropertyUnit_p.h @@ -24,7 +24,7 @@ #ifndef KPROPERTYUNIT_H #define KPROPERTYUNIT_H -#include "kproperty_export.h" +#include "kpropertycore_export.h" #include #include @@ -64,7 +64,7 @@ * bound to the order in the enum (so ABI-compatible extension is possible) and * with the order and scope of listed types controlled by the @c ListOptions parameter. */ -class KPROPERTY_EXPORT KPropertyUnit +class KPROPERTYCORE_EXPORT KPropertyUnit { public: /** Length units supported by Calligra. */ @@ -240,6 +240,8 @@ return symbol(); } +#ifdef KPROPERTY_WIDGET + /** * Get an approximate scale of a unit vector that was converted by * the transfomation. @@ -257,14 +259,15 @@ * average scale of the matrix. */ void adjustByPixelTransform(const QTransform &t); - +#endif + private: Type m_type; qreal m_pixelConversion; }; #ifndef QT_NO_DEBUG_STREAM -KPROPERTY_EXPORT QDebug operator<<(QDebug, const KPropertyUnit &); +KPROPERTYCORE_EXPORT QDebug operator<<(QDebug, const KPropertyUnit &); #endif Q_DECLARE_METATYPE(KPropertyUnit) diff --git a/src/KPropertyUnit_p.cpp b/src/KPropertyUnit_p.cpp --- a/src/KPropertyUnit_p.cpp +++ b/src/KPropertyUnit_p.cpp @@ -22,7 +22,10 @@ #include "KPropertyUnit_p.h" #include "kproperty_debug.h" +#ifdef KPROPERTY_WIDGET #include +#endif + #include #include @@ -370,6 +373,7 @@ return defaultVal; } +#ifdef KPROPERTY_WIDGET qreal KPropertyUnit::approxTransformScale(const QTransform &t) { return std::sqrt(t.determinant()); @@ -379,6 +383,7 @@ { m_pixelConversion *= approxTransformScale(t); } +#endif #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, const KPropertyUnit &unit) diff --git a/src/KPropertyUtils.h b/src/KPropertyUtils.h --- a/src/KPropertyUtils.h +++ b/src/KPropertyUtils.h @@ -20,13 +20,13 @@ #ifndef KPROPERTY_UTILS_H #define KPROPERTY_UTILS_H -#include "kproperty_export.h" +#include "kpropertywidgets_export.h" #include //! @short A container widget that can be used to split information into hideable sections //! for a property editor-like panes. -class KPROPERTY_EXPORT KPropertyGroupWidget : public QWidget +class KPROPERTYWIDGETS_EXPORT KPropertyGroupWidget : public QWidget { public: KPropertyGroupWidget(const QString& title, QWidget* parent); diff --git a/src/KPropertyConfig.cmake.in b/src/KPropertyWidgetsConfig.cmake.in rename from src/KPropertyConfig.cmake.in rename to src/KPropertyWidgetsConfig.cmake.in --- a/src/KPropertyConfig.cmake.in +++ b/src/KPropertyWidgetsConfig.cmake.in @@ -16,7 +16,7 @@ find_dependency(Qt5Core @REQUIRED_QT_VERSION@) find_dependency(Qt5Widgets @REQUIRED_QT_VERSION@) -include("${CMAKE_CURRENT_LIST_DIR}/KPropertyTargets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/KPropertyWidgetsTargets.cmake") # "public" variables: # TODO diff --git a/src/KPropertyFactory.h b/src/KPropertyWidgetsFactory.h copy from src/KPropertyFactory.h copy to src/KPropertyWidgetsFactory.h --- a/src/KPropertyFactory.h +++ b/src/KPropertyWidgetsFactory.h @@ -17,70 +17,26 @@ * Boston, MA 02110-1301, USA. */ -#ifndef KPROPERTY_FACTORY_H -#define KPROPERTY_FACTORY_H +#ifndef KPROPERTYWIDGETS_FACTORY_H +#define KPROPERTYWIDGETS_FACTORY_H +#include "kpropertywidgets_export.h" #include "KProperty.h" +#include "KPropertyFactory.h" #include #include #include + #include #include #include -//! An interface for for composed property handlers -/*! You have to subclass KComposedPropertyInterface to override the behaviour of a property type.\n - In the constructor, you should create the child properties (if needed). - Then, you need to implement the functions concerning values.\n - - Example implementation of composed properties can be found in editors/ directory. -*/ -class KPROPERTY_EXPORT KComposedPropertyInterface -{ -public: - explicit KComposedPropertyInterface(KProperty *parent); - virtual ~KComposedPropertyInterface(); - - /*! This function modifies the child properties for parent value @a value. - It is called by @ref Property::setValue() when - the property is composed. - You don't have to modify the property value, it is done by Property class. - Note that when calling Property::setValue, you need to set - useComposedProperty (the third parameter) to false, or there will be infinite recursion. */ - virtual void setValue(KProperty *property, const QVariant &value, bool rememberOldValue) = 0; - - void childValueChangedInternal(KProperty *child, const QVariant &value, bool rememberOldValue) { - if (m_childValueChangedEnabled) - childValueChanged(child, value, rememberOldValue); - } - - void setChildValueChangedEnabled(bool set) { m_childValueChangedEnabled = set; } - -protected: - virtual void childValueChanged(KProperty *child, const QVariant &value, bool rememberOldValue) = 0; - - /*! This method emits the \a Set::propertyChanged() signal for all - sets our parent-property is registered in. */ - void emitPropertyChanged(); - bool m_childValueChangedEnabled : 1; -}; - -class KPROPERTY_EXPORT KComposedPropertyCreatorInterface -{ -public: - KComposedPropertyCreatorInterface(); - - virtual ~KComposedPropertyCreatorInterface(); - - virtual KComposedPropertyInterface* createComposedProperty(KProperty *parent) const = 0; -}; - //! An interface for editor widget creators. /*! Options can be set in the options attribute in order to customize widget creation process. Do this in the EditorCreatorInterface constructor. */ -class KPROPERTY_EXPORT KPropertyEditorCreatorInterface +class KPROPERTYWIDGETS_EXPORT KPropertyEditorCreatorInterface { public: KPropertyEditorCreatorInterface(); @@ -105,16 +61,16 @@ Options options; }; -class KPROPERTY_EXPORT KPropertyValuePainterInterface +class KPROPERTYWIDGETS_EXPORT KPropertyValuePainterInterface { public: KPropertyValuePainterInterface(); virtual ~KPropertyValuePainterInterface(); virtual void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const = 0; }; -class KPROPERTY_EXPORT KPropertyValueDisplayInterface +class KPROPERTYWIDGETS_EXPORT KPropertyValueDisplayInterface { public: KPropertyValueDisplayInterface(); @@ -125,9 +81,10 @@ { return value.toString(); } }; + //! Label widget that can be used for displaying text-based read-only items //! Used in LabelCreator. -class KPROPERTY_EXPORT KPropertyLabel : public QLabel +class KPROPERTYWIDGETS_EXPORT KPropertyLabel : public QLabel { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -149,7 +106,7 @@ //! Creator returning editor template -class KPROPERTY_EXPORT KPropertyEditorCreator : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyEditorCreator : public KPropertyEditorCreatorInterface, public KPropertyValueDisplayInterface, public KPropertyValuePainterInterface { @@ -181,36 +138,21 @@ typedef KPropertyEditorCreator KPropertyLabelCreator; -//! Creator returning composed property object -template -class KPROPERTY_EXPORT KComposedPropertyCreator : public KComposedPropertyCreatorInterface -{ -public: - KComposedPropertyCreator() : KComposedPropertyCreatorInterface() {} - virtual ~KComposedPropertyCreator() {} - - virtual ComposedProperty* createComposedProperty(KProperty *parent) const { - return new ComposedProperty(parent); - } -}; - -class KPROPERTY_EXPORT KPropertyFactory +class KPROPERTYWIDGETS_EXPORT KPropertyWidgetsFactory : public KPropertyFactory { public: - KPropertyFactory(); - virtual ~KPropertyFactory(); - QHash composedPropertyCreators() const; + KPropertyWidgetsFactory(); + virtual ~KPropertyWidgetsFactory(); + QHash editorCreators() const; QHash valuePainters() const; QHash valueDisplays() const; //! Adds editor creator @a creator for type @a type. //! The creator becomes owned by the factory. void addEditor(int type, KPropertyEditorCreatorInterface *creator); - void addComposedPropertyCreator( int type, KComposedPropertyCreatorInterface* creator ); - void addPainter(int type, KPropertyValuePainterInterface *painter); void addDisplay(int type, KPropertyValueDisplayInterface *display); @@ -222,25 +164,22 @@ protected: void addEditorInternal(int type, KPropertyEditorCreatorInterface *editor, bool own = true); - void addComposedPropertyCreatorInternal(int type, - KComposedPropertyCreatorInterface* creator, bool own = true); - //! Adds value painter @a painter for type @a type. //! The painter becomes owned by the factory. void addPainterInternal(int type, KPropertyValuePainterInterface *painter, bool own = true); //! Adds value-to-text converted @a painter for type @a type. //! The converter becomes owned by the factory. void addDisplayInternal(int type, KPropertyValueDisplayInterface *display, bool own = true); - + class Private; Private * const d; }; class KProperty; class KCustomProperty; -class KPROPERTY_EXPORT KPropertyFactoryManager : public QObject +class KPROPERTYWIDGETS_EXPORT KPropertyWidgetsFactoryManager : public KPropertyFactoryManager { Q_OBJECT public: @@ -256,7 +195,7 @@ QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; - + KComposedPropertyInterface* createComposedProperty(KProperty *parent); bool canConvertValueToText( int type ) const; @@ -266,15 +205,15 @@ QString convertValueToText( const KProperty* property ) const; //! Registers factory @a factory. It becomes owned by the manager. - void registerFactory(KPropertyFactory *factory); + void registerFactory(KPropertyWidgetsFactory *factory); KCustomProperty* createCustomProperty( KProperty *parent ); /*! \return a pointer to a factory manager instance.*/ - static KPropertyFactoryManager* self(); + static KPropertyWidgetsFactoryManager* self(); - KPropertyFactoryManager(); - ~KPropertyFactoryManager(); + KPropertyWidgetsFactoryManager(); + ~KPropertyWidgetsFactoryManager(); private: class Private; diff --git a/src/KPropertyFactory.cpp b/src/KPropertyWidgetsFactory.cpp copy from src/KPropertyFactory.cpp copy to src/KPropertyWidgetsFactory.cpp --- a/src/KPropertyFactory.cpp +++ b/src/KPropertyWidgetsFactory.cpp @@ -19,6 +19,7 @@ #include "KPropertyFactory.h" + #include "KDefaultPropertyFactory.h" #include "KPropertyEditorView.h" #include "KPropertyEditorDataModel.h" @@ -46,13 +47,13 @@ void KPropertyLabel::paintEvent( QPaintEvent * event ) { QLabel::paintEvent(event); - KPropertyFactory::paintTopGridLine(this); + KPropertyWidgetsFactory::paintTopGridLine(this); } //--------------- //! @internal -class KPropertyFactoryManager::Private +class KPropertyWidgetsFactoryManager::Private { public: Private() @@ -64,16 +65,16 @@ } QSet factories; - QHash composedPropertyCreators; QHash editorCreators; QHash valuePainters; QHash valueDisplays; + }; - Q_GLOBAL_STATIC(KPropertyFactoryManager, _self) + Q_GLOBAL_STATIC(KPropertyWidgetsFactoryManager, _self) //! @internal -class KPropertyFactory::Private +class KPropertyWidgetsFactory::Private { public: Private() @@ -86,47 +87,42 @@ qDeleteAll(valueDisplaysSet); } - QHash composedPropertyCreators; QHash editorCreators; QHash valuePainters; QHash valueDisplays; - QSet composedPropertyCreatorsSet; + QSet editorCreatorsSet; QSet valuePaintersSet; QSet valueDisplaysSet; + }; -KPropertyFactory::KPropertyFactory() +KPropertyWidgetsFactory::KPropertyWidgetsFactory() : d( new Private ) { } -KPropertyFactory::~KPropertyFactory() +KPropertyWidgetsFactory::~KPropertyWidgetsFactory() { delete d; } -QHash KPropertyFactory::composedPropertyCreators() const -{ - return d->composedPropertyCreators; -} - -QHash KPropertyFactory::editorCreators() const +QHash KPropertyWidgetsFactory::editorCreators() const { return d->editorCreators; } -QHash KPropertyFactory::valuePainters() const +QHash KPropertyWidgetsFactory::valuePainters() const { return d->valuePainters; } -QHash KPropertyFactory::valueDisplays() const +QHash KPropertyWidgetsFactory::valueDisplays() const { return d->valueDisplays; } -void KPropertyFactory::addEditor(int type, KPropertyEditorCreatorInterface *creator) +void KPropertyWidgetsFactory::addEditor(int type, KPropertyEditorCreatorInterface *creator) { addEditorInternal( type, creator, true ); if (dynamic_cast(creator)) { @@ -141,21 +137,7 @@ } } -void KPropertyFactory::addComposedPropertyCreator( int type, KComposedPropertyCreatorInterface* creator ) -{ - addComposedPropertyCreatorInternal( type, creator, true ); - if (dynamic_cast(creator)) { - addEditorInternal( type, dynamic_cast(creator), false/* !own*/ ); - } - if (dynamic_cast(creator)) { - addPainterInternal( type, dynamic_cast(creator), false/* !own*/ ); - } - if (dynamic_cast(creator)) { - addDisplayInternal( type, dynamic_cast(creator), false/* !own*/ ); - } -} - -void KPropertyFactory::addPainter(int type, KPropertyValuePainterInterface *painter) +void KPropertyWidgetsFactory::addPainter(int type, KPropertyValuePainterInterface *painter) { addPainterInternal(type, painter, true); if (dynamic_cast(painter)) { @@ -170,7 +152,7 @@ } } -void KPropertyFactory::addDisplay(int type, KPropertyValueDisplayInterface *display) +void KPropertyWidgetsFactory::addDisplay(int type, KPropertyValueDisplayInterface *display) { addDisplayInternal(type, display, true); if (dynamic_cast(display)) { @@ -185,36 +167,29 @@ } } -void KPropertyFactory::addEditorInternal(int type, KPropertyEditorCreatorInterface *editor, bool own) +void KPropertyWidgetsFactory::addEditorInternal(int type, KPropertyEditorCreatorInterface *editor, bool own) { if (own) d->editorCreatorsSet.insert(editor); d->editorCreators.insert(type, editor); } -void KPropertyFactory::addComposedPropertyCreatorInternal(int type, KComposedPropertyCreatorInterface* creator, bool own) -{ - if (own) - d->composedPropertyCreatorsSet.insert(creator); - d->composedPropertyCreators.insert(type, creator); -} - -void KPropertyFactory::addPainterInternal(int type, KPropertyValuePainterInterface *painter, bool own) +void KPropertyWidgetsFactory::addPainterInternal(int type, KPropertyValuePainterInterface *painter, bool own) { if (own) d->valuePaintersSet.insert(painter); d->valuePainters.insert(type, painter); } -void KPropertyFactory::addDisplayInternal(int type, KPropertyValueDisplayInterface *display, bool own) +void KPropertyWidgetsFactory::addDisplayInternal(int type, KPropertyValueDisplayInterface *display, bool own) { if (own) d->valueDisplaysSet.insert(display); d->valueDisplays.insert(type, display); } //static -void KPropertyFactory::paintTopGridLine(QWidget *widget) +void KPropertyWidgetsFactory::paintTopGridLine(QWidget *widget) { // paint top grid line QPainter p(widget); @@ -226,7 +201,7 @@ } //static -void KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(QWidget *widget, QWidget* parent, const QString& extraStyleSheet) +void KPropertyWidgetsFactory::setTopAndBottomBordersUsingStyleSheet(QWidget *widget, QWidget* parent, const QString& extraStyleSheet) { QColor gridLineColor( dynamic_cast(parent) ? dynamic_cast(parent)->gridLineColor() @@ -239,34 +214,28 @@ //------------ -KPropertyFactoryManager::KPropertyFactoryManager() - : QObject(0) +KPropertyWidgetsFactoryManager::KPropertyWidgetsFactoryManager() + : KPropertyFactoryManager() , d(new Private) { - setObjectName(QLatin1String("KPropertyFactoryManager")); + setObjectName(QLatin1String("KPropertyWidgetsFactoryManager")); registerFactory(new KDefaultPropertyFactory); } -KPropertyFactoryManager::~KPropertyFactoryManager() +KPropertyWidgetsFactoryManager::~KPropertyWidgetsFactoryManager() { delete d; } -KPropertyFactoryManager* KPropertyFactoryManager::self() +KPropertyWidgetsFactoryManager* KPropertyWidgetsFactoryManager::self() { return _self; } -void KPropertyFactoryManager::registerFactory(KPropertyFactory *factory) +void KPropertyWidgetsFactoryManager::registerFactory(KPropertyWidgetsFactory *factory) { d->factories.insert(factory); - QHash::ConstIterator composedPropertyCreatorsItEnd - = factory->composedPropertyCreators().constEnd(); - for (QHash::ConstIterator it( factory->composedPropertyCreators().constBegin() ); - it != composedPropertyCreatorsItEnd; ++it) - { - d->composedPropertyCreators.insert(it.key(), it.value()); - } + QHash::ConstIterator editorCreatorsItEnd = factory->editorCreators().constEnd(); for (QHash::ConstIterator it( factory->editorCreators().constBegin() ); @@ -290,12 +259,12 @@ } } -bool KPropertyFactoryManager::isEditorForTypeAvailable( int type ) const +bool KPropertyWidgetsFactoryManager::isEditorForTypeAvailable( int type ) const { return d->editorCreators.value(type); } -QWidget * KPropertyFactoryManager::createEditor( +QWidget * KPropertyWidgetsFactoryManager::createEditor( int type, QWidget *parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const { @@ -325,7 +294,7 @@ return w; } -bool KPropertyFactoryManager::paint( int type, QPainter * painter, +bool KPropertyWidgetsFactoryManager::paint( int type, QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const { const KPropertyValuePainterInterface *_painter = d->valuePainters.value(type); @@ -342,28 +311,22 @@ return true; } -bool KPropertyFactoryManager::canConvertValueToText( int type ) const +bool KPropertyWidgetsFactoryManager::canConvertValueToText( int type ) const { return d->valueDisplays.value(type) != 0; } -bool KPropertyFactoryManager::canConvertValueToText( const KProperty* property ) const +bool KPropertyWidgetsFactoryManager::canConvertValueToText( const KProperty* property ) const { return d->valueDisplays.value( property->type() ) != 0; } -QString KPropertyFactoryManager::convertValueToText( const KProperty* property ) const +QString KPropertyWidgetsFactoryManager::convertValueToText( const KProperty* property ) const { const KPropertyValueDisplayInterface *display = d->valueDisplays.value( property->type() ); return display ? display->displayTextForProperty( property ) : property->value().toString(); } -KComposedPropertyInterface* KPropertyFactoryManager::createComposedProperty(KProperty *parent) -{ - const KComposedPropertyCreatorInterface *creator = d->composedPropertyCreators.value( parent->type() ); - return creator ? creator->createComposedProperty(parent) : 0; -} - //! @todo #if 0 const int type = parent->type(); @@ -398,24 +361,6 @@ return 0; #endif -KComposedPropertyInterface::KComposedPropertyInterface(KProperty *parent) - : m_childValueChangedEnabled(true) -{ - Q_UNUSED(parent) -} - -KComposedPropertyInterface::~KComposedPropertyInterface() -{ -} - -KComposedPropertyCreatorInterface::KComposedPropertyCreatorInterface() -{ -} - -KComposedPropertyCreatorInterface::~KComposedPropertyCreatorInterface() -{ -} - KPropertyEditorCreatorInterface::KPropertyEditorCreatorInterface() { } @@ -444,3 +389,4 @@ KPropertyValueDisplayInterface::~KPropertyValueDisplayInterface() { } + diff --git a/src/config-kproperty.h.cmake b/src/config-kproperty.h.cmake --- a/src/config-kproperty.h.cmake +++ b/src/config-kproperty.h.cmake @@ -31,4 +31,8 @@ //! @brief Defined if unfinished features of KProperty are enabled #cmakedefine KPROPERTY_UNFINISHED +//! @def KPROPERTY_WIDGET +//! @brief Defined if QtWidgets components of KProperty are enabled +#cmakedefine KPROPERTY_WIDGET + #endif diff --git a/src/editors/CMakeLists.txt b/src/editors/CMakeLists.txt --- a/src/editors/CMakeLists.txt +++ b/src/editors/CMakeLists.txt @@ -34,13 +34,13 @@ install( FILES ${kproperty_editors_HEADERS} - DESTINATION ${INCLUDE_INSTALL_DIR}/KProperty + DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyWidgets COMPONENT Devel ) install( FILES ${kproperty_editors_FORWARDING_HEADERS} - DESTINATION ${INCLUDE_INSTALL_DIR}/KProperty + DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyWidgets COMPONENT Devel ) diff --git a/src/editors/KPropertyStringEditor.h b/src/editors/KPropertyStringEditor.h --- a/src/editors/KPropertyStringEditor.h +++ b/src/editors/KPropertyStringEditor.h @@ -22,11 +22,11 @@ #ifndef KPROPERTY_STRINGEDIT_H #define KPROPERTY_STRINGEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include -class KPROPERTY_EXPORT KPropertyStringEditor : public QLineEdit +class KPROPERTYWIDGETS_EXPORT KPropertyStringEditor : public QLineEdit { Q_OBJECT Q_PROPERTY(QString value READ value WRITE setValue USER true) @@ -50,7 +50,7 @@ bool m_slotTextChangedEnabled; }; -class KPROPERTY_EXPORT KPropertyStringDelegate : public KPropertyEditorCreatorInterface +class KPROPERTYWIDGETS_EXPORT KPropertyStringDelegate : public KPropertyEditorCreatorInterface { public: KPropertyStringDelegate() {} diff --git a/src/editors/booledit.h b/src/editors/booledit.h --- a/src/editors/booledit.h +++ b/src/editors/booledit.h @@ -32,7 +32,7 @@ //! A bool editor supporting two states: true and false. /*! For null values, false is displayed. */ -class KPROPERTY_EXPORT KPropertyBoolEditor : public QToolButton +class KPROPERTYWIDGETS_EXPORT KPropertyBoolEditor : public QToolButton { Q_OBJECT Q_PROPERTY(bool value READ value WRITE setValue USER true) @@ -70,7 +70,7 @@ //! A bool editor supporting three states: true, false and null. /*! The editor is implemented as a drop-down list. */ -class KPROPERTY_EXPORT KPropertyThreeStateBoolEditor : public KPropertyComboBoxEditor +class KPROPERTYWIDGETS_EXPORT KPropertyThreeStateBoolEditor : public KPropertyComboBoxEditor { Q_OBJECT // Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -86,7 +86,7 @@ void commitData( QWidget * editor ); }; -class KPROPERTY_EXPORT KPropertyBoolDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyBoolDelegate : public KPropertyEditorCreatorInterface, public KPropertyValuePainterInterface { public: diff --git a/src/editors/coloredit.h b/src/editors/coloredit.h --- a/src/editors/coloredit.h +++ b/src/editors/coloredit.h @@ -20,14 +20,15 @@ #ifndef KPROPERTY_COLOREDIT_H #define KPROPERTY_COLOREDIT_H -#include "KPropertyFactory.h" +#include "kpropertywidgets_export.h" +#include "KPropertyWidgetsFactory.h" #include //! Color combo box //! @todo enable transparency selection //! @todo add transparency option //! @todo reimplement view using KColorCells -class KPROPERTY_EXPORT KPropertyColorComboEditor : public KColorCombo +class KPROPERTYWIDGETS_EXPORT KPropertyColorComboEditor : public KColorCombo { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -49,7 +50,7 @@ void slotValueChanged(const QColor&); }; -class KPROPERTY_EXPORT KPropertyColorComboDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyColorComboDelegate : public KPropertyEditorCreatorInterface, public KPropertyValuePainterInterface { public: diff --git a/src/editors/combobox.h b/src/editors/combobox.h --- a/src/editors/combobox.h +++ b/src/editors/combobox.h @@ -22,11 +22,12 @@ #ifndef KPROPERTY_COMBOBOX_H #define KPROPERTY_COMBOBOX_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" +#include "kpropertywidgets_export.h" #include -class KPROPERTY_EXPORT KPropertyComboBoxEditor : public QComboBox +class KPROPERTYWIDGETS_EXPORT KPropertyComboBoxEditor : public QComboBox { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -87,7 +88,7 @@ Options m_options; }; -class KPROPERTY_EXPORT KPropertyComboBoxDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyComboBoxDelegate : public KPropertyEditorCreatorInterface, public KPropertyValueDisplayInterface { public: diff --git a/src/editors/combobox.cpp b/src/editors/combobox.cpp --- a/src/editors/combobox.cpp +++ b/src/editors/combobox.cpp @@ -22,7 +22,8 @@ #include "combobox.h" #include "KPropertyEditorDataModel.h" #include "KPropertyEditorView.h" -#include "kproperty_debug.h" +#include "kpropertywidgets_debug.h" +#include "KPropertyWidgetsFactory.h" #include #include @@ -105,7 +106,7 @@ bool KPropertyComboBoxEditor::listDataKeysAvailable() const { if (m_listData.keys.isEmpty()) { - kprWarning() << "property listData not available!"; + kprwWarning() << "property listData not available!"; return false; } return true; @@ -143,13 +144,13 @@ setCurrentIndex(-1); setEditText(value.toString()); } - kprWarning() << "NO SUCH KEY:" << value.toString() + kprwWarning() << "NO SUCH KEY:" << value.toString() << "property=" << objectName(); } else { QStringList list; for (int i = 0; i < count(); i++) list += itemText(i); - kprWarning() << "NO SUCH INDEX WITHIN COMBOBOX:" << idx + kprwWarning() << "NO SUCH INDEX WITHIN COMBOBOX:" << idx << "count=" << count() << "value=" << value.toString() << "property=" << objectName() << "\nActual combobox contents" << list; @@ -218,7 +219,7 @@ void KPropertyComboBoxEditor::paintEvent( QPaintEvent * event ) { QComboBox::paintEvent(event); - KPropertyFactory::paintTopGridLine(this); + KPropertyWidgetsFactory::paintTopGridLine(this); } /* diff --git a/src/editors/cursoredit.h b/src/editors/cursoredit.h --- a/src/editors/cursoredit.h +++ b/src/editors/cursoredit.h @@ -24,7 +24,7 @@ #include "combobox.h" -class KPROPERTY_EXPORT KPropertyCursorEditor : public KPropertyComboBoxEditor +class KPROPERTYWIDGETS_EXPORT KPropertyCursorEditor : public KPropertyComboBoxEditor { Q_OBJECT Q_PROPERTY(QCursor value READ cursorValue WRITE setCursorValue USER true) @@ -37,7 +37,7 @@ virtual void setCursorValue(const QCursor &value); }; -class KPROPERTY_EXPORT KPropertyCursorDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyCursorDelegate : public KPropertyEditorCreatorInterface, public KPropertyValuePainterInterface { public: diff --git a/src/editors/dateedit.h b/src/editors/dateedit.h --- a/src/editors/dateedit.h +++ b/src/editors/dateedit.h @@ -22,10 +22,10 @@ #ifndef KPROPERTY_DATEEDIT_H #define KPROPERTY_DATEEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include -class KPROPERTY_EXPORT KPropertyDateEditor : public QDateEdit +class KPROPERTYWIDGETS_EXPORT KPropertyDateEditor : public QDateEdit { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -49,7 +49,7 @@ void onDateChanged(); }; -class KPROPERTY_EXPORT KPropertyDateDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyDateDelegate : public KPropertyEditorCreatorInterface, public KPropertyValueDisplayInterface { public: diff --git a/src/editors/dateedit.cpp b/src/editors/dateedit.cpp --- a/src/editors/dateedit.cpp +++ b/src/editors/dateedit.cpp @@ -62,7 +62,7 @@ void KPropertyDateEditor::paintEvent(QPaintEvent* event) { QDateEdit::paintEvent(event); - KPropertyFactory::paintTopGridLine(this); + KPropertyWidgetsFactory::paintTopGridLine(this); } diff --git a/src/editors/datetimeedit.h b/src/editors/datetimeedit.h --- a/src/editors/datetimeedit.h +++ b/src/editors/datetimeedit.h @@ -22,10 +22,10 @@ #ifndef KPROPERTY_DATETIMEEDIT_H #define KPROPERTY_DATETIMEEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include -class KPROPERTY_EXPORT KPropertyDateTimeEditor : public QDateTimeEdit +class KPROPERTYWIDGETS_EXPORT KPropertyDateTimeEditor : public QDateTimeEdit { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -49,7 +49,7 @@ void onDateTimeChanged(); }; -class KPROPERTY_EXPORT KPropertyDateTimeDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyDateTimeDelegate : public KPropertyEditorCreatorInterface, public KPropertyValueDisplayInterface { public: diff --git a/src/editors/datetimeedit.cpp b/src/editors/datetimeedit.cpp --- a/src/editors/datetimeedit.cpp +++ b/src/editors/datetimeedit.cpp @@ -22,6 +22,7 @@ #include "datetimeedit.h" #include "KPropertyEditorDataModel.h" +#include "KPropertyWidgetsFactory.h" #include @@ -64,7 +65,7 @@ void KPropertyDateTimeEditor::paintEvent(QPaintEvent* event) { QDateTimeEdit::paintEvent(event); - KPropertyFactory::paintTopGridLine(this); + KPropertyWidgetsFactory::paintTopGridLine(this); } diff --git a/src/editors/dummywidget.h b/src/editors/dummywidget.h --- a/src/editors/dummywidget.h +++ b/src/editors/dummywidget.h @@ -25,7 +25,7 @@ #include -class KPROPERTY_EXPORT KPropertyDummyWidget: public Widget +class KPROPERTYWIDGETS_EXPORT KPropertyDummyWidget: public Widget { Q_OBJECT diff --git a/src/editors/fontedit.h b/src/editors/fontedit.h --- a/src/editors/fontedit.h +++ b/src/editors/fontedit.h @@ -22,10 +22,10 @@ #ifndef KPROPERTY_FONTEDIT_H #define KPROPERTY_FONTEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" -class KPROPERTY_EXPORT KPropertyFontDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyFontDelegate : public KPropertyEditorCreatorInterface, public KPropertyValuePainterInterface { public: diff --git a/src/editors/linestyleedit.h b/src/editors/linestyleedit.h --- a/src/editors/linestyleedit.h +++ b/src/editors/linestyleedit.h @@ -20,14 +20,14 @@ #ifndef KPROPERTY_LINESTYLEEDIT_H #define KPROPERTY_LINESTYLEEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include "KPropertyLineStyleSelector_p.h" //! Line style combo box (Property::LineStyle, equivalent of Qt::PenStyle) //! @todo enable transparency selection //! @todo add transparency option //! @todo reimplement view using KColorCells -class KPROPERTY_EXPORT KPropertyLineStyleComboEditor : public KPropertyLineStyleSelector +class KPROPERTYWIDGETS_EXPORT KPropertyLineStyleComboEditor : public KPropertyLineStyleSelector { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -49,7 +49,7 @@ void slotValueChanged(int index); }; -class KPROPERTY_EXPORT KPropertyLineStyleComboDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyLineStyleComboDelegate : public KPropertyEditorCreatorInterface, public KPropertyValuePainterInterface { public: diff --git a/src/editors/pixmapedit.h b/src/editors/pixmapedit.h --- a/src/editors/pixmapedit.h +++ b/src/editors/pixmapedit.h @@ -22,15 +22,15 @@ #ifndef KPROPERTY_PIXMAPEDIT_H #define KPROPERTY_PIXMAPEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include #include class QLabel; class QPushButton; -class KPROPERTY_EXPORT KPropertyPixmapEditor : public QWidget +class KPROPERTYWIDGETS_EXPORT KPropertyPixmapEditor : public QWidget { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -71,7 +71,7 @@ QPixmap m_previewPixmap; }; -class KPROPERTY_EXPORT KPropertyPixmapDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyPixmapDelegate : public KPropertyEditorCreatorInterface, public KPropertyValuePainterInterface { public: diff --git a/src/editors/pointedit.h b/src/editors/pointedit.h --- a/src/editors/pointedit.h +++ b/src/editors/pointedit.h @@ -22,9 +22,9 @@ #ifndef KPROPERTY_POINTEDIT_H #define KPROPERTY_POINTEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" -class KPROPERTY_EXPORT KPointComposedProperty : public KComposedPropertyInterface +class KPROPERTYWIDGETS_EXPORT KPointComposedProperty : public KComposedPropertyInterface { public: explicit KPointComposedProperty(KProperty *parent); @@ -36,7 +36,7 @@ const QVariant &value, bool rememberOldValue); }; -class KPROPERTY_EXPORT KPropertyPointDelegate : public KPropertyLabelCreator, +class KPROPERTYWIDGETS_EXPORT KPropertyPointDelegate : public KPropertyLabelCreator, public KComposedPropertyCreator { public: diff --git a/src/editors/pointfedit.h b/src/editors/pointfedit.h --- a/src/editors/pointfedit.h +++ b/src/editors/pointfedit.h @@ -23,9 +23,9 @@ #ifndef KPROPERTY_POINTFEDIT_H #define KPROPERTY_POINTFEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" -class KPROPERTY_EXPORT KPointFComposedProperty : public KComposedPropertyInterface +class KPROPERTYWIDGETS_EXPORT KPointFComposedProperty : public KComposedPropertyInterface { public: explicit KPointFComposedProperty(KProperty *parent); @@ -37,7 +37,7 @@ const QVariant &value, bool rememberOldValue); }; -class KPROPERTY_EXPORT KPropertyPointFDelegate : public KPropertyLabelCreator, +class KPROPERTYWIDGETS_EXPORT KPropertyPointFDelegate : public KPropertyLabelCreator, public KComposedPropertyCreator { public: diff --git a/src/editors/rectedit.h b/src/editors/rectedit.h --- a/src/editors/rectedit.h +++ b/src/editors/rectedit.h @@ -20,9 +20,9 @@ #ifndef KPROPERTY_RECTEDIT_H #define KPROPERTY_RECTEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" -class KPROPERTY_EXPORT KRectComposedProperty : public KComposedPropertyInterface +class KPROPERTYWIDGETS_EXPORT KRectComposedProperty : public KComposedPropertyInterface { public: explicit KRectComposedProperty(KProperty *parent); @@ -34,7 +34,7 @@ const QVariant &value, bool rememberOldValue); }; -class KPROPERTY_EXPORT KPropertyRectDelegate : public KPropertyLabelCreator, +class KPROPERTYWIDGETS_EXPORT KPropertyRectDelegate : public KPropertyLabelCreator, public KComposedPropertyCreator { public: diff --git a/src/editors/sizeedit.h b/src/editors/sizeedit.h --- a/src/editors/sizeedit.h +++ b/src/editors/sizeedit.h @@ -22,9 +22,9 @@ #ifndef KPROPERTY_SIZEEDIT_H #define KPROPERTY_SIZEEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" -class KPROPERTY_EXPORT KSizeComposedProperty : public KComposedPropertyInterface +class KPROPERTYWIDGETS_EXPORT KSizeComposedProperty : public KComposedPropertyInterface { public: explicit KSizeComposedProperty(KProperty *parent); @@ -36,7 +36,7 @@ const QVariant &value, bool rememberOldValue); }; -class KPROPERTY_EXPORT KPropertySizeDelegate : public KPropertyLabelCreator, +class KPROPERTYWIDGETS_EXPORT KPropertySizeDelegate : public KPropertyLabelCreator, public KComposedPropertyCreator { public: diff --git a/src/editors/sizefedit.h b/src/editors/sizefedit.h --- a/src/editors/sizefedit.h +++ b/src/editors/sizefedit.h @@ -22,9 +22,9 @@ #ifndef KPROPERTY_SIZEFEDIT_H #define KPROPERTY_SIZEFEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" -class KPROPERTY_EXPORT KSizeFComposedProperty : public KComposedPropertyInterface +class KPROPERTYWIDGETS_EXPORT KSizeFComposedProperty : public KComposedPropertyInterface { public: explicit KSizeFComposedProperty(KProperty *parent); @@ -36,7 +36,7 @@ const QVariant &value, bool rememberOldValue); }; -class KPROPERTY_EXPORT KPropertySizeFDelegate : public KPropertyLabelCreator, +class KPROPERTYWIDGETS_EXPORT KPropertySizeFDelegate : public KPropertyLabelCreator, public KComposedPropertyCreator { public: diff --git a/src/editors/sizepolicyedit.h b/src/editors/sizepolicyedit.h --- a/src/editors/sizepolicyedit.h +++ b/src/editors/sizepolicyedit.h @@ -20,9 +20,9 @@ #ifndef KPROPERTY_SIZEPOLICYEDIT_H #define KPROPERTY_SIZEPOLICYEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" -class KPROPERTY_EXPORT KSizePolicyComposedProperty : public KComposedPropertyInterface +class KPROPERTYWIDGETS_EXPORT KSizePolicyComposedProperty : public KComposedPropertyInterface { public: explicit KSizePolicyComposedProperty(KProperty *parent); @@ -34,7 +34,7 @@ const QVariant &value, bool rememberOldValue); }; -class KPROPERTY_EXPORT KPropertySizePolicyDelegate : public KPropertyLabelCreator, +class KPROPERTYWIDGETS_EXPORT KPropertySizePolicyDelegate : public KPropertyLabelCreator, public KComposedPropertyCreator { public: diff --git a/src/editors/spinbox.h b/src/editors/spinbox.h --- a/src/editors/spinbox.h +++ b/src/editors/spinbox.h @@ -22,16 +22,16 @@ #ifndef KPROPERTY_SPINBOX_H #define KPROPERTY_SPINBOX_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include #include //! A delegate supporting Int and UInt types /*! Note that due to KIntNumInput limitations, for UInt the maximum value is INT_MAX, not UINT_MAX. */ -class KPROPERTY_EXPORT KPropertyIntSpinBox : public QSpinBox +class KPROPERTYWIDGETS_EXPORT KPropertyIntSpinBox : public QSpinBox { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -62,7 +62,7 @@ }; //! Double editor -class KPROPERTY_EXPORT KPropertyDoubleSpinBox : public QDoubleSpinBox +class KPROPERTYWIDGETS_EXPORT KPropertyDoubleSpinBox : public QDoubleSpinBox { Q_OBJECT Q_PROPERTY(double value READ value WRITE setValue USER true) @@ -97,7 +97,7 @@ }; //! A delegate supporting Int, UInt, LongLong and ULongLong types -class KPROPERTY_EXPORT KPropertyIntSpinBoxDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyIntSpinBoxDelegate : public KPropertyEditorCreatorInterface, public KPropertyValueDisplayInterface { public: @@ -109,7 +109,7 @@ const QStyleOptionViewItem & option, const QModelIndex & index ) const; }; -class KPROPERTY_EXPORT KPropertyDoubleSpinBoxDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyDoubleSpinBoxDelegate : public KPropertyEditorCreatorInterface, public KPropertyValueDisplayInterface { public: diff --git a/src/editors/spinbox.cpp b/src/editors/spinbox.cpp --- a/src/editors/spinbox.cpp +++ b/src/editors/spinbox.cpp @@ -25,7 +25,8 @@ #include "KPropertyEditorDataModel.h" #include "KPropertyEditorView.h" #include "KPropertyUnit_p.h" -#include "kproperty_debug.h" +#include "KPropertyWidgetsFactory.h" +#include "kpropertywidgets_debug.h" #include #include @@ -71,7 +72,7 @@ // kprDebug() << parent->font().pointSize(); setFrame(true); QString css = cssForSpinBox("QSpinBox", font(), itemHeight); - KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); + KPropertyWidgetsFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); setStyleSheet(css); QVariant minVal(prop->option("min", m_unsigned ? 0 : -INT_MAX)); @@ -99,7 +100,7 @@ { int v( value.toInt() ); if (m_unsigned && v<0) { - kprWarning() << "could not assign negative value" << v << "- assigning 0"; + kprwWarning() << "could not assign negative value" << v << "- assigning 0"; v = 0; } QSpinBox::setValue(v); @@ -150,7 +151,7 @@ ).arg(itemHeight/2).arg(itemHeight - itemHeight/2) );*/ QString css = cssForSpinBox("QDoubleSpinBox", font(), itemHeight); - KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); + KPropertyWidgetsFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); setStyleSheet(css); QVariant minVal(prop->option("min")); diff --git a/src/editors/stringlistedit.h b/src/editors/stringlistedit.h --- a/src/editors/stringlistedit.h +++ b/src/editors/stringlistedit.h @@ -28,7 +28,7 @@ class QLineEdit; class QPushButton; -class KPROPERTY_EXPORT KPropertyStringListEditor : public Widget +class KPROPERTYWIDGETS_EXPORT KPropertyStringListEditor : public Widget { Q_OBJECT diff --git a/src/editors/symbolcombo.h b/src/editors/symbolcombo.h --- a/src/editors/symbolcombo.h +++ b/src/editors/symbolcombo.h @@ -26,7 +26,7 @@ class QLineEdit; class QPushButton; -class KPROPERTY_EXPORT KPropertySymbolComboEditor : public Widget +class KPROPERTYWIDGETS_EXPORT KPropertySymbolComboEditor : public Widget { Q_OBJECT diff --git a/src/editors/timeedit.h b/src/editors/timeedit.h --- a/src/editors/timeedit.h +++ b/src/editors/timeedit.h @@ -22,10 +22,10 @@ #ifndef KPROPERTY_TIMEEDIT_H #define KPROPERTY_TIMEEDIT_H -#include "KPropertyFactory.h" +#include "KPropertyWidgetsFactory.h" #include -class KPROPERTY_EXPORT KPropertyTimeEditor : public QTimeEdit +class KPROPERTYWIDGETS_EXPORT KPropertyTimeEditor : public QTimeEdit { Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue USER true) @@ -49,7 +49,7 @@ void onTimeChanged(); }; -class KPROPERTY_EXPORT KPropertyTimeDelegate : public KPropertyEditorCreatorInterface, +class KPROPERTYWIDGETS_EXPORT KPropertyTimeDelegate : public KPropertyEditorCreatorInterface, public KPropertyValueDisplayInterface { public: diff --git a/src/editors/timeedit.cpp b/src/editors/timeedit.cpp --- a/src/editors/timeedit.cpp +++ b/src/editors/timeedit.cpp @@ -60,7 +60,7 @@ void KPropertyTimeEditor::paintEvent(QPaintEvent* event) { QTimeEdit::paintEvent(event); - KPropertyFactory::paintTopGridLine(this); + KPropertyWidgetsFactory::paintTopGridLine(this); } diff --git a/src/editors/urledit.h b/src/editors/urledit.h --- a/src/editors/urledit.h +++ b/src/editors/urledit.h @@ -25,7 +25,7 @@ class KUrlRequester; -class KPROPERTY_EXPORT KPropertyUrlEditor : public Widget +class KPROPERTYWIDGETS_EXPORT KPropertyUrlEditor : public Widget { Q_PROPERTY(QVariant value READ value WRITE setValue USER true) Q_OBJECT diff --git a/src/editors/utils.h b/src/editors/utils.h --- a/src/editors/utils.h +++ b/src/editors/utils.h @@ -20,7 +20,7 @@ #ifndef KPROPERTY_EDITORS_UTILS_H #define KPROPERTY_EDITORS_UTILS_H -#include "kproperty_export.h" +#include "kpropertycore_export.h" #include @@ -30,7 +30,7 @@ { //! Sets up a "..." button with fine-tuned settings. -KPROPERTY_EXPORT void setupDotDotDotButton(QPushButton *button, +KPROPERTYCORE_EXPORT void setupDotDotDotButton(QPushButton *button, const QString& toolTip = QString(), const QString& whatsThis = QString()); } diff --git a/src/editors/utils.cpp b/src/editors/utils.cpp --- a/src/editors/utils.cpp +++ b/src/editors/utils.cpp @@ -22,7 +22,7 @@ #include #include -KPROPERTY_EXPORT void KPropertyUtils::setupDotDotDotButton(QPushButton *button, const QString& toolTip, const QString& whatsThis) +KPROPERTYCORE_EXPORT void KPropertyUtils::setupDotDotDotButton(QPushButton *button, const QString& toolTip, const QString& whatsThis) { button->setText(QObject::tr("...", "Three dots for 'Insert image from file' button")); if (!toolTip.isEmpty()) diff --git a/src/KDefaultPropertyFactory.h b/src/kpropertywidgets_debug.h copy from src/KDefaultPropertyFactory.h copy to src/kpropertywidgets_debug.h --- a/src/KDefaultPropertyFactory.h +++ b/src/kpropertywidgets_debug.h @@ -1,5 +1,5 @@ /* This file is part of the KDE project - Copyright (C) 2008 Jarosław Staniek + Copyright (C) 2015 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -17,16 +17,14 @@ * Boston, MA 02110-1301, USA. */ -#ifndef KDEFAULTPROPERTYFACTORY_H -#define KDEFAULTPROPERTYFACTORY_H +#ifndef KPROPERTYWIDGETS_DEBUG_H +#define KPROPERTYWIDGETS_DEBUG_H -#include "KPropertyFactory.h" +#include +Q_DECLARE_LOGGING_CATEGORY(KPROPERTYW_LOG) -class KDefaultPropertyFactory : public KPropertyFactory -{ -public: - KDefaultPropertyFactory(); - ~KDefaultPropertyFactory(); -}; +#define kprwDebug(...) qCDebug(KPROPERTYW_LOG, __VA_ARGS__) +#define kprwWarning(...) qCWarning(KPROPERTYW_LOG, __VA_ARGS__) +#define kprwCritical(...) qCCritical(KPROPERTYW_LOG, __VA_ARGS__) #endif diff --git a/src/KDefaultPropertyFactory.h b/src/kpropertywidgets_debug.cpp copy from src/KDefaultPropertyFactory.h copy to src/kpropertywidgets_debug.cpp --- a/src/KDefaultPropertyFactory.h +++ b/src/kpropertywidgets_debug.cpp @@ -1,5 +1,5 @@ /* This file is part of the KDE project - Copyright (C) 2008 Jarosław Staniek + Copyright (C) 2015 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -17,16 +17,6 @@ * Boston, MA 02110-1301, USA. */ -#ifndef KDEFAULTPROPERTYFACTORY_H -#define KDEFAULTPROPERTYFACTORY_H +#include "kpropertywidgets_debug.h" +Q_LOGGING_CATEGORY(KPROPERTYW_LOG, "org.kde.kproperty.widgets") -#include "KPropertyFactory.h" - -class KDefaultPropertyFactory : public KPropertyFactory -{ -public: - KDefaultPropertyFactory(); - ~KDefaultPropertyFactory(); -}; - -#endif