Codebase list charmtimetracker / 16712c1
Imported Upstream version 1.11.1 Sandro Knauß 8 years ago
272 changed file(s) with 2212 addition(s) and 1800 deletion(s). Raw diff Collapse all Expand all
99 EXTRA camelcase,null,defines,crud
1010
1111 #skip Keychain
12 SKIP /Charm/Keychain/
12 SKIP /Charm/Keychain/keychain
1313 #if you have a build subdir, skip it
1414 SKIP /build-
1515
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"
2727 SET( CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE )
2828 ENDIF()
2929
30 IF( APPLE AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local" )
30 IF( APPLE AND CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" )
3131 SET( CMAKE_INSTALL_PREFIX "/Applications" )
3232 ENDIF()
3333
3636 CMAKE_MINIMUM_REQUIRED( VERSION 2.6.0 )
3737 SET( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" )
3838
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()
4245
4346 SET( CMAKE_AUTOMOC ON )
4447
4851 IF( NOT CHARM_FORCE_QT4 )
4952 find_package( Qt5Core QUIET )
5053 ENDIF()
54
55 set(QTKEYCHAIN_SYSTEM OFF)
5156
5257 IF(Qt5Core_FOUND)
5358 find_package(Qt5Widgets REQUIRED)
5560 find_package(Qt5Network REQUIRED)
5661 find_package(Qt5Sql REQUIRED)
5762 find_package(Qt5Test REQUIRED)
63 find_package(Qt5Script REQUIRED)
64 if(WIN32)
65 find_package(Qt5WinExtras REQUIRED)
66 endif()
5867
5968 find_package(Qt5PrintSupport)
6069 IF(Qt5PrintSupport_FOUND)
6271 set(QTPRINT_LIBRARIES ${Qt5PrintSupport_LIBRARIES})
6372 ENDIF()
6473
74 find_package(Qt5Keychain QUIET)
75
76 IF(Qt5Keychain_FOUND)
77 set(QTKEYCHAIN_SYSTEM ON)
78 ENDIF()
79
6580 SET(CHARM_MAC_HIGHRES_SUPPORT_ENABLED ON)
6681
6782 IF(WIN32)
68 SET(QT_PLATFORM_SPECIFIC_LIBRARIES Qt5::WinMain)
83 SET(QT_PLATFORM_SPECIFIC_LIBRARIES Qt5::WinMain Qt5::WinExtras)
6984 ELSE()
7085 SET(QT_PLATFORM_SPECIFIC_LIBRARIES)
7186 ENDIF()
107122 set(QT_QTTEST_LIBRARY ${Qt5Test_LIBRARIES})
108123
109124 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}
117133 ${QT_PLATFORM_SPECIFIC_LIBRARIES}
118134 )
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()
129138 ELSE()
130139 # 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)
132141 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()
133149
134150 SET(CHARM_MAC_HIGHRES_SUPPORT_ENABLED OFF)
135151
151167 endmacro()
152168 ENDIF()
153169
154 include_directories(${QT_INCLUDES})
170 include_directories(${QT_INCLUDES} ${QTKEYCHAIN_INCLUDE_DIRS})
155171 #set(QTCORE_LIBRARIES ${QT_QTCORE_LIBRARY})
156172
157173 macro(qt_wrap_cpp)
188204
189205 IF( CMAKE_COMPILER_IS_GNUCXX )
190206 # 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()
197213 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()
200218 ENDIF()
201219
202220
203221 IF( UNIX AND NOT APPLE )
204222 set( Charm_EXECUTABLE charmtimetracker )
205 SET( BIN_INSTALL_DIR bin )
206 SET( DOC_INSTALL_DIR share/doc/${Charm_EXECUTABLE} )
207223 ELSE()
208224 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 . )
210233 SET( DOC_INSTALL_DIR . )
211234 ENDIF()
212 SET( ICONS_DIR "${CMAKE_SOURCE_DIR}/Charm/Icons" )
213235
214236 OPTION( CHARM_IDLE_DETECTION "Build the Charm idle detector" ON )
215237 OPTION( CHARM_TIMESHEET_TOOLS "Build the Charm timesheet tools" OFF )
220242 OPTION( CHARM_CI_TCPSERVER "Build Charm with TCP command interface support" ON )
221243 OPTION( CHARM_CI_LOCALSERVER "Build Charm with local socket command interface support" ON )
222244 ENDIF()
245
246 OPTION(CHARM_PREPARE_DEPLOY "Deploy dependencies with install target(Windows, Apple)" ON)
223247
224248 ADD_SUBDIRECTORY( Core )
225249 ADD_SUBDIRECTORY( Charm )
0 License.txt
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
2525 #include "CharmCMake.h"
2626 #include "Data.h"
2727 #include "ViewHelpers.h"
28 #include "Uniquifier.h"
2928
3029 #include "Core/CharmConstants.h"
3130 #include "Core/CharmExceptions.h"
3534 #include "Idle/IdleDetector.h"
3635 #include "Widgets/ConfigurationDialog.h"
3736 #include "Widgets/NotificationPopup.h"
37 #include "Widgets/TasksView.h"
3838
3939 #include <QDir>
4040 #include <QTimer>
4747 #include <QFile>
4848 #include <QApplication>
4949
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)
5155 #include <QDesktopServices>
5256 #else
5357 #include <QStandardPaths>
5458 #endif
5559
60 #ifdef Q_OS_WIN
61 #include <windows.h>
62 #include <winuser.h>
63 #endif
64
5665 #include <algorithm>
5766 #include <functional>
67 #include <iostream>
5868
5969 #ifdef CHARM_CI_SUPPORT
6070 # include "CI/CharmCommandInterface.h"
6272
6373 ApplicationCore* ApplicationCore::m_instance = nullptr;
6474
65 ApplicationCore::ApplicationCore( QObject* parent )
75 ApplicationCore::ApplicationCore(TaskId startupTask, QObject* parent )
6676 : QObject( parent )
67 , m_closedWindow( nullptr )
6877 , m_actionStopAllTasks( this )
69 , m_windows( QList<CharmWindow*> () << &m_tasksWindow << &m_eventWindow << &m_timeTracker )
7078 , m_actionQuit( this )
71 , m_state(Constructed)
7279 , m_systrayContextMenuStartTask( m_timeTracker.menu()->title() )
7380 , m_actionAboutDialog( this )
7481 , m_actionPreferences( this )
8289 , m_actionActivityReport( this )
8390 , m_actionWeeklyTimesheetReport( this )
8491 , 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
9097 , m_dateChangeWatcher( new DateChangeWatcher( this ) )
9198 {
9299 // QApplication setup
100107
101108 QLocalSocket uniqueApplicationSocket;
102109 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 }
103116 #ifndef NDEBUG
104117 serverName.append( "_debug" );
105118 #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 }
108129 throw AlreadyRunningException();
130 }
109131
110132 connect(&m_uniqueApplicationServer, SIGNAL(newConnection()),
111133 this, SLOT(slotHandleUniqueApplicationConnection()));
128150 slotControllerReadyToQuit()));
129151
130152 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
149173 // my own signals:
150174 connect(this, SIGNAL(goToState(State)), SLOT(setState(State)),
151175 Qt::QueuedConnection);
156180 m_actionStopAllTasks.setShortcutContext( Qt::ApplicationShortcut );
157181 mainView().addAction(&m_actionStopAllTasks); // for the shortcut to work
158182 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() );
162184 m_systrayContextMenu.addSeparator();
163185 m_systrayContextMenu.addAction( &m_actionStopAllTasks );
164186 m_systrayContextMenu.addSeparator();
170192
171193 QApplication::setWindowIcon( Data::charmIcon() );
172194
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
177200
178201 m_systrayContextMenu.addSeparator();
179202 m_systrayContextMenu.addMenu( &m_systrayContextMenuStartTask );
276299 void ApplicationCore::slotHandleUniqueApplicationConnection()
277300 {
278301 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 }
279313 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 }
301335 }
302336
303337 void ApplicationCore::createWindowMenu( QMenuBar *menuBar )
304338 {
305339 auto menu = new QMenu( menuBar );
306340 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") ) );
310345 menu->addSeparator();
311346 menu->addAction( &m_actionEnterVacation );
312347 menu->addSeparator();
357392 menuBar->addMenu( menu );
358393 }
359394
395 CharmWindow &ApplicationCore::mainView()
396 {
397 return m_timeTracker;
398 }
399
360400 void ApplicationCore::setState(State state)
361401 {
362402 if (m_state == state)
395435 };
396436
397437 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 }
401441
402442 switch (m_state)
403443 {
555595
556596 void ApplicationCore::enterConnectedState()
557597 {
598 if ( m_startupTask != -1) {
599 m_timeTracker.slotStartEvent( m_startupTask );
600 }
601 #ifdef Q_OS_WIN
602 updateTaskList();
603 #endif
558604 #ifdef CHARM_CI_SUPPORT
559605 m_cmdInterface->start();
560606 #endif
599645 const QByteArray charmHome = qgetenv("CHARM_HOME");
600646 if ( !charmHome.isEmpty() )
601647 return QFile::decodeName( charmHome ) + QLatin1String("/data/");
602 #if QT_VERSION < 0x050000
648 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
603649 return QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1Char('/');
604650 #else
605651 return QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/');
665711 return true;
666712 }
667713
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
702714 QString ApplicationCore::titleString( const QString& text ) const
703715 {
704716 QString dbInfo;
756768 m_cmdInterface->configurationChanged();
757769 #endif
758770 }
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 }
761774 }
762775
763776 ModelConnector& ApplicationCore::model()
788801 void ApplicationCore::slotMaybeIdle()
789802 {
790803 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() );
794805 }
795806 // there are four parameters to the idle property:
796807 // - the initial start time of the currently active event(s)
805816 // it
806817 }
807818
808 CharmWindow& ApplicationCore::mainView()
809 {
810 return m_timeTracker;
811 }
812
813819 TrayIcon& ApplicationCore::trayIcon()
814820 {
815821 return m_trayIcon;
816822 }
817823
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
822839 }
823840
824841 void ApplicationCore::saveState( QSessionManager & manager )
832849 // Before QApplication closes all windows, save their state.
833850 // Doing this in saveState is too late because then we would store that they are all hidden.
834851 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 }
838855 }
839856 }
840857
848865 }
849866 }
850867
868 void ApplicationCore::slotShowTasksEditor()
869 {
870 m_tasksView.show();
871 }
872
873 void ApplicationCore::slotShowEventEditor()
874 {
875 m_eventView.show();
876 }
877
851878 #include "moc_ApplicationCore.cpp"
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3636 #include "Core/Controller.h"
3737 #include "Core/Configuration.h"
3838 #include "Core/StorageInterface.h"
39 #include "Core/ViewInterface.h"
3940
4041 #include "Widgets/CharmWindow.h"
41 #include "Widgets/TasksWindow.h"
42 #include "Widgets/EventWindow.h"
42 #include "Widgets/EventView.h"
4343 #include "Widgets//TimeTrackingWindow.h"
44 #include "Widgets/TasksView.h"
4445 #include "Widgets/TrayIcon.h"
4546
4647 #include "ModelConnector.h"
5051 class CharmCommandInterface;
5152 class IdleDetector;
5253 class QSessionManager;
54 class QWinJumpList;
5355
5456 class ApplicationCore : public QObject
5557 {
5658 Q_OBJECT
5759
5860 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;
6167
6268 static ApplicationCore& instance();
6369 static bool hasInstance();
8995
9096 TrayIcon& trayIcon();
9197
98 void updateTaskList();
99
92100 public slots:
101 void showMainWindow( ShowMode mode = ShowMode::Show );
102
93103 void setState( State state );
94104 void slotStopAllTasks();
95105 void slotQuitApplication();
96106 void slotControllerReadyToQuit();
97107 void slotSaveConfiguration();
98108 void slotGoToConnectedState();
99 void toggleShowHide();
100109 void setHttpActionsVisible( bool visible );
101110 void saveState( QSessionManager & manager );
102111 void commitData( QSessionManager & manager );
103112
104113 private slots:
105 // void slotMainWindowVisibilityChanged( bool );
106 // void slotTimeTrackerVisibilityChanged( bool );
107114 void slotCurrentBackendStatusChanged( const QString& text );
108115 void slotMaybeIdle();
109 void slotCharmWindowVisibilityChanged( bool visibility );
110116 void slotHandleUniqueApplicationConnection();
111117 void slotStartTaskMenuAboutToShow();
112118 void slotShowNotification( const QString& title, const QString& message );
119 void slotShowTasksEditor();
120 void slotShowEventEditor();
113121
114122 signals:
115123 void goToState( State state );
116124
117125 protected:
118 void openAWindow( bool raise = false );
119
120 CharmWindow* m_closedWindow;
121126 QAction m_actionStopAllTasks;
122 const QList<CharmWindow*> m_windows;
123127 TimeTrackingWindow m_timeTracker;
124128 QAction m_actionQuit;
125129
141145 void enterShuttingDownState();
142146 void leaveShuttingDownState();
143147
144 State m_state;
148 State m_state = Constructed;
145149 ModelConnector m_model;
146150 Controller m_controller;
147151 TrayIcon m_trayIcon;
159163 QAction m_actionActivityReport;
160164 QAction m_actionWeeklyTimesheetReport;
161165 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;
169171 QLocalServer m_uniqueApplicationServer;
172 TaskId m_startupTask;
173 #ifdef Q_OS_WIN
174 QWinJumpList* m_windowsJumpList = nullptr;
175 #endif
170176
171177 // All statics are created as members of Application. This is
172178 // supposed to help on Windows, where constructors for statics
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Guillermo A. Amaral <gamaral@kdab.com>
88
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 )
4949 Widgets/EventEditor.cpp
5050 Widgets/EventEditorDelegate.cpp
5151 Widgets/EventView.cpp
52 Widgets/EventWindow.cpp
5352 Widgets/ExpandStatesHelper.cpp
5453 Widgets/HttpJobProgressDialog.cpp
5554 Widgets/IdleCorrectionDialog.cpp
6362 Widgets/TaskEditor.cpp
6463 Widgets/TasksView.cpp
6564 Widgets/TasksViewDelegate.cpp
66 Widgets/TasksWindow.cpp
6765 Widgets/TimeTrackingView.cpp
6866 Widgets/TimeTrackingWindow.cpp
6967 Widgets/TimeTrackingTaskSelector.cpp
7270 Widgets/WeeklyTimesheet.cpp
7371 Widgets/NotificationPopup.cpp
7472 Widgets/FindAndReplaceEventsDialog.cpp
73 Widgets/WidgetUtils.cpp
7574 )
7675
7776 SET(CharmApplication_LIBS)
9695 ELSEIF( WIN32 )
9796 LIST( APPEND CharmApplication_SRCS Idle/WindowsIdleDetector.cpp )
9897 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()
106110 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()
108121 ENDIF()
109122 ENDIF()
110123 ENDIF()
111124
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()
135149 ENDIF()
136150
137151 QT_WRAP_UI(
161175 CharmApplication STATIC
162176 ${CharmApplication_SRCS} ${UiGenerated_SRCS}
163177 )
164 TARGET_LINK_LIBRARIES(CharmApplication ${CharmApplication_LIBS})
178 TARGET_LINK_LIBRARIES(CharmApplication ${CharmApplication_LIBS} ${QT_LIBRARIES})
165179
166180 SET( Charm_SRCS Charm.cpp )
167181
186200 FILE( COPY ${ICON} DESTINATION ${RESOURCES} )
187201 ENDIF()
188202
189 IF( MSVC )
203 IF(WIN32)
190204 SET( Resources_SRCS ${Resources_SRCS} Charm.rc )
191205 ENDIF()
192206
216230 )
217231
218232 # 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 )
220234 IF( CMAKE_BUILD_TYPE MATCHES "^([Dd][Ee][Bb][Uu][Gg])" )
221235 SET( CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY TRUE )
222236 ENDIF()
248262 # Deploy qsqlite plugin
249263 GET_TARGET_PROPERTY( _loc Qt5::QSQLiteDriverPlugin LOCATION )
250264 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()
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Mike McQuaid <mike.mcquaid@kdab.com>
3636 #include "Core/CharmExceptions.h"
3737 #include "CharmCMake.h"
3838
39 static std::shared_ptr<ApplicationCore> createApplicationCore()
39 static std::shared_ptr<ApplicationCore> createApplicationCore( TaskId startupTask )
4040 {
4141 #ifdef Q_OS_OSX
42 return std::make_shared<MacApplicationCore>();
42 return std::make_shared<MacApplicationCore>( startupTask );
4343 #else
44 return std::make_shared<ApplicationCore>();
44 return std::make_shared<ApplicationCore>( startupTask );
4545 #endif
4646 }
4747
5353
5454 int main ( int argc, char** argv )
5555 {
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 }
6070 }
6171
6272 const QByteArray charmHomeEnv = qgetenv("CHARM_HOME");
6878 QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, user );
6979 QSettings::setPath( QSettings::NativeFormat, QSettings::SystemScope, sys );
7080 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
7185 }
7286
7387 try {
88 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
89 QGuiApplication::setAttribute( Qt::AA_EnableHighDpiScaling );
90 #endif
7491 QApplication app( argc, argv );
75 const std::shared_ptr<ApplicationCore> core( createApplicationCore() );
92 const std::shared_ptr<ApplicationCore> core( createApplicationCore( startupTask ) );
7693 QObject::connect( &app, SIGNAL(commitDataRequest(QSessionManager&)), core.get(), SLOT(commitData(QSessionManager&)) );
7794 QObject::connect( &app, SIGNAL(saveStateRequest(QSessionManager&)), core.get(), SLOT(saveState(QSessionManager&)) );
7895 return app.exec();
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
2828 CommandAddTask::CommandAddTask( const Task& task, QObject* parent )
2929 : CharmCommand( tr("Add Task"), parent )
3030 , m_task( task )
31 , m_success( false )
3231 {
3332 }
3433
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3333
3434 public:
3535 explicit CommandAddTask( const Task&, QObject* parent = nullptr );
36 ~CommandAddTask();
36 ~CommandAddTask() override;
3737
3838 bool prepare() override;
3939 bool execute( ControllerInterface* ) override;
4141
4242 private:
4343 Task m_task;
44 bool m_success;
44 bool m_success = false;
4545 };
4646
4747 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
4040
4141 bool CommandDeleteEvent::execute( ControllerInterface* controller )
4242 {
43 qDebug() << "CommandDeleteEvent::execute: deleting:";
44 m_event.dump();
4543 return controller->deleteEvent( m_event );
4644 }
4745
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3333
3434 public:
3535 explicit CommandDeleteEvent( const Event&, QObject* parent = nullptr );
36 ~CommandDeleteEvent();
36 ~CommandDeleteEvent() override;
3737
3838 bool prepare() override;
3939 bool execute( ControllerInterface* ) override;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3030 CommandDeleteTask::CommandDeleteTask( const Task& task, QObject* parent )
3131 : CharmCommand( tr("Delete Task"), parent )
3232 , m_task( task )
33 , m_success( false )
3433 {
3534 }
3635
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3333
3434 public:
3535 explicit CommandDeleteTask( const Task&, QObject* parent = nullptr );
36 ~CommandDeleteTask();
36 ~CommandDeleteTask() override;
3737
3838 bool prepare() override;
3939 bool execute( ControllerInterface* ) override;
4141
4242 private:
4343 Task m_task;
44 bool m_success;
44 bool m_success = false;
4545 };
4646
4747 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3232
3333 CommandExportToXml::CommandExportToXml( QString filename, QObject* parent )
3434 : CharmCommand( tr("Export to XML"), parent )
35 , m_error( false )
3635 , m_filename( filename )
3736 {
3837 }
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
3232 Q_OBJECT
3333 public:
3434 explicit CommandExportToXml( QString filename, QObject* parent );
35 ~CommandExportToXml();
35 ~CommandExportToXml() override;
3636
3737 bool prepare() override;
3838 bool execute( ControllerInterface* ) override;
3939 bool finalize() override;
4040
4141 private:
42 bool m_error;
42 bool m_error = false;
4343 QString m_errorString;
4444 QString m_filename;
4545 };
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
3232 Q_OBJECT
3333 public:
3434 explicit CommandImportFromXml( QString filename, QObject* parent );
35 ~CommandImportFromXml();
35 ~CommandImportFromXml() override;
3636
3737 bool prepare() override;
3838 bool execute( ControllerInterface* ) override;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
3535
3636 public:
3737 explicit CommandMakeAndActivateEvent( const Task&, QObject* parent );
38 ~CommandMakeAndActivateEvent();
38 ~CommandMakeAndActivateEvent() override;
3939
4040 bool prepare() override;
4141 bool execute( ControllerInterface* ) override;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3030 CommandMakeEvent::CommandMakeEvent( const Task& task,
3131 QObject* parent )
3232 : CharmCommand( tr("Create Event"), parent )
33 , m_rollback( false )
3433 , m_task( task )
3534 {
3635 }
3837 CommandMakeEvent::CommandMakeEvent( const Event& event,
3938 QObject* parent )
4039 : CharmCommand( tr("Create Event"), parent )
41 , m_rollback( false )
4240 , m_event( event )
4341 {
4442 }
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
3636 public:
3737 explicit CommandMakeEvent( const Task& task, QObject* parent );
3838 explicit CommandMakeEvent( const Event& event, QObject* parent );
39 ~CommandMakeEvent();
39 ~CommandMakeEvent() override;
4040
4141 bool prepare() override;
4242 bool execute( ControllerInterface* ) override;
5050 void finishedOk( const Event& );
5151
5252 private:
53 bool m_rollback; //don't show the event in finalize
53 bool m_rollback = false; //don't show the event in finalize
5454 Task m_task; // the task the new event should be assigned to
5555 Event m_event; // the result, only valid after the event has been created
5656 };
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
4343
4444 bool CommandModifyEvent::execute( ControllerInterface* controller )
4545 {
46 // qDebug() << "CommandModifyEvent::execute: committing:";
47 // m_event.dump();
4846 return controller->modifyEvent( m_event );
4947 }
5048
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3333
3434 public:
3535 explicit CommandModifyEvent( const Event&, const Event&, QObject* parent = nullptr );
36 ~CommandModifyEvent();
36 ~CommandModifyEvent() override;
3737
3838 bool prepare() override;
3939 bool execute( ControllerInterface* ) override;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
2727 CommandModifyTask::CommandModifyTask( const Task& task, QObject* parent )
2828 : CharmCommand( tr("Edit Task"), parent )
2929 , m_task( task )
30 , m_success( false )
3130 {
3231 }
3332
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3333
3434 public:
3535 explicit CommandModifyTask( const Task&, QObject* parent = nullptr );
36 ~CommandModifyTask();
36 ~CommandModifyTask() override;
3737
3838 bool prepare() override;
3939 bool execute( ControllerInterface* ) override;
4141
4242 private:
4343 Task m_task;
44 bool m_success;
44 bool m_success = false;
4545 };
4646
4747 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
2828
2929 CommandRelayCommand::CommandRelayCommand( QObject* parent )
3030 : CharmCommand( tr("Relay"), parent )
31 , m_payload( 0 )
3231 { // as long as Charm is single-threaded, this does not do anything,
3332 // because there will be no repaint
3433 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
3636
3737 public:
3838 explicit CommandRelayCommand( QObject* parent );
39 ~CommandRelayCommand();
39 ~CommandRelayCommand() override;
4040
4141 void setCommand( CharmCommand* command );
4242
4646 bool finalize() override;
4747
4848 private:
49 CharmCommand* m_payload;
49 CharmCommand* m_payload = nullptr;
5050 };
5151
5252 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
2727 CommandSetAllTasks::CommandSetAllTasks( const TaskList& tasks, QObject* parent )
2828 : CharmCommand( tr("Import Tasks"), parent )
2929 , m_tasks( tasks )
30 , m_success( false )
3130 {
3231 }
3332
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
3232
3333 public:
3434 explicit CommandSetAllTasks( const TaskList&, QObject* parent );
35 ~CommandSetAllTasks();
35 ~CommandSetAllTasks() override;
3636
3737 bool prepare() override;
3838 bool execute( ControllerInterface* ) override;
4040
4141 private:
4242 TaskList m_tasks;
43 bool m_success;
43 bool m_success = false;
4444 };
4545
4646 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Mike McQuaid <mike.mcquaid@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
4343
4444 public:
4545 explicit EventModelAdapter( CharmDataModel* parent );
46 virtual ~EventModelAdapter();
46 ~EventModelAdapter() override;
4747
4848 int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
4949
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
2626 EventModelFilter::EventModelFilter( CharmDataModel* model, QObject* parent )
2727 : QSortFilterProxyModel( parent )
2828 , m_model( model )
29 , m_filterId()
3029 {
3130 setSourceModel( &m_model );
3231 setDynamicSortFilter( true );
8483 }
8584
8685 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 ) ) {
8891 return false;
8992 }
9093
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
4242
4343 public:
4444 explicit EventModelFilter( CharmDataModel*, QObject* parent = nullptr );
45 virtual ~EventModelFilter();
45 ~EventModelFilter() override;
4646
4747 /** Returns the total number of seconds of all events in the model. */
4848 int totalDuration() const;
7373 EventModelAdapter m_model;
7474 QDate m_start;
7575 QDate m_end;
76 TaskId m_filterId;
76 TaskId m_filterId = {};
7777 };
7878
7979 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
2929 #include <QSettings>
3030
3131 GUIState::GUIState()
32 : m_selectedTask( 0 )
33 , m_showExpired( false )
34 , m_showCurrents( false )
3532 {
3633 }
3734
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
5050
5151 private:
5252 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
5656 };
5757
5858 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Michel Boyer de la Giroday <michel.giroday@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Michel Boyer de la Giroday <michel.giroday@kdab.com>
88
4949 };
5050
5151 explicit CheckForUpdatesJob( QObject* parent=nullptr );
52 ~CheckForUpdatesJob();
52 ~CheckForUpdatesJob() override;
5353
5454 void start();
5555 void setUrl( const QUrl& url );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2929
3030 GetProjectCodesJob::GetProjectCodesJob(QObject* parent)
3131 : HttpJob(parent)
32 , m_verbose( true )
3332 {
3433 QSettings s;
3534 s.beginGroup(QLatin1String("httpconfig"));
5453 QNetworkReply *reply = manager->get(request);
5554
5655 if (reply->error() != QNetworkReply::NoError)
57 setErrorAndEmitFinished(SomethingWentWrong, reply->errorString());
56 setErrorFromReplyAndEmitFinished(reply);
5857 return true;
5958 }
6059
6261 {
6362 /* check for failure */
6463 if (reply->error() != QNetworkReply::NoError) {
65 setErrorAndEmitFinished(SomethingWentWrong, reply->errorString());
64 setErrorFromReplyAndEmitFinished(reply);
6665 return false;
6766 }
6867
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3333 public:
3434
3535 explicit GetProjectCodesJob(QObject* parent=nullptr);
36 ~GetProjectCodesJob();
36 ~GetProjectCodesJob() override;
3737
3838 QByteArray payload() const;
3939
5656 private:
5757 QByteArray m_payload;
5858 QUrl m_downloadUrl;
59 bool m_verbose;
59 bool m_verbose = true;
6060 };
6161
6262 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Pál Tóth <pal.toth@kdab.com>
88
6363 QNetworkReply *reply = manager->get(request);
6464
6565 if (reply->error() != QNetworkReply::NoError)
66 setErrorAndEmitFinished(SomethingWentWrong, reply->errorString());
66 setErrorFromReplyAndEmitFinished(reply);
6767 return true;
6868 }
6969
7272
7373 /* check for failure */
7474 if (reply->error() != QNetworkReply::NoError) {
75 setErrorAndEmitFinished(SomethingWentWrong, reply->errorString());
75 setErrorFromReplyAndEmitFinished(reply);
7676 return false;
7777 }
7878
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Pál Tóth <pal.toth@kdab.com>
88
2525
2626 #include "HttpJob.h"
2727 #include <QUrl>
28 #include <QDebug>
2928 #include <QVariant>
3029 #include <QVariantMap>
3130
3534 public:
3635
3736 explicit GetUserInfoJob(QObject* parent=nullptr, const QString &schema = " ");
38 ~GetUserInfoJob();
37 ~GetUserInfoJob() override;
3938
4039 QByteArray userInfo() const;
4140
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 Author: Olivier JG <olivier.de.gaalon@kdab.com>
2222 */
2323
2424 #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
2635
2736 #include <QNetworkAccessManager>
2837 #include <QNetworkReply>
7685 HttpJob::HttpJob(QObject* parent)
7786 : QObject(parent)
7887 , 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)
8688 {
8789 connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(handle(QNetworkReply*)));
8890 connect(m_networkManager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
261263 QNetworkReply *reply = manager->get(request);
262264
263265 if (reply->error() != QNetworkReply::NoError)
264 setErrorAndEmitFinished(SomethingWentWrong, reply->errorString());
266 setErrorFromReplyAndEmitFinished(reply);
265267 } return true;
266268
267269 case Login:
286288 QNetworkReply *reply = manager->post(request, encodedQueryPlusPlus);
287289
288290 if (reply->error() != QNetworkReply::NoError)
289 setErrorAndEmitFinished(SomethingWentWrong, reply->errorString());
291 setErrorFromReplyAndEmitFinished(reply);
290292
291293 } return true;
292294
300302 {
301303 // check for failure
302304 if (reply->error() != QNetworkReply::NoError) {
303 setErrorAndEmitFinished(SomethingWentWrong, reply->errorString());
305 setErrorFromReplyAndEmitFinished(reply);
304306 return false;
305307 }
306308
352354 emitFinished();
353355 }
354356
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
355365 #include "moc_HttpJob.cpp"
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4848 Canceled,
4949 NotConfigured,
5050 AuthenticationFailed,
51 SomethingWentWrong
51 SomethingWentWrong,
52 HostNotFound
5253 };
5354
5455 explicit HttpJob(QObject* parent=nullptr);
55 ~HttpJob();
56 ~HttpJob() override;
5657
5758 QString username() const;
5859 void setUsername(const QString &value);
105106 void emitFinished();
106107 void setErrorAndEmitFinished(int code, const QString& errorString);
107108 void delayedNext();
109 void setErrorFromReplyAndEmitFinished(QNetworkReply *reply);
108110
109111 static QString extractErrorMessageFromReply(const QByteArray& xml);
110112
123125 QNetworkAccessManager *m_networkManager;
124126 QString m_username;
125127 QString m_password;
126 int m_currentState;
127 int m_errorCode;
128 int m_currentState = Ready;
129 int m_errorCode = NoError;
128130 QString m_errorString;
129131 QUrl m_loginUrl;
130132 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;
134136 };
135137
136138 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 Author: Guillermo A. Amaral <gamaral@kdab.com>
109109 QNetworkReply *reply = manager->post(request, data);
110110
111111 if (reply->error() != QNetworkReply::NoError)
112 setErrorAndEmitFinished(SomethingWentWrong, reply->errorString());
113 return true;
112 setErrorFromReplyAndEmitFinished(reply);
113 return true;
114114 }
115115
116116 bool UploadTimesheetJob::handle(QNetworkReply *reply)
117117 {
118118 /* check for failure */
119119 if (reply->error() != QNetworkReply::NoError) {
120 setErrorAndEmitFinished(SomethingWentWrong, reply->errorString());
120 setErrorFromReplyAndEmitFinished(reply);
121121 return false;
122122 }
123123
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3333 public:
3434
3535 explicit UploadTimesheetJob(QObject* parent=nullptr);
36 ~UploadTimesheetJob();
36 ~UploadTimesheetJob() override;
3737
3838 QByteArray payload() const;
3939 void setPayload(const QByteArray &payload);
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Mike McQuaid <mike.mcquaid@kdab.com>
3737 IdleDetector::IdleDetector( QObject* parent )
3838 : QObject( parent )
3939 , m_idlenessDuration( CHARM_IDLE_TIME ) // from CharmCMake.h
40 , m_available( true )
4140 {
4241 }
4342
5251 return new WindowsIdleDetector( parent );
5352 #endif
5453
55 #ifdef CHARM_IDLE_DETECTION_AVAILABLE_X11
54 #ifdef CHARM_IDLE_DETECTION_AVAILABLE
5655 X11IdleDetector* detector = new X11IdleDetector( parent );
57 detector->setAvailable( X11IdleDetector::idleCheckPossible() );
56 detector->setAvailable( detector->idleCheckPossible() );
5857 return detector;
5958 #endif
6059 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
8181
8282 private:
8383 IdlePeriods m_idlePeriods;
84 int m_idlenessDuration;
85 bool m_available;
84 int m_idlenessDuration = 0;
85 bool m_available = true;
8686 };
8787
8888 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mike McQuaid <mike.mcquaid@kdab.com>
88
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
023 #include <Cocoa/Cocoa.h>
124
225 #include "MacIdleDetector.h"
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 Author: Mike McQuaid <mike.mcquaid@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Jesper Pedersen <jesper.pedersen@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
2626 #include "X11IdleDetector.h"
2727 #include "CharmCMake.h"
2828
29 //TODO for Qt5 port to XCB...
3029 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
3130 #include <QX11Info>
3231 #include <X11/Xlib.h>
3332 #include <X11/Xutil.h>
3433 #include <X11/extensions/scrnsaver.h>
34 #else
35 #include <xcb/screensaver.h>
3536 #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 }
3645
3746 bool X11IdleDetector::idleCheckPossible()
3847 {
4049 int event_base, error_base;
4150 if(XScreenSaverQueryExtension(QX11Info::display(), &event_base, &error_base))
4251 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;
4357 #endif
4458 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();
5359 }
5460
5561 void X11IdleDetector::onIdlenessDurationChanged()
6773 XScreenSaverQueryInfo(QX11Info::display(), QX11Info::appRootWindow(), _mit_info);
6874 const int idleSecs = _mit_info->idle / 1000;
6975 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
7084
7185 if (idleSecs >= idlenessDuration())
7286 maybeIdle( IdlePeriod(QDateTime::currentDateTime().addSecs( -idleSecs ),
7488
7589 if ( m_heartbeat.secsTo( QDateTime::currentDateTime() ) > idlenessDuration() )
7690 maybeIdle( IdlePeriod( m_heartbeat, QDateTime::currentDateTime() ) );
77 #endif
91
7892 m_heartbeat = QDateTime::currentDateTime();
7993 }
8094
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Jesper Pedersen <jesper.pedersen@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
2828
2929 #include <QTimer>
3030
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
3137 class X11IdleDetector : public IdleDetector
3238 {
3339 Q_OBJECT
3440 public:
3541 explicit X11IdleDetector( QObject* parent );
36 static bool idleCheckPossible();
42 bool idleCheckPossible();
3743
3844 protected:
3945 void onIdlenessDurationChanged();
4450 private:
4551 QDateTime m_heartbeat;
4652 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
4759 };
4860
4961
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
023 #include "gnomekeyring_p.h"
124
2 const char* GnomeKeyring::GNOME_KEYRING_DEFAULT = NULL;
25 const char* GnomeKeyring::GNOME_KEYRING_DEFAULT = 0;
326
427 bool GnomeKeyring::isAvailable()
528 {
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
225
326 #include <QLibrary>
427
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2929 {
3030 Q_OBJECT
3131 public:
32 explicit MacApplicationCore( QObject* parent = nullptr );
32 explicit MacApplicationCore( TaskId startupTask, QObject* parent = nullptr );
3333 ~MacApplicationCore();
3434 // This method to be public due to lack of friend classes in Objective-C and
3535 // 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
023 #include <Cocoa/Cocoa.h>
124
225 #include "MacApplicationCore.h"
97120 andEventID:kAEReopenApplication];
98121 }
99122
100 MacApplicationCore::MacApplicationCore( QObject* parent )
101 : ApplicationCore( parent )
123 MacApplicationCore::MacApplicationCore( TaskId startupTask, QObject* parent )
124 : ApplicationCore( startupTask, parent )
102125 , m_private( new MacApplicationCore::Private() )
103126 {
104127 m_private->dockIconClickEventHandler->macApplication = this;
107130 this, SLOT(handleStateChange(State)));
108131
109132 m_dockMenu.addAction( &m_actionStopAllTasks );
110 m_dockMenu.addSeparator();
111
112 Q_FOREACH( CharmWindow* window, m_windows )
113 m_dockMenu.addAction( window->showHideAction() );
114133
115134 m_dockMenu.addSeparator();
116135 m_dockMenu.addMenu( m_timeTracker.menu() );
118137
119138 // OSX doesn't use icons in menus
120139 QApplication::setWindowIcon( QIcon() );
121 Q_FOREACH( CharmWindow* window, m_windows )
122 window->setWindowIcon( QIcon() );
140 m_timeTracker.setWindowIcon( QIcon() );
123141 m_actionQuit.setIcon( QIcon() );
124142 QCoreApplication::setAttribute( Qt::AA_DontShowIconsInMenus );
125143 }
137155
138156 void MacApplicationCore::dockIconClickEvent()
139157 {
140 openAWindow();
158 showMainWindow();
141159 }
142160
143161 QList< QShortcut* > MacApplicationCore::shortcuts( QWidget* parent )
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
6969 void ModelConnector::commitCommand( CharmCommand* command )
7070 {
7171 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";
7575 }
7676 }
7777
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: David Faure <david.faure@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3131 #include <QDomDocument>
3232
3333 MonthlyTimesheetXmlWriter::MonthlyTimesheetXmlWriter()
34 : m_dataModel( nullptr )
35 , m_yearOfMonth ( 0 )
36 , m_monthNumber( 0 )
37 , m_numberOfWeeks( 0 )
38 , m_rootTask()
3934 {}
4035
4136 void MonthlyTimesheetXmlWriter::setDataModel( const CharmDataModel* dataModel )
167162 }
168163 }
169164
170 #if 0
171 qDebug() << "MonthlyTimeSheetReport::slotSaveToXml: generated XML:" << endl
172 << document.toString( 4 );
173 #endif
174
175165 return document.toByteArray( 4 );
176166 }
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4545 void setRootTask( TaskId rootTask );
4646
4747 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 = {};
5353 EventList m_events;
5454 };
5555
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2525 #include "Core/CharmDataModel.h"
2626
2727 TimeSheetInfo::TimeSheetInfo(int segments)
28 : indentation( 0 )
29 , seconds( segments )
30 , taskId( 0 )
31 , aggregated( false )
28 : seconds( segments )
3229 {
3330 seconds.fill( 0 );
3431 }
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
5050 QString formattedTaskIdAndName( int taskPaddingLength ) const;
5151
5252 // the level of indentation, >0 means the numbers are aggregated for the subtasks:
53 int indentation;
53 int indentation = 0;
5454 QString taskName;
5555 QVector<int> seconds;
56 TaskId taskId;
57 bool aggregated;
56 TaskId taskId = {};
57 bool aggregated = false;
5858 };
5959
6060 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3232 static const int DaysInWeek = 7;
3333
3434 WeeklyTimesheetXmlWriter::WeeklyTimesheetXmlWriter()
35 : m_dataModel( nullptr )
36 , m_year( 0 )
37 , m_weekNumber( 0 )
38 , m_rootTask()
3935 {
4036 }
4137
174170 }
175171 }
176172
177 // qDebug() << "WeeklyTimeSheetReport::slotSaveToXml: generated XML:" << endl
178 // << document.toString( 4 );
179 //
180173 return document.toByteArray( 4 );
181174 }
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4343 void setEvents( const EventList& events );
4444 void setRootTask( TaskId rootTask );
4545 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 = {};
5050 EventList m_events;
5151 };
5252
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
364364 return item.childCount() > 0;
365365 }
366366
367 TaskIdList TaskModelAdapter::childrenIds( const Task& task ) const
367 TaskList TaskModelAdapter::children( const Task& task ) const
368368 {
369369 const TaskTreeItem& item = m_dataModel->taskTreeItem( task.id() );
370 return item.childIds();
370 return item.children();
371371 }
372372
373373 bool TaskModelAdapter::taskIdExists( TaskId taskId ) const
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
6262
6363 public:
6464 explicit TaskModelAdapter( CharmDataModel* parent );
65 ~TaskModelAdapter();
65 ~TaskModelAdapter() override;
6666
6767 // reimplement QAbstractItemModel:
6868 int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
9999 bool taskIsActive( const Task& task ) const override;
100100 bool taskHasChildren( const Task& task ) const override;
101101 bool taskIdExists( TaskId taskId ) const override;
102 TaskIdList childrenIds( const Task& task ) const;
102 TaskList children( const Task& task ) const;
103103
104104 // reimplement CommandEmitterInterface:
105105 void commitCommand( CharmCommand* ) override;
106106
107107 signals:
108 void eventActivationNotice( EventId id );
109 void eventDeactivationNotice( EventId id );
108 void eventActivationNotice( EventId id ) override;
109 void eventDeactivationNotice( EventId id ) override;
110110
111111 private:
112112 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
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Nicholas Van Sickle <nicholas.vansickle@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Nicholas Van Sickle <nicholas.vansickle@kdab.com>
88
+0
-48
Charm/Uniquifier.h less more
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
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
9898 case Configuration::TaskPrefilter_ShowAll:
9999 break;
100100 case Configuration::TaskPrefilter_CurrentOnly: {
101 const bool ok = ( task.isCurrentlyValid() || hasValidChildren( task ) );
101 const bool ok = ( task.isCurrentlyValid() || checkChildren( task, HaveValidChild ) );
102102 accepted &= ok;
103103 break;
104104 }
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;
107108 break;
109 }
108110 case Configuration::TaskPrefilter_SubscribedAndCurrentOnly:
109 accepted &= ( task.subscribed() && task.isCurrentlyValid() );
111 accepted &= ( (task.subscribed() || checkChildren( task, HaveSubscribedChild ) ) && ( task.isCurrentlyValid() || checkChildren( task, HaveValidChild ) ) );
110112 break;
111113 default:
112114 break;
125127 return m_model.taskIdExists( taskId );
126128 }
127129
128 bool ViewFilter::hasValidChildren( Task task ) const
130 bool ViewFilter::checkChildren( Task task, CheckFor checkFor ) const
129131 {
130132 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() )
135136 return true;
136 }
137 else if ( checkFor == HaveValidChild && taskChild.isCurrentlyValid() )
138 return true;
137139 }
138140 }
139141 return false;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
4444 Q_OBJECT
4545 public:
4646 explicit ViewFilter( CharmDataModel*, QObject* parent = nullptr );
47 virtual ~ViewFilter();
47 ~ViewFilter() override;
4848
4949 // implement TaskModelInterface
5050 Task taskForIndex( const QModelIndex& ) const override;
6161 bool filterAcceptsRow( int row, const QModelIndex& parent ) const override;
6262
6363 signals:
64 void eventActivationNotice( EventId id );
65 void eventDeactivationNotice( EventId id );
64 void eventActivationNotice( EventId id ) override;
65 void eventDeactivationNotice( EventId id ) override;
6666
6767 private:
68 bool hasValidChildren(Task task) const;
68 enum CheckFor {
69 HaveValidChild,
70 HaveSubscribedChild
71 };
72
73 bool checkChildren( Task task, CheckFor checkFor ) const;
6974 TaskModelAdapter m_model;
7075 };
7176
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
9494 style.replace(QLatin1String("@alternate_row_background_color@"), palette.alternateBase().color().name());
9595 style.replace(QLatin1String("@event_attributes_row_background_color@"), palette.midlight().color().name());
9696 if ( style.isEmpty() ) {
97 qDebug() << "reportStylesheet: default style sheet is empty, too bad";
97 qWarning() << "reportStylesheet: default style sheet is empty, too bad";
9898 }
9999 } else {
100 qDebug() << "reportStylesheet: cannot load report style sheet:" << stylesheet.errorString();
100 qCritical() << "reportStylesheet: cannot load report style sheet:" << stylesheet.errorString();
101101 }
102102 return style;
103103 }
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
+0
-43
Charm/ViewModeInterface.h less more
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
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2929 static const int DAYS_IN_WEEK = 7;
3030
3131 WeeklySummary::WeeklySummary()
32 : task( 0 ), durations( DAYS_IN_WEEK, 0 ) {
32 : durations( DAYS_IN_WEEK, 0 ) {
3333 }
3434
3535 QVector<WeeklySummary> WeeklySummary::summariesForTimespan( CharmDataModel* dataModel, const TimeSpan& timespan )
5656 // now add the times to the tasks:
5757 Q_FOREACH( const Event& event, events ) {
5858 // 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() );
6060 if ( it != uniqueTaskIds.end() ) {
6161 const int index = std::distance( uniqueTaskIds.begin(), it );
6262 Q_ASSERT( index >= 0 && index < summaries.size() );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3838
3939 WeeklySummary();
4040
41 TaskId task;
41 TaskId task = {};
4242 QString taskname;
4343 QVector<int> durations;
4444 };
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2424 #include "ActivityReport.h"
2525 #include "ApplicationCore.h"
2626 #include "DateEntrySyncer.h"
27 #include "Data.h"
2728 #include "SelectTaskDialog.h"
2829 #include "ViewHelpers.h"
2930
3839 #include <QTimer>
3940 #include <QtAlgorithms>
4041 #include <QUrl>
41 #include <QDebug>
4242
4343 #include "ui_ActivityReportConfigurationDialog.h"
4444
4545 ActivityReportConfigurationDialog::ActivityReportConfigurationDialog( QWidget* parent )
4646 : ReportConfigurationDialog( parent )
4747 , m_ui( new Ui::ActivityReportConfigurationDialog )
48 , m_rootTask( 0 )
4948 {
5049 setWindowTitle( tr( "Activity Report" ) );
5150
5958 connect( m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()) );
6059 connect( m_ui->comboBox, SIGNAL(currentIndexChanged(int)),
6160 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()),
6766 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()) );
7269
7370 new DateEntrySyncer(m_ui->spinBoxStartWeek, m_ui->spinBoxStartYear, m_ui->dateEditStart, 1, this );
7471 new DateEntrySyncer(m_ui->spinBoxEndWeek, m_ui->spinBoxEndYear, m_ui->dateEditEnd, 7, this );
123120 }
124121 }
125122
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
150123 void ActivityReportConfigurationDialog::slotSelectTask()
151124 {
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
159137 }
160138
161139 void ActivityReportConfigurationDialog::slotExcludeTask()
162140 {
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() );
170174 }
171175
172176 bool ActivityReportConfigurationDialog::selectTask(TaskId& task)
185189 QDialog::accept();
186190 }
187191
188 void ActivityReportConfigurationDialog::showReportPreviewDialog( QWidget* parent )
192 void ActivityReportConfigurationDialog::showReportPreviewDialog()
189193 {
190194 QDate start, end;
191195 const int index = m_ui->comboBox->currentIndex();
197201 end = m_timespans[index].timespan.second;
198202 }
199203
200 auto report = new ActivityReport( parent );
204 auto report = new ActivityReport();
201205 report->timeSpanSelection( m_timespans[index] );
202 report->setReportProperties( start, end, m_rootTask, m_rootExcludeTask );
206 report->setReportProperties( start, end, m_rootTasks, m_rootExcludeTasks );
203207 report->show();
204208 }
205209
206210 ActivityReport::ActivityReport( QWidget* parent )
207211 : ReportPreviewWindow( parent )
208 , m_rootTask( 0 )
209 , m_rootExcludeTask( 0 )
210212 {
211213 saveToXmlButton()->hide();
212214 saveToTextButton()->hide();
218220 {
219221 }
220222
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 )
222224 {
223225 m_start = start;
224226 m_end = end;
225 m_rootTask = rootTask;
226 m_rootExcludeTask = rootExcludeTask;
227 m_rootTasks = rootTasks;
228 m_rootExcludeTasks = rootExcludeTasks;
227229 slotUpdate();
228230 }
229231
234236
235237 void ActivityReport::slotUpdate()
236238 {
237 const QString DateFormat( "yyyy/MM/dd" );
238 const QString TimeFormat( "HH:mm" );
239 const QString DateTimeFormat( "yyyy/MM/dd HH:mm" );
240
241239 // retrieve matching events:
242240 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 }
243249 matchingEvents = Charm::eventIdsSortedByStartTime( matchingEvents );
244 if ( m_rootTask != 0 ) {
245 matchingEvents = Charm::filteredBySubtree( matchingEvents, m_rootTask );
246 }
247250
248251 // 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 );
251254 }
252255
253256 // calculate total:
318321 paragraph.appendChild( totalsElement );
319322 body.appendChild( paragraph );
320323 }
321 if ( m_rootTask != 0 ) {
324 if ( !m_rootTasks.isEmpty() ) {
322325 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 );
325333 QDomText rootText = doc.createTextNode( rootTaskText );
326334 paragraph.appendChild( rootText );
327335 body.appendChild( paragraph );
441449 default:
442450 Q_ASSERT( false ); // should not happen
443451 }
444 setReportProperties( start, end, m_rootTask, m_rootExcludeTask );
452 setReportProperties( start, end, m_rootTasks, m_rootExcludeTasks );
445453 }
446454 #include "moc_ActivityReport.cpp"
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4343
4444 public:
4545 explicit ActivityReportConfigurationDialog( QWidget* parent );
46 ~ActivityReportConfigurationDialog();
46 ~ActivityReportConfigurationDialog() override;
4747
48 void showReportPreviewDialog( QWidget* parent ) override;
48 void showReportPreviewDialog() override;
4949
5050 public Q_SLOTS:
5151 void accept() override;
5454 void slotDelayedInitialization();
5555 void slotStandardTimeSpansChanged();
5656 void slotTimeSpanSelected( int );
57 void slotCheckboxSubtasksOnlyChecked( bool );
58 void slotCheckBoxExcludeTasksChecked( bool );
5957 void slotSelectTask();
6058 void slotExcludeTask();
59 void slotRemoveExcludedTask();
60 void slotRemoveIncludeTask();
6161
6262 private:
6363 bool selectTask(TaskId& task);
6464
6565 QScopedPointer<Ui::ActivityReportConfigurationDialog> m_ui;
6666 QList<NamedTimeSpan> m_timespans;
67 TaskId m_rootTask;
68 TaskId m_rootExcludeTask;
67 QSet<TaskId> m_rootTasks;
68 QSet<TaskId> m_rootExcludeTasks;
6969 };
7070
7171 class ActivityReport : public ReportPreviewWindow
7474
7575 public:
7676 explicit ActivityReport( QWidget* parent = nullptr );
77 ~ActivityReport();
77 ~ActivityReport() override;
7878
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 );
8181 void timeSpanSelection( NamedTimeSpan timeSpanSelection );
8282
8383 private slots:
8989 private:
9090 QDate m_start;
9191 QDate m_end;
92 TaskId m_rootTask;
93 TaskId m_rootExcludeTask;
92 QSet<TaskId> m_rootTasks;
93 QSet<TaskId> m_rootExcludeTasks;
9494 NamedTimeSpan m_timeSpanSelection;
9595 };
9696
66 <x>0</x>
77 <y>0</y>
88 <width>500</width>
9 <height>397</height>
9 <height>637</height>
1010 </rect>
1111 </property>
1212 <property name="windowTitle">
181181 </widget>
182182 </item>
183183 <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>
184197 <widget class="QGroupBox" name="groupBox_2">
185198 <property name="title">
186199 <string>Included tasks</string>
187200 </property>
188201 <layout class="QVBoxLayout" name="verticalLayout_2">
189202 <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">
247234 <property name="orientation">
248235 <enum>Qt::Horizontal</enum>
249236 </property>
257244 </item>
258245 </layout>
259246 </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">
318288 <property name="orientation">
319289 <enum>Qt::Horizontal</enum>
320290 </property>
332302 </widget>
333303 </item>
334304 <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>
348305 <layout class="QHBoxLayout">
349306 <item>
350307 <widget class="QDialogButtonBox" name="buttonBox">
358315 </layout>
359316 </widget>
360317 <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/>
427319 </ui>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2626 #include <QDialogButtonBox>
2727
2828 BillDialog::BillDialog( QWidget* parent, Qt::WindowFlags f )
29 : QDialog(parent, f), m_year( 0 ), m_week( 0 )
29 : QDialog(parent, f)
3030 {
3131 setResult(Later);
3232 QPalette p = palette();
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4747 QPushButton *m_asYouWish;
4848 QPushButton *m_alreadyDone;
4949 QPushButton *m_later;
50 int m_year;
51 int m_week;
50 int m_year = 0;
51 int m_week = 0;
5252 };
5353
5454 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3636
3737 public:
3838 explicit CharmAboutDialog( QWidget* parent = nullptr );
39 ~CharmAboutDialog();
39 ~CharmAboutDialog() override;
4040
4141 private:
4242 QScopedPointer<Ui::CharmAboutDialog> m_ui;
7777 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
7878 p, li { white-space: pre-wrap; }
7979 &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.Lucida Grande UI'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
80 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;Copyright © 2006-2015 The Charm Authors&lt;/span&gt;&lt;/p&gt;
80 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;Copyright © 2006-2016 The Charm Authors&lt;/span&gt;&lt;/p&gt;
8181 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;Licensed under the terms of the GPL.&lt;/span&gt;&lt;/p&gt;
8282 &lt;p style=&quot;-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;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
8383 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:9pt;&quot;&gt;Charm is supported and maintained by &lt;/span&gt;&lt;a href=&quot;http://www.kdab.com&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; text-decoration: underline; color:#0057ae;&quot;&gt;KDAB&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
9090 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:9pt;&quot;&gt;Frank Osterfeld, Guillermo Amaral&lt;/span&gt;&lt;/p&gt;
9191 &lt;p style=&quot;-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;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
9292 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:9pt;&quot;&gt;Contributors:&lt;/span&gt;&lt;/p&gt;
93 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:9pt;&quot;&gt;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&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
93 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:9pt;&quot;&gt;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&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
9494 </property>
9595 <property name="textInteractionFlags">
9696 <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Michel Boyer de la Giroday <michel.giroday@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Michel Boyer de la Giroday <michel.giroday@kdab.com>
88
3737
3838 public:
3939 explicit CharmNewReleaseDialog( QWidget* parent = nullptr );
40 ~CharmNewReleaseDialog();
40 ~CharmNewReleaseDialog() override;
4141
4242 void setVersion( const QString& newVersion , const QString& localVersion );
4343 void setDownloadLink( const QUrl& link );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 Author: Mathias Hasselmann <mathias.hasselmann@kdab.com>
4545
4646 m_ui.lbWarnUnuploadedTimesheets->setVisible( httpJobPossible );
4747 m_ui.cbWarnUnuploadedTimesheets->setVisible( httpJobPossible );
48 m_ui.lbResetPassword->setVisible( httpJobPossible );
49 m_ui.pbResetPassword->setVisible( httpJobPossible );
4850 m_ui.cbIdleDetection->setEnabled( haveIdleDetection );
4951 m_ui.lbIdleDetection->setEnabled( haveIdleDetection );
5052 m_ui.cbIdleDetection->setChecked( config.detectIdling && m_ui.cbIdleDetection->isEnabled() );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3535 public:
3636 explicit CharmPreferences( const Configuration& config,
3737 QWidget* parent = nullptr );
38 ~CharmPreferences();
38 ~CharmPreferences() override;
3939
4040 Configuration::DurationFormat durationFormat() const;
4141 bool detectIdling() const;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2424 #include "ApplicationCore.h"
2525 #include "Data.h"
2626 #include "ViewHelpers.h"
27 #include "WidgetUtils.h"
2728
2829 #include "Commands/CommandRelayCommand.h"
2930
3940 #include <QToolBar>
4041 #include <QToolButton>
4142
42 #include <algorithm>
43 #include <functional>
44
4543 CharmWindow::CharmWindow( const QString& name, QWidget* parent )
4644 : QMainWindow( parent )
4745 , m_openCharmAction( new QAction( tr( "Open Charm" ), this ) )
4846 , m_showAction( new QAction( this ) )
49 , m_showHideAction( new QAction( this ) )
50 , m_windowNumber( -1 )
51 , m_shortcut( 0 )
5247 {
5348 setWindowName( name );
54 handleOpenCharm( false );
55 handleShow( false );
56 handleShowHide( false );
5749 connect( m_openCharmAction, SIGNAL(triggered(bool)), SLOT(showView()) );
5850 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)) );
6053 m_toolBar = addToolBar( "Toolbar" );
6154 m_toolBar->setMovable( false );
55
56 emit visibilityChanged( false );
6257 }
6358
6459 void CharmWindow::stateChanged( State )
10499 m_windowIdentifier = id;
105100 }
106101
107 QString CharmWindow::windowIdentfier() const
102 QString CharmWindow::windowIdentifier() const
108103 {
109104 return m_windowIdentifier;
110105 }
119114 m_shortcut->setKey( sequence );
120115 #endif
121116 m_shortcut->setContext( Qt::ApplicationShortcut );
122 m_showHideAction->setShortcut( sequence );
123117 m_showAction->setShortcut( sequence );
124118 connect( m_shortcut, SIGNAL(activated()), SLOT(showHideView()) );
125119 connect( m_shortcut, SIGNAL(activated()), SLOT(showView()) );
145139 return m_showAction;
146140 }
147141
148 QAction* CharmWindow::showHideAction()
149 {
150 return m_showHideAction;
151 }
152
153142 void CharmWindow::restore()
154143 {
155144 show();
156145 }
157146
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
158157 void CharmWindow::showEvent( QShowEvent* e )
159158 {
160 handleOpenCharm( true );
161 handleShow( true );
162 handleShowHide( true );
159 checkVisibility();
163160 QMainWindow::showEvent( e );
164161 }
165162
166163 void CharmWindow::hideEvent( QHideEvent* e )
167164 {
168 handleOpenCharm( false );
169 handleShow( false );
170 handleShowHide( false );
165 checkVisibility();
171166 QMainWindow::hideEvent( e );
172167 }
173168
198193 const QString text = tr( "Show %1" ).arg( m_windowName );
199194 m_showAction->setText( text );
200195 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 );
209196 }
210197
211198 void CharmWindow::commitCommand( CharmCommand* command )
241228 w->hide();
242229 return false;
243230 } else {
244 w->show();
245 w->raise();
246 w->activateWindow();
231 showView( w );
247232 return true;
248233 }
249234 }
260245
261246 void CharmWindow::configurationChanged()
262247 {
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 );
266249 }
267250
268251 void CharmWindow::saveGuiState()
269252 {
270 Q_ASSERT( !windowIdentfier().isEmpty() );
253 Q_ASSERT( !windowIdentifier().isEmpty() );
271254 QSettings settings;
272 settings.beginGroup( windowIdentfier() );
255 settings.beginGroup( windowIdentifier() );
273256 // save geometry
274 settings.setValue( MetaKey_MainWindowGeometry, saveGeometry() );
257 WidgetUtils::saveGeometry( this, MetaKey_MainWindowGeometry );
275258 settings.setValue( MetaKey_MainWindowVisible, isVisible() );
276259 }
277260
278261 void CharmWindow::restoreGuiState()
279262 {
280 Q_ASSERT( !windowIdentfier().isEmpty() );
263 const QString identifier = windowIdentifier();
264 Q_ASSERT( !identifier.isEmpty() );
281265 // restore geometry
282266 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 );
287269 // restore visibility
288270 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 );
291274 }
292275 }
293276
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3232 class QShortcut;
3333
3434 class CharmWindow : public QMainWindow,
35 public ViewInterface,
36 public CommandEmitterInterface
35 public ViewInterface
3736 {
3837 Q_OBJECT
3938
4039 public:
4140 explicit CharmWindow( const QString& name, QWidget* parent = nullptr );
4241
43 QAction* showHideAction();
4442 QAction* showAction();
4543 QAction* openCharmAction();
4644
4745 QString windowName() const;
48 QString windowIdentfier() const;
46 QString windowIdentifier() const;
4947 int windowNumber() const;
5048
5149 virtual QToolBar* toolBar() const;
6361 /** Insert the Edit menu. Empty by default. */
6462 virtual void insertEditMenu() {}
6563
64 void checkVisibility();
65
6666 public:
6767 void stateChanged( State previous ) override;
6868 void showEvent( QShowEvent* ) override;
6969 void hideEvent( QHideEvent* ) override;
7070 void keyPressEvent( QKeyEvent* event ) override;
7171
72 virtual void saveGuiState();
73 virtual void restoreGuiState();
72 void saveGuiState() override;
73 void restoreGuiState() override;
7474
7575 static void showView( QWidget* w );
7676 static bool showHideView( QWidget* w );
8888 void showHideView();
8989 void configurationChanged() override;
9090
91 private:
91 private slots:
9292 void handleOpenCharm( bool visible );
9393 void handleShow( bool visible );
94 void handleShowHide( bool visible );
94
95 private:
9596 QString m_windowName;
9697 QAction* m_openCharmAction;
9798 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
100100 QString m_windowIdentifier;
101 QShortcut* m_shortcut;
101 QShortcut* m_shortcut = nullptr;
102102 QToolBar* m_toolBar;
103 bool m_isVisibility = false;
103104 };
104105
105106 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mathias Hasselmann <mathias.hasselmann@kdab.com>
88
3333 CommentEditorPopup::CommentEditorPopup( QWidget *parent )
3434 : QDialog( parent )
3535 , ui( new Ui::CommentEditorPopup )
36 , m_id()
3736 {
3837 ui->setupUi( this );
3938 ui->buttonBox->button( QDialogButtonBox::Ok )->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_Return ) );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mathias Hasselmann <mathias.hasselmann@kdab.com>
88
3737
3838 public:
3939 explicit CommentEditorPopup( QWidget *parent = nullptr );
40 ~CommentEditorPopup();
40 ~CommentEditorPopup() override;
4141
4242 public Q_SLOTS:
4343 void loadEvent( EventId id );
4545
4646 private:
4747 Ui::CommentEditorPopup *ui;
48 EventId m_id;
48 EventId m_id = {};
4949 };
5050
5151 #endif // COMMENTEDITORPOPUP_H
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4242
4343 static QString toHtmlEscaped( const QString& s )
4444 {
45 #if QT_VERSION < 0x050000
45 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
4646 return Qt::escape( s );
4747 #else
4848 return s.toHtmlEscaped();
7070 EventList events;
7171
7272 const int days = start.daysTo( end );
73 #if QT_VERSION >= 0x040700
73 #if QT_VERSION >= QT_VERSION_CHECK(4,7,0)
7474 events.reserve( days );
7575 #endif
7676 for ( int i = 0; i < days; ++i ) {
9393 EnterVacationDialog::EnterVacationDialog( QWidget* parent )
9494 : QDialog( parent )
9595 , m_ui( new Ui::EnterVacationDialog )
96 , m_selectedTaskId( -1 )
9796 {
9897 setWindowTitle( tr( "Enter Vacation" ) );
9998
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3838 Q_OBJECT
3939 public:
4040 explicit EnterVacationDialog( QWidget* parent=nullptr );
41 ~EnterVacationDialog();
41 ~EnterVacationDialog() override;
4242
4343 EventList events() const;
4444
5353
5454 private:
5555 QScopedPointer<Ui::EnterVacationDialog> m_ui;
56 TaskId m_selectedTaskId;
56 TaskId m_selectedTaskId = -1;
5757 EventList m_events;
5858 };
5959
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3939 : QDialog( parent )
4040 , m_ui( new Ui::EventEditor )
4141 , m_event( event )
42 , m_updating( false )
43 , m_endDateChanged( true )
4442 {
4543 m_ui->setupUi( this );
4644 m_ui->dateEditEnd->calendarWidget()->setFirstDayOfWeek( Qt::Monday );
218216 bool active = MODEL.charmDataModel()->isEventActive( m_event.id() );
219217 m_ui->dateEditEnd->setEnabled( !active );
220218 m_ui->timeEditEnd->setEnabled( !active );
221 m_ui->textEditComment->setEnabled( !active );
222219 m_ui->spinBoxHours->setEnabled( !active );
223220 m_ui->spinBoxMinutes->setEnabled( !active );
224221 m_ui->pushButtonSelectTask->setEnabled( !active );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3939
4040 public:
4141 explicit EventEditor( const Event& event, QWidget* parent = nullptr );
42 virtual ~EventEditor();
42 ~EventEditor() override;
4343
4444 // return the result after the dialog has been accepted
4545 Event eventResult() const;
6565
6666 QScopedPointer<Ui::EventEditor> m_ui;
6767 Event m_event;
68 bool m_updating;
69 bool m_endDateChanged;
68 bool m_updating = false;
69 bool m_endDateChanged = true;
7070 };
7171
7272 #endif /* EVENTEDITOR_H */
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4646 // to have the size hint recalculated, simply set m_cachedSizeHint
4747 // to an invalid value (m_cachedSizeHint = QSize();)
4848 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
5155 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 ),
6459 42, EventState_Locked ).size();
6560 }
6661 return m_cachedSizeHint;
7671
7772 if ( event.isValid() ) {
7873 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() );
9674
9775 paint( painter, option,
98 taskName,
99 dateAndDuration,
76 taskName( item ),
77 dateAndDuration( event ),
10078 logDuration( event.duration() ),
10179 locked ? EventState_Locked : EventState_Default );
10280 }
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;
103107 }
104108
105109 QRect EventEditorDelegate::paint( QPainter* painter,
111115 {
112116 painter->save();
113117 const QPalette& palette = option.palette;
114 QFont mainFont = painter->font();
118 const QFont &mainFont = option.font;
119 painter->setFont(mainFont);
115120 QFont detailFont ( mainFont );
116121 detailFont.setPointSizeF( mainFont.pointSizeF() * 0.8 );
117122 QPixmap decoration;
130135 background = palette.color( QPalette::Active, QPalette::Window );
131136 break;
132137 case EventState_Default:
133 default:
134138 foreground = palette.color( QPalette::Active, QPalette::WindowText );
135139 background = palette.color( QPalette::Active, QPalette::Window );
136140 break;
138142
139143 if ( option.state & QStyle::State_Selected ) {
140144 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 );
144146 if ( state != EventState_Locked ) {
145147 foreground = palette.color(
146148 QPalette::Active, QPalette::HighlightedText );
151153
152154 // draw line 1 and decoration:
153155 painter->setFont( mainFont );
154 QRect taskRect;
155 taskRect.setTopLeft( option.rect.topLeft() );
156 QRect taskRect( option.rect );
156157 taskRect.setWidth( option.rect.width() - decoration.width() );
157 taskRect.setHeight( option.rect.height() );
158158 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 );
160160
161161 QRect boundingRect;
162162 QString elidedTask = Charm::elidedTaskName( taskName, mainFont, taskRect.width() );
163163 painter->drawText( taskRect, Qt::AlignLeft | Qt::AlignTop, elidedTask,
164164 &boundingRect );
165 taskRect.setSize( boundingRect.size() );
165 taskRect = boundingRect;
166166 taskRect.setHeight( qMax( taskRect.height(), decoration.height() ) );
167167 // now taskRect tells us where to start line 2
168168 painter->drawPixmap( decorationPoint, decoration );
169169
170170 // draw line 2 (timespan and comment, partly):
171171 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() );
176174 detailsRect.setHeight( option.rect.height() - taskRect.height() );
177175 painter->drawText( detailsRect, Qt::AlignLeft | Qt::AlignTop,
178176 timespan, &boundingRect );
179 detailsRect.setSize( boundingRect.size() );
177 detailsRect = boundingRect;
180178
181179 // draw the duration line:
182180 const int Margin = 2;
183181 QRect durationRect( option.rect.left() + 1, detailsRect.bottom(),
184182 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() );
188184
189185 painter->restore();
190 // return bounding rectangle
191186 return QRect( 0, 0,
192187 qMax( taskRect.width(), detailsRect.width() ),
193188 durationRect.bottom() + 1 - option.rect.top() );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3030 class QStyleOptionViewItem;
3131 class QModelIndex;
3232 class EventModelFilter;
33 class TaskTreeItem;
34 class Event;
3335
3436 class EventEditorDelegate : public QItemDelegate
3537 {
5254 EventModelFilter* m_model;
5355 mutable QSize m_cachedSizeHint;
5456
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
5960 QRect paint( QPainter*, const QStyleOptionViewItem& option,
6061 const QString& taskName, const QString& timespan,
6162 double logDuration, EventState state ) const;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3232 #include "TasksView.h"
3333 #include "ViewHelpers.h"
3434 #include "WeeklyTimesheet.h"
35 #include "WidgetUtils.h"
3536
3637 #include "Commands/CommandDeleteEvent.h"
3738 #include "Commands/CommandMakeEvent.h"
5354 #include <QToolBar>
5455 #include <QVBoxLayout>
5556
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 ) )
5960 , m_actionUndo( this )
6061 , m_actionRedo( this )
6162 , m_actionNewEvent( this )
6768 , m_labelTotal( new QLabel( this ) )
6869 , m_listView( new QListView( this ) )
6970 {
71 setWindowTitle( tr( "Event Editor" ) );
7072 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 );
7276 layout->addWidget( m_listView );
7377
7478 m_listView->setAlternatingRowColors( true );
112116 m_actionNewEvent.setToolTip( tr( "Create a new Event" ) );
113117 m_actionNewEvent.setIcon( Data::newTaskIcon() );
114118 m_actionNewEvent.setShortcut( QKeySequence::New );
115 toolBar->addAction( &m_actionNewEvent );
119 m_toolBar->addAction( &m_actionNewEvent );
116120
117121 m_actionEditEvent.setText( tr( "Edit Event...") );
118122 m_actionEditEvent.setShortcut( Qt::CTRL + Qt::Key_E );
119123 m_actionEditEvent.setIcon( Data::editEventIcon() );
120 toolBar->addAction( &m_actionEditEvent );
124 m_toolBar->addAction( &m_actionEditEvent );
121125
122126 m_actionFindAndReplace.setText( tr( "Search/Replace Events..." ) );
123127 m_actionFindAndReplace.setToolTip( tr( "Change the task events belong to" ) );
124128 m_actionFindAndReplace.setIcon( Data::searchIcon() );
125 toolBar->addAction( &m_actionFindAndReplace );
129 m_toolBar->addAction( &m_actionFindAndReplace );
126130
127131 connect( &m_actionFindAndReplace, SIGNAL(triggered()), SLOT(slotFindAndReplace()) );
128132
134138 #endif
135139 m_actionDeleteEvent.setShortcuts(deleteShortcuts);
136140 m_actionDeleteEvent.setIcon( Data::deleteTaskIcon() );
137 toolBar->addAction( &m_actionDeleteEvent );
141 m_toolBar->addAction( &m_actionDeleteEvent );
138142
139143 // disable all actions, action state will be set when the current
140144 // item changes:
142146 m_actionEditEvent.setEnabled( false );
143147 m_actionDeleteEvent.setEnabled( false );
144148
145 toolBar->addWidget( m_comboBox );
149 m_toolBar->addWidget( m_comboBox );
146150 connect( m_comboBox, SIGNAL(currentIndexChanged(int)),
147151 SLOT(timeFrameChanged(int)) );
148152
150154 QSizePolicy spacerSizePolicy = spacer->sizePolicy();
151155 spacerSizePolicy.setHorizontalPolicy( QSizePolicy::Expanding );
152156 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 );
156160
157161 QTimer::singleShot( 0, this, SLOT(delayedInitialization()) );
158162
205209 } else {
206210 m_comboBox->setCurrentIndex( 0 );
207211 }
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 );
219212 }
220213
221214 void EventView::commitCommand( CharmCommand* command )
272265 void EventView::slotDeleteEvent()
273266 {
274267 const TaskTreeItem& taskTreeItem =
275 MODEL.charmDataModel()->taskTreeItem( m_event.taskId() );
268 MODEL.charmDataModel()->taskTreeItem( m_event.taskId() );
276269 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") )
287292 == QMessageBox::Yes ) {
288293 auto command = new CommandDeleteEvent( m_event, this );
289294 command->prepare();
319324
320325 // all actions are handled in their own slots:
321326 menu.exec( m_listView->mapToGlobal( point ) );
322 }
323
324 // FIXME obsolete
325 Event EventView::newSettings()
326 {
327 Event event( m_event );
328 return event;
329327 }
330328
331329 void EventView::makeVisibleAndCurrent( const Event& event )
451449 timeFrameChanged( m_comboBox->currentIndex() );
452450 }
453451
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 }
458472
459473 void EventView::configurationChanged()
460474 {
475 WidgetUtils::updateToolButtonStyle( this );
461476 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 );
462487 }
463488
464489 void EventView::setModel( ModelConnector* connector )
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2626 #include <QWidget>
2727 #include <QAction>
2828 #include <QUndoStack>
29 #include <QDialog>
2930
31 #include "Core/UIStateInterface.h"
3032 #include "Core/Event.h"
3133 #include "Core/TimeSpans.h"
3234 #include "Core/CommandEmitterInterface.h"
3335
34 #include "ViewModeInterface.h"
35 #include "UndoCharmCommandWrapper.h"
36 #include "Charm/ModelConnector.h"
37 #include "Charm/UndoCharmCommandWrapper.h"
3638
3739 class QModelIndex;
3840
4345 class QLabel;
4446 class QListView;
4547
46 class EventView : public QWidget,
47 public ViewModeInterface,
48 public CommandEmitterInterface
48 class EventView : public QDialog,
49 public UIStateInterface
4950 {
5051 Q_OBJECT
5152
5253 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;
5956
6057 void makeVisibleAndCurrent( const Event& );
6158
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* ) ;
6860
6961 void populateEditMenu( QMenu* );
7062
7163 signals:
72 void visible( bool );
73 void emitCommand( CharmCommand* );
74 void emitCommandRollback( CharmCommand* );
64 void emitCommand( CharmCommand* ) override;
65 void emitCommandRollback( CharmCommand* ) override;
7566
7667 public slots:
7768 void commitCommand( CharmCommand* ) override;
7970 void timeSpansChanged();
8071 void timeFrameChanged(int );
8172 void slotConfigureUi();
73
74 void saveGuiState() override;
75 void restoreGuiState() override;
76 void stateChanged( State previous ) override;
77 void configurationChanged() override;
8278
8379 private slots:
8480 void slotEventDoubleClicked( const QModelIndex& );
10298 void slotReset();
10399
104100 private:
105 Event newSettings();
106101 void setCurrentEvent( const Event& );
107102 void stageCommand( CharmCommand* );
108103
104 QToolBar* m_toolBar;
109105 QUndoStack* m_undoStack;
110106 QList<NamedTimeSpan> m_timeSpans;
111107 Event m_event;
112 EventModelFilter* m_model;
108 EventModelFilter* m_model = nullptr;
113109 QAction m_actionUndo;
114110 QAction m_actionRedo;
115111 QAction m_actionNewEvent;
+0
-75
Charm/Widgets/EventWindow.cpp less more
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
-59
Charm/Widgets/EventWindow.h less more
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
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Michel Boyer de la Giroday <michel.giroday@kdab.com>
88
3434 #include <QCalendarWidget>
3535 #include <QMessageBox>
3636
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 )
4240 {
4341 m_ui->setupUi(this);
4442
138136 void FindAndReplaceEventsDialog::selectTask( SelectTaskType type )
139137 {
140138 SelectTaskDialog dialog( this );
139 if ( type == TaskToSearch ) {
140 dialog.setNonValidSelectable();
141 }
141142 if( !dialog.exec() )
142143 return;
143144
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Michel Boyer de la Giroday <michel.gitroday@kdab.com>
88
4444
4545 public:
4646 explicit FindAndReplaceEventsDialog( QWidget* parent = nullptr );
47 ~FindAndReplaceEventsDialog();
47 ~FindAndReplaceEventsDialog() override;
4848
4949 QList<Event> modifiedEvents() const;
5050
6565 void selectTask( SelectTaskType type );
6666 void eventChangesCompleted( const Event& event );
6767
68 TaskId m_taskToSearch;
69 TaskId m_taskToReplaceWith;
68 TaskId m_taskToSearch = {};
69 TaskId m_taskToReplaceWith = {};
7070 TimeSpan m_timeSpan;
7171 QPushButton* m_replace;
7272 QPushButton* m_cancel;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4242 };
4343
4444 explicit IdleCorrectionDialog( QWidget* parent = nullptr );
45 ~IdleCorrectionDialog();
45 ~IdleCorrectionDialog() override;
4646
4747 Result result() const;
4848
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2727 public:
2828 explicit MakeTemporarilyVisible( QWidget* widget )
2929 : m_widget( widget )
30 , m_wasVisible( false )
3130 {
3231 Q_ASSERT( m_widget );
3332 m_wasVisible = m_widget->isVisible();
4241 }
4342 }
4443 private:
45 QWidget* m_widget;
46 bool m_wasVisible;
44 QWidget* m_widget = {};
45 bool m_wasVisible = false;
4746 };
4847
4948 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4242
4343 MonthlyTimeSheetReport::MonthlyTimeSheetReport( QWidget* parent )
4444 : TimeSheetReport( parent )
45 , m_numberOfWeeks( 0 )
46 , m_monthNumber( 0 )
47 , m_yearOfMonth( 0 )
4845 {
4946 QSettings settings;
5047 settings.beginGroup("users");
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3535
3636 public:
3737 explicit MonthlyTimeSheetReport( QWidget* parent = nullptr );
38 virtual ~MonthlyTimeSheetReport();
38 ~MonthlyTimeSheetReport() override;
3939
4040 void setReportProperties( const QDate& start,
4141 const QDate& end,
5353
5454 private:
5555 // 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;
5959 QString m_weeklyhours;
6060 float m_dailyhours;
6161 };
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
9494 QDialog::accept();
9595 }
9696
97 void MonthlyTimesheetConfigurationDialog::showReportPreviewDialog( QWidget* parent )
97 void MonthlyTimesheetConfigurationDialog::showReportPreviewDialog()
9898 {
9999 QDate start, end;
100100 int index = m_ui->comboBoxMonth->currentIndex();
107107 end = m_monthInfo[index].timespan.second;
108108 }
109109 bool activeOnly = m_ui->checkBoxActiveOnly->isChecked();
110 auto report = new MonthlyTimeSheetReport( parent );
110 auto report = new MonthlyTimeSheetReport();
111111 report->setReportProperties( start, end, m_rootTask, activeOnly );
112112 report->show();
113113 }
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3838
3939 public:
4040 explicit MonthlyTimesheetConfigurationDialog( QWidget* parent );
41 virtual ~MonthlyTimesheetConfigurationDialog();
41 ~MonthlyTimesheetConfigurationDialog() override;
4242
43 void showReportPreviewDialog( QWidget* parent ) override;
43 void showReportPreviewDialog() override;
4444 void showEvent( QShowEvent* ) override;
4545 void setDefaultMonth( int yearOfMonth, int month );
4646
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Michel Boyer de la Giroday <michel.giroday@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Michel Boyer de la Giroday <michel.giroday@kdab.com>
88
3636
3737 public:
3838 explicit NotificationPopup( QWidget *parent = nullptr );
39 ~NotificationPopup();
39 ~NotificationPopup() override;
4040
4141 void showNotification( const QString& title, const QString& message );
4242
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3838
3939 @param parent parent widget for the preview dialog
4040 */
41 virtual void showReportPreviewDialog( QWidget* parent ) = 0;
41 virtual void showReportPreviewDialog() = 0;
4242 };
4343
4444 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3333 ReportPreviewWindow::ReportPreviewWindow( QWidget* parent )
3434 : QDialog( parent )
3535 , m_ui( new Ui::ReportPreviewWindow )
36 , m_document()
3736 {
3837 m_ui->setupUi( this );
3938 setAttribute( Qt::WA_DeleteOnClose );
5352 #else
5453 m_ui->pushButtonPrint->setEnabled(false);
5554 #endif
55
56 m_updateTimer.setInterval(60 * 1000);
57 m_updateTimer.start();
58 connect( &m_updateTimer, SIGNAL(timeout()),
59 SLOT(slotUpdate()) );
60
5661 resize(850, 600);
5762 }
5863
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2727 #include <QDomDocument>
2828 #include <QScopedPointer>
2929 #include <QTextDocument>
30 #include <QTimer>
3031
3132 namespace Ui {
3233 class ReportPreviewWindow;
4041
4142 public:
4243 explicit ReportPreviewWindow( QWidget* parent = nullptr );
43 virtual ~ReportPreviewWindow();
44 ~ReportPreviewWindow() override;
4445
4546 signals:
4647 void anchorClicked(const QUrl& which);
5152 QPushButton* saveToXmlButton() const;
5253 QPushButton* saveToTextButton() const;
5354 QPushButton* uploadButton() const;
55
56 QTimer m_updateTimer;
5457
5558 private slots:
5659 virtual void slotSaveToXml();
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
6565 SelectTaskDialog::SelectTaskDialog( QWidget* parent )
6666 : QDialog( parent )
6767 , m_ui( new Ui::SelectTaskDialog() )
68 , m_selectedTask( 0 )
6968 , m_proxy( MODEL.charmDataModel() )
70 , m_nonTrackableSelectable( false )
7169 {
7270 m_ui->setupUi( this );
7371 m_ui->treeView->setModel( &m_proxy );
176174 return false;
177175 const Task task = m_proxy.taskForIndex( index );
178176
179 const bool taskValid = task.isValid() && task.isCurrentlyValid();
177 const bool taskValid = m_nonValidSelectable || (task.isValid() && task.isCurrentlyValid());
180178
181179 if ( m_nonTrackableSelectable ) {
182180 return taskValid;
199197
200198 Charm::saveExpandStates( m_ui->treeView, &m_expansionStates );
201199 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 );
203204 }
204205
205206 void SelectTaskDialog::slotAccepted()
257258 m_nonTrackableSelectable = true;
258259 }
259260
261 void SelectTaskDialog::setNonValidSelectable()
262 {
263 m_nonValidSelectable = true;
264 }
265
260266 #include "moc_SelectTaskDialog.cpp"
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
5656
5757 public:
5858 explicit SelectTaskDialog( QWidget* parent=nullptr );
59 ~SelectTaskDialog();
59 ~SelectTaskDialog() override;
6060
6161 TaskId selectedTask() const;
6262 void setNonTrackableSelectable();
63 void setNonValidSelectable();
6364
6465 signals:
6566 void saveConfiguration();
8182
8283 private:
8384 QScopedPointer<Ui::SelectTaskDialog> m_ui;
84 TaskId m_selectedTask;
85 TaskId m_selectedTask = {};
8586 SelectTaskDialogProxy m_proxy;
8687 QHash<TaskId,bool> m_expansionStates;
87 bool m_nonTrackableSelectable;
88 bool m_nonTrackableSelectable = false;
89 bool m_nonValidSelectable = false;
8890 };
8991
9092 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
4040
4141 public:
4242 explicit TaskEditor( QWidget* parent = nullptr );
43 virtual ~TaskEditor();
43 ~TaskEditor() override;
4444
4545 void setTask( const Task& task );
4646
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3838
3939 public:
4040 explicit TaskIdDialog( TaskModelInterface* model, TasksView* parent );
41 ~TaskIdDialog();
41 ~TaskIdDialog() override;
4242
4343 void setSuggestedId( int );
4444 int selectedId() const;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3030 #include "TasksViewDelegate.h"
3131 #include "ViewFilter.h"
3232 #include "ViewHelpers.h"
33 #include "WidgetUtils.h"
3334
3435 #include "Commands/CommandAddTask.h"
3536 #include "Commands/CommandDeleteTask.h"
5152 #include <QToolBar>
5253 #include <QTreeView>
5354
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 ) )
5758 , m_delegate( new TasksViewDelegate( this ) )
5859 , m_actionNewTask( this )
5960 , m_actionNewSubTask( this )
6162 , m_actionDeleteTask( this )
6263 , m_actionExpandTree( this )
6364 , 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 ) )
6667 , m_treeView( new QTreeView( this ) )
6768 {
69 setWindowTitle( tr( "Tasks View" ) );
6870 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 );
7074 layout->addWidget( m_treeView );
7175
7276 m_treeView->setItemDelegate( m_delegate );
7781 m_actionNewTask.setText( tr( "New &Task" ) );
7882 m_actionNewTask.setShortcut( QKeySequence::New );
7983 m_actionNewTask.setIcon( Data::newTaskIcon() );
80 toolBar->addAction( &m_actionNewTask );
84 m_toolBar->addAction( &m_actionNewTask );
8185 connect( &m_actionNewTask, SIGNAL(triggered(bool)),
8286 SLOT(actionNewTask()) );
8387
8488 m_actionNewSubTask.setText( tr( "New &Subtask" ) );
8589 m_actionNewSubTask.setShortcut( Qt::META + Qt::Key_N );
8690 m_actionNewSubTask.setIcon( Data::newSubtaskIcon() );
87 toolBar->addAction( &m_actionNewSubTask );
91 m_toolBar->addAction( &m_actionNewSubTask );
8892 connect( &m_actionNewSubTask, SIGNAL(triggered(bool)),
8993 SLOT(actionNewSubTask()) );
9094
9195 m_actionEditTask.setText( tr( "Edit Task" ) );
9296 m_actionEditTask.setShortcut( Qt::CTRL + Qt::Key_E );
9397 m_actionEditTask.setIcon( Data::editTaskIcon() );
94 toolBar->addAction( &m_actionEditTask );
98 m_toolBar->addAction( &m_actionEditTask );
9599 connect( &m_actionEditTask, SIGNAL(triggered(bool)),
96100 SLOT(actionEditTask()) );
97101
103107 #endif
104108 m_actionDeleteTask.setShortcuts(deleteShortcuts);
105109 m_actionDeleteTask.setIcon( Data::deleteTaskIcon() );
106 toolBar->addAction( &m_actionDeleteTask );
110 m_toolBar->addAction( &m_actionDeleteTask );
107111 connect( &m_actionDeleteTask, SIGNAL(triggered(bool)),
108112 SLOT(actionDeleteTask()) );
109113
119123 m_showCurrentOnly->setText( tr( "Current" ) );
120124 m_showCurrentOnly->setCheckable( true );
121125
122 toolBar->addAction( m_showCurrentOnly );
126 m_toolBar->addAction( m_showCurrentOnly );
123127 connect( m_showCurrentOnly, SIGNAL(triggered(bool)),
124128 SLOT(taskPrefilteringChanged()) );
125129
126130 m_showSubscribedOnly->setText( tr( "Selected" ) );
127131 m_showSubscribedOnly->setCheckable( true );
128132
129 toolBar->addAction( m_showSubscribedOnly );
133 m_toolBar->addAction( m_showSubscribedOnly );
130134 connect( m_showSubscribedOnly, SIGNAL(triggered(bool)),
131135 SLOT(taskPrefilteringChanged()) );
132136
134138
135139 connect( searchField, SIGNAL(textChanged(QString)),
136140 SLOT(slotFiltertextChanged(QString)) );
137 toolBar->addWidget( searchField );
141 m_toolBar->addWidget( searchField );
138142
139143 m_treeView->setEditTriggers(QAbstractItemView::EditKeyPressed);
140144 m_treeView->setExpandsOnDoubleClick(false);
145149 m_treeView->setContextMenuPolicy( Qt::CustomContextMenu );
146150 connect( m_treeView, SIGNAL(customContextMenuRequested(QPoint)),
147151 SLOT(slotContextMenuRequested(QPoint)) );
148
149 // I hate doing this but the stupid default view sizeHints suck badly.
150 setMinimumHeight( 200 );
151152
152153 // A reasonable default depth.
153154 m_treeView->expandToDepth( 0 );
268269 SLOT(slotEventActivated(EventId)) );
269270 connect( filter, SIGNAL(eventDeactivationNotice(EventId)),
270271 SLOT(slotEventDeactivated(EventId)) );
272 connect( MODEL.charmDataModel(), SIGNAL(resetGUIState()),
273 SLOT(restoreGuiState()) );
274 configurationChanged();
271275 }
272276 break;
273277 case Connected:
274278 //the model is populated when entering Connected, so delay state restore
275279 QMetaObject::invokeMethod( this, "restoreGuiState", Qt::QueuedConnection );
280 configurationChanged();
276281 break;
277282 case Disconnecting:
278283 saveGuiState();
286291
287292 void TasksView::saveGuiState()
288293 {
294 WidgetUtils::saveGeometry( this, MetaKey_TaskEditorGeometry );
289295 Q_ASSERT( m_treeView );
290296 ViewFilter* filter = ApplicationCore::instance().model().taskModel();
291297 Q_ASSERT( filter );
312318
313319 void TasksView::restoreGuiState()
314320 {
321 WidgetUtils::restoreGeometry( this, MetaKey_TaskEditorGeometry );
315322 Q_ASSERT( m_treeView );
316323 ViewFilter* filter = ApplicationCore::instance().model().taskModel();
317324 Q_ASSERT( filter );
345352
346353 m_treeView->header()->hide();
347354 configureUi();
348 }
349
350 void TasksView::setModel( ModelConnector* connector )
351 {
352 m_treeView->setModel( connector->taskModel() );
353 restoreGuiState();
355 WidgetUtils::updateToolButtonStyle( this );
354356 }
355357
356358 void TasksView::slotFiltertextChanged( const QString& filtertextRaw )
361363
362364 saveGuiState();
363365 filter->setFilterWildcard( filtertext );
366 filter->setFilterRole( TasksViewRole_Filter );
364367 if (!filtertextRaw.isEmpty())
365368 m_treeView->expandAll();
366369 else
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2929 #include <Core/Event.h>
3030 #include <Core/State.h>
3131 #include <Core/CommandEmitterInterface.h>
32 #include <Core/ViewInterface.h>
33 #include <Core/UIStateInterface.h>
3234
33 #include "ViewModeInterface.h"
35 #include <QDialog>
3436
3537 class QMenu;
3638 class TasksViewDelegate;
3739 class QToolBar;
3840 class QTreeView;
3941
40 class TasksView : public QWidget,
41 public ViewModeInterface,
42 public CommandEmitterInterface
42 class TasksView : public QDialog,
43 public UIStateInterface
4344 {
4445 Q_OBJECT
4546
4647 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;
5450
5551 void populateEditMenu( QMenu* );
52
53
5654
5755 public Q_SLOTS:
5856 void commitCommand( CharmCommand* ) override;
5957
58 void stateChanged( State previous ) override;
59 void configurationChanged() override;
60
61 void restoreGuiState() override;
62 void saveGuiState() override;
63
6064 signals:
6165 // FIXME connect to MainWindow
6266 void saveConfiguration();
63 void emitCommand( CharmCommand* );
64 void emitCommandRollback( CharmCommand* );
67 void emitCommand( CharmCommand* ) override;
68 void emitCommandRollback( CharmCommand* ) override;
6569
6670 private slots:
6771 void actionNewTask();
7781 // this method is called every time the UI actions need update, for
7882 // example when the current index changes:
7983 void configureUi();
80 void restoreGuiState() override;
8184
8285 private:
83 void saveGuiState() override;
8486
8587 // helper to retrieve selected task:
8688 Task selectedTask();
8789 void addTaskHelper( const Task& parent );
8890
91 QToolBar* m_toolBar;
8992 TasksViewDelegate* m_delegate;
9093 QAction m_actionNewTask;
9194 QAction m_actionNewSubTask;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3030
3131 TasksViewDelegate::TasksViewDelegate( QObject* parent )
3232 : QItemDelegate( parent )
33 , m_editing( false )
3433 {
3534 connect( this, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),
3635 SLOT(slotCloseEditor(QWidget*,QAbstractItemDelegate::EndEditHint)) );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
6969 };
7070 Layout doLayout( const QStyleOptionViewItem& option,
7171 const QModelIndex& index ) const;
72 mutable bool m_editing;
72 mutable bool m_editing = false;
7373 };
7474 #endif
+0
-91
Charm/Widgets/TasksWindow.cpp less more
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
-62
Charm/Widgets/TasksWindow.h less more
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
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 Author: Montel Laurent <laurent.montel@kdab.com>
4141 #include <QToolButton>
4242 #include <QVBoxLayout>
4343
44 #ifdef Q_OS_WIN
45 #include <QtWinExtras/QtWinExtras>
46 #endif
47
4448 #define CUSTOM_TASK_PROPERTY_NAME "CUSTOM_TASK_PROPERTY"
4549
4650 TimeTrackingTaskSelector::TimeTrackingTaskSelector(QWidget *parent)
5256 , m_taskSelectorButton( new QToolButton( this ) )
5357 , m_startOtherTaskAction( new QAction( tr( "Start Other Task..." ), this ) )
5458 , m_menu( new QMenu( tr( "Start Task" ), this ) )
55 , m_selectedTask( 0 )
56 , m_manuallySelectedTask( 0 )
57 , m_taskManuallySelected( false )
5859 {
5960 connect( m_menu, SIGNAL(triggered(QAction*)),
6061 SLOT(slotActionSelected(QAction*)) );
225226 m_stopGoAction->setChecked( false );
226227 m_editCommentAction->setEnabled( false );
227228 }
229 updateThumbBar();
228230 }
229231
230232 void TimeTrackingTaskSelector::slotActionSelected( QAction* action )
250252 }
251253
252254 if( taskId > 0 ) {
253 taskSelected( action->text(), taskId );
255 taskSelected( taskId );
254256 handleActiveEvents();
255257
256258 if ( !DATAMODEL->isTaskActive( taskId ) ) {
261263 }
262264 }
263265
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 )
265293 {
266294 m_selectedTask = id;
267295 m_stopGoAction->setEnabled( true );
296 const auto taskname = DATAMODEL->taskIdAndSmartNameString( id );
268297 m_taskSelectorButton->setText( escapeAmpersands( taskname ) );
269298 }
270299
280309
281310 void TimeTrackingTaskSelector::taskSelected( const WeeklySummary& summary )
282311 {
283 taskSelected( summary.taskname, summary.task );
312 taskSelected( summary.task );
284313 }
285314
286315 void TimeTrackingTaskSelector::slotManuallySelectTask()
296325 emit updateSummariesPlease();
297326 }
298327
328 void TimeTrackingTaskSelector::showEvent(QShowEvent* e)
329 {
330 updateThumbBar();
331 QWidget::showEvent( e );
332 }
333
299334
300335 #include "moc_TimeTrackingTaskSelector.cpp"
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3737 class QToolButton;
3838 class QTextEdit;
3939 class QToolBar;
40 class QWinThumbnailToolButton;
4041
4142 class TimeTrackingTaskSelector : public QWidget
4243 {
6566 void slotEditCommentClicked();
6667 void slotManuallySelectTask();
6768
69 protected:
70 void showEvent( QShowEvent* ) override;
71
6872 private:
69 void taskSelected( const QString& taskname, TaskId id );
73 void updateThumbBar();
74 void taskSelected( TaskId id );
7075 QToolButton* m_stopGoButton;
7176 QAction* m_stopGoAction;
7277 QToolButton* m_editCommentButton;
7580 QAction* m_startOtherTaskAction;
7681 QMenu *m_menu;
7782 /** The task that has been selected from the menu. */
78 TaskId m_selectedTask;
83 TaskId m_selectedTask = {};
7984 /** If the user selected a task through the "Select other task..." menu action,
8085 its Id is stored here. */
81 TaskId m_manuallySelectedTask;
86 TaskId m_manuallySelectedTask = {};
8287 /** Temporarily store that a task has been manually selected, so that it can be
8388 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
8594 };
8695
8796 #endif // TIMETRACKINGTASKSELECTOR_H
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4242 TimeTrackingView::TimeTrackingView( QWidget* parent )
4343 : QWidget( parent )
4444 , m_taskSelector( new TimeTrackingTaskSelector( this ) )
45 , m_dayOfWeek( 0 )
4645 {
4746 setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4847 // plumbing
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3838 Q_OBJECT
3939 private:
4040 struct DataField {
41 DataField() : hasHighlight( false ), storeAsActive( false ) {}
4241 QString text;
4342 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;
4645 QBrush highlight;
4746 QFont font;
4847 };
111110 PaintAttributes m_paintAttributes;
112111 DataField m_defaultField;
113112 /** Stored for performance reasons, QDate::currentDate() is expensive. */
114 int m_dayOfWeek;
113 int m_dayOfWeek = 0;
115114 /** Stored for performance reasons, QDate::shortDayName() is slow on Mac. */
116115 QString m_shortDayNames[7];
117116 /** Stored for performance reasons, QFontMetrics::elidedText is slow if called many times. */
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 Author: Mathias Hasselmann <mathias.hasselmann@kdab.com>
3535 #include "MessageBox.h"
3636 #include "MonthlyTimesheet.h"
3737 #include "MonthlyTimesheetConfigurationDialog.h"
38 #include "TemporaryValue.h"
3839 #include "TimeTrackingView.h"
39 #include "Uniquifier.h"
4040 #include "ViewHelpers.h"
4141 #include "WeeklyTimesheet.h"
4242
6363 #include <QFileInfo>
6464 #include <QMenuBar>
6565 #include <QMessageBox>
66 #include <QScriptEngine>
67 #include <QScriptValue>
6668 #include <QSettings>
6769 #include <QToolBar>
6870 #include <QtAlgorithms>
7173
7274 TimeTrackingWindow::TimeTrackingWindow( QWidget* parent )
7375 : CharmWindow( tr( "Time Tracker" ), parent )
74 , m_weeklyTimesheetDialog( nullptr )
75 , m_monthlyTimesheetDialog( nullptr )
76 , m_activityReportDialog( nullptr )
7776 , m_summaryWidget( new TimeTrackingView( this ) )
7877 , m_billDialog( new BillDialog( this ) )
7978 {
9190 SLOT(slotBillGone(int)) );
9291 connect( &m_checkCharmReleaseVersionTimer, SIGNAL(timeout()),
9392 SLOT(slotCheckForUpdatesAutomatic()) );
94 connect( &m_updateTasksDefinitionsTimer, SIGNAL(timeout()),
95 SLOT(slotSyncTasksAutomatic()) );
93 connect( &m_updateUserInfoAndTasksDefinitionsTimer, SIGNAL(timeout()),
94 SLOT(slotGetUserInfo()) );
9695
9796 //Check every 60 minutes if there are timesheets due
9897 if (CONFIGURATION.warnUnuploadedTimesheets)
106105 }
107106 #endif
108107 //Update tasks definitions once every 24h
109 m_updateTasksDefinitionsTimer.setInterval(24 * 60 * 60 * 1000);
108 m_updateUserInfoAndTasksDefinitionsTimer.setInterval(24 * 60 * 60 * 1000);
110109 QTimer::singleShot( 1000, this, SLOT(slotSyncTasksAutomatic()) );
111 m_updateTasksDefinitionsTimer.start();
110 m_updateUserInfoAndTasksDefinitionsTimer.start();
112111
113112 toolBar()->hide();
114113 }
283282 QMessageBox::critical( this, tr( "Invalid task" ),
284283 tr( "Task '%1' is no longer valid, so can't be started" ).arg( nm ) );
285284 }
285 ApplicationCore::instance().updateTaskList();
286286 }
287287
288288 void TimeTrackingWindow::slotStopEvent()
388388 void TimeTrackingWindow::showPreview( ReportConfigurationDialog* dialog, int result )
389389 {
390390 if ( result == QDialog::Accepted )
391 dialog->showReportPreviewDialog( this );
391 dialog->showReportPreviewDialog();
392392 }
393393
394394 void TimeTrackingWindow::slotExportToXml()
484484 const QString message = tr("Could not download the task list: %1").arg( job->errorString() );
485485 if ( verbose )
486486 QMessageBox::critical( this, title, message );
487 else
487 else if ( job->error() != HttpJob::HostNotFound )
488488 emit showNotification( title, message );
489489
490490 return;
620620 void TimeTrackingWindow::maybeIdle( IdleDetector* detector )
621621 {
622622 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 );
633629
634630 // handle idle merging:
635631 IdleCorrectionDialog dialog( this );
645641 // FIXME with this option, we can only change the events to
646642 // the start time of one idle period, I chose to use the last
647643 // one:
648 Q_ASSERT( !detector->idlePeriods().isEmpty() );
649644 const IdleDetector::IdlePeriod period = detector->idlePeriods().last();
650645
651646 Q_FOREACH ( EventId eventId, activeEvents ) {
705700 const QString title = success ? tr( "Tasks Import" ) : tr( "Failure setting new tasks" );
706701 if ( verbose )
707702 QMessageBox::information( this, title, detailsText );
708 else
703 else if ( !success )
709704 emit showNotification( title, detailsText );
710 getUserInfo();
711705 }
712706
713707 QSettings settings;
714708 settings.beginGroup( "httpconfig" );
709 const QString userName = settings.value("username").toString();
715710 setValueIfNotNull( &settings, QLatin1String("username"), exporter.metadata( QLatin1String("username") ) );
711 const QString currentUserName = settings.value("username").toString();
716712 setValueIfNotNull( &settings, QLatin1String("portalUrl"), exporter.metadata( QLatin1String("portal-url") ) );
717713 setValueIfNotNull( &settings, QLatin1String("loginUrl"), exporter.metadata( QLatin1String("login-url") ) );
718714 setValueIfNotNull( &settings, QLatin1String("timesheetUploadUrl"), exporter.metadata( QLatin1String("timesheet-upload-url") ) );
719715 setValueIfNotNull( &settings, QLatin1String("projectCodeDownloadUrl"), exporter.metadata( QLatin1String("project-code-download-url") ) );
720716 settings.endGroup();
721717 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") ) );
724720 settings.setValue( QLatin1String("userInfoDownloadUrl"), QLatin1String("https://lotsofcake.kdab.com/KdabHome/rest/user"));
725721 settings.endGroup();
726722
727723 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
728729 } catch( const CharmException& e ) {
729730 const QString title = tr( "Invalid Task Definitions" );
730731 const QString message = e.what().isEmpty()
738739 }
739740 }
740741
741 void TimeTrackingWindow::getUserInfo()
742 void TimeTrackingWindow::slotGetUserInfo()
742743 {
743744 if (!HttpJob::credentialsAvailable())
744745 return;
745746
746747 QSettings settings;
747748 settings.beginGroup( "httpconfig" );
748 m_user = settings.value("username").toString();
749 const QString userName = settings.value( "username" ).toString();
749750 settings.endGroup();
750751
751752 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 );
753754 settings.endGroup();
754755
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 );
759758 connect( client, SIGNAL(finished(HttpJob*)), this, SLOT(slotUserInfoDownloaded(HttpJob*)) );
760759 client->start();
761760 }
762761
763762 void TimeTrackingWindow::slotUserInfoDownloaded( HttpJob* job_ )
764763 {
764 // getUserInfo done -> sync task
765 slotSyncTasksAutomatic();
766
765767 GetUserInfoJob * job = qobject_cast<GetUserInfoJob *>( job_ );
766768 Q_ASSERT( job );
767769 if ( job->error() == HttpJob::Canceled )
768770 return;
769771
770772 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() ) );
772774 return;
773775 }
774776
775777 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
781788 QSettings settings;
782789 settings.beginGroup( "users" );
783 settings.setValue( QLatin1String("weeklyhours"), weeklyH);
790 settings.setValue( QLatin1String( "weeklyhours" ), weeklyHours );
784791 settings.endGroup();
785
786792 }
787793 #include "moc_TimeTrackingWindow.cpp"
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2828 #include "Core/ViewInterface.h"
2929 #include "Core/CharmDataModelAdapterInterface.h"
3030
31 #include "HttpClient/CheckForUpdatesJob.h"
31 #include "Charm/HttpClient/CheckForUpdatesJob.h"
3232
3333 #include "CharmWindow.h"
34 #include "WeeklySummary.h"
34 #include "Charm/WeeklySummary.h"
3535 #include "BillDialog.h"
3636
3737 class HttpJob;
5050 Q_OBJECT
5151 public:
5252 explicit TimeTrackingWindow( QWidget* parent = nullptr );
53 ~TimeTrackingWindow();
53 ~TimeTrackingWindow() override;
5454
5555 enum VerboseMode {
5656 Verbose = 0,
9898 void slotTasksDownloaded( HttpJob* );
9999 void slotUserInfoDownloaded( HttpJob* );
100100 void slotCheckForUpdatesManual();
101 void slotStartEvent( TaskId );
102 void configurationChanged() override;
101103
102104 protected:
103
104105 void insertEditMenu() override;
105106
106107 private slots:
107 void slotStartEvent( TaskId );
108108 void slotStopEvent();
109109 void slotSelectTasksToShow();
110110 void slotWeeklyTimesheetPreview( int result );
115115 void slotCheckForUpdatesAutomatic();
116116 void slotCheckForUpdates( CheckForUpdatesJob::JobData );
117117 void slotSyncTasksAutomatic();
118 void slotGetUserInfo();
118119
119 void configurationChanged() override;
120120
121121 signals:
122 void emitCommand( CharmCommand* );
123 void emitCommandRollback( CharmCommand* );
122 void emitCommand( CharmCommand* ) override;
123 void emitCommandRollback( CharmCommand* ) override;
124124 void showNotification( const QString& title, const QString& message );
125125
126126 private:
129129 void showPreview( ReportConfigurationDialog*, int result );
130130 //ugly but private:
131131 void importTasksFromDeviceOrFile( QIODevice* device, const QString& filename, bool verbose = true );
132 void getUserInfo();
133132 void startCheckForUpdates( VerboseMode mode = Silent );
134133 void informUserAboutNewRelease( const QString& releaseVersion, const QUrl& link , const QString& releaseInfoLink );
135134
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;
139138 TimeTrackingView* m_summaryWidget;
140139 QVector<WeeklySummary> m_summaries;
141140 QTimer m_checkUploadedSheetsTimer;
142141 QTimer m_checkCharmReleaseVersionTimer;
143 QTimer m_updateTasksDefinitionsTimer;
142 QTimer m_updateUserInfoAndTasksDefinitionsTimer;
144143 BillDialog *m_billDialog;
145 CheckForUpdatesJob* m_checkForUpdatesJob;
146 QString m_user;
144 bool m_idleCorrectionDialogVisible = false;
147145 };
148146
149147 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3232
3333 TimeSheetReport::TimeSheetReport( QWidget* parent )
3434 : ReportPreviewWindow( parent )
35 , m_rootTask( 0 )
36 , m_activeTasksOnly( false )
3735 {
3836 }
3937
5957
6058 void TimeSheetReport::slotSaveToXml()
6159 {
62 qDebug() << "TimeSheet::slotSaveToXml: creating XML time sheet";
6360 // first, ask for a file name:
6461 QString filename = getFileName( tr("Charm reports (*.charmreport)") );
6562 if (filename.isEmpty())
8582
8683 void TimeSheetReport::slotSaveToText()
8784 {
88 qDebug() << "TimeSheet::slotSaveToText: creating text file with totals";
8985 // first, ask for a file name:
9086 const QString filename = getFileName( "Text files (*.txt)" );
9187 if (filename.isEmpty())
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3434
3535 public:
3636 explicit TimeSheetReport( QWidget* parent = nullptr );
37 virtual ~TimeSheetReport();
37 ~TimeSheetReport() override;
3838
3939 virtual void setReportProperties( const QDate& start,
4040 const QDate& end,
7878 // properties of the report:
7979 QDate m_start;
8080 QDate m_end;
81 TaskId m_rootTask;
82 bool m_activeTasksOnly;
81 TaskId m_rootTask = {};
82 bool m_activeTasksOnly = false;
8383 };
8484
8585 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
4848 case QSystemTrayIcon::Trigger: //(single click)
4949 case QSystemTrayIcon::DoubleClick:
5050 #ifndef Q_OS_OSX
51 ApplicationCore::instance().toggleShowHide();
51 ApplicationCore::instance().showMainWindow( ApplicationCore::ShowMode::ShowAndRaise );
5252 #endif
5353 break;
5454 case QSystemTrayIcon::MiddleClick:
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
3131
3232 public:
3333 explicit TrayIcon(QObject* parent = nullptr);
34 virtual ~TrayIcon();
34 ~TrayIcon() override;
3535
3636 private Q_SLOTS:
3737 void slotActivated(QSystemTrayIcon::ActivationReason);
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
165165 QDialog::accept();
166166 }
167167
168 void WeeklyTimesheetConfigurationDialog::showReportPreviewDialog( QWidget* parent )
168 void WeeklyTimesheetConfigurationDialog::showReportPreviewDialog()
169169 {
170170 QDate start, end;
171171 int index = m_ui->comboBoxWeek->currentIndex();
179179 end = m_weekInfo[index].timespan.second;
180180 }
181181 bool activeOnly = m_ui->checkBoxActiveOnly->isChecked();
182 auto report = new WeeklyTimeSheetReport( parent );
182 auto report = new WeeklyTimeSheetReport();
183183 report->setReportProperties( start, end, m_rootTask, activeOnly );
184184 report->show();
185185 }
264264
265265 WeeklyTimeSheetReport::WeeklyTimeSheetReport( QWidget* parent )
266266 : TimeSheetReport( parent )
267 , m_weekNumber( 0 )
268 , m_yearOfWeek( 0 )
269267 {
270268 QPushButton* upload = uploadButton();
271269 connect( upload, SIGNAL(clicked()), SLOT(slotUploadTimesheet()) );
272270 connect( this, SIGNAL(anchorClicked(QUrl)), SLOT(slotLinkClicked(QUrl)) );
271
273272 if (!HttpJob::credentialsAvailable())
274273 upload->hide();
275274 }
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
5050
5151 public:
5252 explicit WeeklyTimesheetConfigurationDialog( QWidget* parent );
53 ~WeeklyTimesheetConfigurationDialog();
53 ~WeeklyTimesheetConfigurationDialog() override;
5454
55 void showReportPreviewDialog( QWidget* parent ) override;
55 void showReportPreviewDialog() override;
5656 void showEvent( QShowEvent* ) override;
5757 void setDefaultWeek( int yearOfWeek, int week );
5858
6868 private:
6969 QScopedPointer<Ui::WeeklyTimesheetConfigurationDialog> m_ui;
7070 QList<NamedTimeSpan> m_weekInfo;
71 TaskId m_rootTask;
71 TaskId m_rootTask = {};
7272 };
7373
7474 class WeeklyTimeSheetReport : public TimeSheetReport
7777
7878 public:
7979 explicit WeeklyTimeSheetReport( QWidget* parent = nullptr );
80 virtual ~WeeklyTimeSheetReport();
80 ~WeeklyTimeSheetReport() override;
8181
8282 void setReportProperties( const QDate& start,
8383 const QDate& end,
9797
9898 private:
9999 // properties of the report:
100 int m_weekNumber;
101 int m_yearOfWeek;
100 int m_weekNumber = 0;
101 int m_yearOfWeek = 0;
102102 };
103103
104104 #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
0 [Paths]
1 Plugins = plugins
5757 Charm/Widgets/EventEditor.cpp \
5858 Charm/Widgets/EventEditorDelegate.cpp \
5959 Charm/Widgets/EventView.cpp \
60 Charm/Widgets/EventWindow.cpp \
6160 Charm/Widgets/ExpandStatesHelper.cpp \
6261 Charm/Widgets/IdleCorrectionDialog.cpp \
6362 Charm/Widgets/MessageBox.cpp \
7069 Charm/Widgets/TaskEditor.cpp \
7170 Charm/Widgets/TasksView.cpp \
7271 Charm/Widgets/TasksViewDelegate.cpp \
73 Charm/Widgets/TasksWindow.cpp \
7472 Charm/Widgets/TimeTrackingView.cpp \
7573 Charm/Widgets/TimeTrackingWindow.cpp \
7674 Charm/Widgets/TimeTrackingTaskSelector.cpp \
103101 Charm/Widgets/IdleCorrectionDialog.h \
104102 Charm/Widgets/Timesheet.h \
105103 Charm/Widgets/WeeklyTimesheet.h \
106 Charm/Widgets/TasksWindow.h \
107104 Charm/Widgets/CharmWindow.h \
108105 Charm/Widgets/DateEntrySyncer.h \
109106 Charm/Widgets/MonthlyTimesheetConfigurationDialog.h \
124121 Charm/Widgets/ExpandStatesHelper.h \
125122 Charm/Widgets/SelectTaskDialog.h \
126123 Charm/Widgets/MonthlyTimesheet.h \
127 Charm/Widgets/EventWindow.h \
128124 Charm/Widgets/EventView.h \
129125 Charm/Widgets/ConfigurationDialog.h \
130126 Charm/Widgets/HttpJobProgressDialog.h \
11 #define CHARM_VERSION "@Charm_VERSION@"
22 /* Define if you have enabled the idle detection */
33 #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
66 /* Delay for idle detection, default is 360 */
77 #define CHARM_IDLE_TIME @CHARM_IDLE_TIME@
88 /* Define the url where to check for updates */
1515 /* Defined if local socket command interface is enabled */
1616 #cmakedefine CHARM_CI_LOCALSERVER
1717 #endif
18 /* Defined if systemwide keychain is used */
19 #cmakedefine QTKEYCHAIN_SYSTEM
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
2828
2929 CharmCommand::CharmCommand( const QString& description, QObject *parent )
3030 : QObject( parent ),
31 m_owner(0),
3231 m_description(description)
3332 {
3433 CommandEmitterInterface* emitter = dynamic_cast<CommandEmitterInterface*>( parent );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
6262
6363 public:
6464 explicit CharmCommand( const QString& description, QObject* parent = nullptr );
65 virtual ~CharmCommand();
65 ~CharmCommand() override;
6666
6767 QString description() const;
6868
9494 private:
9595 CharmCommand( const CharmCommand& ); // disallow copying
9696
97 CommandEmitterInterface* m_owner;
97 CommandEmitterInterface* m_owner = nullptr;
9898 const QString m_description;
9999 };
100100
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3939 const QString MetaKey_MainWindowGUIStateShowCurrentTasks = "MainWindowGUIStateShowCurrentTasks";
4040 const QString MetaKey_TimeTrackerGeometry = "TimeTrackerGeometry";
4141 const QString MetaKey_TimeTrackerVisible = "TimeTrackerVisible";
42 const QString MetaKey_EventEditorGeometry = "EventEditorGeometry";
43 const QString MetaKey_TaskEditorGeometry = "TaskEditorGeometry";
4244 const QString MetaKey_ReportsRecentSavePath = "ReportsRecentSavePath";
4345 const QString MetaKey_ExportToXmlRecentSavePath = "ExportToXmlSavePath";
4446 const QString MetaKey_TimesheetSubscribedOnly = "TimesheetSubscribedOnly";
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
5050 extern const QString MetaKey_MainWindowGUIStateShowCurrentTasks;
5151 extern const QString MetaKey_TimeTrackerGeometry;
5252 extern const QString MetaKey_TimeTrackerVisible;
53 extern const QString MetaKey_EventEditorGeometry;
54 extern const QString MetaKey_TaskEditorGeometry;
5355 extern const QString MetaKey_ReportsRecentSavePath;
5456 extern const QString MetaKey_ExportToXmlRecentSavePath;
5557 extern const QString MetaKey_TimesheetActiveOnly;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
138138 Q_FOREACH( auto adapter, m_adapters )
139139 adapter->taskAdded( task.id() );
140140 } 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";
143143 }
144144 }
145145
221221 if ( ! eventExists( events[i].id() ) ) {
222222 m_events[ events[i].id() ] = events[i];
223223 } 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";
226226 }
227227 }
228228
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
5454
5555 public:
5656 CharmDataModel();
57 ~CharmDataModel();
57 ~CharmDataModel() override;
5858
5959 void stateChanged( State previous, State next );
6060 /** Register a CharmDataModelAdapterInterface. */
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
4141 }
4242
4343 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 )
5845 {
5946 }
6047
61 Configuration::Configuration( bool _eventsInLeafsOnly, bool _oneEventAtATime, User _user,
62 TaskPrefilteringMode _taskPrefilteringMode,
48 Configuration::Configuration( TaskPrefilteringMode _taskPrefilteringMode,
6349 TimeTrackerFontSize _timeTrackerFontSize,
6450 DurationFormat _durationFormat, bool _detectIdling,
6551 Qt::ToolButtonStyle _buttonstyle, bool _showStatusBar,
7561 , requestEventComment( _requestEventComment )
7662 , enableCommandInterface( _enableCommandInterface )
7763 , configurationName( DEFAULT_CONFIG_GROUP )
78 , installationId( 0 )
79 , newDatabase( false )
80 , failure( false )
81 , taskPaddingLength( 6 ) // arbitrary
8264 {
8365 }
8466
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
6868 void dump( const QString& why = QString::null );
6969
7070 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;
8080
8181 // these are stored in QSettings, since we need this information to locate and open the database:
8282 QString configurationName;
83 int installationId;
83 int installationId = 0;
8484 QString localStorageType; // SqLite, MySql, ...
8585 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
8888 QString failureMessage; // a message to show the user if something is wrong with the configuration
8989
9090 // appearance properties
91 int taskPaddingLength; // auto-determined
91 int taskPaddingLength = 6; // arbitrary
9292 private:
9393 // allow test classes to create configuration objects (tests are
9494 // the only application that can have (test) multiple
9696 friend class SqLiteStorageTests;
9797 friend class ControllerTests;
9898 // 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,
101100 DurationFormat durationFormat, bool detectIdling, Qt::ToolButtonStyle buttonstyle,
102101 bool showStatusBar, bool warnUnuploadedTimesheets, bool _requestEventComment,
103102 bool enableCommandInterface );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3939 Controller::Controller( QObject* parent_ )
4040 : QObject( parent_ )
4141 , ControllerInterface()
42 , m_storage( nullptr )
4342 {
4443 }
4544
10099
101100 bool Controller::addTask( const Task& task )
102101 {
103 qDebug() << Q_FUNC_INFO << "adding task" << task.id()
104 << "to parent" << task.parent();
105102 if ( m_storage->addTask( task ) ) {
106103 updateSubscriptionForTask( task );
107104 emit taskAdded( task );
115112
116113 bool Controller::modifyTask( const Task& task )
117114 {
118 // find it
119 qDebug() << Q_FUNC_INFO << "committing changes to task"
120 << task.id();
121115 // modify the task itself:
122116 bool result = m_storage->modifyTask( task );
123117 Q_ASSERT( result );
124118 if ( ! result ) {
125 qDebug() << Q_FUNC_INFO << "modifyTask failed!";
119 qCritical() << Q_FUNC_INFO << "modifyTask failed!";
126120 return result;
127121 }
128122
134128
135129 bool Controller::deleteTask( const Task& task )
136130 {
137 qDebug() << Q_FUNC_INFO << "deleting task" << task.id();
138131 if ( m_storage->deleteTask( task ) ) {
139132 m_storage->deleteSubscription( CONFIGURATION.user, task );
140133 emit taskDeleted( task );
147140
148141 bool Controller::setAllTasks( const TaskList& tasks )
149142 {
150 qDebug() << Q_FUNC_INFO << "replacing all tasks";
151143 if ( m_storage->setAllTasks( CONFIGURATION.user, tasks ) ) {
152144 const TaskList newTasks = m_storage->getAllTasks();
153145 // tell the view about the existing tasks;
196188 emit readyToQuit();
197189 if ( m_storage ) {
198190 // this will still leave Qt complaining about a repeated connection
199 // qDebug() << "Application::enterConnectingState: closing existing storage interface";
200191 m_storage->disconnect();
201192 delete m_storage;
202193 m_storage = nullptr;
369360 eventsElement.appendChild( element );
370361 }
371362 root.appendChild( eventsElement );
372 // qDebug() << document.toString( 4 );
373363 return document;
374364 }
375365
406396 databaseSchemaVersion = rootElement.attribute( "version" ).toInt( &ok );
407397 if ( !ok ) throw XmlSerializationException( QObject::tr( "Syntax error, no version attribute found." ) );
408398
409 QDomElement metadataElement = rootElement.firstChildElement( MetaDataElement );
410399 QDomElement tasksElement = rootElement.firstChildElement( TasksElement );
411400 for ( QDomElement element = tasksElement.firstChildElement( Task::tagName() );
412401 !element.isNull(); element = element.nextSiblingElement( Task::tagName() ) ) {
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Olivier JG <olivier.de.gaalon@kdab.com>
4040
4141 public:
4242 explicit Controller( QObject* parent = nullptr );
43 ~Controller();
43 ~Controller() override;
4444
4545 void stateChanged( State previous, State next ) override;
4646 void persistMetaData( Configuration& ) override;
7272 void rollbackCommand ( CharmCommand* ) override;
7373
7474 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;
7878 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;
8484 void currentBackendStatus( const QString& text );
8585
86 void commandCompleted( CharmCommand* );
86 void commandCompleted( CharmCommand* ) override;
8787
8888 private:
8989 void updateSubscriptionForTask( const Task& );
9090
9191 template<class T> void loadConfigValue( const QString &key, T &configValue ) const;
92 StorageInterface* m_storage;
92 StorageInterface* m_storage = nullptr;
9393 };
9494
9595 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 Author: Olivier JG <olivier.de.gaalon@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 Author: Olivier JG <olivier.de.gaalon@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
2727 #include <QDomText>
2828
2929 Event::Event()
30 : m_userid()
31 , m_reportid()
32 , m_installationId()
33 , m_id()
34 , m_taskId()
3530 {
3631 }
3732
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
9393
9494 private:
9595 /** The id of the user who owns the event. */
96 int m_userid;
96 int m_userid = {};
9797 /** The report id. This field is only useful
9898 * if the event is imported from a report.
9999 */
100 int m_reportid;
100 int m_reportid = {};
101101 /** The installation-unique id of the event. */
102 int m_installationId;
103 int m_id;
102 int m_installationId = {};
103 int m_id = {};
104104 /** The task this event belongs to. */
105 TaskId m_taskId;
105 TaskId m_taskId = {};
106106 /** A possible user comment.
107107 May be empty. */
108108 QString m_comment;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
5959
6060 void SmartNameCache::deleteTask( const Task& task )
6161 {
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() );
6363 if ( it != m_tasks.end() ) {
6464 m_tasks.erase( it );
6565 regenerateSmartNames();
7474
7575 Task SmartNameCache::findTask( TaskId id ) const
7676 {
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() );
7878 if ( it != m_tasks.constEnd() )
7979 return *it;
8080 else
123123 it != byName.constEnd();
124124 ++it ) {
125125 const QString currentName = it.key();
126 const QVector<TaskParentPair>& taskPairs = it.value();
126 const auto& taskPairs = it.value();
127127 Q_ASSERT( !taskPairs.isEmpty() );
128128 if ( taskPairs.size() == 1 || cannotMakeUnique.contains( currentName ) ) {
129129 Q_FOREACH( const TaskParentPair& i, taskPairs )
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
110110 SqLiteStorage::SqLiteStorage()
111111 : SqlStorage()
112112 , m_database( QSqlDatabase::addDatabase( DriverName, DatabaseName ) )
113 , m_installationId( 0 )
114113 {
115114 if ( ! QSqlDatabase::isDriverAvailable( DriverName ) ) {
116115 throw CharmException( QObject::tr( "QSQLITE driver not available" ) );
190189 return false;
191190 }
192191
193 // connect:
194 // qDebug() << "SqLiteStorage::connect: creating or opening local sqlite database at "
195 // << fileInfo.absoluteFilePath();
196
197192 const QDir oldDatabaseDirectory( QDir::homePath() + QDir::separator() + ".Charm" );
198193 if ( oldDatabaseDirectory.exists() )
199194 migrateDatabaseDirectory( oldDatabaseDirectory, fileInfo.dir() );
223218 return false;
224219 }
225220
226 // qDebug() << "SqLiteStorage::connect: SUCCESS - connected to database";
227221 if ( ! verifyDatabase() )
228222 {
229 // qDebug() << "SqLiteStorage::connect: empty database, filling in the blanks";
230223 if ( !createDatabase( configuration ) )
231224 {
232225 configuration.failureMessage = QObject::tr( "SqLiteStorage::connect: error creating default database contents" );
238231 {
239232 const int userid = configuration.user.id();
240233 const User user = getUser( userid );
241 // qDebug() << "SqLiteStorage::connect: found user" << user.name()
242 // << "for id" << userid << ( user.isValid() ? "(valid)" : "(invalid)");
243234 if ( !user.isValid() )
244235 return false;
245236
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Mike McQuaid <mike.mcquaid@kdab.com>
5252
5353 private:
5454 QSqlDatabase m_database;
55 int m_installationId;
55 int m_installationId = 0;
5656 };
5757
5858 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
2929 #include <QSqlError>
3030
3131 SqlRaiiTransactor::SqlRaiiTransactor( QSqlDatabase& database )
32 : m_active( false ),
33 m_database ( database )
32 : m_database ( database )
3433 {
3534 if ( ! database.driver()->hasFeature( QSqlDriver::Transactions ) ) {
3635 throw TransactionException( QObject::tr( "Database driver does not support transactions." ) );
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
3434
3535 bool commit();
3636 private:
37 bool m_active;
37 bool m_active = false;
3838 QSqlDatabase& m_database;
3939 };
4040
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
458458
459459 void SqlStorage::stateChanged(State previous)
460460 {
461 Q_UNUSED(previous);
461 Q_UNUSED(previous)
462462 // atm, SqlStorage does not care about state
463 // qDebug() << "SqlStorage::stateChanged: NOT IMPLEMENTED"
464463 }
465464
466465 User SqlStorage::getUser(int userid)
486485 }
487486 else
488487 {
489 qDebug() << "SqlStorage::getUser: no user with id" << userid;
488 qCritical() << "SqlStorage::getUser: no user with id" << userid;
490489 }
491490 }
492491
532531 }
533532 else
534533 {
535 qDebug()
534 qCritical()
536535 << "SqlStorage::makeUser: FAILED to find newly created user";
537536 return user;
538537 }
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3232 #include <algorithm>
3333
3434 Task::Task()
35 : m_id(0)
36 , m_parent(0)
37 , m_subscribed(false)
38 , m_trackable(true)
3935 {
4036 }
4137
4440 , m_parent(parent)
4541 , m_name(name)
4642 , m_subscribed(subscribed)
47 , m_trackable(true)
4843 {
4944 }
5045
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
104104 static bool lowerTaskId( const Task& left, const Task& right );
105105
106106 private:
107 int m_id;
108 int m_parent;
107 int m_id = 0;
108 int m_parent = 0;
109109 QString m_name;
110 bool m_subscribed;
111 bool m_trackable;
110 bool m_subscribed = false;
111 bool m_trackable = true;
112112 /** The timestamp from which the task is valid. */
113113 QDateTime m_validFrom;
114114 /** The timestamp after which the task becomes invalid. */
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
2424 #include "CharmExceptions.h"
2525
2626 TaskListMerger::TaskListMerger()
27 : m_resultsValid( false )
2827 {
2928 }
3029
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
5858 void verifyTaskList( const TaskList& tasks );
5959 void calculateResults() const;
6060
61 mutable bool m_resultsValid;
61 mutable bool m_resultsValid = false;
6262 TaskList m_oldTasks;
6363 TaskList m_newTasks;
6464 mutable TaskList m_results;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
2626 #include <QtDebug>
2727
2828 TaskTreeItem::TaskTreeItem()
29 : m_parent( 0 )
3029 {
3130 }
3231
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
7575 TaskIdList childIds() const;
7676
7777 private:
78 TaskTreeItem* m_parent;
78 TaskTreeItem* m_parent = nullptr;
7979 ConstPointerList m_children;
8080 Task m_task;
8181 };
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 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
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
2828 class User {
2929 public:
3030 User()
31 : m_id( 0 )
3231 {}
3332
3433 User( const QString& name, int id )
6362
6463 private:
6564 QString m_name;
66 int m_id;
65 int m_id = 0;
6766 };
6867
6968 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
2626 #include "Task.h"
2727 #include "State.h"
2828 #include "Event.h"
29 #include "UIStateInterface.h"
2930
3031 class CharmCommand;
3132
32 class ViewInterface
33 class ViewInterface :
34 public UIStateInterface
3335 {
3436 public:
35 virtual ~ViewInterface() {} // keep compiler happy
37 virtual ~ViewInterface() {};
3638
3739 // 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;
4140 virtual void saveConfiguration() = 0;
4241
43 virtual void emitCommand( CharmCommand* ) = 0;
44 virtual void emitCommandRollback( CharmCommand* ) = 0;
4542 virtual void sendCommand( CharmCommand* ) = 0;
4643 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
4846
4947 // restore the view
5048 virtual void restore() = 0;
5149 // quit the application
5250 virtual void quit() = 0;
5351
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;
5463 };
5564
5665 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
121121 void TaskExport::writeTo( const QString& filename, const TaskList& tasks )
122122 {
123123 QDomDocument document = XmlSerialization::createXmlTemplate( reportType() );
124 QDomElement metadata = XmlSerialization::metadataElement( document );
125124 QDomElement report = XmlSerialization::reportElement( document );
126125
127126 // write tasks
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
2323 ADD_EXECUTABLE( ControllerTests ${ControllerTests_SRCS} )
2424 TARGET_LINK_LIBRARIES( ControllerTests ${TEST_LIBRARIES} )
2525 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} )
2634
2735 SET( DatesTests_SRCS DatesTests.cpp )
2836 ADD_EXECUTABLE( DatesTests ${DatesTests_SRCS} )
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3232
3333 CharmDataModelTests::CharmDataModelTests()
3434 : QObject()
35 , m_referenceModel( nullptr )
3635 {
3736 }
3837
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
4242 void cleanupTestCase();
4343
4444 private:
45 CharmDataModel* m_referenceModel;
45 CharmDataModel* m_referenceModel = nullptr;
4646 };
4747
4848 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3636
3737 ControllerTests::ControllerTests()
3838 : QObject()
39 , m_controller( nullptr )
4039 , m_configuration( Configuration::instance() )
4140 , m_localPath( "./ControllerTestDatabase.db" )
42 , m_eventListReceived( false )
43 , m_taskListReceived( false )
4441 {
4542 }
4643
7976 }
8077
8178 void ControllerTests:: persistProvideMetaDataTest()
82 { // stick with user id 0, it is not persisted in the DB, and 0 is the default
79 {
8380 Configuration configs[] = {
84 Configuration( true, true, User( "bla", 0 ), Configuration::TaskPrefilter_ShowAll, Configuration::TimeTrackerFont_Small,
81 Configuration( Configuration::TaskPrefilter_ShowAll, Configuration::TimeTrackerFont_Small,
8582 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,
8784 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,
8986 Configuration::Minutes, true, Qt::ToolButtonTextBesideIcon, true, true, true, false ),
9087 };
9188 const int NumberOfConfigurations = sizeof configs / sizeof configs[0];
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
6767
6868 private:
6969
70 ControllerInterface* m_controller;
70 ControllerInterface* m_controller = nullptr;
7171 Configuration& m_configuration;
7272 QString m_localPath;
7373 EventList m_currentEvents;
74 bool m_eventListReceived;
74 bool m_eventListReceived = false;
7575 TaskList m_definedTasks;
76 bool m_taskListReceived;
76 bool m_taskListReceived = false;
7777 };
7878
7979 #endif
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 Author: Olivier JG <olivier.de.gaalon@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88 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
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
3333 Q_OBJECT
3434 public:
3535 SqLiteStorageTests();
36 ~SqLiteStorageTests();
36 ~SqLiteStorageTests() override;
3737
3838 private:
3939 StorageInterface* m_storage;
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
3939
4040 TestApplication::TestApplication(const QString &databasePath, QObject *parent)
4141 : QObject(parent)
42 , m_controller( nullptr )
43 , m_model( nullptr )
4442 , m_configuration( &Configuration::instance() )
4543 , m_localPath( databasePath )
4644 {
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
4848 QString databasePath() const;
4949
5050 private:
51 Controller* m_controller;
52 CharmDataModel* m_model;
51 Controller* m_controller = nullptr;
52 CharmDataModel* m_model = nullptr;
5353 Configuration* m_configuration;
5454 QString m_localPath;
5555 };
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Franck Arrecot <franck.arrecot@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Franck Arrecot <franck.arrecot@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
2323 #include "TimeSpanTests.h"
2424 #include "Core/TimeSpans.h"
2525 #include <QtTest/QtTest>
26
27 #include <QDebug>
2826
2927 void TimeSpanTests::testTimeSpans()
3028 {
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Frank Osterfeld <frank.osterfeld@kdab.com>
7474 QDomDocument document( "testdocument" );
7575 Q_FOREACH( const Event& event, eventsToTest ) {
7676 QDomElement element = event.toXml( document );
77 // // temp:
78 // document.appendChild( element );
79 // qDebug() << document.toString( 4 );
80 // // ^^^
77
8178 try {
8279 Event readEvent = Event::fromXml( element );
8380 // the extra tests are mostly to immidiately see what is wrong:
176173 }
177174 QVERIFY( tasks == result );
178175 } catch( const XmlSerializationException& e ) {
179 qDebug() << "Failure reading tasks:" << e.what();
176 qCritical() << "Failure reading tasks:" << e.what();
180177 QFAIL( "Read tasks are not equal to the written ones" );
181178 }
182179
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88 Author: Sebastian Sauer <sebastian.sauer@kdab.com>
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
22
33 This file is part of Charm, a task-based time tracking application.
44
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
66
77 Author: Mirko Boehm <mirko.boehm@kdab.com>
88
00 Format: 1.0
11 Source: charmtimetracker
2 Version: 1.9.0
2 Version: 1.10.0
33 Binary: charmtimetracker
44 Maintainer: Frank Osterfeld <frank.osterfeld@kdab.com>
55 Architecture: any
66 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
00 Name: charmtimetracker
1 Version: 1.9.0
1 Version: 1.10.0
22 Release: 0
33 Summary: Time Tracking Application
44 Source: %{name}-%{version}.tar.gz
6666 %{_prefix}/bin/charmtimetracker
6767
6868 %changelog
69 * Mon Oct 05 2015 Allen Winter <allen.winter@kdab.com> 1.10.0
70 - 1.10.0 release
6971 * Thu Mar 26 2015 Allen Winter <allen.winter@kdab.com> 1.9.0
7072 - 1.9.0 release
7173 * 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
07 charmtimetracker (1.9.0) stable; urgency=low
18
29 * 1.9.0 release
310
411 -- Allen Winter <allen.winter@kdab.com> Thu, 26 Mar 2015 10:30:00 -0500
512
6
13
714 charmtimetracker (1.8.0) stable; urgency=low
815
916 * 1.8.0 release
00 #!/usr/bin/make -f
1 DEB_CMAKE_EXTRA_FLAGS = -DCharm_VERSION=1.9.0
1 DEB_CMAKE_EXTRA_FLAGS = -DCharm_VERSION=1.10.0
22 include /usr/share/cdbs/1/rules/debhelper.mk
33 include /usr/share/cdbs/1/class/cmake.mk