Imported Upstream version 1.11.1
Sandro Knauß
8 years ago
9 | 9 | EXTRA camelcase,null,defines,crud |
10 | 10 | |
11 | 11 | #skip Keychain |
12 | SKIP /Charm/Keychain/ | |
12 | SKIP /Charm/Keychain/keychain | |
13 | 13 | #if you have a build subdir, skip it |
14 | 14 | SKIP /build- |
15 | 15 |
0 | = Requirements = | |
1 | ||
2 | Charm supports both Qt 4 and Qt 5 right now. We recommend to use the latest Qt release for the respective major version, i.e. | |
3 | Qt 4.8.7 or Qt 5.5 as of now. We don't run CI or manual tests for older minor releases. | |
4 | ||
5 | The Qt modules required on all platforms are: QtWidgets, QtXml, QtSql with SQLite3 plugin, QtNetwork, QtTest, QtScript (or equivalent Qt 4 features) | |
6 | Optional: QtPrintSupport | |
7 | ||
8 | Charm code uses C++11, so using a recent enough compiler is advised (see below for details). | |
9 | ||
10 | == Linux == | |
11 | ||
12 | * g++ >= 4.8 | |
13 | * CMake 3.x | |
14 | * Qt 4.8.7 or Qt 5; we still use Qt 4 for the distro packages on OpenSUSE Build Service [1] because the Qt 5 packages of the various | |
15 | distros tend to have issues with desktop integration (tray icons in Unity, for example). If you're building from source, we're encouraging | |
16 | you to use Qt 5. | |
17 | * Extra Qt modules/features required: QtDBus | |
18 | ||
19 | [1] https://build.opensuse.org/package/repositories/isv:KDAB/charmtimetracker | |
20 | ||
21 | == OS X == | |
22 | ||
23 | * A new enough clang to support the C++11 features we use. We recommend to use the latest XCode if possible. (7.0.2 right now) | |
24 | * Qt 5 (Qt 4's support for recent OS X versions is lacking, thus Qt4-based builds for OS X are not supported or tested by us); | |
25 | Using the official Qt build is recommended | |
26 | * Extra Qt 5 modules required: QtMacExtras | |
27 | * CMake 3.x | |
28 | ||
29 | == Windows == | |
30 | ||
31 | On Windows we require: | |
32 | * MSVC 2013 or MinGW (gcc >= 4.8; lower versions untested) | |
33 | * A Qt 5 build for MSVC 2013 or MinGW, matching the compiler you want to use | |
34 | (Qt 4-based builds for Windows might work but is not supported or tested by us) | |
35 | * Extra Qt 5 modules required: QtWinExtras | |
36 | * Install OpenSSL and make sure the libraries are in the PATH (TODO: add more details like suggested downloads) | |
37 | * CMake 3.x | |
38 | ||
39 | ||
40 | = Build Instructions = | |
41 | ||
42 | == Building from the Terminal == | |
43 | ||
44 | The build steps for a Debug build when building from the Terminal are: | |
45 | ||
46 | cd Charm | |
47 | mkdir build | |
48 | cd build | |
49 | cmake -DCMAKE_BUILD_TYPE=Debug .. | |
50 | make # Windows: nmake, mingw32-make or jom, see below | |
51 | ||
52 | Windows-specific hints: | |
53 | ||
54 | * Ensure that your compiler's environment is sourced (Call vcvarsall.bat for MSVC2013). | |
55 | * For MinGW: pass -G "MinGW Makefiles". "make" becomes "mingw32-make" | |
56 | * When using MSVC: call "nmake" instead of make. | |
57 | * You can use jom.exe (parallel builds using multiple cores) which is shipped as part of Qt Creator for both MSVC and MinGW builds | |
58 | ||
59 | == Building in Qt Creator == | |
60 | ||
61 | * Choose File -> Open File or Project | |
62 | * Select the top-level CMakeLists.txt | |
63 | * Select the Generator matching your architecture (32bit vs. 64bit) and enter the wanted arguments, e.g. | |
64 | "-DCMAKE_BUILD_TYPE=Debug" | |
65 | * Click "Run CMake" |
27 | 27 | SET( CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE ) |
28 | 28 | ENDIF() |
29 | 29 | |
30 | IF( APPLE AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local" ) | |
30 | IF( APPLE AND CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" ) | |
31 | 31 | SET( CMAKE_INSTALL_PREFIX "/Applications" ) |
32 | 32 | ENDIF() |
33 | 33 | |
36 | 36 | CMAKE_MINIMUM_REQUIRED( VERSION 2.6.0 ) |
37 | 37 | SET( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" ) |
38 | 38 | |
39 | if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | |
40 | set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") | |
41 | endif() | |
39 | IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") | |
40 | SET(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") | |
41 | ENDIF() | |
42 | IF(MSVC) | |
43 | SET(CMAKE_CXX_FLAGS "-D_USING_V110_SDK71_=1 ${CMAKE_CXX_FLAGS}") | |
44 | ENDIF() | |
42 | 45 | |
43 | 46 | SET( CMAKE_AUTOMOC ON ) |
44 | 47 | |
48 | 51 | IF( NOT CHARM_FORCE_QT4 ) |
49 | 52 | find_package( Qt5Core QUIET ) |
50 | 53 | ENDIF() |
54 | ||
55 | set(QTKEYCHAIN_SYSTEM OFF) | |
51 | 56 | |
52 | 57 | IF(Qt5Core_FOUND) |
53 | 58 | find_package(Qt5Widgets REQUIRED) |
55 | 60 | find_package(Qt5Network REQUIRED) |
56 | 61 | find_package(Qt5Sql REQUIRED) |
57 | 62 | find_package(Qt5Test REQUIRED) |
63 | find_package(Qt5Script REQUIRED) | |
64 | if(WIN32) | |
65 | find_package(Qt5WinExtras REQUIRED) | |
66 | endif() | |
58 | 67 | |
59 | 68 | find_package(Qt5PrintSupport) |
60 | 69 | IF(Qt5PrintSupport_FOUND) |
62 | 71 | set(QTPRINT_LIBRARIES ${Qt5PrintSupport_LIBRARIES}) |
63 | 72 | ENDIF() |
64 | 73 | |
74 | find_package(Qt5Keychain QUIET) | |
75 | ||
76 | IF(Qt5Keychain_FOUND) | |
77 | set(QTKEYCHAIN_SYSTEM ON) | |
78 | ENDIF() | |
79 | ||
65 | 80 | SET(CHARM_MAC_HIGHRES_SUPPORT_ENABLED ON) |
66 | 81 | |
67 | 82 | IF(WIN32) |
68 | SET(QT_PLATFORM_SPECIFIC_LIBRARIES Qt5::WinMain) | |
83 | SET(QT_PLATFORM_SPECIFIC_LIBRARIES Qt5::WinMain Qt5::WinExtras) | |
69 | 84 | ELSE() |
70 | 85 | SET(QT_PLATFORM_SPECIFIC_LIBRARIES) |
71 | 86 | ENDIF() |
107 | 122 | set(QT_QTTEST_LIBRARY ${Qt5Test_LIBRARIES}) |
108 | 123 | |
109 | 124 | set(QT_LIBRARIES |
110 | ${Qt5Core_LIBRARIES} | |
111 | ${Qt5Widgets_LIBRARIES} | |
112 | ${Qt5Xml_LIBRARIES} | |
113 | ${Qt5Network_LIBRARIES} | |
114 | ${Qt5Sql_LIBRARIES} | |
115 | ${QTPRINT_LIBRARIES} | |
116 | ${QTDBUS_LIBRARIES} | |
125 | Qt5::Core | |
126 | Qt5::Widgets | |
127 | Qt5::Xml | |
128 | Qt5::Network | |
129 | Qt5::Script | |
130 | Qt5::Sql | |
131 | Qt5::PrintSupport | |
132 | ${QTKEYCHAIN_LIBRARIES} | |
117 | 133 | ${QT_PLATFORM_SPECIFIC_LIBRARIES} |
118 | 134 | ) |
119 | ||
120 | include_directories( | |
121 | ${Qt5Core_INCLUDE_DIRS} | |
122 | ${Qt5Widgets_INCLUDE_DIRS} | |
123 | ${Qt5Xml_INCLUDE_DIRS} | |
124 | ${Qt5Network_INCLUDE_DIRS} | |
125 | ${Qt5Sql_INCLUDE_DIRS} | |
126 | ) | |
127 | ||
128 | SET( CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS}" ) | |
135 | if (TARGET Qt5::DBus) | |
136 | list(APPEND QT_LIBRARIES Qt5::DBus) | |
137 | endif() | |
129 | 138 | ELSE() |
130 | 139 | # No Qt5 found, try Qt4 |
131 | find_package(Qt4 COMPONENTS QtMain QtCore QtGui QtSql QtXml QtNetwork REQUIRED) | |
140 | find_package(Qt4 COMPONENTS QtMain QtCore QtGui QtSql QtXml QtNetwork QtScript REQUIRED) | |
132 | 141 | INCLUDE( UseQt4 ) |
142 | ||
143 | find_package(QtKeychain QUIET) | |
144 | LIST(APPEND QT_LIBRARIES ${QTKEYCHAIN_LIBRARIES}) | |
145 | ||
146 | IF(QtKeychain_FOUND) | |
147 | set(QTKEYCHAIN_SYSTEM ON) | |
148 | ENDIF() | |
133 | 149 | |
134 | 150 | SET(CHARM_MAC_HIGHRES_SUPPORT_ENABLED OFF) |
135 | 151 | |
151 | 167 | endmacro() |
152 | 168 | ENDIF() |
153 | 169 | |
154 | include_directories(${QT_INCLUDES}) | |
170 | include_directories(${QT_INCLUDES} ${QTKEYCHAIN_INCLUDE_DIRS}) | |
155 | 171 | #set(QTCORE_LIBRARIES ${QT_QTCORE_LIBRARY}) |
156 | 172 | |
157 | 173 | macro(qt_wrap_cpp) |
188 | 204 | |
189 | 205 | IF( CMAKE_COMPILER_IS_GNUCXX ) |
190 | 206 | # Add additional GCC options. |
191 | ADD_DEFINITIONS( | |
192 | -Wall -Wundef -Wcast-align -Wchar-subscripts -Wpointer-arith | |
193 | -Wwrite-strings -Wpacked -Wformat-security | |
194 | -Wmissing-format-attribute -Wold-style-cast | |
195 | ) | |
196 | ADD_DEFINITIONS( -fvisibility=hidden ) | |
207 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wundef -Wcast-align -Wchar-subscripts -Wpointer-arith") | |
208 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wwrite-strings -Wpacked -Wformat-security") | |
209 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-format-attribute -Wold-style-cast") | |
210 | IF(NOT WIN32) | |
211 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden ") | |
212 | ENDIF() | |
197 | 213 | ELSEIF( CMAKE_CXX_COMPILER MATCHES "clang" ) |
198 | ADD_DEFINITIONS( -Wall -Wextra -Wno-unused-parameter ) | |
199 | ADD_DEFINITIONS( -fvisibility=hidden ) | |
214 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter" ) | |
215 | IF(NOT WIN32) | |
216 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden" ) | |
217 | ENDIF() | |
200 | 218 | ENDIF() |
201 | 219 | |
202 | 220 | |
203 | 221 | IF( UNIX AND NOT APPLE ) |
204 | 222 | set( Charm_EXECUTABLE charmtimetracker ) |
205 | SET( BIN_INSTALL_DIR bin ) | |
206 | SET( DOC_INSTALL_DIR share/doc/${Charm_EXECUTABLE} ) | |
207 | 223 | ELSE() |
208 | 224 | set( Charm_EXECUTABLE Charm ) |
209 | SET( BIN_INSTALL_DIR . ) | |
225 | ENDIF() | |
226 | ||
227 | SET( BIN_INSTALL_DIR bin ) | |
228 | SET( DOC_INSTALL_DIR share/doc/${Charm_EXECUTABLE} ) | |
229 | SET( ICONS_DIR "${CMAKE_SOURCE_DIR}/Charm/Icons" ) | |
230 | ||
231 | IF( CHARM_PREPARE_DEPLOY AND WIN32 OR APPLE) | |
232 | SET( BIN_INSTALL_DIR . ) | |
210 | 233 | SET( DOC_INSTALL_DIR . ) |
211 | 234 | ENDIF() |
212 | SET( ICONS_DIR "${CMAKE_SOURCE_DIR}/Charm/Icons" ) | |
213 | 235 | |
214 | 236 | OPTION( CHARM_IDLE_DETECTION "Build the Charm idle detector" ON ) |
215 | 237 | OPTION( CHARM_TIMESHEET_TOOLS "Build the Charm timesheet tools" OFF ) |
220 | 242 | OPTION( CHARM_CI_TCPSERVER "Build Charm with TCP command interface support" ON ) |
221 | 243 | OPTION( CHARM_CI_LOCALSERVER "Build Charm with local socket command interface support" ON ) |
222 | 244 | ENDIF() |
245 | ||
246 | OPTION(CHARM_PREPARE_DEPLOY "Deploy dependencies with install target(Windows, Apple)" ON) | |
223 | 247 | |
224 | 248 | ADD_SUBDIRECTORY( Core ) |
225 | 249 | ADD_SUBDIRECTORY( Charm ) |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
25 | 25 | #include "CharmCMake.h" |
26 | 26 | #include "Data.h" |
27 | 27 | #include "ViewHelpers.h" |
28 | #include "Uniquifier.h" | |
29 | 28 | |
30 | 29 | #include "Core/CharmConstants.h" |
31 | 30 | #include "Core/CharmExceptions.h" |
35 | 34 | #include "Idle/IdleDetector.h" |
36 | 35 | #include "Widgets/ConfigurationDialog.h" |
37 | 36 | #include "Widgets/NotificationPopup.h" |
37 | #include "Widgets/TasksView.h" | |
38 | 38 | |
39 | 39 | #include <QDir> |
40 | 40 | #include <QTimer> |
47 | 47 | #include <QFile> |
48 | 48 | #include <QApplication> |
49 | 49 | |
50 | #if QT_VERSION < 0x050000 | |
50 | #ifdef Q_OS_WIN | |
51 | #include <QtWinExtras/QtWinExtras> | |
52 | #endif | |
53 | ||
54 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) | |
51 | 55 | #include <QDesktopServices> |
52 | 56 | #else |
53 | 57 | #include <QStandardPaths> |
54 | 58 | #endif |
55 | 59 | |
60 | #ifdef Q_OS_WIN | |
61 | #include <windows.h> | |
62 | #include <winuser.h> | |
63 | #endif | |
64 | ||
56 | 65 | #include <algorithm> |
57 | 66 | #include <functional> |
67 | #include <iostream> | |
58 | 68 | |
59 | 69 | #ifdef CHARM_CI_SUPPORT |
60 | 70 | # include "CI/CharmCommandInterface.h" |
62 | 72 | |
63 | 73 | ApplicationCore* ApplicationCore::m_instance = nullptr; |
64 | 74 | |
65 | ApplicationCore::ApplicationCore( QObject* parent ) | |
75 | ApplicationCore::ApplicationCore(TaskId startupTask, QObject* parent ) | |
66 | 76 | : QObject( parent ) |
67 | , m_closedWindow( nullptr ) | |
68 | 77 | , m_actionStopAllTasks( this ) |
69 | , m_windows( QList<CharmWindow*> () << &m_tasksWindow << &m_eventWindow << &m_timeTracker ) | |
70 | 78 | , m_actionQuit( this ) |
71 | , m_state(Constructed) | |
72 | 79 | , m_systrayContextMenuStartTask( m_timeTracker.menu()->title() ) |
73 | 80 | , m_actionAboutDialog( this ) |
74 | 81 | , m_actionPreferences( this ) |
82 | 89 | , m_actionActivityReport( this ) |
83 | 90 | , m_actionWeeklyTimesheetReport( this ) |
84 | 91 | , m_actionMonthlyTimesheetReport( this ) |
85 | , m_idleDetector( nullptr ) | |
86 | , m_cmdInterface( nullptr ) | |
87 | , m_timeTrackerHiddenFromSystrayToggle( false ) | |
88 | , m_tasksWindowHiddenFromSystrayToggle( false ) | |
89 | , m_eventWindowHiddenFromSystrayToggle( false ) | |
92 | , m_uiElements( { &m_timeTracker, &m_tasksView, &m_eventView } ) | |
93 | , m_startupTask( startupTask ) | |
94 | #ifdef Q_OS_WIN | |
95 | , m_windowsJumpList( new QWinJumpList( this ) ) | |
96 | #endif | |
90 | 97 | , m_dateChangeWatcher( new DateChangeWatcher( this ) ) |
91 | 98 | { |
92 | 99 | // QApplication setup |
100 | 107 | |
101 | 108 | QLocalSocket uniqueApplicationSocket; |
102 | 109 | QString serverName( "com.kdab.charm" ); |
110 | QString charmHomeEnv( QString::fromLocal8Bit( qgetenv( "CHARM_HOME" ) ) ); | |
111 | if ( !charmHomeEnv.isEmpty() ) { | |
112 | serverName.append( QString::fromLatin1( "_%1" ).arg( | |
113 | charmHomeEnv.replace( QRegExp( QLatin1String( ":?/|:?\\\\" ) ), | |
114 | QLatin1String( "_" ) ) ) ); | |
115 | } | |
103 | 116 | #ifndef NDEBUG |
104 | 117 | serverName.append( "_debug" ); |
105 | 118 | #endif |
106 | uniqueApplicationSocket.connectToServer(serverName, QIODevice::ReadOnly); | |
107 | if (uniqueApplicationSocket.waitForConnected(1000)) | |
119 | uniqueApplicationSocket.connectToServer(serverName, QIODevice::ReadWrite); | |
120 | if (uniqueApplicationSocket.waitForConnected(1000)) { | |
121 | if ( startupTask != -1 ) { | |
122 | QByteArray data( QString::fromLatin1( "start-task: %1" ).arg( startupTask ).toLatin1().constData() ); | |
123 | qint64 written = uniqueApplicationSocket.write( data ); | |
124 | if ( written == -1 || written != data.length() ) { | |
125 | std::cerr << "Failed to pass " << qPrintable( data ) << " to running charm instance, error: " | |
126 | << qPrintable( uniqueApplicationSocket.errorString() ) << std::endl; | |
127 | } | |
128 | } | |
108 | 129 | throw AlreadyRunningException(); |
130 | } | |
109 | 131 | |
110 | 132 | connect(&m_uniqueApplicationServer, SIGNAL(newConnection()), |
111 | 133 | this, SLOT(slotHandleUniqueApplicationConnection())); |
128 | 150 | slotControllerReadyToQuit())); |
129 | 151 | |
130 | 152 | connectControllerAndModel(&m_controller, m_model.charmDataModel()); |
131 | Charm::connectControllerAndView(&m_controller, &mainView()); | |
132 | Q_FOREACH( auto window, m_windows ) { | |
133 | if ( window != &mainView() ) { // main view acts as the main relay | |
134 | connect( window, SIGNAL(emitCommand(CharmCommand*)), | |
135 | &mainView(), SLOT(sendCommand(CharmCommand*)) ); | |
136 | connect( window, SIGNAL(emitCommandRollback(CharmCommand*)), | |
137 | &mainView(), SLOT(sendCommandRollback(CharmCommand*)) ); | |
138 | } else | |
139 | connect( window, SIGNAL(showNotification(QString,QString)), | |
140 | SLOT(slotShowNotification(QString,QString)) ); | |
141 | ||
142 | // save the configuration (configuration is managed by the application) | |
143 | connect( window, SIGNAL(saveConfiguration()), | |
144 | SLOT(slotSaveConfiguration()) ); | |
145 | ||
146 | connect( window, SIGNAL(visibilityChanged(bool)), | |
147 | this, SLOT(slotCharmWindowVisibilityChanged(bool)) ); | |
148 | } | |
153 | Charm::connectControllerAndView(&m_controller, &m_timeTracker); | |
154 | ||
155 | // save the configuration (configuration is managed by the application) | |
156 | connect( &m_timeTracker, SIGNAL(saveConfiguration()), | |
157 | SLOT(slotSaveConfiguration()) ); | |
158 | connect( &m_timeTracker, SIGNAL(showNotification(QString,QString)), | |
159 | SLOT(slotShowNotification(QString,QString)) ); | |
160 | ||
161 | // save the configuration (configuration is managed by the application) | |
162 | connect( &m_tasksView, SIGNAL(saveConfiguration()), | |
163 | SLOT(slotSaveConfiguration()) ); | |
164 | connect( &m_tasksView, SIGNAL(emitCommand(CharmCommand*)), | |
165 | &m_timeTracker, SLOT(sendCommand(CharmCommand*)) ); | |
166 | connect( &m_tasksView, SIGNAL(emitCommandRollback(CharmCommand*)), | |
167 | &m_timeTracker, SLOT(sendCommandRollback(CharmCommand*)) ); | |
168 | connect( &m_eventView, SIGNAL(emitCommand(CharmCommand*)), | |
169 | &m_timeTracker, SLOT(sendCommand(CharmCommand*)) ); | |
170 | connect( &m_eventView, SIGNAL(emitCommandRollback(CharmCommand*)), | |
171 | &m_timeTracker, SLOT(sendCommandRollback(CharmCommand*)) ); | |
172 | ||
149 | 173 | // my own signals: |
150 | 174 | connect(this, SIGNAL(goToState(State)), SLOT(setState(State)), |
151 | 175 | Qt::QueuedConnection); |
156 | 180 | m_actionStopAllTasks.setShortcutContext( Qt::ApplicationShortcut ); |
157 | 181 | mainView().addAction(&m_actionStopAllTasks); // for the shortcut to work |
158 | 182 | connect( &m_actionStopAllTasks, SIGNAL(triggered()), SLOT(slotStopAllTasks()) ); |
159 | int index = m_windows.indexOf( &m_timeTracker ); | |
160 | auto window = m_windows[index]; | |
161 | m_systrayContextMenu.addAction( window->openCharmAction() ); | |
183 | m_systrayContextMenu.addAction( m_timeTracker.openCharmAction() ); | |
162 | 184 | m_systrayContextMenu.addSeparator(); |
163 | 185 | m_systrayContextMenu.addAction( &m_actionStopAllTasks ); |
164 | 186 | m_systrayContextMenu.addSeparator(); |
170 | 192 | |
171 | 193 | QApplication::setWindowIcon( Data::charmIcon() ); |
172 | 194 | |
173 | Q_FOREACH( auto window, m_windows ) { | |
174 | if ( window != &m_timeTracker ) | |
175 | m_systrayContextMenu.addAction( window->showAction() ); | |
176 | } | |
195 | m_systrayContextMenu.addAction( tr( "Show Tasks Editor" ), this, | |
196 | SLOT(slotShowTasksEditor()), QKeySequence( tr("Ctrl+1") ) ); | |
197 | m_systrayContextMenu.addAction( tr( "Show Event Editor" ), this, | |
198 | SLOT(slotShowEventEditor()), QKeySequence( tr("Ctrl+2") ) ); | |
199 | ||
177 | 200 | |
178 | 201 | m_systrayContextMenu.addSeparator(); |
179 | 202 | m_systrayContextMenu.addMenu( &m_systrayContextMenuStartTask ); |
276 | 299 | void ApplicationCore::slotHandleUniqueApplicationConnection() |
277 | 300 | { |
278 | 301 | QLocalSocket* socket = m_uniqueApplicationServer.nextPendingConnection(); |
302 | socket->waitForReadyRead(); | |
303 | QByteArray data = socket->readAll(); | |
304 | if ( data.startsWith( "start-task: " ) ) { //krazy:exclude=strings | |
305 | bool ok = true; | |
306 | TaskId id = data.mid( QString::fromLatin1( "start-task: " ).length() ).toInt( &ok ); | |
307 | if ( ok ) { | |
308 | m_timeTracker.slotStartEvent( id ); | |
309 | } else { | |
310 | qDebug() << "Received invalid argument:" << data; | |
311 | } | |
312 | } | |
279 | 313 | delete socket; |
280 | openAWindow( true ); | |
281 | } | |
282 | ||
283 | void ApplicationCore::openAWindow( bool raise ) { | |
284 | CharmWindow* windowToOpen = 0; | |
285 | foreach( CharmWindow* window, m_windows ) | |
286 | if ( !window->isHidden() ) | |
287 | windowToOpen = window; | |
288 | ||
289 | if ( !windowToOpen && m_closedWindow ) | |
290 | windowToOpen = m_closedWindow; | |
291 | ||
292 | if ( !windowToOpen ) | |
293 | windowToOpen = &mainView(); | |
294 | ||
295 | windowToOpen->show(); | |
296 | if ( raise ) | |
297 | windowToOpen->raise(); | |
298 | ||
299 | if( windowToOpen == m_closedWindow ) | |
300 | m_closedWindow = nullptr; | |
314 | showMainWindow( ApplicationCore::ShowMode::ShowAndRaise ); | |
315 | } | |
316 | ||
317 | void ApplicationCore::showMainWindow(ShowMode mode ) | |
318 | { | |
319 | m_timeTracker.show(); | |
320 | if ( mode == ShowMode::ShowAndRaise ) { | |
321 | m_timeTracker.raise(); | |
322 | #ifdef Q_OS_WIN | |
323 | //krazy:cond=captruefalse,null | |
324 | int idActive = GetWindowThreadProcessId( GetForegroundWindow(), NULL ); | |
325 | int threadId = GetCurrentThreadId(); | |
326 | if ( AttachThreadInput( threadId, idActive, TRUE ) != 0 ) { | |
327 | HWND wid = reinterpret_cast<HWND>( m_timeTracker.winId() ); | |
328 | SetForegroundWindow( wid ); | |
329 | SetFocus( wid ); | |
330 | AttachThreadInput( threadId, idActive, FALSE ); | |
331 | } | |
332 | //krazy:endcond=captruefalse,null | |
333 | #endif | |
334 | } | |
301 | 335 | } |
302 | 336 | |
303 | 337 | void ApplicationCore::createWindowMenu( QMenuBar *menuBar ) |
304 | 338 | { |
305 | 339 | auto menu = new QMenu( menuBar ); |
306 | 340 | menu->setTitle( tr( "Window" ) ); |
307 | Q_FOREACH( CharmWindow* window, m_windows ) { | |
308 | menu->addAction( window->showHideAction() ); | |
309 | } | |
341 | menu->addAction( tr( "Show Tasks Editor Window" ), this, | |
342 | SLOT(slotShowTasksEditor()), QKeySequence( tr("Ctrl+1") ) ); | |
343 | menu->addAction( tr( "Show Event Editor Window" ), this, | |
344 | SLOT(slotShowEventEditor()), QKeySequence( tr("Ctrl+2") ) ); | |
310 | 345 | menu->addSeparator(); |
311 | 346 | menu->addAction( &m_actionEnterVacation ); |
312 | 347 | menu->addSeparator(); |
357 | 392 | menuBar->addMenu( menu ); |
358 | 393 | } |
359 | 394 | |
395 | CharmWindow &ApplicationCore::mainView() | |
396 | { | |
397 | return m_timeTracker; | |
398 | } | |
399 | ||
360 | 400 | void ApplicationCore::setState(State state) |
361 | 401 | { |
362 | 402 | if (m_state == state) |
395 | 435 | }; |
396 | 436 | |
397 | 437 | m_state = state; |
398 | ||
399 | std::for_each( m_windows.begin(), m_windows.end(), | |
400 | std::bind2nd( std::mem_fun( &CharmWindow::stateChanged ), m_state ) ); | |
438 | for ( auto e : m_uiElements ) { | |
439 | e->stateChanged( m_state ); | |
440 | } | |
401 | 441 | |
402 | 442 | switch (m_state) |
403 | 443 | { |
555 | 595 | |
556 | 596 | void ApplicationCore::enterConnectedState() |
557 | 597 | { |
598 | if ( m_startupTask != -1) { | |
599 | m_timeTracker.slotStartEvent( m_startupTask ); | |
600 | } | |
601 | #ifdef Q_OS_WIN | |
602 | updateTaskList(); | |
603 | #endif | |
558 | 604 | #ifdef CHARM_CI_SUPPORT |
559 | 605 | m_cmdInterface->start(); |
560 | 606 | #endif |
599 | 645 | const QByteArray charmHome = qgetenv("CHARM_HOME"); |
600 | 646 | if ( !charmHome.isEmpty() ) |
601 | 647 | return QFile::decodeName( charmHome ) + QLatin1String("/data/"); |
602 | #if QT_VERSION < 0x050000 | |
648 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) | |
603 | 649 | return QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1Char('/'); |
604 | 650 | #else |
605 | 651 | return QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/'); |
665 | 711 | return true; |
666 | 712 | } |
667 | 713 | |
668 | void ApplicationCore::toggleShowHide() | |
669 | { | |
670 | if ( m_timeTracker.isHidden() && m_tasksWindow.isHidden() && m_eventWindow.isHidden() ) { | |
671 | int raised = 0; | |
672 | if ( m_eventWindowHiddenFromSystrayToggle ) { | |
673 | CharmWindow::showHideView( &m_eventWindow ); | |
674 | m_eventWindowHiddenFromSystrayToggle = false; | |
675 | ++raised; | |
676 | } | |
677 | if ( m_tasksWindowHiddenFromSystrayToggle ) { | |
678 | CharmWindow::showHideView( &m_tasksWindow ); | |
679 | m_tasksWindowHiddenFromSystrayToggle = false; | |
680 | ++raised; | |
681 | } | |
682 | if ( m_timeTrackerHiddenFromSystrayToggle || raised == 0 ) { // if no view was visible and the user did not toggle other views before, raise the timetracker | |
683 | m_timeTracker.showHideView(); | |
684 | m_timeTrackerHiddenFromSystrayToggle = false; | |
685 | } | |
686 | } else { | |
687 | if ( m_timeTracker.isVisible() ) { | |
688 | m_timeTracker.hide(); | |
689 | m_timeTrackerHiddenFromSystrayToggle = true; | |
690 | } | |
691 | if ( m_tasksWindow.isVisible() ) { | |
692 | m_tasksWindow.hide(); | |
693 | m_tasksWindowHiddenFromSystrayToggle = true; | |
694 | } | |
695 | if ( m_eventWindow.isVisible() ) { | |
696 | m_eventWindow.hide(); | |
697 | m_eventWindowHiddenFromSystrayToggle = true; | |
698 | } | |
699 | } | |
700 | } | |
701 | ||
702 | 714 | QString ApplicationCore::titleString( const QString& text ) const |
703 | 715 | { |
704 | 716 | QString dbInfo; |
756 | 768 | m_cmdInterface->configurationChanged(); |
757 | 769 | #endif |
758 | 770 | } |
759 | std::for_each( m_windows.begin(), m_windows.end(), | |
760 | std::mem_fun( &CharmWindow::configurationChanged ) ); | |
771 | for ( auto e : m_uiElements ) { | |
772 | e->configurationChanged(); | |
773 | } | |
761 | 774 | } |
762 | 775 | |
763 | 776 | ModelConnector& ApplicationCore::model() |
788 | 801 | void ApplicationCore::slotMaybeIdle() |
789 | 802 | { |
790 | 803 | if ( DATAMODEL->activeEventCount() > 0 ) { |
791 | if ( idleDetector()->idlePeriods().count() == 1 ) { | |
792 | m_timeTracker.maybeIdle( idleDetector() ); | |
793 | } // otherwise, the dialog will be showing already | |
804 | m_timeTracker.maybeIdle( idleDetector() ); | |
794 | 805 | } |
795 | 806 | // there are four parameters to the idle property: |
796 | 807 | // - the initial start time of the currently active event(s) |
805 | 816 | // it |
806 | 817 | } |
807 | 818 | |
808 | CharmWindow& ApplicationCore::mainView() | |
809 | { | |
810 | return m_timeTracker; | |
811 | } | |
812 | ||
813 | 819 | TrayIcon& ApplicationCore::trayIcon() |
814 | 820 | { |
815 | 821 | return m_trayIcon; |
816 | 822 | } |
817 | 823 | |
818 | void ApplicationCore::slotCharmWindowVisibilityChanged( bool visible ) | |
819 | { | |
820 | if( !visible ) | |
821 | m_closedWindow = dynamic_cast< CharmWindow* >( sender() ); | |
824 | void ApplicationCore::updateTaskList() | |
825 | { | |
826 | #ifdef Q_OS_WIN | |
827 | const auto recentData = DATAMODEL->mostRecentlyUsedTasks(); | |
828 | auto recentJumpList = m_windowsJumpList->recent(); | |
829 | recentJumpList->clear(); | |
830 | int count = 0; | |
831 | Q_FOREACH (const auto &id, recentData) { | |
832 | if (count++ > 5) | |
833 | break; | |
834 | recentJumpList->addLink( Data::goIcon(), DATAMODEL->getTask( id ).name(), qApp->applicationFilePath(), | |
835 | { QLatin1String( "--start-task" ), QString::number( id ) } ); | |
836 | } | |
837 | recentJumpList->setVisible( true ); | |
838 | #endif | |
822 | 839 | } |
823 | 840 | |
824 | 841 | void ApplicationCore::saveState( QSessionManager & manager ) |
832 | 849 | // Before QApplication closes all windows, save their state. |
833 | 850 | // Doing this in saveState is too late because then we would store that they are all hidden. |
834 | 851 | if (m_state == Connected) { |
835 | m_tasksWindow.saveGuiState(); | |
836 | m_eventWindow.saveGuiState(); | |
837 | m_timeTracker.saveGuiState(); | |
852 | for ( auto e : m_uiElements ) { | |
853 | e->saveGuiState(); | |
854 | } | |
838 | 855 | } |
839 | 856 | } |
840 | 857 | |
848 | 865 | } |
849 | 866 | } |
850 | 867 | |
868 | void ApplicationCore::slotShowTasksEditor() | |
869 | { | |
870 | m_tasksView.show(); | |
871 | } | |
872 | ||
873 | void ApplicationCore::slotShowEventEditor() | |
874 | { | |
875 | m_eventView.show(); | |
876 | } | |
877 | ||
851 | 878 | #include "moc_ApplicationCore.cpp" |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
36 | 36 | #include "Core/Controller.h" |
37 | 37 | #include "Core/Configuration.h" |
38 | 38 | #include "Core/StorageInterface.h" |
39 | #include "Core/ViewInterface.h" | |
39 | 40 | |
40 | 41 | #include "Widgets/CharmWindow.h" |
41 | #include "Widgets/TasksWindow.h" | |
42 | #include "Widgets/EventWindow.h" | |
42 | #include "Widgets/EventView.h" | |
43 | 43 | #include "Widgets//TimeTrackingWindow.h" |
44 | #include "Widgets/TasksView.h" | |
44 | 45 | #include "Widgets/TrayIcon.h" |
45 | 46 | |
46 | 47 | #include "ModelConnector.h" |
50 | 51 | class CharmCommandInterface; |
51 | 52 | class IdleDetector; |
52 | 53 | class QSessionManager; |
54 | class QWinJumpList; | |
53 | 55 | |
54 | 56 | class ApplicationCore : public QObject |
55 | 57 | { |
56 | 58 | Q_OBJECT |
57 | 59 | |
58 | 60 | public: |
59 | explicit ApplicationCore( QObject* parent = nullptr ); | |
60 | ~ApplicationCore(); | |
61 | enum class ShowMode{ | |
62 | Show, | |
63 | ShowAndRaise | |
64 | }; | |
65 | explicit ApplicationCore( TaskId startupTask, QObject* parent = nullptr ); | |
66 | ~ApplicationCore() override; | |
61 | 67 | |
62 | 68 | static ApplicationCore& instance(); |
63 | 69 | static bool hasInstance(); |
89 | 95 | |
90 | 96 | TrayIcon& trayIcon(); |
91 | 97 | |
98 | void updateTaskList(); | |
99 | ||
92 | 100 | public slots: |
101 | void showMainWindow( ShowMode mode = ShowMode::Show ); | |
102 | ||
93 | 103 | void setState( State state ); |
94 | 104 | void slotStopAllTasks(); |
95 | 105 | void slotQuitApplication(); |
96 | 106 | void slotControllerReadyToQuit(); |
97 | 107 | void slotSaveConfiguration(); |
98 | 108 | void slotGoToConnectedState(); |
99 | void toggleShowHide(); | |
100 | 109 | void setHttpActionsVisible( bool visible ); |
101 | 110 | void saveState( QSessionManager & manager ); |
102 | 111 | void commitData( QSessionManager & manager ); |
103 | 112 | |
104 | 113 | private slots: |
105 | // void slotMainWindowVisibilityChanged( bool ); | |
106 | // void slotTimeTrackerVisibilityChanged( bool ); | |
107 | 114 | void slotCurrentBackendStatusChanged( const QString& text ); |
108 | 115 | void slotMaybeIdle(); |
109 | void slotCharmWindowVisibilityChanged( bool visibility ); | |
110 | 116 | void slotHandleUniqueApplicationConnection(); |
111 | 117 | void slotStartTaskMenuAboutToShow(); |
112 | 118 | void slotShowNotification( const QString& title, const QString& message ); |
119 | void slotShowTasksEditor(); | |
120 | void slotShowEventEditor(); | |
113 | 121 | |
114 | 122 | signals: |
115 | 123 | void goToState( State state ); |
116 | 124 | |
117 | 125 | protected: |
118 | void openAWindow( bool raise = false ); | |
119 | ||
120 | CharmWindow* m_closedWindow; | |
121 | 126 | QAction m_actionStopAllTasks; |
122 | const QList<CharmWindow*> m_windows; | |
123 | 127 | TimeTrackingWindow m_timeTracker; |
124 | 128 | QAction m_actionQuit; |
125 | 129 | |
141 | 145 | void enterShuttingDownState(); |
142 | 146 | void leaveShuttingDownState(); |
143 | 147 | |
144 | State m_state; | |
148 | State m_state = Constructed; | |
145 | 149 | ModelConnector m_model; |
146 | 150 | Controller m_controller; |
147 | 151 | TrayIcon m_trayIcon; |
159 | 163 | QAction m_actionActivityReport; |
160 | 164 | QAction m_actionWeeklyTimesheetReport; |
161 | 165 | QAction m_actionMonthlyTimesheetReport; |
162 | TasksWindow m_tasksWindow; | |
163 | EventWindow m_eventWindow; | |
164 | IdleDetector* m_idleDetector; | |
165 | CharmCommandInterface* m_cmdInterface; | |
166 | bool m_timeTrackerHiddenFromSystrayToggle; | |
167 | bool m_tasksWindowHiddenFromSystrayToggle; | |
168 | bool m_eventWindowHiddenFromSystrayToggle; | |
166 | EventView m_eventView; | |
167 | TasksView m_tasksView; | |
168 | QVector<UIStateInterface*> m_uiElements; | |
169 | IdleDetector* m_idleDetector = nullptr; | |
170 | CharmCommandInterface* m_cmdInterface = nullptr; | |
169 | 171 | QLocalServer m_uniqueApplicationServer; |
172 | TaskId m_startupTask; | |
173 | #ifdef Q_OS_WIN | |
174 | QWinJumpList* m_windowsJumpList = nullptr; | |
175 | #endif | |
170 | 176 | |
171 | 177 | // All statics are created as members of Application. This is |
172 | 178 | // supposed to help on Windows, where constructors for statics |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
8 | 8 |
0 | # Copyright (C) 2015-2016 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
1 | ||
2 | # Redistribution and use is allowed according to the terms of the BSD license | |
3 | ||
4 | # | |
5 | # Try to find XCB library and include path. | |
6 | # Once done this will define | |
7 | # | |
8 | # XCB_INCLUDE_PATH | |
9 | # XCB_INCLUDE_PATH_FOUND | |
10 | # XCB_LIBRARIES | |
11 | # XCB_LIBRARIES_FOUND | |
12 | # XCB_SCREENSAVER_LIBRARIES | |
13 | # XCB_SCREENSAVER_LIBRARIES_FOUND | |
14 | ||
15 | IF ( UNIX AND NOT APPLE ) | |
16 | ||
17 | FIND_PATH( XCB_INCLUDE_PATH xcb/xcb.h | |
18 | /usr/include | |
19 | DOC "The directory where xcb/xcb.h resides") | |
20 | ||
21 | FIND_LIBRARY( XCB_LIBRARY | |
22 | NAMES xcb | |
23 | PATHS | |
24 | /usr/lib | |
25 | DOC "The xcb library") | |
26 | ||
27 | FIND_LIBRARY( XCB_SCREENSAVER_LIBRARY | |
28 | NAMES xcb-screensaver | |
29 | PATHS | |
30 | /usr/lib | |
31 | DOC "The xcb-screensaver library") | |
32 | ||
33 | SET( XCB_INCLUDE_PATH ${XCB_INCLUDE_PATH} ) | |
34 | SET( XCB_LIBRARIES ${XCB_LIBRARY} ) | |
35 | SET( XCB_SCREENSAVER_LIBRARIES ${XCB_SCREENSAVER_LIBRARY} ) | |
36 | ENDIF ( UNIX AND NOT APPLE ) | |
37 | ||
38 | IF ( XCB_INCLUDE_PATH ) | |
39 | SET( XCB_INCLUDE_PATH_FOUND 1 CACHE STRING "Set to 1 if XCB INCLUDE PATH IS FOUND is found, 0 otherwise" ) | |
40 | ELSE ( XCB_INCLUDE_PATH ) | |
41 | SET( XCB_INCLUDE_PATH_FOUND 0 CACHE STRING "Set to 1 if XCB is found, 0 otherwise" ) | |
42 | ENDIF ( XCB_INCLUDE_PATH ) | |
43 | ||
44 | IF ( XCB_LIBRARIES ) | |
45 | SET( XCB_LIBRARIES_FOUND 1 CACHE STRING "Set to 1 if XCB LIBRARIES are found, 0 otherwise" ) | |
46 | ELSE ( XCB_LIBRARIES ) | |
47 | SET( XCB_LIBRARIES_FOUND 0 CACHE STRING "Set to 1 if XCB LIBRARIES are found, 0 otherwise" ) | |
48 | ENDIF ( XCB_LIBRARIES ) | |
49 | ||
50 | IF ( XCB_SCREENSAVER_LIBRARIES ) | |
51 | SET( XCB_SCREENSAVER_LIBRARIES_FOUND 1 CACHE STRING "Set to 1 if XCB screensaver library is found, 0 otherwise" ) | |
52 | ELSE ( XCB_SCREENSAVER_LIBRARIES ) | |
53 | SET( XCB_SCREENSAVER_LIBRARIES_FOUND 0 CACHE STRING "Set to 1 if XCB screensaver library is found, 0 otherwise" ) | |
54 | ENDIF ( XCB_SCREENSAVER_LIBRARIES ) | |
55 | ||
56 | MARK_AS_ADVANCED( XCB_INCLUDE_PATH_FOUND XCB_LIBRARIES_FOUND XCB_SCREENSAVER_LIBRARIES_FOUND ) |
49 | 49 | Widgets/EventEditor.cpp |
50 | 50 | Widgets/EventEditorDelegate.cpp |
51 | 51 | Widgets/EventView.cpp |
52 | Widgets/EventWindow.cpp | |
53 | 52 | Widgets/ExpandStatesHelper.cpp |
54 | 53 | Widgets/HttpJobProgressDialog.cpp |
55 | 54 | Widgets/IdleCorrectionDialog.cpp |
63 | 62 | Widgets/TaskEditor.cpp |
64 | 63 | Widgets/TasksView.cpp |
65 | 64 | Widgets/TasksViewDelegate.cpp |
66 | Widgets/TasksWindow.cpp | |
67 | 65 | Widgets/TimeTrackingView.cpp |
68 | 66 | Widgets/TimeTrackingWindow.cpp |
69 | 67 | Widgets/TimeTrackingTaskSelector.cpp |
72 | 70 | Widgets/WeeklyTimesheet.cpp |
73 | 71 | Widgets/NotificationPopup.cpp |
74 | 72 | Widgets/FindAndReplaceEventsDialog.cpp |
73 | Widgets/WidgetUtils.cpp | |
75 | 74 | ) |
76 | 75 | |
77 | 76 | SET(CharmApplication_LIBS) |
96 | 95 | ELSEIF( WIN32 ) |
97 | 96 | LIST( APPEND CharmApplication_SRCS Idle/WindowsIdleDetector.cpp ) |
98 | 97 | ELSEIF( UNIX ) |
99 | FIND_PACKAGE( X11 ) | |
100 | IF( X11_FOUND AND X11_Xscreensaver_LIB ) | |
101 | MESSAGE( "X11 idle detection enabled." ) | |
102 | INCLUDE_DIRECTORIES( ${X11_INCLUDE_DIR} ) | |
103 | LIST( APPEND CharmApplication_SRCS Idle/X11IdleDetector.cpp ) | |
104 | LIST( APPEND CharmApplication_LIBS ${X11_X11_LIB} ${X11_Xscreensaver_LIB} ) | |
105 | SET( CHARM_IDLE_DETECTION_AVAILABLE_X11 "1" CACHE INTERNAL "" ) | |
98 | SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules/ ) | |
99 | IF( Qt5Core_FOUND ) | |
100 | FIND_PACKAGE( XCB ) | |
101 | IF( XCB_INCLUDE_PATH_FOUND AND XCB_LIBRARIES_FOUND AND XCB_SCREENSAVER_LIBRARIES_FOUND ) | |
102 | INCLUDE_DIRECTORIES( ${XCB_INCLUDE_DIRS} ) | |
103 | LIST( APPEND CharmApplication_LIBS ${XCB_LIBRARIES} ${XCB_SCREENSAVER_LIBRARIES} ) | |
104 | LIST( APPEND CharmApplication_SRCS Idle/X11IdleDetector.cpp ) | |
105 | SET( CHARM_IDLE_DETECTION_AVAILABLE "1" CACHE INTERNAL "" ) | |
106 | ELSE() | |
107 | SET( CHARM_IDLE_DETECTION_AVAILABLE "0" CACHE INTERNAL "" ) | |
108 | MESSAGE( "QT5: Install Xcb headers and library for Xcb idle detection." ) | |
109 | ENDIF() | |
106 | 110 | ELSE() |
107 | MESSAGE( "Install X11/XScreenSaver headers and library for X11 idle detection." ) | |
111 | FIND_PACKAGE( X11 ) | |
112 | IF( X11_FOUND AND X11_Xscreensaver_LIB) | |
113 | INCLUDE_DIRECTORIES( ${X11_INCLUDE_DIR} ) | |
114 | LIST( APPEND CharmApplication_LIBS ${X11_X11_LIB} ${X11_Xscreensaver_LIB} ) | |
115 | LIST( APPEND CharmApplication_SRCS Idle/X11IdleDetector.cpp ) | |
116 | SET( CHARM_IDLE_DETECTION_AVAILABLE "1" CACHE INTERNAL "" ) | |
117 | ELSE() | |
118 | SET( CHARM_IDLE_DETECTION_AVAILABLE "0" CACHE INTERNAL "" ) | |
119 | MESSAGE( "QT4: Install X11/XScreenSaver headers and library for X11 idle detection." ) | |
120 | ENDIF() | |
108 | 121 | ENDIF() |
109 | 122 | ENDIF() |
110 | 123 | ENDIF() |
111 | 124 | |
112 | LIST( APPEND CharmApplication_SRCS Keychain/keychain.cpp ) | |
113 | ||
114 | IF (APPLE) | |
115 | LIST( APPEND CharmApplication_SRCS Keychain/keychain_mac.cpp MacApplicationCore.mm ) | |
116 | ||
117 | FIND_LIBRARY( COREFOUNDATION_LIBRARY CoreFoundation ) | |
118 | LIST( APPEND CharmApplication_LIBS ${COREFOUNDATION_LIBRARY} ) | |
119 | ||
120 | FIND_LIBRARY( SECURITY_LIBRARY Security ) | |
121 | LIST( APPEND CharmApplication_LIBS ${SECURITY_LIBRARY} ) | |
122 | ||
123 | FIND_LIBRARY( APPKIT_LIBRARY AppKit ) | |
124 | LIST( APPEND CharmApplication_LIBS ${APPKIT_LIBRARY} ) | |
125 | ELSEIF ( WIN32 ) | |
126 | LIST( APPEND CharmApplication_SRCS Keychain/keychain_win.cpp ) | |
127 | ELSEIF ( UNIX ) | |
128 | IF (HAVE_DBUS) | |
129 | LIST( APPEND CharmApplication_SRCS Keychain/gnomekeyring.cpp Keychain/keychain_unix.cpp ) | |
130 | QT_ADD_DBUS_INTERFACE( CharmApplication_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/Keychain/org.kde.KWallet.xml kwallet_interface KWalletInterface ) | |
131 | LIST( APPEND CharmApplication_LIBS ${QT_QTDBUS_LIBRARY} ) | |
132 | ELSE() | |
133 | LIST( APPEND CharmApplication_SRCS Keychain/keychain_unsecure.cpp ) | |
134 | ENDIF() | |
125 | IF (NOT QTKEYCHAIN_SYSTEM) | |
126 | LIST( APPEND CharmApplication_SRCS Keychain/keychain.cpp ) | |
127 | IF (APPLE) | |
128 | LIST( APPEND CharmApplication_SRCS Keychain/keychain_mac.cpp MacApplicationCore.mm ) | |
129 | ||
130 | FIND_LIBRARY( COREFOUNDATION_LIBRARY CoreFoundation ) | |
131 | LIST( APPEND CharmApplication_LIBS ${COREFOUNDATION_LIBRARY} ) | |
132 | ||
133 | FIND_LIBRARY( SECURITY_LIBRARY Security ) | |
134 | LIST( APPEND CharmApplication_LIBS ${SECURITY_LIBRARY} ) | |
135 | ||
136 | FIND_LIBRARY( APPKIT_LIBRARY AppKit ) | |
137 | LIST( APPEND CharmApplication_LIBS ${APPKIT_LIBRARY} ) | |
138 | ELSEIF ( WIN32 ) | |
139 | LIST( APPEND CharmApplication_SRCS Keychain/keychain_win.cpp ) | |
140 | ELSEIF ( UNIX ) | |
141 | IF (HAVE_DBUS) | |
142 | LIST( APPEND CharmApplication_SRCS Keychain/gnomekeyring.cpp Keychain/keychain_unix.cpp ) | |
143 | QT_ADD_DBUS_INTERFACE( CharmApplication_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/Keychain/org.kde.KWallet.xml kwallet_interface KWalletInterface ) | |
144 | LIST( APPEND CharmApplication_LIBS ${QT_QTDBUS_LIBRARY} ) | |
145 | ELSE() | |
146 | LIST( APPEND CharmApplication_SRCS Keychain/keychain_unsecure.cpp ) | |
147 | ENDIF() | |
148 | ENDIF() | |
135 | 149 | ENDIF() |
136 | 150 | |
137 | 151 | QT_WRAP_UI( |
161 | 175 | CharmApplication STATIC |
162 | 176 | ${CharmApplication_SRCS} ${UiGenerated_SRCS} |
163 | 177 | ) |
164 | TARGET_LINK_LIBRARIES(CharmApplication ${CharmApplication_LIBS}) | |
178 | TARGET_LINK_LIBRARIES(CharmApplication ${CharmApplication_LIBS} ${QT_LIBRARIES}) | |
165 | 179 | |
166 | 180 | SET( Charm_SRCS Charm.cpp ) |
167 | 181 | |
186 | 200 | FILE( COPY ${ICON} DESTINATION ${RESOURCES} ) |
187 | 201 | ENDIF() |
188 | 202 | |
189 | IF( MSVC ) | |
203 | IF(WIN32) | |
190 | 204 | SET( Resources_SRCS ${Resources_SRCS} Charm.rc ) |
191 | 205 | ENDIF() |
192 | 206 | |
216 | 230 | ) |
217 | 231 | |
218 | 232 | # Only support CPack packaging on newer versions of CMake. |
219 | IF( NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.4" ) | |
233 | IF( NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.4" AND CHARM_PREPARE_DEPLOY ) | |
220 | 234 | IF( CMAKE_BUILD_TYPE MATCHES "^([Dd][Ee][Bb][Uu][Gg])" ) |
221 | 235 | SET( CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY TRUE ) |
222 | 236 | ENDIF() |
248 | 262 | # Deploy qsqlite plugin |
249 | 263 | GET_TARGET_PROPERTY( _loc Qt5::QSQLiteDriverPlugin LOCATION ) |
250 | 264 | INSTALL( FILES ${_loc} DESTINATION plugins/sqldrivers ) |
251 | ENDIF() | |
252 | ENDIF() | |
265 | # Install qt.conf (prevents plugins from the built-in Qt path to be used) | |
266 | INSTALL(FILES qt.conf.in.windows RENAME qt.conf DESTINATION .) | |
267 | ENDIF() | |
268 | ENDIF() |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Mike McQuaid <mike.mcquaid@kdab.com> |
36 | 36 | #include "Core/CharmExceptions.h" |
37 | 37 | #include "CharmCMake.h" |
38 | 38 | |
39 | static std::shared_ptr<ApplicationCore> createApplicationCore() | |
39 | static std::shared_ptr<ApplicationCore> createApplicationCore( TaskId startupTask ) | |
40 | 40 | { |
41 | 41 | #ifdef Q_OS_OSX |
42 | return std::make_shared<MacApplicationCore>(); | |
42 | return std::make_shared<MacApplicationCore>( startupTask ); | |
43 | 43 | #else |
44 | return std::make_shared<ApplicationCore>(); | |
44 | return std::make_shared<ApplicationCore>( startupTask ); | |
45 | 45 | #endif |
46 | 46 | } |
47 | 47 | |
53 | 53 | |
54 | 54 | int main ( int argc, char** argv ) |
55 | 55 | { |
56 | if (argc == 2 && qstrcmp(argv[1], "--version") == 0) { | |
57 | using namespace std; | |
58 | cout << "Charm version " << CHARM_VERSION << endl; | |
59 | return 0; | |
56 | TaskId startupTask = -1; | |
57 | if (argc >= 2) { | |
58 | if ( qstrcmp(argv[1], "--version") == 0) { | |
59 | using namespace std; | |
60 | cout << "Charm version " << CHARM_VERSION << endl; | |
61 | return 0; | |
62 | } else if ( argc == 3 && qstrcmp(argv[1], "--start-task") == 0 ) { | |
63 | bool ok = true; | |
64 | startupTask = QString::fromLocal8Bit( argv[2] ).toInt( &ok ); | |
65 | if ( !ok || startupTask < 0 ) { | |
66 | std::cerr << "Invalid task id passed: " << argv[2]; | |
67 | return 1; | |
68 | } | |
69 | } | |
60 | 70 | } |
61 | 71 | |
62 | 72 | const QByteArray charmHomeEnv = qgetenv("CHARM_HOME"); |
68 | 78 | QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, user ); |
69 | 79 | QSettings::setPath( QSettings::NativeFormat, QSettings::SystemScope, sys ); |
70 | 80 | QSettings::setPath( QSettings::IniFormat, QSettings::SystemScope, sys ); |
81 | #ifdef Q_OS_WIN | |
82 | // Use ini for storing settings as the registry path is not affected by CHARM_HOME. | |
83 | QSettings::setDefaultFormat( QSettings::IniFormat ); | |
84 | #endif | |
71 | 85 | } |
72 | 86 | |
73 | 87 | try { |
88 | #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) | |
89 | QGuiApplication::setAttribute( Qt::AA_EnableHighDpiScaling ); | |
90 | #endif | |
74 | 91 | QApplication app( argc, argv ); |
75 | const std::shared_ptr<ApplicationCore> core( createApplicationCore() ); | |
92 | const std::shared_ptr<ApplicationCore> core( createApplicationCore( startupTask ) ); | |
76 | 93 | QObject::connect( &app, SIGNAL(commitDataRequest(QSessionManager&)), core.get(), SLOT(commitData(QSessionManager&)) ); |
77 | 94 | QObject::connect( &app, SIGNAL(saveStateRequest(QSessionManager&)), core.get(), SLOT(saveState(QSessionManager&)) ); |
78 | 95 | return app.exec(); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
28 | 28 | CommandAddTask::CommandAddTask( const Task& task, QObject* parent ) |
29 | 29 | : CharmCommand( tr("Add Task"), parent ) |
30 | 30 | , m_task( task ) |
31 | , m_success( false ) | |
32 | 31 | { |
33 | 32 | } |
34 | 33 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
33 | 33 | |
34 | 34 | public: |
35 | 35 | explicit CommandAddTask( const Task&, QObject* parent = nullptr ); |
36 | ~CommandAddTask(); | |
36 | ~CommandAddTask() override; | |
37 | 37 | |
38 | 38 | bool prepare() override; |
39 | 39 | bool execute( ControllerInterface* ) override; |
41 | 41 | |
42 | 42 | private: |
43 | 43 | Task m_task; |
44 | bool m_success; | |
44 | bool m_success = false; | |
45 | 45 | }; |
46 | 46 | |
47 | 47 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
40 | 40 | |
41 | 41 | bool CommandDeleteEvent::execute( ControllerInterface* controller ) |
42 | 42 | { |
43 | qDebug() << "CommandDeleteEvent::execute: deleting:"; | |
44 | m_event.dump(); | |
45 | 43 | return controller->deleteEvent( m_event ); |
46 | 44 | } |
47 | 45 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
33 | 33 | |
34 | 34 | public: |
35 | 35 | explicit CommandDeleteEvent( const Event&, QObject* parent = nullptr ); |
36 | ~CommandDeleteEvent(); | |
36 | ~CommandDeleteEvent() override; | |
37 | 37 | |
38 | 38 | bool prepare() override; |
39 | 39 | bool execute( ControllerInterface* ) override; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
30 | 30 | CommandDeleteTask::CommandDeleteTask( const Task& task, QObject* parent ) |
31 | 31 | : CharmCommand( tr("Delete Task"), parent ) |
32 | 32 | , m_task( task ) |
33 | , m_success( false ) | |
34 | 33 | { |
35 | 34 | } |
36 | 35 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
33 | 33 | |
34 | 34 | public: |
35 | 35 | explicit CommandDeleteTask( const Task&, QObject* parent = nullptr ); |
36 | ~CommandDeleteTask(); | |
36 | ~CommandDeleteTask() override; | |
37 | 37 | |
38 | 38 | bool prepare() override; |
39 | 39 | bool execute( ControllerInterface* ) override; |
41 | 41 | |
42 | 42 | private: |
43 | 43 | Task m_task; |
44 | bool m_success; | |
44 | bool m_success = false; | |
45 | 45 | }; |
46 | 46 | |
47 | 47 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
32 | 32 | |
33 | 33 | CommandExportToXml::CommandExportToXml( QString filename, QObject* parent ) |
34 | 34 | : CharmCommand( tr("Export to XML"), parent ) |
35 | , m_error( false ) | |
36 | 35 | , m_filename( filename ) |
37 | 36 | { |
38 | 37 | } |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
32 | 32 | Q_OBJECT |
33 | 33 | public: |
34 | 34 | explicit CommandExportToXml( QString filename, QObject* parent ); |
35 | ~CommandExportToXml(); | |
35 | ~CommandExportToXml() override; | |
36 | 36 | |
37 | 37 | bool prepare() override; |
38 | 38 | bool execute( ControllerInterface* ) override; |
39 | 39 | bool finalize() override; |
40 | 40 | |
41 | 41 | private: |
42 | bool m_error; | |
42 | bool m_error = false; | |
43 | 43 | QString m_errorString; |
44 | 44 | QString m_filename; |
45 | 45 | }; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
32 | 32 | Q_OBJECT |
33 | 33 | public: |
34 | 34 | explicit CommandImportFromXml( QString filename, QObject* parent ); |
35 | ~CommandImportFromXml(); | |
35 | ~CommandImportFromXml() override; | |
36 | 36 | |
37 | 37 | bool prepare() override; |
38 | 38 | bool execute( ControllerInterface* ) override; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
35 | 35 | |
36 | 36 | public: |
37 | 37 | explicit CommandMakeAndActivateEvent( const Task&, QObject* parent ); |
38 | ~CommandMakeAndActivateEvent(); | |
38 | ~CommandMakeAndActivateEvent() override; | |
39 | 39 | |
40 | 40 | bool prepare() override; |
41 | 41 | bool execute( ControllerInterface* ) override; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
30 | 30 | CommandMakeEvent::CommandMakeEvent( const Task& task, |
31 | 31 | QObject* parent ) |
32 | 32 | : CharmCommand( tr("Create Event"), parent ) |
33 | , m_rollback( false ) | |
34 | 33 | , m_task( task ) |
35 | 34 | { |
36 | 35 | } |
38 | 37 | CommandMakeEvent::CommandMakeEvent( const Event& event, |
39 | 38 | QObject* parent ) |
40 | 39 | : CharmCommand( tr("Create Event"), parent ) |
41 | , m_rollback( false ) | |
42 | 40 | , m_event( event ) |
43 | 41 | { |
44 | 42 | } |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
36 | 36 | public: |
37 | 37 | explicit CommandMakeEvent( const Task& task, QObject* parent ); |
38 | 38 | explicit CommandMakeEvent( const Event& event, QObject* parent ); |
39 | ~CommandMakeEvent(); | |
39 | ~CommandMakeEvent() override; | |
40 | 40 | |
41 | 41 | bool prepare() override; |
42 | 42 | bool execute( ControllerInterface* ) override; |
50 | 50 | void finishedOk( const Event& ); |
51 | 51 | |
52 | 52 | private: |
53 | bool m_rollback; //don't show the event in finalize | |
53 | bool m_rollback = false; //don't show the event in finalize | |
54 | 54 | Task m_task; // the task the new event should be assigned to |
55 | 55 | Event m_event; // the result, only valid after the event has been created |
56 | 56 | }; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
43 | 43 | |
44 | 44 | bool CommandModifyEvent::execute( ControllerInterface* controller ) |
45 | 45 | { |
46 | // qDebug() << "CommandModifyEvent::execute: committing:"; | |
47 | // m_event.dump(); | |
48 | 46 | return controller->modifyEvent( m_event ); |
49 | 47 | } |
50 | 48 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
33 | 33 | |
34 | 34 | public: |
35 | 35 | explicit CommandModifyEvent( const Event&, const Event&, QObject* parent = nullptr ); |
36 | ~CommandModifyEvent(); | |
36 | ~CommandModifyEvent() override; | |
37 | 37 | |
38 | 38 | bool prepare() override; |
39 | 39 | bool execute( ControllerInterface* ) override; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
27 | 27 | CommandModifyTask::CommandModifyTask( const Task& task, QObject* parent ) |
28 | 28 | : CharmCommand( tr("Edit Task"), parent ) |
29 | 29 | , m_task( task ) |
30 | , m_success( false ) | |
31 | 30 | { |
32 | 31 | } |
33 | 32 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
33 | 33 | |
34 | 34 | public: |
35 | 35 | explicit CommandModifyTask( const Task&, QObject* parent = nullptr ); |
36 | ~CommandModifyTask(); | |
36 | ~CommandModifyTask() override; | |
37 | 37 | |
38 | 38 | bool prepare() override; |
39 | 39 | bool execute( ControllerInterface* ) override; |
41 | 41 | |
42 | 42 | private: |
43 | 43 | Task m_task; |
44 | bool m_success; | |
44 | bool m_success = false; | |
45 | 45 | }; |
46 | 46 | |
47 | 47 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
28 | 28 | |
29 | 29 | CommandRelayCommand::CommandRelayCommand( QObject* parent ) |
30 | 30 | : CharmCommand( tr("Relay"), parent ) |
31 | , m_payload( 0 ) | |
32 | 31 | { // as long as Charm is single-threaded, this does not do anything, |
33 | 32 | // because there will be no repaint |
34 | 33 | QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
36 | 36 | |
37 | 37 | public: |
38 | 38 | explicit CommandRelayCommand( QObject* parent ); |
39 | ~CommandRelayCommand(); | |
39 | ~CommandRelayCommand() override; | |
40 | 40 | |
41 | 41 | void setCommand( CharmCommand* command ); |
42 | 42 | |
46 | 46 | bool finalize() override; |
47 | 47 | |
48 | 48 | private: |
49 | CharmCommand* m_payload; | |
49 | CharmCommand* m_payload = nullptr; | |
50 | 50 | }; |
51 | 51 | |
52 | 52 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
27 | 27 | CommandSetAllTasks::CommandSetAllTasks( const TaskList& tasks, QObject* parent ) |
28 | 28 | : CharmCommand( tr("Import Tasks"), parent ) |
29 | 29 | , m_tasks( tasks ) |
30 | , m_success( false ) | |
31 | 30 | { |
32 | 31 | } |
33 | 32 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
32 | 32 | |
33 | 33 | public: |
34 | 34 | explicit CommandSetAllTasks( const TaskList&, QObject* parent ); |
35 | ~CommandSetAllTasks(); | |
35 | ~CommandSetAllTasks() override; | |
36 | 36 | |
37 | 37 | bool prepare() override; |
38 | 38 | bool execute( ControllerInterface* ) override; |
40 | 40 | |
41 | 41 | private: |
42 | 42 | TaskList m_tasks; |
43 | bool m_success; | |
43 | bool m_success = false; | |
44 | 44 | }; |
45 | 45 | |
46 | 46 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Mike McQuaid <mike.mcquaid@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
43 | 43 | |
44 | 44 | public: |
45 | 45 | explicit EventModelAdapter( CharmDataModel* parent ); |
46 | virtual ~EventModelAdapter(); | |
46 | ~EventModelAdapter() override; | |
47 | 47 | |
48 | 48 | int rowCount( const QModelIndex& parent = QModelIndex() ) const override; |
49 | 49 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
26 | 26 | EventModelFilter::EventModelFilter( CharmDataModel* model, QObject* parent ) |
27 | 27 | : QSortFilterProxyModel( parent ) |
28 | 28 | , m_model( model ) |
29 | , m_filterId() | |
30 | 29 | { |
31 | 30 | setSourceModel( &m_model ); |
32 | 31 | setDynamicSortFilter( true ); |
84 | 83 | } |
85 | 84 | |
86 | 85 | const auto startDate = event.startDateTime().date(); |
87 | if ( m_start.isValid() && startDate < m_start ) { | |
86 | /* | |
87 | * event.endDateTime().date() < m_start | |
88 | * Show also Events that end within the time span. | |
89 | */ | |
90 | if ( m_start.isValid() && ( startDate < m_start ) && ( event.endDateTime().date() < m_start ) ) { | |
88 | 91 | return false; |
89 | 92 | } |
90 | 93 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
42 | 42 | |
43 | 43 | public: |
44 | 44 | explicit EventModelFilter( CharmDataModel*, QObject* parent = nullptr ); |
45 | virtual ~EventModelFilter(); | |
45 | ~EventModelFilter() override; | |
46 | 46 | |
47 | 47 | /** Returns the total number of seconds of all events in the model. */ |
48 | 48 | int totalDuration() const; |
73 | 73 | EventModelAdapter m_model; |
74 | 74 | QDate m_start; |
75 | 75 | QDate m_end; |
76 | TaskId m_filterId; | |
76 | TaskId m_filterId = {}; | |
77 | 77 | }; |
78 | 78 | |
79 | 79 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
29 | 29 | #include <QSettings> |
30 | 30 | |
31 | 31 | GUIState::GUIState() |
32 | : m_selectedTask( 0 ) | |
33 | , m_showExpired( false ) | |
34 | , m_showCurrents( false ) | |
35 | 32 | { |
36 | 33 | } |
37 | 34 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
50 | 50 | |
51 | 51 | private: |
52 | 52 | TaskIdList m_expandedTasks; |
53 | TaskId m_selectedTask; | |
54 | bool m_showExpired; // show also expired tasks | |
55 | bool m_showCurrents; // show only selected tasks | |
53 | TaskId m_selectedTask = {}; | |
54 | bool m_showExpired = false; // show also expired tasks | |
55 | bool m_showCurrents = false; // show only selected tasks | |
56 | 56 | }; |
57 | 57 | |
58 | 58 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2011-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Michel Boyer de la Giroday <michel.giroday@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2011-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Michel Boyer de la Giroday <michel.giroday@kdab.com> |
8 | 8 | |
49 | 49 | }; |
50 | 50 | |
51 | 51 | explicit CheckForUpdatesJob( QObject* parent=nullptr ); |
52 | ~CheckForUpdatesJob(); | |
52 | ~CheckForUpdatesJob() override; | |
53 | 53 | |
54 | 54 | void start(); |
55 | 55 | void setUrl( const QUrl& url ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2011-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
29 | 29 | |
30 | 30 | GetProjectCodesJob::GetProjectCodesJob(QObject* parent) |
31 | 31 | : HttpJob(parent) |
32 | , m_verbose( true ) | |
33 | 32 | { |
34 | 33 | QSettings s; |
35 | 34 | s.beginGroup(QLatin1String("httpconfig")); |
54 | 53 | QNetworkReply *reply = manager->get(request); |
55 | 54 | |
56 | 55 | if (reply->error() != QNetworkReply::NoError) |
57 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
56 | setErrorFromReplyAndEmitFinished(reply); | |
58 | 57 | return true; |
59 | 58 | } |
60 | 59 | |
62 | 61 | { |
63 | 62 | /* check for failure */ |
64 | 63 | if (reply->error() != QNetworkReply::NoError) { |
65 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
64 | setErrorFromReplyAndEmitFinished(reply); | |
66 | 65 | return false; |
67 | 66 | } |
68 | 67 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2011-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
33 | 33 | public: |
34 | 34 | |
35 | 35 | explicit GetProjectCodesJob(QObject* parent=nullptr); |
36 | ~GetProjectCodesJob(); | |
36 | ~GetProjectCodesJob() override; | |
37 | 37 | |
38 | 38 | QByteArray payload() const; |
39 | 39 | |
56 | 56 | private: |
57 | 57 | QByteArray m_payload; |
58 | 58 | QUrl m_downloadUrl; |
59 | bool m_verbose; | |
59 | bool m_verbose = true; | |
60 | 60 | }; |
61 | 61 | |
62 | 62 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Pál Tóth <pal.toth@kdab.com> |
8 | 8 | |
63 | 63 | QNetworkReply *reply = manager->get(request); |
64 | 64 | |
65 | 65 | if (reply->error() != QNetworkReply::NoError) |
66 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
66 | setErrorFromReplyAndEmitFinished(reply); | |
67 | 67 | return true; |
68 | 68 | } |
69 | 69 | |
72 | 72 | |
73 | 73 | /* check for failure */ |
74 | 74 | if (reply->error() != QNetworkReply::NoError) { |
75 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
75 | setErrorFromReplyAndEmitFinished(reply); | |
76 | 76 | return false; |
77 | 77 | } |
78 | 78 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Pál Tóth <pal.toth@kdab.com> |
8 | 8 | |
25 | 25 | |
26 | 26 | #include "HttpJob.h" |
27 | 27 | #include <QUrl> |
28 | #include <QDebug> | |
29 | 28 | #include <QVariant> |
30 | 29 | #include <QVariantMap> |
31 | 30 | |
35 | 34 | public: |
36 | 35 | |
37 | 36 | explicit GetUserInfoJob(QObject* parent=nullptr, const QString &schema = " "); |
38 | ~GetUserInfoJob(); | |
37 | ~GetUserInfoJob() override; | |
39 | 38 | |
40 | 39 | QByteArray userInfo() const; |
41 | 40 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2011-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Olivier JG <olivier.de.gaalon@kdab.com> |
22 | 22 | */ |
23 | 23 | |
24 | 24 | #include "HttpJob.h" |
25 | #include "Keychain/keychain.h" | |
25 | #include "CharmCMake.h" | |
26 | #ifdef QTKEYCHAIN_SYSTEM | |
27 | #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) | |
28 | #include <qt5keychain/keychain.h> | |
29 | #else | |
30 | #include <qtkeychain/keychain.h> | |
31 | #endif | |
32 | #else | |
33 | #include "Keychain/keychain.h" | |
34 | #endif | |
26 | 35 | |
27 | 36 | #include <QNetworkAccessManager> |
28 | 37 | #include <QNetworkReply> |
76 | 85 | HttpJob::HttpJob(QObject* parent) |
77 | 86 | : QObject(parent) |
78 | 87 | , m_networkManager(new QNetworkAccessManager(this)) |
79 | , m_username() | |
80 | , m_password() | |
81 | , m_currentState(Ready) | |
82 | , m_errorCode(NoError) | |
83 | , m_lastAuthenticationFailed(true) | |
84 | , m_authenticationDoneAlready(false) | |
85 | , m_passwordReadError(false) | |
86 | 88 | { |
87 | 89 | connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(handle(QNetworkReply*))); |
88 | 90 | connect(m_networkManager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); |
261 | 263 | QNetworkReply *reply = manager->get(request); |
262 | 264 | |
263 | 265 | if (reply->error() != QNetworkReply::NoError) |
264 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
266 | setErrorFromReplyAndEmitFinished(reply); | |
265 | 267 | } return true; |
266 | 268 | |
267 | 269 | case Login: |
286 | 288 | QNetworkReply *reply = manager->post(request, encodedQueryPlusPlus); |
287 | 289 | |
288 | 290 | if (reply->error() != QNetworkReply::NoError) |
289 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
291 | setErrorFromReplyAndEmitFinished(reply); | |
290 | 292 | |
291 | 293 | } return true; |
292 | 294 | |
300 | 302 | { |
301 | 303 | // check for failure |
302 | 304 | if (reply->error() != QNetworkReply::NoError) { |
303 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
305 | setErrorFromReplyAndEmitFinished(reply); | |
304 | 306 | return false; |
305 | 307 | } |
306 | 308 | |
352 | 354 | emitFinished(); |
353 | 355 | } |
354 | 356 | |
357 | void HttpJob::setErrorFromReplyAndEmitFinished(QNetworkReply *reply) | |
358 | { | |
359 | if (reply->error() == QNetworkReply::HostNotFoundError) | |
360 | setErrorAndEmitFinished(HostNotFound, reply->errorString()); | |
361 | else | |
362 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
363 | } | |
364 | ||
355 | 365 | #include "moc_HttpJob.cpp" |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2011-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
48 | 48 | Canceled, |
49 | 49 | NotConfigured, |
50 | 50 | AuthenticationFailed, |
51 | SomethingWentWrong | |
51 | SomethingWentWrong, | |
52 | HostNotFound | |
52 | 53 | }; |
53 | 54 | |
54 | 55 | explicit HttpJob(QObject* parent=nullptr); |
55 | ~HttpJob(); | |
56 | ~HttpJob() override; | |
56 | 57 | |
57 | 58 | QString username() const; |
58 | 59 | void setUsername(const QString &value); |
105 | 106 | void emitFinished(); |
106 | 107 | void setErrorAndEmitFinished(int code, const QString& errorString); |
107 | 108 | void delayedNext(); |
109 | void setErrorFromReplyAndEmitFinished(QNetworkReply *reply); | |
108 | 110 | |
109 | 111 | static QString extractErrorMessageFromReply(const QByteArray& xml); |
110 | 112 | |
123 | 125 | QNetworkAccessManager *m_networkManager; |
124 | 126 | QString m_username; |
125 | 127 | QString m_password; |
126 | int m_currentState; | |
127 | int m_errorCode; | |
128 | int m_currentState = Ready; | |
129 | int m_errorCode = NoError; | |
128 | 130 | QString m_errorString; |
129 | 131 | QUrl m_loginUrl; |
130 | 132 | QUrl m_portalUrl; |
131 | bool m_lastAuthenticationFailed; | |
132 | bool m_authenticationDoneAlready; | |
133 | bool m_passwordReadError; | |
133 | bool m_lastAuthenticationFailed = true; | |
134 | bool m_authenticationDoneAlready = false; | |
135 | bool m_passwordReadError = false; | |
134 | 136 | }; |
135 | 137 | |
136 | 138 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2011-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Guillermo A. Amaral <gamaral@kdab.com> |
109 | 109 | QNetworkReply *reply = manager->post(request, data); |
110 | 110 | |
111 | 111 | if (reply->error() != QNetworkReply::NoError) |
112 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
113 | return true; | |
112 | setErrorFromReplyAndEmitFinished(reply); | |
113 | return true; | |
114 | 114 | } |
115 | 115 | |
116 | 116 | bool UploadTimesheetJob::handle(QNetworkReply *reply) |
117 | 117 | { |
118 | 118 | /* check for failure */ |
119 | 119 | if (reply->error() != QNetworkReply::NoError) { |
120 | setErrorAndEmitFinished(SomethingWentWrong, reply->errorString()); | |
120 | setErrorFromReplyAndEmitFinished(reply); | |
121 | 121 | return false; |
122 | 122 | } |
123 | 123 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2011-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
33 | 33 | public: |
34 | 34 | |
35 | 35 | explicit UploadTimesheetJob(QObject* parent=nullptr); |
36 | ~UploadTimesheetJob(); | |
36 | ~UploadTimesheetJob() override; | |
37 | 37 | |
38 | 38 | QByteArray payload() const; |
39 | 39 | void setPayload(const QByteArray &payload); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Mike McQuaid <mike.mcquaid@kdab.com> |
37 | 37 | IdleDetector::IdleDetector( QObject* parent ) |
38 | 38 | : QObject( parent ) |
39 | 39 | , m_idlenessDuration( CHARM_IDLE_TIME ) // from CharmCMake.h |
40 | , m_available( true ) | |
41 | 40 | { |
42 | 41 | } |
43 | 42 | |
52 | 51 | return new WindowsIdleDetector( parent ); |
53 | 52 | #endif |
54 | 53 | |
55 | #ifdef CHARM_IDLE_DETECTION_AVAILABLE_X11 | |
54 | #ifdef CHARM_IDLE_DETECTION_AVAILABLE | |
56 | 55 | X11IdleDetector* detector = new X11IdleDetector( parent ); |
57 | detector->setAvailable( X11IdleDetector::idleCheckPossible() ); | |
56 | detector->setAvailable( detector->idleCheckPossible() ); | |
58 | 57 | return detector; |
59 | 58 | #endif |
60 | 59 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
81 | 81 | |
82 | 82 | private: |
83 | 83 | IdlePeriods m_idlePeriods; |
84 | int m_idlenessDuration; | |
85 | bool m_available; | |
84 | int m_idlenessDuration = 0; | |
85 | bool m_available = true; | |
86 | 86 | }; |
87 | 87 | |
88 | 88 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2011-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mike McQuaid <mike.mcquaid@kdab.com> |
8 | 8 |
0 | /* | |
1 | MacIdleDetector.mm | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2011-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Mike McQuaid <mike.mcquaid@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
0 | 23 | #include <Cocoa/Cocoa.h> |
1 | 24 | |
2 | 25 | #include "MacIdleDetector.h" |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Mike McQuaid <mike.mcquaid@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Jesper Pedersen <jesper.pedersen@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
26 | 26 | #include "X11IdleDetector.h" |
27 | 27 | #include "CharmCMake.h" |
28 | 28 | |
29 | //TODO for Qt5 port to XCB... | |
30 | 29 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) |
31 | 30 | #include <QX11Info> |
32 | 31 | #include <X11/Xlib.h> |
33 | 32 | #include <X11/Xutil.h> |
34 | 33 | #include <X11/extensions/scrnsaver.h> |
34 | #else | |
35 | #include <xcb/screensaver.h> | |
35 | 36 | #endif |
37 | ||
38 | X11IdleDetector::X11IdleDetector( QObject* parent ) | |
39 | : IdleDetector( parent ) | |
40 | { | |
41 | connect( &m_timer, SIGNAL(timeout()), this, SLOT(checkIdleness()) ); | |
42 | m_timer.start( idlenessDuration() * 1000 / 5 ); | |
43 | m_heartbeat = QDateTime::currentDateTime(); | |
44 | } | |
36 | 45 | |
37 | 46 | bool X11IdleDetector::idleCheckPossible() |
38 | 47 | { |
40 | 49 | int event_base, error_base; |
41 | 50 | if(XScreenSaverQueryExtension(QX11Info::display(), &event_base, &error_base)) |
42 | 51 | return true; |
52 | #else | |
53 | m_connection = xcb_connect(NULL, NULL); //krazy:exclude=null | |
54 | m_screen = xcb_setup_roots_iterator(xcb_get_setup (m_connection)).data; | |
55 | if (m_screen) | |
56 | return true; | |
43 | 57 | #endif |
44 | 58 | return false; |
45 | } | |
46 | ||
47 | X11IdleDetector::X11IdleDetector( QObject* parent ) | |
48 | : IdleDetector( parent ) | |
49 | { | |
50 | connect( &m_timer, SIGNAL(timeout()), this, SLOT(checkIdleness()) ); | |
51 | m_timer.start( idlenessDuration() * 1000 / 5 ); | |
52 | m_heartbeat = QDateTime::currentDateTime(); | |
53 | 59 | } |
54 | 60 | |
55 | 61 | void X11IdleDetector::onIdlenessDurationChanged() |
67 | 73 | XScreenSaverQueryInfo(QX11Info::display(), QX11Info::appRootWindow(), _mit_info); |
68 | 74 | const int idleSecs = _mit_info->idle / 1000; |
69 | 75 | XFree(_mit_info); |
76 | #else | |
77 | xcb_screensaver_query_info_cookie_t cookie; | |
78 | cookie = xcb_screensaver_query_info( m_connection, m_screen->root ); | |
79 | xcb_screensaver_query_info_reply_t* info; | |
80 | info = xcb_screensaver_query_info_reply( m_connection, cookie, NULL ); //krazy:exclude=null | |
81 | const int idleSecs = info->ms_since_user_input / 1000; | |
82 | free (info); | |
83 | #endif | |
70 | 84 | |
71 | 85 | if (idleSecs >= idlenessDuration()) |
72 | 86 | maybeIdle( IdlePeriod(QDateTime::currentDateTime().addSecs( -idleSecs ), |
74 | 88 | |
75 | 89 | if ( m_heartbeat.secsTo( QDateTime::currentDateTime() ) > idlenessDuration() ) |
76 | 90 | maybeIdle( IdlePeriod( m_heartbeat, QDateTime::currentDateTime() ) ); |
77 | #endif | |
91 | ||
78 | 92 | m_heartbeat = QDateTime::currentDateTime(); |
79 | 93 | } |
80 | 94 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Jesper Pedersen <jesper.pedersen@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
28 | 28 | |
29 | 29 | #include <QTimer> |
30 | 30 | |
31 | #if defined(Q_OS_UNIX) && !defined(Q_OS_OSX) | |
32 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
33 | #include <xcb/xcb.h> | |
34 | #endif | |
35 | #endif | |
36 | ||
31 | 37 | class X11IdleDetector : public IdleDetector |
32 | 38 | { |
33 | 39 | Q_OBJECT |
34 | 40 | public: |
35 | 41 | explicit X11IdleDetector( QObject* parent ); |
36 | static bool idleCheckPossible(); | |
42 | bool idleCheckPossible(); | |
37 | 43 | |
38 | 44 | protected: |
39 | 45 | void onIdlenessDurationChanged(); |
44 | 50 | private: |
45 | 51 | QDateTime m_heartbeat; |
46 | 52 | QTimer m_timer; |
53 | #if defined(Q_OS_UNIX) && !defined(Q_OS_OSX) | |
54 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
55 | xcb_connection_t* m_connection; | |
56 | xcb_screen_t* m_screen; | |
57 | #endif | |
58 | #endif | |
47 | 59 | }; |
48 | 60 | |
49 | 61 |
0 | /* | |
1 | gnomekeyring.cpp | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
0 | 23 | #include "gnomekeyring_p.h" |
1 | 24 | |
2 | const char* GnomeKeyring::GNOME_KEYRING_DEFAULT = NULL; | |
25 | const char* GnomeKeyring::GNOME_KEYRING_DEFAULT = 0; | |
3 | 26 | |
4 | 27 | bool GnomeKeyring::isAvailable() |
5 | 28 | { |
0 | #ifndef QTKEYCHAIN_GNOME_P_H | |
1 | #define QTKEYCHAIN_GNOME_P_H | |
0 | /* | |
1 | gnomekeyring_p.h | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #ifndef GNOMEKEYRING_P_H | |
24 | #define GNOMEKEYRING_P_H | |
2 | 25 | |
3 | 26 | #include <QLibrary> |
4 | 27 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
29 | 29 | { |
30 | 30 | Q_OBJECT |
31 | 31 | public: |
32 | explicit MacApplicationCore( QObject* parent = nullptr ); | |
32 | explicit MacApplicationCore( TaskId startupTask, QObject* parent = nullptr ); | |
33 | 33 | ~MacApplicationCore(); |
34 | 34 | // This method to be public due to lack of friend classes in Objective-C and |
35 | 35 | // the lack inheritance of Objective-C classes from C++ ones. |
0 | /* | |
1 | MacApplicationCore.mm | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
0 | 23 | #include <Cocoa/Cocoa.h> |
1 | 24 | |
2 | 25 | #include "MacApplicationCore.h" |
97 | 120 | andEventID:kAEReopenApplication]; |
98 | 121 | } |
99 | 122 | |
100 | MacApplicationCore::MacApplicationCore( QObject* parent ) | |
101 | : ApplicationCore( parent ) | |
123 | MacApplicationCore::MacApplicationCore( TaskId startupTask, QObject* parent ) | |
124 | : ApplicationCore( startupTask, parent ) | |
102 | 125 | , m_private( new MacApplicationCore::Private() ) |
103 | 126 | { |
104 | 127 | m_private->dockIconClickEventHandler->macApplication = this; |
107 | 130 | this, SLOT(handleStateChange(State))); |
108 | 131 | |
109 | 132 | m_dockMenu.addAction( &m_actionStopAllTasks ); |
110 | m_dockMenu.addSeparator(); | |
111 | ||
112 | Q_FOREACH( CharmWindow* window, m_windows ) | |
113 | m_dockMenu.addAction( window->showHideAction() ); | |
114 | 133 | |
115 | 134 | m_dockMenu.addSeparator(); |
116 | 135 | m_dockMenu.addMenu( m_timeTracker.menu() ); |
118 | 137 | |
119 | 138 | // OSX doesn't use icons in menus |
120 | 139 | QApplication::setWindowIcon( QIcon() ); |
121 | Q_FOREACH( CharmWindow* window, m_windows ) | |
122 | window->setWindowIcon( QIcon() ); | |
140 | m_timeTracker.setWindowIcon( QIcon() ); | |
123 | 141 | m_actionQuit.setIcon( QIcon() ); |
124 | 142 | QCoreApplication::setAttribute( Qt::AA_DontShowIconsInMenus ); |
125 | 143 | } |
137 | 155 | |
138 | 156 | void MacApplicationCore::dockIconClickEvent() |
139 | 157 | { |
140 | openAWindow(); | |
158 | showMainWindow(); | |
141 | 159 | } |
142 | 160 | |
143 | 161 | QList< QShortcut* > MacApplicationCore::shortcuts( QWidget* parent ) |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
69 | 69 | void ModelConnector::commitCommand( CharmCommand* command ) |
70 | 70 | { |
71 | 71 | if ( ! command->finalize() ) { |
72 | qDebug() << "CharmDataModel::commitCommand:" | |
73 | << command->metaObject()->className() | |
74 | << "command has failed"; | |
72 | qWarning() << "CharmDataModel::commitCommand:" | |
73 | << command->metaObject()->className() | |
74 | << "command has failed"; | |
75 | 75 | } |
76 | 76 | } |
77 | 77 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: David Faure <david.faure@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
31 | 31 | #include <QDomDocument> |
32 | 32 | |
33 | 33 | MonthlyTimesheetXmlWriter::MonthlyTimesheetXmlWriter() |
34 | : m_dataModel( nullptr ) | |
35 | , m_yearOfMonth ( 0 ) | |
36 | , m_monthNumber( 0 ) | |
37 | , m_numberOfWeeks( 0 ) | |
38 | , m_rootTask() | |
39 | 34 | {} |
40 | 35 | |
41 | 36 | void MonthlyTimesheetXmlWriter::setDataModel( const CharmDataModel* dataModel ) |
167 | 162 | } |
168 | 163 | } |
169 | 164 | |
170 | #if 0 | |
171 | qDebug() << "MonthlyTimeSheetReport::slotSaveToXml: generated XML:" << endl | |
172 | << document.toString( 4 ); | |
173 | #endif | |
174 | ||
175 | 165 | return document.toByteArray( 4 ); |
176 | 166 | } |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
45 | 45 | void setRootTask( TaskId rootTask ); |
46 | 46 | |
47 | 47 | private: |
48 | const CharmDataModel* m_dataModel; | |
49 | int m_yearOfMonth; | |
50 | int m_monthNumber; | |
51 | int m_numberOfWeeks; | |
52 | TaskId m_rootTask; | |
48 | const CharmDataModel* m_dataModel = nullptr; | |
49 | int m_yearOfMonth = 0; | |
50 | int m_monthNumber = 0; | |
51 | int m_numberOfWeeks = 0; | |
52 | TaskId m_rootTask = {}; | |
53 | 53 | EventList m_events; |
54 | 54 | }; |
55 | 55 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
25 | 25 | #include "Core/CharmDataModel.h" |
26 | 26 | |
27 | 27 | TimeSheetInfo::TimeSheetInfo(int segments) |
28 | : indentation( 0 ) | |
29 | , seconds( segments ) | |
30 | , taskId( 0 ) | |
31 | , aggregated( false ) | |
28 | : seconds( segments ) | |
32 | 29 | { |
33 | 30 | seconds.fill( 0 ); |
34 | 31 | } |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
50 | 50 | QString formattedTaskIdAndName( int taskPaddingLength ) const; |
51 | 51 | |
52 | 52 | // the level of indentation, >0 means the numbers are aggregated for the subtasks: |
53 | int indentation; | |
53 | int indentation = 0; | |
54 | 54 | QString taskName; |
55 | 55 | QVector<int> seconds; |
56 | TaskId taskId; | |
57 | bool aggregated; | |
56 | TaskId taskId = {}; | |
57 | bool aggregated = false; | |
58 | 58 | }; |
59 | 59 | |
60 | 60 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
32 | 32 | static const int DaysInWeek = 7; |
33 | 33 | |
34 | 34 | WeeklyTimesheetXmlWriter::WeeklyTimesheetXmlWriter() |
35 | : m_dataModel( nullptr ) | |
36 | , m_year( 0 ) | |
37 | , m_weekNumber( 0 ) | |
38 | , m_rootTask() | |
39 | 35 | { |
40 | 36 | } |
41 | 37 | |
174 | 170 | } |
175 | 171 | } |
176 | 172 | |
177 | // qDebug() << "WeeklyTimeSheetReport::slotSaveToXml: generated XML:" << endl | |
178 | // << document.toString( 4 ); | |
179 | // | |
180 | 173 | return document.toByteArray( 4 ); |
181 | 174 | } |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
43 | 43 | void setEvents( const EventList& events ); |
44 | 44 | void setRootTask( TaskId rootTask ); |
45 | 45 | private: |
46 | const CharmDataModel* m_dataModel; | |
47 | int m_year; | |
48 | int m_weekNumber; | |
49 | TaskId m_rootTask; | |
46 | const CharmDataModel* m_dataModel = nullptr; | |
47 | int m_year = 0; | |
48 | int m_weekNumber = 0; | |
49 | TaskId m_rootTask = {}; | |
50 | 50 | EventList m_events; |
51 | 51 | }; |
52 | 52 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
364 | 364 | return item.childCount() > 0; |
365 | 365 | } |
366 | 366 | |
367 | TaskIdList TaskModelAdapter::childrenIds( const Task& task ) const | |
367 | TaskList TaskModelAdapter::children( const Task& task ) const | |
368 | 368 | { |
369 | 369 | const TaskTreeItem& item = m_dataModel->taskTreeItem( task.id() ); |
370 | return item.childIds(); | |
370 | return item.children(); | |
371 | 371 | } |
372 | 372 | |
373 | 373 | bool TaskModelAdapter::taskIdExists( TaskId taskId ) const |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
62 | 62 | |
63 | 63 | public: |
64 | 64 | explicit TaskModelAdapter( CharmDataModel* parent ); |
65 | ~TaskModelAdapter(); | |
65 | ~TaskModelAdapter() override; | |
66 | 66 | |
67 | 67 | // reimplement QAbstractItemModel: |
68 | 68 | int columnCount( const QModelIndex& parent = QModelIndex() ) const override; |
99 | 99 | bool taskIsActive( const Task& task ) const override; |
100 | 100 | bool taskHasChildren( const Task& task ) const override; |
101 | 101 | bool taskIdExists( TaskId taskId ) const override; |
102 | TaskIdList childrenIds( const Task& task ) const; | |
102 | TaskList children( const Task& task ) const; | |
103 | 103 | |
104 | 104 | // reimplement CommandEmitterInterface: |
105 | 105 | void commitCommand( CharmCommand* ) override; |
106 | 106 | |
107 | 107 | signals: |
108 | void eventActivationNotice( EventId id ); | |
109 | void eventDeactivationNotice( EventId id ); | |
108 | void eventActivationNotice( EventId id ) override; | |
109 | void eventDeactivationNotice( EventId id ) override; | |
110 | 110 | |
111 | 111 | private: |
112 | 112 | const TaskTreeItem* itemFor ( const QModelIndex& ) const; |
0 | /* | |
1 | This file is part of Charm, a task-based time tracking application. | |
2 | ||
3 | Copyright (C) 2009-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
4 | ||
5 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation, either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
21 | #ifndef TEMPORARYVALUE_H | |
22 | #define TEMPORARYVALUE_H | |
23 | ||
24 | template <typename T> | |
25 | struct TemporaryValue { | |
26 | explicit TemporaryValue(T& x, const T& value) | |
27 | : m_oldValue(x) | |
28 | , m_x(x) | |
29 | { | |
30 | m_x = value; | |
31 | } | |
32 | ||
33 | ~TemporaryValue() { | |
34 | m_x = m_oldValue; | |
35 | } | |
36 | ||
37 | T& m_x; | |
38 | const T m_oldValue; | |
39 | }; | |
40 | ||
41 | #endif | |
42 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2012-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Nicholas Van Sickle <nicholas.vansickle@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2012-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Nicholas Van Sickle <nicholas.vansickle@kdab.com> |
8 | 8 |
0 | /* | |
1 | Uniquifier.h | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2009-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Mirko Boehm <mirko.boehm@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #ifndef UNIQUIFIER_H | |
24 | #define UNIQUIFIER_H | |
25 | ||
26 | // Usage: | |
27 | // void blurb() { | |
28 | // static bool inProgress = false; | |
29 | // if ( inProgress == true ) return; | |
30 | // Uniquifier u( &inProgress ); | |
31 | // // ... this code will be called only once | |
32 | // } | |
33 | ||
34 | class Uniquifier { | |
35 | public: | |
36 | explicit Uniquifier( bool* guard ) { | |
37 | m_guard = guard; | |
38 | *m_guard = true; | |
39 | } | |
40 | ~Uniquifier() { | |
41 | *m_guard = false; | |
42 | } | |
43 | private: | |
44 | bool *m_guard; | |
45 | }; | |
46 | ||
47 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
98 | 98 | case Configuration::TaskPrefilter_ShowAll: |
99 | 99 | break; |
100 | 100 | case Configuration::TaskPrefilter_CurrentOnly: { |
101 | const bool ok = ( task.isCurrentlyValid() || hasValidChildren( task ) ); | |
101 | const bool ok = ( task.isCurrentlyValid() || checkChildren( task, HaveValidChild ) ); | |
102 | 102 | accepted &= ok; |
103 | 103 | break; |
104 | 104 | } |
105 | case Configuration::TaskPrefilter_SubscribedOnly: | |
106 | accepted &= task.subscribed(); | |
105 | case Configuration::TaskPrefilter_SubscribedOnly: { | |
106 | const bool ok = ( task.subscribed() || checkChildren( task, HaveSubscribedChild ) ); | |
107 | accepted &= ok; | |
107 | 108 | break; |
109 | } | |
108 | 110 | case Configuration::TaskPrefilter_SubscribedAndCurrentOnly: |
109 | accepted &= ( task.subscribed() && task.isCurrentlyValid() ); | |
111 | accepted &= ( (task.subscribed() || checkChildren( task, HaveSubscribedChild ) ) && ( task.isCurrentlyValid() || checkChildren( task, HaveValidChild ) ) ); | |
110 | 112 | break; |
111 | 113 | default: |
112 | 114 | break; |
125 | 127 | return m_model.taskIdExists( taskId ); |
126 | 128 | } |
127 | 129 | |
128 | bool ViewFilter::hasValidChildren( Task task ) const | |
130 | bool ViewFilter::checkChildren( Task task, CheckFor checkFor ) const | |
129 | 131 | { |
130 | 132 | if ( taskHasChildren( task ) ) { |
131 | const TaskIdList idList = m_model.childrenIds( task ); | |
132 | for ( int i = 0; i < idList.count(); ++i ) { | |
133 | const Task childTask = DATAMODEL->getTask( idList[i] ); | |
134 | if ( childTask.isCurrentlyValid() ) { | |
133 | const TaskList taskList = m_model.children( task ); | |
134 | for ( const Task taskChild : taskList ) { | |
135 | if ( checkFor == HaveSubscribedChild && taskChild.subscribed() ) | |
135 | 136 | return true; |
136 | } | |
137 | else if ( checkFor == HaveValidChild && taskChild.isCurrentlyValid() ) | |
138 | return true; | |
137 | 139 | } |
138 | 140 | } |
139 | 141 | return false; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
44 | 44 | Q_OBJECT |
45 | 45 | public: |
46 | 46 | explicit ViewFilter( CharmDataModel*, QObject* parent = nullptr ); |
47 | virtual ~ViewFilter(); | |
47 | ~ViewFilter() override; | |
48 | 48 | |
49 | 49 | // implement TaskModelInterface |
50 | 50 | Task taskForIndex( const QModelIndex& ) const override; |
61 | 61 | bool filterAcceptsRow( int row, const QModelIndex& parent ) const override; |
62 | 62 | |
63 | 63 | signals: |
64 | void eventActivationNotice( EventId id ); | |
65 | void eventDeactivationNotice( EventId id ); | |
64 | void eventActivationNotice( EventId id ) override; | |
65 | void eventDeactivationNotice( EventId id ) override; | |
66 | 66 | |
67 | 67 | private: |
68 | bool hasValidChildren(Task task) const; | |
68 | enum CheckFor { | |
69 | HaveValidChild, | |
70 | HaveSubscribedChild | |
71 | }; | |
72 | ||
73 | bool checkChildren( Task task, CheckFor checkFor ) const; | |
69 | 74 | TaskModelAdapter m_model; |
70 | 75 | }; |
71 | 76 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
94 | 94 | style.replace(QLatin1String("@alternate_row_background_color@"), palette.alternateBase().color().name()); |
95 | 95 | style.replace(QLatin1String("@event_attributes_row_background_color@"), palette.midlight().color().name()); |
96 | 96 | if ( style.isEmpty() ) { |
97 | qDebug() << "reportStylesheet: default style sheet is empty, too bad"; | |
97 | qWarning() << "reportStylesheet: default style sheet is empty, too bad"; | |
98 | 98 | } |
99 | 99 | } else { |
100 | qDebug() << "reportStylesheet: cannot load report style sheet:" << stylesheet.errorString(); | |
100 | qCritical() << "reportStylesheet: cannot load report style sheet:" << stylesheet.errorString(); | |
101 | 101 | } |
102 | 102 | return style; |
103 | 103 | } |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
0 | /* | |
1 | ViewModeInterface.h | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Mirko Boehm <mirko.boehm@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #ifndef CHARM_VIEWMODEINTERFACE_H | |
24 | #define CHARM_VIEWMODEINTERFACE_H | |
25 | ||
26 | #include <Core/State.h> | |
27 | ||
28 | class ModelConnector; | |
29 | ||
30 | // FIXME obsolete, merge into CharmWindow | |
31 | class ViewModeInterface | |
32 | { | |
33 | public: | |
34 | virtual ~ViewModeInterface() {} | |
35 | virtual void saveGuiState() = 0; | |
36 | virtual void restoreGuiState() = 0; | |
37 | virtual void stateChanged( State previous ) = 0; | |
38 | virtual void configurationChanged() = 0; | |
39 | virtual void setModel( ModelConnector* ) = 0; | |
40 | }; | |
41 | ||
42 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
29 | 29 | static const int DAYS_IN_WEEK = 7; |
30 | 30 | |
31 | 31 | WeeklySummary::WeeklySummary() |
32 | : task( 0 ), durations( DAYS_IN_WEEK, 0 ) { | |
32 | : durations( DAYS_IN_WEEK, 0 ) { | |
33 | 33 | } |
34 | 34 | |
35 | 35 | QVector<WeeklySummary> WeeklySummary::summariesForTimespan( CharmDataModel* dataModel, const TimeSpan& timespan ) |
56 | 56 | // now add the times to the tasks: |
57 | 57 | Q_FOREACH( const Event& event, events ) { |
58 | 58 | // find the index for this event: |
59 | TaskIdList::iterator it = std::find( uniqueTaskIds.begin(), uniqueTaskIds.end(), event.taskId() ); | |
59 | auto it = std::find( uniqueTaskIds.begin(), uniqueTaskIds.end(), event.taskId() ); | |
60 | 60 | if ( it != uniqueTaskIds.end() ) { |
61 | 61 | const int index = std::distance( uniqueTaskIds.begin(), it ); |
62 | 62 | Q_ASSERT( index >= 0 && index < summaries.size() ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
38 | 38 | |
39 | 39 | WeeklySummary(); |
40 | 40 | |
41 | TaskId task; | |
41 | TaskId task = {}; | |
42 | 42 | QString taskname; |
43 | 43 | QVector<int> durations; |
44 | 44 | }; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
24 | 24 | #include "ActivityReport.h" |
25 | 25 | #include "ApplicationCore.h" |
26 | 26 | #include "DateEntrySyncer.h" |
27 | #include "Data.h" | |
27 | 28 | #include "SelectTaskDialog.h" |
28 | 29 | #include "ViewHelpers.h" |
29 | 30 | |
38 | 39 | #include <QTimer> |
39 | 40 | #include <QtAlgorithms> |
40 | 41 | #include <QUrl> |
41 | #include <QDebug> | |
42 | 42 | |
43 | 43 | #include "ui_ActivityReportConfigurationDialog.h" |
44 | 44 | |
45 | 45 | ActivityReportConfigurationDialog::ActivityReportConfigurationDialog( QWidget* parent ) |
46 | 46 | : ReportConfigurationDialog( parent ) |
47 | 47 | , m_ui( new Ui::ActivityReportConfigurationDialog ) |
48 | , m_rootTask( 0 ) | |
49 | 48 | { |
50 | 49 | setWindowTitle( tr( "Activity Report" ) ); |
51 | 50 | |
59 | 58 | connect( m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()) ); |
60 | 59 | connect( m_ui->comboBox, SIGNAL(currentIndexChanged(int)), |
61 | 60 | SLOT(slotTimeSpanSelected(int)) ); |
62 | connect( m_ui->checkBoxSubTasksOnly, SIGNAL(toggled(bool)), | |
63 | SLOT(slotCheckboxSubtasksOnlyChecked(bool)) ); | |
64 | connect( m_ui->checkBoxExcludeTasks, SIGNAL(toggled(bool)), | |
65 | SLOT(slotCheckBoxExcludeTasksChecked(bool)) ); | |
66 | connect( m_ui->toolButtonSelectTask, SIGNAL(clicked()), | |
61 | connect( m_ui->addExcludeTaskButton, SIGNAL(clicked()), | |
62 | SLOT(slotExcludeTask()) ); | |
63 | connect( m_ui->removeExcludeTaskButton, SIGNAL(clicked()), | |
64 | SLOT(slotRemoveExcludedTask()) ); | |
65 | connect( m_ui->addIncludeTaskButton, SIGNAL(clicked()), | |
67 | 66 | SLOT(slotSelectTask()) ); |
68 | connect( m_ui->toolButtonExcludeTask, SIGNAL(clicked()), | |
69 | SLOT(slotExcludeTask()) ); | |
70 | slotCheckboxSubtasksOnlyChecked( m_ui->checkBoxSubTasksOnly->isChecked() ); | |
71 | slotCheckBoxExcludeTasksChecked( m_ui->checkBoxExcludeTasks->isChecked() ); | |
67 | connect( m_ui->removeIncludeTaskButton, SIGNAL(clicked()), | |
68 | SLOT(slotRemoveIncludeTask()) ); | |
72 | 69 | |
73 | 70 | new DateEntrySyncer(m_ui->spinBoxStartWeek, m_ui->spinBoxStartYear, m_ui->dateEditStart, 1, this ); |
74 | 71 | new DateEntrySyncer(m_ui->spinBoxEndWeek, m_ui->spinBoxEndYear, m_ui->dateEditEnd, 7, this ); |
123 | 120 | } |
124 | 121 | } |
125 | 122 | |
126 | void ActivityReportConfigurationDialog::slotCheckboxSubtasksOnlyChecked( bool checked ) | |
127 | { | |
128 | if ( checked && m_rootTask == 0 ) { | |
129 | slotSelectTask(); | |
130 | } | |
131 | ||
132 | if ( ! checked ) { | |
133 | m_rootTask = 0; | |
134 | m_ui->labelTaskName->setText( tr( "(All Tasks)" ) ); | |
135 | } | |
136 | } | |
137 | ||
138 | void ActivityReportConfigurationDialog::slotCheckBoxExcludeTasksChecked( bool checked ) | |
139 | { | |
140 | if ( checked && m_rootExcludeTask == 0 ) { | |
141 | slotExcludeTask(); | |
142 | } | |
143 | ||
144 | if ( ! checked ) { | |
145 | m_rootExcludeTask = 0; | |
146 | m_ui->labelExcludeTaskName->setText( tr( "(No Tasks)" ) ); | |
147 | } | |
148 | } | |
149 | ||
150 | 123 | void ActivityReportConfigurationDialog::slotSelectTask() |
151 | 124 | { |
152 | if ( selectTask( m_rootTask ) ) { | |
153 | const TaskTreeItem& item = DATAMODEL->taskTreeItem( m_rootTask ); | |
154 | m_ui->labelTaskName->setText( DATAMODEL->fullTaskName( item.task() ) ); | |
155 | } else { | |
156 | if ( m_rootTask == 0 ) | |
157 | m_ui->checkBoxSubTasksOnly->setChecked( false ); | |
158 | } | |
125 | TaskId taskId; | |
126 | if ( selectTask( taskId ) && !m_rootTasks.contains(taskId)) { | |
127 | const TaskTreeItem& item = DATAMODEL->taskTreeItem( taskId ); | |
128 | QListWidgetItem* listItem = new QListWidgetItem( Data::charmIcon(), | |
129 | DATAMODEL->fullTaskName( item.task() ), | |
130 | m_ui->listWidgetIncludeTask ); | |
131 | listItem->setData( Qt::UserRole, taskId ); | |
132 | m_rootTasks << taskId; | |
133 | } | |
134 | m_ui->removeIncludeTaskButton->setEnabled( !m_rootTasks.isEmpty() ); | |
135 | m_ui->listWidgetIncludeTask->setEnabled( !m_rootTasks.isEmpty() ); | |
136 | ||
159 | 137 | } |
160 | 138 | |
161 | 139 | void ActivityReportConfigurationDialog::slotExcludeTask() |
162 | 140 | { |
163 | if ( selectTask( m_rootExcludeTask ) ) { | |
164 | const TaskTreeItem& item = DATAMODEL->taskTreeItem( m_rootExcludeTask ); | |
165 | m_ui->labelExcludeTaskName->setText( DATAMODEL->fullTaskName( item.task() ) ); | |
166 | } else { | |
167 | if ( m_rootExcludeTask == 0 ) | |
168 | m_ui->checkBoxExcludeTasks->setChecked( false ); | |
169 | } | |
141 | TaskId taskId; | |
142 | if ( selectTask( taskId ) && !m_rootExcludeTasks.contains( taskId ) ) { | |
143 | const TaskTreeItem& item = DATAMODEL->taskTreeItem( taskId ); | |
144 | QListWidgetItem* listItem = new QListWidgetItem( Data::charmIcon(), | |
145 | DATAMODEL->fullTaskName( item.task() ), | |
146 | m_ui->listWidgetExclude ); | |
147 | listItem->setData( Qt::UserRole, taskId ); | |
148 | m_rootExcludeTasks << taskId; | |
149 | } | |
150 | m_ui->removeExcludeTaskButton->setEnabled( !m_rootExcludeTasks.isEmpty() ); | |
151 | m_ui->listWidgetExclude->setEnabled( !m_rootExcludeTasks.isEmpty() ); | |
152 | } | |
153 | ||
154 | void ActivityReportConfigurationDialog::slotRemoveExcludedTask() | |
155 | { | |
156 | QListWidgetItem* item = m_ui->listWidgetExclude->currentItem(); | |
157 | if ( item ) { | |
158 | m_rootExcludeTasks.remove( item->data( Qt::UserRole ).toInt() ); | |
159 | delete item; | |
160 | } | |
161 | m_ui->removeExcludeTaskButton->setEnabled( !m_rootExcludeTasks.isEmpty() ); | |
162 | m_ui->listWidgetExclude->setEnabled( !m_rootExcludeTasks.isEmpty() ); | |
163 | } | |
164 | ||
165 | void ActivityReportConfigurationDialog::slotRemoveIncludeTask() | |
166 | { | |
167 | QListWidgetItem* item = m_ui->listWidgetIncludeTask->currentItem(); | |
168 | if ( item ) { | |
169 | m_rootTasks.remove( item->data( Qt::UserRole ).toInt() ); | |
170 | delete item; | |
171 | } | |
172 | m_ui->removeIncludeTaskButton->setEnabled( !m_rootTasks.isEmpty() ); | |
173 | m_ui->listWidgetIncludeTask->setEnabled( !m_rootTasks.isEmpty() ); | |
170 | 174 | } |
171 | 175 | |
172 | 176 | bool ActivityReportConfigurationDialog::selectTask(TaskId& task) |
185 | 189 | QDialog::accept(); |
186 | 190 | } |
187 | 191 | |
188 | void ActivityReportConfigurationDialog::showReportPreviewDialog( QWidget* parent ) | |
192 | void ActivityReportConfigurationDialog::showReportPreviewDialog() | |
189 | 193 | { |
190 | 194 | QDate start, end; |
191 | 195 | const int index = m_ui->comboBox->currentIndex(); |
197 | 201 | end = m_timespans[index].timespan.second; |
198 | 202 | } |
199 | 203 | |
200 | auto report = new ActivityReport( parent ); | |
204 | auto report = new ActivityReport(); | |
201 | 205 | report->timeSpanSelection( m_timespans[index] ); |
202 | report->setReportProperties( start, end, m_rootTask, m_rootExcludeTask ); | |
206 | report->setReportProperties( start, end, m_rootTasks, m_rootExcludeTasks ); | |
203 | 207 | report->show(); |
204 | 208 | } |
205 | 209 | |
206 | 210 | ActivityReport::ActivityReport( QWidget* parent ) |
207 | 211 | : ReportPreviewWindow( parent ) |
208 | , m_rootTask( 0 ) | |
209 | , m_rootExcludeTask( 0 ) | |
210 | 212 | { |
211 | 213 | saveToXmlButton()->hide(); |
212 | 214 | saveToTextButton()->hide(); |
218 | 220 | { |
219 | 221 | } |
220 | 222 | |
221 | void ActivityReport::setReportProperties( const QDate& start, const QDate& end, TaskId rootTask, TaskId rootExcludeTask ) | |
223 | void ActivityReport::setReportProperties( const QDate& start, const QDate& end, QSet<TaskId> rootTasks, QSet<TaskId> rootExcludeTasks ) | |
222 | 224 | { |
223 | 225 | m_start = start; |
224 | 226 | m_end = end; |
225 | m_rootTask = rootTask; | |
226 | m_rootExcludeTask = rootExcludeTask; | |
227 | m_rootTasks = rootTasks; | |
228 | m_rootExcludeTasks = rootExcludeTasks; | |
227 | 229 | slotUpdate(); |
228 | 230 | } |
229 | 231 | |
234 | 236 | |
235 | 237 | void ActivityReport::slotUpdate() |
236 | 238 | { |
237 | const QString DateFormat( "yyyy/MM/dd" ); | |
238 | const QString TimeFormat( "HH:mm" ); | |
239 | const QString DateTimeFormat( "yyyy/MM/dd HH:mm" ); | |
240 | ||
241 | 239 | // retrieve matching events: |
242 | 240 | EventIdList matchingEvents = DATAMODEL->eventsThatStartInTimeFrame( m_start, m_end ); |
241 | ||
242 | if( !m_rootTasks.isEmpty() ) { | |
243 | QSet<EventId> filteredEvents; | |
244 | Q_FOREACH( TaskId include, m_rootTasks ) { | |
245 | filteredEvents |= Charm::filteredBySubtree( matchingEvents, include ).toSet(); | |
246 | } | |
247 | matchingEvents = filteredEvents.toList(); | |
248 | } | |
243 | 249 | matchingEvents = Charm::eventIdsSortedByStartTime( matchingEvents ); |
244 | if ( m_rootTask != 0 ) { | |
245 | matchingEvents = Charm::filteredBySubtree( matchingEvents, m_rootTask ); | |
246 | } | |
247 | 250 | |
248 | 251 | // filter unproductive events: |
249 | if ( m_rootExcludeTask != 0 ) { | |
250 | matchingEvents = Charm::filteredBySubtree( matchingEvents, m_rootExcludeTask, true ); | |
252 | Q_FOREACH( TaskId exclude, m_rootExcludeTasks ) { | |
253 | matchingEvents = Charm::filteredBySubtree( matchingEvents, exclude, true ); | |
251 | 254 | } |
252 | 255 | |
253 | 256 | // calculate total: |
318 | 321 | paragraph.appendChild( totalsElement ); |
319 | 322 | body.appendChild( paragraph ); |
320 | 323 | } |
321 | if ( m_rootTask != 0 ) { | |
324 | if ( !m_rootTasks.isEmpty() ) { | |
322 | 325 | QDomElement paragraph = doc.createElement( "p" ); |
323 | const Task& task = DATAMODEL->getTask( m_rootTask ); | |
324 | QString rootTaskText = tr( "Activity under task %1" ).arg( DATAMODEL->fullTaskName( task ) ); | |
326 | QString rootTaskText = tr( "Activity under tasks:" ); | |
327 | ||
328 | Q_FOREACH( TaskId taskId, m_rootTasks ) { | |
329 | const Task& task = DATAMODEL->getTask( taskId ); | |
330 | rootTaskText.append( QString::fromLatin1( " ( %1 ),").arg( DATAMODEL->fullTaskName( task ) ) ); | |
331 | } | |
332 | rootTaskText = rootTaskText.mid(0, rootTaskText.length() - 1 ); | |
325 | 333 | QDomText rootText = doc.createTextNode( rootTaskText ); |
326 | 334 | paragraph.appendChild( rootText ); |
327 | 335 | body.appendChild( paragraph ); |
441 | 449 | default: |
442 | 450 | Q_ASSERT( false ); // should not happen |
443 | 451 | } |
444 | setReportProperties( start, end, m_rootTask, m_rootExcludeTask ); | |
452 | setReportProperties( start, end, m_rootTasks, m_rootExcludeTasks ); | |
445 | 453 | } |
446 | 454 | #include "moc_ActivityReport.cpp" |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
43 | 43 | |
44 | 44 | public: |
45 | 45 | explicit ActivityReportConfigurationDialog( QWidget* parent ); |
46 | ~ActivityReportConfigurationDialog(); | |
46 | ~ActivityReportConfigurationDialog() override; | |
47 | 47 | |
48 | void showReportPreviewDialog( QWidget* parent ) override; | |
48 | void showReportPreviewDialog() override; | |
49 | 49 | |
50 | 50 | public Q_SLOTS: |
51 | 51 | void accept() override; |
54 | 54 | void slotDelayedInitialization(); |
55 | 55 | void slotStandardTimeSpansChanged(); |
56 | 56 | void slotTimeSpanSelected( int ); |
57 | void slotCheckboxSubtasksOnlyChecked( bool ); | |
58 | void slotCheckBoxExcludeTasksChecked( bool ); | |
59 | 57 | void slotSelectTask(); |
60 | 58 | void slotExcludeTask(); |
59 | void slotRemoveExcludedTask(); | |
60 | void slotRemoveIncludeTask(); | |
61 | 61 | |
62 | 62 | private: |
63 | 63 | bool selectTask(TaskId& task); |
64 | 64 | |
65 | 65 | QScopedPointer<Ui::ActivityReportConfigurationDialog> m_ui; |
66 | 66 | QList<NamedTimeSpan> m_timespans; |
67 | TaskId m_rootTask; | |
68 | TaskId m_rootExcludeTask; | |
67 | QSet<TaskId> m_rootTasks; | |
68 | QSet<TaskId> m_rootExcludeTasks; | |
69 | 69 | }; |
70 | 70 | |
71 | 71 | class ActivityReport : public ReportPreviewWindow |
74 | 74 | |
75 | 75 | public: |
76 | 76 | explicit ActivityReport( QWidget* parent = nullptr ); |
77 | ~ActivityReport(); | |
77 | ~ActivityReport() override; | |
78 | 78 | |
79 | void setReportProperties( const QDate& start, const QDate& end, | |
80 | TaskId rootTask, TaskId rootExcludeTask ); | |
79 | void setReportProperties(const QDate& start, const QDate& end, | |
80 | QSet<TaskId> rootTasks, QSet<TaskId> rootExcludeTasks ); | |
81 | 81 | void timeSpanSelection( NamedTimeSpan timeSpanSelection ); |
82 | 82 | |
83 | 83 | private slots: |
89 | 89 | private: |
90 | 90 | QDate m_start; |
91 | 91 | QDate m_end; |
92 | TaskId m_rootTask; | |
93 | TaskId m_rootExcludeTask; | |
92 | QSet<TaskId> m_rootTasks; | |
93 | QSet<TaskId> m_rootExcludeTasks; | |
94 | 94 | NamedTimeSpan m_timeSpanSelection; |
95 | 95 | }; |
96 | 96 |
6 | 6 | <x>0</x> |
7 | 7 | <y>0</y> |
8 | 8 | <width>500</width> |
9 | <height>397</height> | |
9 | <height>637</height> | |
10 | 10 | </rect> |
11 | 11 | </property> |
12 | 12 | <property name="windowTitle"> |
181 | 181 | </widget> |
182 | 182 | </item> |
183 | 183 | <item> |
184 | <spacer> | |
185 | <property name="orientation"> | |
186 | <enum>Qt::Vertical</enum> | |
187 | </property> | |
188 | <property name="sizeHint" stdset="0"> | |
189 | <size> | |
190 | <width>20</width> | |
191 | <height>40</height> | |
192 | </size> | |
193 | </property> | |
194 | </spacer> | |
195 | </item> | |
196 | <item> | |
184 | 197 | <widget class="QGroupBox" name="groupBox_2"> |
185 | 198 | <property name="title"> |
186 | 199 | <string>Included tasks</string> |
187 | 200 | </property> |
188 | 201 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
189 | 202 | <item> |
190 | <layout class="QHBoxLayout" name="_3"> | |
191 | <item> | |
192 | <widget class="QCheckBox" name="checkBoxSubTasksOnly"> | |
193 | <property name="text"> | |
194 | <string>Show...</string> | |
195 | </property> | |
196 | </widget> | |
197 | </item> | |
198 | <item> | |
199 | <widget class="QLabel" name="labelTaskName"> | |
200 | <property name="enabled"> | |
201 | <bool>false</bool> | |
202 | </property> | |
203 | <property name="sizePolicy"> | |
204 | <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> | |
205 | <horstretch>0</horstretch> | |
206 | <verstretch>0</verstretch> | |
207 | </sizepolicy> | |
208 | </property> | |
209 | <property name="text"> | |
210 | <string>(task name)</string> | |
211 | </property> | |
212 | <property name="alignment"> | |
213 | <set>Qt::AlignCenter</set> | |
214 | </property> | |
215 | </widget> | |
216 | </item> | |
217 | </layout> | |
218 | </item> | |
219 | <item> | |
220 | <layout class="QHBoxLayout" name="_4"> | |
221 | <item> | |
222 | <widget class="QLabel" name="label_5"> | |
223 | <property name="text"> | |
224 | <string>... and subtasks</string> | |
225 | </property> | |
226 | </widget> | |
227 | </item> | |
228 | <item> | |
229 | <widget class="QToolButton" name="toolButtonSelectTask"> | |
230 | <property name="enabled"> | |
231 | <bool>false</bool> | |
232 | </property> | |
233 | <property name="text"> | |
234 | <string>Select Task...</string> | |
235 | </property> | |
236 | </widget> | |
237 | </item> | |
238 | <item> | |
239 | <widget class="QLabel" name="label_4"> | |
240 | <property name="text"> | |
241 | <string>(all tasks, otherwise).</string> | |
242 | </property> | |
243 | </widget> | |
244 | </item> | |
245 | <item> | |
246 | <spacer> | |
203 | <widget class="QLabel" name="label_5"> | |
204 | <property name="text"> | |
205 | <string>Include tasks and subtasks (all tasks, otherwise).</string> | |
206 | </property> | |
207 | </widget> | |
208 | </item> | |
209 | <item> | |
210 | <widget class="QListWidget" name="listWidgetIncludeTask"> | |
211 | <property name="enabled"> | |
212 | <bool>false</bool> | |
213 | </property> | |
214 | </widget> | |
215 | </item> | |
216 | <item> | |
217 | <layout class="QHBoxLayout" name="horizontalLayout_4"> | |
218 | <item> | |
219 | <widget class="QPushButton" name="addIncludeTaskButton"> | |
220 | <property name="text"> | |
221 | <string>Add Task</string> | |
222 | </property> | |
223 | </widget> | |
224 | </item> | |
225 | <item> | |
226 | <widget class="QPushButton" name="removeIncludeTaskButton"> | |
227 | <property name="text"> | |
228 | <string>Remove Selected Task</string> | |
229 | </property> | |
230 | </widget> | |
231 | </item> | |
232 | <item> | |
233 | <spacer name="horizontalSpacer"> | |
247 | 234 | <property name="orientation"> |
248 | 235 | <enum>Qt::Horizontal</enum> |
249 | 236 | </property> |
257 | 244 | </item> |
258 | 245 | </layout> |
259 | 246 | </item> |
260 | <item> | |
261 | <layout class="QHBoxLayout" name="_5"> | |
262 | <item> | |
263 | <widget class="QCheckBox" name="checkBoxExcludeTasks"> | |
264 | <property name="text"> | |
265 | <string>Exclude...</string> | |
266 | </property> | |
267 | </widget> | |
268 | </item> | |
269 | <item> | |
270 | <widget class="QLabel" name="labelExcludeTaskName"> | |
271 | <property name="enabled"> | |
272 | <bool>false</bool> | |
273 | </property> | |
274 | <property name="sizePolicy"> | |
275 | <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> | |
276 | <horstretch>0</horstretch> | |
277 | <verstretch>0</verstretch> | |
278 | </sizepolicy> | |
279 | </property> | |
280 | <property name="text"> | |
281 | <string>(task name)</string> | |
282 | </property> | |
283 | <property name="alignment"> | |
284 | <set>Qt::AlignCenter</set> | |
285 | </property> | |
286 | </widget> | |
287 | </item> | |
288 | </layout> | |
289 | </item> | |
290 | <item> | |
291 | <layout class="QHBoxLayout" name="_6"> | |
292 | <item> | |
293 | <widget class="QLabel" name="label_6"> | |
294 | <property name="text"> | |
295 | <string>... and subtasks</string> | |
296 | </property> | |
297 | </widget> | |
298 | </item> | |
299 | <item> | |
300 | <widget class="QToolButton" name="toolButtonExcludeTask"> | |
301 | <property name="enabled"> | |
302 | <bool>false</bool> | |
303 | </property> | |
304 | <property name="text"> | |
305 | <string>Select Task...</string> | |
306 | </property> | |
307 | </widget> | |
308 | </item> | |
309 | <item> | |
310 | <widget class="QLabel" name="label_7"> | |
311 | <property name="text"> | |
312 | <string>(no tasks, otherwise).</string> | |
313 | </property> | |
314 | </widget> | |
315 | </item> | |
316 | <item> | |
317 | <spacer> | |
247 | </layout> | |
248 | </widget> | |
249 | </item> | |
250 | <item> | |
251 | <widget class="QGroupBox" name="groupBox_3"> | |
252 | <property name="title"> | |
253 | <string>Exclude tasks</string> | |
254 | </property> | |
255 | <layout class="QVBoxLayout" name="verticalLayout_6"> | |
256 | <item> | |
257 | <widget class="QLabel" name="label_6"> | |
258 | <property name="text"> | |
259 | <string>Exclude tasks and subtasks (no tasks, otherwise).</string> | |
260 | </property> | |
261 | </widget> | |
262 | </item> | |
263 | <item> | |
264 | <widget class="QListWidget" name="listWidgetExclude"> | |
265 | <property name="enabled"> | |
266 | <bool>false</bool> | |
267 | </property> | |
268 | </widget> | |
269 | </item> | |
270 | <item> | |
271 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | |
272 | <item> | |
273 | <widget class="QPushButton" name="addExcludeTaskButton"> | |
274 | <property name="text"> | |
275 | <string>Add Task</string> | |
276 | </property> | |
277 | </widget> | |
278 | </item> | |
279 | <item> | |
280 | <widget class="QPushButton" name="removeExcludeTaskButton"> | |
281 | <property name="text"> | |
282 | <string>Remove Selected Task</string> | |
283 | </property> | |
284 | </widget> | |
285 | </item> | |
286 | <item> | |
287 | <spacer name="horizontalSpacer_2"> | |
318 | 288 | <property name="orientation"> |
319 | 289 | <enum>Qt::Horizontal</enum> |
320 | 290 | </property> |
332 | 302 | </widget> |
333 | 303 | </item> |
334 | 304 | <item> |
335 | <spacer> | |
336 | <property name="orientation"> | |
337 | <enum>Qt::Vertical</enum> | |
338 | </property> | |
339 | <property name="sizeHint" stdset="0"> | |
340 | <size> | |
341 | <width>20</width> | |
342 | <height>40</height> | |
343 | </size> | |
344 | </property> | |
345 | </spacer> | |
346 | </item> | |
347 | <item> | |
348 | 305 | <layout class="QHBoxLayout"> |
349 | 306 | <item> |
350 | 307 | <widget class="QDialogButtonBox" name="buttonBox"> |
358 | 315 | </layout> |
359 | 316 | </widget> |
360 | 317 | <resources/> |
361 | <connections> | |
362 | <connection> | |
363 | <sender>checkBoxSubTasksOnly</sender> | |
364 | <signal>toggled(bool)</signal> | |
365 | <receiver>labelTaskName</receiver> | |
366 | <slot>setEnabled(bool)</slot> | |
367 | <hints> | |
368 | <hint type="sourcelabel"> | |
369 | <x>52</x> | |
370 | <y>160</y> | |
371 | </hint> | |
372 | <hint type="destinationlabel"> | |
373 | <x>201</x> | |
374 | <y>165</y> | |
375 | </hint> | |
376 | </hints> | |
377 | </connection> | |
378 | <connection> | |
379 | <sender>checkBoxSubTasksOnly</sender> | |
380 | <signal>toggled(bool)</signal> | |
381 | <receiver>toolButtonSelectTask</receiver> | |
382 | <slot>setEnabled(bool)</slot> | |
383 | <hints> | |
384 | <hint type="sourcelabel"> | |
385 | <x>64</x> | |
386 | <y>161</y> | |
387 | </hint> | |
388 | <hint type="destinationlabel"> | |
389 | <x>169</x> | |
390 | <y>197</y> | |
391 | </hint> | |
392 | </hints> | |
393 | </connection> | |
394 | <connection> | |
395 | <sender>checkBoxExcludeTasks</sender> | |
396 | <signal>toggled(bool)</signal> | |
397 | <receiver>labelExcludeTaskName</receiver> | |
398 | <slot>setEnabled(bool)</slot> | |
399 | <hints> | |
400 | <hint type="sourcelabel"> | |
401 | <x>69</x> | |
402 | <y>225</y> | |
403 | </hint> | |
404 | <hint type="destinationlabel"> | |
405 | <x>262</x> | |
406 | <y>225</y> | |
407 | </hint> | |
408 | </hints> | |
409 | </connection> | |
410 | <connection> | |
411 | <sender>checkBoxExcludeTasks</sender> | |
412 | <signal>toggled(bool)</signal> | |
413 | <receiver>toolButtonExcludeTask</receiver> | |
414 | <slot>setEnabled(bool)</slot> | |
415 | <hints> | |
416 | <hint type="sourcelabel"> | |
417 | <x>69</x> | |
418 | <y>225</y> | |
419 | </hint> | |
420 | <hint type="destinationlabel"> | |
421 | <x>177</x> | |
422 | <y>260</y> | |
423 | </hint> | |
424 | </hints> | |
425 | </connection> | |
426 | </connections> | |
318 | <connections/> | |
427 | 319 | </ui> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
26 | 26 | #include <QDialogButtonBox> |
27 | 27 | |
28 | 28 | BillDialog::BillDialog( QWidget* parent, Qt::WindowFlags f ) |
29 | : QDialog(parent, f), m_year( 0 ), m_week( 0 ) | |
29 | : QDialog(parent, f) | |
30 | 30 | { |
31 | 31 | setResult(Later); |
32 | 32 | QPalette p = palette(); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
47 | 47 | QPushButton *m_asYouWish; |
48 | 48 | QPushButton *m_alreadyDone; |
49 | 49 | QPushButton *m_later; |
50 | int m_year; | |
51 | int m_week; | |
50 | int m_year = 0; | |
51 | int m_week = 0; | |
52 | 52 | }; |
53 | 53 | |
54 | 54 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
36 | 36 | |
37 | 37 | public: |
38 | 38 | explicit CharmAboutDialog( QWidget* parent = nullptr ); |
39 | ~CharmAboutDialog(); | |
39 | ~CharmAboutDialog() override; | |
40 | 40 | |
41 | 41 | private: |
42 | 42 | QScopedPointer<Ui::CharmAboutDialog> m_ui; |
77 | 77 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> |
78 | 78 | p, li { white-space: pre-wrap; } |
79 | 79 | </style></head><body style=" font-family:'.Lucida Grande UI'; font-size:13pt; font-weight:400; font-style:normal;"> |
80 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Copyright © 2006-2015 The Charm Authors</span></p> | |
80 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Copyright © 2006-2016 The Charm Authors</span></p> | |
81 | 81 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Licensed under the terms of the GPL.</span></p> |
82 | 82 | <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p> |
83 | 83 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:9pt;">Charm is supported and maintained by </span><a href="http://www.kdab.com"><span style=" font-family:'Sans Serif'; font-size:9pt; text-decoration: underline; color:#0057ae;">KDAB</span></a></p> |
90 | 90 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:9pt;">Frank Osterfeld, Guillermo Amaral</span></p> |
91 | 91 | <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:9pt;"><br /></p> |
92 | 92 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:9pt;">Contributors:</span></p> |
93 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:9pt;">Mike McQuaid (former maintainer), Till Adam, David Faure, Nuno Pinheiro, Pradeepto Batthacharya, Katrina Niolet, Nicholas Van Sickle, Jesper K. Pedersen, Sebastian Sauer, Michel Boyer de la Giroday</span></p></body></html></string> | |
93 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:9pt;">Mike McQuaid (former maintainer), Till Adam, David Faure, Nuno Pinheiro, Pradeepto Batthacharya, Katrina Niolet, Nicholas Van Sickle, Jesper K. Pedersen, Sebastian Sauer, Michel Boyer de la Giroday, Hannah von Reth</span></p></body></html></string> | |
94 | 94 | </property> |
95 | 95 | <property name="textInteractionFlags"> |
96 | 96 | <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Michel Boyer de la Giroday <michel.giroday@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Michel Boyer de la Giroday <michel.giroday@kdab.com> |
8 | 8 | |
37 | 37 | |
38 | 38 | public: |
39 | 39 | explicit CharmNewReleaseDialog( QWidget* parent = nullptr ); |
40 | ~CharmNewReleaseDialog(); | |
40 | ~CharmNewReleaseDialog() override; | |
41 | 41 | |
42 | 42 | void setVersion( const QString& newVersion , const QString& localVersion ); |
43 | 43 | void setDownloadLink( const QUrl& link ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Mathias Hasselmann <mathias.hasselmann@kdab.com> |
45 | 45 | |
46 | 46 | m_ui.lbWarnUnuploadedTimesheets->setVisible( httpJobPossible ); |
47 | 47 | m_ui.cbWarnUnuploadedTimesheets->setVisible( httpJobPossible ); |
48 | m_ui.lbResetPassword->setVisible( httpJobPossible ); | |
49 | m_ui.pbResetPassword->setVisible( httpJobPossible ); | |
48 | 50 | m_ui.cbIdleDetection->setEnabled( haveIdleDetection ); |
49 | 51 | m_ui.lbIdleDetection->setEnabled( haveIdleDetection ); |
50 | 52 | m_ui.cbIdleDetection->setChecked( config.detectIdling && m_ui.cbIdleDetection->isEnabled() ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
35 | 35 | public: |
36 | 36 | explicit CharmPreferences( const Configuration& config, |
37 | 37 | QWidget* parent = nullptr ); |
38 | ~CharmPreferences(); | |
38 | ~CharmPreferences() override; | |
39 | 39 | |
40 | 40 | Configuration::DurationFormat durationFormat() const; |
41 | 41 | bool detectIdling() const; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
24 | 24 | #include "ApplicationCore.h" |
25 | 25 | #include "Data.h" |
26 | 26 | #include "ViewHelpers.h" |
27 | #include "WidgetUtils.h" | |
27 | 28 | |
28 | 29 | #include "Commands/CommandRelayCommand.h" |
29 | 30 | |
39 | 40 | #include <QToolBar> |
40 | 41 | #include <QToolButton> |
41 | 42 | |
42 | #include <algorithm> | |
43 | #include <functional> | |
44 | ||
45 | 43 | CharmWindow::CharmWindow( const QString& name, QWidget* parent ) |
46 | 44 | : QMainWindow( parent ) |
47 | 45 | , m_openCharmAction( new QAction( tr( "Open Charm" ), this ) ) |
48 | 46 | , m_showAction( new QAction( this ) ) |
49 | , m_showHideAction( new QAction( this ) ) | |
50 | , m_windowNumber( -1 ) | |
51 | , m_shortcut( 0 ) | |
52 | 47 | { |
53 | 48 | setWindowName( name ); |
54 | handleOpenCharm( false ); | |
55 | handleShow( false ); | |
56 | handleShowHide( false ); | |
57 | 49 | connect( m_openCharmAction, SIGNAL(triggered(bool)), SLOT(showView()) ); |
58 | 50 | connect( m_showAction, SIGNAL(triggered(bool)), SLOT(showView()) ); |
59 | connect( m_showHideAction, SIGNAL(triggered(bool)), SLOT(showHideView()) ); | |
51 | connect( this, SIGNAL(visibilityChanged(bool)), SLOT(handleOpenCharm(bool)) ); | |
52 | connect( this, SIGNAL(visibilityChanged(bool)), SLOT(handleShow(bool)) ); | |
60 | 53 | m_toolBar = addToolBar( "Toolbar" ); |
61 | 54 | m_toolBar->setMovable( false ); |
55 | ||
56 | emit visibilityChanged( false ); | |
62 | 57 | } |
63 | 58 | |
64 | 59 | void CharmWindow::stateChanged( State ) |
104 | 99 | m_windowIdentifier = id; |
105 | 100 | } |
106 | 101 | |
107 | QString CharmWindow::windowIdentfier() const | |
102 | QString CharmWindow::windowIdentifier() const | |
108 | 103 | { |
109 | 104 | return m_windowIdentifier; |
110 | 105 | } |
119 | 114 | m_shortcut->setKey( sequence ); |
120 | 115 | #endif |
121 | 116 | m_shortcut->setContext( Qt::ApplicationShortcut ); |
122 | m_showHideAction->setShortcut( sequence ); | |
123 | 117 | m_showAction->setShortcut( sequence ); |
124 | 118 | connect( m_shortcut, SIGNAL(activated()), SLOT(showHideView()) ); |
125 | 119 | connect( m_shortcut, SIGNAL(activated()), SLOT(showView()) ); |
145 | 139 | return m_showAction; |
146 | 140 | } |
147 | 141 | |
148 | QAction* CharmWindow::showHideAction() | |
149 | { | |
150 | return m_showHideAction; | |
151 | } | |
152 | ||
153 | 142 | void CharmWindow::restore() |
154 | 143 | { |
155 | 144 | show(); |
156 | 145 | } |
157 | 146 | |
147 | void CharmWindow::checkVisibility() | |
148 | { | |
149 | const auto visibility = isVisible(); | |
150 | ||
151 | if (m_isVisibility != visibility) { | |
152 | m_isVisibility = visibility; | |
153 | emit visibilityChanged( m_isVisibility ); | |
154 | } | |
155 | } | |
156 | ||
158 | 157 | void CharmWindow::showEvent( QShowEvent* e ) |
159 | 158 | { |
160 | handleOpenCharm( true ); | |
161 | handleShow( true ); | |
162 | handleShowHide( true ); | |
159 | checkVisibility(); | |
163 | 160 | QMainWindow::showEvent( e ); |
164 | 161 | } |
165 | 162 | |
166 | 163 | void CharmWindow::hideEvent( QHideEvent* e ) |
167 | 164 | { |
168 | handleOpenCharm( false ); | |
169 | handleShow( false ); | |
170 | handleShowHide( false ); | |
165 | checkVisibility(); | |
171 | 166 | QMainWindow::hideEvent( e ); |
172 | 167 | } |
173 | 168 | |
198 | 193 | const QString text = tr( "Show %1" ).arg( m_windowName ); |
199 | 194 | m_showAction->setText( text ); |
200 | 195 | m_showAction->setEnabled( !visible ); |
201 | } | |
202 | ||
203 | void CharmWindow::handleShowHide( bool visible ) | |
204 | { | |
205 | const QString text = visible ? tr( "Hide %1 Window" ).arg( m_windowName ) | |
206 | : tr( "Show %1 Window" ).arg( m_windowName ); | |
207 | m_showHideAction->setText( text ); | |
208 | emit visibilityChanged( visible ); | |
209 | 196 | } |
210 | 197 | |
211 | 198 | void CharmWindow::commitCommand( CharmCommand* command ) |
241 | 228 | w->hide(); |
242 | 229 | return false; |
243 | 230 | } else { |
244 | w->show(); | |
245 | w->raise(); | |
246 | w->activateWindow(); | |
231 | showView( w ); | |
247 | 232 | return true; |
248 | 233 | } |
249 | 234 | } |
260 | 245 | |
261 | 246 | void CharmWindow::configurationChanged() |
262 | 247 | { |
263 | const QList<QToolButton*> buttons = findChildren<QToolButton *>(); | |
264 | std::for_each( buttons.begin(), buttons.end(), | |
265 | std::bind2nd( std::mem_fun( &QToolButton::setToolButtonStyle ), CONFIGURATION.toolButtonStyle ) ); | |
248 | WidgetUtils::updateToolButtonStyle( this ); | |
266 | 249 | } |
267 | 250 | |
268 | 251 | void CharmWindow::saveGuiState() |
269 | 252 | { |
270 | Q_ASSERT( !windowIdentfier().isEmpty() ); | |
253 | Q_ASSERT( !windowIdentifier().isEmpty() ); | |
271 | 254 | QSettings settings; |
272 | settings.beginGroup( windowIdentfier() ); | |
255 | settings.beginGroup( windowIdentifier() ); | |
273 | 256 | // save geometry |
274 | settings.setValue( MetaKey_MainWindowGeometry, saveGeometry() ); | |
257 | WidgetUtils::saveGeometry( this, MetaKey_MainWindowGeometry ); | |
275 | 258 | settings.setValue( MetaKey_MainWindowVisible, isVisible() ); |
276 | 259 | } |
277 | 260 | |
278 | 261 | void CharmWindow::restoreGuiState() |
279 | 262 | { |
280 | Q_ASSERT( !windowIdentfier().isEmpty() ); | |
263 | const QString identifier = windowIdentifier(); | |
264 | Q_ASSERT( !identifier.isEmpty() ); | |
281 | 265 | // restore geometry |
282 | 266 | QSettings settings; |
283 | settings.beginGroup( windowIdentfier() ); | |
284 | if ( settings.contains( MetaKey_MainWindowGeometry ) ) { | |
285 | restoreGeometry( settings.value( MetaKey_MainWindowGeometry ).toByteArray() ); | |
286 | } | |
267 | settings.beginGroup( identifier ); | |
268 | WidgetUtils::restoreGeometry( this, MetaKey_MainWindowGeometry ); | |
287 | 269 | // restore visibility |
288 | 270 | if ( settings.contains( MetaKey_MainWindowVisible ) ) { |
289 | const bool visible = settings.value( MetaKey_MainWindowVisible ).toBool(); | |
290 | setVisible(visible); | |
271 | // Time Tracking Window should always be visible | |
272 | const bool visible = ( identifier == "window_tracking" ) ? true : settings.value( MetaKey_MainWindowVisible ).toBool(); | |
273 | setVisible( visible ); | |
291 | 274 | } |
292 | 275 | } |
293 | 276 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
32 | 32 | class QShortcut; |
33 | 33 | |
34 | 34 | class CharmWindow : public QMainWindow, |
35 | public ViewInterface, | |
36 | public CommandEmitterInterface | |
35 | public ViewInterface | |
37 | 36 | { |
38 | 37 | Q_OBJECT |
39 | 38 | |
40 | 39 | public: |
41 | 40 | explicit CharmWindow( const QString& name, QWidget* parent = nullptr ); |
42 | 41 | |
43 | QAction* showHideAction(); | |
44 | 42 | QAction* showAction(); |
45 | 43 | QAction* openCharmAction(); |
46 | 44 | |
47 | 45 | QString windowName() const; |
48 | QString windowIdentfier() const; | |
46 | QString windowIdentifier() const; | |
49 | 47 | int windowNumber() const; |
50 | 48 | |
51 | 49 | virtual QToolBar* toolBar() const; |
63 | 61 | /** Insert the Edit menu. Empty by default. */ |
64 | 62 | virtual void insertEditMenu() {} |
65 | 63 | |
64 | void checkVisibility(); | |
65 | ||
66 | 66 | public: |
67 | 67 | void stateChanged( State previous ) override; |
68 | 68 | void showEvent( QShowEvent* ) override; |
69 | 69 | void hideEvent( QHideEvent* ) override; |
70 | 70 | void keyPressEvent( QKeyEvent* event ) override; |
71 | 71 | |
72 | virtual void saveGuiState(); | |
73 | virtual void restoreGuiState(); | |
72 | void saveGuiState() override; | |
73 | void restoreGuiState() override; | |
74 | 74 | |
75 | 75 | static void showView( QWidget* w ); |
76 | 76 | static bool showHideView( QWidget* w ); |
88 | 88 | void showHideView(); |
89 | 89 | void configurationChanged() override; |
90 | 90 | |
91 | private: | |
91 | private slots: | |
92 | 92 | void handleOpenCharm( bool visible ); |
93 | 93 | void handleShow( bool visible ); |
94 | void handleShowHide( bool visible ); | |
94 | ||
95 | private: | |
95 | 96 | QString m_windowName; |
96 | 97 | QAction* m_openCharmAction; |
97 | 98 | QAction* m_showAction; |
98 | QAction* m_showHideAction; | |
99 | int m_windowNumber; // Mac numerical window number, used for shortcut etc | |
99 | int m_windowNumber = -1; // Mac numerical window number, used for shortcut etc | |
100 | 100 | QString m_windowIdentifier; |
101 | QShortcut* m_shortcut; | |
101 | QShortcut* m_shortcut = nullptr; | |
102 | 102 | QToolBar* m_toolBar; |
103 | bool m_isVisibility = false; | |
103 | 104 | }; |
104 | 105 | |
105 | 106 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mathias Hasselmann <mathias.hasselmann@kdab.com> |
8 | 8 | |
33 | 33 | CommentEditorPopup::CommentEditorPopup( QWidget *parent ) |
34 | 34 | : QDialog( parent ) |
35 | 35 | , ui( new Ui::CommentEditorPopup ) |
36 | , m_id() | |
37 | 36 | { |
38 | 37 | ui->setupUi( this ); |
39 | 38 | ui->buttonBox->button( QDialogButtonBox::Ok )->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_Return ) ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mathias Hasselmann <mathias.hasselmann@kdab.com> |
8 | 8 | |
37 | 37 | |
38 | 38 | public: |
39 | 39 | explicit CommentEditorPopup( QWidget *parent = nullptr ); |
40 | ~CommentEditorPopup(); | |
40 | ~CommentEditorPopup() override; | |
41 | 41 | |
42 | 42 | public Q_SLOTS: |
43 | 43 | void loadEvent( EventId id ); |
45 | 45 | |
46 | 46 | private: |
47 | 47 | Ui::CommentEditorPopup *ui; |
48 | EventId m_id; | |
48 | EventId m_id = {}; | |
49 | 49 | }; |
50 | 50 | |
51 | 51 | #endif // COMMENTEDITORPOPUP_H |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
42 | 42 | |
43 | 43 | static QString toHtmlEscaped( const QString& s ) |
44 | 44 | { |
45 | #if QT_VERSION < 0x050000 | |
45 | #if QT_VERSION < QT_VERSION_CHECK(5,0,0) | |
46 | 46 | return Qt::escape( s ); |
47 | 47 | #else |
48 | 48 | return s.toHtmlEscaped(); |
70 | 70 | EventList events; |
71 | 71 | |
72 | 72 | const int days = start.daysTo( end ); |
73 | #if QT_VERSION >= 0x040700 | |
73 | #if QT_VERSION >= QT_VERSION_CHECK(4,7,0) | |
74 | 74 | events.reserve( days ); |
75 | 75 | #endif |
76 | 76 | for ( int i = 0; i < days; ++i ) { |
93 | 93 | EnterVacationDialog::EnterVacationDialog( QWidget* parent ) |
94 | 94 | : QDialog( parent ) |
95 | 95 | , m_ui( new Ui::EnterVacationDialog ) |
96 | , m_selectedTaskId( -1 ) | |
97 | 96 | { |
98 | 97 | setWindowTitle( tr( "Enter Vacation" ) ); |
99 | 98 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
38 | 38 | Q_OBJECT |
39 | 39 | public: |
40 | 40 | explicit EnterVacationDialog( QWidget* parent=nullptr ); |
41 | ~EnterVacationDialog(); | |
41 | ~EnterVacationDialog() override; | |
42 | 42 | |
43 | 43 | EventList events() const; |
44 | 44 | |
53 | 53 | |
54 | 54 | private: |
55 | 55 | QScopedPointer<Ui::EnterVacationDialog> m_ui; |
56 | TaskId m_selectedTaskId; | |
56 | TaskId m_selectedTaskId = -1; | |
57 | 57 | EventList m_events; |
58 | 58 | }; |
59 | 59 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
39 | 39 | : QDialog( parent ) |
40 | 40 | , m_ui( new Ui::EventEditor ) |
41 | 41 | , m_event( event ) |
42 | , m_updating( false ) | |
43 | , m_endDateChanged( true ) | |
44 | 42 | { |
45 | 43 | m_ui->setupUi( this ); |
46 | 44 | m_ui->dateEditEnd->calendarWidget()->setFirstDayOfWeek( Qt::Monday ); |
218 | 216 | bool active = MODEL.charmDataModel()->isEventActive( m_event.id() ); |
219 | 217 | m_ui->dateEditEnd->setEnabled( !active ); |
220 | 218 | m_ui->timeEditEnd->setEnabled( !active ); |
221 | m_ui->textEditComment->setEnabled( !active ); | |
222 | 219 | m_ui->spinBoxHours->setEnabled( !active ); |
223 | 220 | m_ui->spinBoxMinutes->setEnabled( !active ); |
224 | 221 | m_ui->pushButtonSelectTask->setEnabled( !active ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
39 | 39 | |
40 | 40 | public: |
41 | 41 | explicit EventEditor( const Event& event, QWidget* parent = nullptr ); |
42 | virtual ~EventEditor(); | |
42 | ~EventEditor() override; | |
43 | 43 | |
44 | 44 | // return the result after the dialog has been accepted |
45 | 45 | Event eventResult() const; |
65 | 65 | |
66 | 66 | QScopedPointer<Ui::EventEditor> m_ui; |
67 | 67 | Event m_event; |
68 | bool m_updating; | |
69 | bool m_endDateChanged; | |
68 | bool m_updating = false; | |
69 | bool m_endDateChanged = true; | |
70 | 70 | }; |
71 | 71 | |
72 | 72 | #endif /* EVENTEDITOR_H */ |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
46 | 46 | // to have the size hint recalculated, simply set m_cachedSizeHint |
47 | 47 | // to an invalid value (m_cachedSizeHint = QSize();) |
48 | 48 | if ( ! m_cachedSizeHint.isValid() ) { |
49 | // make up event settings and calculate the space they need: | |
50 | QPixmap pixmap( 2000, 800 ); // temp | |
49 | ||
50 | const Event& event = m_model->eventForIndex( index ); | |
51 | Q_ASSERT( event.isValid() ); | |
52 | const TaskTreeItem& item = DATAMODEL->taskTreeItem( event.taskId() ); | |
53 | ||
54 | QPixmap pixmap( option.rect.size() ); // temp | |
51 | 55 | QPainter painter( &pixmap ); |
52 | QStyleOptionViewItem fakeOption ( option ); | |
53 | fakeOption.rect.setSize( pixmap.size() ); | |
54 | const QString task ( tr( "KDAB/Programming" ) ); | |
55 | QString dateAndDuration; | |
56 | QTextStream stream( &dateAndDuration ); | |
57 | QDate date = QDate::currentDate(); | |
58 | QTime time = QTime::currentTime(); | |
59 | stream << date.toString( Qt::SystemLocaleDate ) | |
60 | << " " << time.toString( Qt::SystemLocaleDate ) | |
61 | << " " << hoursAndMinutes( 3654 ); | |
62 | m_cachedSizeHint = paint( &painter, fakeOption, | |
63 | task, dateAndDuration, | |
56 | m_cachedSizeHint = paint( &painter, option, | |
57 | taskName( item ), | |
58 | dateAndDuration( event ), | |
64 | 59 | 42, EventState_Locked ).size(); |
65 | 60 | } |
66 | 61 | return m_cachedSizeHint; |
76 | 71 | |
77 | 72 | if ( event.isValid() ) { |
78 | 73 | bool locked = DATAMODEL->isEventActive( event.id() ); |
79 | QString dateAndDuration; | |
80 | QTextStream dateStream( &dateAndDuration ); | |
81 | QDate date = event.startDateTime().date(); | |
82 | QTime time = event.startDateTime().time(); | |
83 | QTime endTime = event.endDateTime().time(); | |
84 | dateStream << date.toString( Qt::SystemLocaleDate ) | |
85 | << " " << time.toString( "h:mm" ) | |
86 | << " - " << endTime.toString( "h:mm" ) | |
87 | << " (" << hoursAndMinutes( event.duration() ) << ") Week " | |
88 | << date.weekNumber(); | |
89 | ||
90 | QString taskName; | |
91 | QTextStream taskStream( &taskName ); | |
92 | // print leading zeroes for the TaskId | |
93 | const int taskIdLength = CONFIGURATION.taskPaddingLength; | |
94 | taskStream << QString( "%1" ).arg( item.task().id(), taskIdLength, 10, QChar( '0' ) ) | |
95 | << " " << DATAMODEL->smartTaskName( item.task() ); | |
96 | 74 | |
97 | 75 | paint( painter, option, |
98 | taskName, | |
99 | dateAndDuration, | |
76 | taskName( item ), | |
77 | dateAndDuration( event ), | |
100 | 78 | logDuration( event.duration() ), |
101 | 79 | locked ? EventState_Locked : EventState_Default ); |
102 | 80 | } |
81 | } | |
82 | ||
83 | QString EventEditorDelegate::taskName( const TaskTreeItem& item ) const | |
84 | { | |
85 | QString taskName; | |
86 | QTextStream taskStream( &taskName ); | |
87 | // print leading zeroes for the TaskId | |
88 | const int taskIdLength = CONFIGURATION.taskPaddingLength; | |
89 | taskStream << QString( "%1" ).arg( item.task().id(), taskIdLength, 10, QChar( '0' ) ) | |
90 | << " " << DATAMODEL->smartTaskName( item.task() ); | |
91 | return taskName; | |
92 | } | |
93 | ||
94 | QString EventEditorDelegate::dateAndDuration( const Event &event ) const | |
95 | { | |
96 | QString dateAndDuration; | |
97 | QTextStream dateStream( &dateAndDuration ); | |
98 | QDate date = event.startDateTime().date(); | |
99 | QTime time = event.startDateTime().time(); | |
100 | QTime endTime = event.endDateTime().time(); | |
101 | dateStream << date.toString( Qt::SystemLocaleDate ) | |
102 | << " " << time.toString( "h:mm" ) | |
103 | << " - " << endTime.toString( "h:mm" ) | |
104 | << " (" << hoursAndMinutes( event.duration() ) << ") Week " | |
105 | << date.weekNumber(); | |
106 | return dateAndDuration; | |
103 | 107 | } |
104 | 108 | |
105 | 109 | QRect EventEditorDelegate::paint( QPainter* painter, |
111 | 115 | { |
112 | 116 | painter->save(); |
113 | 117 | const QPalette& palette = option.palette; |
114 | QFont mainFont = painter->font(); | |
118 | const QFont &mainFont = option.font; | |
119 | painter->setFont(mainFont); | |
115 | 120 | QFont detailFont ( mainFont ); |
116 | 121 | detailFont.setPointSizeF( mainFont.pointSizeF() * 0.8 ); |
117 | 122 | QPixmap decoration; |
130 | 135 | background = palette.color( QPalette::Active, QPalette::Window ); |
131 | 136 | break; |
132 | 137 | case EventState_Default: |
133 | default: | |
134 | 138 | foreground = palette.color( QPalette::Active, QPalette::WindowText ); |
135 | 139 | background = palette.color( QPalette::Active, QPalette::Window ); |
136 | 140 | break; |
138 | 142 | |
139 | 143 | if ( option.state & QStyle::State_Selected ) { |
140 | 144 | QBrush brush( palette.color( QPalette::Active, QPalette::Highlight ) ); |
141 | painter->setBrush( brush ); | |
142 | painter->setPen( Qt::NoPen ); | |
143 | painter->drawRect( option.rect ); | |
145 | painter->fillRect( option.rect, brush ); | |
144 | 146 | if ( state != EventState_Locked ) { |
145 | 147 | foreground = palette.color( |
146 | 148 | QPalette::Active, QPalette::HighlightedText ); |
151 | 153 | |
152 | 154 | // draw line 1 and decoration: |
153 | 155 | painter->setFont( mainFont ); |
154 | QRect taskRect; | |
155 | taskRect.setTopLeft( option.rect.topLeft() ); | |
156 | QRect taskRect( option.rect ); | |
156 | 157 | taskRect.setWidth( option.rect.width() - decoration.width() ); |
157 | taskRect.setHeight( option.rect.height() ); | |
158 | 158 | QPoint decorationPoint ( option.rect.width() - decoration.width(), |
159 | option.rect.top() + ( option.rect.height() - decoration.height() ) / 2 ); | |
159 | option.rect.center().y() - decoration.height() / 2 ); | |
160 | 160 | |
161 | 161 | QRect boundingRect; |
162 | 162 | QString elidedTask = Charm::elidedTaskName( taskName, mainFont, taskRect.width() ); |
163 | 163 | painter->drawText( taskRect, Qt::AlignLeft | Qt::AlignTop, elidedTask, |
164 | 164 | &boundingRect ); |
165 | taskRect.setSize( boundingRect.size() ); | |
165 | taskRect = boundingRect; | |
166 | 166 | taskRect.setHeight( qMax( taskRect.height(), decoration.height() ) ); |
167 | 167 | // now taskRect tells us where to start line 2 |
168 | 168 | painter->drawPixmap( decorationPoint, decoration ); |
169 | 169 | |
170 | 170 | // draw line 2 (timespan and comment, partly): |
171 | 171 | painter->setFont( detailFont ); |
172 | QRect detailsRect; | |
173 | detailsRect.setTopLeft( QPoint( taskRect.topLeft().x(), | |
174 | taskRect.topLeft().y() + taskRect.height() ) ); | |
175 | detailsRect.setWidth( option.rect.width() ); | |
172 | QRect detailsRect( option.rect ); | |
173 | detailsRect.setTop( taskRect.bottom() ); | |
176 | 174 | detailsRect.setHeight( option.rect.height() - taskRect.height() ); |
177 | 175 | painter->drawText( detailsRect, Qt::AlignLeft | Qt::AlignTop, |
178 | 176 | timespan, &boundingRect ); |
179 | detailsRect.setSize( boundingRect.size() ); | |
177 | detailsRect = boundingRect; | |
180 | 178 | |
181 | 179 | // draw the duration line: |
182 | 180 | const int Margin = 2; |
183 | 181 | QRect durationRect( option.rect.left() + 1, detailsRect.bottom(), |
184 | 182 | static_cast<int>( logDuration * ( option.rect.width() - 2 ) ), Margin ); |
185 | painter->setBrush( palette.dark() ); | |
186 | painter->setPen( Qt::NoPen ); | |
187 | painter->drawRect( durationRect ); | |
183 | painter->fillRect( durationRect, palette.dark() ); | |
188 | 184 | |
189 | 185 | painter->restore(); |
190 | // return bounding rectangle | |
191 | 186 | return QRect( 0, 0, |
192 | 187 | qMax( taskRect.width(), detailsRect.width() ), |
193 | 188 | durationRect.bottom() + 1 - option.rect.top() ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
30 | 30 | class QStyleOptionViewItem; |
31 | 31 | class QModelIndex; |
32 | 32 | class EventModelFilter; |
33 | class TaskTreeItem; | |
34 | class Event; | |
33 | 35 | |
34 | 36 | class EventEditorDelegate : public QItemDelegate |
35 | 37 | { |
52 | 54 | EventModelFilter* m_model; |
53 | 55 | mutable QSize m_cachedSizeHint; |
54 | 56 | |
55 | // paint the values into the painter at the given rectangle, return the | |
56 | // bounding rectangle | |
57 | // (factored out to use the same implementation for the size hint | |
58 | // and the painting during paintEvent) | |
57 | QString taskName( const TaskTreeItem& item ) const; | |
58 | QString dateAndDuration( const Event& event ) const; | |
59 | ||
59 | 60 | QRect paint( QPainter*, const QStyleOptionViewItem& option, |
60 | 61 | const QString& taskName, const QString& timespan, |
61 | 62 | double logDuration, EventState state ) const; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
32 | 32 | #include "TasksView.h" |
33 | 33 | #include "ViewHelpers.h" |
34 | 34 | #include "WeeklyTimesheet.h" |
35 | #include "WidgetUtils.h" | |
35 | 36 | |
36 | 37 | #include "Commands/CommandDeleteEvent.h" |
37 | 38 | #include "Commands/CommandMakeEvent.h" |
53 | 54 | #include <QToolBar> |
54 | 55 | #include <QVBoxLayout> |
55 | 56 | |
56 | EventView::EventView( QToolBar* toolBar, QWidget* (parent) ) | |
57 | : QWidget( parent ) | |
58 | , m_model( nullptr ) | |
57 | EventView::EventView( QWidget* parent ) | |
58 | : QDialog( parent ) | |
59 | , m_toolBar( new QToolBar( this ) ) | |
59 | 60 | , m_actionUndo( this ) |
60 | 61 | , m_actionRedo( this ) |
61 | 62 | , m_actionNewEvent( this ) |
67 | 68 | , m_labelTotal( new QLabel( this ) ) |
68 | 69 | , m_listView( new QListView( this ) ) |
69 | 70 | { |
71 | setWindowTitle( tr( "Event Editor" ) ); | |
70 | 72 | auto layout = new QVBoxLayout( this ); |
71 | layout->setContentsMargins( 0, 0, 0, 0 ); | |
73 | layout->setMargin( 0 ); | |
74 | layout->setSpacing( 0 ); | |
75 | layout->addWidget( m_toolBar ); | |
72 | 76 | layout->addWidget( m_listView ); |
73 | 77 | |
74 | 78 | m_listView->setAlternatingRowColors( true ); |
112 | 116 | m_actionNewEvent.setToolTip( tr( "Create a new Event" ) ); |
113 | 117 | m_actionNewEvent.setIcon( Data::newTaskIcon() ); |
114 | 118 | m_actionNewEvent.setShortcut( QKeySequence::New ); |
115 | toolBar->addAction( &m_actionNewEvent ); | |
119 | m_toolBar->addAction( &m_actionNewEvent ); | |
116 | 120 | |
117 | 121 | m_actionEditEvent.setText( tr( "Edit Event...") ); |
118 | 122 | m_actionEditEvent.setShortcut( Qt::CTRL + Qt::Key_E ); |
119 | 123 | m_actionEditEvent.setIcon( Data::editEventIcon() ); |
120 | toolBar->addAction( &m_actionEditEvent ); | |
124 | m_toolBar->addAction( &m_actionEditEvent ); | |
121 | 125 | |
122 | 126 | m_actionFindAndReplace.setText( tr( "Search/Replace Events..." ) ); |
123 | 127 | m_actionFindAndReplace.setToolTip( tr( "Change the task events belong to" ) ); |
124 | 128 | m_actionFindAndReplace.setIcon( Data::searchIcon() ); |
125 | toolBar->addAction( &m_actionFindAndReplace ); | |
129 | m_toolBar->addAction( &m_actionFindAndReplace ); | |
126 | 130 | |
127 | 131 | connect( &m_actionFindAndReplace, SIGNAL(triggered()), SLOT(slotFindAndReplace()) ); |
128 | 132 | |
134 | 138 | #endif |
135 | 139 | m_actionDeleteEvent.setShortcuts(deleteShortcuts); |
136 | 140 | m_actionDeleteEvent.setIcon( Data::deleteTaskIcon() ); |
137 | toolBar->addAction( &m_actionDeleteEvent ); | |
141 | m_toolBar->addAction( &m_actionDeleteEvent ); | |
138 | 142 | |
139 | 143 | // disable all actions, action state will be set when the current |
140 | 144 | // item changes: |
142 | 146 | m_actionEditEvent.setEnabled( false ); |
143 | 147 | m_actionDeleteEvent.setEnabled( false ); |
144 | 148 | |
145 | toolBar->addWidget( m_comboBox ); | |
149 | m_toolBar->addWidget( m_comboBox ); | |
146 | 150 | connect( m_comboBox, SIGNAL(currentIndexChanged(int)), |
147 | 151 | SLOT(timeFrameChanged(int)) ); |
148 | 152 | |
150 | 154 | QSizePolicy spacerSizePolicy = spacer->sizePolicy(); |
151 | 155 | spacerSizePolicy.setHorizontalPolicy( QSizePolicy::Expanding ); |
152 | 156 | spacer->setSizePolicy( spacerSizePolicy ); |
153 | toolBar->addWidget( spacer ); | |
154 | ||
155 | toolBar->addWidget( m_labelTotal ); | |
157 | m_toolBar->addWidget( spacer ); | |
158 | ||
159 | m_toolBar->addWidget( m_labelTotal ); | |
156 | 160 | |
157 | 161 | QTimer::singleShot( 0, this, SLOT(delayedInitialization()) ); |
158 | 162 | |
205 | 209 | } else { |
206 | 210 | m_comboBox->setCurrentIndex( 0 ); |
207 | 211 | } |
208 | } | |
209 | ||
210 | void EventView::closeEvent( QCloseEvent* e ) | |
211 | { | |
212 | e->setAccepted( false ); | |
213 | reject(); | |
214 | } | |
215 | ||
216 | void EventView::reject() | |
217 | { | |
218 | emit visible( false ); | |
219 | 212 | } |
220 | 213 | |
221 | 214 | void EventView::commitCommand( CharmCommand* command ) |
272 | 265 | void EventView::slotDeleteEvent() |
273 | 266 | { |
274 | 267 | const TaskTreeItem& taskTreeItem = |
275 | MODEL.charmDataModel()->taskTreeItem( m_event.taskId() ); | |
268 | MODEL.charmDataModel()->taskTreeItem( m_event.taskId() ); | |
276 | 269 | const QString name = MODEL.charmDataModel()->fullTaskName( taskTreeItem.task() ); |
277 | const QDate date = m_event.startDateTime().date(); | |
278 | const QTime time = m_event.startDateTime().time(); | |
279 | const QString dateAndDuration = date.toString( Qt::SystemLocaleDate ) | |
280 | + ' ' + time.toString( Qt::SystemLocaleDate ) | |
281 | + ' ' + hoursAndMinutes( m_event.duration() ); | |
282 | const QString eventDescription = name + ' ' + dateAndDuration; | |
283 | if ( MessageBox::question( | |
284 | this, tr( "Delete Event?" ), | |
285 | tr( "<html>Do you really want to delete the event <b>%1</b>?" ).arg(eventDescription), | |
286 | tr( "Delete" ), tr("Cancel") ) | |
270 | const QDate startDate = m_event.startDateTime().date(); | |
271 | const QTime startTime = m_event.startDateTime().time(); | |
272 | const QDate endDate = m_event.endDateTime().date(); | |
273 | const QTime endTime = m_event.endDateTime().time(); | |
274 | const bool sameDates = ( startDate == endDate ); | |
275 | QString message; | |
276 | ||
277 | if ( sameDates ) | |
278 | message = tr( "<html><b>%1</b>%2: %3 - %4 (Duration: %5)</html>" ) | |
279 | .arg( name ) | |
280 | .arg( QLocale::system().toString( startDate, QLocale::ShortFormat ) ).arg( QLocale::system().toString( startTime, QLocale::ShortFormat ) ) | |
281 | .arg( QLocale::system().toString( endTime, QLocale::ShortFormat ) ).arg( hoursAndMinutes( m_event.duration() ) ); | |
282 | else | |
283 | message = tr( "<html><b>%1</b><table><tr><td>Starting:</td><td>%2 at %3</td></tr>" | |
284 | "<tr><td>Ending:</td><td>%4 at %5</td></tr><tr><td>Duration:</td><td>%6.</td></tr></html>" ) | |
285 | .arg( name ) | |
286 | .arg( QLocale::system().toString( startDate, QLocale::ShortFormat ) ).arg( QLocale::system().toString( startTime, QLocale::ShortFormat ) ) | |
287 | .arg( QLocale::system().toString( endDate, QLocale::ShortFormat ) ).arg( QLocale::system().toString( endTime, QLocale::ShortFormat ) ) | |
288 | .arg( hoursAndMinutes( m_event.duration() ) ); | |
289 | ||
290 | ||
291 | if ( MessageBox::question( this, tr( "Delete Event?" ), message, tr( "Delete" ), tr("Cancel") ) | |
287 | 292 | == QMessageBox::Yes ) { |
288 | 293 | auto command = new CommandDeleteEvent( m_event, this ); |
289 | 294 | command->prepare(); |
319 | 324 | |
320 | 325 | // all actions are handled in their own slots: |
321 | 326 | menu.exec( m_listView->mapToGlobal( point ) ); |
322 | } | |
323 | ||
324 | // FIXME obsolete | |
325 | Event EventView::newSettings() | |
326 | { | |
327 | Event event( m_event ); | |
328 | return event; | |
329 | 327 | } |
330 | 328 | |
331 | 329 | void EventView::makeVisibleAndCurrent( const Event& event ) |
451 | 449 | timeFrameChanged( m_comboBox->currentIndex() ); |
452 | 450 | } |
453 | 451 | |
454 | // ViewModeInterface: | |
455 | void EventView::saveGuiState() {} | |
456 | void EventView::restoreGuiState() {} | |
457 | void EventView::stateChanged( State previous ) {} | |
452 | void EventView::stateChanged( State previous ) | |
453 | { | |
454 | switch ( ApplicationCore::instance().state() ) { | |
455 | case Connecting: | |
456 | setModel( &MODEL ); | |
457 | connect( MODEL.charmDataModel(), SIGNAL(resetGUIState()), | |
458 | SLOT(restoreGuiState()) ); | |
459 | break; | |
460 | case Connected: | |
461 | //the model is populated when entering Connected, so delay state restore | |
462 | QMetaObject::invokeMethod( this, "restoreGuiState", Qt::QueuedConnection ); | |
463 | configurationChanged(); | |
464 | break; | |
465 | case Disconnecting: | |
466 | saveGuiState(); | |
467 | break; | |
468 | default: | |
469 | break; | |
470 | } | |
471 | } | |
458 | 472 | |
459 | 473 | void EventView::configurationChanged() |
460 | 474 | { |
475 | WidgetUtils::updateToolButtonStyle( this ); | |
461 | 476 | slotConfigureUi(); |
477 | } | |
478 | ||
479 | void EventView::saveGuiState() | |
480 | { | |
481 | WidgetUtils::saveGeometry( this, MetaKey_EventEditorGeometry ); | |
482 | } | |
483 | ||
484 | void EventView::restoreGuiState() | |
485 | { | |
486 | WidgetUtils::restoreGeometry( this, MetaKey_EventEditorGeometry ); | |
462 | 487 | } |
463 | 488 | |
464 | 489 | void EventView::setModel( ModelConnector* connector ) |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
26 | 26 | #include <QWidget> |
27 | 27 | #include <QAction> |
28 | 28 | #include <QUndoStack> |
29 | #include <QDialog> | |
29 | 30 | |
31 | #include "Core/UIStateInterface.h" | |
30 | 32 | #include "Core/Event.h" |
31 | 33 | #include "Core/TimeSpans.h" |
32 | 34 | #include "Core/CommandEmitterInterface.h" |
33 | 35 | |
34 | #include "ViewModeInterface.h" | |
35 | #include "UndoCharmCommandWrapper.h" | |
36 | #include "Charm/ModelConnector.h" | |
37 | #include "Charm/UndoCharmCommandWrapper.h" | |
36 | 38 | |
37 | 39 | class QModelIndex; |
38 | 40 | |
43 | 45 | class QLabel; |
44 | 46 | class QListView; |
45 | 47 | |
46 | class EventView : public QWidget, | |
47 | public ViewModeInterface, | |
48 | public CommandEmitterInterface | |
48 | class EventView : public QDialog, | |
49 | public UIStateInterface | |
49 | 50 | { |
50 | 51 | Q_OBJECT |
51 | 52 | |
52 | 53 | public: |
53 | explicit EventView( QToolBar* toolBar, QWidget* parent ); | |
54 | ~EventView(); | |
55 | ||
56 | void closeEvent( QCloseEvent* ) override; | |
57 | ||
58 | void reject(); | |
54 | explicit EventView( QWidget* parent = nullptr ); | |
55 | ~EventView() override; | |
59 | 56 | |
60 | 57 | void makeVisibleAndCurrent( const Event& ); |
61 | 58 | |
62 | // implement ViewModeInterface: | |
63 | void saveGuiState() override; | |
64 | void restoreGuiState() override; | |
65 | void stateChanged( State previous ) override; | |
66 | void configurationChanged() override; | |
67 | void setModel( ModelConnector* ) override; | |
59 | void setModel( ModelConnector* ) ; | |
68 | 60 | |
69 | 61 | void populateEditMenu( QMenu* ); |
70 | 62 | |
71 | 63 | signals: |
72 | void visible( bool ); | |
73 | void emitCommand( CharmCommand* ); | |
74 | void emitCommandRollback( CharmCommand* ); | |
64 | void emitCommand( CharmCommand* ) override; | |
65 | void emitCommandRollback( CharmCommand* ) override; | |
75 | 66 | |
76 | 67 | public slots: |
77 | 68 | void commitCommand( CharmCommand* ) override; |
79 | 70 | void timeSpansChanged(); |
80 | 71 | void timeFrameChanged(int ); |
81 | 72 | void slotConfigureUi(); |
73 | ||
74 | void saveGuiState() override; | |
75 | void restoreGuiState() override; | |
76 | void stateChanged( State previous ) override; | |
77 | void configurationChanged() override; | |
82 | 78 | |
83 | 79 | private slots: |
84 | 80 | void slotEventDoubleClicked( const QModelIndex& ); |
102 | 98 | void slotReset(); |
103 | 99 | |
104 | 100 | private: |
105 | Event newSettings(); | |
106 | 101 | void setCurrentEvent( const Event& ); |
107 | 102 | void stageCommand( CharmCommand* ); |
108 | 103 | |
104 | QToolBar* m_toolBar; | |
109 | 105 | QUndoStack* m_undoStack; |
110 | 106 | QList<NamedTimeSpan> m_timeSpans; |
111 | 107 | Event m_event; |
112 | EventModelFilter* m_model; | |
108 | EventModelFilter* m_model = nullptr; | |
113 | 109 | QAction m_actionUndo; |
114 | 110 | QAction m_actionRedo; |
115 | 111 | QAction m_actionNewEvent; |
0 | /* | |
1 | EventWindow.cpp | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #include "EventWindow.h" | |
24 | #include "EventView.h" | |
25 | #include "ApplicationCore.h" | |
26 | ||
27 | #include <QMenuBar> | |
28 | ||
29 | EventWindow::EventWindow( QWidget* parent ) | |
30 | : CharmWindow( tr( "Events Editor" ), parent ) | |
31 | , m_eventView( new EventView( toolBar(), this ) ) | |
32 | { | |
33 | setWindowNumber( 2 ); | |
34 | setWindowIdentifier( QLatin1String( "window_events" ) ); | |
35 | setCentralWidget( m_eventView ); | |
36 | setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); | |
37 | connect( m_eventView, SIGNAL(emitCommand(CharmCommand*)), | |
38 | SIGNAL(emitCommand(CharmCommand*)) ); | |
39 | connect( m_eventView, SIGNAL(emitCommandRollback(CharmCommand*)), | |
40 | SIGNAL(emitCommandRollback(CharmCommand*)) ); | |
41 | } | |
42 | ||
43 | EventWindow::~EventWindow() | |
44 | { | |
45 | } | |
46 | ||
47 | void EventWindow::insertEditMenu() | |
48 | { | |
49 | QMenu* editMenu = menuBar()->addMenu( tr( "Edit" ) ); | |
50 | m_eventView->populateEditMenu( editMenu ); | |
51 | } | |
52 | ||
53 | void EventWindow::configurationChanged() | |
54 | { | |
55 | CharmWindow::configurationChanged(); | |
56 | m_eventView->configurationChanged(); | |
57 | } | |
58 | ||
59 | void EventWindow::stateChanged( State previous ) | |
60 | { | |
61 | CharmWindow::stateChanged( previous ); | |
62 | m_eventView->stateChanged( previous ); | |
63 | ||
64 | if ( ApplicationCore::instance().state() == Connecting ) { | |
65 | m_eventView->setModel( & ApplicationCore::instance().model() ); | |
66 | } | |
67 | } | |
68 | ||
69 | void EventWindow::restore() | |
70 | { | |
71 | show(); | |
72 | } | |
73 | ||
74 | #include "moc_EventWindow.cpp" |
0 | /* | |
1 | EventWindow.h | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #ifndef EVENTWINDOW_H | |
24 | #define EVENTWINDOW_H | |
25 | ||
26 | #include "CharmWindow.h" | |
27 | ||
28 | class EventView; | |
29 | ||
30 | class EventWindow : public CharmWindow | |
31 | { | |
32 | Q_OBJECT | |
33 | ||
34 | public: | |
35 | explicit EventWindow( QWidget* parent = nullptr ); | |
36 | ~EventWindow(); | |
37 | ||
38 | void stateChanged( State previous ) override; | |
39 | ||
40 | // restore the view | |
41 | void restore() override; | |
42 | public slots: | |
43 | void configurationChanged() override; | |
44 | ||
45 | protected: | |
46 | void insertEditMenu() override; | |
47 | ||
48 | signals: | |
49 | void emitCommand( CharmCommand* ); | |
50 | void emitCommandRollback( CharmCommand* ); | |
51 | void quit(); | |
52 | ||
53 | private: | |
54 | EventView* m_eventView; | |
55 | ||
56 | }; | |
57 | ||
58 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Michel Boyer de la Giroday <michel.giroday@kdab.com> |
8 | 8 | |
34 | 34 | #include <QCalendarWidget> |
35 | 35 | #include <QMessageBox> |
36 | 36 | |
37 | FindAndReplaceEventsDialog::FindAndReplaceEventsDialog( QWidget* parent ) : | |
38 | QDialog( parent ) | |
39 | ,m_taskToSearch( 0 ) | |
40 | ,m_taskToReplaceWith( 0 ) | |
41 | ,m_ui( new Ui::FindAndReplaceEventsDialog ) | |
37 | FindAndReplaceEventsDialog::FindAndReplaceEventsDialog( QWidget* parent ) | |
38 | : QDialog( parent ) | |
39 | , m_ui( new Ui::FindAndReplaceEventsDialog ) | |
42 | 40 | { |
43 | 41 | m_ui->setupUi(this); |
44 | 42 | |
138 | 136 | void FindAndReplaceEventsDialog::selectTask( SelectTaskType type ) |
139 | 137 | { |
140 | 138 | SelectTaskDialog dialog( this ); |
139 | if ( type == TaskToSearch ) { | |
140 | dialog.setNonValidSelectable(); | |
141 | } | |
141 | 142 | if( !dialog.exec() ) |
142 | 143 | return; |
143 | 144 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Michel Boyer de la Giroday <michel.gitroday@kdab.com> |
8 | 8 | |
44 | 44 | |
45 | 45 | public: |
46 | 46 | explicit FindAndReplaceEventsDialog( QWidget* parent = nullptr ); |
47 | ~FindAndReplaceEventsDialog(); | |
47 | ~FindAndReplaceEventsDialog() override; | |
48 | 48 | |
49 | 49 | QList<Event> modifiedEvents() const; |
50 | 50 | |
65 | 65 | void selectTask( SelectTaskType type ); |
66 | 66 | void eventChangesCompleted( const Event& event ); |
67 | 67 | |
68 | TaskId m_taskToSearch; | |
69 | TaskId m_taskToReplaceWith; | |
68 | TaskId m_taskToSearch = {}; | |
69 | TaskId m_taskToReplaceWith = {}; | |
70 | 70 | TimeSpan m_timeSpan; |
71 | 71 | QPushButton* m_replace; |
72 | 72 | QPushButton* m_cancel; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
42 | 42 | }; |
43 | 43 | |
44 | 44 | explicit IdleCorrectionDialog( QWidget* parent = nullptr ); |
45 | ~IdleCorrectionDialog(); | |
45 | ~IdleCorrectionDialog() override; | |
46 | 46 | |
47 | 47 | Result result() const; |
48 | 48 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
27 | 27 | public: |
28 | 28 | explicit MakeTemporarilyVisible( QWidget* widget ) |
29 | 29 | : m_widget( widget ) |
30 | , m_wasVisible( false ) | |
31 | 30 | { |
32 | 31 | Q_ASSERT( m_widget ); |
33 | 32 | m_wasVisible = m_widget->isVisible(); |
42 | 41 | } |
43 | 42 | } |
44 | 43 | private: |
45 | QWidget* m_widget; | |
46 | bool m_wasVisible; | |
44 | QWidget* m_widget = {}; | |
45 | bool m_wasVisible = false; | |
47 | 46 | }; |
48 | 47 | |
49 | 48 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
42 | 42 | |
43 | 43 | MonthlyTimeSheetReport::MonthlyTimeSheetReport( QWidget* parent ) |
44 | 44 | : TimeSheetReport( parent ) |
45 | , m_numberOfWeeks( 0 ) | |
46 | , m_monthNumber( 0 ) | |
47 | , m_yearOfMonth( 0 ) | |
48 | 45 | { |
49 | 46 | QSettings settings; |
50 | 47 | settings.beginGroup("users"); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
35 | 35 | |
36 | 36 | public: |
37 | 37 | explicit MonthlyTimeSheetReport( QWidget* parent = nullptr ); |
38 | virtual ~MonthlyTimeSheetReport(); | |
38 | ~MonthlyTimeSheetReport() override; | |
39 | 39 | |
40 | 40 | void setReportProperties( const QDate& start, |
41 | 41 | const QDate& end, |
53 | 53 | |
54 | 54 | private: |
55 | 55 | // properties of the report: |
56 | int m_numberOfWeeks; | |
57 | int m_monthNumber; | |
58 | int m_yearOfMonth; | |
56 | int m_numberOfWeeks = 0; | |
57 | int m_monthNumber = 0; | |
58 | int m_yearOfMonth = 0; | |
59 | 59 | QString m_weeklyhours; |
60 | 60 | float m_dailyhours; |
61 | 61 | }; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
94 | 94 | QDialog::accept(); |
95 | 95 | } |
96 | 96 | |
97 | void MonthlyTimesheetConfigurationDialog::showReportPreviewDialog( QWidget* parent ) | |
97 | void MonthlyTimesheetConfigurationDialog::showReportPreviewDialog() | |
98 | 98 | { |
99 | 99 | QDate start, end; |
100 | 100 | int index = m_ui->comboBoxMonth->currentIndex(); |
107 | 107 | end = m_monthInfo[index].timespan.second; |
108 | 108 | } |
109 | 109 | bool activeOnly = m_ui->checkBoxActiveOnly->isChecked(); |
110 | auto report = new MonthlyTimeSheetReport( parent ); | |
110 | auto report = new MonthlyTimeSheetReport(); | |
111 | 111 | report->setReportProperties( start, end, m_rootTask, activeOnly ); |
112 | 112 | report->show(); |
113 | 113 | } |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
38 | 38 | |
39 | 39 | public: |
40 | 40 | explicit MonthlyTimesheetConfigurationDialog( QWidget* parent ); |
41 | virtual ~MonthlyTimesheetConfigurationDialog(); | |
41 | ~MonthlyTimesheetConfigurationDialog() override; | |
42 | 42 | |
43 | void showReportPreviewDialog( QWidget* parent ) override; | |
43 | void showReportPreviewDialog() override; | |
44 | 44 | void showEvent( QShowEvent* ) override; |
45 | 45 | void setDefaultMonth( int yearOfMonth, int month ); |
46 | 46 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Michel Boyer de la Giroday <michel.giroday@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Michel Boyer de la Giroday <michel.giroday@kdab.com> |
8 | 8 | |
36 | 36 | |
37 | 37 | public: |
38 | 38 | explicit NotificationPopup( QWidget *parent = nullptr ); |
39 | ~NotificationPopup(); | |
39 | ~NotificationPopup() override; | |
40 | 40 | |
41 | 41 | void showNotification( const QString& title, const QString& message ); |
42 | 42 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
38 | 38 | |
39 | 39 | @param parent parent widget for the preview dialog |
40 | 40 | */ |
41 | virtual void showReportPreviewDialog( QWidget* parent ) = 0; | |
41 | virtual void showReportPreviewDialog() = 0; | |
42 | 42 | }; |
43 | 43 | |
44 | 44 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
33 | 33 | ReportPreviewWindow::ReportPreviewWindow( QWidget* parent ) |
34 | 34 | : QDialog( parent ) |
35 | 35 | , m_ui( new Ui::ReportPreviewWindow ) |
36 | , m_document() | |
37 | 36 | { |
38 | 37 | m_ui->setupUi( this ); |
39 | 38 | setAttribute( Qt::WA_DeleteOnClose ); |
53 | 52 | #else |
54 | 53 | m_ui->pushButtonPrint->setEnabled(false); |
55 | 54 | #endif |
55 | ||
56 | m_updateTimer.setInterval(60 * 1000); | |
57 | m_updateTimer.start(); | |
58 | connect( &m_updateTimer, SIGNAL(timeout()), | |
59 | SLOT(slotUpdate()) ); | |
60 | ||
56 | 61 | resize(850, 600); |
57 | 62 | } |
58 | 63 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
27 | 27 | #include <QDomDocument> |
28 | 28 | #include <QScopedPointer> |
29 | 29 | #include <QTextDocument> |
30 | #include <QTimer> | |
30 | 31 | |
31 | 32 | namespace Ui { |
32 | 33 | class ReportPreviewWindow; |
40 | 41 | |
41 | 42 | public: |
42 | 43 | explicit ReportPreviewWindow( QWidget* parent = nullptr ); |
43 | virtual ~ReportPreviewWindow(); | |
44 | ~ReportPreviewWindow() override; | |
44 | 45 | |
45 | 46 | signals: |
46 | 47 | void anchorClicked(const QUrl& which); |
51 | 52 | QPushButton* saveToXmlButton() const; |
52 | 53 | QPushButton* saveToTextButton() const; |
53 | 54 | QPushButton* uploadButton() const; |
55 | ||
56 | QTimer m_updateTimer; | |
54 | 57 | |
55 | 58 | private slots: |
56 | 59 | virtual void slotSaveToXml(); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
65 | 65 | SelectTaskDialog::SelectTaskDialog( QWidget* parent ) |
66 | 66 | : QDialog( parent ) |
67 | 67 | , m_ui( new Ui::SelectTaskDialog() ) |
68 | , m_selectedTask( 0 ) | |
69 | 68 | , m_proxy( MODEL.charmDataModel() ) |
70 | , m_nonTrackableSelectable( false ) | |
71 | 69 | { |
72 | 70 | m_ui->setupUi( this ); |
73 | 71 | m_ui->treeView->setModel( &m_proxy ); |
176 | 174 | return false; |
177 | 175 | const Task task = m_proxy.taskForIndex( index ); |
178 | 176 | |
179 | const bool taskValid = task.isValid() && task.isCurrentlyValid(); | |
177 | const bool taskValid = m_nonValidSelectable || (task.isValid() && task.isCurrentlyValid()); | |
180 | 178 | |
181 | 179 | if ( m_nonTrackableSelectable ) { |
182 | 180 | return taskValid; |
199 | 197 | |
200 | 198 | Charm::saveExpandStates( m_ui->treeView, &m_expansionStates ); |
201 | 199 | m_proxy.setFilterWildcard( filtertext ); |
202 | Charm::restoreExpandStates( m_ui->treeView, &m_expansionStates ); | |
200 | if (!filtertext.isEmpty()) | |
201 | m_ui->treeView->expandAll(); | |
202 | else | |
203 | Charm::restoreExpandStates( m_ui->treeView, &m_expansionStates ); | |
203 | 204 | } |
204 | 205 | |
205 | 206 | void SelectTaskDialog::slotAccepted() |
257 | 258 | m_nonTrackableSelectable = true; |
258 | 259 | } |
259 | 260 | |
261 | void SelectTaskDialog::setNonValidSelectable() | |
262 | { | |
263 | m_nonValidSelectable = true; | |
264 | } | |
265 | ||
260 | 266 | #include "moc_SelectTaskDialog.cpp" |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
56 | 56 | |
57 | 57 | public: |
58 | 58 | explicit SelectTaskDialog( QWidget* parent=nullptr ); |
59 | ~SelectTaskDialog(); | |
59 | ~SelectTaskDialog() override; | |
60 | 60 | |
61 | 61 | TaskId selectedTask() const; |
62 | 62 | void setNonTrackableSelectable(); |
63 | void setNonValidSelectable(); | |
63 | 64 | |
64 | 65 | signals: |
65 | 66 | void saveConfiguration(); |
81 | 82 | |
82 | 83 | private: |
83 | 84 | QScopedPointer<Ui::SelectTaskDialog> m_ui; |
84 | TaskId m_selectedTask; | |
85 | TaskId m_selectedTask = {}; | |
85 | 86 | SelectTaskDialogProxy m_proxy; |
86 | 87 | QHash<TaskId,bool> m_expansionStates; |
87 | bool m_nonTrackableSelectable; | |
88 | bool m_nonTrackableSelectable = false; | |
89 | bool m_nonValidSelectable = false; | |
88 | 90 | }; |
89 | 91 | |
90 | 92 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
40 | 40 | |
41 | 41 | public: |
42 | 42 | explicit TaskEditor( QWidget* parent = nullptr ); |
43 | virtual ~TaskEditor(); | |
43 | ~TaskEditor() override; | |
44 | 44 | |
45 | 45 | void setTask( const Task& task ); |
46 | 46 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
38 | 38 | |
39 | 39 | public: |
40 | 40 | explicit TaskIdDialog( TaskModelInterface* model, TasksView* parent ); |
41 | ~TaskIdDialog(); | |
41 | ~TaskIdDialog() override; | |
42 | 42 | |
43 | 43 | void setSuggestedId( int ); |
44 | 44 | int selectedId() const; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
30 | 30 | #include "TasksViewDelegate.h" |
31 | 31 | #include "ViewFilter.h" |
32 | 32 | #include "ViewHelpers.h" |
33 | #include "WidgetUtils.h" | |
33 | 34 | |
34 | 35 | #include "Commands/CommandAddTask.h" |
35 | 36 | #include "Commands/CommandDeleteTask.h" |
51 | 52 | #include <QToolBar> |
52 | 53 | #include <QTreeView> |
53 | 54 | |
54 | TasksView::TasksView( QToolBar* toolBar, QWidget* parent ) | |
55 | : QWidget( parent ) | |
56 | // , ViewInterface() | |
55 | TasksView::TasksView( QWidget* parent ) | |
56 | : QDialog( parent ) | |
57 | , m_toolBar( new QToolBar( this ) ) | |
57 | 58 | , m_delegate( new TasksViewDelegate( this ) ) |
58 | 59 | , m_actionNewTask( this ) |
59 | 60 | , m_actionNewSubTask( this ) |
61 | 62 | , m_actionDeleteTask( this ) |
62 | 63 | , m_actionExpandTree( this ) |
63 | 64 | , m_actionCollapseTree( this ) |
64 | , m_showCurrentOnly( new QAction( toolBar ) ) | |
65 | , m_showSubscribedOnly( new QAction( toolBar ) ) | |
65 | , m_showCurrentOnly( new QAction( m_toolBar ) ) | |
66 | , m_showSubscribedOnly( new QAction( m_toolBar ) ) | |
66 | 67 | , m_treeView( new QTreeView( this ) ) |
67 | 68 | { |
69 | setWindowTitle( tr( "Tasks View" ) ); | |
68 | 70 | auto layout = new QVBoxLayout( this ); |
69 | layout->setContentsMargins( 0, 0, 0, 0 ); | |
71 | layout->setMargin( 0 ); | |
72 | layout->setSpacing( 0 ); | |
73 | layout->addWidget( m_toolBar ); | |
70 | 74 | layout->addWidget( m_treeView ); |
71 | 75 | |
72 | 76 | m_treeView->setItemDelegate( m_delegate ); |
77 | 81 | m_actionNewTask.setText( tr( "New &Task" ) ); |
78 | 82 | m_actionNewTask.setShortcut( QKeySequence::New ); |
79 | 83 | m_actionNewTask.setIcon( Data::newTaskIcon() ); |
80 | toolBar->addAction( &m_actionNewTask ); | |
84 | m_toolBar->addAction( &m_actionNewTask ); | |
81 | 85 | connect( &m_actionNewTask, SIGNAL(triggered(bool)), |
82 | 86 | SLOT(actionNewTask()) ); |
83 | 87 | |
84 | 88 | m_actionNewSubTask.setText( tr( "New &Subtask" ) ); |
85 | 89 | m_actionNewSubTask.setShortcut( Qt::META + Qt::Key_N ); |
86 | 90 | m_actionNewSubTask.setIcon( Data::newSubtaskIcon() ); |
87 | toolBar->addAction( &m_actionNewSubTask ); | |
91 | m_toolBar->addAction( &m_actionNewSubTask ); | |
88 | 92 | connect( &m_actionNewSubTask, SIGNAL(triggered(bool)), |
89 | 93 | SLOT(actionNewSubTask()) ); |
90 | 94 | |
91 | 95 | m_actionEditTask.setText( tr( "Edit Task" ) ); |
92 | 96 | m_actionEditTask.setShortcut( Qt::CTRL + Qt::Key_E ); |
93 | 97 | m_actionEditTask.setIcon( Data::editTaskIcon() ); |
94 | toolBar->addAction( &m_actionEditTask ); | |
98 | m_toolBar->addAction( &m_actionEditTask ); | |
95 | 99 | connect( &m_actionEditTask, SIGNAL(triggered(bool)), |
96 | 100 | SLOT(actionEditTask()) ); |
97 | 101 | |
103 | 107 | #endif |
104 | 108 | m_actionDeleteTask.setShortcuts(deleteShortcuts); |
105 | 109 | m_actionDeleteTask.setIcon( Data::deleteTaskIcon() ); |
106 | toolBar->addAction( &m_actionDeleteTask ); | |
110 | m_toolBar->addAction( &m_actionDeleteTask ); | |
107 | 111 | connect( &m_actionDeleteTask, SIGNAL(triggered(bool)), |
108 | 112 | SLOT(actionDeleteTask()) ); |
109 | 113 | |
119 | 123 | m_showCurrentOnly->setText( tr( "Current" ) ); |
120 | 124 | m_showCurrentOnly->setCheckable( true ); |
121 | 125 | |
122 | toolBar->addAction( m_showCurrentOnly ); | |
126 | m_toolBar->addAction( m_showCurrentOnly ); | |
123 | 127 | connect( m_showCurrentOnly, SIGNAL(triggered(bool)), |
124 | 128 | SLOT(taskPrefilteringChanged()) ); |
125 | 129 | |
126 | 130 | m_showSubscribedOnly->setText( tr( "Selected" ) ); |
127 | 131 | m_showSubscribedOnly->setCheckable( true ); |
128 | 132 | |
129 | toolBar->addAction( m_showSubscribedOnly ); | |
133 | m_toolBar->addAction( m_showSubscribedOnly ); | |
130 | 134 | connect( m_showSubscribedOnly, SIGNAL(triggered(bool)), |
131 | 135 | SLOT(taskPrefilteringChanged()) ); |
132 | 136 | |
134 | 138 | |
135 | 139 | connect( searchField, SIGNAL(textChanged(QString)), |
136 | 140 | SLOT(slotFiltertextChanged(QString)) ); |
137 | toolBar->addWidget( searchField ); | |
141 | m_toolBar->addWidget( searchField ); | |
138 | 142 | |
139 | 143 | m_treeView->setEditTriggers(QAbstractItemView::EditKeyPressed); |
140 | 144 | m_treeView->setExpandsOnDoubleClick(false); |
145 | 149 | m_treeView->setContextMenuPolicy( Qt::CustomContextMenu ); |
146 | 150 | connect( m_treeView, SIGNAL(customContextMenuRequested(QPoint)), |
147 | 151 | SLOT(slotContextMenuRequested(QPoint)) ); |
148 | ||
149 | // I hate doing this but the stupid default view sizeHints suck badly. | |
150 | setMinimumHeight( 200 ); | |
151 | 152 | |
152 | 153 | // A reasonable default depth. |
153 | 154 | m_treeView->expandToDepth( 0 ); |
268 | 269 | SLOT(slotEventActivated(EventId)) ); |
269 | 270 | connect( filter, SIGNAL(eventDeactivationNotice(EventId)), |
270 | 271 | SLOT(slotEventDeactivated(EventId)) ); |
272 | connect( MODEL.charmDataModel(), SIGNAL(resetGUIState()), | |
273 | SLOT(restoreGuiState()) ); | |
274 | configurationChanged(); | |
271 | 275 | } |
272 | 276 | break; |
273 | 277 | case Connected: |
274 | 278 | //the model is populated when entering Connected, so delay state restore |
275 | 279 | QMetaObject::invokeMethod( this, "restoreGuiState", Qt::QueuedConnection ); |
280 | configurationChanged(); | |
276 | 281 | break; |
277 | 282 | case Disconnecting: |
278 | 283 | saveGuiState(); |
286 | 291 | |
287 | 292 | void TasksView::saveGuiState() |
288 | 293 | { |
294 | WidgetUtils::saveGeometry( this, MetaKey_TaskEditorGeometry ); | |
289 | 295 | Q_ASSERT( m_treeView ); |
290 | 296 | ViewFilter* filter = ApplicationCore::instance().model().taskModel(); |
291 | 297 | Q_ASSERT( filter ); |
312 | 318 | |
313 | 319 | void TasksView::restoreGuiState() |
314 | 320 | { |
321 | WidgetUtils::restoreGeometry( this, MetaKey_TaskEditorGeometry ); | |
315 | 322 | Q_ASSERT( m_treeView ); |
316 | 323 | ViewFilter* filter = ApplicationCore::instance().model().taskModel(); |
317 | 324 | Q_ASSERT( filter ); |
345 | 352 | |
346 | 353 | m_treeView->header()->hide(); |
347 | 354 | configureUi(); |
348 | } | |
349 | ||
350 | void TasksView::setModel( ModelConnector* connector ) | |
351 | { | |
352 | m_treeView->setModel( connector->taskModel() ); | |
353 | restoreGuiState(); | |
355 | WidgetUtils::updateToolButtonStyle( this ); | |
354 | 356 | } |
355 | 357 | |
356 | 358 | void TasksView::slotFiltertextChanged( const QString& filtertextRaw ) |
361 | 363 | |
362 | 364 | saveGuiState(); |
363 | 365 | filter->setFilterWildcard( filtertext ); |
366 | filter->setFilterRole( TasksViewRole_Filter ); | |
364 | 367 | if (!filtertextRaw.isEmpty()) |
365 | 368 | m_treeView->expandAll(); |
366 | 369 | else |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
29 | 29 | #include <Core/Event.h> |
30 | 30 | #include <Core/State.h> |
31 | 31 | #include <Core/CommandEmitterInterface.h> |
32 | #include <Core/ViewInterface.h> | |
33 | #include <Core/UIStateInterface.h> | |
32 | 34 | |
33 | #include "ViewModeInterface.h" | |
35 | #include <QDialog> | |
34 | 36 | |
35 | 37 | class QMenu; |
36 | 38 | class TasksViewDelegate; |
37 | 39 | class QToolBar; |
38 | 40 | class QTreeView; |
39 | 41 | |
40 | class TasksView : public QWidget, | |
41 | public ViewModeInterface, | |
42 | public CommandEmitterInterface | |
42 | class TasksView : public QDialog, | |
43 | public UIStateInterface | |
43 | 44 | { |
44 | 45 | Q_OBJECT |
45 | 46 | |
46 | 47 | public: |
47 | explicit TasksView ( QToolBar* toolBar, QWidget* parent = nullptr ); | |
48 | ~TasksView(); | |
49 | ||
50 | // implement ViewModeInterface: | |
51 | void stateChanged( State previous ) override; | |
52 | void configurationChanged() override; | |
53 | void setModel( ModelConnector* ) override; | |
48 | explicit TasksView (QWidget* parent = nullptr ); | |
49 | ~TasksView() override; | |
54 | 50 | |
55 | 51 | void populateEditMenu( QMenu* ); |
52 | ||
53 | ||
56 | 54 | |
57 | 55 | public Q_SLOTS: |
58 | 56 | void commitCommand( CharmCommand* ) override; |
59 | 57 | |
58 | void stateChanged( State previous ) override; | |
59 | void configurationChanged() override; | |
60 | ||
61 | void restoreGuiState() override; | |
62 | void saveGuiState() override; | |
63 | ||
60 | 64 | signals: |
61 | 65 | // FIXME connect to MainWindow |
62 | 66 | void saveConfiguration(); |
63 | void emitCommand( CharmCommand* ); | |
64 | void emitCommandRollback( CharmCommand* ); | |
67 | void emitCommand( CharmCommand* ) override; | |
68 | void emitCommandRollback( CharmCommand* ) override; | |
65 | 69 | |
66 | 70 | private slots: |
67 | 71 | void actionNewTask(); |
77 | 81 | // this method is called every time the UI actions need update, for |
78 | 82 | // example when the current index changes: |
79 | 83 | void configureUi(); |
80 | void restoreGuiState() override; | |
81 | 84 | |
82 | 85 | private: |
83 | void saveGuiState() override; | |
84 | 86 | |
85 | 87 | // helper to retrieve selected task: |
86 | 88 | Task selectedTask(); |
87 | 89 | void addTaskHelper( const Task& parent ); |
88 | 90 | |
91 | QToolBar* m_toolBar; | |
89 | 92 | TasksViewDelegate* m_delegate; |
90 | 93 | QAction m_actionNewTask; |
91 | 94 | QAction m_actionNewSubTask; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
30 | 30 | |
31 | 31 | TasksViewDelegate::TasksViewDelegate( QObject* parent ) |
32 | 32 | : QItemDelegate( parent ) |
33 | , m_editing( false ) | |
34 | 33 | { |
35 | 34 | connect( this, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), |
36 | 35 | SLOT(slotCloseEditor(QWidget*,QAbstractItemDelegate::EndEditHint)) ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
69 | 69 | }; |
70 | 70 | Layout doLayout( const QStyleOptionViewItem& option, |
71 | 71 | const QModelIndex& index ) const; |
72 | mutable bool m_editing; | |
72 | mutable bool m_editing = false; | |
73 | 73 | }; |
74 | 74 | #endif |
0 | /* | |
1 | TasksWindow.cpp | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #include "TasksWindow.h" | |
24 | #include "ApplicationCore.h" | |
25 | #include "TasksView.h" | |
26 | ||
27 | #include <QMenuBar> | |
28 | ||
29 | TasksWindow::TasksWindow( QWidget* parent ) | |
30 | : CharmWindow( tr( "Tasks Editor" ), parent ) | |
31 | , m_tasksView( new TasksView( toolBar(), this ) ) | |
32 | { | |
33 | setWindowNumber( 1 ); | |
34 | setWindowIdentifier( QLatin1String( "window_tasks" ) ); | |
35 | setCentralWidget( m_tasksView ); | |
36 | setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); | |
37 | connect( m_tasksView, SIGNAL(emitCommand(CharmCommand*)), | |
38 | SIGNAL(emitCommand(CharmCommand*)) ); | |
39 | connect( m_tasksView, SIGNAL(emitCommandRollback(CharmCommand*)), | |
40 | SIGNAL(emitCommandRollback(CharmCommand*)) ); | |
41 | connect( m_tasksView, SIGNAL(saveConfiguration()), | |
42 | SIGNAL(saveConfiguration()) ); | |
43 | } | |
44 | ||
45 | TasksWindow::~TasksWindow() | |
46 | { | |
47 | } | |
48 | ||
49 | void TasksWindow::stateChanged( State previous ) | |
50 | { | |
51 | CharmWindow::stateChanged( previous ); | |
52 | m_tasksView->stateChanged( previous ); | |
53 | ||
54 | if ( ApplicationCore::instance().state() == Connecting ) { | |
55 | m_tasksView->setModel( & ApplicationCore::instance().model() ); | |
56 | } | |
57 | } | |
58 | ||
59 | void TasksWindow::restore() | |
60 | { | |
61 | show(); | |
62 | } | |
63 | ||
64 | void TasksWindow::configurationChanged() | |
65 | { | |
66 | CharmWindow::configurationChanged(); | |
67 | m_tasksView->configurationChanged(); | |
68 | } | |
69 | ||
70 | void TasksWindow::insertEditMenu() | |
71 | { | |
72 | QMenu* editMenu = menuBar()->addMenu( tr( "Edit" ) ); | |
73 | m_tasksView->populateEditMenu( editMenu); | |
74 | } | |
75 | ||
76 | void TasksWindow::sendCommand( CharmCommand* ) | |
77 | { | |
78 | Q_ASSERT( false ); // should not be called | |
79 | } | |
80 | ||
81 | void TasksWindow::sendCommandRollback( CharmCommand* ) | |
82 | { | |
83 | Q_ASSERT( false ); // should not be called | |
84 | } | |
85 | ||
86 | void TasksWindow::commitCommand( CharmCommand* ) | |
87 | { | |
88 | } | |
89 | ||
90 | #include "moc_TasksWindow.cpp" |
0 | /* | |
1 | TasksWindow.h | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #ifndef TASKSWINDOW_H | |
24 | #define TASKSWINDOW_H | |
25 | ||
26 | #include "CharmWindow.h" | |
27 | ||
28 | class TasksView; | |
29 | ||
30 | class TasksWindow : public CharmWindow | |
31 | { | |
32 | Q_OBJECT | |
33 | ||
34 | public: | |
35 | explicit TasksWindow( QWidget* parent = nullptr ); | |
36 | ~TasksWindow(); | |
37 | ||
38 | void stateChanged( State previous ) override; | |
39 | void sendCommand( CharmCommand* ) override; | |
40 | void sendCommandRollback( CharmCommand* ) override; | |
41 | void commitCommand( CharmCommand* ) override; | |
42 | ||
43 | // restore the view | |
44 | void restore() override; | |
45 | ||
46 | public slots: | |
47 | void configurationChanged() override; | |
48 | ||
49 | protected: | |
50 | void insertEditMenu() override; | |
51 | ||
52 | signals: | |
53 | void emitCommand( CharmCommand* ) override; | |
54 | void emitCommandRollback( CharmCommand* ) override; | |
55 | void quit() override; | |
56 | ||
57 | private: | |
58 | TasksView* m_tasksView; | |
59 | }; | |
60 | ||
61 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Montel Laurent <laurent.montel@kdab.com> |
41 | 41 | #include <QToolButton> |
42 | 42 | #include <QVBoxLayout> |
43 | 43 | |
44 | #ifdef Q_OS_WIN | |
45 | #include <QtWinExtras/QtWinExtras> | |
46 | #endif | |
47 | ||
44 | 48 | #define CUSTOM_TASK_PROPERTY_NAME "CUSTOM_TASK_PROPERTY" |
45 | 49 | |
46 | 50 | TimeTrackingTaskSelector::TimeTrackingTaskSelector(QWidget *parent) |
52 | 56 | , m_taskSelectorButton( new QToolButton( this ) ) |
53 | 57 | , m_startOtherTaskAction( new QAction( tr( "Start Other Task..." ), this ) ) |
54 | 58 | , m_menu( new QMenu( tr( "Start Task" ), this ) ) |
55 | , m_selectedTask( 0 ) | |
56 | , m_manuallySelectedTask( 0 ) | |
57 | , m_taskManuallySelected( false ) | |
58 | 59 | { |
59 | 60 | connect( m_menu, SIGNAL(triggered(QAction*)), |
60 | 61 | SLOT(slotActionSelected(QAction*)) ); |
225 | 226 | m_stopGoAction->setChecked( false ); |
226 | 227 | m_editCommentAction->setEnabled( false ); |
227 | 228 | } |
229 | updateThumbBar(); | |
228 | 230 | } |
229 | 231 | |
230 | 232 | void TimeTrackingTaskSelector::slotActionSelected( QAction* action ) |
250 | 252 | } |
251 | 253 | |
252 | 254 | if( taskId > 0 ) { |
253 | taskSelected( action->text(), taskId ); | |
255 | taskSelected( taskId ); | |
254 | 256 | handleActiveEvents(); |
255 | 257 | |
256 | 258 | if ( !DATAMODEL->isTaskActive( taskId ) ) { |
261 | 263 | } |
262 | 264 | } |
263 | 265 | |
264 | void TimeTrackingTaskSelector::taskSelected( const QString& taskname, TaskId id ) | |
266 | void TimeTrackingTaskSelector::updateThumbBar() | |
267 | { | |
268 | #ifdef Q_OS_WIN | |
269 | if ( !m_stopGoThumbButton && window()->windowHandle() ) { | |
270 | QWinThumbnailToolBar *toolBar = new QWinThumbnailToolBar( this ); | |
271 | toolBar->setWindow( window()->windowHandle() ); | |
272 | ||
273 | m_stopGoThumbButton = new QWinThumbnailToolButton( toolBar ); | |
274 | toolBar->addButton( m_stopGoThumbButton ); | |
275 | connect(m_stopGoThumbButton, &QWinThumbnailToolButton::clicked, [this](){ | |
276 | slotGoStopToggled( !m_stopGoButton->isChecked() ); | |
277 | }); | |
278 | } | |
279 | if ( m_stopGoThumbButton ) { | |
280 | if ( m_stopGoButton->isChecked() ) { | |
281 | m_stopGoThumbButton->setToolTip( tr( "Stop Task" ) ); | |
282 | m_stopGoThumbButton->setIcon( Data::stopIcon() ); | |
283 | } else { | |
284 | m_stopGoThumbButton->setToolTip( tr( "Start Task" ) ); | |
285 | m_stopGoThumbButton->setIcon( Data::goIcon() ); | |
286 | } | |
287 | m_stopGoThumbButton->setEnabled( m_stopGoButton->isEnabled() ); | |
288 | } | |
289 | #endif | |
290 | } | |
291 | ||
292 | void TimeTrackingTaskSelector::taskSelected( TaskId id ) | |
265 | 293 | { |
266 | 294 | m_selectedTask = id; |
267 | 295 | m_stopGoAction->setEnabled( true ); |
296 | const auto taskname = DATAMODEL->taskIdAndSmartNameString( id ); | |
268 | 297 | m_taskSelectorButton->setText( escapeAmpersands( taskname ) ); |
269 | 298 | } |
270 | 299 | |
280 | 309 | |
281 | 310 | void TimeTrackingTaskSelector::taskSelected( const WeeklySummary& summary ) |
282 | 311 | { |
283 | taskSelected( summary.taskname, summary.task ); | |
312 | taskSelected( summary.task ); | |
284 | 313 | } |
285 | 314 | |
286 | 315 | void TimeTrackingTaskSelector::slotManuallySelectTask() |
296 | 325 | emit updateSummariesPlease(); |
297 | 326 | } |
298 | 327 | |
328 | void TimeTrackingTaskSelector::showEvent(QShowEvent* e) | |
329 | { | |
330 | updateThumbBar(); | |
331 | QWidget::showEvent( e ); | |
332 | } | |
333 | ||
299 | 334 | |
300 | 335 | #include "moc_TimeTrackingTaskSelector.cpp" |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
37 | 37 | class QToolButton; |
38 | 38 | class QTextEdit; |
39 | 39 | class QToolBar; |
40 | class QWinThumbnailToolButton; | |
40 | 41 | |
41 | 42 | class TimeTrackingTaskSelector : public QWidget |
42 | 43 | { |
65 | 66 | void slotEditCommentClicked(); |
66 | 67 | void slotManuallySelectTask(); |
67 | 68 | |
69 | protected: | |
70 | void showEvent( QShowEvent* ) override; | |
71 | ||
68 | 72 | private: |
69 | void taskSelected( const QString& taskname, TaskId id ); | |
73 | void updateThumbBar(); | |
74 | void taskSelected( TaskId id ); | |
70 | 75 | QToolButton* m_stopGoButton; |
71 | 76 | QAction* m_stopGoAction; |
72 | 77 | QToolButton* m_editCommentButton; |
75 | 80 | QAction* m_startOtherTaskAction; |
76 | 81 | QMenu *m_menu; |
77 | 82 | /** The task that has been selected from the menu. */ |
78 | TaskId m_selectedTask; | |
83 | TaskId m_selectedTask = {}; | |
79 | 84 | /** If the user selected a task through the "Select other task..." menu action, |
80 | 85 | its Id is stored here. */ |
81 | TaskId m_manuallySelectedTask; | |
86 | TaskId m_manuallySelectedTask = {}; | |
82 | 87 | /** Temporarily store that a task has been manually selected, so that it can be |
83 | 88 | activated in the menu once after selection. */ |
84 | bool m_taskManuallySelected; | |
89 | bool m_taskManuallySelected = false; | |
90 | ||
91 | #ifdef Q_OS_WIN | |
92 | QWinThumbnailToolButton* m_stopGoThumbButton = nullptr; | |
93 | #endif | |
85 | 94 | }; |
86 | 95 | |
87 | 96 | #endif // TIMETRACKINGTASKSELECTOR_H |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
42 | 42 | TimeTrackingView::TimeTrackingView( QWidget* parent ) |
43 | 43 | : QWidget( parent ) |
44 | 44 | , m_taskSelector( new TimeTrackingTaskSelector( this ) ) |
45 | , m_dayOfWeek( 0 ) | |
46 | 45 | { |
47 | 46 | setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); |
48 | 47 | // plumbing |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
38 | 38 | Q_OBJECT |
39 | 39 | private: |
40 | 40 | struct DataField { |
41 | DataField() : hasHighlight( false ), storeAsActive( false ) {} | |
42 | 41 | QString text; |
43 | 42 | QBrush background; |
44 | bool hasHighlight; // QBrush does not have isValid() | |
45 | bool storeAsActive; | |
43 | bool hasHighlight = false; // QBrush does not have isValid() | |
44 | bool storeAsActive = false; | |
46 | 45 | QBrush highlight; |
47 | 46 | QFont font; |
48 | 47 | }; |
111 | 110 | PaintAttributes m_paintAttributes; |
112 | 111 | DataField m_defaultField; |
113 | 112 | /** Stored for performance reasons, QDate::currentDate() is expensive. */ |
114 | int m_dayOfWeek; | |
113 | int m_dayOfWeek = 0; | |
115 | 114 | /** Stored for performance reasons, QDate::shortDayName() is slow on Mac. */ |
116 | 115 | QString m_shortDayNames[7]; |
117 | 116 | /** Stored for performance reasons, QFontMetrics::elidedText is slow if called many times. */ |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Mathias Hasselmann <mathias.hasselmann@kdab.com> |
35 | 35 | #include "MessageBox.h" |
36 | 36 | #include "MonthlyTimesheet.h" |
37 | 37 | #include "MonthlyTimesheetConfigurationDialog.h" |
38 | #include "TemporaryValue.h" | |
38 | 39 | #include "TimeTrackingView.h" |
39 | #include "Uniquifier.h" | |
40 | 40 | #include "ViewHelpers.h" |
41 | 41 | #include "WeeklyTimesheet.h" |
42 | 42 | |
63 | 63 | #include <QFileInfo> |
64 | 64 | #include <QMenuBar> |
65 | 65 | #include <QMessageBox> |
66 | #include <QScriptEngine> | |
67 | #include <QScriptValue> | |
66 | 68 | #include <QSettings> |
67 | 69 | #include <QToolBar> |
68 | 70 | #include <QtAlgorithms> |
71 | 73 | |
72 | 74 | TimeTrackingWindow::TimeTrackingWindow( QWidget* parent ) |
73 | 75 | : CharmWindow( tr( "Time Tracker" ), parent ) |
74 | , m_weeklyTimesheetDialog( nullptr ) | |
75 | , m_monthlyTimesheetDialog( nullptr ) | |
76 | , m_activityReportDialog( nullptr ) | |
77 | 76 | , m_summaryWidget( new TimeTrackingView( this ) ) |
78 | 77 | , m_billDialog( new BillDialog( this ) ) |
79 | 78 | { |
91 | 90 | SLOT(slotBillGone(int)) ); |
92 | 91 | connect( &m_checkCharmReleaseVersionTimer, SIGNAL(timeout()), |
93 | 92 | SLOT(slotCheckForUpdatesAutomatic()) ); |
94 | connect( &m_updateTasksDefinitionsTimer, SIGNAL(timeout()), | |
95 | SLOT(slotSyncTasksAutomatic()) ); | |
93 | connect( &m_updateUserInfoAndTasksDefinitionsTimer, SIGNAL(timeout()), | |
94 | SLOT(slotGetUserInfo()) ); | |
96 | 95 | |
97 | 96 | //Check every 60 minutes if there are timesheets due |
98 | 97 | if (CONFIGURATION.warnUnuploadedTimesheets) |
106 | 105 | } |
107 | 106 | #endif |
108 | 107 | //Update tasks definitions once every 24h |
109 | m_updateTasksDefinitionsTimer.setInterval(24 * 60 * 60 * 1000); | |
108 | m_updateUserInfoAndTasksDefinitionsTimer.setInterval(24 * 60 * 60 * 1000); | |
110 | 109 | QTimer::singleShot( 1000, this, SLOT(slotSyncTasksAutomatic()) ); |
111 | m_updateTasksDefinitionsTimer.start(); | |
110 | m_updateUserInfoAndTasksDefinitionsTimer.start(); | |
112 | 111 | |
113 | 112 | toolBar()->hide(); |
114 | 113 | } |
283 | 282 | QMessageBox::critical( this, tr( "Invalid task" ), |
284 | 283 | tr( "Task '%1' is no longer valid, so can't be started" ).arg( nm ) ); |
285 | 284 | } |
285 | ApplicationCore::instance().updateTaskList(); | |
286 | 286 | } |
287 | 287 | |
288 | 288 | void TimeTrackingWindow::slotStopEvent() |
388 | 388 | void TimeTrackingWindow::showPreview( ReportConfigurationDialog* dialog, int result ) |
389 | 389 | { |
390 | 390 | if ( result == QDialog::Accepted ) |
391 | dialog->showReportPreviewDialog( this ); | |
391 | dialog->showReportPreviewDialog(); | |
392 | 392 | } |
393 | 393 | |
394 | 394 | void TimeTrackingWindow::slotExportToXml() |
484 | 484 | const QString message = tr("Could not download the task list: %1").arg( job->errorString() ); |
485 | 485 | if ( verbose ) |
486 | 486 | QMessageBox::critical( this, title, message ); |
487 | else | |
487 | else if ( job->error() != HttpJob::HostNotFound ) | |
488 | 488 | emit showNotification( title, message ); |
489 | 489 | |
490 | 490 | return; |
620 | 620 | void TimeTrackingWindow::maybeIdle( IdleDetector* detector ) |
621 | 621 | { |
622 | 622 | Q_ASSERT( detector ); |
623 | static bool inProgress = false; | |
624 | ||
625 | if ( inProgress == true ) return; | |
626 | Uniquifier u( &inProgress ); | |
627 | ||
628 | Q_FOREACH( const IdleDetector::IdlePeriod& p, detector->idlePeriods() ) { | |
629 | qDebug() << "ApplicationCore::slotMaybeIdle: computer might be have been idle from" | |
630 | << p.first | |
631 | << "to" << p.second; | |
632 | } | |
623 | Q_ASSERT( !detector->idlePeriods().isEmpty() ); | |
624 | ||
625 | if ( m_idleCorrectionDialogVisible ) | |
626 | return; | |
627 | ||
628 | const TemporaryValue<bool> tempValue( m_idleCorrectionDialogVisible, true ); | |
633 | 629 | |
634 | 630 | // handle idle merging: |
635 | 631 | IdleCorrectionDialog dialog( this ); |
645 | 641 | // FIXME with this option, we can only change the events to |
646 | 642 | // the start time of one idle period, I chose to use the last |
647 | 643 | // one: |
648 | Q_ASSERT( !detector->idlePeriods().isEmpty() ); | |
649 | 644 | const IdleDetector::IdlePeriod period = detector->idlePeriods().last(); |
650 | 645 | |
651 | 646 | Q_FOREACH ( EventId eventId, activeEvents ) { |
705 | 700 | const QString title = success ? tr( "Tasks Import" ) : tr( "Failure setting new tasks" ); |
706 | 701 | if ( verbose ) |
707 | 702 | QMessageBox::information( this, title, detailsText ); |
708 | else | |
703 | else if ( !success ) | |
709 | 704 | emit showNotification( title, detailsText ); |
710 | getUserInfo(); | |
711 | 705 | } |
712 | 706 | |
713 | 707 | QSettings settings; |
714 | 708 | settings.beginGroup( "httpconfig" ); |
709 | const QString userName = settings.value("username").toString(); | |
715 | 710 | setValueIfNotNull( &settings, QLatin1String("username"), exporter.metadata( QLatin1String("username") ) ); |
711 | const QString currentUserName = settings.value("username").toString(); | |
716 | 712 | setValueIfNotNull( &settings, QLatin1String("portalUrl"), exporter.metadata( QLatin1String("portal-url") ) ); |
717 | 713 | setValueIfNotNull( &settings, QLatin1String("loginUrl"), exporter.metadata( QLatin1String("login-url") ) ); |
718 | 714 | setValueIfNotNull( &settings, QLatin1String("timesheetUploadUrl"), exporter.metadata( QLatin1String("timesheet-upload-url") ) ); |
719 | 715 | setValueIfNotNull( &settings, QLatin1String("projectCodeDownloadUrl"), exporter.metadata( QLatin1String("project-code-download-url") ) ); |
720 | 716 | settings.endGroup(); |
721 | 717 | settings.beginGroup( "users" ); |
722 | settings.setValue( QLatin1String("portalUrl"), QLatin1String("https://lotsofcake.kdab.com:443/KdabHome/apps/portal/")); | |
723 | settings.setValue( QLatin1String("loginUrl"), QLatin1String("https://lotsofcake.kdab.com:443/KdabHome/apps/portal/j_security_check")); | |
718 | setValueIfNotNull( &settings, QLatin1String("portalUrl"), exporter.metadata( QLatin1String("portal-url") ) ); | |
719 | setValueIfNotNull( &settings, QLatin1String("loginUrl"), exporter.metadata( QLatin1String("login-url") ) ); | |
724 | 720 | settings.setValue( QLatin1String("userInfoDownloadUrl"), QLatin1String("https://lotsofcake.kdab.com/KdabHome/rest/user")); |
725 | 721 | settings.endGroup(); |
726 | 722 | |
727 | 723 | ApplicationCore::instance().setHttpActionsVisible( true ); |
724 | ||
725 | // update user info in case the user name has changed | |
726 | if ( !currentUserName.isEmpty() && ( currentUserName != userName ) ) | |
727 | slotGetUserInfo(); | |
728 | ||
728 | 729 | } catch( const CharmException& e ) { |
729 | 730 | const QString title = tr( "Invalid Task Definitions" ); |
730 | 731 | const QString message = e.what().isEmpty() |
738 | 739 | } |
739 | 740 | } |
740 | 741 | |
741 | void TimeTrackingWindow::getUserInfo() | |
742 | void TimeTrackingWindow::slotGetUserInfo() | |
742 | 743 | { |
743 | 744 | if (!HttpJob::credentialsAvailable()) |
744 | 745 | return; |
745 | 746 | |
746 | 747 | QSettings settings; |
747 | 748 | settings.beginGroup( "httpconfig" ); |
748 | m_user = settings.value("username").toString(); | |
749 | const QString userName = settings.value( "username" ).toString(); | |
749 | 750 | settings.endGroup(); |
750 | 751 | |
751 | 752 | settings.beginGroup( "users" ); |
752 | settings.setValue( QLatin1String("userInfoDownloadUrl"), QLatin1String("https://lotsofcake.kdab.com/KdabHome/rest/user?user=") + m_user ); | |
753 | settings.setValue( QLatin1String( "userInfoDownloadUrl" ), QLatin1String( "https://lotsofcake.kdab.com/KdabHome/rest/user?user=" ) + userName ); | |
753 | 754 | settings.endGroup(); |
754 | 755 | |
755 | GetUserInfoJob *client = new GetUserInfoJob(this,"users"); | |
756 | client->schema() = m_user; | |
757 | HttpJobProgressDialog* dialog = new HttpJobProgressDialog( client, this ); | |
758 | dialog->setWindowTitle( tr("Downloading weekly hours") ); | |
756 | GetUserInfoJob *client = new GetUserInfoJob( this, "users" ); | |
757 | client->setSchema( userName ); | |
759 | 758 | connect( client, SIGNAL(finished(HttpJob*)), this, SLOT(slotUserInfoDownloaded(HttpJob*)) ); |
760 | 759 | client->start(); |
761 | 760 | } |
762 | 761 | |
763 | 762 | void TimeTrackingWindow::slotUserInfoDownloaded( HttpJob* job_ ) |
764 | 763 | { |
764 | // getUserInfo done -> sync task | |
765 | slotSyncTasksAutomatic(); | |
766 | ||
765 | 767 | GetUserInfoJob * job = qobject_cast<GetUserInfoJob *>( job_ ); |
766 | 768 | Q_ASSERT( job ); |
767 | 769 | if ( job->error() == HttpJob::Canceled ) |
768 | 770 | return; |
769 | 771 | |
770 | 772 | if ( job->error() ) { |
771 | QMessageBox::critical( this, tr("Error"), tr("Could not download weekly hours: %1").arg( job->errorString() ) ); | |
773 | QMessageBox::critical( this, tr( "Error" ), tr( "Could not download weekly hours: %1" ).arg( job->errorString() ) ); | |
772 | 774 | return; |
773 | 775 | } |
774 | 776 | |
775 | 777 | QByteArray readData = job->userInfo(); |
776 | int index = readData.indexOf("weeklyHours"); | |
777 | index += 13; | |
778 | QString weeklyH = readData.mid(index,2).trimmed(); | |
779 | if (weeklyH.length() != 2 ) | |
780 | weeklyH = "40"; | |
778 | const QString data = readData.constData(); | |
779 | ||
780 | QScriptEngine engine; | |
781 | QScriptValue result = engine.evaluate( '(' + data + ')' ); | |
782 | QScriptValue entries = result.property( "hrInfo" ).property( "weeklyHours" ); | |
783 | QString weeklyHours = QString::number( entries.toVariant().toDouble(), 'g', 2 ); | |
784 | ||
785 | if ( weeklyHours.isEmpty() ) | |
786 | weeklyHours = "40"; | |
787 | ||
781 | 788 | QSettings settings; |
782 | 789 | settings.beginGroup( "users" ); |
783 | settings.setValue( QLatin1String("weeklyhours"), weeklyH); | |
790 | settings.setValue( QLatin1String( "weeklyhours" ), weeklyHours ); | |
784 | 791 | settings.endGroup(); |
785 | ||
786 | 792 | } |
787 | 793 | #include "moc_TimeTrackingWindow.cpp" |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
28 | 28 | #include "Core/ViewInterface.h" |
29 | 29 | #include "Core/CharmDataModelAdapterInterface.h" |
30 | 30 | |
31 | #include "HttpClient/CheckForUpdatesJob.h" | |
31 | #include "Charm/HttpClient/CheckForUpdatesJob.h" | |
32 | 32 | |
33 | 33 | #include "CharmWindow.h" |
34 | #include "WeeklySummary.h" | |
34 | #include "Charm/WeeklySummary.h" | |
35 | 35 | #include "BillDialog.h" |
36 | 36 | |
37 | 37 | class HttpJob; |
50 | 50 | Q_OBJECT |
51 | 51 | public: |
52 | 52 | explicit TimeTrackingWindow( QWidget* parent = nullptr ); |
53 | ~TimeTrackingWindow(); | |
53 | ~TimeTrackingWindow() override; | |
54 | 54 | |
55 | 55 | enum VerboseMode { |
56 | 56 | Verbose = 0, |
98 | 98 | void slotTasksDownloaded( HttpJob* ); |
99 | 99 | void slotUserInfoDownloaded( HttpJob* ); |
100 | 100 | void slotCheckForUpdatesManual(); |
101 | void slotStartEvent( TaskId ); | |
102 | void configurationChanged() override; | |
101 | 103 | |
102 | 104 | protected: |
103 | ||
104 | 105 | void insertEditMenu() override; |
105 | 106 | |
106 | 107 | private slots: |
107 | void slotStartEvent( TaskId ); | |
108 | 108 | void slotStopEvent(); |
109 | 109 | void slotSelectTasksToShow(); |
110 | 110 | void slotWeeklyTimesheetPreview( int result ); |
115 | 115 | void slotCheckForUpdatesAutomatic(); |
116 | 116 | void slotCheckForUpdates( CheckForUpdatesJob::JobData ); |
117 | 117 | void slotSyncTasksAutomatic(); |
118 | void slotGetUserInfo(); | |
118 | 119 | |
119 | void configurationChanged() override; | |
120 | 120 | |
121 | 121 | signals: |
122 | void emitCommand( CharmCommand* ); | |
123 | void emitCommandRollback( CharmCommand* ); | |
122 | void emitCommand( CharmCommand* ) override; | |
123 | void emitCommandRollback( CharmCommand* ) override; | |
124 | 124 | void showNotification( const QString& title, const QString& message ); |
125 | 125 | |
126 | 126 | private: |
129 | 129 | void showPreview( ReportConfigurationDialog*, int result ); |
130 | 130 | //ugly but private: |
131 | 131 | void importTasksFromDeviceOrFile( QIODevice* device, const QString& filename, bool verbose = true ); |
132 | void getUserInfo(); | |
133 | 132 | void startCheckForUpdates( VerboseMode mode = Silent ); |
134 | 133 | void informUserAboutNewRelease( const QString& releaseVersion, const QUrl& link , const QString& releaseInfoLink ); |
135 | 134 | |
136 | WeeklyTimesheetConfigurationDialog* m_weeklyTimesheetDialog; | |
137 | MonthlyTimesheetConfigurationDialog* m_monthlyTimesheetDialog; | |
138 | ActivityReportConfigurationDialog *m_activityReportDialog; | |
135 | WeeklyTimesheetConfigurationDialog* m_weeklyTimesheetDialog = nullptr; | |
136 | MonthlyTimesheetConfigurationDialog* m_monthlyTimesheetDialog = nullptr; | |
137 | ActivityReportConfigurationDialog *m_activityReportDialog = nullptr; | |
139 | 138 | TimeTrackingView* m_summaryWidget; |
140 | 139 | QVector<WeeklySummary> m_summaries; |
141 | 140 | QTimer m_checkUploadedSheetsTimer; |
142 | 141 | QTimer m_checkCharmReleaseVersionTimer; |
143 | QTimer m_updateTasksDefinitionsTimer; | |
142 | QTimer m_updateUserInfoAndTasksDefinitionsTimer; | |
144 | 143 | BillDialog *m_billDialog; |
145 | CheckForUpdatesJob* m_checkForUpdatesJob; | |
146 | QString m_user; | |
144 | bool m_idleCorrectionDialogVisible = false; | |
147 | 145 | }; |
148 | 146 | |
149 | 147 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
32 | 32 | |
33 | 33 | TimeSheetReport::TimeSheetReport( QWidget* parent ) |
34 | 34 | : ReportPreviewWindow( parent ) |
35 | , m_rootTask( 0 ) | |
36 | , m_activeTasksOnly( false ) | |
37 | 35 | { |
38 | 36 | } |
39 | 37 | |
59 | 57 | |
60 | 58 | void TimeSheetReport::slotSaveToXml() |
61 | 59 | { |
62 | qDebug() << "TimeSheet::slotSaveToXml: creating XML time sheet"; | |
63 | 60 | // first, ask for a file name: |
64 | 61 | QString filename = getFileName( tr("Charm reports (*.charmreport)") ); |
65 | 62 | if (filename.isEmpty()) |
85 | 82 | |
86 | 83 | void TimeSheetReport::slotSaveToText() |
87 | 84 | { |
88 | qDebug() << "TimeSheet::slotSaveToText: creating text file with totals"; | |
89 | 85 | // first, ask for a file name: |
90 | 86 | const QString filename = getFileName( "Text files (*.txt)" ); |
91 | 87 | if (filename.isEmpty()) |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
34 | 34 | |
35 | 35 | public: |
36 | 36 | explicit TimeSheetReport( QWidget* parent = nullptr ); |
37 | virtual ~TimeSheetReport(); | |
37 | ~TimeSheetReport() override; | |
38 | 38 | |
39 | 39 | virtual void setReportProperties( const QDate& start, |
40 | 40 | const QDate& end, |
78 | 78 | // properties of the report: |
79 | 79 | QDate m_start; |
80 | 80 | QDate m_end; |
81 | TaskId m_rootTask; | |
82 | bool m_activeTasksOnly; | |
81 | TaskId m_rootTask = {}; | |
82 | bool m_activeTasksOnly = false; | |
83 | 83 | }; |
84 | 84 | |
85 | 85 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
48 | 48 | case QSystemTrayIcon::Trigger: //(single click) |
49 | 49 | case QSystemTrayIcon::DoubleClick: |
50 | 50 | #ifndef Q_OS_OSX |
51 | ApplicationCore::instance().toggleShowHide(); | |
51 | ApplicationCore::instance().showMainWindow( ApplicationCore::ShowMode::ShowAndRaise ); | |
52 | 52 | #endif |
53 | 53 | break; |
54 | 54 | case QSystemTrayIcon::MiddleClick: |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
31 | 31 | |
32 | 32 | public: |
33 | 33 | explicit TrayIcon(QObject* parent = nullptr); |
34 | virtual ~TrayIcon(); | |
34 | ~TrayIcon() override; | |
35 | 35 | |
36 | 36 | private Q_SLOTS: |
37 | 37 | void slotActivated(QSystemTrayIcon::ActivationReason); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
165 | 165 | QDialog::accept(); |
166 | 166 | } |
167 | 167 | |
168 | void WeeklyTimesheetConfigurationDialog::showReportPreviewDialog( QWidget* parent ) | |
168 | void WeeklyTimesheetConfigurationDialog::showReportPreviewDialog() | |
169 | 169 | { |
170 | 170 | QDate start, end; |
171 | 171 | int index = m_ui->comboBoxWeek->currentIndex(); |
179 | 179 | end = m_weekInfo[index].timespan.second; |
180 | 180 | } |
181 | 181 | bool activeOnly = m_ui->checkBoxActiveOnly->isChecked(); |
182 | auto report = new WeeklyTimeSheetReport( parent ); | |
182 | auto report = new WeeklyTimeSheetReport(); | |
183 | 183 | report->setReportProperties( start, end, m_rootTask, activeOnly ); |
184 | 184 | report->show(); |
185 | 185 | } |
264 | 264 | |
265 | 265 | WeeklyTimeSheetReport::WeeklyTimeSheetReport( QWidget* parent ) |
266 | 266 | : TimeSheetReport( parent ) |
267 | , m_weekNumber( 0 ) | |
268 | , m_yearOfWeek( 0 ) | |
269 | 267 | { |
270 | 268 | QPushButton* upload = uploadButton(); |
271 | 269 | connect( upload, SIGNAL(clicked()), SLOT(slotUploadTimesheet()) ); |
272 | 270 | connect( this, SIGNAL(anchorClicked(QUrl)), SLOT(slotLinkClicked(QUrl)) ); |
271 | ||
273 | 272 | if (!HttpJob::credentialsAvailable()) |
274 | 273 | upload->hide(); |
275 | 274 | } |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
50 | 50 | |
51 | 51 | public: |
52 | 52 | explicit WeeklyTimesheetConfigurationDialog( QWidget* parent ); |
53 | ~WeeklyTimesheetConfigurationDialog(); | |
53 | ~WeeklyTimesheetConfigurationDialog() override; | |
54 | 54 | |
55 | void showReportPreviewDialog( QWidget* parent ) override; | |
55 | void showReportPreviewDialog() override; | |
56 | 56 | void showEvent( QShowEvent* ) override; |
57 | 57 | void setDefaultWeek( int yearOfWeek, int week ); |
58 | 58 | |
68 | 68 | private: |
69 | 69 | QScopedPointer<Ui::WeeklyTimesheetConfigurationDialog> m_ui; |
70 | 70 | QList<NamedTimeSpan> m_weekInfo; |
71 | TaskId m_rootTask; | |
71 | TaskId m_rootTask = {}; | |
72 | 72 | }; |
73 | 73 | |
74 | 74 | class WeeklyTimeSheetReport : public TimeSheetReport |
77 | 77 | |
78 | 78 | public: |
79 | 79 | explicit WeeklyTimeSheetReport( QWidget* parent = nullptr ); |
80 | virtual ~WeeklyTimeSheetReport(); | |
80 | ~WeeklyTimeSheetReport() override; | |
81 | 81 | |
82 | 82 | void setReportProperties( const QDate& start, |
83 | 83 | const QDate& end, |
97 | 97 | |
98 | 98 | private: |
99 | 99 | // properties of the report: |
100 | int m_weekNumber; | |
101 | int m_yearOfWeek; | |
100 | int m_weekNumber = 0; | |
101 | int m_yearOfWeek = 0; | |
102 | 102 | }; |
103 | 103 | |
104 | 104 | #endif |
0 | /* | |
1 | WidgetUtils.h | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Hannah von Reth <hannah.vonreth@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #include "WidgetUtils.h" | |
24 | ||
25 | #include <Core/CharmConstants.h> | |
26 | ||
27 | #include <QSettings> | |
28 | #include <QToolButton> | |
29 | #include <QWidget> | |
30 | ||
31 | void WidgetUtils::restoreGeometry( QWidget *widget, const QString &metaKey ) | |
32 | { | |
33 | QSettings settings; | |
34 | settings.beginGroup( QString::fromLatin1( "WindowStates" ) ); | |
35 | if ( settings.contains( metaKey ) ) { | |
36 | widget->restoreGeometry( settings.value( metaKey ).toByteArray() ); | |
37 | } | |
38 | } | |
39 | ||
40 | void WidgetUtils::saveGeometry( QWidget *widget, const QString &metaKey ) | |
41 | { | |
42 | QSettings settings; | |
43 | settings.beginGroup( QString::fromLatin1( "WindowStates" ) ); | |
44 | settings.setValue( metaKey, widget->saveGeometry() ); | |
45 | } | |
46 | ||
47 | void WidgetUtils::updateToolButtonStyle( QWidget *widget ) | |
48 | { | |
49 | const QList<QToolButton*> buttons = widget->findChildren<QToolButton *>(); | |
50 | Q_FOREACH ( auto button, buttons ) { | |
51 | button->setToolButtonStyle( CONFIGURATION.toolButtonStyle ); | |
52 | } | |
53 | } |
0 | /* | |
1 | WidgetUtils.h | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Hannah von Reth <hannah.vonreth@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | #ifndef WIDGETUTILS_H | |
23 | #define WIDGETUTILS_H | |
24 | ||
25 | #include <QSettings> | |
26 | ||
27 | class QWidget; | |
28 | ||
29 | namespace WidgetUtils | |
30 | { | |
31 | void restoreGeometry( QWidget *widget, const QString &metaKey ); | |
32 | void saveGeometry( QWidget *widget, const QString &metaKey ); | |
33 | ||
34 | void updateToolButtonStyle(QWidget *widget); | |
35 | }; | |
36 | ||
37 | #endif // WIDGETUTILS_H |
57 | 57 | Charm/Widgets/EventEditor.cpp \ |
58 | 58 | Charm/Widgets/EventEditorDelegate.cpp \ |
59 | 59 | Charm/Widgets/EventView.cpp \ |
60 | Charm/Widgets/EventWindow.cpp \ | |
61 | 60 | Charm/Widgets/ExpandStatesHelper.cpp \ |
62 | 61 | Charm/Widgets/IdleCorrectionDialog.cpp \ |
63 | 62 | Charm/Widgets/MessageBox.cpp \ |
70 | 69 | Charm/Widgets/TaskEditor.cpp \ |
71 | 70 | Charm/Widgets/TasksView.cpp \ |
72 | 71 | Charm/Widgets/TasksViewDelegate.cpp \ |
73 | Charm/Widgets/TasksWindow.cpp \ | |
74 | 72 | Charm/Widgets/TimeTrackingView.cpp \ |
75 | 73 | Charm/Widgets/TimeTrackingWindow.cpp \ |
76 | 74 | Charm/Widgets/TimeTrackingTaskSelector.cpp \ |
103 | 101 | Charm/Widgets/IdleCorrectionDialog.h \ |
104 | 102 | Charm/Widgets/Timesheet.h \ |
105 | 103 | Charm/Widgets/WeeklyTimesheet.h \ |
106 | Charm/Widgets/TasksWindow.h \ | |
107 | 104 | Charm/Widgets/CharmWindow.h \ |
108 | 105 | Charm/Widgets/DateEntrySyncer.h \ |
109 | 106 | Charm/Widgets/MonthlyTimesheetConfigurationDialog.h \ |
124 | 121 | Charm/Widgets/ExpandStatesHelper.h \ |
125 | 122 | Charm/Widgets/SelectTaskDialog.h \ |
126 | 123 | Charm/Widgets/MonthlyTimesheet.h \ |
127 | Charm/Widgets/EventWindow.h \ | |
128 | 124 | Charm/Widgets/EventView.h \ |
129 | 125 | Charm/Widgets/ConfigurationDialog.h \ |
130 | 126 | Charm/Widgets/HttpJobProgressDialog.h \ |
1 | 1 | #define CHARM_VERSION "@Charm_VERSION@" |
2 | 2 | /* Define if you have enabled the idle detection */ |
3 | 3 | #cmakedefine CHARM_IDLE_DETECTION |
4 | /* Defined if idle detection is available on X11 */ | |
5 | #cmakedefine CHARM_IDLE_DETECTION_AVAILABLE_X11 1 | |
4 | /* Defined if idle detection is available on X11 or XCB*/ | |
5 | #cmakedefine CHARM_IDLE_DETECTION_AVAILABLE | |
6 | 6 | /* Delay for idle detection, default is 360 */ |
7 | 7 | #define CHARM_IDLE_TIME @CHARM_IDLE_TIME@ |
8 | 8 | /* Define the url where to check for updates */ |
15 | 15 | /* Defined if local socket command interface is enabled */ |
16 | 16 | #cmakedefine CHARM_CI_LOCALSERVER |
17 | 17 | #endif |
18 | /* Defined if systemwide keychain is used */ | |
19 | #cmakedefine QTKEYCHAIN_SYSTEM |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
28 | 28 | |
29 | 29 | CharmCommand::CharmCommand( const QString& description, QObject *parent ) |
30 | 30 | : QObject( parent ), |
31 | m_owner(0), | |
32 | 31 | m_description(description) |
33 | 32 | { |
34 | 33 | CommandEmitterInterface* emitter = dynamic_cast<CommandEmitterInterface*>( parent ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
62 | 62 | |
63 | 63 | public: |
64 | 64 | explicit CharmCommand( const QString& description, QObject* parent = nullptr ); |
65 | virtual ~CharmCommand(); | |
65 | ~CharmCommand() override; | |
66 | 66 | |
67 | 67 | QString description() const; |
68 | 68 | |
94 | 94 | private: |
95 | 95 | CharmCommand( const CharmCommand& ); // disallow copying |
96 | 96 | |
97 | CommandEmitterInterface* m_owner; | |
97 | CommandEmitterInterface* m_owner = nullptr; | |
98 | 98 | const QString m_description; |
99 | 99 | }; |
100 | 100 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
39 | 39 | const QString MetaKey_MainWindowGUIStateShowCurrentTasks = "MainWindowGUIStateShowCurrentTasks"; |
40 | 40 | const QString MetaKey_TimeTrackerGeometry = "TimeTrackerGeometry"; |
41 | 41 | const QString MetaKey_TimeTrackerVisible = "TimeTrackerVisible"; |
42 | const QString MetaKey_EventEditorGeometry = "EventEditorGeometry"; | |
43 | const QString MetaKey_TaskEditorGeometry = "TaskEditorGeometry"; | |
42 | 44 | const QString MetaKey_ReportsRecentSavePath = "ReportsRecentSavePath"; |
43 | 45 | const QString MetaKey_ExportToXmlRecentSavePath = "ExportToXmlSavePath"; |
44 | 46 | const QString MetaKey_TimesheetSubscribedOnly = "TimesheetSubscribedOnly"; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
50 | 50 | extern const QString MetaKey_MainWindowGUIStateShowCurrentTasks; |
51 | 51 | extern const QString MetaKey_TimeTrackerGeometry; |
52 | 52 | extern const QString MetaKey_TimeTrackerVisible; |
53 | extern const QString MetaKey_EventEditorGeometry; | |
54 | extern const QString MetaKey_TaskEditorGeometry; | |
53 | 55 | extern const QString MetaKey_ReportsRecentSavePath; |
54 | 56 | extern const QString MetaKey_ExportToXmlRecentSavePath; |
55 | 57 | extern const QString MetaKey_TimesheetActiveOnly; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
138 | 138 | Q_FOREACH( auto adapter, m_adapters ) |
139 | 139 | adapter->taskAdded( task.id() ); |
140 | 140 | } else { |
141 | qDebug() << "CharmDataModel::addTask: duplicate task id" | |
142 | << task.id() << "ignored. THIS IS A BUG"; | |
141 | qCritical() << "CharmDataModel::addTask: duplicate task id" | |
142 | << task.id() << "ignored. THIS IS A BUG"; | |
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
221 | 221 | if ( ! eventExists( events[i].id() ) ) { |
222 | 222 | m_events[ events[i].id() ] = events[i]; |
223 | 223 | } else { |
224 | qDebug() << "CharmDataModel::addTask: duplicate task id" | |
225 | << m_tasks[i].task().id() << "ignored. THIS IS A BUG"; | |
224 | qCritical() << "CharmDataModel::addTask: duplicate task id" | |
225 | << m_tasks[i].task().id() << "ignored. THIS IS A BUG"; | |
226 | 226 | } |
227 | 227 | } |
228 | 228 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
54 | 54 | |
55 | 55 | public: |
56 | 56 | CharmDataModel(); |
57 | ~CharmDataModel(); | |
57 | ~CharmDataModel() override; | |
58 | 58 | |
59 | 59 | void stateChanged( State previous, State next ); |
60 | 60 | /** Register a CharmDataModelAdapterInterface. */ |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
41 | 41 | } |
42 | 42 | |
43 | 43 | Configuration::Configuration() |
44 | : taskPrefilteringMode( TaskPrefilter_ShowAll ) | |
45 | , timeTrackerFontSize( TimeTrackerFont_Regular ) | |
46 | , durationFormat( Minutes ) | |
47 | , toolButtonStyle( Qt::ToolButtonFollowStyle ) | |
48 | , showStatusBar( true ) | |
49 | , detectIdling( true ) | |
50 | , warnUnuploadedTimesheets( true ) | |
51 | , requestEventComment( false ) | |
52 | , enableCommandInterface( false ) | |
53 | , configurationName( DEFAULT_CONFIG_GROUP ) | |
54 | , installationId( 0 ) | |
55 | , newDatabase( false ) | |
56 | , failure( false ) | |
57 | , taskPaddingLength( 6 ) // arbitrary | |
44 | : configurationName( DEFAULT_CONFIG_GROUP ) | |
58 | 45 | { |
59 | 46 | } |
60 | 47 | |
61 | Configuration::Configuration( bool _eventsInLeafsOnly, bool _oneEventAtATime, User _user, | |
62 | TaskPrefilteringMode _taskPrefilteringMode, | |
48 | Configuration::Configuration( TaskPrefilteringMode _taskPrefilteringMode, | |
63 | 49 | TimeTrackerFontSize _timeTrackerFontSize, |
64 | 50 | DurationFormat _durationFormat, bool _detectIdling, |
65 | 51 | Qt::ToolButtonStyle _buttonstyle, bool _showStatusBar, |
75 | 61 | , requestEventComment( _requestEventComment ) |
76 | 62 | , enableCommandInterface( _enableCommandInterface ) |
77 | 63 | , configurationName( DEFAULT_CONFIG_GROUP ) |
78 | , installationId( 0 ) | |
79 | , newDatabase( false ) | |
80 | , failure( false ) | |
81 | , taskPaddingLength( 6 ) // arbitrary | |
82 | 64 | { |
83 | 65 | } |
84 | 66 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
68 | 68 | void dump( const QString& why = QString::null ); |
69 | 69 | |
70 | 70 | User user; // this user's id |
71 | TaskPrefilteringMode taskPrefilteringMode; | |
72 | TimeTrackerFontSize timeTrackerFontSize; | |
73 | DurationFormat durationFormat; | |
74 | Qt::ToolButtonStyle toolButtonStyle; | |
75 | bool showStatusBar; | |
76 | bool detectIdling; | |
77 | bool warnUnuploadedTimesheets; | |
78 | bool requestEventComment; | |
79 | bool enableCommandInterface; | |
71 | TaskPrefilteringMode taskPrefilteringMode = TaskPrefilter_ShowAll; | |
72 | TimeTrackerFontSize timeTrackerFontSize = TimeTrackerFont_Regular; | |
73 | DurationFormat durationFormat = Minutes; | |
74 | Qt::ToolButtonStyle toolButtonStyle = Qt::ToolButtonFollowStyle; | |
75 | bool showStatusBar = true; | |
76 | bool detectIdling = true; | |
77 | bool warnUnuploadedTimesheets = true; | |
78 | bool requestEventComment = false; | |
79 | bool enableCommandInterface = false; | |
80 | 80 | |
81 | 81 | // these are stored in QSettings, since we need this information to locate and open the database: |
82 | 82 | QString configurationName; |
83 | int installationId; | |
83 | int installationId = 0; | |
84 | 84 | QString localStorageType; // SqLite, MySql, ... |
85 | 85 | QString localStorageDatabase; // database name (path, with sqlite) |
86 | bool newDatabase; // true if the configuration has just been created | |
87 | bool failure; // used to reconfigure on failures | |
86 | bool newDatabase = false; // true if the configuration has just been created | |
87 | bool failure = false; // used to reconfigure on failures | |
88 | 88 | QString failureMessage; // a message to show the user if something is wrong with the configuration |
89 | 89 | |
90 | 90 | // appearance properties |
91 | int taskPaddingLength; // auto-determined | |
91 | int taskPaddingLength = 6; // arbitrary | |
92 | 92 | private: |
93 | 93 | // allow test classes to create configuration objects (tests are |
94 | 94 | // the only application that can have (test) multiple |
96 | 96 | friend class SqLiteStorageTests; |
97 | 97 | friend class ControllerTests; |
98 | 98 | // these are all the persisted metadata settings, and the constructor is only used during test runs: |
99 | Configuration( bool eventsInLeafsOnly, bool oneEventAtATime, User user, | |
100 | TaskPrefilteringMode taskPrefilteringMode, TimeTrackerFontSize, | |
99 | Configuration( TaskPrefilteringMode taskPrefilteringMode, TimeTrackerFontSize, | |
101 | 100 | DurationFormat durationFormat, bool detectIdling, Qt::ToolButtonStyle buttonstyle, |
102 | 101 | bool showStatusBar, bool warnUnuploadedTimesheets, bool _requestEventComment, |
103 | 102 | bool enableCommandInterface ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
39 | 39 | Controller::Controller( QObject* parent_ ) |
40 | 40 | : QObject( parent_ ) |
41 | 41 | , ControllerInterface() |
42 | , m_storage( nullptr ) | |
43 | 42 | { |
44 | 43 | } |
45 | 44 | |
100 | 99 | |
101 | 100 | bool Controller::addTask( const Task& task ) |
102 | 101 | { |
103 | qDebug() << Q_FUNC_INFO << "adding task" << task.id() | |
104 | << "to parent" << task.parent(); | |
105 | 102 | if ( m_storage->addTask( task ) ) { |
106 | 103 | updateSubscriptionForTask( task ); |
107 | 104 | emit taskAdded( task ); |
115 | 112 | |
116 | 113 | bool Controller::modifyTask( const Task& task ) |
117 | 114 | { |
118 | // find it | |
119 | qDebug() << Q_FUNC_INFO << "committing changes to task" | |
120 | << task.id(); | |
121 | 115 | // modify the task itself: |
122 | 116 | bool result = m_storage->modifyTask( task ); |
123 | 117 | Q_ASSERT( result ); |
124 | 118 | if ( ! result ) { |
125 | qDebug() << Q_FUNC_INFO << "modifyTask failed!"; | |
119 | qCritical() << Q_FUNC_INFO << "modifyTask failed!"; | |
126 | 120 | return result; |
127 | 121 | } |
128 | 122 | |
134 | 128 | |
135 | 129 | bool Controller::deleteTask( const Task& task ) |
136 | 130 | { |
137 | qDebug() << Q_FUNC_INFO << "deleting task" << task.id(); | |
138 | 131 | if ( m_storage->deleteTask( task ) ) { |
139 | 132 | m_storage->deleteSubscription( CONFIGURATION.user, task ); |
140 | 133 | emit taskDeleted( task ); |
147 | 140 | |
148 | 141 | bool Controller::setAllTasks( const TaskList& tasks ) |
149 | 142 | { |
150 | qDebug() << Q_FUNC_INFO << "replacing all tasks"; | |
151 | 143 | if ( m_storage->setAllTasks( CONFIGURATION.user, tasks ) ) { |
152 | 144 | const TaskList newTasks = m_storage->getAllTasks(); |
153 | 145 | // tell the view about the existing tasks; |
196 | 188 | emit readyToQuit(); |
197 | 189 | if ( m_storage ) { |
198 | 190 | // this will still leave Qt complaining about a repeated connection |
199 | // qDebug() << "Application::enterConnectingState: closing existing storage interface"; | |
200 | 191 | m_storage->disconnect(); |
201 | 192 | delete m_storage; |
202 | 193 | m_storage = nullptr; |
369 | 360 | eventsElement.appendChild( element ); |
370 | 361 | } |
371 | 362 | root.appendChild( eventsElement ); |
372 | // qDebug() << document.toString( 4 ); | |
373 | 363 | return document; |
374 | 364 | } |
375 | 365 | |
406 | 396 | databaseSchemaVersion = rootElement.attribute( "version" ).toInt( &ok ); |
407 | 397 | if ( !ok ) throw XmlSerializationException( QObject::tr( "Syntax error, no version attribute found." ) ); |
408 | 398 | |
409 | QDomElement metadataElement = rootElement.firstChildElement( MetaDataElement ); | |
410 | 399 | QDomElement tasksElement = rootElement.firstChildElement( TasksElement ); |
411 | 400 | for ( QDomElement element = tasksElement.firstChildElement( Task::tagName() ); |
412 | 401 | !element.isNull(); element = element.nextSiblingElement( Task::tagName() ) ) { |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Olivier JG <olivier.de.gaalon@kdab.com> |
40 | 40 | |
41 | 41 | public: |
42 | 42 | explicit Controller( QObject* parent = nullptr ); |
43 | ~Controller(); | |
43 | ~Controller() override; | |
44 | 44 | |
45 | 45 | void stateChanged( State previous, State next ) override; |
46 | 46 | void persistMetaData( Configuration& ) override; |
72 | 72 | void rollbackCommand ( CharmCommand* ) override; |
73 | 73 | |
74 | 74 | signals: |
75 | void eventAdded( const Event& event ); | |
76 | void eventModified( const Event& event ); | |
77 | void eventDeleted( const Event& event ); | |
75 | void eventAdded( const Event& event ) override; | |
76 | void eventModified( const Event& event ) override; | |
77 | void eventDeleted( const Event& event ) override; | |
78 | 78 | void allEvents( const EventList& ); |
79 | void definedTasks( const TaskList& ); | |
80 | void taskAdded( const Task& ); | |
81 | void taskUpdated( const Task& ); | |
82 | void taskDeleted( const Task& ); | |
83 | void readyToQuit(); | |
79 | void definedTasks( const TaskList& ) override; | |
80 | void taskAdded( const Task& ) override; | |
81 | void taskUpdated( const Task& ) override; | |
82 | void taskDeleted( const Task& ) override; | |
83 | void readyToQuit() override; | |
84 | 84 | void currentBackendStatus( const QString& text ); |
85 | 85 | |
86 | void commandCompleted( CharmCommand* ); | |
86 | void commandCompleted( CharmCommand* ) override; | |
87 | 87 | |
88 | 88 | private: |
89 | 89 | void updateSubscriptionForTask( const Task& ); |
90 | 90 | |
91 | 91 | template<class T> void loadConfigValue( const QString &key, T &configValue ) const; |
92 | StorageInterface* m_storage; | |
92 | StorageInterface* m_storage = nullptr; | |
93 | 93 | }; |
94 | 94 | |
95 | 95 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Olivier JG <olivier.de.gaalon@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Olivier JG <olivier.de.gaalon@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
27 | 27 | #include <QDomText> |
28 | 28 | |
29 | 29 | Event::Event() |
30 | : m_userid() | |
31 | , m_reportid() | |
32 | , m_installationId() | |
33 | , m_id() | |
34 | , m_taskId() | |
35 | 30 | { |
36 | 31 | } |
37 | 32 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
93 | 93 | |
94 | 94 | private: |
95 | 95 | /** The id of the user who owns the event. */ |
96 | int m_userid; | |
96 | int m_userid = {}; | |
97 | 97 | /** The report id. This field is only useful |
98 | 98 | * if the event is imported from a report. |
99 | 99 | */ |
100 | int m_reportid; | |
100 | int m_reportid = {}; | |
101 | 101 | /** The installation-unique id of the event. */ |
102 | int m_installationId; | |
103 | int m_id; | |
102 | int m_installationId = {}; | |
103 | int m_id = {}; | |
104 | 104 | /** The task this event belongs to. */ |
105 | TaskId m_taskId; | |
105 | TaskId m_taskId = {}; | |
106 | 106 | /** A possible user comment. |
107 | 107 | May be empty. */ |
108 | 108 | QString m_comment; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2012-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
59 | 59 | |
60 | 60 | void SmartNameCache::deleteTask( const Task& task ) |
61 | 61 | { |
62 | const TaskList::Iterator it = qBinaryFind( m_tasks.begin(), m_tasks.end(), Task( task.id(), QString() ), IdLessThan() ); | |
62 | const auto it = qBinaryFind( m_tasks.begin(), m_tasks.end(), Task( task.id(), QString() ), IdLessThan() ); | |
63 | 63 | if ( it != m_tasks.end() ) { |
64 | 64 | m_tasks.erase( it ); |
65 | 65 | regenerateSmartNames(); |
74 | 74 | |
75 | 75 | Task SmartNameCache::findTask( TaskId id ) const |
76 | 76 | { |
77 | const TaskList::ConstIterator it = qBinaryFind( m_tasks.begin(), m_tasks.end(), Task( id, QString() ), IdLessThan() ); | |
77 | const auto it = qBinaryFind( m_tasks.begin(), m_tasks.end(), Task( id, QString() ), IdLessThan() ); | |
78 | 78 | if ( it != m_tasks.constEnd() ) |
79 | 79 | return *it; |
80 | 80 | else |
123 | 123 | it != byName.constEnd(); |
124 | 124 | ++it ) { |
125 | 125 | const QString currentName = it.key(); |
126 | const QVector<TaskParentPair>& taskPairs = it.value(); | |
126 | const auto& taskPairs = it.value(); | |
127 | 127 | Q_ASSERT( !taskPairs.isEmpty() ); |
128 | 128 | if ( taskPairs.size() == 1 || cannotMakeUnique.contains( currentName ) ) { |
129 | 129 | Q_FOREACH( const TaskParentPair& i, taskPairs ) |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2012-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
110 | 110 | SqLiteStorage::SqLiteStorage() |
111 | 111 | : SqlStorage() |
112 | 112 | , m_database( QSqlDatabase::addDatabase( DriverName, DatabaseName ) ) |
113 | , m_installationId( 0 ) | |
114 | 113 | { |
115 | 114 | if ( ! QSqlDatabase::isDriverAvailable( DriverName ) ) { |
116 | 115 | throw CharmException( QObject::tr( "QSQLITE driver not available" ) ); |
190 | 189 | return false; |
191 | 190 | } |
192 | 191 | |
193 | // connect: | |
194 | // qDebug() << "SqLiteStorage::connect: creating or opening local sqlite database at " | |
195 | // << fileInfo.absoluteFilePath(); | |
196 | ||
197 | 192 | const QDir oldDatabaseDirectory( QDir::homePath() + QDir::separator() + ".Charm" ); |
198 | 193 | if ( oldDatabaseDirectory.exists() ) |
199 | 194 | migrateDatabaseDirectory( oldDatabaseDirectory, fileInfo.dir() ); |
223 | 218 | return false; |
224 | 219 | } |
225 | 220 | |
226 | // qDebug() << "SqLiteStorage::connect: SUCCESS - connected to database"; | |
227 | 221 | if ( ! verifyDatabase() ) |
228 | 222 | { |
229 | // qDebug() << "SqLiteStorage::connect: empty database, filling in the blanks"; | |
230 | 223 | if ( !createDatabase( configuration ) ) |
231 | 224 | { |
232 | 225 | configuration.failureMessage = QObject::tr( "SqLiteStorage::connect: error creating default database contents" ); |
238 | 231 | { |
239 | 232 | const int userid = configuration.user.id(); |
240 | 233 | const User user = getUser( userid ); |
241 | // qDebug() << "SqLiteStorage::connect: found user" << user.name() | |
242 | // << "for id" << userid << ( user.isValid() ? "(valid)" : "(invalid)"); | |
243 | 234 | if ( !user.isValid() ) |
244 | 235 | return false; |
245 | 236 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Mike McQuaid <mike.mcquaid@kdab.com> |
52 | 52 | |
53 | 53 | private: |
54 | 54 | QSqlDatabase m_database; |
55 | int m_installationId; | |
55 | int m_installationId = 0; | |
56 | 56 | }; |
57 | 57 | |
58 | 58 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
29 | 29 | #include <QSqlError> |
30 | 30 | |
31 | 31 | SqlRaiiTransactor::SqlRaiiTransactor( QSqlDatabase& database ) |
32 | : m_active( false ), | |
33 | m_database ( database ) | |
32 | : m_database ( database ) | |
34 | 33 | { |
35 | 34 | if ( ! database.driver()->hasFeature( QSqlDriver::Transactions ) ) { |
36 | 35 | throw TransactionException( QObject::tr( "Database driver does not support transactions." ) ); |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
34 | 34 | |
35 | 35 | bool commit(); |
36 | 36 | private: |
37 | bool m_active; | |
37 | bool m_active = false; | |
38 | 38 | QSqlDatabase& m_database; |
39 | 39 | }; |
40 | 40 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
458 | 458 | |
459 | 459 | void SqlStorage::stateChanged(State previous) |
460 | 460 | { |
461 | Q_UNUSED(previous); | |
461 | Q_UNUSED(previous) | |
462 | 462 | // atm, SqlStorage does not care about state |
463 | // qDebug() << "SqlStorage::stateChanged: NOT IMPLEMENTED" | |
464 | 463 | } |
465 | 464 | |
466 | 465 | User SqlStorage::getUser(int userid) |
486 | 485 | } |
487 | 486 | else |
488 | 487 | { |
489 | qDebug() << "SqlStorage::getUser: no user with id" << userid; | |
488 | qCritical() << "SqlStorage::getUser: no user with id" << userid; | |
490 | 489 | } |
491 | 490 | } |
492 | 491 | |
532 | 531 | } |
533 | 532 | else |
534 | 533 | { |
535 | qDebug() | |
534 | qCritical() | |
536 | 535 | << "SqlStorage::makeUser: FAILED to find newly created user"; |
537 | 536 | return user; |
538 | 537 | } |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
32 | 32 | #include <algorithm> |
33 | 33 | |
34 | 34 | Task::Task() |
35 | : m_id(0) | |
36 | , m_parent(0) | |
37 | , m_subscribed(false) | |
38 | , m_trackable(true) | |
39 | 35 | { |
40 | 36 | } |
41 | 37 | |
44 | 40 | , m_parent(parent) |
45 | 41 | , m_name(name) |
46 | 42 | , m_subscribed(subscribed) |
47 | , m_trackable(true) | |
48 | 43 | { |
49 | 44 | } |
50 | 45 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
104 | 104 | static bool lowerTaskId( const Task& left, const Task& right ); |
105 | 105 | |
106 | 106 | private: |
107 | int m_id; | |
108 | int m_parent; | |
107 | int m_id = 0; | |
108 | int m_parent = 0; | |
109 | 109 | QString m_name; |
110 | bool m_subscribed; | |
111 | bool m_trackable; | |
110 | bool m_subscribed = false; | |
111 | bool m_trackable = true; | |
112 | 112 | /** The timestamp from which the task is valid. */ |
113 | 113 | QDateTime m_validFrom; |
114 | 114 | /** The timestamp after which the task becomes invalid. */ |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
24 | 24 | #include "CharmExceptions.h" |
25 | 25 | |
26 | 26 | TaskListMerger::TaskListMerger() |
27 | : m_resultsValid( false ) | |
28 | 27 | { |
29 | 28 | } |
30 | 29 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
58 | 58 | void verifyTaskList( const TaskList& tasks ); |
59 | 59 | void calculateResults() const; |
60 | 60 | |
61 | mutable bool m_resultsValid; | |
61 | mutable bool m_resultsValid = false; | |
62 | 62 | TaskList m_oldTasks; |
63 | 63 | TaskList m_newTasks; |
64 | 64 | mutable TaskList m_results; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
26 | 26 | #include <QtDebug> |
27 | 27 | |
28 | 28 | TaskTreeItem::TaskTreeItem() |
29 | : m_parent( 0 ) | |
30 | 29 | { |
31 | 30 | } |
32 | 31 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
75 | 75 | TaskIdList childIds() const; |
76 | 76 | |
77 | 77 | private: |
78 | TaskTreeItem* m_parent; | |
78 | TaskTreeItem* m_parent = nullptr; | |
79 | 79 | ConstPointerList m_children; |
80 | 80 | Task m_task; |
81 | 81 | }; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
0 | /* | |
1 | ViewModeInterface.h | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Mirko Boehm <mirko.boehm@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #ifndef CHARM_UISTATEINTERFACE_H | |
24 | #define CHARM_UISTATEINTERFACE_H | |
25 | ||
26 | #include <Core/State.h> | |
27 | #include <Core/CommandEmitterInterface.h> | |
28 | ||
29 | class UIStateInterface : | |
30 | public CommandEmitterInterface | |
31 | { | |
32 | public: | |
33 | virtual ~UIStateInterface() {}; | |
34 | virtual void saveGuiState() = 0; | |
35 | virtual void restoreGuiState() = 0; | |
36 | virtual void stateChanged( State previous ) = 0; | |
37 | virtual void configurationChanged() = 0; | |
38 | virtual void emitCommand( CharmCommand* ) = 0; | |
39 | virtual void emitCommandRollback( CharmCommand* ) = 0; | |
40 | ||
41 | // CommandEmitterInterface | |
42 | virtual void commitCommand( CharmCommand* ) override = 0; | |
43 | }; | |
44 | ||
45 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
28 | 28 | class User { |
29 | 29 | public: |
30 | 30 | User() |
31 | : m_id( 0 ) | |
32 | 31 | {} |
33 | 32 | |
34 | 33 | User( const QString& name, int id ) |
63 | 62 | |
64 | 63 | private: |
65 | 64 | QString m_name; |
66 | int m_id; | |
65 | int m_id = 0; | |
67 | 66 | }; |
68 | 67 | |
69 | 68 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
26 | 26 | #include "Task.h" |
27 | 27 | #include "State.h" |
28 | 28 | #include "Event.h" |
29 | #include "UIStateInterface.h" | |
29 | 30 | |
30 | 31 | class CharmCommand; |
31 | 32 | |
32 | class ViewInterface | |
33 | class ViewInterface : | |
34 | public UIStateInterface | |
33 | 35 | { |
34 | 36 | public: |
35 | virtual ~ViewInterface() {} // keep compiler happy | |
37 | virtual ~ViewInterface() {}; | |
36 | 38 | |
37 | 39 | // application: |
38 | virtual void stateChanged( State previous ) = 0; | |
39 | virtual void visibilityChanged( bool ) = 0; // implement as signal and emit from show and hide events | |
40 | virtual void configurationChanged() = 0; | |
41 | 40 | virtual void saveConfiguration() = 0; |
42 | 41 | |
43 | virtual void emitCommand( CharmCommand* ) = 0; | |
44 | virtual void emitCommandRollback( CharmCommand* ) = 0; | |
45 | 42 | virtual void sendCommand( CharmCommand* ) = 0; |
46 | 43 | virtual void sendCommandRollback( CharmCommand* ) = 0; |
47 | virtual void commitCommand( CharmCommand* ) = 0; | |
44 | ||
45 | virtual void visibilityChanged( bool ) = 0; // implement as signal and emit from show and hide events | |
48 | 46 | |
49 | 47 | // restore the view |
50 | 48 | virtual void restore() = 0; |
51 | 49 | // quit the application |
52 | 50 | virtual void quit() = 0; |
53 | 51 | |
52 | // CommandEmitterInterface | |
53 | virtual void commitCommand( CharmCommand* ) override = 0; | |
54 | ||
55 | // UIStateInterface interface | |
56 | virtual void saveGuiState() override = 0; | |
57 | virtual void restoreGuiState() override = 0; | |
58 | virtual void stateChanged(State previous) override = 0; | |
59 | virtual void configurationChanged() override = 0; | |
60 | ||
61 | virtual void emitCommand( CharmCommand* ) override = 0; | |
62 | virtual void emitCommandRollback( CharmCommand* ) override = 0; | |
54 | 63 | }; |
55 | 64 | |
56 | 65 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
121 | 121 | void TaskExport::writeTo( const QString& filename, const TaskList& tasks ) |
122 | 122 | { |
123 | 123 | QDomDocument document = XmlSerialization::createXmlTemplate( reportType() ); |
124 | QDomElement metadata = XmlSerialization::metadataElement( document ); | |
125 | 124 | QDomElement report = XmlSerialization::reportElement( document ); |
126 | 125 | |
127 | 126 | // write tasks |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
23 | 23 | ADD_EXECUTABLE( ControllerTests ${ControllerTests_SRCS} ) |
24 | 24 | TARGET_LINK_LIBRARIES( ControllerTests ${TEST_LIBRARIES} ) |
25 | 25 | ADD_TEST( NAME ControllerTests COMMAND ControllerTests ) |
26 | ||
27 | SET( EventModelFilterTests_SRCS | |
28 | ${Charm_SOURCE_DIR}/Charm/EventModelAdapter.cpp | |
29 | ${Charm_SOURCE_DIR}/Charm/EventModelFilter.cpp | |
30 | EventModelFilterTests.cpp | |
31 | ) | |
32 | ADD_EXECUTABLE( EventModelFilterTests ${EventModelFilterTests_SRCS} ) | |
33 | TARGET_LINK_LIBRARIES( EventModelFilterTests ${TEST_LIBRARIES} ) | |
26 | 34 | |
27 | 35 | SET( DatesTests_SRCS DatesTests.cpp ) |
28 | 36 | ADD_EXECUTABLE( DatesTests ${DatesTests_SRCS} ) |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
32 | 32 | |
33 | 33 | CharmDataModelTests::CharmDataModelTests() |
34 | 34 | : QObject() |
35 | , m_referenceModel( nullptr ) | |
36 | 35 | { |
37 | 36 | } |
38 | 37 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
42 | 42 | void cleanupTestCase(); |
43 | 43 | |
44 | 44 | private: |
45 | CharmDataModel* m_referenceModel; | |
45 | CharmDataModel* m_referenceModel = nullptr; | |
46 | 46 | }; |
47 | 47 | |
48 | 48 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
36 | 36 | |
37 | 37 | ControllerTests::ControllerTests() |
38 | 38 | : QObject() |
39 | , m_controller( nullptr ) | |
40 | 39 | , m_configuration( Configuration::instance() ) |
41 | 40 | , m_localPath( "./ControllerTestDatabase.db" ) |
42 | , m_eventListReceived( false ) | |
43 | , m_taskListReceived( false ) | |
44 | 41 | { |
45 | 42 | } |
46 | 43 | |
79 | 76 | } |
80 | 77 | |
81 | 78 | void ControllerTests:: persistProvideMetaDataTest() |
82 | { // stick with user id 0, it is not persisted in the DB, and 0 is the default | |
79 | { | |
83 | 80 | Configuration configs[] = { |
84 | Configuration( true, true, User( "bla", 0 ), Configuration::TaskPrefilter_ShowAll, Configuration::TimeTrackerFont_Small, | |
81 | Configuration( Configuration::TaskPrefilter_ShowAll, Configuration::TimeTrackerFont_Small, | |
85 | 82 | Configuration::Minutes, true, Qt::ToolButtonIconOnly, true, true, true, false ), |
86 | Configuration( true, false, User( "blub", 0 ), Configuration::TaskPrefilter_CurrentOnly, Configuration::TimeTrackerFont_Regular, | |
83 | Configuration( Configuration::TaskPrefilter_CurrentOnly, Configuration::TimeTrackerFont_Regular, | |
87 | 84 | Configuration::Minutes, false, Qt::ToolButtonTextOnly, false, false, false, false ), |
88 | Configuration( false, true, User(), Configuration::TaskPrefilter_SubscribedAndCurrentOnly, Configuration::TimeTrackerFont_Large, | |
85 | Configuration( Configuration::TaskPrefilter_SubscribedAndCurrentOnly, Configuration::TimeTrackerFont_Large, | |
89 | 86 | Configuration::Minutes, true, Qt::ToolButtonTextBesideIcon, true, true, true, false ), |
90 | 87 | }; |
91 | 88 | const int NumberOfConfigurations = sizeof configs / sizeof configs[0]; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
67 | 67 | |
68 | 68 | private: |
69 | 69 | |
70 | ControllerInterface* m_controller; | |
70 | ControllerInterface* m_controller = nullptr; | |
71 | 71 | Configuration& m_configuration; |
72 | 72 | QString m_localPath; |
73 | 73 | EventList m_currentEvents; |
74 | bool m_eventListReceived; | |
74 | bool m_eventListReceived = false; | |
75 | 75 | TaskList m_definedTasks; |
76 | bool m_taskListReceived; | |
76 | bool m_taskListReceived = false; | |
77 | 77 | }; |
78 | 78 | |
79 | 79 | #endif |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Olivier JG <olivier.de.gaalon@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | Author: Olivier JG <olivier.de.gaalon@kdab.com> |
0 | /* | |
1 | EventModelFilterTests.cpp | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Michel Boyer de la Giroday <michel.giroday@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #include "EventModelFilterTests.h" | |
24 | #include "Charm/EventModelFilter.h" | |
25 | #include "Core/CharmDataModel.h" | |
26 | #include "Core/Event.h" | |
27 | #include "Core/Task.h" | |
28 | ||
29 | #include <QDateTime> | |
30 | #include <QtTest/QtTest> | |
31 | ||
32 | EventModelFilterTests::EventModelFilterTests() | |
33 | : QObject() | |
34 | { | |
35 | } | |
36 | ||
37 | void EventModelFilterTests::initTestCase() | |
38 | { | |
39 | // set up a model | |
40 | m_referenceModel = new CharmDataModel; | |
41 | ||
42 | // add tasks | |
43 | Task task1( 1000, "Task 1" ); | |
44 | TaskList task; | |
45 | task << task1; | |
46 | m_referenceModel->setAllTasks( task ); | |
47 | m_eventModelFilter = new EventModelFilter( m_referenceModel, this ); | |
48 | ||
49 | TimeSpans spans; | |
50 | m_thisYearSpan = spans.thisYear(); | |
51 | m_theMonthBeforeLastSpan = spans.theMonthBeforeLast(); | |
52 | m_lastMonthSpan = spans.lastMonth(); | |
53 | m_thisMonthSpan = spans.thisMonth(); | |
54 | m_theWeekBeforeLastSpan = spans.theWeekBeforeLast(); | |
55 | m_lastWeekSpan = spans.lastWeek(); | |
56 | m_thisWeekSpan = spans.thisWeek(); | |
57 | m_dayBeforeYesterdaySpan = spans.dayBeforeYesterday(); | |
58 | m_yesterdaySpan = spans.yesterday(); | |
59 | m_todaySpan = spans.today(); | |
60 | NamedTimeSpan allEvents = { | |
61 | tr( "Ever" ), | |
62 | TimeSpan( QDate::currentDate().addYears( -200 ), | |
63 | QDate::currentDate().addYears( +200 ) ) | |
64 | }; | |
65 | m_everSpan = allEvents; | |
66 | } | |
67 | ||
68 | void EventModelFilterTests::checkYearsFilter() | |
69 | { | |
70 | Event event1, event2; | |
71 | QDateTime time = QDateTime::currentDateTime(); | |
72 | time.setDate( m_thisYearSpan.timespan.first ); | |
73 | // Last year | |
74 | event1.setId( 1 ); | |
75 | event1.setComment( "event1" ); | |
76 | event1.setTaskId( 1000 ); | |
77 | event1.setStartDateTime( time.addYears( -1 ) ); | |
78 | event1.setEndDateTime( time.addYears( -1 ).addSecs( 3600 ) ); | |
79 | // This year | |
80 | event2.setId( 2 ); | |
81 | event2.setComment( "event2" ); | |
82 | event2.setTaskId( 1000 ); | |
83 | event2.setStartDateTime( time ); | |
84 | event2.setEndDateTime( time.addSecs( 3600 ) ); | |
85 | ||
86 | EventList events; | |
87 | events << event1 << event2; | |
88 | m_referenceModel->setAllEvents( events ); | |
89 | ||
90 | // Last year | |
91 | m_eventModelFilter->setFilterStartDate( m_thisYearSpan.timespan.first.addYears( -1 ) ); | |
92 | m_eventModelFilter->setFilterEndDate( m_thisYearSpan.timespan.second.addYears( -1 ) ); | |
93 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
94 | ||
95 | // This year | |
96 | m_eventModelFilter->setFilterStartDate( m_thisYearSpan.timespan.first ); | |
97 | m_eventModelFilter->setFilterEndDate( m_thisYearSpan.timespan.second ); | |
98 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
99 | ||
100 | m_referenceModel->clearEvents(); | |
101 | } | |
102 | ||
103 | void EventModelFilterTests::checkMonthsFilter() | |
104 | { | |
105 | m_referenceModel->clearEvents(); | |
106 | Event event1, event2, event3; | |
107 | QDateTime time = QDateTime::currentDateTime(); | |
108 | time.setDate( m_theMonthBeforeLastSpan.timespan.first ); | |
109 | event1.setId( 1 ); | |
110 | event1.setComment( "event1" ); | |
111 | event1.setTaskId( 1000 ); | |
112 | event1.setStartDateTime( time ); | |
113 | event1.setEndDateTime( time.addSecs( 3600 ) ); | |
114 | ||
115 | time.setDate( m_lastMonthSpan.timespan.first ); | |
116 | event2.setId( 2 ); | |
117 | event2.setComment( "event2" ); | |
118 | event2.setTaskId( 1000 ); | |
119 | event2.setStartDateTime( time ); | |
120 | event2.setEndDateTime( time.addSecs( 3600 ) ); | |
121 | ||
122 | time.setDate( m_thisMonthSpan.timespan.first ); | |
123 | event3.setId( 3 ); | |
124 | event3.setComment( "event3" ); | |
125 | event3.setTaskId( 1000 ); | |
126 | event3.setStartDateTime( time ); | |
127 | event3.setEndDateTime( time.addSecs( 3600 ) ); | |
128 | ||
129 | EventList events; | |
130 | events << event1 << event2 << event3; | |
131 | m_referenceModel->setAllEvents( events ); | |
132 | ||
133 | // The month before last month | |
134 | m_eventModelFilter->setFilterStartDate( m_theMonthBeforeLastSpan.timespan.first ); | |
135 | m_eventModelFilter->setFilterEndDate( m_theMonthBeforeLastSpan.timespan.second ); | |
136 | m_eventModelFilter->events(); | |
137 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
138 | // Last month | |
139 | m_eventModelFilter->setFilterStartDate( m_lastMonthSpan.timespan.first ); | |
140 | m_eventModelFilter->setFilterEndDate( m_lastMonthSpan.timespan.second ); | |
141 | m_eventModelFilter->events(); | |
142 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
143 | // This month | |
144 | m_eventModelFilter->setFilterStartDate( m_thisMonthSpan.timespan.first ); | |
145 | m_eventModelFilter->setFilterEndDate( m_thisMonthSpan.timespan.second ); | |
146 | m_eventModelFilter->events(); | |
147 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
148 | ||
149 | m_referenceModel->clearEvents(); | |
150 | } | |
151 | ||
152 | void EventModelFilterTests::checkWeeksFilter() | |
153 | { | |
154 | Event event1, event2, event3; | |
155 | QDateTime time = QDateTime::currentDateTime(); | |
156 | time.setDate( m_theWeekBeforeLastSpan.timespan.first ); | |
157 | event1.setId( 1 ); | |
158 | event1.setComment( "event1" ); | |
159 | event1.setTaskId( 1000 ); | |
160 | event1.setStartDateTime( time ); | |
161 | event1.setEndDateTime( time.addSecs( 3600 ) ); | |
162 | ||
163 | time.setDate( m_lastWeekSpan.timespan.first ); | |
164 | event2.setId( 2 ); | |
165 | event2.setComment( "event2" ); | |
166 | event2.setTaskId( 1000 ); | |
167 | event2.setStartDateTime( time ); | |
168 | event2.setEndDateTime( time.addSecs( 3600 ) ); | |
169 | ||
170 | time.setDate( m_thisWeekSpan.timespan.first ); | |
171 | event3.setId( 3 ); | |
172 | event3.setComment( "event3" ); | |
173 | event3.setTaskId( 1000 ); | |
174 | event3.setStartDateTime( time ); | |
175 | event3.setEndDateTime( time.addSecs( 3600 ) ); | |
176 | ||
177 | EventList events; | |
178 | events << event1 << event2 << event3; | |
179 | m_referenceModel->setAllEvents( events ); | |
180 | ||
181 | // The week before last week | |
182 | m_eventModelFilter->setFilterStartDate( m_theWeekBeforeLastSpan.timespan.first ); | |
183 | m_eventModelFilter->setFilterEndDate( m_theWeekBeforeLastSpan.timespan.second ); | |
184 | m_eventModelFilter->events(); | |
185 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
186 | // Last week | |
187 | m_eventModelFilter->setFilterStartDate( m_lastWeekSpan.timespan.first ); | |
188 | m_eventModelFilter->setFilterEndDate( m_lastWeekSpan.timespan.second ); | |
189 | m_eventModelFilter->events(); | |
190 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
191 | // This week | |
192 | m_eventModelFilter->setFilterStartDate( m_thisWeekSpan.timespan.first ); | |
193 | m_eventModelFilter->setFilterEndDate( m_thisWeekSpan.timespan.second ); | |
194 | m_eventModelFilter->events(); | |
195 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
196 | ||
197 | m_referenceModel->clearEvents(); | |
198 | } | |
199 | ||
200 | void EventModelFilterTests::checkDaysFilter() | |
201 | { | |
202 | Event event1, event2, event3; | |
203 | QDateTime time = QDateTime::currentDateTime(); | |
204 | time.setDate( m_dayBeforeYesterdaySpan.timespan.first ); | |
205 | event1.setId( 1 ); | |
206 | event1.setComment( "event1" ); | |
207 | event1.setTaskId( 1000 ); | |
208 | event1.setStartDateTime( time ); | |
209 | event1.setEndDateTime( time.addSecs( 3600 ) ); | |
210 | ||
211 | time.setDate( m_yesterdaySpan.timespan.first ); | |
212 | event2.setId( 2 ); | |
213 | event2.setComment( "event2" ); | |
214 | event2.setTaskId( 1000 ); | |
215 | event2.setStartDateTime( time ); | |
216 | event2.setEndDateTime( time.addSecs( 3600 ) ); | |
217 | ||
218 | time.setDate( m_todaySpan.timespan.first ); | |
219 | event3.setId( 3 ); | |
220 | event3.setComment( "event3" ); | |
221 | event3.setTaskId( 1000 ); | |
222 | event3.setStartDateTime( time ); | |
223 | event3.setEndDateTime( time.addSecs( 3600 ) ); | |
224 | ||
225 | EventList events; | |
226 | events << event1 << event2 << event3; | |
227 | m_referenceModel->setAllEvents( events ); | |
228 | ||
229 | // The day before yesterday | |
230 | m_eventModelFilter->setFilterStartDate( m_dayBeforeYesterdaySpan.timespan.first ); | |
231 | m_eventModelFilter->setFilterEndDate( m_dayBeforeYesterdaySpan.timespan.second ); | |
232 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
233 | // Yesterday | |
234 | m_eventModelFilter->setFilterStartDate( m_yesterdaySpan.timespan.first ); | |
235 | m_eventModelFilter->setFilterEndDate( m_yesterdaySpan.timespan.second ); | |
236 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
237 | // Today | |
238 | m_eventModelFilter->setFilterStartDate( m_todaySpan.timespan.first ); | |
239 | m_eventModelFilter->setFilterEndDate( m_todaySpan.timespan.second ); | |
240 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
241 | ||
242 | // Ever (all events) | |
243 | m_eventModelFilter->setFilterStartDate( m_everSpan.timespan.first ); | |
244 | m_eventModelFilter->setFilterEndDate( m_everSpan.timespan.second ); | |
245 | m_eventModelFilter->events(); | |
246 | QVERIFY( m_eventModelFilter->events().count() == 3 ); | |
247 | ||
248 | m_referenceModel->clearEvents(); | |
249 | } | |
250 | ||
251 | void EventModelFilterTests::checkEventSpanOver2Weeks() | |
252 | { | |
253 | Event event1; | |
254 | QDateTime time = QDateTime::currentDateTime(); | |
255 | time.setDate( m_theWeekBeforeLastSpan.timespan.first ); | |
256 | event1.setId( 1 ); | |
257 | event1.setComment( "event1" ); | |
258 | event1.setTaskId( 1000 ); | |
259 | event1.setStartDateTime( time ); | |
260 | event1.setEndDateTime( time.addDays( 8 ) ); | |
261 | ||
262 | EventList events; | |
263 | events << event1; | |
264 | m_referenceModel->setAllEvents( events ); | |
265 | ||
266 | // Check the week before last week and last week | |
267 | m_eventModelFilter->setFilterStartDate( m_theWeekBeforeLastSpan.timespan.first ); | |
268 | m_eventModelFilter->setFilterEndDate( m_theWeekBeforeLastSpan.timespan.second ); | |
269 | m_eventModelFilter->events(); | |
270 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
271 | ||
272 | m_eventModelFilter->setFilterStartDate( m_lastWeekSpan.timespan.first ); | |
273 | m_eventModelFilter->setFilterEndDate( m_lastWeekSpan.timespan.second ); | |
274 | m_eventModelFilter->events(); | |
275 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
276 | ||
277 | m_referenceModel->clearEvents(); | |
278 | } | |
279 | ||
280 | void EventModelFilterTests::checkEventSpanOver2Days() | |
281 | { | |
282 | Event event1; | |
283 | QDateTime time = QDateTime::currentDateTime(); | |
284 | time.setDate( m_dayBeforeYesterdaySpan.timespan.first ); | |
285 | event1.setId( 1 ); | |
286 | event1.setComment( "event1" ); | |
287 | event1.setTaskId( 1000 ); | |
288 | event1.setStartDateTime( time ); | |
289 | event1.setEndDateTime( time.addDays( 1 ) ); | |
290 | ||
291 | EventList events; | |
292 | events << event1; | |
293 | m_referenceModel->setAllEvents( events ); | |
294 | ||
295 | // check the day before yesterday and yesterday | |
296 | m_eventModelFilter->setFilterStartDate( m_dayBeforeYesterdaySpan.timespan.first ); | |
297 | m_eventModelFilter->setFilterEndDate( m_dayBeforeYesterdaySpan.timespan.second ); | |
298 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
299 | ||
300 | m_eventModelFilter->setFilterStartDate( m_yesterdaySpan.timespan.first ); | |
301 | m_eventModelFilter->setFilterEndDate( m_yesterdaySpan.timespan.second ); | |
302 | QVERIFY( m_eventModelFilter->events().count() == 1 ); | |
303 | ||
304 | m_referenceModel->clearEvents(); | |
305 | } | |
306 | ||
307 | QTEST_MAIN( EventModelFilterTests ) | |
308 | ||
309 | #include "moc_EventModelFilterTests.cpp" |
0 | /* | |
1 | EventModelFilterTests.h | |
2 | ||
3 | This file is part of Charm, a task-based time tracking application. | |
4 | ||
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | ||
7 | Author: Michel Boyer de la Giroday <michel.giroday@kdab.com> | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation, either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | */ | |
22 | ||
23 | #ifndef EVENTMODELFILTERTESTS | |
24 | #define EVENTMODELFILTERTESTS | |
25 | ||
26 | #include <QObject> | |
27 | ||
28 | #include "Core/TimeSpans.h" | |
29 | ||
30 | class CharmDataModel; | |
31 | class EventModelFilter; | |
32 | ||
33 | class EventModelFilterTests : public QObject | |
34 | { | |
35 | Q_OBJECT | |
36 | ||
37 | public: | |
38 | EventModelFilterTests(); | |
39 | ||
40 | private slots: | |
41 | void initTestCase(); | |
42 | void checkYearsFilter(); | |
43 | void checkMonthsFilter(); | |
44 | void checkWeeksFilter(); | |
45 | void checkDaysFilter(); | |
46 | void checkEventSpanOver2Weeks(); | |
47 | void checkEventSpanOver2Days(); | |
48 | ||
49 | private: | |
50 | CharmDataModel* m_referenceModel = nullptr; | |
51 | EventModelFilter* m_eventModelFilter; | |
52 | ||
53 | NamedTimeSpan m_thisYearSpan; | |
54 | NamedTimeSpan m_theMonthBeforeLastSpan; | |
55 | NamedTimeSpan m_lastMonthSpan; | |
56 | NamedTimeSpan m_thisMonthSpan; | |
57 | NamedTimeSpan m_theWeekBeforeLastSpan; | |
58 | NamedTimeSpan m_lastWeekSpan; | |
59 | NamedTimeSpan m_thisWeekSpan; | |
60 | NamedTimeSpan m_dayBeforeYesterdaySpan; | |
61 | NamedTimeSpan m_yesterdaySpan; | |
62 | NamedTimeSpan m_todaySpan; | |
63 | NamedTimeSpan m_everSpan; | |
64 | }; | |
65 | ||
66 | #endif // EVENTMODELFILTERTESTS | |
67 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2012-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2012-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | |
33 | 33 | Q_OBJECT |
34 | 34 | public: |
35 | 35 | SqLiteStorageTests(); |
36 | ~SqLiteStorageTests(); | |
36 | ~SqLiteStorageTests() override; | |
37 | 37 | |
38 | 38 | private: |
39 | 39 | StorageInterface* m_storage; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
39 | 39 | |
40 | 40 | TestApplication::TestApplication(const QString &databasePath, QObject *parent) |
41 | 41 | : QObject(parent) |
42 | , m_controller( nullptr ) | |
43 | , m_model( nullptr ) | |
44 | 42 | , m_configuration( &Configuration::instance() ) |
45 | 43 | , m_localPath( databasePath ) |
46 | 44 | { |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
48 | 48 | QString databasePath() const; |
49 | 49 | |
50 | 50 | private: |
51 | Controller* m_controller; | |
52 | CharmDataModel* m_model; | |
51 | Controller* m_controller = nullptr; | |
52 | CharmDataModel* m_model = nullptr; | |
53 | 53 | Configuration* m_configuration; |
54 | 54 | QString m_localPath; |
55 | 55 | }; |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Franck Arrecot <franck.arrecot@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2015-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2015-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Franck Arrecot <franck.arrecot@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2012-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 | |
23 | 23 | #include "TimeSpanTests.h" |
24 | 24 | #include "Core/TimeSpans.h" |
25 | 25 | #include <QtTest/QtTest> |
26 | ||
27 | #include <QDebug> | |
28 | 26 | |
29 | 27 | void TimeSpanTests::testTimeSpans() |
30 | 28 | { |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2012-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2012-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2010-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2010-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Frank Osterfeld <frank.osterfeld@kdab.com> |
74 | 74 | QDomDocument document( "testdocument" ); |
75 | 75 | Q_FOREACH( const Event& event, eventsToTest ) { |
76 | 76 | QDomElement element = event.toXml( document ); |
77 | // // temp: | |
78 | // document.appendChild( element ); | |
79 | // qDebug() << document.toString( 4 ); | |
80 | // // ^^^ | |
77 | ||
81 | 78 | try { |
82 | 79 | Event readEvent = Event::fromXml( element ); |
83 | 80 | // the extra tests are mostly to immidiately see what is wrong: |
176 | 173 | } |
177 | 174 | QVERIFY( tasks == result ); |
178 | 175 | } catch( const XmlSerializationException& e ) { |
179 | qDebug() << "Failure reading tasks:" << e.what(); | |
176 | qCritical() << "Failure reading tasks:" << e.what(); | |
180 | 177 | QFAIL( "Read tasks are not equal to the written ones" ); |
181 | 178 | } |
182 | 179 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2007-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2007-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2009-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2009-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2009-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2009-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2009-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2009-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2009-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2009-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 | Author: Sebastian Sauer <sebastian.sauer@kdab.com> |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
2 | 2 | |
3 | 3 | This file is part of Charm, a task-based time tracking application. |
4 | 4 | |
5 | Copyright (C) 2008-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
5 | Copyright (C) 2008-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | |
6 | 6 | |
7 | 7 | Author: Mirko Boehm <mirko.boehm@kdab.com> |
8 | 8 |
0 | 0 | Format: 1.0 |
1 | 1 | Source: charmtimetracker |
2 | Version: 1.9.0 | |
2 | Version: 1.10.0 | |
3 | 3 | Binary: charmtimetracker |
4 | 4 | Maintainer: Frank Osterfeld <frank.osterfeld@kdab.com> |
5 | 5 | Architecture: any |
6 | 6 | Build-Depends: debhelper (>= 4.1.16), cdbs, cmake, libqt4-dev, libxss-dev, libqt4-sql-sqlite |
7 | Files: | |
8 | 00000000000000000000000000000000 00000 charmtimetracker-1.9.0.tar.gz | |
7 | Files: | |
8 | 00000000000000000000000000000000 00000 charmtimetracker-1.10.0.tar.gz |
0 | 0 | Name: charmtimetracker |
1 | Version: 1.9.0 | |
1 | Version: 1.10.0 | |
2 | 2 | Release: 0 |
3 | 3 | Summary: Time Tracking Application |
4 | 4 | Source: %{name}-%{version}.tar.gz |
66 | 66 | %{_prefix}/bin/charmtimetracker |
67 | 67 | |
68 | 68 | %changelog |
69 | * Mon Oct 05 2015 Allen Winter <allen.winter@kdab.com> 1.10.0 | |
70 | - 1.10.0 release | |
69 | 71 | * Thu Mar 26 2015 Allen Winter <allen.winter@kdab.com> 1.9.0 |
70 | 72 | - 1.9.0 release |
71 | 73 | * Tue Jul 02 2013 Kevin Ottens <kevin.ottens@kdab.com> 1.8.0 |
0 | charmtimetracker (1.10.0) stable; urgency=low | |
1 | ||
2 | * 1.10.0 release | |
3 | ||
4 | -- Allen Winter <allen.winter@kdab.com> Mon, 05 Oct 2015 13:30:00 -0500 | |
5 | ||
6 | ||
0 | 7 | charmtimetracker (1.9.0) stable; urgency=low |
1 | 8 | |
2 | 9 | * 1.9.0 release |
3 | 10 | |
4 | 11 | -- Allen Winter <allen.winter@kdab.com> Thu, 26 Mar 2015 10:30:00 -0500 |
5 | 12 | |
6 | ||
13 | ||
7 | 14 | charmtimetracker (1.8.0) stable; urgency=low |
8 | 15 | |
9 | 16 | * 1.8.0 release |