diff --git a/CMakeLists.txt b/CMakeLists.txt index b4cf3ce1a..1d3a275e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,345 +1,344 @@ # The CMake version we require cmake_minimum_required(VERSION 3.1) # Setting the name of the main project project(KMyMoney VERSION "5.0.80" LANGUAGES CXX) # Determine the GIT reference (if we're based on GIT) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") execute_process(COMMAND git rev-parse --short HEAD WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE VERSION_SUFFIX OUTPUT_STRIP_TRAILING_WHITESPACE) set(VERSION_SUFFIX "-${VERSION_SUFFIX}") # Add variables which are similar to the build in names of cmake set(PROJECT_VERSION_SUFFIX "${VERSION_SUFFIX}") set(${PROJECT_NAME}_VERSION_SUFFIX "${VERSION_SUFFIX}") endif() # Automoc all sources set(CMAKE_AUTOMOC TRUE) list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "K_PLUGIN_FACTORY" "K_PLUGIN_FACTORY_WITH_JSON") if (POLICY CMP0063) cmake_policy(SET CMP0063 NEW) # Policy introduced in CMake version 3.3 endif() if (POLICY CMP0071) # We do not require the old behaviour. It is only set to old, to prevent accidential use of # the new behavour. If the new behaviour becomes important, cmake_minimum_required has to be # set to "3.10". cmake_policy(SET CMP0071 OLD) # Policy introduced in CMake version 3.10 endif() ######################### General Requirements ########################## find_package(ECM 5.10 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) include(KDEInstallDirs) include(KDECMakeSettings) include(FeatureSummary) include(CMakeDependentOption) include(GenerateExportHeader) include(KMyMoneyMacros) set (OPT_KF5_COMPONENTS DocTools Holidays Contacts Akonadi IdentityManagement Activities) find_package(Gpgmepp) if (Gpgmepp_FOUND) set(GPG_ENCRYPTION ON) else() set(GPG_ENCRYPTION OFF) list(APPEND OPT_KF5_COMPONENTS Gpgmepp) endif() find_package(Qt5 5.6 REQUIRED COMPONENTS Core DBus Widgets Svg Sql Xml Test PrintSupport OPTIONAL_COMPONENTS Concurrent QuickWidgets) find_package(KF5 5.2 REQUIRED COMPONENTS Archive CoreAddons Config ConfigWidgets I18n Completion KCMUtils ItemModels ItemViews Service Wallet IconThemes XmlGui TextWidgets Notifications KIO OPTIONAL_COMPONENTS ${OPT_KF5_COMPONENTS} ) find_package(LibAlkimia5 7.0.0 REQUIRED) # Recent changes to LibAlkimia should allow us to remove this construct #if(CMAKE_SYSTEM_NAME MATCHES "Windows") # include_directories(${GMP_INCLUDE_DIR}) #endif() find_package(KChart 2.6.0 REQUIRED) if(KF5Gpgmepp_FOUND) set(GPG_ENCRYPTION ON) add_definitions(-DGpgmepp_FOUND) endif() add_feature_info("Encryption" GPG_ENCRYPTION "It allows encrypting your financial data.") add_definitions(-DQT_USE_QSTRINGBUILDER -DQT_NO_CAST_TO_ASCII -DQT_NO_URL_CAST_FROM_STRING) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # use DBus only on Linux if(CMAKE_SYSTEM_NAME MATCHES "Linux") set(KMM_DBUS 1) endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) # check for Doxygen find_package(Doxygen) if(DOXYGEN_FOUND) set(APIDOC_DIR ${CMAKE_CURRENT_BINARY_DIR}/apidocs) make_directory("${APIDOC_DIR}") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/kmymoney.doxygen.in ${CMAKE_CURRENT_BINARY_DIR}/kmymoney.doxygen IMMEDIATE) add_custom_target(apidoc "${DOXYGEN}" "${CMAKE_CURRENT_BINARY_DIR}/kmymoney.doxygen") endif(DOXYGEN_FOUND) add_feature_info("Doxygen" DOXYGEN_FOUND "Generate API documentation with Doxygen (for devs only).") # check some include files exists set(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=500 -D_BSD_SOURCE) include (CheckIncludeFileCXX) check_include_file_cxx("unistd.h" HAVE_UNISTD_H) check_include_file_cxx("pwd.h" HAVE_PWD_H) check_include_file_cxx("windows.h" HAVE_WINDOWS_H) check_include_file_cxx("lmcons.h" HAVE_LMCONS_H) check_include_file_cxx("process.h" HAVE_PROCESS_H) # include check for members in structs include (CheckStructHasMember) ######################### Special Requirements ########################## # This is needed for QtSqlite and QtDesigner # (they'll install files to ${QT_INSTALL_DIR}/plugins/) get_filename_component(QT_BIN_DIR "${QT_MOC_EXECUTABLE}" PATH) get_filename_component(QT_DIR ${QT_BIN_DIR} PATH) set(QT_INSTALL_DIR ${QT_DIR} CACHE PATH "Qt install prefix defaults to the Qt prefix: ${QT_DIR}") if(KF5IdentityManagement_FOUND AND KF5Akonadi_FOUND AND KF5Contacts_FOUND) set(KMM_ADDRESSBOOK_FOUND true) endif() add_feature_info("Address book" KMM_ADDRESSBOOK_FOUND "It allows fetching payee information from KDE PIM system.") add_feature_info("Holidays" KF5Holidays_FOUND "It allows fetching holidays from KDE PIM system.") option(ENABLE_FORECASTVIEW "Enable forecast view" ON) add_feature_info("Forecast view" ENABLE_FORECASTVIEW "It adds possibility to calculate forecasts.") option(ENABLE_REPORTSVIEW "Enable reports view" ON) add_feature_info("Reports view" ENABLE_REPORTSVIEW "It adds possibility to display chart and table reports.") option(ENABLE_BUDGETVIEW "Enable budget view" ON) add_feature_info("Budget view" ENABLE_BUDGETVIEW "It adds possibility to plan a budget.") option(ENABLE_ONLINEJOBOUTBOXVIEW "Enable online job outbox view" ON) add_feature_info("Online job outbox view" ENABLE_ONLINEJOBOUTBOXVIEW "It adds outbox for sending online jobs.") cmake_dependent_option(ENABLE_SQLSTORAGE "Enable SQL storage support." ON "Qt5Sql_FOUND" OFF) add_feature_info("SQL Storage" ENABLE_SQLSTORAGE "It allows storing your financial data in SQL database (note: no encryption yet supported, no iban yet supported).") # check for optional QWebEngine option(ENABLE_WEBENGINE "Enable QWebEngine" OFF) if(ENABLE_WEBENGINE) find_package(Qt5WebEngineWidgets 5.8 REQUIRED) if(Qt5WebEngineWidgets_VERSION VERSION_GREATER 5.8.99 AND Qt5WebEngineWidgets_VERSION VERSION_LESS 5.9.3) message(WARNING "QWebEngine version ${Qt5WebEngineWidgets_VERSION} is known to be unstable with KMyMoney") endif() else(ENABLE_WEBENGINE) find_package(KF5WebKit REQUIRED) endif(ENABLE_WEBENGINE) # check for optional LibOFX support find_package(LibOfx) cmake_dependent_option(ENABLE_OFXIMPORTER "Enable OFX Importer" ON "LIBOFX_FOUND" OFF) if(ENABLE_OFXIMPORTER) if(NOT LIBOFX_HAVE_CLIENTUID) if(CMAKE_SYSTEM_NAME MATCHES "Windows") set(PATH_TO_LIBOFX_HEADER "${LIBOFX_INCLUDE_DIR}/libofx/libofx.h") # Windows doesn't even see the header if it's not full path else() set(PATH_TO_LIBOFX_HEADER "libofx/libofx.h") endif() unset(LIBOFX_HAVE_CLIENTUID) unset(LIBOFX_HAVE_CLIENTUID CACHE) #not doing this will prevent updating below check check_struct_has_member("struct OfxFiLogin" clientuid ${PATH_TO_LIBOFX_HEADER} LIBOFX_HAVE_CLIENTUID LANGUAGE CXX) endif() if (LIBOFX_HAVE_CLIENTUID) set (nice_LIBOFX_HAVE_CLIENTUID "yes") else() set (nice_LIBOFX_HAVE_CLIENTUID "no") endif() else() set (nice_LIBOFX_HAVE_CLIENTUID "unknown") unset(LIBOFX_HAVE_CLIENTUID) unset(LIBOFX_HAVE_CLIENTUID CACHE) endif(ENABLE_OFXIMPORTER) add_feature_info("OFX Importer" ENABLE_OFXIMPORTER "It allows importing OFX files (have client uid version: ${nice_LIBOFX_HAVE_CLIENTUID})" ) # check for optional KBanking support find_package(AQBANKING 5.6.5) find_package(gwenhywfar 4.15.3) find_package(gwengui-cpp) find_package(gwengui-qt5) cmake_dependent_option(ENABLE_KBANKING "Enable KBanking plugin" ON "AQBANKING_FOUND;gwengui-cpp_FOUND;gwengui-qt5_FOUND;Qt5QuickWidgets_FOUND" OFF) add_feature_info(KBanking ENABLE_KBANKING "Interface for the following online banking protocols: HBCI, EBICS, OFX Direct Connect, Paypal") # check for optional Weboob support set(Python_ADDITIONAL_VERSIONS 2.7 2.6) find_package(PythonInterp 2.6) find_package(PythonLibs ${PYTHON_VERSION_STRING}) if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND) if(NOT PYTHON_VERSION_MAJOR VERSION_LESS 3) unset(PYTHONLIBS_FOUND) unset(PYTHONINTERP_FOUND) message(WARNING "Python 2 required, but Python 3 found.") else() include(FindPythonModule) find_python_module(weboob REQUIRED) endif() endif() cmake_dependent_option(ENABLE_WEBOOB "Enable Weboob plugin" ON "PYTHONLIBS_FOUND;PYTHONINTERP_FOUND;PY_WEBOOB;Qt5Concurrent_FOUND" OFF) add_feature_info(Weboob ENABLE_WEBOOB "Online banking interface using Weboob.") # check for optional ical support find_package(Libical) cmake_dependent_option(ENABLE_LIBICAL "Enable Calendar plugin" ON "LIBICAL_FOUND" OFF) add_feature_info(iCalendar ENABLE_LIBICAL "iCalendar integration.") option(ENABLE_QIFIMPORTER "Enable QIF Importer" ON) option(ENABLE_QIFEXPORTER "Enable QIF Exporter" ON) add_feature_info("QIF Importer" ENABLE_QIFIMPORTER "It allows importing QIF files.") add_feature_info("QIF Exporter" ENABLE_QIFEXPORTER "It allows exporting QIF files.") option(ENABLE_GNCIMPORTER "Enable GNC Importer" ON) add_feature_info("GNC Importer" ENABLE_GNCIMPORTER "It allows importing GNUCash files.") option(ENABLE_CSVIMPORTER "Enable CSV Importer" ON) option(ENABLE_CSVEXPORTER "Enable CSV Exporter" ON) add_feature_info("CSV Importer" ENABLE_CSVIMPORTER "It allows importing CSV files.") add_feature_info("CSV Exporter" ENABLE_CSVEXPORTER "It allows exporting CSV files.") option(ENABLE_UNFINISHEDFEATURES "For devs only" OFF) # TODO: this should be removed enable_testing() ######################### Settings ########################## # If no build type is set, use "Release with Debug Info" if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo) endif(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build. Possible values are: 'Release' 'RelWithDebInfo' 'Debug' 'DebugKMM' 'Debugfull' 'Profile' The default value is: 'RelWithDebInfo'" FORCE) # tells gcc to enable exception handling include(KDECompilerSettings) kde_enable_exceptions() -if(CMAKE_SYSTEM_NAME MATCHES "Linux") +# Set linker flags +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") -endif() + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed -Wl,--no-undefined") + # TODO: remove multiple definitions of payeeIdentifierLoader::createPayeeIdentifierFromSqlDatabase + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -Wl,--allow-multiple-definition") -# IDEA: Set on a per target base -set(CMAKE_POSITION_INDEPENDENT_CODE ON) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE:Multiple") +endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # be more pedantic about common symbols - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Wextra") +# Set compiler flags +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wlogical-op -Wnull-dereference -Wshadow -Wmisleading-indentation -Wsuggest-override -Wcast-qual -Wformat=2 -fno-common") - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set(IS_GNU 1) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op") +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-qual -Wformat=2 -Wunreachable-code -fno-common") - # TODO: remove multiple definitions of payeeIdentifierLoader::createPayeeIdentifierFromSqlDatabase - if(CMAKE_SYSTEM_NAME MATCHES "Windows") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xlinker --allow-multiple-definition") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xlinker --allow-multiple-definition") - endif() - endif() - - # DebugKMM, Debugfull, Profile - set(CMAKE_CXX_FLAGS_DEBUGKMM - "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline") - set(CMAKE_CXX_FLAGS_DEBUGFULL - "-g3 -fno-inline") - set(CMAKE_CXX_FLAGS_PROFILE - "-g3 -fno-inline -ftest-coverage -fprofile-arcs") - - # be pedantic about undefined symbols when linking shared libraries - if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "kFreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "GNU") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") - endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE:Multiple") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall") endif() -# preprocessor definitions in case this is a debug build -set(CMAKE_CXX_FLAGS_DEBUGFULL "${CMAKE_CXX_FLAGS_DEBUGFULL} -DQT_STRICT_ITERATORS -DKMM_DEBUG") -set(CMAKE_CXX_FLAGS_DEBUGKMM "${CMAKE_CXX_FLAGS_DEBUGFULL} -DKMM_DEBUG") + +# IDEA: Set on a per target base +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") + if(CMAKE_BUILD_TYPE MATCHES "DebugKMM" OR CMAKE_BUILD_TYPE MATCHES "Debugfull" OR CMAKE_BUILD_TYPE MATCHES "Profile") + # DebugKMM, Debugfull, Profile + set(CMAKE_CXX_FLAGS_DEBUGKMM + "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline") + set(CMAKE_CXX_FLAGS_DEBUGFULL + "-g3 -fno-inline") + set(CMAKE_CXX_FLAGS_PROFILE + "-g3 -fno-inline -ftest-coverage -fprofile-arcs") + + # preprocessor definitions in case this is a debug build + set(CMAKE_CXX_FLAGS_DEBUGFULL "${CMAKE_CXX_FLAGS_DEBUGFULL} -DQT_STRICT_ITERATORS -DKMM_DEBUG") + set(CMAKE_CXX_FLAGS_DEBUGKMM "${CMAKE_CXX_FLAGS_DEBUGFULL} -DKMM_DEBUG") + endif() +endif() # and a variable we can use in the build environment to detect debug builds if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") set(KMM_DEBUG "1") endif() option(USE_MODELTEST "Compile with ModelTest code (default=OFF)" OFF) add_feature_info("Model test" USE_MODELTEST "Generate modeltest code (for devs only).") option(USE_QT_DESIGNER "Install KMyMoney specific widget library for Qt-Designer (default=OFF)" OFF) add_feature_info("QtDesigner" USE_QT_DESIGNER "Qt-Designer library support (for devs only).") ######################### The Actual Targets ########################## add_subdirectory( libkgpgfile ) add_subdirectory( tools ) add_subdirectory( kmymoney ) if(KF5DocTools_FOUND) add_subdirectory( doc ) endif() ######################### Output Results ############################# # create the config.h file out of the config.h.cmake configure_file("config-kmymoney.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config-kmymoney.h") configure_file("config-kmymoney-version.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config-kmymoney-version.h") message(" Build type: ${CMAKE_BUILD_TYPE}") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND DESCRIPTION "The following REQUIRED packages have not been found:") feature_summary(WHAT OPTIONAL_PACKAGES_NOT_FOUND DESCRIPTION "The following OPTIONAL packages have not been found:") feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "The following features have been enabled:") feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "The following features have been disabled:") diff --git a/config-kmymoney.h.cmake b/config-kmymoney.h.cmake index b12689ec5..2e28d671f 100644 --- a/config-kmymoney.h.cmake +++ b/config-kmymoney.h.cmake @@ -1,22 +1,20 @@ /* config-kmymoney.h. Generated from config-kmymoney.h.cmake by cmake */ /* Name of package */ #define PACKAGE "kmymoney" #cmakedefine KMM_DESIGNER 1 #cmakedefine KMM_DBUS 1 #cmakedefine KF5Holidays_FOUND 1 #cmakedefine Gpgmepp_FOUND 1 #cmakedefine KMM_ADDRESSBOOK_FOUND 1 #cmakedefine KF5Activities_FOUND 1 #cmakedefine ENABLE_WEBENGINE 1 -#cmakedefine IS_GNU 1 - #cmakedefine ENABLE_UNFINISHEDFEATURES 1 diff --git a/kmymoney/mymoney/mymoneytracer.h b/kmymoney/mymoney/mymoneytracer.h index 8a9330ff3..8838faca7 100644 --- a/kmymoney/mymoney/mymoneytracer.h +++ b/kmymoney/mymoney/mymoneytracer.h @@ -1,71 +1,70 @@ /*************************************************************************** mymoneytracer.h - description ------------------- begin : Tue Jan 29 2002 copyright : (C) 2000-2002 by Michael Edwardes email : mte@users.sourceforge.net Javier Campos Morales Felix Rodriguez John C Thomas Baumgart Kevin Tambascio (C) 2017 by Łukasz Wojniłowicz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef MYMONEYTRACER_H #define MYMONEYTRACER_H -#include #include "kmm_mymoney_export.h" #include "qglobal.h" -#ifdef IS_GNU +#ifdef __GNUC__ # define KMM_PRINTF_FORMAT(x, y) __attribute__((format(__printf__, x, y))) #else # define KMM_PRINTF_FORMAT(x, y) /*NOTHING*/ #endif class QString; void timestamp(const char* txt); void timestamp_reset(); class MyMoneyTracerPrivate; class KMM_MYMONEY_EXPORT MyMoneyTracer { Q_DISABLE_COPY(MyMoneyTracer) public: explicit MyMoneyTracer(const char* prettyName); #define MYMONEYTRACER(a) MyMoneyTracer a(Q_FUNC_INFO) explicit MyMoneyTracer(const QString& className, const QString& methodName); ~MyMoneyTracer(); /** * This method allows to trace a printf like formatted text * * @param format format mask */ void printf(const char *format, ...) const KMM_PRINTF_FORMAT(2, 3); static void off(); static void on(); static void onOff(int onOff); private: MyMoneyTracerPrivate * const d_ptr; Q_DECLARE_PRIVATE(MyMoneyTracer) }; #endif diff --git a/kmymoney/views/kpayeeidentifierview.h b/kmymoney/views/kpayeeidentifierview.h index e35670fcc..446b04a8b 100644 --- a/kmymoney/views/kpayeeidentifierview.h +++ b/kmymoney/views/kpayeeidentifierview.h @@ -1,63 +1,63 @@ /* * This file is part of KMyMoney, A Personal Finance Manager by KDE * Copyright (C) 2014 Christian Dávid * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef KPAYEEIDENTIFIERVIEW_H #define KPAYEEIDENTIFIERVIEW_H #include #include "widgets/styleditemdelegateforwarder.h" class payeeIdentifier; class MyMoneyPayeeIdentifierContainer; namespace Ui { class KPayeeIdentifierView; } class KPayeeIdentifierView : public QWidget { Q_OBJECT public: explicit KPayeeIdentifierView(QWidget* parent); ~KPayeeIdentifierView(); QList identifiers() const; void closeSource(); Q_SIGNALS: void dataChanged(); public Q_SLOTS: void setSource(MyMoneyPayeeIdentifierContainer data); private Q_SLOTS: void removeSelected(); private: Ui::KPayeeIdentifierView* ui; }; class payeeIdentifierDelegate : public StyledItemDelegateForwarder { Q_OBJECT public: explicit payeeIdentifierDelegate(QObject* parent = 0); - virtual QAbstractItemDelegate* getItemDelegate(const QModelIndex& index) const; + virtual QAbstractItemDelegate* getItemDelegate(const QModelIndex& index) const override; }; #endif // KPAYEEIDENTIFIERVIEW_H diff --git a/kmymoney/widgets/styleditemdelegateforwarder.h b/kmymoney/widgets/styleditemdelegateforwarder.h index 64efd428a..3845934ea 100644 --- a/kmymoney/widgets/styleditemdelegateforwarder.h +++ b/kmymoney/widgets/styleditemdelegateforwarder.h @@ -1,66 +1,66 @@ /* * This file is part of KMyMoney, A Personal Finance Manager by KDE * Copyright (C) 2014 Christian Dávid * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef STYLEDITEMDELEGATEFORWARDER_H #define STYLEDITEMDELEGATEFORWARDER_H #include #include "kmm_widgets_export.h" /** * @brief Helper to use multiple item delegates in a view * * This class allows to select the used item delegate based on the QModelIndex. * */ class KMM_WIDGETS_EXPORT StyledItemDelegateForwarder : public QAbstractItemDelegate { Q_OBJECT public: explicit StyledItemDelegateForwarder(QObject* parent = 0); - virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; - virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; - virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const; - virtual void setEditorData(QWidget* editor, const QModelIndex& index) const; - virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const; - virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const; + void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; + QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override; + void setEditorData(QWidget* editor, const QModelIndex& index) const override; + void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; + void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override; /** * @brief Return delegate for a given index * * If an method of this class is called, it uses this function to receive * the correct delegate where the call is forwarded to. * * @return You must return a valid item delegate. * @see connectSignals() */ virtual QAbstractItemDelegate* getItemDelegate(const QModelIndex& index) const = 0; protected: /** * @brief Connects all signals accordingly * * Call this function if you create a new delegate in getItemDelegate(). */ void connectSignals(QAbstractItemDelegate* delegate, Qt::ConnectionType type = Qt::AutoConnection) const; }; #endif // STYLEDITEMDELEGATEFORWARDER_H