summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile657
-rw-r--r--korganizer/koagenda.cpp2
-rw-r--r--korganizer/koagendaitem.cpp6
-rw-r--r--libkdepim/ksyncmanager.cpp2
4 files changed, 295 insertions, 372 deletions
diff --git a/Makefile b/Makefile
index 467710f..f80c6d4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,368 +1,291 @@
1export KDEPIMDIR = $(shell pwd) 1#############################################################################
2 2# Makefile for building: kdepim-desktop
3export KDEPIM_VERSION=$(shell sed -e 's/.*\"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/' < version) 3# Generated by qmake (1.07a) (Qt 3.3.3) on: Sat Jan 8 00:36:06 2005
4 4# Project: kdepim-desktop.pro
5ifeq ($(PLATFORM) , zaurus) 5# Template: subdirs
6 BUILD_NO_LDAP_PLUGIN=1 6# Command: $(QMAKE) -o Makefile kdepim-desktop.pro
7endif 7#############################################################################
8 8
9ifneq ($(PLATFORM) , zaurus) 9 MAKEFILE =Makefile
10 BUILD_NO_SHARP_PLUGIN=1 10 QMAKE =qmake
11endif 11DEL_FILE = rm -f
12 12CHK_DIR_EXISTS= test -d
13#opie plugin is deprecated. The qtopia plugin handles the task from now on. 13MKDIR = mkdir -p
14BUILD_NO_OPIE_PLUGIN=1 14INSTALL_FILE=
15 15INSTALL_DIR =
16SUBDIRS_MICROKDE = \ 16 SUBTARGETS = \
17 libical/src/libical \ 17 sub-libical \
18 libical/src/libicalss \ 18 sub-libkcal \
19 qtcompat \ 19 sub-kabc \
20 microkde \ 20 sub-libkdepim \
21 libkcal \ 21 sub-microkde \
22 libkdepim \ 22 sub-korganizer \
23 kabc \ 23 sub-kaddressbook \
24 kabc/formats/binary \ 24 sub-kabc-plugins-file \
25 kabc/plugins/file \ 25 sub-kabc-plugins-dir \
26 kabc/plugins/dir \ 26 sub-kabc-plugins-file \
27 korganizer \ 27 sub-kabc-plugins-qtopia \
28 kalarmd \ 28 sub-gammu-emb-common \
29 kaddressbook 29 sub-gammu-emb-gammu \
30 30 sub-kmicromail-libetpan \
31SUBDIRS_QTOPIA_PLUGIN = \ 31 sub-kmicromail-libmailwrapper \
32 kabc/plugins/qtopia 32 sub-kmicromail \
33 33 sub-pwmanager-libcrypt-cipher \
34SUBDIRS_OPIE_PLUGIN = \ 34 sub-pwmanager-libcrypt-error \
35 kabc/plugins/opie 35 sub-pwmanager-libcrypt-mpi \
36 36 sub-pwmanager-libcrypt-zlib \
37SUBDIRS_SHARP_PLUGIN = \ 37 sub-pwmanager-pwmanager
38 kabc/plugins/sharpdtm 38
39 39first: all
40SUBDIRS_LDAP_PLUGIN = \ 40
41 kabc/plugins/ldap 41all: Makefile $(SUBTARGETS)
42 42
43SUBDIRS_MICROMAIL = \ 43libical/$(MAKEFILE):
44 kmicromail/libetpan \ 44 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical"
45 kmicromail/libmailwrapper \ 45 cd libical && $(QMAKE) libical.pro -o $(MAKEFILE)
46 kmicromail 46sub-libical: libical/$(MAKEFILE) FORCE
47 47 cd libical && $(MAKE) -f $(MAKEFILE)
48SUBDIRS_GAMMU = \ 48
49 gammu/emb/common \ 49libkcal/$(MAKEFILE):
50 gammu/emb/gammu 50 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal"
51 51 cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE)
52SUBDIRS_PWMANAGER = \ 52sub-libkcal: libkcal/$(MAKEFILE) FORCE
53 pwmanager/libcrypt/mpi \ 53 cd libkcal && $(MAKE) -f $(MAKEFILE)
54 pwmanager/libcrypt/error \ 54
55 pwmanager/libcrypt/cipher \ 55kabc/$(MAKEFILE):
56 pwmanager/libcrypt/zlib \ 56 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc"
57 pwmanager/pwmanager 57 cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE)
58 58sub-kabc: kabc/$(MAKEFILE) FORCE
59SUBDIRS = \ 59 cd kabc && $(MAKE) -f $(MAKEFILE)
60 $(SUBDIRS_MICROKDE) \ 60
61 $(SUBDIRS_QTOPIA_PLUGIN) \ 61libkdepim/$(MAKEFILE):
62 $(SUBDIRS_OPIE_PLUGIN) \ 62 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim"
63 $(SUBDIRS_SHARP_PLUGIN) \ 63 cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE)
64 $(SUBDIRS_LDAP_PLUGIN) \ 64sub-libkdepim: libkdepim/$(MAKEFILE) FORCE
65 $(SUBDIRS_MICROMAIL) \ 65 cd libkdepim && $(MAKE) -f $(MAKEFILE)
66 $(SUBDIRS_GAMMU) \ 66
67 $(SUBDIRS_PWMANAGER) 67microkde/$(MAKEFILE):
68 68 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde"
69 69 cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE)
70all: build_microkde \ 70sub-microkde: microkde/$(MAKEFILE) FORCE
71 build_qtopia_plugin \ 71 cd microkde && $(MAKE) -f $(MAKEFILE)
72 build_opie_plugin \ 72
73 build_sharp_plugin \ 73korganizer/$(MAKEFILE):
74 build_ldap_plugin \ 74 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer"
75 build_micromail \ 75 cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE)
76 build_gammu \ 76sub-korganizer: korganizer/$(MAKEFILE) FORCE
77 build_pwmanager 77 cd korganizer && $(MAKE) -f $(MAKEFILE)
78 78
79 79kaddressbook/$(MAKEFILE):
80build_microkde: variable_test tmake 80 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook"
81 for i in $(SUBDIRS_MICROKDE); do pushd $$i; \ 81 cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE)
82 make -f Makefile$(PLATFORM) || exit 1; popd; \ 82sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE
83 done 83 cd kaddressbook && $(MAKE) -f $(MAKEFILE)
84 84
85build_qtopia_plugin: build_microkde 85kabc/plugins/file/$(MAKEFILE):
86 ifdef BUILD_NO_QTOPIA_PLUGIN 86 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
87 @echo == qtopia plugin not build. 87 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE)
88 else 88sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
89 for i in $(SUBDIRS_QTOPIA_PLUGIN); do pushd $$i; \ 89 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
90 make -f Makefile$(PLATFORM) || exit 1; popd; \ 90
91 done 91kabc/plugins/dir/$(MAKEFILE):
92 endif 92 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir"
93 93 cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE)
94build_opie_plugin: build_microkde 94sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE
95 ifdef BUILD_NO_OPIE_PLUGIN 95 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE)
96 @echo == opie plugin not build. 96
97 else 97kabc/plugins/file/$(MAKEFILE):
98 for i in $(SUBDIRS_OPIE_PLUGIN); do pushd $$i; \ 98 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
99 make -f Makefile$(PLATFORM) || exit 1; popd; \ 99 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE)
100 done 100sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
101 endif 101 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
102 102
103build_sharp_plugin: build_microkde 103kabc/plugins/qtopia/$(MAKEFILE):
104 ifdef BUILD_NO_SHARP_PLUGIN 104 @$(CHK_DIR_EXISTS) "kabc/plugins/qtopia" || $(MKDIR) "kabc/plugins/qtopia"
105 @echo == ldap plugin not build. 105 cd kabc/plugins/qtopia && $(QMAKE) qtopia.pro -o $(MAKEFILE)
106 else 106sub-kabc-plugins-qtopia: kabc/plugins/qtopia/$(MAKEFILE) FORCE
107 for i in $(SUBDIRS_SHARP_PLUGIN); do pushd $$i; \ 107 cd kabc/plugins/qtopia && $(MAKE) -f $(MAKEFILE)
108 make -f Makefile$(PLATFORM) || exit 1; popd; \ 108
109 done 109gammu/emb/common/$(MAKEFILE):
110 endif 110 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common"
111 111 cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE)
112build_ldap_plugin: build_microkde 112sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE
113 ifdef BUILD_NO_LDAP_PLUGIN 113 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE)
114 @echo == ldap plugin not build. 114
115 else 115gammu/emb/gammu/$(MAKEFILE):
116 for i in $(SUBDIRS_LDAP_PLUGIN); do pushd $$i; \ 116 @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu"
117 make -f Makefile$(PLATFORM) || exit 1; popd; \ 117 cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE)
118 done 118sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE
119 endif 119 cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE)
120 120
121 121kmicromail/libetpan/$(MAKEFILE):
122build_micromail: build_microkde 122 @$(CHK_DIR_EXISTS) "kmicromail/libetpan" || $(MKDIR) "kmicromail/libetpan"
123 ifdef BUILD_NO_MICROMAIL 123 cd kmicromail/libetpan && $(QMAKE) libetpan.pro -o $(MAKEFILE)
124 @echo == kmicromail not build. 124sub-kmicromail-libetpan: kmicromail/libetpan/$(MAKEFILE) FORCE
125 else 125 cd kmicromail/libetpan && $(MAKE) -f $(MAKEFILE)
126 for i in $(SUBDIRS_MICROMAIL); do pushd $$i; \ 126
127 make -f Makefile$(PLATFORM) || exit 1; popd; \ 127kmicromail/libmailwrapper/$(MAKEFILE):
128 done 128 @$(CHK_DIR_EXISTS) "kmicromail/libmailwrapper" || $(MKDIR) "kmicromail/libmailwrapper"
129 endif 129 cd kmicromail/libmailwrapper && $(QMAKE) libmailwrapper.pro -o $(MAKEFILE)
130 130sub-kmicromail-libmailwrapper: kmicromail/libmailwrapper/$(MAKEFILE) FORCE
131build_gammu: variable_test tmake 131 cd kmicromail/libmailwrapper && $(MAKE) -f $(MAKEFILE)
132 ifdef BUILD_NO_GAMMU 132
133 @echo == gammu not build. 133kmicromail/$(MAKEFILE):
134 else 134 @$(CHK_DIR_EXISTS) "kmicromail" || $(MKDIR) "kmicromail"
135 for i in $(SUBDIRS_GAMMU); do pushd $$i; \ 135 cd kmicromail && $(QMAKE) kmicromail.pro -o $(MAKEFILE)
136 make -f Makefile$(PLATFORM) || exit 1; popd; \ 136sub-kmicromail: kmicromail/$(MAKEFILE) FORCE
137 done 137 cd kmicromail && $(MAKE) -f $(MAKEFILE)
138 endif 138
139 139pwmanager/libcrypt/cipher/$(MAKEFILE):
140build_pwmanager: build_microkde 140 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/cipher" || $(MKDIR) "pwmanager/libcrypt/cipher"
141 ifdef BUILD_NO_PWMANAGER 141 cd pwmanager/libcrypt/cipher && $(QMAKE) cipher.pro -o $(MAKEFILE)
142 @echo == pwmanager not build. 142sub-pwmanager-libcrypt-cipher: pwmanager/libcrypt/cipher/$(MAKEFILE) FORCE
143 else 143 cd pwmanager/libcrypt/cipher && $(MAKE) -f $(MAKEFILE)
144 for i in $(SUBDIRS_PWMANAGER); do pushd $$i; \ 144
145 make -f Makefile$(PLATFORM) || exit 1; popd; \ 145pwmanager/libcrypt/error/$(MAKEFILE):
146 done 146 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/error" || $(MKDIR) "pwmanager/libcrypt/error"
147 endif 147 cd pwmanager/libcrypt/error && $(QMAKE) error.pro -o $(MAKEFILE)
148 148sub-pwmanager-libcrypt-error: pwmanager/libcrypt/error/$(MAKEFILE) FORCE
149 149 cd pwmanager/libcrypt/error && $(MAKE) -f $(MAKEFILE)
150variable_info: 150
151 @echo -------------------------------------- 151pwmanager/libcrypt/mpi/$(MAKEFILE):
152 @echo KDEPIM buildsystem, variableinfo... 152 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/mpi" || $(MKDIR) "pwmanager/libcrypt/mpi"
153 @echo KDEPIMDIR=$(KDEPIMDIR) 153 cd pwmanager/libcrypt/mpi && $(QMAKE) mpi.pro -o $(MAKEFILE)
154 @echo QTDIR=$(QTDIR) 154sub-pwmanager-libcrypt-mpi: pwmanager/libcrypt/mpi/$(MAKEFILE) FORCE
155 @echo QPEDIR=$(QPEDIR) 155 cd pwmanager/libcrypt/mpi && $(MAKE) -f $(MAKEFILE)
156 @echo OPIEDIR=$(OPIEDIR) 156
157 @echo PLATFORM=$(PLATFORM) 157pwmanager/libcrypt/zlib/$(MAKEFILE):
158 @echo RELEASE_DEBUG=$(RELEASE_DEBUG) 158 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/zlib" || $(MKDIR) "pwmanager/libcrypt/zlib"
159 @echo BUILD_NO_MICROMAIL=$(BUILD_NO_MICROMAIL) 159 cd pwmanager/libcrypt/zlib && $(QMAKE) zlib.pro -o $(MAKEFILE)
160 @echo BUILD_NO_LDAP_PLUGIN=$(BUILD_NO_LDAP_PLUGIN) 160sub-pwmanager-libcrypt-zlib: pwmanager/libcrypt/zlib/$(MAKEFILE) FORCE
161 @echo BUILD_NO_OPIE_PLUGIN=$(BUILD_NO_OPIE_PLUGIN) 161 cd pwmanager/libcrypt/zlib && $(MAKE) -f $(MAKEFILE)
162 @echo BUILD_NO_QTOPIA_PLUGIN=$(BUILD_NO_QTOPIA_PLUGIN) 162
163 @echo BUILD_NO_SHARP_PLUGIN=$(BUILD_NO_SHARP_PLUGIN) 163pwmanager/pwmanager/$(MAKEFILE):
164 ifndef BUILD_NO_SHARP_PLUGIN 164 @$(CHK_DIR_EXISTS) "pwmanager/pwmanager" || $(MKDIR) "pwmanager/pwmanager"
165 @echo SHARPDTMSDK=$(SHARPDTMSDK) 165 cd pwmanager/pwmanager && $(QMAKE) pwmanager.pro -o $(MAKEFILE)
166 endif 166sub-pwmanager-pwmanager: pwmanager/pwmanager/$(MAKEFILE) FORCE
167 @echo BUILD_NO_GAMMU=$(BUILD_NO_GAMMU) 167 cd pwmanager/pwmanager && $(MAKE) -f $(MAKEFILE)
168 @echo BUILD_NO_PWMANAGER=$(BUILD_NO_PWMANAGER) 168
169 @echo -------------------------------------- 169Makefile: kdepim-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf
170 170 $(QMAKE) -o Makefile kdepim-desktop.pro
171variable_test: variable_info 171qmake: qmake_all
172 @echo KDEPIM buildsystem, variablecheck... 172 @$(QMAKE) -o Makefile kdepim-desktop.pro
173 ifndef KDEPIMDIR 173
174 @echo KDEPIMDIR is not defined. 174all: $(SUBTARGETS)
175 $(error KDEPIMDIR is not defined) 175qmake_all: libical/$(MAKEFILE) libkcal/$(MAKEFILE) kabc/$(MAKEFILE) libkdepim/$(MAKEFILE) microkde/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/qtopia/$(MAKEFILE) gammu/emb/common/$(MAKEFILE) gammu/emb/gammu/$(MAKEFILE) kmicromail/libetpan/$(MAKEFILE) kmicromail/libmailwrapper/$(MAKEFILE) kmicromail/$(MAKEFILE) pwmanager/libcrypt/cipher/$(MAKEFILE) pwmanager/libcrypt/error/$(MAKEFILE) pwmanager/libcrypt/mpi/$(MAKEFILE) pwmanager/libcrypt/zlib/$(MAKEFILE) pwmanager/pwmanager/$(MAKEFILE)
176 endif 176 ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
177 ifndef PLATFORM 177 ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
178 @echo PLATFORM is not defined. 178 ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
179 $(error PLATFORM is not defined) 179 ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
180 endif 180 ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
181 ifdef BUILD_NO_LDAP_PLUGIN 181 ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
182 @echo LDAP PLUGIN will not be build, because BUILD_NO_LDAP_PLUGIN is set to $(BUILD_NO_LDAP_PLUGIN) 182 ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
183 endif 183 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
184 ifdef BUILD_NO_OPIE_PLUGIN 184 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
185 @echo OPIE PLUGIN will not be build, because BUILD_NO_OPIE_PLUGIN is set to $(BUILD_NO_OPIE_PLUGIN) 185 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
186 endif 186 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
187 ifdef BUILD_NO_QTOPIA_PLUGIN 187 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
188 @echo QTOPIA PLUGIN will not be build, because BUILD_NO__QTOPIA_PLUGIN is set to $(BUILD_NO__QTOPIA_PLUGIN) 188 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
189 endif 189 ( [ -d kmicromail/libetpan ] && cd kmicromail/libetpan ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
190 ifdef BUILD_NO_MICROMAIL 190 ( [ -d kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
191 @echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL) 191 ( [ -d kmicromail ] && cd kmicromail ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
192 endif 192 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
193 ifdef BUILD_NO_SHARP_PLUGIN 193 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
194 @echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN) 194 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
195 else 195 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
196 ifndef SHARPDTMSDK 196 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
197 @echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK) 197clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE
198 $(error SHARPDTMSDK is not defined) 198 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true
199 endif 199 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true
200 endif 200 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true
201 ifdef BUILD_NO_GAMMU 201 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true
202 @echo GAMMU will not be build, because BUILD_NO_GAMMU is set to $(BUILD_NO_GAMMU) 202 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true
203 endif 203 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true
204 ifdef BUILD_NO_PWMANAGER 204 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true
205 @echo PWMANAGER will not be build, because BUILD_NO_PWMANAGER is set to $(BUILD_NO_PWMANAGER) 205 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
206 endif 206 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true
207 @echo -------------------------------------- 207 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
208 208 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) $@; ) || true
209 209 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true
210objects: 210 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true
211 for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done 211 ( [ -d kmicromail/libetpan ] && cd kmicromail/libetpan ; $(MAKE) -f $(MAKEFILE) $@; ) || true
212 for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done 212 ( [ -d kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; $(MAKE) -f $(MAKEFILE) $@; ) || true
213 mkdir -p libical/lib/$(PLATFORM) 213 ( [ -d kmicromail ] && cd kmicromail ; $(MAKE) -f $(MAKEFILE) $@; ) || true
214 mkdir -p pwmanager/libcrypt/$(PLATFORM) 214 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; ) || true
215 215 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; ) || true
216clean: 216 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; ) || true
217 rm -rf libical/lib/$(PLATFORM)/*; 217 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; ) || true
218 rm -rf pwmanager/libcrypt/$(PLATFORM)/*; 218 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; ) || true
219 for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ 219uninstall_subdirs: qmake_all FORCE
220 rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ 220 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
221 done 221 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
222 222 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
223install: 223 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
224 224 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
225 cd bin/kdepim; make install 225 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
226 cp -r Pim $(QPEDIR)/apps 226 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
227 cp db2file/db2file $(QPEDIR)/bin/db2file 227 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
228 cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop 228 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
229 cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop 229 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
230 cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kopiemail.desktop 230 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
231 cp pwmanager/pwmanager/pwmanager.desktop $(QPEDIR)/apps/Pim/pwmanager.desktop 231 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
232 232 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
233dist: 233 ( [ -d kmicromail/libetpan ] && cd kmicromail/libetpan ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
234 @echo Dont forget to do "make install" before "make dist" 234 ( [ -d kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
235 rm -f *arm.ipk 235 ( [ -d kmicromail ] && cd kmicromail ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
236 rm -f *~ 236 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
237 cd ..; tar czf kdepimpi-$(KDEPIM_VERSION).tar.gz --exclude=obj --exclude=moc --exclude=CVS --exclude=Makefilezaurus --exclude=Makefileqtopia kdepim 237 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
238 mkipks kmicrokdelibs.control 238 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
239 mkipks korganizer.control 239 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
240 mkipks kaddressbook.control 240 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
241 ifndef BUILD_NO_MICROMAIL 241install_subdirs: qmake_all FORCE
242 mkipks kopiemail.control 242 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true
243 endif 243 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true
244 ifndef BUILD_NO_SHARP_PLUGIN 244 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true
245 mkipks ksharpPIM-DTMaccess.control 245 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true
246 endif 246 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true
247 mkipks korganizer-alarm.control 247 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true
248 ifndef BUILD_NO_GAMMU 248 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true
249 mkipks kmobilephoneaccess.control 249 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
250 endif 250 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true
251 ifndef BUILD_NO_PWMANAGER 251 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
252 mkipks pwmanager.control 252 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) install; ) || true
253 endif 253 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true
254 mkipks pimTABicon.control 254 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true
255 255 ( [ -d kmicromail/libetpan ] && cd kmicromail/libetpan ; $(MAKE) -f $(MAKEFILE) install; ) || true
256tmake: objects \ 256 ( [ -d kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; $(MAKE) -f $(MAKEFILE) install; ) || true
257 qtcompat/Makefile$(PLATFORM) \ 257 ( [ -d kmicromail ] && cd kmicromail ; $(MAKE) -f $(MAKEFILE) install; ) || true
258 microkde/Makefile$(PLATFORM) \ 258 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) install; ) || true
259 libkcal/Makefile$(PLATFORM) \ 259 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) install; ) || true
260 libkdepim/Makefile$(PLATFORM) \ 260 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) install; ) || true
261 korganizer/Makefile$(PLATFORM) \ 261 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) install; ) || true
262 kalarmd/Makefile$(PLATFORM) \ 262 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) install; ) || true
263 libical/src/libical/Makefile$(PLATFORM) \ 263distclean: qmake_all FORCE
264 libical/src/libicalss/Makefile$(PLATFORM) \ 264 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
265 kabc/Makefile$(PLATFORM) \ 265 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
266 kabc/formats/binary/Makefile$(PLATFORM) \ 266 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
267 kabc/plugins/file/Makefile$(PLATFORM) \ 267 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
268 kabc/plugins/dir/Makefile$(PLATFORM) \ 268 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
269 kabc/plugins/ldap/Makefile$(PLATFORM) \ 269 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
270 kabc/plugins/opie/Makefile$(PLATFORM) \ 270 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
271 kabc/plugins/qtopia/Makefile$(PLATFORM) \ 271 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
272 kabc/plugins/sharpdtm/Makefile$(PLATFORM) \ 272 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
273 kaddressbook/Makefile$(PLATFORM) \ 273 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
274 kmicromail/Makefile$(PLATFORM) \ 274 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
275 kmicromail/libetpan/Makefile$(PLATFORM) \ 275 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
276 kmicromail/libmailwrapper/Makefile$(PLATFORM) \ 276 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
277 gammu/emb/common/Makefile$(PLATFORM) \ 277 ( [ -d kmicromail/libetpan ] && cd kmicromail/libetpan ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
278 gammu/emb/gammu/Makefile$(PLATFORM) \ 278 ( [ -d kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
279 pwmanager/pwmanager/Makefile$(PLATFORM) \ 279 ( [ -d kmicromail ] && cd kmicromail ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
280 pwmanager/libcrypt/mpi/Makefile$(PLATFORM) \ 280 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
281 pwmanager/libcrypt/error/Makefile$(PLATFORM) \ 281 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
282 pwmanager/libcrypt/cipher/Makefile$(PLATFORM) \ 282 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
283 pwmanager/libcrypt/zlib/Makefile$(PLATFORM) 283 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
284 284 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
285qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro 285
286 cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtcompat.pro -o Makefile$(PLATFORM) 286install: install_subdirs
287 287
288microkde/Makefile$(PLATFORM): microkde/microkdeE.pro 288uninstall: uninstall_subdirs
289 cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" microkdeE.pro -o Makefile$(PLATFORM) 289
290 290FORCE:
291libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro
292 cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkcalE.pro -o Makefile$(PLATFORM)
293
294
295libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro
296 cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkdepimE.pro -o Makefile$(PLATFORM)
297
298kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro
299 cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kalarmdE.pro -o Makefile$(PLATFORM)
300
301korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro
302 cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" korganizerE.pro -o Makefile$(PLATFORM)
303
304libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro
305 cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalE.pro -o Makefile$(PLATFORM)
306
307libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro
308 cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalssE.pro -o Makefile$(PLATFORM)
309
310kabc/Makefile$(PLATFORM): kabc/kabcE.pro
311 cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcE.pro -o Makefile$(PLATFORM)
312
313kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro
314 cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcformat_binaryE.pro -o Makefile$(PLATFORM)
315
316kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/fileE.pro
317 cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" fileE.pro -o Makefile$(PLATFORM)
318
319kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/dirE.pro
320 cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" dirE.pro -o Makefile$(PLATFORM)
321
322kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/ldapE.pro
323 cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" ldapE.pro -o Makefile$(PLATFORM)
324
325kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/opieE.pro
326 cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" opieE.pro -o Makefile$(PLATFORM)
327
328kabc/plugins/qtopia/Makefile$(PLATFORM): kabc/plugins/qtopia/qtopiaE.pro
329 cd kabc/plugins/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtopiaE.pro -o Makefile$(PLATFORM)
330
331kabc/plugins/sharpdtm/Makefile$(PLATFORM): kabc/plugins/sharpdtm/sharpdtmE.pro
332 cd kabc/plugins/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" sharpdtmE.pro -o Makefile$(PLATFORM)
333
334kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro
335 cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kaddressbookE.pro -o Makefile$(PLATFORM)
336
337kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro
338 cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kmicromailE.pro -o Makefile$(PLATFORM)
339
340kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro
341 cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libetpanE.pro -o Makefile$(PLATFORM)
342
343kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro
344 cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libmailwrapperE.pro -o Makefile$(PLATFORM)
345
346gammu/emb/common/Makefile$(PLATFORM): gammu/emb/common/commonE.pro
347 cd gammu/emb/common; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" commonE.pro -o Makefile$(PLATFORM)
348
349gammu/emb/gammu/Makefile$(PLATFORM): gammu/emb/gammu/gammuE.pro
350 cd gammu/emb/gammu; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" gammuE.pro -o Makefile$(PLATFORM)
351
352pwmanager/pwmanager/Makefile$(PLATFORM): pwmanager/pwmanager/pwmanagerE.pro
353 cd pwmanager/pwmanager; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" pwmanagerE.pro -o Makefile$(PLATFORM)
354
355
356pwmanager/libcrypt/mpi/Makefile$(PLATFORM): pwmanager/libcrypt/mpi/mpi.pro
357 cd pwmanager/libcrypt/mpi;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" mpi.pro -o Makefile$(PLATFORM)
358
359pwmanager/libcrypt/error/Makefile$(PLATFORM): pwmanager/libcrypt/error/error.pro
360 cd pwmanager/libcrypt/error;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" error.pro -o Makefile$(PLATFORM)
361
362pwmanager/libcrypt/cipher/Makefile$(PLATFORM): pwmanager/libcrypt/cipher/cipher.pro
363 cd pwmanager/libcrypt/cipher;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" cipher.pro -o Makefile$(PLATFORM)
364
365pwmanager/libcrypt/zlib/Makefile$(PLATFORM): pwmanager/libcrypt/zlib/zlib.pro
366 cd pwmanager/libcrypt/zlib;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" zlib.pro -o Makefile$(PLATFORM)
367
368 291
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index eb3791e..7e0b216 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -867,1070 +867,1070 @@ void KOAgenda::endItemAction()
867 for ( item=oldconflictItems.first(); item != 0; 867 for ( item=oldconflictItems.first(); item != 0;
868 item=oldconflictItems.next() ) { 868 item=oldconflictItems.next() ) {
869 placeSubCells(item); 869 placeSubCells(item);
870 } 870 }
871 placeSubCells( placeItem ); 871 placeSubCells( placeItem );
872 placeItem = placeItem->nextMultiItem(); 872 placeItem = placeItem->nextMultiItem();
873 873
874 } 874 }
875 placeItem = modifiedItem; 875 placeItem = modifiedItem;
876 while ( placeItem ) { 876 while ( placeItem ) {
877 oldconflictItems = placeItem->conflictItems(); 877 oldconflictItems = placeItem->conflictItems();
878 for ( item=oldconflictItems.first(); item != 0; 878 for ( item=oldconflictItems.first(); item != 0;
879 item=oldconflictItems.next() ) { 879 item=oldconflictItems.next() ) {
880 globalFlagBlockAgendaItemUpdate = 0; 880 globalFlagBlockAgendaItemUpdate = 0;
881 item->repaintMe(); 881 item->repaintMe();
882 globalFlagBlockAgendaItemUpdate = 1; 882 globalFlagBlockAgendaItemUpdate = 1;
883 item->repaint(false); 883 item->repaint(false);
884 } 884 }
885 placeItem = placeItem->nextMultiItem(); 885 placeItem = placeItem->nextMultiItem();
886 } 886 }
887 /* 887 /*
888 888
889 oldconflictItems = modifiedItem->conflictItems(); 889 oldconflictItems = modifiedItem->conflictItems();
890 for ( item=oldconflictItems.first(); item != 0; 890 for ( item=oldconflictItems.first(); item != 0;
891 item=oldconflictItems.next() ) { 891 item=oldconflictItems.next() ) {
892 globalFlagBlockAgendaItemUpdate = 0; 892 globalFlagBlockAgendaItemUpdate = 0;
893 item->paintMe(false); 893 item->paintMe(false);
894 globalFlagBlockAgendaItemUpdate = 1; 894 globalFlagBlockAgendaItemUpdate = 1;
895 item->repaint(false); 895 item->repaint(false);
896 } 896 }
897 */ 897 */
898 898
899 899
900 } 900 }
901 901
902 } 902 }
903 903
904 mScrollUpTimer.stop(); 904 mScrollUpTimer.stop();
905 mScrollDownTimer.stop(); 905 mScrollDownTimer.stop();
906 setCursor( arrowCursor ); 906 setCursor( arrowCursor );
907 mActionItem = 0; 907 mActionItem = 0;
908 mActionType = NOP; 908 mActionType = NOP;
909 mItemMoved = 0; 909 mItemMoved = 0;
910 910
911} 911}
912 912
913void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 913void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
914{ 914{
915// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 915// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
916// QPoint point = viewport()->mapToGlobal(viewportPos); 916// QPoint point = viewport()->mapToGlobal(viewportPos);
917// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 917// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
918// point = clipper()->mapFromGlobal(point); 918// point = clipper()->mapFromGlobal(point);
919// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 919// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
920 920
921 int x,y; 921 int x,y;
922 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 922 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
923// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 923// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
924 int gx,gy; 924 int gx,gy;
925 contentsToGrid(x,y,gx,gy); 925 contentsToGrid(x,y,gx,gy);
926 926
927 // Change cursor to resize cursor if appropriate 927 // Change cursor to resize cursor if appropriate
928 if (mAllDayMode) { 928 if (mAllDayMode) {
929 int gridDistanceX = (x - gx * mGridSpacingX); 929 int gridDistanceX = (x - gx * mGridSpacingX);
930 if (gridDistanceX < mResizeBorderWidth && 930 if (gridDistanceX < mResizeBorderWidth &&
931 moveItem->cellX() == gx) { 931 moveItem->cellX() == gx) {
932 setCursor(sizeHorCursor); 932 setCursor(sizeHorCursor);
933 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 933 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
934 moveItem->cellXWidth() == gx) { 934 moveItem->cellXWidth() == gx) {
935 setCursor(sizeHorCursor); 935 setCursor(sizeHorCursor);
936 } else { 936 } else {
937 setCursor(arrowCursor); 937 setCursor(arrowCursor);
938 } 938 }
939 } else { 939 } else {
940 int gridDistanceY = (y - gy * mGridSpacingY); 940 int gridDistanceY = (y - gy * mGridSpacingY);
941 if (gridDistanceY < mResizeBorderWidth && 941 if (gridDistanceY < mResizeBorderWidth &&
942 moveItem->cellYTop() == gy && 942 moveItem->cellYTop() == gy &&
943 !moveItem->firstMultiItem()) { 943 !moveItem->firstMultiItem()) {
944 setCursor(sizeVerCursor); 944 setCursor(sizeVerCursor);
945 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 945 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
946 moveItem->cellYBottom() == gy && 946 moveItem->cellYBottom() == gy &&
947 !moveItem->lastMultiItem()) { 947 !moveItem->lastMultiItem()) {
948 setCursor(sizeVerCursor); 948 setCursor(sizeVerCursor);
949 } else { 949 } else {
950 setCursor(arrowCursor); 950 setCursor(arrowCursor);
951 } 951 }
952 } 952 }
953} 953}
954 954
955 955
956/* 956/*
957 Place item in cell and take care that multiple items using the same cell do 957 Place item in cell and take care that multiple items using the same cell do
958 not overlap. This method is not yet optimal. It doesn´t use the maximum space 958 not overlap. This method is not yet optimal. It doesn´t use the maximum space
959 it can get in all cases. 959 it can get in all cases.
960 At the moment the method has a bug: When an item is placed only the sub cell 960 At the moment the method has a bug: When an item is placed only the sub cell
961 widths of the items are changed, which are within the Y region the item to 961 widths of the items are changed, which are within the Y region the item to
962 place spans. When the sub cell width change of one of this items affects a 962 place spans. When the sub cell width change of one of this items affects a
963 cell, where other items are, which do not overlap in Y with the item to place, 963 cell, where other items are, which do not overlap in Y with the item to place,
964 the display gets corrupted, although the corruption looks quite nice. 964 the display gets corrupted, although the corruption looks quite nice.
965*/ 965*/
966void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 966void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
967{ 967{
968 968
969 QPtrList<KOAgendaItem> conflictItems; 969 QPtrList<KOAgendaItem> conflictItems;
970 int maxSubCells = 0; 970 int maxSubCells = 0;
971 QIntDict<KOAgendaItem> subCellDict(5); 971 QIntDict<KOAgendaItem> subCellDict(5);
972 972
973 KOAgendaItem *item; 973 KOAgendaItem *item;
974 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 974 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
975 if (item != placeItem) { 975 if (item != placeItem) {
976 if (placeItem->cellX() <= item->cellXWidth() && 976 if (placeItem->cellX() <= item->cellXWidth() &&
977 placeItem->cellXWidth() >= item->cellX()) { 977 placeItem->cellXWidth() >= item->cellX()) {
978 if ((placeItem->cellYTop() <= item->cellYBottom()) && 978 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
979 (placeItem->cellYBottom() >= item->cellYTop())) { 979 (placeItem->cellYBottom() >= item->cellYTop())) {
980 conflictItems.append(item); 980 conflictItems.append(item);
981 if (item->subCells() > maxSubCells) 981 if (item->subCells() > maxSubCells)
982 maxSubCells = item->subCells(); 982 maxSubCells = item->subCells();
983 subCellDict.insert(item->subCell(),item); 983 subCellDict.insert(item->subCell(),item);
984 } 984 }
985 } 985 }
986 } 986 }
987 } 987 }
988 988
989 if (conflictItems.count() > 0) { 989 if (conflictItems.count() > 0) {
990 // Look for unused sub cell and insert item 990 // Look for unused sub cell and insert item
991 int i; 991 int i;
992 for(i=0;i<maxSubCells;++i) { 992 for(i=0;i<maxSubCells;++i) {
993 if (!subCellDict.find(i)) { 993 if (!subCellDict.find(i)) {
994 placeItem->setSubCell(i); 994 placeItem->setSubCell(i);
995 break; 995 break;
996 } 996 }
997 } 997 }
998 if (i == maxSubCells) { 998 if (i == maxSubCells) {
999 placeItem->setSubCell(maxSubCells); 999 placeItem->setSubCell(maxSubCells);
1000 maxSubCells++; // add new item to number of sub cells 1000 maxSubCells++; // add new item to number of sub cells
1001 } 1001 }
1002 1002
1003 // Prepare for sub cell geometry adjustment 1003 // Prepare for sub cell geometry adjustment
1004 int newSubCellWidth; 1004 int newSubCellWidth;
1005 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1005 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1006 else newSubCellWidth = mGridSpacingX / maxSubCells; 1006 else newSubCellWidth = mGridSpacingX / maxSubCells;
1007 conflictItems.append(placeItem); 1007 conflictItems.append(placeItem);
1008 1008
1009 1009
1010 // Adjust sub cell geometry of all items 1010 // Adjust sub cell geometry of all items
1011 for ( item=conflictItems.first(); item != 0; 1011 for ( item=conflictItems.first(); item != 0;
1012 item=conflictItems.next() ) { 1012 item=conflictItems.next() ) {
1013 item->setSubCells(maxSubCells); 1013 item->setSubCells(maxSubCells);
1014 if (mAllDayMode) { 1014 if (mAllDayMode) {
1015 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1015 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1016 } else { 1016 } else {
1017 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1017 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1018 } 1018 }
1019 int x,y; 1019 int x,y;
1020 gridToContents(item->cellX(),item->cellYTop(),x,y); 1020 gridToContents(item->cellX(),item->cellYTop(),x,y);
1021 if (mAllDayMode) { 1021 if (mAllDayMode) {
1022 y += item->subCell() * newSubCellWidth; 1022 y += item->subCell() * newSubCellWidth;
1023 } else { 1023 } else {
1024 x += item->subCell() * newSubCellWidth; 1024 x += item->subCell() * newSubCellWidth;
1025 } 1025 }
1026 moveChild(item,x,y); 1026 moveChild(item,x,y);
1027 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1027 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1028 //item->updateItem(); 1028 //item->updateItem();
1029 } 1029 }
1030 1030
1031 } else { 1031 } else {
1032 placeItem->setSubCell(0); 1032 placeItem->setSubCell(0);
1033 placeItem->setSubCells(1); 1033 placeItem->setSubCells(1);
1034 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1034 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1035 else placeItem->resize(mGridSpacingX,placeItem->height()); 1035 else placeItem->resize(mGridSpacingX,placeItem->height());
1036 int x,y; 1036 int x,y;
1037 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1037 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1038 moveChild(placeItem,x,y); 1038 moveChild(placeItem,x,y);
1039 } 1039 }
1040 placeItem->setConflictItems(conflictItems); 1040 placeItem->setConflictItems(conflictItems);
1041 // for ( item=conflictItems.first(); item != 0; 1041 // for ( item=conflictItems.first(); item != 0;
1042// item=conflictItems.next() ) { 1042// item=conflictItems.next() ) {
1043// //item->updateItem(); 1043// //item->updateItem();
1044// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1044// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1045// } 1045// }
1046// placeItem->updateItem(); 1046// placeItem->updateItem();
1047} 1047}
1048 1048
1049void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1049void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1050{ 1050{
1051 if ( globalFlagBlockAgenda ) 1051 if ( globalFlagBlockAgenda )
1052 return; 1052 return;
1053 //qDebug("KOAgenda::drawContents "); 1053 //qDebug("KOAgenda::drawContents ");
1054 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1054 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1055 ;//drawContentsToPainter(); 1055 ;//drawContentsToPainter();
1056 1056
1057 QPaintDevice* pd = p->device(); 1057 QPaintDevice* pd = p->device();
1058 p->end(); 1058 p->end();
1059 int vx, vy; 1059 int vx, vy;
1060 int selectionX = KOGlobals::self()->reverseLayout() ? 1060 int selectionX = KOGlobals::self()->reverseLayout() ?
1061 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1061 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1062 mSelectionCellX * mGridSpacingX; 1062 mSelectionCellX * mGridSpacingX;
1063 contentsToViewport ( cx, cy, vx,vy); 1063 contentsToViewport ( cx, cy, vx,vy);
1064 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1064 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1065 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1065 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1066 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1066 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1067 1067
1068 if ( mSelectionHeight > 0 ) { 1068 if ( mSelectionHeight > 0 ) {
1069 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1069 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1070 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1070 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1071 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1071 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1072 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1072 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1073 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1073 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1074 } 1074 }
1075 } 1075 }
1076 //qDebug("btbl "); 1076 //qDebug("btbl ");
1077 p->begin( pd ); 1077 p->begin( pd );
1078 //qDebug("end "); 1078 //qDebug("end ");
1079} 1079}
1080 1080
1081void KOAgenda::finishUpdate() 1081void KOAgenda::finishUpdate()
1082{ 1082{
1083 1083
1084 KOAgendaItem *item; 1084 KOAgendaItem *item;
1085 globalFlagBlockAgendaItemPaint = 1; 1085 globalFlagBlockAgendaItemPaint = 1;
1086 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1086 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1087 if ( !item->isVisible() ) 1087 if ( !item->isVisible() )
1088 item->show(); 1088 item->show();
1089 1089
1090 } 1090 }
1091 globalFlagBlockAgendaItemUpdate = 0; 1091 globalFlagBlockAgendaItemUpdate = 0;
1092 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1092 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1093 item->repaintMe( ); 1093 item->repaintMe( );
1094 } 1094 }
1095 globalFlagBlockAgendaItemUpdate = 1; 1095 globalFlagBlockAgendaItemUpdate = 1;
1096 qApp->processEvents(); 1096 qApp->processEvents();
1097 globalFlagBlockAgendaItemPaint = 0; 1097 globalFlagBlockAgendaItemPaint = 0;
1098 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1098 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1099 item->repaint( false ); 1099 item->repaint( false );
1100 } 1100 }
1101 1101
1102} 1102}
1103 1103
1104/* 1104/*
1105 Draw grid in the background of the agenda. 1105 Draw grid in the background of the agenda.
1106*/ 1106*/
1107void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1107void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1108{ 1108{
1109 1109
1110 1110
1111 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1111 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1112 return; 1112 return;
1113 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1113 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1114 return; 1114 return;
1115 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1115 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1116 if ( ch < 1 ) 1116 if ( ch < 1 )
1117 ch = 1; 1117 ch = 1;
1118 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1118 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1119 mPaintPixmap.resize( contentsWidth()+42, ch ); 1119 mPaintPixmap.resize( contentsWidth()+42, ch );
1120 } 1120 }
1121 mCurPixWid = contentsWidth(); 1121 mCurPixWid = contentsWidth();
1122 mCurPixHei = ch; 1122 mCurPixHei = ch;
1123 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { 1123 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) {
1124 mHighlightPixmap.resize( mGridSpacingX-1, ch ); 1124 mHighlightPixmap.resize( mGridSpacingX-1, ch );
1125 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1125 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1126 } 1126 }
1127 mPixPainter.begin( &mPaintPixmap) ; 1127 mPixPainter.begin( &mPaintPixmap) ;
1128 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1128 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1129 QPainter * p ; 1129 QPainter * p ;
1130 if (paint == 0) { 1130 if (paint == 0) {
1131 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1131 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1132 p = &mPixPainter; 1132 p = &mPixPainter;
1133 } 1133 }
1134 else 1134 else
1135 p = paint ; 1135 p = paint ;
1136 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1136 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1137 1137
1138 //--cx;++cw; 1138 //--cx;++cw;
1139 int lGridSpacingY = mGridSpacingY*2; 1139 int lGridSpacingY = mGridSpacingY*2;
1140 int selDay; 1140 int selDay;
1141 if ( !backgroundOnly ) 1141 if ( !backgroundOnly )
1142 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1142 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1143 { 1143 {
1144 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { 1144 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
1145 int x1 = cx; 1145 int x1 = cx;
1146 int y1 = 0; 1146 int y1 = 0;
1147 if (y1 < cy) y1 = cy; 1147 if (y1 < cy) y1 = cy;
1148 int x2 = cx+cw-1; 1148 int x2 = cx+cw-1;
1149 int y2 = contentsHeight(); 1149 int y2 = contentsHeight();
1150 if (y2 > cy+ch-1) y2=cy+ch-1; 1150 if (y2 > cy+ch-1) y2=cy+ch-1;
1151 if (x2 >= x1 && y2 >= y1) { 1151 if (x2 >= x1 && y2 >= y1) {
1152 int gxStart = selDay; 1152 int gxStart = selDay;
1153 int gxEnd = gxStart ; 1153 int gxEnd = gxStart ;
1154 int xStart = KOGlobals::self()->reverseLayout() ? 1154 int xStart = KOGlobals::self()->reverseLayout() ?
1155 (mColumns - 1 - gxStart)*mGridSpacingX : 1155 (mColumns - 1 - gxStart)*mGridSpacingX :
1156 gxStart*mGridSpacingX; 1156 gxStart*mGridSpacingX;
1157 if (xStart < x1) xStart = x1; 1157 if (xStart < x1) xStart = x1;
1158 int xEnd = KOGlobals::self()->reverseLayout() ? 1158 int xEnd = KOGlobals::self()->reverseLayout() ?
1159 (mColumns - gxStart)*mGridSpacingX-1 : 1159 (mColumns - gxStart)*mGridSpacingX-1 :
1160 (gxStart+1)*mGridSpacingX-1; 1160 (gxStart+1)*mGridSpacingX-1;
1161 if (xEnd > x2) xEnd = x2; 1161 if (xEnd > x2) xEnd = x2;
1162 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1162 if ( KOPrefs::instance()->mUseHighlightLightColor )
1163 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1163 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1164 KOPrefs::instance()->mAgendaBgColor.light()); 1164 KOPrefs::instance()->mAgendaBgColor.light());
1165 else 1165 else
1166 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1166 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1167 KOPrefs::instance()->mAgendaBgColor.dark()); 1167 KOPrefs::instance()->mAgendaBgColor.dark());
1168 1168
1169 } 1169 }
1170 } 1170 }
1171 } 1171 }
1172 // Highlight working hours 1172 // Highlight working hours
1173 1173
1174 if ( !backgroundOnly ) 1174 if ( !backgroundOnly )
1175 if (mWorkingHoursEnable) { 1175 if (mWorkingHoursEnable) {
1176 int x1 = cx; 1176 int x1 = cx;
1177 int y1 = mWorkingHoursYTop; 1177 int y1 = mWorkingHoursYTop;
1178 if (y1 < cy) y1 = cy; 1178 if (y1 < cy) y1 = cy;
1179 int x2 = cx+cw-1; 1179 int x2 = cx+cw-1;
1180 // int x2 = mGridSpacingX * 5 - 1; 1180 // int x2 = mGridSpacingX * 5 - 1;
1181 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1181 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1182 int y2 = mWorkingHoursYBottom; 1182 int y2 = mWorkingHoursYBottom;
1183 if (y2 > cy+ch-1) y2=cy+ch-1; 1183 if (y2 > cy+ch-1) y2=cy+ch-1;
1184 1184
1185 if (x2 >= x1 && y2 >= y1) { 1185 if (x2 >= x1 && y2 >= y1) {
1186 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1186 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1187 int gxStart = x1/mGridSpacingX; 1187 int gxStart = x1/mGridSpacingX;
1188 int gxEnd = x2/mGridSpacingX; 1188 int gxEnd = x2/mGridSpacingX;
1189 while(gxStart <= gxEnd) { 1189 while(gxStart <= gxEnd) {
1190 if (gxStart < int(mHolidayMask->count()) && 1190 if (gxStart < int(mHolidayMask->count()) &&
1191 !mHolidayMask->at(gxStart)) { 1191 !mHolidayMask->at(gxStart)) {
1192 int xStart = KOGlobals::self()->reverseLayout() ? 1192 int xStart = KOGlobals::self()->reverseLayout() ?
1193 (mColumns - 1 - gxStart)*mGridSpacingX : 1193 (mColumns - 1 - gxStart)*mGridSpacingX :
1194 gxStart*mGridSpacingX; 1194 gxStart*mGridSpacingX;
1195 if (xStart < x1) xStart = x1; 1195 if (xStart < x1) xStart = x1;
1196 int xEnd = KOGlobals::self()->reverseLayout() ? 1196 int xEnd = KOGlobals::self()->reverseLayout() ?
1197 (mColumns - gxStart)*mGridSpacingX-1 : 1197 (mColumns - gxStart)*mGridSpacingX-1 :
1198 (gxStart+1)*mGridSpacingX-1; 1198 (gxStart+1)*mGridSpacingX-1;
1199 if (xEnd > x2) xEnd = x2; 1199 if (xEnd > x2) xEnd = x2;
1200 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { 1200 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
1201 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1201 if ( KOPrefs::instance()->mUseHighlightLightColor )
1202 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1202 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1203 KOPrefs::instance()->mWorkingHoursColor.light()); 1203 KOPrefs::instance()->mWorkingHoursColor.light());
1204 else 1204 else
1205 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1205 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1206 KOPrefs::instance()->mWorkingHoursColor.dark()); 1206 KOPrefs::instance()->mWorkingHoursColor.dark());
1207 } else { 1207 } else {
1208 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1208 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1209 KOPrefs::instance()->mWorkingHoursColor); 1209 KOPrefs::instance()->mWorkingHoursColor);
1210 } 1210 }
1211 } 1211 }
1212 ++gxStart; 1212 ++gxStart;
1213 } 1213 }
1214 } 1214 }
1215 } 1215 }
1216 /* 1216 /*
1217 int selectionX = KOGlobals::self()->reverseLayout() ? 1217 int selectionX = KOGlobals::self()->reverseLayout() ?
1218 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1218 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1219 mSelectionCellX * mGridSpacingX; 1219 mSelectionCellX * mGridSpacingX;
1220 1220
1221 // Draw selection 1221 // Draw selection
1222 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1222 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1223 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1223 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1224 // TODO: paint only part within cx,cy,cw,ch 1224 // TODO: paint only part within cx,cy,cw,ch
1225 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1225 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1226 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1226 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1227 } 1227 }
1228 */ 1228 */
1229 // Draw vertical lines of grid 1229 // Draw vertical lines of grid
1230 1230
1231 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1231 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1232 if ( mGridSpacingX > 0 ) { 1232 if ( mGridSpacingX > 0 ) {
1233 while (x < cx + cw) { 1233 while (x < cx + cw) {
1234 p->drawLine(x,cy,x,cy+ch); 1234 p->drawLine(x,cy,x,cy+ch);
1235 x+=mGridSpacingX; 1235 x+=mGridSpacingX;
1236 } 1236 }
1237 } 1237 }
1238 // Draw horizontal lines of grid 1238 // Draw horizontal lines of grid
1239 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1239 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1240 if ( lGridSpacingY > 0 ) { 1240 if ( lGridSpacingY > 0 ) {
1241 while (y < cy + ch) { 1241 while (y < cy + ch) {
1242 p->setPen( SolidLine ); 1242 p->setPen( SolidLine );
1243 p->drawLine(cx,y,cx+cw,y); 1243 p->drawLine(cx,y,cx+cw,y);
1244 y+=lGridSpacingY; 1244 y+=lGridSpacingY;
1245 p->setPen( DotLine ); 1245 p->setPen( DotLine );
1246 p->drawLine(cx,y,cx+cw,y); 1246 p->drawLine(cx,y,cx+cw,y);
1247 y+=lGridSpacingY; 1247 y+=lGridSpacingY;
1248 } 1248 }
1249 p->setPen( SolidLine ); 1249 p->setPen( SolidLine );
1250 } 1250 }
1251 mPixPainter.end() ; 1251 mPixPainter.end() ;
1252} 1252}
1253 1253
1254/* 1254/*
1255 Convert srcollview contents coordinates to agenda grid coordinates. 1255 Convert srcollview contents coordinates to agenda grid coordinates.
1256*/ 1256*/
1257void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1257void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1258{ 1258{
1259 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1259 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1260 x/mGridSpacingX; 1260 x/mGridSpacingX;
1261 gy = y/mGridSpacingY; 1261 gy = y/mGridSpacingY;
1262} 1262}
1263 1263
1264/* 1264/*
1265 Convert agenda grid coordinates to scrollview contents coordinates. 1265 Convert agenda grid coordinates to scrollview contents coordinates.
1266*/ 1266*/
1267void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1267void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1268{ 1268{
1269 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1269 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1270 gx*mGridSpacingX; 1270 gx*mGridSpacingX;
1271 y = gy*mGridSpacingY; 1271 y = gy*mGridSpacingY;
1272} 1272}
1273 1273
1274 1274
1275/* 1275/*
1276 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1276 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1277 the grid. 1277 the grid.
1278*/ 1278*/
1279int KOAgenda::timeToY(const QTime &time) 1279int KOAgenda::timeToY(const QTime &time)
1280{ 1280{
1281 int minutesPerCell = 24 * 60 / mRows; 1281 int minutesPerCell = 24 * 60 / mRows;
1282 int timeMinutes = time.hour() * 60 + time.minute(); 1282 int timeMinutes = time.hour() * 60 + time.minute();
1283 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1283 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1284 return Y; 1284 return Y;
1285} 1285}
1286 1286
1287 1287
1288/* 1288/*
1289 Return time corresponding to cell y coordinate. Coordinates are rounded to 1289 Return time corresponding to cell y coordinate. Coordinates are rounded to
1290 fit into the grid. 1290 fit into the grid.
1291*/ 1291*/
1292QTime KOAgenda::gyToTime(int gy) 1292QTime KOAgenda::gyToTime(int gy)
1293{ 1293{
1294 1294
1295 int secondsPerCell = 24 * 60 * 60/ mRows; 1295 int secondsPerCell = 24 * 60 * 60/ mRows;
1296 1296
1297 int timeSeconds = secondsPerCell * gy; 1297 int timeSeconds = secondsPerCell * gy;
1298 1298
1299 QTime time( 0, 0, 0 ); 1299 QTime time( 0, 0, 0 );
1300 if ( timeSeconds < 24 * 60 * 60 ) { 1300 if ( timeSeconds < 24 * 60 * 60 ) {
1301 time = time.addSecs(timeSeconds); 1301 time = time.addSecs(timeSeconds);
1302 } else { 1302 } else {
1303 time.setHMS( 23, 59, 59 ); 1303 time.setHMS( 23, 59, 59 );
1304 } 1304 }
1305 1305
1306 return time; 1306 return time;
1307} 1307}
1308 1308
1309void KOAgenda::setStartHour(int startHour) 1309void KOAgenda::setStartHour(int startHour)
1310{ 1310{
1311 int startCell = startHour * mRows / 24; 1311 int startCell = startHour * mRows / 24;
1312 setContentsPos(0,startCell * gridSpacingY()); 1312 setContentsPos(0,startCell * gridSpacingY());
1313} 1313}
1314void KOAgenda::hideUnused() 1314void KOAgenda::hideUnused()
1315{ 1315{
1316 // experimental only 1316 // experimental only
1317 // return; 1317 // return;
1318 KOAgendaItem *item; 1318 KOAgendaItem *item;
1319 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1319 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1320 item->hide(); 1320 item->hide();
1321 } 1321 }
1322} 1322}
1323 1323
1324 1324
1325KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1325KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1326{ 1326{
1327 1327
1328 KOAgendaItem *fi; 1328 KOAgendaItem *fi;
1329 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1329 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1330 if ( fi->incidence() == event ) { 1330 if ( fi->incidence() == event ) {
1331 mUnusedItems.remove(); 1331 mUnusedItems.remove();
1332 fi->init( event, qd ); 1332 fi->init( event, qd );
1333 return fi; 1333 return fi;
1334 } 1334 }
1335 } 1335 }
1336 fi=mUnusedItems.first(); 1336 fi=mUnusedItems.first();
1337 if ( fi ) { 1337 if ( fi ) {
1338 mUnusedItems.remove(); 1338 mUnusedItems.remove();
1339 fi->init( event, qd ); 1339 fi->init( event, qd );
1340 return fi; 1340 return fi;
1341 } 1341 }
1342 // qDebug("new KOAgendaItem "); 1342 // qDebug("new KOAgendaItem ");
1343 1343
1344 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1344 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1345 agendaItem->installEventFilter(this); 1345 agendaItem->installEventFilter(this);
1346 addChild(agendaItem,0,0); 1346 addChild(agendaItem,0,0);
1347 return agendaItem; 1347 return agendaItem;
1348} 1348}
1349KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1349KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1350{ 1350{
1351 KOAgendaItem *item; 1351 KOAgendaItem *item;
1352 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1352 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1353 if ( item->incidence() == todo ) { 1353 if ( item->incidence() == todo ) {
1354 mItems.remove(); 1354 mItems.remove();
1355 return item; 1355 return item;
1356 } 1356 }
1357 } 1357 }
1358 return 0; 1358 return 0;
1359} 1359}
1360 1360
1361 1361
1362void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1362void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1363{ 1363{
1364 1364
1365 KOAgendaItem *item; 1365 KOAgendaItem *item;
1366 item = getItemForTodo ( todo ); 1366 item = getItemForTodo ( todo );
1367 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1367 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1368 if ( item ) { 1368 if ( item ) {
1369 blockSignals( true ); 1369 blockSignals( true );
1370 //qDebug("item found "); 1370 //qDebug("item found ");
1371 item->hide(); 1371 item->hide();
1372 item->setCellX(-2, -1 ); 1372 item->setCellX(-2, -1 );
1373 item->select(false); 1373 item->select(false);
1374 mUnusedItems.append( item ); 1374 mUnusedItems.append( item );
1375 mItems.remove( item ); 1375 mItems.remove( item );
1376 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1376 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1377 KOAgendaItem *itemit; 1377 KOAgendaItem *itemit;
1378 //globalFlagBlockAgendaItemPaint = 1; 1378 //globalFlagBlockAgendaItemPaint = 1;
1379 for ( itemit=oldconflictItems.first(); itemit != 0; 1379 for ( itemit=oldconflictItems.first(); itemit != 0;
1380 itemit=oldconflictItems.next() ) { 1380 itemit=oldconflictItems.next() ) {
1381 if ( itemit != item ) 1381 if ( itemit != item )
1382 placeSubCells(itemit); 1382 placeSubCells(itemit);
1383 } 1383 }
1384 qApp->processEvents(); 1384 qApp->processEvents();
1385 //globalFlagBlockAgendaItemPaint = 0; 1385 //globalFlagBlockAgendaItemPaint = 0;
1386 for ( itemit=oldconflictItems.first(); itemit != 0; 1386 for ( itemit=oldconflictItems.first(); itemit != 0;
1387 itemit=oldconflictItems.next() ) { 1387 itemit=oldconflictItems.next() ) {
1388 globalFlagBlockAgendaItemUpdate = 0; 1388 globalFlagBlockAgendaItemUpdate = 0;
1389 if ( itemit != item ) 1389 if ( itemit != item )
1390 itemit->repaintMe(); 1390 itemit->repaintMe();
1391 globalFlagBlockAgendaItemUpdate = 1; 1391 globalFlagBlockAgendaItemUpdate = 1;
1392 itemit->repaint(); 1392 itemit->repaint();
1393 } 1393 }
1394 blockSignals( false ); 1394 blockSignals( false );
1395 } 1395 }
1396 if ( remove ) { 1396 if ( remove ) {
1397 //qDebug("remove****************************************** "); 1397 //qDebug("remove****************************************** ");
1398 return; 1398 return;
1399 } 1399 }
1400 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1400 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1401 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1401 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
1402 QDate currentDate; 1402 QDate currentDate;
1403 if ( overdue ) { 1403 if ( overdue ) {
1404 currentDate = QDate::currentDate(); 1404 currentDate = QDate::currentDate();
1405 days += todo->dtDue().date().daysTo( currentDate ); 1405 days += todo->dtDue().date().daysTo( currentDate );
1406 } 1406 }
1407 else 1407 else
1408 currentDate = todo->dtDue().date(); 1408 currentDate = todo->dtDue().date();
1409 1409
1410 if ( todo->doesFloat() || overdue ) { 1410 if ( todo->doesFloat() || overdue ) {
1411 if ( ! mAllDayMode ) return; 1411 if ( ! mAllDayMode ) return;
1412 // aldayagenda 1412 // aldayagenda
1413 globalFlagBlockAgendaItemPaint = 1; 1413 globalFlagBlockAgendaItemPaint = 1;
1414 item = insertAllDayItem(todo, currentDate,days, days); 1414 item = insertAllDayItem(todo, currentDate,days, days);
1415 item->show(); 1415 item->show();
1416 1416
1417 } 1417 }
1418 else { 1418 else {
1419 if ( mAllDayMode ) return; 1419 if ( mAllDayMode ) return;
1420 // mAgenda 1420 // mAgenda
1421 globalFlagBlockAgendaItemPaint = 1; 1421 globalFlagBlockAgendaItemPaint = 1;
1422 int endY = timeToY(todo->dtDue().time()) - 1; 1422 int endY = timeToY(todo->dtDue().time()) - 1;
1423 int hi = 12/KOPrefs::instance()->mHourSize; 1423 int hi = 12/KOPrefs::instance()->mHourSize;
1424 int startY = endY - 1-hi; 1424 int startY = endY - 1-hi;
1425 item = insertItem(todo,currentDate,days,startY,endY); 1425 item = insertItem(todo,currentDate,days,startY,endY);
1426 item->show(); 1426 item->show();
1427 } 1427 }
1428 qApp->processEvents(); 1428 qApp->processEvents();
1429 globalFlagBlockAgendaItemPaint = 0; 1429 globalFlagBlockAgendaItemPaint = 0;
1430 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1430 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1431 KOAgendaItem *itemit; 1431 KOAgendaItem *itemit;
1432 for ( itemit=oldconflictItems.first(); itemit != 0; 1432 for ( itemit=oldconflictItems.first(); itemit != 0;
1433 itemit=oldconflictItems.next() ) { 1433 itemit=oldconflictItems.next() ) {
1434 globalFlagBlockAgendaItemUpdate = 0; 1434 globalFlagBlockAgendaItemUpdate = 0;
1435 itemit->repaintMe(); 1435 itemit->repaintMe();
1436 globalFlagBlockAgendaItemUpdate = 1; 1436 globalFlagBlockAgendaItemUpdate = 1;
1437 itemit->repaint(); 1437 itemit->repaint();
1438 } 1438 }
1439 globalFlagBlockAgendaItemUpdate = 0; 1439 globalFlagBlockAgendaItemUpdate = 0;
1440 item->repaintMe(); 1440 item->repaintMe();
1441 globalFlagBlockAgendaItemUpdate = 1; 1441 globalFlagBlockAgendaItemUpdate = 1;
1442 item->repaint(); 1442 item->repaint();
1443} 1443}
1444/* 1444/*
1445 Insert KOAgendaItem into agenda. 1445 Insert KOAgendaItem into agenda.
1446*/ 1446*/
1447KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1447KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1448{ 1448{
1449 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; 1449 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl;
1450 1450
1451 if (mAllDayMode) { 1451 if (mAllDayMode) {
1452 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; 1452 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl;
1453 return 0; 1453 return 0;
1454 } 1454 }
1455 1455
1456 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1456 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1457 //agendaItem->setFrameStyle(WinPanel|Raised); 1457 //agendaItem->setFrameStyle(WinPanel|Raised);
1458 1458
1459 int YSize = YBottom - YTop + 1; 1459 int YSize = YBottom - YTop + 1;
1460 if (YSize < 0) { 1460 if (YSize < 0) {
1461 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; 1461 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl;
1462 YSize = 1; 1462 YSize = 1;
1463 } 1463 }
1464 int iheight = mGridSpacingY * YSize; 1464 int iheight = mGridSpacingY * YSize;
1465 1465
1466 agendaItem->resize(mGridSpacingX,iheight ); 1466 agendaItem->resize(mGridSpacingX,iheight );
1467 agendaItem->setCellXY(X,YTop,YBottom); 1467 agendaItem->setCellXY(X,YTop,YBottom);
1468 agendaItem->setCellXWidth(X); 1468 agendaItem->setCellXWidth(X);
1469 1469
1470 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1470 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1471 mItems.append(agendaItem); 1471 mItems.append(agendaItem);
1472 1472
1473 placeSubCells(agendaItem); 1473 placeSubCells(agendaItem);
1474 1474
1475 //agendaItem->show(); 1475 //agendaItem->show();
1476 1476
1477 marcus_bains(); 1477 marcus_bains();
1478 1478
1479 return agendaItem; 1479 return agendaItem;
1480} 1480}
1481 1481
1482 1482
1483/* 1483/*
1484 Insert all-day KOAgendaItem into agenda. 1484 Insert all-day KOAgendaItem into agenda.
1485*/ 1485*/
1486KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1486KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1487{ 1487{
1488 if (!mAllDayMode) { 1488 if (!mAllDayMode) {
1489 return 0; 1489 return 0;
1490 } 1490 }
1491 1491
1492 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1492 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1493 1493
1494 agendaItem->setCellXY(XBegin,0,0); 1494 agendaItem->setCellXY(XBegin,0,0);
1495 agendaItem->setCellXWidth(XEnd); 1495 agendaItem->setCellXWidth(XEnd);
1496 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1496 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1497 1497
1498 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1498 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1499 mItems.append(agendaItem); 1499 mItems.append(agendaItem);
1500 1500
1501 placeSubCells(agendaItem); 1501 placeSubCells(agendaItem);
1502 1502
1503 //agendaItem->show(); 1503 //agendaItem->show();
1504 1504
1505 return agendaItem; 1505 return agendaItem;
1506} 1506}
1507 1507
1508 1508
1509void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1509void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1510 int YTop,int YBottom) 1510 int YTop,int YBottom)
1511{ 1511{
1512 if (mAllDayMode) { 1512 if (mAllDayMode) {
1513 ; 1513 ;
1514 return; 1514 return;
1515 } 1515 }
1516 1516
1517 int cellX,cellYTop,cellYBottom; 1517 int cellX,cellYTop,cellYBottom;
1518 QString newtext; 1518 QString newtext;
1519 int width = XEnd - XBegin + 1; 1519 int width = XEnd - XBegin + 1;
1520 int count = 0; 1520 int count = 0;
1521 KOAgendaItem *current = 0; 1521 KOAgendaItem *current = 0;
1522 QPtrList<KOAgendaItem> multiItems; 1522 QPtrList<KOAgendaItem> multiItems;
1523 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1523 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1524 if (cellX == XBegin) cellYTop = YTop; 1524 if (cellX == XBegin) cellYTop = YTop;
1525 else cellYTop = 0; 1525 else cellYTop = 0;
1526 if (cellX == XEnd) cellYBottom = YBottom; 1526 if (cellX == XEnd) cellYBottom = YBottom;
1527 else cellYBottom = rows() - 1; 1527 else cellYBottom = rows() - 1;
1528 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1528 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1529 newtext.append(event->summary()); 1529 newtext.append(event->summary());
1530 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1530 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1531 current->setText(newtext); 1531 current->setText(newtext);
1532 multiItems.append(current); 1532 multiItems.append(current);
1533 } 1533 }
1534 1534
1535 KOAgendaItem *next = 0; 1535 KOAgendaItem *next = 0;
1536 KOAgendaItem *last = multiItems.last(); 1536 KOAgendaItem *last = multiItems.last();
1537 KOAgendaItem *first = multiItems.first(); 1537 KOAgendaItem *first = multiItems.first();
1538 KOAgendaItem *setFirst,*setLast; 1538 KOAgendaItem *setFirst,*setLast;
1539 current = first; 1539 current = first;
1540 while (current) { 1540 while (current) {
1541 next = multiItems.next(); 1541 next = multiItems.next();
1542 if (current == first) setFirst = 0; 1542 if (current == first) setFirst = 0;
1543 else setFirst = first; 1543 else setFirst = first;
1544 if (current == last) setLast = 0; 1544 if (current == last) setLast = 0;
1545 else setLast = last; 1545 else setLast = last;
1546 1546
1547 current->setMultiItem(setFirst,next,setLast); 1547 current->setMultiItem(setFirst,next,setLast);
1548 current = next; 1548 current = next;
1549 } 1549 }
1550 1550
1551 marcus_bains(); 1551 marcus_bains();
1552} 1552}
1553 1553
1554 1554
1555//QSizePolicy KOAgenda::sizePolicy() const 1555//QSizePolicy KOAgenda::sizePolicy() const
1556//{ 1556//{
1557 // Thought this would make the all-day event agenda minimum size and the 1557 // Thought this would make the all-day event agenda minimum size and the
1558 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1558 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1559 // don´t seem to think that an Expanding widget needs more space than a 1559 // don´t seem to think that an Expanding widget needs more space than a
1560 // Preferred one. 1560 // Preferred one.
1561 // But it doesn´t hurt, so it stays. 1561 // But it doesn´t hurt, so it stays.
1562// if (mAllDayMode) { 1562// if (mAllDayMode) {
1563// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1563// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1564// } else { 1564// } else {
1565// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1565// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1566// } 1566// }
1567//} 1567//}
1568void KOAgenda::finishResize ( ) 1568void KOAgenda::finishResize ( )
1569{ 1569{
1570 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1570 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1571 if ( globalFlagBlockAgenda == 0 ) { 1571 if ( globalFlagBlockAgenda == 0 ) {
1572 finishUpdate(); 1572 finishUpdate();
1573 //qDebug("finishUpdate() called "); 1573 //qDebug("finishUpdate() called ");
1574 } 1574 }
1575} 1575}
1576/* 1576/*
1577 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1577 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1578*/ 1578*/
1579void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1579void KOAgenda::resizeEvent ( QResizeEvent *ev )
1580{ 1580{
1581 1581
1582 mResizeTimer.start( 150 , true ); 1582 mResizeTimer.start( 150 , true );
1583 computeSizes(); 1583 computeSizes();
1584 return; 1584 return;
1585 1585
1586} 1586}
1587void KOAgenda::computeSizes() 1587void KOAgenda::computeSizes()
1588{ 1588{
1589 if ( globalFlagBlockStartup ) 1589 if ( globalFlagBlockStartup )
1590 return; 1590 return;
1591 1591
1592 if (mAllDayMode) { 1592 if (mAllDayMode) {
1593 mGridSpacingX = (width()-3) / mColumns; 1593 mGridSpacingX = (width()-3) / mColumns;
1594 mGridSpacingY = height() - 2 * frameWidth() - 1; 1594 mGridSpacingY = height() - 2 * frameWidth() - 1;
1595 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1595 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1596// mGridSpacingY = height(); 1596// mGridSpacingY = height();
1597// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1597// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1598 1598
1599 KOAgendaItem *item; 1599 KOAgendaItem *item;
1600 int subCellWidth; 1600 int subCellWidth;
1601 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1601 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1602 subCellWidth = mGridSpacingY / item->subCells(); 1602 subCellWidth = mGridSpacingY / item->subCells();
1603 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1603 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1604 moveChild(item,KOGlobals::self()->reverseLayout() ? 1604 moveChild(item,KOGlobals::self()->reverseLayout() ?
1605 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1605 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1606 item->cellX() * mGridSpacingX, 1606 item->cellX() * mGridSpacingX,
1607 item->subCell() * subCellWidth); 1607 item->subCell() * subCellWidth);
1608 } 1608 }
1609 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1609 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1610 } else { 1610 } else {
1611 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; 1611 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns;
1612 if (height() > mGridSpacingY * mRows + 1 ) { 1612 if (height() > mGridSpacingY * mRows + 1 ) {
1613 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1613 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1614 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1614 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1615 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1615 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1616 emit resizedSignal(); 1616 emit resizedSignal();
1617 } else 1617 } else
1618 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1618 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1619 KOAgendaItem *item; 1619 KOAgendaItem *item;
1620 int subCellWidth; 1620 int subCellWidth;
1621 1621
1622 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1622 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1623 subCellWidth = mGridSpacingX / item->subCells(); 1623 subCellWidth = mGridSpacingX / item->subCells();
1624 item->resize(subCellWidth,item->height()); 1624 item->resize(subCellWidth,item->height());
1625 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1625 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1626 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1626 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1627 item->cellX() * mGridSpacingX) + 1627 item->cellX() * mGridSpacingX) +
1628 item->subCell() * subCellWidth,childY(item)); 1628 item->subCell() * subCellWidth,childY(item));
1629 } 1629 }
1630 } 1630 }
1631 int cw = contentsWidth(); 1631 int cw = contentsWidth();
1632 int ch = contentsHeight(); 1632 int ch = contentsHeight();
1633 if ( mAllDayMode ) { 1633 if ( mAllDayMode ) {
1634 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1634 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1635 if ( paintPixAll->width() < cw || paintPixAll->height() < ch ) 1635 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1636 paintPixAll->resize( cw, ch ); 1636 paintPixAll->resize( cw, ch );
1637 } else { 1637 } else {
1638 QPixmap* paintPix = KOAgendaItem::paintPix(); 1638 QPixmap* paintPix = KOAgendaItem::paintPix();
1639 if ( paintPix->width() < cw || paintPix->height() < ch ) 1639 if ( paintPix->width() < cw || paintPix->height() < ch )
1640 KOAgendaItem::resizePixmap( cw , ch ); 1640 KOAgendaItem::resizePixmap( cw , ch );
1641 } 1641 }
1642 1642
1643 checkScrollBoundaries(); 1643 checkScrollBoundaries();
1644 marcus_bains(); 1644 marcus_bains();
1645 drawContentsToPainter(); 1645 drawContentsToPainter();
1646 viewport()->repaint(false); 1646 viewport()->repaint(false);
1647} 1647}
1648 1648
1649void KOAgenda::scrollUp() 1649void KOAgenda::scrollUp()
1650{ 1650{
1651 scrollBy(0,-mScrollOffset); 1651 scrollBy(0,-mScrollOffset);
1652} 1652}
1653 1653
1654 1654
1655void KOAgenda::scrollDown() 1655void KOAgenda::scrollDown()
1656{ 1656{
1657 scrollBy(0,mScrollOffset); 1657 scrollBy(0,mScrollOffset);
1658} 1658}
1659 1659
1660void KOAgenda::popupAlarm() 1660void KOAgenda::popupAlarm()
1661{ 1661{
1662 if (!mClickedItem) { 1662 if (!mClickedItem) {
1663 kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; 1663 kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl;
1664 return; 1664 return;
1665 } 1665 }
1666// TODO: deal correctly with multiple alarms 1666// TODO: deal correctly with multiple alarms
1667 Alarm* alarm; 1667 Alarm* alarm;
1668 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1668 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1669 for(alarm=list.first();alarm;alarm=list.next()) { 1669 for(alarm=list.first();alarm;alarm=list.next()) {
1670 alarm->toggleAlarm(); 1670 alarm->toggleAlarm();
1671 } 1671 }
1672 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1672 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1673 mClickedItem->paintMe( true ); 1673 mClickedItem->paintMe( true );
1674 mClickedItem->repaint( false ); 1674 mClickedItem->repaint( false );
1675} 1675}
1676 1676
1677/* 1677/*
1678 Calculates the minimum width 1678 Calculates the minimum width
1679*/ 1679*/
1680int KOAgenda::minimumWidth() const 1680int KOAgenda::minimumWidth() const
1681{ 1681{
1682 // TODO:: develop a way to dynamically determine the minimum width 1682 // TODO:: develop a way to dynamically determine the minimum width
1683 int min = 100; 1683 int min = 100;
1684 1684
1685 return min; 1685 return min;
1686} 1686}
1687 1687
1688void KOAgenda::updateConfig() 1688void KOAgenda::updateConfig()
1689{ 1689{
1690 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 1690 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1691 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 1691 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1692 if ( mAllDayMode ) { 1692 if ( mAllDayMode ) {
1693 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 1693 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1694 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 1694 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1695 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 1695 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1696 // setMaximumHeight( mGridSpacingY+1 ); 1696 // setMaximumHeight( mGridSpacingY+1 );
1697 viewport()->repaint( false ); 1697 viewport()->repaint( false );
1698 //setFixedHeight( mGridSpacingY+1 ); 1698 //setFixedHeight( mGridSpacingY+1 );
1699 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 1699 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1700 } 1700 }
1701 else { 1701 else {
1702 mGridSpacingY = KOPrefs::instance()->mHourSize; 1702 mGridSpacingY = KOPrefs::instance()->mHourSize;
1703 calculateWorkingHours(); 1703 calculateWorkingHours();
1704 marcus_bains(); 1704 marcus_bains();
1705 } 1705 }
1706} 1706}
1707 1707
1708void KOAgenda::checkScrollBoundaries() 1708void KOAgenda::checkScrollBoundaries()
1709{ 1709{
1710 // Invalidate old values to force update 1710 // Invalidate old values to force update
1711 mOldLowerScrollValue = -1; 1711 mOldLowerScrollValue = -1;
1712 mOldUpperScrollValue = -1; 1712 mOldUpperScrollValue = -1;
1713 1713
1714 checkScrollBoundaries(verticalScrollBar()->value()); 1714 checkScrollBoundaries(verticalScrollBar()->value());
1715} 1715}
1716 1716
1717void KOAgenda::checkScrollBoundaries(int v) 1717void KOAgenda::checkScrollBoundaries(int v)
1718{ 1718{
1719 if ( mGridSpacingY == 0 ) 1719 if ( mGridSpacingY == 0 )
1720 return; 1720 return;
1721 int yMin = v/mGridSpacingY; 1721 int yMin = v/mGridSpacingY;
1722 int yMax = (v+visibleHeight())/mGridSpacingY; 1722 int yMax = (v+visibleHeight())/mGridSpacingY;
1723 1723
1724// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 1724// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
1725 1725
1726 if (yMin != mOldLowerScrollValue) { 1726 if (yMin != mOldLowerScrollValue) {
1727 mOldLowerScrollValue = yMin; 1727 mOldLowerScrollValue = yMin;
1728 emit lowerYChanged(yMin); 1728 emit lowerYChanged(yMin);
1729 } 1729 }
1730 if (yMax != mOldUpperScrollValue) { 1730 if (yMax != mOldUpperScrollValue) {
1731 mOldUpperScrollValue = yMax; 1731 mOldUpperScrollValue = yMax;
1732 emit upperYChanged(yMax); 1732 emit upperYChanged(yMax);
1733 } 1733 }
1734} 1734}
1735 1735
1736void KOAgenda::deselectItem() 1736void KOAgenda::deselectItem()
1737{ 1737{
1738 if (mSelectedItem.isNull()) return; 1738 if (mSelectedItem.isNull()) return;
1739 mSelectedItem->select(false); 1739 mSelectedItem->select(false);
1740 mSelectedItem = 0; 1740 mSelectedItem = 0;
1741} 1741}
1742 1742
1743void KOAgenda::selectItem(KOAgendaItem *item) 1743void KOAgenda::selectItem(KOAgendaItem *item)
1744{ 1744{
1745 if ((KOAgendaItem *)mSelectedItem == item) return; 1745 if ((KOAgendaItem *)mSelectedItem == item) return;
1746 deselectItem(); 1746 deselectItem();
1747 if (item == 0) { 1747 if (item == 0) {
1748 emit incidenceSelected( 0 ); 1748 emit incidenceSelected( 0 );
1749 return; 1749 return;
1750 } 1750 }
1751 mSelectedItem = item; 1751 mSelectedItem = item;
1752 mSelectedItem->select(); 1752 mSelectedItem->select();
1753 emit incidenceSelected( mSelectedItem->incidence() ); 1753 emit incidenceSelected( mSelectedItem->incidence() );
1754} 1754}
1755 1755
1756// This function seems never be called. 1756// This function seems never be called.
1757void KOAgenda::keyPressEvent( QKeyEvent *kev ) 1757void KOAgenda::keyPressEvent( QKeyEvent *kev )
1758{ 1758{
1759 switch(kev->key()) { 1759 switch(kev->key()) {
1760 case Key_PageDown: 1760 case Key_PageDown:
1761 verticalScrollBar()->addPage(); 1761 verticalScrollBar()->addPage();
1762 break; 1762 break;
1763 case Key_PageUp: 1763 case Key_PageUp:
1764 verticalScrollBar()->subtractPage(); 1764 verticalScrollBar()->subtractPage();
1765 break; 1765 break;
1766 case Key_Down: 1766 case Key_Down:
1767 verticalScrollBar()->addLine(); 1767 verticalScrollBar()->addLine();
1768 break; 1768 break;
1769 case Key_Up: 1769 case Key_Up:
1770 verticalScrollBar()->subtractLine(); 1770 verticalScrollBar()->subtractLine();
1771 break; 1771 break;
1772 default: 1772 default:
1773 ; 1773 ;
1774 } 1774 }
1775} 1775}
1776 1776
1777void KOAgenda::calculateWorkingHours() 1777void KOAgenda::calculateWorkingHours()
1778{ 1778{
1779// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 1779// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
1780 mWorkingHoursEnable = !mAllDayMode; 1780 mWorkingHoursEnable = !mAllDayMode;
1781 1781
1782 mWorkingHoursYTop = mGridSpacingY * 1782 mWorkingHoursYTop = mGridSpacingY *
1783 KOPrefs::instance()->mWorkingHoursStart * 4; 1783 KOPrefs::instance()->mWorkingHoursStart * 4;
1784 mWorkingHoursYBottom = mGridSpacingY * 1784 mWorkingHoursYBottom = mGridSpacingY *
1785 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 1785 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
1786} 1786}
1787 1787
1788 1788
1789DateList KOAgenda::dateList() const 1789DateList KOAgenda::dateList() const
1790{ 1790{
1791 return mSelectedDates; 1791 return mSelectedDates;
1792} 1792}
1793 1793
1794void KOAgenda::setDateList(const DateList &selectedDates) 1794void KOAgenda::setDateList(const DateList &selectedDates)
1795{ 1795{
1796 mSelectedDates = selectedDates; 1796 mSelectedDates = selectedDates;
1797 marcus_bains(); 1797 marcus_bains();
1798} 1798}
1799 1799
1800void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 1800void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
1801{ 1801{
1802 mHolidayMask = mask; 1802 mHolidayMask = mask;
1803 1803
1804/* 1804/*
1805 kdDebug() << "HolidayMask: "; 1805 kdDebug() << "HolidayMask: ";
1806 for(uint i=0;i<mask->count();++i) { 1806 for(uint i=0;i<mask->count();++i) {
1807 kdDebug() << (mask->at(i) ? "*" : "o"); 1807 kdDebug() << (mask->at(i) ? "*" : "o");
1808 } 1808 }
1809 kdDebug() << endl; 1809 kdDebug() << endl;
1810*/ 1810*/
1811} 1811}
1812 1812
1813void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 1813void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
1814{ 1814{
1815 1815
1816 QScrollView::contentsMousePressEvent(event); 1816 QScrollView::contentsMousePressEvent(event);
1817} 1817}
1818 1818
1819void KOAgenda::storePosition() 1819void KOAgenda::storePosition()
1820{ 1820{
1821 //mContentPosition 1821 //mContentPosition
1822 int max = mGridSpacingY*4*24; 1822 int max = mGridSpacingY*4*24;
1823 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 1823 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
1824 mContentPosition = 0; 1824 mContentPosition = 0;
1825 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 1825 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
1826 mContentPosition = -1.0; 1826 mContentPosition = -1.0;
1827 else 1827 else
1828 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 1828 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
1829 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 1829 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
1830 1830
1831} 1831}
1832void KOAgenda::restorePosition() 1832void KOAgenda::restorePosition()
1833{ 1833{
1834 int posY; 1834 int posY;
1835 int max = mGridSpacingY*4*24; 1835 int max = mGridSpacingY*4*24;
1836 if ( mContentPosition < 0 ) 1836 if ( mContentPosition < 0 )
1837 posY = max-viewport()->height(); 1837 posY = max-viewport()->height();
1838 else 1838 else
1839 if ( mContentPosition == 0 ) 1839 if ( mContentPosition == 0 )
1840 posY = 0; 1840 posY = 0;
1841 else 1841 else
1842 posY = (max/mContentPosition)-(viewport()->height()/2); 1842 posY = (max/mContentPosition)-(viewport()->height()/2);
1843 setContentsPos (0, posY ); 1843 setContentsPos (0, posY );
1844 //qDebug("posY %d hei %d", posY, max); 1844 //qDebug("posY %d hei %d", posY, max);
1845 1845
1846} 1846}
1847void KOAgenda::moveChild( QWidget *w, int x , int y ) 1847void KOAgenda::moveChild( QWidget *w, int x , int y )
1848{ 1848{
1849 ++x; 1849 ++x;
1850 QScrollView::moveChild( w, x , y ); 1850 QScrollView::moveChild( w, x , y );
1851} 1851}
1852#include <qmessagebox.h> 1852#include <qmessagebox.h>
1853#ifdef DESKTOP_VERSION 1853#ifdef DESKTOP_VERSION
1854#include <qprinter.h> 1854#include <qprinter.h>
1855#include <qpainter.h> 1855#include <qpainter.h>
1856#include <qpaintdevicemetrics.h> 1856#include <qpaintdevicemetrics.h>
1857 1857
1858#endif 1858#endif
1859void KOAgenda::printSelection() 1859void KOAgenda::printSelection()
1860{ 1860{
1861#ifdef DESKTOP_VERSION 1861#ifdef DESKTOP_VERSION
1862 if ( mStartCellY == mCurrentCellY ) { 1862 if ( mStartCellY == mCurrentCellY ) {
1863 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1863 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1864 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), 1864 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "),
1865 i18n("OK"), 0, 0, 1865 i18n("OK"), 0, 0,
1866 0, 1 ); 1866 0, 1 );
1867 return; 1867 return;
1868 } 1868 }
1869 1869
1870 float dx, dy; 1870 float dx, dy;
1871 int x,y,w,h; 1871 int x,y,w,h;
1872 x= 0; 1872 x= 0;
1873 w= contentsWidth()+2; 1873 w= contentsWidth()+2;
1874 // h= contentsHeight(); 1874 // h= contentsHeight();
1875 y = mGridSpacingY*mStartCellY; 1875 y = mGridSpacingY*mStartCellY;
1876 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 1876 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
1877 1877
1878 //return; 1878 //return;
1879 QPrinter* printer = new QPrinter(); 1879 QPrinter* printer = new QPrinter();
1880 if ( !printer->setup()) { 1880 if ( !printer->setup()) {
1881 delete printer; 1881 delete printer;
1882 return; 1882 return;
1883 } 1883 }
1884 QPainter p( printer ); 1884 QPainter p( printer );
1885 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 1885 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
1886 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); 1886 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
1887 date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 1887 date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
1888 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); 1888 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
1889 // p.drawText( 0, 0, date ); 1889 // p.drawText( 0, 0, date );
1890 int offset = m.width()/8; 1890 int offset = m.width()/8;
1891 // compute the scale 1891 // compute the scale
1892 dx = ((float) m.width()-offset) / (float)w; 1892 dx = ((float) m.width()-offset) / (float)w;
1893 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 1893 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
1894 float scale; 1894 float scale;
1895 // scale to fit the width or height of the paper 1895 // scale to fit the width or height of the paper
1896 if ( dx < dy ) 1896 if ( dx < dy )
1897 scale = dx; 1897 scale = dx;
1898 else 1898 else
1899 scale = dy; 1899 scale = dy;
1900 // set the scale 1900 // set the scale
1901 p.drawText( offset* scale, offset* scale*3/4, date ); 1901 p.drawText( offset* scale, offset* scale*3/4, date );
1902 1902
1903 int selDay; 1903 int selDay;
1904 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); 1904 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count()));
1905 float startX = 1; 1905 float startX = 1;
1906 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1906 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1907 { 1907 {
1908 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); 1908 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true );
1909 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); 1909 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) );
1910 p.drawText( offset* scale+startX, (offset+hei)* scale, text ); 1910 p.drawText( offset* scale+startX, (offset+hei)* scale, text );
1911 startX += widOffset; 1911 startX += widOffset;
1912 1912
1913 } 1913 }
1914 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); 1914 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale));
1915 p.scale( scale, scale ); 1915 p.scale( scale, scale );
1916 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); 1916 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale );
1917 // now printing with y offset: 2 hei 1917 // now printing with y offset: 2 hei
1918 // p.translate( 0, -y*scale); 1918 // p.translate( 0, -y*scale);
1919 1919
1920 drawContentsToPainter(&p, true ); 1920 drawContentsToPainter(&p, true );
1921 globalFlagBlockAgendaItemUpdate = false; 1921 globalFlagBlockAgendaItemUpdate = false;
1922 KOAgendaItem *item; 1922 KOAgendaItem *item;
1923 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1923 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1924 item->select(false); 1924 item->select(false);
1925 item->paintMe( false, &p ); 1925 item->paintMe( false, &p );
1926 } 1926 }
1927 globalFlagBlockAgendaItemUpdate = true; 1927 globalFlagBlockAgendaItemUpdate = true;
1928 p.end(); 1928 p.end();
1929 delete printer; 1929 delete printer;
1930#else 1930#else
1931 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1931 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1932 i18n("Not supported \non PDA!\n"), 1932 i18n("Not supported \non PDA!\n"),
1933 i18n("OK"), 0, 0, 1933 i18n("OK"), 0, 0,
1934 0, 1 ); 1934 0, 1 );
1935#endif 1935#endif
1936} 1936}
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 6965ba7..62281d4 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,722 +1,722 @@
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 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#define AGENDA_ICON_SIZE 7 38#define AGENDA_ICON_SIZE 7
39#endif 39#endif
40#include <libkcal/icaldrag.h> 40#include <libkcal/icaldrag.h>
41#include <libkcal/vcaldrag.h> 41#include <libkcal/vcaldrag.h>
42#include <libkcal/kincidenceformatter.h> 42#include <libkcal/kincidenceformatter.h>
43extern int globalFlagBlockAgenda; 43extern int globalFlagBlockAgenda;
44extern int globalFlagBlockAgendaItemPaint; 44extern int globalFlagBlockAgendaItemPaint;
45extern int globalFlagBlockAgendaItemUpdate; 45extern int globalFlagBlockAgendaItemUpdate;
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "koagendaitem.h" 49#include "koagendaitem.h"
50//#include "koagendaitem.moc" 50//#include "koagendaitem.moc"
51 51
52 52
53//-------------------------------------------------------------------------- 53//--------------------------------------------------------------------------
54 54
55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
56 56
57//-------------------------------------------------------------------------- 57//--------------------------------------------------------------------------
58 58
59KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 59KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
60 const char *name,WFlags) : 60 const char *name,WFlags) :
61 QWidget(parent, name), mIncidence(incidence), mDate(qd) 61 QWidget(parent, name), mIncidence(incidence), mDate(qd)
62{ 62{
63#ifndef DESKTOP_VERSION 63#ifndef DESKTOP_VERSION
64 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 64 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
65#endif 65#endif
66 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 66 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
67 setWFlags ( wflags); 67 setWFlags ( wflags);
68 mAllDay = allday; 68 mAllDay = allday;
69 init ( incidence, qd ); 69 init ( incidence, qd );
70 setMouseTracking(true); 70 setMouseTracking(true);
71 //setAcceptDrops(true); 71 //setAcceptDrops(true);
72 xPaintCoord = -1; 72 xPaintCoord = -1;
73 yPaintCoord = -1; 73 yPaintCoord = -1;
74} 74}
75 75
76void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 76void KOAgendaItem::init ( Incidence *incidence, QDate qd )
77{ 77{
78 mIncidence = incidence; 78 mIncidence = incidence;
79 mDate = qd; 79 mDate = qd;
80 mFirstMultiItem = 0; 80 mFirstMultiItem = 0;
81 mNextMultiItem = 0; 81 mNextMultiItem = 0;
82 mLastMultiItem = 0; 82 mLastMultiItem = 0;
83 computeText(); 83 computeText();
84 84
85 if ( (incidence->type() == "Todo") && 85 if ( (incidence->type() == "Todo") &&
86 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 86 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
87 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 87 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
88 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 88 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
89 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 89 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
90 else 90 else
91 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 91 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
92 } 92 }
93 else { 93 else {
94 QStringList categories = mIncidence->categories(); 94 QStringList categories = mIncidence->categories();
95 QString cat = categories.first(); 95 QString cat = categories.first();
96 if (cat.isEmpty()) { 96 if (cat.isEmpty()) {
97 mBackgroundColor =KOPrefs::instance()->mEventColor; 97 mBackgroundColor =KOPrefs::instance()->mEventColor;
98 } else { 98 } else {
99 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 99 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
100 } 100 }
101 } 101 }
102 mColorGroup = QColorGroup( mBackgroundColor.light(), 102 mColorGroup = QColorGroup( mBackgroundColor.light(),
103 mBackgroundColor.dark(),mBackgroundColor.light(), 103 mBackgroundColor.dark(),mBackgroundColor.light(),
104 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 104 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
105 setBackgroundColor( mBackgroundColor ); 105 setBackgroundColor( mBackgroundColor );
106 106
107 setCellXY(0,0,1); 107 setCellXY(0,0,1);
108 setCellXWidth(0); 108 setCellXWidth(0);
109 setSubCell(0); 109 setSubCell(0);
110 setSubCells(1); 110 setSubCells(1);
111 setMultiItem(0,0,0); 111 setMultiItem(0,0,0);
112 startMove(); 112 startMove();
113 mSelected = true; 113 mSelected = true;
114 select(false); 114 select(false);
115 QString tipText = mIncidence->summary(); 115 QString tipText = mIncidence->summary();
116 // QToolTip::add(this,tipText); 116 // QToolTip::add(this,tipText);
117 QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 117 QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
118 if ( !mIncidence->doesFloat() ) 118 if ( !mIncidence->doesFloat() )
119 if ( mIncidence->type() == "Event" ) { 119 if ( mIncidence->type() == "Event" ) {
120 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 120 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
121 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 121 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
122 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 122 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
123 } 123 }
124 else { 124 else {
125 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 125 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
126 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 126 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
127 } 127 }
128 } 128 }
129 else if ( mIncidence->type() == "Todo" ) { 129 else if ( mIncidence->type() == "Todo" ) {
130 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr(); 130 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr();
131 } 131 }
132 132
133 if (!mIncidence->location().isEmpty()) { 133 if (!mIncidence->location().isEmpty()) {
134 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 134 tipText += "\n"+i18n("Location: ")+mIncidence->location();
135 } 135 }
136 QToolTip::add(this,tipText,toolTipGroup(),""); 136 QToolTip::add(this,tipText,toolTipGroup(),"");
137 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 137 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
138 mFontPixelSize = fontinf.height();; 138 mFontPixelSize = fontinf.height();;
139 hide(); 139 hide();
140 xPaintCoord = -1; 140 xPaintCoord = -1;
141 yPaintCoord = -1; 141 yPaintCoord = -1;
142} 142}
143 143
144 144
145KOAgendaItem::~KOAgendaItem() 145KOAgendaItem::~KOAgendaItem()
146{ 146{
147 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 147 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
148 148
149} 149}
150 150
151void KOAgendaItem::recreateIncidence() 151void KOAgendaItem::recreateIncidence()
152{ 152{
153#if 0 153#if 0
154 Incidence* newInc = mIncidence->clone(); 154 Incidence* newInc = mIncidence->clone();
155 newInc->recreate(); 155 newInc->recreate();
156 if ( mIncidence->doesRecur() ) { 156 if ( mIncidence->doesRecur() ) {
157 mIncidence->addExDate( mDate ); 157 mIncidence->addExDate( mDate );
158 newInc->recurrence()->unsetRecurs(); 158 newInc->recurrence()->unsetRecurs();
159 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 159 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
160 QTime tim = mIncidence->dtStart().time(); 160 QTime tim = mIncidence->dtStart().time();
161 newInc->setDtStart( QDateTime(mDate, tim) ); 161 newInc->setDtStart( QDateTime(mDate, tim) );
162 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 162 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
163 } 163 }
164#endif 164#endif
165 mIncidence = mIncidence->recreateCloneException( mDate ); 165 mIncidence = mIncidence->recreateCloneException( mDate );
166} 166}
167bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 167bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
168{ 168{
169 int size = AGENDA_ICON_SIZE; 169 int size = AGENDA_ICON_SIZE;
170 170
171 int yOff = 0; 171 int yOff = 0;
172 int xOff = 0; 172 int xOff = 0;
173 int x = pos().x() +3; 173 int x = pos().x() +3;
174 int y; 174 int y;
175 if ( mAllDay ) 175 if ( mAllDay )
176 y = pos().y()+3; 176 y = pos().y()+3;
177 else 177 else
178 y = mCellYTop * ( height() / cellHeight() ) +3; 178 y = mCellYTop * ( height() / cellHeight() ) +3;
179 if (mIncidence->cancelled()) { 179 if (mIncidence->cancelled()) {
180 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 180 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
181 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 181 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
182 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 182 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
183 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 183 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
184 if ( horLayout ) 184 if ( horLayout )
185 ++xOff; 185 ++xOff;
186 else 186 else
187 ++yOff; 187 ++yOff;
188 } 188 }
189 if (mIncidence->isAlarmEnabled()) { 189 if (mIncidence->isAlarmEnabled()) {
190 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 190 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
191 if ( horLayout ) 191 if ( horLayout )
192 ++xOff; 192 ++xOff;
193 else 193 else
194 ++yOff; 194 ++yOff;
195 } 195 }
196 if (mIncidence->recurrence()->doesRecur()) { 196 if (mIncidence->recurrence()->doesRecur()) {
197 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 197 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
198 if ( horLayout ) 198 if ( horLayout )
199 ++xOff; 199 ++xOff;
200 else 200 else
201 ++yOff; 201 ++yOff;
202 } 202 }
203 if (mIncidence->description().length() > 0) { 203 if (mIncidence->description().length() > 0) {
204 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 204 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
205 if ( horLayout ) 205 if ( horLayout )
206 ++xOff; 206 ++xOff;
207 else 207 else
208 ++yOff; 208 ++yOff;
209 } 209 }
210 if (mIncidence->isReadOnly()) { 210 if (mIncidence->isReadOnly()) {
211 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 211 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
212 if ( horLayout ) 212 if ( horLayout )
213 ++xOff; 213 ++xOff;
214 else 214 else
215 ++yOff; 215 ++yOff;
216 } 216 }
217 217
218 if (mIncidence->attendeeCount()>0) { 218 if (mIncidence->attendeeCount()>0) {
219 219
220 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 220 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
222 if ( horLayout ) 222 if ( horLayout )
223 ++xOff; 223 ++xOff;
224 else 224 else
225 ++yOff; 225 ++yOff;
226 } else { 226 } else {
227 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 227 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
228 if (me!=0) { 228 if (me!=0) {
229 229
230 230
231 } else { 231 } else {
232 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 232 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
233 if ( horLayout ) 233 if ( horLayout )
234 ++xOff; 234 ++xOff;
235 else 235 else
236 ++yOff; 236 ++yOff;
237 237
238 } 238 }
239 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 239 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
240 if ( horLayout ) 240 if ( horLayout )
241 ++xOff; 241 ++xOff;
242 else 242 else
243 ++yOff; 243 ++yOff;
244 244
245 } 245 }
246 246
247 } 247 }
248 return ( yOff || xOff ); 248 return ( yOff || xOff );
249} 249}
250 250
251 251
252void KOAgendaItem::select(bool selected) 252void KOAgendaItem::select(bool selected)
253{ 253{
254 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 254 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
255 if (mSelected == selected) return; 255 if (mSelected == selected) return;
256 mSelected = selected; 256 mSelected = selected;
257 if ( ! isVisible() ) 257 if ( ! isVisible() )
258 return; 258 return;
259 if ( firstMultiItem() ) 259 if ( firstMultiItem() )
260 firstMultiItem()->select( selected ); 260 firstMultiItem()->select( selected );
261 if ( !firstMultiItem() && nextMultiItem() ) { 261 if ( !firstMultiItem() && nextMultiItem() ) {
262 KOAgendaItem * placeItem = nextMultiItem(); 262 KOAgendaItem * placeItem = nextMultiItem();
263 while ( placeItem ) { 263 while ( placeItem ) {
264 placeItem->select( selected ); 264 placeItem->select( selected );
265 placeItem = placeItem->nextMultiItem(); 265 placeItem = placeItem->nextMultiItem();
266 } 266 }
267 } 267 }
268 globalFlagBlockAgendaItemUpdate = 0; 268 globalFlagBlockAgendaItemUpdate = 0;
269 paintMe( selected ); 269 paintMe( selected );
270 globalFlagBlockAgendaItemUpdate = 1; 270 globalFlagBlockAgendaItemUpdate = 1;
271 repaint( false ); 271 repaint( false );
272} 272}
273 273
274 274
275/* 275/*
276 The eventFilter has to filter the mouse events of the agenda item childs. The 276 The eventFilter has to filter the mouse events of the agenda item childs. The
277 events are fed into the event handling method of KOAgendaItem. This allows the 277 events are fed into the event handling method of KOAgendaItem. This allows the
278 KOAgenda to handle the KOAgendaItems by using an eventFilter. 278 KOAgenda to handle the KOAgendaItems by using an eventFilter.
279*/ 279*/
280bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 280bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
281{ 281{
282 if (e->type() == QEvent::MouseButtonPress || 282 if (e->type() == QEvent::MouseButtonPress ||
283 e->type() == QEvent::MouseButtonDblClick || 283 e->type() == QEvent::MouseButtonDblClick ||
284 e->type() == QEvent::MouseButtonRelease || 284 e->type() == QEvent::MouseButtonRelease ||
285 e->type() == QEvent::MouseMove) { 285 e->type() == QEvent::MouseMove) {
286 QMouseEvent *me = (QMouseEvent *)e; 286 QMouseEvent *me = (QMouseEvent *)e;
287 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 287 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
288 mapToGlobal(me->pos())); 288 mapToGlobal(me->pos()));
289 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 289 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
290 return event(&returnEvent); 290 return event(&returnEvent);
291 } else { 291 } else {
292 return false; 292 return false;
293 } 293 }
294} 294}
295void KOAgendaItem::repaintMe( ) 295void KOAgendaItem::repaintMe( )
296{ 296{
297 paintMe ( mSelected ); 297 paintMe ( mSelected );
298} 298}
299void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 299void KOAgendaItem::paintMe( bool selected, QPainter* paint )
300{ 300{
301 if ( globalFlagBlockAgendaItemUpdate && ! selected) 301 if ( globalFlagBlockAgendaItemUpdate && ! selected)
302 return; 302 return;
303 QPainter pa; 303 QPainter pa;
304 304
305 if ( mSelected ) { 305 if ( mSelected ) {
306 pa.begin( paintPixSel() ); 306 pa.begin( paintPixSel() );
307 } else { 307 } else {
308 if ( mAllDay ) 308 if ( mAllDay )
309 pa.begin( paintPixAllday() ); 309 pa.begin( paintPixAllday() );
310 else 310 else
311 pa.begin( paintPix() ); 311 pa.begin( paintPix() );
312 } 312 }
313 int x, yy, w, h; 313 int x, yy, w, h;
314 float nfh; 314 float nfh;
315 x = pos().x(); w = width(); h = height (); 315 x = pos().x(); w = width(); h = height ();
316 if ( mAllDay ) 316 if ( mAllDay )
317 yy = y(); 317 yy = y();
318 else 318 else
319 yy = mCellYTop * ( height() / cellHeight() ); 319 yy = mCellYTop * ( height() / cellHeight() );
320 xPaintCoord= x; 320 xPaintCoord= x;
321 yPaintCoord = yy; 321 yPaintCoord = yy;
322 wPaintCoord = width(); 322 wPaintCoord = width();
323 hPaintCoord = height(); 323 hPaintCoord = height();
324 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 324 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
325 if ( paint == 0 ) 325 if ( paint == 0 )
326 paint = &pa; 326 paint = &pa;
327 bool horLayout = ( w < h ); 327 bool horLayout = ( w < h );
328 int maxhei = mFontPixelSize+4; 328 int maxhei = mFontPixelSize+4;
329 if ( horLayout ) 329 if ( horLayout )
330 maxhei += AGENDA_ICON_SIZE -4; 330 maxhei += AGENDA_ICON_SIZE -4;
331 bool small = ( h < maxhei ); 331 bool small = ( h < maxhei );
332 if ( ! small ) 332 if ( ! small )
333 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 333 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
334 else { 334 else {
335 QFont f = KOPrefs::instance()->mAgendaViewFont; 335 QFont f = KOPrefs::instance()->mAgendaViewFont;
336 f.setBold( false ); 336 f.setBold( false );
337 int fh = f.pointSize(); 337 int fh = f.pointSize();
338 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 338 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
339 if ( nfh < 6 ) 339 if ( nfh < 6 )
340 nfh = 6; 340 nfh = 6;
341 f.setPointSize( nfh ); 341 f.setPointSize( nfh );
342 paint->setFont(f); 342 paint->setFont(f);
343 } 343 }
344 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 344 paint->fillRect ( x, yy, w, h, mBackgroundColor );
345 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 345 static const QPixmap completedPxmp = SmallIcon("greenhook16");
346 static const QPixmap overduePxmp = SmallIcon("redcross16"); 346 static const QPixmap overduePxmp = SmallIcon("redcross16");
347 if ( mIncidence->type() == "Todo" ) { 347 if ( mIncidence->type() == "Todo" ) {
348 Todo* tempTodo = static_cast<Todo*>(mIncidence); 348 Todo* tempTodo = static_cast<Todo*>(mIncidence);
349 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 349 int xx = pos().x()+(width()-completedPxmp.width()-3 );
350 int yyy = yy+3; 350 int yyy = yy+3;
351 if ( tempTodo->isCompleted() ) 351 if ( tempTodo->isCompleted() )
352 paint->drawPixmap ( xx, yyy, completedPxmp ); 352 paint->drawPixmap ( xx, yyy, completedPxmp );
353 else { 353 else {
354 paint->drawPixmap ( xx, yyy, overduePxmp ); 354 paint->drawPixmap ( xx, yyy, overduePxmp );
355 355
356 } 356 }
357 } 357 }
358 bool addIcon = false; 358 bool addIcon = false;
359 if ( ! small || w > 3 * h || h > 3* w ) 359 if ( ! small || w > 3 * h || h > 3* w )
360 addIcon = updateIcons( paint, horLayout ); 360 addIcon = updateIcons( paint, horLayout );
361 361
362 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 362 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
363 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 363 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
364 if ( ! small ) { 364 if ( ! small ) {
365 x += 3; yy += 3;w -= 6; h-= 5; 365 x += 3; yy += 3;w -= 6; h-= 5;
366 } else { 366 } else {
367 x += 2; yy += 1;w -= 4; h-= 4; 367 x += 2; yy += 1;w -= 4; h-= 4;
368 if ( nfh < 6.01 ) { 368 if ( nfh < 6.01 ) {
369 yy -= 2; 369 yy -= 2;
370 h += 4; 370 h += 4;
371 } 371 }
372 else 372 else
373 if ( nfh < h -2 ) 373 if ( nfh < h -2 )
374 ++yy; 374 ++yy;
375 } 375 }
376 int align; 376 int align;
377#ifndef DESKTOP_VERSION 377#ifndef DESKTOP_VERSION
378 align = ( AlignLeft|WordBreak|AlignTop); 378 align = ( AlignLeft|WordBreak|AlignTop);
379#else 379#else
380 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 380 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
381#endif 381#endif
382 if ( addIcon ) { 382 if ( addIcon ) {
383 if ( ! horLayout ) { 383 if ( ! horLayout ) {
384 x += AGENDA_ICON_SIZE+3; 384 x += AGENDA_ICON_SIZE+3;
385 w -= (AGENDA_ICON_SIZE+3); 385 w -= (AGENDA_ICON_SIZE+3);
386 } 386 }
387 else { 387 else {
388 yy+= AGENDA_ICON_SIZE+2; 388 yy+= AGENDA_ICON_SIZE+2;
389 h -=(AGENDA_ICON_SIZE+3); 389 h -=(AGENDA_ICON_SIZE+3);
390 } 390 }
391 } 391 }
392 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 392 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
393 if ( colsum < 250 ) 393 if ( colsum < 250 )
394 paint->setPen ( white); 394 paint->setPen ( white);
395 if ( x < 0 ) { 395 if ( x < 0 ) {
396 w = w+x-3; 396 w = w+x-3;
397 x = 3; 397 x = 3;
398 if ( w > parentWidget()->width() ){ 398 if ( w > parentWidget()->width() ){
399 w = parentWidget()->width() - 6; 399 w = parentWidget()->width() - 6;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 align = ( AlignCenter|WordBreak); 401 align = ( AlignCenter|WordBreak);
402#else 402#else
403 align = ( AlignCenter|BreakAnywhere|WordBreak); 403 align = ( AlignCenter|BreakAnywhere|WordBreak);
404#endif 404#endif
405 405
406 } 406 }
407 } 407 }
408 QRect dr; 408 QRect dr;
409 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 409 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
410 if ( mIncidence->cancelled() ){ 410 if ( mIncidence->cancelled() ){
411 if ( ! small ) { 411 if ( ! small ) {
412 QFontMetrics fm ( paint->font() ); 412 QFontMetrics fm ( paint->font() );
413 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 413 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
414 } 414 }
415 415
416 } 416 }
417 pa.end(); 417 pa.end();
418 418
419} 419}
420void KOAgendaItem::resizePixmap( int w , int h ) 420void KOAgendaItem::resizePixmap( int w , int h )
421{ 421{
422 paintPix()->resize( w, h ); 422 paintPix()->resize( w, h );
423 paintPixSel()->resize( w, h ); 423 paintPixSel()->resize( w, h );
424 424
425} 425}
426QPixmap * KOAgendaItem::paintPix() 426QPixmap * KOAgendaItem::paintPix()
427{ 427{
428 static QPixmap* mPaintPix = 0; 428 static QPixmap* mPaintPix = 0;
429 if ( ! mPaintPix ) 429 if ( ! mPaintPix )
430 mPaintPix = new QPixmap(); 430 mPaintPix = new QPixmap(1,1);
431 return mPaintPix ; 431 return mPaintPix ;
432} 432}
433QPixmap * KOAgendaItem::paintPixAllday() 433QPixmap * KOAgendaItem::paintPixAllday()
434{ 434{
435 static QPixmap* mPaintPixA = 0; 435 static QPixmap* mPaintPixA = 0;
436 if ( ! mPaintPixA ) 436 if ( ! mPaintPixA )
437 mPaintPixA = new QPixmap(); 437 mPaintPixA = new QPixmap(1,1);
438 return mPaintPixA ; 438 return mPaintPixA ;
439} 439}
440QPixmap * KOAgendaItem::paintPixSel() 440QPixmap * KOAgendaItem::paintPixSel()
441{ 441{
442 static QPixmap* mPaintPixSel = 0; 442 static QPixmap* mPaintPixSel = 0;
443 if ( ! mPaintPixSel ) 443 if ( ! mPaintPixSel )
444 mPaintPixSel = new QPixmap(); 444 mPaintPixSel = new QPixmap(1,1);
445 return mPaintPixSel ; 445 return mPaintPixSel ;
446} 446}
447void KOAgendaItem::paintEvent ( QPaintEvent *e ) 447void KOAgendaItem::paintEvent ( QPaintEvent *e )
448{ 448{
449 449
450 if ( globalFlagBlockAgendaItemPaint ) 450 if ( globalFlagBlockAgendaItemPaint )
451 return; 451 return;
452 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 452 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
453 return; 453 return;
454 int yy; 454 int yy;
455 if ( mAllDay ) 455 if ( mAllDay )
456 yy = y(); 456 yy = y();
457 else 457 else
458 yy = mCellYTop * ( height() / cellHeight() ); 458 yy = mCellYTop * ( height() / cellHeight() );
459 int xx = x(); 459 int xx = x();
460 if ( xPaintCoord != xx || yPaintCoord != yy || 460 if ( xPaintCoord != xx || yPaintCoord != yy ||
461 wPaintCoord != width() || hPaintCoord != height()) { 461 wPaintCoord != width() || hPaintCoord != height()) {
462 xPaintCoord= xx; 462 xPaintCoord= xx;
463 yPaintCoord = yy; 463 yPaintCoord = yy;
464 wPaintCoord = width(); 464 wPaintCoord = width();
465 hPaintCoord = height(); 465 hPaintCoord = height();
466 globalFlagBlockAgendaItemUpdate = 0; 466 globalFlagBlockAgendaItemUpdate = 0;
467 paintMe( mSelected ); 467 paintMe( mSelected );
468 //qDebug("calling paintMe "); 468 //qDebug("calling paintMe ");
469 globalFlagBlockAgendaItemUpdate = 1; 469 globalFlagBlockAgendaItemUpdate = 1;
470 } 470 }
471 int rx, ry, rw, rh; 471 int rx, ry, rw, rh;
472 rx = e->rect().x(); 472 rx = e->rect().x();
473 ry = e->rect().y(); 473 ry = e->rect().y();
474 rw = e->rect().width(); 474 rw = e->rect().width();
475 rh = e->rect().height(); 475 rh = e->rect().height();
476 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 476 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
477 477
478 QPixmap* paintFrom ; 478 QPixmap* paintFrom ;
479 if ( mSelected ) { 479 if ( mSelected ) {
480 paintFrom = paintPixSel(); 480 paintFrom = paintPixSel();
481 } else { 481 } else {
482 if ( mAllDay ) 482 if ( mAllDay )
483 paintFrom = paintPixAllday(); 483 paintFrom = paintPixAllday();
484 else 484 else
485 paintFrom = paintPix(); 485 paintFrom = paintPix();
486 } 486 }
487 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); 487 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP);
488} 488}
489void KOAgendaItem::computeText() 489void KOAgendaItem::computeText()
490{ 490{
491 mDisplayedText = mIncidence->summary(); 491 mDisplayedText = mIncidence->summary();
492 if ( (mIncidence->type() == "Todo") ) { 492 if ( (mIncidence->type() == "Todo") ) {
493 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 493 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
494 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 494 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
495 else if ( !(mIncidence->doesFloat())) 495 else if ( !(mIncidence->doesFloat()))
496 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 496 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
497 497
498 498
499 499
500 } else { 500 } else {
501 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 501 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
502 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 502 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
503 503
504 if ( mAllDay ) { 504 if ( mAllDay ) {
505 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 505 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
506 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 506 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
507 } 507 }
508 } 508 }
509 509
510 } 510 }
511 511
512 if ( !mIncidence->location().isEmpty() ) { 512 if ( !mIncidence->location().isEmpty() ) {
513 if ( mAllDay ) 513 if ( mAllDay )
514 mDisplayedText += " ("; 514 mDisplayedText += " (";
515 else 515 else
516 mDisplayedText += "\n("; 516 mDisplayedText += "\n(";
517 mDisplayedText += mIncidence->location() +")"; 517 mDisplayedText += mIncidence->location() +")";
518 } 518 }
519} 519}
520void KOAgendaItem::updateItem() 520void KOAgendaItem::updateItem()
521{ 521{
522 computeText(); 522 computeText();
523 523
524 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 524 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
525 paintMe( mSelected ); 525 paintMe( mSelected );
526 repaint( false); 526 repaint( false);
527} 527}
528 528
529void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 529void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
530{ 530{
531 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 531 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
532 paintMe( mSelected ); 532 paintMe( mSelected );
533 repaint( false ); 533 repaint( false );
534} 534}
535 535
536/* 536/*
537 Return height of item in units of agenda cells 537 Return height of item in units of agenda cells
538*/ 538*/
539int KOAgendaItem::cellHeight() 539int KOAgendaItem::cellHeight()
540{ 540{
541 int ret = mCellYBottom - mCellYTop + 1; 541 int ret = mCellYBottom - mCellYTop + 1;
542 if ( ret <= 0 ) { 542 if ( ret <= 0 ) {
543 ret = 1; 543 ret = 1;
544 mCellYBottom = 0; 544 mCellYBottom = 0;
545 mCellYTop = 0; 545 mCellYTop = 0;
546 } 546 }
547 return ret; 547 return ret;
548} 548}
549 549
550/* 550/*
551 Return height of item in units of agenda cells 551 Return height of item in units of agenda cells
552*/ 552*/
553int KOAgendaItem::cellWidth() 553int KOAgendaItem::cellWidth()
554{ 554{
555 return mCellXWidth - mCellX + 1; 555 return mCellXWidth - mCellX + 1;
556} 556}
557 557
558void KOAgendaItem::setItemDate(QDate qd) 558void KOAgendaItem::setItemDate(QDate qd)
559{ 559{
560 mDate = qd; 560 mDate = qd;
561} 561}
562 562
563void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 563void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
564{ 564{
565 mCellX = X; 565 mCellX = X;
566 mCellYTop = YTop; 566 mCellYTop = YTop;
567 mCellYBottom = YBottom; 567 mCellYBottom = YBottom;
568} 568}
569 569
570void KOAgendaItem::setCellXWidth(int xwidth) 570void KOAgendaItem::setCellXWidth(int xwidth)
571{ 571{
572 mCellXWidth = xwidth; 572 mCellXWidth = xwidth;
573} 573}
574 574
575void KOAgendaItem::setCellX(int XLeft, int XRight) 575void KOAgendaItem::setCellX(int XLeft, int XRight)
576{ 576{
577 mCellX = XLeft; 577 mCellX = XLeft;
578 mCellXWidth = XRight; 578 mCellXWidth = XRight;
579} 579}
580 580
581void KOAgendaItem::setCellY(int YTop, int YBottom) 581void KOAgendaItem::setCellY(int YTop, int YBottom)
582{ 582{
583 mCellYTop = YTop; 583 mCellYTop = YTop;
584 mCellYBottom = YBottom; 584 mCellYBottom = YBottom;
585} 585}
586 586
587void KOAgendaItem::setSubCell(int subCell) 587void KOAgendaItem::setSubCell(int subCell)
588{ 588{
589 mSubCell = subCell; 589 mSubCell = subCell;
590} 590}
591 591
592void KOAgendaItem::setSubCells(int subCells) 592void KOAgendaItem::setSubCells(int subCells)
593{ 593{
594 mSubCells = subCells; 594 mSubCells = subCells;
595} 595}
596 596
597void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 597void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
598 KOAgendaItem *last) 598 KOAgendaItem *last)
599{ 599{
600 mFirstMultiItem = first; 600 mFirstMultiItem = first;
601 mNextMultiItem = next; 601 mNextMultiItem = next;
602 mLastMultiItem = last; 602 mLastMultiItem = last;
603} 603}
604 604
605void KOAgendaItem::startMove() 605void KOAgendaItem::startMove()
606{ 606{
607 mStartCellX = mCellX; 607 mStartCellX = mCellX;
608 mStartCellXWidth = mCellXWidth; 608 mStartCellXWidth = mCellXWidth;
609 mStartCellYTop = mCellYTop; 609 mStartCellYTop = mCellYTop;
610 mStartCellYBottom = mCellYBottom; 610 mStartCellYBottom = mCellYBottom;
611} 611}
612 612
613void KOAgendaItem::resetMove() 613void KOAgendaItem::resetMove()
614{ 614{
615 mCellX = mStartCellX; 615 mCellX = mStartCellX;
616 mCellXWidth = mStartCellXWidth; 616 mCellXWidth = mStartCellXWidth;
617 mCellYTop = mStartCellYTop; 617 mCellYTop = mStartCellYTop;
618 mCellYBottom = mStartCellYBottom; 618 mCellYBottom = mStartCellYBottom;
619} 619}
620 620
621void KOAgendaItem::moveRelative(int dx, int dy) 621void KOAgendaItem::moveRelative(int dx, int dy)
622{ 622{
623 int newX = cellX() + dx; 623 int newX = cellX() + dx;
624 int newXWidth = cellXWidth() + dx; 624 int newXWidth = cellXWidth() + dx;
625 int newYTop = cellYTop() + dy; 625 int newYTop = cellYTop() + dy;
626 int newYBottom = cellYBottom() + dy; 626 int newYBottom = cellYBottom() + dy;
627 setCellXY(newX,newYTop,newYBottom); 627 setCellXY(newX,newYTop,newYBottom);
628 setCellXWidth(newXWidth); 628 setCellXWidth(newXWidth);
629} 629}
630 630
631void KOAgendaItem::expandTop(int dy) 631void KOAgendaItem::expandTop(int dy)
632{ 632{
633 int newYTop = cellYTop() + dy; 633 int newYTop = cellYTop() + dy;
634 int newYBottom = cellYBottom(); 634 int newYBottom = cellYBottom();
635 if (newYTop > newYBottom) newYTop = newYBottom; 635 if (newYTop > newYBottom) newYTop = newYBottom;
636 setCellY(newYTop, newYBottom); 636 setCellY(newYTop, newYBottom);
637} 637}
638 638
639void KOAgendaItem::expandBottom(int dy) 639void KOAgendaItem::expandBottom(int dy)
640{ 640{
641 int newYTop = cellYTop(); 641 int newYTop = cellYTop();
642 int newYBottom = cellYBottom() + dy; 642 int newYBottom = cellYBottom() + dy;
643 if (newYBottom < newYTop) newYBottom = newYTop; 643 if (newYBottom < newYTop) newYBottom = newYTop;
644 setCellY(newYTop, newYBottom); 644 setCellY(newYTop, newYBottom);
645} 645}
646 646
647void KOAgendaItem::expandLeft(int dx) 647void KOAgendaItem::expandLeft(int dx)
648{ 648{
649 int newX = cellX() + dx; 649 int newX = cellX() + dx;
650 int newXWidth = cellXWidth(); 650 int newXWidth = cellXWidth();
651 if (newX > newXWidth) newX = newXWidth; 651 if (newX > newXWidth) newX = newXWidth;
652 setCellX(newX,newXWidth); 652 setCellX(newX,newXWidth);
653} 653}
654 654
655void KOAgendaItem::expandRight(int dx) 655void KOAgendaItem::expandRight(int dx)
656{ 656{
657 int newX = cellX(); 657 int newX = cellX();
658 int newXWidth = cellXWidth() + dx; 658 int newXWidth = cellXWidth() + dx;
659 if (newXWidth < newX) newXWidth = newX; 659 if (newXWidth < newX) newXWidth = newX;
660 setCellX(newX,newXWidth); 660 setCellX(newX,newXWidth);
661} 661}
662 662
663QToolTipGroup *KOAgendaItem::toolTipGroup() 663QToolTipGroup *KOAgendaItem::toolTipGroup()
664{ 664{
665 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 665 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
666 return mToolTipGroup; 666 return mToolTipGroup;
667} 667}
668 668
669void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 669void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
670{ 670{
671#ifndef KORG_NODND 671#ifndef KORG_NODND
672 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 672 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
673 !QTextDrag::canDecode( e ) ) { 673 !QTextDrag::canDecode( e ) ) {
674 e->ignore(); 674 e->ignore();
675 return; 675 return;
676 } 676 }
677 e->accept(); 677 e->accept();
678#endif 678#endif
679} 679}
680 680
681void KOAgendaItem::dropEvent( QDropEvent *e ) 681void KOAgendaItem::dropEvent( QDropEvent *e )
682{ 682{
683#ifndef KORG_NODND 683#ifndef KORG_NODND
684 QString text; 684 QString text;
685 if(QTextDrag::decode(e,text)) 685 if(QTextDrag::decode(e,text))
686 { 686 {
687 kdDebug() << "Dropped : " << text << endl; 687 kdDebug() << "Dropped : " << text << endl;
688 QStringList emails = QStringList::split(",",text); 688 QStringList emails = QStringList::split(",",text);
689 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 689 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
690 kdDebug() << " Email: " << (*it) << endl; 690 kdDebug() << " Email: " << (*it) << endl;
691 int pos = (*it).find("<"); 691 int pos = (*it).find("<");
692 QString name = (*it).left(pos); 692 QString name = (*it).left(pos);
693 QString email = (*it).mid(pos); 693 QString email = (*it).mid(pos);
694 if (!email.isEmpty()) { 694 if (!email.isEmpty()) {
695 mIncidence->addAttendee(new Attendee(name,email)); 695 mIncidence->addAttendee(new Attendee(name,email));
696 } 696 }
697 } 697 }
698 } 698 }
699#endif 699#endif
700} 700}
701 701
702 702
703QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 703QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
704{ 704{
705 return mConflictItems; 705 return mConflictItems;
706} 706}
707 707
708void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 708void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
709{ 709{
710 mConflictItems = ci; 710 mConflictItems = ci;
711 KOAgendaItem *item; 711 KOAgendaItem *item;
712 for ( item=mConflictItems.first(); item != 0; 712 for ( item=mConflictItems.first(); item != 0;
713 item=mConflictItems.next() ) { 713 item=mConflictItems.next() ) {
714 item->addConflictItem(this); 714 item->addConflictItem(this);
715 } 715 }
716} 716}
717 717
718void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 718void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
719{ 719{
720 if (mConflictItems.find(ci)<0) 720 if (mConflictItems.find(ci)<0)
721 mConflictItems.append(ci); 721 mConflictItems.append(ci);
722} 722}
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 7c53948..6f68d84 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -579,894 +579,894 @@ int KSyncManager::ringSync()
579 mIsKapiFile = temp->getIsKapiFile(); 579 mIsKapiFile = temp->getIsKapiFile();
580 mWriteBackInFuture = 0; 580 mWriteBackInFuture = 0;
581 if ( temp->getWriteBackFuture() ) 581 if ( temp->getWriteBackFuture() )
582 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 582 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
583 mShowSyncSummary = false; 583 mShowSyncSummary = false;
584 mCurrentSyncDevice = syncProfileNames[i] ; 584 mCurrentSyncDevice = syncProfileNames[i] ;
585 mCurrentSyncName = mLocalMachineName; 585 mCurrentSyncName = mLocalMachineName;
586 if ( i == 0 ) { 586 if ( i == 0 ) {
587 mIsKapiFile = false; 587 mIsKapiFile = false;
588#ifdef DESKTOP_VERSION 588#ifdef DESKTOP_VERSION
589 syncKDE(); 589 syncKDE();
590#else 590#else
591 syncSharp(); 591 syncSharp();
592#endif 592#endif
593 } else { 593 } else {
594 if ( temp->getIsLocalFileSync() ) { 594 if ( temp->getIsLocalFileSync() ) {
595 switch(mTargetApp) 595 switch(mTargetApp)
596 { 596 {
597 case (KAPI): 597 case (KAPI):
598 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 598 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
599 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 599 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
600 break; 600 break;
601 case (KOPI): 601 case (KOPI):
602 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 602 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
603 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 603 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
604 break; 604 break;
605 case (PWMPI): 605 case (PWMPI):
606 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 606 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
607 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 607 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
608 break; 608 break;
609 default: 609 default:
610 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 610 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
611 break; 611 break;
612 } 612 }
613 } else { 613 } else {
614 if ( temp->getIsPhoneSync() ) { 614 if ( temp->getIsPhoneSync() ) {
615 mPhoneDevice = temp->getPhoneDevice( ) ; 615 mPhoneDevice = temp->getPhoneDevice( ) ;
616 mPhoneConnection = temp->getPhoneConnection( ); 616 mPhoneConnection = temp->getPhoneConnection( );
617 mPhoneModel = temp->getPhoneModel( ); 617 mPhoneModel = temp->getPhoneModel( );
618 syncPhone(); 618 syncPhone();
619 } else if ( temp->getIsPiSync() ) { 619 } else if ( temp->getIsPiSync() ) {
620 if ( mTargetApp == KAPI ) { 620 if ( mTargetApp == KAPI ) {
621 mPassWordPiSync = temp->getRemotePwAB(); 621 mPassWordPiSync = temp->getRemotePwAB();
622 mActiveSyncPort = temp->getRemotePortAB(); 622 mActiveSyncPort = temp->getRemotePortAB();
623 mActiveSyncIP = temp->getRemoteIPAB(); 623 mActiveSyncIP = temp->getRemoteIPAB();
624 } else if ( mTargetApp == KOPI ) { 624 } else if ( mTargetApp == KOPI ) {
625 mPassWordPiSync = temp->getRemotePw(); 625 mPassWordPiSync = temp->getRemotePw();
626 mActiveSyncPort = temp->getRemotePort(); 626 mActiveSyncPort = temp->getRemotePort();
627 mActiveSyncIP = temp->getRemoteIP(); 627 mActiveSyncIP = temp->getRemoteIP();
628 } else { 628 } else {
629 mPassWordPiSync = temp->getRemotePwPWM(); 629 mPassWordPiSync = temp->getRemotePwPWM();
630 mActiveSyncPort = temp->getRemotePortPWM(); 630 mActiveSyncPort = temp->getRemotePortPWM();
631 mActiveSyncIP = temp->getRemoteIPPWM(); 631 mActiveSyncIP = temp->getRemoteIPPWM();
632 } 632 }
633 syncPi(); 633 syncPi();
634 while ( !mPisyncFinished ) { 634 while ( !mPisyncFinished ) {
635 //qDebug("waiting "); 635 //qDebug("waiting ");
636 qApp->processEvents(); 636 qApp->processEvents();
637 } 637 }
638 timer.start(); 638 timer.start();
639 while ( timer.elapsed () < 2000 ) { 639 while ( timer.elapsed () < 2000 ) {
640 qApp->processEvents(); 640 qApp->processEvents();
641 } 641 }
642 } else 642 } else
643 syncRemote( temp, false ); 643 syncRemote( temp, false );
644 644
645 } 645 }
646 } 646 }
647 timer.start(); 647 timer.start();
648 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 648 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
649 while ( timer.elapsed () < 2000 ) { 649 while ( timer.elapsed () < 2000 ) {
650 qApp->processEvents(); 650 qApp->processEvents();
651#ifndef _WIN32_ 651#ifndef _WIN32_
652 sleep (1); 652 sleep (1);
653#endif 653#endif
654 } 654 }
655 655
656 } 656 }
657 657
658 } 658 }
659 delete temp; 659 delete temp;
660 return syncedProfiles; 660 return syncedProfiles;
661} 661}
662 662
663void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 663void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
664{ 664{
665 QString question; 665 QString question;
666 if ( ask ) { 666 if ( ask ) {
667 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 667 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
668 if ( QMessageBox::information( mParent, i18n("Sync"), 668 if ( QMessageBox::information( mParent, i18n("Sync"),
669 question, 669 question,
670 i18n("Yes"), i18n("No"), 670 i18n("Yes"), i18n("No"),
671 0, 0 ) != 0 ) 671 0, 0 ) != 0 )
672 return; 672 return;
673 } 673 }
674 674
675 QString preCommand; 675 QString preCommand;
676 QString localTempFile; 676 QString localTempFile;
677 QString postCommand; 677 QString postCommand;
678 678
679 switch(mTargetApp) 679 switch(mTargetApp)
680 { 680 {
681 case (KAPI): 681 case (KAPI):
682 preCommand = prof->getPreSyncCommandAB(); 682 preCommand = prof->getPreSyncCommandAB();
683 postCommand = prof->getPostSyncCommandAB(); 683 postCommand = prof->getPostSyncCommandAB();
684 localTempFile = prof->getLocalTempFileAB(); 684 localTempFile = prof->getLocalTempFileAB();
685 break; 685 break;
686 case (KOPI): 686 case (KOPI):
687 preCommand = prof->getPreSyncCommand(); 687 preCommand = prof->getPreSyncCommand();
688 postCommand = prof->getPostSyncCommand(); 688 postCommand = prof->getPostSyncCommand();
689 localTempFile = prof->getLocalTempFile(); 689 localTempFile = prof->getLocalTempFile();
690 break; 690 break;
691 case (PWMPI): 691 case (PWMPI):
692 preCommand = prof->getPreSyncCommandPWM(); 692 preCommand = prof->getPreSyncCommandPWM();
693 postCommand = prof->getPostSyncCommandPWM(); 693 postCommand = prof->getPostSyncCommandPWM();
694 localTempFile = prof->getLocalTempFilePWM(); 694 localTempFile = prof->getLocalTempFilePWM();
695 break; 695 break;
696 default: 696 default:
697 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 697 qDebug("KSyncManager::syncRemote: invalid apptype selected");
698 break; 698 break;
699 } 699 }
700 700
701 701
702 int fi; 702 int fi;
703 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 703 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
704 QString pwd = getPassword(); 704 QString pwd = getPassword();
705 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 705 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
706 706
707 } 707 }
708 int maxlen = 30; 708 int maxlen = 30;
709 if ( QApplication::desktop()->width() > 320 ) 709 if ( QApplication::desktop()->width() > 320 )
710 maxlen += 25; 710 maxlen += 25;
711 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 711 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
712 int fileSize = 0; 712 int fileSize = 0;
713 int result = system ( preCommand ); 713 int result = system ( preCommand );
714 // 0 : okay 714 // 0 : okay
715 // 256: no such file or dir 715 // 256: no such file or dir
716 // 716 //
717 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 717 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
718 if ( result != 0 ) { 718 if ( result != 0 ) {
719 unsigned int len = maxlen; 719 unsigned int len = maxlen;
720 while ( len < preCommand.length() ) { 720 while ( len < preCommand.length() ) {
721 preCommand.insert( len , "\n" ); 721 preCommand.insert( len , "\n" );
722 len += maxlen +2; 722 len += maxlen +2;
723 } 723 }
724 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 724 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
725 QMessageBox::information( mParent, i18n("Sync - ERROR"), 725 QMessageBox::information( mParent, i18n("Sync - ERROR"),
726 question, 726 question,
727 i18n("Okay!")) ; 727 i18n("Okay!")) ;
728 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 728 mParent->topLevelWidget()->setCaption ("KDE-Pim");
729 return; 729 return;
730 } 730 }
731 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 731 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
732 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 732 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
733 733
734 if ( syncWithFile( localTempFile, true ) ) { 734 if ( syncWithFile( localTempFile, true ) ) {
735 735
736 if ( mWriteBackFile ) { 736 if ( mWriteBackFile ) {
737 int fi; 737 int fi;
738 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 738 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
739 QString pwd = getPassword(); 739 QString pwd = getPassword();
740 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 740 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
741 741
742 } 742 }
743 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 743 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
744 result = system ( postCommand ); 744 result = system ( postCommand );
745 qDebug("Sync:Writing back file result: %d ", result); 745 qDebug("Sync:Writing back file result: %d ", result);
746 if ( result != 0 ) { 746 if ( result != 0 ) {
747 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 747 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
748 return; 748 return;
749 } else { 749 } else {
750 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 750 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
751 } 751 }
752 } 752 }
753 } 753 }
754 return; 754 return;
755} 755}
756bool KSyncManager::edit_pisync_options() 756bool KSyncManager::edit_pisync_options()
757{ 757{
758 QDialog dia( mParent, "dia", true ); 758 QDialog dia( mParent, "dia", true );
759 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 759 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
760 QVBoxLayout lay ( &dia ); 760 QVBoxLayout lay ( &dia );
761 lay.setSpacing( 5 ); 761 lay.setSpacing( 5 );
762 lay.setMargin( 3 ); 762 lay.setMargin( 3 );
763 QLabel lab1 ( i18n("Password for remote access:"), &dia); 763 QLabel lab1 ( i18n("Password for remote access:"), &dia);
764 lay.addWidget( &lab1 ); 764 lay.addWidget( &lab1 );
765 QLineEdit le1 (&dia ); 765 QLineEdit le1 (&dia );
766 lay.addWidget( &le1 ); 766 lay.addWidget( &le1 );
767 QLabel lab2 ( i18n("Remote IP address:"), &dia); 767 QLabel lab2 ( i18n("Remote IP address:"), &dia);
768 lay.addWidget( &lab2 ); 768 lay.addWidget( &lab2 );
769 QLineEdit le2 (&dia ); 769 QLineEdit le2 (&dia );
770 lay.addWidget( &le2 ); 770 lay.addWidget( &le2 );
771 QLabel lab3 ( i18n("Remote port number:"), &dia); 771 QLabel lab3 ( i18n("Remote port number:"), &dia);
772 lay.addWidget( &lab3 ); 772 lay.addWidget( &lab3 );
773 QLineEdit le3 (&dia ); 773 QLineEdit le3 (&dia );
774 lay.addWidget( &le3 ); 774 lay.addWidget( &le3 );
775 QPushButton pb ( "OK", &dia); 775 QPushButton pb ( "OK", &dia);
776 lay.addWidget( &pb ); 776 lay.addWidget( &pb );
777 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 777 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
778 le1.setText( mPassWordPiSync ); 778 le1.setText( mPassWordPiSync );
779 le2.setText( mActiveSyncIP ); 779 le2.setText( mActiveSyncIP );
780 le3.setText( mActiveSyncPort ); 780 le3.setText( mActiveSyncPort );
781 if ( dia.exec() ) { 781 if ( dia.exec() ) {
782 mPassWordPiSync = le1.text(); 782 mPassWordPiSync = le1.text();
783 mActiveSyncPort = le3.text(); 783 mActiveSyncPort = le3.text();
784 mActiveSyncIP = le2.text(); 784 mActiveSyncIP = le2.text();
785 return true; 785 return true;
786 } 786 }
787 return false; 787 return false;
788} 788}
789bool KSyncManager::edit_sync_options() 789bool KSyncManager::edit_sync_options()
790{ 790{
791 791
792 QDialog dia( mParent, "dia", true ); 792 QDialog dia( mParent, "dia", true );
793 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 793 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
794 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 794 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
795 QVBoxLayout lay ( &dia ); 795 QVBoxLayout lay ( &dia );
796 lay.setSpacing( 2 ); 796 lay.setSpacing( 2 );
797 lay.setMargin( 3 ); 797 lay.setMargin( 3 );
798 lay.addWidget(&gr); 798 lay.addWidget(&gr);
799 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 799 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
800 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 800 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
801 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 801 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
802 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 802 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
803 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 803 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
804 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 804 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
805 //QRadioButton both( i18n("Take both on conflict"), &gr ); 805 //QRadioButton both( i18n("Take both on conflict"), &gr );
806 QPushButton pb ( "OK", &dia); 806 QPushButton pb ( "OK", &dia);
807 lay.addWidget( &pb ); 807 lay.addWidget( &pb );
808 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 808 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
809 switch ( mSyncAlgoPrefs ) { 809 switch ( mSyncAlgoPrefs ) {
810 case 0: 810 case 0:
811 loc.setChecked( true); 811 loc.setChecked( true);
812 break; 812 break;
813 case 1: 813 case 1:
814 rem.setChecked( true ); 814 rem.setChecked( true );
815 break; 815 break;
816 case 2: 816 case 2:
817 newest.setChecked( true); 817 newest.setChecked( true);
818 break; 818 break;
819 case 3: 819 case 3:
820 ask.setChecked( true); 820 ask.setChecked( true);
821 break; 821 break;
822 case 4: 822 case 4:
823 f_loc.setChecked( true); 823 f_loc.setChecked( true);
824 break; 824 break;
825 case 5: 825 case 5:
826 f_rem.setChecked( true); 826 f_rem.setChecked( true);
827 break; 827 break;
828 case 6: 828 case 6:
829 // both.setChecked( true); 829 // both.setChecked( true);
830 break; 830 break;
831 default: 831 default:
832 break; 832 break;
833 } 833 }
834 if ( dia.exec() ) { 834 if ( dia.exec() ) {
835 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 835 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
836 return true; 836 return true;
837 } 837 }
838 return false; 838 return false;
839} 839}
840 840
841QString KSyncManager::getPassword( ) 841QString KSyncManager::getPassword( )
842{ 842{
843 QString retfile = ""; 843 QString retfile = "";
844 QDialog dia ( mParent, "input-dialog", true ); 844 QDialog dia ( mParent, "input-dialog", true );
845 QLineEdit lab ( &dia ); 845 QLineEdit lab ( &dia );
846 lab.setEchoMode( QLineEdit::Password ); 846 lab.setEchoMode( QLineEdit::Password );
847 QVBoxLayout lay( &dia ); 847 QVBoxLayout lay( &dia );
848 lay.setMargin(7); 848 lay.setMargin(7);
849 lay.setSpacing(7); 849 lay.setSpacing(7);
850 lay.addWidget( &lab); 850 lay.addWidget( &lab);
851 dia.setFixedSize( 230,50 ); 851 dia.setFixedSize( 230,50 );
852 dia.setCaption( i18n("Enter password") ); 852 dia.setCaption( i18n("Enter password") );
853 QPushButton pb ( "OK", &dia); 853 QPushButton pb ( "OK", &dia);
854 lay.addWidget( &pb ); 854 lay.addWidget( &pb );
855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
856 dia.show(); 856 dia.show();
857 int res = dia.exec(); 857 int res = dia.exec();
858 if ( res ) 858 if ( res )
859 retfile = lab.text(); 859 retfile = lab.text();
860 dia.hide(); 860 dia.hide();
861 qApp->processEvents(); 861 qApp->processEvents();
862 return retfile; 862 return retfile;
863 863
864} 864}
865 865
866 866
867void KSyncManager::confSync() 867void KSyncManager::confSync()
868{ 868{
869 static KSyncPrefsDialog* sp = 0; 869 static KSyncPrefsDialog* sp = 0;
870 if ( ! sp ) { 870 if ( ! sp ) {
871 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 871 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
872 } 872 }
873 sp->usrReadConfig(); 873 sp->usrReadConfig();
874#ifndef DESKTOP_VERSION 874#ifndef DESKTOP_VERSION
875 sp->showMaximized(); 875 sp->showMaximized();
876#else 876#else
877 sp->show(); 877 sp->show();
878#endif 878#endif
879 sp->exec(); 879 sp->exec();
880 QStringList oldSyncProfileNames = mSyncProfileNames; 880 QStringList oldSyncProfileNames = mSyncProfileNames;
881 mSyncProfileNames = sp->getSyncProfileNames(); 881 mSyncProfileNames = sp->getSyncProfileNames();
882 mLocalMachineName = sp->getLocalMachineName (); 882 mLocalMachineName = sp->getLocalMachineName ();
883 int ii; 883 int ii;
884 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 884 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
885 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 885 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
886 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 886 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
887 } 887 }
888 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 888 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
889} 889}
890void KSyncManager::syncKDE() 890void KSyncManager::syncKDE()
891{ 891{
892 mSyncWithDesktop = true; 892 mSyncWithDesktop = true;
893 emit save(); 893 emit save();
894 switch(mTargetApp) 894 switch(mTargetApp)
895 { 895 {
896 case (KAPI): 896 case (KAPI):
897 { 897 {
898#ifdef DESKTOP_VERSION 898#ifdef DESKTOP_VERSION
899 QString command = qApp->applicationDirPath () + "/kdeabdump"; 899 QString command = qApp->applicationDirPath () + "/kdeabdump";
900#else 900#else
901 QString command = "kdeabdump"; 901 QString command = "kdeabdump";
902#endif 902#endif
903 if ( ! QFile::exists ( command ) ) 903 if ( ! QFile::exists ( command ) )
904 command = "kdeabdump"; 904 command = "kdeabdump";
905 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 905 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
906 system ( command.latin1()); 906 system ( command.latin1());
907 if ( syncWithFile( fileName,true ) ) { 907 if ( syncWithFile( fileName,true ) ) {
908 if ( mWriteBackFile ) { 908 if ( mWriteBackFile ) {
909 command += " --read"; 909 command += " --read";
910 system ( command.latin1()); 910 system ( command.latin1());
911 } 911 }
912 } 912 }
913 913
914 } 914 }
915 break; 915 break;
916 case (KOPI): 916 case (KOPI):
917 { 917 {
918#ifdef DESKTOP_VERSION 918#ifdef DESKTOP_VERSION
919 QString command = qApp->applicationDirPath () + "/kdecaldump"; 919 QString command = qApp->applicationDirPath () + "/kdecaldump";
920#else 920#else
921 QString command = "kdecaldump"; 921 QString command = "kdecaldump";
922#endif 922#endif
923 if ( ! QFile::exists ( command ) ) 923 if ( ! QFile::exists ( command ) )
924 command = "kdecaldump"; 924 command = "kdecaldump";
925 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 925 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
926 system ( command.latin1()); 926 system ( command.latin1());
927 if ( syncWithFile( fileName,true ) ) { 927 if ( syncWithFile( fileName,true ) ) {
928 if ( mWriteBackFile ) { 928 if ( mWriteBackFile ) {
929 command += " --read"; 929 command += " --read";
930 system ( command.latin1()); 930 system ( command.latin1());
931 } 931 }
932 } 932 }
933 933
934 } 934 }
935 break; 935 break;
936 case (PWMPI): 936 case (PWMPI):
937 937
938 break; 938 break;
939 default: 939 default:
940 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 940 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
941 break; 941 break;
942 942
943 } 943 }
944} 944}
945 945
946void KSyncManager::syncSharp() 946void KSyncManager::syncSharp()
947{ 947{
948 948
949 if ( ! syncExternalApplication("sharp") ) 949 if ( ! syncExternalApplication("sharp") )
950 qDebug("ERROR sync sharp "); 950 qDebug("ERROR sync sharp ");
951} 951}
952 952
953bool KSyncManager::syncExternalApplication(QString resource) 953bool KSyncManager::syncExternalApplication(QString resource)
954{ 954{
955 955
956 emit save(); 956 emit save();
957 957
958 if ( mAskForPreferences ) 958 if ( mAskForPreferences )
959 if ( !edit_sync_options()) { 959 if ( !edit_sync_options()) {
960 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 960 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
961 return false; 961 return false;
962 } 962 }
963 963
964 qDebug("Sync extern %s", resource.latin1()); 964 qDebug("Sync extern %s", resource.latin1());
965 965
966 bool syncOK = mImplementation->syncExternal(this, resource); 966 bool syncOK = mImplementation->syncExternal(this, resource);
967 967
968 return syncOK; 968 return syncOK;
969 969
970} 970}
971 971
972void KSyncManager::syncPhone() 972void KSyncManager::syncPhone()
973{ 973{
974 974
975 syncExternalApplication("phone"); 975 syncExternalApplication("phone");
976 976
977} 977}
978 978
979void KSyncManager::showProgressBar(int percentage, QString caption, int total) 979void KSyncManager::showProgressBar(int percentage, QString caption, int total)
980{ 980{
981 if (!bar->isVisible()) 981 if (!bar->isVisible())
982 { 982 {
983 bar->setCaption (caption); 983 bar->setCaption (caption);
984 bar->setTotalSteps ( total ) ; 984 bar->setTotalSteps ( total ) ;
985 985
986 bar->show(); 986 bar->show();
987 } 987 }
988 988
989 bar->setProgress( percentage ); 989 bar->setProgress( percentage );
990} 990}
991 991
992void KSyncManager::hideProgressBar() 992void KSyncManager::hideProgressBar()
993{ 993{
994 bar->hide(); 994 bar->hide();
995} 995}
996 996
997bool KSyncManager::isProgressBarCanceled() 997bool KSyncManager::isProgressBarCanceled()
998{ 998{
999 return !bar->isVisible(); 999 return !bar->isVisible();
1000} 1000}
1001 1001
1002QString KSyncManager::syncFileName() 1002QString KSyncManager::syncFileName()
1003{ 1003{
1004 1004
1005 QString fn = "tempfile"; 1005 QString fn = "tempfile";
1006 switch(mTargetApp) 1006 switch(mTargetApp)
1007 { 1007 {
1008 case (KAPI): 1008 case (KAPI):
1009 fn = "tempsyncab.vcf"; 1009 fn = "tempsyncab.vcf";
1010 break; 1010 break;
1011 case (KOPI): 1011 case (KOPI):
1012 fn = "tempsynccal.ics"; 1012 fn = "tempsynccal.ics";
1013 break; 1013 break;
1014 case (PWMPI): 1014 case (PWMPI):
1015 fn = "tempsyncpw.pwm"; 1015 fn = "tempsyncpw.pwm";
1016 break; 1016 break;
1017 default: 1017 default:
1018 break; 1018 break;
1019 } 1019 }
1020#ifdef _WIN32_ 1020#ifdef _WIN32_
1021 return locateLocal( "tmp", fn ); 1021 return locateLocal( "tmp", fn );
1022#else 1022#else
1023 return (QString( "/tmp/" )+ fn ); 1023 return (QString( "/tmp/" )+ fn );
1024#endif 1024#endif
1025} 1025}
1026 1026
1027void KSyncManager::syncPi() 1027void KSyncManager::syncPi()
1028{ 1028{
1029 mIsKapiFile = true; 1029 mIsKapiFile = true;
1030 mPisyncFinished = false; 1030 mPisyncFinished = false;
1031 qApp->processEvents(); 1031 qApp->processEvents();
1032 if ( mAskForPreferences ) 1032 if ( mAskForPreferences )
1033 if ( !edit_pisync_options()) { 1033 if ( !edit_pisync_options()) {
1034 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1034 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1035 return; 1035 return;
1036 } 1036 }
1037 bool ok; 1037 bool ok;
1038 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1038 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1039 if ( ! ok ) { 1039 if ( ! ok ) {
1040 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1040 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1041 return; 1041 return;
1042 } 1042 }
1043 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 1043 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
1044 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1044 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1045 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 1045 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
1046 commandSocket->readFile( syncFileName() ); 1046 commandSocket->readFile( syncFileName() );
1047} 1047}
1048 1048
1049void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1049void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1050{ 1050{
1051 //enum { success, errorW, errorR, quiet }; 1051 //enum { success, errorW, errorR, quiet };
1052 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 1052 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
1053 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1053 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1054 delete s; 1054 delete s;
1055 if ( state == KCommandSocket::errorR ) { 1055 if ( state == KCommandSocket::errorR ) {
1056 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1056 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1057 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1057 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1058 commandSocket->sendStop(); 1058 commandSocket->sendStop();
1059 } 1059 }
1060 mPisyncFinished = true; 1060 mPisyncFinished = true;
1061 return; 1061 return;
1062 1062
1063 } else if ( state == KCommandSocket::errorW ) { 1063 } else if ( state == KCommandSocket::errorW ) {
1064 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1064 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1065 mPisyncFinished = true; 1065 mPisyncFinished = true;
1066 1066
1067 } else if ( state == KCommandSocket::successR ) { 1067 } else if ( state == KCommandSocket::successR ) {
1068 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1068 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1069 1069
1070 } else if ( state == KCommandSocket::successW ) { 1070 } else if ( state == KCommandSocket::successW ) {
1071 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1071 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1072 mPisyncFinished = true; 1072 mPisyncFinished = true;
1073 } 1073 }
1074 1074
1075 delete s; 1075 delete s;
1076} 1076}
1077 1077
1078void KSyncManager::readFileFromSocket() 1078void KSyncManager::readFileFromSocket()
1079{ 1079{
1080 QString fileName = syncFileName(); 1080 QString fileName = syncFileName();
1081 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1081 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1082 if ( ! syncWithFile( fileName , true ) ) { 1082 if ( ! syncWithFile( fileName , true ) ) {
1083 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1083 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1084 mPisyncFinished = true; 1084 mPisyncFinished = true;
1085 return; 1085 return;
1086 } 1086 }
1087 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1087 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1088 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1088 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1089 if ( mWriteBackFile ) 1089 if ( mWriteBackFile )
1090 commandSocket->writeFile( fileName ); 1090 commandSocket->writeFile( fileName );
1091 else { 1091 else {
1092 commandSocket->sendStop(); 1092 commandSocket->sendStop();
1093 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1093 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1094 mPisyncFinished = true; 1094 mPisyncFinished = true;
1095 } 1095 }
1096} 1096}
1097 1097
1098KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1098KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1099{ 1099{
1100 mPassWord = pw; 1100 mPassWord = pw;
1101 mSocket = 0; 1101 mSocket = 0;
1102 mSyncActionDialog = 0; 1102 mSyncActionDialog = 0;
1103 blockRC = false; 1103 blockRC = false;
1104}; 1104};
1105 1105
1106void KServerSocket::newConnection ( int socket ) 1106void KServerSocket::newConnection ( int socket )
1107{ 1107{
1108 // qDebug("KServerSocket:New connection %d ", socket); 1108 // qDebug("KServerSocket:New connection %d ", socket);
1109 if ( mSocket ) { 1109 if ( mSocket ) {
1110 qDebug("KServerSocket::newConnection Socket deleted! "); 1110 qDebug("KServerSocket::newConnection Socket deleted! ");
1111 delete mSocket; 1111 delete mSocket;
1112 mSocket = 0; 1112 mSocket = 0;
1113 } 1113 }
1114 mSocket = new QSocket( this ); 1114 mSocket = new QSocket( this );
1115 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1115 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1116 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1116 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1117 mSocket->setSocket( socket ); 1117 mSocket->setSocket( socket );
1118} 1118}
1119 1119
1120void KServerSocket::discardClient() 1120void KServerSocket::discardClient()
1121{ 1121{
1122 //qDebug(" KServerSocket::discardClient()"); 1122 //qDebug(" KServerSocket::discardClient()");
1123 if ( mSocket ) { 1123 if ( mSocket ) {
1124 delete mSocket; 1124 delete mSocket;
1125 mSocket = 0; 1125 mSocket = 0;
1126 } 1126 }
1127 //emit endConnect(); 1127 //emit endConnect();
1128} 1128}
1129void KServerSocket::readClient() 1129void KServerSocket::readClient()
1130{ 1130{
1131 if ( blockRC ) 1131 if ( blockRC )
1132 return; 1132 return;
1133 if ( mSocket == 0 ) { 1133 if ( mSocket == 0 ) {
1134 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 1134 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
1135 return; 1135 return;
1136 } 1136 }
1137 //qDebug("KServerSocket::readClient()"); 1137 //qDebug("KServerSocket::readClient()");
1138 if ( mSocket->canReadLine() ) { 1138 if ( mSocket->canReadLine() ) {
1139 QString line = mSocket->readLine(); 1139 QString line = mSocket->readLine();
1140 //qDebug("KServerSocket readline: %s ", line.latin1()); 1140 //qDebug("KServerSocket readline: %s ", line.latin1());
1141 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1141 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1142 if ( tokens[0] == "GET" ) { 1142 if ( tokens[0] == "GET" ) {
1143 if ( tokens[1] == mPassWord ) { 1143 if ( tokens[1] == mPassWord ) {
1144 //emit sendFile( mSocket ); 1144 //emit sendFile( mSocket );
1145 bool ok = false; 1145 bool ok = false;
1146 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1146 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1147 if ( ok ) { 1147 if ( ok ) {
1148 KSyncManager::mRequestedSyncEvent = dt; 1148 KSyncManager::mRequestedSyncEvent = dt;
1149 } 1149 }
1150 else 1150 else
1151 KSyncManager::mRequestedSyncEvent = QDateTime(); 1151 KSyncManager::mRequestedSyncEvent = QDateTime();
1152 send_file(); 1152 send_file();
1153 } 1153 }
1154 else { 1154 else {
1155 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 1155 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
1156 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1156 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1157 } 1157 }
1158 } 1158 }
1159 if ( tokens[0] == "PUT" ) { 1159 if ( tokens[0] == "PUT" ) {
1160 if ( tokens[1] == mPassWord ) { 1160 if ( tokens[1] == mPassWord ) {
1161 //emit getFile( mSocket ); 1161 //emit getFile( mSocket );
1162 blockRC = true; 1162 blockRC = true;
1163 get_file(); 1163 get_file();
1164 } 1164 }
1165 else { 1165 else {
1166 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 1166 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
1167 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1167 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1168 } 1168 }
1169 } 1169 }
1170 if ( tokens[0] == "STOP" ) { 1170 if ( tokens[0] == "STOP" ) {
1171 //emit endConnect(); 1171 //emit endConnect();
1172 end_connect(); 1172 end_connect();
1173 } 1173 }
1174 } 1174 }
1175} 1175}
1176void KServerSocket::end_connect() 1176void KServerSocket::end_connect()
1177{ 1177{
1178 delete mSyncActionDialog; 1178 delete mSyncActionDialog;
1179 mSyncActionDialog = 0; 1179 mSyncActionDialog = 0;
1180} 1180}
1181void KServerSocket::send_file() 1181void KServerSocket::send_file()
1182{ 1182{
1183 //qDebug("MainWindow::sendFile(QSocket* s) "); 1183 //qDebug("MainWindow::sendFile(QSocket* s) ");
1184 if ( mSyncActionDialog ) 1184 if ( mSyncActionDialog )
1185 delete mSyncActionDialog; 1185 delete mSyncActionDialog;
1186 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1186 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1187 mSyncActionDialog->setCaption(i18n("Received sync request")); 1187 mSyncActionDialog->setCaption(i18n("Received sync request"));
1188 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1188 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1189 label->setAlignment ( Qt::AlignHCenter ); 1189 label->setAlignment ( Qt::AlignHCenter );
1190 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1190 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1191 lay->addWidget( label); 1191 lay->addWidget( label);
1192 lay->setMargin(7); 1192 lay->setMargin(7);
1193 lay->setSpacing(7); 1193 lay->setSpacing(7);
1194 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1194 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1195 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1195 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1196 if ( secs < 0 ) 1196 if ( secs < 0 )
1197 secs = secs * (-1); 1197 secs = secs * (-1);
1198 if ( secs > 30 ) 1198 if ( secs > 30 )
1199 //if ( true ) 1199 //if ( true )
1200 { 1200 {
1201 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1201 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1202 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1202 QLabel* label = new QLabel( warning, mSyncActionDialog );
1203 label->setAlignment ( Qt::AlignHCenter ); 1203 label->setAlignment ( Qt::AlignHCenter );
1204 lay->addWidget( label); 1204 lay->addWidget( label);
1205 if ( secs > 180 ) 1205 if ( secs > 180 )
1206 { 1206 {
1207 if ( secs > 300 ) { 1207 if ( secs > 300 ) {
1208 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1208 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1209 qDebug("cancelled "); 1209 qDebug("cancelled ");
1210 return ; 1210 return ;
1211 } 1211 }
1212 } 1212 }
1213 QFont f = label->font(); 1213 QFont f = label->font();
1214 f.setPointSize ( f.pointSize() *2 ); 1214 f.setPointSize ( f.pointSize() *2 );
1215 f. setBold (true ); 1215 f. setBold (true );
1216 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1216 QLabel* label = new QLabel( warning, mSyncActionDialog );
1217 label->setFont( f ); 1217 label->setFont( f );
1218 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1218 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1219 label->setText( warning ); 1219 label->setText( warning );
1220 label->setAlignment ( Qt::AlignHCenter ); 1220 label->setAlignment ( Qt::AlignHCenter );
1221 lay->addWidget( label); 1221 lay->addWidget( label);
1222 mSyncActionDialog->setFixedSize( 230, 300); 1222 mSyncActionDialog->setFixedSize( 230, 300);
1223 } else { 1223 } else {
1224 mSyncActionDialog->setFixedSize( 230, 200); 1224 mSyncActionDialog->setFixedSize( 230, 200);
1225 } 1225 }
1226 } else { 1226 } else {
1227 mSyncActionDialog->setFixedSize( 230, 120); 1227 mSyncActionDialog->setFixedSize( 230, 120);
1228 } 1228 }
1229 } else 1229 } else
1230 mSyncActionDialog->setFixedSize( 230, 120); 1230 mSyncActionDialog->setFixedSize( 230, 120);
1231 mSyncActionDialog->show(); 1231 mSyncActionDialog->show();
1232 mSyncActionDialog->raise(); 1232 mSyncActionDialog->raise();
1233 emit request_file(); 1233 emit request_file();
1234 qApp->processEvents(); 1234 qApp->processEvents();
1235 QString fileName = mFileName; 1235 QString fileName = mFileName;
1236 QFile file( fileName ); 1236 QFile file( fileName );
1237 if (!file.open( IO_ReadOnly ) ) { 1237 if (!file.open( IO_ReadOnly ) ) {
1238 delete mSyncActionDialog; 1238 delete mSyncActionDialog;
1239 mSyncActionDialog = 0; 1239 mSyncActionDialog = 0;
1240 qDebug("KSS::error open sync file: %s ", fileName.latin1()); 1240 qDebug("KSS::error open sync file: %s ", fileName.latin1());
1241 mSocket->close(); 1241 mSocket->close();
1242 if ( mSocket->state() == QSocket::Idle ) 1242 if ( mSocket->state() == QSocket::Idle )
1243 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1243 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1244 return ; 1244 return ;
1245 1245
1246 } 1246 }
1247 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1247 mSyncActionDialog->setCaption( i18n("Sending file...") );
1248 QTextStream ts( &file ); 1248 QTextStream ts( &file );
1249 ts.setEncoding( QTextStream::Latin1 ); 1249 ts.setEncoding( QTextStream::Latin1 );
1250 1250
1251 QTextStream os( mSocket ); 1251 QTextStream os( mSocket );
1252 os.setEncoding( QTextStream::Latin1 ); 1252 os.setEncoding( QTextStream::Latin1 );
1253 while ( ! ts.atEnd() ) { 1253 while ( ! ts.atEnd() ) {
1254 os << ts.readLine() << "\r\n"; 1254 os << ts.readLine() << "\r\n";
1255 } 1255 }
1256 //os << ts.read(); 1256 //os << ts.read();
1257 file.close(); 1257 file.close();
1258 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1258 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1259 mSocket->close(); 1259 mSocket->close();
1260 if ( mSocket->state() == QSocket::Idle ) 1260 if ( mSocket->state() == QSocket::Idle )
1261 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1261 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1262} 1262}
1263void KServerSocket::get_file() 1263void KServerSocket::get_file()
1264{ 1264{
1265 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1265 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1266 1266
1267 piTime.start(); 1267 piTime.start();
1268 piFileString = ""; 1268 piFileString = "";
1269 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1269 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1270} 1270}
1271 1271
1272 1272
1273void KServerSocket::readBackFileFromSocket() 1273void KServerSocket::readBackFileFromSocket()
1274{ 1274{
1275 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1275 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1276 while ( mSocket->canReadLine () ) { 1276 while ( mSocket->canReadLine () ) {
1277 piTime.restart(); 1277 piTime.restart();
1278 QString line = mSocket->readLine (); 1278 QString line = mSocket->readLine ();
1279 piFileString += line; 1279 piFileString += line;
1280 //qDebug("readline: %s ", line.latin1()); 1280 //qDebug("readline: %s ", line.latin1());
1281 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1281 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1282 1282
1283 } 1283 }
1284 if ( piTime.elapsed () < 3000 ) { 1284 if ( piTime.elapsed () < 3000 ) {
1285 // wait for more 1285 // wait for more
1286 //qDebug("waitformore "); 1286 //qDebug("waitformore ");
1287 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1287 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1288 return; 1288 return;
1289 } 1289 }
1290 QString fileName = mFileName; 1290 QString fileName = mFileName;
1291 QFile file ( fileName ); 1291 QFile file ( fileName );
1292 if (!file.open( IO_WriteOnly ) ) { 1292 if (!file.open( IO_WriteOnly ) ) {
1293 delete mSyncActionDialog; 1293 delete mSyncActionDialog;
1294 mSyncActionDialog = 0; 1294 mSyncActionDialog = 0;
1295 qDebug("KSS:Error open read back file "); 1295 qDebug("KSS:Error open read back file ");
1296 piFileString = ""; 1296 piFileString = "";
1297 emit file_received( false ); 1297 emit file_received( false );
1298 blockRC = false; 1298 blockRC = false;
1299 return ; 1299 return ;
1300 1300
1301 } 1301 }
1302 1302
1303 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1303 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1304 QTextStream ts ( &file ); 1304 QTextStream ts ( &file );
1305 ts.setEncoding( QTextStream::Latin1 ); 1305 ts.setEncoding( QTextStream::Latin1 );
1306 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1306 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1307 ts << piFileString; 1307 ts << piFileString;
1308 mSocket->close(); 1308 mSocket->close();
1309 if ( mSocket->state() == QSocket::Idle ) 1309 if ( mSocket->state() == QSocket::Idle )
1310 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1310 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1311 file.close(); 1311 file.close();
1312 piFileString = ""; 1312 piFileString = "";
1313 emit file_received( true ); 1313 emit file_received( true );
1314 delete mSyncActionDialog; 1314 delete mSyncActionDialog;
1315 mSyncActionDialog = 0; 1315 mSyncActionDialog = 0;
1316 blockRC = false; 1316 blockRC = false;
1317 1317
1318} 1318}
1319 1319
1320KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1320KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1321{ 1321{
1322 mPassWord = password; 1322 mPassWord = password;
1323 mSocket = 0; 1323 mSocket = 0;
1324 mPort = port; 1324 mPort = port;
1325 mHost = host; 1325 mHost = host;
1326 1326
1327 mRetVal = quiet; 1327 mRetVal = quiet;
1328 mTimerSocket = new QTimer ( this ); 1328 mTimerSocket = new QTimer ( this );
1329 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1329 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1330} 1330}
1331void KCommandSocket::readFile( QString fn ) 1331void KCommandSocket::readFile( QString fn )
1332{ 1332{
1333 if ( !mSocket ) { 1333 if ( !mSocket ) {
1334 mSocket = new QSocket( this ); 1334 mSocket = new QSocket( this );
1335 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1335 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1336 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1336 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1337 } 1337 }
1338 mFileString = ""; 1338 mFileString = "";
1339 mFileName = fn; 1339 mFileName = fn;
1340 mFirst = true; 1340 mFirst = true;
1341 mSocket->connectToHost( mHost, mPort ); 1341 mSocket->connectToHost( mHost, mPort );
1342 QTextStream os( mSocket ); 1342 QTextStream os( mSocket );
1343 os.setEncoding( QTextStream::Latin1 ); 1343 os.setEncoding( QTextStream::Latin1 );
1344 1344
1345 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1345 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1346 os << "GET " << mPassWord << curDt <<"\r\n"; 1346 os << "GET " << mPassWord << curDt <<"\r\n";
1347 mTimerSocket->start( 20000 ); 1347 mTimerSocket->start( 300000 );
1348} 1348}
1349 1349
1350void KCommandSocket::writeFile( QString fileName ) 1350void KCommandSocket::writeFile( QString fileName )
1351{ 1351{
1352 if ( !mSocket ) { 1352 if ( !mSocket ) {
1353 mSocket = new QSocket( this ); 1353 mSocket = new QSocket( this );
1354 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1354 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1355 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1355 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1356 } 1356 }
1357 mFileName = fileName ; 1357 mFileName = fileName ;
1358 mSocket->connectToHost( mHost, mPort ); 1358 mSocket->connectToHost( mHost, mPort );
1359} 1359}
1360void KCommandSocket::writeFileToSocket() 1360void KCommandSocket::writeFileToSocket()
1361{ 1361{
1362 QFile file2( mFileName ); 1362 QFile file2( mFileName );
1363 if (!file2.open( IO_ReadOnly ) ) { 1363 if (!file2.open( IO_ReadOnly ) ) {
1364 mRetVal= errorW; 1364 mRetVal= errorW;
1365 mSocket->close(); 1365 mSocket->close();
1366 if ( mSocket->state() == QSocket::Idle ) 1366 if ( mSocket->state() == QSocket::Idle )
1367 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1367 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1368 return ; 1368 return ;
1369 } 1369 }
1370 QTextStream ts2( &file2 ); 1370 QTextStream ts2( &file2 );
1371 ts2.setEncoding( QTextStream::Latin1 ); 1371 ts2.setEncoding( QTextStream::Latin1 );
1372 QTextStream os2( mSocket ); 1372 QTextStream os2( mSocket );
1373 os2.setEncoding( QTextStream::Latin1 ); 1373 os2.setEncoding( QTextStream::Latin1 );
1374 os2 << "PUT " << mPassWord << "\r\n";; 1374 os2 << "PUT " << mPassWord << "\r\n";;
1375 while ( ! ts2.atEnd() ) { 1375 while ( ! ts2.atEnd() ) {
1376 os2 << ts2.readLine() << "\r\n"; 1376 os2 << ts2.readLine() << "\r\n";
1377 } 1377 }
1378 mRetVal= successW; 1378 mRetVal= successW;
1379 file2.close(); 1379 file2.close();
1380 mSocket->close(); 1380 mSocket->close();
1381 if ( mSocket->state() == QSocket::Idle ) 1381 if ( mSocket->state() == QSocket::Idle )
1382 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1382 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1383} 1383}
1384void KCommandSocket::sendStop() 1384void KCommandSocket::sendStop()
1385{ 1385{
1386 if ( !mSocket ) { 1386 if ( !mSocket ) {
1387 mSocket = new QSocket( this ); 1387 mSocket = new QSocket( this );
1388 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1388 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1389 } 1389 }
1390 mSocket->connectToHost( mHost, mPort ); 1390 mSocket->connectToHost( mHost, mPort );
1391 QTextStream os2( mSocket ); 1391 QTextStream os2( mSocket );
1392 os2.setEncoding( QTextStream::Latin1 ); 1392 os2.setEncoding( QTextStream::Latin1 );
1393 os2 << "STOP\r\n"; 1393 os2 << "STOP\r\n";
1394 mSocket->close(); 1394 mSocket->close();
1395 if ( mSocket->state() == QSocket::Idle ) 1395 if ( mSocket->state() == QSocket::Idle )
1396 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1396 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1397} 1397}
1398 1398
1399void KCommandSocket::startReadFileFromSocket() 1399void KCommandSocket::startReadFileFromSocket()
1400{ 1400{
1401 if ( ! mFirst ) 1401 if ( ! mFirst )
1402 return; 1402 return;
1403 mFirst = false; 1403 mFirst = false;
1404 mTimerSocket->stop(); 1404 mTimerSocket->stop();
1405 mFileString = ""; 1405 mFileString = "";
1406 mTime.start(); 1406 mTime.start();
1407 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1407 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1408 1408
1409} 1409}
1410void KCommandSocket::readFileFromSocket() 1410void KCommandSocket::readFileFromSocket()
1411{ 1411{
1412 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1412 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1413 while ( mSocket->canReadLine () ) { 1413 while ( mSocket->canReadLine () ) {
1414 mTime.restart(); 1414 mTime.restart();
1415 QString line = mSocket->readLine (); 1415 QString line = mSocket->readLine ();
1416 mFileString += line; 1416 mFileString += line;
1417 //qDebug("readline: %s ", line.latin1()); 1417 //qDebug("readline: %s ", line.latin1());
1418 } 1418 }
1419 if ( mTime.elapsed () < 3000 ) { 1419 if ( mTime.elapsed () < 3000 ) {
1420 // wait for more 1420 // wait for more
1421 //qDebug("waitformore "); 1421 //qDebug("waitformore ");
1422 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1422 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1423 return; 1423 return;
1424 } 1424 }
1425 QString fileName = mFileName; 1425 QString fileName = mFileName;
1426 QFile file ( fileName ); 1426 QFile file ( fileName );
1427 if (!file.open( IO_WriteOnly ) ) { 1427 if (!file.open( IO_WriteOnly ) ) {
1428 mFileString = ""; 1428 mFileString = "";
1429 mRetVal = errorR; 1429 mRetVal = errorR;
1430 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1430 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1431 deleteSocket(); 1431 deleteSocket();
1432 return ; 1432 return ;
1433 1433
1434 } 1434 }
1435 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1435 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1436 QTextStream ts ( &file ); 1436 QTextStream ts ( &file );
1437 ts.setEncoding( QTextStream::Latin1 ); 1437 ts.setEncoding( QTextStream::Latin1 );
1438 ts << mFileString; 1438 ts << mFileString;
1439 file.close(); 1439 file.close();
1440 mFileString = ""; 1440 mFileString = "";
1441 mRetVal = successR; 1441 mRetVal = successR;
1442 mSocket->close(); 1442 mSocket->close();
1443 // if state is not idle, deleteSocket(); is called via 1443 // if state is not idle, deleteSocket(); is called via
1444 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1444 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1445 if ( mSocket->state() == QSocket::Idle ) 1445 if ( mSocket->state() == QSocket::Idle )
1446 deleteSocket(); 1446 deleteSocket();
1447} 1447}
1448 1448
1449void KCommandSocket::deleteSocket() 1449void KCommandSocket::deleteSocket()
1450{ 1450{
1451 //qDebug("KCommandSocket::deleteSocket() "); 1451 //qDebug("KCommandSocket::deleteSocket() ");
1452 if ( mTimerSocket->isActive () ) { 1452 if ( mTimerSocket->isActive () ) {
1453 mTimerSocket->stop(); 1453 mTimerSocket->stop();
1454 mRetVal = errorTO; 1454 mRetVal = errorTO;
1455 qDebug("Connection to remote host timed out"); 1455 qDebug("Connection to remote host timed out");
1456 if ( mSocket ) { 1456 if ( mSocket ) {
1457 mSocket->close(); 1457 mSocket->close();
1458 //if ( mSocket->state() == QSocket::Idle ) 1458 //if ( mSocket->state() == QSocket::Idle )
1459 // deleteSocket(); 1459 // deleteSocket();
1460 delete mSocket; 1460 delete mSocket;
1461 mSocket = 0; 1461 mSocket = 0;
1462 } 1462 }
1463 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1463 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1464 emit commandFinished( this, mRetVal ); 1464 emit commandFinished( this, mRetVal );
1465 return; 1465 return;
1466 } 1466 }
1467 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1467 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1468 if ( mSocket) 1468 if ( mSocket)
1469 delete mSocket; 1469 delete mSocket;
1470 mSocket = 0; 1470 mSocket = 0;
1471 emit commandFinished( this, mRetVal ); 1471 emit commandFinished( this, mRetVal );
1472} 1472}