├── .krazy ├── .git-blame-ignore-revs ├── tests ├── manual │ └── CMakeLists.txt ├── benchmarks │ └── CMakeLists.txt ├── features │ ├── pages │ │ └── CMakeLists.txt │ ├── inbox │ │ ├── CMakeLists.txt │ │ └── inboxdisplayfeature.cpp │ ├── datasource │ │ ├── CMakeLists.txt │ │ ├── datasourcelistingfeature.cpp │ │ └── datasourcedefaultsettingsfeature.cpp │ ├── editing │ │ ├── CMakeLists.txt │ │ ├── removingtaskfeature.cpp │ │ └── completingtaskfeature.cpp │ ├── CMakeLists.txt │ ├── contexts │ │ ├── CMakeLists.txt │ │ ├── contextdisplayfeature.cpp │ │ └── contexttaskaddfeature.cpp │ ├── projects │ │ ├── CMakeLists.txt │ │ ├── projectdisplayfeature.cpp │ │ └── projecttaskaddfeature.cpp │ └── workday │ │ ├── CMakeLists.txt │ │ ├── workdaystartbuttonfeature.cpp │ │ ├── workdaytaskremovefeature.cpp │ │ ├── workdaytaskaddfeature.cpp │ │ ├── workdaydisplaycompletedfeature.cpp │ │ ├── workdaydisplayfeature.cpp │ │ └── workdaypostponingfeature.cpp ├── units │ ├── akonadi │ │ ├── testenv │ │ │ ├── xdgconfig │ │ │ │ ├── akonadi_knut_resource_0rc │ │ │ │ └── akonadi-firstrunrc │ │ │ └── config.xml │ │ ├── CMakeLists.txt │ │ ├── akonadistoragetest.cpp │ │ └── akonadicachingstorageintegrationtest.cpp │ ├── migrator │ │ ├── testenv │ │ │ ├── xdgconfig │ │ │ │ ├── akonadi_knut_resource_0rc │ │ │ │ └── akonadi-firstrunrc │ │ │ └── config.xml │ │ └── CMakeLists.txt │ ├── utils │ │ ├── CMakeLists.txt │ │ ├── datetimetest.cpp │ │ └── jobhandlertest.cpp │ ├── domain │ │ ├── CMakeLists.txt │ │ ├── contexttest.cpp │ │ └── projecttest.cpp │ ├── CMakeLists.txt │ ├── testlib │ │ ├── CMakeLists.txt │ │ └── akonadifakestoragetest.cpp │ ├── presentation │ │ ├── CMakeLists.txt │ │ ├── metatypestest.cpp │ │ └── errorhandlertest.cpp │ └── widgets │ │ ├── CMakeLists.txt │ │ └── messageboxstub.h ├── testlib │ ├── qtest_gui_zanshin.h │ ├── testhelpers.h │ ├── testhelpers.cpp │ ├── akonadidebug.h │ ├── akonaditest-run.sh.in │ ├── akonadifakedataxmlloader.h │ ├── CMakeLists.txt │ ├── monitorspy.h │ ├── testsafety.h │ ├── fakejob.h │ ├── gencollection.h │ ├── akonadifakemonitor.h │ ├── akonadidebug.cpp │ ├── gentodo.h │ ├── akonadifakemonitor.cpp │ ├── fakejob.cpp │ ├── akonadifakejobs.h │ └── MacroAkonadiAutoTests.cmake └── featurelib │ └── CMakeLists.txt ├── 3rdparty └── mockitopp │ ├── detail │ ├── m4 │ │ ├── IF.m4 │ │ ├── COMMA_IF.m4 │ │ ├── REPEAT.m4 │ │ ├── REPEAT_FROM_TO.m4 │ │ ├── ENUM_TRAILING_PARAMS.m4 │ │ ├── ENUM_PARAMS.m4 │ │ ├── ENUM_SHIFTED_PARAMS.m4 │ │ └── ENUM_BINARY_PARAMS.m4 │ ├── util │ │ ├── cxx0x_static_assert.hpp │ │ ├── horrible_cast.hpp │ │ ├── remove_member_function_pointer_cv.hpp.m4 │ │ └── tr1_type_traits.hpp │ └── stubbing │ │ └── action.hpp │ ├── matchers │ ├── type │ │ ├── std_container.hpp │ │ ├── std_string.hpp │ │ └── string_literal.hpp │ ├── Matcher.hpp │ ├── base │ │ ├── null.hpp │ │ ├── any.hpp │ │ ├── is_not.hpp │ │ └── equal.hpp │ └── regex.hpp │ ├── mockitopp.hpp │ ├── matchers.hpp │ ├── exceptions.hpp │ └── mock_object.hpp ├── src ├── icons │ ├── 128-apps-zanshin.png │ ├── 256-apps-zanshin.png │ ├── 48-apps-zanshin.png │ ├── 64-apps-zanshin.png │ ├── sc-apps-zanshin.svgz │ └── CMakeLists.txt ├── zanshin │ ├── CMakeLists.txt │ ├── app │ │ ├── zanshin.qrc │ │ ├── aboutdata.h │ │ ├── CMakeLists.txt │ │ ├── aboutdata.cpp │ │ └── zanshinui.rc │ ├── kontact │ │ ├── kontact_plugins.qrc │ │ ├── part.h │ │ ├── kontact_plugin.h │ │ ├── kontact_plugin.cpp │ │ ├── CMakeLists.txt │ │ └── zanshin_part.rc │ ├── runner │ │ ├── CMakeLists.txt │ │ └── zanshinrunner.h │ └── migrator │ │ ├── CMakeLists.txt │ │ ├── NOTES │ │ ├── zanshincontextitemsmigrator.h │ │ ├── main.cpp │ │ └── zanshin021migrator.h ├── domain │ ├── queryresult.cpp │ ├── queryresultinterface.cpp │ ├── queryresultprovider.cpp │ ├── taskqueries.cpp │ ├── projectqueries.cpp │ ├── taskrepository.cpp │ ├── contextrepository.cpp │ ├── projectrepository.cpp │ ├── datasourcerepository.cpp │ ├── contextqueries.cpp │ ├── projectqueries.h │ ├── datasourcerepository.h │ ├── datasourcequeries.cpp │ ├── contextqueries.h │ ├── CMakeLists.txt │ ├── projectrepository.h │ ├── context.cpp │ ├── project.cpp │ ├── contextrepository.h │ ├── context.h │ ├── project.h │ ├── taskqueries.h │ ├── taskrepository.h │ ├── queryresultinterface.h │ └── datasourcequeries.h ├── widgets │ ├── messageboxinterface.cpp │ ├── quickselectdialoginterface.cpp │ ├── nameanddatasourcedialoginterface.cpp │ ├── messagebox.cpp │ ├── messagebox.h │ ├── messageboxinterface.h │ ├── pageviewerrorhandler.cpp │ ├── pageviewerrorhandler.h │ ├── quickselectdialoginterface.h │ ├── datasourcedelegate.h │ ├── nameanddatasourcedialoginterface.h │ ├── availablesourcesview.h │ ├── filterwidget.h │ ├── nameanddatasourcedialog.h │ ├── datasourcedelegate.cpp │ ├── quickselectdialog.h │ ├── CMakeLists.txt │ ├── runningtaskwidget.h │ └── itemdelegate.h ├── integration │ ├── CMakeLists.txt │ └── dependencies.h ├── akonadi │ ├── akonadistorageinterface.cpp │ ├── akonadiserializerinterface.cpp │ ├── akonadimonitorinterface.cpp │ ├── akonadiitemfetchjobinterface.cpp │ ├── akonadicollectionfetchjobinterface.cpp │ ├── akonadiitemfetchjobinterface.h │ ├── akonadicollectionfetchjobinterface.h │ ├── akonadimonitorimpl.h │ ├── akonaditimestampattribute.h │ ├── akonadistoragesettings.h │ ├── akonadiapplicationselectedattribute.h │ ├── akonadiconfigdialog.h │ ├── akonadidatasourcerepository.h │ ├── akonadimonitorinterface.h │ ├── akonadistoragesettings.cpp │ ├── akonaditimestampattribute.cpp │ ├── akonadidatasourcerepository.cpp │ ├── akonadiapplicationselectedattribute.cpp │ ├── akonadiprojectrepository.h │ ├── akonadicontextrepository.h │ ├── akonaditaskrepository.h │ ├── akonadiprojectqueries.cpp │ └── akonadiprojectqueries.h ├── utils │ ├── CMakeLists.txt │ ├── datetime.h │ ├── datetime.cpp │ ├── compositejob.h │ ├── jobhandler.h │ ├── dependencymanager.cpp │ ├── mem_fn.h │ ├── compositejob.cpp │ └── mockobject.h ├── CMakeLists.txt └── presentation │ ├── runningtaskmodelinterface.cpp │ ├── metatypes.cpp │ ├── availablepagessortfilterproxymodel.h │ ├── errorhandler.h │ ├── errorhandlingmodelbase.h │ ├── metatypes.h │ ├── errorhandlingmodelbase.cpp │ ├── availablepagessortfilterproxymodel.cpp │ ├── errorhandler.cpp │ ├── inboxpagemodel.h │ ├── alltaskspagemodel.h │ ├── workdaypagemodel.h │ ├── CMakeLists.txt │ ├── runningtaskmodelinterface.h │ ├── taskfilterproxymodel.h │ ├── runningtaskmodel.h │ ├── availablesourcesmodel.h │ ├── projectpagemodel.h │ └── contextpagemodel.h ├── AUTHORS ├── Messages.sh ├── REUSE.toml ├── .gitlab-ci.yml ├── TODO ├── readme-build-ftime.txt ├── LICENSES ├── LicenseRef-KDE-Accepted-GPL.txt └── MIT.txt ├── .kde-ci.yml └── ClangBuildAnalyzer.ini /.krazy: -------------------------------------------------------------------------------- 1 | IGNORESUBS 3rdparty 2 | EXCLUDE qclasses 3 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | 93d25b2fc8a98dcda61a424af668cc89e2654447 2 | -------------------------------------------------------------------------------- /tests/manual/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_manual_tests( 2 | tasktreeviewer 3 | ) 4 | -------------------------------------------------------------------------------- /tests/benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_manual_tests( 2 | serializerTest 3 | ) 4 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/m4/IF.m4: -------------------------------------------------------------------------------- 1 | define(`M4_IF', `ifelse(eval($1 > 0), 1, `$2', `$3')')dnl 2 | -------------------------------------------------------------------------------- /tests/features/pages/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_feature_tests( 2 | pagesdisplayfeature 3 | ) 4 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/m4/COMMA_IF.m4: -------------------------------------------------------------------------------- 1 | define(`M4_COMMA_IF', `ifelse(eval($1 > 0), 1, `, ', `')')dnl 2 | -------------------------------------------------------------------------------- /src/icons/128-apps-zanshin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KDE/zanshin/HEAD/src/icons/128-apps-zanshin.png -------------------------------------------------------------------------------- /src/icons/256-apps-zanshin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KDE/zanshin/HEAD/src/icons/256-apps-zanshin.png -------------------------------------------------------------------------------- /src/icons/48-apps-zanshin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KDE/zanshin/HEAD/src/icons/48-apps-zanshin.png -------------------------------------------------------------------------------- /src/icons/64-apps-zanshin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KDE/zanshin/HEAD/src/icons/64-apps-zanshin.png -------------------------------------------------------------------------------- /src/icons/sc-apps-zanshin.svgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KDE/zanshin/HEAD/src/icons/sc-apps-zanshin.svgz -------------------------------------------------------------------------------- /tests/units/akonadi/testenv/xdgconfig/akonadi_knut_resource_0rc: -------------------------------------------------------------------------------- 1 | [General] 2 | DataFile[$e]=$XDG_DATA_HOME/testdata.xml 3 | -------------------------------------------------------------------------------- /tests/units/migrator/testenv/xdgconfig/akonadi_knut_resource_0rc: -------------------------------------------------------------------------------- 1 | [General] 2 | DataFile[$e]=$XDG_DATA_HOME/testdata.xml 3 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Authors: 2 | Kevin Ottens (Lead Developer) 3 | Mario Bensi (Developer) 4 | 5 | -------------------------------------------------------------------------------- /tests/features/inbox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_feature_tests( 2 | inboxdisplayfeature 3 | inboxdraganddropfeature 4 | ) 5 | -------------------------------------------------------------------------------- /tests/units/akonadi/testenv/xdgconfig/akonadi-firstrunrc: -------------------------------------------------------------------------------- 1 | [ProcessedDefaults] 2 | defaultaddressbook=done 3 | defaultcalendar=done -------------------------------------------------------------------------------- /tests/units/migrator/testenv/xdgconfig/akonadi-firstrunrc: -------------------------------------------------------------------------------- 1 | [ProcessedDefaults] 2 | defaultaddressbook=done 3 | defaultcalendar=done -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/m4/REPEAT.m4: -------------------------------------------------------------------------------- 1 | define(`M4_REPEAT', `ifelse(eval($1 > 0), 1,`M4_REPEAT(decr($1), `$2') $2(decr($1))', `')')dnl 2 | -------------------------------------------------------------------------------- /src/zanshin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(app) 2 | add_subdirectory(kontact) 3 | add_subdirectory(runner) 4 | add_subdirectory(migrator) 5 | 6 | -------------------------------------------------------------------------------- /src/zanshin/app/zanshin.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | zanshinui.rc 4 | 5 | 6 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers/type/std_container.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/m4/REPEAT_FROM_TO.m4: -------------------------------------------------------------------------------- 1 | define(`M4_REPEAT_FROM_TO', `ifelse(eval($2 > $1), 1,`M4_REPEAT_FROM_TO($1, decr($2), `$3') $3(decr($2))', `')')dnl 2 | -------------------------------------------------------------------------------- /tests/units/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_auto_tests( 2 | compositejobtest 3 | datetimetest 4 | dependencymanagertest 5 | jobhandlertest 6 | mockobjecttest 7 | ) 8 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/m4/ENUM_TRAILING_PARAMS.m4: -------------------------------------------------------------------------------- 1 | define(`M4_ENUM_TRAILING_PARAMS', `ifelse(eval($1 > 0), 1, `M4_ENUM_TRAILING_PARAMS(decr($1), $2), `$2'decr($1)', `')')dnl 2 | -------------------------------------------------------------------------------- /tests/features/datasource/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_feature_tests( 2 | datasourcedefaultsettingsfeature 3 | datasourcelistingfeature 4 | datasourceselectionfeature 5 | ) 6 | -------------------------------------------------------------------------------- /tests/features/editing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_feature_tests( 2 | addingtaskfeature 3 | completingtaskfeature 4 | editingtaskfeature 5 | removingtaskfeature 6 | ) 7 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers/type/std_string.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | starts_with() 7 | ends_with() 8 | contains() 9 | -------------------------------------------------------------------------------- /src/zanshin/kontact/kontact_plugins.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | zanshin_part.rc 5 | 6 | 7 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/m4/ENUM_PARAMS.m4: -------------------------------------------------------------------------------- 1 | include(`mockitopp/detail/m4/COMMA_IF.m4')dnl 2 | define(`M4_ENUM_PARAMS', `ifelse(eval($1 > 0), 1, `M4_ENUM_PARAMS(decr($1), $2)M4_COMMA_IF(decr($1))`$2'decr($1)', `')')dnl 3 | -------------------------------------------------------------------------------- /Messages.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | $EXTRACTRC `find . -name '*.ui' -or -name '*.rc' -or -name '*.kcfg'` >> rc.cpp 3 | $XGETTEXT `find . -name '*.cpp' -or -name '*.h' | grep -v '/tests/'` -o $podir/zanshin.pot 4 | rm -f rc.cpp 5 | -------------------------------------------------------------------------------- /tests/units/domain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_auto_tests( 2 | contexttest 3 | datasourcetest 4 | livequerytest 5 | liverelationshipquerytest 6 | mockitotest 7 | projecttest 8 | queryresulttest 9 | tasktest 10 | ) 11 | -------------------------------------------------------------------------------- /tests/features/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(inbox) 2 | add_subdirectory(workday) 3 | add_subdirectory(editing) 4 | add_subdirectory(contexts) 5 | add_subdirectory(datasource) 6 | add_subdirectory(pages) 7 | add_subdirectory(projects) 8 | -------------------------------------------------------------------------------- /tests/units/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(akonadi) 2 | add_subdirectory(domain) 3 | add_subdirectory(presentation) 4 | add_subdirectory(utils) 5 | add_subdirectory(testlib) 6 | add_subdirectory(widgets) 7 | add_subdirectory(migrator) 8 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/m4/ENUM_SHIFTED_PARAMS.m4: -------------------------------------------------------------------------------- 1 | include(`mockitopp/detail/m4/COMMA_IF.m4')dnl 2 | define(`M4_ENUM_SHIFTED_PARAMS', `ifelse(eval($1 > 1), 1, `M4_ENUM_SHIFTED_PARAMS(decr($1), $2)M4_COMMA_IF(decr($1)-1)`$2'decr($1)', `')')dnl 3 | -------------------------------------------------------------------------------- /src/icons/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ecm_install_icons(ICONS 2 | 128-apps-zanshin.png 3 | 256-apps-zanshin.png 4 | 48-apps-zanshin.png 5 | 64-apps-zanshin.png 6 | sc-apps-zanshin.svgz 7 | DESTINATION ${KDE_INSTALL_ICONDIR} 8 | ) 9 | -------------------------------------------------------------------------------- /tests/units/akonadi/testenv/config.xml: -------------------------------------------------------------------------------- 1 | 2 | xdgconfig 3 | data 4 | akonadi_knut_resource 5 | true 6 | 7 | -------------------------------------------------------------------------------- /tests/units/migrator/testenv/config.xml: -------------------------------------------------------------------------------- 1 | 2 | xdgconfig 3 | data 4 | akonadi_knut_resource 5 | true 6 | 7 | -------------------------------------------------------------------------------- /src/domain/queryresult.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "queryresult.h" 8 | 9 | using namespace Domain; 10 | -------------------------------------------------------------------------------- /REUSE.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | SPDX-FileCopyrightText = "none" 3 | SPDX-License-Identifier = "CC0-1.0" 4 | SPDX-PackageName = "zanshin" 5 | SPDX-PackageSupplier = "Kevin Ottens " 6 | SPDX-PackageDownloadLocation = "https://zanshin.kde.org/" 7 | annotations = ["REUSE.toml"] 8 | -------------------------------------------------------------------------------- /tests/features/contexts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_feature_tests( 2 | contextaddfeature 3 | contexteditfeature 4 | contextdraganddropfeature 5 | contextremovefeature 6 | contexttaskremovefeature 7 | contextdisplayfeature 8 | contexttaskaddfeature 9 | ) 10 | -------------------------------------------------------------------------------- /tests/features/projects/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_feature_tests( 2 | projectdisplayfeature 3 | projectaddfeature 4 | projectdraganddropfeature 5 | projecteditfeature 6 | projecttaskpromotefeature 7 | projecttaskaddfeature 8 | projectremovefeature 9 | ) 10 | -------------------------------------------------------------------------------- /src/domain/queryresultinterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "queryresultinterface.h" 8 | 9 | using namespace Domain; 10 | -------------------------------------------------------------------------------- /src/domain/queryresultprovider.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "queryresultprovider.h" 8 | 9 | using namespace Domain; 10 | -------------------------------------------------------------------------------- /tests/units/testlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_definitions(-DSOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\") 2 | 3 | zanshin_auto_tests( 4 | akonadifakedatatest 5 | akonadifakedataxmlloadertest 6 | akonadifakestoragetest 7 | gencollectiontest 8 | gentodotest 9 | monitorspytest 10 | ) 11 | -------------------------------------------------------------------------------- /src/widgets/messageboxinterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "messageboxinterface.h" 7 | 8 | Widgets::MessageBoxInterface::~MessageBoxInterface() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/mockitopp.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_HPP__ 7 | #define __MOCKITOPP_HPP__ 8 | 9 | #include "exceptions.hpp" 10 | #include "matchers.hpp" 11 | #include "mock_object.hpp" 12 | 13 | #endif //__MOCKITOPP_HPP__ 14 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/m4/ENUM_BINARY_PARAMS.m4: -------------------------------------------------------------------------------- 1 | include(`mockitopp/detail/m4/COMMA_IF.m4')dnl 2 | define(`M4_CHECK_INTERCEPT', `ifelse(`$1', `M4_INTERCEPT', `', `$2')')dnl 3 | define(`M4_ENUM_BINARY_PARAMS', `ifelse(eval($1 > 0), 1, `M4_ENUM_BINARY_PARAMS(decr($1), $2, $3, $4)M4_COMMA_IF(decr($1))`$2'decr($1) `$3'M4_CHECK_INTERCEPT($4, decr($1))', `')')dnl 4 | -------------------------------------------------------------------------------- /src/zanshin/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | kcoreaddons_add_plugin(org.kde.zanshin INSTALL_NAMESPACE "kf6/krunner") 3 | target_sources(org.kde.zanshin PRIVATE 4 | zanshinrunner.cpp 5 | zanshinrunner.h 6 | ) 7 | target_link_libraries(org.kde.zanshin 8 | akonadi 9 | domain 10 | utils 11 | KF6::ConfigCore 12 | KF6::Runner 13 | ) 14 | -------------------------------------------------------------------------------- /src/integration/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(integration STATIC) 3 | target_sources(integration PRIVATE 4 | dependencies.cpp 5 | dependencies.h 6 | ) 7 | set_property(TARGET integration PROPERTY POSITION_INDEPENDENT_CODE ON) 8 | 9 | target_link_libraries(integration 10 | akonadi 11 | domain 12 | presentation 13 | utils 14 | ) 15 | -------------------------------------------------------------------------------- /tests/testlib/qtest_gui_zanshin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef QTEST_GUI_ZANSHIN_H 8 | #define QTEST_GUI_ZANSHIN_H 9 | 10 | #include 11 | 12 | #endif // QTEST_GUI_ZANSHIN_H 13 | -------------------------------------------------------------------------------- /src/domain/taskqueries.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "taskqueries.h" 8 | 9 | using namespace Domain; 10 | 11 | TaskQueries::TaskQueries() 12 | { 13 | } 14 | 15 | TaskQueries::~TaskQueries() 16 | { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/widgets/quickselectdialoginterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "quickselectdialoginterface.h" 8 | 9 | using namespace Widgets; 10 | 11 | QuickSelectDialogInterface::~QuickSelectDialogInterface() 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: None 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | include: 5 | - project: sysadmin/ci-utilities 6 | file: 7 | - /gitlab-templates/linux-qt6.yml 8 | - /gitlab-templates/linux-qt6-next.yml 9 | - /gitlab-templates/json-validation.yml 10 | - /gitlab-templates/freebsd-qt6.yml 11 | - /gitlab-templates/cppcheck.yml 12 | -------------------------------------------------------------------------------- /src/domain/projectqueries.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "projectqueries.h" 8 | 9 | using namespace Domain; 10 | 11 | ProjectQueries::ProjectQueries() 12 | { 13 | } 14 | 15 | ProjectQueries::~ProjectQueries() 16 | { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/domain/taskrepository.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "taskrepository.h" 8 | 9 | using namespace Domain; 10 | 11 | TaskRepository::TaskRepository() 12 | { 13 | } 14 | 15 | TaskRepository::~TaskRepository() 16 | { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/zanshin/app/aboutdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2011-2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef APP_ABOUTDATA_H 8 | #define APP_ABOUTDATA_H 9 | 10 | #include 11 | 12 | namespace App 13 | { 14 | KAboutData getAboutData(); 15 | } 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /tests/features/workday/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_feature_tests( 2 | workdaydisplayfeature 3 | workdaypostponingfeature 4 | workdaystartdateeditfeature 5 | workdaydropfeature 6 | workdaystartbuttonfeature 7 | workdaytaskaddfeature 8 | workdayduedateeditfeature 9 | workdaydisplaycompletedfeature 10 | workdaydraganddropfeature 11 | workdaytaskremovefeature 12 | ) 13 | -------------------------------------------------------------------------------- /src/widgets/nameanddatasourcedialoginterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "nameanddatasourcedialoginterface.h" 8 | 9 | using namespace Widgets; 10 | 11 | NameAndDataSourceDialogInterface::~NameAndDataSourceDialogInterface() 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * Anti-procrastination feature (if you postpone a task too many times popup a dialog asking what to do) 2 | * Use the start date field, and hide actions which have a start date in the future (probably requires an 3 | extra mode to take a look at those actions). 4 | * Proper error handling 5 | * Undo/redo support 6 | * Add a count of the items in the Inbox for LibraryModel 7 | * Allow filtering of the central view. 8 | -------------------------------------------------------------------------------- /src/domain/contextrepository.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "contextrepository.h" 8 | 9 | using namespace Domain; 10 | 11 | ContextRepository::ContextRepository() 12 | { 13 | } 14 | 15 | ContextRepository::~ContextRepository() 16 | { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/domain/projectrepository.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "projectrepository.h" 8 | 9 | using namespace Domain; 10 | 11 | ProjectRepository::ProjectRepository() 12 | { 13 | } 14 | 15 | ProjectRepository::~ProjectRepository() 16 | { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/akonadi/akonadistorageinterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "akonadistorageinterface.h" 8 | 9 | using namespace Akonadi; 10 | 11 | StorageInterface::StorageInterface() 12 | { 13 | } 14 | 15 | StorageInterface::~StorageInterface() 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /src/domain/datasourcerepository.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "datasourcerepository.h" 8 | 9 | using namespace Domain; 10 | 11 | DataSourceRepository::DataSourceRepository() 12 | { 13 | } 14 | 15 | DataSourceRepository::~DataSourceRepository() 16 | { 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(utils STATIC) 2 | target_sources(utils PRIVATE 3 | compositejob.cpp 4 | datetime.cpp 5 | dependencymanager.cpp 6 | jobhandler.cpp 7 | 8 | compositejob.h 9 | datetime.h 10 | dependencymanager.h 11 | jobhandler.h 12 | ) 13 | 14 | set_property(TARGET utils PROPERTY POSITION_INDEPENDENT_CODE ON) 15 | 16 | target_link_libraries(utils 17 | KF6::CoreAddons 18 | ) 19 | -------------------------------------------------------------------------------- /tests/testlib/testhelpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef ZANSHIN_TESTLIB_TESTHELPERS_H 8 | #define ZANSHIN_TESTLIB_TESTHELPERS_H 9 | 10 | namespace Testlib { 11 | 12 | namespace TestHelpers 13 | { 14 | void waitForEmptyJobQueue(); 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /tests/featurelib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(featurelib_SRCS 2 | zanshincontext.cpp 3 | ) 4 | 5 | add_definitions(-DZANSHIN_USER_XMLDATA="${CMAKE_SOURCE_DIR}/tests/features/testenv/data/testdata.xml") 6 | 7 | include_directories(${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/src) 8 | add_library(featurelib STATIC ${featurelib_SRCS}) 9 | target_link_libraries(featurelib 10 | Qt::Test 11 | KF6::ConfigCore 12 | integration 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /src/utils/datetime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Theo Vaucher 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef UTILS_DATETIME 8 | #define UTILS_DATETIME 9 | 10 | class QDateTime; 11 | class QDate; 12 | 13 | namespace Utils { 14 | 15 | namespace DateTime 16 | { 17 | QDate currentDate(); 18 | } 19 | 20 | } 21 | 22 | #endif // UTILS_DATETIME 23 | -------------------------------------------------------------------------------- /src/domain/contextqueries.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-FileCopyrightText: 2014 Rémi Benoit 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include "contextqueries.h" 9 | 10 | using namespace Domain; 11 | 12 | ContextQueries::ContextQueries() 13 | { 14 | } 15 | 16 | ContextQueries::~ContextQueries() 17 | { 18 | } 19 | 20 | -------------------------------------------------------------------------------- /tests/testlib/testhelpers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "testhelpers.h" 8 | 9 | #include 10 | 11 | #include "utils/jobhandler.h" 12 | 13 | using namespace Testlib; 14 | 15 | void TestHelpers::waitForEmptyJobQueue() 16 | { 17 | while (Utils::JobHandler::jobCount() != 0) { 18 | QTest::qWait(20); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/akonadi/akonadiserializerinterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-FileCopyrightText: 2014 Rémi Benoit 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include "akonadiserializerinterface.h" 9 | 10 | using namespace Akonadi; 11 | 12 | SerializerInterface::SerializerInterface() 13 | { 14 | } 15 | 16 | SerializerInterface::~SerializerInterface() 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /tests/testlib/akonadidebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADIDEBUG_H 8 | #define AKONADIDEBUG_H 9 | 10 | #include "akonadi/akonadistorageinterface.h" 11 | 12 | namespace TestLib { 13 | namespace AkonadiDebug { 14 | void dumpTree(const Akonadi::StorageInterface::Ptr &storage); 15 | } 16 | } 17 | 18 | #endif // AKONADIDEBUG_H 19 | -------------------------------------------------------------------------------- /src/akonadi/akonadimonitorinterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "akonadimonitorinterface.h" 8 | 9 | using namespace Akonadi; 10 | 11 | MonitorInterface::MonitorInterface(QObject *parent) 12 | : QObject(parent) 13 | { 14 | } 15 | 16 | MonitorInterface::~MonitorInterface() 17 | { 18 | } 19 | 20 | #include "moc_akonadimonitorinterface.cpp" 21 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_MATCHERS_HPP__ 7 | #define __MOCKITOPP_MATCHERS_HPP__ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #endif //__MOCKITOPP_MATCHERS_HPP__ 16 | -------------------------------------------------------------------------------- /src/widgets/messagebox.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "messagebox.h" 7 | 8 | Widgets::MessageBox::~MessageBox() 9 | { 10 | } 11 | 12 | QMessageBox::Button Widgets::MessageBox::askConfirmation(QWidget *parent, const QString &title, const QString &text) 13 | { 14 | return QMessageBox::question(parent, title, text, QMessageBox::Yes | QMessageBox::No); 15 | } 16 | -------------------------------------------------------------------------------- /tests/units/migrator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(MacroAkonadiAutoTests) 2 | 3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../src/zanshin/migrator) 4 | 5 | zanshin_auto_tests( 6 | ) 7 | 8 | zanshin_akonadi_auto_tests( 9 | zanshin021migrationtest 10 | zanshincontextitemsmigrationtest 11 | ) 12 | 13 | target_link_libraries(tests-units-migrator-zanshin021migrationtest 14 | migrator 15 | testlib 16 | ) 17 | target_link_libraries(tests-units-migrator-zanshincontextitemsmigrationtest 18 | migrator 19 | testlib 20 | ) 21 | -------------------------------------------------------------------------------- /tests/units/presentation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_auto_tests( 2 | applicationmodeltest 3 | editormodeltest 4 | availablepagesmodeltest 5 | availablepagessortfilterproxymodeltest 6 | availablesourcesmodeltest 7 | errorhandlertest 8 | errorhandlingmodelbasetest 9 | inboxpagemodeltest 10 | metatypestest 11 | pagemodeltest 12 | projectpagemodeltest 13 | querytreemodeltest 14 | runningtaskmodeltest 15 | taskfilterproxymodeltest 16 | contextpagemodeltest 17 | workdaypagemodeltest 18 | alltaskspagemodeltest 19 | ) 20 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | add_definitions(-DTRANSLATION_DOMAIN=\"zanshin\") 4 | ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX ZANSHIN VERSION_HEADER zanshin_version.h) 5 | 6 | # icons 7 | add_subdirectory(icons) 8 | 9 | # frontends 10 | add_subdirectory(zanshin) 11 | 12 | # modules 13 | add_subdirectory(akonadi) 14 | add_subdirectory(domain) 15 | add_subdirectory(presentation) 16 | add_subdirectory(integration) 17 | add_subdirectory(utils) 18 | add_subdirectory(widgets) 19 | 20 | -------------------------------------------------------------------------------- /src/presentation/runningtaskmodelinterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2017 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "runningtaskmodelinterface.h" 7 | 8 | using namespace Presentation; 9 | 10 | RunningTaskModelInterface::RunningTaskModelInterface(QObject *parent) 11 | : QObject(parent) 12 | { 13 | } 14 | 15 | RunningTaskModelInterface::~RunningTaskModelInterface() 16 | { 17 | } 18 | 19 | #include "moc_runningtaskmodelinterface.cpp" 20 | -------------------------------------------------------------------------------- /tests/units/widgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | zanshin_auto_tests( 2 | applicationcomponentstest 3 | availablepagesviewtest 4 | availablesourcesviewtest 5 | editorviewtest 6 | filterwidgettest 7 | nameanddatasourcedialogtest 8 | pageviewerrorhandlertest 9 | pageviewtest 10 | quickselectdialogtest 11 | runningtaskwidgettest 12 | ) 13 | 14 | # These tests need a window that takes focus 15 | set_tests_properties(tests-units-widgets-editorviewtest PROPERTIES RUN_SERIAL TRUE) 16 | set_tests_properties(tests-units-widgets-pageviewtest PROPERTIES RUN_SERIAL TRUE) 17 | -------------------------------------------------------------------------------- /src/zanshin/migrator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(migrator STATIC) 3 | target_sources(migrator PRIVATE 4 | zanshin021migrator.cpp 5 | zanshincontextitemsmigrator.cpp 6 | zanshin021migrator.h 7 | zanshincontextitemsmigrator.h 8 | ) 9 | set_property(TARGET migrator PROPERTY POSITION_INDEPENDENT_CODE ON) 10 | target_link_libraries(migrator 11 | akonadi 12 | domain 13 | utils 14 | ) 15 | 16 | add_executable(zanshin-migrator main.cpp) 17 | target_link_libraries(zanshin-migrator migrator) 18 | install(TARGETS zanshin-migrator DESTINATION ${KDE_INSTALL_BINDIR}) 19 | -------------------------------------------------------------------------------- /src/utils/datetime.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Theo Vaucher 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "datetime.h" 7 | 8 | #include 9 | 10 | using namespace Utils; 11 | 12 | QDate DateTime::currentDate() 13 | { 14 | QByteArray overrideDate = qgetenv("ZANSHIN_OVERRIDE_DATE"); 15 | QDate customDate = QDate::fromString(QString::fromLocal8Bit(overrideDate), Qt::ISODate); 16 | 17 | return customDate.isValid() ? customDate : QDate::currentDate(); 18 | } 19 | -------------------------------------------------------------------------------- /src/zanshin/kontact/part.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2011 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef ZANSHIN_PART_H 8 | #define ZANSHIN_PART_H 9 | 10 | #include 11 | 12 | class Part : public KParts::ReadOnlyPart 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Part(QWidget *parentWidget, QObject *parent, const KPluginMetaData &data, const QVariantList &); 18 | ~Part(); 19 | 20 | protected: 21 | bool openFile() override; 22 | }; 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /tests/testlib/akonaditest-run.sh.in: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | _pwd="$PWD" 4 | 5 | restorepwd() { 6 | cd "$_pwd" 7 | } 8 | 9 | trap "restorepwd" EXIT 10 | 11 | echo 12 | echo "======================" 13 | echo 14 | 15 | # Make sure the resource is fully synchronized 16 | # It wasn't necessary until the big code style change in akonadiserver 17 | # Not so innocuous heh ;-) 18 | KNUT_RESOURCE="org.freedesktop.Akonadi.Resource.akonadi_knut_resource_0.$AKONADI_INSTANCE" 19 | qdbus6 $KNUT_RESOURCE / org.freedesktop.Akonadi.Resource.synchronize 20 | 21 | cd "@AKONADITEST_CWD@" 22 | "@zanshin-testcommand@" 2>&1 23 | exit $? 24 | -------------------------------------------------------------------------------- /src/akonadi/akonadiitemfetchjobinterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "akonadiitemfetchjobinterface.h" 8 | 9 | #include 10 | 11 | using namespace Akonadi; 12 | 13 | ItemFetchJobInterface::ItemFetchJobInterface() 14 | { 15 | } 16 | 17 | ItemFetchJobInterface::~ItemFetchJobInterface() 18 | { 19 | } 20 | 21 | KJob *ItemFetchJobInterface::kjob() 22 | { 23 | KJob *job = dynamic_cast(this); 24 | Q_ASSERT(job); 25 | return job; 26 | } 27 | -------------------------------------------------------------------------------- /src/zanshin/app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(app_SRCS 2 | aboutdata.cpp 3 | aboutdata.h 4 | main.cpp 5 | ) 6 | ecm_create_qm_loader(app_SRCS zanshin_qt) 7 | qt_add_resources(app_SRCS zanshin.qrc) 8 | 9 | add_executable(zanshin ${app_SRCS}) 10 | kde_enable_exceptions() 11 | target_link_libraries(zanshin 12 | KF6::XmlGui 13 | KF6::Crash 14 | integration 15 | widgets 16 | ) 17 | 18 | install(TARGETS zanshin DESTINATION ${KDE_INSTALL_BINDIR}) 19 | install(PROGRAMS org.kde.zanshin.desktop DESTINATION ${KDE_INSTALL_APPDIR}) 20 | install(FILES org.kde.zanshin.metainfo.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) 21 | -------------------------------------------------------------------------------- /src/presentation/metatypes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "metatypes.h" 8 | 9 | #include "domain/datasource.h" 10 | #include "domain/task.h" 11 | 12 | using namespace Presentation; 13 | 14 | void MetaTypes::registerAll() 15 | { 16 | qRegisterMetaType(); 17 | qRegisterMetaType(); 18 | qRegisterMetaType(); 19 | qRegisterMetaType(); 20 | qRegisterMetaType(); 21 | } 22 | -------------------------------------------------------------------------------- /src/akonadi/akonadicollectionfetchjobinterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "akonadicollectionfetchjobinterface.h" 8 | 9 | #include 10 | 11 | using namespace Akonadi; 12 | 13 | CollectionFetchJobInterface::CollectionFetchJobInterface() 14 | { 15 | } 16 | 17 | CollectionFetchJobInterface::~CollectionFetchJobInterface() 18 | { 19 | } 20 | 21 | KJob *CollectionFetchJobInterface::kjob() 22 | { 23 | KJob *job = dynamic_cast(this); 24 | Q_ASSERT(job); 25 | return job; 26 | } 27 | -------------------------------------------------------------------------------- /src/widgets/messagebox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef WIDGETS_MESSAGEBOX_H 9 | #define WIDGETS_MESSAGEBOX_H 10 | 11 | #include "messageboxinterface.h" 12 | 13 | namespace Widgets { 14 | 15 | class MessageBox : public MessageBoxInterface 16 | { 17 | public: 18 | typedef QSharedPointer Ptr; 19 | 20 | virtual ~MessageBox(); 21 | 22 | QMessageBox::Button askConfirmation(QWidget *parent, const QString &title, const QString &text) override; 23 | }; 24 | 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /readme-build-ftime.txt: -------------------------------------------------------------------------------- 1 | # Analyzing Build Performance 2 | 3 | For debug build time: 4 | We need ClangBuildAnalyzer 5 | ` 6 | git clone https://github.com/aras-p/ClangBuildAnalyzer 7 | mkdir build 8 | cd build 9 | cmake -DCMAKE_INSTALL_PREFIX= ../ 10 | make install 11 | ` 12 | 13 | ## Command line 14 | 15 | cmake --preset ftime-trace 16 | 17 | ClangBuildAnalyzer --start $PWD/build-ftime-trace 18 | cmake --build --preset ftime-trace 19 | 20 | ClangBuildAnalyzer --stop $PWD/build-ftime-trace build-ftime.txt 21 | 22 | ClangBuildAnalyzer --analyze build-ftime.txt > analyze-build-ftime.txt 23 | 24 | 25 | see https://aras-p.info/blog/2019/09/28/Clang-Build-Analyzer/ 26 | -------------------------------------------------------------------------------- /tests/testlib/akonadifakedataxmlloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef TESTLIB_AKONADIFAKEDATAXMLLOADER_H 8 | #define TESTLIB_AKONADIFAKEDATAXMLLOADER_H 9 | 10 | #include 11 | 12 | namespace Testlib { 13 | 14 | class AkonadiFakeData; 15 | 16 | class AkonadiFakeDataXmlLoader 17 | { 18 | public: 19 | explicit AkonadiFakeDataXmlLoader(AkonadiFakeData *data); 20 | 21 | void load(const QString &fileName) const; 22 | 23 | private: 24 | AkonadiFakeData *m_data; 25 | }; 26 | 27 | } 28 | 29 | #endif // TESTLIB_AKONADIFAKEDATAXMLLOADER_H 30 | -------------------------------------------------------------------------------- /src/zanshin/kontact/kontact_plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2011 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef ZANSHIN_KONTACT_PLUGIN_H 8 | #define ZANSHIN_KONTACT_PLUGIN_H 9 | 10 | #include 11 | #include 12 | 13 | class Plugin : public KontactInterface::Plugin 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | Plugin(KontactInterface::Core *core, const KPluginMetaData &data, const QVariantList &); 19 | 20 | int weight() const override { return 449; } 21 | 22 | protected: 23 | KParts::Part *createPart() override; 24 | }; 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /src/integration/dependencies.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef INTEGRATION_DEPENDENCIES_H 8 | #define INTEGRATION_DEPENDENCIES_H 9 | 10 | namespace Utils 11 | { 12 | class DependencyManager; 13 | } 14 | 15 | namespace Integration 16 | { 17 | void initializeGlobalAppDependencies(); 18 | 19 | void initializeDefaultAkonadiDependencies(Utils::DependencyManager &deps); 20 | void initializeDefaultDomainDependencies(Utils::DependencyManager &deps); 21 | void initializeDefaultPresentationDependencies(Utils::DependencyManager &deps); 22 | } 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /LICENSES/LicenseRef-KDE-Accepted-GPL.txt: -------------------------------------------------------------------------------- 1 | This library is free software; you can redistribute it and/or 2 | modify it under the terms of the GNU General Public License as 3 | published by the Free Software Foundation; either version 3 of 4 | the license or (at your option) at any later version that is 5 | accepted by the membership of KDE e.V. (or its successor 6 | approved by the membership of KDE e.V.), which shall act as a 7 | proxy as defined in Section 14 of version 3 of the license. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | -------------------------------------------------------------------------------- /src/widgets/messageboxinterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef WIDGETS_MESSAGEBOXINTERFACE_H 9 | #define WIDGETS_MESSAGEBOXINTERFACE_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | class QWidget; 16 | 17 | namespace Widgets { 18 | 19 | class MessageBoxInterface 20 | { 21 | public: 22 | typedef QSharedPointer Ptr; 23 | 24 | virtual ~MessageBoxInterface(); 25 | 26 | virtual QMessageBox::Button askConfirmation(QWidget *parent, const QString &title, const QString &text) = 0; 27 | }; 28 | 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/exceptions.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_EXCEPTIONS_HPP__ 7 | #define __MOCKITOPP_EXCEPTIONS_HPP__ 8 | 9 | #include 10 | 11 | namespace mockitopp 12 | { 13 | #define MOCKITO_EXCEPTION(EEE) struct EEE : public ::std::exception {}; 14 | 15 | MOCKITO_EXCEPTION(partial_implementation_exception) 16 | MOCKITO_EXCEPTION(missing_implementation_exception) 17 | 18 | MOCKITO_EXCEPTION(less_invocations_expected); 19 | MOCKITO_EXCEPTION(more_invocations_expected); 20 | MOCKITO_EXCEPTION(zero_invocations_expected); 21 | 22 | #undef MOCKITO_EXCEPTION 23 | } // namespace mockitopp 24 | 25 | #endif //__MOCKITOPP_EXCEPTIONS_HPP__ 26 | -------------------------------------------------------------------------------- /tests/testlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testlib_SRCS 2 | akonadidebug.cpp 3 | akonadifakedata.cpp 4 | akonadifakedataxmlloader.cpp 5 | akonadifakejobs.cpp 6 | akonadifakemonitor.cpp 7 | akonadifakestorage.cpp 8 | akonadifakestoragebehavior.cpp 9 | akonadistoragetestbase.cpp 10 | fakejob.cpp 11 | gencollection.cpp 12 | gentodo.cpp 13 | monitorspy.cpp 14 | testhelpers.cpp 15 | ) 16 | 17 | include_directories(${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/src) 18 | add_library(testlib STATIC ${testlib_SRCS}) 19 | set_property(TARGET testlib PROPERTY POSITION_INDEPENDENT_CODE ON) 20 | 21 | target_link_libraries(testlib 22 | KPim6::AkonadiCore 23 | KPim6::AkonadiXml 24 | KF6::CalendarCore 25 | Qt::DBus 26 | Qt::Test 27 | ) 28 | 29 | -------------------------------------------------------------------------------- /src/domain/projectqueries.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef DOMAIN_PROJECTQUERIES_H 8 | #define DOMAIN_PROJECTQUERIES_H 9 | 10 | #include "project.h" 11 | #include "queryresult.h" 12 | #include "task.h" 13 | 14 | namespace Domain { 15 | 16 | class ProjectQueries 17 | { 18 | public: 19 | typedef QSharedPointer Ptr; 20 | 21 | ProjectQueries(); 22 | virtual ~ProjectQueries(); 23 | 24 | virtual QueryResult::Ptr findAll() const = 0; 25 | virtual QueryResult::Ptr findTopLevel(Project::Ptr project) const = 0; 26 | }; 27 | 28 | } 29 | 30 | #endif // DOMAIN_PROJECTQUERIES_H 31 | -------------------------------------------------------------------------------- /src/zanshin/kontact/kontact_plugin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2011 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "kontact_plugin.h" 7 | 8 | #include 9 | 10 | EXPORT_KONTACT_PLUGIN_WITH_JSON(Plugin, "zanshin_plugin.json") 11 | 12 | Plugin::Plugin(KontactInterface::Core *core, const KPluginMetaData &data, const QVariantList&) 13 | : KontactInterface::Plugin(core, core, data, "zanshin") 14 | { 15 | setComponentName(QStringLiteral("zanshin"), QStringLiteral("zanshin")); 16 | } 17 | 18 | KParts::Part *Plugin::createPart() 19 | { 20 | return loadPart(); 21 | } 22 | 23 | #include "kontact_plugin.moc" 24 | 25 | #include "moc_kontact_plugin.cpp" 26 | -------------------------------------------------------------------------------- /src/akonadi/akonadiitemfetchjobinterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_ITEMFETCHJOBINTERFACE_H 8 | #define AKONADI_ITEMFETCHJOBINTERFACE_H 9 | 10 | #include 11 | #include 12 | 13 | class KJob; 14 | 15 | namespace Akonadi { 16 | 17 | class ItemFetchJobInterface 18 | { 19 | public: 20 | ItemFetchJobInterface(); 21 | virtual ~ItemFetchJobInterface(); 22 | 23 | KJob *kjob(); 24 | 25 | virtual Item::List items() const = 0; 26 | virtual void setCollection(const Akonadi::Collection &collection) = 0; 27 | }; 28 | 29 | } 30 | 31 | #endif // AKONADI_ITEMFETCHJOBINTERFACE_H 32 | -------------------------------------------------------------------------------- /.kde-ci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: None 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | Dependencies: 5 | - 'on': ['Linux', 'FreeBSD', 'Windows'] 6 | 'require': 7 | 'frameworks/extra-cmake-modules': '@latest-kf6' 8 | 'frameworks/kcoreaddons': '@latest-kf6' 9 | 'frameworks/kwindowsystem': '@latest-kf6' 10 | 'frameworks/ki18n': '@latest-kf6' 11 | 'frameworks/kcrash': '@latest-kf6' 12 | 'pim/akonadi' : '@same' 13 | 'pim/akonadi-calendar' : '@same' 14 | 'pim/kontactinterface' : '@same' 15 | 16 | - 'on': ['Linux', 'FreeBSD'] 17 | 'require': 18 | 'frameworks/krunner': '@latest-kf6' 19 | 20 | Options: 21 | ctest-arguments: '--repeat until-pass:3' 22 | use-ccache: True 23 | require-passing-tests-on: ['Linux'] 24 | gcovr-arguments: '--filter src/' 25 | 26 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers/Matcher.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_MATCHER_HPP__ 7 | #define __MOCKITOPP_MATCHER_HPP__ 8 | 9 | #include 10 | 11 | namespace mockitopp 12 | { 13 | namespace matcher 14 | { 15 | template 16 | struct Matcher 17 | { 18 | virtual ~Matcher() {}; 19 | 20 | virtual Matcher* clone() const = 0; 21 | 22 | virtual bool operator== (typename mockitopp::detail::tr1::add_reference::type>::type rhs) const = 0; 23 | }; 24 | } // namespace matcher 25 | } // namespace mockitopp 26 | 27 | #endif //__MOCKITOPP_MATCHER_HPP__ 28 | -------------------------------------------------------------------------------- /src/akonadi/akonadicollectionfetchjobinterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_COLLECTIONFETCHJOBINTERFACE_H 8 | #define AKONADI_COLLECTIONFETCHJOBINTERFACE_H 9 | 10 | #include 11 | 12 | class KJob; 13 | 14 | namespace Akonadi { 15 | 16 | class CollectionFetchJobInterface 17 | { 18 | public: 19 | CollectionFetchJobInterface(); 20 | virtual ~CollectionFetchJobInterface(); 21 | 22 | KJob *kjob(); 23 | 24 | virtual Collection::List collections() const = 0; 25 | virtual void setResource(const QString &resource) = 0; 26 | }; 27 | 28 | } 29 | 30 | #endif // AKONADI_COLLECTIONFETCHJOBINTERFACE_H 31 | -------------------------------------------------------------------------------- /src/zanshin/kontact/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(zanshin_part MODULE) 3 | target_sources(zanshin_part PRIVATE 4 | ../app/aboutdata.cpp 5 | part.cpp 6 | part.h 7 | kontact_plugins.qrc 8 | ) 9 | kde_enable_exceptions() 10 | target_link_libraries(zanshin_part 11 | KF6::Parts 12 | integration 13 | widgets 14 | ) 15 | 16 | install(TARGETS zanshin_part DESTINATION ${KDE_INSTALL_PLUGINDIR}) 17 | 18 | ########################## 19 | 20 | 21 | add_library(kontact_zanshinplugin MODULE) 22 | target_sources(kontact_zanshinplugin PRIVATE 23 | kontact_plugin.cpp 24 | kontact_plugin.h 25 | ) 26 | target_link_libraries(kontact_zanshinplugin KF6::Parts KPim6::KontactInterface) 27 | 28 | install(TARGETS kontact_zanshinplugin DESTINATION ${KDE_INSTALL_PLUGINDIR}/pim6/kontact) 29 | 30 | -------------------------------------------------------------------------------- /tests/units/widgets/messageboxstub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef MESSAGEBOX_STUB_H 8 | #define MESSAGEBOX_STUB_H 9 | 10 | #include "widgets/messageboxinterface.h" 11 | 12 | class MessageBoxStub : public Widgets::MessageBoxInterface 13 | { 14 | public: 15 | typedef QSharedPointer Ptr; 16 | 17 | MessageBoxStub() : m_called(false) {} 18 | 19 | QMessageBox::Button askConfirmation(QWidget *, const QString &, const QString &) override { 20 | m_called = true; 21 | return QMessageBox::Yes; 22 | } 23 | 24 | bool called() const { return m_called; } 25 | 26 | private: 27 | bool m_called; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/domain/datasourcerepository.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef DOMAIN_DATASOURCEREPOSITORY_H 8 | #define DOMAIN_DATASOURCEREPOSITORY_H 9 | 10 | #include "datasource.h" 11 | 12 | class KJob; 13 | 14 | namespace Domain { 15 | 16 | class DataSourceRepository 17 | { 18 | public: 19 | typedef QSharedPointer Ptr; 20 | 21 | DataSourceRepository(); 22 | virtual ~DataSourceRepository(); 23 | 24 | virtual KJob *update(DataSource::Ptr source) = 0; 25 | 26 | virtual void showConfigDialog() = 0; 27 | virtual void windowNeedsDataBackend(QWidget *window) = 0; 28 | }; 29 | 30 | } 31 | 32 | #endif // DOMAIN_DATASOURCEREPOSITORY_H 33 | -------------------------------------------------------------------------------- /src/presentation/availablepagessortfilterproxymodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef PRESENTATION_AVAILABLEPAGESSORTFILTERPROXYMODEL_H 9 | #define PRESENTATION_AVAILABLEPAGESSORTFILTERPROXYMODEL_H 10 | 11 | #include 12 | 13 | namespace Presentation { 14 | 15 | class AvailablePagesSortFilterProxyModel : public QSortFilterProxyModel 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit AvailablePagesSortFilterProxyModel(QObject *parent = 0); 20 | 21 | protected: 22 | bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; 23 | }; 24 | 25 | } 26 | 27 | #endif // PRESENTATION_AVAILABLEPAGESSORTFILTERPROXYMODEL_H 28 | -------------------------------------------------------------------------------- /src/widgets/pageviewerrorhandler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "pageviewerrorhandler.h" 7 | 8 | #include "widgets/pageview.h" 9 | 10 | using namespace Widgets; 11 | 12 | PageViewErrorHandler::PageViewErrorHandler() 13 | : m_pageView(nullptr) 14 | { 15 | } 16 | 17 | Widgets::PageView *PageViewErrorHandler::pageView() const 18 | { 19 | return m_pageView; 20 | } 21 | 22 | void PageViewErrorHandler::setPageView(Widgets::PageView *pageView) 23 | { 24 | m_pageView = pageView; 25 | } 26 | 27 | void Widgets::PageViewErrorHandler::doDisplayMessage(const QString &message) 28 | { 29 | if (m_pageView) 30 | m_pageView->displayErrorMessage(message); 31 | } 32 | -------------------------------------------------------------------------------- /src/widgets/pageviewerrorhandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef WIDGETS_PAGEVIEWERRORHANDLER_H 8 | #define WIDGETS_PAGEVIEWERRORHANDLER_H 9 | 10 | #include "presentation/errorhandler.h" 11 | 12 | namespace Widgets { 13 | 14 | class PageView; 15 | 16 | class PageViewErrorHandler : public Presentation::ErrorHandler 17 | { 18 | public: 19 | PageViewErrorHandler(); 20 | 21 | Widgets::PageView *pageView() const; 22 | void setPageView(Widgets::PageView *pageView); 23 | 24 | private: 25 | void doDisplayMessage(const QString &message) override; 26 | 27 | Widgets::PageView *m_pageView; 28 | }; 29 | 30 | } 31 | 32 | #endif // WIDGETS_PAGEVIEWERRORHANDLER_H 33 | -------------------------------------------------------------------------------- /tests/features/workday/workdaystartbuttonfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: adding a task with start today button 14 | // As someone using tasks 15 | // I can set the date of a task to today by clicking on the "start today" button 16 | // In order to have my task start today 17 | 18 | class WorkdayStartbuttonFeature : public QObject 19 | { 20 | Q_OBJECT 21 | }; 22 | 23 | ZANSHIN_TEST_MAIN(WorkdayStartbuttonFeature) 24 | 25 | #include "workdaystartbuttonfeature.moc" 26 | -------------------------------------------------------------------------------- /src/presentation/errorhandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Mario Bensi 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef PRESENTATION_ERRORHANDLER_H 8 | #define PRESENTATION_ERRORHANDLER_H 9 | 10 | #include 11 | #include 12 | 13 | class KJob; 14 | 15 | namespace Presentation { 16 | 17 | class ErrorHandler 18 | { 19 | public: 20 | virtual ~ErrorHandler(); 21 | 22 | void installHandler(KJob *job, const QString &message); 23 | 24 | private: 25 | void displayMessage(KJob *job, const QString &message); 26 | 27 | virtual void doDisplayMessage(const QString &message) = 0; 28 | }; 29 | 30 | } 31 | 32 | Q_DECLARE_METATYPE(Presentation::ErrorHandler*) 33 | 34 | #endif // PRESENTATION_ERRORHANDLER_H 35 | -------------------------------------------------------------------------------- /src/presentation/errorhandlingmodelbase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Mario Bensi 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef PRESENTATION_ERRORHANDLINGMODELBASE_H 8 | #define PRESENTATION_ERRORHANDLINGMODELBASE_H 9 | 10 | #include 11 | 12 | class KJob; 13 | 14 | namespace Presentation { 15 | 16 | class ErrorHandler; 17 | 18 | class ErrorHandlingModelBase 19 | { 20 | public: 21 | ErrorHandlingModelBase(); 22 | 23 | ErrorHandler *errorHandler() const; 24 | void setErrorHandler(ErrorHandler *errorHandler); 25 | 26 | protected: 27 | void installHandler(KJob *job, const QString &message); 28 | 29 | private: 30 | ErrorHandler *m_errorHandler; 31 | }; 32 | 33 | } 34 | 35 | #endif // PRESENTATION_ERRORHANDLINGMODELBASE_H 36 | -------------------------------------------------------------------------------- /src/akonadi/akonadimonitorimpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_MONITORIMPL_H 8 | #define AKONADI_MONITORIMPL_H 9 | 10 | #include "akonadimonitorinterface.h" 11 | #include 12 | 13 | namespace Akonadi { 14 | 15 | class Monitor; 16 | 17 | class MonitorImpl : public MonitorInterface 18 | { 19 | Q_OBJECT 20 | public: 21 | MonitorImpl(); 22 | virtual ~MonitorImpl(); 23 | 24 | private slots: 25 | void onCollectionChanged(const Akonadi::Collection &collection, const QSet &parts); 26 | 27 | private: 28 | bool hasSupportedMimeTypes(const Collection &collection); 29 | Akonadi::Monitor *m_monitor; 30 | }; 31 | 32 | } 33 | 34 | #endif // AKONADI_MONITORIMPL_H 35 | -------------------------------------------------------------------------------- /src/domain/datasourcequeries.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "datasourcequeries.h" 8 | 9 | using namespace Domain; 10 | 11 | Q_GLOBAL_STATIC(DataSourceQueriesNotifier, s_notifier) 12 | 13 | DataSourceQueries::DataSourceQueries() 14 | { 15 | } 16 | 17 | DataSourceQueries::~DataSourceQueries() 18 | { 19 | } 20 | 21 | DataSourceQueriesNotifier *DataSourceQueries::notifier() const 22 | { 23 | return s_notifier(); 24 | } 25 | 26 | void DataSourceQueries::setDefaultSource(DataSource::Ptr source) 27 | { 28 | if (isDefaultSource(source)) 29 | return; 30 | 31 | changeDefaultSource(source); 32 | emit notifier()->defaultSourceChanged(); 33 | } 34 | 35 | #include "moc_datasourcequeries.cpp" 36 | -------------------------------------------------------------------------------- /src/presentation/metatypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef PRESENTATION_METATYPES_H 9 | #define PRESENTATION_METATYPES_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | typedef QSharedPointer QObjectPtr; 16 | typedef QList QObjectPtrList; 17 | 18 | namespace Presentation { 19 | 20 | namespace MetaTypes 21 | { 22 | void registerAll(); 23 | } 24 | 25 | } 26 | 27 | // cppcheck's parser somehow confuses it for a C-cast 28 | // cppcheck-suppress cstyleCast 29 | Q_DECLARE_METATYPE(QAbstractItemModel*) 30 | 31 | Q_DECLARE_METATYPE(QObjectPtr) 32 | Q_DECLARE_METATYPE(QObjectPtrList) 33 | 34 | #endif // PRESENTATION_METATYPES_H 35 | -------------------------------------------------------------------------------- /src/domain/contextqueries.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-FileCopyrightText: 2014 Rémi Benoit 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #ifndef DOMAIN_CONTEXTQUERIES_H 9 | #define DOMAIN_CONTEXTQUERIES_H 10 | 11 | #include "context.h" 12 | #include "queryresult.h" 13 | #include "task.h" 14 | 15 | namespace Domain { 16 | 17 | class ContextQueries 18 | { 19 | public: 20 | typedef QSharedPointer Ptr; 21 | 22 | ContextQueries(); 23 | virtual ~ContextQueries(); 24 | 25 | virtual QueryResult::Ptr findAll() const = 0; 26 | 27 | virtual QueryResult::Ptr findTopLevelTasks(Context::Ptr context) const = 0; 28 | }; 29 | 30 | } 31 | 32 | #endif // DOMAIN_CONTEXTQUERIES_H 33 | -------------------------------------------------------------------------------- /src/widgets/quickselectdialoginterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef WIDGETS_QUICKSELECTDIALOGINTERFACE_H 9 | #define WIDGETS_QUICKSELECTDIALOGINTERFACE_H 10 | 11 | #include 12 | #include 13 | 14 | class QAbstractItemModel; 15 | 16 | namespace Widgets { 17 | 18 | class QuickSelectDialogInterface 19 | { 20 | public: 21 | typedef QSharedPointer Ptr; 22 | 23 | virtual ~QuickSelectDialogInterface(); 24 | 25 | virtual int exec() = 0; 26 | 27 | virtual QPersistentModelIndex selectedIndex() const = 0; 28 | virtual void setModel(QAbstractItemModel *model) = 0; 29 | }; 30 | 31 | } 32 | 33 | #endif // WIDGETS_QUICKSELECTDIALOGINTERFACE_H 34 | -------------------------------------------------------------------------------- /src/zanshin/runner/zanshinrunner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2011 Kevin Ottens 3 | SPDX-FileCopyrightText: 2014 Mario Bensi 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | #ifndef ZANSHINRUNNER_H 8 | #define ZANSHINRUNNER_H 9 | 10 | #include 11 | 12 | #include "domain/taskrepository.h" 13 | 14 | using namespace KRunner; 15 | 16 | class ZanshinRunner : public AbstractRunner 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | ZanshinRunner(QObject *parent, const KPluginMetaData &metaData); 22 | 23 | private: 24 | void match(RunnerContext &context) override; 25 | void run(const RunnerContext &context, const QueryMatch &action) override; 26 | 27 | Domain::TaskRepository::Ptr m_taskRepository; 28 | const QString m_triggerWord; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/akonadi/akonaditimestampattribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_TIMESTAMPATTRIBUTE_H 8 | #define AKONADI_TIMESTAMPATTRIBUTE_H 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace Akonadi { 15 | 16 | class TimestampAttribute : public Attribute 17 | { 18 | public: 19 | TimestampAttribute(); 20 | ~TimestampAttribute(); 21 | 22 | qint64 timestamp() const; 23 | void refreshTimestamp(); 24 | 25 | QByteArray type() const override; 26 | TimestampAttribute *clone() const override; 27 | 28 | QByteArray serialized() const override; 29 | void deserialize(const QByteArray &data) override; 30 | 31 | private: 32 | qint64 m_timestamp; 33 | }; 34 | 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/presentation/errorhandlingmodelbase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Mario Bensi 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "errorhandlingmodelbase.h" 7 | 8 | #include "presentation/errorhandler.h" 9 | 10 | using namespace Presentation; 11 | 12 | ErrorHandlingModelBase::ErrorHandlingModelBase() 13 | : m_errorHandler(nullptr) 14 | { 15 | } 16 | 17 | ErrorHandler *ErrorHandlingModelBase::errorHandler() const 18 | { 19 | return m_errorHandler; 20 | } 21 | 22 | void ErrorHandlingModelBase::setErrorHandler(ErrorHandler *errorHandler) 23 | { 24 | m_errorHandler = errorHandler; 25 | } 26 | 27 | void ErrorHandlingModelBase::installHandler(KJob *job, const QString &message) 28 | { 29 | if (!m_errorHandler) 30 | return; 31 | 32 | m_errorHandler->installHandler(job, message); 33 | } 34 | -------------------------------------------------------------------------------- /src/utils/compositejob.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Mario Bensi 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef COMPOSITE_JOB 8 | #define COMPOSITE_JOB 9 | 10 | #include "kcompositejob.h" 11 | #include "jobhandler.h" 12 | 13 | namespace Utils { 14 | 15 | class CompositeJob : public KCompositeJob 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit CompositeJob(QObject *parent = nullptr); 20 | 21 | using KCompositeJob::addSubjob; 22 | 23 | void start() override; 24 | virtual bool install(KJob *job, const JobHandler::ResultHandlerWithJob &handler); 25 | virtual bool install(KJob *job, const JobHandler::ResultHandler &handler); 26 | 27 | void emitError(const QString &errorText); 28 | 29 | private slots: 30 | void slotResult(KJob *job) override; 31 | }; 32 | 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /src/widgets/datasourcedelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Christian Mollekopf 3 | SPDX-FileCopyrightText: 2014 Kevin Ottens 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | 9 | #ifndef DATASOURCEDELEGATE_H 10 | #define DATASOURCEDELEGATE_H 11 | 12 | #include 13 | 14 | #include "domain/datasource.h" 15 | 16 | namespace Widgets 17 | { 18 | 19 | class DataSourceDelegate : public QStyledItemDelegate 20 | { 21 | Q_OBJECT 22 | public: 23 | explicit DataSourceDelegate(QObject *parent = nullptr); 24 | 25 | void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 26 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 27 | }; 28 | 29 | } 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /src/utils/jobhandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef UTILS_JOBHANDLER_H 9 | #define UTILS_JOBHANDLER_H 10 | 11 | #include 12 | 13 | class KJob; 14 | 15 | namespace Utils { 16 | 17 | namespace JobHandler 18 | { 19 | enum StartMode { 20 | AutoStart, 21 | ManualStart 22 | }; 23 | 24 | typedef std::function ResultHandlerWithJob; 25 | typedef std::function ResultHandler; 26 | 27 | void install(KJob *job, const ResultHandler &handler, StartMode startMode = AutoStart); 28 | void install(KJob *job, const ResultHandlerWithJob &handler, StartMode startMode = AutoStart); 29 | 30 | void clear(); 31 | 32 | int jobCount(); 33 | } 34 | 35 | } 36 | 37 | #endif // UTILS_JOBHANDLER_H 38 | -------------------------------------------------------------------------------- /tests/testlib/monitorspy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Mario Bensi 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef ZANSHIN_TESTLIB_MONITORSPY_H 8 | #define ZANSHIN_TESTLIB_MONITORSPY_H 9 | 10 | #include "akonadi/akonadimonitorimpl.h" 11 | 12 | #include 13 | #include 14 | 15 | class MonitorSpy : public QObject 16 | { 17 | Q_OBJECT 18 | public: 19 | static int expirationDelay(); 20 | static void setExpirationDelay(int value); 21 | 22 | explicit MonitorSpy(Akonadi::MonitorInterface *monitor, QObject *parent = nullptr); 23 | 24 | void waitForStableState(); 25 | 26 | private slots: 27 | void restartTimer(); 28 | void onDelayExpired(); 29 | 30 | private: 31 | Akonadi::MonitorInterface *m_monitor; 32 | QTimer *m_timer; 33 | bool m_isFinished; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /tests/units/akonadi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(MacroAkonadiAutoTests) 2 | 3 | zanshin_auto_tests( 4 | akonadiapplicationselectedattributetest 5 | akonadicachetest 6 | akonadicachingstoragetest 7 | akonadicontextqueriestest 8 | akonadicontextrepositorytest 9 | akonadidatasourcequeriestest 10 | akonadidatasourcerepositorytest 11 | akonadilivequeryhelperstest 12 | akonadilivequeryintegratortest 13 | akonadiprojectqueriestest 14 | akonadiprojectrepositorytest 15 | akonadiserializertest 16 | akonadistoragesettingstest 17 | akonaditaskqueriestest 18 | akonaditaskrepositorytest 19 | akonaditimestampattributetest 20 | ) 21 | 22 | zanshin_akonadi_auto_tests( 23 | akonadistoragetest 24 | akonadicachingstorageintegrationtest 25 | ) 26 | 27 | target_link_libraries(tests-units-akonadi-akonadistoragetest akonadi testlib) 28 | target_link_libraries(tests-units-akonadi-akonadicachingstorageintegrationtest akonadi testlib) 29 | -------------------------------------------------------------------------------- /tests/testlib/testsafety.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef TESTSAFETY_H 8 | #define TESTSAFETY_H 9 | 10 | #include 11 | #include 12 | 13 | namespace TestLib { 14 | namespace TestSafety { 15 | 16 | /** 17 | * Checks that the test is running in the proper test environment (akonaditest) 18 | */ 19 | bool checkTestIsIsolated() 20 | { 21 | if (qEnvironmentVariableIsEmpty("AKONADI_TESTRUNNER_PID")) { 22 | qCritical() << "This test must be run using ctest, in order to use the testrunner environment. Aborting, to avoid messing up your real akonadi"; 23 | return false; 24 | } 25 | return true; 26 | } 27 | 28 | } 29 | } 30 | 31 | #endif // TESTSAFETY_H 32 | -------------------------------------------------------------------------------- /src/presentation/availablepagessortfilterproxymodel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "availablepagessortfilterproxymodel.h" 8 | 9 | using namespace Presentation; 10 | 11 | AvailablePagesSortFilterProxyModel::AvailablePagesSortFilterProxyModel(QObject *parent) 12 | : QSortFilterProxyModel(parent) 13 | { 14 | setSortCaseSensitivity(Qt::CaseInsensitive); 15 | sort(0, Qt::AscendingOrder); 16 | } 17 | 18 | bool AvailablePagesSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const 19 | { 20 | if ( !left.parent().isValid() ) { 21 | // Toplevel items: no sorting 22 | return left.row() < right.row(); 23 | } 24 | return QSortFilterProxyModel::lessThan(left, right); 25 | } 26 | 27 | #include "moc_availablepagessortfilterproxymodel.cpp" 28 | -------------------------------------------------------------------------------- /src/akonadi/akonadistoragesettings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2012 Christian Mollekopf 3 | SPDX-FileCopyrightText: 2014 Kevin Ottens 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #ifndef AKONADI_STORAGESETTINGS_H 9 | #define AKONADI_STORAGESETTINGS_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Akonadi 16 | { 17 | 18 | class StorageSettings : public QObject 19 | { 20 | Q_OBJECT 21 | private: 22 | StorageSettings(); 23 | 24 | public: 25 | static StorageSettings &instance(); 26 | 27 | Akonadi::Collection defaultCollection(); 28 | 29 | public slots: 30 | void setDefaultCollection(const Akonadi::Collection &collection); 31 | 32 | signals: 33 | void defaultCollectionChanged(const Akonadi::Collection &collection); 34 | }; 35 | 36 | } 37 | 38 | #endif // AKONADI_STORAGESETTINGS_H 39 | -------------------------------------------------------------------------------- /src/akonadi/akonadiapplicationselectedattribute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_APPLICATIONSELECTEDATTRIBUTE_H 8 | #define AKONADI_APPLICATIONSELECTEDATTRIBUTE_H 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace Akonadi { 15 | 16 | class ApplicationSelectedAttribute : public Attribute 17 | { 18 | public: 19 | ApplicationSelectedAttribute(); 20 | ~ApplicationSelectedAttribute(); 21 | 22 | void setSelected(bool selected); 23 | bool isSelected() const; 24 | 25 | QByteArray type() const override; 26 | ApplicationSelectedAttribute *clone() const override; 27 | 28 | QByteArray serialized() const override; 29 | void deserialize(const QByteArray &data) override; 30 | 31 | private: 32 | bool m_selected; 33 | }; 34 | 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/util/cxx0x_static_assert.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_CXX0X_STATIC_ASSERT_HPP__ 7 | #define __MOCKITOPP_CXX0X_STATIC_ASSERT_HPP__ 8 | 9 | namespace mockitopp 10 | { 11 | namespace detail 12 | { 13 | /** 14 | * An emulation of the C++0x static_assert macro that can be 15 | * used to force a compile time error in older compilers. 16 | * 17 | * @author Trevor Pounds 18 | */ 19 | template struct static_assert_impl { typedef bool type; }; 20 | template <> struct static_assert_impl { }; 21 | 22 | #define mockitopp_static_assert(constant_expression) \ 23 | typedef typename ::mockitopp::detail::static_assert_impl::type MOCKITOPP_STATIC_ASSERT_TYPE; 24 | } // namespace detail 25 | } // namespace mockitopp 26 | 27 | #endif //__MOCKITOPP_CXX0X_STATIC_ASSERT_HPP__ 28 | -------------------------------------------------------------------------------- /src/domain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(domain STATIC) 3 | target_sources(domain PRIVATE 4 | context.cpp 5 | contextqueries.cpp 6 | contextrepository.cpp 7 | datasource.cpp 8 | datasourcequeries.cpp 9 | datasourcerepository.cpp 10 | project.cpp 11 | projectqueries.cpp 12 | projectrepository.cpp 13 | queryresult.cpp 14 | queryresultinterface.cpp 15 | queryresultprovider.cpp 16 | task.cpp 17 | taskqueries.cpp 18 | taskrepository.cpp 19 | 20 | context.h 21 | contextqueries.h 22 | contextrepository.h 23 | datasource.h 24 | datasourcequeries.h 25 | datasourcerepository.h 26 | project.h 27 | projectqueries.h 28 | projectrepository.h 29 | queryresult.h 30 | queryresultinterface.h 31 | queryresultprovider.h 32 | task.h 33 | taskqueries.h 34 | taskrepository.h 35 | ) 36 | set_property(TARGET domain PROPERTY POSITION_INDEPENDENT_CODE ON) 37 | 38 | target_link_libraries(domain Qt::Core) 39 | -------------------------------------------------------------------------------- /src/domain/projectrepository.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef DOMAIN_PROJECTREPOSITORY_H 8 | #define DOMAIN_PROJECTREPOSITORY_H 9 | 10 | #include "task.h" 11 | #include "datasource.h" 12 | #include "project.h" 13 | 14 | class KJob; 15 | 16 | namespace Domain { 17 | 18 | class ProjectRepository 19 | { 20 | public: 21 | typedef QSharedPointer Ptr; 22 | 23 | ProjectRepository(); 24 | virtual ~ProjectRepository(); 25 | 26 | virtual KJob *create(Project::Ptr project, DataSource::Ptr source) = 0; 27 | virtual KJob *update(Project::Ptr project) = 0; 28 | virtual KJob *remove(Project::Ptr project) = 0; 29 | 30 | virtual KJob *associate(Project::Ptr parent, Task::Ptr child) = 0; 31 | virtual KJob *dissociate(Task::Ptr child) = 0; 32 | }; 33 | 34 | } 35 | 36 | #endif // DOMAIN_PROJECTREPOSITORY_H 37 | -------------------------------------------------------------------------------- /tests/testlib/fakejob.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef ZANSHIN_TESTLIB_FAKEJOB_H 8 | #define ZANSHIN_TESTLIB_FAKEJOB_H 9 | 10 | #include 11 | 12 | class QTimer; 13 | 14 | class FakeJob : public KJob 15 | { 16 | Q_OBJECT 17 | public: 18 | static const int DURATION = 50; 19 | explicit FakeJob(QObject *parent = nullptr); 20 | 21 | void setExpectedError(int errorCode, const QString &errorText = QString()); 22 | 23 | void start() override; 24 | 25 | private slots: 26 | virtual void onTimeout(); 27 | 28 | public: 29 | bool isDone() const; 30 | int expectedError() const; 31 | QString expectedErrorText() const; 32 | 33 | private: 34 | bool doKill() override; 35 | 36 | QTimer *m_timer; 37 | bool m_done; 38 | bool m_launched; 39 | int m_errorCode; 40 | QString m_errorText; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/utils/dependencymanager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "dependencymanager.h" 8 | 9 | using namespace Utils; 10 | 11 | Q_GLOBAL_STATIC(DependencyManager, s_globalInstance) 12 | 13 | DependencyManager &DependencyManager::globalInstance() 14 | { 15 | return *s_globalInstance(); 16 | } 17 | 18 | DependencyManager::DependencyManager() 19 | { 20 | } 21 | 22 | DependencyManager::DependencyManager(const DependencyManager &other) 23 | : m_cleanupFunctions(other.m_cleanupFunctions) 24 | { 25 | } 26 | 27 | DependencyManager::~DependencyManager() 28 | { 29 | for (const auto &cleanupFunction : std::as_const(m_cleanupFunctions)) { 30 | cleanupFunction(this); 31 | } 32 | } 33 | 34 | DependencyManager &DependencyManager::operator=(const DependencyManager &other) 35 | { 36 | m_cleanupFunctions = other.m_cleanupFunctions; 37 | return *this; 38 | } 39 | -------------------------------------------------------------------------------- /src/widgets/nameanddatasourcedialoginterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef WIDGETS_NAMEANDDATASOURCEDIALOGINTERFACE_H 9 | #define WIDGETS_NAMEANDDATASOURCEDIALOGINTERFACE_H 10 | 11 | #include 12 | 13 | #include "domain/datasource.h" 14 | 15 | class QAbstractItemModel; 16 | 17 | namespace Widgets { 18 | 19 | class NameAndDataSourceDialogInterface 20 | { 21 | public: 22 | typedef QSharedPointer Ptr; 23 | 24 | virtual ~NameAndDataSourceDialogInterface(); 25 | 26 | virtual int exec() = 0; 27 | 28 | virtual void setWindowTitle(const QString &text) = 0; 29 | virtual void setDataSourcesModel(QAbstractItemModel *model) = 0; 30 | virtual QString name() const = 0; 31 | virtual Domain::DataSource::Ptr dataSource() const = 0; 32 | }; 33 | 34 | } 35 | 36 | #endif // WIDGETS_NAMEANDDATASOURCEDIALOGINTERFACE_H 37 | -------------------------------------------------------------------------------- /src/presentation/errorhandler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Mario Bensi 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "errorhandler.h" 7 | 8 | #include 9 | #include 10 | 11 | #include "utils/jobhandler.h" 12 | #include "utils/mem_fn.h" 13 | 14 | using namespace Presentation; 15 | 16 | ErrorHandler::~ErrorHandler() 17 | { 18 | } 19 | 20 | void ErrorHandler::installHandler(KJob *job, const QString &message) 21 | { 22 | auto resultHandler = std::function(std::bind(Utils::mem_fn(&ErrorHandler::displayMessage), 23 | this, job, message)); 24 | Utils::JobHandler::install(job, resultHandler); 25 | } 26 | 27 | void ErrorHandler::displayMessage(KJob *job, const QString &message) 28 | { 29 | if (job->error() != KJob::NoError) { 30 | doDisplayMessage(QCoreApplication::translate("ErrorHandler", "%1: %2").arg(message, job->errorString())); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/units/presentation/metatypestest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | 9 | #include "domain/datasource.h" 10 | #include "domain/task.h" 11 | 12 | #include "presentation/metatypes.h" 13 | 14 | class MetaTypesTest : public QObject 15 | { 16 | Q_OBJECT 17 | private slots: 18 | void shouldRegisterMetaTypes() 19 | { 20 | // GIVEN 21 | 22 | // WHEN 23 | Presentation::MetaTypes::registerAll(); 24 | 25 | // THEN 26 | QVERIFY(QMetaType::isRegistered(qMetaTypeId())); 27 | QVERIFY(QMetaType::isRegistered(qMetaTypeId())); 28 | QVERIFY(QMetaType::isRegistered(qMetaTypeId())); 29 | QVERIFY(QMetaType::isRegistered(qMetaTypeId())); 30 | } 31 | }; 32 | 33 | ZANSHIN_TEST_MAIN(MetaTypesTest) 34 | 35 | #include "metatypestest.moc" 36 | -------------------------------------------------------------------------------- /src/domain/context.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "context.h" 8 | 9 | using namespace Domain; 10 | 11 | Context::Context(QObject *parent) 12 | : QObject(parent) 13 | { 14 | } 15 | 16 | Context::~Context() 17 | { 18 | } 19 | 20 | QString Context::name() const 21 | { 22 | return m_name; 23 | } 24 | 25 | void Context::setName(const QString &name) 26 | { 27 | if (m_name == name) 28 | return; 29 | 30 | m_name = name; 31 | emit nameChanged(name); 32 | } 33 | 34 | QDebug operator<<(QDebug dbg, const Domain::Context &context) 35 | { 36 | dbg << "Context" << context.name(); 37 | return dbg; 38 | } 39 | 40 | QDebug operator<<(QDebug dbg, const Domain::Context::Ptr &context) 41 | { 42 | if (!context) 43 | dbg << "Ptr to null context"; 44 | else 45 | dbg << "Ptr to" << *context; 46 | return dbg; 47 | } 48 | 49 | #include "moc_context.cpp" 50 | -------------------------------------------------------------------------------- /src/domain/project.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "project.h" 8 | 9 | using namespace Domain; 10 | 11 | Project::Project(QObject *parent) 12 | : QObject(parent) 13 | { 14 | } 15 | 16 | Project::~Project() 17 | { 18 | } 19 | 20 | QString Project::name() const 21 | { 22 | return m_name; 23 | } 24 | 25 | void Project::setName(const QString &name) 26 | { 27 | if (m_name == name) 28 | return; 29 | 30 | m_name = name; 31 | emit nameChanged(name); 32 | } 33 | 34 | QDebug operator<<(QDebug dbg, const Domain::Project &project) 35 | { 36 | dbg << "Project" << project.name(); 37 | return dbg; 38 | } 39 | 40 | QDebug operator<<(QDebug dbg, const Domain::Project::Ptr &project) 41 | { 42 | if (!project) 43 | dbg << "Ptr to null project"; 44 | else 45 | dbg << "Ptr to" << *project; 46 | return dbg; 47 | } 48 | 49 | #include "moc_project.cpp" 50 | -------------------------------------------------------------------------------- /src/akonadi/akonadiconfigdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2011-2015 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_CONFIGDIALOG_H 8 | #define AKONADI_CONFIGDIALOG_H 9 | 10 | #include 11 | 12 | #include "akonadistorageinterface.h" 13 | 14 | namespace Akonadi 15 | { 16 | 17 | class AgentInstanceFilterProxyModel; 18 | class AgentInstanceWidget; 19 | class AgentFilterProxyModel; 20 | 21 | class ConfigDialog : public QDialog 22 | { 23 | Q_OBJECT 24 | public: 25 | explicit ConfigDialog(QWidget *parent = nullptr); 26 | 27 | private slots: 28 | void onAddTriggered(); 29 | void onRemoveTriggered(); 30 | void onConfigureTriggered(); 31 | 32 | private: 33 | void applyContentTypes(Akonadi::AgentInstanceFilterProxyModel *model); 34 | void applyContentTypes(AgentFilterProxyModel *model); 35 | 36 | Akonadi::AgentInstanceWidget *const m_agentInstanceWidget; 37 | }; 38 | 39 | } 40 | 41 | #endif // AKONADI_CONFIGDIALOG_H 42 | 43 | -------------------------------------------------------------------------------- /src/domain/contextrepository.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef DOMAIN_CONTEXTREPOSITORY_H 8 | #define DOMAIN_CONTEXTREPOSITORY_H 9 | 10 | #include "context.h" 11 | #include "datasource.h" 12 | #include "task.h" 13 | 14 | class KJob; 15 | 16 | namespace Domain { 17 | 18 | class ContextRepository 19 | { 20 | public: 21 | typedef QSharedPointer Ptr; 22 | 23 | ContextRepository(); 24 | virtual ~ContextRepository(); 25 | 26 | virtual KJob *create(Context::Ptr context, DataSource::Ptr source) = 0; 27 | virtual KJob *update(Context::Ptr context) = 0; 28 | virtual KJob *remove(Context::Ptr context) = 0; 29 | 30 | virtual KJob *associate(Context::Ptr parent, Task::Ptr child) = 0; 31 | virtual KJob *dissociate(Context::Ptr parent, Task::Ptr child) = 0; 32 | virtual KJob *dissociateAll(Task::Ptr child) = 0; 33 | }; 34 | 35 | } 36 | 37 | #endif // DOMAIN_CONTEXTREPOSITORY_H 38 | -------------------------------------------------------------------------------- /src/zanshin/migrator/NOTES: -------------------------------------------------------------------------------- 1 | dans zanshin: KConfig read, QProcess migration 2 | 3 | 4 | KConfig read 5 | 6 | QHash< uid, { item, bool dirty } > 7 | 8 | fetchCollections 9 | fetchItems (ItemFetchJob) 10 | // TODO fetch all tags (probably none...) 11 | 12 | quand on a tout: 13 | 14 | // QSet tags_a_creer 15 | // iteration qhash 16 | // - for each category, if not in existing tags, add to tags_a_creer 17 | 18 | // transactionsequence (= composite job) 19 | // for each tags_a_creer 20 | // TagCreateJob 21 | 22 | // fetch all tags again (to get remoteId) 23 | 24 | transactionsequence (= composite job) 25 | iteration qhash 26 | - si comment -> setAsProject(sequence, item) 27 | iteration qhash 28 | - si parent et parent->customprop est vide -> setAsProject(sequence, parent) 29 | iteration qhash 30 | - // TODO contexts (for each category, if (!item.hasTag()) item.setTag() 31 | 32 | setAsProject(sequence, item) { 33 | setCustomProperty 34 | ItemModifyJob(parent = sequence) 35 | } 36 | 37 | sequence.exec 38 | 39 | slotSequenceFinished() 40 | { 41 | KConfig write 42 | } 43 | 44 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers/base/null.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_MATCHER_NULL_HPP__ 7 | #define __MOCKITOPP_MATCHER_NULL_HPP__ 8 | 9 | #include 10 | 11 | namespace mockitopp 12 | { 13 | namespace matcher 14 | { 15 | namespace detail 16 | { 17 | template 18 | struct NullT : public Matcher 19 | { 20 | NullT() 21 | {} 22 | 23 | virtual Matcher* clone() const 24 | { return new NullT(); } 25 | 26 | virtual bool operator== (typename mockitopp::detail::tr1::add_reference::type>::type rhs) const 27 | { return rhs == 0; } 28 | }; 29 | } // namespace detail 30 | 31 | template 32 | detail::NullT null() 33 | { return detail::NullT(); } 34 | } // namespace matcher 35 | } // namespace mockitopp 36 | 37 | #endif //__MOCKITOPP_MATCHER_NULL_HPP__ 38 | -------------------------------------------------------------------------------- /tests/features/workday/workdaytaskremovefeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Removing a task 14 | // As someone using tasks 15 | // I can remove a task 16 | // In order to clean up 17 | class WorkdayTaskRemoveFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Removing_a_task_that_appear_in_the_Workday_list() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Workday")); 25 | And(c.there_is_an_item_in_the_central_list("Buy pears")); 26 | When(c.I_remove_the_item()); 27 | And(c.I_list_the_items()); 28 | Then(c.the_list_does_not_contain("Buy pears")); 29 | } 30 | }; 31 | 32 | ZANSHIN_TEST_MAIN(WorkdayTaskRemoveFeature) 33 | 34 | #include "workdaytaskremovefeature.moc" 35 | -------------------------------------------------------------------------------- /tests/testlib/gencollection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef TESTLIB_GENCOLLECTION_H 8 | #define TESTLIB_GENCOLLECTION_H 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace Testlib { 15 | 16 | class GenCollection 17 | { 18 | public: 19 | explicit GenCollection(const Akonadi::Collection &collection = Akonadi::Collection()); 20 | 21 | operator Akonadi::Collection(); 22 | 23 | GenCollection &withId(Akonadi::Collection::Id id); 24 | GenCollection &withParent(Akonadi::Collection::Id id); 25 | GenCollection &withRootAsParent(); 26 | GenCollection &withName(const QString &name); 27 | GenCollection &withIcon(const QString &iconName); 28 | GenCollection &selected(bool value = true); 29 | GenCollection &withTaskContent(bool value = true); 30 | GenCollection &withNoteContent(bool value = true); 31 | 32 | private: 33 | Akonadi::Collection m_collection; 34 | }; 35 | 36 | } 37 | 38 | #endif // TESTLIB_GENCOLLECTION_H 39 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers/base/any.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_MATCHER_ANY_HPP__ 7 | #define __MOCKITOPP_MATCHER_ANY_HPP__ 8 | 9 | #include 10 | 11 | namespace mockitopp 12 | { 13 | namespace matcher 14 | { 15 | namespace detail 16 | { 17 | template 18 | struct AnyT : public Matcher 19 | { 20 | AnyT() 21 | {} 22 | 23 | Matcher* clone() const override 24 | { return new AnyT(); } 25 | 26 | bool operator== (typename mockitopp::detail::tr1::add_reference::type>::type rhs) const override 27 | { 28 | (void)rhs; 29 | return true; 30 | } 31 | }; 32 | } // namespace detail 33 | 34 | template 35 | detail::AnyT any() 36 | { return detail::AnyT(); } 37 | } // namespace matcher 38 | } // namespace mockitopp 39 | 40 | #endif //__MOCKITOPP_MATCHER_ANY_HPP__ 41 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License Copyright (c) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice (including the next 11 | paragraph) shall be included in all copies or substantial portions of the 12 | Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 17 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 19 | OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /src/utils/mem_fn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 René J.V. Bertin 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef UTILS_MEMFN_H 9 | #define UTILS_MEMFN_H 10 | 11 | #ifdef ZANSHIN_USE_BOOST_MEM_FN 12 | 13 | namespace boost { 14 | // this template teaches get_pointer about QSharedPointer 15 | template class Q > T* get_pointer(const Q &pointer) 16 | { 17 | return pointer.data(); 18 | } 19 | } 20 | 21 | #include 22 | 23 | #else // ZANSHIN_USE_BOOST_MEM_FN 24 | 25 | #include 26 | 27 | #endif // ZANSHIN_USE_BOOST_MEM_FN 28 | 29 | namespace Utils { 30 | #ifdef ZANSHIN_USE_BOOST_MEM_FN 31 | 32 | template 33 | auto mem_fn(PTMorPTMF const& ptm) -> decltype(boost::mem_fn(ptm)) { 34 | return boost::mem_fn(ptm); 35 | } 36 | 37 | #else 38 | 39 | template 40 | auto mem_fn(PTMorPTMF const& ptm) -> decltype(std::mem_fn(ptm)) { 41 | return std::mem_fn(ptm); 42 | } 43 | 44 | #endif 45 | } 46 | 47 | #endif // UTILS_MEMFN_H 48 | -------------------------------------------------------------------------------- /tests/testlib/akonadifakemonitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef TESTLIB_AKONADIFAKEMONITOR_H 8 | #define TESTLIB_AKONADIFAKEMONITOR_H 9 | 10 | #include "akonadi/akonadimonitorinterface.h" 11 | 12 | namespace Testlib { 13 | 14 | class AkonadiFakeMonitor : public Akonadi::MonitorInterface 15 | { 16 | Q_OBJECT 17 | public: 18 | typedef QSharedPointer Ptr; 19 | 20 | explicit AkonadiFakeMonitor(QObject *parent = nullptr); 21 | 22 | public slots: 23 | void addCollection(const Akonadi::Collection &collection); 24 | void removeCollection(const Akonadi::Collection &collection); 25 | void changeCollection(const Akonadi::Collection &collection); 26 | void changeCollectionSelection(const Akonadi::Collection &collection); 27 | 28 | void addItem(const Akonadi::Item &item); 29 | void removeItem(const Akonadi::Item &item); 30 | void changeItem(const Akonadi::Item &item); 31 | void moveItem(const Akonadi::Item &item); 32 | }; 33 | 34 | } 35 | 36 | #endif // TESTLIB_AKONADIFAKEMONITOR_H 37 | -------------------------------------------------------------------------------- /tests/features/workday/workdaytaskaddfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Adding a task from the workday view 14 | // As someone adding tasks 15 | // I can input a task for today in the quick entry 16 | // In order to have a new task that starts today 17 | class WorkdayTaskAddFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Tasks_added_from_the_workday_view_start_today() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Workday")); 25 | When(c.I_look_at_the_central_list()); 26 | And(c.I_add_a_task("Burn some confidential documents")); 27 | And(c.I_list_the_items()); 28 | Then(c.the_list_contains("Burn some confidential documents")); 29 | } 30 | }; 31 | 32 | ZANSHIN_TEST_MAIN(WorkdayTaskAddFeature) 33 | 34 | #include "workdaytaskaddfeature.moc" 35 | -------------------------------------------------------------------------------- /src/domain/context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef DOMAIN_CONTEXT_H 9 | #define DOMAIN_CONTEXT_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace Domain { 18 | 19 | class Context : public QObject 20 | { 21 | Q_OBJECT 22 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) 23 | 24 | public: 25 | typedef QSharedPointer Ptr; 26 | typedef QList List; 27 | 28 | explicit Context(QObject *parent = nullptr); 29 | virtual ~Context(); 30 | 31 | QString name() const; 32 | 33 | public slots: 34 | void setName(const QString &name); 35 | 36 | signals: 37 | void nameChanged(const QString &name); 38 | 39 | private: 40 | QString m_name; 41 | }; 42 | 43 | } 44 | 45 | Q_DECLARE_METATYPE(Domain::Context::Ptr) 46 | QDebug operator<<(QDebug dbg, const Domain::Context &context); 47 | QDebug operator<<(QDebug dbg, const Domain::Context::Ptr &context); 48 | 49 | #endif // DOMAIN_CONTEXT_H 50 | -------------------------------------------------------------------------------- /src/domain/project.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef DOMAIN_PROJECT_H 9 | #define DOMAIN_PROJECT_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace Domain { 18 | 19 | class Project : public QObject 20 | { 21 | Q_OBJECT 22 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) 23 | 24 | public: 25 | typedef QSharedPointer Ptr; 26 | typedef QList List; 27 | 28 | explicit Project(QObject *parent = nullptr); 29 | virtual ~Project(); 30 | 31 | QString name() const; 32 | 33 | public slots: 34 | void setName(const QString &name); 35 | 36 | signals: 37 | void nameChanged(const QString &name); 38 | 39 | private: 40 | QString m_name; 41 | }; 42 | 43 | } 44 | 45 | Q_DECLARE_METATYPE(Domain::Project::Ptr) 46 | QDebug operator<<(QDebug dbg, const Domain::Project &project); 47 | QDebug operator<<(QDebug dbg, const Domain::Project::Ptr &project); 48 | 49 | #endif // DOMAIN_PROJECT_H 50 | -------------------------------------------------------------------------------- /src/widgets/availablesourcesview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef WIDGETS_AVAILABLESOURCESVIEW_H 9 | #define WIDGETS_AVAILABLESOURCESVIEW_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | class QSortFilterProxyModel; 16 | class QTreeView; 17 | 18 | namespace Widgets { 19 | 20 | class AvailableSourcesView : public QWidget 21 | { 22 | Q_OBJECT 23 | public: 24 | explicit AvailableSourcesView(QWidget *parent = nullptr); 25 | 26 | QHash globalActions() const; 27 | 28 | QObject *model() const; 29 | 30 | void setSourceModel(const QByteArray &propertyName); 31 | public slots: 32 | void setModel(QObject *model); 33 | 34 | private slots: 35 | void onSelectionChanged(); 36 | void onSettingsTriggered(); 37 | void onDefaultTriggered(); 38 | 39 | private: 40 | QHash m_actions; 41 | QAction *m_defaultAction; 42 | QObject *m_model; 43 | QSortFilterProxyModel *m_sortProxy; 44 | QTreeView *m_sourcesView; 45 | }; 46 | 47 | } 48 | 49 | #endif // WIDGETS_AVAILABLESOURCESVIEW_H 50 | -------------------------------------------------------------------------------- /src/akonadi/akonadidatasourcerepository.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_DATASOURCEREPOSITORY_H 8 | #define AKONADI_DATASOURCEREPOSITORY_H 9 | 10 | #include "domain/datasourcerepository.h" 11 | 12 | #include "akonadi/akonadiserializerinterface.h" 13 | #include "akonadi/akonadistorageinterface.h" 14 | 15 | namespace Akonadi { 16 | 17 | class SerializerInterface; 18 | class StorageInterface; 19 | 20 | class DataSourceRepository : public QObject, public Domain::DataSourceRepository 21 | { 22 | Q_OBJECT 23 | public: 24 | typedef QSharedPointer Ptr; 25 | 26 | DataSourceRepository(const StorageInterface::Ptr &storage, 27 | const SerializerInterface::Ptr &serializer); 28 | 29 | KJob *update(Domain::DataSource::Ptr source) override; 30 | 31 | void showConfigDialog() override; 32 | void windowNeedsDataBackend(QWidget *window) override; 33 | 34 | private: 35 | StorageInterface::Ptr m_storage; 36 | SerializerInterface::Ptr m_serializer; 37 | }; 38 | 39 | } 40 | 41 | #endif // AKONADI_DATASOURCEREPOSITORY_H 42 | -------------------------------------------------------------------------------- /tests/units/domain/contexttest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | 9 | #include "domain/context.h" 10 | #include 11 | 12 | using namespace Domain; 13 | 14 | class ContextTest : public QObject 15 | { 16 | Q_OBJECT 17 | private slots: 18 | void shouldHaveEmptyPropertiesByDefault() 19 | { 20 | Context c; 21 | QCOMPARE(c.name(), QString()); 22 | } 23 | 24 | void shouldNotifyNameChanges() 25 | { 26 | Context c; 27 | QSignalSpy spy(&c, &Context::nameChanged); 28 | c.setName(QStringLiteral("foo")); 29 | QCOMPARE(spy.count(), 1); 30 | QCOMPARE(spy.first().first().toString(), QStringLiteral("foo")); 31 | } 32 | 33 | void shouldNotNotifyIdenticalNameChanges() 34 | { 35 | Context c; 36 | c.setName(QStringLiteral("foo")); 37 | QSignalSpy spy(&c, &Context::nameChanged); 38 | c.setName(QStringLiteral("foo")); 39 | QCOMPARE(spy.count(), 0); 40 | } 41 | }; 42 | 43 | ZANSHIN_TEST_MAIN(ContextTest) 44 | 45 | #include "contexttest.moc" 46 | -------------------------------------------------------------------------------- /ClangBuildAnalyzer.ini: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2025 Laurent Montel 2 | # SPDX-License-Identifier: CC0-1.0 3 | # ClangBuildAnalyzer reads ClangBuildAnalyzer.ini file from the working directory 4 | # when invoked, and various aspects of reporting can be configured this way. 5 | 6 | # How many of most expensive things are reported? 7 | [counts] 8 | 9 | # files that took most time to parse 10 | fileParse = 20 11 | # files that took most time to generate code for 12 | fileCodegen = 20 13 | # functions that took most time to generate code for 14 | function = 50 15 | # header files that were most expensive to include 16 | header = 10 17 | # for each expensive header, this many include paths to it are shown 18 | headerChain = 10 19 | # templates that took longest to instantiate 20 | template = 30 21 | 22 | 23 | # Minimum times (in ms) for things to be recorded into trace 24 | [minTimes] 25 | 26 | # parse/codegen for a file 27 | file = 10 28 | 29 | 30 | [misc] 31 | 32 | # Maximum length of symbol names printed; longer names will get truncated 33 | maxNameLength = 100 34 | 35 | # Only print "root" headers in expensive header report, i.e. 36 | # only headers that are directly included by at least one source file 37 | onlyRootHeaders = true 38 | -------------------------------------------------------------------------------- /src/widgets/filterwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef WIDGETS_FILTERWIDGET_H 9 | #define WIDGETS_FILTERWIDGET_H 10 | 11 | #include 12 | 13 | class QComboBox; 14 | class QLineEdit; 15 | 16 | namespace Presentation 17 | { 18 | class TaskFilterProxyModel; 19 | } 20 | 21 | namespace Ui { 22 | class FilterWidget; 23 | } 24 | 25 | namespace Widgets { 26 | 27 | class FilterWidget : public QWidget 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit FilterWidget(QWidget *parent = nullptr); 32 | ~FilterWidget(); 33 | 34 | Presentation::TaskFilterProxyModel *proxyModel() const; 35 | 36 | public slots: 37 | void clear(); 38 | void setShowDoneTasks(bool show); 39 | void setShowFutureTasks(bool show); 40 | 41 | private slots: 42 | void onTextChanged(const QString &text); 43 | void onSortTypeChanged(int index); 44 | void onAscendingClicked(); 45 | void onDescendingClicked(); 46 | 47 | private: 48 | Ui::FilterWidget *ui; 49 | Presentation::TaskFilterProxyModel *m_model; 50 | }; 51 | 52 | } 53 | 54 | #endif // WIDGETS_FILTERWIDGET_H 55 | -------------------------------------------------------------------------------- /tests/units/domain/projecttest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | 9 | #include "domain/project.h" 10 | 11 | #include 12 | 13 | using namespace Domain; 14 | 15 | class ProjectTest : public QObject 16 | { 17 | Q_OBJECT 18 | private slots: 19 | void shouldHaveEmptyPropertiesByDefault() 20 | { 21 | Project p; 22 | QCOMPARE(p.name(), QString()); 23 | } 24 | 25 | void shouldNotifyNameChanges() 26 | { 27 | Project p; 28 | QSignalSpy spy(&p, &Project::nameChanged); 29 | p.setName(QStringLiteral("foo")); 30 | QCOMPARE(spy.count(), 1); 31 | QCOMPARE(spy.first().first().toString(), QStringLiteral("foo")); 32 | } 33 | 34 | void shouldNotNotifyIdenticalNameChanges() 35 | { 36 | Project p; 37 | p.setName(QStringLiteral("foo")); 38 | QSignalSpy spy(&p, &Project::nameChanged); 39 | p.setName(QStringLiteral("foo")); 40 | QCOMPARE(spy.count(), 0); 41 | } 42 | }; 43 | 44 | ZANSHIN_TEST_MAIN(ProjectTest) 45 | 46 | #include "projecttest.moc" 47 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/util/horrible_cast.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_HORRIBLE_CAST_HPP__ 7 | #define __MOCKITOPP_HORRIBLE_CAST_HPP__ 8 | 9 | #include 10 | 11 | namespace mockitopp 12 | { 13 | namespace detail 14 | { 15 | /** 16 | * A potentially unsafe cast using a union of two possibly 17 | * incompatible data types that can be used to completely 18 | * subvert the compiler's cast system...USE WITH CAUTION! 19 | * 20 | * @author Trevor Pounds 21 | */ 22 | template 23 | T horrible_cast(F from) 24 | { 25 | /** 26 | * Abort compilation to avoid casting potentially 27 | * incompatible types due obvious differences in size. 28 | */ 29 | //mockitopp_static_assert(sizeof(T) == sizeof(F)); 30 | 31 | union 32 | { 33 | F from; 34 | T to; 35 | } u; 36 | u.from = from; 37 | return u.to; 38 | } 39 | } // namespace detail 40 | } // namespace mockitopp 41 | 42 | #endif //__MOCKITOPP_HORRIBLE_CAST_HPP__ 43 | -------------------------------------------------------------------------------- /src/akonadi/akonadimonitorinterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_MONITORINTERFACE_H 8 | #define AKONADI_MONITORINTERFACE_H 9 | 10 | #include 11 | #include 12 | 13 | namespace Akonadi { 14 | 15 | class Collection; 16 | class Item; 17 | 18 | class MonitorInterface : public QObject 19 | { 20 | Q_OBJECT 21 | public: 22 | typedef QSharedPointer Ptr; 23 | 24 | explicit MonitorInterface(QObject *parent = nullptr); 25 | virtual ~MonitorInterface(); 26 | 27 | signals: 28 | void collectionAdded(const Akonadi::Collection &collection); 29 | void collectionRemoved(const Akonadi::Collection &collection); 30 | void collectionChanged(const Akonadi::Collection &collection); 31 | void collectionSelectionChanged(const Akonadi::Collection &collection); 32 | 33 | void itemAdded(const Akonadi::Item &item); 34 | void itemRemoved(const Akonadi::Item &item); 35 | void itemChanged(const Akonadi::Item &items); 36 | void itemMoved(const Akonadi::Item &item); 37 | }; 38 | 39 | } 40 | 41 | #endif // AKONADI_MONITORINTERFACE_H 42 | -------------------------------------------------------------------------------- /src/presentation/inboxpagemodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef PRESENTATION_INBOXPAGEMODEL_H 9 | #define PRESENTATION_INBOXPAGEMODEL_H 10 | 11 | #include "presentation/pagemodel.h" 12 | 13 | #include "domain/taskqueries.h" 14 | #include "domain/taskrepository.h" 15 | 16 | namespace Presentation { 17 | 18 | class InboxPageModel : public PageModel 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit InboxPageModel(const Domain::TaskQueries::Ptr &taskQueries, 23 | const Domain::TaskRepository::Ptr &taskRepository, 24 | QObject *parent = nullptr); 25 | 26 | Domain::Task::Ptr addItem(const QString &title, const QModelIndex &parentIndex = QModelIndex()) override; 27 | void removeItem(const QModelIndex &index) override; 28 | void promoteItem(const QModelIndex &index) override; 29 | 30 | private: 31 | QAbstractItemModel *createCentralListModel() override; 32 | 33 | Domain::TaskQueries::Ptr m_taskQueries; 34 | Domain::TaskRepository::Ptr m_taskRepository; 35 | }; 36 | 37 | } 38 | 39 | #endif // PRESENTATION_INBOXPAGEMODEL_H 40 | -------------------------------------------------------------------------------- /src/akonadi/akonadistoragesettings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2012 Christian Mollekopf 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "akonadistoragesettings.h" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace Akonadi; 13 | 14 | StorageSettings::StorageSettings() 15 | : QObject() 16 | { 17 | } 18 | 19 | StorageSettings &StorageSettings::instance() 20 | { 21 | static StorageSettings i; 22 | return i; 23 | } 24 | 25 | Collection StorageSettings::defaultCollection() 26 | { 27 | KConfigGroup config(KSharedConfig::openConfig(), "General"); 28 | Collection::Id id = config.readEntry("defaultCollection", -1); 29 | return Collection(id); 30 | } 31 | 32 | void StorageSettings::setDefaultCollection(const Collection &collection) 33 | { 34 | if (defaultCollection() == collection) 35 | return; 36 | 37 | KConfigGroup config(KSharedConfig::openConfig(), "General"); 38 | config.writeEntry("defaultCollection", QString::number(collection.id())); 39 | config.sync(); 40 | emit defaultCollectionChanged(collection); 41 | } 42 | 43 | #include "moc_akonadistoragesettings.cpp" 44 | -------------------------------------------------------------------------------- /tests/features/contexts/contextdisplayfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Context content 14 | // As someone collecting tasks 15 | // I can display a context 16 | // In order to see the tasks associated to it 17 | class ContextDisplayFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Context_tasks_appear_in_the_corresponding_page() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Contexts / Errands")); 25 | And(c.I_look_at_the_central_list()); 26 | When(c.I_list_the_items()); 27 | Then(c.the_list_is({ 28 | { "display" }, 29 | { 30 | { "Buy kiwis" }, 31 | } 32 | })); 33 | } 34 | }; 35 | 36 | ZANSHIN_TEST_MAIN(ContextDisplayFeature) 37 | 38 | #include "contextdisplayfeature.moc" 39 | -------------------------------------------------------------------------------- /src/akonadi/akonaditimestampattribute.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "akonaditimestampattribute.h" 7 | 8 | #include 9 | 10 | using namespace Akonadi; 11 | 12 | TimestampAttribute::TimestampAttribute() 13 | : Attribute(), 14 | m_timestamp(0) 15 | { 16 | refreshTimestamp(); 17 | } 18 | 19 | TimestampAttribute::~TimestampAttribute() 20 | { 21 | } 22 | 23 | qint64 TimestampAttribute::timestamp() const 24 | { 25 | return m_timestamp; 26 | } 27 | 28 | void TimestampAttribute::refreshTimestamp() 29 | { 30 | m_timestamp = QDateTime::currentMSecsSinceEpoch(); 31 | } 32 | 33 | TimestampAttribute *TimestampAttribute::clone() const 34 | { 35 | auto attr = new TimestampAttribute(); 36 | attr->m_timestamp = m_timestamp; 37 | return attr; 38 | } 39 | 40 | QByteArray TimestampAttribute::type() const 41 | { 42 | return "ZanshinTimestamp"; 43 | } 44 | 45 | QByteArray TimestampAttribute::serialized() const 46 | { 47 | return QByteArray::number(m_timestamp); 48 | } 49 | 50 | void TimestampAttribute::deserialize(const QByteArray &data) 51 | { 52 | m_timestamp = data.toLongLong(); 53 | } 54 | -------------------------------------------------------------------------------- /src/presentation/alltaskspagemodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef PRESENTATION_ALLTASKSPAGEMODEL_H 9 | #define PRESENTATION_ALLTASKSPAGEMODEL_H 10 | 11 | #include "presentation/pagemodel.h" 12 | 13 | #include "domain/taskqueries.h" 14 | #include "domain/taskrepository.h" 15 | 16 | namespace Presentation { 17 | 18 | class AllTasksPageModel : public PageModel 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit AllTasksPageModel(const Domain::TaskQueries::Ptr &taskQueries, 23 | const Domain::TaskRepository::Ptr &taskRepository, 24 | QObject *parent = nullptr); 25 | 26 | Domain::Task::Ptr addItem(const QString &title, const QModelIndex &parentIndex = QModelIndex()) override; 27 | void removeItem(const QModelIndex &index) override; 28 | void promoteItem(const QModelIndex &index) override; 29 | 30 | private: 31 | QAbstractItemModel *createCentralListModel() override; 32 | 33 | Domain::TaskQueries::Ptr m_taskQueries; 34 | Domain::TaskRepository::Ptr m_taskRepository; 35 | }; 36 | 37 | } 38 | 39 | #endif // PRESENTATION_ALLTASKSPAGEMODEL_H 40 | -------------------------------------------------------------------------------- /src/presentation/workdaypagemodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Theo Vaucher 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef PRESENTATION_WORKDAYPAGEMODEL_H 9 | #define PRESENTATION_WORKDAYPAGEMODEL_H 10 | 11 | #include "presentation/pagemodel.h" 12 | 13 | #include "domain/taskqueries.h" 14 | #include "domain/taskrepository.h" 15 | 16 | namespace Presentation { 17 | 18 | class WorkdayPageModel : public PageModel 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit WorkdayPageModel(const Domain::TaskQueries::Ptr &taskQueries, 23 | const Domain::TaskRepository::Ptr &taskRepository, 24 | QObject *parent = nullptr); 25 | 26 | Domain::Task::Ptr addItem(const QString &title, const QModelIndex &parentIndex = QModelIndex()) override; 27 | void removeItem(const QModelIndex &index) override; 28 | void promoteItem(const QModelIndex &index) override; 29 | 30 | private: 31 | QAbstractItemModel *createCentralListModel() override; 32 | 33 | Domain::TaskQueries::Ptr m_taskQueries; 34 | Domain::TaskRepository::Ptr m_taskRepository; 35 | }; 36 | 37 | } 38 | 39 | #endif // PRESENTATION_WORKDAYPAGEMODEL_H 40 | -------------------------------------------------------------------------------- /src/akonadi/akonadidatasourcerepository.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "akonadidatasourcerepository.h" 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include "akonadiconfigdialog.h" 14 | 15 | using namespace Akonadi; 16 | 17 | DataSourceRepository::DataSourceRepository(const StorageInterface::Ptr &storage, 18 | const SerializerInterface::Ptr &serializer) 19 | : m_storage(storage), 20 | m_serializer(serializer) 21 | { 22 | } 23 | 24 | KJob *DataSourceRepository::update(Domain::DataSource::Ptr source) 25 | { 26 | auto collection = m_serializer->createCollectionFromDataSource(source); 27 | Q_ASSERT(collection.isValid()); 28 | return m_storage->updateCollection(collection, this); 29 | } 30 | 31 | void DataSourceRepository::showConfigDialog() 32 | { 33 | ConfigDialog dialog(qApp->activeWindow()); 34 | dialog.exec(); 35 | } 36 | 37 | void DataSourceRepository::windowNeedsDataBackend(QWidget *window) 38 | { 39 | Akonadi::ControlGui::widgetNeedsAkonadi(window); 40 | } 41 | 42 | #include "moc_akonadidatasourcerepository.cpp" 43 | -------------------------------------------------------------------------------- /src/zanshin/app/aboutdata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2011-2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "aboutdata.h" 7 | #include "../../zanshin_version.h" 8 | #include 9 | #include 10 | 11 | KAboutData App::getAboutData() 12 | { 13 | KAboutData about(QStringLiteral("zanshin"), 14 | i18n("Zanshin Tasks"), QStringLiteral(ZANSHIN_VERSION_STRING), 15 | i18n("A Getting Things Done application which aims at getting your mind like water"), 16 | KAboutLicense::GPL_V3, 17 | i18n("Copyright 2008-2016, Kevin Ottens ")); 18 | 19 | about.addAuthor(i18nc("@info:credit", "Kevin Ottens"), 20 | i18n("Lead Developer"), 21 | QStringLiteral("ervin@kde.org")); 22 | 23 | about.addAuthor(i18nc("@info:credit", "Mario Bensi"), 24 | i18n("Developer"), 25 | QStringLiteral("nef@ipsquad.net")); 26 | 27 | about.addAuthor(i18nc("@info:credit", "Franck Arrecot"), 28 | i18n("Developer"), 29 | QStringLiteral("franck.arrecot@gmail.com")); 30 | 31 | return about; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/zanshin/kontact/zanshin_part.rc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | &Go 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Main Toolbar 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/domain/taskqueries.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef DOMAIN_TASKQUERIES_H 8 | #define DOMAIN_TASKQUERIES_H 9 | 10 | #include "context.h" 11 | #include "queryresult.h" 12 | #include "task.h" 13 | #include "project.h" 14 | #include "datasource.h" 15 | 16 | namespace Domain { 17 | 18 | class TaskQueries 19 | { 20 | public: 21 | typedef QSharedPointer Ptr; 22 | 23 | TaskQueries(); 24 | virtual ~TaskQueries(); 25 | 26 | virtual QueryResult::Ptr findAll() const = 0; 27 | 28 | virtual QueryResult::Ptr findChildren(Task::Ptr task) const = 0; 29 | 30 | virtual QueryResult::Ptr findTopLevel() const = 0; 31 | 32 | virtual QueryResult::Ptr findInboxTopLevel() const = 0; 33 | 34 | virtual QueryResult::Ptr findWorkdayTopLevel() const = 0; 35 | 36 | virtual QueryResult::Ptr findContexts(Task::Ptr task) const = 0; 37 | 38 | virtual QueryResult::Ptr findProject(Task::Ptr task) const = 0; 39 | 40 | virtual QueryResult::Ptr findDataSource(Task::Ptr task) const = 0; 41 | }; 42 | 43 | } 44 | 45 | #endif // DOMAIN_TASKQUERIES_H 46 | -------------------------------------------------------------------------------- /src/zanshin/migrator/zanshincontextitemsmigrator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef ZANSHINCONTEXTITEMSMIGRATOR_H 8 | #define ZANSHINCONTEXTITEMSMIGRATOR_H 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | enum class WhichItems { TasksToConvert, OnlyContexts, AllTasks }; 15 | 16 | class ZanshinContextItemsMigrator 17 | { 18 | public: 19 | ZanshinContextItemsMigrator(bool forceMigration = false); 20 | 21 | struct FetchResult 22 | { 23 | Akonadi::Item::List items; 24 | Akonadi::Collection pickedCollection; 25 | }; 26 | FetchResult fetchAllItems(WhichItems which); 27 | Akonadi::Tag::List fetchAllTags(); 28 | 29 | void createContexts(const Akonadi::Tag::List &contextTags, const Akonadi::Collection &collection); 30 | 31 | void associateContexts(Akonadi::Item::List &items); 32 | 33 | bool migrateTags(); 34 | 35 | private: 36 | Akonadi::Storage m_storage; 37 | Akonadi::Serializer m_serializer; 38 | bool m_forceMigration; 39 | 40 | QHash m_tagUids; 41 | }; 42 | 43 | #endif // ZANSHINCONTEXTITEMSMIGRATOR_H 44 | -------------------------------------------------------------------------------- /src/domain/taskrepository.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef DOMAIN_TASKREPOSITORY_H 8 | #define DOMAIN_TASKREPOSITORY_H 9 | 10 | #include "context.h" 11 | #include "datasource.h" 12 | #include "project.h" 13 | #include "task.h" 14 | 15 | class KJob; 16 | 17 | namespace Domain { 18 | 19 | class TaskRepository 20 | { 21 | public: 22 | typedef QSharedPointer Ptr; 23 | 24 | TaskRepository(); 25 | virtual ~TaskRepository(); 26 | 27 | virtual KJob *create(Task::Ptr task) = 0; 28 | virtual KJob *createChild(Domain::Task::Ptr task, Domain::Task::Ptr parent) = 0; 29 | virtual KJob *createInProject(Task::Ptr task, Project::Ptr project) = 0; 30 | virtual KJob *createInContext(Task::Ptr task, Context::Ptr context) = 0; 31 | 32 | virtual KJob *update(Task::Ptr task) = 0; 33 | virtual KJob *remove(Task::Ptr task) = 0; 34 | 35 | virtual KJob *promoteToProject(Task::Ptr task) = 0; 36 | 37 | virtual KJob *associate(Task::Ptr parent, Task::Ptr child) = 0; 38 | virtual KJob *dissociate(Task::Ptr child) = 0; 39 | virtual KJob *dissociateAll(Task::Ptr child) = 0; 40 | }; 41 | 42 | } 43 | 44 | #endif // DOMAIN_TASKREPOSITORY_H 45 | -------------------------------------------------------------------------------- /tests/testlib/akonadidebug.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "akonadidebug.h" 8 | 9 | #include 10 | 11 | #include "akonadi/akonadicollectionfetchjobinterface.h" 12 | #include "akonadi/akonadiitemfetchjobinterface.h" 13 | 14 | void TestLib::AkonadiDebug::dumpTree(const Akonadi::StorageInterface::Ptr &storage) 15 | { 16 | auto colJob = storage->fetchCollections(Akonadi::Collection::root(), 17 | Akonadi::StorageInterface::Recursive, 18 | nullptr); 19 | colJob->kjob()->exec(); 20 | foreach (const auto &col, colJob->collections()) { 21 | qDebug() << "COL:" << col.id() << col.name() << col.remoteId(); 22 | auto itemJob = storage->fetchItems(col, nullptr); 23 | itemJob->kjob()->exec(); 24 | foreach (const auto &item, itemJob->items()) { 25 | QString summary; 26 | if (item.hasPayload()) 27 | summary = item.payload()->summary(); 28 | qDebug() << "\tITEM:" << item.id() << item.remoteId() << summary; 29 | } 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/akonadi/akonadiapplicationselectedattribute.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "akonadiapplicationselectedattribute.h" 7 | 8 | using namespace Akonadi; 9 | 10 | ApplicationSelectedAttribute::ApplicationSelectedAttribute() 11 | : Attribute(), 12 | m_selected(true) 13 | { 14 | } 15 | 16 | ApplicationSelectedAttribute::~ApplicationSelectedAttribute() 17 | { 18 | } 19 | 20 | void ApplicationSelectedAttribute::setSelected(bool selected) 21 | { 22 | m_selected = selected; 23 | } 24 | 25 | bool ApplicationSelectedAttribute::isSelected() const 26 | { 27 | return m_selected; 28 | } 29 | 30 | ApplicationSelectedAttribute *ApplicationSelectedAttribute::clone() const 31 | { 32 | auto attr = new ApplicationSelectedAttribute(); 33 | attr->m_selected = m_selected; 34 | return attr; 35 | } 36 | 37 | QByteArray ApplicationSelectedAttribute::type() const 38 | { 39 | return "ZanshinSelected"; 40 | } 41 | 42 | QByteArray ApplicationSelectedAttribute::serialized() const 43 | { 44 | return m_selected ? "true" : "false"; 45 | } 46 | 47 | void ApplicationSelectedAttribute::deserialize(const QByteArray &data) 48 | { 49 | m_selected = (data == "true"); 50 | } 51 | -------------------------------------------------------------------------------- /src/domain/queryresultinterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef DOMAIN_QUERYRESULTINTERFACE_H 9 | #define DOMAIN_QUERYRESULTINTERFACE_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Domain { 16 | 17 | template 18 | class QueryResultInterface 19 | { 20 | public: 21 | typedef QSharedPointer> Ptr; 22 | typedef QWeakPointer> WeakPtr; 23 | typedef std::function ChangeHandler; 24 | 25 | virtual ~QueryResultInterface() {} 26 | 27 | virtual QList data() const = 0; 28 | 29 | virtual void addPreInsertHandler(const ChangeHandler &handler) = 0; 30 | virtual void addPostInsertHandler(const ChangeHandler &handler) = 0; 31 | virtual void addPreRemoveHandler(const ChangeHandler &handler) = 0; 32 | virtual void addPostRemoveHandler(const ChangeHandler &handler) = 0; 33 | virtual void addPreReplaceHandler(const ChangeHandler &handler) = 0; 34 | virtual void addPostReplaceHandler(const ChangeHandler &handler) = 0; 35 | }; 36 | 37 | } 38 | 39 | #endif // DOMAIN_QUERYRESULTINTERFACE_H 40 | -------------------------------------------------------------------------------- /src/akonadi/akonadiprojectrepository.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_PROJECTREPOSITORY_H 8 | #define AKONADI_PROJECTREPOSITORY_H 9 | 10 | #include "domain/projectrepository.h" 11 | 12 | #include "akonadi/akonadiserializerinterface.h" 13 | #include "akonadi/akonadistorageinterface.h" 14 | 15 | namespace Akonadi { 16 | 17 | class ProjectRepository : public QObject, public Domain::ProjectRepository 18 | { 19 | Q_OBJECT 20 | public: 21 | typedef QSharedPointer Ptr; 22 | 23 | ProjectRepository(const StorageInterface::Ptr &storage, 24 | const SerializerInterface::Ptr &serializer); 25 | 26 | KJob *create(Domain::Project::Ptr project, Domain::DataSource::Ptr source) override; 27 | KJob *update(Domain::Project::Ptr project) override; 28 | KJob *remove(Domain::Project::Ptr project) override; 29 | 30 | KJob *associate(Domain::Project::Ptr parent, Domain::Task::Ptr child) override; 31 | KJob *dissociate(Domain::Task::Ptr child) override; 32 | 33 | private: 34 | StorageInterface::Ptr m_storage; 35 | SerializerInterface::Ptr m_serializer; 36 | }; 37 | 38 | } 39 | 40 | #endif // AKONADI_PROJECTREPOSITORY_H 41 | -------------------------------------------------------------------------------- /tests/units/akonadi/akonadistoragetest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014-2015 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "akonadi/akonadimonitorimpl.h" 13 | #include "akonadi/akonadistorage.h" 14 | 15 | class AkonadiStorageTest : public Testlib::AkonadiStorageTestBase 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit AkonadiStorageTest(QObject *parent = nullptr) 20 | : AkonadiStorageTestBase(parent) 21 | { 22 | } 23 | 24 | Akonadi::StorageInterface::Ptr createStorage() override 25 | { 26 | return Akonadi::StorageInterface::Ptr(new Akonadi::Storage); 27 | } 28 | 29 | Akonadi::MonitorInterface::Ptr createMonitor() override 30 | { 31 | Akonadi::MonitorInterface::Ptr ptr(new Akonadi::MonitorImpl); 32 | QTest::qWait(10); // give Monitor time to upload settings 33 | return ptr; 34 | } 35 | 36 | private slots: 37 | void initTestCase() 38 | { 39 | QVERIFY(TestLib::TestSafety::checkTestIsIsolated()); 40 | } 41 | }; 42 | 43 | ZANSHIN_TEST_MAIN(AkonadiStorageTest) 44 | 45 | #include "akonadistoragetest.moc" 46 | -------------------------------------------------------------------------------- /tests/features/workday/workdaydisplaycompletedfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Display completed tasks in Workday list 14 | // As someone using tasks 15 | // I can display the Workday list 16 | // In order to know which tasks I’ve completed today (e.g. if done date is today) 17 | class WorkdayDisplayCompletedFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void The_tasks_that_have_been_done_today_appear_in_the_Workday_list() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Inbox")); 25 | And(c.there_is_an_item_in_the_central_list("Buy rutabagas")); 26 | When(c.I_check_the_item()); 27 | And(c.I_display_the_page("Workday")); 28 | And(c.I_look_at_the_central_list()); 29 | And(c.I_list_the_items()); 30 | Then(c.the_list_contains("Buy rutabagas")); 31 | } 32 | }; 33 | 34 | ZANSHIN_TEST_MAIN(WorkdayDisplayCompletedFeature) 35 | 36 | #include "workdaydisplaycompletedfeature.moc" 37 | -------------------------------------------------------------------------------- /src/presentation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(presentation STATIC) 2 | 3 | target_sources(presentation PRIVATE 4 | applicationmodel.cpp 5 | editormodel.cpp 6 | availablepagesmodel.cpp 7 | availablepagessortfilterproxymodel.cpp 8 | availablesourcesmodel.cpp 9 | contextpagemodel.cpp 10 | errorhandler.cpp 11 | errorhandlingmodelbase.cpp 12 | inboxpagemodel.cpp 13 | metatypes.cpp 14 | pagemodel.cpp 15 | projectpagemodel.cpp 16 | alltaskspagemodel.cpp 17 | querytreemodelbase.cpp 18 | runningtaskmodelinterface.cpp 19 | runningtaskmodel.cpp 20 | taskfilterproxymodel.cpp 21 | workdaypagemodel.cpp 22 | 23 | applicationmodel.h 24 | editormodel.h 25 | availablepagesmodel.h 26 | availablepagessortfilterproxymodel.h 27 | availablesourcesmodel.h 28 | contextpagemodel.h 29 | errorhandler.h 30 | errorhandlingmodelbase.h 31 | inboxpagemodel.h 32 | metatypes.h 33 | pagemodel.h 34 | projectpagemodel.h 35 | alltaskspagemodel.h 36 | querytreemodelbase.h 37 | runningtaskmodelinterface.h 38 | runningtaskmodel.h 39 | taskfilterproxymodel.h 40 | workdaypagemodel.h 41 | ) 42 | 43 | set_property(TARGET presentation PROPERTY POSITION_INDEPENDENT_CODE ON) 44 | 45 | target_link_libraries(presentation Qt::Core Qt::Gui KF6::I18n domain utils) 46 | -------------------------------------------------------------------------------- /src/presentation/runningtaskmodelinterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2017 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef PRESENTATION_RUNNINGTASKMODELINTERFACE_H 8 | #define PRESENTATION_RUNNINGTASKMODELINTERFACE_H 9 | 10 | #include 11 | 12 | #include "domain/task.h" 13 | 14 | #include "errorhandlingmodelbase.h" 15 | 16 | namespace Presentation { 17 | 18 | class RunningTaskModelInterface : public QObject, public ErrorHandlingModelBase 19 | { 20 | Q_OBJECT 21 | Q_PROPERTY(Domain::Task::Ptr runningTask READ runningTask WRITE setRunningTask NOTIFY runningTaskChanged) 22 | public: 23 | typedef QSharedPointer Ptr; 24 | 25 | explicit RunningTaskModelInterface(QObject *parent = nullptr); 26 | ~RunningTaskModelInterface(); 27 | 28 | virtual Domain::Task::Ptr runningTask() const = 0; 29 | virtual void setRunningTask(const Domain::Task::Ptr &runningTask) = 0; 30 | 31 | virtual void taskDeleted(const Domain::Task::Ptr &task) = 0; 32 | 33 | signals: 34 | void runningTaskChanged(const Domain::Task::Ptr &task); 35 | 36 | public slots: 37 | virtual void stopTask() = 0; 38 | virtual void doneTask() = 0; 39 | }; 40 | 41 | } 42 | 43 | #endif // PRESENTATION_RUNNINGTASKMODEL_H 44 | -------------------------------------------------------------------------------- /tests/features/contexts/contexttaskaddfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Task creation from a context 14 | // As someone collecting tasks 15 | // I can add a task directly associated to a context 16 | // In order to give my tasks some semantic 17 | class ContextTaskAddFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Task_added_from_a_context_appear_in_its_list() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Contexts / Online")); 25 | When(c.I_add_a_task("Checking mail")); 26 | And(c.I_look_at_the_central_list()); 27 | When(c.I_list_the_items()); 28 | Then(c.the_list_is({ 29 | { "display" }, 30 | { 31 | { "Checking mail" }, 32 | } 33 | })); 34 | } 35 | }; 36 | 37 | ZANSHIN_TEST_MAIN(ContextTaskAddFeature) 38 | 39 | #include "contexttaskaddfeature.moc" 40 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/stubbing/action.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_ACTION_HPP__ 7 | #define __MOCKITOPP_ACTION_HPP__ 8 | 9 | namespace mockitopp 10 | { 11 | namespace detail 12 | { 13 | template 14 | struct action 15 | { 16 | virtual R invoke() = 0; 17 | 18 | virtual ~action() {} 19 | }; 20 | 21 | template 22 | struct returnable_action : public action 23 | { 24 | R _returnable; 25 | 26 | returnable_action(const R& returnable) 27 | : _returnable(returnable) 28 | {} 29 | 30 | R invoke() override { return _returnable; } 31 | }; 32 | 33 | template <> 34 | struct returnable_action : public action 35 | { 36 | void invoke() override {} 37 | }; 38 | 39 | template 40 | struct throwable_action : public action 41 | { 42 | T _throwable; 43 | 44 | throwable_action(const T& throwable) 45 | : _throwable(throwable) 46 | {} 47 | 48 | R invoke() override { throw _throwable; } 49 | }; 50 | } // namespace detail 51 | } // namespace mockitopp 52 | 53 | #endif //__MOCKITOPP_ACTION_HPP__ 54 | -------------------------------------------------------------------------------- /src/presentation/taskfilterproxymodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef PRESENTATION_TASKFILTERPROXYMODEL_H 9 | #define PRESENTATION_TASKFILTERPROXYMODEL_H 10 | 11 | #include 12 | 13 | namespace Presentation { 14 | 15 | class TaskFilterProxyModel : public QSortFilterProxyModel 16 | { 17 | Q_OBJECT 18 | public: 19 | enum SortType { 20 | TitleSort = 0, 21 | DateSort 22 | }; 23 | Q_ENUM(SortType) 24 | 25 | explicit TaskFilterProxyModel(QObject *parent = nullptr); 26 | 27 | SortType sortType() const; 28 | void setSortType(SortType type); 29 | 30 | void setSortOrder(Qt::SortOrder order); 31 | 32 | bool showDoneTasks() const; 33 | void setShowDoneTasks(bool show); 34 | 35 | bool showFutureTasks() const; 36 | void setShowFutureTasks(bool show); 37 | 38 | protected: 39 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; 40 | bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; 41 | 42 | private: 43 | SortType m_sortType; 44 | bool m_showDone; 45 | bool m_showFuture; 46 | }; 47 | 48 | } 49 | 50 | #endif // PRESENTATION_TASKFILTERPROXYMODEL_H 51 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers/base/is_not.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_MATCHER_NOT_HPP__ 7 | #define __MOCKITOPP_MATCHER_NOT_HPP__ 8 | 9 | #include 10 | 11 | namespace mockitopp 12 | { 13 | namespace matcher 14 | { 15 | namespace detail 16 | { 17 | template 18 | struct NotT : public Matcher 19 | { 20 | NotT(const Matcher& matcher) 21 | : matcher_(matcher.clone()) 22 | {} 23 | 24 | virtual ~NotT() 25 | { delete matcher_; } 26 | 27 | virtual Matcher* clone() const 28 | { return new NotT(*matcher_); } 29 | 30 | virtual bool operator== (typename mockitopp::detail::tr1::add_reference::type>::type rhs) const 31 | { return !(*matcher_ == rhs); } 32 | 33 | private: 34 | 35 | Matcher* matcher_; 36 | }; 37 | } // namespace detail 38 | 39 | template 40 | detail::NotT is_not(const Matcher& matcher) 41 | { return detail::NotT(matcher); } 42 | } // namespace matcher 43 | } // namespace mockitopp 44 | 45 | #endif //__MOCKITOPP_MATCHER_EQ_HPP__ 46 | -------------------------------------------------------------------------------- /tests/features/projects/projectdisplayfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Project content 14 | // As someone collecting tasks 15 | // I can display a project 16 | // In order to see the artifacts associated to it 17 | class ProjectDisplayFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Project_tasks_appear_in_the_corresponding_page() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Projects / TestData » Calendar1 / Read List")); 25 | And(c.I_look_at_the_central_list()); 26 | When(c.I_list_the_items()); 27 | Then(c.the_list_is({ 28 | { "display" }, 29 | { 30 | { "\"Clean Code\" by Robert C Martin" }, 31 | { "\"Domain Driven Design\" by Eric Evans" }, 32 | } 33 | })); 34 | } 35 | }; 36 | 37 | ZANSHIN_TEST_MAIN(ProjectDisplayFeature) 38 | 39 | #include "projectdisplayfeature.moc" 40 | -------------------------------------------------------------------------------- /src/zanshin/migrator/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-FileCopyrightText: 2014 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include "zanshin021migrator.h" 11 | #include "zanshincontextitemsmigrator.h" 12 | 13 | int main(int argc, char **argv) 14 | { 15 | QApplication app(argc, argv); 16 | 17 | // Qt5 TODO use QCommandLineParser 18 | const bool forceTags = (argc > 1 && QByteArray(argv[1]) == "--forceMigratingTags"); 19 | 20 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("zanshin-migratorrc")); 21 | KConfigGroup group = config->group("Migrations"); 22 | if (!group.readEntry("Migrated021Projects", false)) { 23 | Zanshin021Migrator migrator; 24 | if (!migrator.migrateProjects()) { 25 | return 1; 26 | } 27 | group.writeEntry("Migrated021Projects", true); 28 | } 29 | 30 | if (forceTags || !group.readEntry("MigratedTags", false)) { 31 | ZanshinContextItemsMigrator migrator(forceTags); 32 | if (!migrator.migrateTags()) { 33 | return 1; 34 | } 35 | group.writeEntry("MigratedTags", true); 36 | } 37 | 38 | config->sync(); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /tests/testlib/gentodo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef TESTLIB_GENTODO_H 8 | #define TESTLIB_GENTODO_H 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace Testlib { 15 | 16 | class GenTodo 17 | { 18 | public: 19 | explicit GenTodo(const Akonadi::Item &item = Akonadi::Item()); 20 | 21 | operator Akonadi::Item(); 22 | 23 | GenTodo &withId(Akonadi::Item::Id id); 24 | GenTodo &withParent(Akonadi::Collection::Id id); 25 | GenTodo &withContexts(const QStringList &contextUids); 26 | GenTodo &asProject(bool value = true); 27 | GenTodo &asContext(bool value = true); 28 | GenTodo &withUid(const QString &uid); 29 | GenTodo &withParentUid(const QString &uid); 30 | GenTodo &withTitle(const QString &title); 31 | GenTodo &withText(const QString &text); 32 | GenTodo &done(bool value = true); 33 | GenTodo &withDoneDate(const QString &date); 34 | GenTodo &withDoneDate(const QDate &date); 35 | GenTodo &withStartDate(const QString &date); 36 | GenTodo &withStartDate(const QDate &date); 37 | GenTodo &withDueDate(const QString &date); 38 | GenTodo &withDueDate(const QDate &date); 39 | 40 | private: 41 | Akonadi::Item m_item; 42 | }; 43 | 44 | } 45 | 46 | #endif // TESTLIB_GENTODO_H 47 | -------------------------------------------------------------------------------- /src/widgets/nameanddatasourcedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef WIDGETS_NAMEANDDATASOURCEDIALOG_H 9 | #define WIDGETS_NAMEANDDATASOURCEDIALOG_H 10 | 11 | #include 12 | 13 | #include "widgets/nameanddatasourcedialoginterface.h" 14 | 15 | class QModelIndex; 16 | class KDescendantsProxyModel; 17 | 18 | namespace Ui { 19 | class NameAndDataSourceDialog; 20 | } 21 | 22 | namespace Widgets { 23 | 24 | class NameAndDataSourceDialog : public QDialog, public NameAndDataSourceDialogInterface 25 | { 26 | Q_OBJECT 27 | public: 28 | explicit NameAndDataSourceDialog(QWidget *parent = nullptr); 29 | ~NameAndDataSourceDialog(); 30 | 31 | int exec() override; 32 | 33 | void accept() override; 34 | 35 | void setWindowTitle(const QString &title) override; 36 | void setDataSourcesModel(QAbstractItemModel *model) override; 37 | 38 | QString name() const override; 39 | Domain::DataSource::Ptr dataSource() const override; 40 | 41 | private slots: 42 | void onUserInputChanged(); 43 | 44 | private: 45 | Ui::NameAndDataSourceDialog *ui; 46 | KDescendantsProxyModel *m_flattenProxy; 47 | QString m_name; 48 | Domain::DataSource::Ptr m_source; 49 | }; 50 | 51 | } 52 | 53 | #endif // WIDGETS_NAMEANDDATASOURCEDIALOG_H 54 | -------------------------------------------------------------------------------- /src/widgets/datasourcedelegate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Christian Mollekopf 3 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include "datasourcedelegate.h" 9 | 10 | #include 11 | #include 12 | 13 | #include "presentation/querytreemodel.h" 14 | 15 | using namespace Widgets; 16 | 17 | const int DELEGATE_HEIGHT = 16; 18 | 19 | DataSourceDelegate::DataSourceDelegate(QObject *parent) 20 | : QStyledItemDelegate(parent) 21 | { 22 | } 23 | 24 | void DataSourceDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const 25 | { 26 | Q_ASSERT(index.isValid()); 27 | 28 | const auto isDefault = index.data(Presentation::QueryTreeModelBase::IsDefaultRole).toBool(); 29 | 30 | QStyleOptionViewItem option = opt; 31 | initStyleOption(&option, index); 32 | option.font.setBold(isDefault); 33 | 34 | QStyledItemDelegate::paint(painter, option, index); 35 | } 36 | 37 | QSize DataSourceDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 38 | { 39 | QSize size = QStyledItemDelegate::sizeHint(option, index); 40 | // Make sure we got a constant height 41 | size.setHeight(DELEGATE_HEIGHT + 4); 42 | return size; 43 | } 44 | 45 | #include "moc_datasourcedelegate.cpp" 46 | -------------------------------------------------------------------------------- /src/widgets/quickselectdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-FileCopyrightText: 2015 Franck Arrecot 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #ifndef WIDGETS_QUICKSELECTDIALOG_H 9 | #define WIDGETS_QUICKSELECTDIALOG_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "presentation/metatypes.h" 16 | 17 | #include "widgets/quickselectdialoginterface.h" 18 | 19 | class QAbstractItemModel; 20 | class QLabel; 21 | class QTreeView; 22 | 23 | class QSortFilterProxyModel; 24 | 25 | namespace Widgets { 26 | 27 | class QuickSelectDialog : public QDialog, public QuickSelectDialogInterface 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit QuickSelectDialog(QWidget *parent = nullptr); 32 | 33 | int exec() override; 34 | 35 | QPersistentModelIndex selectedIndex() const override; 36 | void setModel(QAbstractItemModel *model) override; 37 | 38 | private slots: 39 | void applyFilterChanged(const QString &textFilter); 40 | bool eventFilter(QObject *object, QEvent *ev) override; 41 | 42 | private: 43 | QString m_filter; 44 | QAbstractItemModel *m_model; 45 | QSortFilterProxyModel *m_filterProxyModel; 46 | 47 | QLabel *m_label; 48 | QTreeView *m_tree; 49 | }; 50 | 51 | } 52 | 53 | #endif // WIDGETS_QUICKSELECTDIALOG_H 54 | -------------------------------------------------------------------------------- /tests/features/projects/projecttaskaddfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Task creation from a project 14 | // As someone collecting tasks 15 | // I can add a task directly inside a project 16 | // In order to organize my tasks 17 | class ProjectTaskAddFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Task_added_from_a_project_appear_in_its_list() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Projects / TestData » Calendar1 » Calendar2 / Backlog")); 25 | When(c.I_add_a_task("Buy a cake")); 26 | And(c.I_add_a_task("Buy a present")); 27 | And(c.I_look_at_the_central_list()); 28 | When(c.I_list_the_items()); 29 | Then(c.the_list_is({ 30 | { "display" }, 31 | { 32 | { "Buy a cake" }, 33 | { "Buy a present" }, 34 | } 35 | })); 36 | } 37 | }; 38 | 39 | ZANSHIN_TEST_MAIN(ProjectTaskAddFeature) 40 | 41 | #include "projecttaskaddfeature.moc" 42 | -------------------------------------------------------------------------------- /src/utils/compositejob.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Mario Bensi 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | #include "compositejob.h" 7 | 8 | using namespace Utils; 9 | 10 | CompositeJob::CompositeJob(QObject *parent) 11 | : KCompositeJob(parent) 12 | { 13 | 14 | } 15 | 16 | void CompositeJob::start() 17 | { 18 | if (hasSubjobs()) { 19 | subjobs().first()->start(); 20 | } else { 21 | emitResult(); 22 | } 23 | } 24 | 25 | bool CompositeJob::install(KJob *job, const JobHandler::ResultHandlerWithJob &handler) 26 | { 27 | if (!addSubjob(job)) 28 | return false; 29 | 30 | JobHandler::install(job, handler); 31 | return true; 32 | } 33 | 34 | bool CompositeJob::install(KJob *job, const JobHandler::ResultHandler &handler) 35 | { 36 | JobHandler::install(job, handler); 37 | 38 | if (!addSubjob(job)) 39 | return false; 40 | 41 | return true; 42 | } 43 | 44 | void CompositeJob::emitError(const QString &errorText) 45 | { 46 | setError(KJob::UserDefinedError); 47 | setErrorText(errorText); 48 | emitResult(); 49 | } 50 | 51 | void CompositeJob::slotResult(KJob *job) 52 | { 53 | if (job->error()) { 54 | KCompositeJob::slotResult(job); 55 | } else { 56 | removeSubjob(job); 57 | if (!hasSubjobs()) 58 | emitResult(); 59 | } 60 | } 61 | 62 | #include "moc_compositejob.cpp" 63 | -------------------------------------------------------------------------------- /src/widgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(widgets STATIC) 2 | 3 | ki18n_wrap_ui(widgets_SRCS 4 | editorview.ui 5 | filterwidget.ui 6 | nameanddatasourcedialog.ui 7 | ) 8 | 9 | 10 | target_sources(widgets PRIVATE 11 | ${widgets_SRCS} 12 | applicationcomponents.cpp 13 | availablepagesview.cpp 14 | availablesourcesview.cpp 15 | datasourcedelegate.cpp 16 | editorview.cpp 17 | filterwidget.cpp 18 | itemdelegate.cpp 19 | messagebox.cpp 20 | messageboxinterface.cpp 21 | nameanddatasourcedialog.cpp 22 | nameanddatasourcedialoginterface.cpp 23 | pageview.cpp 24 | pageviewerrorhandler.cpp 25 | runningtaskwidget.cpp 26 | quickselectdialog.cpp 27 | quickselectdialoginterface.cpp 28 | 29 | applicationcomponents.h 30 | availablepagesview.h 31 | availablesourcesview.h 32 | datasourcedelegate.h 33 | editorview.h 34 | filterwidget.h 35 | itemdelegate.h 36 | messagebox.h 37 | messageboxinterface.h 38 | nameanddatasourcedialog.h 39 | nameanddatasourcedialoginterface.h 40 | pageview.h 41 | pageviewerrorhandler.h 42 | runningtaskwidget.h 43 | quickselectdialog.h 44 | quickselectdialoginterface.h 45 | ) 46 | 47 | set_property(TARGET widgets PROPERTY POSITION_INDEPENDENT_CODE ON) 48 | 49 | target_link_libraries(widgets 50 | Qt::Widgets 51 | presentation 52 | KF6::ConfigCore 53 | KF6::ItemModels 54 | KF6::WidgetsAddons 55 | KF6::WindowSystem 56 | ) 57 | -------------------------------------------------------------------------------- /tests/units/testlib/akonadifakestoragetest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include "testlib/akonadifakedata.h" 12 | #include "testlib/akonadifakedataxmlloader.h" 13 | #include "testlib/akonadifakemonitor.h" 14 | #include "testlib/akonadifakestorage.h" 15 | #include "testlib/monitorspy.h" 16 | 17 | 18 | class AkonadiFakeStorageTest : public Testlib::AkonadiStorageTestBase 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit AkonadiFakeStorageTest(QObject *parent = nullptr) 23 | : Testlib::AkonadiStorageTestBase(parent) 24 | { 25 | MonitorSpy::setExpirationDelay(100); 26 | auto loader = Testlib::AkonadiFakeDataXmlLoader(&m_data); 27 | loader.load(SOURCE_DIR "/../akonadi/testenv/data/testdata.xml"); 28 | } 29 | 30 | Akonadi::StorageInterface::Ptr createStorage() override 31 | { 32 | return Akonadi::StorageInterface::Ptr(m_data.createStorage()); 33 | } 34 | 35 | Akonadi::MonitorInterface::Ptr createMonitor() override 36 | { 37 | return Akonadi::MonitorInterface::Ptr(m_data.createMonitor()); 38 | } 39 | 40 | private: 41 | Testlib::AkonadiFakeData m_data; 42 | }; 43 | 44 | ZANSHIN_TEST_MAIN(AkonadiFakeStorageTest) 45 | 46 | #include "akonadifakestoragetest.moc" 47 | -------------------------------------------------------------------------------- /tests/features/datasource/datasourcelistingfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Data sources listing 14 | // As an advanced user 15 | // I can list sources 16 | // In order to list and store tasks 17 | class DatasourceListingFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void All_task_sources_appear_in_the_list() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_available_data_sources()); 25 | When(c.I_list_the_items()); 26 | Then(c.the_list_is({ 27 | { "display", "icon" }, 28 | { 29 | { "TestData", "folder" }, 30 | { "TestData / Calendar1", "view-calendar-tasks" }, 31 | { "TestData / Calendar1 / Calendar2", "view-calendar-tasks" }, 32 | { "TestData / Calendar1 / Calendar2 / Calendar3", "folder" }, 33 | } 34 | })); 35 | } 36 | }; 37 | 38 | ZANSHIN_TEST_MAIN(DatasourceListingFeature) 39 | 40 | #include "datasourcelistingfeature.moc" 41 | -------------------------------------------------------------------------------- /src/akonadi/akonadicontextrepository.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-FileCopyrightText: 2014 Franck Arrecot 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #ifndef AKONADICONTEXTREPOSITORY_H 9 | #define AKONADICONTEXTREPOSITORY_H 10 | 11 | #include "domain/contextrepository.h" 12 | 13 | #include "akonadi/akonadiserializerinterface.h" 14 | #include "akonadi/akonadistorageinterface.h" 15 | 16 | namespace Akonadi { 17 | 18 | class ContextRepository : public QObject, public Domain::ContextRepository 19 | { 20 | Q_OBJECT 21 | public: 22 | typedef QSharedPointer Ptr; 23 | 24 | ContextRepository(const StorageInterface::Ptr &storage, 25 | const SerializerInterface::Ptr &serializer); 26 | 27 | KJob *create(Domain::Context::Ptr context, Domain::DataSource::Ptr source) override; 28 | KJob *update(Domain::Context::Ptr context) override; 29 | KJob *remove(Domain::Context::Ptr context) override; 30 | 31 | KJob *associate(Domain::Context::Ptr context, Domain::Task::Ptr child) override; 32 | KJob *dissociate(Domain::Context::Ptr context, Domain::Task::Ptr child) override; 33 | KJob *dissociateAll(Domain::Task::Ptr child) override; 34 | 35 | private: 36 | StorageInterface::Ptr m_storage; 37 | SerializerInterface::Ptr m_serializer; 38 | }; 39 | 40 | } 41 | 42 | #endif // AKONADICONTEXTREPOSITORY_H 43 | -------------------------------------------------------------------------------- /tests/features/workday/workdaydisplayfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Workday content 14 | // As someone using tasks 15 | // I can display the Workday list 16 | // In order to know which tasks should be completed today (e.g. if start date or due date is today or in the past) 17 | class WorkdayDisplayFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void The_tasks_that_need_to_be_done_today_appear_in_the_Workday_list() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Workday")); 25 | And(c.I_look_at_the_central_list()); 26 | When(c.I_list_the_items()); 27 | Then(c.the_list_is({ 28 | { "display" }, 29 | { 30 | { "\"Clean Code\" by Robert C Martin" }, 31 | { "Buy kiwis" }, 32 | { "Buy pears" }, 33 | { "Errands" }, 34 | } 35 | })); 36 | } 37 | }; 38 | 39 | ZANSHIN_TEST_MAIN(WorkdayDisplayFeature) 40 | 41 | #include "workdaydisplayfeature.moc" 42 | -------------------------------------------------------------------------------- /tests/features/datasource/datasourcedefaultsettingsfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Default data source 14 | // As an advanced user 15 | // I can choose the default data source 16 | // In order to quickly store tasks 17 | class DatasourceDefaultSettingsFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Have_a_default_data_source_for_tasks_in_the_inbox() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_available_data_sources()); 25 | When(c.I_change_the_setting("defaultCollection", 7)); 26 | Then(c.the_default_data_source_is("TestData / Calendar1 / Calendar2")); 27 | } 28 | 29 | void Change_the_default_data_source_for_tasks_in_the_inbox() 30 | { 31 | ZanshinContext c; 32 | Given(c.I_display_the_available_data_sources()); 33 | And(c.I_change_the_setting("defaultCollection", 42)); 34 | When(c.I_change_the_default_data_source("TestData / Calendar1 / Calendar2")); 35 | Then(c.the_setting_is("defaultCollection", 7)); 36 | } 37 | }; 38 | 39 | ZANSHIN_TEST_MAIN(DatasourceDefaultSettingsFeature) 40 | 41 | #include "datasourcedefaultsettingsfeature.moc" 42 | -------------------------------------------------------------------------------- /tests/testlib/akonadifakemonitor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "akonadifakemonitor.h" 8 | 9 | using namespace Testlib; 10 | 11 | AkonadiFakeMonitor::AkonadiFakeMonitor(QObject *parent) 12 | : Akonadi::MonitorInterface(parent) 13 | { 14 | } 15 | 16 | void AkonadiFakeMonitor::addCollection(const Akonadi::Collection &collection) 17 | { 18 | emit collectionAdded(collection); 19 | } 20 | 21 | void AkonadiFakeMonitor::removeCollection(const Akonadi::Collection &collection) 22 | { 23 | emit collectionRemoved(collection); 24 | } 25 | 26 | void AkonadiFakeMonitor::changeCollection(const Akonadi::Collection &collection) 27 | { 28 | emit collectionChanged(collection); 29 | } 30 | 31 | void AkonadiFakeMonitor::changeCollectionSelection(const Akonadi::Collection &collection) 32 | { 33 | emit collectionSelectionChanged(collection); 34 | } 35 | 36 | void AkonadiFakeMonitor::addItem(const Akonadi::Item &item) 37 | { 38 | emit itemAdded(item); 39 | } 40 | 41 | void AkonadiFakeMonitor::removeItem(const Akonadi::Item &item) 42 | { 43 | emit itemRemoved(item); 44 | } 45 | 46 | void AkonadiFakeMonitor::changeItem(const Akonadi::Item &item) 47 | { 48 | emit itemChanged(item); 49 | } 50 | 51 | void AkonadiFakeMonitor::moveItem(const Akonadi::Item &item) 52 | { 53 | emit itemMoved(item); 54 | } 55 | 56 | 57 | 58 | #include "moc_akonadifakemonitor.cpp" 59 | -------------------------------------------------------------------------------- /src/zanshin/app/zanshinui.rc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | &Go 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | &Panels 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Main Toolbar 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/presentation/runningtaskmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016-2017 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef PRESENTATION_RUNNINGTASKMODEL_H 8 | #define PRESENTATION_RUNNINGTASKMODEL_H 9 | 10 | #include "domain/taskqueries.h" 11 | #include "domain/taskrepository.h" 12 | 13 | #include "runningtaskmodelinterface.h" 14 | 15 | namespace Presentation { 16 | 17 | class RunningTaskModel : public RunningTaskModelInterface 18 | { 19 | Q_OBJECT 20 | public: 21 | typedef QSharedPointer Ptr; 22 | 23 | explicit RunningTaskModel(const Domain::TaskQueries::Ptr &taskQueries, 24 | const Domain::TaskRepository::Ptr &taskRepository, 25 | QObject *parent = nullptr); 26 | ~RunningTaskModel(); 27 | 28 | Domain::Task::Ptr runningTask() const override; 29 | void setRunningTask(const Domain::Task::Ptr &runningTask) override; 30 | 31 | void taskDeleted(const Domain::Task::Ptr &task) override; 32 | 33 | public slots: 34 | void stopTask() override; 35 | void doneTask() override; 36 | 37 | private: 38 | void taskTitleChanged(const QString &title); 39 | 40 | Domain::Task::Ptr m_runningTask; 41 | 42 | Domain::QueryResult::Ptr m_taskList; 43 | Domain::TaskQueries::Ptr m_queries; 44 | Domain::TaskRepository::Ptr m_taskRepository; 45 | }; 46 | 47 | } 48 | 49 | #endif // PRESENTATION_RUNNINGTASKMODEL_H 50 | -------------------------------------------------------------------------------- /tests/features/editing/removingtaskfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Removing tasks 14 | // As a task junkie 15 | // I can delete a task so it is removed 16 | // In order to clean up the old junk I accumulated 17 | class RemovingTaskFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Removing_a_simple_task_from_a_page_data() 22 | { 23 | QTest::addColumn("page"); 24 | QTest::addColumn("title"); 25 | 26 | QTest::newRow("inbox") << "Inbox" << "Buy cheese"; 27 | QTest::newRow("readlist") << "Projects / TestData » Calendar1 / Read List" << "\"Domain Driven Design\" by Eric Evans"; 28 | } 29 | 30 | void Removing_a_simple_task_from_a_page() 31 | { 32 | QFETCH(QString, page); 33 | QFETCH(QString, title); 34 | 35 | ZanshinContext c; 36 | Given(c.I_display_the_page(page)); 37 | And(c.there_is_an_item_in_the_central_list(title)); 38 | When(c.I_remove_the_item()); 39 | And(c.I_list_the_items()); 40 | Then(c.the_list_does_not_contain(title)); 41 | } 42 | }; 43 | 44 | ZANSHIN_TEST_MAIN(RemovingTaskFeature) 45 | 46 | #include "removingtaskfeature.moc" 47 | -------------------------------------------------------------------------------- /tests/testlib/fakejob.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "fakejob.h" 8 | 9 | #include 10 | 11 | FakeJob::FakeJob(QObject *parent) 12 | : KJob(parent), 13 | m_timer(new QTimer(this)), 14 | m_done(false), 15 | m_launched(false), 16 | m_errorCode(KJob::NoError) 17 | { 18 | m_timer->setTimerType(Qt::PreciseTimer); 19 | m_timer->setSingleShot(true); 20 | connect(m_timer, &QTimer::timeout, this, &FakeJob::onTimeout); 21 | } 22 | 23 | void FakeJob::setExpectedError(int errorCode, const QString &errorText) 24 | { 25 | m_errorCode = errorCode; 26 | m_errorText = errorText; 27 | } 28 | 29 | void FakeJob::start() 30 | { 31 | if (!m_launched) { 32 | m_launched = true; 33 | m_timer->start(DURATION); 34 | } 35 | } 36 | 37 | void FakeJob::onTimeout() 38 | { 39 | if (m_errorCode == KJob::NoError) 40 | m_done = true; 41 | 42 | setError(m_errorCode); 43 | setErrorText(m_errorText); 44 | emitResult(); 45 | } 46 | 47 | bool FakeJob::isDone() const 48 | { 49 | return m_done; 50 | } 51 | 52 | int FakeJob::expectedError() const 53 | { 54 | return m_errorCode; 55 | } 56 | 57 | QString FakeJob::expectedErrorText() const 58 | { 59 | return m_errorText; 60 | } 61 | 62 | bool FakeJob::doKill() 63 | { 64 | setError(KJob::KilledJobError); 65 | emitResult(); 66 | return true; 67 | } 68 | 69 | #include "moc_fakejob.cpp" 70 | -------------------------------------------------------------------------------- /src/widgets/runningtaskwidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2016 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef RUNNINGTASKWIDGET_H 8 | #define RUNNINGTASKWIDGET_H 9 | 10 | #include 11 | #include "domain/task.h" 12 | 13 | class QLabel; 14 | class QHBoxLayout; 15 | class QPushButton; 16 | 17 | namespace Presentation { 18 | class RunningTaskModelInterface; 19 | } 20 | 21 | namespace Widgets { 22 | 23 | class RunningTaskWidget : public QWidget 24 | { 25 | Q_OBJECT 26 | public: 27 | explicit RunningTaskWidget(QWidget *parent = nullptr); 28 | 29 | void setModel(Presentation::RunningTaskModelInterface *model); 30 | 31 | Presentation::RunningTaskModelInterface *model() const; 32 | 33 | QString currentText() const; // for the unittest 34 | 35 | private slots: 36 | // connected to the model 37 | void onRunningTaskChanged(const Domain::Task::Ptr &task); 38 | // connected to the push buttons 39 | void onTaskRunStopped(); 40 | void onTaskRunDone(); 41 | 42 | void setCollapsed(bool b); 43 | 44 | protected: 45 | void enterEvent(QEnterEvent *ev) override; 46 | void leaveEvent(QEvent *ev) override; 47 | 48 | private: 49 | void resize(); 50 | 51 | Presentation::RunningTaskModelInterface *m_model; 52 | QHBoxLayout *m_layout; 53 | QLabel *m_titleLabel; 54 | QPushButton *m_stopButton; 55 | QPushButton *m_doneButton; 56 | bool m_collapsed; 57 | }; 58 | 59 | } 60 | 61 | #endif // RUNNINGTASKWIDGET_H 62 | -------------------------------------------------------------------------------- /tests/units/utils/datetimetest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2015 Theo Vaucher 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | 9 | #include "utils/datetime.h" 10 | 11 | using namespace Utils; 12 | 13 | class DateTimeTest : public QObject 14 | { 15 | Q_OBJECT 16 | private slots: 17 | void shouldNotOverrideCurrentDate() 18 | { 19 | // GIVEN 20 | const auto todayDate = QDate::currentDate(); 21 | 22 | // WHEN 23 | const QDate zanshinDate = DateTime::currentDate(); 24 | 25 | // THEN 26 | QCOMPARE(zanshinDate, todayDate); 27 | } 28 | 29 | void shouldOverrideCurrentDate() 30 | { 31 | // GIVEN 32 | const QByteArray dateExpected = "2015-03-10"; 33 | qputenv("ZANSHIN_OVERRIDE_DATE", dateExpected); 34 | 35 | // WHEN 36 | const QDate zanshinDate = DateTime::currentDate(); 37 | 38 | // THEN 39 | QCOMPARE(zanshinDate, QDate(2015, 3, 10)); 40 | } 41 | 42 | void shouldNotOverrideCurrentDateWhenInvalidDate() 43 | { 44 | // GIVEN 45 | const QByteArray dateExpected = "Invalid!"; 46 | qputenv("ZANSHIN_OVERRIDE_DATE", dateExpected); 47 | 48 | // WHEN 49 | const QDate zanshinDate = DateTime::currentDate(); 50 | 51 | // THEN 52 | QCOMPARE(zanshinDate, QDate::currentDate()); 53 | } 54 | }; 55 | 56 | ZANSHIN_TEST_MAIN(DateTimeTest) 57 | 58 | #include "datetimetest.moc" 59 | -------------------------------------------------------------------------------- /src/widgets/itemdelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef WIDGETS_ITEMDELEGATE_H 9 | #define WIDGETS_ITEMDELEGATE_H 10 | 11 | #include 12 | 13 | namespace Widgets { 14 | 15 | class ItemDelegate : public QStyledItemDelegate 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit ItemDelegate(QObject *parent = nullptr); 20 | 21 | QSize sizeHint(const QStyleOptionViewItem &option, 22 | const QModelIndex &index) const override; 23 | void paint(QPainter *painter, 24 | const QStyleOptionViewItem &option, 25 | const QModelIndex &index) const override; 26 | 27 | QWidget *createEditor(QWidget *parent, 28 | const QStyleOptionViewItem &option, 29 | const QModelIndex &index) const override; 30 | void setModelData(QWidget *editor, 31 | QAbstractItemModel *model, 32 | const QModelIndex &index) const override; 33 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 34 | 35 | private: 36 | enum class EditingState { NotEditing, JustCreatedEditor, Editing }; 37 | mutable EditingState m_editingState = EditingState::NotEditing; 38 | 39 | struct Layout; 40 | Layout doLayout(const QStyleOptionViewItem &option, 41 | const QModelIndex &index) const; 42 | }; 43 | 44 | } 45 | 46 | #endif // WIDGETS_ITEMDELEGATE_H 47 | -------------------------------------------------------------------------------- /tests/features/editing/completingtaskfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Completing tasks 14 | // As someone who just accomplished something 15 | // I can mark a task as completed 16 | // In order to have a warm feeling about getting it done 17 | class CompletingTaskFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Checking_task_in_the_list() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Inbox")); 25 | And(c.there_is_an_item_in_the_central_list("Buy cheese")); 26 | When(c.I_check_the_item()); 27 | Then(c.the_task_corresponding_to_the_item_is_done()); 28 | } 29 | 30 | void Checking_task_in_the_editor() 31 | { 32 | ZanshinContext c; 33 | Given(c.I_display_the_page("Inbox")); 34 | And(c.there_is_an_item_in_the_central_list("Buy apples")); 35 | When(c.I_open_the_item_in_the_editor()); 36 | And(c.I_mark_the_item_done_in_the_editor()); 37 | And(c.I_open_the_item_in_the_editor_again()); 38 | Then(c.the_task_corresponding_to_the_item_is_done()); 39 | And(c.the_editor_shows_the_task_as_done()); 40 | } 41 | }; 42 | 43 | ZANSHIN_TEST_MAIN(CompletingTaskFeature) 44 | 45 | #include "completingtaskfeature.moc" 46 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/util/remove_member_function_pointer_cv.hpp.m4: -------------------------------------------------------------------------------- 1 | #ifndef __MOCKITOPP_REMOVE_MEMBER_FUNCTION_POINTER_CV_HPP__ 2 | #define __MOCKITOPP_REMOVE_MEMBER_FUNCTION_POINTER_CV_HPP__ 3 | 4 | include(`mockitopp/detail/m4/ENUM_PARAMS.m4')dnl 5 | include(`mockitopp/detail/m4/ENUM_TRAILING_PARAMS.m4')dnl 6 | include(`mockitopp/detail/m4/REPEAT.m4')dnl 7 | namespace mockitopp 8 | { 9 | namespace detail 10 | { 11 | /** 12 | * Simple meta-prorgramming template that removes 13 | * const/volatile from member function pointers 14 | * making them suitable for internal use. 15 | * 16 | * @author Trevor Pounds 17 | */ 18 | template 19 | struct remove_member_function_pointer_cv 20 | { typedef T type; }; 21 | 22 | define(`REMOVE_MFP_CV_TEMPLATE', 23 | ` // $1 argument MFP remove const template 24 | template 25 | struct remove_member_function_pointer_cv 26 | { typedef R (C::*type)(M4_ENUM_PARAMS($1, A)); }; 27 | 28 | // $1 argument MFP remove const volatile template 29 | template 30 | struct remove_member_function_pointer_cv 31 | { typedef R (C::*type)(M4_ENUM_PARAMS($1, A)); }; 32 | 33 | ')dnl 34 | M4_REPEAT(eval(MOCKITOPP_MAX_VIRTUAL_FUNCTION_ARITY + 1), `REMOVE_MFP_CV_TEMPLATE')dnl 35 | } // namespace detail 36 | } // namespace mockitopp 37 | 38 | #endif //__MOCKITOPP_TR1_TYPE_TRAITS_HPP__ 39 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/mock_object.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_MOCK_OBJECT_HPP__ 7 | #define __MOCKITOPP_MOCK_OBJECT_HPP__ 8 | 9 | #include 10 | 11 | /** 12 | * helper macro to make mocking of overloaded functions less verbose 13 | */ 14 | #define overloaded_method(return_type, type, method, ...) \ 15 | static_cast(&type::method) 16 | 17 | namespace mockitopp 18 | { 19 | /** 20 | * provides a base implementation of a mock object 21 | * 22 | * @author Trevor Pounds 23 | */ 24 | template 25 | struct mock_object : protected detail::dynamic_object 26 | { 27 | /** 28 | * returns a mock object of the given abstract base class/interface 29 | * 30 | * @return mock object 31 | */ 32 | T& getInstance() 33 | { return reinterpret_cast(*this); } 34 | 35 | /** 36 | * stub functionality for a given method 37 | * 38 | * @param ptr2member method to be stubbed 39 | */ 40 | template 41 | detail::dynamic_vfunction::type>& expect(M ptr2member) 42 | { return define_function(ptr2member); } 43 | 44 | template 45 | detail::dynamic_vfunction::type>& operator() (M ptr2member) 46 | { return expect(ptr2member); } 47 | }; 48 | } // namespace mockitopp 49 | 50 | #endif //__MOCKITOPP_MOCK_OBJECT_HPP__ 51 | -------------------------------------------------------------------------------- /tests/testlib/akonadifakejobs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef TESTLIB_AKONADIFAKEJOBS_H 8 | #define TESTLIB_AKONADIFAKEJOBS_H 9 | 10 | #include "fakejob.h" 11 | #include "akonadi/akonadicollectionfetchjobinterface.h" 12 | #include "akonadi/akonadiitemfetchjobinterface.h" 13 | 14 | namespace Testlib { 15 | 16 | // cppcheck seems to get confused by the "using" in this class 17 | // cppcheck-suppress noConstructor 18 | class AkonadiFakeCollectionFetchJob : public FakeJob, public Akonadi::CollectionFetchJobInterface 19 | { 20 | Q_OBJECT 21 | public: 22 | using FakeJob::FakeJob; 23 | 24 | void setCollections(const Akonadi::Collection::List &collections); 25 | Akonadi::Collection::List collections() const override; 26 | 27 | QString resource() const; 28 | void setResource(const QString &resource) override; 29 | 30 | private: 31 | Akonadi::Collection::List m_collections; 32 | QString m_resource; 33 | }; 34 | 35 | class AkonadiFakeItemFetchJob : public FakeJob, public Akonadi::ItemFetchJobInterface 36 | { 37 | Q_OBJECT 38 | public: 39 | using FakeJob::FakeJob; 40 | 41 | void setItems(const Akonadi::Item::List &items); 42 | Akonadi::Item::List items() const override; 43 | 44 | Akonadi::Collection collection() const; 45 | void setCollection(const Akonadi::Collection &collection) override; 46 | 47 | private: 48 | Akonadi::Item::List m_items; 49 | Akonadi::Collection m_collection; 50 | }; 51 | 52 | } 53 | 54 | #endif // TESTLIB_AKONADIFAKEJOBS_H 55 | -------------------------------------------------------------------------------- /tests/features/inbox/inboxdisplayfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | #include 9 | 10 | using namespace Testlib; 11 | 12 | // Feature: Inbox content 13 | // As someone collecting tasks 14 | // I can display the Inbox 15 | // In order to see the tasks which need to be organized (e.g. any task not associated to any project or context) 16 | class InboxDisplayFeature : public QObject 17 | { 18 | Q_OBJECT 19 | private slots: 20 | void Unorganized_tasks_appear_in_the_inbox() 21 | { 22 | ZanshinContext c; 23 | Given(c.I_display_the_page("Inbox")); 24 | And(c.I_look_at_the_central_list()); 25 | When(c.I_list_the_items()); 26 | Then(c.the_list_is({ 27 | { "display" }, 28 | { 29 | { "Errands" }, 30 | { "\"Capital in the Twenty-First Century\" by Thomas Piketty" }, 31 | { "\"The Pragmatic Programmer\" by Hunt and Thomas" }, 32 | { "Buy cheese" }, 33 | { "Buy kiwis" }, 34 | { "Buy apples" }, 35 | { "Buy pears" }, 36 | { "Buy rutabagas" } 37 | } 38 | })); 39 | } 40 | }; 41 | 42 | ZANSHIN_TEST_MAIN(InboxDisplayFeature) 43 | 44 | #include "inboxdisplayfeature.moc" 45 | -------------------------------------------------------------------------------- /src/presentation/availablesourcesmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef PRESENTATION_AVAILABLESOURCESMODEL_H 9 | #define PRESENTATION_AVAILABLESOURCESMODEL_H 10 | 11 | #include 12 | 13 | #include "domain/datasourcequeries.h" 14 | #include "domain/datasourcerepository.h" 15 | 16 | #include "presentation/metatypes.h" 17 | #include "presentation/errorhandlingmodelbase.h" 18 | 19 | class QModelIndex; 20 | 21 | namespace Presentation { 22 | 23 | class AvailableSourcesModel : public QObject, public ErrorHandlingModelBase 24 | { 25 | Q_OBJECT 26 | Q_PROPERTY(QAbstractItemModel* sourceListModel READ sourceListModel) 27 | public: 28 | explicit AvailableSourcesModel(const Domain::DataSourceQueries::Ptr &dataSourceQueries, 29 | const Domain::DataSourceRepository::Ptr &dataSourceRepository, 30 | QObject *parent = nullptr); 31 | 32 | QAbstractItemModel *sourceListModel(); 33 | 34 | public slots: 35 | void setDefaultItem(const QModelIndex &index); 36 | 37 | void showConfigDialog(); 38 | 39 | private slots: 40 | void onDefaultSourceChanged(); 41 | 42 | private: 43 | void emitDefaultSourceChanged(const QModelIndex &root); 44 | 45 | QAbstractItemModel *createSourceListModel(); 46 | 47 | QAbstractItemModel *m_sourceListModel; 48 | 49 | Domain::DataSourceQueries::Ptr m_dataSourceQueries; 50 | Domain::DataSourceRepository::Ptr m_dataSourceRepository; 51 | }; 52 | 53 | } 54 | 55 | #endif // PRESENTATION_AVAILABLESOURCESMODEL_H 56 | -------------------------------------------------------------------------------- /src/utils/mockobject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef UTILS_MOCKOBJECT_H 9 | #define UTILS_MOCKOBJECT_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Utils { 16 | template 17 | class MockObject 18 | { 19 | typedef mockitopp::mock_object InternalMockType; 20 | 21 | class InternalDeleter 22 | { 23 | public: 24 | explicit InternalDeleter(InternalMockType *mockObject) 25 | : m_mockObject(mockObject) 26 | { 27 | } 28 | 29 | void operator ()(T *) 30 | { 31 | delete m_mockObject; 32 | } 33 | 34 | private: 35 | InternalMockType *m_mockObject; 36 | }; 37 | 38 | public: 39 | MockObject() 40 | : m_mockObject(new InternalMockType), 41 | m_mockPtr(&m_mockObject->getInstance(), InternalDeleter(m_mockObject)) 42 | { 43 | } 44 | 45 | QSharedPointer getInstance() 46 | { 47 | return m_mockPtr; 48 | } 49 | 50 | template 51 | mockitopp::detail::dynamic_vfunction::type>& operator() (M ptr2member) 52 | { 53 | return (*m_mockObject)(ptr2member); 54 | } 55 | 56 | private: 57 | InternalMockType *m_mockObject; 58 | QSharedPointer m_mockPtr; 59 | }; 60 | } 61 | 62 | #endif // UTILS_MOCKOBJECT_H 63 | -------------------------------------------------------------------------------- /src/domain/datasourcequeries.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef DOMAIN_DATASOURCEQUERIES_H 8 | #define DOMAIN_DATASOURCEQUERIES_H 9 | 10 | #include 11 | 12 | #include "datasource.h" 13 | #include "project.h" 14 | #include "queryresult.h" 15 | 16 | namespace Domain { 17 | 18 | class DataSourceQueries; 19 | 20 | class DataSourceQueriesNotifier : public QObject 21 | { 22 | Q_OBJECT 23 | signals: 24 | void defaultSourceChanged(); 25 | 26 | private: 27 | friend class DataSourceQueries; 28 | }; 29 | 30 | class DataSourceQueries 31 | { 32 | public: 33 | typedef QSharedPointer Ptr; 34 | 35 | DataSourceQueries(); 36 | virtual ~DataSourceQueries(); 37 | 38 | DataSourceQueriesNotifier *notifier() const; 39 | 40 | virtual bool isDefaultSource(DataSource::Ptr source) const = 0; 41 | void setDefaultSource(DataSource::Ptr source); 42 | 43 | // HACK: Ugly right? Find me another way to mock changeDefaultSource then... 44 | #ifdef ZANSHIN_I_SWEAR_I_AM_IN_A_PRESENTATION_TEST 45 | public: 46 | #else 47 | private: 48 | #endif 49 | virtual void changeDefaultSource(DataSource::Ptr source) = 0; 50 | 51 | public: 52 | virtual QueryResult::Ptr findTopLevel() const = 0; 53 | virtual QueryResult::Ptr findChildren(DataSource::Ptr source) const = 0; 54 | virtual QueryResult::Ptr findAllSelected() const = 0; 55 | virtual QueryResult::Ptr findProjects(DataSource::Ptr source) const = 0; 56 | }; 57 | 58 | } 59 | 60 | #endif // DOMAIN_DATASOURCEQUERIES_H 61 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers/base/equal.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_MATCHER_EQ_HPP__ 7 | #define __MOCKITOPP_MATCHER_EQ_HPP__ 8 | 9 | #include 10 | #include 11 | 12 | namespace mockitopp 13 | { 14 | namespace matcher 15 | { 16 | namespace detail 17 | { 18 | template 19 | struct EqualT : public Matcher 20 | { 21 | EqualT(typename mockitopp::detail::tr1::add_reference< 22 | typename mockitopp::detail::tr1::add_const::type>::type element) 23 | : element_(element) 24 | {} 25 | 26 | Matcher* clone() const override 27 | { return new EqualT(element_); } 28 | 29 | bool operator== (typename mockitopp::detail::tr1::add_reference< 30 | typename mockitopp::detail::tr1::add_const::type>::type rhs) const override 31 | { return element_ == rhs; } 32 | 33 | private: 34 | 35 | T element_; 36 | }; 37 | } // namespace detail 38 | 39 | template 40 | detail::EqualT equal(typename mockitopp::detail::tr1::add_reference< 41 | typename mockitopp::detail::tr1::add_const::type>::type element) 42 | { return detail::EqualT(element); } 43 | 44 | inline detail::EqualT equal(const char* element) 45 | { return detail::EqualT(element); } 46 | } // namespace matcher 47 | } // namespace mockitopp 48 | 49 | #endif //__MOCKITOPP_MATCHER_EQ_HPP__ 50 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers/type/string_literal.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_MATCHER_STRING_LITERAL_HPP__ 7 | #define __MOCKITOPP_MATCHER_STRING_LITERAL_HPP__ 8 | 9 | #include 10 | #include 11 | 12 | namespace mockitopp 13 | { 14 | namespace matcher 15 | { 16 | namespace detail 17 | { 18 | template struct is_string_literal {}; 19 | template <> struct is_string_literal { typedef char* type; }; 20 | template <> struct is_string_literal { typedef const char* type; }; 21 | 22 | template 23 | struct StringLiteralT : public Matcher 24 | { 25 | StringLiteralT(const T& string_lit) 26 | : internal_string(string_lit) 27 | {} 28 | 29 | virtual Matcher* clone() const 30 | { return new StringLiteralT(const_cast(internal_string.c_str())); } 31 | 32 | virtual bool operator== (typename mockitopp::detail::tr1::add_reference::type>::type rhs) const 33 | { return internal_string == rhs; } 34 | 35 | private: 36 | 37 | std::string internal_string; 38 | }; 39 | } // namespace detail 40 | 41 | template 42 | detail::StringLiteralT string_literal(typename detail::is_string_literal::type string_lit) 43 | { return detail::StringLiteralT(string_lit); } 44 | } // namespace matcher 45 | } // namespace mockitopp 46 | 47 | #endif //__MOCKITOPP_MATCHER_STRING_LITERAL_HPP__ 48 | -------------------------------------------------------------------------------- /tests/units/utils/jobhandlertest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | 9 | #include "utils/jobhandler.h" 10 | #include "utils/compositejob.h" 11 | 12 | #include "testlib/fakejob.h" 13 | 14 | using namespace Utils; 15 | 16 | namespace 17 | { 18 | template 19 | QSet listToSet(const QList &list) 20 | { 21 | return {list.cbegin(), list.cend()}; 22 | } 23 | } 24 | 25 | class JobHandlerTest : public QObject 26 | { 27 | Q_OBJECT 28 | private slots: 29 | void shouldCallHandlers() 30 | { 31 | int callCount = 0; 32 | QList seenJobs; 33 | 34 | auto handler = [&]() { 35 | callCount++; 36 | }; 37 | 38 | auto handlerWithJob = [&](KJob *job) { 39 | callCount++; 40 | seenJobs << job; 41 | }; 42 | 43 | FakeJob *job1 = new FakeJob(this); 44 | JobHandler::install(job1, handler); 45 | JobHandler::install(job1, handlerWithJob); 46 | QCOMPARE(JobHandler::jobCount(), 2); 47 | job1->start(); 48 | 49 | FakeJob *job2 = new FakeJob(this); 50 | JobHandler::install(job2, handler); 51 | JobHandler::install(job2, handlerWithJob); 52 | QCOMPARE(JobHandler::jobCount(), 4); 53 | job2->start(); 54 | 55 | QTest::qWait(FakeJob::DURATION + 10); 56 | 57 | QCOMPARE(callCount, 4); 58 | QCOMPARE(listToSet(seenJobs), QSet() << job1 << job2); 59 | QCOMPARE(JobHandler::jobCount(), 0); 60 | } 61 | }; 62 | 63 | ZANSHIN_TEST_MAIN(JobHandlerTest) 64 | 65 | #include "jobhandlertest.moc" 66 | -------------------------------------------------------------------------------- /src/akonadi/akonaditaskrepository.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_TASKREPOSITORY_H 8 | #define AKONADI_TASKREPOSITORY_H 9 | 10 | #include "domain/taskrepository.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "akonadi/akonadiserializerinterface.h" 16 | #include "akonadi/akonadistorageinterface.h" 17 | 18 | namespace Akonadi { 19 | 20 | class TaskRepository : public QObject, public Domain::TaskRepository 21 | { 22 | Q_OBJECT 23 | public: 24 | typedef QSharedPointer Ptr; 25 | 26 | TaskRepository(const StorageInterface::Ptr &storage, 27 | const SerializerInterface::Ptr &serializer); 28 | 29 | KJob *create(Domain::Task::Ptr task) override; 30 | KJob *createChild(Domain::Task::Ptr task, Domain::Task::Ptr parent) override; 31 | KJob *createInProject(Domain::Task::Ptr task, Domain::Project::Ptr project) override; 32 | KJob *createInContext(Domain::Task::Ptr task, Domain::Context::Ptr context) override; 33 | 34 | KJob *update(Domain::Task::Ptr task) override; 35 | KJob *remove(Domain::Task::Ptr task) override; 36 | 37 | KJob *promoteToProject(Domain::Task::Ptr task) override; 38 | 39 | KJob *associate(Domain::Task::Ptr parent, Domain::Task::Ptr child) override; 40 | KJob *dissociate(Domain::Task::Ptr child) override; 41 | KJob *dissociateAll(Domain::Task::Ptr child) override; 42 | 43 | private: 44 | StorageInterface::Ptr m_storage; 45 | SerializerInterface::Ptr m_serializer; 46 | 47 | KJob *createItem(const Akonadi::Item &item); 48 | }; 49 | 50 | } 51 | 52 | #endif // AKONADI_TASKREPOSITORY_H 53 | -------------------------------------------------------------------------------- /src/zanshin/migrator/zanshin021migrator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 David Faure 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef ZANSHIN021MIGRATOR_H 8 | #define ZANSHIN021MIGRATOR_H 9 | 10 | #include 11 | #include 12 | 13 | namespace Akonadi { 14 | class TransactionSequence; 15 | } 16 | 17 | class SeenItem 18 | { 19 | public: 20 | explicit SeenItem(const Akonadi::Item &theItem) 21 | : m_item(theItem) 22 | { 23 | } 24 | // invalid item, for QHash::value 25 | SeenItem() 26 | : m_item(Akonadi::Item()) 27 | { 28 | } 29 | bool isDirty() const { return m_dirty; } 30 | void setDirty() { m_dirty = true; } 31 | 32 | Akonadi::Item &item() { return m_item; } 33 | const Akonadi::Item &item() const { return m_item; } 34 | 35 | private: 36 | Akonadi::Item m_item; 37 | bool m_dirty = false; 38 | }; 39 | 40 | class Zanshin021Migrator 41 | { 42 | public: 43 | Zanshin021Migrator(); 44 | 45 | typedef QHash SeenItemHash; 46 | SeenItemHash fetchAllItems(); 47 | 48 | void migrateProjectComments(Zanshin021Migrator::SeenItemHash& items, Akonadi::TransactionSequence* sequence); 49 | 50 | void migrateProjectWithChildren(Zanshin021Migrator::SeenItemHash& items, Akonadi::TransactionSequence* sequence); 51 | 52 | bool migrateProjects(); 53 | 54 | // returns true if item is a "new style" project 55 | static bool isProject(const Akonadi::Item &item); 56 | 57 | private: 58 | void markAsProject(SeenItem &seenItem, Akonadi::TransactionSequence* sequence); 59 | 60 | Akonadi::Storage m_storage; 61 | 62 | }; 63 | 64 | #endif // ZANSHIN021MIGRATOR_H 65 | -------------------------------------------------------------------------------- /src/akonadi/akonadiprojectqueries.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include "akonadiprojectqueries.h" 8 | 9 | using namespace Akonadi; 10 | 11 | ProjectQueries::ProjectQueries(const StorageInterface::Ptr &storage, const SerializerInterface::Ptr &serializer, const MonitorInterface::Ptr &monitor) 12 | : m_serializer(serializer), 13 | m_helpers(new LiveQueryHelpers(serializer, storage)), 14 | m_integrator(new LiveQueryIntegrator(serializer, monitor)) 15 | { 16 | m_integrator->addRemoveHandler([this] (const Item &item) { 17 | m_findTopLevel.remove(item.id()); 18 | }); 19 | } 20 | 21 | ProjectQueries::ProjectResult::Ptr ProjectQueries::findAll() const 22 | { 23 | auto fetch = m_helpers->fetchItems(const_cast(this)); 24 | auto predicate = [this] (const Akonadi::Item &item) { 25 | return m_serializer->isProjectItem(item); 26 | }; 27 | m_integrator->bind("ProjectQueries::findAll", m_findAll, fetch, predicate); 28 | return m_findAll->result(); 29 | } 30 | 31 | ProjectQueries::TaskResult::Ptr ProjectQueries::findTopLevel(Domain::Project::Ptr project) const 32 | { 33 | Akonadi::Item item = m_serializer->createItemFromProject(project); 34 | auto &query = m_findTopLevel[item.id()]; 35 | auto fetch = m_helpers->fetchSiblings(item, const_cast(this)); 36 | auto predicate = [this, project] (const Akonadi::Item &item) { 37 | return m_serializer->isProjectChild(project, item); 38 | }; 39 | m_integrator->bind("ProjectQueries::findTopLevel", query, fetch, predicate); 40 | return query->result(); 41 | } 42 | 43 | #include "moc_akonadiprojectqueries.cpp" 44 | -------------------------------------------------------------------------------- /tests/units/akonadi/akonadicachingstorageintegrationtest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2017 Kevin Ottens 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "akonadi/akonadicachingstorage.h" 13 | #include "akonadi/akonadimonitorimpl.h" 14 | #include "akonadi/akonadiserializer.h" 15 | #include "akonadi/akonadistorage.h" 16 | 17 | class AkonadiCachingStorageIntegrationTest : public Testlib::AkonadiStorageTestBase 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit AkonadiCachingStorageIntegrationTest(QObject *parent = nullptr) 22 | : AkonadiStorageTestBase(parent) 23 | { 24 | } 25 | 26 | Akonadi::StorageInterface::Ptr createStorage() override 27 | { 28 | auto serializer = Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer); 29 | return Akonadi::StorageInterface::Ptr(new Akonadi::CachingStorage(Akonadi::Cache::Ptr::create(serializer, 30 | createMonitor()), 31 | Akonadi::StorageInterface::Ptr(new Akonadi::Storage))); 32 | } 33 | 34 | Akonadi::MonitorInterface::Ptr createMonitor() override 35 | { 36 | return Akonadi::MonitorInterface::Ptr(new Akonadi::MonitorImpl); 37 | } 38 | 39 | private slots: 40 | void initTestCase() 41 | { 42 | QVERIFY(TestLib::TestSafety::checkTestIsIsolated()); 43 | } 44 | }; 45 | 46 | ZANSHIN_TEST_MAIN(AkonadiCachingStorageIntegrationTest) 47 | 48 | #include "akonadicachingstorageintegrationtest.moc" 49 | -------------------------------------------------------------------------------- /src/presentation/projectpagemodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | 8 | #ifndef PRESENTATION_PROJECTPAGEMODEL_H 9 | #define PRESENTATION_PROJECTPAGEMODEL_H 10 | 11 | #include "presentation/pagemodel.h" 12 | 13 | #include "domain/projectqueries.h" 14 | #include "domain/projectrepository.h" 15 | #include "domain/taskqueries.h" 16 | #include "domain/taskrepository.h" 17 | 18 | namespace Presentation { 19 | 20 | class ProjectPageModel : public PageModel 21 | { 22 | Q_OBJECT 23 | public: 24 | explicit ProjectPageModel(const Domain::Project::Ptr &project, 25 | const Domain::ProjectQueries::Ptr &projectQueries, 26 | const Domain::ProjectRepository::Ptr &projectRepository, 27 | const Domain::TaskQueries::Ptr &taskQueries, 28 | const Domain::TaskRepository::Ptr &taskRepository, 29 | QObject *parent = nullptr); 30 | 31 | Domain::Project::Ptr project() const; 32 | 33 | Domain::Task::Ptr addItem(const QString &title, const QModelIndex &parentIndex = QModelIndex()) override; 34 | void removeItem(const QModelIndex &index) override; 35 | void promoteItem(const QModelIndex &index) override; 36 | 37 | private: 38 | QAbstractItemModel *createCentralListModel() override; 39 | 40 | Domain::ProjectQueries::Ptr m_projectQueries; 41 | Domain::ProjectRepository::Ptr m_projectRepository; 42 | Domain::Project::Ptr m_project; 43 | 44 | Domain::TaskQueries::Ptr m_taskQueries; 45 | Domain::TaskRepository::Ptr m_taskRepository; 46 | }; 47 | 48 | } 49 | 50 | #endif // PRESENTATION_PROJECTPAGEMODEL_H 51 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/detail/util/tr1_type_traits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_TR1_TYPE_TRAITS_HPP__ 7 | #define __MOCKITOPP_TR1_TYPE_TRAITS_HPP__ 8 | 9 | namespace mockitopp 10 | { 11 | namespace detail 12 | { 13 | /** 14 | * Simple subset adaptation of tr1 type_traits 15 | * for internal mockitopp use. 16 | * 17 | * @author Trevor Pounds 18 | * @see http://www.boost.org/doc/libs/release/libs/type_traits/ 19 | */ 20 | namespace tr1 21 | { 22 | #ifdef _MSC_VER 23 | // C4181: qualifier applied to reference type 24 | #pragma warning(disable:4181) 25 | #endif 26 | 27 | // std::tr1::add_const 28 | template struct add_const { typedef const T type; }; 29 | template struct add_const { typedef const T type; }; 30 | 31 | #ifdef _MSC_VER 32 | #pragma warning(default:4181) 33 | #endif 34 | 35 | // std::tr1::remove_const 36 | template struct remove_const { typedef T type; }; 37 | template struct remove_const { typedef T type; }; 38 | 39 | // std::tr1::add_reference 40 | template struct add_reference { typedef T type; }; 41 | template struct add_reference { typedef T& type; }; 42 | 43 | // std::tr1::remove_reference 44 | template struct remove_reference { typedef T type; }; 45 | template struct remove_reference { typedef T type; }; 46 | } // namespace tr1 47 | } // namespace detail 48 | } // namespace mockitopp 49 | 50 | #endif //__MOCKITOPP_TR1_TYPE_TRAITS_HPP__ 51 | -------------------------------------------------------------------------------- /src/presentation/contextpagemodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | SPDX-FileCopyrightText: 2014 Rémi Benoit 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #ifndef CONTEXTPAGEMODEL_H 9 | #define CONTEXTPAGEMODEL_H 10 | 11 | #include "presentation/pagemodel.h" 12 | 13 | #include "domain/contextqueries.h" 14 | #include "domain/contextrepository.h" 15 | #include "domain/taskqueries.h" 16 | #include "domain/taskrepository.h" 17 | 18 | namespace Presentation { 19 | 20 | class ContextPageModel : public PageModel 21 | { 22 | Q_OBJECT 23 | public: 24 | explicit ContextPageModel(const Domain::Context::Ptr &context, 25 | const Domain::ContextQueries::Ptr &contextQueries, 26 | const Domain::ContextRepository::Ptr &contextRepository, 27 | const Domain::TaskQueries::Ptr &taskQueries, 28 | const Domain::TaskRepository::Ptr &taskRepository, 29 | QObject *parent = nullptr); 30 | 31 | Domain::Context::Ptr context() const; 32 | public slots: 33 | Domain::Task::Ptr addItem(const QString &title, const QModelIndex &parentIndex = QModelIndex()) override; 34 | void removeItem(const QModelIndex &index) override; 35 | void promoteItem(const QModelIndex &index) override; 36 | 37 | private: 38 | QAbstractItemModel *createCentralListModel() override; 39 | 40 | Domain::Context::Ptr m_context; 41 | Domain::ContextQueries::Ptr m_contextQueries; 42 | Domain::ContextRepository::Ptr m_contextRepository; 43 | Domain::TaskQueries::Ptr m_taskQueries; 44 | Domain::TaskRepository::Ptr m_taskRepository; 45 | }; 46 | 47 | } 48 | #endif // CONTEXTPAGEMODEL_H 49 | -------------------------------------------------------------------------------- /src/akonadi/akonadiprojectqueries.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Kevin Ottens 3 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #ifndef AKONADI_PROJECTQUERIES_H 8 | #define AKONADI_PROJECTQUERIES_H 9 | 10 | #include "domain/projectqueries.h" 11 | 12 | #include "akonadi/akonadilivequeryhelpers.h" 13 | #include "akonadi/akonadilivequeryintegrator.h" 14 | 15 | namespace Akonadi { 16 | 17 | class ProjectQueries : public QObject, public Domain::ProjectQueries 18 | { 19 | Q_OBJECT 20 | public: 21 | typedef QSharedPointer Ptr; 22 | 23 | typedef Domain::LiveQueryInput ItemInputQuery; 24 | typedef Domain::LiveQueryOutput ProjectQueryOutput; 25 | typedef Domain::QueryResultProvider ProjectProvider; 26 | typedef Domain::QueryResult ProjectResult; 27 | 28 | typedef Domain::LiveQueryOutput TaskQueryOutput; 29 | typedef Domain::QueryResultProvider TaskProvider; 30 | typedef Domain::QueryResult TaskResult; 31 | 32 | ProjectQueries(const StorageInterface::Ptr &storage, 33 | const SerializerInterface::Ptr &serializer, 34 | const MonitorInterface::Ptr &monitor); 35 | 36 | ProjectResult::Ptr findAll() const override; 37 | TaskResult::Ptr findTopLevel(Domain::Project::Ptr project) const override; 38 | 39 | private: 40 | SerializerInterface::Ptr m_serializer; 41 | LiveQueryHelpers::Ptr m_helpers; 42 | LiveQueryIntegrator::Ptr m_integrator; 43 | 44 | mutable ProjectQueryOutput::Ptr m_findAll; 45 | mutable QHash m_findTopLevel; 46 | }; 47 | 48 | } 49 | 50 | #endif // AKONADI_PROJECTQUERIES_H 51 | -------------------------------------------------------------------------------- /tests/features/workday/workdaypostponingfeature.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2019 Kevin Ottens 3 | SPDX-FileCopyrightText: 2019 David Faure 4 | * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | using namespace Testlib; 12 | 13 | // Feature: Postponing a task 14 | // As someone using tasks 15 | // I can change the start or due date of a task 16 | // In order to procrastinate 17 | class WorkdayPostponingFeature : public QObject 18 | { 19 | Q_OBJECT 20 | private slots: 21 | void Setting_a_date_s_start_date_to_a_date_in_the_future_makes_it_disappear_in_the_Workday_page() 22 | { 23 | ZanshinContext c; 24 | Given(c.I_display_the_page("Workday")); 25 | And(c.there_is_an_item_in_the_central_list("Errands")); 26 | When(c.I_open_the_item_in_the_editor()); 27 | And(c.I_change_the_editor_field("start date", "2015-03-20")); 28 | And(c.I_look_at_the_central_list()); 29 | And(c.I_list_the_items()); 30 | Then(c.the_list_does_not_contain("Errands")); 31 | } 32 | 33 | void Setting_a_date_s_due_date_to_a_date_in_the_future_makes_it_disappear_in_the_Workday_page() 34 | { 35 | ZanshinContext c; 36 | Given(c.I_display_the_page("Workday")); 37 | And(c.there_is_an_item_in_the_central_list("Buy kiwis")); 38 | When(c.I_open_the_item_in_the_editor()); 39 | And(c.I_change_the_editor_field("due date", "2015-03-20")); 40 | And(c.I_look_at_the_central_list()); 41 | And(c.I_list_the_items()); 42 | Then(c.the_list_does_not_contain("Buy kiwis")); 43 | } 44 | }; 45 | 46 | ZANSHIN_TEST_MAIN(WorkdayPostponingFeature) 47 | 48 | #include "workdaypostponingfeature.moc" 49 | -------------------------------------------------------------------------------- /3rdparty/mockitopp/matchers/regex.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2008 Trevor Pounds 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | 6 | #ifndef __MOCKITOPP_MATCHER_REGEX_HPP__ 7 | #define __MOCKITOPP_MATCHER_REGEX_HPP__ 8 | 9 | #include 10 | 11 | namespace mockitopp 12 | { 13 | namespace matcher 14 | { 15 | namespace detail 16 | { 17 | #if defined(BOOST_RE_REGEX_HPP) 18 | namespace __tr1 = ::boost; 19 | #elif defined(_GLIBCXX_TR1_REGEX) || defined(_REGEX_) 20 | namespace __tr1 = ::std::tr1; 21 | #elif defined(_GLIBCXX_REGEX) 22 | namespace __tr1 = ::std; 23 | #else 24 | #error compatible tr1 regex header not found! 25 | #endif 26 | 27 | template 28 | struct RegexT : public Matcher 29 | { 30 | RegexT(typename mockitopp::detail::tr1::add_reference::type>::type expr) 31 | : expr_(expr) 32 | {} 33 | 34 | virtual Matcher* clone() const 35 | { return new RegexT(expr_); } 36 | 37 | virtual bool operator== (typename mockitopp::detail::tr1::add_reference::type>::type rhs) const 38 | { return __tr1::regex_match(rhs, expr_); } 39 | 40 | private: 41 | 42 | __tr1::regex expr_; 43 | 44 | RegexT(const __tr1::regex& expr) 45 | : expr_(expr) 46 | {} 47 | }; 48 | } // namespace detail 49 | 50 | template 51 | detail::RegexT regex(T expr) 52 | { return detail::RegexT(expr); } 53 | } // namespace matcher 54 | } // namespace mockitopp 55 | 56 | #endif //__MOCKITOPP_MATCHER_REGEX_HPP__ 57 | -------------------------------------------------------------------------------- /tests/testlib/MacroAkonadiAutoTests.cmake: -------------------------------------------------------------------------------- 1 | set(_akonaditest_source_dir ${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | MACRO(ZANSHIN_AKONADI_AUTO_TESTS) 4 | set(prefix "${CMAKE_CURRENT_SOURCE_DIR}") 5 | string(REPLACE "${CMAKE_SOURCE_DIR}" "" prefix "${prefix}") 6 | string(REPLACE "/" "-" prefix "${prefix}") 7 | string(REPLACE "\\" "-" prefix "${prefix}") 8 | string(LENGTH "${prefix}" prefix_length) 9 | string(SUBSTRING "${prefix}" 1 ${prefix_length}-1 prefix) 10 | 11 | FOREACH(_testname ${ARGN}) 12 | set(_prefixed_testname "${prefix}-${_testname}") 13 | add_executable(${_prefixed_testname} ${_testname}.cpp) 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}") 15 | target_link_libraries(${_prefixed_testname} Qt::Test akonadi domain utils) 16 | 17 | set(_location "${CMAKE_BINARY_DIR}/bin/${_prefixed_testname}") 18 | if (WIN32) 19 | set(_executable "${_location}.exe") 20 | else (WIN32) 21 | set(_executable "${_location}") 22 | endif (WIN32) 23 | 24 | find_program(_testrunner akonaditest) 25 | 26 | set(AKONADITEST_CWD "${CMAKE_CURRENT_SOURCE_DIR}") 27 | set(zanshin-testcommand "${_executable}") 28 | configure_file(${_akonaditest_source_dir}/akonaditest-run.sh.in ${_prefixed_testname}-run.sh) 29 | 30 | set(akonaditest-run-cmd "${_testrunner}" -c "${CMAKE_CURRENT_SOURCE_DIR}/testenv/config.xml" 31 | sh "${CMAKE_CURRENT_BINARY_DIR}/${_prefixed_testname}-run.sh") 32 | 33 | add_custom_target(${_prefixed_testname}-run 34 | COMMAND ${akonaditest-run-cmd} 35 | WORKING_DIRECTORY ${AKONADITEST_CWD} 36 | USES_TERMINAL 37 | ) 38 | 39 | add_test(NAME ${_prefixed_testname} COMMAND ${CMAKE_MAKE_PROGRAM} -C "${CMAKE_BINARY_DIR}" ${_prefixed_testname}-run) 40 | ENDFOREACH(_testname) 41 | ENDMACRO(ZANSHIN_AKONADI_AUTO_TESTS) 42 | -------------------------------------------------------------------------------- /tests/units/presentation/errorhandlertest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2014 Mario Bensi 3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 | */ 5 | 6 | 7 | #include 8 | 9 | #include "presentation/errorhandler.h" 10 | 11 | #include "testlib/fakejob.h" 12 | 13 | class FakeErrorHandler : public Presentation::ErrorHandler 14 | { 15 | public: 16 | void doDisplayMessage(const QString &message) override 17 | { 18 | m_message = message; 19 | } 20 | 21 | QString m_message; 22 | }; 23 | 24 | class ErrorHandlerTest : public QObject 25 | { 26 | Q_OBJECT 27 | private slots: 28 | void shouldDisplayErrorMessage() 29 | { 30 | // GIVEN 31 | 32 | // create job 33 | auto job = new FakeJob(this); 34 | job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); 35 | 36 | // create ErrorHandler 37 | FakeErrorHandler errorHandler; 38 | 39 | const QString message = QStringLiteral("I Failed !!!!!!!!!!"); 40 | 41 | // WHEN 42 | errorHandler.installHandler(job, message); 43 | 44 | // THEN 45 | QTest::qWait(150); 46 | QCOMPARE(errorHandler.m_message, QStringLiteral("I Failed !!!!!!!!!!: Foo")); 47 | } 48 | 49 | void shouldDisplayNothing() 50 | { 51 | // GIVEN 52 | 53 | // create job 54 | auto job = new FakeJob(this); 55 | 56 | // create ErrorHandler 57 | FakeErrorHandler errorHandler; 58 | 59 | const QString message = QStringLiteral("I Failed !!!!!!!!!!"); 60 | 61 | // WHEN 62 | errorHandler.installHandler(job, message); 63 | 64 | // THEN 65 | QTest::qWait(150); 66 | QVERIFY(errorHandler.m_message.isEmpty()); 67 | } 68 | }; 69 | 70 | ZANSHIN_TEST_MAIN(ErrorHandlerTest) 71 | 72 | #include "errorhandlertest.moc" 73 | --------------------------------------------------------------------------------