diff --git a/CMakeLists.txt b/CMakeLists.txt index feac12c2..e66c7a61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,45 +1,46 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 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}) include(SetKReportCMakePolicies NO_POLICY_SCOPE) project(KReport VERSION 2.99.3) # Update this include(ECMGeneratePriFile) include(ECMPoQmTools) include(ECMSetupVersion) include(ECMInstallIcons) include(ECMOptionalAddSubdirectory) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings) include(KDECMakeSettings) include(KReportMacros) +include(KReportAddIconsRccFile) # Dependencies set(REQUIRED_QT_VERSION "5.3.0") set(REQUIRED_KF5_VERSION 5.7.0) set(REQUIRED_KPROPERTY_VERSION 2.99.3) # Required components to build this framework # TODO move Widgets/KF5WidgetsAddons-dependent part to a libKReportDesigner find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets Xml PrintSupport) find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED CoreAddons WidgetsAddons GuiAddons Config) find_package(KPropertyWidgets ${REQUIRED_KPROPERTY_VERSION} REQUIRED) get_git_revision_and_branch() add_tests() add_examples() add_unfinished_features_option() add_pc_file(${PROJECT_NAME}) add_subdirectory(src) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED I18n) ki18n_install(po) endif() feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) macro_display_feature_log() diff --git a/cmake/modules/KReportAddIconsRccFile.cmake b/cmake/modules/KReportAddIconsRccFile.cmake new file mode 100644 index 00000000..a5aa05ab --- /dev/null +++ b/cmake/modules/KReportAddIconsRccFile.cmake @@ -0,0 +1,87 @@ +# Copyright (C) 2016 Jarosław Staniek +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +add_custom_target(update_all_rcc + COMMENT "Updating all file lists for rcc icons files" +) + +# Builds and install an rcc file with icons. +# - resource subdirectory in the current build subdir is created +# - ${_target}.qrc is created based on icons/${_theme}/files.cmake +# - ${_target}.rcc is generated using rcc-qt5 +# - if _prefix is not empty, icons are placed in icons/${_prefix}/${_theme} path (useful for plugins) +# - dependency for the parent target ${_parent_target} is added +# - the .rcc file is installed to ${ICONS_INSTALL_DIR} +# - update_${_target} target is added for requesting update of icons/${_theme}/files.cmake +# - adds a update_all_rcc target that executes commands for all targets created with kreport_add_icons_rcc_file() +macro(kreport_add_icons_rcc_file _target _parent_target _theme _prefix) + set(_RESOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/resource) + set(_QRC_FILE "${_RESOURCE_DIR}/${_target}.qrc") + set(_RCC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${_target}.rcc") + include(icons/${_theme}/files.cmake) + + add_custom_target(${_target}_copy_icons + COMMAND ${CMAKE_COMMAND} -E remove_directory ${_RESOURCE_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_RESOURCE_DIR} + COMMAND ${CMAKE_COMMAND} -E copy_directory icons/${_theme} ${_RESOURCE_DIR}/icons/${_prefix}/${_theme} + COMMAND ${CMAKE_COMMAND} -E remove -f ${_RESOURCE_DIR}/CMakeLists.txt + COMMAND ${CMAKE_COMMAND} -E remove -f ${_RESOURCE_DIR}/icons/${_prefix}/${_theme}/files.cmake + DEPENDS "${_FILES}" + SOURCES "${_FILES}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Copying icon files to ${_RESOURCE_DIR}" + VERBATIM + ) + + add_custom_target(${_target}_build_qrc + COMMAND ${Qt5Core_RCC_EXECUTABLE} --project -o "${CMAKE_CURRENT_BINARY_DIR}/${_target}.qrc" + # avoid adding the .qrc file to rcc due to rcc misfeature + COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/${_target}.qrc" "${_QRC_FILE}" + DEPENDS "${_FILES}" + SOURCES "${_FILES}" + WORKING_DIRECTORY "${_RESOURCE_DIR}" + COMMENT "Building Qt resource file ${_QRC_FILE}" + VERBATIM + ) + add_dependencies(${_target}_build_qrc ${_target}_copy_icons) + + add_custom_target(${_target}_build_rcc + COMMAND ${Qt5Core_RCC_EXECUTABLE} --compress 9 --threshold 0 --binary + --output "${_RCC_FILE}" "${_QRC_FILE}" + #COMMAND ${CMAKE_COMMAND} -E remove -f ${_QRC_FILE} + DEPENDS "${_QRC_FILE}" "${_FILES}" + WORKING_DIRECTORY "${_RESOURCE_DIR}" + COMMENT "Building external Qt resource ${_RCC_FILE}" + VERBATIM + ) + add_dependencies(${_target}_build_rcc ${_target}_build_qrc) + + add_dependencies(${_parent_target} ${_target}_build_rcc) + + install(FILES + ${_RCC_FILE} + DESTINATION "${ICONS_INSTALL_DIR}" + ) + + add_update_file_target( + TARGET update_${_target} + COMMAND "${PROJECT_SOURCE_DIR}/cmake/modules/update_icon_list.sh" + ${_theme} icons/${_theme}/files.cmake + FILE ${_target}_files.cmake + SOURCES "${PROJECT_SOURCE_DIR}/cmake/modules/update_icon_list.sh" + ) + add_dependencies(update_all_rcc update_${_target}) + + unset(_RESOURCE_DIR) + unset(_QRC_FILE) + unset(_RCC_FILE) +endmacro() + +# Convenience macro for plugin icons. Icons are places in a path that contains _plugin_target. +# For example, icons/org.kde.kreport.barcode/breeze/actions/16/kreport-barcode-element.svg. +# This helps to make plugins not conflicting. +macro(kreport_add_plugin_icons_rcc_file _plugin_target _theme) + kreport_add_icons_rcc_file(${_plugin_target}_${_theme} ${_plugin_target} ${_theme} ${_plugin_target}) +endmacro() diff --git a/cmake/modules/KReportMacros.cmake b/cmake/modules/KReportMacros.cmake index 295934b5..75f2de7a 100644 --- a/cmake/modules/KReportMacros.cmake +++ b/cmake/modules/KReportMacros.cmake @@ -1,152 +1,186 @@ # Additional CMake macros # # Copyright (C) 2015-2016 Jarosław Staniek # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. include(KDbGenerateHeaders) # from KDb, adds support for generated headers to ECMGenerateHeaders include(KDbCreateSharedDataClasses) # from KDb include(GenerateExportHeader) include(MacroLogFeature) include(FeatureSummary) include(GetGitRevisionDescription) string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER) string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) string(COMPARE EQUAL "${CMAKE_CXX_COMPILER_ID}" "Clang" CMAKE_COMPILER_IS_CLANG) # x.80.y or larger means test release, so the stable major version is x+1 if(PROJECT_VERSION_MINOR GREATER 80) set(PROJECT_UNSTABLE ON) math(EXPR PROJECT_STABLE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR} + 1") else() set(PROJECT_STABLE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) endif() +if(WIN32) + set(LIB_INSTALL_DIR ${LIB_INSTALL_DIR} + RUNTIME DESTINATION ${BIN_INSTALL_DIR} + LIBRARY ${INSTALL_TARGETS_DEFAULT_ARGS} + ARCHIVE ${INSTALL_TARGETS_DEFAULT_ARGS} ) + set(DATA_INSTALL_DIR "$ENV{APPDATA}") + STRING(REGEX REPLACE "\\\\" "/" DATA_INSTALL_DIR ${DATA_INSTALL_DIR}) + # Install own icons to CMAKE_INSTALL_FULL_ICONDIR (relative to bin/data/ on Windows) on Windows. + # We're consistent because icons from breeze-icons.git are installed there as well. + set(ICONS_INSTALL_DIR ${CMAKE_INSTALL_FULL_ICONDIR}) +else() + # On other OSes install own icons in app's data dir + set(ICONS_INSTALL_DIR + "${DATA_INSTALL_DIR}/${PROJECT_NAME_LOWER}${PROJECT_STABLE_VERSION_MAJOR}/icons") +endif() + # Adds a feature info using add_feature_info() with _NAME and _DESCRIPTION. # If _NAME is equal to _DEFAULT, shows this fact. macro(add_simple_feature_info _NAME _DESCRIPTION _DEFAULT) if("${_DEFAULT}" STREQUAL "${${_NAME}}") set(_STATUS " (default value)") else() set(_STATUS "") endif() add_feature_info(${_NAME} ${_NAME} ${_DESCRIPTION}${_STATUS}) endmacro() # Adds a simple option using option() with _NAME and _DESCRIPTION and a feature # info for it using add_simple_feature_info(). If _NAME is equal to _DEFAULT, shows this fact. macro(simple_option _NAME _DESCRIPTION _DEFAULT) option(${_NAME} ${_DESCRIPTION} ${_DEFAULT}) add_simple_feature_info(${_NAME} ${_DESCRIPTION} ${_DEFAULT}) endmacro() # Fetches git revision and branch from the source dir of the current build if possible. # Sets ${PROJECT_NAME_UPPER}_GIT_SHA1_STRING and ${PROJECT_NAME_UPPER}_GIT_BRANCH_STRING variables. # If git information is not available but ${CMAKE_SOURCE_DIR}/GIT_VERSION file exists, # it is parsed. This file can be created by scripts while preparing tarballs and is # supposed to contain two lines: hash and branch. macro(get_git_revision_and_branch) set(${PROJECT_NAME_UPPER}_GIT_SHA1_STRING "") set(${PROJECT_NAME_UPPER}_GIT_BRANCH_STRING "") get_git_head_revision(GIT_REFSPEC ${PROJECT_NAME_UPPER}_GIT_SHA1_STRING) get_git_branch(${PROJECT_NAME_UPPER}_GIT_BRANCH_STRING) if(NOT ${PROJECT_NAME_UPPER}_GIT_SHA1_STRING OR NOT ${PROJECT_NAME_UPPER}_GIT_BRANCH_STRING) if(EXISTS "${CMAKE_SOURCE_DIR}/GIT_VERSION") file(READ "${CMAKE_SOURCE_DIR}/GIT_VERSION" _ver) string(REGEX REPLACE "\n" ";" _ver "${_ver}") list(GET _ver 0 ${PROJECT_NAME_UPPER}_GIT_SHA1_STRING) list(GET _ver 1 ${PROJECT_NAME_UPPER}_GIT_BRANCH_STRING) endif() endif() if(${PROJECT_NAME_UPPER}_GIT_SHA1_STRING OR ${PROJECT_NAME_UPPER}_GIT_BRANCH_STRING) string(SUBSTRING ${${PROJECT_NAME_UPPER}_GIT_SHA1_STRING} 0 7 ${PROJECT_NAME_UPPER}_GIT_SHA1_STRING) else() set(${PROJECT_NAME_UPPER}_GIT_SHA1_STRING "") set(${PROJECT_NAME_UPPER}_GIT_BRANCH_STRING "") endif() endmacro() # Adds BUILD_TESTING option to enable all kinds of tests. If enabled, build in autotests/ # and tests/ subdirectory is enabled. IF optional argument ARG1 is ON, building tests will # be ON by default. Otherwise building tests will be OFF. ARG1 is OFF by default. # If tests are OFF, BUILD_COVERAGE is set to OFF. # If tests are on BUILD_TESTING macro is defined. macro(add_tests) if (NOT "${ARG1}" STREQUAL "ON") set(_SET OFF) endif() simple_option(BUILD_TESTING "Build tests" ${_SET}) # override default from CTest.cmake if(BUILD_TESTING) add_definitions(-DBUILD_TESTING) include(CTest) if (EXISTS ${CMAKE_SOURCE_DIR}/autotests) add_subdirectory(autotests) endif() if (EXISTS ${CMAKE_SOURCE_DIR}/tests) add_subdirectory(tests) endif() else() set(BUILD_COVERAGE OFF) simple_option(BUILD_COVERAGE "Build test coverage (disabled because BUILD_TESTING is OFF)" OFF) endif() endmacro() # Adds BUILD_EXAMPLES option to enable examples. If enabled, build in examples/ subdirectory # is enabled. If optional argument ARG1 is ON, building examples will be ON by default. # Otherwise building examples will be OFF. ARG1 is OFF by default. macro(add_examples) set(_SET ${ARGV0}) if (NOT "${_SET}" STREQUAL ON) set(_SET OFF) endif() simple_option(BUILD_EXAMPLES "Build example applications" ${_SET}) if (BUILD_EXAMPLES AND EXISTS ${CMAKE_SOURCE_DIR}/examples) add_subdirectory(examples) endif() endmacro() # Adds ${PROJECT_NAME_UPPER}_UNFINISHED option. If it is ON, unfinished features # (useful for testing but may confuse end-user) are compiled-in. # This option is OFF by default. macro(add_unfinished_features_option) simple_option(${PROJECT_NAME_UPPER}_UNFINISHED "Include unfinished features (useful for testing but may confuse end-user)" OFF) endmacro() # Adds commands that generate ${_filename}${PROJECT_STABLE_VERSION_MAJOR}.pc file # out of ${_filename}.pc.cmake file and installs the .pc file to ${LIB_INSTALL_DIR}/pkgconfig. # These commands are not executed for WIN32. # ${CMAKE_SOURCE_DIR}/${_filename}.pc.cmake should exist. macro(add_pc_file _filename) if (NOT WIN32) set(_name ${_filename}${PROJECT_STABLE_VERSION_MAJOR}) configure_file(${CMAKE_SOURCE_DIR}/${_filename}.pc.cmake ${CMAKE_BINARY_DIR}/${_name}.pc @ONLY) install(FILES ${CMAKE_BINARY_DIR}/${_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) endif() endmacro() # Sets detailed version information for library co-installability. # - adds PROJECT_VERSION_MAJOR to the lib name # - sets VERSION and SOVERSION to PROJECT_VERSION_MAJOR.PROJECT_VERSION_MINOR # - sets ${_target_upper}_BASE_NAME variable to the final lib name # - sets ${_target_upper}_BASE_NAME_LOWER variable to the final lib name, lowercase # - sets ${_target_upper}_INCLUDE_INSTALL_DIR to include dir for library headers # - (where _target_upper is uppercase ${_target} macro(set_coinstallable_lib_version _target) set(_name ${_target}${PROJECT_STABLE_VERSION_MAJOR}) set_target_properties(${_target} PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} SOVERSION ${PROJECT_VERSION_MAJOR} EXPORT_NAME ${_target} OUTPUT_NAME ${_name} ) string(TOUPPER ${_target} _target_upper) string(TOUPPER ${_target_upper}_BASE_NAME _var) set(${_var} ${_name}) string(TOLOWER ${_name} ${_var}_LOWER) set(${_target_upper}_INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR}/${_name}) unset(_target_upper) unset(_var) endmacro() + +# Adds custom target ${_target} that updates file ${_file} in the current working dir +# using command ${_command} and add sources ${_sources} to the project files. +# The command is run as a part of the project. +function(add_update_file_target) + set(options) + set(oneValueArgs TARGET FILE) + set(multiValueArgs COMMAND SOURCES) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + add_custom_target(${ARG_TARGET} + COMMAND ${ARG_COMMAND} + SOURCES ${ARG_SOURCES} + DEPENDS ${ARG_SOURCES} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Updating ${ARG_FILE}" + VERBATIM + ) +endfunction() diff --git a/cmake/modules/update_icon_list.sh b/cmake/modules/update_icon_list.sh new file mode 100755 index 00000000..eb093c0d --- /dev/null +++ b/cmake/modules/update_icon_list.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# +# This file is part of the KDE project +# Copyright (C) 2016 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.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# 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. +# +# Updates list of icon files in icons/$1/ and outputs to $2. +# Used by kreport_add_icons_rcc_file() cmake macro. +# +set -e + +theme=$1 +output=$2 +if [ -z "$theme" ] ; then echo "Theme name required as first argument"; exit 1; fi +if [ -z "$output" ] ; then echo "Output .cmake file required as second argument"; exit 1; fi +script=$(basename $0) + +function content() +{ + echo "# List of project's own icon files" + echo "# This file is generated by $script" + echo "# WARNING! All changes made in this file will be lost!" + echo + echo "set(_PNG_FILES" + find icons/$theme/ -name \*png | sed "s/\.\///g" | sort + echo ")" + echo + + echo "set(_SVG_FILES" + find icons/$theme/ -name \*svg | sed "s/\.\///g" | sort + echo ")" + echo + + echo "set(_FILES \${_PNG_FILES} \${_SVG_FILES})" +} + +content > $output diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index cabf69e3..f8ac5184 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,19 +1,19 @@ find_package(Qt5Widgets REQUIRED) find_package(KF5WidgetsAddons) find_package(KF5GuiAddons) remove_definitions( -DQT_NO_KEYWORDS -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_CAST_FROM_ASCII ) add_definitions(-DKREPORTEXAMPLE_DATA_DIR="\\"${CMAKE_CURRENT_SOURCE_DIR}\\"") set(kreportexample_SRCS main.cpp window.cpp DesignerWidget.cpp KReportExampleData.cpp ) add_executable(kreportexample ${kreportexample_SRCS}) -target_link_libraries(kreportexample Qt5::Widgets KReport) +target_link_libraries(kreportexample KF5::ConfigGui KReport) diff --git a/examples/main.cpp b/examples/main.cpp index 7b5d4b58..6548ed88 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -1,39 +1,40 @@ /* This file is part of the KDE project Copyright (C) 2015 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.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 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 #include "window.h" #include +#include //static const char description[] = "An example application for the KReport library"; int main(int argc, char **argv) { QApplication app(argc, argv); QCoreApplication::setApplicationName("KReportExample"); QCoreApplication::setApplicationVersion(KREPORT_VERSION_STRING); QCoreApplication::setOrganizationDomain("kde.org"); - + (void)KReportPrivate::setupGlobalIconTheme(); Window window; window.show(); return app.exec(); } diff --git a/src/common/KReportPluginManager.cpp b/src/common/KReportPluginManager.cpp index d8bb1657..370a10e2 100644 --- a/src/common/KReportPluginManager.cpp +++ b/src/common/KReportPluginManager.cpp @@ -1,305 +1,320 @@ /* This file is part of the KDE project Copyright (C) 2010 by Adam Pigg (adam@piggz.co.uk) - Copyright (C) 2015 Jarosław Staniek + Copyright (C) 2015-2016 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.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 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 "KReportPluginManager.h" #include "KReportPluginManagerPrivate.h" #include "KReportPluginMetaData.h" #include "KReportJsonTrader_p.h" +#include "KReportUtils_p.h" #include "kreport_debug.h" #include //Include the static items #include "../items/label/KReportLabelPlugin.h" #include "../items/check/KReportCheckBoxPlugin.h" #include "../items/field/KReportFieldPlugin.h" #include "../items/image/KReportImagePlugin.h" #include "../items/text/KReportTextPlugin.h" KReportPluginManager::Private::Private(KReportPluginManager *qq) : q(qq), m_parent(new QObject), m_findPlugins(true) { Q_UNUSED(q); } // --- KReportPluginEntry::KReportPluginEntry() : m_loader(0), m_interface(0), m_metaData(0) { } KReportPluginEntry::KReportPluginEntry(KReportPluginInterface *staticInterface) : m_loader(0), m_interface(staticInterface), m_metaData(0) { } KReportPluginEntry::~KReportPluginEntry() { delete m_metaData; delete m_interface; } KReportPluginInterface* KReportPluginEntry::plugin() { if (m_interface) { return m_interface; } if (!m_loader) { kreportWarning() << "No such plugin"; return 0; } if (!m_loader->load()) { kreportWarning() << "Could not load plugin" << m_loader->fileName(); return 0; } KPluginFactory *factory = qobject_cast(m_loader->instance()); if (!factory) { kreportWarning() << "Could not create factory for plugin" << m_loader->fileName(); return 0; } m_interface = factory->create(); if (!m_interface) { kreportWarning() << "Could not create instance of plugin" << m_loader->fileName(); return 0; } m_interface->setMetaData(m_metaData); return m_interface; } void KReportPluginEntry::setBuiltIn(bool set) { m_metaData->setBuiltIn(set); } void KReportPluginEntry::setStatic(bool set) { m_metaData->setStatic(set); } const KReportPluginMetaData *KReportPluginEntry::metaData() const { return m_metaData; } void KReportPluginEntry::setMetaData(KReportPluginMetaData *metaData) { delete m_metaData; m_metaData = metaData; if (m_interface) { m_interface->setMetaData(m_metaData); } } void KReportPluginEntry::setMetaData(const QJsonObject &metaData) { setMetaData(new KReportPluginMetaData(metaData)); } void KReportPluginEntry::setMetaData(QPluginLoader *loader) { m_loader = loader; setMetaData(new KReportPluginMetaData(*m_loader)); } // --- KReportPluginManager::Private::~Private() { delete m_parent; } template void KReportPluginManager::Private::addBuiltInPlugin(const QJsonObject &json) { KReportPluginEntry *entry = new KReportPluginEntry(new PluginClass(m_parent)); QJsonObject j = json.value(QLatin1String("MetaData")).toObject(); //kreportDebug() << j; entry->setMetaData(j); entry->setBuiltIn(true); if (entry->metaData()->id().isEmpty()) { kreportWarning() << "Plugin" << entry->metaData()->name() << "has no identifier so won't be added to manager"; delete entry; return; } entry->setStatic(true); m_plugins.insert(entry->metaData()->id(), entry); m_pluginsByLegacyName.insert(entry->metaData()->value(QLatin1String("X-KDE-PluginInfo-LegacyName"), entry->metaData()->id()), entry); } #if 0 //! Typedef of plugin version matching the one exported by KEXI_EXPORT_PLUGIN. typedef quint32 (*plugin_version_t)(); bool loadPlugin(KService::Ptr service) { if (service.isNull()) { kreportWarning() << "No service specified"; return; } kreportDebug() << "library:" << service->library(); QPluginLoader loader(service->library()); QLibrary lib(loader.fileName()); plugin_version_t plugin_version_function = (plugin_version_t)lib.resolve("plugin_version"); if (!plugin_version_function) { kreportWarning() << "Plugin version not found for" << service->name(); return; } quint32 foundVersion = plugin_version_function(); kreportDebug() << "foundVersion:" << d->foundVersion; QPointer factory = loader.factory(); if (!d->factory) { kreportWarning() << "Failed to create instance of factory for plugin" << ptr->name(); return; } QString pluginName; if (!pluginNameProperty.isEmpty()) { pluginName = ptr->property(pluginNameProperty).toString(); } if (!factory()) return 0; KReportPluginInterface* plugin = factory()->create(parent); if (plugin) { plugin->setObjectName(pluginName()); } return plugin; } #endif #define KREPORT_ADD_BUILTIN_PLUGIN(name) \ addBuiltInPlugin(KREPORT_STATIC_PLUGIN_METADATA(name)) QMap* KReportPluginManager::Private::plugins() { if (m_findPlugins) { findPlugins(); } return &m_plugins; } QMap* KReportPluginManager::Private::pluginsByLegacyName() { if (m_findPlugins) { findPlugins(); } return &m_pluginsByLegacyName; } void KReportPluginManager::Private::findPlugins() { KREPORT_ADD_BUILTIN_PLUGIN(KReportLabelPlugin); KREPORT_ADD_BUILTIN_PLUGIN(KReportCheckBoxPlugin); KREPORT_ADD_BUILTIN_PLUGIN(KReportFieldPlugin); KREPORT_ADD_BUILTIN_PLUGIN(KReportImagePlugin); KREPORT_ADD_BUILTIN_PLUGIN(KReportTextPlugin); //kreportDebug() << "Load all plugins"; const QList offers = KReportJsonTrader::self()->query(QLatin1String("KReport/Element")); foreach(QPluginLoader *loader, offers) { //QJsonObject json = loader->metaData(); //kreportDebug() << json; //! @todo check version KReportPluginEntry *entry = new KReportPluginEntry; entry->setMetaData(loader); + if (!KReportPrivate::setupPrivateIconsResourceWithMessage( + QLatin1String(KREPORT_BASE_NAME_LOWER), + QString::fromLatin1("icons/%1_%2.rcc") + .arg(entry->metaData()->id()).arg(KReportPrivate::supportedIconTheme), + QtWarningMsg, + QString::fromLatin1(":/icons/%1").arg(entry->metaData()->id()))) + { + delete entry; + continue; + } m_plugins.insert(entry->metaData()->id(), entry); - if (entry->metaData()->id().startsWith(QLatin1String("org.kde.kreport"))) { - m_pluginsByLegacyName.insert(entry->metaData()->value(QLatin1String("X-KDE-PluginInfo-LegacyName"), entry->metaData()->id()), entry); + const QString legacyName(entry->metaData()->value(QLatin1String("X-KDE-PluginInfo-LegacyName"), entry->metaData()->id())); + if (!legacyName.isEmpty() && entry->metaData()->id().startsWith(QLatin1String("org.kde.kreport"))) { + m_pluginsByLegacyName.insert(legacyName, entry); } } m_findPlugins = false; } // --- //! Class for access to KReportPluginManager constructor class KReportPluginManagerSingleton { public: KReportPluginManager object; }; KReportPluginManager::KReportPluginManager() : d(new Private(this)) { + KReportPrivate::setupPrivateIconsResourceWithMessage( + QLatin1String(KREPORT_BASE_NAME_LOWER), + QString::fromLatin1("icons/kreport_%1.rcc").arg(KReportPrivate::supportedIconTheme), QtFatalMsg); } KReportPluginManager::~KReportPluginManager() { delete d; } Q_GLOBAL_STATIC(KReportPluginManagerSingleton, s_self) KReportPluginManager* KReportPluginManager::self() { return &s_self->object; } QStringList KReportPluginManager::pluginIds() const { return d->plugins()->keys(); } const KReportPluginMetaData *KReportPluginManager::pluginMetaData(const QString& id) const { KReportPluginEntry *entry = d->plugins()->value(id); if (!entry) { return 0; } return entry->metaData(); } KReportPluginInterface* KReportPluginManager::plugin(const QString& id) const { KReportPluginEntry *entry; entry = d->plugins()->value(id); if (!entry) { entry = d->pluginsByLegacyName()->value(id); } if (!entry) { return 0; } return entry->plugin(); } QList KReportPluginManager::createActions(QObject *parent) { Q_ASSERT(parent); const QMap *plugins = d->plugins(); QList actList; foreach(KReportPluginEntry* plugin, *plugins) { const KReportPluginMetaData *metaData = plugin->metaData(); if (metaData) { QAction *act = new QAction(QIcon::fromTheme(metaData->iconName()), metaData->name(), parent); act->setObjectName(metaData->id()); act->setCheckable(true); //Store the order priority in the user data field act->setData(metaData->priority()); actList << act; } } return actList; } diff --git a/src/common/KReportSectionData.cpp b/src/common/KReportSectionData.cpp index 58652a2c..ac3252a8 100644 --- a/src/common/KReportSectionData.cpp +++ b/src/common/KReportSectionData.cpp @@ -1,221 +1,221 @@ /* This file is part of the KDE project * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com) * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk) * Copyright (C) 2010 Jarosław Staniek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "KReportSectionData.h" #include "KReportDocument.h" #include "KReportPluginInterface.h" #include "KReportPluginManager.h" #include "KReportItemLine.h" #include "KReportDesigner.h" #include "kreport_debug.h" #include #include KReportSectionData::KReportSectionData(QObject* parent) : QObject(parent) { createProperties(QDomElement()); } KReportSectionData::KReportSectionData(const QDomElement & elemSource, KReportDocument* report) : QObject(report) { setObjectName(elemSource.tagName()); if (objectName() != QLatin1String("report:section")) { m_valid = false; return; } m_type = sectionTypeFromString(elemSource.attribute(QLatin1String("report:section-type"))); if (m_type == KReportSectionData::None) { m_valid = false; return; } createProperties(elemSource); m_backgroundColor->setValue(QColor(elemSource.attribute(QLatin1String("fo:background-color")))); KReportPluginManager* manager = KReportPluginManager::self(); QDomNodeList section = elemSource.childNodes(); for (int nodeCounter = 0; nodeCounter < section.count(); nodeCounter++) { QDomElement elemThis = section.item(nodeCounter).toElement(); QString n = elemThis.tagName(); if (n.startsWith(QLatin1String("report:"))) { QString reportItemName = n.mid(qstrlen("report:")); if (reportItemName == QLatin1String("line")) { KReportItemLine * line = new KReportItemLine(elemThis); m_objects.append(line); continue; } KReportPluginInterface *plugin = manager->plugin(reportItemName); if (plugin) { QObject *obj = plugin->createRendererInstance(elemThis); if (obj) { KReportItemBase *krobj = dynamic_cast(obj); if (krobj) { m_objects.append(krobj); } continue; } } } kreportWarning() << "While parsing section encountered an unknown element: " << n; } qSort(m_objects.begin(), m_objects.end(), zLessThan); m_valid = true; } KReportSectionData::~KReportSectionData() { delete m_set; qDeleteAll(m_objects); } bool KReportSectionData::zLessThan(KReportItemBase* s1, KReportItemBase* s2) { return s1->Z < s2->Z; } bool KReportSectionData::xLessThan(KReportItemBase* s1, KReportItemBase* s2) { return s1->position().toPoint().x() < s2->position().toPoint().x(); } void KReportSectionData::createProperties(const QDomElement & elemSource) { m_set = new KPropertySet(this); KReportDesigner::addMetaProperties(m_set, - tr("Section", "Report section"), QLatin1String("kreport_section_element")); + tr("Section", "Report section"), QLatin1String("kreport-section-element")); m_height = new KProperty("height", KReportUnit(KReportUnit::Centimeter).fromUserValue(2.0), tr("Height")); m_backgroundColor = new KProperty("background-color", QColor(Qt::white), tr("Background Color")); m_height->setOption("unit", QLatin1String("cm")); if (!elemSource.isNull()) m_height->setValue(KReportUnit::parseValue(elemSource.attribute(QLatin1String("svg:height"), QLatin1String("2.0cm")))); m_set->addProperty(m_height); m_set->addProperty(m_backgroundColor); } QString KReportSectionData::name() const { return (objectName() + QLatin1Char('-') + sectionTypeString(m_type)); } QString KReportSectionData::sectionTypeString(KReportSectionData::Section s) { //! @todo use QMap QString sectiontype; switch (s) { case KReportSectionData::PageHeaderAny: sectiontype = QLatin1String("header-page-any"); break; case KReportSectionData::PageHeaderEven: sectiontype = QLatin1String("header-page-even"); break; case KReportSectionData::PageHeaderOdd: sectiontype = QLatin1String("header-page-odd"); break; case KReportSectionData::PageHeaderFirst: sectiontype = QLatin1String("header-page-first"); break; case KReportSectionData::PageHeaderLast: sectiontype = QLatin1String("header-page-last"); break; case KReportSectionData::PageFooterAny: sectiontype = QLatin1String("footer-page-any"); break; case KReportSectionData::PageFooterEven: sectiontype = QLatin1String("footer-page-even"); break; case KReportSectionData::PageFooterOdd: sectiontype = QLatin1String("footer-page-odd"); break; case KReportSectionData::PageFooterFirst: sectiontype = QLatin1String("footer-page-first"); break; case KReportSectionData::PageFooterLast: sectiontype = QLatin1String("footer-page-last"); break; case KReportSectionData::ReportHeader: sectiontype = QLatin1String("header-report"); break; case KReportSectionData::ReportFooter: sectiontype = QLatin1String("footer-report"); break; case KReportSectionData::GroupHeader: sectiontype = QLatin1String("group-header"); break; case KReportSectionData::GroupFooter: sectiontype = QLatin1String("group-footer"); break; case KReportSectionData::Detail: sectiontype = QLatin1String("detail"); break; default: ; } return sectiontype; } KReportSectionData::Section KReportSectionData::sectionTypeFromString(const QString& s) { //! @todo use QMap KReportSectionData::Section sec; //kreportDebug() << "Determining section type for " << s; if (s == QLatin1String("header-page-any")) sec = KReportSectionData::PageHeaderAny; else if (s == QLatin1String("header-page-even")) sec = KReportSectionData::PageHeaderEven; else if (s == QLatin1String("header-page-odd")) sec = KReportSectionData::PageHeaderOdd; else if (s == QLatin1String("header-page-first")) sec = KReportSectionData::PageHeaderFirst; else if (s == QLatin1String("header-page-last")) sec = KReportSectionData::PageHeaderLast; else if (s == QLatin1String("header-report")) sec = KReportSectionData::ReportHeader; else if (s == QLatin1String("footer-page-any")) sec = KReportSectionData::PageFooterAny; else if (s == QLatin1String("footer-page-even")) sec = KReportSectionData::PageFooterEven; else if (s == QLatin1String("footer-page-odd")) sec = KReportSectionData::PageFooterOdd; else if (s == QLatin1String("footer-page-first")) sec = KReportSectionData::PageFooterFirst; else if (s == QLatin1String("footer-page-last")) sec = KReportSectionData::PageFooterLast; else if (s == QLatin1String("footer-report")) sec = KReportSectionData::ReportFooter; else if (s == QLatin1String("group-header")) sec = KReportSectionData::GroupHeader; else if (s == QLatin1String("group-footer")) sec = KReportSectionData::GroupFooter; else if (s == QLatin1String("detail")) sec = KReportSectionData::Detail; else sec = KReportSectionData::None; return sec; } diff --git a/src/common/KReportUtils_p.h b/src/common/KReportUtils_p.h new file mode 100644 index 00000000..701f5f7a --- /dev/null +++ b/src/common/KReportUtils_p.h @@ -0,0 +1,346 @@ +/* This file is part of the KDE project + Copyright (C) 2015-2016 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.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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 KREPORTUTILS_P_H +#define KREPORTUTILS_P_H + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +// This is a private code made inline for use in the lib and examples. +//! @todo Move to a shared lib to use in other Kexi libraries as well. + +namespace KReportPrivate { + +//! @todo Support other themes +const QString supportedIconTheme = QLatin1String("breeze"); + +//! @brief @return true if @a path is readable +bool fileReadable(const QString &path) +{ + return !path.isEmpty() && QFileInfo(path).isReadable(); +} + +//! @brief Used for a workaround: locations for QStandardPaths::AppDataLocation end with app name. +//! If this is not an expected app but for example a test app, replace +//! the subdir name with app name so we can find resource file(s). +QStringList correctStandardLocations(const QString &privateName, + QStandardPaths::StandardLocation location, + const QString &extraLocation) +{ + QStringList result; + if (!privateName.isEmpty()) { + QRegularExpression re(QLatin1Char('/') + QCoreApplication::applicationName() + QLatin1Char('$')); + QStringList standardLocations(QStandardPaths::standardLocations(location)); + if (!extraLocation.isEmpty()) { + standardLocations.append(extraLocation); + } + for(const QString &dir : standardLocations) { + if (dir.indexOf(re) != -1) { + QString realDir(dir); + realDir.replace(re, QLatin1Char('/') + privateName); + result.append(realDir); + } + } + } + return result; +} + +/*! @brief Locates a file path for specified parameters + * @param privateName Name to be used instead of application name for resource lookup + * @param path Relative path to the resource file + * @param location Standard file location to use for file lookup + * @param extraLocation Extra directory path for file lookup + * @return Empty string on failure + */ +QString locateFile(const QString &privateName, + const QString& path, QStandardPaths::StandardLocation location, + const QString &extraLocation) +{ + // let QStandardPaths handle this, it will look for app local stuff + QString fullPath = QFileInfo( + QStandardPaths::locate(location, path)).canonicalFilePath(); + if (fileReadable(fullPath)) { + return fullPath; + } + + // Try extra location + fullPath = QFileInfo(extraLocation + QLatin1Char('/') + path).canonicalFilePath(); + if (fileReadable(fullPath)) { + return fullPath; + } + + const QStringList correctedStandardLocations(correctStandardLocations(privateName, location, extraLocation)); + for(const QString &dir : correctedStandardLocations) { + fullPath = QFileInfo(dir + QLatin1Char('/') + path).canonicalFilePath(); + if (fileReadable(fullPath)) { + return fullPath; + } + } + return QString(); +} + +/*! @brief Registers icons resource file + * @param privateName Name to be used instead of application name for resource lookup + * @param path Relative path to the resource file + * @param location Standard file location to use for file lookup + * @param resourceRoot A resource root for QResource::registerResource() + * @param errorMessage On failure it is set to a brief error message. + * @param errorDescription On failure it is set to a detailed error message. + * other for warning + */ +bool registerIconsResource(const QString &privateName, const QString& path, + QStandardPaths::StandardLocation location, + const QString &resourceRoot, const QString &extraLocation, + QString *errorMessage, QString *detailedErrorMessage) +{ + const QString fullPath = locateFile(privateName, path, location, extraLocation); + if (fullPath.isEmpty() || !QFileInfo(fullPath).isReadable() + || !QResource::registerResource(fullPath, resourceRoot)) + { + QStringList triedLocations(QStandardPaths::standardLocations(location)); + if (!extraLocation.isEmpty()) { + triedLocations.append(extraLocation); + } + triedLocations.append(correctStandardLocations(privateName, location, extraLocation)); + const QString triedLocationsString = QLocale().createSeparatedList(triedLocations); +#ifdef QT_ONLY + *errorMessage = QString("Could not open icon resource file %1.").arg(path); + *detailedErrorMessage = QString("Tried to find in %1.").arg(triedLocationsString); +#else + //! @todo 3.1 Re-add translation + *errorMessage = /*QObject::tr*/ QString::fromLatin1( + "Could not open icon resource file \"%1\". " + "Application will not start. " + "Please check if it is properly installed.") + .arg(QFileInfo(path).fileName()); + //! @todo 3.1 Re-add translation + *detailedErrorMessage = QString::fromLatin1("Tried to find in %1.").arg(triedLocationsString); +#endif + return false; + } + *errorMessage = QString(); + *detailedErrorMessage = QString(); + return true; +} + +/*! @brief Registers a global icon resource file + * @param themeName A name of icon theme to use. + * @param errorMessage On failure it is set to a brief error message. + * @param errorDescription On failure it is set to a detailed error message. + * other for warning + */ +bool registerGlobalIconsResource(const QString &themeName, + QString *errorMessage, + QString *detailedErrorMessage) +{ + QString extraLocation; +#ifdef CMAKE_INSTALL_FULL_ICONDIR + extraLocation = QDir::fromNativeSeparators(QFile::decodeName(CMAKE_INSTALL_FULL_ICONDIR)); + if (extraLocation.endsWith("/icons")) { + extraLocation.chop(QLatin1String("/icons").size()); + } +#elif defined(Q_OS_WIN) + extraLocation = QCoreApplication::applicationDirPath() + QStringLiteral("/data"); +#endif + return registerIconsResource(QString(), QString::fromLatin1("icons/%1/%1-icons.rcc").arg(themeName), + QStandardPaths::GenericDataLocation, + QStringLiteral("/icons/") + themeName, + extraLocation, errorMessage, + detailedErrorMessage); +} + +/*! @brief Registers a global icon resource file + * @param themeName A name of icon theme to use. + */ +bool registerGlobalIconsResource(const QString &themeName) +{ + QString errorMessage; + QString detailedErrorMessage; + if (!registerGlobalIconsResource(themeName, &errorMessage, &detailedErrorMessage)) { + if (detailedErrorMessage.isEmpty()) { + KMessageBox::error(nullptr, errorMessage); + } else { + KMessageBox::detailedError(nullptr, errorMessage, detailedErrorMessage); + } + qWarning() << qPrintable(errorMessage); + return false; + } + return true; +} + +/*! @brief Registers a global icon resource file for default theme name. + */ +bool registerGlobalIconsResource() +{ + return registerGlobalIconsResource(supportedIconTheme); +} + +/*! @brief Sets up a private icon resource file + * @return @c false on failure and sets error message. Does not warn or exit on failure. + * @param privateName Name to be used instead of application name for resource lookup + * @param path Relative path to the resource file + * @param themeName Icon theme to use. It affects filename. + * @param errorMessage On failure it is set to a brief error message + * @param errorDescription On failure it is set to a detailed error message + * other for warning + * @param prefix Resource path prefix. The default is useful for library-global resource, + * other values is useful for plugins. + */ +bool setupPrivateIconsResource(const QString &privateName, const QString& path, + const QString &themeName, + QString *errorMessage, QString *detailedErrorMessage, + const QString &prefix = QLatin1String(":/icons")) +{ + // Register application's resource first to have priority over the theme. + // Some icons may exists in both resources. + if (!registerIconsResource(privateName, path, + QStandardPaths::AppDataLocation, + QString(), QString(), errorMessage, detailedErrorMessage)) + { + return false; + } + bool changeTheme = false; +#ifdef QT_GUI_LIB + QIcon::setThemeSearchPaths(QStringList() << prefix << QIcon::themeSearchPaths()); + changeTheme = 0 != QIcon::themeName().compare(themeName, Qt::CaseInsensitive); + if (changeTheme) { + QIcon::setThemeName(themeName); + } +#endif + + KConfigGroup cg(KSharedConfig::openConfig(), "Icons"); + changeTheme = changeTheme || 0 != cg.readEntry("Theme", QString()).compare(themeName, Qt::CaseInsensitive); + // tell KIconLoader an co. about the theme + if (changeTheme) { + cg.writeEntry("Theme", themeName); + cg.sync(); + } + return true; +} + +/*! @brief Sets up a private icon resource file + * @return @c false on failure and sets error message. + * @param privateName Name to be used instead of application name for resource lookup + * @param path Relative path to the resource file + * @param themeName Icon theme to use. It affects filename. + * @param errorMessage On failure it is set to a brief error message. + * @param errorDescription On failure it is set to a detailed error message. + * other for warning + * @param prefix Resource path prefix. The default is useful for library-global resource, + * other values is useful for plugins. + */ +bool setupPrivateIconsResourceWithMessage(const QString &privateName, const QString& path, + const QString &themeName, + QString *errorMessage, QString *detailedErrorMessage, + const QString &prefix = QLatin1String(":/icons")) +{ + if (!setupPrivateIconsResource(privateName, path, themeName, + errorMessage, detailedErrorMessage, prefix)) + { + if (detailedErrorMessage->isEmpty()) { + KMessageBox::error(nullptr, *errorMessage); + } else { + KMessageBox::detailedError(nullptr, *errorMessage, *detailedErrorMessage); + } + return false; + } + return true; +} + +/*! @overload setupPrivateIconsResourceWithMessage(QString &privateName, const QString& path, + const QString &themeName, + QString *errorMessage, QString *detailedErrorMessage, + const QString &prefix = QLatin1String(":/icons")) + Uses default theme name. + */ +bool setupPrivateIconsResourceWithMessage(const QString &privateName, const QString& path, + QString *errorMessage, QString *detailedErrorMessage, + const QString &prefix = QLatin1String(":/icons")) +{ + return setupPrivateIconsResourceWithMessage(privateName, path, supportedIconTheme, + errorMessage, detailedErrorMessage, prefix); +} + +/*! @brief Sets up a private icon resource file + * Warns on failure and returns @c false. + * @param privateName Name to be used instead of application name for resource lookup + * @param path Relative path to the resource file + * @param messageType Type of message to use on error, QtFatalMsg for fatal exit and any + * other for warning + * @param prefix Resource path prefix. The default is useful for library-global resource, + * other values is useful for plugins. + */ +bool setupPrivateIconsResourceWithMessage(const QString &privateName, const QString& path, + QtMsgType messageType, + const QString &prefix = QLatin1String(":/icons")) +{ + QString errorMessage; + QString detailedErrorMessage; + if (!setupPrivateIconsResourceWithMessage(privateName, path, + &errorMessage, &detailedErrorMessage, prefix)) { + if (messageType == QtFatalMsg) { + qFatal("%s %s", qPrintable(errorMessage), qPrintable(detailedErrorMessage)); + } else { + qWarning() << qPrintable(errorMessage) << qPrintable(detailedErrorMessage); + } + return false; + } + return true; +} + +//! Sets up a global icon theme if it is different from supported. +//! Warns on failure and returns @c false. +bool setupGlobalIconTheme() +{ + if (0 != QIcon::themeName().compare(supportedIconTheme, Qt::CaseInsensitive)) { + const QString message = QString::fromLatin1( + "\"%1\" supports only \"%2\" icon theme but current system theme is \"%3\". " + "Application's icon theme will be changed to \"%2\". " + "Please consider adding support for other themes to %4.") + .arg(QLatin1String(KREPORT_BASE_NAME)).arg(supportedIconTheme).arg(QIcon::themeName()) + .arg(QCoreApplication::applicationName()); + qDebug() << qPrintable(message); + if (!registerGlobalIconsResource()) { + // don't fail, just warn + const QString message = QString::fromLatin1( + "Failed to set icon theme to \"%1\". Icons in the application will be inconsistent. " + "Please install .rcc file(s) for the system theme.") + .arg(supportedIconTheme); + qDebug() << qPrintable(message); + return false; + } + } + return true; +} + +} // KReportPrivate + +#endif diff --git a/src/items/check/check.json b/src/items/check/check.json index b548d9cf..87b5a25d 100644 --- a/src/items/check/check.json +++ b/src/items/check/check.json @@ -1,75 +1,75 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[it]": "La squadra di Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Check box element for Reports", "Description[ca@valencia]": "Element de casella de selecció per informes", "Description[ca]": "Element de casella de selecció per informes", "Description[de]": "Ankreuzfeld für Berichte", "Description[en_GB]": "Tick box element for Reports", "Description[es]": "Elemento de casilla de verificación para Reports", "Description[fi]": "Valintaruutuelementti raportteihin", "Description[gl]": "Caixa de verificación para informes.", "Description[it]": "Elemento «casella» per rapporti", "Description[nl]": "Keuzevakje-element voor rapporten", "Description[pl]": "Element pora wyboru dla raportów", "Description[pt]": "Elemento de opção de marcação para os Relatórios", "Description[pt_BR]": "Elemento Caixa de verificação para Relatórios", "Description[sk]": "Prvok zaškrtávacieho políčka pre Reports", "Description[sv]": "Element med kryssruta för rapporter", "Description[uk]": "Елемент пункту позначки для звітів", "Description[x-test]": "xxCheck box element for Reportsxx", "EnabledByDefault": true, - "Icon": "kreport_checkbox_element", + "Icon": "kreport-checkbox-element", "Id": "org.kde.kreport.checkbox", "License": "LGPL", "Name": "Check box", "Name[ast]": "Caxellu", "Name[ca@valencia]": "Casella de selecció", "Name[ca]": "Casella de selecció", "Name[de]": "Ankreuzfeld", "Name[en_GB]": "Tick box", "Name[es]": "Casilla de verificación", "Name[fi]": "Valintaruutu", "Name[gl]": "Caixa de verificación", "Name[it]": "Casella", "Name[nl]": "Keuzevakje", "Name[pl]": "Pole wyboru", "Name[pt]": "Opção de marcação", "Name[pt_BR]": "Caixa de verificação", "Name[sk]": "Zaškrtávacie políčko", "Name[sv]": "Kryssruta", "Name[uk]": "Пункт позначки", "Name[x-test]": "xxCheck boxxx", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "X-KDE-PluginInfo-LegacyName": "check", "X-KReport-Priority": "5" -} \ No newline at end of file +} diff --git a/src/items/field/field.json b/src/items/field/field.json index a4c85130..ec7d92c3 100644 --- a/src/items/field/field.json +++ b/src/items/field/field.json @@ -1,74 +1,74 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[it]": "La squadra di Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Field element for Reports", "Description[ca@valencia]": "Element de camp per informes", "Description[ca]": "Element de camp per informes", "Description[de]": "Feldelement für Berichte", "Description[es]": "Elemento de campo para Reports", "Description[fi]": "Kenttäelementti raportteihin", "Description[gl]": "Campo para informes.", "Description[it]": "Elemento «campo» per rapporti", "Description[nl]": "Veld-element voor rapporten", "Description[pl]": "Element pola dla raportów", "Description[pt]": "Elemento de campo para os Relatórios", "Description[pt_BR]": "Elemento Campo para Relatórios", "Description[sk]": "Prvok poľa pre Reports", "Description[sv]": "Fältelement för rapporter", "Description[uk]": "Елемент поля для звітів", "Description[x-test]": "xxField element for Reportsxx", "EnabledByDefault": true, - "Icon": "kreport_field_element", + "Icon": "kreport-field-element", "Id": "org.kde.kreport.field", "License": "LGPL", "Name": "Field", "Name[ast]": "Campu", "Name[ca@valencia]": "Camp", "Name[ca]": "Camp", "Name[cs]": "Pole", "Name[de]": "Feld", "Name[es]": "Campo", "Name[fi]": "Kenttä", "Name[gl]": "Campo", "Name[it]": "Campo", "Name[nl]": "Veld", "Name[pl]": "Pole", "Name[pt]": "Campo", "Name[pt_BR]": "Campo", "Name[sk]": "Pole", "Name[sv]": "Fält", "Name[uk]": "Поле", "Name[x-test]": "xxFieldxx", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "X-KDE-PluginInfo-LegacyName": "field", "X-KReport-Priority": "1" -} \ No newline at end of file +} diff --git a/src/items/image/image.json b/src/items/image/image.json index b2936a76..33a406b7 100644 --- a/src/items/image/image.json +++ b/src/items/image/image.json @@ -1,74 +1,74 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[it]": "La squadra di Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Image element for Reports", "Description[ca@valencia]": "Element d'imatge per informes", "Description[ca]": "Element d'imatge per informes", "Description[de]": "Bildelement für Berichte", "Description[es]": "Elemento de imagen para Reports", "Description[fi]": "Kuvaelementti raportteihin", "Description[gl]": "Imaxe para informes.", "Description[it]": "Elemento «immagine» per rapporti", "Description[nl]": "Afbeeldingselement voor rapporten", "Description[pl]": "Element obrazu dla raportów", "Description[pt]": "Elemento de imagem para os Relatórios", "Description[pt_BR]": "Elemento Imagem para Relatórios", "Description[sk]": "Prvok obrázku pre Reports", "Description[sv]": "Bildelement för rapporter", "Description[uk]": "Елемент зображення для звітів", "Description[x-test]": "xxImage element for Reportsxx", "EnabledByDefault": true, - "Icon": "kreport_image_element", + "Icon": "kreport-image-element", "Id": "org.kde.kreport.image", "License": "LGPL", "Name": "Image", "Name[ast]": "Imaxe", "Name[ca@valencia]": "Imatge", "Name[ca]": "Imatge", "Name[cs]": "Obrázek", "Name[de]": "Bild", "Name[es]": "Imagen", "Name[fi]": "Kuva", "Name[gl]": "Imaxe", "Name[it]": "Immagine", "Name[nl]": "Afbeelding", "Name[pl]": "Obraz", "Name[pt]": "Imagem", "Name[pt_BR]": "Imagem", "Name[sk]": "Obrázok", "Name[sv]": "Bild", "Name[uk]": "Зображення", "Name[x-test]": "xxImagexx", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "X-KDE-PluginInfo-LegacyName": "image", "X-KReport-Priority": "1" -} \ No newline at end of file +} diff --git a/src/items/label/label.json b/src/items/label/label.json index 56cb5c58..59e524a1 100644 --- a/src/items/label/label.json +++ b/src/items/label/label.json @@ -1,73 +1,73 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[it]": "La squadra di Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Label element for Reports", "Description[ca@valencia]": "Element d'etiqueta per informes", "Description[ca]": "Element d'etiqueta per informes", "Description[de]": "Beschriftungselement für Berichte", "Description[es]": "Elemento de etiqueta para Reports", "Description[fi]": "Selite-elementti raportteihin", "Description[gl]": "Etiqueta para informes.", "Description[it]": "Elemento «etichetta» per rapporti", "Description[nl]": "Labelelement voor rapporten", "Description[pl]": "Element etykiety dla raportów", "Description[pt]": "Elemento de legenda para os Relatórios", "Description[pt_BR]": "Elemento Legenda para Relatórios", "Description[sk]": "Prvok popisu pre Reports", "Description[sv]": "Etikettelement för rapporter", "Description[uk]": "Елемент мітки для звітів", "Description[x-test]": "xxLabel element for Reportsxx", "EnabledByDefault": true, - "Icon": "kreport_label_element", + "Icon": "kreport-label-element", "Id": "org.kde.kreport.label", "License": "LGPL", "Name": "Label", "Name[ast]": "Etiqueta", "Name[ca@valencia]": "Etiqueta", "Name[ca]": "Etiqueta", "Name[cs]": "Popisek", "Name[de]": "Beschriftungsfeld", "Name[es]": "Etiqueta", "Name[fi]": "Selite", "Name[gl]": "Etiqueta", "Name[it]": "Etichetta", "Name[pl]": "Etykieta", "Name[pt]": "Legenda", "Name[pt_BR]": "Legenda", "Name[sk]": "Štítok", "Name[sv]": "Etikett", "Name[uk]": "Мітка", "Name[x-test]": "xxLabelxx", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "X-KDE-PluginInfo-LegacyName": "label", "X-KReport-Priority": "1" -} \ No newline at end of file +} diff --git a/src/items/text/text.json b/src/items/text/text.json index b0edbc35..b7b473ea 100644 --- a/src/items/text/text.json +++ b/src/items/text/text.json @@ -1,68 +1,68 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[it]": "La squadra di Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Text element for Reports", "Description[ca@valencia]": "Element de text per informes", "Description[ca]": "Element de text per informes", "Description[de]": "Textelement für Berichte", "Description[es]": "Elemento de texto para Reports", "Description[fi]": "Tekstielementti raportteihin", "Description[gl]": "Texto para informes.", "Description[it]": "Elemento «testo» per rapporti", "Description[nl]": "Tekstelement voor rapporten", "Description[pl]": "Element tekstowy dla raportów", "Description[pt]": "Elemento de texto para os Relatórios", "Description[pt_BR]": "Elemento Texto para Relatórios", "Description[sk]": "Prvok textu pre Reports", "Description[sv]": "Textelement för rapporter", "Description[uk]": "Елемент тексту для звітів", "Description[x-test]": "xxText element for Reportsxx", "EnabledByDefault": true, - "Icon": "kreport_text_element", + "Icon": "kreport-text-element", "Id": "org.kde.kreport.text", "License": "LGPL", "Name": "Text", "Name[ast]": "Testu", "Name[es]": "Texto", "Name[fi]": "Teksti", "Name[gl]": "Texto", "Name[it]": "Testo", "Name[nl]": "Tekst", "Name[pl]": "Tekst", "Name[pt]": "Texto", "Name[pt_BR]": "Texto", "Name[uk]": "Текст", "Name[x-test]": "xxTextxx", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "X-KDE-PluginInfo-LegacyName": "text", "X-KReport-Priority": "1" -} \ No newline at end of file +} diff --git a/src/pics/CMakeLists.txt b/src/pics/CMakeLists.txt index 6a05301b..a3f0c396 100644 --- a/src/pics/CMakeLists.txt +++ b/src/pics/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(hicolor) +kreport_add_icons_rcc_file(kreport_breeze KReport breeze "") diff --git a/src/pics/hicolor/CMakeLists.txt b/src/pics/hicolor/CMakeLists.txt deleted file mode 100644 index 9ec8cbb2..00000000 --- a/src/pics/hicolor/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -ecm_install_icons(ICONS - 16-actions-kreport_checkbox_element.svg 22-actions-kreport_checkbox_element.svg - 16-actions-kreport_field_element.svg 22-actions-kreport_field_element.svg - 16-actions-kreport_image_element.svg 22-actions-kreport_image_element.svg - 16-actions-kreport_label_element.svg 22-actions-kreport_label_element.svg - 16-actions-kreport_line_element.svg 22-actions-kreport_line_element.svg - 16-actions-kreport_text_element.svg 22-actions-kreport_text_element.svg - - DESTINATION ${ICON_INSTALL_DIR} - THEME hicolor -) diff --git a/src/pics/hicolor/16-actions-kreport_checkbox_element.svg b/src/pics/icons/breeze/actions/16/kreport-checkbox-element.svg similarity index 100% rename from src/pics/hicolor/16-actions-kreport_checkbox_element.svg rename to src/pics/icons/breeze/actions/16/kreport-checkbox-element.svg diff --git a/src/pics/hicolor/16-actions-kreport_field_element.svg b/src/pics/icons/breeze/actions/16/kreport-field-element.svg similarity index 100% rename from src/pics/hicolor/16-actions-kreport_field_element.svg rename to src/pics/icons/breeze/actions/16/kreport-field-element.svg diff --git a/src/pics/hicolor/16-actions-kreport_image_element.svg b/src/pics/icons/breeze/actions/16/kreport-image-element.svg similarity index 100% rename from src/pics/hicolor/16-actions-kreport_image_element.svg rename to src/pics/icons/breeze/actions/16/kreport-image-element.svg diff --git a/src/pics/hicolor/16-actions-kreport_label_element.svg b/src/pics/icons/breeze/actions/16/kreport-label-element.svg similarity index 100% rename from src/pics/hicolor/16-actions-kreport_label_element.svg rename to src/pics/icons/breeze/actions/16/kreport-label-element.svg diff --git a/src/pics/hicolor/16-actions-kreport_line_element.svg b/src/pics/icons/breeze/actions/16/kreport-line-element.svg similarity index 100% rename from src/pics/hicolor/16-actions-kreport_line_element.svg rename to src/pics/icons/breeze/actions/16/kreport-line-element.svg diff --git a/src/pics/hicolor/16-actions-kreport_text_element.svg b/src/pics/icons/breeze/actions/16/kreport-text-element.svg similarity index 100% rename from src/pics/hicolor/16-actions-kreport_text_element.svg rename to src/pics/icons/breeze/actions/16/kreport-text-element.svg diff --git a/src/pics/hicolor/22-actions-kreport_checkbox_element.svg b/src/pics/icons/breeze/actions/22/kreport-checkbox-element.svg similarity index 100% rename from src/pics/hicolor/22-actions-kreport_checkbox_element.svg rename to src/pics/icons/breeze/actions/22/kreport-checkbox-element.svg diff --git a/src/pics/hicolor/22-actions-kreport_field_element.svg b/src/pics/icons/breeze/actions/22/kreport-field-element.svg similarity index 100% rename from src/pics/hicolor/22-actions-kreport_field_element.svg rename to src/pics/icons/breeze/actions/22/kreport-field-element.svg diff --git a/src/pics/hicolor/22-actions-kreport_image_element.svg b/src/pics/icons/breeze/actions/22/kreport-image-element.svg similarity index 100% rename from src/pics/hicolor/22-actions-kreport_image_element.svg rename to src/pics/icons/breeze/actions/22/kreport-image-element.svg diff --git a/src/pics/hicolor/22-actions-kreport_label_element.svg b/src/pics/icons/breeze/actions/22/kreport-label-element.svg similarity index 100% rename from src/pics/hicolor/22-actions-kreport_label_element.svg rename to src/pics/icons/breeze/actions/22/kreport-label-element.svg diff --git a/src/pics/hicolor/22-actions-kreport_line_element.svg b/src/pics/icons/breeze/actions/22/kreport-line-element.svg similarity index 100% rename from src/pics/hicolor/22-actions-kreport_line_element.svg rename to src/pics/icons/breeze/actions/22/kreport-line-element.svg diff --git a/src/pics/hicolor/22-actions-kreport_text_element.svg b/src/pics/icons/breeze/actions/22/kreport-text-element.svg similarity index 100% rename from src/pics/hicolor/22-actions-kreport_text_element.svg rename to src/pics/icons/breeze/actions/22/kreport-text-element.svg diff --git a/src/pics/icons/breeze/files.cmake b/src/pics/icons/breeze/files.cmake new file mode 100644 index 00000000..ca32f5da --- /dev/null +++ b/src/pics/icons/breeze/files.cmake @@ -0,0 +1,23 @@ +# List of project's own icon files +# This file is generated by update_icon_list.sh +# WARNING! All changes made in this file will be lost! + +set(_PNG_FILES +) + +set(_SVG_FILES +icons/breeze/actions/16/kreport-checkbox-element.svg +icons/breeze/actions/16/kreport-field-element.svg +icons/breeze/actions/16/kreport-image-element.svg +icons/breeze/actions/16/kreport-label-element.svg +icons/breeze/actions/16/kreport-line-element.svg +icons/breeze/actions/16/kreport-text-element.svg +icons/breeze/actions/22/kreport-checkbox-element.svg +icons/breeze/actions/22/kreport-field-element.svg +icons/breeze/actions/22/kreport-image-element.svg +icons/breeze/actions/22/kreport-label-element.svg +icons/breeze/actions/22/kreport-line-element.svg +icons/breeze/actions/22/kreport-text-element.svg +) + +set(_FILES ${_PNG_FILES} ${_SVG_FILES}) diff --git a/src/plugins/barcode/CMakeLists.txt b/src/plugins/barcode/CMakeLists.txt index fe52da24..6561ae8b 100644 --- a/src/plugins/barcode/CMakeLists.txt +++ b/src/plugins/barcode/CMakeLists.txt @@ -1,36 +1,37 @@ ecm_create_qm_loader(kreport_barcodeplugin_QM_LOADER kreport_barcodeplugin_qt) set(kreport_barcodeplugin_LIB_SRCS ${PROJECT_SOURCE_DIR}/src/common/kreportplugin_debug.cpp KReportItemBarcode.cpp KReportDesignerItemBarcode.cpp 3of9.cpp i2of5.cpp code128.cpp codeean.cpp ext3of9.cpp i2of5paint.cpp 3of9paint.cpp ext3of9paint.cpp codeeanpaint.cpp code128paint.cpp KReportBarcodePlugin.cpp ${kreport_barcodeplugin_QM_LOADER} + kreport_barcodeplugin.json ) if(KREPORT_SCRIPTING) list(APPEND kreport_barcodeplugin_LIB_SRCS KReportScriptBarcode.cpp ) endif() -add_library(kreport_barcodeplugin MODULE ${kreport_barcodeplugin_LIB_SRCS}) +add_library(org.kde.kreport.barcode MODULE ${kreport_barcodeplugin_LIB_SRCS}) -target_link_libraries(kreport_barcodeplugin +target_link_libraries(org.kde.kreport.barcode PUBLIC KReport ) -install(TARGETS kreport_barcodeplugin DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) +install(TARGETS org.kde.kreport.barcode DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) add_subdirectory(pics) diff --git a/src/plugins/barcode/kreport_barcodeplugin.json b/src/plugins/barcode/kreport_barcodeplugin.json index e91aed6b..69309d29 100644 --- a/src/plugins/barcode/kreport_barcodeplugin.json +++ b/src/plugins/barcode/kreport_barcodeplugin.json @@ -1,74 +1,74 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[it]": "La squadra di Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Barcode element for Reports", "Description[ca@valencia]": "Element de codi de barres per informes", "Description[ca]": "Element de codi de barres per informes", "Description[de]": "Strichcode-Element für Berichte", "Description[es]": "Elemento de código de barras para Reports", "Description[fi]": "Viivakoodielementti raportteihin", "Description[gl]": "Código de barras para informes.", "Description[it]": "Elemento «codice a barre» per rapporti", "Description[nl]": "Barcode-element voor rapporten", "Description[pl]": "Element kodu kreskowego dla raportów", "Description[pt]": "Elemento de código de barras para os Relatórios", "Description[pt_BR]": "Elemento Código de barras para Relatórios", "Description[sk]": "Prvok čiarového kódu pre Reports", "Description[sv]": "Streckkodselement för rapporter", "Description[uk]": "Елемент штрихкоду для звітів", "Description[x-test]": "xxBarcode element for Reportsxx", "EnabledByDefault": true, - "Icon": "kreport_barcode_element", + "Icon": "kreport-barcode-element", "Id": "org.kde.kreport.barcode", "License": "LGPL", "Name": "Barcode", "Name[ast]": "Códigu de barres", "Name[ca@valencia]": "Codi de barres", "Name[ca]": "Codi de barres", "Name[cs]": "Čárový kód", "Name[de]": "Strichcode", "Name[es]": "Código de barras", "Name[fi]": "Viivakoodi", "Name[gl]": "Código de barras", "Name[it]": "Codice a barre", "Name[pl]": "Kod paskowy", "Name[pt]": "Código de Barras", "Name[pt_BR]": "Código de barras", "Name[sk]": "Čiarový kód", "Name[sv]": "Streckkod", "Name[uk]": "Штрихкод", "Name[x-test]": "xxBarcodexx", "Name[zh_CN]": "条形码", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "X-KDE-PluginInfo-LegacyName": "barcode", "X-KReport-Priority": "50" -} \ No newline at end of file +} diff --git a/src/plugins/barcode/pics/CMakeLists.txt b/src/plugins/barcode/pics/CMakeLists.txt index 6a05301b..b60d1319 100644 --- a/src/plugins/barcode/pics/CMakeLists.txt +++ b/src/plugins/barcode/pics/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(hicolor) +kreport_add_plugin_icons_rcc_file(org.kde.kreport.barcode breeze) diff --git a/src/plugins/barcode/pics/hicolor/CMakeLists.txt b/src/plugins/barcode/pics/hicolor/CMakeLists.txt deleted file mode 100644 index d77a88d6..00000000 --- a/src/plugins/barcode/pics/hicolor/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -ecm_install_icons(ICONS - 16-actions-kreport_barcode_element.svg 22-actions-kreport_barcode_element.svg - - DESTINATION ${ICON_INSTALL_DIR} - THEME hicolor -) diff --git a/src/plugins/barcode/pics/hicolor/16-actions-kreport_barcode_element.svg b/src/plugins/barcode/pics/icons/breeze/actions/16/kreport-barcode-element.svg similarity index 100% rename from src/plugins/barcode/pics/hicolor/16-actions-kreport_barcode_element.svg rename to src/plugins/barcode/pics/icons/breeze/actions/16/kreport-barcode-element.svg diff --git a/src/plugins/barcode/pics/hicolor/22-actions-kreport_barcode_element.svg b/src/plugins/barcode/pics/icons/breeze/actions/22/kreport-barcode-element.svg similarity index 100% rename from src/plugins/barcode/pics/hicolor/22-actions-kreport_barcode_element.svg rename to src/plugins/barcode/pics/icons/breeze/actions/22/kreport-barcode-element.svg diff --git a/src/plugins/barcode/pics/icons/breeze/files.cmake b/src/plugins/barcode/pics/icons/breeze/files.cmake new file mode 100644 index 00000000..e189a02f --- /dev/null +++ b/src/plugins/barcode/pics/icons/breeze/files.cmake @@ -0,0 +1,13 @@ +# List of project's own icon files +# This file is generated by update_icon_list.sh +# WARNING! All changes made in this file will be lost! + +set(_PNG_FILES +) + +set(_SVG_FILES +icons/breeze/actions/16/kreport-barcode-element.svg +icons/breeze/actions/22/kreport-barcode-element.svg +) + +set(_FILES ${_PNG_FILES} ${_SVG_FILES}) diff --git a/src/plugins/chart/CMakeLists.txt b/src/plugins/chart/CMakeLists.txt index 170d155a..e5a5305f 100644 --- a/src/plugins/chart/CMakeLists.txt +++ b/src/plugins/chart/CMakeLists.txt @@ -1,28 +1,28 @@ ecm_create_qm_loader(kreport_chartplugin_QM_LOADER kreport_chartplugin_qt) set(kreport_chartplugin_LIB_SRCS ${PROJECT_SOURCE_DIR}/src/common/kreportplugin_debug.cpp KReportItemChart.cpp KReportDesignerItemChart.cpp KReportChartPlugin.cpp ${kreport_chartplugin_QM_LOADER} ) if(KREPORT_SCRIPTING) list(APPEND kreport_chartplugin_LIB_SRCS KReportScriptChart.cpp ) endif() -add_library(kreport_chartplugin MODULE ${kreport_chartplugin_LIB_SRCS}) +add_library(org.kde.kreport.chart MODULE ${kreport_chartplugin_LIB_SRCS}) -target_link_libraries(kreport_chartplugin +target_link_libraries(org.kde.kreport.chart PUBLIC KReport PRIVATE KChart ) -install(TARGETS kreport_chartplugin DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) +install(TARGETS org.kde.kreport.chart DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) add_subdirectory(pics) diff --git a/src/plugins/chart/kreport_chartplugin.json b/src/plugins/chart/kreport_chartplugin.json index b6895ba4..6a0bbc8c 100644 --- a/src/plugins/chart/kreport_chartplugin.json +++ b/src/plugins/chart/kreport_chartplugin.json @@ -1,73 +1,73 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[it]": "La squadra di Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Chart element for Reports", "Description[ca@valencia]": "Element de gràfic per informes", "Description[ca]": "Element de gràfic per informes", "Description[de]": "Diagrammelement für Berichte", "Description[es]": "Elemento de gráfica para Reports", "Description[fi]": "Kaavioelementti raportteihin", "Description[gl]": "Gráfica para informes.", "Description[it]": "Elemento «grafico» per rapporti", "Description[nl]": "Grafiekelement voor rapporten", "Description[pl]": "Element tabeli dla raportów", "Description[pt]": "Elemento de gráfico para os Relatórios", "Description[pt_BR]": "Elemento Gráfico para Relatórios", "Description[sk]": "Prvky grafu pre správy", "Description[sv]": "Diagramelement för rapporter", "Description[uk]": "Елемент діаграми для звітів", "Description[x-test]": "xxChart element for Reportsxx", "EnabledByDefault": true, - "Icon": "report_chart_element", + "Icon": "report-chart-element", "Id": "org.kde.kreport.chart", "License": "LGPL", "Name": "Chart", "Name[ca@valencia]": "Gràfic", "Name[ca]": "Gràfic", "Name[cs]": "Graf", "Name[de]": "Diagramm", "Name[es]": "Gráfica", "Name[fi]": "Kaavio", "Name[gl]": "Gráfica", "Name[it]": "Grafico", "Name[nl]": "Grafiek", "Name[pl]": "Wykres", "Name[pt]": "Gráfico", "Name[pt_BR]": "Gráfico", "Name[sk]": "Graf", "Name[sv]": "Diagram", "Name[uk]": "Діаграма", "Name[x-test]": "xxChartxx", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "X-KDE-PluginInfo-LegacyName": "chart", "X-KReport-Priority": "50" -} \ No newline at end of file +} diff --git a/src/plugins/chart/pics/CMakeLists.txt b/src/plugins/chart/pics/CMakeLists.txt index 6a05301b..2b411cc7 100644 --- a/src/plugins/chart/pics/CMakeLists.txt +++ b/src/plugins/chart/pics/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(hicolor) +kreport_add_plugin_icons_rcc_file(org.kde.kreport.chart breeze) diff --git a/src/plugins/chart/pics/hicolor/CMakeLists.txt b/src/plugins/chart/pics/hicolor/CMakeLists.txt deleted file mode 100644 index 39fb7058..00000000 --- a/src/plugins/chart/pics/hicolor/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -ecm_install_icons(ICONS - 16-actions-kreport_chart_element.svg 22-actions-kreport_chart_element.svg - - DESTINATION ${ICON_INSTALL_DIR} - THEME hicolor -) diff --git a/src/plugins/chart/pics/hicolor/16-actions-kreport_chart_element.svg b/src/plugins/chart/pics/icons/breeze/actions/16/kreport-chart-element.svg similarity index 100% rename from src/plugins/chart/pics/hicolor/16-actions-kreport_chart_element.svg rename to src/plugins/chart/pics/icons/breeze/actions/16/kreport-chart-element.svg diff --git a/src/plugins/chart/pics/hicolor/22-actions-kreport_chart_element.svg b/src/plugins/chart/pics/icons/breeze/actions/22/kreport-chart-element.svg similarity index 100% rename from src/plugins/chart/pics/hicolor/22-actions-kreport_chart_element.svg rename to src/plugins/chart/pics/icons/breeze/actions/22/kreport-chart-element.svg diff --git a/src/plugins/chart/pics/icons/breeze/files.cmake b/src/plugins/chart/pics/icons/breeze/files.cmake new file mode 100644 index 00000000..9ce254a1 --- /dev/null +++ b/src/plugins/chart/pics/icons/breeze/files.cmake @@ -0,0 +1,13 @@ +# List of project's own icon files +# This file is generated by update_icon_list.sh +# WARNING! All changes made in this file will be lost! + +set(_PNG_FILES +) + +set(_SVG_FILES +icons/breeze/actions/16/kreport-charts-element.svg +icons/breeze/actions/22/kreport-charts-element.svg +) + +set(_FILES ${_PNG_FILES} ${_SVG_FILES}) diff --git a/src/plugins/maps/CMakeLists.txt b/src/plugins/maps/CMakeLists.txt index d70c584e..103db25c 100644 --- a/src/plugins/maps/CMakeLists.txt +++ b/src/plugins/maps/CMakeLists.txt @@ -1,32 +1,33 @@ ecm_create_qm_loader(kreport_mapsplugin_QM_LOADER kreport_mapsplugin_qt) #build a shared library set(kreport_mapsplugin_LIB_SRCS ${PROJECT_SOURCE_DIR}/src/common/kreportplugin_debug.cpp KReportDesignerItemMaps.cpp KReportItemMaps.cpp KReportMapsPlugin.cpp KReportMapRenderer.cpp ${kreport_mapsplugin_QM_LOADER} + kreport_mapsplugin.json ) if(KREPORT_SCRIPTING) list(APPEND kreport_mapsplugin_LIB_SRCS KReportScriptMaps.cpp ) endif() -add_library(kreport_mapsplugin MODULE ${kreport_mapsplugin_LIB_SRCS}) +add_library(org.kde.kreport.maps MODULE ${kreport_mapsplugin_LIB_SRCS}) -target_link_libraries(kreport_mapsplugin +target_link_libraries(org.kde.kreport.maps PUBLIC KReport PRIVATE Marble ) ########### install files ############### -install(TARGETS kreport_mapsplugin DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) +install(TARGETS org.kde.kreport.maps DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) add_subdirectory(pics) diff --git a/src/plugins/maps/kreport_mapsplugin.json b/src/plugins/maps/kreport_mapsplugin.json index 5f5e3bb4..3accfba5 100644 --- a/src/plugins/maps/kreport_mapsplugin.json +++ b/src/plugins/maps/kreport_mapsplugin.json @@ -1,74 +1,74 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[it]": "La squadra di Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Maps element for Reports", "Description[ca@valencia]": "Element de mapes per informes", "Description[ca]": "Element de mapes per informes", "Description[de]": "Kartenelement für Berichte", "Description[es]": "Elemento de mapas para Reports", "Description[fi]": "Karttaelementti raportteihin", "Description[gl]": "Elemento de mapas para informes.", "Description[it]": "Elemento «mappe» per rapporti", "Description[nl]": "Kaartelement voor rapporten", "Description[pl]": "Element mapy dla raportów", "Description[pt]": "Elemento de mapas para os Relatórios", "Description[pt_BR]": "Elemento Mapas para Relatórios", "Description[sk]": "Prvok máp pre Reports", "Description[sv]": "Kartelement för rapporter", "Description[uk]": "Елемент карти для звітів", "Description[x-test]": "xxMaps element for Reportsxx", "EnabledByDefault": true, - "Icon": "kreport_maps_element", + "Icon": "kreport-maps-element", "Id": "org.kde.kreport.maps", "License": "LGPL", "Name": "Maps", "Name[ast]": "Mapes", "Name[ca@valencia]": "Mapes", "Name[ca]": "Mapes", "Name[cs]": "Mapy", "Name[de]": "Karten", "Name[es]": "Mapas", "Name[fi]": "Kartta", "Name[gl]": "Mapas", "Name[it]": "Mappe", "Name[nl]": "Kaarten", "Name[pl]": "Mapy", "Name[pt]": "Mapas", "Name[pt_BR]": "Mapas", "Name[sk]": "Mapy", "Name[sv]": "Kartor", "Name[uk]": "Карти", "Name[x-test]": "xxMapsxx", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "X-KDE-PluginInfo-LegacyName": "maps", "X-KReport-Priority": "50" -} \ No newline at end of file +} diff --git a/src/plugins/maps/pics/CMakeLists.txt b/src/plugins/maps/pics/CMakeLists.txt index 6a05301b..dec72438 100644 --- a/src/plugins/maps/pics/CMakeLists.txt +++ b/src/plugins/maps/pics/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(hicolor) +kreport_add_plugin_icons_rcc_file(org.kde.kreport.maps breeze) diff --git a/src/plugins/maps/pics/hicolor/CMakeLists.txt b/src/plugins/maps/pics/hicolor/CMakeLists.txt deleted file mode 100644 index 62e6a13c..00000000 --- a/src/plugins/maps/pics/hicolor/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -ecm_install_icons(ICONS - 16-actions-kreport_maps_element.svg 22-actions-kreport_maps_element.svg - - DESTINATION ${ICON_INSTALL_DIR} - THEME hicolor -) diff --git a/src/plugins/maps/pics/hicolor/16-actions-kreport_maps_element.svg b/src/plugins/maps/pics/icons/breeze/actions/16/kreport-maps-element.svg similarity index 100% rename from src/plugins/maps/pics/hicolor/16-actions-kreport_maps_element.svg rename to src/plugins/maps/pics/icons/breeze/actions/16/kreport-maps-element.svg diff --git a/src/plugins/maps/pics/hicolor/22-actions-kreport_maps_element.svg b/src/plugins/maps/pics/icons/breeze/actions/22/kreport-maps-element.svg similarity index 100% rename from src/plugins/maps/pics/hicolor/22-actions-kreport_maps_element.svg rename to src/plugins/maps/pics/icons/breeze/actions/22/kreport-maps-element.svg diff --git a/src/plugins/maps/pics/icons/breeze/files.cmake b/src/plugins/maps/pics/icons/breeze/files.cmake new file mode 100644 index 00000000..237d4857 --- /dev/null +++ b/src/plugins/maps/pics/icons/breeze/files.cmake @@ -0,0 +1,13 @@ +# List of project's own icon files +# This file is generated by update_icon_list.sh +# WARNING! All changes made in this file will be lost! + +set(_PNG_FILES +) + +set(_SVG_FILES +icons/breeze/actions/16/kreport-maps-element.svg +icons/breeze/actions/22/kreport-maps-element.svg +) + +set(_FILES ${_PNG_FILES} ${_SVG_FILES}) diff --git a/src/plugins/web/CMakeLists.txt b/src/plugins/web/CMakeLists.txt index d36878c2..9f2fb076 100644 --- a/src/plugins/web/CMakeLists.txt +++ b/src/plugins/web/CMakeLists.txt @@ -1,27 +1,27 @@ ecm_create_qm_loader(kreport_webplugin_QM_LOADER kreport_webplugin_qt) #build a shared library set(kreport_webplugin_LIB_SRCS ${PROJECT_SOURCE_DIR}/src/common/kreportplugin_debug.cpp KReportDesignerItemWeb.cpp KReportItemWeb.cpp KReportWebPlugin.cpp ${kreport_webplugin_QM_LOADER} ) -add_library(kreport_webplugin MODULE ${kreport_webplugin_LIB_SRCS}) +add_library(org.kde.kreport.web MODULE ${kreport_webplugin_LIB_SRCS}) set (QT_USE_QTWEBKIT TRUE) -target_link_libraries(kreport_webplugin +target_link_libraries(org.kde.kreport.web PUBLIC KReport PRIVATE Qt5::WebKitWidgets # TODO WebEngineWidgets? ) ########### install files ############### -install(TARGETS kreport_webplugin DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) +install(TARGETS org.kde.kreport.web DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) add_subdirectory(pics) diff --git a/src/plugins/web/kreport_webplugin.json b/src/plugins/web/kreport_webplugin.json index 820b5bca..73d2af1a 100644 --- a/src/plugins/web/kreport_webplugin.json +++ b/src/plugins/web/kreport_webplugin.json @@ -1,69 +1,69 @@ { "KPlugin": { "Authors": [ { "Email": "kexi@kde.org", "Name": "Kexi Team", "Name[ast]": "L'equipu de Kexi", "Name[ca@valencia]": "L'equip del Kexi", "Name[ca]": "L'equip del Kexi", "Name[cs]": "Tým Kexi", "Name[de]": "Kexi-Team", "Name[es]": "El equipo de Kexi", "Name[fi]": "Kexi-työryhmä", "Name[gl]": "Equipo de Kexi", "Name[it]": "La squadra di Kexi", "Name[nl]": "Het team van Kexi", "Name[pl]": "Zespół Kexi", "Name[pt]": "Equipa do Kexi", "Name[pt_BR]": "Equipe do Kexi", "Name[sk]": "Tím Kexi", "Name[sv]": "Kexi-gruppen", "Name[uk]": "Команда Kexi", "Name[x-test]": "xxKexi Teamxx" } ], "Category": "", "Dependencies": [], "Description": "Web browser element for Reports", "Description[ca@valencia]": "Element de navegador web per informes", "Description[ca]": "Element de navegador web per informes", "Description[de]": "Webbrowser-Element für Berichte", "Description[es]": "Elemento de navegador Web para Reports", "Description[fi]": "Verkkoselainelementti raportteihin", "Description[gl]": "Elemento de navegador web para informes", "Description[it]": "Elemento «browser web» per rapporti", "Description[nl]": "Webbrowserelement voor rapporten", "Description[pl]": "Element przeglądarki dla raportów", "Description[pt]": "Elemento de navegador Web para os Relatórios", "Description[pt_BR]": "Elemento Navegador Web para Relatórios", "Description[sk]": "Prvok webového prehliadača pre správy", "Description[sv]": "Webbläsarelement för rapporter", "Description[uk]": "Елемент засобу для перегляду інтернету для звітів", "Description[x-test]": "xxWeb browser element for Reportsxx", "EnabledByDefault": true, - "Icon": "report_web_element", + "Icon": "report-web-element", "Id": "org.kde.kreport.web", "License": "LGPL", "Name": "Web browser", "Name[ca@valencia]": "Navegador web", "Name[ca]": "Navegador web", "Name[cs]": "Webový prohlížeč", "Name[de]": "Webbrowser", "Name[es]": "Navegador web", "Name[it]": "Browser web", "Name[nl]": "Webbrowser", "Name[pl]": "Przeglądarka sieciowa", "Name[pt]": "Navegador Web", "Name[sv]": "Webbläsare", "Name[uk]": "Переглядач інтернету", "Name[x-test]": "xxWeb browserxx", "ServiceTypes": [ "KReport/Element" ], "Version": "1.0", "Website": "http://kexi-project.org" }, "X-KDE-PluginInfo-LegacyName": "web", "X-KReport-Priority": "50" -} \ No newline at end of file +} diff --git a/src/plugins/web/pics/CMakeLists.txt b/src/plugins/web/pics/CMakeLists.txt index 6a05301b..a6f233b7 100644 --- a/src/plugins/web/pics/CMakeLists.txt +++ b/src/plugins/web/pics/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(hicolor) +kreport_add_plugin_icons_rcc_file(org.kde.kreport.web breeze) diff --git a/src/plugins/web/pics/hicolor/CMakeLists.txt b/src/plugins/web/pics/hicolor/CMakeLists.txt deleted file mode 100644 index e4427c56..00000000 --- a/src/plugins/web/pics/hicolor/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -ecm_install_icons(ICONS - 16-actions-kreport_web_element.svg 22-actions-kreport_web_element.svg - - DESTINATION ${ICON_INSTALL_DIR} - THEME hicolor -) diff --git a/src/plugins/web/pics/hicolor/16-actions-kreport_web_element.svg b/src/plugins/web/pics/icons/breeze/actions/16/kreport-web-element.svg similarity index 100% rename from src/plugins/web/pics/hicolor/16-actions-kreport_web_element.svg rename to src/plugins/web/pics/icons/breeze/actions/16/kreport-web-element.svg diff --git a/src/plugins/web/pics/hicolor/22-actions-kreport_web_element.svg b/src/plugins/web/pics/icons/breeze/actions/22/kreport-web-element.svg similarity index 100% rename from src/plugins/web/pics/hicolor/22-actions-kreport_web_element.svg rename to src/plugins/web/pics/icons/breeze/actions/22/kreport-web-element.svg diff --git a/src/plugins/web/pics/icons/breeze/files.cmake b/src/plugins/web/pics/icons/breeze/files.cmake new file mode 100644 index 00000000..a045d59b --- /dev/null +++ b/src/plugins/web/pics/icons/breeze/files.cmake @@ -0,0 +1,13 @@ +# List of project's own icon files +# This file is generated by update_icon_list.sh +# WARNING! All changes made in this file will be lost! + +set(_PNG_FILES +) + +set(_SVG_FILES +icons/breeze/actions/16/kreport-web-element.svg +icons/breeze/actions/22/kreport-web-element.svg +) + +set(_FILES ${_PNG_FILES} ${_SVG_FILES}) diff --git a/src/wrtembed/KReportDesigner.cpp b/src/wrtembed/KReportDesigner.cpp index 9e84d1b9..ad88ac83 100644 --- a/src/wrtembed/KReportDesigner.cpp +++ b/src/wrtembed/KReportDesigner.cpp @@ -1,1550 +1,1552 @@ /* This file is part of the KDE project * Copyright (C) 2001-2007 by OpenMFG, LLC * Copyright (C) 2007-2010 by Adam Pigg * Copyright (C) 2011 Jarosław Staniek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "KReportDesigner.h" #include "KReportDesignerSection.h" #include "KReportDesignerSectionScene.h" #include "KReportDesignerSectionView.h" #include "KReportDesignerSectionDetailGroup.h" #include "KReportPropertiesButton.h" #include "KReportSectionEditor.h" #include "KReportDesignerSectionDetail.h" #include "KReportDesignerItemLine.h" #include "KReportRuler_p.h" #include "KReportZoomHandler.h" #include "KReportPageSize.h" #include "KReportDpi.h" #include "KReportUtils.h" #include "KReportPluginInterface.h" #include "KReportPluginManager.h" #include "KReportSection.h" #include "KReportPluginMetaData.h" #include "kreport_debug.h" #include #include #include #include #include #include #include #include #include #include #include #include #include //! Also add public method for runtime? const char ns[] = "http://kexi-project.org/report/2.0"; static QDomElement propertyToElement(QDomDocument* d, KProperty* p) { QDomElement e = d->createElement(QLatin1String("report:" + p->name().toLower())); e.appendChild(d->createTextNode(p->value().toString())); return e; } // // define and implement the ReportWriterSectionData class // a simple class to hold/hide data in the ReportHandler class // class ReportWriterSectionData { public: ReportWriterSectionData() { selected_x_offset = 0; selected_y_offset = 0; mouseAction = ReportWriterSectionData::MA_None; } virtual ~ReportWriterSectionData() { } enum MouseAction { MA_None = 0, MA_Insert = 1, MA_Grab = 2, MA_MoveStartPoint, MA_MoveEndPoint, MA_ResizeNW = 8, MA_ResizeN, MA_ResizeNE, MA_ResizeE, MA_ResizeSE, MA_ResizeS, MA_ResizeSW, MA_ResizeW }; int selected_x_offset; int selected_y_offset; MouseAction mouseAction; QString insertItem; QList copy_list; QList cut_list; }; //! @internal class KReportDesigner::Private { public: Private() : activeScene(0) , reportHeader(0) , pageHeaderFirst(0) , pageHeaderOdd(0) , pageHeaderEven(0) , pageHeaderLast(0) , pageHeaderAny(0) , pageFooterFirst(0) , pageFooterOdd(0) , pageFooterEven(0) , pageFooterLast(0) , pageFooterAny(0) , reportFooter(0) , detail(0) , pressX(-1) , pressY(-1) , releaseX(-1) , releaseY(-1) , modified(false) , kordata(0) {} ~Private() { delete zoom; delete sectionData; delete set; delete kordata; } QGridLayout *grid; KReportRuler *hruler; KReportZoomHandler *zoom; QVBoxLayout *vboxlayout; KReportPropertiesButton *pageButton; QGraphicsScene *activeScene; ReportWriterSectionData *sectionData; KReportDesignerSection *reportHeader; KReportDesignerSection *pageHeaderFirst; KReportDesignerSection *pageHeaderOdd; KReportDesignerSection *pageHeaderEven; KReportDesignerSection *pageHeaderLast; KReportDesignerSection *pageHeaderAny; KReportDesignerSection *pageFooterFirst; KReportDesignerSection *pageFooterOdd; KReportDesignerSection *pageFooterEven; KReportDesignerSection *pageFooterLast; KReportDesignerSection *pageFooterAny; KReportDesignerSection *reportFooter; KReportDesignerSectionDetail *detail; //Properties KPropertySet *set; KPropertySet *itmset; KProperty *title; KProperty *pageSize; KProperty *orientation; KProperty *unit; KProperty *customHeight; KProperty *customWidth; KProperty *leftMargin; KProperty *rightMargin; KProperty *topMargin; KProperty *bottomMargin; KProperty *showGrid; KProperty *gridDivisions; KProperty *gridSnap; KProperty *labelType; #ifdef KREPORT_SCRIPTING KProperty *script; #endif //Actions QAction *editCutAction; QAction *editCopyAction; QAction *editPasteAction; QAction *editDeleteAction; QAction *sectionEdit; QAction *parameterEdit; QAction *itemRaiseAction; QAction *itemLowerAction; qreal pressX; qreal pressY; qreal releaseX; qreal releaseY; bool modified; // true if this document has been modified, false otherwise QString originalInterpreter; //Value of the script interpreter at load time QString originalScript; //Value of the script at load time KReportData *kordata; }; KReportDesigner::KReportDesigner(QWidget * parent) : QWidget(parent), d(new Private()) { init(); } void KReportDesigner::init() { + KReportPluginManager::self(); // this loads icons early enough + d->sectionData = new ReportWriterSectionData(); createProperties(); createActions(); d->grid = new QGridLayout(this); d->grid->setSpacing(0); d->grid->setMargin(0); d->grid->setColumnStretch(1, 1); d->grid->setRowStretch(1, 1); d->grid->setSizeConstraint(QLayout::SetFixedSize); d->vboxlayout = new QVBoxLayout(); d->vboxlayout->setSpacing(0); d->vboxlayout->setMargin(0); d->vboxlayout->setSizeConstraint(QLayout::SetFixedSize); //Create nice rulers d->zoom = new KReportZoomHandler(); d->hruler = new KReportRuler(this, Qt::Horizontal, d->zoom); d->pageButton = new KReportPropertiesButton(this); d->hruler->setUnit(KReportUnit(KReportUnit::Centimeter)); d->grid->addWidget(d->pageButton, 0, 0); d->grid->addWidget(d->hruler, 0, 1); d->grid->addLayout(d->vboxlayout, 1, 0, 1, 2); d->pageButton->setMaximumSize(QSize(19, 22)); d->pageButton->setMinimumSize(QSize(19, 22)); d->detail = new KReportDesignerSectionDetail(this); d->vboxlayout->insertWidget(0, d->detail); setLayout(d->grid); connect(d->pageButton, SIGNAL(released()), this, SLOT(slotPageButton_Pressed())); emit pagePropertyChanged(*d->set); connect(d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); changeSet(d->set); } KReportDesigner::~KReportDesigner() { delete d; } ///The loading Code KReportDesigner::KReportDesigner(QWidget *parent, const QDomElement &data) : QWidget(parent), d(new Private()) { init(); if (data.tagName() != QLatin1String("report:content")) { // arg we got an xml file but not one i know of kreportWarning() << "root element was not "; } //kreportDebug() << data.text(); deleteDetail(); QDomNodeList nlist = data.childNodes(); QDomNode it; for (int i = 0; i < nlist.count(); ++i) { it = nlist.item(i); // at this level all the children we get should be Elements if (it.isElement()) { QString n = it.nodeName().toLower(); //kreportDebug() << n; if (n == QLatin1String("report:title")) { setReportTitle(it.firstChild().nodeValue()); #ifdef KREPORT_SCRIPTING } else if (n == QLatin1String("report:script")) { d->originalInterpreter = it.toElement().attribute(QLatin1String("report:script-interpreter")); d->originalScript = it.firstChild().nodeValue(); d->script->setValue(d->originalScript); if (d->originalInterpreter != QLatin1String("javascript") && d->originalInterpreter != QLatin1String("qtscript")) { QString msg = tr("This report contains scripts of type \"%1\". " "Only scripts written in JavaScript language are " "supported. To prevent losing the scripts, their type " "and content will not be changed unless you change these scripts." ).arg(d->originalInterpreter); QMessageBox::warning(this, tr("Unsupported Script Type"), msg); } #endif } else if (n == QLatin1String("report:grid")) { d->showGrid->setValue(it.toElement().attribute(QLatin1String("report:grid-visible"), QString::number(1)).toInt() != 0); d->gridSnap->setValue(it.toElement().attribute(QLatin1String("report:grid-snap"), QString::number(1)).toInt() != 0); d->gridDivisions->setValue(it.toElement().attribute(QLatin1String("report:grid-divisions"), QString::number(4)).toInt()); d->unit->setValue(it.toElement().attribute(QLatin1String("report:page-unit"), QLatin1String("cm"))); } //! @todo Load page options else if (n == QLatin1String("report:page-style")) { QString pagetype = it.firstChild().nodeValue(); if (pagetype == QLatin1String("predefined")) { d->pageSize->setValue(it.toElement().attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); } else if (pagetype == QLatin1String("custom")) { d->pageSize->setValue(QLatin1String("custom")); d->customHeight->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("report:custom-page-height"), QLatin1String("")))); d->customWidth->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("report:custom-page-widtht"), QLatin1String("")))); } else if (pagetype == QLatin1String("label")) { //! @todo } d->rightMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))); d->leftMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))); d->topMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))); d->bottomMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))); d->orientation->setValue(it.toElement().attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait"))); } else if (n == QLatin1String("report:body")) { QDomNodeList sectionlist = it.childNodes(); QDomNode sec; for (int s = 0; s < sectionlist.count(); ++s) { sec = sectionlist.item(s); if (sec.isElement()) { QString sn = sec.nodeName().toLower(); //kreportDebug() << sn; if (sn == QLatin1String("report:section")) { QString sectiontype = sec.toElement().attribute(QLatin1String("report:section-type")); if (section(KReportSectionData::sectionTypeFromString(sectiontype)) == 0) { insertSection(KReportSectionData::sectionTypeFromString(sectiontype)); section(KReportSectionData::sectionTypeFromString(sectiontype))->initFromXML(sec); } } else if (sn == QLatin1String("report:detail")) { KReportDesignerSectionDetail * rsd = new KReportDesignerSectionDetail(this); rsd->initFromXML(&sec); setDetail(rsd); } } else { kreportWarning() << "Encountered an unknown Element: " << n; } } } } else { kreportWarning() << "Encountered a child node of root that is not an Element"; } } this->slotPageButton_Pressed(); emit reportDataChanged(); slotPropertyChanged(*d->set, *d->unit); // set unit for all items setModified(false); } ///The saving code QDomElement KReportDesigner::document() const { QDomDocument doc; QString saveInterpreter; QDomElement content = doc.createElement(QLatin1String("report:content")); content.setAttribute(QLatin1String("xmlns:report"), QLatin1String(ns)); content.setAttribute(QLatin1String("xmlns:fo"), QLatin1String("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0")); content.setAttribute(QLatin1String("xmlns:svg"), QLatin1String("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")); doc.appendChild(content); //title content.appendChild(propertyToElement(&doc, d->title)); #ifdef KREPORT_SCRIPTING if (!d->script->value().toString().isEmpty()) { if (d->script->value().toString() != d->originalScript || d->originalInterpreter == QLatin1String("qtscript")) { //The script has changed so force interpreter to 'javascript'. Also set if was using qtscript saveInterpreter = QLatin1String("javascript"); } else { saveInterpreter = d->originalInterpreter; } QDomElement scr = propertyToElement(&doc, d->script); scr.setAttribute(QLatin1String("report:script-interpreter"), saveInterpreter); content.appendChild(scr); } #endif QDomElement grd = doc.createElement(QLatin1String("report:grid")); KReportUtils::addPropertyAsAttribute(&grd, d->showGrid); KReportUtils::addPropertyAsAttribute(&grd, d->gridDivisions); KReportUtils::addPropertyAsAttribute(&grd, d->gridSnap); KReportUtils::addPropertyAsAttribute(&grd, d->unit); content.appendChild(grd); // pageOptions // -- size QDomElement pagestyle = doc.createElement(QLatin1String("report:page-style")); if (d->pageSize->value().toString() == QLatin1String("Custom")) { pagestyle.appendChild(doc.createTextNode(QLatin1String("custom"))); KReportUtils::setAttribute(&pagestyle, QLatin1String("report:custom-page-width"), d->customWidth->value().toDouble()); KReportUtils::setAttribute(&pagestyle, QLatin1String("report:custom-page-height"), d->customHeight->value().toDouble()); } else if (d->pageSize->value().toString() == QLatin1String("Label")) { pagestyle.appendChild(doc.createTextNode(QLatin1String("label"))); pagestyle.setAttribute(QLatin1String("report:page-label-type"), d->labelType->value().toString()); } else { pagestyle.appendChild(doc.createTextNode(QLatin1String("predefined"))); KReportUtils::addPropertyAsAttribute(&pagestyle, d->pageSize); //pagestyle.setAttribute("report:page-size", d->pageSize->value().toString()); } // -- orientation KReportUtils::addPropertyAsAttribute(&pagestyle, d->orientation); // -- margins: save as points, and not localized KReportUtils::setAttribute(&pagestyle, QLatin1String("fo:margin-top"), d->topMargin->value().toDouble()); KReportUtils::setAttribute(&pagestyle, QLatin1String("fo:margin-bottom"), d->bottomMargin->value().toDouble()); KReportUtils::setAttribute(&pagestyle, QLatin1String("fo:margin-right"), d->rightMargin->value().toDouble()); KReportUtils::setAttribute(&pagestyle, QLatin1String("fo:margin-left"), d->leftMargin->value().toDouble()); content.appendChild(pagestyle); QDomElement body = doc.createElement(QLatin1String("report:body")); QDomElement domsection; for (int i = KReportSectionData::PageHeaderFirst; i <= KReportSectionData::PageFooterAny; ++i) { KReportDesignerSection *sec = section((KReportSectionData::Section)i); if (sec) { domsection = doc.createElement(QLatin1String("report:section")); domsection.setAttribute(QLatin1String("report:section-type"), KReportSectionData::sectionTypeString(KReportSectionData::Section(i))); sec->buildXML(&doc, &domsection); body.appendChild(domsection); } } QDomElement detail = doc.createElement(QLatin1String("report:detail")); d->detail->buildXML(&doc, &detail); body.appendChild(detail); content.appendChild(body); return content; } void KReportDesigner::slotSectionEditor() { KReportSectionEditor se(this); (void)se.exec(); } void KReportDesigner::setReportData(KReportData* kodata) { if (d->kordata == kodata) { return; } delete d->kordata; d->kordata = kodata; slotPageButton_Pressed(); setModified(true); emit reportDataChanged(); } KReportDesignerSection * KReportDesigner::section(KReportSectionData::Section s) const { KReportDesignerSection *sec; switch (s) { case KReportSectionData::PageHeaderAny: sec = d->pageHeaderAny; break; case KReportSectionData::PageHeaderEven: sec = d->pageHeaderEven; break; case KReportSectionData::PageHeaderOdd: sec = d->pageHeaderOdd; break; case KReportSectionData::PageHeaderFirst: sec = d->pageHeaderFirst; break; case KReportSectionData::PageHeaderLast: sec = d->pageHeaderLast; break; case KReportSectionData::PageFooterAny: sec = d->pageFooterAny; break; case KReportSectionData::PageFooterEven: sec = d->pageFooterEven; break; case KReportSectionData::PageFooterOdd: sec = d->pageFooterOdd; break; case KReportSectionData::PageFooterFirst: sec = d->pageFooterFirst; break; case KReportSectionData::PageFooterLast: sec = d->pageFooterLast; break; case KReportSectionData::ReportHeader: sec = d->reportHeader; break; case KReportSectionData::ReportFooter: sec = d->reportFooter; break; default: sec = 0; } return sec; } void KReportDesigner::removeSection(KReportSectionData::Section s) { KReportDesignerSection* sec = section(s); if (sec) { delete sec; switch (s) { case KReportSectionData::PageHeaderAny: d->pageHeaderAny = 0; break; case KReportSectionData::PageHeaderEven: sec = d->pageHeaderEven = 0; break; case KReportSectionData::PageHeaderOdd: d->pageHeaderOdd = 0; break; case KReportSectionData::PageHeaderFirst: d->pageHeaderFirst = 0; break; case KReportSectionData::PageHeaderLast: d->pageHeaderLast = 0; break; case KReportSectionData::PageFooterAny: d->pageFooterAny = 0; break; case KReportSectionData::PageFooterEven: d->pageFooterEven = 0; break; case KReportSectionData::PageFooterOdd: d->pageFooterOdd = 0; break; case KReportSectionData::PageFooterFirst: d->pageFooterFirst = 0; break; case KReportSectionData::PageFooterLast: d->pageFooterLast = 0; break; case KReportSectionData::ReportHeader: d->reportHeader = 0; break; case KReportSectionData::ReportFooter: d->reportFooter = 0; break; default: sec = 0; } setModified(true); adjustSize(); } } void KReportDesigner::insertSection(KReportSectionData::Section s) { KReportDesignerSection* sec = section(s); if (!sec) { int idx = 0; for (int i = 1; i <= s; ++i) { if (section((KReportSectionData::Section)i)) idx++; } if (s > KReportSectionData::ReportHeader) idx++; //kreportDebug() << idx; KReportDesignerSection *rs = new KReportDesignerSection(this); d->vboxlayout->insertWidget(idx, rs); switch (s) { case KReportSectionData::PageHeaderAny: rs->setTitle(tr("Page Header (Any)")); d->pageHeaderAny = rs; break; case KReportSectionData::PageHeaderEven: rs->setTitle(tr("Page Header (Even)")); d->pageHeaderEven = rs; break; case KReportSectionData::PageHeaderOdd: rs->setTitle(tr("Page Header (Odd)")); d->pageHeaderOdd = rs; break; case KReportSectionData::PageHeaderFirst: rs->setTitle(tr("Page Header (First)")); d->pageHeaderFirst = rs; break; case KReportSectionData::PageHeaderLast: rs->setTitle(tr("Page Header (Last)")); d->pageHeaderLast = rs; break; case KReportSectionData::PageFooterAny: rs->setTitle(tr("Page Footer (Any)")); d->pageFooterAny = rs; break; case KReportSectionData::PageFooterEven: rs->setTitle(tr("Page Footer (Even)")); d->pageFooterEven = rs; break; case KReportSectionData::PageFooterOdd: rs->setTitle(tr("Page Footer (Odd)")); d->pageFooterOdd = rs; break; case KReportSectionData::PageFooterFirst: rs->setTitle(tr("Page Footer (First)")); d->pageFooterFirst = rs; break; case KReportSectionData::PageFooterLast: rs->setTitle(tr("Page Footer (Last)")); d->pageFooterLast = rs; break; case KReportSectionData::ReportHeader: rs->setTitle(tr("Report Header")); d->reportHeader = rs; break; case KReportSectionData::ReportFooter: rs->setTitle(tr("Report Footer")); d->reportFooter = rs; break; //These sections cannot be inserted this way case KReportSectionData::None: case KReportSectionData::GroupHeader: case KReportSectionData::GroupFooter: case KReportSectionData::Detail: break; } rs->show(); setModified(true); adjustSize(); emit pagePropertyChanged(*d->set); } } void KReportDesigner::setReportTitle(const QString & str) { if (reportTitle() != str) { d->title->setValue(str); setModified(true); } } KPropertySet * KReportDesigner::propertySet() const { return d->set; } KPropertySet* KReportDesigner::itemPropertySet() const { return d->itmset; } KReportData *KReportDesigner::reportData() const { return d->kordata; } KReportDesignerSectionDetail * KReportDesigner::detailSection() const { return d->detail; } QString KReportDesigner::reportTitle() const { return d->title->value().toString(); } bool KReportDesigner::isModified() const { return d->modified; } void KReportDesigner::setModified(bool mod) { d->modified = mod; if (d->modified) { emit dirty(); } } QStringList KReportDesigner::fieldNames() const { QStringList qs; qs << QString(); if (d->kordata) qs << d->kordata->fieldNames(); return qs; } QStringList KReportDesigner::fieldKeys() const { QStringList qs; qs << QString(); if (d->kordata) qs << d->kordata->fieldKeys(); return qs; } void KReportDesigner::createProperties() { QStringList keys, strings; d->set = new KPropertySet; KReportDesigner::addMetaProperties(d->set, - tr("Report", "Main report element"), QLatin1String("kreport_report_element")); + tr("Report", "Main report element"), QLatin1String("kreport-report-element")); connect(d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); d->title = new KProperty("title", QLatin1String("Report"), tr("Title"), tr("Report Title")); keys.clear(); keys = KReportPageSize::pageFormatKeys(); strings = KReportPageSize::pageFormatNames(); QString defaultKey = KReportPageSize::pageSizeKey(KReportPageSize::defaultSize()); d->pageSize = new KProperty("page-size", keys, strings, defaultKey, tr("Page Size")); keys.clear(); strings.clear(); keys << QLatin1String("portrait") << QLatin1String("landscape"); strings << tr("Portrait") << tr("Landscape"); d->orientation = new KProperty("print-orientation", keys, strings, QLatin1String("portrait"), tr("Page Orientation")); keys.clear(); strings.clear(); strings = KReportUnit::listOfUnitNameForUi(KReportUnit::HidePixel); QString unit; foreach(const QString &un, strings) { unit = un.mid(un.indexOf(QLatin1String("(")) + 1, 2); keys << unit; } d->unit = new KProperty("page-unit", keys, strings, QLatin1String("cm"), tr("Page Unit")); d->showGrid = new KProperty("grid-visible", true, tr("Show Grid")); d->gridSnap = new KProperty("grid-snap", true, tr("Snap to Grid")); d->gridDivisions = new KProperty("grid-divisions", 4, tr("Grid Divisions")); d->leftMargin = new KProperty("margin-left", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), tr("Left Margin"), tr("Left Margin"), KProperty::Double); d->rightMargin = new KProperty("margin-right", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), tr("Right Margin"), tr("Right Margin"), KProperty::Double); d->topMargin = new KProperty("margin-top", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), tr("Top Margin"), tr("Top Margin"), KProperty::Double); d->bottomMargin = new KProperty("margin-bottom", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), tr("Bottom Margin"), tr("Bottom Margin"), KProperty::Double); d->leftMargin->setOption("unit", QLatin1String("cm")); d->rightMargin->setOption("unit", QLatin1String("cm")); d->topMargin->setOption("unit", QLatin1String("cm")); d->bottomMargin->setOption("unit", QLatin1String("cm")); d->set->addProperty(d->title); d->set->addProperty(d->pageSize); d->set->addProperty(d->orientation); d->set->addProperty(d->unit); d->set->addProperty(d->gridSnap); d->set->addProperty(d->showGrid); d->set->addProperty(d->gridDivisions); d->set->addProperty(d->leftMargin); d->set->addProperty(d->rightMargin); d->set->addProperty(d->topMargin); d->set->addProperty(d->bottomMargin); #ifdef KREPORT_SCRIPTING d->script = new KProperty("script", QStringList(), QStringList(), QString(), tr("Object Script")); d->set->addProperty(d->script); #endif // KProperty* _customHeight; // KProperty* _customWidth; } /** @brief Handle property changes */ void KReportDesigner::slotPropertyChanged(KPropertySet &s, KProperty &p) { setModified(true); emit pagePropertyChanged(s); if (p.name() == "page-unit") { d->hruler->setUnit(pageUnit()); QString newstr = d->set->property("page-unit").value().toString(); d->set->property("margin-left").setOption("unit", newstr); d->set->property("margin-right").setOption("unit", newstr); d->set->property("margin-top").setOption("unit", newstr); d->set->property("margin-bottom").setOption("unit", newstr); } } void KReportDesigner::slotPageButton_Pressed() { #ifdef KREPORT_SCRIPTING if (d->kordata) { QStringList sl = d->kordata->scriptList(); sl.prepend(QLatin1String("")); d->script->setListData(sl, sl); } changeSet(d->set); #endif } QSize KReportDesigner::sizeHint() const { int w = 0; int h = 0; if (d->pageFooterAny) h += d->pageFooterAny->sizeHint().height(); if (d->pageFooterEven) h += d->pageFooterEven->sizeHint().height(); if (d->pageFooterFirst) h += d->pageFooterFirst->sizeHint().height(); if (d->pageFooterLast) h += d->pageFooterLast->sizeHint().height(); if (d->pageFooterOdd) h += d->pageFooterOdd->sizeHint().height(); if (d->pageHeaderAny) h += d->pageHeaderAny->sizeHint().height(); if (d->pageHeaderEven) h += d->pageHeaderEven->sizeHint().height(); if (d->pageHeaderFirst) h += d->pageHeaderFirst->sizeHint().height(); if (d->pageHeaderLast) h += d->pageHeaderLast->sizeHint().height(); if (d->pageHeaderOdd) h += d->pageHeaderOdd->sizeHint().height(); if (d->reportHeader) h += d->reportHeader->sizeHint().height(); if (d->reportFooter) { h += d->reportFooter->sizeHint().height(); } if (d->detail) { h += d->detail->sizeHint().height(); w += d->detail->sizeHint().width(); } h += d->hruler->height(); return QSize(w, h); } int KReportDesigner::pageWidthPx() const { KReportPageOptions po; po.setPageSize(d->set->property("page-size").value().toString()); po.setPortrait(d->set->property("print-orientation").value().toString() == QLatin1String("portrait")); QSizeF pageSizePx = po.pixelSize(); int width = pageSizePx.width(); width = width - POINT_TO_INCH(d->set->property("margin-left").value().toDouble()) * KReportDpi::dpiX(); width = width - POINT_TO_INCH(d->set->property("margin-right").value().toDouble()) * KReportDpi::dpiX(); return width; } void KReportDesigner::resizeEvent(QResizeEvent * event) { Q_UNUSED(event); d->hruler->setRulerLength(pageWidthPx()); } void KReportDesigner::setDetail(KReportDesignerSectionDetail *rsd) { if (!d->detail) { int idx = 0; if (d->pageHeaderFirst) idx++; if (d->pageHeaderOdd) idx++; if (d->pageHeaderEven) idx++; if (d->pageHeaderLast) idx++; if (d->pageHeaderAny) idx++; if (d->reportHeader) idx++; d->detail = rsd; d->vboxlayout->insertWidget(idx, d->detail); } } void KReportDesigner::deleteDetail() { delete d->detail; d->detail = 0; } KReportUnit KReportDesigner::pageUnit() const { QString u; bool found; u = d->unit->value().toString(); KReportUnit unit = KReportUnit::fromSymbol(u, &found); if (!found) { unit = KReportUnit(KReportUnit::Centimeter); } return unit; } void KReportDesigner::setGridOptions(bool vis, int div) { d->showGrid->setValue(QVariant(vis)); d->gridDivisions->setValue(div); } // // methods for the sectionMouse*Event() // void KReportDesigner::sectionContextMenuEvent(KReportDesignerSectionScene * s, QGraphicsSceneContextMenuEvent * e) { Q_UNUSED(s); QMenu pop; bool itemsSelected = selectionCount() > 0; if (itemsSelected) { //! @todo KF5 use KStandardAction QAction *a = new QAction(QIcon::fromTheme(QLatin1String("edit-cut")), tr("Cut"), this); connect(a, SIGNAL(triggered()), this, SLOT(slotEditCut())); pop.addAction(a); //! @todo KF5 use KStandardAction a = new QAction(QIcon::fromTheme(QLatin1String("edit-copy")), tr("Copy"), this); connect(a, SIGNAL(triggered()), this, SLOT(slotEditCopy())); pop.addAction(a); } if (!d->sectionData->copy_list.isEmpty()) { QAction *a = new QAction(QIcon::fromTheme(QLatin1String("edit-paste")), tr("Paste"), this); connect(a, SIGNAL(triggered()), this, SLOT(slotEditPaste())); pop.addAction(a); } if (itemsSelected) { pop.addSeparator(); //! @todo KF5 use KStandard* //const KGuiItem del = KStandardGuiItem::del(); //a->setToolTip(del.toolTip()); //a->setShortcut(QKeySequence(QKeySequence::Delete)); QAction *a = new QAction(QIcon::fromTheme(QLatin1String("edit-delete")), tr("Delete"), this); connect(a, SIGNAL(triggered()), SLOT(slotEditDelete())); pop.addAction(a); } if (!pop.actions().isEmpty()) { pop.exec(e->screenPos()); } } void KReportDesigner::sectionMousePressEvent(KReportDesignerSectionView * v, QMouseEvent * e) { Q_UNUSED(v); d->pressX = e->pos().x(); d->pressY = e->pos().y(); } void KReportDesigner::sectionMouseReleaseEvent(KReportDesignerSectionView * v, QMouseEvent * e) { e->accept(); d->releaseX = e->pos().x(); d->releaseY = e->pos().y(); if (e->button() == Qt::LeftButton) { QPointF pos(d->pressX, d->pressY); QPointF end(d->releaseX, d->releaseY); if (d->releaseY >= v->scene()->height()) { d->releaseY = v->scene()->height(); end.setY(v->scene()->height()); } if (d->releaseX >= v->scene()->width()) { d->releaseX = v->scene()->width(); end.setX(v->scene()->width()); } if (d->sectionData->mouseAction == ReportWriterSectionData::MA_Insert) { QGraphicsItem * item = 0; QString classString; QString iconName; if (d->sectionData->insertItem == QLatin1String("org.kde.kreport.line")) { item = new KReportDesignerItemLine(v->designer(), v->scene(), pos, end); classString = tr("Line", "Report line element"); - iconName = QLatin1String("kreport_line_element"); + iconName = QLatin1String("kreport-line-element"); } else { KReportPluginManager* pluginManager = KReportPluginManager::self(); KReportPluginInterface *plug = pluginManager->plugin(d->sectionData->insertItem); if (plug) { QObject *obj = plug->createDesignerInstance(v->designer(), v->scene(), pos); if (obj) { item = dynamic_cast(obj); classString = plug->metaData()->name(); iconName = plug->metaData()->iconName(); } } else { kreportWarning() << "attempted to insert an unknown item"; } } if (item) { item->setVisible(true); item->setSelected(true); KReportItemBase* baseReportItem = dynamic_cast(item); if (baseReportItem) { KPropertySet *set = baseReportItem->propertySet(); KReportDesigner::addMetaProperties(set, classString, iconName); changeSet(set); if (v && v->designer()) { v->designer()->setModified(true); } emit itemInserted(d->sectionData->insertItem); } } d->sectionData->mouseAction = ReportWriterSectionData::MA_None; d->sectionData->insertItem.clear(); unsetSectionCursor(); } } } unsigned int KReportDesigner::selectionCount() const { if (activeScene()) return activeScene()->selectedItems().count(); else return 0; } void KReportDesigner::changeSet(KPropertySet *s) { //Set the checked state of the report properties button if (s == d->set) d->pageButton->setCheckState(Qt::Checked); else d->pageButton->setCheckState(Qt::Unchecked); d->itmset = s; emit propertySetChanged(); } // // Actions // void KReportDesigner::slotItem(const QString &entity) { //kreportDebug() << entity; d->sectionData->mouseAction = ReportWriterSectionData::MA_Insert; d->sectionData->insertItem = entity; setSectionCursor(QCursor(Qt::CrossCursor)); } void KReportDesigner::slotEditDelete() { QGraphicsItem * item = 0; bool modified = false; while (selectionCount() > 0) { item = activeScene()->selectedItems().value(0); if (item) { QGraphicsScene * scene = item->scene(); delete item; scene->update(); d->sectionData->mouseAction = ReportWriterSectionData::MA_None; modified = true; } } activeScene()->selectedItems().clear(); /*! @todo temporary: clears cut and copy lists to make sure we do not crash if weve deleted something in the list should really check if an item is in the list first and remove it. */ d->sectionData->cut_list.clear(); d->sectionData->copy_list.clear(); if (modified) { setModified(true); } } void KReportDesigner::slotEditCut() { if (selectionCount() > 0) { //First delete any items that are curerntly in the list //so as not to leak memory qDeleteAll(d->sectionData->cut_list); d->sectionData->cut_list.clear(); QGraphicsItem * item = activeScene()->selectedItems().first(); bool modified = false; if (item) { d->sectionData->copy_list.clear(); foreach(QGraphicsItem *item, activeScene()->selectedItems()) { d->sectionData->cut_list.append(dynamic_cast(item)); d->sectionData->copy_list.append(dynamic_cast(item)); } foreach(QGraphicsItem *item, activeScene()->selectedItems()) { activeScene()->removeItem(item); activeScene()->update(); modified = true; } d->sectionData->selected_x_offset = 10; d->sectionData->selected_y_offset = 10; } if (modified) { setModified(true); } } } void KReportDesigner::slotEditCopy() { if (selectionCount() < 1) return; QGraphicsItem * item = activeScene()->selectedItems().first(); if (item) { d->sectionData->copy_list.clear(); foreach(QGraphicsItem *item, activeScene()->selectedItems()) { d->sectionData->copy_list.append(dynamic_cast(item)); } d->sectionData->selected_x_offset = 10; d->sectionData->selected_y_offset = 10; } } void KReportDesigner::slotEditPaste() { // call the editPaste function passing it a reportsection slotEditPaste(activeScene()); } void KReportDesigner::slotEditPaste(QGraphicsScene * canvas) { // paste a new item of the copy we have in the specified location if (!d->sectionData->copy_list.isEmpty()) { QList activeItems = canvas->selectedItems(); QGraphicsItem *activeItem = 0; if (activeItems.count() == 1) { activeItem = activeItems.first(); } canvas->clearSelection(); d->sectionData->mouseAction = ReportWriterSectionData::MA_None; //! @todo this code sucks :) //! The setPos calls only work AFTER the name has been set ?!?!? foreach(KReportDesignerItemBase *item, d->sectionData->copy_list) { KReportItemBase *obj = dynamic_cast(item); const QString type = obj ? obj->typeName() : QLatin1String("object"); //kreportDebug() << type; KReportDesignerItemBase *ent = item->clone(); KReportItemBase *new_obj = dynamic_cast(ent); new_obj->setEntityName(suggestEntityName(type)); if (activeItem) { new_obj->position().setScenePos(QPointF(activeItem->x() + 10, activeItem->y() + 10)); } else { new_obj->position().setScenePos(QPointF(0, 0)); } changeSet(new_obj->propertySet()); QGraphicsItem *pasted_ent = dynamic_cast(ent); if (pasted_ent) { pasted_ent->setSelected(true); canvas->addItem(pasted_ent); pasted_ent->show(); d->sectionData->mouseAction = ReportWriterSectionData::MA_Grab; setModified(true); } } } } void KReportDesigner::slotRaiseSelected() { dynamic_cast(activeScene())->raiseSelected(); } void KReportDesigner::slotLowerSelected() { dynamic_cast(activeScene())->lowerSelected(); } QGraphicsScene* KReportDesigner::activeScene() const { return d->activeScene; } void KReportDesigner::setActiveScene(QGraphicsScene* a) { if (d->activeScene && d->activeScene != a) d->activeScene->clearSelection(); d->activeScene = a; //Trigger an update so that the last scene redraws its title; update(); } KReportZoomHandler* KReportDesigner::zoomHandler() const { return d->zoom; } QString KReportDesigner::suggestEntityName(const QString &n) const { KReportDesignerSection *sec; int itemCount = 0; //Count items in the main sections for (int i = 1; i <= KReportSectionData::PageFooterAny; i++) { sec = section((KReportSectionData::Section) i); if (sec) { const QGraphicsItemList l = sec->items(); itemCount += l.count(); } } if (d->detail) { //Count items in the group headers/footers for (int i = 0; i < d->detail->groupSectionCount(); i++) { sec = d->detail->groupSection(i)->groupHeader(); if (sec) { const QGraphicsItemList l = sec->items(); itemCount += l.count(); } sec = d->detail->groupSection(i)->groupFooter(); if (sec) { const QGraphicsItemList l = sec->items(); itemCount += l.count(); } } sec = d->detail->detailSection(); if (sec) { const QGraphicsItemList l = sec->items(); itemCount += l.count(); } } while (!isEntityNameUnique(n + QString::number(itemCount))) { itemCount++; } return n + QString::number(itemCount); } bool KReportDesigner::isEntityNameUnique(const QString &n, KReportItemBase* ignore) const { KReportDesignerSection *sec; bool unique = true; //Check items in the main sections for (int i = 1; i <= KReportSectionData::PageFooterAny; i++) { sec = section((KReportSectionData::Section)i); if (sec) { const QGraphicsItemList l = sec->items(); for (QGraphicsItemList::const_iterator it = l.constBegin(); it != l.constEnd(); ++it) { KReportItemBase* itm = dynamic_cast(*it); if (itm && itm->entityName() == n && itm != ignore) { unique = false; break; } } if (!unique) break; } } //Count items in the group headers/footers if (unique && d->detail) { for (int i = 0; i < d->detail->groupSectionCount(); ++i) { sec = d->detail->groupSection(i)->groupHeader(); if (sec) { const QGraphicsItemList l = sec->items(); for (QGraphicsItemList::const_iterator it = l.constBegin(); it != l.constEnd(); ++it) { KReportItemBase* itm = dynamic_cast(*it); if (itm && itm->entityName() == n && itm != ignore) { unique = false; break; } } } sec = d->detail->groupSection(i)->groupFooter(); if (unique && sec) { const QGraphicsItemList l = sec->items(); for (QGraphicsItemList::const_iterator it = l.constBegin(); it != l.constEnd(); ++it) { KReportItemBase* itm = dynamic_cast(*it); if (itm && itm->entityName() == n && itm != ignore) { unique = false; break; } } } } } if (unique && d->detail) { sec = d->detail->detailSection(); if (sec) { const QGraphicsItemList l = sec->items(); for (QGraphicsItemList::const_iterator it = l.constBegin(); it != l.constEnd(); ++it) { KReportItemBase* itm = dynamic_cast(*it); if (itm && itm->entityName() == n && itm != ignore) { unique = false; break; } } } } return unique; } static bool actionPriortyLessThan(QAction* act1, QAction* act2) { if (act1->data().toInt() > 0 && act2->data().toInt() > 0) { return act1->data().toInt() < act2->data().toInt(); } return false; } QList KReportDesigner::itemActions(QActionGroup* group) { KReportPluginManager* manager = KReportPluginManager::self(); QList actList = manager->createActions(group); //! @todo make line a real plugin so this isn't needed: - QAction *act = new QAction(QIcon::fromTheme(QLatin1String("kreport_line_element")), tr("Line"), group); + QAction *act = new QAction(QIcon::fromTheme(QLatin1String("kreport-line-element")), tr("Line"), group); act->setObjectName(QLatin1String("org.kde.kreport.line")); act->setData(9); act->setCheckable(true); actList << act; qSort(actList.begin(), actList.end(), actionPriortyLessThan); int i = 0; /*! @todo maybe this is a bit hackish It finds the first plugin based on the priority in userdata The lowest oriority a plugin can have is 10 And inserts a separator before it. */ bool sepInserted = false; foreach(QAction *a, actList) { ++i; if (!sepInserted && a->data().toInt() >= 10) { QAction *sep = new QAction(QLatin1String("separator"), group); sep->setSeparator(true); actList.insert(i-1, sep); sepInserted = true; } if (group) { group->addAction(a); } } return actList; } QList< QAction* > KReportDesigner::designerActions() { QList al; QAction *sep = new QAction(QString(), this); sep->setSeparator(true); al << d->editCutAction << d->editCopyAction << d->editPasteAction << d->editDeleteAction << sep << d->sectionEdit << sep << d->itemLowerAction << d->itemRaiseAction; return al; } void KReportDesigner::createActions() { d->editCutAction = new QAction(QIcon::fromTheme(QLatin1String("edit-cut")), tr("Cu&t"), this); d->editCutAction->setObjectName(QLatin1String("edit_cut")); d->editCutAction->setToolTip(tr("Cut selection to clipboard")); d->editCutAction->setShortcuts(KStandardShortcut::cut()); d->editCutAction->setProperty("iconOnly", true); d->editCopyAction = new QAction(QIcon::fromTheme(QLatin1String("edit-copy")), tr("&Copy"), this); d->editCopyAction->setObjectName(QLatin1String("edit_copy")); d->editCopyAction->setToolTip(tr("Copy selection to clipboard")); d->editCopyAction->setShortcuts(KStandardShortcut::copy()); d->editCopyAction->setProperty("iconOnly", true); d->editPasteAction = new QAction(QIcon::fromTheme(QLatin1String("edit-paste")), tr("&Paste"), this); d->editPasteAction->setObjectName(QLatin1String("edit_paste")); d->editPasteAction->setToolTip(tr("Paste clipboard content")); d->editPasteAction->setShortcuts(KStandardShortcut::paste()); d->editPasteAction->setProperty("iconOnly", true); const KGuiItem del = KStandardGuiItem::del(); d->editDeleteAction = new QAction(del.icon(), del.text(), this); d->editDeleteAction->setObjectName(QLatin1String("edit_delete")); d->editDeleteAction->setToolTip(del.toolTip()); d->editDeleteAction->setWhatsThis(del.whatsThis()); d->editDeleteAction->setProperty("iconOnly", true); d->sectionEdit = new QAction(tr("Edit Sections"), this); d->sectionEdit->setObjectName(QLatin1String("section_edit")); d->itemRaiseAction = new QAction(QIcon::fromTheme(QLatin1String("arrow-up")), tr("Raise"), this); d->itemRaiseAction->setObjectName(QLatin1String("item_raise")); d->itemLowerAction = new QAction(QIcon::fromTheme(QLatin1String("arrow-down")), tr("Lower"), this); d->itemLowerAction->setObjectName(QLatin1String("item_lower")); //Edit Actions connect(d->editCutAction, SIGNAL(triggered(bool)), this, SLOT(slotEditCut())); connect(d->editCopyAction, SIGNAL(triggered(bool)), this, SLOT(slotEditCopy())); connect(d->editPasteAction, SIGNAL(triggered(bool)), this, SLOT(slotEditPaste())); connect(d->editDeleteAction, SIGNAL(triggered(bool)), this, SLOT(slotEditDelete())); connect(d->sectionEdit, SIGNAL(triggered(bool)), this, SLOT(slotSectionEditor())); //Raise/Lower connect(d->itemRaiseAction, SIGNAL(triggered(bool)), this, SLOT(slotRaiseSelected())); connect(d->itemLowerAction, SIGNAL(triggered(bool)), this, SLOT(slotLowerSelected())); } void KReportDesigner::setSectionCursor(const QCursor& c) { if (d->pageFooterAny) d->pageFooterAny->setSectionCursor(c); if (d->pageFooterEven) d->pageFooterEven->setSectionCursor(c); if (d->pageFooterFirst) d->pageFooterFirst->setSectionCursor(c); if (d->pageFooterLast) d->pageFooterLast->setSectionCursor(c); if (d->pageFooterOdd) d->pageFooterOdd->setSectionCursor(c); if (d->pageHeaderAny) d->pageHeaderAny->setSectionCursor(c); if (d->pageHeaderEven) d->pageHeaderEven->setSectionCursor(c); if (d->pageHeaderFirst) d->pageHeaderFirst->setSectionCursor(c); if (d->pageHeaderLast) d->pageHeaderLast->setSectionCursor(c); if (d->pageHeaderOdd) d->pageHeaderOdd->setSectionCursor(c); if (d->detail) d->detail->setSectionCursor(c); } void KReportDesigner::unsetSectionCursor() { if (d->pageFooterAny) d->pageFooterAny->unsetSectionCursor(); if (d->pageFooterEven) d->pageFooterEven->unsetSectionCursor(); if (d->pageFooterFirst) d->pageFooterFirst->unsetSectionCursor(); if (d->pageFooterLast) d->pageFooterLast->unsetSectionCursor(); if (d->pageFooterOdd) d->pageFooterOdd->unsetSectionCursor(); if (d->pageHeaderAny) d->pageHeaderAny->unsetSectionCursor(); if (d->pageHeaderEven) d->pageHeaderEven->unsetSectionCursor(); if (d->pageHeaderFirst) d->pageHeaderFirst->unsetSectionCursor(); if (d->pageHeaderLast) d->pageHeaderLast->unsetSectionCursor(); if (d->pageHeaderOdd) d->pageHeaderOdd->unsetSectionCursor(); if (d->detail) d->detail->unsetSectionCursor(); } qreal KReportDesigner::countSelectionHeight() const { if (d->releaseY == -1 || d->pressY == -1) { return -1; } return qAbs(d->releaseY - d->pressY); } qreal KReportDesigner::countSelectionWidth() const { if (d->releaseX == -1 || d->pressX == -1) { return -1; } return qAbs(d->releaseX - d->pressX); } qreal KReportDesigner::getSelectionPressX() const { return d->pressX; } qreal KReportDesigner::getSelectionPressY() const { return d->pressY; } QPointF KReportDesigner::getPressPoint() const { return QPointF(d->pressX, d->pressY); } QPointF KReportDesigner::getReleasePoint() const { return QPointF(d->releaseX, d->releaseY); } void KReportDesigner::plugItemActions(const QList &actList) { foreach(QAction *a, actList) { connect(a, SIGNAL(triggered(bool)), this, SLOT(slotItemTriggered(bool))); } } void KReportDesigner::slotItemTriggered(bool checked) { if (!checked) { return; } QObject *theSender = sender(); if (!theSender) { return; } slotItem(theSender->objectName()); } void KReportDesigner::addMetaProperties(KPropertySet* set, const QString &classString, const QString &iconName) { Q_ASSERT(set); KProperty *prop; set->addProperty(prop = new KProperty("this:classString", classString)); prop->setVisible(false); set->addProperty(prop = new KProperty("this:iconName", iconName)); prop->setVisible(false); } diff --git a/src/wrtembed/KReportDesigner.h b/src/wrtembed/KReportDesigner.h index 9d00b193..a4dda0d8 100644 --- a/src/wrtembed/KReportDesigner.h +++ b/src/wrtembed/KReportDesigner.h @@ -1,348 +1,348 @@ /* This file is part of the KDE project * Copyright (C) 2001-2007 by OpenMFG, LLC * Copyright (C) 2007-2008 by Adam Pigg * Copyright (C) 2011 Jarosław Staniek * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef KREPORTDESIGNER_H #define KREPORTDESIGNER_H #include #include "KReportDocument.h" #include "KReportData.h" class KProperty; class KPropertySet; class KReportItemBase; class QGraphicsScene; class QActionGroup; class QGraphicsSceneContextMenuEvent; class QString; class KReportZoomHandler; class KReportDesignerSectionDetail; class KReportDesignerSection; class KReportUnit; class KReportDesignerSectionScene; class KReportDesignerSectionView; class QAction; // // Class ReportDesigner // The ReportDesigner is the main widget for designing a report // class KREPORT_EXPORT KReportDesigner : public QWidget { Q_OBJECT public: /** @brief Constructor that create a blank designer @param widget QWidget parent */ explicit KReportDesigner(QWidget *parent = 0); /** @brief Constructor that create a designer, and loads the report described in the QDomElement @param widget QWidget parent @param element Report structure XML element */ KReportDesigner(QWidget *, const QDomElement &data); /** @brief Desctructor */ ~KReportDesigner(); /** @brief Sets the report data The report data interface contains functions to retrieve data and information about the fields. @param kodata Pointer to KReportData instance, ownership is transferred */ void setReportData(KReportData* kodata); /** @brief Return a pointer to the reports data @return Pointer to report data */ KReportData *reportData() const; /** @brief Return a pointer to the section specified @param section KReportSectionData::Section enum value of the section to return @return Pointer to report section object, or 0 if no section exists */ KReportDesignerSection* section(KReportSectionData::Section) const; /** @brief Deletes the section specified @param section KReportSectionData::Section enum value of the section to return */ void removeSection(KReportSectionData::Section); /** @brief Create a new section and insert it into the report @param section KReportSectionData::Section enum value of the section to return */ void insertSection(KReportSectionData::Section); /** @brief Return a pointer to the detail section. The detail section contains the actual detail section and related group sections @return Pointer to detail section */ KReportDesignerSectionDetail* detailSection() const; /** @brief Sets the title of the reportData @param title Report Title */ void setReportTitle(const QString &); /** @brief Sets the parameters for the display of the background gridpoints @param visible Grid visibility @param divisions Number of minor divisions between major points */ void setGridOptions(bool visible, int divisions); /** @brief Return the title of the report */ QString reportTitle() const; /** @brief Return an XML description of the report @return QDomElement describing the report definition */ QDomElement document() const; /** @brief Return true if the design has been modified @return modified status */ bool isModified() const; /** @return a list of field names in the selected KReportData */ QStringList fieldNames() const; /** @return a list of field keys in the selected KReportData The keys can be used to reference the names */ QStringList fieldKeys() const; /** @brief Calculate the width of the page in pixels given the paper size, orientation, dpi and margin @return integer value of width in pixels */ int pageWidthPx() const; /** @return the scene (section) that is currently active */ QGraphicsScene* activeScene() const; /** @brief Sets the active Scene @param scene The scene to make active */ void setActiveScene(QGraphicsScene* scene); /** @return the property set for the general report properties */ KPropertySet* propertySet() const; /** @brief Give a hint on the size of the widget */ virtual QSize sizeHint() const; /** @brief Return a pointer to the zoom handler */ KReportZoomHandler* zoomHandler() const; /** @brief Return the current unit assigned to the report */ KReportUnit pageUnit() const; /** @brief Handle the context menu event for a report section @param scene The associated scene (section) */ void sectionContextMenuEvent(KReportDesignerSectionScene *, QGraphicsSceneContextMenuEvent * e); /** @brief Handle the mouse release event for a report section */ void sectionMouseReleaseEvent(KReportDesignerSectionView *, QMouseEvent * e); void sectionMousePressEvent(KReportDesignerSectionView *, QMouseEvent * e); /** @brief Sets the property set for the currently selected item @param set Property set of item */ void changeSet(KPropertySet *); /** @brief Return the property set for the curently selected item */ KPropertySet* itemPropertySet() const; /** @brief Sets the modified status, defaulting to true for modified @param modified Modified status */ void setModified(bool = true); /** @brief Return a unique name that can be used by the entity @param entity Name of entity */ QString suggestEntityName(const QString &) const; /** @brief Checks if the supplied name is unique among all entities */ bool isEntityNameUnique(const QString &, KReportItemBase* = 0) const; /** @brief Returns a list of actions that represent the entities that can be inserted into the report. Actions are created as children of @a group and belong to the group. @return list of actions */ static QList itemActions(QActionGroup* group = 0); /** @brief Populates the toolbar with actions that can be applied to the report Actions are created as children of @a group and belong to the group. @return list of actions */ QList designerActions(); /** @return X position of mouse when mouse press occurs */ qreal getSelectionPressX() const; /** @return Y position of mouse when mouse press occurs */ qreal getSelectionPressY() const; /** @return difference between X position of mouse release and press */ qreal countSelectionWidth() const; /** @return difference between Y position of mouse release and press */ qreal countSelectionHeight() const; /** @return point that contains X,Y coordinates of mouse press */ QPointF getPressPoint() const; /** @return point that contains X,Y coordinates of mouse press */ QPointF getReleasePoint() const; void plugItemActions(const QList &actList); /** * @brief Adds meta-properties to the property set @a set for consumption by property editor * - "this:classString" - user-visible translated name of element type, e.g. tr("Label") - * - "this:iconName" - name of user-visible icon, e.g. "kreport_label_element" + * - "this:iconName" - name of user-visible icon, e.g. "kreport-label-element" * * All the properties are set to invisible. * @see propertySet() */ static void addMetaProperties(KPropertySet* set, const QString &classString, const QString &iconName); public Q_SLOTS: void slotEditDelete(); void slotEditCut(); void slotEditCopy(); void slotEditPaste(); void slotEditPaste(QGraphicsScene *); void slotItem(const QString&); void slotSectionEditor(); void slotRaiseSelected(); void slotLowerSelected(); private: void init(); /** @brief Sets the detail section to the given section */ void setDetail(KReportDesignerSectionDetail *rsd); /** @brief Deletes the detail section */ void deleteDetail(); virtual void resizeEvent(QResizeEvent * event); //Properties void createProperties(); unsigned int selectionCount() const; void setSectionCursor(const QCursor&); void unsetSectionCursor(); void createActions(); private Q_SLOTS: void slotPropertyChanged(KPropertySet &s, KProperty &p); /** @brief When the 'page' button in the top left is pressed, change the property set to the reports properties. */ void slotPageButton_Pressed(); void slotItemTriggered(bool checked); Q_SIGNALS: void pagePropertyChanged(KPropertySet &s); void propertySetChanged(); void dirty(); void reportDataChanged(); void itemInserted(const QString& entity); private: Q_DISABLE_COPY(KReportDesigner) class Private; Private * const d; }; #endif