author | zautrix <zautrix> | 2004-09-12 10:30:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 10:30:29 (UTC) |
commit | a3a24948c51aa2983e415c990eaf0db9ac3c0005 (patch) (unidiff) | |
tree | 558fee47ff2cacbb591c72b9ab16c830cc2f857a | |
parent | 31fab1d7e531b492d1075964ddcbebe7a563a41a (diff) | |
download | kdepimpi-a3a24948c51aa2983e415c990eaf0db9ac3c0005.zip kdepimpi-a3a24948c51aa2983e415c990eaf0db9ac3c0005.tar.gz kdepimpi-a3a24948c51aa2983e415c990eaf0db9ac3c0005.tar.bz2 |
Desktop compile fixes
-rw-r--r-- | Makefile | 472 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 1 |
4 files changed, 173 insertions, 302 deletions
@@ -1,303 +1,171 @@ | |||
1 | export KDEPIMDIR = $(shell pwd) | 1 | ############################################################################# |
2 | # Makefile for building: kdepim-desktop | ||
3 | # Generated by qmake (1.07a) (Qt 3.3.2) on: Sun Sep 12 12:10:39 2004 | ||
4 | # Project: kdepim-desktop.pro | ||
5 | # Template: subdirs | ||
6 | # Command: $(QMAKE) -o Makefile kdepim-desktop.pro | ||
7 | ############################################################################# | ||
8 | |||
9 | MAKEFILE =Makefile | ||
10 | QMAKE =qmake | ||
11 | DEL_FILE = rm -f | ||
12 | CHK_DIR_EXISTS= test -d | ||
13 | MKDIR = mkdir -p | ||
14 | INSTALL_FILE= | ||
15 | INSTALL_DIR = | ||
16 | SUBTARGETS = \ | ||
17 | sub-gammu-emb-common \ | ||
18 | sub-gammu-emb-gammu \ | ||
19 | sub-libical \ | ||
20 | sub-libkcal \ | ||
21 | sub-microkde \ | ||
22 | sub-libkdepim \ | ||
23 | sub-kabc \ | ||
24 | sub-korganizer \ | ||
25 | sub-kaddressbook \ | ||
26 | sub-kabc-plugins-file \ | ||
27 | sub-kabc-plugins-dir | ||
28 | |||
29 | first: all | ||
30 | |||
31 | all: Makefile $(SUBTARGETS) | ||
32 | |||
33 | gammu/emb/common/$(MAKEFILE): | ||
34 | @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common" | ||
35 | cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE) | ||
36 | sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE | ||
37 | cd gammu/emb/common && $(MAKE) -f $(MAKEFILE) | ||
38 | |||
39 | gammu/emb/gammu/$(MAKEFILE): | ||
40 | @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu" | ||
41 | cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE) | ||
42 | sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE | ||
43 | cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE) | ||
44 | |||
45 | libical/$(MAKEFILE): | ||
46 | @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" | ||
47 | cd libical && $(QMAKE) libical.pro -o $(MAKEFILE) | ||
48 | sub-libical: libical/$(MAKEFILE) FORCE | ||
49 | cd libical && $(MAKE) -f $(MAKEFILE) | ||
50 | |||
51 | libkcal/$(MAKEFILE): | ||
52 | @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" | ||
53 | cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE) | ||
54 | sub-libkcal: libkcal/$(MAKEFILE) FORCE | ||
55 | cd libkcal && $(MAKE) -f $(MAKEFILE) | ||
56 | |||
57 | microkde/$(MAKEFILE): | ||
58 | @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" | ||
59 | cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE) | ||
60 | sub-microkde: microkde/$(MAKEFILE) FORCE | ||
61 | cd microkde && $(MAKE) -f $(MAKEFILE) | ||
62 | |||
63 | libkdepim/$(MAKEFILE): | ||
64 | @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" | ||
65 | cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE) | ||
66 | sub-libkdepim: libkdepim/$(MAKEFILE) FORCE | ||
67 | cd libkdepim && $(MAKE) -f $(MAKEFILE) | ||
68 | |||
69 | kabc/$(MAKEFILE): | ||
70 | @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" | ||
71 | cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE) | ||
72 | sub-kabc: kabc/$(MAKEFILE) FORCE | ||
73 | cd kabc && $(MAKE) -f $(MAKEFILE) | ||
74 | |||
75 | korganizer/$(MAKEFILE): | ||
76 | @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" | ||
77 | cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE) | ||
78 | sub-korganizer: korganizer/$(MAKEFILE) FORCE | ||
79 | cd korganizer && $(MAKE) -f $(MAKEFILE) | ||
80 | |||
81 | kaddressbook/$(MAKEFILE): | ||
82 | @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" | ||
83 | cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE) | ||
84 | sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE | ||
85 | cd kaddressbook && $(MAKE) -f $(MAKEFILE) | ||
86 | |||
87 | kabc/plugins/file/$(MAKEFILE): | ||
88 | @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" | ||
89 | cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE) | ||
90 | sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE | ||
91 | cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) | ||
92 | |||
93 | kabc/plugins/dir/$(MAKEFILE): | ||
94 | @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" | ||
95 | cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE) | ||
96 | sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE | ||
97 | cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) | ||
98 | |||
99 | Makefile: kdepim-desktop.pro /usr/local/qtgcc/mkspecs/default/qmake.conf | ||
100 | $(QMAKE) -o Makefile kdepim-desktop.pro | ||
101 | qmake: qmake_all | ||
102 | @$(QMAKE) -o Makefile kdepim-desktop.pro | ||
103 | |||
104 | all: $(SUBTARGETS) | ||
105 | qmake_all: gammu/emb/common/$(MAKEFILE) gammu/emb/gammu/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) | ||
106 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
107 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
108 | ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
109 | ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
110 | ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
111 | ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
112 | ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
113 | ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
114 | ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
115 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
116 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | ||
117 | clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE | ||
118 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
119 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
120 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
121 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
122 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
123 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
124 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
125 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
126 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
127 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
128 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true | ||
129 | uninstall_subdirs: qmake_all FORCE | ||
130 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
131 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
132 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
133 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
134 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
135 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
136 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
137 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
138 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
139 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
140 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | ||
141 | install_subdirs: qmake_all FORCE | ||
142 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
143 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
144 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
145 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
146 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
147 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
148 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
149 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
150 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
151 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
152 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true | ||
153 | distclean: qmake_all FORCE | ||
154 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
155 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
156 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
157 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
158 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
159 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
160 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
161 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
162 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
163 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
164 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | ||
165 | |||
166 | install: install_subdirs | ||
167 | |||
168 | uninstall: uninstall_subdirs | ||
169 | |||
170 | FORCE: | ||
2 | 171 | ||
3 | |||
4 | ifeq ($(PLATFORM) , zaurus) | ||
5 | BUILD_NO_LDAP_PLUGIN=1 | ||
6 | endif | ||
7 | |||
8 | ifneq ($(PLATFORM) , zaurus) | ||
9 | BUILD_NO_SHARP_PLUGIN=1 | ||
10 | endif | ||
11 | |||
12 | SUBDIRS_MICROKDE = \ | ||
13 | libical/src/libical \ | ||
14 | libical/src/libicalss \ | ||
15 | qtcompat \ | ||
16 | microkde \ | ||
17 | libkcal \ | ||
18 | libkdepim \ | ||
19 | kabc \ | ||
20 | kabc/formats/binary \ | ||
21 | kabc/plugins/file \ | ||
22 | kabc/plugins/dir \ | ||
23 | korganizer \ | ||
24 | kalarmd \ | ||
25 | kaddressbook | ||
26 | |||
27 | SUBDIRS_QTOPIA_PLUGIN = \ | ||
28 | kabc/plugins/qtopia | ||
29 | |||
30 | SUBDIRS_OPIE_PLUGIN = \ | ||
31 | kabc/plugins/opie | ||
32 | |||
33 | SUBDIRS_SHARP_PLUGIN = \ | ||
34 | kabc/plugins/sharpdtm | ||
35 | |||
36 | SUBDIRS_LDAP_PLUGIN = \ | ||
37 | kabc/plugins/ldap | ||
38 | |||
39 | SUBDIRS_MICROMAIL = \ | ||
40 | kmicromail/libetpan \ | ||
41 | kmicromail/libmailwrapper \ | ||
42 | kmicromail | ||
43 | |||
44 | SUBDIRS_GAMMU = \ | ||
45 | gammu/emb/common \ | ||
46 | gammu/emb/gammu | ||
47 | |||
48 | SUBDIRS = \ | ||
49 | $(SUBDIRS_MICROKDE) \ | ||
50 | $(SUBDIRS_QTOPIA_PLUGIN) \ | ||
51 | $(SUBDIRS_OPIE_PLUGIN) \ | ||
52 | $(SUBDIRS_SHARP_PLUGIN) \ | ||
53 | $(SUBDIRS_LDAP_PLUGIN) \ | ||
54 | $(SUBDIRS_MICROMAIL) \ | ||
55 | $(SUBDIRS_GAMMU) | ||
56 | |||
57 | all: build_microkde \ | ||
58 | build_qtopia_plugin \ | ||
59 | build_opie_plugin \ | ||
60 | build_sharp_plugin \ | ||
61 | build_ldap_plugin \ | ||
62 | build_micromail \ | ||
63 | build_gammu | ||
64 | |||
65 | |||
66 | build_microkde: variable_test tmake | ||
67 | for i in $(SUBDIRS_MICROKDE); do pushd $$i; \ | ||
68 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | ||
69 | done | ||
70 | |||
71 | build_qtopia_plugin: build_microkde | ||
72 | for i in $(SUBDIRS_QTOPIA_PLUGIN); do pushd $$i; \ | ||
73 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | ||
74 | done | ||
75 | |||
76 | build_opie_plugin: build_microkde | ||
77 | ifdef BUILD_NO_OPIE_PLUGIN | ||
78 | @echo == opie plugin not build. | ||
79 | else | ||
80 | for i in $(SUBDIRS_OPIE_PLUGIN); do pushd $$i; \ | ||
81 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | ||
82 | done | ||
83 | endif | ||
84 | |||
85 | build_sharp_plugin: build_microkde | ||
86 | ifdef BUILD_NO_SHARP_PLUGIN | ||
87 | @echo == ldap plugin not build. | ||
88 | else | ||
89 | for i in $(SUBDIRS_SHARP_PLUGIN); do pushd $$i; \ | ||
90 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | ||
91 | done | ||
92 | endif | ||
93 | |||
94 | build_ldap_plugin: build_microkde | ||
95 | ifdef BUILD_NO_LDAP_PLUGIN | ||
96 | @echo == ldap plugin not build. | ||
97 | else | ||
98 | for i in $(SUBDIRS_LDAP_PLUGIN); do pushd $$i; \ | ||
99 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | ||
100 | done | ||
101 | endif | ||
102 | |||
103 | |||
104 | build_micromail: build_microkde | ||
105 | ifdef BUILD_NO_MICROMAIL | ||
106 | @echo == kmicromail not build. | ||
107 | else | ||
108 | for i in $(SUBDIRS_MICROMAIL); do pushd $$i; \ | ||
109 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | ||
110 | done | ||
111 | endif | ||
112 | |||
113 | build_gammu: variable_test tmake | ||
114 | ifdef BUILD_NO_GAMMU | ||
115 | @echo == gammu not build. | ||
116 | else | ||
117 | for i in $(SUBDIRS_GAMMU); do pushd $$i; \ | ||
118 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | ||
119 | done | ||
120 | endif | ||
121 | |||
122 | |||
123 | variable_info: | ||
124 | @echo -------------------------------------- | ||
125 | @echo KDEPIM buildsystem, variableinfo... | ||
126 | @echo KDEPIMDIR=$(KDEPIMDIR) | ||
127 | @echo QTDIR=$(QTDIR) | ||
128 | @echo QPEDIR=$(QPEDIR) | ||
129 | @echo OPIEDIR=$(OPIEDIR) | ||
130 | @echo PLATFORM=$(PLATFORM) | ||
131 | @echo RELEASE_DEBUG=$(RELEASE_DEBUG) | ||
132 | @echo BUILD_NO_MICROMAIL=$(BUILD_NO_MICROMAIL) | ||
133 | @echo BUILD_NO_LDAP_PLUGIN=$(BUILD_NO_LDAP_PLUGIN) | ||
134 | @echo BUILD_NO_OPIE_PLUGIN=$(BUILD_NO_OPIE_PLUGIN) | ||
135 | @echo BUILD_NO_SHARP_PLUGIN=$(BUILD_NO_SHARP_PLUGIN) | ||
136 | ifndef BUILD_NO_SHARP_PLUGIN | ||
137 | @echo SHARPDTMSDK=$(SHARPDTMSDK) | ||
138 | endif | ||
139 | @echo BUILD_NO_GAMMU=$(BUILD_NO_GAMMU) | ||
140 | @echo -------------------------------------- | ||
141 | |||
142 | variable_test: variable_info | ||
143 | @echo KDEPIM buildsystem, variablecheck... | ||
144 | ifndef KDEPIMDIR | ||
145 | @echo KDEPIMDIR is not defined. | ||
146 | $(error KDEPIMDIR is not defined) | ||
147 | endif | ||
148 | ifndef PLATFORM | ||
149 | @echo PLATFORM is not defined. | ||
150 | $(error PLATFORM is not defined) | ||
151 | endif | ||
152 | ifdef BUILD_NO_LDAP_PLUGIN | ||
153 | @echo LDAP PLUGIN will not be build, because BUILD_NO_LDAP_PLUGIN is set to $(BUILD_NO_LDAP_PLUGIN) | ||
154 | endif | ||
155 | ifdef BUILD_NO_OPIE_PLUGIN | ||
156 | @echo OPIE PLUGIN will not be build, because BUILD_NO_OPIE_PLUGIN is set to $(BUILD_NO_OPIE_PLUGIN) | ||
157 | endif | ||
158 | ifdef BUILD_NO_MICROMAIL | ||
159 | @echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL) | ||
160 | endif | ||
161 | ifdef BUILD_NO_SHARP_PLUGIN | ||
162 | @echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN) | ||
163 | else | ||
164 | ifndef SHARPDTMSDK | ||
165 | @echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK) | ||
166 | $(error SHARPDTMSDK is not defined) | ||
167 | endif | ||
168 | endif | ||
169 | ifdef BUILD_NO_GAMMU | ||
170 | @echo GAMMU will not be build, because BUILD_NO_GAMMU is set to $(BUILD_NO_GAMMU) | ||
171 | endif | ||
172 | @echo -------------------------------------- | ||
173 | |||
174 | |||
175 | objects: | ||
176 | for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done | ||
177 | for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done | ||
178 | mkdir -p libical/lib/$(PLATFORM) | ||
179 | |||
180 | clean: | ||
181 | rm -rf libical/lib/$(PLATFORM)/*; | ||
182 | for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ | ||
183 | rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ | ||
184 | done | ||
185 | install: | ||
186 | |||
187 | cd bin/kdepim; make install | ||
188 | cp -r Pim $(QPEDIR)/apps | ||
189 | cp db2file/db2file $(QPEDIR)/bin/db2file | ||
190 | cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop | ||
191 | cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop | ||
192 | cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kopiemail.desktop | ||
193 | |||
194 | dist: | ||
195 | @echo Dont forget to do "make install" before "make dist" | ||
196 | rm -f *arm.ipk | ||
197 | rm -f *~ | ||
198 | cd ..; tar czf kdepim.src.tar.gz --exclude=obj --exclude=moc --exclude=CVS --exclude=Makefilezaurus --exclude=Makefileqtopia kdepim | ||
199 | ./mkipks kmicrokdelibs.control | ||
200 | ./mkipks korganizer.control | ||
201 | ./mkipks kaddressbook.control | ||
202 | ifndef BUILD_NO_MICROMAIL | ||
203 | ./mkipks kopiemail.control | ||
204 | endif | ||
205 | ./mkipks korganizer-alarm.control | ||
206 | ifndef BUILD_NO_GAMMU | ||
207 | ./mkipks kammu.control | ||
208 | endif | ||
209 | ./mkipks pim_TAB_icon.control | ||
210 | |||
211 | tmake: objects \ | ||
212 | qtcompat/Makefile$(PLATFORM) \ | ||
213 | microkde/Makefile$(PLATFORM) \ | ||
214 | libkcal/Makefile$(PLATFORM) \ | ||
215 | libkdepim/Makefile$(PLATFORM) \ | ||
216 | korganizer/Makefile$(PLATFORM) \ | ||
217 | kalarmd/Makefile$(PLATFORM) \ | ||
218 | libical/src/libical/Makefile$(PLATFORM) \ | ||
219 | libical/src/libicalss/Makefile$(PLATFORM) \ | ||
220 | kabc/Makefile$(PLATFORM) \ | ||
221 | kabc/formats/binary/Makefile$(PLATFORM) \ | ||
222 | kabc/plugins/file/Makefile$(PLATFORM) \ | ||
223 | kabc/plugins/dir/Makefile$(PLATFORM) \ | ||
224 | kabc/plugins/ldap/Makefile$(PLATFORM) \ | ||
225 | kabc/plugins/opie/Makefile$(PLATFORM) \ | ||
226 | kabc/plugins/qtopia/Makefile$(PLATFORM) \ | ||
227 | kabc/plugins/sharpdtm/Makefile$(PLATFORM) \ | ||
228 | kaddressbook/Makefile$(PLATFORM) \ | ||
229 | kmicromail/Makefile$(PLATFORM) \ | ||
230 | kmicromail/libetpan/Makefile$(PLATFORM) \ | ||
231 | kmicromail/libmailwrapper/Makefile$(PLATFORM) \ | ||
232 | gammu/emb/common/Makefile$(PLATFORM) \ | ||
233 | gammu/emb/gammu/Makefile$(PLATFORM) \ | ||
234 | |||
235 | |||
236 | |||
237 | |||
238 | qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro | ||
239 | cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" qtcompat.pro -o Makefile$(PLATFORM) | ||
240 | |||
241 | microkde/Makefile$(PLATFORM): microkde/microkdeE.pro | ||
242 | cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" microkdeE.pro -o Makefile$(PLATFORM) | ||
243 | |||
244 | libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro | ||
245 | cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" libkcalE.pro -o Makefile$(PLATFORM) | ||
246 | |||
247 | |||
248 | libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro | ||
249 | cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" libkdepimE.pro -o Makefile$(PLATFORM) | ||
250 | |||
251 | kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro | ||
252 | cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" kalarmdE.pro -o Makefile$(PLATFORM) | ||
253 | |||
254 | korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro | ||
255 | cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" korganizerE.pro -o Makefile$(PLATFORM) | ||
256 | |||
257 | libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro | ||
258 | cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalE.pro -o Makefile$(PLATFORM) | ||
259 | |||
260 | libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro | ||
261 | cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalssE.pro -o Makefile$(PLATFORM) | ||
262 | |||
263 | kabc/Makefile$(PLATFORM): kabc/kabcE.pro | ||
264 | cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcE.pro -o Makefile$(PLATFORM) | ||
265 | |||
266 | kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro | ||
267 | cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcformat_binaryE.pro -o Makefile$(PLATFORM) | ||
268 | |||
269 | kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/fileE.pro | ||
270 | cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" fileE.pro -o Makefile$(PLATFORM) | ||
271 | |||
272 | kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/dirE.pro | ||
273 | cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" dirE.pro -o Makefile$(PLATFORM) | ||
274 | |||
275 | kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/ldapE.pro | ||
276 | cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" ldapE.pro -o Makefile$(PLATFORM) | ||
277 | |||
278 | kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/opieE.pro | ||
279 | cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" opieE.pro -o Makefile$(PLATFORM) | ||
280 | |||
281 | kabc/plugins/qtopia/Makefile$(PLATFORM): kabc/plugins/qtopia/qtopiaE.pro | ||
282 | cd kabc/plugins/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" qtopiaE.pro -o Makefile$(PLATFORM) | ||
283 | |||
284 | kabc/plugins/sharpdtm/Makefile$(PLATFORM): kabc/plugins/sharpdtm/sharpdtmE.pro | ||
285 | cd kabc/plugins/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" sharpdtmE.pro -o Makefile$(PLATFORM) | ||
286 | |||
287 | kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro | ||
288 | cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" kaddressbookE.pro -o Makefile$(PLATFORM) | ||
289 | |||
290 | kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro | ||
291 | cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" kmicromailE.pro -o Makefile$(PLATFORM) | ||
292 | |||
293 | kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro | ||
294 | cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" libetpanE.pro -o Makefile$(PLATFORM) | ||
295 | |||
296 | kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro | ||
297 | cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" libmailwrapperE.pro -o Makefile$(PLATFORM) | ||
298 | |||
299 | gammu/emb/common/Makefile$(PLATFORM): gammu/emb/common/commonE.pro | ||
300 | cd gammu/emb/common; tmake "CONFIG+=$(RELEASE_DEBUG)" commonE.pro -o Makefile$(PLATFORM) | ||
301 | |||
302 | gammu/emb/gammu/Makefile$(PLATFORM): gammu/emb/gammu/gammuE.pro | ||
303 | cd gammu/emb/gammu; tmake "CONFIG+=$(RELEASE_DEBUG)" gammuE.pro -o Makefile$(PLATFORM) | ||
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 49c0691..8d0fca1 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -1,445 +1,446 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qdragobject.h> | 24 | #include <qdragobject.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qiconview.h> | 26 | #include <qiconview.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qregexp.h> | ||
29 | 30 | ||
30 | #include <kabc/addressbook.h> | 31 | #include <kabc/addressbook.h> |
31 | #include <kabc/addressee.h> | 32 | #include <kabc/addressee.h> |
32 | #include <kconfig.h> | 33 | #include <kconfig.h> |
33 | #include <kdebug.h> | 34 | #include <kdebug.h> |
34 | #include <klocale.h> | 35 | #include <klocale.h> |
35 | 36 | ||
36 | #include "kabprefs.h" | 37 | #include "kabprefs.h" |
37 | #include "viewmanager.h" | 38 | #include "viewmanager.h" |
38 | 39 | ||
39 | #include "kaddressbookcardview.h" | 40 | #include "kaddressbookcardview.h" |
40 | 41 | ||
41 | #ifndef KAB_EMBEDDED | 42 | #ifndef KAB_EMBEDDED |
42 | extern "C" { | 43 | extern "C" { |
43 | void *init_libkaddrbk_cardview() | 44 | void *init_libkaddrbk_cardview() |
44 | { | 45 | { |
45 | return ( new CardViewFactory ); | 46 | return ( new CardViewFactory ); |
46 | } | 47 | } |
47 | } | 48 | } |
48 | #endif //KAB_EMBEDDED | 49 | #endif //KAB_EMBEDDED |
49 | 50 | ||
50 | //////////////////////////////// | 51 | //////////////////////////////// |
51 | // AddresseeCardViewItem (internal class) | 52 | // AddresseeCardViewItem (internal class) |
52 | class AddresseeCardViewItem : public CardViewItem | 53 | class AddresseeCardViewItem : public CardViewItem |
53 | { | 54 | { |
54 | public: | 55 | public: |
55 | AddresseeCardViewItem(const KABC::Field::List &fields, | 56 | AddresseeCardViewItem(const KABC::Field::List &fields, |
56 | bool showEmptyFields, | 57 | bool showEmptyFields, |
57 | KABC::AddressBook *doc, const KABC::Addressee &a, | 58 | KABC::AddressBook *doc, const KABC::Addressee &a, |
58 | CardView *parent) | 59 | CardView *parent) |
59 | : CardViewItem(parent, a.formattedName()), | 60 | : CardViewItem(parent, a.formattedName()), |
60 | mFields( fields ), mShowEmptyFields(showEmptyFields), | 61 | mFields( fields ), mShowEmptyFields(showEmptyFields), |
61 | mDocument(doc), mAddressee(a) | 62 | mDocument(doc), mAddressee(a) |
62 | { | 63 | { |
63 | if ( mFields.isEmpty() ) { | 64 | if ( mFields.isEmpty() ) { |
64 | mFields = KABC::Field::defaultFields(); | 65 | mFields = KABC::Field::defaultFields(); |
65 | } | 66 | } |
66 | refresh(); | 67 | refresh(); |
67 | } | 68 | } |
68 | 69 | ||
69 | const KABC::Addressee &addressee() const { return mAddressee; } | 70 | const KABC::Addressee &addressee() const { return mAddressee; } |
70 | 71 | ||
71 | void refresh() | 72 | void refresh() |
72 | { | 73 | { |
73 | // Update our addressee, since it may have changed elsewhere | 74 | // Update our addressee, since it may have changed elsewhere |
74 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 75 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
75 | 76 | ||
76 | if (!mAddressee.isEmpty()) | 77 | if (!mAddressee.isEmpty()) |
77 | { | 78 | { |
78 | clearFields(); | 79 | clearFields(); |
79 | 80 | ||
80 | // Try all the selected fields until we find one with text. | 81 | // Try all the selected fields until we find one with text. |
81 | // This will limit the number of unlabeled icons in the view | 82 | // This will limit the number of unlabeled icons in the view |
82 | KABC::Field::List::Iterator iter; | 83 | KABC::Field::List::Iterator iter; |
83 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) | 84 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) |
84 | { | 85 | { |
85 | // insert empty fields or not? not doing so saves a bit of memory and CPU | 86 | // insert empty fields or not? not doing so saves a bit of memory and CPU |
86 | // (during geometry calculations), but prevents having equally | 87 | // (during geometry calculations), but prevents having equally |
87 | // wide label columns in all cards, unless CardViewItem/CardView search | 88 | // wide label columns in all cards, unless CardViewItem/CardView search |
88 | // globally for the widest label. (anders) | 89 | // globally for the widest label. (anders) |
89 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) | 90 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) |
90 | insertField((*iter)->label(), (*iter)->value( mAddressee )); | 91 | insertField((*iter)->label(), (*iter)->value( mAddressee )); |
91 | } | 92 | } |
92 | 93 | ||
93 | // We might want to make this the first field. hmm... -mpilone | 94 | // We might want to make this the first field. hmm... -mpilone |
94 | setCaption( mAddressee.realName() ); | 95 | setCaption( mAddressee.realName() ); |
95 | } | 96 | } |
96 | } | 97 | } |
97 | 98 | ||
98 | private: | 99 | private: |
99 | KABC::Field::List mFields; | 100 | KABC::Field::List mFields; |
100 | bool mShowEmptyFields; | 101 | bool mShowEmptyFields; |
101 | KABC::AddressBook *mDocument; | 102 | KABC::AddressBook *mDocument; |
102 | KABC::Addressee mAddressee; | 103 | KABC::Addressee mAddressee; |
103 | }; | 104 | }; |
104 | 105 | ||
105 | /////////////////////////////// | 106 | /////////////////////////////// |
106 | // AddresseeCardView | 107 | // AddresseeCardView |
107 | 108 | ||
108 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 109 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) |
109 | : CardView(parent, name) | 110 | : CardView(parent, name) |
110 | { | 111 | { |
111 | setAcceptDrops(true); | 112 | setAcceptDrops(true); |
112 | } | 113 | } |
113 | 114 | ||
114 | AddresseeCardView::~AddresseeCardView() | 115 | AddresseeCardView::~AddresseeCardView() |
115 | { | 116 | { |
116 | } | 117 | } |
117 | 118 | ||
118 | 119 | ||
119 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 120 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
120 | { | 121 | { |
121 | #ifndef KAB_EMBEDDED | 122 | #ifndef KAB_EMBEDDED |
122 | if (QTextDrag::canDecode(e)) | 123 | if (QTextDrag::canDecode(e)) |
123 | e->accept(); | 124 | e->accept(); |
124 | #else //KAB_EMBEDDED | 125 | #else //KAB_EMBEDDED |
125 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 126 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
126 | #endif //KAB_EMBEDDED | 127 | #endif //KAB_EMBEDDED |
127 | } | 128 | } |
128 | 129 | ||
129 | void AddresseeCardView::dropEvent(QDropEvent *e) | 130 | void AddresseeCardView::dropEvent(QDropEvent *e) |
130 | { | 131 | { |
131 | emit addresseeDropped(e); | 132 | emit addresseeDropped(e); |
132 | } | 133 | } |
133 | 134 | ||
134 | void AddresseeCardView::startDrag() | 135 | void AddresseeCardView::startDrag() |
135 | { | 136 | { |
136 | emit startAddresseeDrag(); | 137 | emit startAddresseeDrag(); |
137 | } | 138 | } |
138 | 139 | ||
139 | 140 | ||
140 | /////////////////////////////// | 141 | /////////////////////////////// |
141 | // KAddressBookCardView | 142 | // KAddressBookCardView |
142 | 143 | ||
143 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 144 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, |
144 | QWidget *parent, const char *name ) | 145 | QWidget *parent, const char *name ) |
145 | : KAddressBookView( ab, parent, name ) | 146 | : KAddressBookView( ab, parent, name ) |
146 | { | 147 | { |
147 | mShowEmptyFields = false; | 148 | mShowEmptyFields = false; |
148 | 149 | ||
149 | // Init the GUI | 150 | // Init the GUI |
150 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 151 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
151 | 152 | ||
152 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); | 153 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); |
153 | mCardView->setSelectionMode(CardView::Extended); | 154 | mCardView->setSelectionMode(CardView::Extended); |
154 | layout->addWidget(mCardView); | 155 | layout->addWidget(mCardView); |
155 | 156 | ||
156 | // Connect up the signals | 157 | // Connect up the signals |
157 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 158 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
158 | this, SLOT(addresseeExecuted(CardViewItem *))); | 159 | this, SLOT(addresseeExecuted(CardViewItem *))); |
159 | connect(mCardView, SIGNAL(selectionChanged()), | 160 | connect(mCardView, SIGNAL(selectionChanged()), |
160 | this, SLOT(addresseeSelected())); | 161 | this, SLOT(addresseeSelected())); |
161 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), | 162 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), |
162 | this, SIGNAL(dropped(QDropEvent*))); | 163 | this, SIGNAL(dropped(QDropEvent*))); |
163 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 164 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
164 | this, SIGNAL(startDrag())); | 165 | this, SIGNAL(startDrag())); |
165 | } | 166 | } |
166 | 167 | ||
167 | KAddressBookCardView::~KAddressBookCardView() | 168 | KAddressBookCardView::~KAddressBookCardView() |
168 | { | 169 | { |
169 | } | 170 | } |
170 | 171 | ||
171 | void KAddressBookCardView::readConfig(KConfig *config) | 172 | void KAddressBookCardView::readConfig(KConfig *config) |
172 | { | 173 | { |
173 | KAddressBookView::readConfig(config); | 174 | KAddressBookView::readConfig(config); |
174 | 175 | ||
175 | // costum colors? | 176 | // costum colors? |
176 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 177 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
177 | { | 178 | { |
178 | QPalette p( mCardView->palette() ); | 179 | QPalette p( mCardView->palette() ); |
179 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 180 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
180 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 181 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
181 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 182 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
182 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 183 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
183 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 184 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
184 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 185 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
185 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 186 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
186 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 187 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
187 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 188 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
188 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 189 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
189 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 190 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
190 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 191 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
191 | mCardView->viewport()->setPalette( p ); | 192 | mCardView->viewport()->setPalette( p ); |
192 | } | 193 | } |
193 | else | 194 | else |
194 | { | 195 | { |
195 | // needed if turned off during a session. | 196 | // needed if turned off during a session. |
196 | mCardView->viewport()->setPalette( mCardView->palette() ); | 197 | mCardView->viewport()->setPalette( mCardView->palette() ); |
197 | } | 198 | } |
198 | 199 | ||
199 | //custom fonts? | 200 | //custom fonts? |
200 | QFont f( font() ); | 201 | QFont f( font() ); |
201 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 202 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
202 | { | 203 | { |
203 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); | 204 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); |
204 | f.setBold( true ); | 205 | f.setBold( true ); |
205 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 206 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
206 | } | 207 | } |
207 | else | 208 | else |
208 | { | 209 | { |
209 | mCardView->setFont( f ); | 210 | mCardView->setFont( f ); |
210 | f.setBold( true ); | 211 | f.setBold( true ); |
211 | mCardView->setHeaderFont( f ); | 212 | mCardView->setHeaderFont( f ); |
212 | } | 213 | } |
213 | 214 | ||
214 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); | 215 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); |
215 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", | 216 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", |
216 | true)); | 217 | true)); |
217 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); | 218 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); |
218 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); | 219 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); |
219 | 220 | ||
220 | mCardView->setShowEmptyFields( mShowEmptyFields ); | 221 | mCardView->setShowEmptyFields( mShowEmptyFields ); |
221 | 222 | ||
222 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); | 223 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); |
223 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); | 224 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); |
224 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); | 225 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); |
225 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); | 226 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); |
226 | 227 | ||
227 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), | 228 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), |
228 | this, SLOT(addresseeExecuted(CardViewItem *))); | 229 | this, SLOT(addresseeExecuted(CardViewItem *))); |
229 | 230 | ||
230 | if (KABPrefs::instance()->mHonorSingleClick) | 231 | if (KABPrefs::instance()->mHonorSingleClick) |
231 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 232 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
232 | this, SLOT(addresseeExecuted(CardViewItem *))); | 233 | this, SLOT(addresseeExecuted(CardViewItem *))); |
233 | else | 234 | else |
234 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 235 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
235 | this, SLOT(addresseeExecuted(CardViewItem *))); | 236 | this, SLOT(addresseeExecuted(CardViewItem *))); |
236 | 237 | ||
237 | } | 238 | } |
238 | 239 | ||
239 | void KAddressBookCardView::writeConfig( KConfig *config ) | 240 | void KAddressBookCardView::writeConfig( KConfig *config ) |
240 | { | 241 | { |
241 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 242 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
242 | KAddressBookView::writeConfig( config ); | 243 | KAddressBookView::writeConfig( config ); |
243 | } | 244 | } |
244 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 245 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) |
245 | { | 246 | { |
246 | mCardView->clear(); | 247 | mCardView->clear(); |
247 | if ( s.isEmpty() || s == "*" ) { | 248 | if ( s.isEmpty() || s == "*" ) { |
248 | refresh(); | 249 | refresh(); |
249 | return; | 250 | return; |
250 | } | 251 | } |
251 | QString pattern = s.lower()+"*"; | 252 | QString pattern = s.lower()+"*"; |
252 | QRegExp re; | 253 | QRegExp re; |
253 | re.setWildcard(true); // most people understand these better. | 254 | re.setWildcard(true); // most people understand these better. |
254 | re.setCaseSensitive(false); | 255 | re.setCaseSensitive(false); |
255 | re.setPattern( pattern ); | 256 | re.setPattern( pattern ); |
256 | if (!re.isValid()) | 257 | if (!re.isValid()) |
257 | return; | 258 | return; |
258 | mCardView->viewport()->setUpdatesEnabled( false ); | 259 | mCardView->viewport()->setUpdatesEnabled( false ); |
259 | KABC::Addressee::List addresseeList = addressees(); | 260 | KABC::Addressee::List addresseeList = addressees(); |
260 | KABC::Addressee::List::Iterator it; | 261 | KABC::Addressee::List::Iterator it; |
261 | if ( field ) { | 262 | if ( field ) { |
262 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 263 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
263 | #if QT_VERSION >= 300 | 264 | #if QT_VERSION >= 300 |
264 | if (re.search(field->value( *it ).lower()) != -1) | 265 | if (re.search(field->value( *it ).lower()) != -1) |
265 | #else | 266 | #else |
266 | if (re.match(field->value( *it ).lower()) != -1) | 267 | if (re.match(field->value( *it ).lower()) != -1) |
267 | #endif | 268 | #endif |
268 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 269 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
269 | addressBook(), *it, mCardView); | 270 | addressBook(), *it, mCardView); |
270 | 271 | ||
271 | } | 272 | } |
272 | } else { | 273 | } else { |
273 | KABC::Field::List fieldList = fields(); | 274 | KABC::Field::List fieldList = fields(); |
274 | KABC::Field::List::ConstIterator fieldIt; | 275 | KABC::Field::List::ConstIterator fieldIt; |
275 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 276 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
276 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 277 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
277 | #if QT_VERSION >= 300 | 278 | #if QT_VERSION >= 300 |
278 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 279 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
279 | #else | 280 | #else |
280 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 281 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
281 | #endif | 282 | #endif |
282 | { | 283 | { |
283 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 284 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
284 | addressBook(), *it, mCardView); | 285 | addressBook(), *it, mCardView); |
285 | continue; | 286 | continue; |
286 | } | 287 | } |
287 | } | 288 | } |
288 | } | 289 | } |
289 | } | 290 | } |
290 | mCardView->viewport()->setUpdatesEnabled( true ); | 291 | mCardView->viewport()->setUpdatesEnabled( true ); |
291 | mCardView->viewport()->update(); | 292 | mCardView->viewport()->update(); |
292 | // by default nothing is selected | 293 | // by default nothing is selected |
293 | emit selected(QString::null); | 294 | emit selected(QString::null); |
294 | } | 295 | } |
295 | QStringList KAddressBookCardView::selectedUids() | 296 | QStringList KAddressBookCardView::selectedUids() |
296 | { | 297 | { |
297 | QStringList uidList; | 298 | QStringList uidList; |
298 | CardViewItem *item; | 299 | CardViewItem *item; |
299 | AddresseeCardViewItem *aItem; | 300 | AddresseeCardViewItem *aItem; |
300 | 301 | ||
301 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 302 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
302 | { | 303 | { |
303 | if (item->isSelected()) | 304 | if (item->isSelected()) |
304 | { | 305 | { |
305 | #ifndef KAB_EMBEDDED | 306 | #ifndef KAB_EMBEDDED |
306 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 307 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
307 | #else //KAB_EMBEDDED | 308 | #else //KAB_EMBEDDED |
308 | aItem = (AddresseeCardViewItem*)(item); | 309 | aItem = (AddresseeCardViewItem*)(item); |
309 | #endif //KAB_EMBEDDED | 310 | #endif //KAB_EMBEDDED |
310 | if (aItem) | 311 | if (aItem) |
311 | uidList << aItem->addressee().uid(); | 312 | uidList << aItem->addressee().uid(); |
312 | } | 313 | } |
313 | } | 314 | } |
314 | 315 | ||
315 | return uidList; | 316 | return uidList; |
316 | } | 317 | } |
317 | 318 | ||
318 | void KAddressBookCardView::refresh(QString uid) | 319 | void KAddressBookCardView::refresh(QString uid) |
319 | { | 320 | { |
320 | CardViewItem *item; | 321 | CardViewItem *item; |
321 | AddresseeCardViewItem *aItem; | 322 | AddresseeCardViewItem *aItem; |
322 | 323 | ||
323 | if (uid.isNull()) | 324 | if (uid.isNull()) |
324 | { | 325 | { |
325 | // Rebuild the view | 326 | // Rebuild the view |
326 | mCardView->viewport()->setUpdatesEnabled( false ); | 327 | mCardView->viewport()->setUpdatesEnabled( false ); |
327 | mCardView->clear(); | 328 | mCardView->clear(); |
328 | 329 | ||
329 | KABC::Addressee::List addresseeList = addressees(); | 330 | KABC::Addressee::List addresseeList = addressees(); |
330 | KABC::Addressee::List::Iterator iter; | 331 | KABC::Addressee::List::Iterator iter; |
331 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 332 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |
332 | { | 333 | { |
333 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, | 334 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, |
334 | addressBook(), *iter, mCardView); | 335 | addressBook(), *iter, mCardView); |
335 | } | 336 | } |
336 | mCardView->viewport()->setUpdatesEnabled( true ); | 337 | mCardView->viewport()->setUpdatesEnabled( true ); |
337 | mCardView->viewport()->update(); | 338 | mCardView->viewport()->update(); |
338 | 339 | ||
339 | // by default nothing is selected | 340 | // by default nothing is selected |
340 | emit selected(QString::null); | 341 | emit selected(QString::null); |
341 | } | 342 | } |
342 | else | 343 | else |
343 | { | 344 | { |
344 | // Try to find the one to refresh | 345 | // Try to find the one to refresh |
345 | bool found = false; | 346 | bool found = false; |
346 | for (item = mCardView->firstItem(); item && !found; | 347 | for (item = mCardView->firstItem(); item && !found; |
347 | item = item->nextItem()) | 348 | item = item->nextItem()) |
348 | { | 349 | { |
349 | #ifndef KAB_EMBEDDED | 350 | #ifndef KAB_EMBEDDED |
350 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 351 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
351 | #else //KAB_EMBEDDED | 352 | #else //KAB_EMBEDDED |
352 | aItem = (AddresseeCardViewItem*)(item); | 353 | aItem = (AddresseeCardViewItem*)(item); |
353 | #endif //KAB_EMBEDDED | 354 | #endif //KAB_EMBEDDED |
354 | 355 | ||
355 | if ((aItem) && (aItem->addressee().uid() == uid)) | 356 | if ((aItem) && (aItem->addressee().uid() == uid)) |
356 | { | 357 | { |
357 | aItem->refresh(); | 358 | aItem->refresh(); |
358 | found = true; | 359 | found = true; |
359 | } | 360 | } |
360 | } | 361 | } |
361 | } | 362 | } |
362 | } | 363 | } |
363 | 364 | ||
364 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 365 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
365 | { | 366 | { |
366 | CardViewItem *item; | 367 | CardViewItem *item; |
367 | AddresseeCardViewItem *aItem; | 368 | AddresseeCardViewItem *aItem; |
368 | 369 | ||
369 | if (uid.isNull()) | 370 | if (uid.isNull()) |
370 | { | 371 | { |
371 | mCardView->selectAll(selected); | 372 | mCardView->selectAll(selected); |
372 | } | 373 | } |
373 | else | 374 | else |
374 | { | 375 | { |
375 | bool found = false; | 376 | bool found = false; |
376 | for (item = mCardView->firstItem(); item && !found; | 377 | for (item = mCardView->firstItem(); item && !found; |
377 | item = item->nextItem()) | 378 | item = item->nextItem()) |
378 | { | 379 | { |
379 | #ifndef KAB_EMBEDDED | 380 | #ifndef KAB_EMBEDDED |
380 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 381 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
381 | #else //KAB_EMBEDDED | 382 | #else //KAB_EMBEDDED |
382 | aItem = (AddresseeCardViewItem*)(item); | 383 | aItem = (AddresseeCardViewItem*)(item); |
383 | #endif //KAB_EMBEDDED | 384 | #endif //KAB_EMBEDDED |
384 | 385 | ||
385 | if ((aItem) && (aItem->addressee().uid() == uid)) | 386 | if ((aItem) && (aItem->addressee().uid() == uid)) |
386 | { | 387 | { |
387 | mCardView->setSelected(aItem, selected); | 388 | mCardView->setSelected(aItem, selected); |
388 | mCardView->ensureItemVisible(item); | 389 | mCardView->ensureItemVisible(item); |
389 | found = true; | 390 | found = true; |
390 | } | 391 | } |
391 | } | 392 | } |
392 | } | 393 | } |
393 | } | 394 | } |
394 | 395 | ||
395 | //US added an additional method without parameter | 396 | //US added an additional method without parameter |
396 | void KAddressBookCardView::setSelected() | 397 | void KAddressBookCardView::setSelected() |
397 | { | 398 | { |
398 | setSelected(QString::null, true); | 399 | setSelected(QString::null, true); |
399 | } | 400 | } |
400 | 401 | ||
401 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | 402 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) |
402 | { | 403 | { |
403 | #ifndef KAB_EMBEDDED | 404 | #ifndef KAB_EMBEDDED |
404 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 405 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
405 | #else //KAB_EMBEDDED | 406 | #else //KAB_EMBEDDED |
406 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); | 407 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); |
407 | #endif //KAB_EMBEDDED | 408 | #endif //KAB_EMBEDDED |
408 | if (aItem) | 409 | if (aItem) |
409 | { | 410 | { |
410 | //kdDebug()<<"... even has a valid item:)"<<endl; | 411 | //kdDebug()<<"... even has a valid item:)"<<endl; |
411 | emit executed(aItem->addressee().uid()); | 412 | emit executed(aItem->addressee().uid()); |
412 | } | 413 | } |
413 | } | 414 | } |
414 | 415 | ||
415 | void KAddressBookCardView::addresseeSelected() | 416 | void KAddressBookCardView::addresseeSelected() |
416 | { | 417 | { |
417 | CardViewItem *item; | 418 | CardViewItem *item; |
418 | AddresseeCardViewItem *aItem; | 419 | AddresseeCardViewItem *aItem; |
419 | 420 | ||
420 | bool found = false; | 421 | bool found = false; |
421 | for (item = mCardView->firstItem(); item && !found; | 422 | for (item = mCardView->firstItem(); item && !found; |
422 | item = item->nextItem()) | 423 | item = item->nextItem()) |
423 | { | 424 | { |
424 | if (item->isSelected()) | 425 | if (item->isSelected()) |
425 | { | 426 | { |
426 | #ifndef KAB_EMBEDDED | 427 | #ifndef KAB_EMBEDDED |
427 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 428 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
428 | #else //KAB_EMBEDDED | 429 | #else //KAB_EMBEDDED |
429 | aItem = (AddresseeCardViewItem*)(item); | 430 | aItem = (AddresseeCardViewItem*)(item); |
430 | #endif //KAB_EMBEDDED | 431 | #endif //KAB_EMBEDDED |
431 | if ( aItem ) | 432 | if ( aItem ) |
432 | { | 433 | { |
433 | emit selected(aItem->addressee().uid()); | 434 | emit selected(aItem->addressee().uid()); |
434 | found = true; | 435 | found = true; |
435 | } | 436 | } |
436 | } | 437 | } |
437 | } | 438 | } |
438 | 439 | ||
439 | if (!found) | 440 | if (!found) |
440 | emit selected(QString::null); | 441 | emit selected(QString::null); |
441 | 442 | ||
442 | } | 443 | } |
443 | #ifndef KAB_EMBEDDED | 444 | #ifndef KAB_EMBEDDED |
444 | #include "kaddressbookcardview.moc" | 445 | #include "kaddressbookcardview.moc" |
445 | #endif //KAB_EMBEDDED | 446 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index 78d63b0..0ffc674 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -1,425 +1,426 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KAB_EMBEDDED | 24 | #ifndef KAB_EMBEDDED |
25 | #include <qiconview.h> | 25 | #include <qiconview.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | 27 | ||
28 | #include <kabc/addressee.h> | 28 | #include <kabc/addressee.h> |
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #else //KAB_EMBEDDED | 35 | #else //KAB_EMBEDDED |
36 | #endif //KAB_EMBEDDED | 36 | #endif //KAB_EMBEDDED |
37 | 37 | ||
38 | #include <kabc/addressbook.h> | 38 | #include <kabc/addressbook.h> |
39 | #include "kabprefs.h" | 39 | #include "kabprefs.h" |
40 | #include "viewmanager.h" | 40 | #include "viewmanager.h" |
41 | #include "kaddressbookiconview.h" | 41 | #include "kaddressbookiconview.h" |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qregexp.h> | ||
43 | #include <kglobal.h> | 44 | #include <kglobal.h> |
44 | /*US transfered to the headerfile | 45 | /*US transfered to the headerfile |
45 | class IconViewFactory : public ViewFactory | 46 | class IconViewFactory : public ViewFactory |
46 | { | 47 | { |
47 | public: | 48 | public: |
48 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 49 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
49 | { | 50 | { |
50 | return new KAddressBookIconView( ab, parent, name ); | 51 | return new KAddressBookIconView( ab, parent, name ); |
51 | } | 52 | } |
52 | 53 | ||
53 | QString type() const { return "Icon"; } | 54 | QString type() const { return "Icon"; } |
54 | 55 | ||
55 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } | 56 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } |
56 | }; | 57 | }; |
57 | 58 | ||
58 | */ | 59 | */ |
59 | 60 | ||
60 | extern "C" { | 61 | extern "C" { |
61 | void *init_libkaddrbk_iconview() | 62 | void *init_libkaddrbk_iconview() |
62 | { | 63 | { |
63 | return ( new IconViewFactory ); | 64 | return ( new IconViewFactory ); |
64 | } | 65 | } |
65 | } | 66 | } |
66 | 67 | ||
67 | //////////////////////////////// | 68 | //////////////////////////////// |
68 | // AddresseeIconView (internal class) | 69 | // AddresseeIconView (internal class) |
69 | #ifndef KAB_EMBEDDED | 70 | #ifndef KAB_EMBEDDED |
70 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 71 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
71 | : KIconView(parent, name) | 72 | : KIconView(parent, name) |
72 | #else //KAB_EMBEDDED | 73 | #else //KAB_EMBEDDED |
73 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 74 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
74 | : QIconView(parent, name) | 75 | : QIconView(parent, name) |
75 | #endif //KAB_EMBEDDED | 76 | #endif //KAB_EMBEDDED |
76 | 77 | ||
77 | { | 78 | { |
78 | setSelectionMode( QIconView::Extended ); | 79 | setSelectionMode( QIconView::Extended ); |
79 | setResizeMode( QIconView::Adjust ); | 80 | setResizeMode( QIconView::Adjust ); |
80 | setWordWrapIconText( true ); | 81 | setWordWrapIconText( true ); |
81 | setGridX( 100 ); | 82 | setGridX( 100 ); |
82 | setItemsMovable(false); | 83 | setItemsMovable(false); |
83 | setSorting(true, true); | 84 | setSorting(true, true); |
84 | 85 | ||
85 | 86 | ||
86 | //US ??? setMode( KIconView::Select ); | 87 | //US ??? setMode( KIconView::Select ); |
87 | 88 | ||
88 | #ifndef KAB_EMBEDDED | 89 | #ifndef KAB_EMBEDDED |
89 | 90 | ||
90 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), | 91 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), |
91 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); | 92 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); |
92 | #endif //KAB_EMBEDDED | 93 | #endif //KAB_EMBEDDED |
93 | } | 94 | } |
94 | 95 | ||
95 | AddresseeIconView::~AddresseeIconView() | 96 | AddresseeIconView::~AddresseeIconView() |
96 | { | 97 | { |
97 | } | 98 | } |
98 | 99 | ||
99 | 100 | ||
100 | void AddresseeIconView::itemDropped(QDropEvent *e, | 101 | void AddresseeIconView::itemDropped(QDropEvent *e, |
101 | const QValueList<QIconDragItem> &) | 102 | const QValueList<QIconDragItem> &) |
102 | { | 103 | { |
103 | emit addresseeDropped(e); | 104 | emit addresseeDropped(e); |
104 | } | 105 | } |
105 | 106 | ||
106 | QDragObject *AddresseeIconView::dragObject() | 107 | QDragObject *AddresseeIconView::dragObject() |
107 | { | 108 | { |
108 | emit startAddresseeDrag(); | 109 | emit startAddresseeDrag(); |
109 | 110 | ||
110 | // We never want IconView to start the drag | 111 | // We never want IconView to start the drag |
111 | return 0; | 112 | return 0; |
112 | } | 113 | } |
113 | //////////////////////////////// | 114 | //////////////////////////////// |
114 | // AddresseeIconViewItem (internal class) | 115 | // AddresseeIconViewItem (internal class) |
115 | #ifndef KAB_EMBEDDED | 116 | #ifndef KAB_EMBEDDED |
116 | class AddresseeIconViewItem : public KIconViewItem | 117 | class AddresseeIconViewItem : public KIconViewItem |
117 | #else //KAB_EMBEDDED | 118 | #else //KAB_EMBEDDED |
118 | class AddresseeIconViewItem : public QIconViewItem | 119 | class AddresseeIconViewItem : public QIconViewItem |
119 | #endif //KAB_EMBEDDED | 120 | #endif //KAB_EMBEDDED |
120 | { | 121 | { |
121 | public: | 122 | public: |
122 | #ifndef KAB_EMBEDDED | 123 | #ifndef KAB_EMBEDDED |
123 | AddresseeIconViewItem(const KABC::Field::List &fields, | 124 | AddresseeIconViewItem(const KABC::Field::List &fields, |
124 | KABC::AddressBook *doc, const KABC::Addressee &a, | 125 | KABC::AddressBook *doc, const KABC::Addressee &a, |
125 | QIconView *parent) | 126 | QIconView *parent) |
126 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 127 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
127 | #else //KAB_EMBEDDED | 128 | #else //KAB_EMBEDDED |
128 | AddresseeIconViewItem(const KABC::Field::List &fields, | 129 | AddresseeIconViewItem(const KABC::Field::List &fields, |
129 | KABC::AddressBook *doc, const KABC::Addressee &a, | 130 | KABC::AddressBook *doc, const KABC::Addressee &a, |
130 | QIconView *parent) | 131 | QIconView *parent) |
131 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 132 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
132 | #endif //KAB_EMBEDDED | 133 | #endif //KAB_EMBEDDED |
133 | { | 134 | { |
134 | if ( mFields.isEmpty() ) { | 135 | if ( mFields.isEmpty() ) { |
135 | mFields = KABC::Field::defaultFields(); | 136 | mFields = KABC::Field::defaultFields(); |
136 | } | 137 | } |
137 | refresh(); | 138 | refresh(); |
138 | } | 139 | } |
139 | 140 | ||
140 | const KABC::Addressee &addressee() const { return mAddressee; } | 141 | const KABC::Addressee &addressee() const { return mAddressee; } |
141 | 142 | ||
142 | void refresh() | 143 | void refresh() |
143 | { | 144 | { |
144 | // Update our addressee, since it may have changed elsewhere | 145 | // Update our addressee, since it may have changed elsewhere |
145 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 146 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
146 | 147 | ||
147 | if (!mAddressee.isEmpty()) | 148 | if (!mAddressee.isEmpty()) |
148 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); | 149 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); |
149 | 150 | ||
150 | QPixmap icon; | 151 | QPixmap icon; |
151 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); | 152 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); |
152 | KABC::Picture pic = mAddressee.photo(); | 153 | KABC::Picture pic = mAddressee.photo(); |
153 | if ( pic.data().isNull() ) | 154 | if ( pic.data().isNull() ) |
154 | pic = mAddressee.logo(); | 155 | pic = mAddressee.logo(); |
155 | 156 | ||
156 | if ( pic.isIntern() && !pic.data().isNull() ) { | 157 | if ( pic.isIntern() && !pic.data().isNull() ) { |
157 | QImage img = pic.data(); | 158 | QImage img = pic.data(); |
158 | #ifndef KAB_EMBEDDED | 159 | #ifndef KAB_EMBEDDED |
159 | if ( img.width() > img.height() ) | 160 | if ( img.width() > img.height() ) |
160 | icon = img.scaleWidth( 32 ); | 161 | icon = img.scaleWidth( 32 ); |
161 | else | 162 | else |
162 | icon = img.scaleHeight( 32 ); | 163 | icon = img.scaleHeight( 32 ); |
163 | #else //KAB_EMBEDDED | 164 | #else //KAB_EMBEDDED |
164 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); | 165 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); |
165 | icon.convertFromImage(img.smoothScale(32, 32)); | 166 | icon.convertFromImage(img.smoothScale(32, 32)); |
166 | #endif //KAB_EMBEDDED | 167 | #endif //KAB_EMBEDDED |
167 | 168 | ||
168 | } else | 169 | } else |
169 | icon = defaultIcon; | 170 | icon = defaultIcon; |
170 | 171 | ||
171 | setPixmap( icon ); | 172 | setPixmap( icon ); |
172 | } | 173 | } |
173 | 174 | ||
174 | private: | 175 | private: |
175 | KABC::Field::List mFields; | 176 | KABC::Field::List mFields; |
176 | KABC::AddressBook *mDocument; | 177 | KABC::AddressBook *mDocument; |
177 | KABC::Addressee mAddressee; | 178 | KABC::Addressee mAddressee; |
178 | }; | 179 | }; |
179 | 180 | ||
180 | /////////////////////////////// | 181 | /////////////////////////////// |
181 | // KAddressBookView | 182 | // KAddressBookView |
182 | 183 | ||
183 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 184 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, |
184 | QWidget *parent, const char *name) | 185 | QWidget *parent, const char *name) |
185 | : KAddressBookView( ab, parent, name ) | 186 | : KAddressBookView( ab, parent, name ) |
186 | { | 187 | { |
187 | // Init the GUI | 188 | // Init the GUI |
188 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 189 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
189 | 190 | ||
190 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); | 191 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); |
191 | layout->addWidget(mIconView); | 192 | layout->addWidget(mIconView); |
192 | 193 | ||
193 | // Connect up the signals | 194 | // Connect up the signals |
194 | 195 | ||
195 | //US method executed is part of KIconView | 196 | //US method executed is part of KIconView |
196 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 197 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
197 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 198 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
198 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 199 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
199 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 200 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
200 | 201 | ||
201 | connect(mIconView, SIGNAL(selectionChanged()), | 202 | connect(mIconView, SIGNAL(selectionChanged()), |
202 | this, SLOT(addresseeSelected())); | 203 | this, SLOT(addresseeSelected())); |
203 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 204 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
204 | this, SIGNAL(dropped(QDropEvent*))); | 205 | this, SIGNAL(dropped(QDropEvent*))); |
205 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 206 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
206 | this, SIGNAL(startDrag())); | 207 | this, SIGNAL(startDrag())); |
207 | } | 208 | } |
208 | 209 | ||
209 | KAddressBookIconView::~KAddressBookIconView() | 210 | KAddressBookIconView::~KAddressBookIconView() |
210 | { | 211 | { |
211 | } | 212 | } |
212 | 213 | ||
213 | void KAddressBookIconView::readConfig(KConfig *config) | 214 | void KAddressBookIconView::readConfig(KConfig *config) |
214 | { | 215 | { |
215 | KAddressBookView::readConfig(config); | 216 | KAddressBookView::readConfig(config); |
216 | 217 | ||
217 | //US method executed is part of KIconView | 218 | //US method executed is part of KIconView |
218 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), | 219 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), |
219 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 220 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
220 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 221 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
221 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 222 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
222 | 223 | ||
223 | //US method executed is part of KIconView. Use selectionChanged instead | 224 | //US method executed is part of KIconView. Use selectionChanged instead |
224 | /*US | 225 | /*US |
225 | if (KABPrefs::instance()->mHonorSingleClick) | 226 | if (KABPrefs::instance()->mHonorSingleClick) |
226 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 227 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
227 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 228 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
228 | else | 229 | else |
229 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), | 230 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), |
230 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 231 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
231 | */ | 232 | */ |
232 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 233 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
233 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 234 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
234 | 235 | ||
235 | } | 236 | } |
236 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 237 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) |
237 | { | 238 | { |
238 | mIconView->clear(); | 239 | mIconView->clear(); |
239 | mIconList.clear(); | 240 | mIconList.clear(); |
240 | if ( s.isEmpty() || s == "*" ) { | 241 | if ( s.isEmpty() || s == "*" ) { |
241 | refresh(); | 242 | refresh(); |
242 | return; | 243 | return; |
243 | } | 244 | } |
244 | QString pattern = s.lower()+"*"; | 245 | QString pattern = s.lower()+"*"; |
245 | QRegExp re; | 246 | QRegExp re; |
246 | re.setWildcard(true); // most people understand these better. | 247 | re.setWildcard(true); // most people understand these better. |
247 | re.setCaseSensitive(false); | 248 | re.setCaseSensitive(false); |
248 | re.setPattern( pattern ); | 249 | re.setPattern( pattern ); |
249 | if (!re.isValid()) | 250 | if (!re.isValid()) |
250 | return; | 251 | return; |
251 | KABC::Addressee::List addresseeList = addressees(); | 252 | KABC::Addressee::List addresseeList = addressees(); |
252 | KABC::Addressee::List::Iterator it; | 253 | KABC::Addressee::List::Iterator it; |
253 | if ( field ) { | 254 | if ( field ) { |
254 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 255 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
255 | #if QT_VERSION >= 300 | 256 | #if QT_VERSION >= 300 |
256 | if (re.search(field->value( *it ).lower()) != -1) | 257 | if (re.search(field->value( *it ).lower()) != -1) |
257 | #else | 258 | #else |
258 | if (re.match(field->value( *it ).lower()) != -1) | 259 | if (re.match(field->value( *it ).lower()) != -1) |
259 | #endif | 260 | #endif |
260 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 261 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
261 | 262 | ||
262 | 263 | ||
263 | } | 264 | } |
264 | } else { | 265 | } else { |
265 | KABC::Field::List fieldList = fields(); | 266 | KABC::Field::List fieldList = fields(); |
266 | KABC::Field::List::ConstIterator fieldIt; | 267 | KABC::Field::List::ConstIterator fieldIt; |
267 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 268 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
268 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 269 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
269 | #if QT_VERSION >= 300 | 270 | #if QT_VERSION >= 300 |
270 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 271 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
271 | #else | 272 | #else |
272 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 273 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
273 | #endif | 274 | #endif |
274 | { | 275 | { |
275 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 276 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
276 | continue; | 277 | continue; |
277 | } | 278 | } |
278 | } | 279 | } |
279 | } | 280 | } |
280 | } | 281 | } |
281 | mIconView->arrangeItemsInGrid( true ); | 282 | mIconView->arrangeItemsInGrid( true ); |
282 | } | 283 | } |
283 | QStringList KAddressBookIconView::selectedUids() | 284 | QStringList KAddressBookIconView::selectedUids() |
284 | { | 285 | { |
285 | QStringList uidList; | 286 | QStringList uidList; |
286 | QIconViewItem *item; | 287 | QIconViewItem *item; |
287 | AddresseeIconViewItem *aItem; | 288 | AddresseeIconViewItem *aItem; |
288 | 289 | ||
289 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 290 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
290 | { | 291 | { |
291 | if (item->isSelected()) | 292 | if (item->isSelected()) |
292 | { | 293 | { |
293 | #ifndef KAB_EMBEDDED | 294 | #ifndef KAB_EMBEDDED |
294 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 295 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
295 | #else //KAB_EMBEDDED | 296 | #else //KAB_EMBEDDED |
296 | aItem = (AddresseeIconViewItem*)(item); | 297 | aItem = (AddresseeIconViewItem*)(item); |
297 | #endif //KAB_EMBEDDED | 298 | #endif //KAB_EMBEDDED |
298 | if (aItem) | 299 | if (aItem) |
299 | uidList << aItem->addressee().uid(); | 300 | uidList << aItem->addressee().uid(); |
300 | } | 301 | } |
301 | } | 302 | } |
302 | 303 | ||
303 | return uidList; | 304 | return uidList; |
304 | } | 305 | } |
305 | 306 | ||
306 | void KAddressBookIconView::refresh(QString uid) | 307 | void KAddressBookIconView::refresh(QString uid) |
307 | { | 308 | { |
308 | QIconViewItem *item; | 309 | QIconViewItem *item; |
309 | AddresseeIconViewItem *aItem; | 310 | AddresseeIconViewItem *aItem; |
310 | 311 | ||
311 | if ( uid.isNull() ) { | 312 | if ( uid.isNull() ) { |
312 | // Rebuild the view | 313 | // Rebuild the view |
313 | mIconView->clear(); | 314 | mIconView->clear(); |
314 | mIconList.clear(); | 315 | mIconList.clear(); |
315 | 316 | ||
316 | KABC::Addressee::List addresseeList = addressees(); | 317 | KABC::Addressee::List addresseeList = addressees(); |
317 | KABC::Addressee::List::Iterator iter; | 318 | KABC::Addressee::List::Iterator iter; |
318 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) | 319 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) |
319 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); | 320 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); |
320 | 321 | ||
321 | mIconView->arrangeItemsInGrid( true ); | 322 | mIconView->arrangeItemsInGrid( true ); |
322 | 323 | ||
323 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) | 324 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) |
324 | { | 325 | { |
325 | #ifndef KAB_EMBEDDED | 326 | #ifndef KAB_EMBEDDED |
326 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); | 327 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); |
327 | #else //KAB_EMBEDDED | 328 | #else //KAB_EMBEDDED |
328 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); | 329 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); |
329 | #endif //KAB_EMBEDDED | 330 | #endif //KAB_EMBEDDED |
330 | mIconList.append( aivi ); | 331 | mIconList.append( aivi ); |
331 | } | 332 | } |
332 | 333 | ||
333 | } else { | 334 | } else { |
334 | // Try to find the one to refresh | 335 | // Try to find the one to refresh |
335 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { | 336 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { |
336 | #ifndef KAB_EMBEDDED | 337 | #ifndef KAB_EMBEDDED |
337 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 338 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
338 | #else //KAB_EMBEDDED | 339 | #else //KAB_EMBEDDED |
339 | aItem = (AddresseeIconViewItem*)(item); | 340 | aItem = (AddresseeIconViewItem*)(item); |
340 | #endif //KAB_EMBEDDED | 341 | #endif //KAB_EMBEDDED |
341 | if ((aItem) && (aItem->addressee().uid() == uid)) { | 342 | if ((aItem) && (aItem->addressee().uid() == uid)) { |
342 | aItem->refresh(); | 343 | aItem->refresh(); |
343 | mIconView->arrangeItemsInGrid( true ); | 344 | mIconView->arrangeItemsInGrid( true ); |
344 | return; | 345 | return; |
345 | } | 346 | } |
346 | } | 347 | } |
347 | refresh( QString::null ); | 348 | refresh( QString::null ); |
348 | } | 349 | } |
349 | } | 350 | } |
350 | 351 | ||
351 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 352 | void KAddressBookIconView::setSelected(QString uid, bool selected) |
352 | { | 353 | { |
353 | QIconViewItem *item; | 354 | QIconViewItem *item; |
354 | AddresseeIconViewItem *aItem; | 355 | AddresseeIconViewItem *aItem; |
355 | 356 | ||
356 | if (uid.isNull()) | 357 | if (uid.isNull()) |
357 | { | 358 | { |
358 | mIconView->selectAll(selected); | 359 | mIconView->selectAll(selected); |
359 | } | 360 | } |
360 | else | 361 | else |
361 | { | 362 | { |
362 | bool found = false; | 363 | bool found = false; |
363 | for (item = mIconView->firstItem(); item && !found; | 364 | for (item = mIconView->firstItem(); item && !found; |
364 | item = item->nextItem()) | 365 | item = item->nextItem()) |
365 | { | 366 | { |
366 | #ifndef KAB_EMBEDDED | 367 | #ifndef KAB_EMBEDDED |
367 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 368 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
368 | #else //KAB_EMBEDDED | 369 | #else //KAB_EMBEDDED |
369 | aItem = (AddresseeIconViewItem*)(item); | 370 | aItem = (AddresseeIconViewItem*)(item); |
370 | #endif //KAB_EMBEDDED | 371 | #endif //KAB_EMBEDDED |
371 | 372 | ||
372 | if ((aItem) && (aItem->addressee().uid() == uid)) | 373 | if ((aItem) && (aItem->addressee().uid() == uid)) |
373 | { | 374 | { |
374 | mIconView->setSelected(aItem, selected); | 375 | mIconView->setSelected(aItem, selected); |
375 | mIconView->ensureItemVisible( aItem ); | 376 | mIconView->ensureItemVisible( aItem ); |
376 | found = true; | 377 | found = true; |
377 | } | 378 | } |
378 | } | 379 | } |
379 | } | 380 | } |
380 | } | 381 | } |
381 | 382 | ||
382 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 383 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) |
383 | { | 384 | { |
384 | #ifndef KAB_EMBEDDED | 385 | #ifndef KAB_EMBEDDED |
385 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 386 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
386 | #else //KAB_EMBEDDED | 387 | #else //KAB_EMBEDDED |
387 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); | 388 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); |
388 | #endif //KAB_EMBEDDED | 389 | #endif //KAB_EMBEDDED |
389 | 390 | ||
390 | if (aItem) { | 391 | if (aItem) { |
391 | emit executed(aItem->addressee().uid()); | 392 | emit executed(aItem->addressee().uid()); |
392 | } | 393 | } |
393 | } | 394 | } |
394 | 395 | ||
395 | void KAddressBookIconView::addresseeSelected() | 396 | void KAddressBookIconView::addresseeSelected() |
396 | { | 397 | { |
397 | QIconViewItem *item; | 398 | QIconViewItem *item; |
398 | AddresseeIconViewItem *aItem; | 399 | AddresseeIconViewItem *aItem; |
399 | 400 | ||
400 | bool found = false; | 401 | bool found = false; |
401 | for (item = mIconView->firstItem(); item && !found; | 402 | for (item = mIconView->firstItem(); item && !found; |
402 | item = item->nextItem()) | 403 | item = item->nextItem()) |
403 | { | 404 | { |
404 | if (item->isSelected()) | 405 | if (item->isSelected()) |
405 | { | 406 | { |
406 | #ifndef KAB_EMBEDDED | 407 | #ifndef KAB_EMBEDDED |
407 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 408 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
408 | #else //KAB_EMBEDDED | 409 | #else //KAB_EMBEDDED |
409 | aItem = (AddresseeIconViewItem*)(item); | 410 | aItem = (AddresseeIconViewItem*)(item); |
410 | #endif //KAB_EMBEDDED | 411 | #endif //KAB_EMBEDDED |
411 | if (aItem) | 412 | if (aItem) |
412 | { | 413 | { |
413 | emit selected(aItem->addressee().uid()); | 414 | emit selected(aItem->addressee().uid()); |
414 | found = true; | 415 | found = true; |
415 | } | 416 | } |
416 | } | 417 | } |
417 | } | 418 | } |
418 | 419 | ||
419 | if (!found) | 420 | if (!found) |
420 | emit selected(QString::null); | 421 | emit selected(QString::null); |
421 | } | 422 | } |
422 | 423 | ||
423 | #ifndef KAB_EMBEDDED | 424 | #ifndef KAB_EMBEDDED |
424 | #include "kaddressbookiconview.moc" | 425 | #include "kaddressbookiconview.moc" |
425 | #endif //KAB_EMBEDDED | 426 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 63ad0ed..1dc9198 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,442 +1,443 @@ | |||
1 | // $Id$ | 1 | // $Id$ |
2 | 2 | ||
3 | #include <qvbox.h> | 3 | #include <qvbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qdragobject.h> | 10 | #include <qdragobject.h> |
11 | #include <qevent.h> | 11 | #include <qevent.h> |
12 | #include <qurl.h> | 12 | #include <qurl.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | 14 | ||
15 | #include <kabc/addressbook.h> | 15 | #include <kabc/addressbook.h> |
16 | #include <kapplication.h> | 16 | #include <kapplication.h> |
17 | #include <kconfig.h> | 17 | #include <kconfig.h> |
18 | #include <kcolorbutton.h> | 18 | #include <kcolorbutton.h> |
19 | #include <kdebug.h> | 19 | #include <kdebug.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <kiconloader.h> | 21 | #include <kiconloader.h> |
22 | #include <klineedit.h> | 22 | #include <klineedit.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <kurl.h> | 25 | #include <kurl.h> |
26 | #include <kurlrequester.h> | 26 | #include <kurlrequester.h> |
27 | 27 | ||
28 | //US#include "configuretableviewdialog.h" | 28 | //US#include "configuretableviewdialog.h" |
29 | #include "contactlistview.h" | 29 | #include "contactlistview.h" |
30 | #include "kabprefs.h" | 30 | #include "kabprefs.h" |
31 | #include "undocmds.h" | 31 | #include "undocmds.h" |
32 | #include "viewmanager.h" | 32 | #include "viewmanager.h" |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qheader.h> | 35 | #include <qheader.h> |
36 | #include <qregexp.h> | ||
36 | 37 | ||
37 | #include "kaddressbooktableview.h" | 38 | #include "kaddressbooktableview.h" |
38 | 39 | ||
39 | 40 | ||
40 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
41 | QWidget *parent, const char *name ) | 42 | QWidget *parent, const char *name ) |
42 | : KAddressBookView( ab, parent, name ) | 43 | : KAddressBookView( ab, parent, name ) |
43 | { | 44 | { |
44 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
45 | 46 | ||
46 | // The list view will be created when the config is read. | 47 | // The list view will be created when the config is read. |
47 | mListView = 0; | 48 | mListView = 0; |
48 | } | 49 | } |
49 | 50 | ||
50 | KAddressBookTableView::~KAddressBookTableView() | 51 | KAddressBookTableView::~KAddressBookTableView() |
51 | { | 52 | { |
52 | } | 53 | } |
53 | 54 | ||
54 | void KAddressBookTableView::reconstructListView() | 55 | void KAddressBookTableView::reconstructListView() |
55 | { | 56 | { |
56 | if (mListView) | 57 | if (mListView) |
57 | { | 58 | { |
58 | disconnect(mListView, SIGNAL(selectionChanged()), | 59 | disconnect(mListView, SIGNAL(selectionChanged()), |
59 | this, SLOT(addresseeSelected())); | 60 | this, SLOT(addresseeSelected())); |
60 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 61 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
61 | this, SLOT(addresseeExecuted(QListViewItem*))); | 62 | this, SLOT(addresseeExecuted(QListViewItem*))); |
62 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 63 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
63 | this, SLOT(addresseeExecuted(QListViewItem*))); | 64 | this, SLOT(addresseeExecuted(QListViewItem*))); |
64 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 65 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
65 | SIGNAL(startDrag())); | 66 | SIGNAL(startDrag())); |
66 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 67 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
67 | this, SLOT(addresseeExecuted(QListViewItem*))); | 68 | this, SLOT(addresseeExecuted(QListViewItem*))); |
68 | 69 | ||
69 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 70 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
70 | SIGNAL(dropped(QDropEvent*))); | 71 | SIGNAL(dropped(QDropEvent*))); |
71 | delete mListView; | 72 | delete mListView; |
72 | } | 73 | } |
73 | 74 | ||
74 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 75 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
75 | 76 | ||
76 | // Add the columns | 77 | // Add the columns |
77 | KABC::Field::List fieldList = fields(); | 78 | KABC::Field::List fieldList = fields(); |
78 | KABC::Field::List::ConstIterator it; | 79 | KABC::Field::List::ConstIterator it; |
79 | 80 | ||
80 | int c = 0; | 81 | int c = 0; |
81 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 82 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
82 | mListView->addColumn( (*it)->label() ); | 83 | mListView->addColumn( (*it)->label() ); |
83 | mListView->setColumnWidthMode(c++, QListView::Manual); | 84 | mListView->setColumnWidthMode(c++, QListView::Manual); |
84 | //US | 85 | //US |
85 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 86 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
86 | } | 87 | } |
87 | 88 | ||
88 | connect(mListView, SIGNAL(selectionChanged()), | 89 | connect(mListView, SIGNAL(selectionChanged()), |
89 | this, SLOT(addresseeSelected())); | 90 | this, SLOT(addresseeSelected())); |
90 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 91 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
91 | SIGNAL(startDrag())); | 92 | SIGNAL(startDrag())); |
92 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 93 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
93 | SIGNAL(dropped(QDropEvent*))); | 94 | SIGNAL(dropped(QDropEvent*))); |
94 | 95 | ||
95 | if (KABPrefs::instance()->mHonorSingleClick) | 96 | if (KABPrefs::instance()->mHonorSingleClick) |
96 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 97 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
97 | this, SLOT(addresseeExecuted(QListViewItem*))); | 98 | this, SLOT(addresseeExecuted(QListViewItem*))); |
98 | else | 99 | else |
99 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 100 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
100 | this, SLOT(addresseeExecuted(QListViewItem*))); | 101 | this, SLOT(addresseeExecuted(QListViewItem*))); |
101 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 102 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
102 | this, SLOT(addresseeExecuted(QListViewItem*))); | 103 | this, SLOT(addresseeExecuted(QListViewItem*))); |
103 | connect(mListView, SIGNAL(signalDelete()), | 104 | connect(mListView, SIGNAL(signalDelete()), |
104 | this, SLOT(addresseeDeleted())); | 105 | this, SLOT(addresseeDeleted())); |
105 | 106 | ||
106 | //US performceimprovement. Refresh is done from the outside | 107 | //US performceimprovement. Refresh is done from the outside |
107 | //US refresh(); | 108 | //US refresh(); |
108 | 109 | ||
109 | mListView->setSorting( 0, true ); | 110 | mListView->setSorting( 0, true ); |
110 | mainLayout->addWidget( mListView ); | 111 | mainLayout->addWidget( mListView ); |
111 | mainLayout->activate(); | 112 | mainLayout->activate(); |
112 | mListView->show(); | 113 | mListView->show(); |
113 | } | 114 | } |
114 | 115 | ||
115 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 116 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
116 | { | 117 | { |
117 | mListView->clear(); | 118 | mListView->clear(); |
118 | if ( s.isEmpty() || s == "*" ) { | 119 | if ( s.isEmpty() || s == "*" ) { |
119 | refresh(); | 120 | refresh(); |
120 | return; | 121 | return; |
121 | } | 122 | } |
122 | QString pattern = s.lower()+"*"; | 123 | QString pattern = s.lower()+"*"; |
123 | QRegExp re; | 124 | QRegExp re; |
124 | re.setWildcard(true); // most people understand these better. | 125 | re.setWildcard(true); // most people understand these better. |
125 | re.setCaseSensitive(false); | 126 | re.setCaseSensitive(false); |
126 | re.setPattern( pattern ); | 127 | re.setPattern( pattern ); |
127 | if (!re.isValid()) | 128 | if (!re.isValid()) |
128 | return; | 129 | return; |
129 | KABC::Addressee::List addresseeList = addressees(); | 130 | KABC::Addressee::List addresseeList = addressees(); |
130 | KABC::Addressee::List::Iterator it; | 131 | KABC::Addressee::List::Iterator it; |
131 | if ( field ) { | 132 | if ( field ) { |
132 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 133 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
133 | #if QT_VERSION >= 300 | 134 | #if QT_VERSION >= 300 |
134 | if (re.search(field->value( *it ).lower()) != -1) | 135 | if (re.search(field->value( *it ).lower()) != -1) |
135 | #else | 136 | #else |
136 | if (re.match(field->value( *it ).lower()) != -1) | 137 | if (re.match(field->value( *it ).lower()) != -1) |
137 | #endif | 138 | #endif |
138 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 139 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
139 | 140 | ||
140 | } | 141 | } |
141 | } else { | 142 | } else { |
142 | KABC::Field::List fieldList = fields(); | 143 | KABC::Field::List fieldList = fields(); |
143 | KABC::Field::List::ConstIterator fieldIt; | 144 | KABC::Field::List::ConstIterator fieldIt; |
144 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 145 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
145 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 146 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
146 | #if QT_VERSION >= 300 | 147 | #if QT_VERSION >= 300 |
147 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 148 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
148 | #else | 149 | #else |
149 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 150 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
150 | #endif | 151 | #endif |
151 | { | 152 | { |
152 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 153 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
153 | break; | 154 | break; |
154 | } | 155 | } |
155 | } | 156 | } |
156 | } | 157 | } |
157 | } | 158 | } |
158 | // Sometimes the background pixmap gets messed up when we add lots | 159 | // Sometimes the background pixmap gets messed up when we add lots |
159 | // of items. | 160 | // of items. |
160 | mListView->repaint(); | 161 | mListView->repaint(); |
161 | emit selected(QString::null); | 162 | emit selected(QString::null); |
162 | 163 | ||
163 | } | 164 | } |
164 | void KAddressBookTableView::writeConfig(KConfig *config) | 165 | void KAddressBookTableView::writeConfig(KConfig *config) |
165 | { | 166 | { |
166 | KAddressBookView::writeConfig(config); | 167 | KAddressBookView::writeConfig(config); |
167 | 168 | ||
168 | mListView->saveLayout(config, config->group()); | 169 | mListView->saveLayout(config, config->group()); |
169 | } | 170 | } |
170 | 171 | ||
171 | void KAddressBookTableView::readConfig(KConfig *config) | 172 | void KAddressBookTableView::readConfig(KConfig *config) |
172 | { | 173 | { |
173 | KAddressBookView::readConfig( config ); | 174 | KAddressBookView::readConfig( config ); |
174 | // The config could have changed the fields, so we need to reconstruct | 175 | // The config could have changed the fields, so we need to reconstruct |
175 | // the listview. | 176 | // the listview. |
176 | reconstructListView(); | 177 | reconstructListView(); |
177 | 178 | ||
178 | // costum colors? | 179 | // costum colors? |
179 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 180 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
180 | { | 181 | { |
181 | QPalette p( mListView->palette() ); | 182 | QPalette p( mListView->palette() ); |
182 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 183 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
183 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 184 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
184 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 185 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
185 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 186 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
186 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 187 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
187 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 188 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
188 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 189 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
189 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 190 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
190 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 191 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
191 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 192 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
192 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 193 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
193 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 194 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
194 | #ifndef KAB_EMBEDDED | 195 | #ifndef KAB_EMBEDDED |
195 | c = KGlobalSettings::alternateBackgroundColor(); | 196 | c = KGlobalSettings::alternateBackgroundColor(); |
196 | #else //KAB_EMBEDDED | 197 | #else //KAB_EMBEDDED |
197 | c = QColor(240, 240, 240); | 198 | c = QColor(240, 240, 240); |
198 | #endif //KAB_EMBEDDED | 199 | #endif //KAB_EMBEDDED |
199 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 200 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
200 | mListView->setAlternateColor(c); | 201 | mListView->setAlternateColor(c); |
201 | 202 | ||
202 | 203 | ||
203 | //US mListView->viewport()->setPalette( p ); | 204 | //US mListView->viewport()->setPalette( p ); |
204 | mListView->setPalette( p ); | 205 | mListView->setPalette( p ); |
205 | } | 206 | } |
206 | else | 207 | else |
207 | { | 208 | { |
208 | // needed if turned off during a session. | 209 | // needed if turned off during a session. |
209 | //US mListView->viewport()->setPalette( mListView->palette() ); | 210 | //US mListView->viewport()->setPalette( mListView->palette() ); |
210 | mListView->setPalette( mListView->palette() ); | 211 | mListView->setPalette( mListView->palette() ); |
211 | } | 212 | } |
212 | 213 | ||
213 | //custom fonts? | 214 | //custom fonts? |
214 | QFont f( font() ); | 215 | QFont f( font() ); |
215 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 216 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
216 | { | 217 | { |
217 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 218 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
218 | f.setBold( true ); | 219 | f.setBold( true ); |
219 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 220 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
220 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 221 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
221 | } | 222 | } |
222 | else | 223 | else |
223 | { | 224 | { |
224 | mListView->setFont( f ); | 225 | mListView->setFont( f ); |
225 | f.setBold( true ); | 226 | f.setBold( true ); |
226 | //US mListView->setHeaderFont( f ); | 227 | //US mListView->setHeaderFont( f ); |
227 | mListView->header()->setFont( f ); | 228 | mListView->header()->setFont( f ); |
228 | } | 229 | } |
229 | 230 | ||
230 | 231 | ||
231 | 232 | ||
232 | 233 | ||
233 | 234 | ||
234 | // Set the list view options | 235 | // Set the list view options |
235 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 236 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
236 | true)); | 237 | true)); |
237 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 238 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
238 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 239 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
239 | 240 | ||
240 | if (config->readBoolEntry("Background", false)) | 241 | if (config->readBoolEntry("Background", false)) |
241 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 242 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
242 | 243 | ||
243 | // Restore the layout of the listview | 244 | // Restore the layout of the listview |
244 | mListView->restoreLayout(config, config->group()); | 245 | mListView->restoreLayout(config, config->group()); |
245 | } | 246 | } |
246 | 247 | ||
247 | void KAddressBookTableView::refresh(QString uid) | 248 | void KAddressBookTableView::refresh(QString uid) |
248 | { | 249 | { |
249 | // For now just repopulate. In reality this method should | 250 | // For now just repopulate. In reality this method should |
250 | // check the value of uid, and if valid iterate through | 251 | // check the value of uid, and if valid iterate through |
251 | // the listview to find the entry, then tell it to refresh. | 252 | // the listview to find the entry, then tell it to refresh. |
252 | 253 | ||
253 | if (uid.isNull()) { | 254 | if (uid.isNull()) { |
254 | // Clear the list view | 255 | // Clear the list view |
255 | QString currentUID, nextUID; | 256 | QString currentUID, nextUID; |
256 | #ifndef KAB_EMBEDDED | 257 | #ifndef KAB_EMBEDDED |
257 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 258 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
258 | #else //KAB_EMBEDDED | 259 | #else //KAB_EMBEDDED |
259 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 260 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
260 | #endif //KAB_EMBEDDED | 261 | #endif //KAB_EMBEDDED |
261 | 262 | ||
262 | if ( currentItem ) { | 263 | if ( currentItem ) { |
263 | #ifndef KAB_EMBEDDED | 264 | #ifndef KAB_EMBEDDED |
264 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 265 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
265 | #else //KAB_EMBEDDED | 266 | #else //KAB_EMBEDDED |
266 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 267 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
267 | #endif //KAB_EMBEDDED | 268 | #endif //KAB_EMBEDDED |
268 | if ( nextItem ) | 269 | if ( nextItem ) |
269 | nextUID = nextItem->addressee().uid(); | 270 | nextUID = nextItem->addressee().uid(); |
270 | currentUID = currentItem->addressee().uid(); | 271 | currentUID = currentItem->addressee().uid(); |
271 | } | 272 | } |
272 | 273 | ||
273 | mListView->clear(); | 274 | mListView->clear(); |
274 | 275 | ||
275 | currentItem = 0; | 276 | currentItem = 0; |
276 | KABC::Addressee::List addresseeList = addressees(); | 277 | KABC::Addressee::List addresseeList = addressees(); |
277 | KABC::Addressee::List::Iterator it; | 278 | KABC::Addressee::List::Iterator it; |
278 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 279 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
279 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 280 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
280 | if ( (*it).uid() == currentUID ) | 281 | if ( (*it).uid() == currentUID ) |
281 | currentItem = item; | 282 | currentItem = item; |
282 | else if ( (*it).uid() == nextUID && !currentItem ) | 283 | else if ( (*it).uid() == nextUID && !currentItem ) |
283 | currentItem = item; | 284 | currentItem = item; |
284 | } | 285 | } |
285 | 286 | ||
286 | // Sometimes the background pixmap gets messed up when we add lots | 287 | // Sometimes the background pixmap gets messed up when we add lots |
287 | // of items. | 288 | // of items. |
288 | mListView->repaint(); | 289 | mListView->repaint(); |
289 | 290 | ||
290 | if ( currentItem ) { | 291 | if ( currentItem ) { |
291 | mListView->setCurrentItem( currentItem ); | 292 | mListView->setCurrentItem( currentItem ); |
292 | mListView->ensureItemVisible( currentItem ); | 293 | mListView->ensureItemVisible( currentItem ); |
293 | } | 294 | } |
294 | } else { | 295 | } else { |
295 | // Only need to update on entry. Iterate through and try to find it | 296 | // Only need to update on entry. Iterate through and try to find it |
296 | ContactListViewItem *ceItem; | 297 | ContactListViewItem *ceItem; |
297 | QListViewItemIterator it( mListView ); | 298 | QListViewItemIterator it( mListView ); |
298 | while ( it.current() ) { | 299 | while ( it.current() ) { |
299 | #ifndef KAB_EMBEDDED | 300 | #ifndef KAB_EMBEDDED |
300 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 301 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
301 | #else //KAB_EMBEDDED | 302 | #else //KAB_EMBEDDED |
302 | ceItem = (ContactListViewItem*)( it.current() ); | 303 | ceItem = (ContactListViewItem*)( it.current() ); |
303 | #endif //KAB_EMBEDDED | 304 | #endif //KAB_EMBEDDED |
304 | 305 | ||
305 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 306 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
306 | ceItem->refresh(); | 307 | ceItem->refresh(); |
307 | return; | 308 | return; |
308 | } | 309 | } |
309 | ++it; | 310 | ++it; |
310 | } | 311 | } |
311 | 312 | ||
312 | refresh( QString::null ); | 313 | refresh( QString::null ); |
313 | } | 314 | } |
314 | } | 315 | } |
315 | 316 | ||
316 | QStringList KAddressBookTableView::selectedUids() | 317 | QStringList KAddressBookTableView::selectedUids() |
317 | { | 318 | { |
318 | QStringList uidList; | 319 | QStringList uidList; |
319 | QListViewItem *item; | 320 | QListViewItem *item; |
320 | ContactListViewItem *ceItem; | 321 | ContactListViewItem *ceItem; |
321 | 322 | ||
322 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 323 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
323 | { | 324 | { |
324 | if (mListView->isSelected( item )) | 325 | if (mListView->isSelected( item )) |
325 | { | 326 | { |
326 | #ifndef KAB_EMBEDDED | 327 | #ifndef KAB_EMBEDDED |
327 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 328 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
328 | #else //KAB_EMBEDDED | 329 | #else //KAB_EMBEDDED |
329 | ceItem = (ContactListViewItem*)(item); | 330 | ceItem = (ContactListViewItem*)(item); |
330 | #endif //KAB_EMBEDDED | 331 | #endif //KAB_EMBEDDED |
331 | 332 | ||
332 | if (ceItem != 0L) | 333 | if (ceItem != 0L) |
333 | uidList << ceItem->addressee().uid(); | 334 | uidList << ceItem->addressee().uid(); |
334 | } | 335 | } |
335 | } | 336 | } |
336 | if ( uidList.count() == 0 ) | 337 | if ( uidList.count() == 0 ) |
337 | if ( mListView->currentItem() ) { | 338 | if ( mListView->currentItem() ) { |
338 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 339 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
339 | uidList << ceItem->addressee().uid(); | 340 | uidList << ceItem->addressee().uid(); |
340 | } | 341 | } |
341 | 342 | ||
342 | return uidList; | 343 | return uidList; |
343 | } | 344 | } |
344 | 345 | ||
345 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 346 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
346 | { | 347 | { |
347 | QListViewItem *item; | 348 | QListViewItem *item; |
348 | ContactListViewItem *ceItem; | 349 | ContactListViewItem *ceItem; |
349 | 350 | ||
350 | if (uid.isNull()) | 351 | if (uid.isNull()) |
351 | { | 352 | { |
352 | mListView->selectAll(selected); | 353 | mListView->selectAll(selected); |
353 | } | 354 | } |
354 | else | 355 | else |
355 | { | 356 | { |
356 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 357 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
357 | { | 358 | { |
358 | #ifndef KAB_EMBEDDED | 359 | #ifndef KAB_EMBEDDED |
359 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 360 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
360 | #else //KAB_EMBEDDED | 361 | #else //KAB_EMBEDDED |
361 | ceItem = (ContactListViewItem*)(item); | 362 | ceItem = (ContactListViewItem*)(item); |
362 | #endif //KAB_EMBEDDED | 363 | #endif //KAB_EMBEDDED |
363 | 364 | ||
364 | 365 | ||
365 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 366 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
366 | { | 367 | { |
367 | mListView->setSelected(item, selected); | 368 | mListView->setSelected(item, selected); |
368 | 369 | ||
369 | if (selected) | 370 | if (selected) |
370 | mListView->ensureItemVisible(item); | 371 | mListView->ensureItemVisible(item); |
371 | } | 372 | } |
372 | } | 373 | } |
373 | } | 374 | } |
374 | } | 375 | } |
375 | 376 | ||
376 | void KAddressBookTableView::addresseeSelected() | 377 | void KAddressBookTableView::addresseeSelected() |
377 | { | 378 | { |
378 | // We need to try to find the first selected item. This might not be the | 379 | // We need to try to find the first selected item. This might not be the |
379 | // last selected item, but when QListView is in multiselection mode, | 380 | // last selected item, but when QListView is in multiselection mode, |
380 | // there is no way to figure out which one was | 381 | // there is no way to figure out which one was |
381 | // selected last. | 382 | // selected last. |
382 | QListViewItem *item; | 383 | QListViewItem *item; |
383 | bool found =false; | 384 | bool found =false; |
384 | for (item = mListView->firstChild(); item && !found; | 385 | for (item = mListView->firstChild(); item && !found; |
385 | item = item->nextSibling()) | 386 | item = item->nextSibling()) |
386 | { | 387 | { |
387 | if (item->isSelected()) | 388 | if (item->isSelected()) |
388 | { | 389 | { |
389 | found = true; | 390 | found = true; |
390 | #ifndef KAB_EMBEDDED | 391 | #ifndef KAB_EMBEDDED |
391 | ContactListViewItem *ceItem | 392 | ContactListViewItem *ceItem |
392 | = dynamic_cast<ContactListViewItem*>(item); | 393 | = dynamic_cast<ContactListViewItem*>(item); |
393 | #else //KAB_EMBEDDED | 394 | #else //KAB_EMBEDDED |
394 | ContactListViewItem *ceItem | 395 | ContactListViewItem *ceItem |
395 | = (ContactListViewItem*)(item); | 396 | = (ContactListViewItem*)(item); |
396 | #endif //KAB_EMBEDDED | 397 | #endif //KAB_EMBEDDED |
397 | 398 | ||
398 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 399 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
399 | } | 400 | } |
400 | } | 401 | } |
401 | 402 | ||
402 | if (!found) | 403 | if (!found) |
403 | emit selected(QString::null); | 404 | emit selected(QString::null); |
404 | } | 405 | } |
405 | 406 | ||
406 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 407 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
407 | { | 408 | { |
408 | if (item) | 409 | if (item) |
409 | { | 410 | { |
410 | #ifndef KAB_EMBEDDED | 411 | #ifndef KAB_EMBEDDED |
411 | ContactListViewItem *ceItem | 412 | ContactListViewItem *ceItem |
412 | = dynamic_cast<ContactListViewItem*>(item); | 413 | = dynamic_cast<ContactListViewItem*>(item); |
413 | #else //KAB_EMBEDDED | 414 | #else //KAB_EMBEDDED |
414 | ContactListViewItem *ceItem | 415 | ContactListViewItem *ceItem |
415 | = (ContactListViewItem*)(item); | 416 | = (ContactListViewItem*)(item); |
416 | #endif //KAB_EMBEDDED | 417 | #endif //KAB_EMBEDDED |
417 | 418 | ||
418 | if (ceItem) | 419 | if (ceItem) |
419 | { | 420 | { |
420 | emit executed(ceItem->addressee().uid()); | 421 | emit executed(ceItem->addressee().uid()); |
421 | } | 422 | } |
422 | } | 423 | } |
423 | else | 424 | else |
424 | { | 425 | { |
425 | emit executed(QString::null); | 426 | emit executed(QString::null); |
426 | } | 427 | } |
427 | } | 428 | } |
428 | 429 | ||
429 | void KAddressBookTableView::addresseeDeleted() | 430 | void KAddressBookTableView::addresseeDeleted() |
430 | { | 431 | { |
431 | 432 | ||
432 | emit deleteRequest(); | 433 | emit deleteRequest(); |
433 | 434 | ||
434 | } | 435 | } |
435 | 436 | ||
436 | 437 | ||
437 | 438 | ||
438 | 439 | ||
439 | 440 | ||
440 | #ifndef KAB_EMBEDDED | 441 | #ifndef KAB_EMBEDDED |
441 | #include "kaddressbooktableview.moc" | 442 | #include "kaddressbooktableview.moc" |
442 | #endif //KAB_EMBEDDED | 443 | #endif //KAB_EMBEDDED |