summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/gammu/gammu.pro5
-rw-r--r--kaddressbook/kaddressbook.pro6
-rw-r--r--korganizer/calendarview.cpp6
-rw-r--r--korganizer/korganizer.pro10
-rw-r--r--korganizer/kotodoview.h1
-rw-r--r--korganizer/koviewmanager.cpp5
6 files changed, 25 insertions, 8 deletions
diff --git a/gammu/emb/gammu/gammu.pro b/gammu/emb/gammu/gammu.pro
index 55bfdec..c8aa3f0 100644
--- a/gammu/emb/gammu/gammu.pro
+++ b/gammu/emb/gammu/gammu.pro
@@ -1,64 +1,65 @@
1###################################################################### 1######################################################################
2# Automatically generated by qmake (1.07a) Fri Jul 30 22:22:02 2004 2# Automatically generated by qmake (1.07a) Fri Jul 30 22:22:02 2004
3###################################################################### 3######################################################################
4 4
5TEMPLATE = app 5TEMPLATE = app
6DEPENDPATH += msvc06.mak \ 6DEPENDPATH += msvc06.mak \
7 msvc2003.mak \ 7 msvc2003.mak \
8 smsd \ 8 smsd \
9 depend/nokia \ 9 depend/nokia \
10 depend/siemens \ 10 depend/siemens \
11 depend/nokia/dct3trac 11 depend/nokia/dct3trac
12INCLUDEPATH += . smsd depend/nokia depend/nokia/dct3trac depend/siemens 12INCLUDEPATH += . smsd depend/nokia depend/nokia/dct3trac depend/siemens
13 CONFIG = warn_off release console 13 CONFIG += warn_off console
14# Input 14# Input
15 15
16include( ../../../variables.pri )
16HEADERS += gammu.h \ 17HEADERS += gammu.h \
17 sniff.h \ 18 sniff.h \
18 smsd/s_files.h \ 19 smsd/s_files.h \
19 smsd/s_mysql.h \ 20 smsd/s_mysql.h \
20 smsd/smsdcore.h \ 21 smsd/smsdcore.h \
21 depend/nokia/dct3.h \ 22 depend/nokia/dct3.h \
22 depend/nokia/dct4.h \ 23 depend/nokia/dct4.h \
23 depend/siemens/chiffre.h \ 24 depend/siemens/chiffre.h \
24 depend/siemens/dsiemens.h \ 25 depend/siemens/dsiemens.h \
25 depend/nokia/dct3trac/type-cc.h \ 26 depend/nokia/dct3trac/type-cc.h \
26 depend/nokia/dct3trac/type-mm.h \ 27 depend/nokia/dct3trac/type-mm.h \
27 depend/nokia/dct3trac/type-rr.h \ 28 depend/nokia/dct3trac/type-rr.h \
28 depend/nokia/dct3trac/type-sms.h \ 29 depend/nokia/dct3trac/type-sms.h \
29 depend/nokia/dct3trac/type-ss.h \ 30 depend/nokia/dct3trac/type-ss.h \
30 depend/nokia/dct3trac/wmx-gsm.h \ 31 depend/nokia/dct3trac/wmx-gsm.h \
31 depend/nokia/dct3trac/wmx-list.h \ 32 depend/nokia/dct3trac/wmx-list.h \
32 depend/nokia/dct3trac/wmx-sim.h \ 33 depend/nokia/dct3trac/wmx-sim.h \
33 depend/nokia/dct3trac/wmx-util.h \ 34 depend/nokia/dct3trac/wmx-util.h \
34 depend/nokia/dct3trac/wmx.h 35 depend/nokia/dct3trac/wmx.h
35SOURCES += gammu.c \ 36SOURCES += gammu.c \
36 sniff.c \ 37 sniff.c \
37 smsd/s_files.c \ 38 smsd/s_files.c \
38 smsd/smsdcore.c \ 39 smsd/smsdcore.c \
39 depend/nokia/dct3.c \ 40 depend/nokia/dct3.c \
40 depend/nokia/dct4.c \ 41 depend/nokia/dct4.c \
41 depend/siemens/chiffre.c \ 42 depend/siemens/chiffre.c \
42 depend/siemens/dsiemens.c \ 43 depend/siemens/dsiemens.c \
43 depend/nokia/dct3trac/wmx-gsm.c \ 44 depend/nokia/dct3trac/wmx-gsm.c \
44 depend/nokia/dct3trac/wmx-list.c \ 45 depend/nokia/dct3trac/wmx-list.c \
45 depend/nokia/dct3trac/wmx-sim.c \ 46 depend/nokia/dct3trac/wmx-sim.c \
46 depend/nokia/dct3trac/wmx-util.c \ 47 depend/nokia/dct3trac/wmx-util.c \
47 depend/nokia/dct3trac/wmx.c 48 depend/nokia/dct3trac/wmx.c
48unix : { 49unix : {
49LIBS += ../../../bin/libmicrogammu.so /usr/lib/libpthread.so 50LIBS += ../../../bin/libmicrogammu.so /usr/lib/libpthread.so
50# bluetooth disabled for now 51# bluetooth disabled for now
51#/usr/lib/libbluetooth.so /usr/lib/libsdp.so 52#/usr/lib/libbluetooth.so /usr/lib/libsdp.so
52OBJECTS_DIR = obj/unix 53OBJECTS_DIR = obj/unix
53} 54}
54win32 : { 55win32 : {
55 CONFIG = qt warn_on 56 CONFIG += qt warn_on
56#LIBS += mfc71u.lib 57#LIBS += mfc71u.lib
57LIBS += libc.lib 58LIBS += libc.lib
58#LIBS += msvcrt.lib 59#LIBS += msvcrt.lib
59QMAKE_LINK += /NODEFAULTLIB:msvcrt 60QMAKE_LINK += /NODEFAULTLIB:msvcrt
60LIBS += ../../../bin/microgammu.lib 61LIBS += ../../../bin/microgammu.lib
61OBJECTS_DIR = obj/win 62OBJECTS_DIR = obj/win
62} 63}
63DESTDIR = ../../../bin 64DESTDIR = ../../../bin
64TARGET = kammu 65TARGET = kammu
diff --git a/kaddressbook/kaddressbook.pro b/kaddressbook/kaddressbook.pro
index 7203eb3..f9d22d5 100644
--- a/kaddressbook/kaddressbook.pro
+++ b/kaddressbook/kaddressbook.pro
@@ -1,198 +1,202 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3 TARGET = kapi 3 TARGET = kapi
4DESTDIR= ../bin 4DESTDIR= ../bin
5 5
6include( ../variables.pri ) 6include( ../variables.pri )
7 7
8 8
9INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../ interfaces 9INCLUDEPATH += . ./details ./features ./xxport ../libkdepim ../microkde ../microkde/kdecore ../microkde/kutils ../microkde/kio/kfile ../microkde/kio/kio ../microkde/kdeui ../microkde/kresources ../kabc ../ interfaces
10DEFINES += KAB_EMBEDDED KAB_NOSPLITTER DESKTOP_VERSION 10DEFINES += KAB_EMBEDDED KAB_NOSPLITTER DESKTOP_VERSION
11 11
12unix : { 12unix : {
13 13
14staticlib: { 14staticlib: {
15LIBS += ../bin/libmicrokabc_qtopia.a 15LIBS += ../bin/libmicrokabc_qtopia.a
16LIBS += ../bin/libmicrokabc_file.a 16LIBS += ../bin/libmicrokabc_file.a
17LIBS += ../bin/libmicrokabc_dir.a 17LIBS += ../bin/libmicrokabc_dir.a
18LIBS += ../bin/libmicrokdepim.a 18LIBS += ../bin/libmicrokdepim.a
19LIBS += ../bin/libmicrokcal.a 19LIBS += ../bin/libmicrokcal.a
20LIBS += ../bin/libmicrokabc.a 20LIBS += ../bin/libmicrokabc.a
21LIBS += ../bin/libmicrokde.a 21LIBS += ../bin/libmicrokde.a
22LIBS += ../bin/libmicrokabc_qtopia.a 22LIBS += ../bin/libmicrokabc_qtopia.a
23LIBS += ../bin/libmicrokabc_file.a 23LIBS += ../bin/libmicrokabc_file.a
24LIBS += ../bin/libmicrokabc_dir.a 24LIBS += ../bin/libmicrokabc_dir.a
25LIBS += ../bin/libmicrokdepim.a 25LIBS += ../bin/libmicrokdepim.a
26LIBS += ../bin/libmicrokcal.a 26LIBS += ../bin/libmicrokcal.a
27LIBS += ../bin/libmicrokabc.a 27LIBS += ../bin/libmicrokabc.a
28LIBS += ../bin/libmicrokde.a 28LIBS += ../bin/libmicrokde.a
29LIBS += ../libical/lib/libical.a 29LIBS += ../libical/lib/libical.a
30LIBS += ../libical/lib/libicalss.a 30LIBS += ../libical/lib/libicalss.a
31 31
32} else { 32} else {
33LIBS += ../bin/libmicrokdepim.so 33LIBS += ../bin/libmicrokdepim.so
34LIBS += ../bin/libmicrokde.so 34LIBS += ../bin/libmicrokde.so
35LIBS += ../bin/libmicrokabc.so 35LIBS += ../bin/libmicrokabc.so
36LIBS += ../bin/libmicrokcal.so 36LIBS += ../bin/libmicrokcal.so
37#LIBS += -lldap 37#LIBS += -lldap
38} 38}
39OBJECTS_DIR = obj/unix 39OBJECTS_DIR = obj/unix
40MOC_DIR = moc/unix 40MOC_DIR = moc/unix
41} 41}
42win32: { 42win32: {
43RC_FILE = winicons.rc 43RC_FILE = winicons.rc
44DEFINES += _WIN32_ 44DEFINES += _WIN32_
45LIBS += ../bin/microkdepim.lib 45LIBS += ../bin/microkdepim.lib
46LIBS += ../bin/microkcal.lib 46LIBS += ../bin/microkcal.lib
47LIBS += ../bin/microkde.lib 47LIBS += ../bin/microkde.lib
48LIBS += ../bin/microkabc.lib 48LIBS += ../bin/microkabc.lib
49QMAKE_LINK += /NODEFAULTLIB:LIBC 49QMAKE_LINK += /NODEFAULTLIB:LIBC
50OBJECTS_DIR = obj/win 50OBJECTS_DIR = obj/win
51MOC_DIR = moc/win 51MOC_DIR = moc/win
52#olimport section 52#olimport section
53#blabla: { 53#blabla: {
54 54debug: {
55LIBS += mfc71ud.lib
56}
57release: {
55LIBS += mfc71u.lib 58LIBS += mfc71u.lib
59}
56DEFINES += _OL_IMPORT_ 60DEFINES += _OL_IMPORT_
57HEADERS = ../outport/msoutl9.h \ 61HEADERS = ../outport/msoutl9.h \
58 kaimportoldialog.h 62 kaimportoldialog.h
59SOURCES = ../outport/msoutl9.cpp \ 63SOURCES = ../outport/msoutl9.cpp \
60 kaimportoldialog.cpp 64 kaimportoldialog.cpp
61#} 65#}
62#olimport section end 66#olimport section end
63} 67}
64 68
65INTERFACES = \ 69INTERFACES = \
66# filteredit_base.ui \ 70# filteredit_base.ui \
67# kofilterview_base.ui \ 71# kofilterview_base.ui \
68 72
69HEADERS += \ 73HEADERS += \
70features/mergewidget.h \ 74features/mergewidget.h \
71features/distributionlistwidget.h \ 75features/distributionlistwidget.h \
72kcmconfigs/addresseewidget.h \ 76kcmconfigs/addresseewidget.h \
73kcmconfigs/extensionconfigdialog.h \ 77kcmconfigs/extensionconfigdialog.h \
74kcmconfigs/kcmkabconfig.h \ 78kcmconfigs/kcmkabconfig.h \
75kcmconfigs/kabconfigwidget.h \ 79kcmconfigs/kabconfigwidget.h \
76addresseeeditordialog.h \ 80addresseeeditordialog.h \
77addresseeeditorwidget.h \ 81addresseeeditorwidget.h \
78addresseditwidget.h \ 82addresseditwidget.h \
79addresseeconfig.h \ 83addresseeconfig.h \
80addresseeutil.h \ 84addresseeutil.h \
81emaileditwidget.h \ 85emaileditwidget.h \
82filtereditdialog.h \ 86filtereditdialog.h \
83kaddressbookmain.h \ 87kaddressbookmain.h \
84kabprefs.h \ 88kabprefs.h \
85kabcore.h \ 89kabcore.h \
86viewmanager.h \ 90viewmanager.h \
87extensionmanager.h \ 91extensionmanager.h \
88extensionwidget.h \ 92extensionwidget.h \
89kaddressbookview.h \ 93kaddressbookview.h \
90geowidget.h \ 94geowidget.h \
91imagewidget.h \ 95imagewidget.h \
92incsearchwidget.h \ 96incsearchwidget.h \
93jumpbuttonbar.h \ 97jumpbuttonbar.h \
94phoneeditwidget.h \ 98phoneeditwidget.h \
95secrecywidget.h \ 99secrecywidget.h \
96keywidget.h \ 100keywidget.h \
97nameeditdialog.h \ 101nameeditdialog.h \
98filter.h \ 102filter.h \
99addviewdialog.h \ 103addviewdialog.h \
100configurewidget.h \ 104configurewidget.h \
101viewconfigurewidget.h \ 105viewconfigurewidget.h \
102viewconfigurefieldspage.h \ 106viewconfigurefieldspage.h \
103viewconfigurefilterpage.h \ 107viewconfigurefilterpage.h \
104typecombo.h \ 108typecombo.h \
105undo.h \ 109undo.h \
106undocmds.h \ 110undocmds.h \
107xxportmanager.h \ 111xxportmanager.h \
108xxportobject.h \ 112xxportobject.h \
109xxportselectdialog.h \ 113xxportselectdialog.h \
110details/detailsviewcontainer.h \ 114details/detailsviewcontainer.h \
111details/look_basic.h \ 115details/look_basic.h \
112details/look_html.h \ 116details/look_html.h \
113views/kaddressbookiconview.h \ 117views/kaddressbookiconview.h \
114views/kaddressbooktableview.h \ 118views/kaddressbooktableview.h \
115views/kaddressbookcardview.h \ 119views/kaddressbookcardview.h \
116views/configuretableviewdialog.h \ 120views/configuretableviewdialog.h \
117views/configurecardviewdialog.h \ 121views/configurecardviewdialog.h \
118views/cardview.h \ 122views/cardview.h \
119views/colorlistbox.h \ 123views/colorlistbox.h \
120views/contactlistview.h \ 124views/contactlistview.h \
121xxport/vcard_xxport.h \ 125xxport/vcard_xxport.h \
122xxport/kde2_xxport.h \ 126xxport/kde2_xxport.h \
123xxport/csv_xxport.h \ 127xxport/csv_xxport.h \
124xxport/csvimportdialog.h \ 128xxport/csvimportdialog.h \
125xxport/opie_xxport.h \ 129xxport/opie_xxport.h \
126xxport/qtopia_xxport.h \ 130xxport/qtopia_xxport.h \
127xxport/sharpdtm_xxport.h \ 131xxport/sharpdtm_xxport.h \
128#details/look_details.h \ 132#details/look_details.h \
129#mainwindoiw.h \ 133#mainwindoiw.h \
130# alarmclient.h \ 134# alarmclient.h \
131# calendarview.h \ 135# calendarview.h \
132# customlistviewitem.h \ 136# customlistviewitem.h \
133# datenavigator.h 137# datenavigator.h
134 138
135SOURCES += \ 139SOURCES += \
136addresseeeditordialog.cpp \ 140addresseeeditordialog.cpp \
137addresseeeditorwidget.cpp \ 141addresseeeditorwidget.cpp \
138addresseditwidget.cpp \ 142addresseditwidget.cpp \
139addresseeconfig.cpp \ 143addresseeconfig.cpp \
140addresseeutil.cpp \ 144addresseeutil.cpp \
141extensionmanager.cpp \ 145extensionmanager.cpp \
142features/mergewidget.cpp \ 146features/mergewidget.cpp \
143features/distributionlistwidget.cpp \ 147features/distributionlistwidget.cpp \
144kcmconfigs/addresseewidget.cpp \ 148kcmconfigs/addresseewidget.cpp \
145kcmconfigs/extensionconfigdialog.cpp \ 149kcmconfigs/extensionconfigdialog.cpp \
146kcmconfigs/kcmkabconfig.cpp \ 150kcmconfigs/kcmkabconfig.cpp \
147kcmconfigs/kabconfigwidget.cpp \ 151kcmconfigs/kabconfigwidget.cpp \
148emaileditwidget.cpp \ 152emaileditwidget.cpp \
149filtereditdialog.cpp \ 153filtereditdialog.cpp \
150mainembedded.cpp \ 154mainembedded.cpp \
151kaddressbookmain.cpp \ 155kaddressbookmain.cpp \
152kabcore.cpp \ 156kabcore.cpp \
153kabprefs.cpp \ 157kabprefs.cpp \
154viewmanager.cpp \ 158viewmanager.cpp \
155kaddressbookview.cpp \ 159kaddressbookview.cpp \
156extensionwidget.cpp \ 160extensionwidget.cpp \
157geowidget.cpp \ 161geowidget.cpp \
158imagewidget.cpp \ 162imagewidget.cpp \
159incsearchwidget.cpp \ 163incsearchwidget.cpp \
160jumpbuttonbar.cpp \ 164jumpbuttonbar.cpp \
161phoneeditwidget.cpp \ 165phoneeditwidget.cpp \
162secrecywidget.cpp \ 166secrecywidget.cpp \
163keywidget.cpp \ 167keywidget.cpp \
164nameeditdialog.cpp \ 168nameeditdialog.cpp \
165filter.cpp \ 169filter.cpp \
166addviewdialog.cpp \ 170addviewdialog.cpp \
167configurewidget.cpp \ 171configurewidget.cpp \
168viewconfigurewidget.cpp \ 172viewconfigurewidget.cpp \
169viewconfigurefieldspage.cpp \ 173viewconfigurefieldspage.cpp \
170viewconfigurefilterpage.cpp \ 174viewconfigurefilterpage.cpp \
171undo.cpp \ 175undo.cpp \
172undocmds.cpp \ 176undocmds.cpp \
173xxportmanager.cpp \ 177xxportmanager.cpp \
174xxportobject.cpp \ 178xxportobject.cpp \
175xxportselectdialog.cpp \ 179xxportselectdialog.cpp \
176details/detailsviewcontainer.cpp \ 180details/detailsviewcontainer.cpp \
177details/look_basic.cpp \ 181details/look_basic.cpp \
178details/look_html.cpp \ 182details/look_html.cpp \
179views/kaddressbookiconview.cpp \ 183views/kaddressbookiconview.cpp \
180views/kaddressbooktableview.cpp \ 184views/kaddressbooktableview.cpp \
181views/kaddressbookcardview.cpp \ 185views/kaddressbookcardview.cpp \
182views/configuretableviewdialog.cpp \ 186views/configuretableviewdialog.cpp \
183views/configurecardviewdialog.cpp \ 187views/configurecardviewdialog.cpp \
184views/cardview.cpp \ 188views/cardview.cpp \
185views/contactlistview.cpp \ 189views/contactlistview.cpp \
186views/colorlistbox.cpp \ 190views/colorlistbox.cpp \
187xxport/vcard_xxport.cpp \ 191xxport/vcard_xxport.cpp \
188xxport/kde2_xxport.cpp \ 192xxport/kde2_xxport.cpp \
189xxport/csv_xxport.cpp \ 193xxport/csv_xxport.cpp \
190xxport/csvimportdialog.cpp \ 194xxport/csvimportdialog.cpp \
191xxport/opie_xxport.cpp \ 195xxport/opie_xxport.cpp \
192xxport/qtopia_xxport.cpp \ 196xxport/qtopia_xxport.cpp \
193xxport/sharpdtm_xxport.cpp \ 197xxport/sharpdtm_xxport.cpp \
194#details/look_details.cpp \ 198#details/look_details.cpp \
195#mainwindow.cpp \ 199#mainwindow.cpp \
196# calendarview.cpp \ 200# calendarview.cpp \
197# timespanview.cpp 201# timespanview.cpp
198 202
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 904bbe2..a8ad467 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4151 +1,4153 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141 141
142class KOBeamPrefs : public QDialog 142class KOBeamPrefs : public QDialog
143{ 143{
144 public: 144 public:
145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
146 QDialog( parent, name, true ) 146 QDialog( parent, name, true )
147 { 147 {
148 setCaption( i18n("Beam Options") ); 148 setCaption( i18n("Beam Options") );
149 QVBoxLayout* lay = new QVBoxLayout( this ); 149 QVBoxLayout* lay = new QVBoxLayout( this );
150 lay->setSpacing( 3 ); 150 lay->setSpacing( 3 );
151 lay->setMargin( 3 ); 151 lay->setMargin( 3 );
152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
153 lay->addWidget( format ); 153 lay->addWidget( format );
154 format->setExclusive ( true ) ; 154 format->setExclusive ( true ) ;
155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
156 lay->addWidget( time ); time->setExclusive ( true ) ; 156 lay->addWidget( time ); time->setExclusive ( true ) ;
157 vcal = new QRadioButton(" vCalendar ", format ); 157 vcal = new QRadioButton(" vCalendar ", format );
158 ical = new QRadioButton(" iCalendar ", format ); 158 ical = new QRadioButton(" iCalendar ", format );
159 vcal->setChecked( true ); 159 vcal->setChecked( true );
160 tz = new QRadioButton(i18n(" With timezone "), time ); 160 tz = new QRadioButton(i18n(" With timezone "), time );
161 local = new QRadioButton(i18n(" Local time "), time ); 161 local = new QRadioButton(i18n(" Local time "), time );
162 tz->setChecked( true ); 162 tz->setChecked( true );
163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
164 lay->addWidget( ok ); 164 lay->addWidget( ok );
165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
166 lay->addWidget( cancel ); 166 lay->addWidget( cancel );
167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
169 resize( 200, 200 ); 169 resize( 200, 200 );
170 } 170 }
171 171
172 bool beamVcal() { return vcal->isChecked(); } 172 bool beamVcal() { return vcal->isChecked(); }
173 bool beamLocal() { return local->isChecked(); } 173 bool beamLocal() { return local->isChecked(); }
174private: 174private:
175 QRadioButton* vcal, *ical, *local, *tz; 175 QRadioButton* vcal, *ical, *local, *tz;
176}; 176};
177class KOCatPrefs : public QDialog 177class KOCatPrefs : public QDialog
178{ 178{
179 public: 179 public:
180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
181 QDialog( parent, name, true ) 181 QDialog( parent, name, true )
182 { 182 {
183 setCaption( i18n("Manage new Categories") ); 183 setCaption( i18n("Manage new Categories") );
184 QVBoxLayout* lay = new QVBoxLayout( this ); 184 QVBoxLayout* lay = new QVBoxLayout( this );
185 lay->setSpacing( 3 ); 185 lay->setSpacing( 3 );
186 lay->setMargin( 3 ); 186 lay->setMargin( 3 );
187 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 187 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
188 lay->addWidget( lab ); 188 lay->addWidget( lab );
189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
190 lay->addWidget( format ); 190 lay->addWidget( format );
191 format->setExclusive ( true ) ; 191 format->setExclusive ( true ) ;
192 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 192 addCatBut = new QRadioButton(i18n("Add to category list"), format );
193 new QRadioButton(i18n("Remove from Events/Todos"), format ); 193 new QRadioButton(i18n("Remove from Events/Todos"), format );
194 addCatBut->setChecked( true ); 194 addCatBut->setChecked( true );
195 QPushButton * ok = new QPushButton( i18n("OK"), this ); 195 QPushButton * ok = new QPushButton( i18n("OK"), this );
196 lay->addWidget( ok ); 196 lay->addWidget( ok );
197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
198 lay->addWidget( cancel ); 198 lay->addWidget( cancel );
199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
201 resize( 200, 200 ); 201 resize( 200, 200 );
202 } 202 }
203 203
204 bool addCat() { return addCatBut->isChecked(); } 204 bool addCat() { return addCatBut->isChecked(); }
205private: 205private:
206 QRadioButton* addCatBut; 206 QRadioButton* addCatBut;
207}; 207};
208 208
209 209
210 210
211CalendarView::CalendarView( CalendarResources *calendar, 211CalendarView::CalendarView( CalendarResources *calendar,
212 QWidget *parent, const char *name ) 212 QWidget *parent, const char *name )
213 : CalendarViewBase( parent, name ), 213 : CalendarViewBase( parent, name ),
214 mCalendar( calendar ), 214 mCalendar( calendar ),
215 mResourceManager( calendar->resourceManager() ) 215 mResourceManager( calendar->resourceManager() )
216{ 216{
217 217
218 mEventEditor = 0; 218 mEventEditor = 0;
219 mTodoEditor = 0; 219 mTodoEditor = 0;
220 220
221 init(); 221 init();
222} 222}
223 223
224CalendarView::CalendarView( Calendar *calendar, 224CalendarView::CalendarView( Calendar *calendar,
225 QWidget *parent, const char *name ) 225 QWidget *parent, const char *name )
226 : CalendarViewBase( parent, name ), 226 : CalendarViewBase( parent, name ),
227 mCalendar( calendar ), 227 mCalendar( calendar ),
228 mResourceManager( 0 ) 228 mResourceManager( 0 )
229{ 229{
230 230
231 mEventEditor = 0; 231 mEventEditor = 0;
232 mTodoEditor = 0; 232 mTodoEditor = 0;
233 init(); 233 init();
234} 234}
235 235
236void CalendarView::init() 236void CalendarView::init()
237{ 237{
238 mNextAlarmDateTime = QDateTime::currentDateTime(); 238 mNextAlarmDateTime = QDateTime::currentDateTime();
239 setFocusPolicy ( NoFocus ); 239 setFocusPolicy ( NoFocus );
240 mViewerCallerIsSearchDialog = false; 240 mViewerCallerIsSearchDialog = false;
241 mBlockShowDates = false; 241 mBlockShowDates = false;
242 beamDialog = new KOBeamPrefs(); 242 beamDialog = new KOBeamPrefs();
243 mDatePickerMode = 0; 243 mDatePickerMode = 0;
244 mCurrentSyncDevice = ""; 244 mCurrentSyncDevice = "";
245 writeLocale(); 245 writeLocale();
246 mViewManager = new KOViewManager( this ); 246 mViewManager = new KOViewManager( this );
247 mDialogManager = new KODialogManager( this ); 247 mDialogManager = new KODialogManager( this );
248 mEventViewerDialog = 0; 248 mEventViewerDialog = 0;
249 mModified = false; 249 mModified = false;
250 mReadOnly = false; 250 mReadOnly = false;
251 mSelectedIncidence = 0; 251 mSelectedIncidence = 0;
252 mCalPrinter = 0; 252 mCalPrinter = 0;
253 mFilters.setAutoDelete(true); 253 mFilters.setAutoDelete(true);
254 254
255 mCalendar->registerObserver( this ); 255 mCalendar->registerObserver( this );
256 // TODO: Make sure that view is updated, when calendar is changed. 256 // TODO: Make sure that view is updated, when calendar is changed.
257 257
258 mStorage = new FileStorage( mCalendar ); 258 mStorage = new FileStorage( mCalendar );
259 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 259 mNavigator = new DateNavigator( this, "datevav", mViewManager );
260 260
261 QBoxLayout *topLayout = (QBoxLayout*)layout(); 261 QBoxLayout *topLayout = (QBoxLayout*)layout();
262#ifndef KORG_NOSPLITTER 262#ifndef KORG_NOSPLITTER
263 // create the main layout frames. 263 // create the main layout frames.
264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
265 topLayout->addWidget(mPanner); 265 topLayout->addWidget(mPanner);
266 266
267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
268 "CalendarView::LeftFrame"); 268 "CalendarView::LeftFrame");
269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
270 270
271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
272 "CalendarView::DateNavigator" ); 272 "CalendarView::DateNavigator" );
273 273
274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
276 mTodoList->setNavigator( mNavigator ); 276 mTodoList->setNavigator( mNavigator );
277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
278 278
279#ifdef KORG_NORESOURCEVIEW 279#ifdef KORG_NORESOURCEVIEW
280 mResourceView = 0; 280 mResourceView = 0;
281#else 281#else
282 if ( mResourceManager ) { 282 if ( mResourceManager ) {
283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
284 mResourceView->updateView(); 284 mResourceView->updateView();
285 connect( mResourceView, SIGNAL( resourcesChanged() ), 285 connect( mResourceView, SIGNAL( resourcesChanged() ),
286 SLOT( updateView() ) ); 286 SLOT( updateView() ) );
287 } else { 287 } else {
288 mResourceView = 0; 288 mResourceView = 0;
289 } 289 }
290#endif 290#endif
291 QWidget *rightBox = new QWidget( mPanner ); 291 QWidget *rightBox = new QWidget( mPanner );
292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
293 293
294 mRightFrame = new QWidgetStack( rightBox ); 294 mRightFrame = new QWidgetStack( rightBox );
295 rightLayout->addWidget( mRightFrame, 1 ); 295 rightLayout->addWidget( mRightFrame, 1 );
296 296
297 mLeftFrame = mLeftSplitter; 297 mLeftFrame = mLeftSplitter;
298#else 298#else
299 //QWidget *mainBox = new QWidget( this ); 299 //QWidget *mainBox = new QWidget( this );
300 //QWidget *leftFrame = new QWidget( mainBox ); 300 //QWidget *leftFrame = new QWidget( mainBox );
301 //QBoxLayout * mainBoxLayout; 301 //QBoxLayout * mainBoxLayout;
302 if ( KOPrefs::instance()->mVerticalScreen ) { 302 if ( KOPrefs::instance()->mVerticalScreen ) {
303 //mainBoxLayout = new QVBoxLayout(mainBox); 303 //mainBoxLayout = new QVBoxLayout(mainBox);
304 //leftFrameLayout = new QHBoxLayout(leftFrame ); 304 //leftFrameLayout = new QHBoxLayout(leftFrame );
305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
309 } else { 309 } else {
310 //mainBoxLayout = new QHBoxLayout(mainBox); 310 //mainBoxLayout = new QHBoxLayout(mainBox);
311 //leftFrameLayout = new QVBoxLayout(leftFrame ); 311 //leftFrameLayout = new QVBoxLayout(leftFrame );
312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
316 } 316 }
317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
318 //QBoxLayout * leftFrameLayout; 318 //QBoxLayout * leftFrameLayout;
319 topLayout->addWidget( mMainFrame ); 319 topLayout->addWidget( mMainFrame );
320 //mainBoxLayout->addWidget (mLeftFrame); 320 //mainBoxLayout->addWidget (mLeftFrame);
321 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 321 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
322 "CalendarView::DateNavigator" ); 322 "CalendarView::DateNavigator" );
323#if 0 323#if 0
324 // FIXME 324 // FIXME
325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
326 "CalendarView::DateNavigator", QDate::currentDate()); 326 "CalendarView::DateNavigator", QDate::currentDate());
327#endif 327#endif
328 // mDateNavigator->blockSignals( true ); 328 // mDateNavigator->blockSignals( true );
329 //leftFrameLayout->addWidget( mDateNavigator ); 329 //leftFrameLayout->addWidget( mDateNavigator );
330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
332 mTodoList->setNavigator( mNavigator ); 332 mTodoList->setNavigator( mNavigator );
333#if 0 333#if 0
334 if ( QApplication::desktop()->width() < 480 ) { 334 if ( QApplication::desktop()->width() < 480 ) {
335 leftFrameLayout->addWidget(mFilterView); 335 leftFrameLayout->addWidget(mFilterView);
336 leftFrameLayout->addWidget(mTodoList, 2 ); 336 leftFrameLayout->addWidget(mTodoList, 2 );
337 337
338 } else { 338 } else {
339 leftFrameLayout->addWidget(mTodoList,2 ); 339 leftFrameLayout->addWidget(mTodoList,2 );
340 leftFrameLayout->addWidget(mFilterView ); 340 leftFrameLayout->addWidget(mFilterView );
341 } 341 }
342#endif 342#endif
343 mFilterView->hide(); 343 mFilterView->hide();
344 QWidget *rightBox = new QWidget( mMainFrame ); 344 QWidget *rightBox = new QWidget( mMainFrame );
345 //mainBoxLayout->addWidget ( rightBox, 10 ); 345 //mainBoxLayout->addWidget ( rightBox, 10 );
346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
347 mRightFrame = new QWidgetStack( rightBox ); 347 mRightFrame = new QWidgetStack( rightBox );
348 rightLayout->addWidget( mRightFrame, 10 ); 348 rightLayout->addWidget( mRightFrame, 10 );
349 349
350 //mLeftFrame = (QWidget *)leftFrame; 350 //mLeftFrame = (QWidget *)leftFrame;
351 if ( KOPrefs::instance()->mVerticalScreen ) { 351 if ( KOPrefs::instance()->mVerticalScreen ) {
352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
356 } else { 356 } else {
357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
360 } 360 }
361 if ( !KOPrefs::instance()->mShowDateNavigator) 361 if ( !KOPrefs::instance()->mShowDateNavigator)
362 mDateNavigator->hide(); 362 mDateNavigator->hide();
363 //qDebug("Calendarview Size %d %d ", width(), height()); 363 //qDebug("Calendarview Size %d %d ", width(), height());
364#endif 364#endif
365 365
366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
367 SLOT( showDates( const KCal::DateList & ) ) ); 367 SLOT( showDates( const KCal::DateList & ) ) );
368 368
369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
371 371
372 372
373 373
374 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 374 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
375 mViewManager, SLOT( showMonth( const QDate & ) ) ); 375 mViewManager, SLOT( showMonth( const QDate & ) ) );
376 376
377 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 377 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
378 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 378 mNavigator, SLOT( selectWeek( const QDate & ) ) );
379 379
380 connect( mDateNavigator, SIGNAL( goPrevYear() ), 380 connect( mDateNavigator, SIGNAL( goPrevYear() ),
381 mNavigator, SLOT( selectPreviousYear() ) ); 381 mNavigator, SLOT( selectPreviousYear() ) );
382 connect( mDateNavigator, SIGNAL( goNextYear() ), 382 connect( mDateNavigator, SIGNAL( goNextYear() ),
383 mNavigator, SLOT( selectNextYear() ) ); 383 mNavigator, SLOT( selectNextYear() ) );
384 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 384 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
385 mNavigator, SLOT( selectPreviousMonth() ) ); 385 mNavigator, SLOT( selectPreviousMonth() ) );
386 connect( mDateNavigator, SIGNAL( goNextMonth() ), 386 connect( mDateNavigator, SIGNAL( goNextMonth() ),
387 mNavigator, SLOT( selectNextMonth() ) ); 387 mNavigator, SLOT( selectNextMonth() ) );
388 388
389 connect( mDateNavigator, SIGNAL( goPrevious() ), 389 connect( mDateNavigator, SIGNAL( goPrevious() ),
390 mNavigator, SLOT( selectPrevious() ) ); 390 mNavigator, SLOT( selectPrevious() ) );
391 connect( mDateNavigator, SIGNAL( goNext() ), 391 connect( mDateNavigator, SIGNAL( goNext() ),
392 mNavigator, SLOT( selectNext() ) ); 392 mNavigator, SLOT( selectNext() ) );
393 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 393 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
394 mNavigator, SLOT( slotMonthSelect( int ) ) ); 394 mNavigator, SLOT( slotMonthSelect( int ) ) );
395 395
396 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 396 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
397 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 397 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
398#if 0 398#if 0
399 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 399 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
400 SLOT( incidenceAdded( Incidence *) ) ); 400 SLOT( incidenceAdded( Incidence *) ) );
401#endif 401#endif
402 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 402 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
403 403
404 connect( this, SIGNAL( configChanged() ), 404 connect( this, SIGNAL( configChanged() ),
405 mDateNavigator, SLOT( updateConfig() ) ); 405 mDateNavigator, SLOT( updateConfig() ) );
406 406
407 connect( mTodoList, SIGNAL( newTodoSignal() ), 407 connect( mTodoList, SIGNAL( newTodoSignal() ),
408 SLOT( newTodo() ) ); 408 SLOT( newTodo() ) );
409 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 409 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
410 SLOT( newSubTodo( Todo * ) ) ); 410 SLOT( newSubTodo( Todo * ) ) );
411 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 411 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
412 SLOT( editTodo( Todo * ) ) ); 412 SLOT( editTodo( Todo * ) ) );
413 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
414 SLOT( showTodo( Todo *) ) ); 414 SLOT( showTodo( Todo *) ) );
415 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 415 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
416 SLOT( deleteTodo( Todo *) ) ); 416 SLOT( deleteTodo( Todo *) ) );
417 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 417 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
418 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 418 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
419 SLOT( purgeCompleted() ) ); 419 SLOT( purgeCompleted() ) );
420 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 420 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
421 SIGNAL( todoModified( Todo *, int ) ) ); 421 SIGNAL( todoModified( Todo *, int ) ) );
422 422
423 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 423 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
424 this, SLOT ( cloneIncidence( Incidence * ) ) ); 424 this, SLOT ( cloneIncidence( Incidence * ) ) );
425 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 425 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
426 this, SLOT (cancelIncidence( Incidence * ) ) ); 426 this, SLOT (cancelIncidence( Incidence * ) ) );
427 427
428 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 428 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
429 this, SLOT ( moveIncidence( Incidence * ) ) ); 429 this, SLOT ( moveIncidence( Incidence * ) ) );
430 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 430 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
431 this, SLOT ( beamIncidence( Incidence * ) ) ); 431 this, SLOT ( beamIncidence( Incidence * ) ) );
432 432
433 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 433 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
434 this, SLOT ( todo_unsub( Todo * ) ) ); 434 this, SLOT ( todo_unsub( Todo * ) ) );
435 435
436 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 436 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
437 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 437 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
438 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 438 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
439 SLOT( updateTodo( Todo *, int ) ) ); 439 SLOT( updateTodo( Todo *, int ) ) );
440 connect( this, SIGNAL( todoModified( Todo *, int )), this, 440 connect( this, SIGNAL( todoModified( Todo *, int )), this,
441 SLOT( changeTodoDisplay( Todo *, int ) ) ); 441 SLOT( changeTodoDisplay( Todo *, int ) ) );
442 442
443 443
444 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 444 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
445 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 445 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
446 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 446 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
447 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 447 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
448 448
449 449
450 450
451 451
452 452
453 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 453 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
454 SLOT(checkClipboard())); 454 SLOT(checkClipboard()));
455 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 455 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
456 SLOT( processTodoListSelection( Incidence * ) ) ); 456 SLOT( processTodoListSelection( Incidence * ) ) );
457 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 457 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
458 458
459 // kdDebug() << "CalendarView::CalendarView() done" << endl; 459 // kdDebug() << "CalendarView::CalendarView() done" << endl;
460 460
461 mDateFrame = new QVBox(0,0,WType_Popup); 461 mDateFrame = new QVBox(0,0,WType_Popup);
462 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 462 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
463 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 463 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
464 mDateFrame->setLineWidth(3); 464 mDateFrame->setLineWidth(3);
465 mDateFrame->hide(); 465 mDateFrame->hide();
466 mDateFrame->setCaption( i18n( "Pick a date to display")); 466 mDateFrame->setCaption( i18n( "Pick a date to display"));
467 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 467 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
468 468
469 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 469 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
470 470
471 mEventEditor = mDialogManager->getEventEditor(); 471 mEventEditor = mDialogManager->getEventEditor();
472 mTodoEditor = mDialogManager->getTodoEditor(); 472 mTodoEditor = mDialogManager->getTodoEditor();
473 473
474 mFlagEditDescription = false; 474 mFlagEditDescription = false;
475 475
476 mSuspendTimer = new QTimer( this ); 476 mSuspendTimer = new QTimer( this );
477 mAlarmTimer = new QTimer( this ); 477 mAlarmTimer = new QTimer( this );
478 mRecheckAlarmTimer = new QTimer( this ); 478 mRecheckAlarmTimer = new QTimer( this );
479 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 479 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
480 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 480 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
481 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 481 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
482 mAlarmDialog = new AlarmDialog( this ); 482 mAlarmDialog = new AlarmDialog( this );
483 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 483 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
484 mAlarmDialog->setServerNotification( false ); 484 mAlarmDialog->setServerNotification( false );
485 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 485 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
486 486
487 487
488#ifndef DESKTOP_VERSION 488#ifndef DESKTOP_VERSION
489//US listen for arriving address resultsets 489//US listen for arriving address resultsets
490 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 490 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
491 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 491 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
492#endif 492#endif
493 mDateNavigator->setCalendar( mCalendar ); 493 mDateNavigator->setCalendar( mCalendar );
494} 494}
495 495
496 496
497CalendarView::~CalendarView() 497CalendarView::~CalendarView()
498{ 498{
499 // kdDebug() << "~CalendarView()" << endl; 499 // kdDebug() << "~CalendarView()" << endl;
500 //qDebug("CalendarView::~CalendarView() "); 500 //qDebug("CalendarView::~CalendarView() ");
501 delete mDialogManager; 501 delete mDialogManager;
502 delete mViewManager; 502 delete mViewManager;
503 delete mStorage; 503 delete mStorage;
504 delete mDateFrame ; 504 delete mDateFrame ;
505 delete beamDialog; 505 delete beamDialog;
506 delete mEventViewerDialog; 506 delete mEventViewerDialog;
507 //kdDebug() << "~CalendarView() done" << endl; 507 //kdDebug() << "~CalendarView() done" << endl;
508} 508}
509 509
510void CalendarView::showDay( QDate d ) 510void CalendarView::showDay( QDate d )
511{ 511{
512 dateNavigator()->blockSignals( true ); 512 dateNavigator()->blockSignals( true );
513 dateNavigator()->selectDate( d ); 513 dateNavigator()->selectDate( d );
514 dateNavigator()->blockSignals( false ); 514 dateNavigator()->blockSignals( false );
515 mViewManager->showDayView(); 515 mViewManager->showDayView();
516 //dateNavigator()->selectDate( d ); 516 //dateNavigator()->selectDate( d );
517} 517}
518void CalendarView::timerAlarm() 518void CalendarView::timerAlarm()
519{ 519{
520 //qDebug("CalendarView::timerAlarm() "); 520 //qDebug("CalendarView::timerAlarm() ");
521 computeAlarm(mAlarmNotification ); 521 computeAlarm(mAlarmNotification );
522} 522}
523 523
524void CalendarView::suspendAlarm() 524void CalendarView::suspendAlarm()
525{ 525{
526 //qDebug(" CalendarView::suspendAlarm() "); 526 //qDebug(" CalendarView::suspendAlarm() ");
527 computeAlarm(mSuspendAlarmNotification ); 527 computeAlarm(mSuspendAlarmNotification );
528 528
529} 529}
530 530
531void CalendarView::startAlarm( QString mess , QString filename) 531void CalendarView::startAlarm( QString mess , QString filename)
532{ 532{
533 533
534 topLevelWidget()->showNormal(); 534 topLevelWidget()->showNormal();
535 topLevelWidget()->setActiveWindow(); 535 topLevelWidget()->setActiveWindow();
536 topLevelWidget()->raise(); 536 topLevelWidget()->raise();
537 537
538 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 538 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
539 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 539 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
540 540
541} 541}
542 542
543void CalendarView::checkNextTimerAlarm() 543void CalendarView::checkNextTimerAlarm()
544{ 544{
545 mCalendar->checkAlarmForIncidence( 0, true ); 545 mCalendar->checkAlarmForIncidence( 0, true );
546} 546}
547 547
548void CalendarView::computeAlarm( QString msg ) 548void CalendarView::computeAlarm( QString msg )
549{ 549{
550 550
551 QString mess = msg; 551 QString mess = msg;
552 QString mAlarmMessage = mess.mid( 9 ); 552 QString mAlarmMessage = mess.mid( 9 );
553 QString filename = MainWindow::resourcePath(); 553 QString filename = MainWindow::resourcePath();
554 filename += "koalarm.wav"; 554 filename += "koalarm.wav";
555 QString tempfilename; 555 QString tempfilename;
556 if ( mess.left( 13 ) == "suspend_alarm") { 556 if ( mess.left( 13 ) == "suspend_alarm") {
557 bool error = false; 557 bool error = false;
558 int len = mess.mid( 13 ).find("+++"); 558 int len = mess.mid( 13 ).find("+++");
559 if ( len < 2 ) 559 if ( len < 2 )
560 error = true; 560 error = true;
561 else { 561 else {
562 tempfilename = mess.mid( 13, len ); 562 tempfilename = mess.mid( 13, len );
563 if ( !QFile::exists( tempfilename ) ) 563 if ( !QFile::exists( tempfilename ) )
564 error = true; 564 error = true;
565 } 565 }
566 if ( ! error ) { 566 if ( ! error ) {
567 filename = tempfilename; 567 filename = tempfilename;
568 } 568 }
569 mAlarmMessage = mess.mid( 13+len+3 ); 569 mAlarmMessage = mess.mid( 13+len+3 );
570 //qDebug("suspend file %s ",tempfilename.latin1() ); 570 //qDebug("suspend file %s ",tempfilename.latin1() );
571 startAlarm( mAlarmMessage, filename); 571 startAlarm( mAlarmMessage, filename);
572 return; 572 return;
573 } 573 }
574 if ( mess.left( 11 ) == "timer_alarm") { 574 if ( mess.left( 11 ) == "timer_alarm") {
575 //mTimerTime = 0; 575 //mTimerTime = 0;
576 startAlarm( mess.mid( 11 ), filename ); 576 startAlarm( mess.mid( 11 ), filename );
577 return; 577 return;
578 } 578 }
579 if ( mess.left( 10 ) == "proc_alarm") { 579 if ( mess.left( 10 ) == "proc_alarm") {
580 bool error = false; 580 bool error = false;
581 int len = mess.mid( 10 ).find("+++"); 581 int len = mess.mid( 10 ).find("+++");
582 if ( len < 2 ) 582 if ( len < 2 )
583 error = true; 583 error = true;
584 else { 584 else {
585 tempfilename = mess.mid( 10, len ); 585 tempfilename = mess.mid( 10, len );
586 if ( !QFile::exists( tempfilename ) ) 586 if ( !QFile::exists( tempfilename ) )
587 error = true; 587 error = true;
588 } 588 }
589 if ( error ) { 589 if ( error ) {
590 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 590 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
591 mAlarmMessage += mess.mid( 10+len+3+9 ); 591 mAlarmMessage += mess.mid( 10+len+3+9 );
592 } else { 592 } else {
593 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 593 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
594 //qDebug("-----system command %s ",tempfilename.latin1() ); 594 //qDebug("-----system command %s ",tempfilename.latin1() );
595#ifndef _WIN32_ 595#ifndef _WIN32_
596 if ( vfork () == 0 ) { 596 if ( vfork () == 0 ) {
597 execl ( tempfilename.latin1(), 0 ); 597 execl ( tempfilename.latin1(), 0 );
598 return; 598 return;
599 } 599 }
600#else 600#else
601 QProcess* p = new QProcess(); 601 QProcess* p = new QProcess();
602 p->addArgument( tempfilename.latin1() ); 602 p->addArgument( tempfilename.latin1() );
603 p->start(); 603 p->start();
604 return; 604 return;
605#endif 605#endif
606 606
607 return; 607 return;
608 } 608 }
609 609
610 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 610 //qDebug("+++++++system command %s ",tempfilename.latin1() );
611 } 611 }
612 if ( mess.left( 11 ) == "audio_alarm") { 612 if ( mess.left( 11 ) == "audio_alarm") {
613 bool error = false; 613 bool error = false;
614 int len = mess.mid( 11 ).find("+++"); 614 int len = mess.mid( 11 ).find("+++");
615 if ( len < 2 ) 615 if ( len < 2 )
616 error = true; 616 error = true;
617 else { 617 else {
618 tempfilename = mess.mid( 11, len ); 618 tempfilename = mess.mid( 11, len );
619 if ( !QFile::exists( tempfilename ) ) 619 if ( !QFile::exists( tempfilename ) )
620 error = true; 620 error = true;
621 } 621 }
622 if ( ! error ) { 622 if ( ! error ) {
623 filename = tempfilename; 623 filename = tempfilename;
624 } 624 }
625 mAlarmMessage = mess.mid( 11+len+3+9 ); 625 mAlarmMessage = mess.mid( 11+len+3+9 );
626 //qDebug("audio file command %s ",tempfilename.latin1() ); 626 //qDebug("audio file command %s ",tempfilename.latin1() );
627 } 627 }
628 if ( mess.left( 9 ) == "cal_alarm") { 628 if ( mess.left( 9 ) == "cal_alarm") {
629 mAlarmMessage = mess.mid( 9 ) ; 629 mAlarmMessage = mess.mid( 9 ) ;
630 } 630 }
631 631
632 startAlarm( mAlarmMessage, filename ); 632 startAlarm( mAlarmMessage, filename );
633 633
634 634
635} 635}
636 636
637void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 637void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
638{ 638{
639 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 639 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
640 640
641 mSuspendAlarmNotification = noti; 641 mSuspendAlarmNotification = noti;
642 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 642 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
643 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 643 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
644 mSuspendTimer->start( ms , true ); 644 mSuspendTimer->start( ms , true );
645 645
646} 646}
647 647
648void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 648void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
649{ 649{
650 mNextAlarmDateTime = qdt; 650 mNextAlarmDateTime = qdt;
651 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 651 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
652 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 652 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
653#ifndef DESKTOP_VERSION 653#ifndef DESKTOP_VERSION
654 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 654 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
655#endif 655#endif
656 return; 656 return;
657 } 657 }
658 int maxSec; 658 int maxSec;
659 //maxSec = 5; //testing only 659 //maxSec = 5; //testing only
660 maxSec = 86400+3600; // one day+1hour 660 maxSec = 86400+3600; // one day+1hour
661 mAlarmNotification = noti; 661 mAlarmNotification = noti;
662 int sec = QDateTime::currentDateTime().secsTo( qdt ); 662 int sec = QDateTime::currentDateTime().secsTo( qdt );
663 if ( sec > maxSec ) { 663 if ( sec > maxSec ) {
664 mRecheckAlarmTimer->start( maxSec * 1000 ); 664 mRecheckAlarmTimer->start( maxSec * 1000 );
665 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 665 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
666 return; 666 return;
667 } else { 667 } else {
668 mRecheckAlarmTimer->stop(); 668 mRecheckAlarmTimer->stop();
669 } 669 }
670 //qDebug("Alarm timer started with secs: %d ", sec); 670 //qDebug("Alarm timer started with secs: %d ", sec);
671 mAlarmTimer->start( sec *1000 , true ); 671 mAlarmTimer->start( sec *1000 , true );
672 672
673} 673}
674// called by mRecheckAlarmTimer to get next alarm 674// called by mRecheckAlarmTimer to get next alarm
675// we need this, because a QTimer has only a max range of 25 days 675// we need this, because a QTimer has only a max range of 25 days
676void CalendarView::recheckTimerAlarm() 676void CalendarView::recheckTimerAlarm()
677{ 677{
678 mAlarmTimer->stop(); 678 mAlarmTimer->stop();
679 mRecheckAlarmTimer->stop(); 679 mRecheckAlarmTimer->stop();
680 mCalendar->checkAlarmForIncidence( 0, true ); 680 mCalendar->checkAlarmForIncidence( 0, true );
681} 681}
682void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 682void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
683{ 683{
684 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 684 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
685 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 685 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
686#ifndef DESKTOP_VERSION 686#ifndef DESKTOP_VERSION
687 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 687 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
688#endif 688#endif
689 return; 689 return;
690 } 690 }
691 mAlarmTimer->stop(); 691 mAlarmTimer->stop();
692} 692}
693void CalendarView::selectWeekNum ( int num ) 693void CalendarView::selectWeekNum ( int num )
694{ 694{
695 dateNavigator()->blockSignals( true ); 695 dateNavigator()->blockSignals( true );
696 dateNavigator()->selectWeek( num ); 696 dateNavigator()->selectWeek( num );
697 dateNavigator()->blockSignals( false ); 697 dateNavigator()->blockSignals( false );
698 mViewManager->showWeekView(); 698 mViewManager->showWeekView();
699} 699}
700KOViewManager *CalendarView::viewManager() 700KOViewManager *CalendarView::viewManager()
701{ 701{
702 return mViewManager; 702 return mViewManager;
703} 703}
704 704
705KODialogManager *CalendarView::dialogManager() 705KODialogManager *CalendarView::dialogManager()
706{ 706{
707 return mDialogManager; 707 return mDialogManager;
708} 708}
709 709
710QDate CalendarView::startDate() 710QDate CalendarView::startDate()
711{ 711{
712 DateList dates = mNavigator->selectedDates(); 712 DateList dates = mNavigator->selectedDates();
713 713
714 return dates.first(); 714 return dates.first();
715} 715}
716 716
717QDate CalendarView::endDate() 717QDate CalendarView::endDate()
718{ 718{
719 DateList dates = mNavigator->selectedDates(); 719 DateList dates = mNavigator->selectedDates();
720 720
721 return dates.last(); 721 return dates.last();
722} 722}
723 723
724 724
725void CalendarView::createPrinter() 725void CalendarView::createPrinter()
726{ 726{
727#ifndef KORG_NOPRINTER 727#ifndef KORG_NOPRINTER
728 if (!mCalPrinter) { 728 if (!mCalPrinter) {
729 mCalPrinter = new CalPrinter(this, mCalendar); 729 mCalPrinter = new CalPrinter(this, mCalendar);
730 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 730 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
731 } 731 }
732#endif 732#endif
733} 733}
734 734
735 735
736//KOPrefs::instance()->mWriteBackFile 736//KOPrefs::instance()->mWriteBackFile
737//KOPrefs::instance()->mWriteBackExistingOnly 737//KOPrefs::instance()->mWriteBackExistingOnly
738 738
739// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 739// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
740// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 740// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
741// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 741// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
742// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 742// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
743// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 743// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
744// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 744// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
745 745
746int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 746int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
747{ 747{
748 748
749 // 0 equal 749 // 0 equal
750 // 1 take local 750 // 1 take local
751 // 2 take remote 751 // 2 take remote
752 // 3 cancel 752 // 3 cancel
753 QDateTime lastSync = mLastCalendarSync; 753 QDateTime lastSync = mLastCalendarSync;
754 QDateTime localMod = local->lastModified(); 754 QDateTime localMod = local->lastModified();
755 QDateTime remoteMod = remote->lastModified(); 755 QDateTime remoteMod = remote->lastModified();
756 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 756 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
757 bool remCh, locCh; 757 bool remCh, locCh;
758 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 758 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
759 //if ( remCh ) 759 //if ( remCh )
760 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 760 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
761 locCh = ( localMod > mLastCalendarSync ); 761 locCh = ( localMod > mLastCalendarSync );
762 if ( !remCh && ! locCh ) { 762 if ( !remCh && ! locCh ) {
763 //qDebug("both not changed "); 763 //qDebug("both not changed ");
764 lastSync = localMod.addDays(1); 764 lastSync = localMod.addDays(1);
765 if ( mode <= SYNC_PREF_ASK ) 765 if ( mode <= SYNC_PREF_ASK )
766 return 0; 766 return 0;
767 } else { 767 } else {
768 if ( locCh ) { 768 if ( locCh ) {
769 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 769 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
770 lastSync = localMod.addDays( -1 ); 770 lastSync = localMod.addDays( -1 );
771 if ( !remCh ) 771 if ( !remCh )
772 remoteMod = ( lastSync.addDays( -1 ) ); 772 remoteMod = ( lastSync.addDays( -1 ) );
773 } else { 773 } else {
774 //qDebug(" not loc changed "); 774 //qDebug(" not loc changed ");
775 lastSync = localMod.addDays( 1 ); 775 lastSync = localMod.addDays( 1 );
776 if ( remCh ) 776 if ( remCh )
777 remoteMod =( lastSync.addDays( 1 ) ); 777 remoteMod =( lastSync.addDays( 1 ) );
778 778
779 } 779 }
780 } 780 }
781 full = true; 781 full = true;
782 if ( mode < SYNC_PREF_ASK ) 782 if ( mode < SYNC_PREF_ASK )
783 mode = SYNC_PREF_ASK; 783 mode = SYNC_PREF_ASK;
784 } else { 784 } else {
785 if ( localMod == remoteMod ) 785 if ( localMod == remoteMod )
786 // if ( local->revision() == remote->revision() ) 786 // if ( local->revision() == remote->revision() )
787 return 0; 787 return 0;
788 788
789 } 789 }
790 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 790 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
791 791
792 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 792 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
793 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 793 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
794 //full = true; //debug only 794 //full = true; //debug only
795 if ( full ) { 795 if ( full ) {
796 bool equ = false; 796 bool equ = false;
797 if ( local->type() == "Event" ) { 797 if ( local->type() == "Event" ) {
798 equ = (*((Event*) local) == *((Event*) remote)); 798 equ = (*((Event*) local) == *((Event*) remote));
799 } 799 }
800 else if ( local->type() =="Todo" ) 800 else if ( local->type() =="Todo" )
801 equ = (*((Todo*) local) == (*(Todo*) remote)); 801 equ = (*((Todo*) local) == (*(Todo*) remote));
802 else if ( local->type() =="Journal" ) 802 else if ( local->type() =="Journal" )
803 equ = (*((Journal*) local) == *((Journal*) remote)); 803 equ = (*((Journal*) local) == *((Journal*) remote));
804 if ( equ ) { 804 if ( equ ) {
805 //qDebug("equal "); 805 //qDebug("equal ");
806 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 806 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
807 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 807 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
808 } 808 }
809 if ( mode < SYNC_PREF_FORCE_LOCAL ) 809 if ( mode < SYNC_PREF_FORCE_LOCAL )
810 return 0; 810 return 0;
811 811
812 }//else //debug only 812 }//else //debug only
813 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 813 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
814 } 814 }
815 int result; 815 int result;
816 bool localIsNew; 816 bool localIsNew;
817 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 817 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
818 818
819 819
820 // ************************************************ 820 // ************************************************
821 // ************************************************ 821 // ************************************************
822 // ************************************************ 822 // ************************************************
823 // We may have that lastSync > remoteMod AND lastSync > localMod 823 // We may have that lastSync > remoteMod AND lastSync > localMod
824 // BUT remoteMod != localMod 824 // BUT remoteMod != localMod
825 825
826 826
827 if ( full && mode < SYNC_PREF_NEWEST ) 827 if ( full && mode < SYNC_PREF_NEWEST )
828 mode = SYNC_PREF_ASK; 828 mode = SYNC_PREF_ASK;
829 829
830 switch( mode ) { 830 switch( mode ) {
831 case SYNC_PREF_LOCAL: 831 case SYNC_PREF_LOCAL:
832 if ( lastSync > remoteMod ) 832 if ( lastSync > remoteMod )
833 return 1; 833 return 1;
834 if ( lastSync > localMod ) 834 if ( lastSync > localMod )
835 return 2; 835 return 2;
836 return 1; 836 return 1;
837 break; 837 break;
838 case SYNC_PREF_REMOTE: 838 case SYNC_PREF_REMOTE:
839 if ( lastSync > localMod ) 839 if ( lastSync > localMod )
840 return 2; 840 return 2;
841 if ( lastSync > remoteMod ) 841 if ( lastSync > remoteMod )
842 return 1; 842 return 1;
843 return 2; 843 return 2;
844 break; 844 break;
845 case SYNC_PREF_NEWEST: 845 case SYNC_PREF_NEWEST:
846 if ( localMod >= remoteMod ) 846 if ( localMod >= remoteMod )
847 return 1; 847 return 1;
848 else 848 else
849 return 2; 849 return 2;
850 break; 850 break;
851 case SYNC_PREF_ASK: 851 case SYNC_PREF_ASK:
852 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 852 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
853 if ( lastSync > remoteMod && lastSync > localMod) 853 if ( lastSync > remoteMod && lastSync > localMod)
854 return 0; 854 return 0;
855 if ( lastSync > remoteMod ) 855 if ( lastSync > remoteMod )
856 return 1; 856 return 1;
857 if ( lastSync > localMod ) 857 if ( lastSync > localMod )
858 return 2; 858 return 2;
859 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 859 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
860 localIsNew = localMod >= remoteMod; 860 localIsNew = localMod >= remoteMod;
861 if ( localIsNew ) 861 if ( localIsNew )
862 getEventViewerDialog()->setColorMode( 1 ); 862 getEventViewerDialog()->setColorMode( 1 );
863 else 863 else
864 getEventViewerDialog()->setColorMode( 2 ); 864 getEventViewerDialog()->setColorMode( 2 );
865 getEventViewerDialog()->setIncidence(local); 865 getEventViewerDialog()->setIncidence(local);
866 if ( localIsNew ) 866 if ( localIsNew )
867 getEventViewerDialog()->setColorMode( 2 ); 867 getEventViewerDialog()->setColorMode( 2 );
868 else 868 else
869 getEventViewerDialog()->setColorMode( 1 ); 869 getEventViewerDialog()->setColorMode( 1 );
870 getEventViewerDialog()->addIncidence(remote); 870 getEventViewerDialog()->addIncidence(remote);
871 getEventViewerDialog()->setColorMode( 0 ); 871 getEventViewerDialog()->setColorMode( 0 );
872 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 872 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
873 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 873 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
874 getEventViewerDialog()->showMe(); 874 getEventViewerDialog()->showMe();
875 result = getEventViewerDialog()->executeS( localIsNew ); 875 result = getEventViewerDialog()->executeS( localIsNew );
876 return result; 876 return result;
877 877
878 break; 878 break;
879 case SYNC_PREF_FORCE_LOCAL: 879 case SYNC_PREF_FORCE_LOCAL:
880 return 1; 880 return 1;
881 break; 881 break;
882 case SYNC_PREF_FORCE_REMOTE: 882 case SYNC_PREF_FORCE_REMOTE:
883 return 2; 883 return 2;
884 break; 884 break;
885 885
886 default: 886 default:
887 // SYNC_PREF_TAKE_BOTH not implemented 887 // SYNC_PREF_TAKE_BOTH not implemented
888 break; 888 break;
889 } 889 }
890 return 0; 890 return 0;
891} 891}
892Event* CalendarView::getLastSyncEvent() 892Event* CalendarView::getLastSyncEvent()
893{ 893{
894 Event* lse; 894 Event* lse;
895 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 895 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
896 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 896 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
897 if (!lse) { 897 if (!lse) {
898 lse = new Event(); 898 lse = new Event();
899 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 899 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
900 QString sum = ""; 900 QString sum = "";
901 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 901 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
902 sum = "E: "; 902 sum = "E: ";
903 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 903 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
904 lse->setDtStart( mLastCalendarSync ); 904 lse->setDtStart( mLastCalendarSync );
905 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 905 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
906 lse->setCategories( i18n("SyncEvent") ); 906 lse->setCategories( i18n("SyncEvent") );
907 lse->setReadOnly( true ); 907 lse->setReadOnly( true );
908 mCalendar->addEvent( lse ); 908 mCalendar->addEvent( lse );
909 } 909 }
910 910
911 return lse; 911 return lse;
912 912
913} 913}
914 914
915// we check, if the to delete event has a id for a profile 915// we check, if the to delete event has a id for a profile
916// if yes, we set this id in the profile to delete 916// if yes, we set this id in the profile to delete
917void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 917void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
918{ 918{
919 if ( lastSync.count() == 0 ) { 919 if ( lastSync.count() == 0 ) {
920 //qDebug(" lastSync.count() == 0"); 920 //qDebug(" lastSync.count() == 0");
921 return; 921 return;
922 } 922 }
923 if ( toDelete->type() == "Journal" ) 923 if ( toDelete->type() == "Journal" )
924 return; 924 return;
925 925
926 Event* eve = lastSync.first(); 926 Event* eve = lastSync.first();
927 927
928 while ( eve ) { 928 while ( eve ) {
929 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 929 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
930 if ( !id.isEmpty() ) { 930 if ( !id.isEmpty() ) {
931 QString des = eve->description(); 931 QString des = eve->description();
932 QString pref = "e"; 932 QString pref = "e";
933 if ( toDelete->type() == "Todo" ) 933 if ( toDelete->type() == "Todo" )
934 pref = "t"; 934 pref = "t";
935 des += pref+ id + ","; 935 des += pref+ id + ",";
936 eve->setReadOnly( false ); 936 eve->setReadOnly( false );
937 eve->setDescription( des ); 937 eve->setDescription( des );
938 //qDebug("setdes %s ", des.latin1()); 938 //qDebug("setdes %s ", des.latin1());
939 eve->setReadOnly( true ); 939 eve->setReadOnly( true );
940 } 940 }
941 eve = lastSync.next(); 941 eve = lastSync.next();
942 } 942 }
943 943
944} 944}
945void CalendarView::checkExternalId( Incidence * inc ) 945void CalendarView::checkExternalId( Incidence * inc )
946{ 946{
947 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 947 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
948 checkExternSyncEvent( lastSync, inc ); 948 checkExternSyncEvent( lastSync, inc );
949 949
950} 950}
951bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 951bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
952{ 952{
953 bool syncOK = true; 953 bool syncOK = true;
954 int addedEvent = 0; 954 int addedEvent = 0;
955 int addedEventR = 0; 955 int addedEventR = 0;
956 int deletedEventR = 0; 956 int deletedEventR = 0;
957 int deletedEventL = 0; 957 int deletedEventL = 0;
958 int changedLocal = 0; 958 int changedLocal = 0;
959 int changedRemote = 0; 959 int changedRemote = 0;
960 int filteredIN = 0; 960 int filteredIN = 0;
961 int filteredOUT = 0; 961 int filteredOUT = 0;
962 //QPtrList<Event> el = local->rawEvents(); 962 //QPtrList<Event> el = local->rawEvents();
963 Event* eventR; 963 Event* eventR;
964 QString uid; 964 QString uid;
965 int take; 965 int take;
966 Event* eventL; 966 Event* eventL;
967 Event* eventRSync; 967 Event* eventRSync;
968 Event* eventLSync; 968 Event* eventLSync;
969 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 969 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
970 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 970 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
971 bool fullDateRange = false; 971 bool fullDateRange = false;
972 local->resetTempSyncStat(); 972 local->resetTempSyncStat();
973 mLastCalendarSync = QDateTime::currentDateTime(); 973 mLastCalendarSync = QDateTime::currentDateTime();
974 if ( mSyncManager->syncWithDesktop() ) { 974 if ( mSyncManager->syncWithDesktop() ) {
975 remote->resetPilotStat(1); 975 remote->resetPilotStat(1);
976 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 976 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
977 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 977 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
978 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 978 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
979 } else { 979 } else {
980 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 980 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
981 } 981 }
982 } 982 }
983 QDateTime modifiedCalendar = mLastCalendarSync; 983 QDateTime modifiedCalendar = mLastCalendarSync;
984 eventLSync = getLastSyncEvent(); 984 eventLSync = getLastSyncEvent();
985 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 985 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
986 if ( eventR ) { 986 if ( eventR ) {
987 eventRSync = (Event*) eventR->clone(); 987 eventRSync = (Event*) eventR->clone();
988 remote->deleteEvent(eventR ); 988 remote->deleteEvent(eventR );
989 989
990 } else { 990 } else {
991 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 991 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
992 eventRSync = (Event*)eventLSync->clone(); 992 eventRSync = (Event*)eventLSync->clone();
993 } else { 993 } else {
994 fullDateRange = true; 994 fullDateRange = true;
995 eventRSync = new Event(); 995 eventRSync = new Event();
996 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 996 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
997 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 997 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
998 eventRSync->setDtStart( mLastCalendarSync ); 998 eventRSync->setDtStart( mLastCalendarSync );
999 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 999 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1000 eventRSync->setCategories( i18n("SyncEvent") ); 1000 eventRSync->setCategories( i18n("SyncEvent") );
1001 } 1001 }
1002 } 1002 }
1003 if ( eventLSync->dtStart() == mLastCalendarSync ) 1003 if ( eventLSync->dtStart() == mLastCalendarSync )
1004 fullDateRange = true; 1004 fullDateRange = true;
1005 1005
1006 if ( ! fullDateRange ) { 1006 if ( ! fullDateRange ) {
1007 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1007 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1008 1008
1009 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1009 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1010 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1010 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1011 fullDateRange = true; 1011 fullDateRange = true;
1012 } 1012 }
1013 } 1013 }
1014 if ( mSyncManager->syncWithDesktop() ) { 1014 if ( mSyncManager->syncWithDesktop() ) {
1015 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1015 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1016 } 1016 }
1017 if ( fullDateRange ) 1017 if ( fullDateRange )
1018 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1018 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1019 else 1019 else
1020 mLastCalendarSync = eventLSync->dtStart(); 1020 mLastCalendarSync = eventLSync->dtStart();
1021 // for resyncing if own file has changed 1021 // for resyncing if own file has changed
1022 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1022 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1023 mLastCalendarSync = loadedFileVersion; 1023 mLastCalendarSync = loadedFileVersion;
1024 //qDebug("setting mLastCalendarSync "); 1024 //qDebug("setting mLastCalendarSync ");
1025 } 1025 }
1026 //qDebug("*************************** "); 1026 //qDebug("*************************** ");
1027 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1027 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1028 QPtrList<Incidence> er = remote->rawIncidences(); 1028 QPtrList<Incidence> er = remote->rawIncidences();
1029 Incidence* inR = er.first(); 1029 Incidence* inR = er.first();
1030 Incidence* inL; 1030 Incidence* inL;
1031 QProgressBar bar( er.count(),0 ); 1031 QProgressBar bar( er.count(),0 );
1032 bar.setCaption (i18n("Syncing - close to abort!") ); 1032 bar.setCaption (i18n("Syncing - close to abort!") );
1033 1033
1034 // ************** setting up filter ************* 1034 // ************** setting up filter *************
1035 CalFilter *filterIN = 0; 1035 CalFilter *filterIN = 0;
1036 CalFilter *filterOUT = 0; 1036 CalFilter *filterOUT = 0;
1037 CalFilter *filter = mFilters.first(); 1037 CalFilter *filter = mFilters.first();
1038 while(filter) { 1038 while(filter) {
1039 if ( filter->name() == mSyncManager->mFilterInCal ) 1039 if ( filter->name() == mSyncManager->mFilterInCal )
1040 filterIN = filter; 1040 filterIN = filter;
1041 if ( filter->name() == mSyncManager->mFilterOutCal ) 1041 if ( filter->name() == mSyncManager->mFilterOutCal )
1042 filterOUT = filter; 1042 filterOUT = filter;
1043 filter = mFilters.next(); 1043 filter = mFilters.next();
1044 } 1044 }
1045 int w = 300; 1045 int w = 300;
1046 if ( QApplication::desktop()->width() < 320 ) 1046 if ( QApplication::desktop()->width() < 320 )
1047 w = 220; 1047 w = 220;
1048 int h = bar.sizeHint().height() ; 1048 int h = bar.sizeHint().height() ;
1049 int dw = QApplication::desktop()->width(); 1049 int dw = QApplication::desktop()->width();
1050 int dh = QApplication::desktop()->height(); 1050 int dh = QApplication::desktop()->height();
1051 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1051 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1052 bar.show(); 1052 bar.show();
1053 int modulo = (er.count()/10)+1; 1053 int modulo = (er.count()/10)+1;
1054 int incCounter = 0; 1054 int incCounter = 0;
1055 while ( inR ) { 1055 while ( inR ) {
1056 if ( ! bar.isVisible() ) 1056 if ( ! bar.isVisible() )
1057 return false; 1057 return false;
1058 if ( incCounter % modulo == 0 ) 1058 if ( incCounter % modulo == 0 )
1059 bar.setProgress( incCounter ); 1059 bar.setProgress( incCounter );
1060 ++incCounter; 1060 ++incCounter;
1061 uid = inR->uid(); 1061 uid = inR->uid();
1062 bool skipIncidence = false; 1062 bool skipIncidence = false;
1063 if ( uid.left(15) == QString("last-syncEvent-") ) 1063 if ( uid.left(15) == QString("last-syncEvent-") )
1064 skipIncidence = true; 1064 skipIncidence = true;
1065 QString idS; 1065 QString idS;
1066 qApp->processEvents(); 1066 qApp->processEvents();
1067 if ( !skipIncidence ) { 1067 if ( !skipIncidence ) {
1068 inL = local->incidence( uid ); 1068 inL = local->incidence( uid );
1069 if ( inL ) { // maybe conflict - same uid in both calendars 1069 if ( inL ) { // maybe conflict - same uid in both calendars
1070 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1070 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1071 //qDebug("take %d %s ", take, inL->summary().latin1()); 1071 //qDebug("take %d %s ", take, inL->summary().latin1());
1072 if ( take == 3 ) 1072 if ( take == 3 )
1073 return false; 1073 return false;
1074 if ( take == 1 ) {// take local ********************** 1074 if ( take == 1 ) {// take local **********************
1075 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1075 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1076 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1076 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1077 else 1077 else
1078 idS = inR->IDStr(); 1078 idS = inR->IDStr();
1079 remote->deleteIncidence( inR ); 1079 remote->deleteIncidence( inR );
1080 inR = inL->clone(); 1080 inR = inL->clone();
1081 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1081 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1082 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1082 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1083 inR->setIDStr( idS ); 1083 inR->setIDStr( idS );
1084 remote->addIncidence( inR ); 1084 remote->addIncidence( inR );
1085 if ( mSyncManager->syncWithDesktop() ) 1085 if ( mSyncManager->syncWithDesktop() )
1086 inR->setPilotId( 2 ); 1086 inR->setPilotId( 2 );
1087 ++changedRemote; 1087 ++changedRemote;
1088 } else {// take remote ********************** 1088 } else {// take remote **********************
1089 idS = inL->IDStr(); 1089 idS = inL->IDStr();
1090 int pid = inL->pilotId(); 1090 int pid = inL->pilotId();
1091 local->deleteIncidence( inL ); 1091 local->deleteIncidence( inL );
1092 inL = inR->clone(); 1092 inL = inR->clone();
1093 if ( mSyncManager->syncWithDesktop() ) 1093 if ( mSyncManager->syncWithDesktop() )
1094 inL->setPilotId( pid ); 1094 inL->setPilotId( pid );
1095 inL->setIDStr( idS ); 1095 inL->setIDStr( idS );
1096 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1096 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1097 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1097 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1098 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1098 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1099 } 1099 }
1100 local->addIncidence( inL ); 1100 local->addIncidence( inL );
1101 ++changedLocal; 1101 ++changedLocal;
1102 } 1102 }
1103 } 1103 }
1104 } else { // no conflict ********** add or delete remote 1104 } else { // no conflict ********** add or delete remote
1105 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1105 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1106 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1106 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1107 QString des = eventLSync->description(); 1107 QString des = eventLSync->description();
1108 QString pref = "e"; 1108 QString pref = "e";
1109 if ( inR->type() == "Todo" ) 1109 if ( inR->type() == "Todo" )
1110 pref = "t"; 1110 pref = "t";
1111 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1111 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1112 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1112 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1113 //remote->deleteIncidence( inR ); 1113 //remote->deleteIncidence( inR );
1114 ++deletedEventR; 1114 ++deletedEventR;
1115 } else { 1115 } else {
1116 inR->setLastModified( modifiedCalendar ); 1116 inR->setLastModified( modifiedCalendar );
1117 inL = inR->clone(); 1117 inL = inR->clone();
1118 inL->setIDStr( ":" ); 1118 inL->setIDStr( ":" );
1119 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1119 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1120 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1120 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1121 local->addIncidence( inL ); 1121 local->addIncidence( inL );
1122 ++addedEvent; 1122 ++addedEvent;
1123 1123
1124 } 1124 }
1125 } else { 1125 } else {
1126 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1126 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1127 inR->setLastModified( modifiedCalendar ); 1127 inR->setLastModified( modifiedCalendar );
1128 inL = inR->clone(); 1128 inL = inR->clone();
1129 inL->setIDStr( ":" ); 1129 inL->setIDStr( ":" );
1130 local->addIncidence( inL ); 1130 local->addIncidence( inL );
1131 ++addedEvent; 1131 ++addedEvent;
1132 1132
1133 } else { 1133 } else {
1134 checkExternSyncEvent(eventRSyncSharp, inR); 1134 checkExternSyncEvent(eventRSyncSharp, inR);
1135 remote->deleteIncidence( inR ); 1135 remote->deleteIncidence( inR );
1136 ++deletedEventR; 1136 ++deletedEventR;
1137 } 1137 }
1138 } 1138 }
1139 } else { 1139 } else {
1140 ++filteredIN; 1140 ++filteredIN;
1141 } 1141 }
1142 } 1142 }
1143 } 1143 }
1144 inR = er.next(); 1144 inR = er.next();
1145 } 1145 }
1146 QPtrList<Incidence> el = local->rawIncidences(); 1146 QPtrList<Incidence> el = local->rawIncidences();
1147 inL = el.first(); 1147 inL = el.first();
1148 modulo = (el.count()/10)+1; 1148 modulo = (el.count()/10)+1;
1149 bar.setCaption (i18n("Add / remove events") ); 1149 bar.setCaption (i18n("Add / remove events") );
1150 bar.setTotalSteps ( el.count() ) ; 1150 bar.setTotalSteps ( el.count() ) ;
1151 bar.show(); 1151 bar.show();
1152 incCounter = 0; 1152 incCounter = 0;
1153 1153
1154 while ( inL ) { 1154 while ( inL ) {
1155 1155
1156 qApp->processEvents(); 1156 qApp->processEvents();
1157 if ( ! bar.isVisible() ) 1157 if ( ! bar.isVisible() )
1158 return false; 1158 return false;
1159 if ( incCounter % modulo == 0 ) 1159 if ( incCounter % modulo == 0 )
1160 bar.setProgress( incCounter ); 1160 bar.setProgress( incCounter );
1161 ++incCounter; 1161 ++incCounter;
1162 uid = inL->uid(); 1162 uid = inL->uid();
1163 bool skipIncidence = false; 1163 bool skipIncidence = false;
1164 if ( uid.left(15) == QString("last-syncEvent-") ) 1164 if ( uid.left(15) == QString("last-syncEvent-") )
1165 skipIncidence = true; 1165 skipIncidence = true;
1166 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1166 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1167 skipIncidence = true; 1167 skipIncidence = true;
1168 if ( !skipIncidence ) { 1168 if ( !skipIncidence ) {
1169 inR = remote->incidence( uid ); 1169 inR = remote->incidence( uid );
1170 if ( ! inR ) { 1170 if ( ! inR ) {
1171 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1171 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1172 // no conflict ********** add or delete local 1172 // no conflict ********** add or delete local
1173 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1173 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1174 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1174 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1175 checkExternSyncEvent(eventLSyncSharp, inL); 1175 checkExternSyncEvent(eventLSyncSharp, inL);
1176 local->deleteIncidence( inL ); 1176 local->deleteIncidence( inL );
1177 ++deletedEventL; 1177 ++deletedEventL;
1178 } else { 1178 } else {
1179 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1179 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1180 inL->removeID(mCurrentSyncDevice ); 1180 inL->removeID(mCurrentSyncDevice );
1181 ++addedEventR; 1181 ++addedEventR;
1182 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1182 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1183 inL->setLastModified( modifiedCalendar ); 1183 inL->setLastModified( modifiedCalendar );
1184 inR = inL->clone(); 1184 inR = inL->clone();
1185 inR->setIDStr( ":" ); 1185 inR->setIDStr( ":" );
1186 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1186 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1187 remote->addIncidence( inR ); 1187 remote->addIncidence( inR );
1188 } 1188 }
1189 } 1189 }
1190 } else { 1190 } else {
1191 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1191 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1192 checkExternSyncEvent(eventLSyncSharp, inL); 1192 checkExternSyncEvent(eventLSyncSharp, inL);
1193 local->deleteIncidence( inL ); 1193 local->deleteIncidence( inL );
1194 ++deletedEventL; 1194 ++deletedEventL;
1195 } else { 1195 } else {
1196 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1196 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1197 ++addedEventR; 1197 ++addedEventR;
1198 inL->setLastModified( modifiedCalendar ); 1198 inL->setLastModified( modifiedCalendar );
1199 inR = inL->clone(); 1199 inR = inL->clone();
1200 inR->setIDStr( ":" ); 1200 inR->setIDStr( ":" );
1201 remote->addIncidence( inR ); 1201 remote->addIncidence( inR );
1202 } 1202 }
1203 } 1203 }
1204 } 1204 }
1205 } else { 1205 } else {
1206 ++filteredOUT; 1206 ++filteredOUT;
1207 } 1207 }
1208 } 1208 }
1209 } 1209 }
1210 inL = el.next(); 1210 inL = el.next();
1211 } 1211 }
1212 int delFut = 0; 1212 int delFut = 0;
1213 int remRem = 0; 1213 int remRem = 0;
1214 if ( mSyncManager->mWriteBackInFuture ) { 1214 if ( mSyncManager->mWriteBackInFuture ) {
1215 er = remote->rawIncidences(); 1215 er = remote->rawIncidences();
1216 remRem = er.count(); 1216 remRem = er.count();
1217 inR = er.first(); 1217 inR = er.first();
1218 QDateTime dt; 1218 QDateTime dt;
1219 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1219 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1220 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1220 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1221 while ( inR ) { 1221 while ( inR ) {
1222 if ( inR->type() == "Todo" ) { 1222 if ( inR->type() == "Todo" ) {
1223 Todo * t = (Todo*)inR; 1223 Todo * t = (Todo*)inR;
1224 if ( t->hasDueDate() ) 1224 if ( t->hasDueDate() )
1225 dt = t->dtDue(); 1225 dt = t->dtDue();
1226 else 1226 else
1227 dt = cur.addSecs( 62 ); 1227 dt = cur.addSecs( 62 );
1228 } 1228 }
1229 else if (inR->type() == "Event" ) { 1229 else if (inR->type() == "Event" ) {
1230 bool ok; 1230 bool ok;
1231 dt = inR->getNextOccurence( cur, &ok ); 1231 dt = inR->getNextOccurence( cur, &ok );
1232 if ( !ok ) 1232 if ( !ok )
1233 dt = cur.addSecs( -62 ); 1233 dt = cur.addSecs( -62 );
1234 } 1234 }
1235 else 1235 else
1236 dt = inR->dtStart(); 1236 dt = inR->dtStart();
1237 if ( dt < cur || dt > end ) { 1237 if ( dt < cur || dt > end ) {
1238 remote->deleteIncidence( inR ); 1238 remote->deleteIncidence( inR );
1239 ++delFut; 1239 ++delFut;
1240 } 1240 }
1241 inR = er.next(); 1241 inR = er.next();
1242 } 1242 }
1243 } 1243 }
1244 bar.hide(); 1244 bar.hide();
1245 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1245 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1246 eventLSync->setReadOnly( false ); 1246 eventLSync->setReadOnly( false );
1247 eventLSync->setDtStart( mLastCalendarSync ); 1247 eventLSync->setDtStart( mLastCalendarSync );
1248 eventRSync->setDtStart( mLastCalendarSync ); 1248 eventRSync->setDtStart( mLastCalendarSync );
1249 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1249 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1250 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1250 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1251 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1251 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1252 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1252 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1253 eventLSync->setReadOnly( true ); 1253 eventLSync->setReadOnly( true );
1254 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1254 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1255 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1255 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1256 remote->addEvent( eventRSync ); 1256 remote->addEvent( eventRSync );
1257 else 1257 else
1258 delete eventRSync; 1258 delete eventRSync;
1259 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1259 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1260 QString mes; 1260 QString mes;
1261 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1261 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1262 QString delmess; 1262 QString delmess;
1263 if ( delFut ) { 1263 if ( delFut ) {
1264 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1264 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1265 mes += delmess; 1265 mes += delmess;
1266 } 1266 }
1267 mes = i18n("Local calendar changed!\n") +mes; 1267 mes = i18n("Local calendar changed!\n") +mes;
1268 mCalendar->checkAlarmForIncidence( 0, true ); 1268 mCalendar->checkAlarmForIncidence( 0, true );
1269 qDebug( mes ); 1269 qDebug( mes );
1270 if ( mSyncManager->mShowSyncSummary ) { 1270 if ( mSyncManager->mShowSyncSummary ) {
1271 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1271 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1272 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1272 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1273 qDebug("KO: WB cancelled "); 1273 qDebug("KO: WB cancelled ");
1274 mSyncManager->mWriteBackFile = false; 1274 mSyncManager->mWriteBackFile = false;
1275 return syncOK; 1275 return syncOK;
1276 } 1276 }
1277 } 1277 }
1278 return syncOK; 1278 return syncOK;
1279} 1279}
1280 1280
1281void CalendarView::setSyncDevice( QString s ) 1281void CalendarView::setSyncDevice( QString s )
1282{ 1282{
1283 mCurrentSyncDevice= s; 1283 mCurrentSyncDevice= s;
1284} 1284}
1285void CalendarView::setSyncName( QString s ) 1285void CalendarView::setSyncName( QString s )
1286{ 1286{
1287 mCurrentSyncName= s; 1287 mCurrentSyncName= s;
1288} 1288}
1289bool CalendarView::syncCalendar(QString filename, int mode) 1289bool CalendarView::syncCalendar(QString filename, int mode)
1290{ 1290{
1291 //qDebug("syncCalendar %s ", filename.latin1()); 1291 //qDebug("syncCalendar %s ", filename.latin1());
1292 mGlobalSyncMode = SYNC_MODE_NORMAL; 1292 mGlobalSyncMode = SYNC_MODE_NORMAL;
1293 CalendarLocal* calendar = new CalendarLocal(); 1293 CalendarLocal* calendar = new CalendarLocal();
1294 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1294 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1295 FileStorage* storage = new FileStorage( calendar ); 1295 FileStorage* storage = new FileStorage( calendar );
1296 bool syncOK = false; 1296 bool syncOK = false;
1297 storage->setFileName( filename ); 1297 storage->setFileName( filename );
1298 // qDebug("loading ... "); 1298 // qDebug("loading ... ");
1299 if ( storage->load() ) { 1299 if ( storage->load() ) {
1300 getEventViewerDialog()->setSyncMode( true ); 1300 getEventViewerDialog()->setSyncMode( true );
1301 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1301 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1302 getEventViewerDialog()->setSyncMode( false ); 1302 getEventViewerDialog()->setSyncMode( false );
1303 if ( syncOK ) { 1303 if ( syncOK ) {
1304 if ( mSyncManager->mWriteBackFile ) 1304 if ( mSyncManager->mWriteBackFile )
1305 { 1305 {
1306 storage->setSaveFormat( new ICalFormat() ); 1306 storage->setSaveFormat( new ICalFormat() );
1307 storage->save(); 1307 storage->save();
1308 } 1308 }
1309 } 1309 }
1310 setModified( true ); 1310 setModified( true );
1311 } 1311 }
1312 delete storage; 1312 delete storage;
1313 delete calendar; 1313 delete calendar;
1314 if ( syncOK ) 1314 if ( syncOK )
1315 updateView(); 1315 updateView();
1316 return syncOK; 1316 return syncOK;
1317} 1317}
1318 1318
1319void CalendarView::syncExternal( int mode ) 1319void CalendarView::syncExternal( int mode )
1320{ 1320{
1321 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1321 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1322 1322
1323 qApp->processEvents(); 1323 qApp->processEvents();
1324 CalendarLocal* calendar = new CalendarLocal(); 1324 CalendarLocal* calendar = new CalendarLocal();
1325 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1325 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1326 bool syncOK = false; 1326 bool syncOK = false;
1327 bool loadSuccess = false; 1327 bool loadSuccess = false;
1328 PhoneFormat* phoneFormat = 0; 1328 PhoneFormat* phoneFormat = 0;
1329 emit tempDisableBR(true); 1329 emit tempDisableBR(true);
1330#ifndef DESKTOP_VERSION 1330#ifndef DESKTOP_VERSION
1331 SharpFormat* sharpFormat = 0; 1331 SharpFormat* sharpFormat = 0;
1332 if ( mode == 0 ) { // sharp 1332 if ( mode == 0 ) { // sharp
1333 sharpFormat = new SharpFormat () ; 1333 sharpFormat = new SharpFormat () ;
1334 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1334 loadSuccess = sharpFormat->load( calendar, mCalendar );
1335 1335
1336 } else 1336 } else
1337#endif 1337#endif
1338 if ( mode == 1 ) { // phone 1338 if ( mode == 1 ) { // phone
1339 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1339 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1340 mSyncManager->mPhoneDevice, 1340 mSyncManager->mPhoneDevice,
1341 mSyncManager->mPhoneConnection, 1341 mSyncManager->mPhoneConnection,
1342 mSyncManager->mPhoneModel); 1342 mSyncManager->mPhoneModel);
1343 loadSuccess = phoneFormat->load( calendar,mCalendar); 1343 loadSuccess = phoneFormat->load( calendar,mCalendar);
1344 1344
1345 } else { 1345 } else {
1346 emit tempDisableBR(false); 1346 emit tempDisableBR(false);
1347 return; 1347 return;
1348 } 1348 }
1349 if ( loadSuccess ) { 1349 if ( loadSuccess ) {
1350 getEventViewerDialog()->setSyncMode( true ); 1350 getEventViewerDialog()->setSyncMode( true );
1351 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1351 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1352 getEventViewerDialog()->setSyncMode( false ); 1352 getEventViewerDialog()->setSyncMode( false );
1353 qApp->processEvents(); 1353 qApp->processEvents();
1354 if ( syncOK ) { 1354 if ( syncOK ) {
1355 if ( mSyncManager->mWriteBackFile ) 1355 if ( mSyncManager->mWriteBackFile )
1356 { 1356 {
1357 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1357 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1358 Incidence* inc = iL.first(); 1358 Incidence* inc = iL.first();
1359 if ( phoneFormat ) { 1359 if ( phoneFormat ) {
1360 while ( inc ) { 1360 while ( inc ) {
1361 inc->removeID(mCurrentSyncDevice); 1361 inc->removeID(mCurrentSyncDevice);
1362 inc = iL.next(); 1362 inc = iL.next();
1363 } 1363 }
1364 } 1364 }
1365#ifndef DESKTOP_VERSION 1365#ifndef DESKTOP_VERSION
1366 if ( sharpFormat ) 1366 if ( sharpFormat )
1367 sharpFormat->save(calendar); 1367 sharpFormat->save(calendar);
1368#endif 1368#endif
1369 if ( phoneFormat ) 1369 if ( phoneFormat )
1370 phoneFormat->save(calendar); 1370 phoneFormat->save(calendar);
1371 iL = calendar->rawIncidences(); 1371 iL = calendar->rawIncidences();
1372 inc = iL.first(); 1372 inc = iL.first();
1373 Incidence* loc; 1373 Incidence* loc;
1374 while ( inc ) { 1374 while ( inc ) {
1375 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1375 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1376 loc = mCalendar->incidence(inc->uid() ); 1376 loc = mCalendar->incidence(inc->uid() );
1377 if ( loc ) { 1377 if ( loc ) {
1378 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1378 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1379 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1379 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1380 } 1380 }
1381 } 1381 }
1382 inc = iL.next(); 1382 inc = iL.next();
1383 } 1383 }
1384 Incidence* lse = getLastSyncEvent(); 1384 Incidence* lse = getLastSyncEvent();
1385 if ( lse ) { 1385 if ( lse ) {
1386 lse->setReadOnly( false ); 1386 lse->setReadOnly( false );
1387 lse->setDescription( "" ); 1387 lse->setDescription( "" );
1388 lse->setReadOnly( true ); 1388 lse->setReadOnly( true );
1389 } 1389 }
1390 } 1390 }
1391 } else { 1391 } else {
1392 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1392 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1393 } 1393 }
1394 setModified( true ); 1394 setModified( true );
1395 } else { 1395 } else {
1396 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1396 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1397 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1397 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1398 question, i18n("Ok")) ; 1398 question, i18n("Ok")) ;
1399 1399
1400 } 1400 }
1401 delete calendar; 1401 delete calendar;
1402 updateView(); 1402 updateView();
1403 emit tempDisableBR(false); 1403 emit tempDisableBR(false);
1404 return ;//syncOK; 1404 return ;//syncOK;
1405 1405
1406} 1406}
1407 1407
1408bool CalendarView::importBday() 1408bool CalendarView::importBday()
1409{ 1409{
1410#ifndef KORG_NOKABC 1410#ifndef KORG_NOKABC
1411 1411
1412#ifdef DESKTOP_VERSION 1412#ifdef DESKTOP_VERSION
1413 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1413 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1414 KABC::AddressBook::Iterator it; 1414 KABC::AddressBook::Iterator it;
1415 int count = 0; 1415 int count = 0;
1416 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1416 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1417 ++count; 1417 ++count;
1418 } 1418 }
1419 QProgressBar bar(count,0 ); 1419 QProgressBar bar(count,0 );
1420 int w = 300; 1420 int w = 300;
1421 if ( QApplication::desktop()->width() < 320 ) 1421 if ( QApplication::desktop()->width() < 320 )
1422 w = 220; 1422 w = 220;
1423 int h = bar.sizeHint().height() ; 1423 int h = bar.sizeHint().height() ;
1424 int dw = QApplication::desktop()->width(); 1424 int dw = QApplication::desktop()->width();
1425 int dh = QApplication::desktop()->height(); 1425 int dh = QApplication::desktop()->height();
1426 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1426 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1427 bar.show(); 1427 bar.show();
1428 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1428 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1429 qApp->processEvents(); 1429 qApp->processEvents();
1430 count = 0; 1430 count = 0;
1431 int addCount = 0; 1431 int addCount = 0;
1432 KCal::Attendee* a = 0; 1432 KCal::Attendee* a = 0;
1433 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1433 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1434 if ( ! bar.isVisible() ) 1434 if ( ! bar.isVisible() )
1435 return false; 1435 return false;
1436 bar.setProgress( count++ ); 1436 bar.setProgress( count++ );
1437 qApp->processEvents(); 1437 qApp->processEvents();
1438 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1438 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1439 if ( (*it).birthday().date().isValid() ){ 1439 if ( (*it).birthday().date().isValid() ){
1440 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1440 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1441 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1441 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1442 ++addCount; 1442 ++addCount;
1443 } 1443 }
1444 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1444 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1445 if ( anni.isValid() ){ 1445 if ( anni.isValid() ){
1446 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1446 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1447 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1447 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1448 ++addCount; 1448 ++addCount;
1449 } 1449 }
1450 } 1450 }
1451 updateView(); 1451 updateView();
1452 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1452 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1453#else //DESKTOP_VERSION 1453#else //DESKTOP_VERSION
1454 1454
1455 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1455 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1456 // the result should now arrive through method insertBirthdays 1456 // the result should now arrive through method insertBirthdays
1457 1457
1458#endif //DESKTOP_VERSION 1458#endif //DESKTOP_VERSION
1459 1459
1460#endif //KORG_NOKABC 1460#endif //KORG_NOKABC
1461 1461
1462 1462
1463 return true; 1463 return true;
1464} 1464}
1465 1465
1466// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1466// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1467void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1467void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1468 const QStringList& anniversaryList, const QStringList& realNameList, 1468 const QStringList& anniversaryList, const QStringList& realNameList,
1469 const QStringList& emailList, const QStringList& assembledNameList, 1469 const QStringList& emailList, const QStringList& assembledNameList,
1470 const QStringList& uidList) 1470 const QStringList& uidList)
1471{ 1471{
1472 //qDebug("KO::CalendarView::insertBirthdays"); 1472 //qDebug("KO::CalendarView::insertBirthdays");
1473 if (uid == this->name()) 1473 if (uid == this->name())
1474 { 1474 {
1475 int count = birthdayList.count(); 1475 int count = birthdayList.count();
1476 int addCount = 0; 1476 int addCount = 0;
1477 KCal::Attendee* a = 0; 1477 KCal::Attendee* a = 0;
1478 1478
1479 //qDebug("CalView 1 %i", count); 1479 //qDebug("CalView 1 %i", count);
1480 1480
1481 QProgressBar bar(count,0 ); 1481 QProgressBar bar(count,0 );
1482 int w = 300; 1482 int w = 300;
1483 if ( QApplication::desktop()->width() < 320 ) 1483 if ( QApplication::desktop()->width() < 320 )
1484 w = 220; 1484 w = 220;
1485 int h = bar.sizeHint().height() ; 1485 int h = bar.sizeHint().height() ;
1486 int dw = QApplication::desktop()->width(); 1486 int dw = QApplication::desktop()->width();
1487 int dh = QApplication::desktop()->height(); 1487 int dh = QApplication::desktop()->height();
1488 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1488 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1489 bar.show(); 1489 bar.show();
1490 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1490 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1491 qApp->processEvents(); 1491 qApp->processEvents();
1492 1492
1493 QDate birthday; 1493 QDate birthday;
1494 QDate anniversary; 1494 QDate anniversary;
1495 QString realName; 1495 QString realName;
1496 QString email; 1496 QString email;
1497 QString assembledName; 1497 QString assembledName;
1498 QString uid; 1498 QString uid;
1499 bool ok = true; 1499 bool ok = true;
1500 for ( int i = 0; i < count; i++) 1500 for ( int i = 0; i < count; i++)
1501 { 1501 {
1502 if ( ! bar.isVisible() ) 1502 if ( ! bar.isVisible() )
1503 return; 1503 return;
1504 bar.setProgress( i ); 1504 bar.setProgress( i );
1505 qApp->processEvents(); 1505 qApp->processEvents();
1506 1506
1507 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1507 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1508 if (!ok) { 1508 if (!ok) {
1509 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1509 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1510 } 1510 }
1511 1511
1512 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1512 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1513 if (!ok) { 1513 if (!ok) {
1514 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1514 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1515 } 1515 }
1516 realName = realNameList[i]; 1516 realName = realNameList[i];
1517 email = emailList[i]; 1517 email = emailList[i];
1518 assembledName = assembledNameList[i]; 1518 assembledName = assembledNameList[i];
1519 uid = uidList[i]; 1519 uid = uidList[i];
1520 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1520 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1521 1521
1522 if ( birthday.isValid() ){ 1522 if ( birthday.isValid() ){
1523 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1523 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1524 KCal::Attendee::ReqParticipant,uid) ; 1524 KCal::Attendee::ReqParticipant,uid) ;
1525 if ( addAnniversary( birthday, assembledName, a, true ) ) 1525 if ( addAnniversary( birthday, assembledName, a, true ) )
1526 ++addCount; 1526 ++addCount;
1527 } 1527 }
1528 1528
1529 if ( anniversary.isValid() ){ 1529 if ( anniversary.isValid() ){
1530 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1530 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1531 KCal::Attendee::ReqParticipant,uid) ; 1531 KCal::Attendee::ReqParticipant,uid) ;
1532 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1532 if ( addAnniversary( anniversary, assembledName, a, false ) )
1533 ++addCount; 1533 ++addCount;
1534 } 1534 }
1535 } 1535 }
1536 1536
1537 updateView(); 1537 updateView();
1538 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1538 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1539 1539
1540 } 1540 }
1541 1541
1542} 1542}
1543 1543
1544 1544
1545 1545
1546bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1546bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1547{ 1547{
1548 //qDebug("addAnni "); 1548 //qDebug("addAnni ");
1549 Event * ev = new Event(); 1549 Event * ev = new Event();
1550 ev->setOrganizer(KOPrefs::instance()->email()); 1550 ev->setOrganizer(KOPrefs::instance()->email());
1551 if ( a ) { 1551 if ( a ) {
1552 ev->addAttendee( a ); 1552 ev->addAttendee( a );
1553 } 1553 }
1554 QString kind; 1554 QString kind;
1555 if ( birthday ) { 1555 if ( birthday ) {
1556 kind = i18n( "Birthday" ); 1556 kind = i18n( "Birthday" );
1557 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1557 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1558 } 1558 }
1559 else { 1559 else {
1560 kind = i18n( "Anniversary" ); 1560 kind = i18n( "Anniversary" );
1561 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1561 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1562 } 1562 }
1563 ev->setCategories( kind ); 1563 ev->setCategories( kind );
1564 ev->setDtStart( QDateTime(date) ); 1564 ev->setDtStart( QDateTime(date) );
1565 ev->setDtEnd( QDateTime(date) ); 1565 ev->setDtEnd( QDateTime(date) );
1566 ev->setFloats( true ); 1566 ev->setFloats( true );
1567 Recurrence * rec = ev->recurrence(); 1567 Recurrence * rec = ev->recurrence();
1568 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1568 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1569 rec->addYearlyNum( date.month() ); 1569 rec->addYearlyNum( date.month() );
1570 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1570 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1571 delete ev; 1571 delete ev;
1572 return false; 1572 return false;
1573 } 1573 }
1574 return true; 1574 return true;
1575 1575
1576} 1576}
1577bool CalendarView::importQtopia( const QString &categories, 1577bool CalendarView::importQtopia( const QString &categories,
1578 const QString &datebook, 1578 const QString &datebook,
1579 const QString &todolist ) 1579 const QString &todolist )
1580{ 1580{
1581 1581
1582 QtopiaFormat qtopiaFormat; 1582 QtopiaFormat qtopiaFormat;
1583 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1583 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1584 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1584 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1585 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1585 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1586 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1586 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1587 1587
1588 updateView(); 1588 updateView();
1589 return true; 1589 return true;
1590 1590
1591#if 0 1591#if 0
1592 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1592 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1593 mCurrentSyncDevice = "qtopia-XML"; 1593 mCurrentSyncDevice = "qtopia-XML";
1594 if ( mSyncManager->mAskForPreferences ) 1594 if ( mSyncManager->mAskForPreferences )
1595 edit_sync_options(); 1595 edit_sync_options();
1596 qApp->processEvents(); 1596 qApp->processEvents();
1597 CalendarLocal* calendar = new CalendarLocal(); 1597 CalendarLocal* calendar = new CalendarLocal();
1598 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1598 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1599 bool syncOK = false; 1599 bool syncOK = false;
1600 QtopiaFormat qtopiaFormat; 1600 QtopiaFormat qtopiaFormat;
1601 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1601 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1602 bool loadOk = true; 1602 bool loadOk = true;
1603 if ( !categories.isEmpty() ) 1603 if ( !categories.isEmpty() )
1604 loadOk = qtopiaFormat.load( calendar, categories ); 1604 loadOk = qtopiaFormat.load( calendar, categories );
1605 if ( loadOk && !datebook.isEmpty() ) 1605 if ( loadOk && !datebook.isEmpty() )
1606 loadOk = qtopiaFormat.load( calendar, datebook ); 1606 loadOk = qtopiaFormat.load( calendar, datebook );
1607 if ( loadOk && !todolist.isEmpty() ) 1607 if ( loadOk && !todolist.isEmpty() )
1608 loadOk = qtopiaFormat.load( calendar, todolist ); 1608 loadOk = qtopiaFormat.load( calendar, todolist );
1609 1609
1610 if ( loadOk ) { 1610 if ( loadOk ) {
1611 getEventViewerDialog()->setSyncMode( true ); 1611 getEventViewerDialog()->setSyncMode( true );
1612 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1612 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1613 getEventViewerDialog()->setSyncMode( false ); 1613 getEventViewerDialog()->setSyncMode( false );
1614 qApp->processEvents(); 1614 qApp->processEvents();
1615 if ( syncOK ) { 1615 if ( syncOK ) {
1616 if ( mSyncManager->mWriteBackFile ) 1616 if ( mSyncManager->mWriteBackFile )
1617 { 1617 {
1618 // write back XML file 1618 // write back XML file
1619 1619
1620 } 1620 }
1621 setModified( true ); 1621 setModified( true );
1622 } 1622 }
1623 } else { 1623 } else {
1624 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1624 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1625 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1625 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1626 question, i18n("Ok")) ; 1626 question, i18n("Ok")) ;
1627 } 1627 }
1628 delete calendar; 1628 delete calendar;
1629 updateView(); 1629 updateView();
1630 return syncOK; 1630 return syncOK;
1631 1631
1632 1632
1633#endif 1633#endif
1634 1634
1635} 1635}
1636 1636
1637void CalendarView::setSyncEventsReadOnly() 1637void CalendarView::setSyncEventsReadOnly()
1638{ 1638{
1639 Event * ev; 1639 Event * ev;
1640 QPtrList<Event> eL = mCalendar->rawEvents(); 1640 QPtrList<Event> eL = mCalendar->rawEvents();
1641 ev = eL.first(); 1641 ev = eL.first();
1642 while ( ev ) { 1642 while ( ev ) {
1643 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1643 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1644 ev->setReadOnly( true ); 1644 ev->setReadOnly( true );
1645 ev = eL.next(); 1645 ev = eL.next();
1646 } 1646 }
1647} 1647}
1648bool CalendarView::openCalendar(QString filename, bool merge) 1648bool CalendarView::openCalendar(QString filename, bool merge)
1649{ 1649{
1650 1650
1651 if (filename.isEmpty()) { 1651 if (filename.isEmpty()) {
1652 return false; 1652 return false;
1653 } 1653 }
1654 1654
1655 if (!QFile::exists(filename)) { 1655 if (!QFile::exists(filename)) {
1656 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1656 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1657 return false; 1657 return false;
1658 } 1658 }
1659 1659
1660 globalFlagBlockAgenda = 1; 1660 globalFlagBlockAgenda = 1;
1661 if (!merge) mCalendar->close(); 1661 if (!merge) {
1662 1662 mCalendar->close();
1663 mTodoList->clearList();
1664 }
1663 mStorage->setFileName( filename ); 1665 mStorage->setFileName( filename );
1664 1666
1665 if ( mStorage->load() ) { 1667 if ( mStorage->load() ) {
1666 if ( merge ) ;//setModified( true ); 1668 if ( merge ) ;//setModified( true );
1667 else { 1669 else {
1668 //setModified( true ); 1670 //setModified( true );
1669 mViewManager->setDocumentId( filename ); 1671 mViewManager->setDocumentId( filename );
1670 mDialogManager->setDocumentId( filename ); 1672 mDialogManager->setDocumentId( filename );
1671 mTodoList->setDocumentId( filename ); 1673 mTodoList->setDocumentId( filename );
1672 } 1674 }
1673 globalFlagBlockAgenda = 2; 1675 globalFlagBlockAgenda = 2;
1674 // if ( getLastSyncEvent() ) 1676 // if ( getLastSyncEvent() )
1675 // getLastSyncEvent()->setReadOnly( true ); 1677 // getLastSyncEvent()->setReadOnly( true );
1676 mCalendar->reInitAlarmSettings(); 1678 mCalendar->reInitAlarmSettings();
1677 setSyncEventsReadOnly(); 1679 setSyncEventsReadOnly();
1678 updateUnmanagedViews(); 1680 updateUnmanagedViews();
1679 updateView(); 1681 updateView();
1680 if ( filename != MainWindow::defaultFileName() ) { 1682 if ( filename != MainWindow::defaultFileName() ) {
1681 saveCalendar( MainWindow::defaultFileName() ); 1683 saveCalendar( MainWindow::defaultFileName() );
1682 } else { 1684 } else {
1683 QFileInfo finf ( MainWindow::defaultFileName()); 1685 QFileInfo finf ( MainWindow::defaultFileName());
1684 if ( finf.exists() ) { 1686 if ( finf.exists() ) {
1685 setLoadedFileVersion( finf.lastModified () ); 1687 setLoadedFileVersion( finf.lastModified () );
1686 } 1688 }
1687 } 1689 }
1688 return true; 1690 return true;
1689 } else { 1691 } else {
1690 // while failing to load, the calendar object could 1692 // while failing to load, the calendar object could
1691 // have become partially populated. Clear it out. 1693 // have become partially populated. Clear it out.
1692 if ( !merge ) { 1694 if ( !merge ) {
1693 mCalendar->close(); 1695 mCalendar->close();
1694 mViewManager->setDocumentId( filename ); 1696 mViewManager->setDocumentId( filename );
1695 mDialogManager->setDocumentId( filename ); 1697 mDialogManager->setDocumentId( filename );
1696 mTodoList->setDocumentId( filename ); 1698 mTodoList->setDocumentId( filename );
1697 } 1699 }
1698 1700
1699 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1701 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1700 1702
1701 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1703 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1702 globalFlagBlockAgenda = 2; 1704 globalFlagBlockAgenda = 2;
1703 mCalendar->reInitAlarmSettings(); 1705 mCalendar->reInitAlarmSettings();
1704 setSyncEventsReadOnly(); 1706 setSyncEventsReadOnly();
1705 updateUnmanagedViews(); 1707 updateUnmanagedViews();
1706 updateView(); 1708 updateView();
1707 } 1709 }
1708 return false; 1710 return false;
1709} 1711}
1710void CalendarView::showOpenError() 1712void CalendarView::showOpenError()
1711{ 1713{
1712 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1714 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1713} 1715}
1714void CalendarView::setLoadedFileVersion(QDateTime dt) 1716void CalendarView::setLoadedFileVersion(QDateTime dt)
1715{ 1717{
1716 loadedFileVersion = dt; 1718 loadedFileVersion = dt;
1717} 1719}
1718bool CalendarView::checkFileChanged(QString fn) 1720bool CalendarView::checkFileChanged(QString fn)
1719{ 1721{
1720 QFileInfo finf ( fn ); 1722 QFileInfo finf ( fn );
1721 if ( !finf.exists() ) 1723 if ( !finf.exists() )
1722 return true; 1724 return true;
1723 QDateTime dt = finf.lastModified (); 1725 QDateTime dt = finf.lastModified ();
1724 if ( dt <= loadedFileVersion ) 1726 if ( dt <= loadedFileVersion )
1725 return false; 1727 return false;
1726 return true; 1728 return true;
1727 1729
1728} 1730}
1729void CalendarView::watchSavedFile() 1731void CalendarView::watchSavedFile()
1730{ 1732{
1731 QFileInfo finf ( MainWindow::defaultFileName()); 1733 QFileInfo finf ( MainWindow::defaultFileName());
1732 if ( !finf.exists() ) 1734 if ( !finf.exists() )
1733 return; 1735 return;
1734 QDateTime dt = finf.lastModified (); 1736 QDateTime dt = finf.lastModified ();
1735 if ( dt < loadedFileVersion ) { 1737 if ( dt < loadedFileVersion ) {
1736 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1738 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1737 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1739 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1738 return; 1740 return;
1739 } 1741 }
1740 loadedFileVersion = dt; 1742 loadedFileVersion = dt;
1741} 1743}
1742 1744
1743bool CalendarView::checkFileVersion(QString fn) 1745bool CalendarView::checkFileVersion(QString fn)
1744{ 1746{
1745 QFileInfo finf ( fn ); 1747 QFileInfo finf ( fn );
1746 if ( !finf.exists() ) 1748 if ( !finf.exists() )
1747 return true; 1749 return true;
1748 QDateTime dt = finf.lastModified (); 1750 QDateTime dt = finf.lastModified ();
1749 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1751 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1750 //qDebug("file on disk version %s",dt.toString().latin1()); 1752 //qDebug("file on disk version %s",dt.toString().latin1());
1751 if ( dt <= loadedFileVersion ) 1753 if ( dt <= loadedFileVersion )
1752 return true; 1754 return true;
1753 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1755 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1754 i18n("KO/Pi Warning"),i18n("Overwrite"), 1756 i18n("KO/Pi Warning"),i18n("Overwrite"),
1755 i18n("Sync+save")); 1757 i18n("Sync+save"));
1756 1758
1757 if ( km == KMessageBox::Cancel ) 1759 if ( km == KMessageBox::Cancel )
1758 return false; 1760 return false;
1759 if ( km == KMessageBox::Yes ) 1761 if ( km == KMessageBox::Yes )
1760 return true; 1762 return true;
1761 1763
1762 setSyncDevice("deleteaftersync" ); 1764 setSyncDevice("deleteaftersync" );
1763 mSyncManager->mAskForPreferences = true; 1765 mSyncManager->mAskForPreferences = true;
1764 mSyncManager->mSyncAlgoPrefs = 3; 1766 mSyncManager->mSyncAlgoPrefs = 3;
1765 mSyncManager->mWriteBackFile = false; 1767 mSyncManager->mWriteBackFile = false;
1766 mSyncManager->mWriteBackExistingOnly = false; 1768 mSyncManager->mWriteBackExistingOnly = false;
1767 mSyncManager->mShowSyncSummary = false; 1769 mSyncManager->mShowSyncSummary = false;
1768 syncCalendar( fn, 3 ); 1770 syncCalendar( fn, 3 );
1769 Event * e = getLastSyncEvent(); 1771 Event * e = getLastSyncEvent();
1770 mCalendar->deleteEvent ( e ); 1772 mCalendar->deleteEvent ( e );
1771 updateView(); 1773 updateView();
1772 return true; 1774 return true;
1773} 1775}
1774 1776
1775bool CalendarView::saveCalendar( QString filename ) 1777bool CalendarView::saveCalendar( QString filename )
1776{ 1778{
1777 1779
1778 // Store back all unsaved data into calendar object 1780 // Store back all unsaved data into calendar object
1779 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1781 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1780 if ( mViewManager->currentView() ) 1782 if ( mViewManager->currentView() )
1781 mViewManager->currentView()->flushView(); 1783 mViewManager->currentView()->flushView();
1782 1784
1783 1785
1784 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1786 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1785 mStorage->setSaveFormat( new ICalFormat() ); 1787 mStorage->setSaveFormat( new ICalFormat() );
1786 mStorage->setFileName( filename ); 1788 mStorage->setFileName( filename );
1787 bool success; 1789 bool success;
1788 success = mStorage->save(); 1790 success = mStorage->save();
1789 if ( !success ) { 1791 if ( !success ) {
1790 return false; 1792 return false;
1791 } 1793 }
1792 if ( filename == MainWindow::defaultFileName() ) { 1794 if ( filename == MainWindow::defaultFileName() ) {
1793 setLoadedFileVersion( lfv ); 1795 setLoadedFileVersion( lfv );
1794 watchSavedFile(); 1796 watchSavedFile();
1795 } 1797 }
1796 return true; 1798 return true;
1797} 1799}
1798 1800
1799void CalendarView::closeCalendar() 1801void CalendarView::closeCalendar()
1800{ 1802{
1801 1803
1802 // child windows no longer valid 1804 // child windows no longer valid
1803 emit closingDown(); 1805 emit closingDown();
1804 1806
1805 mCalendar->close(); 1807 mCalendar->close();
1806 setModified(false); 1808 setModified(false);
1807 updateView(); 1809 updateView();
1808} 1810}
1809 1811
1810void CalendarView::archiveCalendar() 1812void CalendarView::archiveCalendar()
1811{ 1813{
1812 mDialogManager->showArchiveDialog(); 1814 mDialogManager->showArchiveDialog();
1813} 1815}
1814 1816
1815 1817
1816void CalendarView::readSettings() 1818void CalendarView::readSettings()
1817{ 1819{
1818 1820
1819 1821
1820 // mViewManager->showAgendaView(); 1822 // mViewManager->showAgendaView();
1821 QString str; 1823 QString str;
1822 //qDebug("CalendarView::readSettings() "); 1824 //qDebug("CalendarView::readSettings() ");
1823 // read settings from the KConfig, supplying reasonable 1825 // read settings from the KConfig, supplying reasonable
1824 // defaults where none are to be found 1826 // defaults where none are to be found
1825 KConfig *config = KOGlobals::config(); 1827 KConfig *config = KOGlobals::config();
1826#ifndef KORG_NOSPLITTER 1828#ifndef KORG_NOSPLITTER
1827 config->setGroup("KOrganizer Geometry"); 1829 config->setGroup("KOrganizer Geometry");
1828 1830
1829 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1831 QValueList<int> sizes = config->readIntListEntry("Separator1");
1830 if (sizes.count() != 2) { 1832 if (sizes.count() != 2) {
1831 sizes << mDateNavigator->minimumSizeHint().width(); 1833 sizes << mDateNavigator->minimumSizeHint().width();
1832 sizes << 300; 1834 sizes << 300;
1833 } 1835 }
1834 mPanner->setSizes(sizes); 1836 mPanner->setSizes(sizes);
1835 1837
1836 sizes = config->readIntListEntry("Separator2"); 1838 sizes = config->readIntListEntry("Separator2");
1837 if ( ( mResourceView && sizes.count() == 4 ) || 1839 if ( ( mResourceView && sizes.count() == 4 ) ||
1838 ( !mResourceView && sizes.count() == 3 ) ) { 1840 ( !mResourceView && sizes.count() == 3 ) ) {
1839 mLeftSplitter->setSizes(sizes); 1841 mLeftSplitter->setSizes(sizes);
1840 } 1842 }
1841#endif 1843#endif
1842 globalFlagBlockAgenda = 1; 1844 globalFlagBlockAgenda = 1;
1843 mViewManager->showAgendaView(); 1845 mViewManager->showAgendaView();
1844 //mViewManager->readSettings( config ); 1846 //mViewManager->readSettings( config );
1845 mTodoList->restoreLayout(config,QString("Todo Layout")); 1847 mTodoList->restoreLayout(config,QString("Todo Layout"));
1846 readFilterSettings(config); 1848 readFilterSettings(config);
1847 1849
1848#ifdef DESKTOP_VERSION 1850#ifdef DESKTOP_VERSION
1849 config->setGroup("WidgetLayout"); 1851 config->setGroup("WidgetLayout");
1850 QStringList list; 1852 QStringList list;
1851 list = config->readListEntry("MainLayout"); 1853 list = config->readListEntry("MainLayout");
1852 int x,y,w,h; 1854 int x,y,w,h;
1853 if ( ! list.isEmpty() ) { 1855 if ( ! list.isEmpty() ) {
1854 x = list[0].toInt(); 1856 x = list[0].toInt();
1855 y = list[1].toInt(); 1857 y = list[1].toInt();
1856 w = list[2].toInt(); 1858 w = list[2].toInt();
1857 h = list[3].toInt(); 1859 h = list[3].toInt();
1858 KApplication::testCoords( &x,&y,&w,&h ); 1860 KApplication::testCoords( &x,&y,&w,&h );
1859 topLevelWidget()->setGeometry(x,y,w,h); 1861 topLevelWidget()->setGeometry(x,y,w,h);
1860 1862
1861 } else { 1863 } else {
1862 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1864 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1863 } 1865 }
1864 list = config->readListEntry("EditEventLayout"); 1866 list = config->readListEntry("EditEventLayout");
1865 if ( ! list.isEmpty() ) { 1867 if ( ! list.isEmpty() ) {
1866 x = list[0].toInt(); 1868 x = list[0].toInt();
1867 y = list[1].toInt(); 1869 y = list[1].toInt();
1868 w = list[2].toInt(); 1870 w = list[2].toInt();
1869 h = list[3].toInt(); 1871 h = list[3].toInt();
1870 KApplication::testCoords( &x,&y,&w,&h ); 1872 KApplication::testCoords( &x,&y,&w,&h );
1871 mEventEditor->setGeometry(x,y,w,h); 1873 mEventEditor->setGeometry(x,y,w,h);
1872 1874
1873 } 1875 }
1874 list = config->readListEntry("EditTodoLayout"); 1876 list = config->readListEntry("EditTodoLayout");
1875 if ( ! list.isEmpty() ) { 1877 if ( ! list.isEmpty() ) {
1876 x = list[0].toInt(); 1878 x = list[0].toInt();
1877 y = list[1].toInt(); 1879 y = list[1].toInt();
1878 w = list[2].toInt(); 1880 w = list[2].toInt();
1879 h = list[3].toInt(); 1881 h = list[3].toInt();
1880 KApplication::testCoords( &x,&y,&w,&h ); 1882 KApplication::testCoords( &x,&y,&w,&h );
1881 mTodoEditor->setGeometry(x,y,w,h); 1883 mTodoEditor->setGeometry(x,y,w,h);
1882 1884
1883 } 1885 }
1884 list = config->readListEntry("ViewerLayout"); 1886 list = config->readListEntry("ViewerLayout");
1885 if ( ! list.isEmpty() ) { 1887 if ( ! list.isEmpty() ) {
1886 x = list[0].toInt(); 1888 x = list[0].toInt();
1887 y = list[1].toInt(); 1889 y = list[1].toInt();
1888 w = list[2].toInt(); 1890 w = list[2].toInt();
1889 h = list[3].toInt(); 1891 h = list[3].toInt();
1890 KApplication::testCoords( &x,&y,&w,&h ); 1892 KApplication::testCoords( &x,&y,&w,&h );
1891 getEventViewerDialog()->setGeometry(x,y,w,h); 1893 getEventViewerDialog()->setGeometry(x,y,w,h);
1892 } 1894 }
1893#endif 1895#endif
1894 config->setGroup( "Views" ); 1896 config->setGroup( "Views" );
1895 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1897 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1896 1898
1897 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1899 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1898 1900
1899 int resetval = 0; 1901 int resetval = 0;
1900 int maxVal = 0; 1902 int maxVal = 0;
1901 if (sizes.count() != 3) { 1903 if (sizes.count() != 3) {
1902 if ( KOPrefs::instance()->mVerticalScreen ) { 1904 if ( KOPrefs::instance()->mVerticalScreen ) {
1903 resetval = mDateNavigator->sizeHint().width()+2; 1905 resetval = mDateNavigator->sizeHint().width()+2;
1904 } else { 1906 } else {
1905 resetval = mDateNavigator->sizeHint().height()+2; 1907 resetval = mDateNavigator->sizeHint().height()+2;
1906 } 1908 }
1907 } 1909 }
1908 if ( resetval ) { 1910 if ( resetval ) {
1909 sizes.clear(); 1911 sizes.clear();
1910 if ( KOPrefs::instance()->mVerticalScreen ) { 1912 if ( KOPrefs::instance()->mVerticalScreen ) {
1911 maxVal = QApplication::desktop()->width() -10; 1913 maxVal = QApplication::desktop()->width() -10;
1912 } else { 1914 } else {
1913 maxVal = QApplication::desktop()->height()-10; 1915 maxVal = QApplication::desktop()->height()-10;
1914 } 1916 }
1915 sizes << resetval; 1917 sizes << resetval;
1916 if ( maxVal < resetval + resetval) 1918 if ( maxVal < resetval + resetval)
1917 resetval = maxVal - resetval; 1919 resetval = maxVal - resetval;
1918 sizes << resetval; 1920 sizes << resetval;
1919 sizes << 100; 1921 sizes << 100;
1920 } 1922 }
1921 mLeftFrame->setSizes(sizes); 1923 mLeftFrame->setSizes(sizes);
1922 sizes = config->readIntListEntry("Main Splitter Frame"); 1924 sizes = config->readIntListEntry("Main Splitter Frame");
1923 resetval = 0; 1925 resetval = 0;
1924 maxVal = 0; 1926 maxVal = 0;
1925 if (sizes.count() != 2) { 1927 if (sizes.count() != 2) {
1926 if ( !KOPrefs::instance()->mVerticalScreen ) { 1928 if ( !KOPrefs::instance()->mVerticalScreen ) {
1927 resetval = mDateNavigator->sizeHint().width()+2; 1929 resetval = mDateNavigator->sizeHint().width()+2;
1928 } else { 1930 } else {
1929 resetval = mDateNavigator->sizeHint().height()+2; 1931 resetval = mDateNavigator->sizeHint().height()+2;
1930 } 1932 }
1931 } 1933 }
1932 if ( resetval ) { 1934 if ( resetval ) {
1933 sizes.clear(); 1935 sizes.clear();
1934 if ( !KOPrefs::instance()->mVerticalScreen ) { 1936 if ( !KOPrefs::instance()->mVerticalScreen ) {
1935 maxVal = QApplication::desktop()->width() -10; 1937 maxVal = QApplication::desktop()->width() -10;
1936 } else { 1938 } else {
1937 maxVal = QApplication::desktop()->height()-10; 1939 maxVal = QApplication::desktop()->height()-10;
1938 } 1940 }
1939 sizes << resetval; 1941 sizes << resetval;
1940 if ( maxVal < resetval + resetval) 1942 if ( maxVal < resetval + resetval)
1941 resetval = maxVal - resetval; 1943 resetval = maxVal - resetval;
1942 sizes << resetval; 1944 sizes << resetval;
1943 } 1945 }
1944 mMainFrame->setSizes(sizes); 1946 mMainFrame->setSizes(sizes);
1945 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1947 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1946 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1948 else if ( dateCount == 7 ) mNavigator->selectWeek();
1947 else mNavigator->selectDates( dateCount ); 1949 else mNavigator->selectDates( dateCount );
1948 // mViewManager->readSettings( config ); 1950 // mViewManager->readSettings( config );
1949 updateConfig(); 1951 updateConfig();
1950 globalFlagBlockAgenda = 2; 1952 globalFlagBlockAgenda = 2;
1951 mViewManager->readSettings( config ); 1953 mViewManager->readSettings( config );
1952 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 1954 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
1953} 1955}
1954 1956
1955 1957
1956void CalendarView::writeSettings() 1958void CalendarView::writeSettings()
1957{ 1959{
1958 // kdDebug() << "CalendarView::writeSettings" << endl; 1960 // kdDebug() << "CalendarView::writeSettings" << endl;
1959 1961
1960 KConfig *config = KOGlobals::config(); 1962 KConfig *config = KOGlobals::config();
1961 1963
1962 mViewManager->writeSettings( config ); 1964 mViewManager->writeSettings( config );
1963 mTodoList->saveLayout(config,QString("Todo Layout")); 1965 mTodoList->saveLayout(config,QString("Todo Layout"));
1964 mDialogManager->writeSettings( config ); 1966 mDialogManager->writeSettings( config );
1965 //KOPrefs::instance()->usrWriteConfig(); 1967 //KOPrefs::instance()->usrWriteConfig();
1966 KOPrefs::instance()->writeConfig(); 1968 KOPrefs::instance()->writeConfig();
1967 1969
1968 writeFilterSettings(config); 1970 writeFilterSettings(config);
1969 1971
1970 config->setGroup( "Views" ); 1972 config->setGroup( "Views" );
1971 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1973 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1972 1974
1973 QValueList<int> listINT = mLeftFrame->sizes(); 1975 QValueList<int> listINT = mLeftFrame->sizes();
1974 config->writeEntry("Left Splitter Frame",listINT); 1976 config->writeEntry("Left Splitter Frame",listINT);
1975 QValueList<int> listINT2 = mMainFrame->sizes(); 1977 QValueList<int> listINT2 = mMainFrame->sizes();
1976 config->writeEntry("Main Splitter Frame",listINT2); 1978 config->writeEntry("Main Splitter Frame",listINT2);
1977#ifdef DESKTOP_VERSION 1979#ifdef DESKTOP_VERSION
1978 config->setGroup("WidgetLayout"); 1980 config->setGroup("WidgetLayout");
1979 QStringList list ;//= config->readListEntry("MainLayout"); 1981 QStringList list ;//= config->readListEntry("MainLayout");
1980 int x,y,w,h; 1982 int x,y,w,h;
1981 QWidget* wid; 1983 QWidget* wid;
1982 wid = topLevelWidget(); 1984 wid = topLevelWidget();
1983 x = wid->geometry().x(); 1985 x = wid->geometry().x();
1984 y = wid->geometry().y(); 1986 y = wid->geometry().y();
1985 w = wid->width(); 1987 w = wid->width();
1986 h = wid->height(); 1988 h = wid->height();
1987 list.clear(); 1989 list.clear();
1988 list << QString::number( x ); 1990 list << QString::number( x );
1989 list << QString::number( y ); 1991 list << QString::number( y );
1990 list << QString::number( w ); 1992 list << QString::number( w );
1991 list << QString::number( h ); 1993 list << QString::number( h );
1992 config->writeEntry("MainLayout",list ); 1994 config->writeEntry("MainLayout",list );
1993 1995
1994 wid = mEventEditor; 1996 wid = mEventEditor;
1995 x = wid->geometry().x(); 1997 x = wid->geometry().x();
1996 y = wid->geometry().y(); 1998 y = wid->geometry().y();
1997 w = wid->width(); 1999 w = wid->width();
1998 h = wid->height(); 2000 h = wid->height();
1999 list.clear(); 2001 list.clear();
2000 list << QString::number( x ); 2002 list << QString::number( x );
2001 list << QString::number( y ); 2003 list << QString::number( y );
2002 list << QString::number( w ); 2004 list << QString::number( w );
2003 list << QString::number( h ); 2005 list << QString::number( h );
2004 config->writeEntry("EditEventLayout",list ); 2006 config->writeEntry("EditEventLayout",list );
2005 2007
2006 wid = mTodoEditor; 2008 wid = mTodoEditor;
2007 x = wid->geometry().x(); 2009 x = wid->geometry().x();
2008 y = wid->geometry().y(); 2010 y = wid->geometry().y();
2009 w = wid->width(); 2011 w = wid->width();
2010 h = wid->height(); 2012 h = wid->height();
2011 list.clear(); 2013 list.clear();
2012 list << QString::number( x ); 2014 list << QString::number( x );
2013 list << QString::number( y ); 2015 list << QString::number( y );
2014 list << QString::number( w ); 2016 list << QString::number( w );
2015 list << QString::number( h ); 2017 list << QString::number( h );
2016 config->writeEntry("EditTodoLayout",list ); 2018 config->writeEntry("EditTodoLayout",list );
2017 wid = getEventViewerDialog(); 2019 wid = getEventViewerDialog();
2018 x = wid->geometry().x(); 2020 x = wid->geometry().x();
2019 y = wid->geometry().y(); 2021 y = wid->geometry().y();
2020 w = wid->width(); 2022 w = wid->width();
2021 h = wid->height(); 2023 h = wid->height();
2022 list.clear(); 2024 list.clear();
2023 list << QString::number( x ); 2025 list << QString::number( x );
2024 list << QString::number( y ); 2026 list << QString::number( y );
2025 list << QString::number( w ); 2027 list << QString::number( w );
2026 list << QString::number( h ); 2028 list << QString::number( h );
2027 config->writeEntry("ViewerLayout",list ); 2029 config->writeEntry("ViewerLayout",list );
2028 wid = mDialogManager->getSearchDialog(); 2030 wid = mDialogManager->getSearchDialog();
2029 if ( wid ) { 2031 if ( wid ) {
2030 x = wid->geometry().x(); 2032 x = wid->geometry().x();
2031 y = wid->geometry().y(); 2033 y = wid->geometry().y();
2032 w = wid->width(); 2034 w = wid->width();
2033 h = wid->height(); 2035 h = wid->height();
2034 list.clear(); 2036 list.clear();
2035 list << QString::number( x ); 2037 list << QString::number( x );
2036 list << QString::number( y ); 2038 list << QString::number( y );
2037 list << QString::number( w ); 2039 list << QString::number( w );
2038 list << QString::number( h ); 2040 list << QString::number( h );
2039 config->writeEntry("SearchLayout",list ); 2041 config->writeEntry("SearchLayout",list );
2040 } 2042 }
2041#endif 2043#endif
2042 2044
2043 2045
2044 config->sync(); 2046 config->sync();
2045} 2047}
2046 2048
2047void CalendarView::readFilterSettings(KConfig *config) 2049void CalendarView::readFilterSettings(KConfig *config)
2048{ 2050{
2049 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2051 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2050 2052
2051 mFilters.clear(); 2053 mFilters.clear();
2052 2054
2053 config->setGroup("General"); 2055 config->setGroup("General");
2054 QStringList filterList = config->readListEntry("CalendarFilters"); 2056 QStringList filterList = config->readListEntry("CalendarFilters");
2055 2057
2056 QStringList::ConstIterator it = filterList.begin(); 2058 QStringList::ConstIterator it = filterList.begin();
2057 QStringList::ConstIterator end = filterList.end(); 2059 QStringList::ConstIterator end = filterList.end();
2058 while(it != end) { 2060 while(it != end) {
2059 // kdDebug() << " filter: " << (*it) << endl; 2061 // kdDebug() << " filter: " << (*it) << endl;
2060 2062
2061 CalFilter *filter; 2063 CalFilter *filter;
2062 filter = new CalFilter(*it); 2064 filter = new CalFilter(*it);
2063 config->setGroup("Filter_" + (*it).utf8()); 2065 config->setGroup("Filter_" + (*it).utf8());
2064 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2066 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2065 filter->setCriteria(config->readNumEntry("Criteria",0)); 2067 filter->setCriteria(config->readNumEntry("Criteria",0));
2066 filter->setCategoryList(config->readListEntry("CategoryList")); 2068 filter->setCategoryList(config->readListEntry("CategoryList"));
2067 mFilters.append(filter); 2069 mFilters.append(filter);
2068 2070
2069 ++it; 2071 ++it;
2070 } 2072 }
2071 2073
2072 if (mFilters.count() == 0) { 2074 if (mFilters.count() == 0) {
2073 CalFilter *filter = new CalFilter(i18n("Default")); 2075 CalFilter *filter = new CalFilter(i18n("Default"));
2074 mFilters.append(filter); 2076 mFilters.append(filter);
2075 } 2077 }
2076 mFilterView->updateFilters(); 2078 mFilterView->updateFilters();
2077 config->setGroup("FilterView"); 2079 config->setGroup("FilterView");
2078 2080
2079 mFilterView->blockSignals(true); 2081 mFilterView->blockSignals(true);
2080 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2082 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2081 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2083 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2082 mFilterView->blockSignals(false); 2084 mFilterView->blockSignals(false);
2083 // We do it manually to avoid it being done twice by the above calls 2085 // We do it manually to avoid it being done twice by the above calls
2084 updateFilter(); 2086 updateFilter();
2085} 2087}
2086 2088
2087void CalendarView::writeFilterSettings(KConfig *config) 2089void CalendarView::writeFilterSettings(KConfig *config)
2088{ 2090{
2089 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2091 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2090 2092
2091 QStringList filterList; 2093 QStringList filterList;
2092 2094
2093 CalFilter *filter = mFilters.first(); 2095 CalFilter *filter = mFilters.first();
2094 while(filter) { 2096 while(filter) {
2095 // kdDebug() << " fn: " << filter->name() << endl; 2097 // kdDebug() << " fn: " << filter->name() << endl;
2096 filterList << filter->name(); 2098 filterList << filter->name();
2097 config->setGroup("Filter_" + filter->name().utf8()); 2099 config->setGroup("Filter_" + filter->name().utf8());
2098 config->writeEntry("Criteria",filter->criteria()); 2100 config->writeEntry("Criteria",filter->criteria());
2099 config->writeEntry("CategoryList",filter->categoryList()); 2101 config->writeEntry("CategoryList",filter->categoryList());
2100 filter = mFilters.next(); 2102 filter = mFilters.next();
2101 } 2103 }
2102 config->setGroup("General"); 2104 config->setGroup("General");
2103 config->writeEntry("CalendarFilters",filterList); 2105 config->writeEntry("CalendarFilters",filterList);
2104 2106
2105 config->setGroup("FilterView"); 2107 config->setGroup("FilterView");
2106 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2108 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2107 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2109 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2108} 2110}
2109 2111
2110 2112
2111void CalendarView::goToday() 2113void CalendarView::goToday()
2112{ 2114{
2113 if ( mViewManager->currentView()->isMonthView() ) 2115 if ( mViewManager->currentView()->isMonthView() )
2114 mNavigator->selectTodayMonth(); 2116 mNavigator->selectTodayMonth();
2115 else 2117 else
2116 mNavigator->selectToday(); 2118 mNavigator->selectToday();
2117} 2119}
2118 2120
2119void CalendarView::goNext() 2121void CalendarView::goNext()
2120{ 2122{
2121 mNavigator->selectNext(); 2123 mNavigator->selectNext();
2122} 2124}
2123 2125
2124void CalendarView::goPrevious() 2126void CalendarView::goPrevious()
2125{ 2127{
2126 mNavigator->selectPrevious(); 2128 mNavigator->selectPrevious();
2127} 2129}
2128void CalendarView::goNextMonth() 2130void CalendarView::goNextMonth()
2129{ 2131{
2130 mNavigator->selectNextMonth(); 2132 mNavigator->selectNextMonth();
2131} 2133}
2132 2134
2133void CalendarView::goPreviousMonth() 2135void CalendarView::goPreviousMonth()
2134{ 2136{
2135 mNavigator->selectPreviousMonth(); 2137 mNavigator->selectPreviousMonth();
2136} 2138}
2137void CalendarView::writeLocale() 2139void CalendarView::writeLocale()
2138{ 2140{
2139 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2141 //KPimGlobalPrefs::instance()->setGlobalConfig();
2140#if 0 2142#if 0
2141 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2143 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2142 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2144 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2143 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2145 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2144 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2146 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2145 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2147 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2146 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2148 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2147 dummy = KOPrefs::instance()->mUserDateFormatShort; 2149 dummy = KOPrefs::instance()->mUserDateFormatShort;
2148 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2150 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2149 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2151 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2150 KOPrefs::instance()->mDaylightsavingStart, 2152 KOPrefs::instance()->mDaylightsavingStart,
2151 KOPrefs::instance()->mDaylightsavingEnd ); 2153 KOPrefs::instance()->mDaylightsavingEnd );
2152 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2154 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2153#endif 2155#endif
2154} 2156}
2155void CalendarView::updateConfig() 2157void CalendarView::updateConfig()
2156{ 2158{
2157 writeLocale(); 2159 writeLocale();
2158 if ( KOPrefs::instance()->mUseAppColors ) 2160 if ( KOPrefs::instance()->mUseAppColors )
2159 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2161 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2160 emit configChanged(); 2162 emit configChanged();
2161 mTodoList->updateConfig(); 2163 mTodoList->updateConfig();
2162 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2164 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2163 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2165 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2164 // To make the "fill window" configurations work 2166 // To make the "fill window" configurations work
2165 //mViewManager->raiseCurrentView(); 2167 //mViewManager->raiseCurrentView();
2166} 2168}
2167 2169
2168 2170
2169void CalendarView::eventChanged(Event *event) 2171void CalendarView::eventChanged(Event *event)
2170{ 2172{
2171 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2173 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2172 //updateUnmanagedViews(); 2174 //updateUnmanagedViews();
2173} 2175}
2174 2176
2175void CalendarView::eventAdded(Event *event) 2177void CalendarView::eventAdded(Event *event)
2176{ 2178{
2177 changeEventDisplay(event,KOGlobals::EVENTADDED); 2179 changeEventDisplay(event,KOGlobals::EVENTADDED);
2178} 2180}
2179 2181
2180void CalendarView::eventToBeDeleted(Event *) 2182void CalendarView::eventToBeDeleted(Event *)
2181{ 2183{
2182 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2184 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2183} 2185}
2184 2186
2185void CalendarView::eventDeleted() 2187void CalendarView::eventDeleted()
2186{ 2188{
2187 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2189 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2188} 2190}
2189void CalendarView::changeTodoDisplay(Todo *which, int action) 2191void CalendarView::changeTodoDisplay(Todo *which, int action)
2190{ 2192{
2191 changeIncidenceDisplay((Incidence *)which, action); 2193 changeIncidenceDisplay((Incidence *)which, action);
2192 mDateNavigator->updateView(); //LR 2194 mDateNavigator->updateView(); //LR
2193 //mDialogManager->updateSearchDialog(); 2195 //mDialogManager->updateSearchDialog();
2194 2196
2195 if (which) { 2197 if (which) {
2196 mViewManager->updateWNview(); 2198 mViewManager->updateWNview();
2197 //mTodoList->updateView(); 2199 //mTodoList->updateView();
2198 } 2200 }
2199 2201
2200} 2202}
2201 2203
2202void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2204void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2203{ 2205{
2204 updateUnmanagedViews(); 2206 updateUnmanagedViews();
2205 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2207 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2206 if ( action == KOGlobals::EVENTDELETED ) { //delete 2208 if ( action == KOGlobals::EVENTDELETED ) { //delete
2207 mCalendar->checkAlarmForIncidence( 0, true ); 2209 mCalendar->checkAlarmForIncidence( 0, true );
2208 if ( mEventViewerDialog ) 2210 if ( mEventViewerDialog )
2209 mEventViewerDialog->hide(); 2211 mEventViewerDialog->hide();
2210 } 2212 }
2211 else 2213 else
2212 mCalendar->checkAlarmForIncidence( which , false ); 2214 mCalendar->checkAlarmForIncidence( which , false );
2213} 2215}
2214 2216
2215// most of the changeEventDisplays() right now just call the view's 2217// most of the changeEventDisplays() right now just call the view's
2216// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2218// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2217void CalendarView::changeEventDisplay(Event *which, int action) 2219void CalendarView::changeEventDisplay(Event *which, int action)
2218{ 2220{
2219 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2221 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2220 changeIncidenceDisplay((Incidence *)which, action); 2222 changeIncidenceDisplay((Incidence *)which, action);
2221 mDateNavigator->updateView(); 2223 mDateNavigator->updateView();
2222 //mDialogManager->updateSearchDialog(); 2224 //mDialogManager->updateSearchDialog();
2223 2225
2224 if (which) { 2226 if (which) {
2225 // If there is an event view visible update the display 2227 // If there is an event view visible update the display
2226 mViewManager->currentView()->changeEventDisplay(which,action); 2228 mViewManager->currentView()->changeEventDisplay(which,action);
2227 // TODO: check, if update needed 2229 // TODO: check, if update needed
2228 // if (which->getTodoStatus()) { 2230 // if (which->getTodoStatus()) {
2229 mTodoList->updateView(); 2231 mTodoList->updateView();
2230 // } 2232 // }
2231 } else { 2233 } else {
2232 mViewManager->currentView()->updateView(); 2234 mViewManager->currentView()->updateView();
2233 } 2235 }
2234} 2236}
2235 2237
2236 2238
2237void CalendarView::updateTodoViews() 2239void CalendarView::updateTodoViews()
2238{ 2240{
2239 mTodoList->updateView(); 2241 mTodoList->updateView();
2240 mViewManager->currentView()->updateView(); 2242 mViewManager->currentView()->updateView();
2241 2243
2242} 2244}
2243 2245
2244 2246
2245void CalendarView::updateView(const QDate &start, const QDate &end) 2247void CalendarView::updateView(const QDate &start, const QDate &end)
2246{ 2248{
2247 mTodoList->updateView(); 2249 mTodoList->updateView();
2248 mViewManager->updateView(start, end); 2250 mViewManager->updateView(start, end);
2249 //mDateNavigator->updateView(); 2251 //mDateNavigator->updateView();
2250} 2252}
2251 2253
2252void CalendarView::updateView() 2254void CalendarView::updateView()
2253{ 2255{
2254 DateList tmpList = mNavigator->selectedDates(); 2256 DateList tmpList = mNavigator->selectedDates();
2255 2257
2256 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2258 if ( KOPrefs::instance()->mHideNonStartedTodos )
2257 mTodoList->updateView(); 2259 mTodoList->updateView();
2258 // We assume that the navigator only selects consecutive days. 2260 // We assume that the navigator only selects consecutive days.
2259 updateView( tmpList.first(), tmpList.last() ); 2261 updateView( tmpList.first(), tmpList.last() );
2260} 2262}
2261 2263
2262void CalendarView::updateUnmanagedViews() 2264void CalendarView::updateUnmanagedViews()
2263{ 2265{
2264 mDateNavigator->updateDayMatrix(); 2266 mDateNavigator->updateDayMatrix();
2265} 2267}
2266 2268
2267int CalendarView::msgItemDelete(const QString name) 2269int CalendarView::msgItemDelete(const QString name)
2268{ 2270{
2269 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2271 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2270 i18n("This item will be\npermanently deleted."), 2272 i18n("This item will be\npermanently deleted."),
2271 i18n("KO/Pi Confirmation"),i18n("Delete")); 2273 i18n("KO/Pi Confirmation"),i18n("Delete"));
2272} 2274}
2273 2275
2274 2276
2275void CalendarView::edit_cut() 2277void CalendarView::edit_cut()
2276{ 2278{
2277 Event *anEvent=0; 2279 Event *anEvent=0;
2278 2280
2279 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2281 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2280 2282
2281 if (mViewManager->currentView()->isEventView()) { 2283 if (mViewManager->currentView()->isEventView()) {
2282 if ( incidence && incidence->type() == "Event" ) { 2284 if ( incidence && incidence->type() == "Event" ) {
2283 anEvent = static_cast<Event *>(incidence); 2285 anEvent = static_cast<Event *>(incidence);
2284 } 2286 }
2285 } 2287 }
2286 2288
2287 if (!anEvent) { 2289 if (!anEvent) {
2288 KNotifyClient::beep(); 2290 KNotifyClient::beep();
2289 return; 2291 return;
2290 } 2292 }
2291 DndFactory factory( mCalendar ); 2293 DndFactory factory( mCalendar );
2292 factory.cutIncidence(anEvent); 2294 factory.cutIncidence(anEvent);
2293 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2295 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2294} 2296}
2295 2297
2296void CalendarView::edit_copy() 2298void CalendarView::edit_copy()
2297{ 2299{
2298 Event *anEvent=0; 2300 Event *anEvent=0;
2299 2301
2300 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2302 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2301 2303
2302 if (mViewManager->currentView()->isEventView()) { 2304 if (mViewManager->currentView()->isEventView()) {
2303 if ( incidence && incidence->type() == "Event" ) { 2305 if ( incidence && incidence->type() == "Event" ) {
2304 anEvent = static_cast<Event *>(incidence); 2306 anEvent = static_cast<Event *>(incidence);
2305 } 2307 }
2306 } 2308 }
2307 2309
2308 if (!anEvent) { 2310 if (!anEvent) {
2309 KNotifyClient::beep(); 2311 KNotifyClient::beep();
2310 return; 2312 return;
2311 } 2313 }
2312 DndFactory factory( mCalendar ); 2314 DndFactory factory( mCalendar );
2313 factory.copyIncidence(anEvent); 2315 factory.copyIncidence(anEvent);
2314} 2316}
2315 2317
2316void CalendarView::edit_paste() 2318void CalendarView::edit_paste()
2317{ 2319{
2318 QDate date = mNavigator->selectedDates().first(); 2320 QDate date = mNavigator->selectedDates().first();
2319 2321
2320 DndFactory factory( mCalendar ); 2322 DndFactory factory( mCalendar );
2321 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2323 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2322 2324
2323 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2325 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2324} 2326}
2325 2327
2326void CalendarView::edit_options() 2328void CalendarView::edit_options()
2327{ 2329{
2328 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2330 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2329 emit save(); 2331 emit save();
2330 emit saveStopTimer(); 2332 emit saveStopTimer();
2331 mDialogManager->showOptionsDialog(); 2333 mDialogManager->showOptionsDialog();
2332 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2334 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2333 emit saveStopTimer(); 2335 emit saveStopTimer();
2334 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2336 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2335 i18n("Timezone settings"),i18n("Reload"))) { 2337 i18n("Timezone settings"),i18n("Reload"))) {
2336 qDebug("KO: TZ reload cancelled "); 2338 qDebug("KO: TZ reload cancelled ");
2337 return; 2339 return;
2338 } 2340 }
2339 qDebug("KO: Timezone change "); 2341 qDebug("KO: Timezone change ");
2340 openCalendar( MainWindow::defaultFileName() ); 2342 openCalendar( MainWindow::defaultFileName() );
2341 setModified(true); 2343 setModified(true);
2342 } 2344 }
2343 else 2345 else
2344 qDebug("KO: No tz change "); 2346 qDebug("KO: No tz change ");
2345 2347
2346} 2348}
2347 2349
2348 2350
2349void CalendarView::slotSelectPickerDate( QDate d) 2351void CalendarView::slotSelectPickerDate( QDate d)
2350{ 2352{
2351 mDateFrame->hide(); 2353 mDateFrame->hide();
2352 if ( mDatePickerMode == 1 ) { 2354 if ( mDatePickerMode == 1 ) {
2353 mNavigator->slotDaySelect( d ); 2355 mNavigator->slotDaySelect( d );
2354 } else if ( mDatePickerMode == 2 ) { 2356 } else if ( mDatePickerMode == 2 ) {
2355 if ( mMoveIncidence->type() == "Todo" ) { 2357 if ( mMoveIncidence->type() == "Todo" ) {
2356 Todo * to = (Todo *) mMoveIncidence; 2358 Todo * to = (Todo *) mMoveIncidence;
2357 QTime tim; 2359 QTime tim;
2358 int len = 0; 2360 int len = 0;
2359 if ( to->hasStartDate() && to->hasDueDate() ) 2361 if ( to->hasStartDate() && to->hasDueDate() )
2360 len = to->dtStart().secsTo( to->dtDue()); 2362 len = to->dtStart().secsTo( to->dtDue());
2361 if ( to->hasDueDate() ) 2363 if ( to->hasDueDate() )
2362 tim = to->dtDue().time(); 2364 tim = to->dtDue().time();
2363 else { 2365 else {
2364 tim = QTime ( 0,0,0 ); 2366 tim = QTime ( 0,0,0 );
2365 to->setFloats( true ); 2367 to->setFloats( true );
2366 to->setHasDueDate( true ); 2368 to->setHasDueDate( true );
2367 } 2369 }
2368 QDateTime dt ( d,tim ); 2370 QDateTime dt ( d,tim );
2369 to->setDtDue( dt ); 2371 to->setDtDue( dt );
2370 2372
2371 if ( to->hasStartDate() ) { 2373 if ( to->hasStartDate() ) {
2372 if ( len>0 ) 2374 if ( len>0 )
2373 to->setDtStart(to->dtDue().addSecs( -len )); 2375 to->setDtStart(to->dtDue().addSecs( -len ));
2374 else 2376 else
2375 if (to->dtStart() > to->dtDue() ) 2377 if (to->dtStart() > to->dtDue() )
2376 to->setDtStart(to->dtDue().addDays( -3 )); 2378 to->setDtStart(to->dtDue().addDays( -3 ));
2377 } 2379 }
2378 2380
2379 todoChanged( to ); 2381 todoChanged( to );
2380 } else { 2382 } else {
2381 if ( mMoveIncidence->doesRecur() ) { 2383 if ( mMoveIncidence->doesRecur() ) {
2382#if 0 2384#if 0
2383 // PENDING implement this 2385 // PENDING implement this
2384 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2386 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2385 mCalendar()->addIncidence( newInc ); 2387 mCalendar()->addIncidence( newInc );
2386 if ( mMoveIncidence->type() == "Todo" ) 2388 if ( mMoveIncidence->type() == "Todo" )
2387 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2389 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2388 else 2390 else
2389 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2391 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2390 mMoveIncidence = newInc; 2392 mMoveIncidence = newInc;
2391 2393
2392#endif 2394#endif
2393 } 2395 }
2394 QTime tim = mMoveIncidence->dtStart().time(); 2396 QTime tim = mMoveIncidence->dtStart().time();
2395 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2397 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2396 QDateTime dt ( d,tim ); 2398 QDateTime dt ( d,tim );
2397 mMoveIncidence->setDtStart( dt ); 2399 mMoveIncidence->setDtStart( dt );
2398 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2400 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2399 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2401 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2400 } 2402 }
2401 2403
2402 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2404 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2403 } 2405 }
2404} 2406}
2405 2407
2406void CalendarView::removeCategories() 2408void CalendarView::removeCategories()
2407{ 2409{
2408 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2410 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2409 QStringList catList = KOPrefs::instance()->mCustomCategories; 2411 QStringList catList = KOPrefs::instance()->mCustomCategories;
2410 QStringList catIncList; 2412 QStringList catIncList;
2411 QStringList newCatList; 2413 QStringList newCatList;
2412 Incidence* inc = incList.first(); 2414 Incidence* inc = incList.first();
2413 int i; 2415 int i;
2414 int count = 0; 2416 int count = 0;
2415 while ( inc ) { 2417 while ( inc ) {
2416 newCatList.clear(); 2418 newCatList.clear();
2417 catIncList = inc->categories() ; 2419 catIncList = inc->categories() ;
2418 for( i = 0; i< catIncList.count(); ++i ) { 2420 for( i = 0; i< catIncList.count(); ++i ) {
2419 if ( catList.contains (catIncList[i])) 2421 if ( catList.contains (catIncList[i]))
2420 newCatList.append( catIncList[i] ); 2422 newCatList.append( catIncList[i] );
2421 } 2423 }
2422 newCatList.sort(); 2424 newCatList.sort();
2423 inc->setCategories( newCatList.join(",") ); 2425 inc->setCategories( newCatList.join(",") );
2424 inc = incList.next(); 2426 inc = incList.next();
2425 } 2427 }
2426} 2428}
2427 2429
2428int CalendarView::addCategories() 2430int CalendarView::addCategories()
2429{ 2431{
2430 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2432 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2431 QStringList catList = KOPrefs::instance()->mCustomCategories; 2433 QStringList catList = KOPrefs::instance()->mCustomCategories;
2432 QStringList catIncList; 2434 QStringList catIncList;
2433 Incidence* inc = incList.first(); 2435 Incidence* inc = incList.first();
2434 int i; 2436 int i;
2435 int count = 0; 2437 int count = 0;
2436 while ( inc ) { 2438 while ( inc ) {
2437 catIncList = inc->categories() ; 2439 catIncList = inc->categories() ;
2438 for( i = 0; i< catIncList.count(); ++i ) { 2440 for( i = 0; i< catIncList.count(); ++i ) {
2439 if ( !catList.contains (catIncList[i])) { 2441 if ( !catList.contains (catIncList[i])) {
2440 catList.append( catIncList[i] ); 2442 catList.append( catIncList[i] );
2441 //qDebug("add cat %s ", catIncList[i].latin1()); 2443 //qDebug("add cat %s ", catIncList[i].latin1());
2442 ++count; 2444 ++count;
2443 } 2445 }
2444 } 2446 }
2445 inc = incList.next(); 2447 inc = incList.next();
2446 } 2448 }
2447 catList.sort(); 2449 catList.sort();
2448 KOPrefs::instance()->mCustomCategories = catList; 2450 KOPrefs::instance()->mCustomCategories = catList;
2449 return count; 2451 return count;
2450} 2452}
2451 2453
2452void CalendarView::manageCategories() 2454void CalendarView::manageCategories()
2453{ 2455{
2454 KOCatPrefs* cp = new KOCatPrefs(); 2456 KOCatPrefs* cp = new KOCatPrefs();
2455 cp->show(); 2457 cp->show();
2456 int w =cp->sizeHint().width() ; 2458 int w =cp->sizeHint().width() ;
2457 int h = cp->sizeHint().height() ; 2459 int h = cp->sizeHint().height() ;
2458 int dw = QApplication::desktop()->width(); 2460 int dw = QApplication::desktop()->width();
2459 int dh = QApplication::desktop()->height(); 2461 int dh = QApplication::desktop()->height();
2460 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2462 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2461 if ( !cp->exec() ) { 2463 if ( !cp->exec() ) {
2462 delete cp; 2464 delete cp;
2463 return; 2465 return;
2464 } 2466 }
2465 int count = 0; 2467 int count = 0;
2466 if ( cp->addCat() ) { 2468 if ( cp->addCat() ) {
2467 count = addCategories(); 2469 count = addCategories();
2468 if ( count ) { 2470 if ( count ) {
2469 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2471 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2470 writeSettings(); 2472 writeSettings();
2471 } else 2473 } else
2472 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2474 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2473 } else { 2475 } else {
2474 removeCategories(); 2476 removeCategories();
2475 updateView(); 2477 updateView();
2476 } 2478 }
2477 delete cp; 2479 delete cp;
2478} 2480}
2479 2481
2480void CalendarView::beamIncidence(Incidence * Inc) 2482void CalendarView::beamIncidence(Incidence * Inc)
2481{ 2483{
2482 QPtrList<Incidence> delSel ; 2484 QPtrList<Incidence> delSel ;
2483 delSel.append(Inc); 2485 delSel.append(Inc);
2484 beamIncidenceList( delSel ); 2486 beamIncidenceList( delSel );
2485} 2487}
2486void CalendarView::beamCalendar() 2488void CalendarView::beamCalendar()
2487{ 2489{
2488 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2490 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2489 //qDebug("beamCalendar() "); 2491 //qDebug("beamCalendar() ");
2490 beamIncidenceList( delSel ); 2492 beamIncidenceList( delSel );
2491} 2493}
2492void CalendarView::beamFilteredCalendar() 2494void CalendarView::beamFilteredCalendar()
2493{ 2495{
2494 QPtrList<Incidence> delSel = mCalendar->incidences(); 2496 QPtrList<Incidence> delSel = mCalendar->incidences();
2495 //qDebug("beamFilteredCalendar() "); 2497 //qDebug("beamFilteredCalendar() ");
2496 beamIncidenceList( delSel ); 2498 beamIncidenceList( delSel );
2497} 2499}
2498void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2500void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2499{ 2501{
2500 if ( beamDialog->exec () == QDialog::Rejected ) 2502 if ( beamDialog->exec () == QDialog::Rejected )
2501 return; 2503 return;
2502#ifdef DESKTOP_VERSION 2504#ifdef DESKTOP_VERSION
2503 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2505 QString fn = locateLocal( "tmp", "kopibeamfile" );
2504#else 2506#else
2505 QString fn = "/tmp/kopibeamfile"; 2507 QString fn = "/tmp/kopibeamfile";
2506#endif 2508#endif
2507 QString mes; 2509 QString mes;
2508 bool createbup = true; 2510 bool createbup = true;
2509 if ( createbup ) { 2511 if ( createbup ) {
2510 QString description = "\n"; 2512 QString description = "\n";
2511 CalendarLocal* cal = new CalendarLocal(); 2513 CalendarLocal* cal = new CalendarLocal();
2512 if ( beamDialog->beamLocal() ) 2514 if ( beamDialog->beamLocal() )
2513 cal->setLocalTime(); 2515 cal->setLocalTime();
2514 else 2516 else
2515 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2517 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2516 Incidence *incidence = delSel.first(); 2518 Incidence *incidence = delSel.first();
2517 bool addText = false; 2519 bool addText = false;
2518 if ( delSel.count() < 10 ) 2520 if ( delSel.count() < 10 )
2519 addText = true; 2521 addText = true;
2520 else { 2522 else {
2521 description.sprintf(i18n(" %d items?"),delSel.count() ); 2523 description.sprintf(i18n(" %d items?"),delSel.count() );
2522 } 2524 }
2523 while ( incidence ) { 2525 while ( incidence ) {
2524 Incidence *in = incidence->clone(); 2526 Incidence *in = incidence->clone();
2525 if ( ! in->summary().isEmpty() ) { 2527 if ( ! in->summary().isEmpty() ) {
2526 in->setDescription(""); 2528 in->setDescription("");
2527 } else { 2529 } else {
2528 in->setSummary( in->description().left(20)); 2530 in->setSummary( in->description().left(20));
2529 in->setDescription(""); 2531 in->setDescription("");
2530 } 2532 }
2531 if ( addText ) 2533 if ( addText )
2532 description += in->summary() + "\n"; 2534 description += in->summary() + "\n";
2533 cal->addIncidence( in ); 2535 cal->addIncidence( in );
2534 incidence = delSel.next(); 2536 incidence = delSel.next();
2535 } 2537 }
2536 if ( beamDialog->beamVcal() ) { 2538 if ( beamDialog->beamVcal() ) {
2537 fn += ".vcs"; 2539 fn += ".vcs";
2538 FileStorage storage( cal, fn, new VCalFormat ); 2540 FileStorage storage( cal, fn, new VCalFormat );
2539 storage.save(); 2541 storage.save();
2540 } else { 2542 } else {
2541 fn += ".ics"; 2543 fn += ".ics";
2542 FileStorage storage( cal, fn, new ICalFormat( ) ); 2544 FileStorage storage( cal, fn, new ICalFormat( ) );
2543 storage.save(); 2545 storage.save();
2544 } 2546 }
2545 delete cal; 2547 delete cal;
2546 mes = i18n("KO/Pi: Ready for beaming"); 2548 mes = i18n("KO/Pi: Ready for beaming");
2547 topLevelWidget()->setCaption(mes); 2549 topLevelWidget()->setCaption(mes);
2548 KApplication::convert2latin1( fn ); 2550 KApplication::convert2latin1( fn );
2549#ifndef DESKTOP_VERSION 2551#ifndef DESKTOP_VERSION
2550 Ir *ir = new Ir( this ); 2552 Ir *ir = new Ir( this );
2551 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2553 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2552 ir->send( fn, description, "text/x-vCalendar" ); 2554 ir->send( fn, description, "text/x-vCalendar" );
2553#endif 2555#endif
2554 } 2556 }
2555} 2557}
2556void CalendarView::beamDone( Ir *ir ) 2558void CalendarView::beamDone( Ir *ir )
2557{ 2559{
2558#ifndef DESKTOP_VERSION 2560#ifndef DESKTOP_VERSION
2559 delete ir; 2561 delete ir;
2560#endif 2562#endif
2561 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2563 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2562 topLevelWidget()->raise(); 2564 topLevelWidget()->raise();
2563} 2565}
2564 2566
2565void CalendarView::moveIncidence(Incidence * inc ) 2567void CalendarView::moveIncidence(Incidence * inc )
2566{ 2568{
2567 if ( !inc ) return; 2569 if ( !inc ) return;
2568 showDatePickerPopup(); 2570 showDatePickerPopup();
2569 mDatePickerMode = 2; 2571 mDatePickerMode = 2;
2570 mMoveIncidence = inc ; 2572 mMoveIncidence = inc ;
2571 QDate da; 2573 QDate da;
2572 if ( mMoveIncidence->type() == "Todo" ) { 2574 if ( mMoveIncidence->type() == "Todo" ) {
2573 Todo * to = (Todo *) mMoveIncidence; 2575 Todo * to = (Todo *) mMoveIncidence;
2574 if ( to->hasDueDate() ) 2576 if ( to->hasDueDate() )
2575 da = to->dtDue().date(); 2577 da = to->dtDue().date();
2576 else 2578 else
2577 da = QDate::currentDate(); 2579 da = QDate::currentDate();
2578 } else { 2580 } else {
2579 da = mMoveIncidence->dtStart().date(); 2581 da = mMoveIncidence->dtStart().date();
2580 } 2582 }
2581 //PENDING set date for recurring incidence to date of recurrence 2583 //PENDING set date for recurring incidence to date of recurrence
2582 //mMoveIncidenceOldDate; 2584 //mMoveIncidenceOldDate;
2583 mDatePicker->setDate( da ); 2585 mDatePicker->setDate( da );
2584} 2586}
2585void CalendarView::showDatePickerPopup() 2587void CalendarView::showDatePickerPopup()
2586{ 2588{
2587 if ( mDateFrame->isVisible() ) 2589 if ( mDateFrame->isVisible() )
2588 mDateFrame->hide(); 2590 mDateFrame->hide();
2589 else { 2591 else {
2590 int offX = 0, offY = 0; 2592 int offX = 0, offY = 0;
2591#ifdef DESKTOP_VERSION 2593#ifdef DESKTOP_VERSION
2592 int w =mDatePicker->sizeHint().width() ; 2594 int w =mDatePicker->sizeHint().width() ;
2593 int h = mDatePicker->sizeHint().height() ; 2595 int h = mDatePicker->sizeHint().height() ;
2594 int dw = topLevelWidget()->width(); 2596 int dw = topLevelWidget()->width();
2595 int dh = topLevelWidget()->height(); 2597 int dh = topLevelWidget()->height();
2596 offX = topLevelWidget()->x(); 2598 offX = topLevelWidget()->x();
2597 offY = topLevelWidget()->y(); 2599 offY = topLevelWidget()->y();
2598#else 2600#else
2599 int w =mDatePicker->sizeHint().width() ; 2601 int w =mDatePicker->sizeHint().width() ;
2600 int h = mDatePicker->sizeHint().height() ; 2602 int h = mDatePicker->sizeHint().height() ;
2601 int dw = QApplication::desktop()->width(); 2603 int dw = QApplication::desktop()->width();
2602 int dh = QApplication::desktop()->height(); 2604 int dh = QApplication::desktop()->height();
2603#endif 2605#endif
2604 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2606 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2605 mDateFrame->show(); 2607 mDateFrame->show();
2606 } 2608 }
2607} 2609}
2608void CalendarView::showDatePicker( ) 2610void CalendarView::showDatePicker( )
2609{ 2611{
2610 showDatePickerPopup(); 2612 showDatePickerPopup();
2611 mDatePickerMode = 1; 2613 mDatePickerMode = 1;
2612 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2614 mDatePicker->setDate( mNavigator->selectedDates().first() );
2613} 2615}
2614 2616
2615void CalendarView::showEventEditor() 2617void CalendarView::showEventEditor()
2616{ 2618{
2617#ifdef DESKTOP_VERSION 2619#ifdef DESKTOP_VERSION
2618 int x,y,w,h; 2620 int x,y,w,h;
2619 x = mEventEditor->geometry().x(); 2621 x = mEventEditor->geometry().x();
2620 y = mEventEditor->geometry().y(); 2622 y = mEventEditor->geometry().y();
2621 w = mEventEditor->width(); 2623 w = mEventEditor->width();
2622 h = mEventEditor->height(); 2624 h = mEventEditor->height();
2623 mEventEditor->show(); 2625 mEventEditor->show();
2624 mEventEditor->setGeometry(x,y,w,h); 2626 mEventEditor->setGeometry(x,y,w,h);
2625#else 2627#else
2626 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2628 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2627 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2629 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2628 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2630 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2629 qApp->processEvents(); 2631 qApp->processEvents();
2630 delete mEventEditor; 2632 delete mEventEditor;
2631 mEventEditor = mDialogManager->getEventEditor(); 2633 mEventEditor = mDialogManager->getEventEditor();
2632 topLevelWidget()->setCaption( i18n("") ); 2634 topLevelWidget()->setCaption( i18n("") );
2633 } 2635 }
2634 mEventEditor->showMaximized(); 2636 mEventEditor->showMaximized();
2635#endif 2637#endif
2636} 2638}
2637void CalendarView::showTodoEditor() 2639void CalendarView::showTodoEditor()
2638{ 2640{
2639#ifdef DESKTOP_VERSION 2641#ifdef DESKTOP_VERSION
2640 int x,y,w,h; 2642 int x,y,w,h;
2641 x = mTodoEditor->geometry().x(); 2643 x = mTodoEditor->geometry().x();
2642 y = mTodoEditor->geometry().y(); 2644 y = mTodoEditor->geometry().y();
2643 w = mTodoEditor->width(); 2645 w = mTodoEditor->width();
2644 h = mTodoEditor->height(); 2646 h = mTodoEditor->height();
2645 mTodoEditor->show(); 2647 mTodoEditor->show();
2646 mTodoEditor->setGeometry(x,y,w,h); 2648 mTodoEditor->setGeometry(x,y,w,h);
2647#else 2649#else
2648 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2650 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2649 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2651 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2650 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2652 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2651 qApp->processEvents(); 2653 qApp->processEvents();
2652 delete mTodoEditor; 2654 delete mTodoEditor;
2653 mTodoEditor = mDialogManager->getTodoEditor(); 2655 mTodoEditor = mDialogManager->getTodoEditor();
2654 topLevelWidget()->setCaption( i18n("") ); 2656 topLevelWidget()->setCaption( i18n("") );
2655 } 2657 }
2656 mTodoEditor->showMaximized(); 2658 mTodoEditor->showMaximized();
2657#endif 2659#endif
2658} 2660}
2659 2661
2660void CalendarView::cloneIncidence() 2662void CalendarView::cloneIncidence()
2661{ 2663{
2662 Incidence *incidence = currentSelection(); 2664 Incidence *incidence = currentSelection();
2663 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2665 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2664 if ( incidence ) { 2666 if ( incidence ) {
2665 cloneIncidence(incidence); 2667 cloneIncidence(incidence);
2666 } 2668 }
2667} 2669}
2668void CalendarView::moveIncidence() 2670void CalendarView::moveIncidence()
2669{ 2671{
2670 Incidence *incidence = currentSelection(); 2672 Incidence *incidence = currentSelection();
2671 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2673 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2672 if ( incidence ) { 2674 if ( incidence ) {
2673 moveIncidence(incidence); 2675 moveIncidence(incidence);
2674 } 2676 }
2675} 2677}
2676void CalendarView::beamIncidence() 2678void CalendarView::beamIncidence()
2677{ 2679{
2678 Incidence *incidence = currentSelection(); 2680 Incidence *incidence = currentSelection();
2679 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2681 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2680 if ( incidence ) { 2682 if ( incidence ) {
2681 beamIncidence(incidence); 2683 beamIncidence(incidence);
2682 } 2684 }
2683} 2685}
2684void CalendarView::toggleCancelIncidence() 2686void CalendarView::toggleCancelIncidence()
2685{ 2687{
2686 Incidence *incidence = currentSelection(); 2688 Incidence *incidence = currentSelection();
2687 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2689 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2688 if ( incidence ) { 2690 if ( incidence ) {
2689 cancelIncidence(incidence); 2691 cancelIncidence(incidence);
2690 } 2692 }
2691} 2693}
2692 2694
2693 2695
2694void CalendarView::cancelIncidence(Incidence * inc ) 2696void CalendarView::cancelIncidence(Incidence * inc )
2695{ 2697{
2696 inc->setCancelled( ! inc->cancelled() ); 2698 inc->setCancelled( ! inc->cancelled() );
2697 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2699 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2698 updateView(); 2700 updateView();
2699} 2701}
2700void CalendarView::cloneIncidence(Incidence * orgInc ) 2702void CalendarView::cloneIncidence(Incidence * orgInc )
2701{ 2703{
2702 Incidence * newInc = orgInc->clone(); 2704 Incidence * newInc = orgInc->clone();
2703 newInc->recreate(); 2705 newInc->recreate();
2704 2706
2705 if ( newInc->type() == "Todo" ) { 2707 if ( newInc->type() == "Todo" ) {
2706 Todo* t = (Todo*) newInc; 2708 Todo* t = (Todo*) newInc;
2707 bool cloneSub = false; 2709 bool cloneSub = false;
2708 if ( orgInc->relations().count() ) { 2710 if ( orgInc->relations().count() ) {
2709 int result = KMessageBox::warningYesNoCancel(this, 2711 int result = KMessageBox::warningYesNoCancel(this,
2710 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 2712 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
2711 i18n("Todo has subtodos"), 2713 i18n("Todo has subtodos"),
2712 i18n("Yes"), 2714 i18n("Yes"),
2713 i18n("No")); 2715 i18n("No"));
2714 2716
2715 if ( result == KMessageBox::Cancel ) { 2717 if ( result == KMessageBox::Cancel ) {
2716 delete t; 2718 delete t;
2717 return; 2719 return;
2718 } 2720 }
2719 if (result == KMessageBox::Yes) cloneSub = true; 2721 if (result == KMessageBox::Yes) cloneSub = true;
2720 } 2722 }
2721 showTodoEditor(); 2723 showTodoEditor();
2722 mTodoEditor->editTodo( t ); 2724 mTodoEditor->editTodo( t );
2723 if ( mTodoEditor->exec() ) { 2725 if ( mTodoEditor->exec() ) {
2724 if ( cloneSub ) { 2726 if ( cloneSub ) {
2725 orgInc->cloneRelations( t ); 2727 orgInc->cloneRelations( t );
2726 mCalendar->addIncidenceBranch( t ); 2728 mCalendar->addIncidenceBranch( t );
2727 updateView(); 2729 updateView();
2728 2730
2729 } else { 2731 } else {
2730 mCalendar->addTodo( t ); 2732 mCalendar->addTodo( t );
2731 updateView(); 2733 updateView();
2732 } 2734 }
2733 } else { 2735 } else {
2734 delete t; 2736 delete t;
2735 } 2737 }
2736 } 2738 }
2737 else { 2739 else {
2738 Event* e = (Event*) newInc; 2740 Event* e = (Event*) newInc;
2739 showEventEditor(); 2741 showEventEditor();
2740 mEventEditor->editEvent( e ); 2742 mEventEditor->editEvent( e );
2741 if ( mEventEditor->exec() ) { 2743 if ( mEventEditor->exec() ) {
2742 mCalendar->addEvent( e ); 2744 mCalendar->addEvent( e );
2743 updateView(); 2745 updateView();
2744 } else { 2746 } else {
2745 delete e; 2747 delete e;
2746 } 2748 }
2747 } 2749 }
2748 setActiveWindow(); 2750 setActiveWindow();
2749} 2751}
2750 2752
2751void CalendarView::newEvent() 2753void CalendarView::newEvent()
2752{ 2754{
2753 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2755 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2754 KOAgendaView *aView = mViewManager->agendaView(); 2756 KOAgendaView *aView = mViewManager->agendaView();
2755 if (aView) { 2757 if (aView) {
2756 if (aView->selectionStart().isValid()) { 2758 if (aView->selectionStart().isValid()) {
2757 if (aView->selectedIsAllDay()) { 2759 if (aView->selectedIsAllDay()) {
2758 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2760 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2759 } else { 2761 } else {
2760 newEvent(aView->selectionStart(),aView->selectionEnd()); 2762 newEvent(aView->selectionStart(),aView->selectionEnd());
2761 } 2763 }
2762 return; 2764 return;
2763 } 2765 }
2764 } 2766 }
2765 2767
2766 QDate date = mNavigator->selectedDates().first(); 2768 QDate date = mNavigator->selectedDates().first();
2767 QDateTime current = QDateTime::currentDateTime(); 2769 QDateTime current = QDateTime::currentDateTime();
2768 if ( date <= current.date() ) { 2770 if ( date <= current.date() ) {
2769 int hour = current.time().hour() +1; 2771 int hour = current.time().hour() +1;
2770 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2772 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2771 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2773 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2772 } else 2774 } else
2773 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2775 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2774 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2776 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2775 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2777 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2776} 2778}
2777 2779
2778void CalendarView::newEvent(QDateTime fh) 2780void CalendarView::newEvent(QDateTime fh)
2779{ 2781{
2780 newEvent(fh, 2782 newEvent(fh,
2781 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2783 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2782} 2784}
2783 2785
2784void CalendarView::newEvent(QDate dt) 2786void CalendarView::newEvent(QDate dt)
2785{ 2787{
2786 newEvent(QDateTime(dt, QTime(0,0,0)), 2788 newEvent(QDateTime(dt, QTime(0,0,0)),
2787 QDateTime(dt, QTime(0,0,0)), true); 2789 QDateTime(dt, QTime(0,0,0)), true);
2788} 2790}
2789void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2791void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2790{ 2792{
2791 newEvent(fromHint, toHint, false); 2793 newEvent(fromHint, toHint, false);
2792} 2794}
2793void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2795void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2794{ 2796{
2795 2797
2796 showEventEditor(); 2798 showEventEditor();
2797 mEventEditor->newEvent(fromHint,toHint,allDay); 2799 mEventEditor->newEvent(fromHint,toHint,allDay);
2798 if ( mFilterView->filtersEnabled() ) { 2800 if ( mFilterView->filtersEnabled() ) {
2799 CalFilter *filter = mFilterView->selectedFilter(); 2801 CalFilter *filter = mFilterView->selectedFilter();
2800 if (filter && filter->showCategories()) { 2802 if (filter && filter->showCategories()) {
2801 mEventEditor->setCategories(filter->categoryList().join(",") ); 2803 mEventEditor->setCategories(filter->categoryList().join(",") );
2802 } 2804 }
2803 if ( filter ) 2805 if ( filter )
2804 mEventEditor->setSecrecy( filter->getSecrecy() ); 2806 mEventEditor->setSecrecy( filter->getSecrecy() );
2805 } 2807 }
2806 mEventEditor->exec(); 2808 mEventEditor->exec();
2807 setActiveWindow(); 2809 setActiveWindow();
2808} 2810}
2809void CalendarView::todoAdded(Todo * t) 2811void CalendarView::todoAdded(Todo * t)
2810{ 2812{
2811 2813
2812 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2814 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2813 updateTodoViews(); 2815 updateTodoViews();
2814} 2816}
2815void CalendarView::todoChanged(Todo * t) 2817void CalendarView::todoChanged(Todo * t)
2816{ 2818{
2817 emit todoModified( t, 4 ); 2819 emit todoModified( t, 4 );
2818 // updateTodoViews(); 2820 // updateTodoViews();
2819} 2821}
2820void CalendarView::todoToBeDeleted(Todo *) 2822void CalendarView::todoToBeDeleted(Todo *)
2821{ 2823{
2822 //qDebug("todoToBeDeleted(Todo *) "); 2824 //qDebug("todoToBeDeleted(Todo *) ");
2823 updateTodoViews(); 2825 updateTodoViews();
2824} 2826}
2825void CalendarView::todoDeleted() 2827void CalendarView::todoDeleted()
2826{ 2828{
2827 //qDebug(" todoDeleted()"); 2829 //qDebug(" todoDeleted()");
2828 updateTodoViews(); 2830 updateTodoViews();
2829} 2831}
2830 2832
2831 2833
2832void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2834void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2833{ 2835{
2834 showTodoEditor(); 2836 showTodoEditor();
2835 mTodoEditor->newTodo(dt,0,allday); 2837 mTodoEditor->newTodo(dt,0,allday);
2836 if ( mFilterView->filtersEnabled() ) { 2838 if ( mFilterView->filtersEnabled() ) {
2837 CalFilter *filter = mFilterView->selectedFilter(); 2839 CalFilter *filter = mFilterView->selectedFilter();
2838 if (filter && filter->showCategories()) { 2840 if (filter && filter->showCategories()) {
2839 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2841 mTodoEditor->setCategories(filter->categoryList().join(",") );
2840 } 2842 }
2841 if ( filter ) 2843 if ( filter )
2842 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2844 mTodoEditor->setSecrecy( filter->getSecrecy() );
2843 } 2845 }
2844 mTodoEditor->exec(); 2846 mTodoEditor->exec();
2845 setActiveWindow(); 2847 setActiveWindow();
2846} 2848}
2847 2849
2848void CalendarView::newTodo() 2850void CalendarView::newTodo()
2849{ 2851{
2850 newTodoDateTime( QDateTime(),true ); 2852 newTodoDateTime( QDateTime(),true );
2851} 2853}
2852 2854
2853void CalendarView::newSubTodo() 2855void CalendarView::newSubTodo()
2854{ 2856{
2855 Todo *todo = selectedTodo(); 2857 Todo *todo = selectedTodo();
2856 if ( todo ) newSubTodo( todo ); 2858 if ( todo ) newSubTodo( todo );
2857} 2859}
2858 2860
2859void CalendarView::newSubTodo(Todo *parentEvent) 2861void CalendarView::newSubTodo(Todo *parentEvent)
2860{ 2862{
2861 2863
2862 showTodoEditor(); 2864 showTodoEditor();
2863 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2865 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2864 mTodoEditor->exec(); 2866 mTodoEditor->exec();
2865 setActiveWindow(); 2867 setActiveWindow();
2866} 2868}
2867 2869
2868void CalendarView::newFloatingEvent() 2870void CalendarView::newFloatingEvent()
2869{ 2871{
2870 DateList tmpList = mNavigator->selectedDates(); 2872 DateList tmpList = mNavigator->selectedDates();
2871 QDate date = tmpList.first(); 2873 QDate date = tmpList.first();
2872 2874
2873 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2875 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2874 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2876 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2875} 2877}
2876 2878
2877 2879
2878void CalendarView::editEvent( Event *event ) 2880void CalendarView::editEvent( Event *event )
2879{ 2881{
2880 2882
2881 if ( !event ) return; 2883 if ( !event ) return;
2882 if ( event->isReadOnly() ) { 2884 if ( event->isReadOnly() ) {
2883 showEvent( event ); 2885 showEvent( event );
2884 return; 2886 return;
2885 } 2887 }
2886 showEventEditor(); 2888 showEventEditor();
2887 mEventEditor->editEvent( event , mFlagEditDescription); 2889 mEventEditor->editEvent( event , mFlagEditDescription);
2888 mEventEditor->exec(); 2890 mEventEditor->exec();
2889 setActiveWindow(); 2891 setActiveWindow();
2890 2892
2891} 2893}
2892void CalendarView::editJournal( Journal *jour ) 2894void CalendarView::editJournal( Journal *jour )
2893{ 2895{
2894 if ( !jour ) return; 2896 if ( !jour ) return;
2895 mDialogManager->hideSearchDialog(); 2897 mDialogManager->hideSearchDialog();
2896 mViewManager->showJournalView(); 2898 mViewManager->showJournalView();
2897 mNavigator->slotDaySelect( jour->dtStart().date() ); 2899 mNavigator->slotDaySelect( jour->dtStart().date() );
2898} 2900}
2899void CalendarView::editTodo( Todo *todo ) 2901void CalendarView::editTodo( Todo *todo )
2900{ 2902{
2901 if ( !todo ) return; 2903 if ( !todo ) return;
2902 2904
2903 if ( todo->isReadOnly() ) { 2905 if ( todo->isReadOnly() ) {
2904 showTodo( todo ); 2906 showTodo( todo );
2905 return; 2907 return;
2906 } 2908 }
2907 showTodoEditor(); 2909 showTodoEditor();
2908 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2910 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2909 mTodoEditor->exec(); 2911 mTodoEditor->exec();
2910 setActiveWindow(); 2912 setActiveWindow();
2911 2913
2912} 2914}
2913 2915
2914KOEventViewerDialog* CalendarView::getEventViewerDialog() 2916KOEventViewerDialog* CalendarView::getEventViewerDialog()
2915{ 2917{
2916 if ( !mEventViewerDialog ) { 2918 if ( !mEventViewerDialog ) {
2917 mEventViewerDialog = new KOEventViewerDialog(0); 2919 mEventViewerDialog = new KOEventViewerDialog(0);
2918 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2920 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2919 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2921 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2920 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2922 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2921 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2923 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2922 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2924 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2923 viewManager(), SLOT( showAgendaView( bool ) ) ); 2925 viewManager(), SLOT( showAgendaView( bool ) ) );
2924 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 2926 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2925 this, SLOT( slotViewerClosed() ) ); 2927 this, SLOT( slotViewerClosed() ) );
2926 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2928 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2927 this, SLOT( todoChanged(Todo *) ) ); 2929 this, SLOT( todoChanged(Todo *) ) );
2928 mEventViewerDialog->resize( 640, 480 ); 2930 mEventViewerDialog->resize( 640, 480 );
2929 2931
2930 } 2932 }
2931 return mEventViewerDialog; 2933 return mEventViewerDialog;
2932} 2934}
2933void CalendarView::showEvent(Event *event) 2935void CalendarView::showEvent(Event *event)
2934{ 2936{
2935 getEventViewerDialog()->setEvent(event); 2937 getEventViewerDialog()->setEvent(event);
2936 getEventViewerDialog()->showMe(); 2938 getEventViewerDialog()->showMe();
2937} 2939}
2938 2940
2939void CalendarView::showTodo(Todo *event) 2941void CalendarView::showTodo(Todo *event)
2940{ 2942{
2941 getEventViewerDialog()->setTodo(event); 2943 getEventViewerDialog()->setTodo(event);
2942 getEventViewerDialog()->showMe(); 2944 getEventViewerDialog()->showMe();
2943} 2945}
2944void CalendarView::showJournal( Journal *jour ) 2946void CalendarView::showJournal( Journal *jour )
2945{ 2947{
2946 getEventViewerDialog()->setJournal(jour); 2948 getEventViewerDialog()->setJournal(jour);
2947 getEventViewerDialog()->showMe(); 2949 getEventViewerDialog()->showMe();
2948 2950
2949} 2951}
2950// void CalendarView::todoModified (Todo *event, int changed) 2952// void CalendarView::todoModified (Todo *event, int changed)
2951// { 2953// {
2952// // if (mDialogList.find (event) != mDialogList.end ()) { 2954// // if (mDialogList.find (event) != mDialogList.end ()) {
2953// // kdDebug() << "Todo modified and open" << endl; 2955// // kdDebug() << "Todo modified and open" << endl;
2954// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2956// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2955// // temp->modified (changed); 2957// // temp->modified (changed);
2956 2958
2957// // } 2959// // }
2958 2960
2959// mViewManager->updateView(); 2961// mViewManager->updateView();
2960// } 2962// }
2961 2963
2962void CalendarView::appointment_show() 2964void CalendarView::appointment_show()
2963{ 2965{
2964 Event *anEvent = 0; 2966 Event *anEvent = 0;
2965 2967
2966 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2968 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2967 2969
2968 if (mViewManager->currentView()->isEventView()) { 2970 if (mViewManager->currentView()->isEventView()) {
2969 if ( incidence && incidence->type() == "Event" ) { 2971 if ( incidence && incidence->type() == "Event" ) {
2970 anEvent = static_cast<Event *>(incidence); 2972 anEvent = static_cast<Event *>(incidence);
2971 } 2973 }
2972 } 2974 }
2973 2975
2974 if (!anEvent) { 2976 if (!anEvent) {
2975 KNotifyClient::beep(); 2977 KNotifyClient::beep();
2976 return; 2978 return;
2977 } 2979 }
2978 2980
2979 showEvent(anEvent); 2981 showEvent(anEvent);
2980} 2982}
2981 2983
2982void CalendarView::appointment_edit() 2984void CalendarView::appointment_edit()
2983{ 2985{
2984 Event *anEvent = 0; 2986 Event *anEvent = 0;
2985 2987
2986 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2988 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2987 2989
2988 if (mViewManager->currentView()->isEventView()) { 2990 if (mViewManager->currentView()->isEventView()) {
2989 if ( incidence && incidence->type() == "Event" ) { 2991 if ( incidence && incidence->type() == "Event" ) {
2990 anEvent = static_cast<Event *>(incidence); 2992 anEvent = static_cast<Event *>(incidence);
2991 } 2993 }
2992 } 2994 }
2993 2995
2994 if (!anEvent) { 2996 if (!anEvent) {
2995 KNotifyClient::beep(); 2997 KNotifyClient::beep();
2996 return; 2998 return;
2997 } 2999 }
2998 3000
2999 editEvent(anEvent); 3001 editEvent(anEvent);
3000} 3002}
3001 3003
3002void CalendarView::appointment_delete() 3004void CalendarView::appointment_delete()
3003{ 3005{
3004 Event *anEvent = 0; 3006 Event *anEvent = 0;
3005 3007
3006 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3008 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3007 3009
3008 if (mViewManager->currentView()->isEventView()) { 3010 if (mViewManager->currentView()->isEventView()) {
3009 if ( incidence && incidence->type() == "Event" ) { 3011 if ( incidence && incidence->type() == "Event" ) {
3010 anEvent = static_cast<Event *>(incidence); 3012 anEvent = static_cast<Event *>(incidence);
3011 } 3013 }
3012 } 3014 }
3013 3015
3014 if (!anEvent) { 3016 if (!anEvent) {
3015 KNotifyClient::beep(); 3017 KNotifyClient::beep();
3016 return; 3018 return;
3017 } 3019 }
3018 3020
3019 deleteEvent(anEvent); 3021 deleteEvent(anEvent);
3020} 3022}
3021 3023
3022void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3024void CalendarView::todo_resub( Todo * parent, Todo * sub )
3023{ 3025{
3024 if (!sub) return; 3026 if (!sub) return;
3025 if ( sub->relatedTo() == parent ) 3027 if ( sub->relatedTo() == parent )
3026 return; 3028 return;
3027 sub->setRelatedTo(parent); 3029 sub->setRelatedTo(parent);
3028 sub->updated(); 3030 sub->updated();
3029 setModified(true); 3031 setModified(true);
3030 updateView(); 3032 updateView();
3031} 3033}
3032void CalendarView::todo_unsub(Todo *anTodo ) 3034void CalendarView::todo_unsub(Todo *anTodo )
3033{ 3035{
3034 todo_resub( 0, anTodo ); 3036 todo_resub( 0, anTodo );
3035} 3037}
3036 3038
3037void CalendarView::deleteTodo(Todo *todo) 3039void CalendarView::deleteTodo(Todo *todo)
3038{ 3040{
3039 if (!todo) { 3041 if (!todo) {
3040 KNotifyClient::beep(); 3042 KNotifyClient::beep();
3041 return; 3043 return;
3042 } 3044 }
3043 if (KOPrefs::instance()->mConfirm) { 3045 if (KOPrefs::instance()->mConfirm) {
3044 QString text = todo->summary().left(20); 3046 QString text = todo->summary().left(20);
3045 if (!todo->relations().isEmpty()) { 3047 if (!todo->relations().isEmpty()) {
3046 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3048 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3047 3049
3048 } 3050 }
3049 switch (msgItemDelete(text)) { 3051 switch (msgItemDelete(text)) {
3050 case KMessageBox::Continue: // OK 3052 case KMessageBox::Continue: // OK
3051 bool deleteT = false; 3053 bool deleteT = false;
3052 if (!todo->relations().isEmpty()) { 3054 if (!todo->relations().isEmpty()) {
3053 deleteT = removeCompletedSubTodos( todo ); 3055 deleteT = removeCompletedSubTodos( todo );
3054 } 3056 }
3055 // deleteT == true: todo already deleted in removeCompletedSubTodos 3057 // deleteT == true: todo already deleted in removeCompletedSubTodos
3056 if ( !deleteT ) { 3058 if ( !deleteT ) {
3057 checkExternalId( todo ); 3059 checkExternalId( todo );
3058 calendar()->deleteTodo(todo); 3060 calendar()->deleteTodo(todo);
3059 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3061 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3060 updateView(); 3062 updateView();
3061 } 3063 }
3062 break; 3064 break;
3063 } // switch 3065 } // switch
3064 } else { 3066 } else {
3065 checkExternalId( todo ); 3067 checkExternalId( todo );
3066 mCalendar->deleteTodo(todo); 3068 mCalendar->deleteTodo(todo);
3067 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3069 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3068 updateView(); 3070 updateView();
3069 } 3071 }
3070 3072
3071 emit updateSearchDialog(); 3073 emit updateSearchDialog();
3072} 3074}
3073void CalendarView::deleteJournal(Journal *jour) 3075void CalendarView::deleteJournal(Journal *jour)
3074{ 3076{
3075 if (!jour) { 3077 if (!jour) {
3076 KNotifyClient::beep(); 3078 KNotifyClient::beep();
3077 return; 3079 return;
3078 } 3080 }
3079 if (KOPrefs::instance()->mConfirm) { 3081 if (KOPrefs::instance()->mConfirm) {
3080 switch (msgItemDelete( jour->description().left(20))) { 3082 switch (msgItemDelete( jour->description().left(20))) {
3081 case KMessageBox::Continue: // OK 3083 case KMessageBox::Continue: // OK
3082 calendar()->deleteJournal(jour); 3084 calendar()->deleteJournal(jour);
3083 updateView(); 3085 updateView();
3084 break; 3086 break;
3085 } // switch 3087 } // switch
3086 } else { 3088 } else {
3087 calendar()->deleteJournal(jour);; 3089 calendar()->deleteJournal(jour);;
3088 updateView(); 3090 updateView();
3089 } 3091 }
3090 emit updateSearchDialog(); 3092 emit updateSearchDialog();
3091} 3093}
3092 3094
3093void CalendarView::deleteEvent(Event *anEvent) 3095void CalendarView::deleteEvent(Event *anEvent)
3094{ 3096{
3095 if (!anEvent) { 3097 if (!anEvent) {
3096 KNotifyClient::beep(); 3098 KNotifyClient::beep();
3097 return; 3099 return;
3098 } 3100 }
3099 3101
3100 if (anEvent->recurrence()->doesRecur()) { 3102 if (anEvent->recurrence()->doesRecur()) {
3101 QDate itemDate = mViewManager->currentSelectionDate(); 3103 QDate itemDate = mViewManager->currentSelectionDate();
3102 int km; 3104 int km;
3103 if (!itemDate.isValid()) { 3105 if (!itemDate.isValid()) {
3104 //kdDebug() << "Date Not Valid" << endl; 3106 //kdDebug() << "Date Not Valid" << endl;
3105 if (KOPrefs::instance()->mConfirm) { 3107 if (KOPrefs::instance()->mConfirm) {
3106 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3108 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3107 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3109 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3108 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3110 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3109 if ( km == KMessageBox::Continue ) 3111 if ( km == KMessageBox::Continue )
3110 km = KMessageBox::No; // No = all below 3112 km = KMessageBox::No; // No = all below
3111 } else 3113 } else
3112 km = KMessageBox::No; 3114 km = KMessageBox::No;
3113 } else { 3115 } else {
3114 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3116 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3115 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3117 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3116 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3118 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3117 i18n("KO/Pi Confirmation"),i18n("Current"), 3119 i18n("KO/Pi Confirmation"),i18n("Current"),
3118 i18n("All")); 3120 i18n("All"));
3119 } 3121 }
3120 switch(km) { 3122 switch(km) {
3121 3123
3122 case KMessageBox::No: // Continue // all 3124 case KMessageBox::No: // Continue // all
3123 //qDebug("KMessageBox::No "); 3125 //qDebug("KMessageBox::No ");
3124 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3126 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3125 schedule(Scheduler::Cancel,anEvent); 3127 schedule(Scheduler::Cancel,anEvent);
3126 3128
3127 checkExternalId( anEvent); 3129 checkExternalId( anEvent);
3128 mCalendar->deleteEvent(anEvent); 3130 mCalendar->deleteEvent(anEvent);
3129 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3131 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3130 break; 3132 break;
3131 3133
3132 // Disabled because it does not work 3134 // Disabled because it does not work
3133 //#if 0 3135 //#if 0
3134 case KMessageBox::Yes: // just this one 3136 case KMessageBox::Yes: // just this one
3135 //QDate qd = mNavigator->selectedDates().first(); 3137 //QDate qd = mNavigator->selectedDates().first();
3136 //if (!qd.isValid()) { 3138 //if (!qd.isValid()) {
3137 // kdDebug() << "no date selected, or invalid date" << endl; 3139 // kdDebug() << "no date selected, or invalid date" << endl;
3138 // KNotifyClient::beep(); 3140 // KNotifyClient::beep();
3139 // return; 3141 // return;
3140 //} 3142 //}
3141 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3143 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3142 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3144 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3143 anEvent->addExDate(itemDate); 3145 anEvent->addExDate(itemDate);
3144 int duration = anEvent->recurrence()->duration(); 3146 int duration = anEvent->recurrence()->duration();
3145 if ( duration > 0 ) { 3147 if ( duration > 0 ) {
3146 anEvent->recurrence()->setDuration( duration - 1 ); 3148 anEvent->recurrence()->setDuration( duration - 1 );
3147 } 3149 }
3148 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3150 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3149 } 3151 }
3150 break; 3152 break;
3151 //#endif 3153 //#endif
3152 } // switch 3154 } // switch
3153 } else { 3155 } else {
3154 if (KOPrefs::instance()->mConfirm) { 3156 if (KOPrefs::instance()->mConfirm) {
3155 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3157 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3156 i18n("\nAre you sure you want\nto delete this event?"), 3158 i18n("\nAre you sure you want\nto delete this event?"),
3157 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3159 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3158 case KMessageBox::Continue: // OK 3160 case KMessageBox::Continue: // OK
3159 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3161 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3160 schedule(Scheduler::Cancel,anEvent); 3162 schedule(Scheduler::Cancel,anEvent);
3161 checkExternalId( anEvent); 3163 checkExternalId( anEvent);
3162 mCalendar->deleteEvent(anEvent); 3164 mCalendar->deleteEvent(anEvent);
3163 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3165 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3164 break; 3166 break;
3165 } // switch 3167 } // switch
3166 } else { 3168 } else {
3167 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3169 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3168 schedule(Scheduler::Cancel,anEvent); 3170 schedule(Scheduler::Cancel,anEvent);
3169 checkExternalId( anEvent); 3171 checkExternalId( anEvent);
3170 mCalendar->deleteEvent(anEvent); 3172 mCalendar->deleteEvent(anEvent);
3171 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3173 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3172 } 3174 }
3173 } // if-else 3175 } // if-else
3174 emit updateSearchDialog(); 3176 emit updateSearchDialog();
3175} 3177}
3176 3178
3177bool CalendarView::deleteEvent(const QString &uid) 3179bool CalendarView::deleteEvent(const QString &uid)
3178{ 3180{
3179 Event *ev = mCalendar->event(uid); 3181 Event *ev = mCalendar->event(uid);
3180 if (ev) { 3182 if (ev) {
3181 deleteEvent(ev); 3183 deleteEvent(ev);
3182 return true; 3184 return true;
3183 } else { 3185 } else {
3184 return false; 3186 return false;
3185 } 3187 }
3186} 3188}
3187 3189
3188/*****************************************************************************/ 3190/*****************************************************************************/
3189 3191
3190void CalendarView::action_mail() 3192void CalendarView::action_mail()
3191{ 3193{
3192#ifndef KORG_NOMAIL 3194#ifndef KORG_NOMAIL
3193 KOMailClient mailClient; 3195 KOMailClient mailClient;
3194 3196
3195 Incidence *incidence = currentSelection(); 3197 Incidence *incidence = currentSelection();
3196 3198
3197 if (!incidence) { 3199 if (!incidence) {
3198 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3200 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3199 return; 3201 return;
3200 } 3202 }
3201 if(incidence->attendeeCount() == 0 ) { 3203 if(incidence->attendeeCount() == 0 ) {
3202 KMessageBox::sorry(this, 3204 KMessageBox::sorry(this,
3203 i18n("Can't generate mail:\nNo attendees defined.\n")); 3205 i18n("Can't generate mail:\nNo attendees defined.\n"));
3204 return; 3206 return;
3205 } 3207 }
3206 3208
3207 CalendarLocal cal_tmp; 3209 CalendarLocal cal_tmp;
3208 Event *event = 0; 3210 Event *event = 0;
3209 Event *ev = 0; 3211 Event *ev = 0;
3210 if ( incidence && incidence->type() == "Event" ) { 3212 if ( incidence && incidence->type() == "Event" ) {
3211 event = static_cast<Event *>(incidence); 3213 event = static_cast<Event *>(incidence);
3212 ev = new Event(*event); 3214 ev = new Event(*event);
3213 cal_tmp.addEvent(ev); 3215 cal_tmp.addEvent(ev);
3214 } 3216 }
3215 ICalFormat mForm(); 3217 ICalFormat mForm();
3216 QString attachment = mForm.toString( &cal_tmp ); 3218 QString attachment = mForm.toString( &cal_tmp );
3217 if (ev) delete(ev); 3219 if (ev) delete(ev);
3218 3220
3219 mailClient.mailAttendees(currentSelection(), attachment); 3221 mailClient.mailAttendees(currentSelection(), attachment);
3220 3222
3221#endif 3223#endif
3222 3224
3223#if 0 3225#if 0
3224 Event *anEvent = 0; 3226 Event *anEvent = 0;
3225 if (mViewManager->currentView()->isEventView()) { 3227 if (mViewManager->currentView()->isEventView()) {
3226 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3228 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3227 } 3229 }
3228 3230
3229 if (!anEvent) { 3231 if (!anEvent) {
3230 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3232 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3231 return; 3233 return;
3232 } 3234 }
3233 if(anEvent->attendeeCount() == 0 ) { 3235 if(anEvent->attendeeCount() == 0 ) {
3234 KMessageBox::sorry(this, 3236 KMessageBox::sorry(this,
3235 i18n("Can't generate mail:\nNo attendees defined.\n")); 3237 i18n("Can't generate mail:\nNo attendees defined.\n"));
3236 return; 3238 return;
3237 } 3239 }
3238 3240
3239 mailobject.emailEvent(anEvent); 3241 mailobject.emailEvent(anEvent);
3240#endif 3242#endif
3241} 3243}
3242 3244
3243 3245
3244void CalendarView::schedule_publish(Incidence *incidence) 3246void CalendarView::schedule_publish(Incidence *incidence)
3245{ 3247{
3246 Event *event = 0; 3248 Event *event = 0;
3247 Todo *todo = 0; 3249 Todo *todo = 0;
3248 3250
3249 if (incidence == 0) { 3251 if (incidence == 0) {
3250 incidence = mViewManager->currentView()->selectedIncidences().first(); 3252 incidence = mViewManager->currentView()->selectedIncidences().first();
3251 if (incidence == 0) { 3253 if (incidence == 0) {
3252 incidence = mTodoList->selectedIncidences().first(); 3254 incidence = mTodoList->selectedIncidences().first();
3253 } 3255 }
3254 } 3256 }
3255 if ( incidence && incidence->type() == "Event" ) { 3257 if ( incidence && incidence->type() == "Event" ) {
3256 event = static_cast<Event *>(incidence); 3258 event = static_cast<Event *>(incidence);
3257 } else { 3259 } else {
3258 if ( incidence && incidence->type() == "Todo" ) { 3260 if ( incidence && incidence->type() == "Todo" ) {
3259 todo = static_cast<Todo *>(incidence); 3261 todo = static_cast<Todo *>(incidence);
3260 } 3262 }
3261 } 3263 }
3262 3264
3263 if (!event && !todo) { 3265 if (!event && !todo) {
3264 KMessageBox::sorry(this,i18n("No event selected.")); 3266 KMessageBox::sorry(this,i18n("No event selected."));
3265 return; 3267 return;
3266 } 3268 }
3267 3269
3268 PublishDialog *publishdlg = new PublishDialog(); 3270 PublishDialog *publishdlg = new PublishDialog();
3269 if (incidence->attendeeCount()>0) { 3271 if (incidence->attendeeCount()>0) {
3270 QPtrList<Attendee> attendees = incidence->attendees(); 3272 QPtrList<Attendee> attendees = incidence->attendees();
3271 attendees.first(); 3273 attendees.first();
3272 while ( attendees.current()!=0 ) { 3274 while ( attendees.current()!=0 ) {
3273 publishdlg->addAttendee(attendees.current()); 3275 publishdlg->addAttendee(attendees.current());
3274 attendees.next(); 3276 attendees.next();
3275 } 3277 }
3276 } 3278 }
3277 bool send = true; 3279 bool send = true;
3278 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3280 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3279 if ( publishdlg->exec() != QDialog::Accepted ) 3281 if ( publishdlg->exec() != QDialog::Accepted )
3280 send = false; 3282 send = false;
3281 } 3283 }
3282 if ( send ) { 3284 if ( send ) {
3283 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3285 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3284 if ( event ) { 3286 if ( event ) {
3285 Event *ev = new Event(*event); 3287 Event *ev = new Event(*event);
3286 ev->registerObserver(0); 3288 ev->registerObserver(0);
3287 ev->clearAttendees(); 3289 ev->clearAttendees();
3288 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3290 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3289 delete(ev); 3291 delete(ev);
3290 } 3292 }
3291 } else { 3293 } else {
3292 if ( todo ) { 3294 if ( todo ) {
3293 Todo *ev = new Todo(*todo); 3295 Todo *ev = new Todo(*todo);
3294 ev->registerObserver(0); 3296 ev->registerObserver(0);
3295 ev->clearAttendees(); 3297 ev->clearAttendees();
3296 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3298 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3297 delete(ev); 3299 delete(ev);
3298 } 3300 }
3299 } 3301 }
3300 } 3302 }
3301 } 3303 }
3302 delete publishdlg; 3304 delete publishdlg;
3303} 3305}
3304 3306
3305void CalendarView::schedule_request(Incidence *incidence) 3307void CalendarView::schedule_request(Incidence *incidence)
3306{ 3308{
3307 schedule(Scheduler::Request,incidence); 3309 schedule(Scheduler::Request,incidence);
3308} 3310}
3309 3311
3310void CalendarView::schedule_refresh(Incidence *incidence) 3312void CalendarView::schedule_refresh(Incidence *incidence)
3311{ 3313{
3312 schedule(Scheduler::Refresh,incidence); 3314 schedule(Scheduler::Refresh,incidence);
3313} 3315}
3314 3316
3315void CalendarView::schedule_cancel(Incidence *incidence) 3317void CalendarView::schedule_cancel(Incidence *incidence)
3316{ 3318{
3317 schedule(Scheduler::Cancel,incidence); 3319 schedule(Scheduler::Cancel,incidence);
3318} 3320}
3319 3321
3320void CalendarView::schedule_add(Incidence *incidence) 3322void CalendarView::schedule_add(Incidence *incidence)
3321{ 3323{
3322 schedule(Scheduler::Add,incidence); 3324 schedule(Scheduler::Add,incidence);
3323} 3325}
3324 3326
3325void CalendarView::schedule_reply(Incidence *incidence) 3327void CalendarView::schedule_reply(Incidence *incidence)
3326{ 3328{
3327 schedule(Scheduler::Reply,incidence); 3329 schedule(Scheduler::Reply,incidence);
3328} 3330}
3329 3331
3330void CalendarView::schedule_counter(Incidence *incidence) 3332void CalendarView::schedule_counter(Incidence *incidence)
3331{ 3333{
3332 schedule(Scheduler::Counter,incidence); 3334 schedule(Scheduler::Counter,incidence);
3333} 3335}
3334 3336
3335void CalendarView::schedule_declinecounter(Incidence *incidence) 3337void CalendarView::schedule_declinecounter(Incidence *incidence)
3336{ 3338{
3337 schedule(Scheduler::Declinecounter,incidence); 3339 schedule(Scheduler::Declinecounter,incidence);
3338} 3340}
3339 3341
3340void CalendarView::schedule_publish_freebusy(int daysToPublish) 3342void CalendarView::schedule_publish_freebusy(int daysToPublish)
3341{ 3343{
3342 QDateTime start = QDateTime::currentDateTime(); 3344 QDateTime start = QDateTime::currentDateTime();
3343 QDateTime end = start.addDays(daysToPublish); 3345 QDateTime end = start.addDays(daysToPublish);
3344 3346
3345 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3347 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3346 freebusy->setOrganizer(KOPrefs::instance()->email()); 3348 freebusy->setOrganizer(KOPrefs::instance()->email());
3347 3349
3348 3350
3349 PublishDialog *publishdlg = new PublishDialog(); 3351 PublishDialog *publishdlg = new PublishDialog();
3350 if ( publishdlg->exec() == QDialog::Accepted ) { 3352 if ( publishdlg->exec() == QDialog::Accepted ) {
3351 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3353 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3352 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3354 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3353 delete(freebusy); 3355 delete(freebusy);
3354 } 3356 }
3355 } 3357 }
3356 delete publishdlg; 3358 delete publishdlg;
3357} 3359}
3358 3360
3359void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3361void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3360{ 3362{
3361 Event *event = 0; 3363 Event *event = 0;
3362 Todo *todo = 0; 3364 Todo *todo = 0;
3363 3365
3364 if (incidence == 0) { 3366 if (incidence == 0) {
3365 incidence = mViewManager->currentView()->selectedIncidences().first(); 3367 incidence = mViewManager->currentView()->selectedIncidences().first();
3366 if (incidence == 0) { 3368 if (incidence == 0) {
3367 incidence = mTodoList->selectedIncidences().first(); 3369 incidence = mTodoList->selectedIncidences().first();
3368 } 3370 }
3369 } 3371 }
3370 if ( incidence && incidence->type() == "Event" ) { 3372 if ( incidence && incidence->type() == "Event" ) {
3371 event = static_cast<Event *>(incidence); 3373 event = static_cast<Event *>(incidence);
3372 } 3374 }
3373 if ( incidence && incidence->type() == "Todo" ) { 3375 if ( incidence && incidence->type() == "Todo" ) {
3374 todo = static_cast<Todo *>(incidence); 3376 todo = static_cast<Todo *>(incidence);
3375 } 3377 }
3376 3378
3377 if (!event && !todo) { 3379 if (!event && !todo) {
3378 KMessageBox::sorry(this,i18n("No event selected.")); 3380 KMessageBox::sorry(this,i18n("No event selected."));
3379 return; 3381 return;
3380 } 3382 }
3381 3383
3382 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3384 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3383 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3385 KMessageBox::sorry(this,i18n("The event has no attendees."));
3384 return; 3386 return;
3385 } 3387 }
3386 3388
3387 Event *ev = 0; 3389 Event *ev = 0;
3388 if (event) ev = new Event(*event); 3390 if (event) ev = new Event(*event);
3389 Todo *to = 0; 3391 Todo *to = 0;
3390 if (todo) to = new Todo(*todo); 3392 if (todo) to = new Todo(*todo);
3391 3393
3392 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3394 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3393 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3395 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3394 if (!me) { 3396 if (!me) {
3395 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3397 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3396 return; 3398 return;
3397 } 3399 }
3398 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3400 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3399 StatusDialog *statdlg = new StatusDialog(this); 3401 StatusDialog *statdlg = new StatusDialog(this);
3400 if (!statdlg->exec()==QDialog::Accepted) return; 3402 if (!statdlg->exec()==QDialog::Accepted) return;
3401 me->setStatus( statdlg->status() ); 3403 me->setStatus( statdlg->status() );
3402 delete(statdlg); 3404 delete(statdlg);
3403 } 3405 }
3404 Attendee *menew = new Attendee(*me); 3406 Attendee *menew = new Attendee(*me);
3405 if (ev) { 3407 if (ev) {
3406 ev->clearAttendees(); 3408 ev->clearAttendees();
3407 ev->addAttendee(menew,false); 3409 ev->addAttendee(menew,false);
3408 } else { 3410 } else {
3409 if (to) { 3411 if (to) {
3410 todo->clearAttendees(); 3412 todo->clearAttendees();
3411 todo->addAttendee(menew,false); 3413 todo->addAttendee(menew,false);
3412 } 3414 }
3413 } 3415 }
3414 } 3416 }
3415 3417
3416 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3418 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3417 if (ev) { 3419 if (ev) {
3418 if ( !dlg->addMessage(ev,method) ) delete(ev); 3420 if ( !dlg->addMessage(ev,method) ) delete(ev);
3419 } else { 3421 } else {
3420 if (to) { 3422 if (to) {
3421 if ( !dlg->addMessage(to,method) ) delete(to); 3423 if ( !dlg->addMessage(to,method) ) delete(to);
3422 } 3424 }
3423 } 3425 }
3424} 3426}
3425 3427
3426void CalendarView::openAddressbook() 3428void CalendarView::openAddressbook()
3427{ 3429{
3428 KRun::runCommand("kaddressbook"); 3430 KRun::runCommand("kaddressbook");
3429} 3431}
3430 3432
3431void CalendarView::setModified(bool modified) 3433void CalendarView::setModified(bool modified)
3432{ 3434{
3433 if ( modified ) 3435 if ( modified )
3434 emit signalmodified(); 3436 emit signalmodified();
3435 if (mModified != modified) { 3437 if (mModified != modified) {
3436 mModified = modified; 3438 mModified = modified;
3437 emit modifiedChanged(mModified); 3439 emit modifiedChanged(mModified);
3438 } 3440 }
3439} 3441}
3440 3442
3441bool CalendarView::isReadOnly() 3443bool CalendarView::isReadOnly()
3442{ 3444{
3443 return mReadOnly; 3445 return mReadOnly;
3444} 3446}
3445 3447
3446void CalendarView::setReadOnly(bool readOnly) 3448void CalendarView::setReadOnly(bool readOnly)
3447{ 3449{
3448 if (mReadOnly != readOnly) { 3450 if (mReadOnly != readOnly) {
3449 mReadOnly = readOnly; 3451 mReadOnly = readOnly;
3450 emit readOnlyChanged(mReadOnly); 3452 emit readOnlyChanged(mReadOnly);
3451 } 3453 }
3452} 3454}
3453 3455
3454bool CalendarView::isModified() 3456bool CalendarView::isModified()
3455{ 3457{
3456 return mModified; 3458 return mModified;
3457} 3459}
3458void CalendarView::slotprintSelInc() 3460void CalendarView::slotprintSelInc()
3459{ 3461{
3460 if ( currentSelection() == 0 ) { 3462 if ( currentSelection() == 0 ) {
3461 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3463 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3462 return; 3464 return;
3463 } 3465 }
3464 showIncidence(); 3466 showIncidence();
3465 getEventViewerDialog()->print(); 3467 getEventViewerDialog()->print();
3466 3468
3467} 3469}
3468void CalendarView::printSetup() 3470void CalendarView::printSetup()
3469{ 3471{
3470#ifndef KORG_NOPRINTER 3472#ifndef KORG_NOPRINTER
3471 createPrinter(); 3473 createPrinter();
3472 3474
3473 mCalPrinter->setupPrinter(); 3475 mCalPrinter->setupPrinter();
3474#endif 3476#endif
3475} 3477}
3476 3478
3477void CalendarView::print() 3479void CalendarView::print()
3478{ 3480{
3479#ifndef KORG_NOPRINTER 3481#ifndef KORG_NOPRINTER
3480 createPrinter(); 3482 createPrinter();
3481 3483
3482 DateList tmpDateList = mNavigator->selectedDates(); 3484 DateList tmpDateList = mNavigator->selectedDates();
3483 mCalPrinter->print(CalPrinter::Month, 3485 mCalPrinter->print(CalPrinter::Month,
3484 tmpDateList.first(), tmpDateList.last()); 3486 tmpDateList.first(), tmpDateList.last());
3485#endif 3487#endif
3486} 3488}
3487 3489
3488void CalendarView::printPreview() 3490void CalendarView::printPreview()
3489{ 3491{
3490#ifndef KORG_NOPRINTER 3492#ifndef KORG_NOPRINTER
3491 kdDebug() << "CalendarView::printPreview()" << endl; 3493 kdDebug() << "CalendarView::printPreview()" << endl;
3492 3494
3493 createPrinter(); 3495 createPrinter();
3494 3496
3495 DateList tmpDateList = mNavigator->selectedDates(); 3497 DateList tmpDateList = mNavigator->selectedDates();
3496 3498
3497 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3499 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3498 tmpDateList.last()); 3500 tmpDateList.last());
3499#endif 3501#endif
3500} 3502}
3501 3503
3502void CalendarView::exportICalendar() 3504void CalendarView::exportICalendar()
3503{ 3505{
3504 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3506 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3505 3507
3506 // Force correct extension 3508 // Force correct extension
3507 if (filename.right(4) != ".ics") filename += ".ics"; 3509 if (filename.right(4) != ".ics") filename += ".ics";
3508 3510
3509 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3511 FileStorage storage( mCalendar, filename, new ICalFormat() );
3510 storage.save(); 3512 storage.save();
3511} 3513}
3512 3514
3513bool CalendarView::exportVCalendar( QString filename ) 3515bool CalendarView::exportVCalendar( QString filename )
3514{ 3516{
3515 if (mCalendar->journals().count() > 0) { 3517 if (mCalendar->journals().count() > 0) {
3516 int result = KMessageBox::warningContinueCancel(this, 3518 int result = KMessageBox::warningContinueCancel(this,
3517 i18n("The journal entries can not be\nexported to a vCalendar file."), 3519 i18n("The journal entries can not be\nexported to a vCalendar file."),
3518 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3520 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3519 true); 3521 true);
3520 if (result != KMessageBox::Continue) return false; 3522 if (result != KMessageBox::Continue) return false;
3521 } 3523 }
3522 3524
3523 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3525 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3524 3526
3525 // Force correct extension 3527 // Force correct extension
3526 if (filename.right(4) != ".vcs") filename += ".vcs"; 3528 if (filename.right(4) != ".vcs") filename += ".vcs";
3527 3529
3528 FileStorage storage( mCalendar, filename, new VCalFormat ); 3530 FileStorage storage( mCalendar, filename, new VCalFormat );
3529 return storage.save(); 3531 return storage.save();
3530 3532
3531} 3533}
3532 3534
3533void CalendarView::eventUpdated(Incidence *) 3535void CalendarView::eventUpdated(Incidence *)
3534{ 3536{
3535 setModified(); 3537 setModified();
3536 // Don't call updateView here. The code, which has caused the update of the 3538 // Don't call updateView here. The code, which has caused the update of the
3537 // event is responsible for updating the view. 3539 // event is responsible for updating the view.
3538 // updateView(); 3540 // updateView();
3539} 3541}
3540 3542
3541void CalendarView::adaptNavigationUnits() 3543void CalendarView::adaptNavigationUnits()
3542{ 3544{
3543 if (mViewManager->currentView()->isEventView()) { 3545 if (mViewManager->currentView()->isEventView()) {
3544 int days = mViewManager->currentView()->currentDateCount(); 3546 int days = mViewManager->currentView()->currentDateCount();
3545 if (days == 1) { 3547 if (days == 1) {
3546 emit changeNavStringPrev(i18n("&Previous Day")); 3548 emit changeNavStringPrev(i18n("&Previous Day"));
3547 emit changeNavStringNext(i18n("&Next Day")); 3549 emit changeNavStringNext(i18n("&Next Day"));
3548 } else { 3550 } else {
3549 emit changeNavStringPrev(i18n("&Previous Week")); 3551 emit changeNavStringPrev(i18n("&Previous Week"));
3550 emit changeNavStringNext(i18n("&Next Week")); 3552 emit changeNavStringNext(i18n("&Next Week"));
3551 } 3553 }
3552 } 3554 }
3553} 3555}
3554 3556
3555void CalendarView::processMainViewSelection( Incidence *incidence ) 3557void CalendarView::processMainViewSelection( Incidence *incidence )
3556{ 3558{
3557 if ( incidence ) mTodoList->clearSelection(); 3559 if ( incidence ) mTodoList->clearSelection();
3558 processIncidenceSelection( incidence ); 3560 processIncidenceSelection( incidence );
3559} 3561}
3560 3562
3561void CalendarView::processTodoListSelection( Incidence *incidence ) 3563void CalendarView::processTodoListSelection( Incidence *incidence )
3562{ 3564{
3563 if ( incidence && mViewManager->currentView() ) { 3565 if ( incidence && mViewManager->currentView() ) {
3564 mViewManager->currentView()->clearSelection(); 3566 mViewManager->currentView()->clearSelection();
3565 } 3567 }
3566 processIncidenceSelection( incidence ); 3568 processIncidenceSelection( incidence );
3567} 3569}
3568 3570
3569void CalendarView::processIncidenceSelection( Incidence *incidence ) 3571void CalendarView::processIncidenceSelection( Incidence *incidence )
3570{ 3572{
3571 if ( incidence == mSelectedIncidence ) return; 3573 if ( incidence == mSelectedIncidence ) return;
3572 3574
3573 mSelectedIncidence = incidence; 3575 mSelectedIncidence = incidence;
3574 3576
3575 emit incidenceSelected( mSelectedIncidence ); 3577 emit incidenceSelected( mSelectedIncidence );
3576 3578
3577 if ( incidence && incidence->type() == "Event" ) { 3579 if ( incidence && incidence->type() == "Event" ) {
3578 Event *event = static_cast<Event *>( incidence ); 3580 Event *event = static_cast<Event *>( incidence );
3579 if ( event->organizer() == KOPrefs::instance()->email() ) { 3581 if ( event->organizer() == KOPrefs::instance()->email() ) {
3580 emit organizerEventsSelected( true ); 3582 emit organizerEventsSelected( true );
3581 } else { 3583 } else {
3582 emit organizerEventsSelected(false); 3584 emit organizerEventsSelected(false);
3583 } 3585 }
3584 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3586 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3585 KOPrefs::instance()->email() ) ) { 3587 KOPrefs::instance()->email() ) ) {
3586 emit groupEventsSelected( true ); 3588 emit groupEventsSelected( true );
3587 } else { 3589 } else {
3588 emit groupEventsSelected(false); 3590 emit groupEventsSelected(false);
3589 } 3591 }
3590 return; 3592 return;
3591 } else { 3593 } else {
3592 if ( incidence && incidence->type() == "Todo" ) { 3594 if ( incidence && incidence->type() == "Todo" ) {
3593 emit todoSelected( true ); 3595 emit todoSelected( true );
3594 Todo *event = static_cast<Todo *>( incidence ); 3596 Todo *event = static_cast<Todo *>( incidence );
3595 if ( event->organizer() == KOPrefs::instance()->email() ) { 3597 if ( event->organizer() == KOPrefs::instance()->email() ) {
3596 emit organizerEventsSelected( true ); 3598 emit organizerEventsSelected( true );
3597 } else { 3599 } else {
3598 emit organizerEventsSelected(false); 3600 emit organizerEventsSelected(false);
3599 } 3601 }
3600 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3602 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3601 KOPrefs::instance()->email() ) ) { 3603 KOPrefs::instance()->email() ) ) {
3602 emit groupEventsSelected( true ); 3604 emit groupEventsSelected( true );
3603 } else { 3605 } else {
3604 emit groupEventsSelected(false); 3606 emit groupEventsSelected(false);
3605 } 3607 }
3606 return; 3608 return;
3607 } else { 3609 } else {
3608 emit todoSelected( false ); 3610 emit todoSelected( false );
3609 emit organizerEventsSelected(false); 3611 emit organizerEventsSelected(false);
3610 emit groupEventsSelected(false); 3612 emit groupEventsSelected(false);
3611 } 3613 }
3612 return; 3614 return;
3613 } 3615 }
3614 3616
3615 /* if ( incidence && incidence->type() == "Todo" ) { 3617 /* if ( incidence && incidence->type() == "Todo" ) {
3616 emit todoSelected( true ); 3618 emit todoSelected( true );
3617 } else { 3619 } else {
3618 emit todoSelected( false ); 3620 emit todoSelected( false );
3619 }*/ 3621 }*/
3620} 3622}
3621 3623
3622 3624
3623void CalendarView::checkClipboard() 3625void CalendarView::checkClipboard()
3624{ 3626{
3625#ifndef KORG_NODND 3627#ifndef KORG_NODND
3626 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3628 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3627 emit pasteEnabled(true); 3629 emit pasteEnabled(true);
3628 } else { 3630 } else {
3629 emit pasteEnabled(false); 3631 emit pasteEnabled(false);
3630 } 3632 }
3631#endif 3633#endif
3632} 3634}
3633 3635
3634void CalendarView::showDates(const DateList &selectedDates) 3636void CalendarView::showDates(const DateList &selectedDates)
3635{ 3637{
3636 // kdDebug() << "CalendarView::selectDates()" << endl; 3638 // kdDebug() << "CalendarView::selectDates()" << endl;
3637 3639
3638 3640
3639 if ( !mBlockShowDates ) { 3641 if ( !mBlockShowDates ) {
3640 if ( mViewManager->currentView() ) { 3642 if ( mViewManager->currentView() ) {
3641 updateView( selectedDates.first(), selectedDates.last() ); 3643 updateView( selectedDates.first(), selectedDates.last() );
3642 } else { 3644 } else {
3643 mViewManager->showAgendaView(); 3645 mViewManager->showAgendaView();
3644 } 3646 }
3645 } 3647 }
3646 3648
3647 QDate date = selectedDates.first(); 3649 QDate date = selectedDates.first();
3648 if ( ! date.isValid() ) { 3650 if ( ! date.isValid() ) {
3649 topLevelWidget()->setCaption(""); 3651 topLevelWidget()->setCaption("");
3650 return; 3652 return;
3651 } 3653 }
3652 3654
3653 QString selDates; 3655 QString selDates;
3654 selDates = KGlobal::locale()->formatDate( date, true); 3656 selDates = KGlobal::locale()->formatDate( date, true);
3655 if (selectedDates.first() < selectedDates.last() ) 3657 if (selectedDates.first() < selectedDates.last() )
3656 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3658 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3657 else { 3659 else {
3658 QString addString; 3660 QString addString;
3659 if ( date == QDateTime::currentDateTime().date() ) 3661 if ( date == QDateTime::currentDateTime().date() )
3660 addString = i18n("Today"); 3662 addString = i18n("Today");
3661 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3663 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3662 addString = i18n("Tomorrow"); 3664 addString = i18n("Tomorrow");
3663 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3665 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3664 addString = i18n("Yesterday"); 3666 addString = i18n("Yesterday");
3665 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3667 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3666 addString = i18n("Day before yesterday"); 3668 addString = i18n("Day before yesterday");
3667 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3669 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3668 addString = i18n("Day after tomorrow"); 3670 addString = i18n("Day after tomorrow");
3669 if ( !addString.isEmpty() ) { 3671 if ( !addString.isEmpty() ) {
3670 topLevelWidget()->setCaption( addString+", " + selDates ); 3672 topLevelWidget()->setCaption( addString+", " + selDates );
3671 return; 3673 return;
3672 } 3674 }
3673 } 3675 }
3674 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3676 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3675 3677
3676} 3678}
3677 3679
3678QPtrList<CalFilter> CalendarView::filters() 3680QPtrList<CalFilter> CalendarView::filters()
3679{ 3681{
3680 return mFilters; 3682 return mFilters;
3681 3683
3682} 3684}
3683void CalendarView::editFilters() 3685void CalendarView::editFilters()
3684{ 3686{
3685 // kdDebug() << "CalendarView::editFilters()" << endl; 3687 // kdDebug() << "CalendarView::editFilters()" << endl;
3686 3688
3687 CalFilter *filter = mFilters.first(); 3689 CalFilter *filter = mFilters.first();
3688 while(filter) { 3690 while(filter) {
3689 kdDebug() << " Filter: " << filter->name() << endl; 3691 kdDebug() << " Filter: " << filter->name() << endl;
3690 filter = mFilters.next(); 3692 filter = mFilters.next();
3691 } 3693 }
3692 3694
3693 mDialogManager->showFilterEditDialog(&mFilters); 3695 mDialogManager->showFilterEditDialog(&mFilters);
3694} 3696}
3695void CalendarView::toggleFilter() 3697void CalendarView::toggleFilter()
3696{ 3698{
3697 showFilter(! mFilterView->isVisible()); 3699 showFilter(! mFilterView->isVisible());
3698} 3700}
3699 3701
3700KOFilterView *CalendarView::filterView() 3702KOFilterView *CalendarView::filterView()
3701{ 3703{
3702 return mFilterView; 3704 return mFilterView;
3703} 3705}
3704void CalendarView::selectFilter( int fil ) 3706void CalendarView::selectFilter( int fil )
3705{ 3707{
3706 mFilterView->setSelectedFilter( fil ); 3708 mFilterView->setSelectedFilter( fil );
3707} 3709}
3708void CalendarView::showFilter(bool visible) 3710void CalendarView::showFilter(bool visible)
3709{ 3711{
3710 if (visible) mFilterView->show(); 3712 if (visible) mFilterView->show();
3711 else mFilterView->hide(); 3713 else mFilterView->hide();
3712} 3714}
3713void CalendarView::toggleFilerEnabled( ) 3715void CalendarView::toggleFilerEnabled( )
3714{ 3716{
3715 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3717 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3716 if ( !mFilterView->filtersEnabled() ) 3718 if ( !mFilterView->filtersEnabled() )
3717 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3719 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3718 3720
3719} 3721}
3720void CalendarView::updateFilter() 3722void CalendarView::updateFilter()
3721{ 3723{
3722 CalFilter *filter = mFilterView->selectedFilter(); 3724 CalFilter *filter = mFilterView->selectedFilter();
3723 if (filter) { 3725 if (filter) {
3724 QString mess; 3726 QString mess;
3725 if (mFilterView->filtersEnabled()) { 3727 if (mFilterView->filtersEnabled()) {
3726 mess = i18n("Filter selected: ")+filter->name(); 3728 mess = i18n("Filter selected: ")+filter->name();
3727 filter->setEnabled(true); 3729 filter->setEnabled(true);
3728 } 3730 }
3729 else filter->setEnabled(false); 3731 else filter->setEnabled(false);
3730 mCalendar->setFilter(filter); 3732 mCalendar->setFilter(filter);
3731 updateView(); 3733 updateView();
3732 if ( !mess.isEmpty() ) 3734 if ( !mess.isEmpty() )
3733 topLevelWidget()->setCaption( mess ); 3735 topLevelWidget()->setCaption( mess );
3734 3736
3735 } 3737 }
3736} 3738}
3737 3739
3738void CalendarView::filterEdited() 3740void CalendarView::filterEdited()
3739{ 3741{
3740 mFilterView->updateFilters(); 3742 mFilterView->updateFilters();
3741 updateFilter(); 3743 updateFilter();
3742 writeSettings(); 3744 writeSettings();
3743} 3745}
3744 3746
3745 3747
3746void CalendarView::takeOverEvent() 3748void CalendarView::takeOverEvent()
3747{ 3749{
3748 Incidence *incidence = currentSelection(); 3750 Incidence *incidence = currentSelection();
3749 3751
3750 if (!incidence) return; 3752 if (!incidence) return;
3751 3753
3752 incidence->setOrganizer(KOPrefs::instance()->email()); 3754 incidence->setOrganizer(KOPrefs::instance()->email());
3753 incidence->recreate(); 3755 incidence->recreate();
3754 incidence->setReadOnly(false); 3756 incidence->setReadOnly(false);
3755 3757
3756 updateView(); 3758 updateView();
3757} 3759}
3758 3760
3759void CalendarView::takeOverCalendar() 3761void CalendarView::takeOverCalendar()
3760{ 3762{
3761 // TODO: Create Calendar::allIncidences() function and use it here 3763 // TODO: Create Calendar::allIncidences() function and use it here
3762 3764
3763 QPtrList<Event> events = mCalendar->events(); 3765 QPtrList<Event> events = mCalendar->events();
3764 for(uint i=0; i<events.count(); ++i) { 3766 for(uint i=0; i<events.count(); ++i) {
3765 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3767 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3766 events.at(i)->recreate(); 3768 events.at(i)->recreate();
3767 events.at(i)->setReadOnly(false); 3769 events.at(i)->setReadOnly(false);
3768 } 3770 }
3769 3771
3770 QPtrList<Todo> todos = mCalendar->todos(); 3772 QPtrList<Todo> todos = mCalendar->todos();
3771 for(uint i=0; i<todos.count(); ++i) { 3773 for(uint i=0; i<todos.count(); ++i) {
3772 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3774 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3773 todos.at(i)->recreate(); 3775 todos.at(i)->recreate();
3774 todos.at(i)->setReadOnly(false); 3776 todos.at(i)->setReadOnly(false);
3775 } 3777 }
3776 3778
3777 QPtrList<Journal> journals = mCalendar->journals(); 3779 QPtrList<Journal> journals = mCalendar->journals();
3778 for(uint i=0; i<journals.count(); ++i) { 3780 for(uint i=0; i<journals.count(); ++i) {
3779 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3781 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3780 journals.at(i)->recreate(); 3782 journals.at(i)->recreate();
3781 journals.at(i)->setReadOnly(false); 3783 journals.at(i)->setReadOnly(false);
3782 } 3784 }
3783 3785
3784 updateView(); 3786 updateView();
3785} 3787}
3786 3788
3787void CalendarView::showIntro() 3789void CalendarView::showIntro()
3788{ 3790{
3789 kdDebug() << "To be implemented." << endl; 3791 kdDebug() << "To be implemented." << endl;
3790} 3792}
3791 3793
3792QWidgetStack *CalendarView::viewStack() 3794QWidgetStack *CalendarView::viewStack()
3793{ 3795{
3794 return mRightFrame; 3796 return mRightFrame;
3795} 3797}
3796 3798
3797QWidget *CalendarView::leftFrame() 3799QWidget *CalendarView::leftFrame()
3798{ 3800{
3799 return ( QWidget *)mLeftFrame; 3801 return ( QWidget *)mLeftFrame;
3800} 3802}
3801 3803
3802DateNavigator *CalendarView::dateNavigator() 3804DateNavigator *CalendarView::dateNavigator()
3803{ 3805{
3804 return mNavigator; 3806 return mNavigator;
3805} 3807}
3806 3808
3807KDateNavigator* CalendarView::dateNavigatorWidget() 3809KDateNavigator* CalendarView::dateNavigatorWidget()
3808{ 3810{
3809 return mDateNavigator->navigatorView(); 3811 return mDateNavigator->navigatorView();
3810} 3812}
3811void CalendarView::toggleDateNavigatorWidget() 3813void CalendarView::toggleDateNavigatorWidget()
3812{ 3814{
3813 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3815 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3814 3816
3815 if (!KOPrefs::instance()->mShowDateNavigator ) 3817 if (!KOPrefs::instance()->mShowDateNavigator )
3816 mDateNavigator->hide(); 3818 mDateNavigator->hide();
3817 else 3819 else
3818 mDateNavigator->show(); 3820 mDateNavigator->show();
3819} 3821}
3820void CalendarView::addView(KOrg::BaseView *view) 3822void CalendarView::addView(KOrg::BaseView *view)
3821{ 3823{
3822 mViewManager->addView(view); 3824 mViewManager->addView(view);
3823} 3825}
3824 3826
3825void CalendarView::showView(KOrg::BaseView *view) 3827void CalendarView::showView(KOrg::BaseView *view)
3826{ 3828{
3827 mViewManager->showView(view, mLeftFrame->isVisible()); 3829 mViewManager->showView(view, mLeftFrame->isVisible());
3828} 3830}
3829 3831
3830Incidence *CalendarView::currentSelection() 3832Incidence *CalendarView::currentSelection()
3831{ 3833{
3832 return mViewManager->currentSelection(); 3834 return mViewManager->currentSelection();
3833} 3835}
3834void CalendarView::toggleAllDaySize() 3836void CalendarView::toggleAllDaySize()
3835{ 3837{
3836 /* 3838 /*
3837 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3839 if ( KOPrefs::instance()->mAllDaySize > 47 )
3838 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3840 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3839 else 3841 else
3840 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3842 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3841 */ 3843 */
3842 viewManager()->agendaView()->toggleAllDay(); 3844 viewManager()->agendaView()->toggleAllDay();
3843} 3845}
3844void CalendarView::toggleExpand() 3846void CalendarView::toggleExpand()
3845{ 3847{
3846 // if ( mLeftFrame->isHidden() ) { 3848 // if ( mLeftFrame->isHidden() ) {
3847 // mLeftFrame->show(); 3849 // mLeftFrame->show();
3848 // emit calendarViewExpanded( false ); 3850 // emit calendarViewExpanded( false );
3849 // } else { 3851 // } else {
3850 // mLeftFrame->hide(); 3852 // mLeftFrame->hide();
3851 // emit calendarViewExpanded( true ); 3853 // emit calendarViewExpanded( true );
3852 // } 3854 // }
3853 //qDebug(" CalendarView::toggleExpand()"); 3855 //qDebug(" CalendarView::toggleExpand()");
3854 globalFlagBlockAgenda = 1; 3856 globalFlagBlockAgenda = 1;
3855 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3857 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3856 globalFlagBlockAgenda = 5; 3858 globalFlagBlockAgenda = 5;
3857 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3859 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3858 //mViewManager->showView( 0, true ); 3860 //mViewManager->showView( 0, true );
3859} 3861}
3860 3862
3861void CalendarView::calendarModified( bool modified, Calendar * ) 3863void CalendarView::calendarModified( bool modified, Calendar * )
3862{ 3864{
3863 setModified( modified ); 3865 setModified( modified );
3864} 3866}
3865 3867
3866Todo *CalendarView::selectedTodo() 3868Todo *CalendarView::selectedTodo()
3867{ 3869{
3868 Incidence *incidence = currentSelection(); 3870 Incidence *incidence = currentSelection();
3869 if ( incidence && incidence->type() == "Todo" ) { 3871 if ( incidence && incidence->type() == "Todo" ) {
3870 return static_cast<Todo *>( incidence ); 3872 return static_cast<Todo *>( incidence );
3871 } 3873 }
3872 3874
3873 incidence = mTodoList->selectedIncidences().first(); 3875 incidence = mTodoList->selectedIncidences().first();
3874 if ( incidence && incidence->type() == "Todo" ) { 3876 if ( incidence && incidence->type() == "Todo" ) {
3875 return static_cast<Todo *>( incidence ); 3877 return static_cast<Todo *>( incidence );
3876 } 3878 }
3877 3879
3878 return 0; 3880 return 0;
3879} 3881}
3880 3882
3881void CalendarView::dialogClosing(Incidence *in) 3883void CalendarView::dialogClosing(Incidence *in)
3882{ 3884{
3883 // mDialogList.remove(in); 3885 // mDialogList.remove(in);
3884} 3886}
3885 3887
3886void CalendarView::showIncidence() 3888void CalendarView::showIncidence()
3887{ 3889{
3888 mViewerCallerIsSearchDialog = false; 3890 mViewerCallerIsSearchDialog = false;
3889 Incidence *incidence = currentSelection(); 3891 Incidence *incidence = currentSelection();
3890 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3892 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3891 if ( incidence ) { 3893 if ( incidence ) {
3892 ShowIncidenceVisitor v; 3894 ShowIncidenceVisitor v;
3893 v.act( incidence, this ); 3895 v.act( incidence, this );
3894 } 3896 }
3895} 3897}
3896void CalendarView::editIncidenceDescription() 3898void CalendarView::editIncidenceDescription()
3897{ 3899{
3898 mFlagEditDescription = true; 3900 mFlagEditDescription = true;
3899 editIncidence(); 3901 editIncidence();
3900 mFlagEditDescription = false; 3902 mFlagEditDescription = false;
3901} 3903}
3902void CalendarView::editIncidence() 3904void CalendarView::editIncidence()
3903{ 3905{
3904 // qDebug("editIncidence() "); 3906 // qDebug("editIncidence() ");
3905 Incidence *incidence = currentSelection(); 3907 Incidence *incidence = currentSelection();
3906 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3908 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3907 if ( incidence ) { 3909 if ( incidence ) {
3908 EditIncidenceVisitor v; 3910 EditIncidenceVisitor v;
3909 v.act( incidence, this ); 3911 v.act( incidence, this );
3910 } 3912 }
3911} 3913}
3912 3914
3913void CalendarView::deleteIncidence() 3915void CalendarView::deleteIncidence()
3914{ 3916{
3915 Incidence *incidence = currentSelection(); 3917 Incidence *incidence = currentSelection();
3916 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3918 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3917 if ( incidence ) { 3919 if ( incidence ) {
3918 deleteIncidence(incidence); 3920 deleteIncidence(incidence);
3919 } 3921 }
3920} 3922}
3921 3923
3922void CalendarView::showIncidence(Incidence *incidence) 3924void CalendarView::showIncidence(Incidence *incidence)
3923{ 3925{
3924 mViewerCallerIsSearchDialog = false; 3926 mViewerCallerIsSearchDialog = false;
3925 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 3927 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3926 if ( sender() && mDialogManager->getSearchDialog() ) { 3928 if ( sender() && mDialogManager->getSearchDialog() ) {
3927 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 3929 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3928 mViewerCallerIsSearchDialog = true; 3930 mViewerCallerIsSearchDialog = true;
3929 } 3931 }
3930 } 3932 }
3931 if ( incidence ) { 3933 if ( incidence ) {
3932 ShowIncidenceVisitor v; 3934 ShowIncidenceVisitor v;
3933 v.act( incidence, this ); 3935 v.act( incidence, this );
3934 } 3936 }
3935} 3937}
3936 3938
3937void CalendarView::editIncidence(Incidence *incidence) 3939void CalendarView::editIncidence(Incidence *incidence)
3938{ 3940{
3939 if ( incidence ) { 3941 if ( incidence ) {
3940 3942
3941 EditIncidenceVisitor v; 3943 EditIncidenceVisitor v;
3942 v.act( incidence, this ); 3944 v.act( incidence, this );
3943 3945
3944 } 3946 }
3945} 3947}
3946 3948
3947void CalendarView::deleteIncidence(Incidence *incidence) 3949void CalendarView::deleteIncidence(Incidence *incidence)
3948{ 3950{
3949 //qDebug(" CalendarView::deleteIncidence "); 3951 //qDebug(" CalendarView::deleteIncidence ");
3950 if ( incidence ) { 3952 if ( incidence ) {
3951 DeleteIncidenceVisitor v; 3953 DeleteIncidenceVisitor v;
3952 v.act( incidence, this ); 3954 v.act( incidence, this );
3953 } 3955 }
3954} 3956}
3955 3957
3956 3958
3957void CalendarView::lookForOutgoingMessages() 3959void CalendarView::lookForOutgoingMessages()
3958{ 3960{
3959 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3961 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3960 ogd->loadMessages(); 3962 ogd->loadMessages();
3961} 3963}
3962 3964
3963void CalendarView::lookForIncomingMessages() 3965void CalendarView::lookForIncomingMessages()
3964{ 3966{
3965 IncomingDialog *icd = mDialogManager->incomingDialog(); 3967 IncomingDialog *icd = mDialogManager->incomingDialog();
3966 icd->retrieve(); 3968 icd->retrieve();
3967} 3969}
3968 3970
3969bool CalendarView::removeCompletedSubTodos( Todo* t ) 3971bool CalendarView::removeCompletedSubTodos( Todo* t )
3970{ 3972{
3971 bool deleteTodo = true; 3973 bool deleteTodo = true;
3972 QPtrList<Incidence> subTodos; 3974 QPtrList<Incidence> subTodos;
3973 Incidence *aTodo; 3975 Incidence *aTodo;
3974 subTodos = t->relations(); 3976 subTodos = t->relations();
3975 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3977 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3976 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3978 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3977 deleteTodo = false; 3979 deleteTodo = false;
3978 } 3980 }
3979 if ( deleteTodo ) { 3981 if ( deleteTodo ) {
3980 if ( t->isCompleted() && !t->doesRecur()) { 3982 if ( t->isCompleted() && !t->doesRecur()) {
3981 checkExternalId( t ); 3983 checkExternalId( t );
3982 mCalendar->deleteTodo( t ); 3984 mCalendar->deleteTodo( t );
3983 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3985 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3984 } 3986 }
3985 else 3987 else
3986 deleteTodo = false; 3988 deleteTodo = false;
3987 } 3989 }
3988 return deleteTodo; 3990 return deleteTodo;
3989 3991
3990} 3992}
3991void CalendarView::purgeCompleted() 3993void CalendarView::purgeCompleted()
3992{ 3994{
3993 int result = KMessageBox::warningContinueCancel(this, 3995 int result = KMessageBox::warningContinueCancel(this,
3994 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 3996 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
3995 3997
3996 if (result == KMessageBox::Continue) { 3998 if (result == KMessageBox::Continue) {
3997 3999
3998 QPtrList<Todo> todoCal; 4000 QPtrList<Todo> todoCal;
3999 QPtrList<Todo> rootTodos; 4001 QPtrList<Todo> rootTodos;
4000 //QPtrList<Incidence> rel; 4002 //QPtrList<Incidence> rel;
4001 Todo *aTodo;//, *rTodo; 4003 Todo *aTodo;//, *rTodo;
4002 Incidence *rIncidence; 4004 Incidence *rIncidence;
4003 bool childDelete = false; 4005 bool childDelete = false;
4004 bool deletedOne = true; 4006 bool deletedOne = true;
4005 todoCal = calendar()->todos(); 4007 todoCal = calendar()->todos();
4006 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4008 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4007 if ( !aTodo->relatedTo() ) 4009 if ( !aTodo->relatedTo() )
4008 rootTodos.append( aTodo ); 4010 rootTodos.append( aTodo );
4009 } 4011 }
4010 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4012 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4011 removeCompletedSubTodos( aTodo ); 4013 removeCompletedSubTodos( aTodo );
4012 } 4014 }
4013 4015
4014 updateView(); 4016 updateView();
4015 } 4017 }
4016} 4018}
4017 4019
4018void CalendarView::slotCalendarChanged() 4020void CalendarView::slotCalendarChanged()
4019{ 4021{
4020 ; 4022 ;
4021} 4023}
4022 4024
4023void CalendarView::keyPressEvent ( QKeyEvent *e) 4025void CalendarView::keyPressEvent ( QKeyEvent *e)
4024{ 4026{
4025 //qDebug(" alendarView::keyPressEvent "); 4027 //qDebug(" alendarView::keyPressEvent ");
4026 e->ignore(); 4028 e->ignore();
4027} 4029}
4028 4030
4029 4031
4030bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4032bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4031{ 4033{
4032 // mSyncManager = manager; 4034 // mSyncManager = manager;
4033 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4035 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4034 qDebug("KO: SyncKDE request detected!"); 4036 qDebug("KO: SyncKDE request detected!");
4035 } 4037 }
4036 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4038 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4037 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4039 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4038 return syncCalendar( filename, mode ); 4040 return syncCalendar( filename, mode );
4039} 4041}
4040bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4042bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4041{ 4043{
4042 //mSyncManager = manager; 4044 //mSyncManager = manager;
4043 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4045 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4044 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4046 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4045 if ( resource == "sharp" ) 4047 if ( resource == "sharp" )
4046 syncExternal( 0 ); 4048 syncExternal( 0 );
4047 if ( resource == "phone" ) 4049 if ( resource == "phone" )
4048 syncExternal( 1 ); 4050 syncExternal( 1 );
4049 // pending setmodified 4051 // pending setmodified
4050 return true; 4052 return true;
4051} 4053}
4052void CalendarView::setSyncManager(KSyncManager* manager) 4054void CalendarView::setSyncManager(KSyncManager* manager)
4053{ 4055{
4054 mSyncManager = manager; 4056 mSyncManager = manager;
4055} 4057}
4056 4058
4057void CalendarView::removeSyncInfo( QString syncProfile) 4059void CalendarView::removeSyncInfo( QString syncProfile)
4058{ 4060{
4059 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4061 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4060 mCalendar->removeSyncInfo( syncProfile ); 4062 mCalendar->removeSyncInfo( syncProfile );
4061 4063
4062} 4064}
4063 4065
4064void CalendarView::undo_delete() 4066void CalendarView::undo_delete()
4065{ 4067{
4066 //qDebug("undo_delete() "); 4068 //qDebug("undo_delete() ");
4067 Incidence* undo = mCalendar->undoIncidence(); 4069 Incidence* undo = mCalendar->undoIncidence();
4068 if ( !undo ) { 4070 if ( !undo ) {
4069 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4071 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4070 i18n("KO/Pi")); 4072 i18n("KO/Pi"));
4071 return; 4073 return;
4072 } 4074 }
4073 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4075 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4074 i18n("\nAre you sure you want\nto restore this?"), 4076 i18n("\nAre you sure you want\nto restore this?"),
4075 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4077 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4076 mCalendar->undoDeleteIncidence(); 4078 mCalendar->undoDeleteIncidence();
4077 updateView(); 4079 updateView();
4078 } 4080 }
4079} 4081}
4080 4082
4081void CalendarView::slotViewerClosed() 4083void CalendarView::slotViewerClosed()
4082{ 4084{
4083 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4085 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4084} 4086}
4085 4087
4086void CalendarView::resetFocus() 4088void CalendarView::resetFocus()
4087{ 4089{
4088 if ( mViewerCallerIsSearchDialog ) { 4090 if ( mViewerCallerIsSearchDialog ) {
4089 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4091 if ( mDialogManager->getSearchDialog()->isVisible() ){
4090 mDialogManager->getSearchDialog()->raise(); 4092 mDialogManager->getSearchDialog()->raise();
4091 mDialogManager->getSearchDialog()->setActiveWindow(); 4093 mDialogManager->getSearchDialog()->setActiveWindow();
4092 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4094 mDialogManager->getSearchDialog()->listview()->resetFocus();
4093 } else 4095 } else
4094 mViewerCallerIsSearchDialog = false; 4096 mViewerCallerIsSearchDialog = false;
4095 } 4097 }
4096 if ( !mViewerCallerIsSearchDialog ) { 4098 if ( !mViewerCallerIsSearchDialog ) {
4097 //mViewManager->currentView()->setFocus(); 4099 //mViewManager->currentView()->setFocus();
4098 //qDebug("sssssssssssssssset focus "); 4100 //qDebug("sssssssssssssssset focus ");
4099 topLevelWidget()->raise(); 4101 topLevelWidget()->raise();
4100 setActiveWindow(); 4102 setActiveWindow();
4101 //setFocus(); 4103 //setFocus();
4102 } 4104 }
4103 mViewerCallerIsSearchDialog = false; 4105 mViewerCallerIsSearchDialog = false;
4104} 4106}
4105 4107
4106void CalendarView::showNextAlarms() 4108void CalendarView::showNextAlarms()
4107{ 4109{
4108 QString message; 4110 QString message;
4109 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4111 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4110 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4112 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4111 QString sum = mCalendar->nextSummary(); 4113 QString sum = mCalendar->nextSummary();
4112 QDateTime nextA = mNextAlarmDateTime; 4114 QDateTime nextA = mNextAlarmDateTime;
4113 QDateTime cur = QDateTime::currentDateTime(); 4115 QDateTime cur = QDateTime::currentDateTime();
4114 int secs = cur.secsTo( nextA ); 4116 int secs = cur.secsTo( nextA );
4115 int min = secs /60; 4117 int min = secs /60;
4116 int hours = min /60; 4118 int hours = min /60;
4117 min = min % 60; 4119 min = min % 60;
4118 int days = hours /24; 4120 int days = hours /24;
4119 hours = hours % 24; 4121 hours = hours % 24;
4120 4122
4121 //message = i18n("The next alarm is in:\n"); 4123 //message = i18n("The next alarm is in:\n");
4122 if ( days > 1 ) 4124 if ( days > 1 )
4123 message += i18n("%1 days\n").arg( days ); 4125 message += i18n("%1 days\n").arg( days );
4124 else if ( days == 1 ) 4126 else if ( days == 1 )
4125 message += i18n("1 day\n"); 4127 message += i18n("1 day\n");
4126 if ( hours > 1 ) 4128 if ( hours > 1 )
4127 message += i18n("%1 hours\n").arg( hours ); 4129 message += i18n("%1 hours\n").arg( hours );
4128 else if ( hours == 1 ) 4130 else if ( hours == 1 )
4129 message += i18n("1 hour\n"); 4131 message += i18n("1 hour\n");
4130 if ( min > 1 ) 4132 if ( min > 1 )
4131 message += i18n("%1 minutes\n").arg( min ); 4133 message += i18n("%1 minutes\n").arg( min );
4132 else if ( min == 1 ) 4134 else if ( min == 1 )
4133 message += i18n("1 minute\n"); 4135 message += i18n("1 minute\n");
4134 if ( message.isEmpty() ) 4136 if ( message.isEmpty() )
4135 message = i18n("The next alarm is in\nless than one minute!"); 4137 message = i18n("The next alarm is in\nless than one minute!");
4136 else 4138 else
4137 message = i18n("The next alarm is in:\n") + message; 4139 message = i18n("The next alarm is in:\n") + message;
4138 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4140 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4139 } else { 4141 } else {
4140 message = i18n("There is no next alarm."); 4142 message = i18n("There is no next alarm.");
4141 4143
4142 } 4144 }
4143#ifdef DESKTOP_VERSION 4145#ifdef DESKTOP_VERSION
4144 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4146 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4145 message += i18n("\nThe internal alarm notification is disabled!\n"); 4147 message += i18n("\nThe internal alarm notification is disabled!\n");
4146 message += i18n("Enable it in the settings menu, TAB alarm."); 4148 message += i18n("Enable it in the settings menu, TAB alarm.");
4147 } 4149 }
4148 4150
4149#endif 4151#endif
4150 KMessageBox::information( this, message); 4152 KMessageBox::information( this, message);
4151} 4153}
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
index d88c300..32ad10a 100644
--- a/korganizer/korganizer.pro
+++ b/korganizer/korganizer.pro
@@ -1,208 +1,214 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3 TARGET = kopi 3 TARGET = kopi
4OBJECTS_DIR = _obj/ 4OBJECTS_DIR = _obj/
5MOC_DIR = _moc 5MOC_DIR = _moc
6DESTDIR= ../bin 6DESTDIR= ../bin
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim 10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim
11#../qtcompat 11#../qtcompat
12DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL 12DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
14#KORG_NOPRINTER KORG_NOKABC KORG_NODND 14#KORG_NOPRINTER KORG_NOKABC KORG_NODND
15DEFINES += KORG_NOLVALTERNATION 15DEFINES += KORG_NOLVALTERNATION
16DEFINES += DESKTOP_VERSION 16DEFINES += DESKTOP_VERSION
17unix : { 17unix : {
18staticlib: { 18staticlib: {
19LIBS += ../bin/libmicrokabc_qtopia.a 19LIBS += ../bin/libmicrokabc_qtopia.a
20LIBS += ../bin/libmicrokabc_file.a 20LIBS += ../bin/libmicrokabc_file.a
21LIBS += ../bin/libmicrokabc_dir.a 21LIBS += ../bin/libmicrokabc_dir.a
22LIBS += ../bin/libmicrokdepim.a 22LIBS += ../bin/libmicrokdepim.a
23LIBS += ../bin/libmicrokcal.a 23LIBS += ../bin/libmicrokcal.a
24LIBS += ../bin/libmicrokabc.a 24LIBS += ../bin/libmicrokabc.a
25LIBS += ../bin/libmicrokde.a 25LIBS += ../bin/libmicrokde.a
26LIBS += ../bin/libmicrokabc_qtopia.a 26LIBS += ../bin/libmicrokabc_qtopia.a
27LIBS += ../bin/libmicrokabc_file.a 27LIBS += ../bin/libmicrokabc_file.a
28LIBS += ../bin/libmicrokabc_dir.a 28LIBS += ../bin/libmicrokabc_dir.a
29LIBS += ../bin/libmicrokdepim.a 29LIBS += ../bin/libmicrokdepim.a
30LIBS += ../bin/libmicrokcal.a 30LIBS += ../bin/libmicrokcal.a
31LIBS += ../bin/libmicrokabc.a 31LIBS += ../bin/libmicrokabc.a
32LIBS += ../bin/libmicrokde.a 32LIBS += ../bin/libmicrokde.a
33LIBS += ../libical/lib/libical.a 33LIBS += ../libical/lib/libical.a
34LIBS += ../libical/lib/libicalss.a 34LIBS += ../libical/lib/libicalss.a
35} else { 35} else {
36LIBS += ../bin/libmicrokdepim.so 36LIBS += ../bin/libmicrokdepim.so
37LIBS += ../bin/libmicrokcal.so 37LIBS += ../bin/libmicrokcal.so
38LIBS += ../bin/libmicrokde.so 38LIBS += ../bin/libmicrokde.so
39LIBS += ../bin/libmicrokabc.so 39LIBS += ../bin/libmicrokabc.so
40#LIBS += -lbluetooth 40#LIBS += -lbluetooth
41#LIBS += -lsdp 41#LIBS += -lsdp
42 42
43#LIBS += -lldap 43#LIBS += -lldap
44} 44}
45OBJECTS_DIR = obj/unix 45OBJECTS_DIR = obj/unix
46MOC_DIR = moc/unix 46MOC_DIR = moc/unix
47} 47}
48win32: { 48win32: {
49RC_FILE = winicons.rc 49RC_FILE = winicons.rc
50DEFINES += _WIN32_ 50DEFINES += _WIN32_
51LIBS += ../bin/microkdepim.lib 51LIBS += ../bin/microkdepim.lib
52LIBS += ../bin/microkcal.lib 52LIBS += ../bin/microkcal.lib
53LIBS += ../bin/microkde.lib 53LIBS += ../bin/microkde.lib
54LIBS += ../bin/microkabc.lib 54LIBS += ../bin/microkabc.lib
55LIBS += ../libical/lib/ical.lib 55LIBS += ../libical/lib/ical.lib
56LIBS += ../libical/lib/icalss.lib 56LIBS += ../libical/lib/icalss.lib
57#LIBS += atls.lib 57#LIBS += atls.lib
58QMAKE_LINK += /NODEFAULTLIB:LIBC 58QMAKE_LINK += /NODEFAULTLIB:LIBC
59#QMAKE_LINK += /NODEFAULTLIB:MSVCRT 59QMAKE_LINK += /NODEFAULTLIB:MSVCRT
60#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib 60QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
61OBJECTS_DIR = obj/win 61OBJECTS_DIR = obj/win
62MOC_DIR = moc/win 62MOC_DIR = moc/win
63#olimport section 63#olimport section
64#blabla: { 64#blabla: {
65debug: {
66LIBS += mfc71ud.lib
67}
68release: {
65LIBS += mfc71u.lib 69LIBS += mfc71u.lib
70}
66DEFINES += _OL_IMPORT_ 71DEFINES += _OL_IMPORT_
67 72
68HEADERS += ../outport/msoutl9.h \ 73HEADERS += ../outport/msoutl9.h \
69 koimportoldialog.h 74 koimportoldialog.h
75
70SOURCES += ../outport/msoutl9.cpp \ 76SOURCES += ../outport/msoutl9.cpp \
71 koimportoldialog.cpp 77 koimportoldialog.cpp
72#} 78#}
73#olimport section end 79#olimport section end
74 80
75} 81}
76 82
77 83
78INTERFACES = kofilterview_base.ui 84INTERFACES = kofilterview_base.ui
79#filteredit_base.ui 85#filteredit_base.ui
80 86
81# kdateedit.h \ 87# kdateedit.h \
82 88
83HEADERS += datenavigatorcontainer.h \ 89HEADERS += datenavigatorcontainer.h \
84 filteredit_base.h \ 90 filteredit_base.h \
85 alarmclient.h \ 91 alarmclient.h \
86 calendarview.h \ 92 calendarview.h \
87 customlistviewitem.h \ 93 customlistviewitem.h \
88 datenavigator.h \ 94 datenavigator.h \
89 docprefs.h \ 95 docprefs.h \
90 filtereditdialog.h \ 96 filtereditdialog.h \
91 incomingdialog.h \ 97 incomingdialog.h \
92 incomingdialog_base.h \ 98 incomingdialog_base.h \
93 interfaces/korganizer/baseview.h \ 99 interfaces/korganizer/baseview.h \
94 interfaces/korganizer/calendarviewbase.h \ 100 interfaces/korganizer/calendarviewbase.h \
95 journalentry.h \ 101 journalentry.h \
96 kdatenavigator.h \ 102 kdatenavigator.h \
97 koagenda.h \ 103 koagenda.h \
98 koagendaitem.h \ 104 koagendaitem.h \
99 koagendaview.h \ 105 koagendaview.h \
100 kocounterdialog.h \ 106 kocounterdialog.h \
101 kodaymatrix.h \ 107 kodaymatrix.h \
102 kodialogmanager.h \ 108 kodialogmanager.h \
103 koeditordetails.h \ 109 koeditordetails.h \
104 koeditorgeneral.h \ 110 koeditorgeneral.h \
105 koeditorgeneralevent.h \ 111 koeditorgeneralevent.h \
106 koeditorgeneraltodo.h \ 112 koeditorgeneraltodo.h \
107 koeditorrecurrence.h \ 113 koeditorrecurrence.h \
108 koeventeditor.h \ 114 koeventeditor.h \
109 koeventpopupmenu.h \ 115 koeventpopupmenu.h \
110 koeventview.h \ 116 koeventview.h \
111 koeventviewer.h \ 117 koeventviewer.h \
112 koeventviewerdialog.h \ 118 koeventviewerdialog.h \
113 kofilterview.h \ 119 kofilterview.h \
114 koglobals.h \ 120 koglobals.h \
115 koincidenceeditor.h \ 121 koincidenceeditor.h \
116 kojournalview.h \ 122 kojournalview.h \
117 kolistview.h \ 123 kolistview.h \
118 kolocationbox.h \ 124 kolocationbox.h \
119 komonthview.h \ 125 komonthview.h \
120 koprefs.h \ 126 koprefs.h \
121 koprefsdialog.h \ 127 koprefsdialog.h \
122 kotimespanview.h \ 128 kotimespanview.h \
123 kotodoeditor.h \ 129 kotodoeditor.h \
124 kotodoview.h \ 130 kotodoview.h \
125 kotodoviewitem.h \ 131 kotodoviewitem.h \
126 koviewmanager.h \ 132 koviewmanager.h \
127 kowhatsnextview.h \ 133 kowhatsnextview.h \
128 ktimeedit.h \ 134 ktimeedit.h \
129 lineview.h \ 135 lineview.h \
130 mainwindow.h \ 136 mainwindow.h \
131 navigatorbar.h \ 137 navigatorbar.h \
132 outgoingdialog.h \ 138 outgoingdialog.h \
133 outgoingdialog_base.h \ 139 outgoingdialog_base.h \
134 publishdialog.h \ 140 publishdialog.h \
135 publishdialog_base.h \ 141 publishdialog_base.h \
136 savetemplatedialog.h \ 142 savetemplatedialog.h \
137 searchdialog.h \ 143 searchdialog.h \
138 statusdialog.h \ 144 statusdialog.h \
139 timeline.h \ 145 timeline.h \
140 timespanview.h \ 146 timespanview.h \
141 version.h \ 147 version.h \
142 ../kalarmd/alarmdialog.h \ 148 ../kalarmd/alarmdialog.h \
143 149
144 150
145SOURCES += datenavigatorcontainer.cpp \ 151SOURCES += datenavigatorcontainer.cpp \
146filteredit_base.cpp \ 152filteredit_base.cpp \
147 calendarview.cpp \ 153 calendarview.cpp \
148 datenavigator.cpp \ 154 datenavigator.cpp \
149 docprefs.cpp \ 155 docprefs.cpp \
150 filtereditdialog.cpp \ 156 filtereditdialog.cpp \
151 incomingdialog.cpp \ 157 incomingdialog.cpp \
152 incomingdialog_base.cpp \ 158 incomingdialog_base.cpp \
153 journalentry.cpp \ 159 journalentry.cpp \
154 kdatenavigator.cpp \ 160 kdatenavigator.cpp \
155 koagenda.cpp \ 161 koagenda.cpp \
156 koagendaitem.cpp \ 162 koagendaitem.cpp \
157 koagendaview.cpp \ 163 koagendaview.cpp \
158 kocounterdialog.cpp \ 164 kocounterdialog.cpp \
159 kodaymatrix.cpp \ 165 kodaymatrix.cpp \
160 kodialogmanager.cpp \ 166 kodialogmanager.cpp \
161 koeditordetails.cpp \ 167 koeditordetails.cpp \
162 koeditorgeneral.cpp \ 168 koeditorgeneral.cpp \
163 koeditorgeneralevent.cpp \ 169 koeditorgeneralevent.cpp \
164 koeditorgeneraltodo.cpp \ 170 koeditorgeneraltodo.cpp \
165 koeditorrecurrence.cpp \ 171 koeditorrecurrence.cpp \
166 koeventeditor.cpp \ 172 koeventeditor.cpp \
167 koeventpopupmenu.cpp \ 173 koeventpopupmenu.cpp \
168 koeventview.cpp \ 174 koeventview.cpp \
169 koeventviewer.cpp \ 175 koeventviewer.cpp \
170 koeventviewerdialog.cpp \ 176 koeventviewerdialog.cpp \
171 kofilterview.cpp \ 177 kofilterview.cpp \
172 koglobals.cpp \ 178 koglobals.cpp \
173 koincidenceeditor.cpp \ 179 koincidenceeditor.cpp \
174 kojournalview.cpp \ 180 kojournalview.cpp \
175 kolistview.cpp \ 181 kolistview.cpp \
176 kolocationbox.cpp \ 182 kolocationbox.cpp \
177 komonthview.cpp \ 183 komonthview.cpp \
178 koprefs.cpp \ 184 koprefs.cpp \
179 koprefsdialog.cpp \ 185 koprefsdialog.cpp \
180 kotimespanview.cpp \ 186 kotimespanview.cpp \
181 kotodoeditor.cpp \ 187 kotodoeditor.cpp \
182 kotodoview.cpp \ 188 kotodoview.cpp \
183 kotodoviewitem.cpp \ 189 kotodoviewitem.cpp \
184 koviewmanager.cpp \ 190 koviewmanager.cpp \
185 kowhatsnextview.cpp \ 191 kowhatsnextview.cpp \
186 ktimeedit.cpp \ 192 ktimeedit.cpp \
187 lineview.cpp \ 193 lineview.cpp \
188 main.cpp \ 194 main.cpp \
189 mainwindow.cpp \ 195 mainwindow.cpp \
190 navigatorbar.cpp \ 196 navigatorbar.cpp \
191 outgoingdialog.cpp \ 197 outgoingdialog.cpp \
192 outgoingdialog_base.cpp \ 198 outgoingdialog_base.cpp \
193 publishdialog.cpp \ 199 publishdialog.cpp \
194 publishdialog_base.cpp \ 200 publishdialog_base.cpp \
195 savetemplatedialog.cpp \ 201 savetemplatedialog.cpp \
196 searchdialog.cpp \ 202 searchdialog.cpp \
197 statusdialog.cpp \ 203 statusdialog.cpp \
198 timeline.cpp \ 204 timeline.cpp \
199 timespanview.cpp \ 205 timespanview.cpp \
200 ../kalarmd/alarmdialog.cpp 206 ../kalarmd/alarmdialog.cpp
201 207
202HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h 208HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h
203INTERFACES += calprintdayconfig_base.ui \ 209INTERFACES += calprintdayconfig_base.ui \
204 calprintmonthconfig_base.ui \ 210 calprintmonthconfig_base.ui \
205 calprinttodoconfig_base.ui \ 211 calprinttodoconfig_base.ui \
206 calprintweekconfig_base.ui 212 calprintweekconfig_base.ui
207SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp 213SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp
208 214
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index d368513..1ffc34a 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -1,264 +1,265 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOTODOVIEW_H 23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H 24#define KOTODOVIEW_H
25 25
26#include <qfont.h> 26#include <qfont.h>
27#include <qfontmetrics.h> 27#include <qfontmetrics.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qlistbox.h> 31#include <qlistbox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qlistview.h> 35#include <qlistview.h>
36#include <klistview.h> 36#include <klistview.h>
37 37
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40 40
41#include <korganizer/baseview.h> 41#include <korganizer/baseview.h>
42 42
43#include "kotodoviewitem.h" 43#include "kotodoviewitem.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "koglobals.h" 45#include "koglobals.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47 47
48class QDragEnterEvent; 48class QDragEnterEvent;
49class QDragMoveEvent; 49class QDragMoveEvent;
50class QDragLeaveEvent; 50class QDragLeaveEvent;
51class QDropEvent; 51class QDropEvent;
52class KOTodoViewWhatsThis; 52class KOTodoViewWhatsThis;
53 53
54class DocPrefs; 54class DocPrefs;
55 55
56class KOTodoListView : public KListView 56class KOTodoListView : public KListView
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59 public: 59 public:
60 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 60 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
61 virtual ~KOTodoListView() {} 61 virtual ~KOTodoListView() {}
62 62
63 signals: 63 signals:
64 void paintNeeded(); 64 void paintNeeded();
65 void todoDropped(Todo *, int); 65 void todoDropped(Todo *, int);
66 void double_Clicked(QListViewItem *item); 66 void double_Clicked(QListViewItem *item);
67 void reparentTodoSignal( Todo *,Todo * ); 67 void reparentTodoSignal( Todo *,Todo * );
68 void unparentTodoSignal(Todo *); 68 void unparentTodoSignal(Todo *);
69 void deleteTodo( Todo * ); 69 void deleteTodo( Todo * );
70 protected: 70 protected:
71 void wheelEvent (QWheelEvent *e); 71 void wheelEvent (QWheelEvent *e);
72 void contentsDragEnterEvent(QDragEnterEvent *); 72 void contentsDragEnterEvent(QDragEnterEvent *);
73 void contentsDragMoveEvent(QDragMoveEvent *); 73 void contentsDragMoveEvent(QDragMoveEvent *);
74 void contentsDragLeaveEvent(QDragLeaveEvent *); 74 void contentsDragLeaveEvent(QDragLeaveEvent *);
75 void contentsDropEvent(QDropEvent *); 75 void contentsDropEvent(QDropEvent *);
76 76
77 void contentsMousePressEvent(QMouseEvent *); 77 void contentsMousePressEvent(QMouseEvent *);
78 void contentsMouseMoveEvent(QMouseEvent *); 78 void contentsMouseMoveEvent(QMouseEvent *);
79 void contentsMouseReleaseEvent(QMouseEvent *); 79 void contentsMouseReleaseEvent(QMouseEvent *);
80 void contentsMouseDoubleClickEvent(QMouseEvent *); 80 void contentsMouseDoubleClickEvent(QMouseEvent *);
81 81
82 private: 82 private:
83 void paintEvent(QPaintEvent * pevent); 83 void paintEvent(QPaintEvent * pevent);
84 bool internalDrop; 84 bool internalDrop;
85 QString mName; 85 QString mName;
86 Calendar *mCalendar; 86 Calendar *mCalendar;
87 QPoint mPressPos; 87 QPoint mPressPos;
88 bool mMousePressed; 88 bool mMousePressed;
89 QListViewItem *mOldCurrent; 89 QListViewItem *mOldCurrent;
90 bool mFlagKeyPressed; 90 bool mFlagKeyPressed;
91 void keyPressEvent ( QKeyEvent * ) ; 91 void keyPressEvent ( QKeyEvent * ) ;
92 void keyReleaseEvent ( QKeyEvent * ) ; 92 void keyReleaseEvent ( QKeyEvent * ) ;
93}; 93};
94 94
95 95
96/** 96/**
97 This is the line-edit on top of the todoview for fast addition of new todos 97 This is the line-edit on top of the todoview for fast addition of new todos
98*/ 98*/
99class KOQuickTodo : public QLineEdit 99class KOQuickTodo : public QLineEdit
100{ 100{
101 public: 101 public:
102 KOQuickTodo(QWidget *parent=0); 102 KOQuickTodo(QWidget *parent=0);
103 protected: 103 protected:
104 void focusInEvent(QFocusEvent *ev); 104 void focusInEvent(QFocusEvent *ev);
105 void focusOutEvent(QFocusEvent *ev); 105 void focusOutEvent(QFocusEvent *ev);
106}; 106};
107 107
108 108
109/** 109/**
110 This class provides a multi-column list view of todo events. 110 This class provides a multi-column list view of todo events.
111 111
112 @short multi-column list view of todo events. 112 @short multi-column list view of todo events.
113 @author Cornelius Schumacher <schumacher@kde.org> 113 @author Cornelius Schumacher <schumacher@kde.org>
114*/ 114*/
115class KOTodoView : public KOrg::BaseView 115class KOTodoView : public KOrg::BaseView
116{ 116{
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); 119 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 );
120 ~KOTodoView(); 120 ~KOTodoView();
121 121
122 QPtrList<Incidence> selectedIncidences(); 122 QPtrList<Incidence> selectedIncidences();
123 QPtrList<Todo> selectedTodos(); 123 QPtrList<Todo> selectedTodos();
124 124
125 DateList selectedDates() 125 DateList selectedDates()
126 {DateList q; 126 {DateList q;
127 return q;} 127 return q;}
128 128
129 /** Return number of shown dates. TodoView does not show dates, */ 129 /** Return number of shown dates. TodoView does not show dates, */
130 int currentDateCount() { return 0; } 130 int currentDateCount() { return 0; }
131 131
132 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); 132 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td);
133 133
134 void setDocumentId( const QString & ); 134 void setDocumentId( const QString & );
135 135
136 void saveLayout(KConfig *config, const QString &group) const; 136 void saveLayout(KConfig *config, const QString &group) const;
137 void restoreLayout(KConfig *config, const QString &group); 137 void restoreLayout(KConfig *config, const QString &group);
138 /** Create a popup menu to set categories */ 138 /** Create a popup menu to set categories */
139 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); 139 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem);
140 void setNavigator( DateNavigator* nav ) {mNavigator = nav;} 140 void setNavigator( DateNavigator* nav ) {mNavigator = nav;}
141 QString getWhatsThisText(QPoint p); 141 QString getWhatsThisText(QPoint p);
142 void clearList() {mTodoListView->clear(); }
142 143
143 public slots: 144 public slots:
144 void updateView(); 145 void updateView();
145 void updateConfig(); 146 void updateConfig();
146 147
147 void changeEventDisplay(Event *, int); 148 void changeEventDisplay(Event *, int);
148 149
149 void showDates(const QDate &start, const QDate &end); 150 void showDates(const QDate &start, const QDate &end);
150 void showEvents(QPtrList<Event> eventList); 151 void showEvents(QPtrList<Event> eventList);
151 152
152 void clearSelection(); 153 void clearSelection();
153 void jumpToDate (); 154 void jumpToDate ();
154 155
155 void editItem(QListViewItem *item); 156 void editItem(QListViewItem *item);
156 void showItem(QListViewItem *item,const QPoint &,int); 157 void showItem(QListViewItem *item,const QPoint &,int);
157 void popupMenu(QListViewItem *item,const QPoint &,int); 158 void popupMenu(QListViewItem *item,const QPoint &,int);
158 void newTodo(); 159 void newTodo();
159 void newSubTodo(); 160 void newSubTodo();
160 void unparentTodo(); 161 void unparentTodo();
161 void reparentTodo(); 162 void reparentTodo();
162 void showTodo(); 163 void showTodo();
163 void editTodo(); 164 void editTodo();
164 void cloneTodo(); 165 void cloneTodo();
165 void cancelTodo(); 166 void cancelTodo();
166 void moveTodo(); 167 void moveTodo();
167 void beamTodo(); 168 void beamTodo();
168 void deleteTodo(); 169 void deleteTodo();
169 170
170 void setNewPriority(int); 171 void setNewPriority(int);
171 void setNewPercentage(int); 172 void setNewPercentage(int);
172 void changedCategories(int); 173 void changedCategories(int);
173 174
174 void setAllOpen(); 175 void setAllOpen();
175 void setAllClose(); 176 void setAllClose();
176 void setAllFlat(); 177 void setAllFlat();
177 void displayAllFlat(); 178 void displayAllFlat();
178 179
179 void purgeCompleted(); 180 void purgeCompleted();
180 void toggleCompleted(); 181 void toggleCompleted();
181 void toggleRunning(); 182 void toggleRunning();
182 void toggleQuickTodo(); 183 void toggleQuickTodo();
183 void updateTodo( Todo *, int ); 184 void updateTodo( Todo *, int );
184 185
185 void itemClicked(QListViewItem *); 186 void itemClicked(QListViewItem *);
186 void itemStateChanged(QListViewItem *); 187 void itemStateChanged(QListViewItem *);
187 void modified(bool); 188 void modified(bool);
188 void itemDoubleClicked(QListViewItem *item); 189 void itemDoubleClicked(QListViewItem *item);
189 190
190 signals: 191 signals:
191 void newTodoSignal(); 192 void newTodoSignal();
192 void newSubTodoSignal(Todo *); 193 void newSubTodoSignal(Todo *);
193 void unparentTodoSignal(Todo *); 194 void unparentTodoSignal(Todo *);
194 void reparentTodoSignal( Todo *,Todo * ); 195 void reparentTodoSignal( Todo *,Todo * );
195 void showTodoSignal(Todo *); 196 void showTodoSignal(Todo *);
196 197
197 void editTodoSignal(Todo *); 198 void editTodoSignal(Todo *);
198 void deleteTodoSignal(Todo *); 199 void deleteTodoSignal(Todo *);
199 void todoModifiedSignal (Todo *, int); 200 void todoModifiedSignal (Todo *, int);
200 201
201 void isModified(bool); 202 void isModified(bool);
202 void cloneTodoSignal( Incidence * ); 203 void cloneTodoSignal( Incidence * );
203 void cancelTodoSignal( Incidence * ); 204 void cancelTodoSignal( Incidence * );
204 void moveTodoSignal( Incidence * ); 205 void moveTodoSignal( Incidence * );
205 void beamTodoSignal( Incidence * ); 206 void beamTodoSignal( Incidence * );
206 void purgeCompletedSignal(); 207 void purgeCompletedSignal();
207 208
208 protected slots: 209 protected slots:
209 void toggleRunningItem(); 210 void toggleRunningItem();
210 void paintNeeded(); 211 void paintNeeded();
211 void processSelectionChange(); 212 void processSelectionChange();
212 void addQuickTodo(); 213 void addQuickTodo();
213 void setTodoModified( Todo* ); 214 void setTodoModified( Todo* );
214 void todoModified(Todo *, int ); 215 void todoModified(Todo *, int );
215 216
216 private: 217 private:
217 /* 218 /*
218 * the TodoEditor approach is rather unscaling in the long 219 * the TodoEditor approach is rather unscaling in the long
219 * run. 220 * run.
220 * Korganizer keeps it in memory and we need to update 221 * Korganizer keeps it in memory and we need to update
221 * 1. make KOTodoViewItem a QObject again? 222 * 1. make KOTodoViewItem a QObject again?
222 * 2. add a public method for setting one todo modified? 223 * 2. add a public method for setting one todo modified?
223 * 3. add a private method for setting a todo modified + friend here? 224 * 3. add a private method for setting a todo modified + friend here?
224 * -- zecke 2002-07-08 225 * -- zecke 2002-07-08
225 */ 226 */
226 KOTodoViewWhatsThis* mKOTodoViewWhatsThis; 227 KOTodoViewWhatsThis* mKOTodoViewWhatsThis;
227 friend class KOTodoListView; 228 friend class KOTodoListView;
228 void paintEvent(QPaintEvent * pevent); 229 void paintEvent(QPaintEvent * pevent);
229 bool mPendingUpdateBeforeRepaint; 230 bool mPendingUpdateBeforeRepaint;
230 friend class KOTodoViewItem; 231 friend class KOTodoViewItem;
231 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); 232 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
232 void restoreItemState( QListViewItem * ); 233 void restoreItemState( QListViewItem * );
233 234
234 bool checkTodo( Todo * ); 235 bool checkTodo( Todo * );
235 bool isFlatDisplay; 236 bool isFlatDisplay;
236 void setOpen( QListViewItem*, bool setOpen); 237 void setOpen( QListViewItem*, bool setOpen);
237 KOTodoListView *mTodoListView; 238 KOTodoListView *mTodoListView;
238 QPopupMenu *mItemPopupMenu; 239 QPopupMenu *mItemPopupMenu;
239 QPopupMenu *mPopupMenu; 240 QPopupMenu *mPopupMenu;
240 QPopupMenu *mPriorityPopupMenu; 241 QPopupMenu *mPriorityPopupMenu;
241 QPopupMenu *mPercentageCompletedPopupMenu; 242 QPopupMenu *mPercentageCompletedPopupMenu;
242 QPopupMenu *mCategoryPopupMenu; 243 QPopupMenu *mCategoryPopupMenu;
243 244
244 QMap<int, int> mPercentage; 245 QMap<int, int> mPercentage;
245 QMap<int, int> mPriority; 246 QMap<int, int> mPriority;
246 QMap<int, QString> mCategory; 247 QMap<int, QString> mCategory;
247 KOTodoViewItem *mActiveItem; 248 KOTodoViewItem *mActiveItem;
248 249
249 QMap<Todo *,KOTodoViewItem *> mTodoMap; 250 QMap<Todo *,KOTodoViewItem *> mTodoMap;
250 QString mName; 251 QString mName;
251 252
252 DocPrefs *mDocPrefs; 253 DocPrefs *mDocPrefs;
253 QString mCurrentDoc; 254 QString mCurrentDoc;
254 KOQuickTodo *mQuickAdd; 255 KOQuickTodo *mQuickAdd;
255 bool mBlockUpdate; 256 bool mBlockUpdate;
256 void keyPressEvent ( QKeyEvent * ) ; 257 void keyPressEvent ( QKeyEvent * ) ;
257 KOTodoViewItem * pendingSubtodo; 258 KOTodoViewItem * pendingSubtodo;
258 DateNavigator* mNavigator; 259 DateNavigator* mNavigator;
259 void storeCurrentItem(); 260 void storeCurrentItem();
260 void resetCurrentItem(); 261 void resetCurrentItem();
261 Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; 262 Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove;
262}; 263};
263 264
264#endif 265#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 2e5a943..fb4de37 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,835 +1,838 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 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 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 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 flagResetViewChangeDate = 0; 64 flagResetViewChangeDate = 0;
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 91 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 92 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 93 showMonthView();
94 else 94 else
95 showMonthViewWeek(); 95 showMonthViewWeek();
96 } 96 }
97 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
101 else { 101 else {
102 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
105 showAgendaView(); 105 showAgendaView();
106 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 109#endif
110 } 110 }
111} 111}
112 112
113void KOViewManager::showDateView( int view, QDate date) 113void KOViewManager::showDateView( int view, QDate date)
114{ 114{
115 static int lastMode = 0; 115 static int lastMode = 0;
116 static int lastCount = 0; 116 static int lastCount = 0;
117 static bool lastNDMode = false; 117 static bool lastNDMode = false;
118 static QDate lastDate; 118 static QDate lastDate;
119 //qDebug("date %d %s", view, date.toString().latin1()); 119 //qDebug("date %d %s", view, date.toString().latin1());
120 120
121 if (view != 9) 121 if (view != 9)
122 lastMode = 0; 122 lastMode = 0;
123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
124 bool savemFlagShowNextxDays = mFlagShowNextxDays; 124 bool savemFlagShowNextxDays = mFlagShowNextxDays;
125 mFlagShowNextxDays = false; 125 mFlagShowNextxDays = false;
126 if ( view == 3 ) { 126 if ( view == 3 ) {
127 //mCurrentAgendaView = 1 ; 127 //mCurrentAgendaView = 1 ;
128 lastDate = mMainView->dateNavigator()->selectedDates().first(); 128 lastDate = mMainView->dateNavigator()->selectedDates().first();
129 lastCount = mMainView->dateNavigator()->selectedDates().count(); 129 lastCount = mMainView->dateNavigator()->selectedDates().count();
130 lastNDMode = savemFlagShowNextxDays; 130 lastNDMode = savemFlagShowNextxDays;
131 mMainView->dateNavigator()->selectDate( date ); 131 mMainView->dateNavigator()->selectDate( date );
132 lastMode = 1; 132 lastMode = 1;
133 mCurrentAgendaView = 1 ; 133 mCurrentAgendaView = 1 ;
134 } else if (view == 4 ) { 134 } else if (view == 4 ) {
135 mCurrentAgendaView = 7 ; 135 mCurrentAgendaView = 7 ;
136 mMainView->dateNavigator()->selectDates( date, 7 ); 136 mMainView->dateNavigator()->selectDates( date, 7 );
137 } else if (view == 5 ) { 137 } else if (view == 5 ) {
138 mCurrentAgendaView = 14 ; 138 mCurrentAgendaView = 14 ;
139 mMainView->dateNavigator()->selectDates( date, 14); 139 mMainView->dateNavigator()->selectDates( date, 14);
140 } else if (view == 6 ) { 140 } else if (view == 6 ) {
141 resetDateSilent( date,1); 141 resetDateSilent( date,1);
142 showMonthView(); 142 showMonthView();
143 } else if (view == 7 ) { 143 } else if (view == 7 ) {
144 mMainView->dateNavigator()->selectDate( date ); 144 mMainView->dateNavigator()->selectDate( date );
145 showJournalView(); 145 showJournalView();
146 } else if (view == 8 ) { 146 } else if (view == 8 ) {
147 globalFlagBlockAgenda = 1; 147 globalFlagBlockAgenda = 1;
148 if ( mCurrentAgendaView != 3 ) 148 if ( mCurrentAgendaView != 3 )
149 mCurrentAgendaView = -1; 149 mCurrentAgendaView = -1;
150 showAgendaView(KOPrefs::instance()->mFullViewMonth); 150 showAgendaView(KOPrefs::instance()->mFullViewMonth);
151 globalFlagBlockAgenda = 2; 151 globalFlagBlockAgenda = 2;
152 mMainView->dateNavigator()->selectDates( date , 152 mMainView->dateNavigator()->selectDates( date ,
153 KOPrefs::instance()->mNextXDays ); 153 KOPrefs::instance()->mNextXDays );
154 mFlagShowNextxDays = true; 154 mFlagShowNextxDays = true;
155 mCurrentAgendaView = 3 ; 155 mCurrentAgendaView = 3 ;
156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
157 if ( lastMode ) { 157 if ( lastMode ) {
158 mCurrentAgendaView = lastCount ; 158 mCurrentAgendaView = lastCount ;
159 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 159 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
160 mFlagShowNextxDays = lastNDMode; 160 mFlagShowNextxDays = lastNDMode;
161 if ( mFlagShowNextxDays ) { 161 if ( mFlagShowNextxDays ) {
162 mCurrentAgendaView = 3 ; 162 mCurrentAgendaView = 3 ;
163 } 163 }
164 } else 164 } else
165 showWeekView(); 165 showWeekView();
166 } else if (view == 10) { 166 } else if (view == 10) {
167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
168 } 168 }
169} 169}
170 170
171 171
172 172
173void KOViewManager::writeSettings(KConfig *config) 173void KOViewManager::writeSettings(KConfig *config)
174{ 174{
175 config->setGroup("General"); 175 config->setGroup("General");
176 176
177 QString view; 177 QString view;
178 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 178 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
179 else if (mCurrentView == mMonthView) view = "Month"; 179 else if (mCurrentView == mMonthView) view = "Month";
180 else if (mCurrentView == mListView) view = "List"; 180 else if (mCurrentView == mListView) view = "List";
181 else if (mCurrentView == mJournalView) view = "Journal"; 181 else if (mCurrentView == mJournalView) view = "Journal";
182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
183 else if (mCurrentView == mTodoView) view = "Todo"; 183 else if (mCurrentView == mTodoView) view = "Todo";
184 else view = "Agenda"; 184 else view = "Agenda";
185 185
186 config->writeEntry("Current View",view); 186 config->writeEntry("Current View",view);
187 187
188 if (mAgendaView) { 188 if (mAgendaView) {
189 mAgendaView->writeSettings(config); 189 mAgendaView->writeSettings(config);
190 } 190 }
191 if (mTimeSpanView) { 191 if (mTimeSpanView) {
192 mTimeSpanView->writeSettings(config); 192 mTimeSpanView->writeSettings(config);
193 } 193 }
194 if (mListView) { 194 if (mListView) {
195 mListView->writeSettings(config); 195 mListView->writeSettings(config);
196 } 196 }
197 if (mTodoView) { 197 if (mTodoView) {
198 mTodoView->saveLayout(config,"Todo View"); 198 mTodoView->saveLayout(config,"Todo View");
199 } 199 }
200} 200}
201void KOViewManager::showNextView() 201void KOViewManager::showNextView()
202{ 202{
203 static int selecteddatescount = 0; 203 static int selecteddatescount = 0;
204 static QDate selecteddate = QDate ( 2000, 1, 1 ); 204 static QDate selecteddate = QDate ( 2000, 1, 1 );
205 static QDate baseCycleDate = QDate ( 2000, 1, 1 ); 205 static QDate baseCycleDate = QDate ( 2000, 1, 1 );
206 int newCount = mMainView->dateNavigator()->selectedDates().count(); 206 int newCount = mMainView->dateNavigator()->selectedDates().count();
207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { 207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) {
208 flagResetViewChangeDate = 1; 208 flagResetViewChangeDate = 1;
209 } 209 }
210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) 210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() )
211 flagResetViewChangeDate = 1; 211 flagResetViewChangeDate = 1;
212 if ( flagResetViewChangeDate > 0 ) { 212 if ( flagResetViewChangeDate > 0 ) {
213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); 213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first();
214 //qDebug("newCycle "); 214 //qDebug("newCycle ");
215 } 215 }
216 if (mCurrentView == mWhatsNextView) goto NEXT_X; 216 if (mCurrentView == mWhatsNextView) goto NEXT_X;
217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; 217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL;
218 if (mCurrentView == mJournalView ) goto DAY_1; 218 if (mCurrentView == mJournalView ) goto DAY_1;
219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; 219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5;
220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; 220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7;
221 if (mCurrentView == mAgendaView ) goto DAY_6; 221 if (mCurrentView == mAgendaView ) goto DAY_6;
222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; 222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH;
223 if (mCurrentView == mMonthView ) goto LIST; 223 if (mCurrentView == mMonthView ) goto LIST;
224 if (mCurrentView == mListView ) goto TODO; 224 if (mCurrentView == mListView ) goto TODO;
225 // if (mCurrentView == mTodoView ) goto NEXT; 225 // if (mCurrentView == mTodoView ) goto NEXT;
226 NEXT: 226 NEXT:
227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} 227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;}
228 NEXT_X: 228 NEXT_X:
229 if ( KOPrefs::instance()->mShowIconNextDays ) { 229 if ( KOPrefs::instance()->mShowIconNextDays ) {
230 showNextXView(); 230 showNextXView();
231 goto ENTE ; 231 goto ENTE ;
232 } 232 }
233 JOURNAL: 233 JOURNAL:
234 if ( KOPrefs::instance()->mShowIconJournal ) { 234 if ( KOPrefs::instance()->mShowIconJournal ) {
235 resetDateSilent( baseCycleDate , 1 ); 235 resetDateSilent( baseCycleDate , 1 );
236 showJournalView() ;goto ENTE ;} 236 showJournalView() ;goto ENTE ;}
237 DAY_1: 237 DAY_1:
238 if ( KOPrefs::instance()->mShowIconDay1 ) { 238 if ( KOPrefs::instance()->mShowIconDay1 ) {
239 resetDateSilent( baseCycleDate , 2 ); 239 resetDateSilent( baseCycleDate , 2 );
240 showDayView() ;goto ENTE ;} 240 showDayView() ;goto ENTE ;}
241 DAY_5: 241 DAY_5:
242 if ( KOPrefs::instance()->mShowIconDay5 ) { 242 if ( KOPrefs::instance()->mShowIconDay5 ) {
243 resetDateSilent( baseCycleDate , 2 ); 243 resetDateSilent( baseCycleDate , 2 );
244 showWorkWeekView() ;goto ENTE ;} 244 showWorkWeekView() ;goto ENTE ;}
245 DAY_7: 245 DAY_7:
246 if ( KOPrefs::instance()->mShowIconDay7 ) { 246 if ( KOPrefs::instance()->mShowIconDay7 ) {
247 resetDateSilent( baseCycleDate , 2 ); 247 resetDateSilent( baseCycleDate , 2 );
248 showWeekView();goto ENTE ;} 248 showWeekView();goto ENTE ;}
249 DAY_6: 249 DAY_6:
250 if ( KOPrefs::instance()->mShowIconDay6 ) { 250 if ( KOPrefs::instance()->mShowIconDay6 ) {
251 resetDateSilent( baseCycleDate , 2 ); 251 resetDateSilent( baseCycleDate , 2 );
252 showMonthViewWeek();goto ENTE ;} 252 showMonthViewWeek();goto ENTE ;}
253 MONTH: 253 MONTH:
254 if ( KOPrefs::instance()->mShowIconMonth ) { 254 if ( KOPrefs::instance()->mShowIconMonth ) {
255 resetDateSilent( baseCycleDate , 2 ); 255 resetDateSilent( baseCycleDate , 2 );
256 showMonthView();goto ENTE ;} 256 showMonthView();goto ENTE ;}
257 LIST: 257 LIST:
258 if ( KOPrefs::instance()->mShowIconList ) { 258 if ( KOPrefs::instance()->mShowIconList ) {
259 resetDateSilent( baseCycleDate , 2 ); 259 resetDateSilent( baseCycleDate , 2 );
260 showListView() ;goto ENTE ;} 260 showListView() ;goto ENTE ;}
261 TODO: 261 TODO:
262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} 263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;}
264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} 264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;}
265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} 265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;}
266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} 266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;}
267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} 267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;}
268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} 268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;}
269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} 269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;}
270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} 270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;}
271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} 271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;}
272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
273 ENTE: 273 ENTE:
274 flagResetViewChangeDate = 0; 274 flagResetViewChangeDate = 0;
275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); 275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count();
276 selecteddate = mMainView->dateNavigator()->selectedDates().first(); 276 selecteddate = mMainView->dateNavigator()->selectedDates().first();
277 277
278} 278}
279void KOViewManager::resetDateSilent( QDate date , int days ) 279void KOViewManager::resetDateSilent( QDate date , int days )
280{ 280{
281 mMainView->dateNavigator()->blockSignals( true ); 281 mMainView->dateNavigator()->blockSignals( true );
282 mMainView->dateNavigator()->selectDates( date , days ); 282 mMainView->dateNavigator()->selectDates( date , days );
283 mMainView->dateNavigator()->blockSignals( false ); 283 mMainView->dateNavigator()->blockSignals( false );
284} 284}
285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
286{ 286{
287 if ( flagResetViewChangeDate < 10 ) 287 if ( flagResetViewChangeDate < 10 )
288 ++flagResetViewChangeDate; 288 ++flagResetViewChangeDate;
289 //mFlagShowNextxDays = false; 289 //mFlagShowNextxDays = false;
290 //if(view == mCurrentView) return; 290 //if(view == mCurrentView) return;
291 if ( view == 0 ) { 291 if ( view == 0 ) {
292 view = mCurrentView; 292 view = mCurrentView;
293 if ( view == 0 ) 293 if ( view == 0 )
294 return; 294 return;
295 } 295 }
296 bool callupdate = !(view == mCurrentView); 296 bool callupdate = !(view == mCurrentView);
297 bool full = fullScreen; 297 bool full = fullScreen;
298 if(view == mCurrentView && view != mWhatsNextView ) { 298 if(view == mCurrentView && view != mWhatsNextView ) {
299 if ( mCurrentAgendaView < 0 ) 299 if ( mCurrentAgendaView < 0 )
300 return; 300 return;
301 if ( view != mMonthView ) 301 if ( view != mMonthView )
302 full = mMainView->leftFrame()->isVisible(); 302 full = mMainView->leftFrame()->isVisible();
303 } else { 303 } else {
304 if ( view == mMonthView && mMonthView) 304 if ( view == mMonthView && mMonthView)
305 ;//mMonthView->skipResize = true ; 305 ;//mMonthView->skipResize = true ;
306 mCurrentView = view; 306 mCurrentView = view;
307 // bool full = fullScreen; 307 // bool full = fullScreen;
308 bool isFull = !mMainView->leftFrame()->isVisible(); 308 bool isFull = !mMainView->leftFrame()->isVisible();
309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
310 full = true; 310 full = true;
311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
312 full = false; 312 full = false;
313 } 313 }
314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
315 //raiseCurrentView( full ); 315 //raiseCurrentView( full );
316 mMainView->processIncidenceSelection( 0 ); 316 mMainView->processIncidenceSelection( 0 );
317 //mMainView->updateView(); 317 //mMainView->updateView();
318 raiseCurrentView( full, callupdate ); 318 raiseCurrentView( full, callupdate );
319 mMainView->adaptNavigationUnits(); 319 mMainView->adaptNavigationUnits();
320 mMainView->updateUnmanagedViews(); 320 mMainView->updateUnmanagedViews();
321} 321}
322 322
323void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 323void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
324{ 324{
325 mCurrentAgendaView = 0; 325 mCurrentAgendaView = 0;
326 if ( fullScreen ) { 326 if ( fullScreen ) {
327 mMainView->leftFrame()->hide(); 327 mMainView->leftFrame()->hide();
328 } else { 328 } else {
329 mMainView->leftFrame()->show(); 329 mMainView->leftFrame()->show();
330 } 330 }
331 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 331 //if ( mCurrentView == mMonthView ) qApp->processEvents();
332 emit signalFullScreen( !fullScreen ); 332 emit signalFullScreen( !fullScreen );
333 if ( callUpdateView ) 333 if ( callUpdateView )
334 mMainView->updateView(); 334 mMainView->updateView();
335 335
336 if ( globalFlagBlockAgenda == 5 ) { 336 if ( globalFlagBlockAgenda == 5 ) {
337 globalFlagBlockAgenda = 4; 337 globalFlagBlockAgenda = 4;
338 globalFlagBlockAgendaItemPaint = 1; 338 globalFlagBlockAgendaItemPaint = 1;
339 } 339 }
340 mMainView->viewStack()->raiseWidget(mCurrentView); 340 mMainView->viewStack()->raiseWidget(mCurrentView);
341 if ( globalFlagBlockAgenda == 4 ) { 341 if ( globalFlagBlockAgenda == 4 ) {
342 if ( mCurrentView == mAgendaView ) { 342 if ( mCurrentView == mAgendaView ) {
343 //globalFlagBlockAgenda =1 ; 343 //globalFlagBlockAgenda =1 ;
344 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 344 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
345 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 345 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
346 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 346 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
347 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 347 mAgendaView->setStartHour( QTime::currentTime ().hour() );
348 qApp->processEvents(); 348 qApp->processEvents();
349 //qDebug("qApp->processEvents() "); 349 //qDebug("qApp->processEvents() ");
350 globalFlagBlockAgenda = 0; 350 globalFlagBlockAgenda = 0;
351 mAgendaView->repaintAgenda(); 351 mAgendaView->repaintAgenda();
352 352
353 } 353 }
354 globalFlagBlockAgenda = 0; 354 globalFlagBlockAgenda = 0;
355 } 355 }
356 emit signalAgendaView( mCurrentView == mAgendaView ); 356 emit signalAgendaView( mCurrentView == mAgendaView );
357 //qDebug("raiseCurrentView ende "); 357 //qDebug("raiseCurrentView ende ");
358 358
359} 359}
360 360
361void KOViewManager::updateView() 361void KOViewManager::updateView()
362{ 362{
363 // qDebug("KOViewManager::updateView() "); 363 // qDebug("KOViewManager::updateView() ");
364 // if we are updating mTodoView, we get endless recursion 364 // if we are updating mTodoView, we get endless recursion
365 if ( mTodoView == mCurrentView ) 365 if ( mTodoView == mCurrentView )
366 return; 366 return;
367 if ( mCurrentView ) mCurrentView->updateView(); 367 if ( mCurrentView ) mCurrentView->updateView();
368 368
369} 369}
370 370
371void KOViewManager::updateView(const QDate &start, const QDate &end) 371void KOViewManager::updateView(const QDate &start, const QDate &end)
372{ 372{
373 // kdDebug() << "KOViewManager::updateView()" << endl; 373 // kdDebug() << "KOViewManager::updateView()" << endl;
374 374
375 if (mCurrentView) mCurrentView->showDates(start, end); 375 if (mCurrentView) mCurrentView->showDates(start, end);
376 376
377 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 377 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
378} 378}
379 379
380 380
381void KOViewManager::updateWNview() 381void KOViewManager::updateWNview()
382{ 382{
383 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 383 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
384 mWhatsNextView->updateView(); 384 mWhatsNextView->updateView();
385 if ( mCurrentView == mMonthView && mMonthView ) 385 if ( mCurrentView == mMonthView && mMonthView )
386 mMonthView->updateView(); 386 mMonthView->updateView();
387 387
388} 388}
389void KOViewManager::showWhatsNextView() 389void KOViewManager::showWhatsNextView()
390{ 390{
391 if (!mWhatsNextView) { 391 if (!mWhatsNextView) {
392 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 392 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
393 "KOViewManager::WhatsNextView"); 393 "KOViewManager::WhatsNextView");
394 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 394 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
395 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 395 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
396 addView(mWhatsNextView); 396 addView(mWhatsNextView);
397 connect(this, SIGNAL( printWNV() ), 397 connect(this, SIGNAL( printWNV() ),
398 mWhatsNextView, SLOT( printMe() ) ); 398 mWhatsNextView, SLOT( printMe() ) );
399 } 399 }
400 globalFlagBlockAgenda = 1; 400 globalFlagBlockAgenda = 1;
401 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 401 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
402 showView(mWhatsNextView, true ); 402 showView(mWhatsNextView, true );
403 //mWhatsNextView->updateView(); 403 //mWhatsNextView->updateView();
404 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 404 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
405} 405}
406 406
407void KOViewManager::slotprintWNV() 407void KOViewManager::slotprintWNV()
408{ 408{
409 if (!mWhatsNextView) 409 if (!mWhatsNextView)
410 showWhatsNextView(); 410 showWhatsNextView();
411 emit printWNV(); 411 emit printWNV();
412 412
413} 413}
414void KOViewManager::showListView() 414void KOViewManager::showListView()
415{ 415{
416 if (!mListView) { 416 if (!mListView) {
417 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 417 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
418 addView(mListView); 418 addView(mListView);
419 419
420 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 420 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
421 mMainView, SLOT(showIncidence(Incidence *))); 421 mMainView, SLOT(showIncidence(Incidence *)));
422 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 422 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
423 mMainView, SLOT(editIncidence(Incidence *))); 423 mMainView, SLOT(editIncidence(Incidence *)));
424 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 424 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
425 mMainView, SLOT(deleteIncidence(Incidence *))); 425 mMainView, SLOT(deleteIncidence(Incidence *)));
426 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 426 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
427 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 427 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
428 connect( mListView, SIGNAL( signalNewEvent() ), 428 connect( mListView, SIGNAL( signalNewEvent() ),
429 mMainView, SLOT( newEvent() ) ); 429 mMainView, SLOT( newEvent() ) );
430 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 430 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
431 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 431 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
432 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 432 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
433 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 433 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
434 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 434 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
435 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 435 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
436 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 436 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
437 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 437 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
438 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 438 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
439 } 439 }
440 // bool temp = mFlagShowNextxDays; 440 // bool temp = mFlagShowNextxDays;
441 //globalFlagBlockPainting = true; 441 //globalFlagBlockPainting = true;
442 globalFlagBlockAgenda = 1; 442 globalFlagBlockAgenda = 1;
443 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 443 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
444 mMainView->setBlockShowDates( true ); 444 mMainView->setBlockShowDates( true );
445 mMainView->dateNavigator()->selectMonth(); 445 mMainView->dateNavigator()->selectMonth();
446 mMainView->setBlockShowDates( false ); 446 mMainView->setBlockShowDates( false );
447 } 447 }
448 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 448 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
449 showView(mListView, KOPrefs::instance()->mFullViewTodo); 449 showView(mListView, KOPrefs::instance()->mFullViewTodo);
450 //mFlagShowNextxDays = temp; 450 //mFlagShowNextxDays = temp;
451 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 451 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
452} 452}
453 453
454void KOViewManager::showAgendaView( bool fullScreen ) 454void KOViewManager::showAgendaView( bool fullScreen )
455{ 455{
456 456
457 mMainView->dialogManager()->hideSearchDialog(); 457 mMainView->dialogManager()->hideSearchDialog();
458 // qDebug("KOViewManager::showAgendaView "); 458 // qDebug("KOViewManager::showAgendaView ");
459 bool full; 459 bool full;
460 full = fullScreen; 460 full = fullScreen;
461 if (!mAgendaView) { 461 if (!mAgendaView) {
462 full = false; 462 full = false;
463 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 463 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
464 addView(mAgendaView); 464 addView(mAgendaView);
465#ifndef DESKTOP_VERSION 465#ifndef DESKTOP_VERSION
466 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 466 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
467#endif 467#endif
468 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 468 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
469 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 469 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
470 470
471 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 471 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
472 472
473 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 473 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
474 474
475 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 475 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
476 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 476 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
477 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 477 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
478 mMainView, SLOT(newEvent(QDateTime))); 478 mMainView, SLOT(newEvent(QDateTime)));
479 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 479 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
480 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 480 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
481 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 481 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
482 mMainView, SLOT(newEvent(QDate))); 482 mMainView, SLOT(newEvent(QDate)));
483 483
484 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 484 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
485 mMainView, SLOT(editIncidence(Incidence *))); 485 mMainView, SLOT(editIncidence(Incidence *)));
486 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 486 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
487 mMainView, SLOT(showIncidence(Incidence *))); 487 mMainView, SLOT(showIncidence(Incidence *)));
488 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 488 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
489 mMainView, SLOT(deleteIncidence(Incidence *))); 489 mMainView, SLOT(deleteIncidence(Incidence *)));
490 490
491 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 491 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
492 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 492 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
493 493
494 connect(mAgendaView, SIGNAL( toggleExpand() ), 494 connect(mAgendaView, SIGNAL( toggleExpand() ),
495 mMainView, SLOT( toggleExpand() ) ); 495 mMainView, SLOT( toggleExpand() ) );
496 496
497 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 497 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
498 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 498 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
499 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 499 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
500 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 500 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
501 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 501 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
502 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 502 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
503 SLOT( updateTodo( Todo *, int ) ) ); 503 SLOT( updateTodo( Todo *, int ) ) );
504 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 504 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
505 mMainView, SIGNAL( todoModified( Todo *, int ))); 505 mMainView, SIGNAL( todoModified( Todo *, int )));
506 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 506 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
507 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 507 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
508 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 508 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
509 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 509 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
510 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 510 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
511 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 511 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
512 mAgendaView->readSettings(); 512 mAgendaView->readSettings();
513 mAgendaView->updateConfig(); 513 mAgendaView->updateConfig();
514 } 514 }
515 515
516 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; 516 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
517 showView( mAgendaView, full); 517 showView( mAgendaView, full);
518 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; 518 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
519} 519}
520 520
521void KOViewManager::showDayView() 521void KOViewManager::showDayView()
522{ 522{
523 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 523 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
524 mFlagShowNextxDays = false; 524 mFlagShowNextxDays = false;
525 globalFlagBlockLabel = 1; 525 globalFlagBlockLabel = 1;
526 globalFlagBlockAgenda = 1; 526 globalFlagBlockAgenda = 1;
527 if ( mCurrentAgendaView != 1 ) 527 if ( mCurrentAgendaView != 1 )
528 mCurrentAgendaView = -1; 528 mCurrentAgendaView = -1;
529 showAgendaView(); 529 showAgendaView();
530 qApp->processEvents(); 530 qApp->processEvents();
531 globalFlagBlockAgenda = 2; 531 globalFlagBlockAgenda = 2;
532 globalFlagBlockLabel = 0; 532 globalFlagBlockLabel = 0;
533 mMainView->dateNavigator()->selectDates( 1 ); 533 mMainView->dateNavigator()->selectDates( 1 );
534 mCurrentAgendaView = 1 ; 534 mCurrentAgendaView = 1 ;
535 535
536} 536}
537 537
538void KOViewManager::showWorkWeekView() 538void KOViewManager::showWorkWeekView()
539{ 539{
540 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 540 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
541 mFlagShowNextxDays = false; 541 mFlagShowNextxDays = false;
542 globalFlagBlockAgenda = 1; 542 globalFlagBlockAgenda = 1;
543 globalFlagBlockLabel = 1; 543 globalFlagBlockLabel = 1;
544 if ( mCurrentAgendaView != 5 ) 544 if ( mCurrentAgendaView != 5 )
545 mCurrentAgendaView = -1; 545 mCurrentAgendaView = -1;
546 showAgendaView(); 546 showAgendaView();
547 qApp->processEvents(); 547 qApp->processEvents();
548 globalFlagBlockAgenda = 2; 548 globalFlagBlockAgenda = 2;
549 globalFlagBlockLabel = 0; 549 globalFlagBlockLabel = 0;
550 mMainView->dateNavigator()->selectWorkWeek(); 550 mMainView->dateNavigator()->selectWorkWeek();
551 mCurrentAgendaView = 5 ; 551 mCurrentAgendaView = 5 ;
552 552
553} 553}
554 554
555void KOViewManager::showWeekView() 555void KOViewManager::showWeekView()
556{ 556{
557 557
558 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 558 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
559 mFlagShowNextxDays = false; 559 mFlagShowNextxDays = false;
560 globalFlagBlockAgenda = 1; 560 globalFlagBlockAgenda = 1;
561 globalFlagBlockLabel = 1; 561 globalFlagBlockLabel = 1;
562 if ( mCurrentAgendaView != 7 ) 562 if ( mCurrentAgendaView != 7 )
563 mCurrentAgendaView = -1; 563 mCurrentAgendaView = -1;
564 showAgendaView(); 564 showAgendaView();
565 qApp->processEvents(); 565 qApp->processEvents();
566 globalFlagBlockAgenda = 2; 566 globalFlagBlockAgenda = 2;
567 globalFlagBlockLabel = 0; 567 globalFlagBlockLabel = 0;
568 mMainView->dateNavigator()->selectWeek(); 568 mMainView->dateNavigator()->selectWeek();
569 mCurrentAgendaView = 7 ; 569 mCurrentAgendaView = 7 ;
570} 570}
571 571
572void KOViewManager::showNextXView() 572void KOViewManager::showNextXView()
573{ 573{
574 574
575 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; 575 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
576 globalFlagBlockAgenda = 1; 576 globalFlagBlockAgenda = 1;
577 if ( mCurrentAgendaView != 3 ) 577 if ( mCurrentAgendaView != 3 )
578 mCurrentAgendaView = -1; 578 mCurrentAgendaView = -1;
579 showAgendaView(KOPrefs::instance()->mFullViewMonth); 579 showAgendaView(KOPrefs::instance()->mFullViewMonth);
580 globalFlagBlockAgenda = 2; 580 globalFlagBlockAgenda = 2;
581 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 581 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
582 KOPrefs::instance()->mNextXDays ); 582 KOPrefs::instance()->mNextXDays );
583 mFlagShowNextxDays = true; 583 mFlagShowNextxDays = true;
584 mCurrentAgendaView = 3 ; 584 mCurrentAgendaView = 3 ;
585 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; 585 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
586} 586}
587bool KOViewManager::showsNextDays() 587bool KOViewManager::showsNextDays()
588{ 588{
589 return mFlagShowNextxDays; 589 return mFlagShowNextxDays;
590} 590}
591void KOViewManager::createMonthView() 591void KOViewManager::createMonthView()
592{ 592{
593if (!mMonthView) { 593if (!mMonthView) {
594 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 594 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
595 595
596 addView(mMonthView); 596 addView(mMonthView);
597 // mMonthView->show(); 597 // mMonthView->show();
598 // SIGNALS/SLOTS FOR MONTH VIEW 598 // SIGNALS/SLOTS FOR MONTH VIEW
599 599
600 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); 600 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate )));
601 601
602 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), 602 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)),
603 mMainView, SLOT(newTodoDateTime(QDateTime, bool))); 603 mMainView, SLOT(newTodoDateTime(QDateTime, bool)));
604 604
605 605
606 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 606 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
607 mMainView, SLOT(newEvent(QDateTime))); 607 mMainView, SLOT(newEvent(QDateTime)));
608 608
609 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 609 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
610 mMainView, SLOT(showIncidence(Incidence *))); 610 mMainView, SLOT(showIncidence(Incidence *)));
611 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 611 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
612 mMainView, SLOT(editIncidence(Incidence *))); 612 mMainView, SLOT(editIncidence(Incidence *)));
613 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 613 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
614 mMainView, SLOT(deleteIncidence(Incidence *))); 614 mMainView, SLOT(deleteIncidence(Incidence *)));
615 615
616 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 616 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
617 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 617 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
618 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 618 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
619 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 619 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
620 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 620 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
621 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 621 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
622 622
623 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 623 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
624 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 624 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
625 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 625 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
626 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 626 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
627 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 627 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
628 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 628 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
629 connect( mMonthView, SIGNAL( selectMonth() ), 629 connect( mMonthView, SIGNAL( selectMonth() ),
630 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 630 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
631 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 631 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
632 mMainView, SLOT ( showDay( QDate ) ) ); 632 mMainView, SLOT ( showDay( QDate ) ) );
633 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 633 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
634 connect( mMonthView, SIGNAL(nextMonth() ), 634 connect( mMonthView, SIGNAL(nextMonth() ),
635 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 635 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
636 connect( mMonthView, SIGNAL(prevMonth() ), 636 connect( mMonthView, SIGNAL(prevMonth() ),
637 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 637 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
638 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 638 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
639 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 639 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
640 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 640 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
641 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 641 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
642 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 642 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
643 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 643 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
644 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 644 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
645 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 645 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
646 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 646 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
647 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 647 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
648 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 648 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
649 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 649 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
650 650
651 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 651 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
652 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 652 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
653 653
654 654
655 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 655 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
656 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 656 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
657 657
658 } 658 }
659} 659}
660void KOViewManager::showMonthViewWeek() 660void KOViewManager::showMonthViewWeek()
661{ 661{
662 createMonthView(); 662 createMonthView();
663 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; 663 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
664 globalFlagBlockAgenda = 1; 664 globalFlagBlockAgenda = 1;
665 bool full = true; 665 bool full = true;
666 if ( mCurrentView == mMonthView) 666 if ( mCurrentView == mMonthView)
667 full = mMainView->leftFrame()->isVisible(); 667 full = mMainView->leftFrame()->isVisible();
668 if ( !KOPrefs::instance()->mMonthViewWeek ) { 668 if ( !KOPrefs::instance()->mMonthViewWeek ) {
669 mMonthView->switchView(); 669 mMonthView->switchView();
670 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 670 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
671 full = false; 671 full = false;
672 else 672 else
673 full = true; 673 full = true;
674 } 674 }
675 mMainView->dateNavigator()->selectWeek(); 675 mMainView->dateNavigator()->selectWeek();
676 showView(mMonthView, full ); 676 showView(mMonthView, full );
677 mMonthView->setKeyBFocus(); 677 mMonthView->setKeyBFocus();
678 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; 678 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
679} 679}
680 680
681void KOViewManager::showMonth( const QDate & date ) 681void KOViewManager::showMonth( const QDate & date )
682{ 682{
683 mMainView->dateNavigator()->blockSignals( true ); 683 mMainView->dateNavigator()->blockSignals( true );
684 mMainView->dateNavigator()->selectDate( date ); 684 mMainView->dateNavigator()->selectDate( date );
685 mMainView->dateNavigator()->blockSignals( false ); 685 mMainView->dateNavigator()->blockSignals( false );
686 showMonthView(); 686 showMonthView();
687} 687}
688void KOViewManager::showMonthView() 688void KOViewManager::showMonthView()
689 { 689 {
690 690
691 createMonthView(); 691 createMonthView();
692 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 692 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
693 globalFlagBlockAgenda = 1; 693 globalFlagBlockAgenda = 1;
694 //mFlagShowNextxDays = false; 694 //mFlagShowNextxDays = false;
695 bool full = true; 695 bool full = true;
696 if ( mCurrentView == mMonthView) 696 if ( mCurrentView == mMonthView)
697 full = mMainView->leftFrame()->isVisible(); 697 full = mMainView->leftFrame()->isVisible();
698 // if(mMonthView == mCurrentView) return; 698 // if(mMonthView == mCurrentView) return;
699 if ( KOPrefs::instance()->mMonthViewWeek ) { 699 if ( KOPrefs::instance()->mMonthViewWeek ) {
700 mMonthView->switchView(); 700 mMonthView->switchView();
701 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 701 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
702 full = false; 702 full = false;
703 else 703 else
704 full = true; 704 full = true;
705 } 705 }
706 mMainView->dateNavigator()->selectMonth(); 706 mMainView->dateNavigator()->selectMonth();
707 707
708 showView(mMonthView, full ); 708 showView(mMonthView, full );
709 mMonthView->setKeyBFocus(); 709 mMonthView->setKeyBFocus();
710 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 710 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
711 711
712} 712}
713 713
714void KOViewManager::showTodoView() 714void KOViewManager::showTodoView()
715{ 715{
716 //mFlagShowNextxDays = false; 716 //mFlagShowNextxDays = false;
717 if ( !mTodoView ) { 717 if ( !mTodoView ) {
718 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 718 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
719 "KOViewManager::TodoView" ); 719 "KOViewManager::TodoView" );
720 720
721 addView( mTodoView ); 721 addView( mTodoView );
722 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 722 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
723 723
724 // SIGNALS/SLOTS FOR TODO VIEW 724 // SIGNALS/SLOTS FOR TODO VIEW
725 connect( mTodoView, SIGNAL( newTodoSignal() ), 725 connect( mTodoView, SIGNAL( newTodoSignal() ),
726 mMainView, SLOT( newTodo() ) ); 726 mMainView, SLOT( newTodo() ) );
727 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 727 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
728 mMainView, SLOT( newSubTodo( Todo *) ) ); 728 mMainView, SLOT( newSubTodo( Todo *) ) );
729 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 729 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
730 mMainView, SLOT( showTodo( Todo * ) ) ); 730 mMainView, SLOT( showTodo( Todo * ) ) );
731 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 731 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
732 mMainView, SLOT( editTodo( Todo * ) ) ); 732 mMainView, SLOT( editTodo( Todo * ) ) );
733 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 733 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
734 mMainView, SLOT( deleteTodo( Todo * ) ) ); 734 mMainView, SLOT( deleteTodo( Todo * ) ) );
735 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 735 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
736 mMainView, SLOT( purgeCompleted() ) ); 736 mMainView, SLOT( purgeCompleted() ) );
737 737
738 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 738 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
739 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 739 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
740 740
741 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 741 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
742 SLOT( updateConfig() ) ); 742 SLOT( updateConfig() ) );
743 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 743 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
744 SLOT( updateTodo( Todo *, int ) ) ); 744 SLOT( updateTodo( Todo *, int ) ) );
745 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 745 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
746 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 746 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
747 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 747 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
748 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 748 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
749 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 749 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
750 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 750 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
751 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 751 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
752 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 752 mMainView, SLOT ( todo_unsub( Todo * ) ) );
753 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 753 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
754 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 754 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
755 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 755 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
756 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 756 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
757 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 757 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
758 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 758 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
759 KConfig *config = KOGlobals::config(); 759 KConfig *config = KOGlobals::config();
760 mTodoView->restoreLayout(config,"Todo View"); 760 mTodoView->restoreLayout(config,"Todo View");
761 mTodoView->setNavigator( mMainView->dateNavigator() ); 761 mTodoView->setNavigator( mMainView->dateNavigator() );
762 } 762 }
763 763
764 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 764 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
765 globalFlagBlockAgenda = 1; 765 globalFlagBlockAgenda = 1;
766 showView( mTodoView, true ); 766 showView( mTodoView, true );
767 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 767 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
768 768
769} 769}
770 770
771void KOViewManager::showJournalView() 771void KOViewManager::showJournalView()
772{ 772{
773 //mFlagShowNextxDays = false; 773 //mFlagShowNextxDays = false;
774 if (!mJournalView) { 774 if (!mJournalView) {
775 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 775 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
776 "KOViewManager::JournalView"); 776 "KOViewManager::JournalView");
777 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 777 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
778 SLOT( updateConfig() ) ); 778 SLOT( updateConfig() ) );
779 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 779 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
780 addView(mJournalView); 780 addView(mJournalView);
781 } 781 }
782 782
783 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 783 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
784 showView(mJournalView); 784 showView(mJournalView);
785 mMainView->dateNavigator()->selectDates( 1 ); 785 mMainView->dateNavigator()->selectDates( 1 );
786 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 786 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
787} 787}
788 788
789void KOViewManager::showTimeSpanView() 789void KOViewManager::showTimeSpanView()
790{ 790{
791 //mFlagShowNextxDays = false; 791 //mFlagShowNextxDays = false;
792 if (!mTimeSpanView) { 792 if (!mTimeSpanView) {
793 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 793 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
794 "KOViewManager::TimeSpanView"); 794 "KOViewManager::TimeSpanView");
795 addView(mTimeSpanView); 795 addView(mTimeSpanView);
796 796
797 mTimeSpanView->readSettings(); 797 mTimeSpanView->readSettings();
798 } 798 }
799 799
800 showView(mTimeSpanView); 800 showView(mTimeSpanView);
801} 801}
802 802
803Incidence *KOViewManager::currentSelection() 803Incidence *KOViewManager::currentSelection()
804{ 804{
805 if (!mCurrentView) return 0; 805 if (!mCurrentView) return 0;
806 if ( mCurrentView == mListView ) { 806 if ( mCurrentView == mListView ) {
807 if ( mListView->currentItem() ) 807 if ( mListView->currentItem() )
808 return mListView->currentItem(); 808 return mListView->currentItem();
809 } 809 }
810 return mCurrentView->selectedIncidences().first(); 810 return mCurrentView->selectedIncidences().first();
811} 811}
812 812
813QDate KOViewManager::currentSelectionDate() 813QDate KOViewManager::currentSelectionDate()
814{ 814{
815 QDate qd; 815 QDate qd;
816 if (mCurrentView) { 816 if (mCurrentView) {
817 DateList qvl = mCurrentView->selectedDates(); 817 DateList qvl = mCurrentView->selectedDates();
818 if (!qvl.isEmpty()) qd = qvl.first(); 818 if (!qvl.isEmpty()) qd = qvl.first();
819 } 819 }
820 return qd; 820 return qd;
821} 821}
822 822
823void KOViewManager::addView(KOrg::BaseView *view) 823void KOViewManager::addView(KOrg::BaseView *view)
824{ 824{
825#if QT_VERSION >= 0x030000 825#if QT_VERSION >= 0x030000
826 mMainView->viewStack()->addWidget( view ); 826 mMainView->viewStack()->addWidget( view );
827#else 827#else
828 mMainView->viewStack()->addWidget( view, 1 ); 828 mMainView->viewStack()->addWidget( view, 1 );
829#endif 829#endif
830} 830}
831 831
832void KOViewManager::setDocumentId( const QString &id ) 832void KOViewManager::setDocumentId( const QString &id )
833{ 833{
834 if (mTodoView) mTodoView->setDocumentId( id ); 834 if (mTodoView) {
835 mTodoView->clearList();
836 mTodoView->setDocumentId( id );
837 }
835} 838}