summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-09 15:18:54 (UTC)
committer zautrix <zautrix>2005-04-09 15:18:54 (UTC)
commit329ecb2c6b4153c51415513a28f2dc0576f4ddca (patch) (unidiff)
treef96a8be84d1386c5d10a9d18cf2c59c8727046b2
parent16546abfab89df8dcf3168eaa7c0c346b8e400b4 (diff)
downloadkdepimpi-329ecb2c6b4153c51415513a28f2dc0576f4ddca.zip
kdepimpi-329ecb2c6b4153c51415513a28f2dc0576f4ddca.tar.gz
kdepimpi-329ecb2c6b4153c51415513a28f2dc0576f4ddca.tar.bz2
agenda fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile662
-rw-r--r--korganizer/koagenda.cpp51
2 files changed, 329 insertions, 384 deletions
diff --git a/Makefile b/Makefile
index 594d47d..4d42c35 100644
--- a/Makefile
+++ b/Makefile
@@ -1,385 +1,279 @@
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.4) on: Sat Apr 9 15:21:46 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-kabc-plugins-file \
18 libical/src/libicalss \ 18 sub-kabc-plugins-dir \
19 qtcompat \ 19 sub-kabc-plugins-qtopia \
20 microkde \ 20 sub-libical \
21 libkcal \ 21 sub-libkcal \
22 libkdepim \ 22 sub-kabc \
23 kabc \ 23 sub-libkdepim \
24 kabc/formats/binary \ 24 sub-microkde \
25 kabc/plugins/file \ 25 sub-korganizer \
26 kabc/plugins/dir \ 26 sub-kaddressbook \
27 korganizer \ 27 sub-gammu-emb-common \
28 kalarmd \ 28 sub-gammu-emb-gammu \
29 kaddressbook 29 sub-libetpan \
30 30 sub-kmicromail-libmailwrapper \
31SUBDIRS_QTOPIA_PLUGIN = \ 31 sub-kmicromail \
32 kabc/plugins/qtopia 32 sub-pwmanager-libcrypt-cipher \
33 33 sub-pwmanager-libcrypt-error \
34SUBDIRS_OPIE_PLUGIN = \ 34 sub-pwmanager-libcrypt-mpi \
35 kabc/plugins/opie 35 sub-pwmanager-libcrypt-zlib \
36 36 sub-pwmanager-pwmanager
37SUBDIRS_SHARP_PLUGIN = \ 37
38 kabc/plugins/sharpdtm 38first: all
39 39
40SUBDIRS_LDAP_PLUGIN = \ 40all: Makefile $(SUBTARGETS)
41 kabc/plugins/ldap 41
42 42kabc/plugins/file/$(MAKEFILE):
43SUBDIRS_MICROMAIL = \ 43 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
44 libetpan \ 44 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE)
45 kmicromail/libmailwrapper \ 45sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
46 kmicromail 46 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
47 47
48SUBDIRS_GAMMU = \ 48kabc/plugins/dir/$(MAKEFILE):
49 gammu/emb/common \ 49 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir"
50 gammu/emb/gammu 50 cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE)
51 51sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE
52SUBDIRS_PWMANAGER = \ 52 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE)
53 pwmanager/libcrypt/mpi \ 53
54 pwmanager/libcrypt/error \ 54kabc/plugins/qtopia/$(MAKEFILE):
55 pwmanager/libcrypt/cipher \ 55 @$(CHK_DIR_EXISTS) "kabc/plugins/qtopia" || $(MKDIR) "kabc/plugins/qtopia"
56 pwmanager/libcrypt/zlib \ 56 cd kabc/plugins/qtopia && $(QMAKE) qtopia.pro -o $(MAKEFILE)
57 pwmanager/pwmanager 57sub-kabc-plugins-qtopia: kabc/plugins/qtopia/$(MAKEFILE) FORCE
58 58 cd kabc/plugins/qtopia && $(MAKE) -f $(MAKEFILE)
59SUBDIRS = \ 59
60 $(SUBDIRS_MICROKDE) \ 60libical/$(MAKEFILE):
61 $(SUBDIRS_QTOPIA_PLUGIN) \ 61 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical"
62 $(SUBDIRS_OPIE_PLUGIN) \ 62 cd libical && $(QMAKE) libical.pro -o $(MAKEFILE)
63 $(SUBDIRS_SHARP_PLUGIN) \ 63sub-libical: libical/$(MAKEFILE) FORCE
64 $(SUBDIRS_LDAP_PLUGIN) \ 64 cd libical && $(MAKE) -f $(MAKEFILE)
65 $(SUBDIRS_MICROMAIL) \ 65
66 $(SUBDIRS_GAMMU) \ 66libkcal/$(MAKEFILE):
67 $(SUBDIRS_PWMANAGER) 67 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal"
68 68 cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE)
69 69sub-libkcal: libkcal/$(MAKEFILE) FORCE
70all: build_microkde \ 70 cd libkcal && $(MAKE) -f $(MAKEFILE)
71 build_qtopia_plugin \ 71
72 build_opie_plugin \ 72kabc/$(MAKEFILE):
73 build_sharp_plugin \ 73 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc"
74 build_ldap_plugin \ 74 cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE)
75 build_micromail \ 75sub-kabc: kabc/$(MAKEFILE) FORCE
76 build_gammu \ 76 cd kabc && $(MAKE) -f $(MAKEFILE)
77 build_pwmanager 77
78 78libkdepim/$(MAKEFILE):
79 79 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim"
80build_microkde: variable_test tmake 80 cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE)
81 for i in $(SUBDIRS_MICROKDE); do pushd $$i; \ 81sub-libkdepim: libkdepim/$(MAKEFILE) FORCE
82 make -f Makefile$(PLATFORM) || exit 1; popd; \ 82 cd libkdepim && $(MAKE) -f $(MAKEFILE)
83 done 83
84 84microkde/$(MAKEFILE):
85build_qtopia_plugin: build_microkde 85 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde"
86 ifdef BUILD_NO_QTOPIA_PLUGIN 86 cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE)
87 @echo == qtopia plugin not build. 87sub-microkde: microkde/$(MAKEFILE) FORCE
88 else 88 cd microkde && $(MAKE) -f $(MAKEFILE)
89 for i in $(SUBDIRS_QTOPIA_PLUGIN); do pushd $$i; \ 89
90 make -f Makefile$(PLATFORM) || exit 1; popd; \ 90korganizer/$(MAKEFILE):
91 done 91 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer"
92 endif 92 cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE)
93 93sub-korganizer: korganizer/$(MAKEFILE) FORCE
94build_opie_plugin: build_microkde 94 cd korganizer && $(MAKE) -f $(MAKEFILE)
95 ifdef BUILD_NO_OPIE_PLUGIN 95
96 @echo == opie plugin not build. 96kaddressbook/$(MAKEFILE):
97 else 97 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook"
98 for i in $(SUBDIRS_OPIE_PLUGIN); do pushd $$i; \ 98 cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE)
99 make -f Makefile$(PLATFORM) || exit 1; popd; \ 99sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE
100 done 100 cd kaddressbook && $(MAKE) -f $(MAKEFILE)
101 endif 101
102 102gammu/emb/common/$(MAKEFILE):
103build_sharp_plugin: build_microkde 103 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common"
104 ifdef BUILD_NO_SHARP_PLUGIN 104 cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE)
105 @echo == ldap plugin not build. 105sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE
106 else 106 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE)
107 for i in $(SUBDIRS_SHARP_PLUGIN); do pushd $$i; \ 107
108 make -f Makefile$(PLATFORM) || exit 1; popd; \ 108gammu/emb/gammu/$(MAKEFILE):
109 done 109 @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu"
110 endif 110 cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE)
111 111sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE
112build_ldap_plugin: build_microkde 112 cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE)
113 ifdef BUILD_NO_LDAP_PLUGIN 113
114 @echo == ldap plugin not build. 114libetpan/$(MAKEFILE):
115 else 115 @$(CHK_DIR_EXISTS) "libetpan" || $(MKDIR) "libetpan"
116 for i in $(SUBDIRS_LDAP_PLUGIN); do pushd $$i; \ 116 cd libetpan && $(QMAKE) libetpan.pro -o $(MAKEFILE)
117 make -f Makefile$(PLATFORM) || exit 1; popd; \ 117sub-libetpan: libetpan/$(MAKEFILE) FORCE
118 done 118 cd libetpan && $(MAKE) -f $(MAKEFILE)
119 endif 119
120 120kmicromail/libmailwrapper/$(MAKEFILE):
121 121 @$(CHK_DIR_EXISTS) "kmicromail/libmailwrapper" || $(MKDIR) "kmicromail/libmailwrapper"
122build_micromail: build_microkde 122 cd kmicromail/libmailwrapper && $(QMAKE) libmailwrapper.pro -o $(MAKEFILE)
123 ifdef BUILD_NO_MICROMAIL 123sub-kmicromail-libmailwrapper: kmicromail/libmailwrapper/$(MAKEFILE) FORCE
124 @echo == kmicromail not build. 124 cd kmicromail/libmailwrapper && $(MAKE) -f $(MAKEFILE)
125 else 125
126 for i in $(SUBDIRS_MICROMAIL); do pushd $$i; \ 126kmicromail/$(MAKEFILE):
127 make -f Makefile$(PLATFORM) || exit 1; popd; \ 127 @$(CHK_DIR_EXISTS) "kmicromail" || $(MKDIR) "kmicromail"
128 done 128 cd kmicromail && $(QMAKE) kmicromail.pro -o $(MAKEFILE)
129 endif 129sub-kmicromail: kmicromail/$(MAKEFILE) FORCE
130 130 cd kmicromail && $(MAKE) -f $(MAKEFILE)
131build_gammu: variable_test tmake 131
132 ifdef BUILD_NO_GAMMU 132pwmanager/libcrypt/cipher/$(MAKEFILE):
133 @echo == gammu not build. 133 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/cipher" || $(MKDIR) "pwmanager/libcrypt/cipher"
134 else 134 cd pwmanager/libcrypt/cipher && $(QMAKE) cipher.pro -o $(MAKEFILE)
135 for i in $(SUBDIRS_GAMMU); do pushd $$i; \ 135sub-pwmanager-libcrypt-cipher: pwmanager/libcrypt/cipher/$(MAKEFILE) FORCE
136 make -f Makefile$(PLATFORM) || exit 1; popd; \ 136 cd pwmanager/libcrypt/cipher && $(MAKE) -f $(MAKEFILE)
137 done 137
138 endif 138pwmanager/libcrypt/error/$(MAKEFILE):
139 139 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/error" || $(MKDIR) "pwmanager/libcrypt/error"
140build_pwmanager: build_microkde 140 cd pwmanager/libcrypt/error && $(QMAKE) error.pro -o $(MAKEFILE)
141 ifdef BUILD_NO_PWMANAGER 141sub-pwmanager-libcrypt-error: pwmanager/libcrypt/error/$(MAKEFILE) FORCE
142 @echo == pwmanager not build. 142 cd pwmanager/libcrypt/error && $(MAKE) -f $(MAKEFILE)
143 else 143
144 for i in $(SUBDIRS_PWMANAGER); do pushd $$i; \ 144pwmanager/libcrypt/mpi/$(MAKEFILE):
145 make -f Makefile$(PLATFORM) || exit 1; popd; \ 145 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/mpi" || $(MKDIR) "pwmanager/libcrypt/mpi"
146 done 146 cd pwmanager/libcrypt/mpi && $(QMAKE) mpi.pro -o $(MAKEFILE)
147 endif 147sub-pwmanager-libcrypt-mpi: pwmanager/libcrypt/mpi/$(MAKEFILE) FORCE
148 148 cd pwmanager/libcrypt/mpi && $(MAKE) -f $(MAKEFILE)
149 149
150variable_info: 150pwmanager/libcrypt/zlib/$(MAKEFILE):
151 @echo -------------------------------------- 151 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/zlib" || $(MKDIR) "pwmanager/libcrypt/zlib"
152 @echo KDEPIM buildsystem, variableinfo... 152 cd pwmanager/libcrypt/zlib && $(QMAKE) zlib.pro -o $(MAKEFILE)
153 @echo KDEPIMDIR=$(KDEPIMDIR) 153sub-pwmanager-libcrypt-zlib: pwmanager/libcrypt/zlib/$(MAKEFILE) FORCE
154 @echo QTDIR=$(QTDIR) 154 cd pwmanager/libcrypt/zlib && $(MAKE) -f $(MAKEFILE)
155 @echo QPEDIR=$(QPEDIR) 155
156 @echo OPIEDIR=$(OPIEDIR) 156pwmanager/pwmanager/$(MAKEFILE):
157 @echo PLATFORM=$(PLATFORM) 157 @$(CHK_DIR_EXISTS) "pwmanager/pwmanager" || $(MKDIR) "pwmanager/pwmanager"
158 @echo RELEASE_DEBUG=$(RELEASE_DEBUG) 158 cd pwmanager/pwmanager && $(QMAKE) pwmanager.pro -o $(MAKEFILE)
159 @echo BUILD_NO_MICROMAIL=$(BUILD_NO_MICROMAIL) 159sub-pwmanager-pwmanager: pwmanager/pwmanager/$(MAKEFILE) FORCE
160 @echo BUILD_NO_LDAP_PLUGIN=$(BUILD_NO_LDAP_PLUGIN) 160 cd pwmanager/pwmanager && $(MAKE) -f $(MAKEFILE)
161 @echo BUILD_NO_OPIE_PLUGIN=$(BUILD_NO_OPIE_PLUGIN) 161
162 @echo BUILD_NO_QTOPIA_PLUGIN=$(BUILD_NO_QTOPIA_PLUGIN) 162Makefile: kdepim-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf variables.pri
163 @echo BUILD_NO_SHARP_PLUGIN=$(BUILD_NO_SHARP_PLUGIN) 163 $(QMAKE) -o Makefile kdepim-desktop.pro
164 ifndef BUILD_NO_SHARP_PLUGIN 164qmake: qmake_all
165 @echo SHARPDTMSDK=$(SHARPDTMSDK) 165 @$(QMAKE) -o Makefile kdepim-desktop.pro
166 endif 166
167 @echo BUILD_NO_GAMMU=$(BUILD_NO_GAMMU) 167all: $(SUBTARGETS)
168 @echo BUILD_NO_PWMANAGER=$(BUILD_NO_PWMANAGER) 168qmake_all: kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) kabc/plugins/qtopia/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) kabc/$(MAKEFILE) libkdepim/$(MAKEFILE) microkde/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) gammu/emb/common/$(MAKEFILE) gammu/emb/gammu/$(MAKEFILE) 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)
169 @echo -------------------------------------- 169 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
170 170 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
171variable_test: variable_info 171 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
172 @echo KDEPIM buildsystem, variablecheck... 172 ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
173 ifndef KDEPIMDIR 173 ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
174 @echo KDEPIMDIR is not defined. 174 ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
175 $(error KDEPIMDIR is not defined) 175 ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
176 endif 176 ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
177 ifndef PLATFORM 177 ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
178 @echo PLATFORM is not defined. 178 ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
179 $(error PLATFORM is not defined) 179 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
180 endif 180 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
181 ifdef BUILD_NO_LDAP_PLUGIN 181 ( [ -d libetpan ] && cd libetpan ; 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 kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
183 endif 183 ( [ -d kmicromail ] && cd kmicromail ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
184 ifdef BUILD_NO_OPIE_PLUGIN 184 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; 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 pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
186 endif 186 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
187 ifdef BUILD_NO_QTOPIA_PLUGIN 187 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; 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 pwmanager/pwmanager ] && cd pwmanager/pwmanager ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
189 endif 189clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE
190 ifdef BUILD_NO_MICROMAIL 190 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
191 @echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL) 191 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true
192 endif 192 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) $@; ) || true
193 ifdef BUILD_NO_SHARP_PLUGIN 193 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true
194 @echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN) 194 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true
195 else 195 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true
196 ifndef SHARPDTMSDK 196 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true
197 @echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK) 197 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true
198 $(error SHARPDTMSDK is not defined) 198 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true
199 endif 199 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true
200 endif 200 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true
201 ifdef BUILD_NO_GAMMU 201 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true
202 @echo GAMMU will not be build, because BUILD_NO_GAMMU is set to $(BUILD_NO_GAMMU) 202 ( [ -d libetpan ] && cd libetpan ; $(MAKE) -f $(MAKEFILE) $@; ) || true
203 endif 203 ( [ -d kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; $(MAKE) -f $(MAKEFILE) $@; ) || true
204 ifdef BUILD_NO_PWMANAGER 204 ( [ -d kmicromail ] && cd kmicromail ; $(MAKE) -f $(MAKEFILE) $@; ) || true
205 @echo PWMANAGER will not be build, because BUILD_NO_PWMANAGER is set to $(BUILD_NO_PWMANAGER) 205 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; ) || true
206 endif 206 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; ) || true
207 @echo -------------------------------------- 207 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; ) || true
208 208 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; ) || true
209 209 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; ) || true
210objects: 210uninstall_subdirs: qmake_all FORCE
211 for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done 211 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
212 for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done 212 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
213 mkdir -p libical/lib/$(PLATFORM) 213 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
214 mkdir -p dest 214 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
215 mkdir -p dest$(LIBICAL_PATH) 215 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
216 mkdir -p pwmanager/libcrypt/$(PLATFORM) 216 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
217 217 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
218clean: 218 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
219 rm -rf libical/lib/$(PLATFORM)/*; 219 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
220 rm -rf pwmanager/libcrypt/$(PLATFORM)/*; 220 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
221 for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ 221 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
222 rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ 222 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
223 done 223 ( [ -d libetpan ] && cd libetpan ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
224 224 ( [ -d kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
225pac: 225 ( [ -d kmicromail ] && cd kmicromail ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
226 rm -f $(QPEDIR)/lib/libmicro* 226 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
227 rm -f $(QPEDIR)/plugins/applets/libkopi* 227 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
228 make 228 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
229 make install 229 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
230 make dist 230 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
231install: 231install_subdirs: qmake_all FORCE
232 232 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
233 cd bin/kdepim; make install 233 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true
234 cp -r Pim $(QPEDIR)/apps 234 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) install; ) || true
235 cp db2file/db2file $(QPEDIR)/bin/db2file 235 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true
236 chmod ugo+x $(QPEDIR)/bin/db2file 236 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true
237 cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop 237 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true
238 cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop 238 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true
239 cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kopiemail.desktop 239 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true
240 cp pwmanager/pwmanager/pwmanager.desktop $(QPEDIR)/apps/Pim/pwmanager.desktop 240 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true
241 241 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true
242dist: 242 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true
243 @echo Dont forget to do "make install" before "make dist" 243 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true
244 rm -f *arm.ipk 244 ( [ -d libetpan ] && cd libetpan ; $(MAKE) -f $(MAKEFILE) install; ) || true
245 rm -f *ipk.zip 245 ( [ -d kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; $(MAKE) -f $(MAKEFILE) install; ) || true
246 rm -rf ../kdepimpi_$(KDEPIM_VERSION)/* 246 ( [ -d kmicromail ] && cd kmicromail ; $(MAKE) -f $(MAKEFILE) install; ) || true
247 rm -f *~ 247 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) install; ) || true
248 cd ..;mkdir -p kdepimpi_$(KDEPIM_VERSION) 248 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) install; ) || true
249 cd ../kdepimpi_$(KDEPIM_VERSION);mkdir -p ipk 249 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) install; ) || true
250 cd ..; tar czf kdepimpi-$(KDEPIM_VERSION).tar.gz --exclude=obj --exclude=moc --exclude=CVS --exclude=Makefilezaurus --exclude=Makefileqtopia kdepim 250 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) install; ) || true
251 mkipks kmicrokdelibs.control 251 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) install; ) || true
252 mkipks korganizer.control 252distclean: qmake_all FORCE
253 mkipks kaddressbook.control 253 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
254 ifndef BUILD_NO_MICROMAIL 254 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
255 mkipks kopiemail.control 255 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
256 endif 256 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
257 ifndef BUILD_NO_SHARP_PLUGIN 257 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
258 mkipks ksharpPIM-DTMaccess.control 258 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
259 endif 259 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
260 mkipks korganizer-alarm.control 260 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
261 ifndef BUILD_NO_GAMMU 261 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
262 mkipks kmobilephoneaccess.control 262 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
263 endif 263 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
264 ifndef BUILD_NO_PWMANAGER 264 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
265 mkipks pwmanager.control 265 ( [ -d libetpan ] && cd libetpan ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
266 endif 266 ( [ -d kmicromail/libmailwrapper ] && cd kmicromail/libmailwrapper ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
267 mkipks pimTABicon.control 267 ( [ -d kmicromail ] && cd kmicromail ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
268 zip kdepim_$(KDEPIM_VERSION)_for_SharpRom.ipk.zip *.ipk ReleaseNotes.txt 268 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
269 mv *.ipk ../kdepimpi_$(KDEPIM_VERSION)/ipk/ 269 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
270 mv *for_SharpRom.ipk.zip ../kdepimpi_$(KDEPIM_VERSION)/ 270 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
271 mv ../kdepimpi-$(KDEPIM_VERSION).tar.gz ../kdepimpi_$(KDEPIM_VERSION)/ 271 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
272 272 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
273tmake: objects \ 273
274 qtcompat/Makefile$(PLATFORM) \ 274install: install_subdirs
275 microkde/Makefile$(PLATFORM) \ 275
276 libkcal/Makefile$(PLATFORM) \ 276uninstall: uninstall_subdirs
277 libkdepim/Makefile$(PLATFORM) \ 277
278 korganizer/Makefile$(PLATFORM) \ 278FORCE:
279 kalarmd/Makefile$(PLATFORM) \
280 libical/src/libical/Makefile$(PLATFORM) \
281 libical/src/libicalss/Makefile$(PLATFORM) \
282 kabc/Makefile$(PLATFORM) \
283 kabc/formats/binary/Makefile$(PLATFORM) \
284 kabc/plugins/file/Makefile$(PLATFORM) \
285 kabc/plugins/dir/Makefile$(PLATFORM) \
286 kabc/plugins/ldap/Makefile$(PLATFORM) \
287 kabc/plugins/opie/Makefile$(PLATFORM) \
288 kabc/plugins/qtopia/Makefile$(PLATFORM) \
289 kabc/plugins/sharpdtm/Makefile$(PLATFORM) \
290 kaddressbook/Makefile$(PLATFORM) \
291 kmicromail/Makefile$(PLATFORM) \
292 libetpan/Makefile$(PLATFORM) \
293 kmicromail/libmailwrapper/Makefile$(PLATFORM) \
294 gammu/emb/common/Makefile$(PLATFORM) \
295 gammu/emb/gammu/Makefile$(PLATFORM) \
296 pwmanager/pwmanager/Makefile$(PLATFORM) \
297 pwmanager/libcrypt/mpi/Makefile$(PLATFORM) \
298 pwmanager/libcrypt/error/Makefile$(PLATFORM) \
299 pwmanager/libcrypt/cipher/Makefile$(PLATFORM) \
300 pwmanager/libcrypt/zlib/Makefile$(PLATFORM)
301
302qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro
303 cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtcompat.pro -o Makefile$(PLATFORM)
304
305microkde/Makefile$(PLATFORM): microkde/microkdeE.pro
306 cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" microkdeE.pro -o Makefile$(PLATFORM)
307
308libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro
309 cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkcalE.pro -o Makefile$(PLATFORM)
310
311
312libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro
313 cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkdepimE.pro -o Makefile$(PLATFORM)
314
315kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro
316 cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kalarmdE.pro -o Makefile$(PLATFORM)
317
318korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro
319 cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" korganizerE.pro -o Makefile$(PLATFORM)
320
321libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro
322 cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalE.pro -o Makefile$(PLATFORM)
323
324libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro
325 cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalssE.pro -o Makefile$(PLATFORM)
326
327kabc/Makefile$(PLATFORM): kabc/kabcE.pro
328 cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcE.pro -o Makefile$(PLATFORM)
329
330kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro
331 cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcformat_binaryE.pro -o Makefile$(PLATFORM)
332
333kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/fileE.pro
334 cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" fileE.pro -o Makefile$(PLATFORM)
335
336kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/dirE.pro
337 cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" dirE.pro -o Makefile$(PLATFORM)
338
339kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/ldapE.pro
340 cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" ldapE.pro -o Makefile$(PLATFORM)
341
342kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/opieE.pro
343 cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" opieE.pro -o Makefile$(PLATFORM)
344
345kabc/plugins/qtopia/Makefile$(PLATFORM): kabc/plugins/qtopia/qtopiaE.pro
346 cd kabc/plugins/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtopiaE.pro -o Makefile$(PLATFORM)
347
348kabc/plugins/sharpdtm/Makefile$(PLATFORM): kabc/plugins/sharpdtm/sharpdtmE.pro
349 cd kabc/plugins/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" sharpdtmE.pro -o Makefile$(PLATFORM)
350
351kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro
352 cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kaddressbookE.pro -o Makefile$(PLATFORM)
353
354kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro
355 cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kmicromailE.pro -o Makefile$(PLATFORM)
356
357libetpan/Makefile$(PLATFORM): libetpan/libetpanE.pro
358 cd libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libetpanE.pro -o Makefile$(PLATFORM)
359
360kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro
361 cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libmailwrapperE.pro -o Makefile$(PLATFORM)
362
363gammu/emb/common/Makefile$(PLATFORM): gammu/emb/common/commonE.pro
364 cd gammu/emb/common; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" commonE.pro -o Makefile$(PLATFORM)
365
366gammu/emb/gammu/Makefile$(PLATFORM): gammu/emb/gammu/gammuE.pro
367 cd gammu/emb/gammu; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" gammuE.pro -o Makefile$(PLATFORM)
368
369pwmanager/pwmanager/Makefile$(PLATFORM): pwmanager/pwmanager/pwmanagerE.pro
370 cd pwmanager/pwmanager; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" pwmanagerE.pro -o Makefile$(PLATFORM)
371
372
373pwmanager/libcrypt/mpi/Makefile$(PLATFORM): pwmanager/libcrypt/mpi/mpi.pro
374 cd pwmanager/libcrypt/mpi;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" mpi.pro -o Makefile$(PLATFORM)
375
376pwmanager/libcrypt/error/Makefile$(PLATFORM): pwmanager/libcrypt/error/error.pro
377 cd pwmanager/libcrypt/error;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" error.pro -o Makefile$(PLATFORM)
378
379pwmanager/libcrypt/cipher/Makefile$(PLATFORM): pwmanager/libcrypt/cipher/cipher.pro
380 cd pwmanager/libcrypt/cipher;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" cipher.pro -o Makefile$(PLATFORM)
381
382pwmanager/libcrypt/zlib/Makefile$(PLATFORM): pwmanager/libcrypt/zlib/zlib.pro
383 cd pwmanager/libcrypt/zlib;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" zlib.pro -o Makefile$(PLATFORM)
384
385 279
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index b5d52d2..148d914 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,2274 +1,2325 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63//////////////////////////////////////////////////////////////////////////// 63////////////////////////////////////////////////////////////////////////////
64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
65 : QFrame(_agenda->viewport(),name), agenda(_agenda) 65 : QFrame(_agenda->viewport(),name), agenda(_agenda)
66{ 66{
67 setLineWidth(0); 67 setLineWidth(0);
68 setMargin(0); 68 setMargin(0);
69 setBackgroundColor(Qt::red); 69 setBackgroundColor(Qt::red);
70 minutes = new QTimer(this); 70 minutes = new QTimer(this);
71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
72 minutes->start(0, true); 72 minutes->start(0, true);
73 mTimeBox = new QLabel(this); 73 mTimeBox = new QLabel(this);
74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
75 QPalette pal = mTimeBox->palette(); 75 QPalette pal = mTimeBox->palette();
76 pal.setColor(QColorGroup::Foreground, Qt::red); 76 pal.setColor(QColorGroup::Foreground, Qt::red);
77 mTimeBox->setPalette(pal); 77 mTimeBox->setPalette(pal);
78 //mTimeBox->setAutoMask(true); 78 //mTimeBox->setAutoMask(true);
79 79
80 agenda->addChild(mTimeBox); 80 agenda->addChild(mTimeBox);
81 81
82 oldToday = -1; 82 oldToday = -1;
83} 83}
84 84
85MarcusBains::~MarcusBains() 85MarcusBains::~MarcusBains()
86{ 86{
87 delete minutes; 87 delete minutes;
88} 88}
89 89
90int MarcusBains::todayColumn() 90int MarcusBains::todayColumn()
91{ 91{
92 QDate currentDate = QDate::currentDate(); 92 QDate currentDate = QDate::currentDate();
93 93
94 DateList dateList = agenda->dateList(); 94 DateList dateList = agenda->dateList();
95 DateList::ConstIterator it; 95 DateList::ConstIterator it;
96 int col = 0; 96 int col = 0;
97 for(it = dateList.begin(); it != dateList.end(); ++it) { 97 for(it = dateList.begin(); it != dateList.end(); ++it) {
98 if((*it) == currentDate) 98 if((*it) == currentDate)
99 return KOGlobals::self()->reverseLayout() ? 99 return KOGlobals::self()->reverseLayout() ?
100 agenda->columns() - 1 - col : col; 100 agenda->columns() - 1 - col : col;
101 ++col; 101 ++col;
102 } 102 }
103 103
104 return -1; 104 return -1;
105} 105}
106void MarcusBains::updateLoc() 106void MarcusBains::updateLoc()
107{ 107{
108 updateLocation(); 108 updateLocation();
109} 109}
110void MarcusBains::updateLocation(bool recalculate) 110void MarcusBains::updateLocation(bool recalculate)
111{ 111{
112 112
113 QTime tim = QTime::currentTime(); 113 QTime tim = QTime::currentTime();
114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
115 if((tim.hour() == 0) && (oldTime.hour()==23)) 115 if((tim.hour() == 0) && (oldTime.hour()==23))
116 recalculate = true; 116 recalculate = true;
117 117
118 int mins = tim.hour()*60 + tim.minute(); 118 int mins = tim.hour()*60 + tim.minute();
119 int minutesPerCell = 24 * 60 / agenda->rows(); 119 int minutesPerCell = 24 * 60 / agenda->rows();
120 int y = mins*agenda->gridSpacingY()/minutesPerCell; 120 int y = mins*agenda->gridSpacingY()/minutesPerCell;
121 int today = recalculate ? todayColumn() : oldToday; 121 int today = recalculate ? todayColumn() : oldToday;
122 int x = agenda->gridSpacingX()*today; 122 int x = agenda->gridSpacingX()*today;
123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
124 124
125 oldTime = tim; 125 oldTime = tim;
126 oldToday = today; 126 oldToday = today;
127 127
128 if(disabled || (today<0)) { 128 if(disabled || (today<0)) {
129 hide(); mTimeBox->hide(); 129 hide(); mTimeBox->hide();
130 return; 130 return;
131 } else { 131 } else {
132 show(); mTimeBox->show(); 132 show(); mTimeBox->show();
133 } 133 }
134 134
135 if(recalculate) 135 if(recalculate)
136 setFixedSize(agenda->gridSpacingX(),1); 136 setFixedSize(agenda->gridSpacingX(),1);
137 agenda->moveChild(this, x, y); 137 agenda->moveChild(this, x, y);
138 raise(); 138 raise();
139 139
140 if(recalculate) 140 if(recalculate)
141 //mTimeBox->setFont(QFont("helvetica",10)); 141 //mTimeBox->setFont(QFont("helvetica",10));
142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
143 143
144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
145 mTimeBox->adjustSize(); 145 mTimeBox->adjustSize();
146 // the -2 below is there because there is a bug in this program 146 // the -2 below is there because there is a bug in this program
147 // somewhere, where the last column of this widget is a few pixels 147 // somewhere, where the last column of this widget is a few pixels
148 // narrower than the other columns. 148 // narrower than the other columns.
149 int offs = (today==agenda->columns()-1) ? -4 : 0; 149 int offs = (today==agenda->columns()-1) ? -4 : 0;
150 agenda->moveChild(mTimeBox, 150 agenda->moveChild(mTimeBox,
151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
152 y-mTimeBox->height()); 152 y-mTimeBox->height());
153 153
154 mTimeBox->raise(); 154 mTimeBox->raise();
155 //mTimeBox->setAutoMask(true); 155 //mTimeBox->setAutoMask(true);
156 minutes->start(5000,true); 156 minutes->start(5000,true);
157} 157}
158 158
159 159
160//////////////////////////////////////////////////////////////////////////// 160////////////////////////////////////////////////////////////////////////////
161 161
162 162
163/* 163/*
164 Create an agenda widget with rows rows and columns columns. 164 Create an agenda widget with rows rows and columns columns.
165*/ 165*/
166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
167 const char *name,WFlags f) : 167 const char *name,WFlags f) :
168 QScrollView(parent,name,f) 168 QScrollView(parent,name,f)
169{ 169{
170 170
171 mAllAgendaPopup = 0; 171 mAllAgendaPopup = 0;
172 mColumns = columns; 172 mColumns = columns;
173 mRows = rows; 173 mRows = rows;
174 mGridSpacingY = rowSize; 174 mGridSpacingY = rowSize;
175 mAllDayMode = false; 175 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 178#endif
179 mHolidayMask = 0; 179 mHolidayMask = 0;
180 init(); 180 init();
181} 181}
182 182
183/* 183/*
184 Create an agenda widget with columns columns and one row. This is used for 184 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 185 all-day events.
186*/ 186*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 188 QScrollView(parent,name,f)
189{ 189{
190 mAllAgendaPopup = 0; 190 mAllAgendaPopup = 0;
191 blockResize = false; 191 blockResize = false;
192 mColumns = columns; 192 mColumns = columns;
193 mRows = 1; 193 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 195 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 196 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 199#endif
200 mHolidayMask = 0; 200 mHolidayMask = 0;
201 init(); 201 init();
202} 202}
203 203
204 204
205KOAgenda::~KOAgenda() 205KOAgenda::~KOAgenda()
206{ 206{
207 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
208 208
209} 209}
210 210
211Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
212{ 212{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 214}
215 215
216 216
217QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
218{ 218{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 220}
221 221
222 222
223void KOAgenda::init() 223void KOAgenda::init()
224{ 224{
225 mPopupTimer = new QTimer(this); 225 mPopupTimer = new QTimer(this);
226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
227 227
228 mNewItemPopup = new QPopupMenu( this ); 228 mNewItemPopup = new QPopupMenu( this );
229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
230 QString pathString = ""; 230 QString pathString = "";
231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
232 if ( QApplication::desktop()->width() < 480 ) 232 if ( QApplication::desktop()->width() < 480 )
233 pathString += "icons16/"; 233 pathString += "icons16/";
234 } else 234 } else
235 pathString += "iconsmini/"; 235 pathString += "iconsmini/";
236 236
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
239 mNewItemPopup->insertSeparator ( ); 239 mNewItemPopup->insertSeparator ( );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
246#ifndef _WIN32_ 246#ifndef _WIN32_
247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
248 viewport()->setWFlags ( wflags); 248 viewport()->setWFlags ( wflags);
249#endif 249#endif
250 mGridSpacingX = 80; 250 mGridSpacingX = 80;
251 mResizeBorderWidth = 8; 251 mResizeBorderWidth = 8;
252 mScrollBorderWidth = 8; 252 mScrollBorderWidth = 8;
253 mScrollDelay = 30; 253 mScrollDelay = 30;
254 mScrollOffset = 10; 254 mScrollOffset = 10;
255 mPaintPixmap.resize( 20,20); 255 mPaintPixmap.resize( 20,20);
256 //enableClipper(true); 256 //enableClipper(true);
257 257
258 // Grab key strokes for keyboard navigation of agenda. Seems to have no 258 // Grab key strokes for keyboard navigation of agenda. Seems to have no
259 // effect. Has to be fixed. 259 // effect. Has to be fixed.
260 setFocusPolicy(WheelFocus); 260 setFocusPolicy(WheelFocus);
261 261
262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
265 265
266 mStartCellX = 0; 266 mStartCellX = 0;
267 mStartCellY = 0; 267 mStartCellY = 0;
268 mCurrentCellX = 0; 268 mCurrentCellX = 0;
269 mCurrentCellY = 0; 269 mCurrentCellY = 0;
270 270
271 mSelectionCellX = 0; 271 mSelectionCellX = 0;
272 mSelectionYTop = 0; 272 mSelectionYTop = 0;
273 mSelectionHeight = 0; 273 mSelectionHeight = 0;
274 274
275 mOldLowerScrollValue = -1; 275 mOldLowerScrollValue = -1;
276 mOldUpperScrollValue = -1; 276 mOldUpperScrollValue = -1;
277 277
278 mClickedItem = 0; 278 mClickedItem = 0;
279 279
280 mActionItem = 0; 280 mActionItem = 0;
281 mActionType = NOP; 281 mActionType = NOP;
282 mItemMoved = false; 282 mItemMoved = false;
283 283
284 mSelectedItem = 0; 284 mSelectedItem = 0;
285 285
286 // mItems.setAutoDelete(true); 286 // mItems.setAutoDelete(true);
287 287
288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
289 289
290 viewport()->update(); 290 viewport()->update();
291 291
292 setMinimumSize(30, 1); 292 setMinimumSize(30, 1);
293// setMaximumHeight(mGridSpacingY * mRows + 5); 293// setMaximumHeight(mGridSpacingY * mRows + 5);
294 294
295 // Disable horizontal scrollbar. This is a hack. The geometry should be 295 // Disable horizontal scrollbar. This is a hack. The geometry should be
296 // controlled in a way that the contents horizontally always fits. Then it is 296 // controlled in a way that the contents horizontally always fits. Then it is
297 // not necessary to turn off the scrollbar. 297 // not necessary to turn off the scrollbar.
298 setHScrollBarMode(AlwaysOff); 298 setHScrollBarMode(AlwaysOff);
299 if ( ! mAllDayMode ) 299 if ( ! mAllDayMode )
300 setVScrollBarMode(AlwaysOn); 300 setVScrollBarMode(AlwaysOn);
301 else 301 else
302 setVScrollBarMode(AlwaysOff); 302 setVScrollBarMode(AlwaysOff);
303 303
304 setStartHour(KOPrefs::instance()->mDayBegins); 304 setStartHour(KOPrefs::instance()->mDayBegins);
305 305
306 calculateWorkingHours(); 306 calculateWorkingHours();
307 307
308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
309 SLOT(checkScrollBoundaries(int))); 309 SLOT(checkScrollBoundaries(int)));
310 310
311 // Create the Marcus Bains line. 311 // Create the Marcus Bains line.
312 if(mAllDayMode) 312 if(mAllDayMode)
313 mMarcusBains = 0; 313 mMarcusBains = 0;
314 else { 314 else {
315 mMarcusBains = new MarcusBains(this); 315 mMarcusBains = new MarcusBains(this);
316 addChild(mMarcusBains); 316 addChild(mMarcusBains);
317 } 317 }
318 mPopupKind = 0; 318 mPopupKind = 0;
319 mPopupItem = 0; 319 mPopupItem = 0;
320} 320}
321 321
322void KOAgenda::clear() 322void KOAgenda::clear()
323{ 323{
324 KOAgendaItem *item; 324 KOAgendaItem *item;
325 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 325 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
326 mUnusedItems.append( item ); 326 mUnusedItems.append( item );
327 //item->hide(); 327 //item->hide();
328 } 328 }
329 mItems.clear(); 329 mItems.clear();
330 mSelectedItem = 0; 330 mSelectedItem = 0;
331 clearSelection(); 331 clearSelection();
332} 332}
333 333
334void KOAgenda::clearSelection() 334void KOAgenda::clearSelection()
335{ 335{
336 mSelectionCellX = 0; 336 mSelectionCellX = 0;
337 mSelectionYTop = 0; 337 mSelectionYTop = 0;
338 mSelectionHeight = 0; 338 mSelectionHeight = 0;
339} 339}
340 340
341void KOAgenda::marcus_bains() 341void KOAgenda::marcus_bains()
342{ 342{
343 if(mMarcusBains) mMarcusBains->updateLocation(true); 343 if(mMarcusBains) mMarcusBains->updateLocation(true);
344} 344}
345 345
346 346
347void KOAgenda::changeColumns(int columns) 347void KOAgenda::changeColumns(int columns)
348{ 348{
349 if (columns == 0) { 349 if (columns == 0) {
350 qDebug("KOAgenda::changeColumns() called with argument 0 "); 350 qDebug("KOAgenda::changeColumns() called with argument 0 ");
351 return; 351 return;
352 } 352 }
353 clear(); 353 clear();
354 mColumns = columns; 354 mColumns = columns;
355 computeSizes(); 355 computeSizes();
356} 356}
357 357
358/* 358/*
359 This is the eventFilter function, which gets all events from the KOAgendaItems 359 This is the eventFilter function, which gets all events from the KOAgendaItems
360 contained in the agenda. It has to handle moving and resizing for all items. 360 contained in the agenda. It has to handle moving and resizing for all items.
361*/ 361*/
362bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 362bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
363{ 363{
364 // kdDebug() << "KOAgenda::eventFilter" << endl; 364 // kdDebug() << "KOAgenda::eventFilter" << endl;
365 switch(event->type()) { 365 switch(event->type()) {
366 case QEvent::MouseButtonPress: 366 case QEvent::MouseButtonPress:
367 case QEvent::MouseButtonDblClick: 367 case QEvent::MouseButtonDblClick:
368 case QEvent::MouseButtonRelease: 368 case QEvent::MouseButtonRelease:
369 case QEvent::MouseMove: 369 case QEvent::MouseMove:
370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
371 371
372 case (QEvent::Leave): 372 case (QEvent::Leave):
373 if (!mActionItem) 373 if (!mActionItem)
374 setCursor(arrowCursor); 374 setCursor(arrowCursor);
375 return true; 375 return true;
376 376
377 default: 377 default:
378 return QScrollView::eventFilter(object,event); 378 return QScrollView::eventFilter(object,event);
379 } 379 }
380} 380}
381void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
382{ 382{
383 mPopupTimer->stop(); 383 mPopupTimer->stop();
384 if ( mPopupKind == 1 ) { 384 if ( mPopupKind == 1 ) {
385 if (mActionItem ) { 385 if (mActionItem ) {
386 endItemAction(); 386 endItemAction();
387 } 387 }
388 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
389 if (mPopupItem) { 389 if (mPopupItem) {
390 //mClickedItem = mPopupItem; 390 //mClickedItem = mPopupItem;
391 selectItem(mPopupItem); 391 selectItem(mPopupItem);
392 if ( mAllAgendaPopup ) 392 if ( mAllAgendaPopup )
393 mAllAgendaPopup->installEventFilter( this ); 393 mAllAgendaPopup->installEventFilter( this );
394 emit showIncidencePopupSignal(mPopupItem->incidence()); 394 emit showIncidencePopupSignal(mPopupItem->incidence());
395 395
396 } 396 }
397 } else if ( mPopupKind == 2 ) { 397 } else if ( mPopupKind == 2 ) {
398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
399 endSelectAction( false ); // do not emit new event signal 399 endSelectAction( false ); // do not emit new event signal
400 mLeftMouseDown = false; // no more leftMouse computation 400 mLeftMouseDown = false; // no more leftMouse computation
401 } 401 }
402 mNewItemPopup->installEventFilter( this ); 402 mNewItemPopup->installEventFilter( this );
403 mNewItemPopup->popup( mPopupPos); 403 mNewItemPopup->popup( mPopupPos);
404 404
405 } 405 }
406 mLeftMouseDown = false; 406 mLeftMouseDown = false;
407 mPopupItem = 0; 407 mPopupItem = 0;
408 mPopupKind = 0; 408 mPopupKind = 0;
409} 409}
410 410
411bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 411bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
412{ 412{
413 static int startX = 0; 413 static int startX = 0;
414 static int startY = 0; 414 static int startY = 0;
415 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 415 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
416 static bool blockMoving = true; 416 static bool blockMoving = true;
417 417
418 //qDebug("KOAgenda::eventFilter_mous "); 418 //qDebug("KOAgenda::eventFilter_mous ");
419 if ( object == mNewItemPopup ) { 419 if ( object == mNewItemPopup ) {
420 //qDebug("mNewItemPopup "); 420 //qDebug("mNewItemPopup ");
421 if ( me->type() == QEvent::MouseButtonRelease ) { 421 if ( me->type() == QEvent::MouseButtonRelease ) {
422 mNewItemPopup->removeEventFilter( this ); 422 mNewItemPopup->removeEventFilter( this );
423 int dX = me->globalPos().x() - mPopupPos.x();; 423 int dX = me->globalPos().x() - mPopupPos.x();;
424 if ( dX < 0 ) 424 if ( dX < 0 )
425 dX = -dX; 425 dX = -dX;
426 int dY = me->globalPos().y() - mPopupPos.y(); 426 int dY = me->globalPos().y() - mPopupPos.y();
427 if ( dY < 0 ) 427 if ( dY < 0 )
428 dY = -dY; 428 dY = -dY;
429 if ( dX > blockmoveDist || dY > blockmoveDist ) { 429 if ( dX > blockmoveDist || dY > blockmoveDist ) {
430 mNewItemPopup->hide(); 430 mNewItemPopup->hide();
431 } 431 }
432 } 432 }
433 return true; 433 return true;
434 } 434 }
435 if ( object == mAllAgendaPopup ) { 435 if ( object == mAllAgendaPopup ) {
436 //qDebug(" mAllAgendaPopup "); 436 //qDebug(" mAllAgendaPopup ");
437 if ( me->type() == QEvent::MouseButtonRelease ) { 437 if ( me->type() == QEvent::MouseButtonRelease ) {
438 mAllAgendaPopup->removeEventFilter( this ); 438 mAllAgendaPopup->removeEventFilter( this );
439 int dX = me->globalPos().x() - mPopupPos.x();; 439 int dX = me->globalPos().x() - mPopupPos.x();;
440 if ( dX < 0 ) 440 if ( dX < 0 )
441 dX = -dX; 441 dX = -dX;
442 int dY = me->globalPos().y() - mPopupPos.y(); 442 int dY = me->globalPos().y() - mPopupPos.y();
443 if ( dY < 0 ) 443 if ( dY < 0 )
444 dY = -dY; 444 dY = -dY;
445 if ( dX > blockmoveDist || dY > blockmoveDist ) { 445 if ( dX > blockmoveDist || dY > blockmoveDist ) {
446 mAllAgendaPopup->hide(); 446 mAllAgendaPopup->hide();
447 } 447 }
448 } 448 }
449 return true; 449 return true;
450 } 450 }
451 QPoint viewportPos; 451 QPoint viewportPos;
452 if (object != viewport()) { 452 if (object != viewport()) {
453 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 453 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
454 } else { 454 } else {
455 viewportPos = me->pos(); 455 viewportPos = me->pos();
456 } 456 }
457 457
458 switch (me->type()) { 458 switch (me->type()) {
459 case QEvent::MouseButtonPress: 459 case QEvent::MouseButtonPress:
460 if (me->button() == LeftButton) { 460 if (me->button() == LeftButton) {
461 mPopupTimer->start( 600 ); 461 mPopupTimer->start( 600 );
462 mLeftMouseDown = true; 462 mLeftMouseDown = true;
463 } 463 }
464 blockMoving = true; 464 blockMoving = true;
465 startX = viewportPos.x(); 465 startX = viewportPos.x();
466 startY = viewportPos.y(); 466 startY = viewportPos.y();
467 mPopupPos = me->globalPos(); 467 mPopupPos = me->globalPos();
468 if (object != viewport()) { 468 if (object != viewport()) {
469 mPopupItem = (KOAgendaItem *)object; 469 mPopupItem = (KOAgendaItem *)object;
470 mPopupKind = 1; 470 mPopupKind = 1;
471 if (me->button() == RightButton) { 471 if (me->button() == RightButton) {
472 popupMenu(); 472 popupMenu();
473 } else if (me->button() == LeftButton) { 473 } else if (me->button() == LeftButton) {
474 mActionItem = (KOAgendaItem *)object; 474 mActionItem = (KOAgendaItem *)object;
475 if (mActionItem) { 475 if (mActionItem) {
476 if ( mSelectionHeight > 0 ) { 476 if ( mSelectionHeight > 0 ) {
477 int selectionCellX = mSelectionCellX * mGridSpacingX; 477 int selectionCellX = mSelectionCellX * mGridSpacingX;
478 int selectionYTop = mSelectionYTop; 478 int selectionYTop = mSelectionYTop;
479 int gridSpacingX = mGridSpacingX; 479 int gridSpacingX = mGridSpacingX;
480 int selectionHeight = mSelectionHeight; 480 int selectionHeight = mSelectionHeight;
481 clearSelection(); 481 clearSelection();
482 repaintContents( selectionCellX, selectionYTop, 482 repaintContents( selectionCellX, selectionYTop,
483 gridSpacingX, selectionHeight,false ); 483 gridSpacingX, selectionHeight,false );
484 } 484 }
485 selectItem(mActionItem); 485 selectItem(mActionItem);
486 Incidence *incidence = mActionItem->incidence(); 486 Incidence *incidence = mActionItem->incidence();
487 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 487 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
488 mActionItem = 0; 488 mActionItem = 0;
489 } else { 489 } else {
490 startItemAction(viewportPos); 490 startItemAction(viewportPos);
491 } 491 }
492 } 492 }
493 } 493 }
494 } else { // ---------- viewport() 494 } else { // ---------- viewport()
495 mPopupItem = 0; 495 mPopupItem = 0;
496 mPopupKind = 2; 496 mPopupKind = 2;
497 selectItem(0); 497 selectItem(0);
498 mActionItem = 0; 498 mActionItem = 0;
499 if (me->button() == RightButton) { 499 if (me->button() == RightButton) {
500 int x,y; 500 int x,y;
501 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 501 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
502 int gx,gy; 502 int gx,gy;
503 contentsToGrid(x,y,gx,gy); 503 contentsToGrid(x,y,gx,gy);
504 mCurrentCellX = gx; 504 mCurrentCellX = gx;
505 mCurrentCellY = gy; 505 mCurrentCellY = gy;
506 mStartCellX = gx; 506 mStartCellX = gx;
507 mStartCellY = gy; 507 mStartCellY = gy;
508 popupMenu(); 508 popupMenu();
509 } else if (me->button() == LeftButton) { 509 } else if (me->button() == LeftButton) {
510 setCursor(arrowCursor); 510 setCursor(arrowCursor);
511 startSelectAction(viewportPos); 511 startSelectAction(viewportPos);
512 } 512 }
513 } 513 }
514 break; 514 break;
515 515
516 case QEvent::MouseButtonRelease: 516 case QEvent::MouseButtonRelease:
517 if (me->button() == LeftButton ) { 517 if (me->button() == LeftButton ) {
518 mPopupTimer->stop(); 518 mPopupTimer->stop();
519 } 519 }
520 if (object != viewport()) { 520 if (object != viewport()) {
521 if (me->button() == LeftButton && mLeftMouseDown) { 521 if (me->button() == LeftButton && mLeftMouseDown) {
522 if (mActionItem) { 522 if (mActionItem) {
523 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 523 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
524 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 524 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
525 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 525 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
526 mScrollUpTimer.stop(); 526 mScrollUpTimer.stop();
527 mScrollDownTimer.stop(); 527 mScrollDownTimer.stop();
528 mActionItem->resetMove(); 528 mActionItem->resetMove();
529 placeSubCells( mActionItem ); 529 placeSubCells( mActionItem );
530 // emit startDragSignal( mActionItem->incidence() ); 530 // emit startDragSignal( mActionItem->incidence() );
531 setCursor( arrowCursor ); 531 setCursor( arrowCursor );
532 mActionItem = 0; 532 mActionItem = 0;
533 mActionType = NOP; 533 mActionType = NOP;
534 mItemMoved = 0; 534 mItemMoved = 0;
535 mLeftMouseDown = false; 535 mLeftMouseDown = false;
536 return true; 536 return true;
537 } 537 }
538 endItemAction(); 538 endItemAction();
539 } 539 }
540 } 540 }
541 541
542 } else { // ---------- viewport() 542 } else { // ---------- viewport()
543 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 543 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
544 endSelectAction( true ); // emit new event signal 544 endSelectAction( true ); // emit new event signal
545 } 545 }
546 } 546 }
547 if (me->button() == LeftButton) 547 if (me->button() == LeftButton)
548 mLeftMouseDown = false; 548 mLeftMouseDown = false;
549 549
550 break; 550 break;
551 551
552 case QEvent::MouseMove: 552 case QEvent::MouseMove:
553 //qDebug("mm "); 553 //qDebug("mm ");
554 if ( !mLeftMouseDown ) 554 if ( !mLeftMouseDown )
555 return false; 555 return false;
556 if ( blockMoving ) { 556 if ( blockMoving ) {
557 int dX, dY; 557 int dX, dY;
558 dX = startX - viewportPos.x(); 558 dX = startX - viewportPos.x();
559 if ( dX < 0 ) 559 if ( dX < 0 )
560 dX = -dX; 560 dX = -dX;
561 dY = viewportPos.y() - startY; 561 dY = viewportPos.y() - startY;
562 if ( dY < 0 ) 562 if ( dY < 0 )
563 dY = -dY; 563 dY = -dY;
564 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 564 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
565 if ( dX > blockmoveDist || dY > blockmoveDist ) { 565 if ( dX > blockmoveDist || dY > blockmoveDist ) {
566 blockMoving = false; 566 blockMoving = false;
567 } 567 }
568 } 568 }
569 if ( ! blockMoving ) 569 if ( ! blockMoving )
570 mPopupTimer->stop(); 570 mPopupTimer->stop();
571 if (object != viewport()) { 571 if (object != viewport()) {
572 KOAgendaItem *moveItem = (KOAgendaItem *)object; 572 KOAgendaItem *moveItem = (KOAgendaItem *)object;
573 if (!moveItem->incidence()->isReadOnly() ) { 573 if (!moveItem->incidence()->isReadOnly() ) {
574 if (!mActionItem) 574 if (!mActionItem)
575 setNoActionCursor(moveItem,viewportPos); 575 setNoActionCursor(moveItem,viewportPos);
576 else { 576 else {
577 if ( !blockMoving ) 577 if ( !blockMoving )
578 performItemAction(viewportPos); 578 performItemAction(viewportPos);
579 } 579 }
580 } 580 }
581 } else { // ---------- viewport() 581 } else { // ---------- viewport()
582 mPopupPos = viewport()->mapToGlobal( me->pos() ); 582 mPopupPos = viewport()->mapToGlobal( me->pos() );
583 if ( mActionType == SELECT ) { 583 if ( mActionType == SELECT ) {
584 performSelectAction( viewportPos ); 584 performSelectAction( viewportPos );
585 } 585 }
586 } 586 }
587 break; 587 break;
588 588
589 case QEvent::MouseButtonDblClick: 589 case QEvent::MouseButtonDblClick:
590 mPopupTimer->stop(); 590 mPopupTimer->stop();
591 if (object == viewport()) { 591 if (object == viewport()) {
592 selectItem(0); 592 selectItem(0);
593 int x,y; 593 int x,y;
594 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 594 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
595 int gx,gy; 595 int gx,gy;
596 contentsToGrid(x,y,gx,gy); 596 contentsToGrid(x,y,gx,gy);
597 emit newEventSignal(gx,gy); 597 emit newEventSignal(gx,gy);
598 } else { 598 } else {
599 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 599 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
600 selectItem(doubleClickedItem); 600 selectItem(doubleClickedItem);
601 if ( KOPrefs::instance()->mEditOnDoubleClick ) 601 if ( KOPrefs::instance()->mEditOnDoubleClick )
602 emit editIncidenceSignal(doubleClickedItem->incidence()); 602 emit editIncidenceSignal(doubleClickedItem->incidence());
603 else 603 else
604 emit showIncidenceSignal(doubleClickedItem->incidence()); 604 emit showIncidenceSignal(doubleClickedItem->incidence());
605 } 605 }
606 break; 606 break;
607 607
608 default: 608 default:
609 break; 609 break;
610 } 610 }
611 return true; 611 return true;
612#if 0 612#if 0
613 //qDebug("KOAgenda::eventFilter_mous "); 613 //qDebug("KOAgenda::eventFilter_mous ");
614 QPoint viewportPos; 614 QPoint viewportPos;
615 if (object != viewport()) { 615 if (object != viewport()) {
616 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 616 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
617 } else { 617 } else {
618 viewportPos = me->pos(); 618 viewportPos = me->pos();
619 } 619 }
620 static int startX = 0; 620 static int startX = 0;
621 static int startY = 0; 621 static int startY = 0;
622 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 622 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
623 static bool blockMoving = true; 623 static bool blockMoving = true;
624 static bool leftMouseDown = false; 624 static bool leftMouseDown = false;
625 bool rightButtonPressed = false; 625 bool rightButtonPressed = false;
626 switch (me->type()) { 626 switch (me->type()) {
627 case QEvent::MouseButtonPress: 627 case QEvent::MouseButtonPress:
628 if (me->button() == LeftButton) { 628 if (me->button() == LeftButton) {
629 leftMouseDown = true; 629 leftMouseDown = true;
630 } 630 }
631 else if (me->button() == RightButton) { 631 else if (me->button() == RightButton) {
632 leftMouseDown = false; 632 leftMouseDown = false;
633 } 633 }
634 blockMoving = true; 634 blockMoving = true;
635 startX = viewportPos.x(); 635 startX = viewportPos.x();
636 startY = viewportPos.y(); 636 startY = viewportPos.y();
637 if (object != viewport()) { // item clicked ************** 637 if (object != viewport()) { // item clicked **************
638 if (me->button() == RightButton) { 638 if (me->button() == RightButton) {
639 leftMouseDown = false; 639 leftMouseDown = false;
640 mClickedItem = (KOAgendaItem *)object; 640 mClickedItem = (KOAgendaItem *)object;
641 if (mActionItem ) { 641 if (mActionItem ) {
642 endItemAction(); 642 endItemAction();
643 } 643 }
644 if (mClickedItem) { 644 if (mClickedItem) {
645 selectItem(mClickedItem); 645 selectItem(mClickedItem);
646 emit showIncidencePopupSignal(mClickedItem->incidence()); 646 emit showIncidencePopupSignal(mClickedItem->incidence());
647 } 647 }
648 return true; 648 return true;
649 } else if (me->button() == LeftButton) { 649 } else if (me->button() == LeftButton) {
650 mActionItem = (KOAgendaItem *)object; 650 mActionItem = (KOAgendaItem *)object;
651 if (mActionItem) { 651 if (mActionItem) {
652 if ( mSelectionHeight > 0 ) { 652 if ( mSelectionHeight > 0 ) {
653 int selectionCellX = mSelectionCellX * mGridSpacingX; 653 int selectionCellX = mSelectionCellX * mGridSpacingX;
654 int selectionYTop = mSelectionYTop; 654 int selectionYTop = mSelectionYTop;
655 int gridSpacingX = mGridSpacingX; 655 int gridSpacingX = mGridSpacingX;
656 int selectionHeight = mSelectionHeight; 656 int selectionHeight = mSelectionHeight;
657 clearSelection(); 657 clearSelection();
658 repaintContents( selectionCellX, selectionYTop, 658 repaintContents( selectionCellX, selectionYTop,
659 gridSpacingX, selectionHeight,false ); 659 gridSpacingX, selectionHeight,false );
660 } 660 }
661 selectItem(mActionItem); 661 selectItem(mActionItem);
662 Incidence *incidence = mActionItem->incidence(); 662 Incidence *incidence = mActionItem->incidence();
663 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 663 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
664 mActionItem = 0; 664 mActionItem = 0;
665 } else { 665 } else {
666 startItemAction(viewportPos); 666 startItemAction(viewportPos);
667 } 667 }
668 } 668 }
669 } 669 }
670 } else { // ---------- viewport() 670 } else { // ---------- viewport()
671 selectItem(0); 671 selectItem(0);
672 mActionItem = 0; 672 mActionItem = 0;
673 if (me->button() == LeftButton ) { 673 if (me->button() == LeftButton ) {
674 setCursor(arrowCursor); 674 setCursor(arrowCursor);
675 startSelectAction(viewportPos); 675 startSelectAction(viewportPos);
676 } else if (me->button() == RightButton ) { 676 } else if (me->button() == RightButton ) {
677 setCursor(arrowCursor); 677 setCursor(arrowCursor);
678 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action 678 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
679 endSelectAction( false ); // do not emit new event signal 679 endSelectAction( false ); // do not emit new event signal
680 leftMouseDown = false; // no more leftMouse computation 680 leftMouseDown = false; // no more leftMouse computation
681 } 681 }
682 int x,y; 682 int x,y;
683 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 683 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
684 int gx,gy; 684 int gx,gy;
685 contentsToGrid(x,y,gx,gy); 685 contentsToGrid(x,y,gx,gy);
686 mCurrentCellX = gx; 686 mCurrentCellX = gx;
687 mCurrentCellY = gy; 687 mCurrentCellY = gy;
688 mStartCellX = gx; 688 mStartCellX = gx;
689 mStartCellY = gy; 689 mStartCellY = gy;
690 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); 690 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
691 } 691 }
692 } 692 }
693 break; 693 break;
694 694
695 case QEvent::MouseButtonRelease: 695 case QEvent::MouseButtonRelease:
696 696
697 if (object != viewport()) { 697 if (object != viewport()) {
698 if (me->button() == LeftButton && leftMouseDown) { 698 if (me->button() == LeftButton && leftMouseDown) {
699 if (mActionItem) { 699 if (mActionItem) {
700 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 700 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
701 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 701 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
702 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 702 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
703 mScrollUpTimer.stop(); 703 mScrollUpTimer.stop();
704 mScrollDownTimer.stop(); 704 mScrollDownTimer.stop();
705 mActionItem->resetMove(); 705 mActionItem->resetMove();
706 placeSubCells( mActionItem ); 706 placeSubCells( mActionItem );
707 // emit startDragSignal( mActionItem->incidence() ); 707 // emit startDragSignal( mActionItem->incidence() );
708 setCursor( arrowCursor ); 708 setCursor( arrowCursor );
709 mActionItem = 0; 709 mActionItem = 0;
710 mActionType = NOP; 710 mActionType = NOP;
711 mItemMoved = 0; 711 mItemMoved = 0;
712 leftMouseDown = false; 712 leftMouseDown = false;
713 return true; 713 return true;
714 } 714 }
715 endItemAction(); 715 endItemAction();
716 } 716 }
717 } 717 }
718 718
719 } else { // ---------- viewport() 719 } else { // ---------- viewport()
720 if (me->button() == LeftButton && leftMouseDown ) { //left click 720 if (me->button() == LeftButton && leftMouseDown ) { //left click
721 endSelectAction( true ); // emit new event signal 721 endSelectAction( true ); // emit new event signal
722 } 722 }
723 } 723 }
724 if (me->button() == LeftButton) 724 if (me->button() == LeftButton)
725 leftMouseDown = false; 725 leftMouseDown = false;
726 726
727 break; 727 break;
728 728
729 case QEvent::MouseMove: 729 case QEvent::MouseMove:
730 if ( !leftMouseDown ) 730 if ( !leftMouseDown )
731 return true; 731 return true;
732 if ( blockMoving ) { 732 if ( blockMoving ) {
733 int dX, dY; 733 int dX, dY;
734 dX = startX - viewportPos.x(); 734 dX = startX - viewportPos.x();
735 if ( dX < 0 ) 735 if ( dX < 0 )
736 dX = -dX; 736 dX = -dX;
737 dY = viewportPos.y() - startY; 737 dY = viewportPos.y() - startY;
738 if ( dY < 0 ) 738 if ( dY < 0 )
739 dY = -dY; 739 dY = -dY;
740 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 740 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
741 if ( dX > blockmoveDist || dY > blockmoveDist ) { 741 if ( dX > blockmoveDist || dY > blockmoveDist ) {
742 blockMoving = false; 742 blockMoving = false;
743 } 743 }
744 } 744 }
745 if (object != viewport()) { 745 if (object != viewport()) {
746 KOAgendaItem *moveItem = (KOAgendaItem *)object; 746 KOAgendaItem *moveItem = (KOAgendaItem *)object;
747 if (!moveItem->incidence()->isReadOnly() ) { 747 if (!moveItem->incidence()->isReadOnly() ) {
748 if (!mActionItem) 748 if (!mActionItem)
749 setNoActionCursor(moveItem,viewportPos); 749 setNoActionCursor(moveItem,viewportPos);
750 else { 750 else {
751 if ( !blockMoving ) 751 if ( !blockMoving )
752 performItemAction(viewportPos); 752 performItemAction(viewportPos);
753 } 753 }
754 } 754 }
755 } else { // ---------- viewport() 755 } else { // ---------- viewport()
756 if ( mActionType == SELECT ) { 756 if ( mActionType == SELECT ) {
757 performSelectAction( viewportPos ); 757 performSelectAction( viewportPos );
758 } 758 }
759 } 759 }
760 break; 760 break;
761 761
762 case QEvent::MouseButtonDblClick: 762 case QEvent::MouseButtonDblClick:
763 blockMoving = false; 763 blockMoving = false;
764 leftMouseDown = false; 764 leftMouseDown = false;
765 if (object == viewport()) { 765 if (object == viewport()) {
766 selectItem(0); 766 selectItem(0);
767 int x,y; 767 int x,y;
768 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 768 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
769 int gx,gy; 769 int gx,gy;
770 contentsToGrid(x,y,gx,gy); 770 contentsToGrid(x,y,gx,gy);
771 emit newEventSignal(gx,gy); 771 emit newEventSignal(gx,gy);
772 } else { 772 } else {
773 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 773 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
774 selectItem(doubleClickedItem); 774 selectItem(doubleClickedItem);
775 if ( KOPrefs::instance()->mEditOnDoubleClick ) 775 if ( KOPrefs::instance()->mEditOnDoubleClick )
776 emit editIncidenceSignal(doubleClickedItem->incidence()); 776 emit editIncidenceSignal(doubleClickedItem->incidence());
777 else 777 else
778 emit showIncidenceSignal(doubleClickedItem->incidence()); 778 emit showIncidenceSignal(doubleClickedItem->incidence());
779 } 779 }
780 break; 780 break;
781 781
782 default: 782 default:
783 break; 783 break;
784 } 784 }
785 return true; 785 return true;
786#endif 786#endif
787} 787}
788 788
789void KOAgenda::newItem( int item ) 789void KOAgenda::newItem( int item )
790{ 790{
791 if ( item == 1 ) { //new event 791 if ( item == 1 ) { //new event
792 newEventSignal(mStartCellX ,mStartCellY ); 792 newEventSignal(mStartCellX ,mStartCellY );
793 } else 793 } else
794 if ( item == 2 ) { //new event 794 if ( item == 2 ) { //new event
795 newTodoSignal(mStartCellX ,mStartCellY ); 795 newTodoSignal(mStartCellX ,mStartCellY );
796 } else 796 } else
797 { 797 {
798 emit showDateView( item, mStartCellX ); 798 emit showDateView( item, mStartCellX );
799 // 3Day view 799 // 3Day view
800 // 4Week view 800 // 4Week view
801 // 5Month view 801 // 5Month view
802 // 6Journal view 802 // 6Journal view
803 } 803 }
804} 804}
805void KOAgenda::startSelectAction(QPoint viewportPos) 805void KOAgenda::startSelectAction(QPoint viewportPos)
806{ 806{
807 //emit newStartSelectSignal(); 807 //emit newStartSelectSignal();
808 808
809 mActionType = SELECT; 809 mActionType = SELECT;
810 810
811 int x,y; 811 int x,y;
812 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 812 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
813 int gx,gy; 813 int gx,gy;
814 contentsToGrid(x,y,gx,gy); 814 contentsToGrid(x,y,gx,gy);
815 815
816 mStartCellX = gx; 816 mStartCellX = gx;
817 mStartCellY = gy; 817 mStartCellY = gy;
818 mCurrentCellX = gx; 818 mCurrentCellX = gx;
819 mCurrentCellY = gy; 819 mCurrentCellY = gy;
820 820
821 // Store coordinates of old selection 821 // Store coordinates of old selection
822 int selectionX = mSelectionCellX * mGridSpacingX; 822 int selectionX = mSelectionCellX * mGridSpacingX;
823 int selectionYTop = mSelectionYTop; 823 int selectionYTop = mSelectionYTop;
824 int selectionHeight = mSelectionHeight; 824 int selectionHeight = mSelectionHeight;
825 825
826 // Store new selection 826 // Store new selection
827 mSelectionCellX = gx; 827 mSelectionCellX = gx;
828 mSelectionYTop = gy * mGridSpacingY; 828 mSelectionYTop = gy * mGridSpacingY;
829 mSelectionHeight = mGridSpacingY; 829 mSelectionHeight = mGridSpacingY;
830 830
831 // Clear old selection 831 // Clear old selection
832 repaintContents( selectionX, selectionYTop, 832 repaintContents( selectionX, selectionYTop,
833 mGridSpacingX, selectionHeight,false ); 833 mGridSpacingX, selectionHeight,false );
834 834
835 // Paint new selection 835 // Paint new selection
836 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 836 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
837 // mGridSpacingX, mSelectionHeight ); 837 // mGridSpacingX, mSelectionHeight );
838} 838}
839 839
840void KOAgenda::performSelectAction(QPoint viewportPos) 840void KOAgenda::performSelectAction(QPoint viewportPos)
841{ 841{
842 int x,y; 842 int x,y;
843 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 843 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
844 int gx,gy; 844 int gx,gy;
845 contentsToGrid(x,y,gx,gy); 845 contentsToGrid(x,y,gx,gy);
846 846
847 QPoint clipperPos = clipper()-> 847 QPoint clipperPos = clipper()->
848 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 848 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
849 849
850 // Scroll if cursor was moved to upper or lower end of agenda. 850 // Scroll if cursor was moved to upper or lower end of agenda.
851 if (clipperPos.y() < mScrollBorderWidth) { 851 if (clipperPos.y() < mScrollBorderWidth) {
852 mScrollUpTimer.start(mScrollDelay); 852 mScrollUpTimer.start(mScrollDelay);
853 } else if (visibleHeight() - clipperPos.y() < 853 } else if (visibleHeight() - clipperPos.y() <
854 mScrollBorderWidth) { 854 mScrollBorderWidth) {
855 mScrollDownTimer.start(mScrollDelay); 855 mScrollDownTimer.start(mScrollDelay);
856 } else { 856 } else {
857 mScrollUpTimer.stop(); 857 mScrollUpTimer.stop();
858 mScrollDownTimer.stop(); 858 mScrollDownTimer.stop();
859 } 859 }
860 860
861 if ( gy > mCurrentCellY ) { 861 if ( gy > mCurrentCellY ) {
862 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 862 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
863 863
864#if 0 864#if 0
865 // FIXME: Repaint only the newly selected region 865 // FIXME: Repaint only the newly selected region
866 repaintContents( mSelectionCellX * mGridSpacingX, 866 repaintContents( mSelectionCellX * mGridSpacingX,
867 mCurrentCellY + mGridSpacingY, 867 mCurrentCellY + mGridSpacingY,
868 mGridSpacingX, 868 mGridSpacingX,
869 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); 869 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
870#else 870#else
871 repaintContents( (KOGlobals::self()->reverseLayout() ? 871 repaintContents( (KOGlobals::self()->reverseLayout() ?
872 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 872 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
873 mGridSpacingX, mSelectionYTop, 873 mGridSpacingX, mSelectionYTop,
874 mGridSpacingX, mSelectionHeight , false); 874 mGridSpacingX, mSelectionHeight , false);
875#endif 875#endif
876 876
877 mCurrentCellY = gy; 877 mCurrentCellY = gy;
878 } else if ( gy < mCurrentCellY ) { 878 } else if ( gy < mCurrentCellY ) {
879 if ( gy >= mStartCellY ) { 879 if ( gy >= mStartCellY ) {
880 int selectionHeight = mSelectionHeight; 880 int selectionHeight = mSelectionHeight;
881 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 881 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
882 882
883 repaintContents( (KOGlobals::self()->reverseLayout() ? 883 repaintContents( (KOGlobals::self()->reverseLayout() ?
884 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 884 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
885 mGridSpacingX, mSelectionYTop, 885 mGridSpacingX, mSelectionYTop,
886 mGridSpacingX, selectionHeight,false ); 886 mGridSpacingX, selectionHeight,false );
887 887
888 mCurrentCellY = gy; 888 mCurrentCellY = gy;
889 } else { 889 } else {
890 } 890 }
891 } 891 }
892} 892}
893 893
894void KOAgenda::endSelectAction( bool emitNewEvent ) 894void KOAgenda::endSelectAction( bool emitNewEvent )
895{ 895{
896 mActionType = NOP; 896 mActionType = NOP;
897 mScrollUpTimer.stop(); 897 mScrollUpTimer.stop();
898 mScrollDownTimer.stop(); 898 mScrollDownTimer.stop();
899 899
900 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 900 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
901 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 901 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
902 qDebug("ew event signal "); 902 qDebug("ew event signal ");
903 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 903 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
904 } 904 }
905} 905}
906 906
907void KOAgenda::startItemAction(QPoint viewportPos) 907void KOAgenda::startItemAction(QPoint viewportPos)
908{ 908{
909 int x,y; 909 int x,y;
910 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 910 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
911 int gx,gy; 911 int gx,gy;
912 contentsToGrid(x,y,gx,gy); 912 contentsToGrid(x,y,gx,gy);
913 913
914 mStartCellX = gx; 914 mStartCellX = gx;
915 mStartCellY = gy; 915 mStartCellY = gy;
916 mCurrentCellX = gx; 916 mCurrentCellX = gx;
917 mCurrentCellY = gy; 917 mCurrentCellY = gy;
918 918
919 if (mAllDayMode) { 919 if (mAllDayMode) {
920 int gridDistanceX = (x - gx * mGridSpacingX); 920 int gridDistanceX = (x - gx * mGridSpacingX);
921 if (gridDistanceX < mResizeBorderWidth && 921 if (gridDistanceX < mResizeBorderWidth &&
922 mActionItem->cellX() == mCurrentCellX) { 922 mActionItem->cellX() == mCurrentCellX) {
923 mActionType = RESIZELEFT; 923 mActionType = RESIZELEFT;
924 setCursor(sizeHorCursor); 924 setCursor(sizeHorCursor);
925 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 925 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
926 mActionItem->cellXWidth() == mCurrentCellX) { 926 mActionItem->cellXWidth() == mCurrentCellX) {
927 mActionType = RESIZERIGHT; 927 mActionType = RESIZERIGHT;
928 setCursor(sizeHorCursor); 928 setCursor(sizeHorCursor);
929 } else { 929 } else {
930 mActionType = MOVE; 930 mActionType = MOVE;
931 mActionItem->startMove(); 931 mActionItem->startMove();
932 setCursor(sizeAllCursor); 932 setCursor(sizeAllCursor);
933 } 933 }
934 } else { 934 } else {
935 int gridDistanceY = (y - gy * mGridSpacingY); 935 int gridDistanceY = (y - gy * mGridSpacingY);
936 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 936 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
937 if (allowResize && gridDistanceY < mResizeBorderWidth && 937 if (allowResize && gridDistanceY < mResizeBorderWidth &&
938 mActionItem->cellYTop() == mCurrentCellY && 938 mActionItem->cellYTop() == mCurrentCellY &&
939 !mActionItem->firstMultiItem()) { 939 !mActionItem->firstMultiItem()) {
940 mActionType = RESIZETOP; 940 mActionType = RESIZETOP;
941 setCursor(sizeVerCursor); 941 setCursor(sizeVerCursor);
942 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 942 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
943 mActionItem->cellYBottom() == mCurrentCellY && 943 mActionItem->cellYBottom() == mCurrentCellY &&
944 !mActionItem->lastMultiItem()) { 944 !mActionItem->lastMultiItem()) {
945 mActionType = RESIZEBOTTOM; 945 mActionType = RESIZEBOTTOM;
946 setCursor(sizeVerCursor); 946 setCursor(sizeVerCursor);
947 } else { 947 } else {
948 mActionType = MOVE; 948 mActionType = MOVE;
949 mActionItem->startMove(); 949 mActionItem->startMove();
950 setCursor(sizeAllCursor); 950 setCursor(sizeAllCursor);
951 } 951 }
952 } 952 }
953} 953}
954 954
955void KOAgenda::performItemAction(QPoint viewportPos) 955void KOAgenda::performItemAction(QPoint viewportPos)
956{ 956{
957// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 957// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
958// QPoint point = viewport()->mapToGlobal(viewportPos); 958// QPoint point = viewport()->mapToGlobal(viewportPos);
959// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 959// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
960// point = clipper()->mapFromGlobal(point); 960// point = clipper()->mapFromGlobal(point);
961// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 961// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
962// kdDebug() << "visible height: " << visibleHeight() << endl; 962// kdDebug() << "visible height: " << visibleHeight() << endl;
963 int x,y; 963 int x,y;
964 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 964 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
965// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 965// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
966 int gx,gy; 966 int gx,gy;
967 contentsToGrid(x,y,gx,gy); 967 contentsToGrid(x,y,gx,gy);
968 QPoint clipperPos = clipper()-> 968 QPoint clipperPos = clipper()->
969 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 969 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
970 970
971 // Cursor left active agenda area. 971 // Cursor left active agenda area.
972 // This starts a drag. 972 // This starts a drag.
973 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 973 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
974 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 974 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
975 if ( mActionType == MOVE ) { 975 if ( mActionType == MOVE ) {
976 mScrollUpTimer.stop(); 976 mScrollUpTimer.stop();
977 mScrollDownTimer.stop(); 977 mScrollDownTimer.stop();
978 mActionItem->resetMove(); 978 mActionItem->resetMove();
979 placeSubCells( mActionItem ); 979 placeSubCells( mActionItem );
980 // emit startDragSignal( mActionItem->incidence() ); 980 // emit startDragSignal( mActionItem->incidence() );
981 setCursor( arrowCursor ); 981 setCursor( arrowCursor );
982 mActionItem = 0; 982 mActionItem = 0;
983 mActionType = NOP; 983 mActionType = NOP;
984 mItemMoved = 0; 984 mItemMoved = 0;
985 return; 985 return;
986 } 986 }
987 } else { 987 } else {
988 switch ( mActionType ) { 988 switch ( mActionType ) {
989 case MOVE: 989 case MOVE:
990 setCursor( sizeAllCursor ); 990 setCursor( sizeAllCursor );
991 break; 991 break;
992 case RESIZETOP: 992 case RESIZETOP:
993 case RESIZEBOTTOM: 993 case RESIZEBOTTOM:
994 setCursor( sizeVerCursor ); 994 setCursor( sizeVerCursor );
995 break; 995 break;
996 case RESIZELEFT: 996 case RESIZELEFT:
997 case RESIZERIGHT: 997 case RESIZERIGHT:
998 setCursor( sizeHorCursor ); 998 setCursor( sizeHorCursor );
999 break; 999 break;
1000 default: 1000 default:
1001 setCursor( arrowCursor ); 1001 setCursor( arrowCursor );
1002 } 1002 }
1003 } 1003 }
1004 1004
1005 // Scroll if item was moved to upper or lower end of agenda. 1005 // Scroll if item was moved to upper or lower end of agenda.
1006 if (clipperPos.y() < mScrollBorderWidth) { 1006 if (clipperPos.y() < mScrollBorderWidth) {
1007 mScrollUpTimer.start(mScrollDelay); 1007 mScrollUpTimer.start(mScrollDelay);
1008 } else if (visibleHeight() - clipperPos.y() < 1008 } else if (visibleHeight() - clipperPos.y() <
1009 mScrollBorderWidth) { 1009 mScrollBorderWidth) {
1010 mScrollDownTimer.start(mScrollDelay); 1010 mScrollDownTimer.start(mScrollDelay);
1011 } else { 1011 } else {
1012 mScrollUpTimer.stop(); 1012 mScrollUpTimer.stop();
1013 mScrollDownTimer.stop(); 1013 mScrollDownTimer.stop();
1014 } 1014 }
1015 1015
1016 // Move or resize item if necessary 1016 // Move or resize item if necessary
1017 if (mCurrentCellX != gx || mCurrentCellY != gy) { 1017 if (mCurrentCellX != gx || mCurrentCellY != gy) {
1018 mItemMoved = true; 1018 mItemMoved = true;
1019 mActionItem->raise(); 1019 mActionItem->raise();
1020 if (mActionType == MOVE) { 1020 if (mActionType == MOVE) {
1021 // Move all items belonging to a multi item 1021 // Move all items belonging to a multi item
1022 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 1022 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
1023 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 1023 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
1024 if (!moveItem) moveItem = mActionItem; 1024 if (!moveItem) moveItem = mActionItem;
1025 while (moveItem) { 1025 while (moveItem) {
1026 int dy; 1026 int dy;
1027 if (isMultiItem) dy = 0; 1027 if (isMultiItem) dy = 0;
1028 else dy = gy - mCurrentCellY; 1028 else dy = gy - mCurrentCellY;
1029 moveItem->moveRelative(gx - mCurrentCellX,dy); 1029 moveItem->moveRelative(gx - mCurrentCellX,dy);
1030 int x,y; 1030 int x,y;
1031 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 1031 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
1032 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 1032 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
1033 mGridSpacingY * moveItem->cellHeight()); 1033 mGridSpacingY * moveItem->cellHeight());
1034 moveChild(moveItem,x,y); 1034 moveChild(moveItem,x,y);
1035 moveItem = moveItem->nextMultiItem(); 1035 moveItem = moveItem->nextMultiItem();
1036 } 1036 }
1037 } else if (mActionType == RESIZETOP) { 1037 } else if (mActionType == RESIZETOP) {
1038 if (mCurrentCellY <= mActionItem->cellYBottom()) { 1038 if (mCurrentCellY <= mActionItem->cellYBottom()) {
1039 mActionItem->expandTop(gy - mCurrentCellY); 1039 mActionItem->expandTop(gy - mCurrentCellY);
1040 mActionItem->resize(mActionItem->width(), 1040 mActionItem->resize(mActionItem->width(),
1041 mGridSpacingY * mActionItem->cellHeight()); 1041 mGridSpacingY * mActionItem->cellHeight());
1042 int x,y; 1042 int x,y;
1043 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 1043 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
1044 //moveChild(mActionItem,childX(mActionItem),y); 1044 //moveChild(mActionItem,childX(mActionItem),y);
1045 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 1045 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
1046 } 1046 }
1047 } else if (mActionType == RESIZEBOTTOM) { 1047 } else if (mActionType == RESIZEBOTTOM) {
1048 if (mCurrentCellY >= mActionItem->cellYTop()) { 1048 if (mCurrentCellY >= mActionItem->cellYTop()) {
1049 mActionItem->expandBottom(gy - mCurrentCellY); 1049 mActionItem->expandBottom(gy - mCurrentCellY);
1050 mActionItem->resize(mActionItem->width(), 1050 mActionItem->resize(mActionItem->width(),
1051 mGridSpacingY * mActionItem->cellHeight()); 1051 mGridSpacingY * mActionItem->cellHeight());
1052 } 1052 }
1053 } else if (mActionType == RESIZELEFT) { 1053 } else if (mActionType == RESIZELEFT) {
1054 if (mCurrentCellX <= mActionItem->cellXWidth()) { 1054 if (mCurrentCellX <= mActionItem->cellXWidth()) {
1055 mActionItem->expandLeft(gx - mCurrentCellX); 1055 mActionItem->expandLeft(gx - mCurrentCellX);
1056 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 1056 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
1057 mActionItem->height()); 1057 mActionItem->height());
1058 int x,y; 1058 int x,y;
1059 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 1059 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
1060 moveChild(mActionItem,x,childY(mActionItem)); 1060 moveChild(mActionItem,x,childY(mActionItem));
1061 } 1061 }
1062 } else if (mActionType == RESIZERIGHT) { 1062 } else if (mActionType == RESIZERIGHT) {
1063 if (mCurrentCellX >= mActionItem->cellX()) { 1063 if (mCurrentCellX >= mActionItem->cellX()) {
1064 mActionItem->expandRight(gx - mCurrentCellX); 1064 mActionItem->expandRight(gx - mCurrentCellX);
1065 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 1065 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
1066 mActionItem->height()); 1066 mActionItem->height());
1067 } 1067 }
1068 } 1068 }
1069 mCurrentCellX = gx; 1069 mCurrentCellX = gx;
1070 mCurrentCellY = gy; 1070 mCurrentCellY = gy;
1071 } 1071 }
1072} 1072}
1073 1073
1074void KOAgenda::endItemAction() 1074void KOAgenda::endItemAction()
1075{ 1075{
1076 1076
1077 if ( mItemMoved ) { 1077 if ( mItemMoved ) {
1078 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 1078 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
1079 if ( !placeItem ) { 1079 if ( !placeItem ) {
1080 placeItem = mActionItem; 1080 placeItem = mActionItem;
1081 } 1081 }
1082 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 1082 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
1083 Incidence* oldInc = placeItem->incidence(); 1083 Incidence* oldInc = placeItem->incidence();
1084 placeItem->recreateIncidence(); 1084 placeItem->recreateIncidence();
1085 emit addToCalSignal(placeItem->incidence(), oldInc ); 1085 emit addToCalSignal(placeItem->incidence(), oldInc );
1086 } 1086 }
1087 int type = mActionType; 1087 int type = mActionType;
1088 if ( mAllDayMode ) 1088 if ( mAllDayMode )
1089 type = -1; 1089 type = -1;
1090 KOAgendaItem *modifiedItem = placeItem; 1090 KOAgendaItem *modifiedItem = placeItem;
1091 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1091 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
1092 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1092 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
1093 KOAgendaItem *item; 1093 KOAgendaItem *item;
1094 1094
1095 if ( placeItem->incidence()->type() == "Todo" ) { 1095 if ( placeItem->incidence()->type() == "Todo" ) {
1096 mSelectedItem = 0; 1096 mSelectedItem = 0;
1097 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1097 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
1098 modifiedItem->mLastMoveXPos = mCurrentCellX; 1098 modifiedItem->mLastMoveXPos = mCurrentCellX;
1099 emit itemModified( modifiedItem, mActionType ); 1099 emit itemModified( modifiedItem, mActionType );
1100 } 1100 }
1101 else { 1101 else {
1102#if 0 1102#if 0
1103 for ( item=oldconflictItems.first(); item != 0; 1103 for ( item=oldconflictItems.first(); item != 0;
1104 item=oldconflictItems.next() ) { 1104 item=oldconflictItems.next() ) {
1105 placeSubCells(item); 1105 placeSubCells(item);
1106 } 1106 }
1107 while ( placeItem ) { 1107 while ( placeItem ) {
1108 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1108 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1109 placeSubCells( placeItem ); 1109 placeSubCells( placeItem );
1110 placeItem = placeItem->nextMultiItem(); 1110 placeItem = placeItem->nextMultiItem();
1111 } 1111 }
1112#endif 1112#endif
1113 1113
1114 globalFlagBlockAgendaItemPaint = 1; 1114 globalFlagBlockAgendaItemPaint = 1;
1115 for ( item=oldconflictItems.first(); item != 0; 1115 for ( item=oldconflictItems.first(); item != 0;
1116 item=oldconflictItems.next() ) { 1116 item=oldconflictItems.next() ) {
1117 placeSubCells(item); 1117 placeSubCells(item);
1118 } 1118 }
1119 while ( placeItem ) { 1119 while ( placeItem ) {
1120 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1120 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1121 oldconflictItems = placeItem->conflictItems(); 1121 oldconflictItems = placeItem->conflictItems();
1122 for ( item=oldconflictItems.first(); item != 0; 1122 for ( item=oldconflictItems.first(); item != 0;
1123 item=oldconflictItems.next() ) { 1123 item=oldconflictItems.next() ) {
1124 placeSubCells(item); 1124 placeSubCells(item);
1125 } 1125 }
1126 placeSubCells( placeItem ); 1126 placeSubCells( placeItem );
1127 placeItem = placeItem->nextMultiItem(); 1127 placeItem = placeItem->nextMultiItem();
1128 } 1128 }
1129 globalFlagBlockAgendaItemPaint = 0; 1129 globalFlagBlockAgendaItemPaint = 0;
1130 for ( item=oldconflictItems.first(); item != 0; 1130 for ( item=oldconflictItems.first(); item != 0;
1131 item=oldconflictItems.next() ) { 1131 item=oldconflictItems.next() ) {
1132 globalFlagBlockAgendaItemUpdate = 0; 1132 globalFlagBlockAgendaItemUpdate = 0;
1133 item->repaintMe(); 1133 item->repaintMe();
1134 globalFlagBlockAgendaItemUpdate = 1; 1134 globalFlagBlockAgendaItemUpdate = 1;
1135 item->repaint( false ); 1135 item->repaint( false );
1136 } 1136 }
1137 placeItem = modifiedItem; 1137 placeItem = modifiedItem;
1138 1138
1139 while ( placeItem ) { 1139 while ( placeItem ) {
1140 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1140 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1141 globalFlagBlockAgendaItemUpdate = 0; 1141 globalFlagBlockAgendaItemUpdate = 0;
1142 placeItem->repaintMe(); 1142 placeItem->repaintMe();
1143 globalFlagBlockAgendaItemUpdate = 1; 1143 globalFlagBlockAgendaItemUpdate = 1;
1144 placeItem->repaint(false); 1144 placeItem->repaint(false);
1145 placeItem = placeItem->nextMultiItem(); 1145 placeItem = placeItem->nextMultiItem();
1146 } 1146 }
1147 emit itemModified( modifiedItem, mActionType ); 1147 emit itemModified( modifiedItem, mActionType );
1148 1148
1149 1149
1150 placeItem = modifiedItem; 1150 placeItem = modifiedItem;
1151 while ( placeItem ) { 1151 while ( placeItem ) {
1152 oldconflictItems = placeItem->conflictItems(); 1152 oldconflictItems = placeItem->conflictItems();
1153 for ( item=oldconflictItems.first(); item != 0; 1153 for ( item=oldconflictItems.first(); item != 0;
1154 item=oldconflictItems.next() ) { 1154 item=oldconflictItems.next() ) {
1155 placeSubCells(item); 1155 placeSubCells(item);
1156 } 1156 }
1157 placeSubCells( placeItem ); 1157 placeSubCells( placeItem );
1158 placeItem = placeItem->nextMultiItem(); 1158 placeItem = placeItem->nextMultiItem();
1159 1159
1160 } 1160 }
1161 placeItem = modifiedItem; 1161 placeItem = modifiedItem;
1162 while ( placeItem ) { 1162 while ( placeItem ) {
1163 oldconflictItems = placeItem->conflictItems(); 1163 oldconflictItems = placeItem->conflictItems();
1164 for ( item=oldconflictItems.first(); item != 0; 1164 for ( item=oldconflictItems.first(); item != 0;
1165 item=oldconflictItems.next() ) { 1165 item=oldconflictItems.next() ) {
1166 globalFlagBlockAgendaItemUpdate = 0; 1166 globalFlagBlockAgendaItemUpdate = 0;
1167 item->repaintMe(); 1167 item->repaintMe();
1168 globalFlagBlockAgendaItemUpdate = 1; 1168 globalFlagBlockAgendaItemUpdate = 1;
1169 item->repaint(false); 1169 item->repaint(false);
1170 } 1170 }
1171 placeItem = placeItem->nextMultiItem(); 1171 placeItem = placeItem->nextMultiItem();
1172 } 1172 }
1173 /* 1173 /*
1174 1174
1175 oldconflictItems = modifiedItem->conflictItems(); 1175 oldconflictItems = modifiedItem->conflictItems();
1176 for ( item=oldconflictItems.first(); item != 0; 1176 for ( item=oldconflictItems.first(); item != 0;
1177 item=oldconflictItems.next() ) { 1177 item=oldconflictItems.next() ) {
1178 globalFlagBlockAgendaItemUpdate = 0; 1178 globalFlagBlockAgendaItemUpdate = 0;
1179 item->paintMe(false); 1179 item->paintMe(false);
1180 globalFlagBlockAgendaItemUpdate = 1; 1180 globalFlagBlockAgendaItemUpdate = 1;
1181 item->repaint(false); 1181 item->repaint(false);
1182 } 1182 }
1183 */ 1183 */
1184 1184
1185 1185
1186 } 1186 }
1187 1187
1188 } 1188 }
1189 1189
1190 mScrollUpTimer.stop(); 1190 mScrollUpTimer.stop();
1191 mScrollDownTimer.stop(); 1191 mScrollDownTimer.stop();
1192 setCursor( arrowCursor ); 1192 setCursor( arrowCursor );
1193 mActionItem = 0; 1193 mActionItem = 0;
1194 mActionType = NOP; 1194 mActionType = NOP;
1195 mItemMoved = 0; 1195 mItemMoved = 0;
1196 1196
1197} 1197}
1198 1198
1199void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1199void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1200{ 1200{
1201// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1201// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1202// QPoint point = viewport()->mapToGlobal(viewportPos); 1202// QPoint point = viewport()->mapToGlobal(viewportPos);
1203// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1203// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1204// point = clipper()->mapFromGlobal(point); 1204// point = clipper()->mapFromGlobal(point);
1205// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1205// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1206 1206
1207 int x,y; 1207 int x,y;
1208 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1208 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1209// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1209// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1210 int gx,gy; 1210 int gx,gy;
1211 contentsToGrid(x,y,gx,gy); 1211 contentsToGrid(x,y,gx,gy);
1212 1212
1213 // Change cursor to resize cursor if appropriate 1213 // Change cursor to resize cursor if appropriate
1214 if (mAllDayMode) { 1214 if (mAllDayMode) {
1215 int gridDistanceX = (x - gx * mGridSpacingX); 1215 int gridDistanceX = (x - gx * mGridSpacingX);
1216 if (gridDistanceX < mResizeBorderWidth && 1216 if (gridDistanceX < mResizeBorderWidth &&
1217 moveItem->cellX() == gx) { 1217 moveItem->cellX() == gx) {
1218 setCursor(sizeHorCursor); 1218 setCursor(sizeHorCursor);
1219 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1219 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1220 moveItem->cellXWidth() == gx) { 1220 moveItem->cellXWidth() == gx) {
1221 setCursor(sizeHorCursor); 1221 setCursor(sizeHorCursor);
1222 } else { 1222 } else {
1223 setCursor(arrowCursor); 1223 setCursor(arrowCursor);
1224 } 1224 }
1225 } else { 1225 } else {
1226 int gridDistanceY = (y - gy * mGridSpacingY); 1226 int gridDistanceY = (y - gy * mGridSpacingY);
1227 if (gridDistanceY < mResizeBorderWidth && 1227 if (gridDistanceY < mResizeBorderWidth &&
1228 moveItem->cellYTop() == gy && 1228 moveItem->cellYTop() == gy &&
1229 !moveItem->firstMultiItem()) { 1229 !moveItem->firstMultiItem()) {
1230 setCursor(sizeVerCursor); 1230 setCursor(sizeVerCursor);
1231 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1231 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1232 moveItem->cellYBottom() == gy && 1232 moveItem->cellYBottom() == gy &&
1233 !moveItem->lastMultiItem()) { 1233 !moveItem->lastMultiItem()) {
1234 setCursor(sizeVerCursor); 1234 setCursor(sizeVerCursor);
1235 } else { 1235 } else {
1236 setCursor(arrowCursor); 1236 setCursor(arrowCursor);
1237 } 1237 }
1238 } 1238 }
1239} 1239}
1240 1240
1241 1241
1242/* 1242/*
1243 Place item in cell and take care that multiple items using the same cell do 1243 Place item in cell and take care that multiple items using the same cell do
1244 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1244 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1245 it can get in all cases. 1245 it can get in all cases.
1246 At the moment the method has a bug: When an item is placed only the sub cell 1246 At the moment the method has a bug: When an item is placed only the sub cell
1247 widths of the items are changed, which are within the Y region the item to 1247 widths of the items are changed, which are within the Y region the item to
1248 place spans. When the sub cell width change of one of this items affects a 1248 place spans. When the sub cell width change of one of this items affects a
1249 cell, where other items are, which do not overlap in Y with the item to place, 1249 cell, where other items are, which do not overlap in Y with the item to place,
1250 the display gets corrupted, although the corruption looks quite nice. 1250 the display gets corrupted, although the corruption looks quite nice.
1251*/ 1251*/
1252void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1252void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1253{ 1253{
1254 1254
1255 QPtrList<KOAgendaItem> conflictItems; 1255 QPtrList<KOAgendaItem> conflictItems;
1256 int maxSubCells = 0; 1256 int maxSubCells = 0;
1257 QIntDict<KOAgendaItem> subCellDict(5); 1257 QIntDict<KOAgendaItem> subCellDict(5);
1258 1258
1259 KOAgendaItem *item; 1259 KOAgendaItem *item;
1260 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1260 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1261 if (item != placeItem) { 1261 if (item != placeItem) {
1262 if (placeItem->cellX() <= item->cellXWidth() && 1262 if (placeItem->cellX() <= item->cellXWidth() &&
1263 placeItem->cellXWidth() >= item->cellX()) { 1263 placeItem->cellXWidth() >= item->cellX()) {
1264 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1264 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1265 (placeItem->cellYBottom() >= item->cellYTop())) { 1265 (placeItem->cellYBottom() >= item->cellYTop())) {
1266 conflictItems.append(item); 1266 conflictItems.append(item);
1267 if (item->subCells() > maxSubCells) 1267 if (item->subCells() > maxSubCells)
1268 maxSubCells = item->subCells(); 1268 maxSubCells = item->subCells();
1269 subCellDict.insert(item->subCell(),item); 1269 subCellDict.insert(item->subCell(),item);
1270 } 1270 }
1271 } 1271 }
1272 } 1272 }
1273 } 1273 }
1274 1274
1275 if (conflictItems.count() > 0) { 1275 if (conflictItems.count() > 0) {
1276 // Look for unused sub cell and insert item 1276 // Look for unused sub cell and insert item
1277 int i; 1277 int i;
1278 for(i=0;i<maxSubCells;++i) { 1278 for(i=0;i<maxSubCells;++i) {
1279 if (!subCellDict.find(i)) { 1279 if (!subCellDict.find(i)) {
1280 placeItem->setSubCell(i); 1280 placeItem->setSubCell(i);
1281 break; 1281 break;
1282 } 1282 }
1283 } 1283 }
1284 if (i == maxSubCells) { 1284 if (i == maxSubCells) {
1285 placeItem->setSubCell(maxSubCells); 1285 placeItem->setSubCell(maxSubCells);
1286 maxSubCells++; // add new item to number of sub cells 1286 maxSubCells++; // add new item to number of sub cells
1287 } 1287 }
1288 1288
1289 // Prepare for sub cell geometry adjustment 1289 // Prepare for sub cell geometry adjustment
1290 int newSubCellWidth; 1290 int newSubCellWidth;
1291 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1291 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1292 else newSubCellWidth = mGridSpacingX / maxSubCells; 1292 else newSubCellWidth = mGridSpacingX / maxSubCells;
1293 conflictItems.append(placeItem); 1293 conflictItems.append(placeItem);
1294 1294
1295 1295
1296 // Adjust sub cell geometry of all direct conflict items 1296 // Adjust sub cell geometry of all direct conflict items
1297 for ( item=conflictItems.first(); item != 0; 1297 for ( item=conflictItems.first(); item != 0;
1298 item=conflictItems.next() ) { 1298 item=conflictItems.next() ) {
1299 item->setSubCells(maxSubCells); 1299 item->setSubCells(maxSubCells);
1300 if (mAllDayMode) { 1300 if (mAllDayMode) {
1301 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1301 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1302 } else { 1302 } else {
1303 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1303 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1304 } 1304 }
1305 int x,y; 1305 int x,y;
1306 gridToContents(item->cellX(),item->cellYTop(),x,y); 1306 gridToContents(item->cellX(),item->cellYTop(),x,y);
1307 if (mAllDayMode) { 1307 if (mAllDayMode) {
1308 y += item->subCell() * newSubCellWidth; 1308 y += item->subCell() * newSubCellWidth;
1309 } else { 1309 } else {
1310 x += item->subCell() * newSubCellWidth; 1310 x += item->subCell() * newSubCellWidth;
1311 } 1311 }
1312 moveChild(item,x,y); 1312 moveChild(item,x,y);
1313 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1313 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1314 //item->updateItem(); 1314 //item->updateItem();
1315 } 1315 }
1316 // Adjust sub cell geometry of all conflict items of all conflict items 1316 // Adjust sub cell geometry of all conflict items of all conflict items
1317 for ( item=conflictItems.first(); item != 0; 1317 for ( item=conflictItems.first(); item != 0;
1318 item=conflictItems.next() ) { 1318 item=conflictItems.next() ) {
1319 if ( placeItem != item ) { 1319 if ( placeItem != item ) {
1320 KOAgendaItem *item2; 1320 KOAgendaItem *item2;
1321 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1321 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1322 for ( item2=conflictItems2.first(); item2 != 0; 1322 for ( item2=conflictItems2.first(); item2 != 0;
1323 item2=conflictItems2.next() ) { 1323 item2=conflictItems2.next() ) {
1324 if ( item2->subCells() != maxSubCells) { 1324 if ( item2->subCells() != maxSubCells) {
1325 item2->setSubCells(maxSubCells); 1325 item2->setSubCells(maxSubCells);
1326 if (mAllDayMode) { 1326 if (mAllDayMode) {
1327 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1327 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1328 } else { 1328 } else {
1329 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1329 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1330 } 1330 }
1331 int x,y; 1331 int x,y;
1332 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1332 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1333 if (mAllDayMode) { 1333 if (mAllDayMode) {
1334 y += item2->subCell() * newSubCellWidth; 1334 y += item2->subCell() * newSubCellWidth;
1335 } else { 1335 } else {
1336 x += item2->subCell() * newSubCellWidth; 1336 x += item2->subCell() * newSubCellWidth;
1337 } 1337 }
1338 moveChild(item2,x,y); 1338 moveChild(item2,x,y);
1339 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1339 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1340 } 1340 }
1341 } 1341 }
1342 } 1342 }
1343 } 1343 }
1344 } else { 1344 } else {
1345 placeItem->setSubCell(0); 1345 placeItem->setSubCell(0);
1346 placeItem->setSubCells(1); 1346 placeItem->setSubCells(1);
1347 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1347 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1348 else placeItem->resize(mGridSpacingX,placeItem->height()); 1348 else placeItem->resize(mGridSpacingX,placeItem->height());
1349 int x,y; 1349 int x,y;
1350 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1350 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1351 moveChild(placeItem,x,y); 1351 moveChild(placeItem,x,y);
1352 } 1352 }
1353 placeItem->setConflictItems(conflictItems); 1353 placeItem->setConflictItems(conflictItems);
1354 // for ( item=conflictItems.first(); item != 0; 1354 // for ( item=conflictItems.first(); item != 0;
1355// item=conflictItems.next() ) { 1355// item=conflictItems.next() ) {
1356// //item->updateItem(); 1356// //item->updateItem();
1357// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1357// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1358// } 1358// }
1359// placeItem->updateItem(); 1359// placeItem->updateItem();
1360} 1360}
1361 1361
1362void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1362void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1363{ 1363{
1364 if ( globalFlagBlockAgenda ) 1364 if ( globalFlagBlockAgenda )
1365 return; 1365 return;
1366 //qDebug("KOAgenda::drawContents "); 1366 //qDebug("KOAgenda::drawContents ");
1367 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1367 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1368 ;//drawContentsToPainter(); 1368 ;//drawContentsToPainter();
1369 1369
1370 QPaintDevice* pd = p->device(); 1370 QPaintDevice* pd = p->device();
1371 p->end(); 1371 p->end();
1372 int vx, vy; 1372 int vx, vy;
1373 int selectionX = KOGlobals::self()->reverseLayout() ? 1373 int selectionX = KOGlobals::self()->reverseLayout() ?
1374 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1374 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1375 mSelectionCellX * mGridSpacingX; 1375 mSelectionCellX * mGridSpacingX;
1376 contentsToViewport ( cx, cy, vx,vy); 1376 contentsToViewport ( cx, cy, vx,vy);
1377 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1378
1379 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1380 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1381 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1382
1383 int vxSel, vySel;
1384 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1385 int off = mSelectionHeight;
1386 if ( vySel < 0 )
1387 off += vySel;
1388 //qDebug("OFF %d %d %d", off,vySel, vy );
1389 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1390 } else {
1391 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1392 }
1393 }
1394 if ( mSelectionHeight > 0 ) {
1395 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1396 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1397 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1398 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1399 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1400 }
1401 }
1402 //qDebug("btbl ");
1403 p->begin( pd );
1404 //qDebug("end ");
1405#if 0
1406
1407 if ( globalFlagBlockAgenda )
1408 return;
1409 //qDebug("KOAgenda::drawContents ");
1410 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1411 ;//drawContentsToPainter();
1412
1413 QPaintDevice* pd = p->device();
1414 p->end();
1415 int vx, vy;
1416 int selectionX = KOGlobals::self()->reverseLayout() ?
1417 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1418 mSelectionCellX * mGridSpacingX;
1419 contentsToViewport ( cx, cy, vx,vy);
1377 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1420 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1378 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1421 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1379 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1422 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1380 1423
1381 if ( mSelectionHeight > 0 ) { 1424 if ( mSelectionHeight > 0 ) {
1382 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1425 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1383 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1426 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1384 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1427 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1385 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1428 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1386 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1429 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1387 } 1430 }
1388 } 1431 }
1389 //qDebug("btbl "); 1432 //qDebug("btbl ");
1390 p->begin( pd ); 1433 p->begin( pd );
1391 //qDebug("end "); 1434 //qDebug("end ");
1435
1436
1437
1438
1439
1440
1441
1442#endif
1392} 1443}
1393 1444
1394void KOAgenda::finishUpdate() 1445void KOAgenda::finishUpdate()
1395{ 1446{
1396 1447
1397 KOAgendaItem *item; 1448 KOAgendaItem *item;
1398 globalFlagBlockAgendaItemPaint = 1; 1449 globalFlagBlockAgendaItemPaint = 1;
1399 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1450 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1400 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1451 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1401 if ( !item->checkLayout() ) { 1452 if ( !item->checkLayout() ) {
1402 //qDebug(" conflictitem found "); 1453 //qDebug(" conflictitem found ");
1403 int newSubCellWidth; 1454 int newSubCellWidth;
1404 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1455 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1405 else newSubCellWidth = mGridSpacingX / item->subCells(); 1456 else newSubCellWidth = mGridSpacingX / item->subCells();
1406 1457
1407 if (mAllDayMode) { 1458 if (mAllDayMode) {
1408 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1459 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1409 } else { 1460 } else {
1410 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1461 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1411 } 1462 }
1412 int x,y; 1463 int x,y;
1413 gridToContents(item->cellX(),item->cellYTop(),x,y); 1464 gridToContents(item->cellX(),item->cellYTop(),x,y);
1414 if (mAllDayMode) { 1465 if (mAllDayMode) {
1415 y += item->subCell() * newSubCellWidth; 1466 y += item->subCell() * newSubCellWidth;
1416 } else { 1467 } else {
1417 x += item->subCell() * newSubCellWidth; 1468 x += item->subCell() * newSubCellWidth;
1418 } 1469 }
1419 moveChild(item,x,y); 1470 moveChild(item,x,y);
1420 } 1471 }
1421 } 1472 }
1422 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1473 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1423 if ( !item->isVisible() ) 1474 if ( !item->isVisible() )
1424 item->show(); 1475 item->show();
1425 1476
1426 } 1477 }
1427 globalFlagBlockAgendaItemUpdate = 0; 1478 globalFlagBlockAgendaItemUpdate = 0;
1428 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1479 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1429 item->repaintMe( ); 1480 item->repaintMe( );
1430 } 1481 }
1431 globalFlagBlockAgendaItemUpdate = 1; 1482 globalFlagBlockAgendaItemUpdate = 1;
1432 qApp->processEvents(); 1483 qApp->processEvents();
1433 globalFlagBlockAgendaItemPaint = 0; 1484 globalFlagBlockAgendaItemPaint = 0;
1434 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1485 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1435 item->repaint( false ); 1486 item->repaint( false );
1436 } 1487 }
1437 1488
1438} 1489}
1439 1490
1440/* 1491/*
1441 Draw grid in the background of the agenda. 1492 Draw grid in the background of the agenda.
1442*/ 1493*/
1443void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1494void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1444{ 1495{
1445 1496
1446 1497
1447 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1498 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1448 return; 1499 return;
1449 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1500 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1450 return; 1501 return;
1451 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1502 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1452 if ( ch < 1 ) 1503 if ( ch < 1 )
1453 ch = 1; 1504 ch = 1;
1454 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1505 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1455 mPaintPixmap.resize( contentsWidth()+42, ch ); 1506 mPaintPixmap.resize( contentsWidth()+42, ch );
1456 } 1507 }
1457 mCurPixWid = contentsWidth(); 1508 mCurPixWid = contentsWidth();
1458 mCurPixHei = ch; 1509 mCurPixHei = ch;
1459 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { 1510 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) {
1460 mHighlightPixmap.resize( mGridSpacingX-1, ch ); 1511 mHighlightPixmap.resize( mGridSpacingX-1, ch );
1461 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1512 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1462 } 1513 }
1463 mPixPainter.begin( &mPaintPixmap) ; 1514 mPixPainter.begin( &mPaintPixmap) ;
1464 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1515 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1465 QPainter * p ; 1516 QPainter * p ;
1466 if (paint == 0) { 1517 if (paint == 0) {
1467 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1518 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1468 p = &mPixPainter; 1519 p = &mPixPainter;
1469 } 1520 }
1470 else 1521 else
1471 p = paint ; 1522 p = paint ;
1472 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1523 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1473 1524
1474 //--cx;++cw; 1525 //--cx;++cw;
1475 int lGridSpacingY = mGridSpacingY*2; 1526 int lGridSpacingY = mGridSpacingY*2;
1476 int selDay; 1527 int selDay;
1477 if ( !backgroundOnly ) 1528 if ( !backgroundOnly )
1478 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1529 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1479 { 1530 {
1480 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { 1531 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
1481 int x1 = cx; 1532 int x1 = cx;
1482 int y1 = 0; 1533 int y1 = 0;
1483 if (y1 < cy) y1 = cy; 1534 if (y1 < cy) y1 = cy;
1484 int x2 = cx+cw-1; 1535 int x2 = cx+cw-1;
1485 int y2 = contentsHeight(); 1536 int y2 = contentsHeight();
1486 if (y2 > cy+ch-1) y2=cy+ch-1; 1537 if (y2 > cy+ch-1) y2=cy+ch-1;
1487 if (x2 >= x1 && y2 >= y1) { 1538 if (x2 >= x1 && y2 >= y1) {
1488 int gxStart = selDay; 1539 int gxStart = selDay;
1489 int gxEnd = gxStart ; 1540 int gxEnd = gxStart ;
1490 int xStart = KOGlobals::self()->reverseLayout() ? 1541 int xStart = KOGlobals::self()->reverseLayout() ?
1491 (mColumns - 1 - gxStart)*mGridSpacingX : 1542 (mColumns - 1 - gxStart)*mGridSpacingX :
1492 gxStart*mGridSpacingX; 1543 gxStart*mGridSpacingX;
1493 if (xStart < x1) xStart = x1; 1544 if (xStart < x1) xStart = x1;
1494 int xEnd = KOGlobals::self()->reverseLayout() ? 1545 int xEnd = KOGlobals::self()->reverseLayout() ?
1495 (mColumns - gxStart)*mGridSpacingX-1 : 1546 (mColumns - gxStart)*mGridSpacingX-1 :
1496 (gxStart+1)*mGridSpacingX-1; 1547 (gxStart+1)*mGridSpacingX-1;
1497 if (xEnd > x2) xEnd = x2; 1548 if (xEnd > x2) xEnd = x2;
1498 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1549 if ( KOPrefs::instance()->mUseHighlightLightColor )
1499 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1550 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1500 KOPrefs::instance()->mAgendaBgColor.light()); 1551 KOPrefs::instance()->mAgendaBgColor.light());
1501 else 1552 else
1502 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1553 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1503 KOPrefs::instance()->mAgendaBgColor.dark()); 1554 KOPrefs::instance()->mAgendaBgColor.dark());
1504 1555
1505 } 1556 }
1506 } 1557 }
1507 } 1558 }
1508 // Highlight working hours 1559 // Highlight working hours
1509 1560
1510 if ( !backgroundOnly ) 1561 if ( !backgroundOnly )
1511 if (mWorkingHoursEnable) { 1562 if (mWorkingHoursEnable) {
1512 int x1 = cx; 1563 int x1 = cx;
1513 int y1 = mWorkingHoursYTop; 1564 int y1 = mWorkingHoursYTop;
1514 if (y1 < cy) y1 = cy; 1565 if (y1 < cy) y1 = cy;
1515 int x2 = cx+cw-1; 1566 int x2 = cx+cw-1;
1516 // int x2 = mGridSpacingX * 5 - 1; 1567 // int x2 = mGridSpacingX * 5 - 1;
1517 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1568 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1518 int y2 = mWorkingHoursYBottom; 1569 int y2 = mWorkingHoursYBottom;
1519 if (y2 > cy+ch-1) y2=cy+ch-1; 1570 if (y2 > cy+ch-1) y2=cy+ch-1;
1520 1571
1521 if (x2 >= x1 && y2 >= y1) { 1572 if (x2 >= x1 && y2 >= y1) {
1522 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1573 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1523 int gxStart = x1/mGridSpacingX; 1574 int gxStart = x1/mGridSpacingX;
1524 int gxEnd = x2/mGridSpacingX; 1575 int gxEnd = x2/mGridSpacingX;
1525 while(gxStart <= gxEnd) { 1576 while(gxStart <= gxEnd) {
1526 if (gxStart < int(mHolidayMask->count()) && 1577 if (gxStart < int(mHolidayMask->count()) &&
1527 !mHolidayMask->at(gxStart)) { 1578 !mHolidayMask->at(gxStart)) {
1528 int xStart = KOGlobals::self()->reverseLayout() ? 1579 int xStart = KOGlobals::self()->reverseLayout() ?
1529 (mColumns - 1 - gxStart)*mGridSpacingX : 1580 (mColumns - 1 - gxStart)*mGridSpacingX :
1530 gxStart*mGridSpacingX; 1581 gxStart*mGridSpacingX;
1531 if (xStart < x1) xStart = x1; 1582 if (xStart < x1) xStart = x1;
1532 int xEnd = KOGlobals::self()->reverseLayout() ? 1583 int xEnd = KOGlobals::self()->reverseLayout() ?
1533 (mColumns - gxStart)*mGridSpacingX-1 : 1584 (mColumns - gxStart)*mGridSpacingX-1 :
1534 (gxStart+1)*mGridSpacingX-1; 1585 (gxStart+1)*mGridSpacingX-1;
1535 if (xEnd > x2) xEnd = x2; 1586 if (xEnd > x2) xEnd = x2;
1536 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { 1587 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
1537 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1588 if ( KOPrefs::instance()->mUseHighlightLightColor )
1538 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1589 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1539 KOPrefs::instance()->mWorkingHoursColor.light()); 1590 KOPrefs::instance()->mWorkingHoursColor.light());
1540 else 1591 else
1541 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1592 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1542 KOPrefs::instance()->mWorkingHoursColor.dark()); 1593 KOPrefs::instance()->mWorkingHoursColor.dark());
1543 } else { 1594 } else {
1544 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1595 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1545 KOPrefs::instance()->mWorkingHoursColor); 1596 KOPrefs::instance()->mWorkingHoursColor);
1546 } 1597 }
1547 } 1598 }
1548 ++gxStart; 1599 ++gxStart;
1549 } 1600 }
1550 } 1601 }
1551 } 1602 }
1552 /* 1603 /*
1553 int selectionX = KOGlobals::self()->reverseLayout() ? 1604 int selectionX = KOGlobals::self()->reverseLayout() ?
1554 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1605 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1555 mSelectionCellX * mGridSpacingX; 1606 mSelectionCellX * mGridSpacingX;
1556 1607
1557 // Draw selection 1608 // Draw selection
1558 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1609 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1559 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1610 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1560 // TODO: paint only part within cx,cy,cw,ch 1611 // TODO: paint only part within cx,cy,cw,ch
1561 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1612 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1562 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1613 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1563 } 1614 }
1564 */ 1615 */
1565 // Draw vertical lines of grid 1616 // Draw vertical lines of grid
1566 1617
1567 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1618 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1568 if ( mGridSpacingX > 0 ) { 1619 if ( mGridSpacingX > 0 ) {
1569 while (x < cx + cw) { 1620 while (x < cx + cw) {
1570 p->drawLine(x,cy,x,cy+ch); 1621 p->drawLine(x,cy,x,cy+ch);
1571 x+=mGridSpacingX; 1622 x+=mGridSpacingX;
1572 } 1623 }
1573 } 1624 }
1574 // Draw horizontal lines of grid 1625 // Draw horizontal lines of grid
1575 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1626 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1576 if ( lGridSpacingY > 0 ) { 1627 if ( lGridSpacingY > 0 ) {
1577 while (y < cy + ch) { 1628 while (y < cy + ch) {
1578 p->setPen( SolidLine ); 1629 p->setPen( SolidLine );
1579 p->drawLine(cx,y,cx+cw,y); 1630 p->drawLine(cx,y,cx+cw,y);
1580 y+=lGridSpacingY; 1631 y+=lGridSpacingY;
1581 p->setPen( DotLine ); 1632 p->setPen( DotLine );
1582 p->drawLine(cx,y,cx+cw,y); 1633 p->drawLine(cx,y,cx+cw,y);
1583 y+=lGridSpacingY; 1634 y+=lGridSpacingY;
1584 } 1635 }
1585 p->setPen( SolidLine ); 1636 p->setPen( SolidLine );
1586 } 1637 }
1587 mPixPainter.end() ; 1638 mPixPainter.end() ;
1588} 1639}
1589 1640
1590/* 1641/*
1591 Convert srcollview contents coordinates to agenda grid coordinates. 1642 Convert srcollview contents coordinates to agenda grid coordinates.
1592*/ 1643*/
1593void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1644void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1594{ 1645{
1595 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1646 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1596 x/mGridSpacingX; 1647 x/mGridSpacingX;
1597 gy = y/mGridSpacingY; 1648 gy = y/mGridSpacingY;
1598} 1649}
1599 1650
1600/* 1651/*
1601 Convert agenda grid coordinates to scrollview contents coordinates. 1652 Convert agenda grid coordinates to scrollview contents coordinates.
1602*/ 1653*/
1603void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1654void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1604{ 1655{
1605 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1656 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1606 gx*mGridSpacingX; 1657 gx*mGridSpacingX;
1607 y = gy*mGridSpacingY; 1658 y = gy*mGridSpacingY;
1608} 1659}
1609 1660
1610 1661
1611/* 1662/*
1612 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1663 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1613 the grid. 1664 the grid.
1614*/ 1665*/
1615int KOAgenda::timeToY(const QTime &time) 1666int KOAgenda::timeToY(const QTime &time)
1616{ 1667{
1617 int minutesPerCell = 24 * 60 / mRows; 1668 int minutesPerCell = 24 * 60 / mRows;
1618 int timeMinutes = time.hour() * 60 + time.minute(); 1669 int timeMinutes = time.hour() * 60 + time.minute();
1619 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1670 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1620 return Y; 1671 return Y;
1621} 1672}
1622 1673
1623 1674
1624/* 1675/*
1625 Return time corresponding to cell y coordinate. Coordinates are rounded to 1676 Return time corresponding to cell y coordinate. Coordinates are rounded to
1626 fit into the grid. 1677 fit into the grid.
1627*/ 1678*/
1628QTime KOAgenda::gyToTime(int gy) 1679QTime KOAgenda::gyToTime(int gy)
1629{ 1680{
1630 1681
1631 int secondsPerCell = 24 * 60 * 60/ mRows; 1682 int secondsPerCell = 24 * 60 * 60/ mRows;
1632 1683
1633 int timeSeconds = secondsPerCell * gy; 1684 int timeSeconds = secondsPerCell * gy;
1634 1685
1635 QTime time( 0, 0, 0 ); 1686 QTime time( 0, 0, 0 );
1636 if ( timeSeconds < 24 * 60 * 60 ) { 1687 if ( timeSeconds < 24 * 60 * 60 ) {
1637 time = time.addSecs(timeSeconds); 1688 time = time.addSecs(timeSeconds);
1638 } else { 1689 } else {
1639 time.setHMS( 23, 59, 59 ); 1690 time.setHMS( 23, 59, 59 );
1640 } 1691 }
1641 1692
1642 return time; 1693 return time;
1643} 1694}
1644 1695
1645void KOAgenda::setStartHour(int startHour) 1696void KOAgenda::setStartHour(int startHour)
1646{ 1697{
1647 int startCell = startHour * mRows / 24; 1698 int startCell = startHour * mRows / 24;
1648 setContentsPos(0,startCell * gridSpacingY()); 1699 setContentsPos(0,startCell * gridSpacingY());
1649} 1700}
1650void KOAgenda::hideUnused() 1701void KOAgenda::hideUnused()
1651{ 1702{
1652 // experimental only 1703 // experimental only
1653 // return; 1704 // return;
1654 KOAgendaItem *item; 1705 KOAgendaItem *item;
1655 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1706 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1656 item->hide(); 1707 item->hide();
1657 } 1708 }
1658} 1709}
1659 1710
1660 1711
1661KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1712KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1662{ 1713{
1663 1714
1664 KOAgendaItem *fi; 1715 KOAgendaItem *fi;
1665 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1716 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1666 if ( fi->incidence() == event ) { 1717 if ( fi->incidence() == event ) {
1667 mUnusedItems.remove(); 1718 mUnusedItems.remove();
1668 fi->init( event, qd ); 1719 fi->init( event, qd );
1669 return fi; 1720 return fi;
1670 } 1721 }
1671 } 1722 }
1672 fi=mUnusedItems.first(); 1723 fi=mUnusedItems.first();
1673 if ( fi ) { 1724 if ( fi ) {
1674 mUnusedItems.remove(); 1725 mUnusedItems.remove();
1675 fi->init( event, qd ); 1726 fi->init( event, qd );
1676 return fi; 1727 return fi;
1677 } 1728 }
1678 // qDebug("new KOAgendaItem "); 1729 // qDebug("new KOAgendaItem ");
1679 1730
1680 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1731 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1681 agendaItem->installEventFilter(this); 1732 agendaItem->installEventFilter(this);
1682 addChild(agendaItem,0,0); 1733 addChild(agendaItem,0,0);
1683 return agendaItem; 1734 return agendaItem;
1684} 1735}
1685KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1736KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1686{ 1737{
1687 KOAgendaItem *item; 1738 KOAgendaItem *item;
1688 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1739 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1689 if ( item->incidence() == todo ) { 1740 if ( item->incidence() == todo ) {
1690 mItems.remove(); 1741 mItems.remove();
1691 return item; 1742 return item;
1692 } 1743 }
1693 } 1744 }
1694 return 0; 1745 return 0;
1695} 1746}
1696 1747
1697 1748
1698void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1749void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1699{ 1750{
1700 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1751 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1701 KOAgendaItem *item; 1752 KOAgendaItem *item;
1702 item = getItemForTodo ( todo ); 1753 item = getItemForTodo ( todo );
1703 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1754 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1704 if ( item ) { 1755 if ( item ) {
1705 blockSignals( true ); 1756 blockSignals( true );
1706 //qDebug("item found "); 1757 //qDebug("item found ");
1707 item->hide(); 1758 item->hide();
1708 item->setCellX(-2, -1 ); 1759 item->setCellX(-2, -1 );
1709 item->select(false); 1760 item->select(false);
1710 mUnusedItems.append( item ); 1761 mUnusedItems.append( item );
1711 mItems.remove( item ); 1762 mItems.remove( item );
1712 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1763 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1713 KOAgendaItem *itemit; 1764 KOAgendaItem *itemit;
1714 //globalFlagBlockAgendaItemPaint = 1; 1765 //globalFlagBlockAgendaItemPaint = 1;
1715 for ( itemit=oldconflictItems.first(); itemit != 0; 1766 for ( itemit=oldconflictItems.first(); itemit != 0;
1716 itemit=oldconflictItems.next() ) { 1767 itemit=oldconflictItems.next() ) {
1717 if ( itemit != item ) 1768 if ( itemit != item )
1718 placeSubCells(itemit); 1769 placeSubCells(itemit);
1719 } 1770 }
1720 qApp->processEvents(); 1771 qApp->processEvents();
1721 //globalFlagBlockAgendaItemPaint = 0; 1772 //globalFlagBlockAgendaItemPaint = 0;
1722 for ( itemit=oldconflictItems.first(); itemit != 0; 1773 for ( itemit=oldconflictItems.first(); itemit != 0;
1723 itemit=oldconflictItems.next() ) { 1774 itemit=oldconflictItems.next() ) {
1724 globalFlagBlockAgendaItemUpdate = 0; 1775 globalFlagBlockAgendaItemUpdate = 0;
1725 if ( itemit != item ) 1776 if ( itemit != item )
1726 itemit->repaintMe(); 1777 itemit->repaintMe();
1727 globalFlagBlockAgendaItemUpdate = 1; 1778 globalFlagBlockAgendaItemUpdate = 1;
1728 itemit->repaint(); 1779 itemit->repaint();
1729 } 1780 }
1730 blockSignals( false ); 1781 blockSignals( false );
1731 } 1782 }
1732 if ( remove ) { 1783 if ( remove ) {
1733 //qDebug("remove****************************************** "); 1784 //qDebug("remove****************************************** ");
1734 return; 1785 return;
1735 } 1786 }
1736 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1787 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1737 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1788 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
1738 QDate currentDate; 1789 QDate currentDate;
1739 QDateTime dt; 1790 QDateTime dt;
1740 if ( todo->hasCompletedDate() ) 1791 if ( todo->hasCompletedDate() )
1741 dt = todo->completed(); 1792 dt = todo->completed();
1742 else 1793 else
1743 dt = todo->dtDue(); 1794 dt = todo->dtDue();
1744 if ( overdue ) { 1795 if ( overdue ) {
1745 currentDate = QDate::currentDate(); 1796 currentDate = QDate::currentDate();
1746 days += todo->dtDue().date().daysTo( currentDate ); 1797 days += todo->dtDue().date().daysTo( currentDate );
1747 } 1798 }
1748 else 1799 else
1749 currentDate = dt.date(); 1800 currentDate = dt.date();
1750 1801
1751 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1802 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1752 if ( ! mAllDayMode ) return; 1803 if ( ! mAllDayMode ) return;
1753 // aldayagenda 1804 // aldayagenda
1754 globalFlagBlockAgendaItemPaint = 1; 1805 globalFlagBlockAgendaItemPaint = 1;
1755 item = insertAllDayItem(todo, currentDate,days, days); 1806 item = insertAllDayItem(todo, currentDate,days, days);
1756 item->show(); 1807 item->show();
1757 1808
1758 } 1809 }
1759 else { 1810 else {
1760 if ( mAllDayMode ) return; 1811 if ( mAllDayMode ) return;
1761 // mAgenda 1812 // mAgenda
1762 globalFlagBlockAgendaItemPaint = 1; 1813 globalFlagBlockAgendaItemPaint = 1;
1763 int endY = timeToY(dt.time()) - 1; 1814 int endY = timeToY(dt.time()) - 1;
1764 int hi = 12/KOPrefs::instance()->mHourSize; 1815 int hi = 12/KOPrefs::instance()->mHourSize;
1765 int startY = endY - 1-hi; 1816 int startY = endY - 1-hi;
1766 item = insertItem(todo,currentDate,days,startY,endY); 1817 item = insertItem(todo,currentDate,days,startY,endY);
1767 item->show(); 1818 item->show();
1768 } 1819 }
1769 qApp->processEvents(); 1820 qApp->processEvents();
1770 globalFlagBlockAgendaItemPaint = 0; 1821 globalFlagBlockAgendaItemPaint = 0;
1771 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1822 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1772 KOAgendaItem *itemit; 1823 KOAgendaItem *itemit;
1773 for ( itemit=oldconflictItems.first(); itemit != 0; 1824 for ( itemit=oldconflictItems.first(); itemit != 0;
1774 itemit=oldconflictItems.next() ) { 1825 itemit=oldconflictItems.next() ) {
1775 globalFlagBlockAgendaItemUpdate = 0; 1826 globalFlagBlockAgendaItemUpdate = 0;
1776 itemit->repaintMe(); 1827 itemit->repaintMe();
1777 globalFlagBlockAgendaItemUpdate = 1; 1828 globalFlagBlockAgendaItemUpdate = 1;
1778 itemit->repaint(); 1829 itemit->repaint();
1779 } 1830 }
1780 globalFlagBlockAgendaItemUpdate = 0; 1831 globalFlagBlockAgendaItemUpdate = 0;
1781 item->repaintMe(); 1832 item->repaintMe();
1782 globalFlagBlockAgendaItemUpdate = 1; 1833 globalFlagBlockAgendaItemUpdate = 1;
1783 item->repaint(); 1834 item->repaint();
1784} 1835}
1785/* 1836/*
1786 Insert KOAgendaItem into agenda. 1837 Insert KOAgendaItem into agenda.
1787*/ 1838*/
1788KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1839KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1789{ 1840{
1790 if (mAllDayMode) { 1841 if (mAllDayMode) {
1791 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1842 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1792 return 0; 1843 return 0;
1793 } 1844 }
1794 1845
1795 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1846 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1796 //agendaItem->setFrameStyle(WinPanel|Raised); 1847 //agendaItem->setFrameStyle(WinPanel|Raised);
1797 1848
1798 int YSize = YBottom - YTop + 1; 1849 int YSize = YBottom - YTop + 1;
1799 if (YSize < 0) { 1850 if (YSize < 0) {
1800 YSize = 1; 1851 YSize = 1;
1801 } 1852 }
1802 int iheight = mGridSpacingY * YSize; 1853 int iheight = mGridSpacingY * YSize;
1803 1854
1804 agendaItem->resize(mGridSpacingX,iheight ); 1855 agendaItem->resize(mGridSpacingX,iheight );
1805 agendaItem->setCellXY(X,YTop,YBottom); 1856 agendaItem->setCellXY(X,YTop,YBottom);
1806 agendaItem->setCellXWidth(X); 1857 agendaItem->setCellXWidth(X);
1807 1858
1808 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1859 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1809 mItems.append(agendaItem); 1860 mItems.append(agendaItem);
1810 1861
1811 placeSubCells(agendaItem); 1862 placeSubCells(agendaItem);
1812 1863
1813 //agendaItem->show(); 1864 //agendaItem->show();
1814 1865
1815 marcus_bains(); 1866 marcus_bains();
1816 1867
1817 return agendaItem; 1868 return agendaItem;
1818} 1869}
1819 1870
1820 1871
1821/* 1872/*
1822 Insert all-day KOAgendaItem into agenda. 1873 Insert all-day KOAgendaItem into agenda.
1823*/ 1874*/
1824KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1875KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1825{ 1876{
1826 if (!mAllDayMode) { 1877 if (!mAllDayMode) {
1827 return 0; 1878 return 0;
1828 } 1879 }
1829 1880
1830 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1881 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1831 1882
1832 agendaItem->setCellXY(XBegin,0,0); 1883 agendaItem->setCellXY(XBegin,0,0);
1833 agendaItem->setCellXWidth(XEnd); 1884 agendaItem->setCellXWidth(XEnd);
1834 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1885 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1835 1886
1836 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1887 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1837 mItems.append(agendaItem); 1888 mItems.append(agendaItem);
1838 1889
1839 placeSubCells(agendaItem); 1890 placeSubCells(agendaItem);
1840 1891
1841 //agendaItem->show(); 1892 //agendaItem->show();
1842 1893
1843 return agendaItem; 1894 return agendaItem;
1844} 1895}
1845 1896
1846 1897
1847void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1898void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1848 int YTop,int YBottom) 1899 int YTop,int YBottom)
1849{ 1900{
1850 if (mAllDayMode) { 1901 if (mAllDayMode) {
1851 ; 1902 ;
1852 return; 1903 return;
1853 } 1904 }
1854 1905
1855 int cellX,cellYTop,cellYBottom; 1906 int cellX,cellYTop,cellYBottom;
1856 QString newtext; 1907 QString newtext;
1857 int width = XEnd - XBegin + 1; 1908 int width = XEnd - XBegin + 1;
1858 int count = 0; 1909 int count = 0;
1859 KOAgendaItem *current = 0; 1910 KOAgendaItem *current = 0;
1860 QPtrList<KOAgendaItem> multiItems; 1911 QPtrList<KOAgendaItem> multiItems;
1861 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1912 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1862 if (cellX == XBegin) cellYTop = YTop; 1913 if (cellX == XBegin) cellYTop = YTop;
1863 else cellYTop = 0; 1914 else cellYTop = 0;
1864 if (cellX == XEnd) cellYBottom = YBottom; 1915 if (cellX == XEnd) cellYBottom = YBottom;
1865 else cellYBottom = rows() - 1; 1916 else cellYBottom = rows() - 1;
1866 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1917 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1867 newtext.append(event->summary()); 1918 newtext.append(event->summary());
1868 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1919 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1869 current->setText(newtext); 1920 current->setText(newtext);
1870 multiItems.append(current); 1921 multiItems.append(current);
1871 } 1922 }
1872 1923
1873 KOAgendaItem *next = 0; 1924 KOAgendaItem *next = 0;
1874 KOAgendaItem *last = multiItems.last(); 1925 KOAgendaItem *last = multiItems.last();
1875 KOAgendaItem *first = multiItems.first(); 1926 KOAgendaItem *first = multiItems.first();
1876 KOAgendaItem *setFirst,*setLast; 1927 KOAgendaItem *setFirst,*setLast;
1877 current = first; 1928 current = first;
1878 while (current) { 1929 while (current) {
1879 next = multiItems.next(); 1930 next = multiItems.next();
1880 if (current == first) setFirst = 0; 1931 if (current == first) setFirst = 0;
1881 else setFirst = first; 1932 else setFirst = first;
1882 if (current == last) setLast = 0; 1933 if (current == last) setLast = 0;
1883 else setLast = last; 1934 else setLast = last;
1884 1935
1885 current->setMultiItem(setFirst,next,setLast); 1936 current->setMultiItem(setFirst,next,setLast);
1886 current = next; 1937 current = next;
1887 } 1938 }
1888 1939
1889 marcus_bains(); 1940 marcus_bains();
1890} 1941}
1891 1942
1892 1943
1893//QSizePolicy KOAgenda::sizePolicy() const 1944//QSizePolicy KOAgenda::sizePolicy() const
1894//{ 1945//{
1895 // Thought this would make the all-day event agenda minimum size and the 1946 // Thought this would make the all-day event agenda minimum size and the
1896 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1947 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1897 // don´t seem to think that an Expanding widget needs more space than a 1948 // don´t seem to think that an Expanding widget needs more space than a
1898 // Preferred one. 1949 // Preferred one.
1899 // But it doesn´t hurt, so it stays. 1950 // But it doesn´t hurt, so it stays.
1900// if (mAllDayMode) { 1951// if (mAllDayMode) {
1901// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1952// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1902// } else { 1953// } else {
1903// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1954// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1904// } 1955// }
1905//} 1956//}
1906void KOAgenda::finishResize ( ) 1957void KOAgenda::finishResize ( )
1907{ 1958{
1908 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1959 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1909 if ( globalFlagBlockAgenda == 0 ) { 1960 if ( globalFlagBlockAgenda == 0 ) {
1910 finishUpdate(); 1961 finishUpdate();
1911 //qDebug("finishUpdate() called "); 1962 //qDebug("finishUpdate() called ");
1912 } 1963 }
1913} 1964}
1914/* 1965/*
1915 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1966 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1916*/ 1967*/
1917void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1968void KOAgenda::resizeEvent ( QResizeEvent *ev )
1918{ 1969{
1919 1970
1920 mResizeTimer.start( 150 , true ); 1971 mResizeTimer.start( 150 , true );
1921 computeSizes(); 1972 computeSizes();
1922 return; 1973 return;
1923 1974
1924} 1975}
1925void KOAgenda::computeSizes() 1976void KOAgenda::computeSizes()
1926{ 1977{
1927 if ( globalFlagBlockStartup ) 1978 if ( globalFlagBlockStartup )
1928 return; 1979 return;
1929 int frameOffset = frameWidth() * 2 +1; 1980 int frameOffset = frameWidth() * 2 +1;
1930 if (mAllDayMode) { 1981 if (mAllDayMode) {
1931 mGridSpacingX = (width()-frameOffset) / mColumns; 1982 mGridSpacingX = (width()-frameOffset) / mColumns;
1932 mGridSpacingY = height() - 2 * frameWidth() - 1; 1983 mGridSpacingY = height() - 2 * frameWidth() - 1;
1933 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1984 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1934 // mGridSpacingY = height(); 1985 // mGridSpacingY = height();
1935 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1986 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1936 1987
1937 KOAgendaItem *item; 1988 KOAgendaItem *item;
1938 int subCellWidth; 1989 int subCellWidth;
1939 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1990 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1940 subCellWidth = mGridSpacingY / item->subCells(); 1991 subCellWidth = mGridSpacingY / item->subCells();
1941 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1992 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1942 moveChild(item,KOGlobals::self()->reverseLayout() ? 1993 moveChild(item,KOGlobals::self()->reverseLayout() ?
1943 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1994 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1944 item->cellX() * mGridSpacingX, 1995 item->cellX() * mGridSpacingX,
1945 item->subCell() * subCellWidth); 1996 item->subCell() * subCellWidth);
1946 } 1997 }
1947 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1998 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1948 } else { 1999 } else {
1949 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 2000 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1950 if (height() > mGridSpacingY * mRows + 1 ) { 2001 if (height() > mGridSpacingY * mRows + 1 ) {
1951 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 2002 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1952 mGridSpacingY = KOPrefs::instance()->mHourSize ; 2003 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1953 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 2004 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1954 emit resizedSignal(); 2005 emit resizedSignal();
1955 } else 2006 } else
1956 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 2007 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1957 KOAgendaItem *item; 2008 KOAgendaItem *item;
1958 int subCellWidth; 2009 int subCellWidth;
1959 2010
1960 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 2011 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1961 subCellWidth = mGridSpacingX / item->subCells(); 2012 subCellWidth = mGridSpacingX / item->subCells();
1962 item->resize(subCellWidth,item->height()); 2013 item->resize(subCellWidth,item->height());
1963 moveChild(item,(KOGlobals::self()->reverseLayout() ? 2014 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1964 (mColumns - 1 - item->cellX()) * mGridSpacingX : 2015 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1965 item->cellX() * mGridSpacingX) + 2016 item->cellX() * mGridSpacingX) +
1966 item->subCell() * subCellWidth,childY(item)); 2017 item->subCell() * subCellWidth,childY(item));
1967 } 2018 }
1968 } 2019 }
1969 int cw = contentsWidth(); 2020 int cw = contentsWidth();
1970 int ch = contentsHeight(); 2021 int ch = contentsHeight();
1971 if ( mAllDayMode ) { 2022 if ( mAllDayMode ) {
1972 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 2023 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1973 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) 2024 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1974 paintPixAll->resize( cw, ch ); 2025 paintPixAll->resize( cw, ch );
1975 } else { 2026 } else {
1976 QPixmap* paintPix = KOAgendaItem::paintPix(); 2027 QPixmap* paintPix = KOAgendaItem::paintPix();
1977 if ( paintPix->width() < cw || paintPix->height() < ch ) 2028 if ( paintPix->width() < cw || paintPix->height() < ch )
1978 KOAgendaItem::resizePixmap( cw , ch ); 2029 KOAgendaItem::resizePixmap( cw , ch );
1979 } 2030 }
1980 2031
1981 checkScrollBoundaries(); 2032 checkScrollBoundaries();
1982 marcus_bains(); 2033 marcus_bains();
1983 drawContentsToPainter(); 2034 drawContentsToPainter();
1984 viewport()->repaint(false); 2035 viewport()->repaint(false);
1985} 2036}
1986 2037
1987void KOAgenda::scrollUp() 2038void KOAgenda::scrollUp()
1988{ 2039{
1989 scrollBy(0,-mScrollOffset); 2040 scrollBy(0,-mScrollOffset);
1990} 2041}
1991 2042
1992 2043
1993void KOAgenda::scrollDown() 2044void KOAgenda::scrollDown()
1994{ 2045{
1995 scrollBy(0,mScrollOffset); 2046 scrollBy(0,mScrollOffset);
1996} 2047}
1997 2048
1998void KOAgenda::popupAlarm() 2049void KOAgenda::popupAlarm()
1999{ 2050{
2000 if (!mClickedItem) { 2051 if (!mClickedItem) {
2001 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 2052 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
2002 return; 2053 return;
2003 } 2054 }
2004 // TODO: deal correctly with multiple alarms 2055 // TODO: deal correctly with multiple alarms
2005 Alarm* alarm; 2056 Alarm* alarm;
2006 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 2057 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
2007 for(alarm=list.first();alarm;alarm=list.next()) { 2058 for(alarm=list.first();alarm;alarm=list.next()) {
2008 alarm->toggleAlarm(); 2059 alarm->toggleAlarm();
2009 } 2060 }
2010 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 2061 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
2011 mClickedItem->paintMe( true ); 2062 mClickedItem->paintMe( true );
2012 mClickedItem->repaint( false ); 2063 mClickedItem->repaint( false );
2013} 2064}
2014 2065
2015/* 2066/*
2016 Calculates the minimum width 2067 Calculates the minimum width
2017*/ 2068*/
2018int KOAgenda::minimumWidth() const 2069int KOAgenda::minimumWidth() const
2019{ 2070{
2020 // TODO:: develop a way to dynamically determine the minimum width 2071 // TODO:: develop a way to dynamically determine the minimum width
2021 int min = 100; 2072 int min = 100;
2022 2073
2023 return min; 2074 return min;
2024} 2075}
2025 2076
2026void KOAgenda::updateConfig() 2077void KOAgenda::updateConfig()
2027{ 2078{
2028 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 2079 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
2029 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 2080 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
2030 if ( mAllDayMode ) { 2081 if ( mAllDayMode ) {
2031 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 2082 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
2032 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 2083 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
2033 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 2084 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
2034 // setMaximumHeight( mGridSpacingY+1 ); 2085 // setMaximumHeight( mGridSpacingY+1 );
2035 viewport()->repaint( false ); 2086 viewport()->repaint( false );
2036 //setFixedHeight( mGridSpacingY+1 ); 2087 //setFixedHeight( mGridSpacingY+1 );
2037 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 2088 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
2038 } 2089 }
2039 else { 2090 else {
2040 mGridSpacingY = KOPrefs::instance()->mHourSize; 2091 mGridSpacingY = KOPrefs::instance()->mHourSize;
2041 calculateWorkingHours(); 2092 calculateWorkingHours();
2042 marcus_bains(); 2093 marcus_bains();
2043 } 2094 }
2044} 2095}
2045 2096
2046void KOAgenda::checkScrollBoundaries() 2097void KOAgenda::checkScrollBoundaries()
2047{ 2098{
2048 // Invalidate old values to force update 2099 // Invalidate old values to force update
2049 mOldLowerScrollValue = -1; 2100 mOldLowerScrollValue = -1;
2050 mOldUpperScrollValue = -1; 2101 mOldUpperScrollValue = -1;
2051 2102
2052 checkScrollBoundaries(verticalScrollBar()->value()); 2103 checkScrollBoundaries(verticalScrollBar()->value());
2053} 2104}
2054 2105
2055void KOAgenda::checkScrollBoundaries(int v) 2106void KOAgenda::checkScrollBoundaries(int v)
2056{ 2107{
2057 if ( mGridSpacingY == 0 ) 2108 if ( mGridSpacingY == 0 )
2058 return; 2109 return;
2059 int yMin = v/mGridSpacingY; 2110 int yMin = v/mGridSpacingY;
2060 int yMax = (v+visibleHeight())/mGridSpacingY; 2111 int yMax = (v+visibleHeight())/mGridSpacingY;
2061 2112
2062// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 2113// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
2063 2114
2064 if (yMin != mOldLowerScrollValue) { 2115 if (yMin != mOldLowerScrollValue) {
2065 mOldLowerScrollValue = yMin; 2116 mOldLowerScrollValue = yMin;
2066 emit lowerYChanged(yMin); 2117 emit lowerYChanged(yMin);
2067 } 2118 }
2068 if (yMax != mOldUpperScrollValue) { 2119 if (yMax != mOldUpperScrollValue) {
2069 mOldUpperScrollValue = yMax; 2120 mOldUpperScrollValue = yMax;
2070 emit upperYChanged(yMax); 2121 emit upperYChanged(yMax);
2071 } 2122 }
2072} 2123}
2073 2124
2074void KOAgenda::deselectItem() 2125void KOAgenda::deselectItem()
2075{ 2126{
2076 if (mSelectedItem.isNull()) return; 2127 if (mSelectedItem.isNull()) return;
2077 mSelectedItem->select(false); 2128 mSelectedItem->select(false);
2078 mSelectedItem = 0; 2129 mSelectedItem = 0;
2079} 2130}
2080 2131
2081void KOAgenda::selectItem(KOAgendaItem *item) 2132void KOAgenda::selectItem(KOAgendaItem *item)
2082{ 2133{
2083 if ((KOAgendaItem *)mSelectedItem == item) return; 2134 if ((KOAgendaItem *)mSelectedItem == item) return;
2084 deselectItem(); 2135 deselectItem();
2085 if (item == 0) { 2136 if (item == 0) {
2086 emit incidenceSelected( 0 ); 2137 emit incidenceSelected( 0 );
2087 return; 2138 return;
2088 } 2139 }
2089 mSelectedItem = item; 2140 mSelectedItem = item;
2090 mSelectedItem->select(); 2141 mSelectedItem->select();
2091 emit incidenceSelected( mSelectedItem->incidence() ); 2142 emit incidenceSelected( mSelectedItem->incidence() );
2092} 2143}
2093 2144
2094// This function seems never be called. 2145// This function seems never be called.
2095void KOAgenda::keyPressEvent( QKeyEvent *kev ) 2146void KOAgenda::keyPressEvent( QKeyEvent *kev )
2096{ 2147{
2097 switch(kev->key()) { 2148 switch(kev->key()) {
2098 case Key_PageDown: 2149 case Key_PageDown:
2099 verticalScrollBar()->addPage(); 2150 verticalScrollBar()->addPage();
2100 break; 2151 break;
2101 case Key_PageUp: 2152 case Key_PageUp:
2102 verticalScrollBar()->subtractPage(); 2153 verticalScrollBar()->subtractPage();
2103 break; 2154 break;
2104 case Key_Down: 2155 case Key_Down:
2105 verticalScrollBar()->addLine(); 2156 verticalScrollBar()->addLine();
2106 break; 2157 break;
2107 case Key_Up: 2158 case Key_Up:
2108 verticalScrollBar()->subtractLine(); 2159 verticalScrollBar()->subtractLine();
2109 break; 2160 break;
2110 default: 2161 default:
2111 ; 2162 ;
2112 } 2163 }
2113} 2164}
2114 2165
2115void KOAgenda::calculateWorkingHours() 2166void KOAgenda::calculateWorkingHours()
2116{ 2167{
2117// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 2168// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
2118 mWorkingHoursEnable = !mAllDayMode; 2169 mWorkingHoursEnable = !mAllDayMode;
2119 2170
2120 mWorkingHoursYTop = mGridSpacingY * 2171 mWorkingHoursYTop = mGridSpacingY *
2121 KOPrefs::instance()->mWorkingHoursStart * 4; 2172 KOPrefs::instance()->mWorkingHoursStart * 4;
2122 mWorkingHoursYBottom = mGridSpacingY * 2173 mWorkingHoursYBottom = mGridSpacingY *
2123 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 2174 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
2124} 2175}
2125 2176
2126 2177
2127DateList KOAgenda::dateList() const 2178DateList KOAgenda::dateList() const
2128{ 2179{
2129 return mSelectedDates; 2180 return mSelectedDates;
2130} 2181}
2131 2182
2132void KOAgenda::setDateList(const DateList &selectedDates) 2183void KOAgenda::setDateList(const DateList &selectedDates)
2133{ 2184{
2134 mSelectedDates = selectedDates; 2185 mSelectedDates = selectedDates;
2135 marcus_bains(); 2186 marcus_bains();
2136} 2187}
2137 2188
2138void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 2189void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
2139{ 2190{
2140 mHolidayMask = mask; 2191 mHolidayMask = mask;
2141 2192
2142/* 2193/*
2143 kdDebug() << "HolidayMask: "; 2194 kdDebug() << "HolidayMask: ";
2144 for(uint i=0;i<mask->count();++i) { 2195 for(uint i=0;i<mask->count();++i) {
2145 kdDebug() << (mask->at(i) ? "*" : "o"); 2196 kdDebug() << (mask->at(i) ? "*" : "o");
2146 } 2197 }
2147 kdDebug() << endl; 2198 kdDebug() << endl;
2148*/ 2199*/
2149} 2200}
2150 2201
2151void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 2202void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
2152{ 2203{
2153 2204
2154 QScrollView::contentsMousePressEvent(event); 2205 QScrollView::contentsMousePressEvent(event);
2155} 2206}
2156 2207
2157void KOAgenda::storePosition() 2208void KOAgenda::storePosition()
2158{ 2209{
2159 //mContentPosition 2210 //mContentPosition
2160 int max = mGridSpacingY*4*24; 2211 int max = mGridSpacingY*4*24;
2161 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 2212 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
2162 mContentPosition = 0; 2213 mContentPosition = 0;
2163 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 2214 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
2164 mContentPosition = -1.0; 2215 mContentPosition = -1.0;
2165 else 2216 else
2166 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 2217 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
2167 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 2218 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
2168 2219
2169} 2220}
2170void KOAgenda::restorePosition() 2221void KOAgenda::restorePosition()
2171{ 2222{
2172 int posY; 2223 int posY;
2173 int max = mGridSpacingY*4*24; 2224 int max = mGridSpacingY*4*24;
2174 if ( mContentPosition < 0 ) 2225 if ( mContentPosition < 0 )
2175 posY = max-viewport()->height(); 2226 posY = max-viewport()->height();
2176 else 2227 else
2177 if ( mContentPosition == 0 ) 2228 if ( mContentPosition == 0 )
2178 posY = 0; 2229 posY = 0;
2179 else 2230 else
2180 posY = (max/mContentPosition)-(viewport()->height()/2); 2231 posY = (max/mContentPosition)-(viewport()->height()/2);
2181 setContentsPos (0, posY ); 2232 setContentsPos (0, posY );
2182 //qDebug("posY %d hei %d", posY, max); 2233 //qDebug("posY %d hei %d", posY, max);
2183 2234
2184} 2235}
2185void KOAgenda::moveChild( QWidget *w, int x , int y ) 2236void KOAgenda::moveChild( QWidget *w, int x , int y )
2186{ 2237{
2187 ++x; 2238 ++x;
2188 QScrollView::moveChild( w, x , y ); 2239 QScrollView::moveChild( w, x , y );
2189} 2240}
2190#include <qmessagebox.h> 2241#include <qmessagebox.h>
2191#ifdef DESKTOP_VERSION 2242#ifdef DESKTOP_VERSION
2192#include <qprinter.h> 2243#include <qprinter.h>
2193#include <qpainter.h> 2244#include <qpainter.h>
2194#include <qpaintdevicemetrics.h> 2245#include <qpaintdevicemetrics.h>
2195 2246
2196#endif 2247#endif
2197void KOAgenda::printSelection() 2248void KOAgenda::printSelection()
2198{ 2249{
2199#ifdef DESKTOP_VERSION 2250#ifdef DESKTOP_VERSION
2200 if ( mStartCellY == mCurrentCellY ) { 2251 if ( mStartCellY == mCurrentCellY ) {
2201 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2252 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2202 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. "), 2253 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. "),
2203 i18n("OK"), 0, 0, 2254 i18n("OK"), 0, 0,
2204 0, 1 ); 2255 0, 1 );
2205 return; 2256 return;
2206 } 2257 }
2207 2258
2208 float dx, dy; 2259 float dx, dy;
2209 int x,y,w,h; 2260 int x,y,w,h;
2210 x= 0; 2261 x= 0;
2211 w= contentsWidth()+2; 2262 w= contentsWidth()+2;
2212 // h= contentsHeight(); 2263 // h= contentsHeight();
2213 y = mGridSpacingY*mStartCellY; 2264 y = mGridSpacingY*mStartCellY;
2214 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 2265 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
2215 2266
2216 //return; 2267 //return;
2217 QPrinter* printer = new QPrinter(); 2268 QPrinter* printer = new QPrinter();
2218 if ( !printer->setup()) { 2269 if ( !printer->setup()) {
2219 delete printer; 2270 delete printer;
2220 return; 2271 return;
2221 } 2272 }
2222 QPainter p( printer ); 2273 QPainter p( printer );
2223 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 2274 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
2224 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); 2275 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
2225 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 2276 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
2226 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); 2277 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
2227 // p.drawText( 0, 0, date ); 2278 // p.drawText( 0, 0, date );
2228 int offset = m.width()/8; 2279 int offset = m.width()/8;
2229 // compute the scale 2280 // compute the scale
2230 dx = ((float) m.width()-offset) / (float)w; 2281 dx = ((float) m.width()-offset) / (float)w;
2231 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 2282 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
2232 float scale; 2283 float scale;
2233 // scale to fit the width or height of the paper 2284 // scale to fit the width or height of the paper
2234 if ( dx < dy ) 2285 if ( dx < dy )
2235 scale = dx; 2286 scale = dx;
2236 else 2287 else
2237 scale = dy; 2288 scale = dy;
2238 // set the scale 2289 // set the scale
2239 p.drawText( offset* scale, offset* scale*3/4, date ); 2290 p.drawText( offset* scale, offset* scale*3/4, date );
2240 2291
2241 int selDay; 2292 int selDay;
2242 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); 2293 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count()));
2243 float startX = 1; 2294 float startX = 1;
2244 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 2295 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
2245 { 2296 {
2246 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); 2297 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true );
2247 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); 2298 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) );
2248 p.drawText( offset* scale+startX, (offset+hei)* scale, text ); 2299 p.drawText( offset* scale+startX, (offset+hei)* scale, text );
2249 startX += widOffset; 2300 startX += widOffset;
2250 2301
2251 } 2302 }
2252 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); 2303 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale));
2253 p.scale( scale, scale ); 2304 p.scale( scale, scale );
2254 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); 2305 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale );
2255 // now printing with y offset: 2 hei 2306 // now printing with y offset: 2 hei
2256 // p.translate( 0, -y*scale); 2307 // p.translate( 0, -y*scale);
2257 2308
2258 drawContentsToPainter(&p, true ); 2309 drawContentsToPainter(&p, true );
2259 globalFlagBlockAgendaItemUpdate = false; 2310 globalFlagBlockAgendaItemUpdate = false;
2260 KOAgendaItem *item; 2311 KOAgendaItem *item;
2261 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 2312 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
2262 item->select(false); 2313 item->select(false);
2263 item->paintMe( false, &p ); 2314 item->paintMe( false, &p );
2264 } 2315 }
2265 globalFlagBlockAgendaItemUpdate = true; 2316 globalFlagBlockAgendaItemUpdate = true;
2266 p.end(); 2317 p.end();
2267 delete printer; 2318 delete printer;
2268#else 2319#else
2269 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2320 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2270 i18n("Not supported \non PDA!\n"), 2321 i18n("Not supported \non PDA!\n"),
2271 i18n("OK"), 0, 0, 2322 i18n("OK"), 0, 0,
2272 0, 1 ); 2323 0, 1 );
2273#endif 2324#endif
2274} 2325}