diff --git a/CMakeLists.txt b/CMakeLists.txt index e93a7c8..dd0f3f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,60 +1,60 @@ -if(EXISTS "/usr/lib/qt5/qml/Sailfish/Silica/SilicaGridView.qml") #SailfishOS +if(EXISTS "/usr/include/sailfishapp/sailfishapp.h") #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 find_package(ECM 1.8.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) if(POLICY CMP0063) # Honor visibility properties for all target types (since cmake 3.3) cmake_policy(SET CMP0063 OLD) endif() include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(ECMPackageConfigHelpers) include(ECMPoQmTools) include(ECMSetupVersion) include(ECMOptionalAddSubdirectory) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings) include(KDECMakeSettings) include(FeatureSummary) include(GenerateExportHeader) include(MacroLogFeature) include(KPropertyMacros) simple_option(KPROPERTY_WIDGETS "Build the QtWidget components of KProperty" ON) -set(KPROPERTY_VERSION "2.96.0") # Update this +set(KPROPERTY_VERSION "2.97.0") # Update this # Dependencies set(REQUIRED_QT_VERSION "5.2.0") 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() add_unfinished_features_option() add_pc_file(KPropertyCore) add_pc_file(KPropertyWidgets) add_subdirectory(src) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) macro_display_feature_log() diff --git a/KPropertyCore.pc.cmake b/KPropertyCore.pc.cmake index 71020a3..fe44a1d 100644 --- a/KPropertyCore.pc.cmake +++ b/KPropertyCore.pc.cmake @@ -1,12 +1,12 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: KPropertyCore -Description: A property editing framework with editor (core) +Description: A property editing framework (core library) Version: @KPROPERTY_VERSION@ URL: https://community.kde.org/KProperty Requires: Qt5Core Libs: -L${libdir} Cflags: -I${includedir} diff --git a/KPropertyWidgets.pc.cmake b/KPropertyWidgets.pc.cmake index 7ff30c1..24f26d0 100644 --- a/KPropertyWidgets.pc.cmake +++ b/KPropertyWidgets.pc.cmake @@ -1,12 +1,12 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: KPropertyWidgets -Description: A property editing framework with edito (widgets) +Description: A property editing framework with editor (Qt Widgets library) Version: @KPROPERTY_VERSION@ URL: https://community.kde.org/KProperty Requires: KPropertyCore Qt5Core Qt5Gui KF5WidgetsAddons KF5GuiAddons Libs: -L${libdir} Cflags: -I${includedir} diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 0863058..00244bb 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,22 +1,22 @@ remove_definitions( -DQT_NO_KEYWORDS -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_CAST_FROM_ASCII -DQT_USE_QSTRINGBUILDER ) set(FILES_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) add_definitions( -DFILES_OUTPUT_DIR=\"${FILES_OUTPUT_DIR}\" ) include_directories( ${CMAKE_BINARY_DIR}/src/kproperty ${CMAKE_BINARY_DIR}/src/editors/kproperty ) include(ECMAddTests) find_package(Qt5Test REQUIRED) -add_subdirectory(headers) +#TODO fix add_subdirectory(headers) diff --git a/autotests/headers/HeadersTestInclude.cmake b/autotests/headers/HeadersTestInclude.cmake index 32cf583..1d9aa38 100644 --- a/autotests/headers/HeadersTestInclude.cmake +++ b/autotests/headers/HeadersTestInclude.cmake @@ -1,4 +1,5 @@ set(REQUIRED_QT_VERSION "5.2.0") find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets) find_package(KF5 5.7.0 REQUIRED Config CoreAddons WidgetsAddons GuiAddons) -find_package(KProperty REQUIRED) +find_package(KPropertyCore ${KPROPERTY_VERSION} REQUIRED) +find_package(KPropertyWidgets ${KPROPERTY_VERSION} REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4101ac8..dd1d487 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,246 +1,242 @@ # Options -# simple_option(KPROPERTY_...... "....." OFF) configure_file(config-kproperty.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kproperty.h) set(kpropertycore_LIB_SRCS KProperty.cpp KPropertySet.cpp KPropertyUnit_p.cpp KPropertyFactory.cpp kproperty_debug.cpp ) 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 + 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 + + kproperty_debug.cpp # needed here too + KPropertyWidgetsFactory.cpp + KDefaultPropertyFactory.cpp + KPropertyEditorView.cpp + KPropertyEditorDataModel.cpp + KPropertyUtils.cpp + KPropertyLineStyleSelector_p.cpp + KPropertyLineStyleModel_p.cpp + KPropertyLineStyleItemDelegate_p.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 + ecm_create_qm_loader(kpropertywidgets_LIB_SRCS kpropertywidgets_qt) + + set(kpropertywidgets_INCLUDE_DIRS + ${CMAKE_CURRENT_BINARY_DIR}/editors ) endif() -set(kproperty_INCLUDE_DIRS - ${CMAKE_CURRENT_BINARY_DIR}/kproperty - ${CMAKE_CURRENT_BINARY_DIR}/editors +set(kpropertycore_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/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_include_directories(KPropertyCore - PUBLIC "$" + PUBLIC "$" INTERFACE "$" - PRIVATE editors ) set_target_properties(KPropertyCore PROPERTIES VERSION 1.0 SOVERSION 1.0.0 EXPORT_NAME KPropertyCore ) if(KPROPERTY_WIDGETS) add_library(KPropertyWidgets SHARED ${kpropertywidgets_LIB_SRCS}) target_link_libraries(KPropertyWidgets - KPropertyCore + KPropertyCore KF5::WidgetsAddons KF5::GuiAddons ) generate_export_header(KPropertyWidgets) target_include_directories(KPropertyWidgets - PUBLIC "$" - INTERFACE "$" - PRIVATE editors + PUBLIC "$" + INTERFACE "$" + PRIVATE editors ) set_target_properties(KPropertyWidgets - PROPERTIES VERSION 1.0 - SOVERSION 1.0.0 - EXPORT_NAME 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_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 + VARIABLE_PREFIX KPROPERTYCORE VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kproperty_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KPropertyCoreConfigVersion.cmake" ) ecm_configure_package_config_file( "${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}/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) - + DESTINATION "${CMAKECONFIG_CORE_INSTALL_DIR}" + FILE KPropertyCoreTargets.cmake) + if(KPROPERTY_WIDGETS) - set(CMAKECONFIG_WIDGETS_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KPropertyWidgets") + 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" + VARIABLE_PREFIX KPROPERTYWIDGETS + 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}" + "${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) + "${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) + 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 KPropertyCore LIB_NAME KPropertyCore DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR}/KPropertyCore ) - -if(KPROPERTY_WIDGETS) + +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 + BASE_NAME KPropertyWidgets + LIB_NAME KPropertyWidgets + DEPS "widgets KPropertyCore" + 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(kpropertycore_FORWARDING_HEADERS REQUIRED_HEADERS kpropertycore_HEADERS ORIGINAL CAMELCASE HEADER_NAMES KProperty KPropertySet KPropertyFactory ) install( FILES ${kpropertycore_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyCore COMPONENT Devel ) install( FILES ${kpropertycore_FORWARDING_HEADERS} ${PROJECT_BINARY_DIR}/src/kpropertycore_export.h ${PROJECT_BINARY_DIR}/src/config-kproperty.h DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyCore COMPONENT Devel ) -if(KPROPERTY_WIDGETS) +if(KPROPERTY_WIDGETS) ecm_generate_headers(kpropertywidgets_FORWARDING_HEADERS - REQUIRED_HEADERS kpropertywidgets_HEADERS - ORIGINAL CAMELCASE - HEADER_NAMES - KPropertyWidgetsFactory - KPropertyUtils - KPropertyEditorView - KPropertyEditorDataModel + REQUIRED_HEADERS kpropertywidgets_HEADERS + ORIGINAL CAMELCASE + HEADER_NAMES + KPropertyWidgetsFactory + KPropertyUtils + KPropertyEditorView + KPropertyEditorDataModel ) install( - FILES - ${kpropertywidgets_HEADERS} - DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyWidgets - COMPONENT Devel + 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 + FILES + ${kpropertywidgets_FORWARDING_HEADERS} + ${PROJECT_BINARY_DIR}/src/kpropertywidgets_export.h + DESTINATION ${INCLUDE_INSTALL_DIR}/KPropertyWidgets + COMPONENT Devel ) endif() enable_testing() diff --git a/src/KDefaultPropertyFactory.cpp b/src/KDefaultPropertyFactory.cpp index a137a95..fa9b152 100644 --- a/src/KDefaultPropertyFactory.cpp +++ b/src/KDefaultPropertyFactory.cpp @@ -1,78 +1,76 @@ /* This file is part of the KDE project Copyright (C) 2008 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KDefaultPropertyFactory.h" -#include "KPropertyWidgetsFactory.h" -#include "KProperty.h" /* #include "customproperty.h"*/ #include "editors/booledit.h" #include "editors/combobox.h" #include "editors/coloredit.h" #include "editors/cursoredit.h" #include "editors/dateedit.h" #include "editors/datetimeedit.h" // #include "editors/dummywidget.h" #include "editors/pixmapedit.h" #include "editors/pointedit.h" #include "editors/pointfedit.h" #include "editors/fontedit.h" #include "editors/rectedit.h" #include "editors/sizeedit.h" #include "editors/sizefedit.h" #include "editors/sizepolicyedit.h" #include "editors/spinbox.h" /*#include "stringlistedit.h"*/ #include "editors/linestyleedit.h" #include "editors/KPropertyStringEditor.h" // #include "symbolcombo.h" #include "editors/timeedit.h" // #include "urledit.h" KDefaultPropertyFactory::KDefaultPropertyFactory() : KPropertyWidgetsFactory() { addEditor( KProperty::Bool, new KPropertyBoolDelegate ); addEditor( KProperty::Cursor, new KPropertyCursorDelegate ); addEditor( KProperty::Color, new KPropertyColorComboDelegate ); addEditor( KProperty::Date, new KPropertyDateDelegate ); addEditor( KProperty::DateTime, new KPropertyDateTimeDelegate ); addEditor( KProperty::Double, new KPropertyDoubleSpinBoxDelegate ); addEditor( KProperty::Font, new KPropertyFontDelegate ); addEditor( KProperty::Int, new KPropertyIntSpinBoxDelegate ); addEditor( KProperty::LineStyle, new KPropertyLineStyleComboDelegate ); //! @todo addEditor( KProperty::LongLong, new LongLongSpinBoxDelegate ); addEditor( KProperty::Pixmap, new KPropertyPixmapDelegate ); addEditor( KProperty::Point, new KPropertyPointDelegate ); addEditor( KProperty::PointF, new KPropertyPointFDelegate ); addEditor( KProperty::Rect, new KPropertyRectDelegate ); //! @todo addEditor( KProperty::RectF, new RectFDelegate ); addEditor( KProperty::Size, new KPropertySizeDelegate ); addEditor( KProperty::SizeF, new KPropertySizeFDelegate ); addEditor( KProperty::SizePolicy, new KPropertySizePolicyDelegate ); addEditor( KProperty::String, new KPropertyStringDelegate ); addEditor( KProperty::Time, new KPropertyTimeDelegate ); //! @todo addEditor( KProperty::UInt, new IntSpinBoxDelegate ); //! @todo addEditor( KProperty::ULongLong, new LongLongSpinBoxDelegate ); addEditor( KProperty::ValueFromList, new KPropertyComboBoxDelegate ); } KDefaultPropertyFactory::~KDefaultPropertyFactory() { } diff --git a/src/KProperty.cpp b/src/KProperty.cpp index c9f3e92..02454ff 100644 --- a/src/KProperty.cpp +++ b/src/KProperty.cpp @@ -1,820 +1,820 @@ /* This file is part of the KDE project Copyright (C) 2004 Cedric Pasteur Copyright (C) 2004 Alexander Dymo Copyright (C) 2004-2009 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KProperty.h" #include "KProperty_p.h" #include "KPropertySet.h" #include "KPropertyFactory.h" #include "kproperty_debug.h" #include -#ifdef KPROPERTY_WIDGET +#ifdef KPROPERTY_WIDGETS #include #endif //! @internal class KProperty::Private { public: Private() : type(0), caption(0), listData(0), changed(false), storable(true), readOnly(false), visible(true), autosync(-1), composed(0), useComposedProperty(true), sets(0), parent(0), children(0), relatedProperties(0) { } inline void setCaptionForDisplaying(const QString& captionForDisplaying) { delete caption; if (captionForDisplaying.simplified() != captionForDisplaying) { if (captionForDisplaying.isEmpty()) { caption = 0; } else { caption = new QString(captionForDisplaying.simplified()); } } else { caption = 0; } this->captionForDisplaying = captionForDisplaying; } ~Private() { delete caption; caption = 0; delete listData; if (children) { qDeleteAll(*children); delete children; } delete relatedProperties; delete composed; delete sets; } int type; QByteArray name; QString captionForDisplaying; QString* caption; QString description; QVariant value; QVariant oldValue; /*! The string-to-value correspondence list of the property.*/ KPropertyListData* listData; QString icon; bool changed; bool storable; bool readOnly; bool visible; int autosync; QMap options; KComposedPropertyInterface *composed; //! Flag used to allow composed property to use setValue() without causing recursion bool useComposedProperty; //! Used when a single set is assigned for the property QPointer set; //! Used when multiple sets are assigned for the property QList< QPointer > *sets; KProperty *parent; QList *children; //! list of properties with the same name (when intersecting buffers) QList *relatedProperties; }; ///////////////////////////////////////////////////////////////// KPropertyListData::KPropertyListData(const QStringList& keys_, const QStringList& names_) : names(names_) { setKeysAsStringList(keys_); } KPropertyListData::KPropertyListData(const QList keys_, const QStringList& names_) : keys(keys_), names(names_) { } KPropertyListData::KPropertyListData() { } KPropertyListData::~KPropertyListData() { } void KPropertyListData::setKeysAsStringList(const QStringList& list) { keys.clear(); for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) { keys.append(*it); } } QStringList KPropertyListData::keysAsStringList() const { QStringList result; for (QList::ConstIterator it = keys.constBegin(); it != keys.constEnd(); ++it) { result.append((*it).toString()); } return result; } ///////////////////////////////////////////////////////////////// KProperty::KProperty(const QByteArray &name, const QVariant &value, const QString &caption, const QString &description, int type, KProperty* parent) : d(new KProperty::Private()) { d->name = name; d->setCaptionForDisplaying(caption); d->description = description; if (type == (int)Auto) d->type = value.type(); else d->type = type; d->composed = KPropertyFactoryManager::self()->createComposedProperty(this); if (parent) parent->addChild(this); setValue(value, false); } KProperty::KProperty(const QByteArray &name, const QStringList &keys, const QStringList &strings, const QVariant &value, const QString &caption, const QString &description, int type, KProperty* parent) : d(new KProperty::Private()) { d->name = name; d->setCaptionForDisplaying(caption); d->description = description; d->type = type; setListData(keys, strings); d->composed = KPropertyFactoryManager::self()->createComposedProperty(this); if (parent) parent->addChild(this); setValue(value, false); } KProperty::KProperty(const QByteArray &name, KPropertyListData* listData, const QVariant &value, const QString &caption, const QString &description, int type, KProperty* parent) : d(new KProperty::Private()) { d->name = name; d->setCaptionForDisplaying(caption); d->description = description; d->type = type; d->listData = listData; d->composed = KPropertyFactoryManager::self()->createComposedProperty(this); if (parent) parent->addChild(this); setValue(value, false); } KProperty::KProperty() : d(new KProperty::Private()) { } KProperty::KProperty(const KProperty &prop) : d(new KProperty::Private()) { *this = prop; } KProperty::~KProperty() { delete d; } QByteArray KProperty::name() const { return d->name; } void KProperty::setName(const QByteArray &name) { d->name = name; } QString KProperty::caption() const { return d->caption ? *d->caption : d->captionForDisplaying; } QString KProperty::captionForDisplaying() const { return d->captionForDisplaying; } void KProperty::setCaption(const QString &caption) { d->setCaptionForDisplaying(caption); } QString KProperty::description() const { return d->description; } void KProperty::setDescription(const QString &desc) { d->description = desc; } int KProperty::type() const { return d->type; } void KProperty::setType(int type) { d->type = type; } QString KProperty::icon() const { return d->icon; } void KProperty::setIcon(const QString &icon) { d->icon = icon; } QVariant KProperty::value() const { return d->value; } QVariant KProperty::oldValue() const { return d->oldValue; } void KProperty::childValueChanged(KProperty *child, const QVariant &value, bool rememberOldValue) { if (!d->composed) return; d->composed->childValueChangedInternal(child, value, rememberOldValue); } //! @return true if @a currentValue and @a value are compatible static bool compatibleTypes(const QVariant& currentValue, const QVariant &value) { if (currentValue.isNull() || value.isNull()) return true; const QVariant::Type t = currentValue.type(); const QVariant::Type newt = value.type(); if (t == newt) return true; if ( (t == QVariant::Int && newt == QVariant::UInt) || (t == QVariant::UInt && newt == QVariant::Int) || (t == QVariant::ByteArray && newt == QVariant::String) || (t == QVariant::String && newt == QVariant::ByteArray) || (t == QVariant::ULongLong && newt == QVariant::LongLong) || (t == QVariant::LongLong && newt == QVariant::ULongLong)) { return true; } return false; } void KProperty::setValue(const QVariant &value, bool rememberOldValue, bool useComposedProperty) { if (d->name.isEmpty()) { kprWarning() << "COULD NOT SET value to a null property"; return; } QVariant currentValue = this->value(); if (!compatibleTypes(currentValue, value)) { kprWarning() << "INCOMPATIBLE TYPES! old=" << currentValue << "new=" << value; } //1. Check if the value should be changed bool ch; const QVariant::Type t = currentValue.type(); const QVariant::Type newt = value.type(); if ( t == QVariant::DateTime || t == QVariant::Time) { //for date and datetime types: compare with strings, because there //can be miliseconds difference ch = (currentValue.toString() != value.toString()); } else if (t == QVariant::String || t == QVariant::ByteArray) { //property is changed for string type, //if one of value is empty and other isn't.. ch = ((currentValue.toString().isEmpty() != value.toString().isEmpty()) //..or both are not empty and values differ || (!currentValue.toString().isEmpty() && !value.toString().isEmpty() && currentValue != value)); } else if (t == QVariant::Double) { const double factor = 1.0 / option("step", KPROPERTY_DEFAULT_DOUBLE_VALUE_STEP).toDouble(); //kprDebug() // << "double compared:" << currentValue.toDouble() << value.toDouble() // << ":" << static_cast(currentValue.toDouble() * factor) << static_cast(value.toDouble() * factor); ch = static_cast(currentValue.toDouble() * factor) != static_cast(value.toDouble() * factor); } else if (t == QVariant::Invalid && newt == QVariant::Invalid) { ch = false; -#ifdef KPROPERTY_WIDGET +#ifdef KPROPERTY_WIDGETS } else if (t == QVariant::SizePolicy) { ch = (currentValue.value() != value.value()); #endif } else { ch = (currentValue != value); } if (!ch) return; //2. Then change it, and store old value if necessary if (rememberOldValue) { if (!d->changed) d->oldValue = currentValue; d->changed = true; } else { d->oldValue = QVariant(); // clear old value d->changed = false; } if (d->parent) { d->parent->childValueChanged(this, value, rememberOldValue); } QVariant prevValue; if (d->composed && useComposedProperty) { prevValue = currentValue; //??? d->composed->setChildValueChangedEnabled(false); d->composed->setValue(this, value, rememberOldValue); d->composed->setChildValueChangedEnabled(true); } else { prevValue = currentValue; } d->value = value; if (!d->parent) { // emit only if parent has not done it emitPropertyChanged(); // called as last step in this method! } } void KProperty::resetValue() { d->changed = false; bool cleared = false; if (d->set) d->set->informAboutClearing(cleared); //inform me about possibly clearing the property sets setValue(oldValue(), false); if (cleared) return; //property set has been cleared: no further actions make sense as 'this' is dead // maybe parent prop is also unchanged now if (d->parent && d->parent->value() == d->parent->oldValue()) d->parent->d->changed = false; if (d->sets) { foreach (QPointer set, *d->sets) { if (!set.isNull()) //may be destroyed in the meantime emit set->propertyReset(*set, *this); } } else if (d->set) { emit d->set->propertyReset(*d->set, *this); } } KPropertyListData* KProperty::listData() const { return d->listData; } void KProperty::setListData(KPropertyListData* list) { if (list == d->listData) return; delete d->listData; d->listData = list; } void KProperty::setListData(const QStringList &keys, const QStringList &names) { KPropertyListData* list = new KPropertyListData(keys, names); setListData(list); } //////////////////////////////////////////////////////////////// bool KProperty::isNull() const { return d->name.isEmpty(); } bool KProperty::isModified() const { return d->changed; } void KProperty::clearModifiedFlag() { d->changed = false; } bool KProperty::isReadOnly() const { return d->readOnly; } void KProperty::setReadOnly(bool readOnly) { d->readOnly = readOnly; } bool KProperty::isVisible() const { return d->visible; } void KProperty::setVisible(bool visible) { d->visible = visible; } int KProperty::autoSync() const { return d->autosync; } void KProperty::setAutoSync(int sync) { d->autosync = sync; } bool KProperty::isStorable() const { return d->storable; } void KProperty::setStorable(bool storable) { d->storable = storable; } void KProperty::setOption(const char* name, const QVariant& val) { d->options[name] = val; } QVariant KProperty::option(const char* name, const QVariant& defaultValue) const { if (d->options.contains(name)) return d->options[name]; return defaultValue; } bool KProperty::hasOptions() const { return !d->options.isEmpty(); } ///////////////////////////////////////////////////////////////// const KProperty& KProperty::operator= (const QVariant & val) { setValue(val); return *this; } const KProperty& KProperty::operator= (const KProperty & property) { if (&property == this) return *this; delete d->listData; d->listData = 0; delete d->children; d->children = 0; delete d->relatedProperties; d->relatedProperties = 0; delete d->composed; d->composed = 0; d->name = property.d->name; d->setCaptionForDisplaying(property.captionForDisplaying()); d->description = property.d->description; d->type = property.d->type; d->icon = property.d->icon; d->autosync = property.d->autosync; d->visible = property.d->visible; d->storable = property.d->storable; d->readOnly = property.d->readOnly; d->options = property.d->options; if (property.d->listData) { d->listData = new KPropertyListData(*property.d->listData); } if (property.d->composed) { delete d->composed; d->composed = KPropertyFactoryManager::self()->createComposedProperty(this); // updates all children value, using KComposedPropertyInterface setValue(property.value()); } else { d->value = property.d->value; if (property.d->children) { // no KComposedPropertyInterface (should never happen), simply copy all children d->children = new QList(); QList::ConstIterator endIt = property.d->children->constEnd(); for (QList::ConstIterator it = property.d->children->constBegin(); it != endIt; ++it) { KProperty *child = new KProperty(*(*it)); addChild(child); } } } if (property.d->relatedProperties) { d->relatedProperties = new QList(*(property.d->relatedProperties)); } // update these later because they may have been changed when creating children d->oldValue = property.d->oldValue; d->changed = property.d->changed; return *this; } bool KProperty::operator ==(const KProperty &prop) const { return ((d->name == prop.d->name) && (value() == prop.value())); } ///////////////////////////////////////////////////////////////// const QList* KProperty::children() const { return d->children; } KProperty* KProperty::child(const QByteArray &name) { QList::ConstIterator endIt = d->children->constEnd(); for (QList::ConstIterator it = d->children->constBegin(); it != endIt; ++it) { if ((*it)->name() == name) return *it; } return 0; } KProperty* KProperty::parent() const { return d->parent; } void KProperty::addChild(KProperty *prop) { if (!prop) return; if (!d->children || qFind(d->children->begin(), d->children->end(), prop) == d->children->end()) { // not in our list if (!d->children) d->children = new QList(); d->children->append(prop); prop->d->parent = this; } else { kprWarning() << "property" << name() << ": child property" << prop->name() << "already added"; return; } } void KProperty::addSet(KPropertySet *set) { if (!set) return; if (!d->set) {//simple case d->set = set; return; } if (d->set == set || d->sets->contains(set)) return; if (!d->sets) { d->sets = new QList< QPointer >; } d->sets->append(QPointer(set)); } const QList* KProperty::related() const { return d->relatedProperties; } void KProperty::addRelatedProperty(KProperty *property) { if (!d->relatedProperties) d->relatedProperties = new QList(); QList::iterator it = qFind(d->relatedProperties->begin(), d->relatedProperties->end(), property); if (it == d->relatedProperties->end()) // not in our list d->relatedProperties->append(property); } KComposedPropertyInterface* KProperty::composedProperty() const { return d->composed; } void KProperty::setComposedProperty(KComposedPropertyInterface *prop) { if (d->composed == prop) return; delete d->composed; d->composed = prop; } #if 0 int Property::sortingKey() const { return d->sortingKey; } void Property::setSortingKey(int key) { d->sortingKey = key; } #endif void KProperty::emitPropertyChanged() { QList< QPointer > *sets = 0; if (d->sets) { sets = d->sets; } else if (d->parent) { sets = d->parent->d->sets; } if (sets) { foreach (QPointer s, *sets) { if (!s.isNull()) { //may be destroyed in the meantime emit s->propertyChangedInternal(*s, *this); emit s->propertyChanged(*s, *this); } } } else { QPointer set; set = d->set; if (d->set) { set = d->set; } else if (d->parent) { set = d->parent->d->set; } if (!set.isNull()) { //if the slot connect with that signal may call set->clear() - that's //the case e.g. at kexi/plugins/{macros|scripting}/* - this Property //may got destroyed ( see Set::removeProperty(Property*) ) while we are //still on it. So, if we try to access ourself/this once the signal //got emitted we may end in a very hard to reproduce crash. So, the //emit should happen as last step in this method! emit set->propertyChangedInternal(*set, *this); emit set->propertyChanged(*set, *this); } } } QMap KProperty::options() const { return d->options; } ///////////////////////////////////////////////////////////////// void KProperty::debug() const { kprDebug() << *this; } KPROPERTYCORE_EXPORT QDebug operator<<(QDebug dbg, const KProperty &p) { dbg.nospace() << "KProperty(" << "NAME=" << p.name(); if (!p.caption().isEmpty()) { dbg.nospace() << " CAPTION=" << p.caption(); } if (!p.description().isEmpty()) { dbg.nospace() << " DESC=" << p.description(); } dbg.nospace() << " TYPE=" << p.type(); if (p.value().isValid()) { dbg.nospace() << " VALUE=" << p.value(); } else { dbg.nospace() << " VALUE="; } if (p.oldValue().isValid()) { dbg.nospace() << " OLDVALUE=" << p.oldValue(); } if (p.isModified()) { dbg.nospace() << " MODIFIED"; } if (!p.isVisible()) { dbg.nospace() << " HIDDEN"; } //! @todo children... if (p.hasOptions()) { dbg.nospace() << " OPTIONS(" << p.options().count() << "): ["; QList optionKeys( p.options().keys() ); qSort(optionKeys); bool first = true; foreach (const QByteArray& key, optionKeys) { if (first) { first = false; } else { dbg.space() << ","; } dbg.nospace() << key << ":" << p.option(key.constData()); } dbg.nospace() << "]"; } dbg.nospace() << ")"; return dbg.space(); } diff --git a/src/KPropertyCoreConfig.cmake.in b/src/KPropertyCoreConfig.cmake.in index 5f1f402..3b56c04 100644 --- a/src/KPropertyCoreConfig.cmake.in +++ b/src/KPropertyCoreConfig.cmake.in @@ -1,21 +1,21 @@ -# KPropertyConfig.cmake provides information about the installed KProperty library. -# It can be used directly from CMake via find_package(KProperty NO_MODULE) +# KPropertyCoreConfig.cmake provides information about the installed KPropertyCore library. +# It can be used directly from CMake via find_package(KPropertyCore NO_MODULE) # # The following CMake variables are provided: -# KProperty_VERSION_MAJOR - the major version number of KProperty -# KProperty_VERSION_MINOR - the minor version number of KProperty -# KProperty_VERSION_PATCH - the patch version number of KProperty -# KProperty_INCLUDE_DIRS - the include directories to use +# KPropertyCore_VERSION_MAJOR - the major version number of KPropertyCore +# KPropertyCore_VERSION_MINOR - the minor version number of KPropertyCore +# KPropertyCore_VERSION_PATCH - the patch version number of KPropertyCore +# KPropertyCore_INCLUDE_DIRS - the include directories to use # # Additionally, the following imported library targets are created, which may be used directly # with target_link_libraries(): -# KProperty - the KProperty library +# KPropertyCore - the KPropertyCore library @PACKAGE_INIT@ find_dependency(Qt5Core @REQUIRED_QT_VERSION@) include("${CMAKE_CURRENT_LIST_DIR}/KPropertyCoreTargets.cmake") # "public" variables: # TODO diff --git a/src/KPropertyFactory.cpp b/src/KPropertyFactory.cpp index ec1f4c9..6fae10a 100644 --- a/src/KPropertyFactory.cpp +++ b/src/KPropertyFactory.cpp @@ -1,206 +1,206 @@ /* This file is part of the KDE project Copyright (C) 2008 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KPropertyFactory.h" //--------------- //! @internal class KPropertyFactoryManager::Private { public: Private() { } ~Private() { qDeleteAll(factories); } QSet factories; QHash composedPropertyCreators; }; Q_GLOBAL_STATIC(KPropertyFactoryManager, _self) //! @internal class KPropertyFactory::Private { public: Private() { } ~Private() { } QHash composedPropertyCreators; QSet composedPropertyCreatorsSet; }; KPropertyFactory::KPropertyFactory() : d( new Private ) { } KPropertyFactory::~KPropertyFactory() { delete d; } QHash KPropertyFactory::composedPropertyCreators() const { return d->composedPropertyCreators; } -#ifdef KPROPERTY_WIDGET +#ifdef KPROPERTY_WIDGETS QHash KPropertyFactory::editorCreators() const { return d->editorCreators; } QHash KPropertyFactory::valuePainters() const { return d->valuePainters; } QHash KPropertyFactory::valueDisplays() const { return d->valueDisplays; } void KPropertyFactory::addEditor(int type, KPropertyEditorCreatorInterface *creator) { addEditorInternal( type, creator, true ); if (dynamic_cast(creator)) { addComposedPropertyCreatorInternal( 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*/ ); } } #endif void KPropertyFactory::addComposedPropertyCreator( int type, KComposedPropertyCreatorInterface* creator ) { addComposedPropertyCreatorInternal( type, creator, true ); } void KPropertyFactory::addComposedPropertyCreatorInternal(int type, KComposedPropertyCreatorInterface* creator, bool own) { if (own) d->composedPropertyCreatorsSet.insert(creator); d->composedPropertyCreators.insert(type, creator); } //------------ KPropertyFactoryManager::KPropertyFactoryManager() : QObject(0) , d(new Private) { setObjectName(QLatin1String("KPropertyFactoryManager")); //TODO ??? registerFactory(new KDefaultPropertyFactory); } KPropertyFactoryManager::~KPropertyFactoryManager() { delete d; } KPropertyFactoryManager* KPropertyFactoryManager::self() { return _self; } void KPropertyFactoryManager::registerFactory(KPropertyFactory *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()); } } 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(); /* CustomPropertyFactory *factory = d->registeredWidgets[type]; if (factory) return factory->createCustomProperty(parent); */ switch (type) { case Size: case Size_Width: case Size_Height: return new SizeCustomProperty(parent); case Point: case Point_X: case Point_Y: return new PointCustomProperty(parent); case Rect: case Rect_X: case Rect_Y: case Rect_Width: case Rect_Height: return new RectCustomProperty(parent); case SizePolicy: /* case SizePolicy_HorizontalStretch: case SizePolicy_VerticalStretch: case SizePolicy_HorizontalPolicy: case SizePolicy_VerticalPolicy:*/ return new SizePolicyCustomProperty(parent); default:; } return 0; #endif KComposedPropertyInterface::KComposedPropertyInterface(KProperty *parent) : m_childValueChangedEnabled(true) { Q_UNUSED(parent) } KComposedPropertyInterface::~KComposedPropertyInterface() { } KComposedPropertyCreatorInterface::KComposedPropertyCreatorInterface() { } KComposedPropertyCreatorInterface::~KComposedPropertyCreatorInterface() { } diff --git a/src/KPropertyFactory.h b/src/KPropertyFactory.h index 8907d89..bc1c768 100644 --- a/src/KPropertyFactory.h +++ b/src/KPropertyFactory.h @@ -1,133 +1,133 @@ /* This file is part of the KDE project Copyright (C) 2008 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KPROPERTY_FACTORY_H #define KPROPERTY_FACTORY_H #include "KProperty.h" #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 KPROPERTYCORE_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 KPROPERTYCORE_EXPORT KComposedPropertyCreatorInterface { public: KComposedPropertyCreatorInterface(); virtual ~KComposedPropertyCreatorInterface(); virtual KComposedPropertyInterface* createComposedProperty(KProperty *parent) const = 0; }; //! Creator returning composed property object template class KPROPERTYCORE_EXPORT KComposedPropertyCreator : public KComposedPropertyCreatorInterface { public: KComposedPropertyCreator() : KComposedPropertyCreatorInterface() {} virtual ~KComposedPropertyCreator() {} virtual ComposedProperty* createComposedProperty(KProperty *parent) const { return new ComposedProperty(parent); } }; class KPROPERTYCORE_EXPORT KPropertyFactory { public: KPropertyFactory(); virtual ~KPropertyFactory(); QHash composedPropertyCreators() const; void addComposedPropertyCreator( int type, KComposedPropertyCreatorInterface* creator ); protected: void addComposedPropertyCreatorInternal(int type, KComposedPropertyCreatorInterface* creator, bool own = true); - + class Private; Private * const d; }; class KProperty; class KCustomProperty; class KPROPERTYCORE_EXPORT KPropertyFactoryManager : public QObject { Q_OBJECT public: bool isEditorForTypeAvailable( int type ) const; - + KComposedPropertyInterface* createComposedProperty(KProperty *parent); //! Registers factory @a factory. It becomes owned by the manager. void registerFactory(KPropertyFactory *factory); KCustomProperty* createCustomProperty( KProperty *parent ); /*! \return a pointer to a factory manager instance.*/ static KPropertyFactoryManager* self(); KPropertyFactoryManager(); ~KPropertyFactoryManager(); private: class Private; Private * const d; }; #endif diff --git a/src/KPropertyUnit_p.cpp b/src/KPropertyUnit_p.cpp index 86217fe..27b2f6f 100644 --- a/src/KPropertyUnit_p.cpp +++ b/src/KPropertyUnit_p.cpp @@ -1,399 +1,399 @@ /* This file is part of the KDE project Copyright (C) 2001 David Faure Copyright (C) 2004, Nicolas GOUTTE Copyright 2012 Friedrich W. H. Kossebau This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KPropertyUnit_p.h" #include "kproperty_debug.h" -#ifdef KPROPERTY_WIDGET +#ifdef KPROPERTY_WIDGETS #include #endif #include #include // ensure the same order as in KPropertyUnit::Unit static const char* const unitNameList[KPropertyUnit::TypeCount] = { "mm", "pt", "in", "cm", "dm", "pi", "cc", "px" }; QString KPropertyUnit::unitDescription(KPropertyUnit::Type type) { switch (type) { case KPropertyUnit::Millimeter: return QObject::tr("Millimeters (mm)"); case KPropertyUnit::Centimeter: return QObject::tr("Centimeters (cm)"); case KPropertyUnit::Decimeter: return QObject::tr("Decimeters (dm)"); case KPropertyUnit::Inch: return QObject::tr("Inches (in)"); case KPropertyUnit::Pica: return QObject::tr("Pica (pi)"); case KPropertyUnit::Cicero: return QObject::tr("Cicero (cc)"); case KPropertyUnit::Point: return QObject::tr("Points (pt)"); case KPropertyUnit::Pixel: return QObject::tr("Pixels (px)"); default: return QObject::tr("Unsupported unit"); } } // grouped by units which are similar static const KPropertyUnit::Type typesInUi[KPropertyUnit::TypeCount] = { KPropertyUnit::Millimeter, KPropertyUnit::Centimeter, KPropertyUnit::Decimeter, KPropertyUnit::Inch, KPropertyUnit::Pica, KPropertyUnit::Cicero, KPropertyUnit::Point, KPropertyUnit::Pixel, }; QStringList KPropertyUnit::listOfUnitNameForUi(ListOptions listOptions) { QStringList lst; for (int i = 0; i < KPropertyUnit::TypeCount; ++i) { const Type type = typesInUi[i]; if ((type != Pixel) || ((listOptions & HideMask) == ListAll)) lst.append(unitDescription(type)); } return lst; } KPropertyUnit KPropertyUnit::fromListForUi(int index, ListOptions listOptions, qreal factor) { KPropertyUnit::Type type = KPropertyUnit::Point; if ((0 <= index) && (index < KPropertyUnit::TypeCount)) { // iterate through all enums and skip the Pixel enum if needed for (int i = 0; i < KPropertyUnit::TypeCount; ++i) { if ((listOptions&HidePixel) && (typesInUi[i] == Pixel)) { ++index; continue; } if (i == index) { type = typesInUi[i]; break; } } } return KPropertyUnit(type, factor); } int KPropertyUnit::indexInListForUi(ListOptions listOptions) const { if ((listOptions&HidePixel) && (m_type == Pixel)) { return -1; } int result = -1; int skipped = 0; for (int i = 0; i < KPropertyUnit::TypeCount; ++i) { if ((listOptions&HidePixel) && (typesInUi[i] == Pixel)) { ++skipped; continue; } if (typesInUi[i] == m_type) { result = i - skipped; break; } } return result; } qreal KPropertyUnit::toUserValue(qreal ptValue) const { switch (m_type) { case Millimeter: return toMillimeter(ptValue); case Centimeter: return toCentimeter(ptValue); case Decimeter: return toDecimeter(ptValue); case Inch: return toInch(ptValue); case Pica: return toPica(ptValue); case Cicero: return toCicero(ptValue); case Pixel: return ptValue * m_pixelConversion; case Point: default: return toPoint(ptValue); } } qreal KPropertyUnit::ptToUnit(qreal ptValue, const KPropertyUnit &unit) { switch (unit.m_type) { case Millimeter: return POINT_TO_MM(ptValue); case Centimeter: return POINT_TO_CM(ptValue); case Decimeter: return POINT_TO_DM(ptValue); case Inch: return POINT_TO_INCH(ptValue); case Pica: return POINT_TO_PI(ptValue); case Cicero: return POINT_TO_CC(ptValue); case Pixel: return ptValue * unit.m_pixelConversion; case Point: default: return ptValue; } } QString KPropertyUnit::toUserStringValue(qreal ptValue) const { return QLocale::system().toString(toUserValue(ptValue)); } qreal KPropertyUnit::fromUserValue(qreal value) const { switch (m_type) { case Millimeter: return MM_TO_POINT(value); case Centimeter: return CM_TO_POINT(value); case Decimeter: return DM_TO_POINT(value); case Inch: return INCH_TO_POINT(value); case Pica: return PI_TO_POINT(value); case Cicero: return CC_TO_POINT(value); case Pixel: return value / m_pixelConversion; case Point: default: return value; } } qreal KPropertyUnit::fromUserValue(const QString &value, bool *ok) const { return fromUserValue(QLocale::system().toDouble(value, ok)); } qreal KPropertyUnit::parseValue(const QString& _value, qreal defaultVal) { if (_value.isEmpty()) return defaultVal; QString value(_value.simplified()); value.remove(QLatin1Char(' ')); int firstLetter = -1; for (int i = 0; i < value.length(); ++i) { if (value.at(i).isLetter()) { if (value.at(i) == QLatin1Char('e')) continue; firstLetter = i; break; } } if (firstLetter == -1) return value.toDouble(); const QString symbol = value.mid(firstLetter); value.truncate(firstLetter); const qreal val = value.toDouble(); if (symbol == QLatin1String("pt")) return val; bool ok; KPropertyUnit u = KPropertyUnit::fromSymbol(symbol, &ok); if (ok) return u.fromUserValue(val); if (symbol == QLatin1String("m")) return DM_TO_POINT(val * 10.0); else if (symbol == QLatin1String("km")) return DM_TO_POINT(val * 10000.0); kprWarning() << "KPropertyUnit::parseValue: Unit " << symbol << " is not supported, please report."; //! @todo add support for mi/ft ? return defaultVal; } KPropertyUnit KPropertyUnit::fromSymbol(const QString &symbol, bool *ok) { Type result = Point; if (symbol == QLatin1String("inch") /*compat*/) { result = Inch; if (ok) *ok = true; } else { if (ok) *ok = false; for (int i = 0; i < TypeCount; ++i) { if (symbol == QLatin1String(unitNameList[i])) { result = static_cast(i); if (ok) *ok = true; } } } return KPropertyUnit(result); } qreal KPropertyUnit::convertFromUnitToUnit(qreal value, const KPropertyUnit &fromUnit, const KPropertyUnit &toUnit, qreal factor) { qreal pt; switch (fromUnit.type()) { case Millimeter: pt = MM_TO_POINT(value); break; case Centimeter: pt = CM_TO_POINT(value); break; case Decimeter: pt = DM_TO_POINT(value); break; case Inch: pt = INCH_TO_POINT(value); break; case Pica: pt = PI_TO_POINT(value); break; case Cicero: pt = CC_TO_POINT(value); break; case Pixel: pt = value / factor; break; case Point: default: pt = value; } switch (toUnit.type()) { case Millimeter: return POINT_TO_MM(pt); case Centimeter: return POINT_TO_CM(pt); case Decimeter: return POINT_TO_DM(pt); case Inch: return POINT_TO_INCH(pt); case Pica: return POINT_TO_PI(pt); case Cicero: return POINT_TO_CC(pt); case Pixel: return pt * factor; case Point: default: return pt; } } QString KPropertyUnit::symbol() const { return QLatin1String(unitNameList[m_type]); } qreal KPropertyUnit::parseAngle(const QString& _value, qreal defaultVal) { if (_value.isEmpty()) return defaultVal; QString value(_value.simplified()); value.remove(QLatin1Char(' ')); int firstLetter = -1; for (int i = 0; i < value.length(); ++i) { if (value.at(i).isLetter()) { if (value.at(i) == QLatin1Char('e')) continue; firstLetter = i; break; } } if (firstLetter == -1) return value.toDouble(); const QString type = value.mid(firstLetter); value.truncate(firstLetter); const qreal val = value.toDouble(); if (type == QLatin1String("deg")) return val; else if (type == QLatin1String("rad")) return val * 180 / M_PI; else if (type == QLatin1String("grad")) return val * 0.9; return defaultVal; } -#ifdef KPROPERTY_WIDGET +#ifdef KPROPERTY_WIDGETS qreal KPropertyUnit::approxTransformScale(const QTransform &t) { return std::sqrt(t.determinant()); } void KPropertyUnit::adjustByPixelTransform(const QTransform &t) { m_pixelConversion *= approxTransformScale(t); } #endif #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, const KPropertyUnit &unit) { #ifndef NDEBUG debug.nospace() << unit.symbol(); #else Q_UNUSED(unit); #endif return debug.space(); } #endif diff --git a/src/KPropertyUnit_p.h b/src/KPropertyUnit_p.h index e83291f..91337ca 100644 --- a/src/KPropertyUnit_p.h +++ b/src/KPropertyUnit_p.h @@ -1,276 +1,276 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999 Reginald Stadlbauer Copyright (C) 1998, 1999 Torben Weis Copyright (C) 2004, Nicolas GOUTTE Copyright (C) 2010 Thomas Zander Copyright 2012 Friedrich W. H. Kossebau This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KPROPERTYUNIT_H #define KPROPERTYUNIT_H #include "kpropertycore_export.h" #include #include #include #include #include // for floor // 1 inch ^= 72 pt // 1 inch ^= 25.399956 mm (-pedantic ;p) // 1 pt = 1/12 pi // 1 pt ^= 0.0077880997 cc // 1 cc = 12 dd // Note: I don't use division but multiplication with the inverse value // because it's faster ;p (Werner) #define POINT_TO_MM(px) qreal((px)*0.352777167) #define MM_TO_POINT(mm) qreal((mm)*2.83465058) #define POINT_TO_CM(px) qreal((px)*0.0352777167) #define CM_TO_POINT(cm) qreal((cm)*28.3465058) #define POINT_TO_DM(px) qreal((px)*0.00352777167) #define DM_TO_POINT(dm) qreal((dm)*283.465058) #define POINT_TO_INCH(px) qreal((px)*0.01388888888889) #define INCH_TO_POINT(inch) qreal((inch)*72.0) #define MM_TO_INCH(mm) qreal((mm)*0.039370147) #define INCH_TO_MM(inch) qreal((inch)*25.399956) #define POINT_TO_PI(px) qreal((px)*0.083333333) #define POINT_TO_CC(px) qreal((px)*0.077880997) #define PI_TO_POINT(pi) qreal((pi)*12) #define CC_TO_POINT(cc) qreal((cc)*12.840103) /** * %Calligra stores everything in pt (using "qreal") internally. * When displaying a value to the user, the value is converted to the user's unit * of choice, and rounded to a reasonable precision to avoid 0.999999 * * For implementing the selection of a unit type in the UI use the *ForUi() methods. * They ensure the same order of the unit types in all places, with the order not * 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 KPROPERTYCORE_EXPORT KPropertyUnit { public: /** Length units supported by Calligra. */ enum Type { Millimeter = 0, Point, ///< Postscript point, 1/72th of an Inco Inch, Centimeter, Decimeter, Pica, Cicero, Pixel, TypeCount ///< @internal }; /// Used to control the scope of the unit types listed in the UI enum ListOption { ListAll = 0, HidePixel = 1, HideMask = HidePixel }; Q_DECLARE_FLAGS(ListOptions, ListOption) /** Returns a KPropertyUnit instance with the type at the @p index of the UI list with the given @p listOptions. */ static KPropertyUnit fromListForUi(int index, ListOptions listOptions = ListAll, qreal factor = 1.0); /// Convert a unit symbol string into a KPropertyUnit /// @param symbol symbol to convert /// @param ok if set, it will be true if the unit was known, false if unknown static KPropertyUnit fromSymbol(const QString &symbol, bool *ok = 0); /** Construction requires initialization. The factor is for variable factor units like pixel */ explicit KPropertyUnit(Type unit = Point, qreal factor = 1.0) { m_type = unit; m_pixelConversion = factor; } KPropertyUnit& operator=(Type unit) { m_type = unit; m_pixelConversion = 1.0; return *this; } bool operator!=(const KPropertyUnit &other) const { return !operator==(other); } bool operator==(const KPropertyUnit &other) const { return m_type == other.m_type && (m_type != Pixel || qFuzzyCompare(m_pixelConversion, other.m_pixelConversion)); } KPropertyUnit::Type type() const { return m_type; } void setFactor(qreal factor) { m_pixelConversion = factor; } /** * Prepare ptValue to be displayed in pt * This method will round to 0.001 precision */ static qreal toPoint(qreal ptValue) { // No conversion, only rounding (to 0.001 precision) return floor(ptValue * 1000.0) / 1000.0; } /** * Prepare ptValue to be displayed in mm * This method will round to 0.0001 precision, use POINT_TO_MM() for lossless conversion. */ static qreal toMillimeter(qreal ptValue) { // "mm" values are rounded to 0.0001 millimeters return floor(POINT_TO_MM(ptValue) * 10000.0) / 10000.0; } /** * Prepare ptValue to be displayed in cm * This method will round to 0.0001 precision, use POINT_TO_CM() for lossless conversion. */ static qreal toCentimeter(qreal ptValue) { return floor(POINT_TO_CM(ptValue) * 10000.0) / 10000.0; } /** * Prepare ptValue to be displayed in dm * This method will round to 0.0001 precision, use POINT_TO_DM() for lossless conversion. */ static qreal toDecimeter(qreal ptValue) { return floor(POINT_TO_DM(ptValue) * 10000.0) / 10000.0; } /** * Prepare ptValue to be displayed in inch * This method will round to 0.00001 precision, use POINT_TO_INCH() for lossless conversion. */ static qreal toInch(qreal ptValue) { // "in" values are rounded to 0.00001 inches return floor(POINT_TO_INCH(ptValue) * 100000.0) / 100000.0; } /** * Prepare ptValue to be displayed in pica * This method will round to 0.00001 precision, use POINT_TO_PI() for lossless conversion. */ static qreal toPica(qreal ptValue) { // "pi" values are rounded to 0.00001 inches return floor(POINT_TO_PI(ptValue) * 100000.0) / 100000.0; } /** * Prepare ptValue to be displayed in cicero * This method will round to 0.00001 precision, use POINT_TO_CC() for lossless conversion. */ static qreal toCicero(qreal ptValue) { // "cc" values are rounded to 0.00001 inches return floor(POINT_TO_CC(ptValue) * 100000.0) / 100000.0; } /** * convert the given value directly from one unit to another */ static qreal convertFromUnitToUnit(qreal value, const KPropertyUnit &fromUnit, const KPropertyUnit &toUnit, qreal factor = 1.0); /** * This method is the one to use to display a value in a dialog * \return the value @p ptValue converted to unit and rounded, ready to be displayed */ qreal toUserValue(qreal ptValue) const; /** * Convert the value @p ptValue to a given unit @p unit * Unlike KPropertyUnit::ptToUnit the return value remains unrounded, so that it can be used in complex calculation * \return the converted value */ static qreal ptToUnit(qreal ptValue, const KPropertyUnit &unit); /// This method is the one to use to display a value in a dialog /// @return the value @p ptValue converted the unit and rounded, ready to be displayed QString toUserStringValue(qreal ptValue) const; /// This method is the one to use to read a value from a dialog /// @return the value converted to points for internal use qreal fromUserValue(qreal value) const; /// This method is the one to use to read a value from a dialog /// @param value value entered by the user /// @param ok if set, the pointed bool is set to true if the value could be /// converted to a qreal, and to false otherwise. /// @return the value converted to points for internal use qreal fromUserValue(const QString &value, bool *ok = 0) const; /// Get the description string of the given unit static QString unitDescription(KPropertyUnit::Type type); /// Get the symbol string of the unit QString symbol() const; /// Returns the list of unit types for the UI, controlled with the given @p listOptions. static QStringList listOfUnitNameForUi(ListOptions listOptions = ListAll); /// Get the index of this unit in the list of unit types for the UI, /// if it is controlled with the given @p listOptions. int indexInListForUi(ListOptions listOptions = ListAll) const; /// parse common %Calligra and Odf values, like "10cm", "5mm" to pt static qreal parseValue(const QString &value, qreal defaultVal = 0.0); /// parse an angle to its value in degrees static qreal parseAngle(const QString &value, qreal defaultVal = 0.0); QString toString() { return symbol(); } -#ifdef KPROPERTY_WIDGET +#ifdef KPROPERTY_WIDGETS /** * Get an approximate scale of a unit vector that was converted by * the transfomation. * * Please note that exact values are guaranteed only for * combinations of Translate, Rotation and Unifor Scale * matrices. For combinations having shears and perspective the * value will be average for the point near CS origin. */ static qreal approxTransformScale(const QTransform &t); /** * Adjust the unit by pixel transformation applied to the * describing object. It multiplies the pixel coefficient by the * average scale of the matrix. */ void adjustByPixelTransform(const QTransform &t); #endif - + private: Type m_type; qreal m_pixelConversion; }; #ifndef QT_NO_DEBUG_STREAM KPROPERTYCORE_EXPORT QDebug operator<<(QDebug, const KPropertyUnit &); #endif Q_DECLARE_METATYPE(KPropertyUnit) Q_DECLARE_OPERATORS_FOR_FLAGS(KPropertyUnit::ListOptions) #endif diff --git a/src/KPropertyWidgetsConfig.cmake.in b/src/KPropertyWidgetsConfig.cmake.in index 4e28e53..24d666b 100644 --- a/src/KPropertyWidgetsConfig.cmake.in +++ b/src/KPropertyWidgetsConfig.cmake.in @@ -1,22 +1,22 @@ -# KPropertyConfig.cmake provides information about the installed KProperty library. -# It can be used directly from CMake via find_package(KProperty NO_MODULE) +# KPropertyWidgetsConfig.cmake provides information about the installed KPropertyWidgets library. +# It can be used directly from CMake via find_package(KPropertyWidgets NO_MODULE) # # The following CMake variables are provided: -# KProperty_VERSION_MAJOR - the major version number of KProperty -# KProperty_VERSION_MINOR - the minor version number of KProperty -# KProperty_VERSION_PATCH - the patch version number of KProperty -# KProperty_INCLUDE_DIRS - the include directories to use +# KPropertyWidgets_VERSION_MAJOR - the major version number of KPropertyWidgets +# KPropertyWidgets_VERSION_MINOR - the minor version number of KPropertyWidgets +# KPropertyWidgets_VERSION_PATCH - the patch version number of KPropertyWidgets +# KPropertyWidgets_INCLUDE_DIRS - the include directories to use # # Additionally, the following imported library targets are created, which may be used directly # with target_link_libraries(): -# KProperty - the KProperty library +# KPropertyWidgets - the KPropertyWidgets library @PACKAGE_INIT@ -find_dependency(Qt5Core @REQUIRED_QT_VERSION@) find_dependency(Qt5Widgets @REQUIRED_QT_VERSION@) +find_dependency(KPropertyCore @KPROPERTY_VERSION@) include("${CMAKE_CURRENT_LIST_DIR}/KPropertyWidgetsTargets.cmake") # "public" variables: # TODO diff --git a/src/KPropertyWidgetsFactory.h b/src/KPropertyWidgetsFactory.h index a2a6dfa..c6614bb 100644 --- a/src/KPropertyWidgetsFactory.h +++ b/src/KPropertyWidgetsFactory.h @@ -1,223 +1,223 @@ /* This file is part of the KDE project Copyright (C) 2008 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #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 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 KPROPERTYWIDGETS_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 KPROPERTYWIDGETS_EXPORT KPropertyValuePainterInterface { public: KPropertyValuePainterInterface(); virtual ~KPropertyValuePainterInterface(); virtual void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const = 0; }; class KPROPERTYWIDGETS_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 KPROPERTYWIDGETS_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 KPROPERTYWIDGETS_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; class KPROPERTYWIDGETS_EXPORT KPropertyWidgetsFactory : public KPropertyFactory { public: 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 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); //! 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 KPROPERTYWIDGETS_EXPORT KPropertyWidgetsFactoryManager : public KPropertyFactoryManager { 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(KPropertyWidgetsFactory *factory); KCustomProperty* createCustomProperty( KProperty *parent ); /*! \return a pointer to a factory manager instance.*/ static KPropertyWidgetsFactoryManager* self(); KPropertyWidgetsFactoryManager(); ~KPropertyWidgetsFactoryManager(); private: class Private; Private * const d; }; #endif diff --git a/src/config-kproperty.h.cmake b/src/config-kproperty.h.cmake index e5c9d32..f22c993 100644 --- a/src/config-kproperty.h.cmake +++ b/src/config-kproperty.h.cmake @@ -1,38 +1,38 @@ #ifndef KPROPERTY_CONFIG_H #define KPROPERTY_CONFIG_H /* config-kproperty.h. Generated by cmake from config-kproperty.h.cmake */ /*! @file config-kproperty.h Global KProperty configuration (build time) */ //! @def KPROPERTY_GIT_SHA1_STRING //! @brief Indicates the git sha1 commit which was used for compilation of KProperty #cmakedefine KPROPERTY_GIT_SHA1_STRING "@KPROPERTY_GIT_SHA1_STRING@" //! @def KPROPERTY_GIT_BRANCH_STRING //! @brief Indicates the git branch which was used for compilation of KProperty #cmakedefine KPROPERTY_GIT_BRANCH_STRING "@KPROPERTY_GIT_BRANCH_STRING@" //! @def BIN_INSTALL_DIR //! @brief The subdirectory relative to the install prefix for executables. #define BIN_INSTALL_DIR "${BIN_INSTALL_DIR}" //! @def KPROPERTY_TESTING_EXPORT //! @brief Export symbols for testing #ifdef BUILD_TESTING # define KPROPERTY_TESTING_EXPORT KPROPERTY_EXPORT #else # define KPROPERTY_TESTING_EXPORT #endif //! @def KPROPERTY_UNFINISHED //! @brief Defined if unfinished features of KProperty are enabled #cmakedefine KPROPERTY_UNFINISHED -//! @def KPROPERTY_WIDGET +//! @def KPROPERTY_WIDGETS //! @brief Defined if QtWidgets components of KProperty are enabled -#cmakedefine KPROPERTY_WIDGET +#cmakedefine KPROPERTY_WIDGETS #endif diff --git a/src/editors/combobox.cpp b/src/editors/combobox.cpp index 855aa77..6147676 100644 --- a/src/editors/combobox.cpp +++ b/src/editors/combobox.cpp @@ -1,294 +1,294 @@ /* This file is part of the KDE project Copyright (C) 2004 Cedric Pasteur Copyright (C) 2004 Alexander Dymo Copyright (C) 2008 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "combobox.h" #include "KPropertyEditorDataModel.h" #include "KPropertyEditorView.h" -#include "kpropertywidgets_debug.h" +#include "kproperty_debug.h" #include "KPropertyWidgetsFactory.h" #include #include KPropertyComboBoxEditor::Options::Options() : iconProvider(0) , extraValueAllowed(false) { } KPropertyComboBoxEditor::Options::Options(const KPropertyComboBoxEditor::Options& other) { *this = other; if (other.iconProvider) iconProvider = other.iconProvider->clone(); } KPropertyComboBoxEditor::Options::~Options() { delete iconProvider; } KPropertyComboBoxEditor::KPropertyComboBoxEditor(const KPropertyListData& listData, const Options& options, QWidget *parent) : QComboBox(parent) , m_setValueEnabled(true) , m_options(options) { // QHBoxLayout *l = new QHBoxLayout(this); // l->setMargin(0); // l->setSpacing(0); // m_edit = new KComboBox(this); // m_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // m_edit->setMinimumHeight(5); //setPlainWidgetStyle(m_edit); // l->addWidget(m_edit); setEditable( m_options.extraValueAllowed ); setInsertPolicy(QComboBox::NoInsert); // m_edit->setMinimumSize(10, 0); // to allow the combo to be resized to a small size setAutoCompletion(true); setContextMenuPolicy(Qt::NoContextMenu); // if (listData) setListData(listData); // if (property->listData()) { // fillValues(property); //} //not needed for combo setLeavesTheSpaceForRevertButton(true); // setFocusWidget(m_edit); connect(this, SIGNAL(activated(int)), this, SLOT(slotValueChanged(int))); setFrame(false); /* QList > children( findChildren() ); foreach (QWidget* w, children) { kprDebug() << w->objectName() << w->metaObject()->className(); w->setStyleSheet(QString()); }*/ //QComboBoxPrivateContainer //Set the stylesheet to a plain style QString styleSheet; QPalette p = QGuiApplication::palette(); QColor focus = p.highlight().color(); styleSheet = QString::fromLatin1("QComboBox { \ border: 1px solid %1; \ border-radius: 0px; \ padding: 0px 18px; }").arg(focus.name()); setStyleSheet(styleSheet); } KPropertyComboBoxEditor::~KPropertyComboBoxEditor() { } bool KPropertyComboBoxEditor::listDataKeysAvailable() const { if (m_listData.keys.isEmpty()) { - kprwWarning() << "property listData not available!"; + kprWarning() << "property listData not available!"; return false; } return true; } QVariant KPropertyComboBoxEditor::value() const { if (!listDataKeysAvailable()) return QVariant(); const int idx = currentIndex(); if (idx < 0 || idx >= (int)m_listData.keys.count() || m_listData.names[idx] != currentText().trimmed()) { if (!m_options.extraValueAllowed || currentText().isEmpty()) return QVariant(); return QVariant(currentText().trimmed());//trimmed 4 safety } return QVariant(m_listData.keys[idx]); } void KPropertyComboBoxEditor::setValue(const QVariant &value) { if (!listDataKeysAvailable()) return; if (!m_setValueEnabled) return; int idx = m_listData.keys.indexOf(value/*.toString()TODO*/); // kprDebug() << "**********" << idx << "" << value.toString(); if (idx >= 0 && idx < count()) { setCurrentIndex(idx); } else { if (idx < 0) { if (m_options.extraValueAllowed) { setCurrentIndex(-1); setEditText(value.toString()); } - kprwWarning() << "NO SUCH KEY:" << value.toString() + kprWarning() << "NO SUCH KEY:" << value.toString() << "property=" << objectName(); } else { QStringList list; for (int i = 0; i < count(); i++) list += itemText(i); - kprwWarning() << "NO SUCH INDEX WITHIN COMBOBOX:" << idx + kprWarning() << "NO SUCH INDEX WITHIN COMBOBOX:" << idx << "count=" << count() << "value=" << value.toString() << "property=" << objectName() << "\nActual combobox contents" << list; } setItemText(currentIndex(), QString()); } if (value.isNull()) return; //?? if (emitChange) //?? emit valueChanged(this); } void KPropertyComboBoxEditor::fillValues() { clear(); //m_edit->clearContents(); // if (!m_property) // return; if (!listDataKeysAvailable()) return; // m_keys = m_property->listData()->keys; int index = 0; foreach( const QString& itemName, m_listData.names ) { addItem(itemName); if (m_options.iconProvider) { QIcon icon = m_options.iconProvider->icon(index); setItemIcon(index, icon); } index++; } QCompleter *comp = new QCompleter(m_listData.names); comp->setWidget(this); } /* void ComboBox::setProperty( const Property *property ) { // const bool b = (property() == prop); // m_setValueEnabled = false; //setValue() couldn't be called before fillBox() // Widget::setProperty(prop); // m_setValueEnabled = true; // if (!b) // m_property = property; m_listData = *property->listData(); fillValues(); // if (prop) // setValue(prop->value(), false); //now the value can be set }*/ void KPropertyComboBoxEditor::setListData(const KPropertyListData & listData) { m_listData = listData; fillValues(); } void KPropertyComboBoxEditor::slotValueChanged(int) { // emit valueChanged(this); emit commitData( this ); } void KPropertyComboBoxEditor::paintEvent( QPaintEvent * event ) { QComboBox::paintEvent(event); KPropertyWidgetsFactory::paintTopGridLine(this); } /* void ComboBox::setReadOnlyInternal(bool readOnly) { setVisibleFlag(!readOnly); }*/ /*QString ComboBox::keyForValue(const QVariant &value) { const QMap *list = property()->valueList(); Property::ListData *list = property()->listData(); if (!list) return QString(); int idx = listData->keys.findIndex( value ); QMap::ConstIterator endIt = list->constEnd(); for(QMap::ConstIterator it = list->constBegin(); it != endIt; ++it) { if(it.data() == value) return it.key(); } return QString(); }*/ //----------------------- KPropertyComboBoxDelegate::KPropertyComboBoxDelegate() { options.removeBorders = false; } QString KPropertyComboBoxDelegate::displayTextForProperty( const KProperty* property ) const { KPropertyListData *listData = property->listData(); if (!listData) return property->value().toString(); if (property->value().isNull()) return QString(); //kprDebug() << "property->value()==" << property->value(); const int idx = listData->keys.indexOf( property->value() ); //kprDebug() << "idx==" << idx; if (idx == -1) { if (!property->option("extraValueAllowed").toBool()) return QString(); else return property->value().toString(); } return property->listData()->names[ idx ]; } QWidget* KPropertyComboBoxDelegate::createEditor( int type, QWidget *parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const { Q_UNUSED(type); Q_UNUSED(option); const KPropertyEditorDataModel *editorModel = dynamic_cast(index.model()); KProperty *property = editorModel->propertyForItem(index); KPropertyComboBoxEditor::Options options; options.extraValueAllowed = property->option("extraValueAllowed", false).toBool(); KPropertyComboBoxEditor *cb = new KPropertyComboBoxEditor(*property->listData(), options, parent); return cb; } /*void ComboBoxDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const { }*/ diff --git a/src/editors/spinbox.cpp b/src/editors/spinbox.cpp index 0d46f9e..fce7f06 100644 --- a/src/editors/spinbox.cpp +++ b/src/editors/spinbox.cpp @@ -1,290 +1,290 @@ /* This file is part of the KDE project Copyright (C) 2004 Cedric Pasteur Copyright (C) 2004 Alexander Dymo Copyright (C) 2008-2009 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "spinbox.h" #include "KProperty.h" #include "KProperty_p.h" #include "KPropertyEditorDataModel.h" #include "KPropertyEditorView.h" #include "KPropertyUnit_p.h" #include "KPropertyWidgetsFactory.h" -#include "kpropertywidgets_debug.h" +#include "kproperty_debug.h" #include #include #include #include //! @return font size expressed in points (pt) //! or if points are not available - in pixels (px) for @a font static QString fontSizeForCSS(const QFont& font) { return font.pointSize() > 0 ? QString::fromLatin1("%1pt").arg(font.pointSize()) : QString::fromLatin1("%1px").arg(font.pixelSize()); } static QString cssForSpinBox(const char *_class, const QFont& font, int itemHeight) { return QString::fromLatin1( "%5 { border-left: 0; border-right: 0; font-size: %3; } " "%5::down-button { height: %1px; %4 } " "%5::up-button { height: %2px; } " "QLineEdit { border-width:0px; } " ) .arg(itemHeight/2 - 1).arg(itemHeight - itemHeight/2 - 1) .arg(fontSizeForCSS(font)) .arg(QLatin1String((itemHeight/2 <= 9) ? "bottom: 2px;" : "bottom: 0px;")) .arg(QLatin1String(_class)); } KPropertyIntSpinBox::KPropertyIntSpinBox(const KProperty* prop, QWidget *parent, int itemHeight) : QSpinBox(parent) , m_unsigned(prop->type() == KProperty::UInt) { // kprDebug() << "itemHeight:" << itemHeight; QLineEdit* le = findChild(); setContentsMargins(0,0,0,0); if (le) { // le->setFixedHeight(itemHeight); le->setAlignment(Qt::AlignLeft); le->setContentsMargins(0,0,0,0); } // kprDebug() << parent->font().pointSize(); setFrame(true); QString css = cssForSpinBox("QSpinBox", font(), itemHeight); KPropertyWidgetsFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); setStyleSheet(css); QVariant minVal(prop->option("min", m_unsigned ? 0 : -INT_MAX)); QVariant maxVal(prop->option("max", INT_MAX)); setMinimum(minVal.toInt()); setMaximum(maxVal.toInt()); QString minValueText(prop->option("minValueText").toString()); if (!minValueText.isEmpty()) setSpecialValueText(minValueText); connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(int))); } KPropertyIntSpinBox::~KPropertyIntSpinBox() { } QVariant KPropertyIntSpinBox::value() const { if (m_unsigned) return uint(QSpinBox::value()); return QSpinBox::value(); } void KPropertyIntSpinBox::setValue(const QVariant& value) { int v( value.toInt() ); if (m_unsigned && v<0) { - kprwWarning() << "could not assign negative value" << v << "- assigning 0"; + kprWarning() << "could not assign negative value" << v << "- assigning 0"; v = 0; } QSpinBox::setValue(v); } void KPropertyIntSpinBox::slotValueChanged(int value) { Q_UNUSED(value); emit commitData(this); } //----------------------- class KPropertyDoubleSpinBox::Private { public: KPropertyUnit unit; bool hasUnit; }; static void decodeUnit(const KProperty &property, KPropertyUnit *unit, bool *hasUnit) { const QString unitString = property.option("unit").toString(); if (unitString.isEmpty()) { *hasUnit = false; } else { *unit = KPropertyUnit::fromSymbol(unitString, hasUnit); } } KPropertyDoubleSpinBox::KPropertyDoubleSpinBox(const KProperty* prop, QWidget *parent, int itemHeight) : QDoubleSpinBox(parent) , d(new Private) { setFrame(false); QLineEdit* le = findChild(); if (le) { le->setAlignment(Qt::AlignLeft); le->setContentsMargins(0,0,0,0); le->setFrame(false); } /* KPropertyFactory::setTopAndBottomBordersUsingStyleSheet(sb, parent, QString::fromLatin1( "QDoubleSpinBox { border-left: 0; border-right: 0; } " "QDoubleSpinBox::down-button { height: %1px; } " "QDoubleSpinBox::up-button { height: %2px; }" ).arg(itemHeight/2).arg(itemHeight - itemHeight/2) );*/ QString css = cssForSpinBox("QDoubleSpinBox", font(), itemHeight); KPropertyWidgetsFactory::setTopAndBottomBordersUsingStyleSheet(this, parent, css); setStyleSheet(css); QVariant minVal(prop->option("min")); if (minVal.canConvert(QMetaType::Double)) { setMinimum(minVal.toDouble()); } QVariant maxVal(prop->option("max", double(INT_MAX / 100))); if (maxVal.canConvert(QMetaType::Double)) { setMaximum(maxVal.toDouble()); } QVariant step(prop->option("step", KPROPERTY_DEFAULT_DOUBLE_VALUE_STEP)); if (step.canConvert(QMetaType::Double)) { setSingleStep(step.toDouble()); } //! @todo implement slider // bool slider = prop->option("slider", false).toBool(); QVariant precision(prop->option("precision")); if (precision.canConvert(QMetaType::Int)) { setDecimals(precision.toInt()); } QString minValueText(prop->option("minValueText").toString()); if (!minValueText.isEmpty()) setSpecialValueText(minValueText); decodeUnit(*prop, &d->unit, &d->hasUnit); connect(this, SIGNAL(valueChanged(double)), this, SLOT(slotValueChanged(double))); } KPropertyDoubleSpinBox::~KPropertyDoubleSpinBox() { delete d; } void KPropertyDoubleSpinBox::resizeEvent( QResizeEvent * event ) { setFixedHeight(height() + 1); QDoubleSpinBox::resizeEvent(event); } void KPropertyDoubleSpinBox::setValue(double v) { if (d->hasUnit) { QDoubleSpinBox::setValue(d->unit.toUserValue(v)); return; } QDoubleSpinBox::setValue(v); } double KPropertyDoubleSpinBox::value() const { if (d->hasUnit) { return d->unit.fromUserValue(QDoubleSpinBox::value()); } return QDoubleSpinBox::value(); } void KPropertyDoubleSpinBox::slotValueChanged(double value) { Q_UNUSED(value); emit commitData(this); } //----------------------- KPropertyIntSpinBoxDelegate::KPropertyIntSpinBoxDelegate() { } QString KPropertyIntSpinBoxDelegate::displayTextForProperty( const KProperty* prop ) const { if (prop->hasOptions()) { //replace min value with minValueText if defined QVariant minValue(prop->option("min")); QString minValueText(prop->option("minValueText").toString()); if (!minValue.isNull() && !minValueText.isEmpty() && minValue.toInt() == prop->value().toInt()) { return minValueText; } } return QString::number(prop->value().toInt()); } QWidget* KPropertyIntSpinBoxDelegate::createEditor( int type, QWidget *parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const { Q_UNUSED(type); const KPropertyEditorDataModel *editorModel = dynamic_cast(index.model()); KProperty *prop = editorModel->propertyForItem(index); return new KPropertyIntSpinBox(prop, parent, option.rect.height() - 2); } //----------------------- KPropertyDoubleSpinBoxDelegate::KPropertyDoubleSpinBoxDelegate() { } QString KPropertyDoubleSpinBoxDelegate::displayTextForProperty( const KProperty* prop ) const { KPropertyUnit unit; bool hasUnit; decodeUnit(*prop, &unit, &hasUnit); QLocale locale; if (prop->hasOptions()) { //replace min value with minValueText if defined QVariant minValue(prop->option("min")); QString minValueText(prop->option("minValueText").toString()); if (!minValue.isNull() && !minValueText.isEmpty() && minValue.toDouble() == prop->value().toDouble()) { if (hasUnit) return QObject::tr("%1 %2", " ").arg(minValueText).arg(unit.toString()); else return minValueText; } } //! @todo precision? //! @todo rounding using KLocale::formatNumber(const QString &numStr, bool round = true,int precision = 2)? if (hasUnit) { return QObject::tr("%1 %2", " ") .arg(locale.toString(prop->value().toDouble())).arg(unit.toString()); } return locale.toString(prop->value().toDouble()); } QWidget* KPropertyDoubleSpinBoxDelegate::createEditor( int type, QWidget *parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const { Q_UNUSED(type); const KPropertyEditorDataModel *editorModel = dynamic_cast(index.model()); KProperty *prop = editorModel->propertyForItem(index); return new KPropertyDoubleSpinBox(prop, parent, option.rect.height() - 2 - 1); } diff --git a/src/editors/utils.cpp b/src/editors/utils.cpp index d85655b..2549267 100644 --- a/src/editors/utils.cpp +++ b/src/editors/utils.cpp @@ -1,36 +1,36 @@ /* This file is part of the KDE project Copyright (C) 2008 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "utils.h" #include #include -KPROPERTYCORE_EXPORT void KPropertyUtils::setupDotDotDotButton(QPushButton *button, const QString& toolTip, const QString& whatsThis) +KPROPERTYWIDGETS_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()) button->setToolTip(toolTip); if (!whatsThis.isEmpty()) button->setWhatsThis(whatsThis); button->setFocusPolicy(Qt::NoFocus); button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); const QFontMetrics fm(button->font()); button->setFixedWidth(fm.width(button->text() + QLatin1String(" "))); } diff --git a/src/editors/utils.h b/src/editors/utils.h index 9238c25..6d4cf0d 100644 --- a/src/editors/utils.h +++ b/src/editors/utils.h @@ -1,38 +1,38 @@ /* This file is part of the KDE project Copyright (C) 2008 Jarosław Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KPROPERTY_EDITORS_UTILS_H #define KPROPERTY_EDITORS_UTILS_H -#include "kpropertycore_export.h" +#include "kpropertywidgets_export.h" #include class QPushButton; namespace KPropertyUtils { //! Sets up a "..." button with fine-tuned settings. -KPROPERTYCORE_EXPORT void setupDotDotDotButton(QPushButton *button, +KPROPERTYWIDGETS_EXPORT void setupDotDotDotButton(QPushButton *button, const QString& toolTip = QString(), const QString& whatsThis = QString()); } #endif diff --git a/src/kproperty_debug.cpp b/src/kproperty_debug.cpp index e3d07a9..9167de5 100644 --- a/src/kproperty_debug.cpp +++ b/src/kproperty_debug.cpp @@ -1,22 +1,22 @@ /* This file is part of the KDE project 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 License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kproperty_debug.h" -Q_LOGGING_CATEGORY(KPROPERTY_LOG, "org.kde.kproperty.core") +Q_LOGGING_CATEGORY(KPROPERTY_LOG, "org.kde.kproperty") diff --git a/src/kpropertywidgets_debug.cpp b/src/kpropertywidgets_debug.cpp deleted file mode 100644 index 07bcb30..0000000 --- a/src/kpropertywidgets_debug.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* This file is part of the KDE project - 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 - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. -*/ - -#include "kpropertywidgets_debug.h" -Q_LOGGING_CATEGORY(KPROPERTYW_LOG, "org.kde.kproperty.widgets") - diff --git a/src/kpropertywidgets_debug.h b/src/kpropertywidgets_debug.h deleted file mode 100644 index 7b67090..0000000 --- a/src/kpropertywidgets_debug.h +++ /dev/null @@ -1,30 +0,0 @@ -/* This file is part of the KDE project - 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 - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. -*/ - -#ifndef KPROPERTYWIDGETS_DEBUG_H -#define KPROPERTYWIDGETS_DEBUG_H - -#include -Q_DECLARE_LOGGING_CATEGORY(KPROPERTYW_LOG) - -#define kprwDebug(...) qCDebug(KPROPERTYW_LOG, __VA_ARGS__) -#define kprwWarning(...) qCWarning(KPROPERTYW_LOG, __VA_ARGS__) -#define kprwCritical(...) qCCritical(KPROPERTYW_LOG, __VA_ARGS__) - -#endif