summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-07 11:56:39 (UTC)
committer zautrix <zautrix>2004-07-07 11:56:39 (UTC)
commit56721aac86c9ae5253abac8962474c8d1a7e648a (patch) (unidiff)
treec12f41eba0d5724ee800cdb92727ffd6d3c1cf6c
parent13d88c91f2916090bd45e23b504d0b665c68126f (diff)
downloadkdepimpi-56721aac86c9ae5253abac8962474c8d1a7e648a.zip
kdepimpi-56721aac86c9ae5253abac8962474c8d1a7e648a.tar.gz
kdepimpi-56721aac86c9ae5253abac8962474c8d1a7e648a.tar.bz2
Changes for compiling on desktop
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile263
-rw-r--r--kabc/kabc.pro4
-rw-r--r--kabc/plugins/dir/dir.pro29
-rw-r--r--kabc/plugins/dir/resourcedir.cpp6
-rw-r--r--kabc/plugins/file/file.pro30
-rw-r--r--kabc/plugins/file/resourcefile.cpp6
-rw-r--r--kaddressbook/kcmconfigs/addresseewidget.cpp1
-rw-r--r--kaddressbook/mainembedded.cpp7
-rw-r--r--kopi-desktop.pro2
-rw-r--r--kopiemail.control2
-rw-r--r--microkde/kdecore/klibloader.cpp17
-rw-r--r--microkde/kdecore/kstandarddirs.cpp3
-rw-r--r--microkde/kdeui/ktoolbar.cpp2
-rw-r--r--microkde/kresources/factory.cpp3
-rw-r--r--microkde/microkde.pro10
15 files changed, 239 insertions, 146 deletions
diff --git a/Makefile b/Makefile
index d770a05..620581b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,118 +1,147 @@
1DISTPATH = $(shell pwd) 1#############################################################################
2DISTDIR = $(shell basename $(DISTPATH)) 2# Makefile for building: kopi-desktop
3 3# Generated by qmake (1.07a) (Qt 3.3.2) on: Wed Jul 7 13:43:59 2004
4SUBDIRS = libical/src/libical libical/src/libicalss qtcompat microkde \ 4# Project: kopi-desktop.pro
5 libkcal libkdepim kabc kabc/converter/opie kabc/formats/binary kabc/plugins/file kabc/plugins/dir \ 5# Template: subdirs
6 kabc/plugins/opie \ 6# Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro
7 korganizer kalarmd kaddressbook kmicromail/libetpan kmicromail/libmailwrapper kmicromail 7#############################################################################
8all: tmake 8
9 for i in $(SUBDIRS); do pushd $$i; \ 9 MAKEFILE =Makefile
10 make -f Makefile$(PLATFORM) || exit 1; popd; \ 10 QMAKE =qmake
11 done 11DEL_FILE = rm -f
12 12CHK_DIR_EXISTS= test -d
13objects: 13MKDIR = mkdir -p
14 for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done 14INSTALL_FILE=
15 for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done 15INSTALL_DIR =
16 mkdir -p libical/lib/$(PLATFORM) 16 SUBTARGETS = \
17 17 sub-libical \
18clean: 18 sub-libkcal \
19 rm -f libical/lib/$(PLATFORM)/*; 19 sub-microkde \
20 for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ 20 sub-libkdepim \
21 rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ 21 sub-kabc \
22 done 22 sub-korganizer \
23install: 23 sub-kaddressbook \
24 cd bin/kdepim; make install 24 sub-kabc-plugins-file \
25 cp db2file/db2file $(QPEDIR)/bin/db2file 25 sub-kabc-plugins-dir
26 cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop 26
27 cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kmicromail.desktop 27first: all
28 cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop 28
29 29all: Makefile $(SUBTARGETS)
30dist: 30
31 @echo Dont forget to do "make install" before "make dist" 31libical/$(MAKEFILE):
32 rm -f *arm.ipk 32 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical"
33 rm -f *~ 33 cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
34 cd ..; tar czf kdepim.src.tar.gz --exclude=obj --exclude=moc kdepim 34sub-libical: libical/$(MAKEFILE) FORCE
35 mkipks kmicrokdelibs.control 35 cd libical && $(MAKE) -f $(MAKEFILE)
36 mkipks korganizer.control 36
37 mkipks kaddressbook.control 37libkcal/$(MAKEFILE):
38 mkipks kopiemail.control 38 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal"
39 mkipks korganizer-alarm.control 39 cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
40 40sub-libkcal: libkcal/$(MAKEFILE) FORCE
41tmake: objects qtcompat/Makefile$(PLATFORM) microkde/Makefile$(PLATFORM) \ 41 cd libkcal && $(MAKE) -f $(MAKEFILE)
42 libkcal/Makefile$(PLATFORM) \ 42
43 libkdepim/Makefile$(PLATFORM) korganizer/Makefile$(PLATFORM) \ 43microkde/$(MAKEFILE):
44 kalarmd/Makefile$(PLATFORM) \ 44 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde"
45 libical/src/libical/Makefile$(PLATFORM) \ 45 cd microkde && $(QMAKE) microkde.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
46 libical/src/libicalss/Makefile$(PLATFORM) \ 46sub-microkde: microkde/$(MAKEFILE) FORCE
47 kabc/Makefile$(PLATFORM) \ 47 cd microkde && $(MAKE) -f $(MAKEFILE)
48 kabc/converter/opie/Makefile$(PLATFORM) \ 48
49 kabc/formats/binary/Makefile$(PLATFORM) \ 49libkdepim/$(MAKEFILE):
50 kabc/plugins/file/Makefile$(PLATFORM) \ 50 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim"
51 kabc/plugins/dir/Makefile$(PLATFORM) \ 51 cd libkdepim && $(QMAKE) libkdepim.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
52 kabc/plugins/ldap/Makefile$(PLATFORM) \ 52sub-libkdepim: libkdepim/$(MAKEFILE) FORCE
53 kabc/plugins/opie/Makefile$(PLATFORM) \ 53 cd libkdepim && $(MAKE) -f $(MAKEFILE)
54 kaddressbook/Makefile$(PLATFORM) \ 54
55 kmicromail/Makefile$(PLATFORM) \ 55kabc/$(MAKEFILE):
56 kmicromail/libetpan/Makefile$(PLATFORM) \ 56 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc"
57 kmicromail/libmailwrapper/Makefile$(PLATFORM) 57 cd kabc && $(QMAKE) kabc.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
58 58sub-kabc: kabc/$(MAKEFILE) FORCE
59 59 cd kabc && $(MAKE) -f $(MAKEFILE)
60 60
61qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro 61korganizer/$(MAKEFILE):
62 cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" qtcompat.pro -o Makefile$(PLATFORM) 62 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer"
63 63 cd korganizer && $(QMAKE) korganizer.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
64microkde/Makefile$(PLATFORM): microkde/microkdeE.pro 64sub-korganizer: korganizer/$(MAKEFILE) FORCE
65 cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" microkdeE.pro -o Makefile$(PLATFORM) 65 cd korganizer && $(MAKE) -f $(MAKEFILE)
66 66
67libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro 67kaddressbook/$(MAKEFILE):
68 cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" libkcalE.pro -o Makefile$(PLATFORM) 68 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook"
69 69 cd kaddressbook && $(QMAKE) kaddressbook.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
70 70sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE
71libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro 71 cd kaddressbook && $(MAKE) -f $(MAKEFILE)
72 cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" libkdepimE.pro -o Makefile$(PLATFORM) 72
73 73kabc/plugins/file/$(MAKEFILE):
74kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro 74 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
75 cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" kalarmdE.pro -o Makefile$(PLATFORM) 75 cd kabc/plugins/file && $(QMAKE) file.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
76 76sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
77korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro 77 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
78 cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" korganizerE.pro -o Makefile$(PLATFORM) 78
79 79kabc/plugins/dir/$(MAKEFILE):
80libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro 80 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir"
81 cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalE.pro -o Makefile$(PLATFORM) 81 cd kabc/plugins/dir && $(QMAKE) dir.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
82 82sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE
83libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro 83 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE)
84 cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalssE.pro -o Makefile$(PLATFORM) 84
85 85Makefile: kopi-desktop.pro /usr/local/qtgcc/mkspecs/default/qmake.conf
86kabc/Makefile$(PLATFORM): kabc/kabcE.pro 86 $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro
87 cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcE.pro -o Makefile$(PLATFORM) 87qmake: qmake_all
88 88 @$(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro
89kabc/converter/opie/Makefile$(PLATFORM): kabc/converter/opie/opieconverterE.pro 89
90 cd kabc/converter/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" opieconverterE.pro -o Makefile$(PLATFORM) 90all: $(SUBTARGETS)
91 91qmake_all: libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE)
92kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro 92 ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
93 cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcformat_binaryE.pro -o Makefile$(PLATFORM) 93 ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
94 94 ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
95kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/kabc_fileE.pro 95 ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
96 cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" kabc_fileE.pro -o Makefile$(PLATFORM) 96 ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
97 97 ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
98kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/kabc_dirE.pro 98 ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
99 cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" kabc_dirE.pro -o Makefile$(PLATFORM) 99 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
100 100 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
101kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/kabc_ldapE.pro 101clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE
102 cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" kabc_ldapE.pro -o Makefile$(PLATFORM) 102 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true
103 103 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true
104kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/kabc_opieE.pro 104 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true
105 cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" kabc_opieE.pro -o Makefile$(PLATFORM) 105 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true
106 106 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true
107 107 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true
108kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro 108 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true
109 cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" kaddressbookE.pro -o Makefile$(PLATFORM) 109 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
110 110 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true
111 111uninstall_subdirs: qmake_all FORCE
112kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro 112 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
113 cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" kmicromailE.pro -o Makefile$(PLATFORM) 113 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
114kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro 114 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
115 cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" libetpanE.pro -o Makefile$(PLATFORM) 115 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
116kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro 116 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
117 cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" libmailwrapperE.pro -o Makefile$(PLATFORM) 117 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
118 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
119 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
120 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
121install_subdirs: qmake_all FORCE
122 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true
123 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true
124 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true
125 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true
126 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true
127 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true
128 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true
129 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
130 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true
131distclean: qmake_all FORCE
132 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
133 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
134 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
135 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
136 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
137 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
138 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
139 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
140 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
141
142install: install_subdirs
143
144uninstall: uninstall_subdirs
145
146FORCE:
118 147
diff --git a/kabc/kabc.pro b/kabc/kabc.pro
index ea4bbb7..4a8d73a 100644
--- a/kabc/kabc.pro
+++ b/kabc/kabc.pro
@@ -1,214 +1,214 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3#release debug 3#release debug
4DESTDIR=../bin 4DESTDIR=../bin
5 5
6TARGET = microkabc 6TARGET = microkabc
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../qtcompat ../microkde/kdeui 10INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../qtcompat ../microkde/kdeui
11 11
12#LIBS += -lmicrokde -lldap 12#LIBS += -lmicrokde -lldap
13LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
14DEFINES += KAB_EMBEDDED DESKTOP_VERSION 14DEFINES += KAB_EMBEDDED DESKTOP_VERSION
15unix : { 15unix : {
16 16
17OBJECTS_DIR = obj/unix 17OBJECTS_DIR = obj/unix
18MOC_DIR = moc/unix 18MOC_DIR = moc/unix
19} 19}
20win32: { 20win32: {
21DEFINES += _WIN32_ 21DEFINES += _WIN32_
22OBJECTS_DIR = obj/win 22OBJECTS_DIR = obj/win
23MOC_DIR = moc/win 23MOC_DIR = moc/win
24} 24}
25INTERFACES = \ 25INTERFACES = \
26 26
27 27
28HEADERS = \ 28HEADERS = \
29 resource.h \ 29 resource.h \
30 stdaddressbook.h \ 30 stdaddressbook.h \
31 agent.h \ 31 agent.h \
32 geo.h \ 32 geo.h \
33 key.h \ 33 key.h \
34 field.h \ 34 field.h \
35 plugin.h \ 35 plugin.h \
36 address.h \ 36 address.h \
37 addresseelist.h \ 37 addresseelist.h \
38formatfactory.h \ 38formatfactory.h \
39 formatplugin.h \ 39 formatplugin.h \
40 phonenumber.h \ 40 phonenumber.h \
41distributionlist.h \ 41distributionlist.h \
42distributionlistdialog.h \ 42distributionlistdialog.h \
43distributionlisteditor.h \ 43distributionlisteditor.h \
44vcardformatplugin.h \ 44vcardformatplugin.h \
45formats/binaryformat.h \
46formats/vcardformatplugin2.h \ 45formats/vcardformatplugin2.h \
47 picture.h \ 46 picture.h \
48 secrecy.h \ 47 secrecy.h \
49 sound.h \ 48 sound.h \
50 addressbook.h \ 49 addressbook.h \
51 timezone.h \ 50 timezone.h \
52 addressee.h \ 51 addressee.h \
53 addresseedialog.h \ 52 addresseedialog.h \
54 vcardconverter.h \ 53 vcardconverter.h \
55 vcard21parser.h \ 54 vcard21parser.h \
56 vcardformatimpl.h \ 55 vcardformatimpl.h \
57 plugins/file/resourcefile.h \ 56 plugins/file/resourcefile.h \
58 plugins/file/resourcefileconfig.h \ 57 plugins/file/resourcefileconfig.h \
59 plugins/dir/resourcedir.h \ 58 plugins/dir/resourcedir.h \
60 plugins/dir/resourcedirconfig.h \ 59 plugins/dir/resourcedirconfig.h \
61 vcardparser/vcardline.h \ 60 vcardparser/vcardline.h \
62 vcardparser/vcard.h \ 61 vcardparser/vcard.h \
63 vcardparser/vcardtool.h \ 62 vcardparser/vcardtool.h \
64 vcardparser/vcardparser.h \ 63 vcardparser/vcardparser.h \
65vcard/include/VCardAdrParam.h \ 64vcard/include/VCardAdrParam.h \
66vcard/include/VCardAdrValue.h \ 65vcard/include/VCardAdrValue.h \
67vcard/include/VCardAgentParam.h \ 66vcard/include/VCardAgentParam.h \
68vcard/include/VCardContentLine.h \ 67vcard/include/VCardContentLine.h \
69vcard/include/VCardDateParam.h \ 68vcard/include/VCardDateParam.h \
70vcard/include/VCardDateValue.h \ 69vcard/include/VCardDateValue.h \
71vcard/include/VCardEmailParam.h \ 70vcard/include/VCardEmailParam.h \
72vcard/include/VCardGeoValue.h \ 71vcard/include/VCardGeoValue.h \
73vcard/include/VCardGroup.h \ 72vcard/include/VCardGroup.h \
74vcard/include/VCardImageParam.h \ 73vcard/include/VCardImageParam.h \
75vcard/include/VCardImageValue.h \ 74vcard/include/VCardImageValue.h \
76vcard/include/VCardLangValue.h \ 75vcard/include/VCardLangValue.h \
77vcard/include/VCardNValue.h \ 76vcard/include/VCardNValue.h \
78vcard/include/VCardParam.h \ 77vcard/include/VCardParam.h \
79vcard/include/VCardPhoneNumberValue.h \ 78vcard/include/VCardPhoneNumberValue.h \
80vcard/include/VCardSourceParam.h \ 79vcard/include/VCardSourceParam.h \
81vcard/include/VCardTelParam.h \ 80vcard/include/VCardTelParam.h \
82vcard/include/VCardTextParam.h \ 81vcard/include/VCardTextParam.h \
83vcard/include/VCardTextNSParam.h \ 82vcard/include/VCardTextNSParam.h \
84vcard/include/VCardTextValue.h \ 83vcard/include/VCardTextValue.h \
85vcard/include/VCardTextBinParam.h \ 84vcard/include/VCardTextBinParam.h \
86vcard/include/VCardURIValue.h \ 85vcard/include/VCardURIValue.h \
87vcard/include/VCardVCard.h \ 86vcard/include/VCardVCard.h \
88vcard/include/VCardEntity.h \ 87vcard/include/VCardEntity.h \
89vcard/include/VCardValue.h \ 88vcard/include/VCardValue.h \
90vcard/include/VCardSoundValue.h \ 89vcard/include/VCardSoundValue.h \
91vcard/include/VCardAgentValue.h \ 90vcard/include/VCardAgentValue.h \
92vcard/include/VCardTelValue.h \ 91vcard/include/VCardTelValue.h \
93vcard/include/VCardTextBinValue.h \ 92vcard/include/VCardTextBinValue.h \
94vcard/include/VCardOrgValue.h \ 93vcard/include/VCardOrgValue.h \
95vcard/include/VCardUTCValue.h \ 94vcard/include/VCardUTCValue.h \
96vcard/include/VCardClassValue.h \ 95vcard/include/VCardClassValue.h \
97vcard/include/VCardFloatValue.h \ 96vcard/include/VCardFloatValue.h \
98vcard/include/VCardTextListValue.h \ 97vcard/include/VCardTextListValue.h \
99vcard/include/generated/AdrParam-generated.h \ 98vcard/include/generated/AdrParam-generated.h \
100vcard/include/generated/AdrValue-generated.h \ 99vcard/include/generated/AdrValue-generated.h \
101vcard/include/generated/AgentParam-generated.h \ 100vcard/include/generated/AgentParam-generated.h \
102vcard/include/generated/ContentLine-generated.h \ 101vcard/include/generated/ContentLine-generated.h \
103vcard/include/generated/DateParam-generated.h \ 102vcard/include/generated/DateParam-generated.h \
104vcard/include/generated/DateValue-generated.h \ 103vcard/include/generated/DateValue-generated.h \
105vcard/include/generated/EmailParam-generated.h \ 104vcard/include/generated/EmailParam-generated.h \
106vcard/include/generated/GeoValue-generated.h \ 105vcard/include/generated/GeoValue-generated.h \
107vcard/include/generated/Group-generated.h \ 106vcard/include/generated/Group-generated.h \
108vcard/include/generated/ImageParam-generated.h \ 107vcard/include/generated/ImageParam-generated.h \
109vcard/include/generated/ImageValue-generated.h \ 108vcard/include/generated/ImageValue-generated.h \
110vcard/include/generated/LangValue-generated.h \ 109vcard/include/generated/LangValue-generated.h \
111vcard/include/generated/NValue-generated.h \ 110vcard/include/generated/NValue-generated.h \
112vcard/include/generated/Param-generated.h \ 111vcard/include/generated/Param-generated.h \
113vcard/include/generated/PhoneNumberValue-generated.h \ 112vcard/include/generated/PhoneNumberValue-generated.h \
114vcard/include/generated/SourceParam-generated.h \ 113vcard/include/generated/SourceParam-generated.h \
115vcard/include/generated/TelParam-generated.h \ 114vcard/include/generated/TelParam-generated.h \
116vcard/include/generated/TextParam-generated.h \ 115vcard/include/generated/TextParam-generated.h \
117vcard/include/generated/TextNSParam-generated.h \ 116vcard/include/generated/TextNSParam-generated.h \
118vcard/include/generated/TextValue-generated.h \ 117vcard/include/generated/TextValue-generated.h \
119vcard/include/generated/TextBinParam-generated.h \ 118vcard/include/generated/TextBinParam-generated.h \
120vcard/include/generated/URIValue-generated.h \ 119vcard/include/generated/URIValue-generated.h \
121vcard/include/generated/VCard-generated.h \ 120vcard/include/generated/VCard-generated.h \
122vcard/include/generated/VCardEntity-generated.h \ 121vcard/include/generated/VCardEntity-generated.h \
123vcard/include/generated/Value-generated.h \ 122vcard/include/generated/Value-generated.h \
124vcard/include/generated/SoundValue-generated.h \ 123vcard/include/generated/SoundValue-generated.h \
125vcard/include/generated/AgentValue-generated.h \ 124vcard/include/generated/AgentValue-generated.h \
126vcard/include/generated/TelValue-generated.h \ 125vcard/include/generated/TelValue-generated.h \
127vcard/include/generated/TextBinValue-generated.h \ 126vcard/include/generated/TextBinValue-generated.h \
128vcard/include/generated/OrgValue-generated.h \ 127vcard/include/generated/OrgValue-generated.h \
129vcard/include/generated/UTCValue-generated.h \ 128vcard/include/generated/UTCValue-generated.h \
130vcard/include/generated/ClassValue-generated.h \ 129vcard/include/generated/ClassValue-generated.h \
131vcard/include/generated/FloatValue-generated.h \ 130vcard/include/generated/FloatValue-generated.h \
132vcard/include/generated/TextListValue-generated.h 131vcard/include/generated/TextListValue-generated.h
133 132
134 133
135# plugins/ldap/resourceldap.h \ 134# plugins/ldap/resourceldap.h \
136# plugins/ldap/resourceldapconfig.h \ 135# plugins/ldap/resourceldapconfig.h \
136#formats/binary/binaryformat.h \
137 137
138 138
139SOURCES = \ 139SOURCES = \
140distributionlist.cpp \ 140distributionlist.cpp \
141distributionlistdialog.cpp \ 141distributionlistdialog.cpp \
142distributionlisteditor.cpp \ 142distributionlisteditor.cpp \
143vcardformatplugin.cpp \ 143vcardformatplugin.cpp \
144formats/binaryformat.cpp \
145formats/vcardformatplugin2.cpp \ 144formats/vcardformatplugin2.cpp \
146formatfactory.cpp \ 145formatfactory.cpp \
147 resource.cpp \ 146 resource.cpp \
148 stdaddressbook.cpp \ 147 stdaddressbook.cpp \
149 plugin.cpp \ 148 plugin.cpp \
150 agent.cpp \ 149 agent.cpp \
151 geo.cpp \ 150 geo.cpp \
152 key.cpp \ 151 key.cpp \
153 field.cpp \ 152 field.cpp \
154 address.cpp \ 153 address.cpp \
155 phonenumber.cpp \ 154 phonenumber.cpp \
156 picture.cpp \ 155 picture.cpp \
157 secrecy.cpp \ 156 secrecy.cpp \
158 sound.cpp \ 157 sound.cpp \
159 addressbook.cpp \ 158 addressbook.cpp \
160 timezone.cpp \ 159 timezone.cpp \
161 addressee.cpp \ 160 addressee.cpp \
162 addresseelist.cpp \ 161 addresseelist.cpp \
163 addresseedialog.cpp \ 162 addresseedialog.cpp \
164 vcardconverter.cpp \ 163 vcardconverter.cpp \
165 vcard21parser.cpp \ 164 vcard21parser.cpp \
166 vcardformatimpl.cpp \ 165 vcardformatimpl.cpp \
167 plugins/file/resourcefile.cpp \ 166 plugins/file/resourcefile.cpp \
168 plugins/file/resourcefileconfig.cpp \ 167 plugins/file/resourcefileconfig.cpp \
169 plugins/dir/resourcedir.cpp \ 168 plugins/dir/resourcedir.cpp \
170 plugins/dir/resourcedirconfig.cpp \ 169 plugins/dir/resourcedirconfig.cpp \
171 vcardparser/vcardline.cpp \ 170 vcardparser/vcardline.cpp \
172 vcardparser/vcard.cpp \ 171 vcardparser/vcard.cpp \
173 vcardparser/vcardtool.cpp \ 172 vcardparser/vcardtool.cpp \
174 vcardparser/vcardparser.cpp \ 173 vcardparser/vcardparser.cpp \
175vcard/AdrParam.cpp \ 174vcard/AdrParam.cpp \
176vcard/AdrValue.cpp \ 175vcard/AdrValue.cpp \
177vcard/AgentParam.cpp \ 176vcard/AgentParam.cpp \
178vcard/ContentLine.cpp \ 177vcard/ContentLine.cpp \
179vcard/DateParam.cpp \ 178vcard/DateParam.cpp \
180vcard/DateValue.cpp \ 179vcard/DateValue.cpp \
181vcard/EmailParam.cpp \ 180vcard/EmailParam.cpp \
182vcard/Entity.cpp \ 181vcard/Entity.cpp \
183vcard/Enum.cpp \ 182vcard/Enum.cpp \
184vcard/GeoValue.cpp \ 183vcard/GeoValue.cpp \
185vcard/ImageParam.cpp \ 184vcard/ImageParam.cpp \
186vcard/ImageValue.cpp \ 185vcard/ImageValue.cpp \
187vcard/LangValue.cpp \ 186vcard/LangValue.cpp \
188vcard/NValue.cpp \ 187vcard/NValue.cpp \
189vcard/Param.cpp \ 188vcard/Param.cpp \
190vcard/PhoneNumberValue.cpp \ 189vcard/PhoneNumberValue.cpp \
191vcard/RToken.cpp \ 190vcard/RToken.cpp \
192vcard/SourceParam.cpp \ 191vcard/SourceParam.cpp \
193vcard/TelParam.cpp \ 192vcard/TelParam.cpp \
194vcard/TextParam.cpp \ 193vcard/TextParam.cpp \
195vcard/TextValue.cpp \ 194vcard/TextValue.cpp \
196vcard/TextBinParam.cpp \ 195vcard/TextBinParam.cpp \
197vcard/URIValue.cpp \ 196vcard/URIValue.cpp \
198vcard/VCardv.cpp \ 197vcard/VCardv.cpp \
199vcard/VCardEntity.cpp \ 198vcard/VCardEntity.cpp \
200vcard/Value.cpp \ 199vcard/Value.cpp \
201vcard/SoundValue.cpp \ 200vcard/SoundValue.cpp \
202vcard/AgentValue.cpp \ 201vcard/AgentValue.cpp \
203vcard/TelValue.cpp \ 202vcard/TelValue.cpp \
204vcard/TextBinValue.cpp \ 203vcard/TextBinValue.cpp \
205vcard/OrgValue.cpp \ 204vcard/OrgValue.cpp \
206vcard/UTCValue.cpp \ 205vcard/UTCValue.cpp \
207vcard/ClassValue.cpp \ 206vcard/ClassValue.cpp \
208vcard/FloatValue.cpp \ 207vcard/FloatValue.cpp \
209vcard/TextListValue.cpp 208vcard/TextListValue.cpp
210 209
211 210
212# plugins/ldap/resourceldap.cpp \ 211# plugins/ldap/resourceldap.cpp \
213# plugins/ldap/resourceldapconfig.cpp \ 212# plugins/ldap/resourceldapconfig.cpp \
214 213
214#formats/binary/binaryformat.cpp \
diff --git a/kabc/plugins/dir/dir.pro b/kabc/plugins/dir/dir.pro
new file mode 100644
index 0000000..3db201f
--- a/dev/null
+++ b/kabc/plugins/dir/dir.pro
@@ -0,0 +1,29 @@
1 TEMPLATE= lib
2CONFIG += qt warn_on release
3#release debug
4
5TARGET = microkabc_dir
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
7DESTDIR = ../../../bin
8#LIBS += -lmicrokde -lmicrokabc
9#LIBS += -L$(QPEDIR)/lib
10
11INTERFACES = \
12
13HEADERS = \
14 resourcedir.h \
15 resourcedirconfig.h
16
17SOURCES = \
18 resourcedir.cpp \
19 resourcedirconfig.cpp
20
21unix : {
22OBJECTS_DIR = obj/unix
23MOC_DIR = moc/unix
24}
25win32: {
26DEFINES += _WIN32_
27OBJECTS_DIR = obj/win
28MOC_DIR = moc/win
29} \ No newline at end of file
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index be19821..6ea2f4b 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -1,358 +1,360 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28 28
29#include <sys/types.h> 29#include <sys/types.h>
30#include <sys/stat.h> 30#include <sys/stat.h>
31#ifndef _WIN32_ 31#ifndef _WIN32_
32#include <unistd.h> 32#include <unistd.h>
33#endif 33#endif
34 34
35#include <qregexp.h> 35#include <qregexp.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qwidget.h> 37#include <qwidget.h>
38 38
39#include <kapplication.h> 39#include <kapplication.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <kdebug.h> 41#include <kdebug.h>
42//US #include <kgenericfactory.h> 42//US #include <kgenericfactory.h>
43#include <kglobal.h> 43#include <kglobal.h>
44#include <klocale.h> 44#include <klocale.h>
45#include <kstandarddirs.h> 45#include <kstandarddirs.h>
46#include <kurlrequester.h> 46#include <kurlrequester.h>
47 47
48#include "addressbook.h" 48#include "addressbook.h"
49 49
50#include "formatfactory.h" 50#include "formatfactory.h"
51 51
52#include "resourcedirconfig.h" 52#include "resourcedirconfig.h"
53#include "stdaddressbook.h" 53#include "stdaddressbook.h"
54 54
55//US 55//US
56#include <qdir.h> 56#include <qdir.h>
57//US #include "../../formats/vcardformatplugin2.h" 57//US #include "../../formats/vcardformatplugin2.h"
58//US #include "../../formats/binaryformat.h" 58//US #include "../../formats/binaryformat.h"
59 59
60#include "resourcedir.h" 60#include "resourcedir.h"
61 61
62using namespace KABC; 62using namespace KABC;
63 63
64extern "C" 64extern "C"
65{ 65{
66//US void *init_kabc_dir() 66//US void *init_kabc_dir()
67 void *init_microkabc_dir() 67 void *init_microkabc_dir()
68 { 68 {
69 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>(); 69 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>();
70 } 70 }
71} 71}
72 72
73 73
74ResourceDir::ResourceDir( const KConfig *config ) 74ResourceDir::ResourceDir( const KConfig *config )
75 : Resource( config ) 75 : Resource( config )
76{ 76{
77 QString path; 77 QString path;
78 78
79 KConfig *cfg = (KConfig *)config; 79 KConfig *cfg = (KConfig *)config;
80 if ( cfg ) { 80 if ( cfg ) {
81//US path = config->readEntry( "FilePath" ); 81//US path = config->readEntry( "FilePath" );
82 path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() ); 82 path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() );
83//US mFormatName = config->readEntry( "FileFormat" ); 83//US mFormatName = config->readEntry( "FileFormat" );
84 mFormatName = cfg->readEntry( "FileFormat", "vcard" ); 84 mFormatName = cfg->readEntry( "FileFormat", "vcard" );
85 } else { 85 } else {
86 path = StdAddressBook::directoryName(); 86 path = StdAddressBook::directoryName();
87 mFormatName = "vcard"; 87 mFormatName = "vcard";
88 } 88 }
89 89
90 90
91 FormatFactory *factory = FormatFactory::self(); 91 FormatFactory *factory = FormatFactory::self();
92 mFormat = factory->format( mFormatName ); 92 mFormat = factory->format( mFormatName );
93 93
94 if ( !mFormat ) { 94 if ( !mFormat ) {
95 mFormatName = "vcard"; 95 mFormatName = "vcard";
96 mFormat = factory->format( mFormatName ); 96 mFormat = factory->format( mFormatName );
97 } 97 }
98 98
99/*US 99/*US
100//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); 100//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1());
101 if (mFormatName == "vcard") 101 if (mFormatName == "vcard")
102 mFormat = new VCardFormatPlugin2(); 102 mFormat = new VCardFormatPlugin2();
103 else if (mFormatName == "binary") 103 else if (mFormatName == "binary")
104 mFormat = new BinaryFormat(); 104 mFormat = new BinaryFormat();
105 else 105 else
106 qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); 106 qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1());
107*/ 107*/
108 108
109/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods 109/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
110 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); 110 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) );
111 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); 111 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) );
112 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); 112 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) );
113*/ 113*/
114 114
115 setPath( path ); 115 setPath( path );
116} 116}
117 117
118ResourceDir::~ResourceDir() 118ResourceDir::~ResourceDir()
119{ 119{
120 delete mFormat; 120 delete mFormat;
121 mFormat = 0; 121 mFormat = 0;
122} 122}
123 123
124void ResourceDir::writeConfig( KConfig *config ) 124void ResourceDir::writeConfig( KConfig *config )
125{ 125{
126 Resource::writeConfig( config ); 126 Resource::writeConfig( config );
127 127
128 config->writeEntry( "FilePath", mPath ); 128 config->writeEntry( "FilePath", mPath );
129 config->writeEntry( "FileFormat", mFormatName ); 129 config->writeEntry( "FileFormat", mFormatName );
130} 130}
131 131
132Ticket *ResourceDir::requestSaveTicket() 132Ticket *ResourceDir::requestSaveTicket()
133{ 133{
134 kdDebug(5700) << "ResourceDir::requestSaveTicket()" << endl; 134 kdDebug(5700) << "ResourceDir::requestSaveTicket()" << endl;
135 135
136 if ( !addressBook() ) return 0; 136 if ( !addressBook() ) return 0;
137 137
138 if ( !lock( mPath ) ) { 138 if ( !lock( mPath ) ) {
139 kdDebug(5700) << "ResourceDir::requestSaveTicket(): Unable to lock path '" 139 kdDebug(5700) << "ResourceDir::requestSaveTicket(): Unable to lock path '"
140 << mPath << "'" << endl; 140 << mPath << "'" << endl;
141 return 0; 141 return 0;
142 } 142 }
143 return createTicket( this ); 143 return createTicket( this );
144} 144}
145 145
146 146
147bool ResourceDir::doOpen() 147bool ResourceDir::doOpen()
148{ 148{
149 QDir dir( mPath ); 149 QDir dir( mPath );
150 if ( !dir.exists() ) { // no directory available 150 if ( !dir.exists() ) { // no directory available
151 return dir.mkdir( dir.path() ); 151 return dir.mkdir( dir.path() );
152 } else { 152 } else {
153 QString testName = dir.entryList( QDir::Files )[0]; 153 QString testName = dir.entryList( QDir::Files )[0];
154 if ( testName.isNull() || testName.isEmpty() ) // no file in directory 154 if ( testName.isNull() || testName.isEmpty() ) // no file in directory
155 return true; 155 return true;
156 156
157 QFile file( mPath + "/" + testName ); 157 QFile file( mPath + "/" + testName );
158 if ( file.open( IO_ReadOnly ) ) 158 if ( file.open( IO_ReadOnly ) )
159 return true; 159 return true;
160 160
161 if ( file.size() == 0 ) 161 if ( file.size() == 0 )
162 return true; 162 return true;
163 163
164 bool ok = mFormat->checkFormat( &file ); 164 bool ok = mFormat->checkFormat( &file );
165 file.close(); 165 file.close();
166 return ok; 166 return ok;
167 } 167 }
168} 168}
169 169
170void ResourceDir::doClose() 170void ResourceDir::doClose()
171{ 171{
172} 172}
173 173
174bool ResourceDir::load() 174bool ResourceDir::load()
175{ 175{
176 kdDebug(5700) << "ResourceDir::load(): '" << mPath << "'" << endl; 176 kdDebug(5700) << "ResourceDir::load(): '" << mPath << "'" << endl;
177 177
178 QDir dir( mPath ); 178 QDir dir( mPath );
179 QStringList files = dir.entryList( QDir::Files ); 179 QStringList files = dir.entryList( QDir::Files );
180 180
181 QStringList::Iterator it; 181 QStringList::Iterator it;
182 bool ok = true; 182 bool ok = true;
183 for ( it = files.begin(); it != files.end(); ++it ) { 183 for ( it = files.begin(); it != files.end(); ++it ) {
184 QFile file( mPath + "/" + (*it) ); 184 QFile file( mPath + "/" + (*it) );
185 185
186 if ( !file.open( IO_ReadOnly ) ) { 186 if ( !file.open( IO_ReadOnly ) ) {
187 addressBook()->error( i18n( "Unable to open file '%1' for reading" ).arg( file.name() ) ); 187 addressBook()->error( i18n( "Unable to open file '%1' for reading" ).arg( file.name() ) );
188 ok = false; 188 ok = false;
189 continue; 189 continue;
190 } 190 }
191 191
192 if ( !mFormat->loadAll( addressBook(), this, &file ) ) 192 if ( !mFormat->loadAll( addressBook(), this, &file ) )
193 ok = false; 193 ok = false;
194 194
195 file.close(); 195 file.close();
196 } 196 }
197 197
198 return ok; 198 return ok;
199} 199}
200 200
201bool ResourceDir::save( Ticket *ticket ) 201bool ResourceDir::save( Ticket *ticket )
202{ 202{
203 kdDebug(5700) << "ResourceDir::save(): '" << mPath << "'" << endl; 203 kdDebug(5700) << "ResourceDir::save(): '" << mPath << "'" << endl;
204 204
205 AddressBook::Iterator it; 205 AddressBook::Iterator it;
206 bool ok = true; 206 bool ok = true;
207 207
208 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 208 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
209 if ( (*it).resource() != this || !(*it).changed() ) 209 if ( (*it).resource() != this || !(*it).changed() )
210 continue; 210 continue;
211 211
212 QFile file( mPath + "/" + (*it).uid() ); 212 QFile file( mPath + "/" + (*it).uid() );
213 if ( !file.open( IO_WriteOnly ) ) { 213 if ( !file.open( IO_WriteOnly ) ) {
214 addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) ); 214 addressBook()->error( i18n( "Unable to open file '%1' for writing" ).arg( file.name() ) );
215 continue; 215 continue;
216 } 216 }
217 217
218 mFormat->save( *it, &file ); 218 mFormat->save( *it, &file );
219 219
220 // mark as unchanged 220 // mark as unchanged
221 (*it).setChanged( false ); 221 (*it).setChanged( false );
222 222
223 file.close(); 223 file.close();
224 } 224 }
225 225
226 delete ticket; 226 delete ticket;
227 unlock( mPath ); 227 unlock( mPath );
228 228
229 return ok; 229 return ok;
230} 230}
231 231
232bool ResourceDir::lock( const QString &path ) 232bool ResourceDir::lock( const QString &path )
233{ 233{
234 kdDebug(5700) << "ResourceDir::lock()" << endl; 234 kdDebug(5700) << "ResourceDir::lock()" << endl;
235 235
236 QString p = path; 236 QString p = path;
237//US change the implementation how the lockfilename is getting created 237//US change the implementation how the lockfilename is getting created
238//US p.replace( QRegExp("/"), "_" ); 238//US p.replace( QRegExp("/"), "_" );
239//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); 239//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" );
240 KURL url(p); 240 KURL url(p);
241 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 241 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
242 242
243 243
244 kdDebug(5700) << "-- lock name: " << lockName << endl; 244 kdDebug(5700) << "-- lock name: " << lockName << endl;
245 245
246 if ( QFile::exists( lockName ) ) return false; 246 if ( QFile::exists( lockName ) ) return false;
247 247
248 QString lockUniqueName; 248 QString lockUniqueName;
249 lockUniqueName = p + KApplication::randomString( 8 ); 249 lockUniqueName = p + KApplication::randomString( 8 );
250 250
251 url = lockUniqueName; 251 url = lockUniqueName;
252//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 252//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
253 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 253 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
254 254
255 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 255 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
256 256
257 // Create unique file 257 // Create unique file
258 QFile file( mLockUniqueName ); 258 QFile file( mLockUniqueName );
259 file.open( IO_WriteOnly ); 259 file.open( IO_WriteOnly );
260 file.close(); 260 file.close();
261 261
262 // Create lock file 262 // Create lock file
263 int result = ::link( QFile::encodeName( mLockUniqueName ), 263 int result = 0;
264#ifndef _WIN32_
265 result = ::link( QFile::encodeName( mLockUniqueName ),
264 QFile::encodeName( lockName ) ); 266 QFile::encodeName( lockName ) );
265 267#endif
266 if ( result == 0 ) { 268 if ( result == 0 ) {
267 addressBook()->emitAddressBookLocked(); 269 addressBook()->emitAddressBookLocked();
268 return true; 270 return true;
269 } 271 }
270 272
271 // TODO: check stat 273 // TODO: check stat
272 274
273 return false; 275 return false;
274} 276}
275 277
276void ResourceDir::unlock( const QString &path ) 278void ResourceDir::unlock( const QString &path )
277{ 279{
278 QString p = path; 280 QString p = path;
279//US change the implementation how the lockfilename is getting created 281//US change the implementation how the lockfilename is getting created
280//US p.replace( QRegExp( "/" ), "_" ); 282//US p.replace( QRegExp( "/" ), "_" );
281//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); 283//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" );
282 KURL url(p); 284 KURL url(p);
283 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); 285 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" );
284 286
285 ::unlink( QFile::encodeName( lockName ) ); 287 ::unlink( QFile::encodeName( lockName ) );
286 QFile::remove( mLockUniqueName ); 288 QFile::remove( mLockUniqueName );
287 addressBook()->emitAddressBookUnlocked(); 289 addressBook()->emitAddressBookUnlocked();
288} 290}
289 291
290void ResourceDir::setPath( const QString &path ) 292void ResourceDir::setPath( const QString &path )
291{ 293{
292/*US ToDo: no synchronization so far. Has to be changed in the future 294/*US ToDo: no synchronization so far. Has to be changed in the future
293 mDirWatch.stopScan(); 295 mDirWatch.stopScan();
294 mDirWatch.removeDir( mPath ); 296 mDirWatch.removeDir( mPath );
295*/ 297*/
296 mPath = path; 298 mPath = path;
297 299
298/*US ToDo: no synchronization so far. Has to be changed in the future 300/*US ToDo: no synchronization so far. Has to be changed in the future
299 mDirWatch.addDir( mPath, true ); 301 mDirWatch.addDir( mPath, true );
300 mDirWatch.startScan(); 302 mDirWatch.startScan();
301*/ 303*/
302 304
303//US simulate KDirWatch event 305//US simulate KDirWatch event
304 pathChanged(); 306 pathChanged();
305 307
306} 308}
307 309
308QString ResourceDir::path() const 310QString ResourceDir::path() const
309{ 311{
310 return mPath; 312 return mPath;
311} 313}
312 314
313void ResourceDir::setFormat( const QString &format ) 315void ResourceDir::setFormat( const QString &format )
314{ 316{
315 mFormatName = format; 317 mFormatName = format;
316 318
317 if ( mFormat ) 319 if ( mFormat )
318 delete mFormat; 320 delete mFormat;
319 321
320 FormatFactory *factory = FormatFactory::self(); 322 FormatFactory *factory = FormatFactory::self();
321 mFormat = factory->format( mFormatName ); 323 mFormat = factory->format( mFormatName );
322/*US 324/*US
323qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1()); 325qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1());
324 if (mFormatName == "vcard") 326 if (mFormatName == "vcard")
325 mFormat = new VCardFormatPlugin2(); 327 mFormat = new VCardFormatPlugin2();
326 else if (mFormatName == "binary") 328 else if (mFormatName == "binary")
327 mFormat = new BinaryFormat(); 329 mFormat = new BinaryFormat();
328 else 330 else
329 qDebug("ResourceDir::setFormat format unknown !!! %s ", format.latin1()); 331 qDebug("ResourceDir::setFormat format unknown !!! %s ", format.latin1());
330*/ 332*/
331 333
332} 334}
333 335
334QString ResourceDir::format() const 336QString ResourceDir::format() const
335{ 337{
336 return mFormatName; 338 return mFormatName;
337} 339}
338 340
339void ResourceDir::pathChanged() 341void ResourceDir::pathChanged()
340{ 342{
341 if ( !addressBook() ) 343 if ( !addressBook() )
342 return; 344 return;
343 345
344 load(); 346 load();
345 addressBook()->emitAddressBookChanged(); 347 addressBook()->emitAddressBookChanged();
346} 348}
347 349
348void ResourceDir::removeAddressee( const Addressee& addr ) 350void ResourceDir::removeAddressee( const Addressee& addr )
349{ 351{
350 QFile::remove( mPath + "/" + addr.uid() ); 352 QFile::remove( mPath + "/" + addr.uid() );
351} 353}
352 354
353void ResourceDir::cleanUp() 355void ResourceDir::cleanUp()
354{ 356{
355 unlock( mPath ); 357 unlock( mPath );
356} 358}
357 359
358//US #include "resourcedir.moc" 360//US #include "resourcedir.moc"
diff --git a/kabc/plugins/file/file.pro b/kabc/plugins/file/file.pro
new file mode 100644
index 0000000..a5ade93
--- a/dev/null
+++ b/kabc/plugins/file/file.pro
@@ -0,0 +1,30 @@
1 TEMPLATE= lib
2CONFIG += qt warn_on release
3#release debug
4
5TARGET = microkabc_file
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
7
8DESTDIR = ../../../bin
9#LIBS += -lmicrokde -lmicrokabc
10#LIBS += -L$(QPEDIR)/lib
11
12INTERFACES = \
13
14HEADERS = \
15 resourcefile.h \
16 resourcefileconfig.h
17
18SOURCES = \
19 resourcefile.cpp \
20 resourcefileconfig.cpp
21
22unix : {
23OBJECTS_DIR = obj/unix
24MOC_DIR = moc/unix
25}
26win32: {
27DEFINES += _WIN32_
28OBJECTS_DIR = obj/win
29MOC_DIR = moc/win
30} \ No newline at end of file
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 3920f69..4b4c935 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -1,389 +1,391 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <sys/types.h> 28#include <sys/types.h>
29#include <sys/stat.h> 29#include <sys/stat.h>
30#ifndef _WIN32_ 30#ifndef _WIN32_
31#include <unistd.h> 31#include <unistd.h>
32#endif 32#endif
33 33
34#include <qfile.h> 34#include <qfile.h>
35#include <qfileinfo.h> 35#include <qfileinfo.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qtimer.h> 37#include <qtimer.h>
38 38
39#include <kapplication.h> 39#include <kapplication.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <klocale.h> 42#include <klocale.h>
43//US #include <ksavefile.h> 43//US #include <ksavefile.h>
44#include <kstandarddirs.h> 44#include <kstandarddirs.h>
45 45
46#include "formatfactory.h" 46#include "formatfactory.h"
47 47
48#include "resource.h" 48#include "resource.h"
49#include "resourcefileconfig.h" 49#include "resourcefileconfig.h"
50#include "stdaddressbook.h" 50#include "stdaddressbook.h"
51 51
52//US #include "../../formats/vcardformatplugin2.h" 52//US #include "../../formats/vcardformatplugin2.h"
53//US #include "../../formats/binaryformat.h" 53//US #include "../../formats/binaryformat.h"
54 54
55 55
56#include "resourcefile.h" 56#include "resourcefile.h"
57 57
58using namespace KABC; 58using namespace KABC;
59 59
60extern "C" 60extern "C"
61{ 61{
62//US void *init_kabc_file() 62//US void *init_kabc_file()
63 void *init_microkabc_file() 63 void *init_microkabc_file()
64 { 64 {
65 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); 65 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>();
66 } 66 }
67} 67}
68 68
69 69
70ResourceFile::ResourceFile( const KConfig *config ) 70ResourceFile::ResourceFile( const KConfig *config )
71 : Resource( config ) , mFormat( 0 ) 71 : Resource( config ) , mFormat( 0 )
72{ 72{
73 QString fileName, formatName; 73 QString fileName, formatName;
74 74
75 KConfig *cfg = (KConfig *)config; 75 KConfig *cfg = (KConfig *)config;
76 if ( cfg ) { 76 if ( cfg ) {
77 fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); 77 fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() );
78 formatName = cfg->readEntry( "FileFormat", "vcard" ); 78 formatName = cfg->readEntry( "FileFormat", "vcard" );
79// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() ); 79// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() );
80 } else { 80 } else {
81 fileName = StdAddressBook::fileName(); 81 fileName = StdAddressBook::fileName();
82 formatName = "vcard"; 82 formatName = "vcard";
83// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() ); 83// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() );
84 } 84 }
85 85
86 init( fileName, formatName ); 86 init( fileName, formatName );
87} 87}
88 88
89ResourceFile::ResourceFile( const QString &fileName, 89ResourceFile::ResourceFile( const QString &fileName,
90 const QString &formatName ) 90 const QString &formatName )
91 : Resource( 0 ) 91 : Resource( 0 )
92{ 92{
93// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); 93// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
94 init( fileName, formatName ); 94 init( fileName, formatName );
95} 95}
96 96
97void ResourceFile::init( const QString &fileName, const QString &formatName ) 97void ResourceFile::init( const QString &fileName, const QString &formatName )
98{ 98{
99 mFormatName = formatName; 99 mFormatName = formatName;
100 100
101 FormatFactory *factory = FormatFactory::self(); 101 FormatFactory *factory = FormatFactory::self();
102 mFormat = factory->format( mFormatName ); 102 mFormat = factory->format( mFormatName );
103 103
104 if ( !mFormat ) { 104 if ( !mFormat ) {
105 mFormatName = "vcard"; 105 mFormatName = "vcard";
106 mFormat = factory->format( mFormatName ); 106 mFormat = factory->format( mFormatName );
107 } 107 }
108 108
109/*US 109/*US
110//US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1()); 110//US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1());
111 if (mFormatName == "vcard") { 111 if (mFormatName == "vcard") {
112 mFormat = new VCardFormatPlugin2(); 112 mFormat = new VCardFormatPlugin2();
113// qDebug("ResourceFile::init format VCardFormatPlugin2"); 113// qDebug("ResourceFile::init format VCardFormatPlugin2");
114 } 114 }
115 else if (mFormatName == "binary") { 115 else if (mFormatName == "binary") {
116 mFormat = new BinaryFormat(); 116 mFormat = new BinaryFormat();
117// qDebug("ResourceFile::init format BinaryFormat"); 117// qDebug("ResourceFile::init format BinaryFormat");
118 } 118 }
119 else 119 else
120 qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1()); 120 qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1());
121*/ 121*/
122 122
123/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods 123/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
124 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 124 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
125 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 125 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
126 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 126 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
127*/ 127*/
128 128
129 setFileName( fileName ); 129 setFileName( fileName );
130} 130}
131 131
132ResourceFile::~ResourceFile() 132ResourceFile::~ResourceFile()
133{ 133{
134 delete mFormat; 134 delete mFormat;
135 mFormat = 0; 135 mFormat = 0;
136} 136}
137 137
138void ResourceFile::writeConfig( KConfig *config ) 138void ResourceFile::writeConfig( KConfig *config )
139{ 139{
140 Resource::writeConfig( config ); 140 Resource::writeConfig( config );
141 141
142 config->writeEntry( "FileName", mFileName ); 142 config->writeEntry( "FileName", mFileName );
143 config->writeEntry( "FileFormat", mFormatName ); 143 config->writeEntry( "FileFormat", mFormatName );
144 144
145// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); 145// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
146 146
147} 147}
148 148
149Ticket *ResourceFile::requestSaveTicket() 149Ticket *ResourceFile::requestSaveTicket()
150{ 150{
151 kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; 151 kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl;
152 152
153 if ( !addressBook() ) return 0; 153 if ( !addressBook() ) return 0;
154 154
155 if ( !lock( mFileName ) ) { 155 if ( !lock( mFileName ) ) {
156 kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" 156 kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '"
157 << mFileName << "'" << endl; 157 << mFileName << "'" << endl;
158 return 0; 158 return 0;
159 } 159 }
160 return createTicket( this ); 160 return createTicket( this );
161} 161}
162 162
163 163
164bool ResourceFile::doOpen() 164bool ResourceFile::doOpen()
165{ 165{
166 QFile file( mFileName ); 166 QFile file( mFileName );
167 167
168 if ( !file.exists() ) { 168 if ( !file.exists() ) {
169 // try to create the file 169 // try to create the file
170 bool ok = file.open( IO_WriteOnly ); 170 bool ok = file.open( IO_WriteOnly );
171 if ( ok ) 171 if ( ok )
172 file.close(); 172 file.close();
173 173
174 return ok; 174 return ok;
175 } else { 175 } else {
176 if ( !file.open( IO_ReadWrite ) ) 176 if ( !file.open( IO_ReadWrite ) )
177 return false; 177 return false;
178 178
179 if ( file.size() == 0 ) { 179 if ( file.size() == 0 ) {
180 file.close(); 180 file.close();
181 return true; 181 return true;
182 } 182 }
183 183
184 bool ok = mFormat->checkFormat( &file ); 184 bool ok = mFormat->checkFormat( &file );
185 file.close(); 185 file.close();
186 186
187 return ok; 187 return ok;
188 } 188 }
189} 189}
190 190
191void ResourceFile::doClose() 191void ResourceFile::doClose()
192{ 192{
193} 193}
194 194
195bool ResourceFile::load() 195bool ResourceFile::load()
196{ 196{
197 197
198 198
199 QFile file( mFileName ); 199 QFile file( mFileName );
200 if ( !file.open( IO_ReadOnly ) ) { 200 if ( !file.open( IO_ReadOnly ) ) {
201 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); 201 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) );
202 return false; 202 return false;
203 } 203 }
204 204
205// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); 205// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
206 206
207 return mFormat->loadAll( addressBook(), this, &file ); 207 return mFormat->loadAll( addressBook(), this, &file );
208} 208}
209 209
210bool ResourceFile::save( Ticket *ticket ) 210bool ResourceFile::save( Ticket *ticket )
211{ 211{
212// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); 212// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
213 213
214 214
215 // create backup file 215 // create backup file
216 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 216 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
217 217
218/*US we use a simpler method to create a backupfile 218/*US we use a simpler method to create a backupfile
219 219
220 (void) KSaveFile::backupFile( mFileName, QString::null 220 (void) KSaveFile::backupFile( mFileName, QString::null
221 ,extension ); 221 ,extension );
222 222
223 KSaveFile saveFile( mFileName ); 223 KSaveFile saveFile( mFileName );
224 bool ok = false; 224 bool ok = false;
225 if ( saveFile.status() == 0 && saveFile.file() ) 225 if ( saveFile.status() == 0 && saveFile.file() )
226 { 226 {
227 mFormat->saveAll( addressBook(), this, saveFile.file() ); 227 mFormat->saveAll( addressBook(), this, saveFile.file() );
228 ok = saveFile.close(); 228 ok = saveFile.close();
229 } 229 }
230*/ 230*/
231 231
232//US ToDo: write backupfile 232//US ToDo: write backupfile
233 QFile info; 233 QFile info;
234 info.setName( mFileName ); 234 info.setName( mFileName );
235 bool ok = info.open( IO_WriteOnly ); 235 bool ok = info.open( IO_WriteOnly );
236 if ( ok ) { 236 if ( ok ) {
237 mFormat->saveAll( addressBook(), this, &info ); 237 mFormat->saveAll( addressBook(), this, &info );
238 238
239 info.close(); 239 info.close();
240 ok = true; 240 ok = true;
241 } 241 }
242 else { 242 else {
243 243
244 } 244 }
245 245
246 if ( !ok ) 246 if ( !ok )
247 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 247 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
248 248
249 delete ticket; 249 delete ticket;
250 unlock( mFileName ); 250 unlock( mFileName );
251 251
252 return ok; 252 return ok;
253 253
254 qDebug("ResourceFile::save has to be changed"); 254 qDebug("ResourceFile::save has to be changed");
255 return true; 255 return true;
256} 256}
257 257
258bool ResourceFile::lock( const QString &fileName ) 258bool ResourceFile::lock( const QString &fileName )
259{ 259{
260 260
261 261
262 QString fn = fileName; 262 QString fn = fileName;
263 263
264//US change the implementation how the lockfilename is getting created 264//US change the implementation how the lockfilename is getting created
265//US fn.replace( QRegExp("/"), "_" ); 265//US fn.replace( QRegExp("/"), "_" );
266//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 266//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
267 267
268 KURL url(fn); 268 KURL url(fn);
269 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 269 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
270 270
271 271
272 272
273 if (QFile::exists( lockName )) return false; 273 if (QFile::exists( lockName )) return false;
274 274
275 QString lockUniqueName; 275 QString lockUniqueName;
276 lockUniqueName = fn + KApplication::randomString( 8 ); 276 lockUniqueName = fn + KApplication::randomString( 8 );
277 277
278 url = lockUniqueName; 278 url = lockUniqueName;
279//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 279//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
280 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 280 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
281 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 281 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
282 282
283 // Create unique file 283 // Create unique file
284 QFile file( mLockUniqueName ); 284 QFile file( mLockUniqueName );
285 file.open( IO_WriteOnly ); 285 file.open( IO_WriteOnly );
286 file.close(); 286 file.close();
287 287
288 // Create lock file 288 // Create lock file
289 int result = ::link( QFile::encodeName( mLockUniqueName ), 289 int result = 0;
290#ifndef _WIN32_
291 result = ::link( QFile::encodeName( mLockUniqueName ),
290 QFile::encodeName( lockName ) ); 292 QFile::encodeName( lockName ) );
291 293#endif
292 if ( result == 0 ) { 294 if ( result == 0 ) {
293 addressBook()->emitAddressBookLocked(); 295 addressBook()->emitAddressBookLocked();
294 return true; 296 return true;
295 } 297 }
296 298
297 // TODO: check stat 299 // TODO: check stat
298 300
299 return false; 301 return false;
300} 302}
301 303
302void ResourceFile::unlock( const QString &fileName ) 304void ResourceFile::unlock( const QString &fileName )
303{ 305{
304 QString fn = fileName; 306 QString fn = fileName;
305//US change the implementation how the lockfilename is getting created 307//US change the implementation how the lockfilename is getting created
306//US fn.replace( QRegExp( "/" ), "_" ); 308//US fn.replace( QRegExp( "/" ), "_" );
307//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 309//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
308//US QString lockName = fn + ".lock"; 310//US QString lockName = fn + ".lock";
309 KURL url(fn); 311 KURL url(fn);
310 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 312 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
311 313
312 QFile::remove( lockName ); 314 QFile::remove( lockName );
313 QFile::remove( mLockUniqueName ); 315 QFile::remove( mLockUniqueName );
314 addressBook()->emitAddressBookUnlocked(); 316 addressBook()->emitAddressBookUnlocked();
315} 317}
316 318
317void ResourceFile::setFileName( const QString &fileName ) 319void ResourceFile::setFileName( const QString &fileName )
318{ 320{
319/*US ToDo: no synchronization so far. Has to be changed in the future 321/*US ToDo: no synchronization so far. Has to be changed in the future
320 mDirWatch.stopScan(); 322 mDirWatch.stopScan();
321 mDirWatch.removeFile( mFileName ); 323 mDirWatch.removeFile( mFileName );
322*/ 324*/
323 mFileName = fileName; 325 mFileName = fileName;
324 326
325 327
326/*US ToDo: no synchronization so far. Has to be changed in the future 328/*US ToDo: no synchronization so far. Has to be changed in the future
327 mDirWatch.addFile( mFileName ); 329 mDirWatch.addFile( mFileName );
328 mDirWatch.startScan(); 330 mDirWatch.startScan();
329*/ 331*/
330//US simulate KDirWatch event 332//US simulate KDirWatch event
331 fileChanged(); 333 fileChanged();
332} 334}
333 335
334QString ResourceFile::fileName() const 336QString ResourceFile::fileName() const
335{ 337{
336 return mFileName; 338 return mFileName;
337} 339}
338 340
339void ResourceFile::setFormat( const QString &format ) 341void ResourceFile::setFormat( const QString &format )
340{ 342{
341 mFormatName = format; 343 mFormatName = format;
342 delete mFormat; 344 delete mFormat;
343 345
344 FormatFactory *factory = FormatFactory::self(); 346 FormatFactory *factory = FormatFactory::self();
345 mFormat = factory->format( mFormatName ); 347 mFormat = factory->format( mFormatName );
346/*US 348/*US
347//qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1()); 349//qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1());
348 if (mFormatName == "vcard") { 350 if (mFormatName == "vcard") {
349 mFormat = new VCardFormatPlugin2(); 351 mFormat = new VCardFormatPlugin2();
350// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); 352// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1());
351 } 353 }
352 else if (mFormatName == "binary") { 354 else if (mFormatName == "binary") {
353 mFormat = new BinaryFormat(); 355 mFormat = new BinaryFormat();
354// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); 356// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1());
355 } 357 }
356 else 358 else
357 qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1()); 359 qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1());
358*/ 360*/
359 361
360} 362}
361 363
362QString ResourceFile::format() const 364QString ResourceFile::format() const
363{ 365{
364 return mFormatName; 366 return mFormatName;
365} 367}
366 368
367void ResourceFile::fileChanged() 369void ResourceFile::fileChanged()
368{ 370{
369 // There is a small theoretical chance that KDirWatch calls us before 371 // There is a small theoretical chance that KDirWatch calls us before
370 // we are fully constructed 372 // we are fully constructed
371 if (!addressBook()) 373 if (!addressBook())
372 return; 374 return;
373 load(); 375 load();
374 addressBook()->emitAddressBookChanged(); 376 addressBook()->emitAddressBookChanged();
375} 377}
376 378
377void ResourceFile::removeAddressee( const Addressee &addr ) 379void ResourceFile::removeAddressee( const Addressee &addr )
378{ 380{
379 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) ); 381 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) );
380 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) ); 382 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) );
381 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) ); 383 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) );
382} 384}
383 385
384void ResourceFile::cleanUp() 386void ResourceFile::cleanUp()
385{ 387{
386 unlock( mFileName ); 388 unlock( mFileName );
387} 389}
388 390
389//US #include "resourcefile.moc" 391//US #include "resourcefile.moc"
diff --git a/kaddressbook/kcmconfigs/addresseewidget.cpp b/kaddressbook/kcmconfigs/addresseewidget.cpp
index f84b2ba..eb5bdd9 100644
--- a/kaddressbook/kcmconfigs/addresseewidget.cpp
+++ b/kaddressbook/kcmconfigs/addresseewidget.cpp
@@ -1,242 +1,243 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qgroupbox.h> 24#include <qgroupbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qapplication.h>
29 30
30#include <kbuttonbox.h> 31#include <kbuttonbox.h>
31#include <kcombobox.h> 32#include <kcombobox.h>
32#include <kconfig.h> 33#include <kconfig.h>
33#include <kdialog.h> 34#include <kdialog.h>
34#include <klocale.h> 35#include <klocale.h>
35#include <kglobal.h> 36#include <kglobal.h>
36#include <klineedit.h> 37#include <klineedit.h>
37#include <kstandarddirs.h> 38#include <kstandarddirs.h>
38 39
39#include "addresseewidget.h" 40#include "addresseewidget.h"
40 41
41NamePartWidget::NamePartWidget( const QString &title, QWidget *parent, 42NamePartWidget::NamePartWidget( const QString &title, QWidget *parent,
42 const char *name ) 43 const char *name )
43 : QWidget( parent, name ) 44 : QWidget( parent, name )
44{ 45{
45 if (KGlobal::getOrientation() == KGlobal::Portrait) 46 if (KGlobal::getOrientation() == KGlobal::Portrait)
46 { 47 {
47 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(), 48 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(),
48 KDialog::spacingHintSmall() ); 49 KDialog::spacingHintSmall() );
49 50
50 QLabel *label = new QLabel( i18n( title ), this ); 51 QLabel *label = new QLabel( i18n( title ), this );
51 layout->addWidget( label, 0, 1 ); 52 layout->addWidget( label, 0, 1 );
52 53
53 mBox = new QListBox( this ); 54 mBox = new QListBox( this );
54 mBox->setMaximumSize(70, 70); 55 mBox->setMaximumSize(70, 70);
55 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 ); 56 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 );
56 57
57 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical ); 58 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical );
58 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 59 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
59 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) ); 60 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) );
60 bbox->layout(); 61 bbox->layout();
61 layout->addMultiCellWidget( bbox, 0, 1, 2,2); 62 layout->addMultiCellWidget( bbox, 0, 1, 2,2);
62 63
63 mEdit = new KLineEdit( this ); 64 mEdit = new KLineEdit( this );
64 layout->addWidget( mEdit, 1, 1 ); 65 layout->addWidget( mEdit, 1, 1 );
65 //mEdit->setMinimumWidth(50); 66 //mEdit->setMinimumWidth(50);
66 67
67// layout->addWidget( group ); 68// layout->addWidget( group );
68 69
69 } 70 }
70 else 71 else
71 { 72 {
72 QHBoxLayout *layout = new QHBoxLayout( this ); 73 QHBoxLayout *layout = new QHBoxLayout( this );
73 74
74 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this ); 75 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this );
75 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2, 76 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2,
76 KDialog::spacingHint() ); 77 KDialog::spacingHint() );
77 78
78 mBox = new QListBox( group ); 79 mBox = new QListBox( group );
79 80
80 groupLayout->addWidget( mBox, 0, 0 ); 81 groupLayout->addWidget( mBox, 0, 0 );
81 82
82 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical ); 83 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical );
83 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 84 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
84 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) ); 85 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) );
85 bbox->layout(); 86 bbox->layout();
86 groupLayout->addWidget( bbox, 0, 1 ); 87 groupLayout->addWidget( bbox, 0, 1 );
87 88
88 mEdit = new KLineEdit( group ); 89 mEdit = new KLineEdit( group );
89 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 ); 90 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 );
90 91
91 layout->addWidget( group ); 92 layout->addWidget( group );
92 93
93 } 94 }
94 95
95 mAddButton->setEnabled( false ); 96 mAddButton->setEnabled( false );
96 mRemoveButton->setEnabled( false ); 97 mRemoveButton->setEnabled( false );
97 98
98 99
99 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ), 100 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ),
100 SLOT( selectionChanged( QListBoxItem* ) ) ); 101 SLOT( selectionChanged( QListBoxItem* ) ) );
101 connect( mEdit, SIGNAL( textChanged( const QString& ) ), 102 connect( mEdit, SIGNAL( textChanged( const QString& ) ),
102 SLOT( textChanged( const QString& ) ) ); 103 SLOT( textChanged( const QString& ) ) );
103 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); 104 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) );
104 105
105} 106}
106 107
107NamePartWidget::~NamePartWidget() 108NamePartWidget::~NamePartWidget()
108{ 109{
109} 110}
110 111
111void NamePartWidget::setNameParts( const QStringList &list ) 112void NamePartWidget::setNameParts( const QStringList &list )
112{ 113{
113 mBox->clear(); 114 mBox->clear();
114 mBox->insertStringList( list ); 115 mBox->insertStringList( list );
115} 116}
116 117
117QStringList NamePartWidget::nameParts() const 118QStringList NamePartWidget::nameParts() const
118{ 119{
119 QStringList parts; 120 QStringList parts;
120 for ( uint i = 0; i < mBox->count(); ++i ) 121 for ( uint i = 0; i < mBox->count(); ++i )
121 parts.append( mBox->text( i ) ); 122 parts.append( mBox->text( i ) );
122 123
123 return parts; 124 return parts;
124} 125}
125 126
126void NamePartWidget::add() 127void NamePartWidget::add()
127{ 128{
128 if ( !mEdit->text().isEmpty() ) { 129 if ( !mEdit->text().isEmpty() ) {
129 mBox->insertItem( mEdit->text() ); 130 mBox->insertItem( mEdit->text() );
130 emit modified(); 131 emit modified();
131 } 132 }
132 133
133 mEdit->setText( "" ); 134 mEdit->setText( "" );
134} 135}
135 136
136void NamePartWidget::remove() 137void NamePartWidget::remove()
137{ 138{
138 mBox->removeItem( mBox->currentItem() ); 139 mBox->removeItem( mBox->currentItem() );
139 if ( mBox->count() == 0 ) 140 if ( mBox->count() == 0 )
140 selectionChanged( 0 ); 141 selectionChanged( 0 );
141 142
142 emit modified(); 143 emit modified();
143} 144}
144 145
145void NamePartWidget::selectionChanged( QListBoxItem *item ) 146void NamePartWidget::selectionChanged( QListBoxItem *item )
146{ 147{
147 mRemoveButton->setEnabled( item != 0 ); 148 mRemoveButton->setEnabled( item != 0 );
148} 149}
149 150
150void NamePartWidget::textChanged( const QString& text ) 151void NamePartWidget::textChanged( const QString& text )
151{ 152{
152 mAddButton->setEnabled( !text.isEmpty() ); 153 mAddButton->setEnabled( !text.isEmpty() );
153} 154}
154 155
155 156
156AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name ) 157AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name )
157 : QWidget( parent, name ) 158 : QWidget( parent, name )
158{ 159{
159 QGridLayout *layout; 160 QGridLayout *layout;
160 161
161 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this ); 162 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this );
162 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this ); 163 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this );
163 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this ); 164 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this );
164 QString dfn; 165 QString dfn;
165 if (QApplication::desktop()->width() > 320 ) 166 if (QApplication::desktop()->width() > 320 )
166 dfn = i18n( "Default formatted name:" ); 167 dfn = i18n( "Default formatted name:" );
167 else 168 else
168 dfn = i18n( "Def. formatted name:" ); 169 dfn = i18n( "Def. formatted name:" );
169 170
170 QLabel *label = new QLabel( dfn, this ); 171 QLabel *label = new QLabel( dfn, this );
171 172
172 mFormattedNameCombo = new KComboBox( this ); 173 mFormattedNameCombo = new KComboBox( this );
173 mFormattedNameCombo->insertItem( i18n( "Empty" ) ); 174 mFormattedNameCombo->insertItem( i18n( "Empty" ) );
174 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) ); 175 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) );
175 mFormattedNameCombo->insertItem( i18n( "Full Name" ) ); 176 mFormattedNameCombo->insertItem( i18n( "Full Name" ) );
176 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) ); 177 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) );
177 178
178 if (KGlobal::getOrientation() == KGlobal::Portrait) 179 if (KGlobal::getOrientation() == KGlobal::Portrait)
179 { 180 {
180 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(), 181 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(),
181 KDialog::spacingHintSmall() ); 182 KDialog::spacingHintSmall() );
182 183
183 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 ); 184 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 );
184 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 ); 185 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 );
185 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 ); 186 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 );
186 layout->addWidget( label, 3, 0 ); 187 layout->addWidget( label, 3, 0 );
187 layout->addWidget( mFormattedNameCombo, 3, 1 ); 188 layout->addWidget( mFormattedNameCombo, 3, 1 );
188 189
189 } 190 }
190 else 191 else
191 { 192 {
192 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(), 193 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(),
193 KDialog::spacingHint() ); 194 KDialog::spacingHint() );
194 195
195 layout->addWidget( mPrefix, 0, 0 ); 196 layout->addWidget( mPrefix, 0, 0 );
196 layout->addWidget( mInclusion, 0, 1 ); 197 layout->addWidget( mInclusion, 0, 1 );
197 layout->addWidget( mSuffix, 0, 2 ); 198 layout->addWidget( mSuffix, 0, 2 );
198 layout->addWidget( label, 1, 0 ); 199 layout->addWidget( label, 1, 0 );
199 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 ); 200 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 );
200 } 201 }
201 202
202 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) ); 203 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) );
203 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) ); 204 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) );
204 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) ); 205 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) );
205 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) ); 206 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) );
206} 207}
207 208
208AddresseeWidget::~AddresseeWidget() 209AddresseeWidget::~AddresseeWidget()
209{ 210{
210} 211}
211 212
212void AddresseeWidget::restoreSettings() 213void AddresseeWidget::restoreSettings()
213{ 214{
214 KConfig config( locateLocal("config", "kabcrc") ); 215 KConfig config( locateLocal("config", "kabcrc") );
215 config.setGroup( "General" ); 216 config.setGroup( "General" );
216 217
217 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) ); 218 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) );
218 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) ); 219 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) );
219 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) ); 220 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) );
220 221
221 KConfig cfg( locateLocal("config","kaddressbookrc") ); 222 KConfig cfg( locateLocal("config","kaddressbookrc") );
222 cfg.setGroup( "General" ); 223 cfg.setGroup( "General" );
223 mFormattedNameCombo->setCurrentItem( cfg.readNumEntry( "FormattedNameType", 1 ) ); 224 mFormattedNameCombo->setCurrentItem( cfg.readNumEntry( "FormattedNameType", 1 ) );
224} 225}
225 226
226void AddresseeWidget::saveSettings() 227void AddresseeWidget::saveSettings()
227{ 228{
228 KConfig config( locateLocal("config","kabcrc") ); 229 KConfig config( locateLocal("config","kabcrc") );
229 config.setGroup( "General" ); 230 config.setGroup( "General" );
230 231
231 config.writeEntry( "Prefixes", mPrefix->nameParts() ); 232 config.writeEntry( "Prefixes", mPrefix->nameParts() );
232 config.writeEntry( "Inclusions", mInclusion->nameParts() ); 233 config.writeEntry( "Inclusions", mInclusion->nameParts() );
233 config.writeEntry( "Suffixes", mSuffix->nameParts() ); 234 config.writeEntry( "Suffixes", mSuffix->nameParts() );
234 235
235 KConfig cfg( locateLocal("config","kaddressbookrc") ); 236 KConfig cfg( locateLocal("config","kaddressbookrc") );
236 cfg.setGroup( "General" ); 237 cfg.setGroup( "General" );
237 cfg.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() ); 238 cfg.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() );
238} 239}
239 240
240#ifndef KAB_EMBEDDED 241#ifndef KAB_EMBEDDED
241#include "addresseewidget.moc" 242#include "addresseewidget.moc"
242#endif //KAB_EMBEDDED 243#endif //KAB_EMBEDDED
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index dce6a88..cf1fd3e 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,189 +1,190 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#else 4#else
5#include <qapplication.h> 5#include <qapplication.h>
6#include <qwindowsstyle.h> 6#include <qwindowsstyle.h>
7#include <qplatinumstyle.h> 7#include <qplatinumstyle.h>
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#endif 9#endif
10 10
11#include <kstandarddirs.h> 11#include <kstandarddirs.h>
12#include <kglobal.h> 12#include <kglobal.h>
13#include <stdio.h> 13#include <stdio.h>
14#include <qdir.h> 14#include <qdir.h>
15#include "kaddressbookmain.h" 15#include "kaddressbookmain.h"
16 16
17int main( int argc, char **argv ) 17int main( int argc, char **argv )
18{ 18{
19#ifndef DESKTOP_VERSION 19#ifndef DESKTOP_VERSION
20 QPEApplication a( argc, argv ); 20 QPEApplication a( argc, argv );
21 a.setKeepRunning (); 21 a.setKeepRunning ();
22#else 22#else
23 QApplication a( argc, argv ); 23 QApplication a( argc, argv );
24 QApplication::setStyle( new QPlatinumStyle ()); 24 QApplication::setStyle( new QPlatinumStyle ());
25#endif 25#endif
26 26
27 bool exitHelp = false; 27 bool exitHelp = false;
28 if ( argc > 1 ) { 28 if ( argc > 1 ) {
29 QString command = argv[1]; 29 QString command = argv[1];
30 if ( command == "-help" ){ 30 if ( command == "-help" ){
31 printf("KA/E command line commands:\n"); 31 printf("KA/E command line commands:\n");
32 printf(" no command: Start KA/E in usual way\n"); 32 printf(" no command: Start KA/E in usual way\n");
33 printf(" -help: This output\n"); 33 printf(" -help: This output\n");
34 printf(" KA/E is exiting now. Bye!\n"); 34 printf(" KA/E is exiting now. Bye!\n");
35 exitHelp = true; 35 exitHelp = true;
36 } 36 }
37 } 37 }
38 if ( ! exitHelp ) { 38 if ( ! exitHelp ) {
39 39
40 KGlobal::setAppName( "kaddressbook" ); 40 KGlobal::setAppName( "kaddressbook" );
41#ifndef DESKTOP_VERSION 41#ifndef DESKTOP_VERSION
42 if ( QApplication::desktop()->width() > 320 ) 42 if ( QApplication::desktop()->width() > 320 )
43 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 43 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
44 else 44 else
45 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 45 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
46#else 46#else
47 QString fileName ; 47 QString fileName ;
48 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; 48 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
49 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 49 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
50 QApplication::addLibraryPath ( qApp->applicationDirPath () );
50 51
51#endif 52#endif
52 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 53 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
53 KAddressBookMain m ; 54 KAddressBookMain m ;
54//US MainWindow m; 55//US MainWindow m;
55//US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 56//US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
56 57
57#ifndef DESKTOP_VERSION 58#ifndef DESKTOP_VERSION
58 a.showMainWidget( &m ); 59 a.showMainWidget( &m );
59#else 60#else
60 a.setMainWidget(m ); 61 a.setMainWidget( &m );
61 m->show(); 62 m.show();
62#endif 63#endif
63 a.exec(); 64 a.exec();
64 65
65 } 66 }
66 qDebug("KA: Bye! "); 67 qDebug("KA: Bye! ");
67} 68}
68 69
69/* 70/*
70#include <stdlib.h> 71#include <stdlib.h>
71 72
72#include <qstring.h> 73#include <qstring.h>
73 74
74#include <kabc/stdaddressbook.h> 75#include <kabc/stdaddressbook.h>
75#include <kaboutdata.h> 76#include <kaboutdata.h>
76#include <kcmdlineargs.h> 77#include <kcmdlineargs.h>
77#include <kcrash.h> 78#include <kcrash.h>
78#include <kdebug.h> 79#include <kdebug.h>
79#include <klocale.h> 80#include <klocale.h>
80#include <kstartupinfo.h> 81#include <kstartupinfo.h>
81#include <kuniqueapplication.h> 82#include <kuniqueapplication.h>
82#include <kwin.h> 83#include <kwin.h>
83 84
84#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
85#include "kabcore.h" 86#include "kabcore.h"
86 87
87extern "C" { 88extern "C" {
88 89
89void crashHandler( int ) 90void crashHandler( int )
90{ 91{
91 KABC::StdAddressBook::handleCrash(); 92 KABC::StdAddressBook::handleCrash();
92 ::exit( 0 ); 93 ::exit( 0 );
93} 94}
94 95
95} 96}
96 97
97class KAddressBookApp : public KUniqueApplication { 98class KAddressBookApp : public KUniqueApplication {
98 public: 99 public:
99 KAddressBookApp() : mMainWin( 0 ) {} 100 KAddressBookApp() : mMainWin( 0 ) {}
100 ~KAddressBookApp() {} 101 ~KAddressBookApp() {}
101 102
102 int newInstance(); 103 int newInstance();
103 104
104 private: 105 private:
105 KAddressBookMain *mMainWin; 106 KAddressBookMain *mMainWin;
106}; 107};
107 108
108int KAddressBookApp::newInstance() 109int KAddressBookApp::newInstance()
109{ 110{
110 if ( isRestored() ) { 111 if ( isRestored() ) {
111 // There can only be one main window 112 // There can only be one main window
112 if ( KMainWindow::canBeRestored( 1 ) ) { 113 if ( KMainWindow::canBeRestored( 1 ) ) {
113 mMainWin = new KAddressBookMain; 114 mMainWin = new KAddressBookMain;
114 mMainWin->show(); 115 mMainWin->show();
115 mMainWin->restore( 1 ); 116 mMainWin->restore( 1 );
116 } 117 }
117 } else { 118 } else {
118 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 119 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
119 120
120 QCString addrStr = args->getOption( "addr" ); 121 QCString addrStr = args->getOption( "addr" );
121 QCString uidStr = args->getOption( "uid" ); 122 QCString uidStr = args->getOption( "uid" );
122 QString addr; 123 QString addr;
123 QString uid; 124 QString uid;
124 if ( !addrStr.isEmpty() ) 125 if ( !addrStr.isEmpty() )
125 addr = QString::fromLocal8Bit( addrStr ); 126 addr = QString::fromLocal8Bit( addrStr );
126 if ( !uidStr.isEmpty() ) 127 if ( !uidStr.isEmpty() )
127 uid = QString::fromLocal8Bit( uidStr ); 128 uid = QString::fromLocal8Bit( uidStr );
128 129
129 130
130 if ( args->isSet( "editor-only" ) ) { 131 if ( args->isSet( "editor-only" ) ) {
131 if ( !mMainWin ) 132 if ( !mMainWin )
132 mMainWin = new KAddressBookMain; 133 mMainWin = new KAddressBookMain;
133 KStartupInfo::appStarted(); 134 KStartupInfo::appStarted();
134 mMainWin->hide(); 135 mMainWin->hide();
135 } else { 136 } else {
136 if ( mMainWin ) { 137 if ( mMainWin ) {
137 mMainWin->show(); 138 mMainWin->show();
138 KWin::setActiveWindow( mMainWin->winId() ); 139 KWin::setActiveWindow( mMainWin->winId() );
139 } else { 140 } else {
140 mMainWin = new KAddressBookMain; 141 mMainWin = new KAddressBookMain;
141 mMainWin->show(); 142 mMainWin->show();
142 } 143 }
143 } 144 }
144 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do 145 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
145 if ( !addr.isEmpty() ) 146 if ( !addr.isEmpty() )
146 mMainWin->addEmail( addr ); 147 mMainWin->addEmail( addr );
147 148
148 if ( !uid.isEmpty() ) 149 if ( !uid.isEmpty() )
149 mMainWin->showContactEditor( uid ); 150 mMainWin->showContactEditor( uid );
150 if ( args->isSet( "new-contact" ) ) { 151 if ( args->isSet( "new-contact" ) ) {
151 mMainWin->newContact(); 152 mMainWin->newContact();
152 } 153 }
153 } 154 }
154 155
155 KCrash::setEmergencySaveFunction( crashHandler ); 156 KCrash::setEmergencySaveFunction( crashHandler );
156 157
157 return 0; 158 return 0;
158} 159}
159 160
160// the dummy argument is required, because KMail apparently sends an empty 161// the dummy argument is required, because KMail apparently sends an empty
161// argument. 162// argument.
162static KCmdLineOptions kmoptions[] = 163static KCmdLineOptions kmoptions[] =
163{ 164{
164 { "a", 0 , 0 }, 165 { "a", 0 , 0 },
165 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 166 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
166 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 167 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
167 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 168 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
168 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 169 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
169 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 170 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
170 { 0, 0, 0} 171 { 0, 0, 0}
171}; 172};
172 173
173int main( int argc, char *argv[] ) 174int main( int argc, char *argv[] )
174{ 175{
175 KLocale::setMainCatalogue( "kaddressbook" ); 176 KLocale::setMainCatalogue( "kaddressbook" );
176 177
177 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 178 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
178 KCmdLineArgs::addCmdLineOptions( kmoptions ); 179 KCmdLineArgs::addCmdLineOptions( kmoptions );
179 KUniqueApplication::addCmdLineOptions(); 180 KUniqueApplication::addCmdLineOptions();
180 181
181 if ( !KAddressBookApp::start() ) 182 if ( !KAddressBookApp::start() )
182 exit( 0 ); 183 exit( 0 );
183 184
184 KAddressBookApp app; 185 KAddressBookApp app;
185 KGlobal::locale()->insertCatalogue( "libkdepim" ); 186 KGlobal::locale()->insertCatalogue( "libkdepim" );
186 187
187 return app.exec(); 188 return app.exec();
188} 189}
189*/ 190*/
diff --git a/kopi-desktop.pro b/kopi-desktop.pro
index 1a5fabd..b255756 100644
--- a/kopi-desktop.pro
+++ b/kopi-desktop.pro
@@ -1,6 +1,6 @@
1 1
2 2
3TEMPLATE = subdirs 3TEMPLATE = subdirs
4SUBDIRS = libical libkcal microkde libkdepim kabc korganizer kaddressbook 4SUBDIRS = libical libkcal microkde libkdepim kabc korganizer kaddressbook kabc/plugins/file kabc/plugins/dir
5#kalarmd 5#kalarmd
6 6
diff --git a/kopiemail.control b/kopiemail.control
index 3d563f0..7a93a1b 100644
--- a/kopiemail.control
+++ b/kopiemail.control
@@ -1,14 +1,14 @@
1Files: bin/ompi apps/Pim/kmicromail.desktop pics/kdepim/kmicromail/* lib/libssl* lib/libcrypto.* lib/libkmicro* 1Files: bin/ompi apps/Pim/kmicromail.desktop pics/kdepim/kmicromail/* lib/libssl* lib/libcrypto.* lib/libkmicro*
2 2
3Priority: optional 3Priority: optional
4Section: qpe/pim 4Section: qpe/pim
5Maintainer: Lutz Rogowski <lutz@pi-sync.net> 5Maintainer: Lutz Rogowski <lutz@pi-sync.net>
6Architecture: arm 6Architecture: arm
7Version: 1.9.2a 7Version: 1.9.2b
8License: GPL 8License: GPL
9Depends: lib/libmicrokde.so 9Depends: lib/libmicrokde.so
10Description: KOrganizer/Pi and Kaddressbook/Pi 10Description: KOrganizer/Pi and Kaddressbook/Pi
11 The embedded version of KOrganizer/Platform-independend, 11 The embedded version of KOrganizer/Platform-independend,
12 the KDE calendar and scheduling program 12 the KDE calendar and scheduling program
13 optimized for 640x480 and 320x240 resolution 13 optimized for 640x480 and 320x240 resolution
14 on Zaurus PDA 14 on Zaurus PDA
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp
index c07d50f..c091e05 100644
--- a/microkde/kdecore/klibloader.cpp
+++ b/microkde/kdecore/klibloader.cpp
@@ -1,647 +1,648 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Torben Weis <weis@kde.org> 2 Copyright (C) 1999 Torben Weis <weis@kde.org>
3 Copyright (C) 2000 Michael Matz <matz@kde.org> 3 Copyright (C) 2000 Michael Matz <matz@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19//US #include <config.h> 19//US #include <config.h>
20#include <qclipboard.h> 20#include <qclipboard.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qobjectdict.h> 23#include <qobjectdict.h>
24#include <qwidgetlist.h> 24#include <qwidgetlist.h>
25#include <qwidget.h> 25#include <qwidget.h>
26 26
27#include "kapplication.h" 27#include "kapplication.h"
28#include "klibloader.h" 28#include "klibloader.h"
29#include "kstandarddirs.h" 29#include "kstandarddirs.h"
30#include "kdebug.h" 30#include "kdebug.h"
31#include "klocale.h" 31#include "klocale.h"
32 32
33/*US 33/*US
34#ifndef NDEBUG 34#ifndef NDEBUG
35#include "ltdl.h" 35#include "ltdl.h"
36#endif 36#endif
37*/ 37*/
38 38
39//US do everything through qlibrary 39//US do everything through qlibrary
40#ifndef DESKTOP_VERSION 40#ifndef DESKTOP_VERSION
41#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
42#include <qtopia/qlibrary.h> 42#include <qtopia/qlibrary.h>
43#else
44#include <qlibrary.h>
43#endif 45#endif
44 46
45/*US 47
46#ifdef Q_WS_X11
47#include <X11/Xlib.h>
48#include <X11/Xatom.h>
49#endif
50*/
51template class QAsciiDict<KLibrary>; 48template class QAsciiDict<KLibrary>;
52 49
53#include <stdlib.h> //getenv 50#include <stdlib.h> //getenv
54 51
55/*US 52/*US
56#if HAVE_DLFCN_H 53#if HAVE_DLFCN_H
57# include <dlfcn.h> 54# include <dlfcn.h>
58#endif 55#endif
59 56
60#ifdef RTLD_GLOBAL 57#ifdef RTLD_GLOBAL
61# define LT_GLOBAL RTLD_GLOBAL 58# define LT_GLOBAL RTLD_GLOBAL
62#else 59#else
63# ifdef DL_GLOBAL 60# ifdef DL_GLOBAL
64# define LT_GLOBAL DL_GLOBAL 61# define LT_GLOBAL DL_GLOBAL
65# endif 62# endif
66#endif 63#endif
67#ifndef LT_GLOBAL 64#ifndef LT_GLOBAL
68# define LT_GLOBAL 0 65# define LT_GLOBAL 0
69#endif 66#endif
70*/ 67*/
71 68
72/*US 69/*US
73extern "C" { 70extern "C" {
74extern int lt_dlopen_flag; 71extern int lt_dlopen_flag;
75} 72}
76*/ 73*/
77 74
78KLibFactory::KLibFactory( QObject* parent, const char* name ) 75KLibFactory::KLibFactory( QObject* parent, const char* name )
79 : QObject( parent, name ) 76 : QObject( parent, name )
80{ 77{
81} 78}
82 79
83KLibFactory::~KLibFactory() 80KLibFactory::~KLibFactory()
84{ 81{
85// kdDebug(150) << "Deleting KLibFactory " << this << endl; 82// kdDebug(150) << "Deleting KLibFactory " << this << endl;
86} 83}
87 84
88QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args ) 85QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args )
89{ 86{
90 QObject* obj = createObject( parent, name, classname, args ); 87 QObject* obj = createObject( parent, name, classname, args );
91 if ( obj ) 88 if ( obj )
92 emit objectCreated( obj ); 89 emit objectCreated( obj );
93 return obj; 90 return obj;
94} 91}
95 92
96 93
97QObject* KLibFactory::createObject( QObject*, const char*, const char*, const QStringList &) 94QObject* KLibFactory::createObject( QObject*, const char*, const char*, const QStringList &)
98{ 95{
99 return 0; 96 return 0;
100} 97}
101 98
102 99
103// ----------------------------------------------- 100// -----------------------------------------------
104 101
105//US KLibrary::KLibrary( const QString& libname, const QString& filename, void * handle ) 102//US KLibrary::KLibrary( const QString& libname, const QString& filename, void * handle )
106KLibrary::KLibrary( const QString& libname, const QString& filename, QLibrary* handle ) 103KLibrary::KLibrary( const QString& libname, const QString& filename, QLibrary* handle )
107{ 104{
108 /* Make sure, we have a KLibLoader */ 105 /* Make sure, we have a KLibLoader */
109 (void) KLibLoader::self(); 106 (void) KLibLoader::self();
110 m_libname = libname; 107 m_libname = libname;
111 m_filename = filename; 108 m_filename = filename;
112 m_handle = handle; 109 m_handle = handle;
113 m_factory = 0; 110 m_factory = 0;
114 m_timer = 0; 111 m_timer = 0;
115} 112}
116 113
117KLibrary::~KLibrary() 114KLibrary::~KLibrary()
118{ 115{
119// kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl; 116// kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl;
120 if ( m_timer && m_timer->isActive() ) 117 if ( m_timer && m_timer->isActive() )
121 m_timer->stop(); 118 m_timer->stop();
122 119
123 // If any object is remaining, delete 120 // If any object is remaining, delete
124 if ( m_objs.count() > 0 ) 121 if ( m_objs.count() > 0 )
125 { 122 {
126 QPtrListIterator<QObject> it( m_objs ); 123 QPtrListIterator<QObject> it( m_objs );
127 for ( ; it.current() ; ++it ) 124 for ( ; it.current() ; ++it )
128 { 125 {
129 kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl; 126 kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl;
130 disconnect( it.current(), SIGNAL( destroyed() ), 127 disconnect( it.current(), SIGNAL( destroyed() ),
131 this, SLOT( slotObjectDestroyed() ) ); 128 this, SLOT( slotObjectDestroyed() ) );
132 } 129 }
133 m_objs.setAutoDelete(true); 130 m_objs.setAutoDelete(true);
134 m_objs.clear(); 131 m_objs.clear();
135 } 132 }
136 133
137 if ( m_factory ) { 134 if ( m_factory ) {
138 //kdDebug(150) << " ... deleting the factory " << m_factory << endl; 135 //kdDebug(150) << " ... deleting the factory " << m_factory << endl;
139 delete m_factory; 136 delete m_factory;
140 } 137 }
141} 138}
142 139
143QString KLibrary::name() const 140QString KLibrary::name() const
144{ 141{
145 return m_libname; 142 return m_libname;
146} 143}
147 144
148QString KLibrary::fileName() const 145QString KLibrary::fileName() const
149{ 146{
150 return m_filename; 147 return m_filename;
151} 148}
152 149
153KLibFactory* KLibrary::factory() 150KLibFactory* KLibrary::factory()
154{ 151{
155 if ( m_factory ) 152 if ( m_factory )
156 return m_factory; 153 return m_factory;
157 154
158 QCString symname; 155 QCString symname;
159 symname.sprintf("init_%s", name().latin1() ); 156 symname.sprintf("init_%s", name().latin1() );
160 157
161 void* sym = symbol( symname ); 158 void* sym = symbol( symname );
162 if ( !sym ) 159 if ( !sym )
163 { 160 {
164 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); 161 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data());
165#ifndef NDEBUG 162#ifndef NDEBUG
166//US qDebug("KLibrary: errorcode: %s", lt_dlerror()); 163//US qDebug("KLibrary: errorcode: %s", lt_dlerror());
167#endif 164#endif
168 kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; 165 kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl;
169 return 0; 166 return 0;
170 } 167 }
171 168
172 typedef KLibFactory* (*t_func)(); 169 typedef KLibFactory* (*t_func)();
173 t_func func = (t_func)sym; 170 t_func func = (t_func)sym;
174 m_factory = func(); 171 m_factory = func();
175 172
176 if( !m_factory ) 173 if( !m_factory )
177 { 174 {
178 kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; 175 kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl;
179 return 0; 176 return 0;
180 } 177 }
181 178
182 connect( m_factory, SIGNAL( objectCreated( QObject * ) ), 179 connect( m_factory, SIGNAL( objectCreated( QObject * ) ),
183 this, SLOT( slotObjectCreated( QObject * ) ) ); 180 this, SLOT( slotObjectCreated( QObject * ) ) );
184 181
185 return m_factory; 182 return m_factory;
186} 183}
187 184
188void* KLibrary::symbol( const char* symname ) const 185void* KLibrary::symbol( const char* symname ) const
189{ 186{
190//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); 187//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname );
191 void* sym = m_handle->resolve( symname ); 188 void* sym = m_handle->resolve( symname );
192 if ( !sym ) 189 if ( !sym )
193 { 190 {
194//US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; 191//US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl;
195 kdWarning(150) << "KLibrary: " << m_libname << ", symbol:" << symname << " not found " << endl;
196 return 0; 192 return 0;
197 } 193 }
198 194
199 return sym; 195 return sym;
200} 196}
201 197
202bool KLibrary::hasSymbol( const char* symname ) const 198bool KLibrary::hasSymbol( const char* symname ) const
203{ 199{
204//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); 200//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname );
205 void* sym = m_handle->resolve( symname ); 201 void* sym = m_handle->resolve( symname );
206 return (sym != 0L ); 202 return (sym != 0L );
207} 203}
208 204
209void KLibrary::unload() const 205void KLibrary::unload() const
210{ 206{
211 if (KLibLoader::s_self) 207 if (KLibLoader::s_self)
212 KLibLoader::s_self->unloadLibrary(QFile::encodeName(name())); 208 KLibLoader::s_self->unloadLibrary(QFile::encodeName(name()));
213} 209}
214 210
215void KLibrary::slotObjectCreated( QObject *obj ) 211void KLibrary::slotObjectCreated( QObject *obj )
216{ 212{
217 if ( !obj ) 213 if ( !obj )
218 return; 214 return;
219 215
220 if ( m_timer && m_timer->isActive() ) 216 if ( m_timer && m_timer->isActive() )
221 m_timer->stop(); 217 m_timer->stop();
222 218
223 if ( m_objs.containsRef( obj ) ) 219 if ( m_objs.containsRef( obj ) )
224 return; // we know this object already 220 return; // we know this object already
225 221
226 connect( obj, SIGNAL( destroyed() ), 222 connect( obj, SIGNAL( destroyed() ),
227 this, SLOT( slotObjectDestroyed() ) ); 223 this, SLOT( slotObjectDestroyed() ) );
228 224
229 m_objs.append( obj ); 225 m_objs.append( obj );
230} 226}
231 227
232void KLibrary::slotObjectDestroyed() 228void KLibrary::slotObjectDestroyed()
233{ 229{
234 m_objs.removeRef( sender() ); 230 m_objs.removeRef( sender() );
235 231
236 if ( m_objs.count() == 0 ) 232 if ( m_objs.count() == 0 )
237 { 233 {
238// kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!" 234// kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!"
239// << endl; 235// << endl;
240 236
241 if ( !m_timer ) 237 if ( !m_timer )
242 { 238 {
243 m_timer = new QTimer( this, "klibrary_shutdown_timer" ); 239 m_timer = new QTimer( this, "klibrary_shutdown_timer" );
244 connect( m_timer, SIGNAL( timeout() ), 240 connect( m_timer, SIGNAL( timeout() ),
245 this, SLOT( slotTimeout() ) ); 241 this, SLOT( slotTimeout() ) );
246 } 242 }
247 243
248 // as long as it's not stable make the timeout short, for debugging 244 // as long as it's not stable make the timeout short, for debugging
249 // pleasure (matz) 245 // pleasure (matz)
250 //m_timer->start( 1000*60, true ); 246 //m_timer->start( 1000*60, true );
251 m_timer->start( 1000*10, true ); 247 m_timer->start( 1000*10, true );
252 } 248 }
253} 249}
254 250
255void KLibrary::slotTimeout() 251void KLibrary::slotTimeout()
256{ 252{
257 if ( m_objs.count() != 0 ) 253 if ( m_objs.count() != 0 )
258 return; 254 return;
259 255
260 /* Don't go through KLibLoader::unloadLibrary(), because that uses the 256 /* Don't go through KLibLoader::unloadLibrary(), because that uses the
261 ref counter, but this timeout means to unconditionally close this library 257 ref counter, but this timeout means to unconditionally close this library
262 The destroyed() signal will take care to remove us from all lists. 258 The destroyed() signal will take care to remove us from all lists.
263 */ 259 */
264 delete this; 260 delete this;
265} 261}
266 262
267// ------------------------------------------------- 263// -------------------------------------------------
268 264
269/* This helper class is needed, because KLibraries can go away without 265/* This helper class is needed, because KLibraries can go away without
270 being unloaded. So we need some info about KLibraries even after its 266 being unloaded. So we need some info about KLibraries even after its
271 death. */ 267 death. */
272class KLibWrapPrivate 268class KLibWrapPrivate
273{ 269{
274public: 270public:
275//US KLibWrapPrivate(KLibrary *l, lt_dlhandle h); 271//US KLibWrapPrivate(KLibrary *l, lt_dlhandle h);
276 KLibWrapPrivate(KLibrary *l, QLibrary* h); 272 KLibWrapPrivate(KLibrary *l, QLibrary* h);
277 273
278 KLibrary *lib; 274 KLibrary *lib;
279 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; 275 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode;
280 int ref_count; 276 int ref_count;
281//US lt_dlhandle handle; 277//US lt_dlhandle handle;
282 QLibrary *handle; 278 QLibrary *handle;
283 QString name; 279 QString name;
284 QString filename; 280 QString filename;
285}; 281};
286 282
287//US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h) 283//US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h)
288KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h) 284KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h)
289 : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName()) 285 : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName())
290{ 286{
291 unload_mode = UNKNOWN; 287 unload_mode = UNKNOWN;
292/*US 288/*US
293 if (lt_dlsym(handle, "__kde_do_not_unload") != 0) { 289 if (lt_dlsym(handle, "__kde_do_not_unload") != 0) {
294// kdDebug(150) << "Will not unload " << name << endl; 290// kdDebug(150) << "Will not unload " << name << endl;
295 unload_mode = DONT_UNLOAD; 291 unload_mode = DONT_UNLOAD;
296 } else if (lt_dlsym(handle, "__kde_do_unload") != 0) { 292 } else if (lt_dlsym(handle, "__kde_do_unload") != 0) {
297 unload_mode = UNLOAD; 293 unload_mode = UNLOAD;
298 } 294 }
299*/ 295*/
300//US use instead: 296//US use instead:
301 if (h->resolve("__kde_do_not_unload") != 0) { 297 if (h->resolve("__kde_do_not_unload") != 0) {
302// kdDebug(150) << "Will not unload " << name << endl; 298// kdDebug(150) << "Will not unload " << name << endl;
303 unload_mode = DONT_UNLOAD; 299 unload_mode = DONT_UNLOAD;
304 } else if (h->resolve("__kde_do_unload") != 0) { 300 } else if (h->resolve("__kde_do_unload") != 0) {
305 unload_mode = UNLOAD; 301 unload_mode = UNLOAD;
306 } 302 }
307} 303}
308 304
309class KLibLoaderPrivate 305class KLibLoaderPrivate
310{ 306{
311public: 307public:
312 QPtrList<KLibWrapPrivate> loaded_stack; 308 QPtrList<KLibWrapPrivate> loaded_stack;
313 QPtrList<KLibWrapPrivate> pending_close; 309 QPtrList<KLibWrapPrivate> pending_close;
314 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; 310 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode;
315 311
316 QString errorMessage; 312 QString errorMessage;
317}; 313};
318 314
319KLibLoader* KLibLoader::s_self = 0; 315KLibLoader* KLibLoader::s_self = 0;
320 316
321KLibLoader* KLibLoader::self() 317KLibLoader* KLibLoader::self()
322{ 318{
323 if ( !s_self ) 319 if ( !s_self )
324 s_self = new KLibLoader; 320 s_self = new KLibLoader;
325 return s_self; 321 return s_self;
326} 322}
327 323
328void KLibLoader::cleanUp() 324void KLibLoader::cleanUp()
329{ 325{
330 if ( !s_self ) 326 if ( !s_self )
331 return; 327 return;
332 328
333 delete s_self; 329 delete s_self;
334 s_self = 0; 330 s_self = 0;
335} 331}
336 332
337KLibLoader::KLibLoader( QObject* parent, const char* name ) 333KLibLoader::KLibLoader( QObject* parent, const char* name )
338 : QObject( parent, name ) 334 : QObject( parent, name )
339{ 335{
340 s_self = this; 336 s_self = this;
341 d = new KLibLoaderPrivate; 337 d = new KLibLoaderPrivate;
342//US lt_dlinit(); 338//US lt_dlinit();
343 d->unload_mode = KLibLoaderPrivate::UNKNOWN; 339 d->unload_mode = KLibLoaderPrivate::UNKNOWN;
344 if (getenv("KDE_NOUNLOAD") != 0) 340 if (getenv("KDE_NOUNLOAD") != 0)
345 d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD; 341 d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD;
346 else if (getenv("KDE_DOUNLOAD") != 0) 342 else if (getenv("KDE_DOUNLOAD") != 0)
347 d->unload_mode = KLibLoaderPrivate::UNLOAD; 343 d->unload_mode = KLibLoaderPrivate::UNLOAD;
348 d->loaded_stack.setAutoDelete( true ); 344 d->loaded_stack.setAutoDelete( true );
349} 345}
350 346
351KLibLoader::~KLibLoader() 347KLibLoader::~KLibLoader()
352{ 348{
353// kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; 349// kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl;
354 350
355 QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); 351 QAsciiDictIterator<KLibWrapPrivate> it( m_libs );
356 for (; it.current(); ++it ) 352 for (; it.current(); ++it )
357 { 353 {
358 kdDebug(150) << "The KLibLoader contains the library " << it.current()->name 354 kdDebug(150) << "The KLibLoader contains the library " << it.current()->name
359 << " (" << it.current()->lib << ")" << endl; 355 << " (" << it.current()->lib << ")" << endl;
360 d->pending_close.append(it.current()); 356 d->pending_close.append(it.current());
361 } 357 }
362 358
363 close_pending(0); 359 close_pending(0);
364 360
365 delete d; 361 delete d;
366} 362}
367 363
368//static 364//static
369QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) 365QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ )
370{ 366{
371 QCString libname( name ); 367 QCString libname( name );
372 368
373 // only append ".la" if there is no extension 369 // only append ".la" if there is no extension
374 // this allows to load non-libtool libraries as well 370 // this allows to load non-libtool libraries as well
375 // (mhk, 20000228) 371 // (mhk, 20000228)
376 int pos = libname.findRev('/'); 372 int pos = libname.findRev('/');
377 if (pos < 0) 373 if (pos < 0)
378 pos = 0; 374 pos = 0;
379/*US 375/*US
380 if (libname.find('.', pos) < 0) { 376 if (libname.find('.', pos) < 0) {
381 libname += ".la"; 377 libname += ".la";
382 } 378 }
383*/ 379*/
384//US in the microedition we work only with shared libraries. 380//US in the microedition we work only with shared libraries.
385 if (libname.find('.', pos) < 0) { 381 if (libname.find('.', pos) < 0) {
386 libname += ".so"; 382 libname += ".so";
387 } 383 }
388 384
389 // only look up the file if it is not an absolute filename 385 // only look up the file if it is not an absolute filename
390 // (mhk, 20000228) 386 // (mhk, 20000228)
391 QString libfile; 387 QString libfile;
392 if (libname[0] == '/') 388 if (libname[0] == '/')
393 libfile = libname; 389 libfile = libname;
394 else 390 else
395 { 391 {
396//US at this point the libname must exist as real filesname. No expansions will be made later 392//US at this point the libname must exist as real filesname. No expansions will be made later
397// in findResources. Because of that we prepend the lib prefix here to the name 393// in findResources. Because of that we prepend the lib prefix here to the name
398//US I add also the "lib" prefix. I do not how could this could have worked before without it? 394//US I add also the "lib" prefix. I do not how could this could have worked before without it?
399 libname.insert(pos, "lib"); 395 libname.insert(pos, "lib");
400 396
401 397
402//US libfile = instance->dirs()->findResource( "module", libname ); 398//US libfile = instance->dirs()->findResource( "module", libname );
403 libfile = KGlobal::dirs()->findResource( "module", libname ); 399 libfile = KGlobal::dirs()->findResource( "module", libname );
404 if ( libfile.isEmpty() ) 400 if ( libfile.isEmpty() )
405 { 401 {
406//US libfile = instance->dirs()->findResource( "lib", libname ); 402//US libfile = instance->dirs()->findResource( "lib", libname );
407 libfile = KGlobal::dirs()->findResource( "lib", libname ); 403 libfile = KGlobal::dirs()->findResource( "lib", libname );
408#ifndef NDEBUG 404#ifndef NDEBUG
409 if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules 405 if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules
410 kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; 406 kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl;
411#endif 407#endif
412 } 408 }
413 if ( libfile.isEmpty() ) 409 if ( libfile.isEmpty() )
414 { 410 {
415#ifndef NDEBUG 411#ifndef NDEBUG
416 kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; 412 kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl;
417 self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); 413 self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname);
418 414
419 qDebug("KLibLoader::library could not find library: %s", libname.data()); 415 qDebug("KLibLoader::library could not find library: %s", libname.data());
420#endif 416#endif
421 417
422 } 418 }
423 else 419 else
424 self()->d->errorMessage = QString::null; 420 self()->d->errorMessage = QString::null;
425 } 421 }
426 return libfile; 422 return libfile;
427} 423}
428 424
429 425
430KLibrary* KLibLoader::globalLibrary( const char *name ) 426KLibrary* KLibLoader::globalLibrary( const char *name )
431{ 427{
432KLibrary *tmp; 428KLibrary *tmp;
433/*US 429/*US
434int olt_dlopen_flag = lt_dlopen_flag; 430int olt_dlopen_flag = lt_dlopen_flag;
435 431
436 lt_dlopen_flag |= LT_GLOBAL; 432 lt_dlopen_flag |= LT_GLOBAL;
437 kdDebug(150) << "Loading the next library global with flag " 433 kdDebug(150) << "Loading the next library global with flag "
438 << lt_dlopen_flag 434 << lt_dlopen_flag
439 << "." << endl; 435 << "." << endl;
440*/ 436*/
441 tmp = library(name); 437 tmp = library(name);
442/*US 438/*US
443 lt_dlopen_flag = olt_dlopen_flag; 439 lt_dlopen_flag = olt_dlopen_flag;
444*/ 440*/
445return tmp; 441return tmp;
446} 442}
447 443
448 444
449KLibrary* KLibLoader::library( const char *name ) 445KLibrary* KLibLoader::library( const char *name )
450{ 446{
451 if (!name) 447 if (!name)
452 return 0; 448 return 0;
453 449
454 KLibWrapPrivate* wrap = m_libs[name]; 450 KLibWrapPrivate* wrap = m_libs[name];
455 if (wrap) { 451 if (wrap) {
456 /* Nothing to do to load the library. */ 452 /* Nothing to do to load the library. */
457 wrap->ref_count++; 453 wrap->ref_count++;
458 return wrap->lib; 454 return wrap->lib;
459 } 455 }
460 456
461 /* Test if this library was loaded at some time, but got 457 /* Test if this library was loaded at some time, but got
462 unloaded meanwhile, whithout being dlclose()'ed. */ 458 unloaded meanwhile, whithout being dlclose()'ed. */
463 QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); 459 QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack);
464 for (; it.current(); ++it) { 460 for (; it.current(); ++it) {
465 if (it.current()->name == name) 461 if (it.current()->name == name)
466 wrap = it.current(); 462 wrap = it.current();
467 } 463 }
468 464
469 if (wrap) { 465 if (wrap) {
470 d->pending_close.removeRef(wrap); 466 d->pending_close.removeRef(wrap);
471 if (!wrap->lib) { 467 if (!wrap->lib) {
472 /* This lib only was in loaded_stack, but not in m_libs. */ 468 /* This lib only was in loaded_stack, but not in m_libs. */
473 wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); 469 wrap->lib = new KLibrary( name, wrap->filename, wrap->handle );
474 } 470 }
475 wrap->ref_count++; 471 wrap->ref_count++;
476 } else { 472 } else {
477 QString libfile = findLibrary( name ); 473 QString libfile = findLibrary( name );
478 if ( libfile.isEmpty() ) 474 if ( libfile.isEmpty() )
479 return 0; 475 return 0;
480 476#ifdef DESKTOP_VERSION
477 QLibrary *qlib = new QLibrary( libfile.latin1() );
478#else
481 QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); 479 QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately );
480#endif
482 481
483//US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); 482//US lt_dlhandle handle = lt_dlopen( libfile.latin1() );
484//US if ( !handle ) 483//US if ( !handle )
485 if ( !qlib ) 484 if ( !qlib )
486 { 485 {
487//US const char* errmsg = lt_dlerror(); 486//US const char* errmsg = lt_dlerror();
488 char* errmsg; 487 char* errmsg;
489 sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); 488 sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1());
490 qDebug(errmsg); 489 qDebug(errmsg);
491 490
492 if(errmsg) 491 if(errmsg)
493 d->errorMessage = QString::fromLatin1(errmsg); 492 d->errorMessage = QString::fromLatin1(errmsg);
494 else 493 else
495 d->errorMessage = QString::null; 494 d->errorMessage = QString::null;
496 kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl; 495 kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl;
497 return 0; 496 return 0;
498 } 497 }
499 else 498 else
500 d->errorMessage = QString::null; 499 d->errorMessage = QString::null;
501 500
502 KLibrary *lib = new KLibrary( name, libfile, qlib ); 501 KLibrary *lib = new KLibrary( name, libfile, qlib );
503 wrap = new KLibWrapPrivate(lib, qlib); 502 wrap = new KLibWrapPrivate(lib, qlib);
504 d->loaded_stack.prepend(wrap); 503 d->loaded_stack.prepend(wrap);
505 } 504 }
506 m_libs.insert( name, wrap ); 505 m_libs.insert( name, wrap );
507 506
508 connect( wrap->lib, SIGNAL( destroyed() ), 507 connect( wrap->lib, SIGNAL( destroyed() ),
509 this, SLOT( slotLibraryDestroyed() ) ); 508 this, SLOT( slotLibraryDestroyed() ) );
510 509
511 return wrap->lib; 510 return wrap->lib;
512} 511}
513 512
514QString KLibLoader::lastErrorMessage() const 513QString KLibLoader::lastErrorMessage() const
515{ 514{
516 return d->errorMessage; 515 return d->errorMessage;
517} 516}
518 517
519void KLibLoader::unloadLibrary( const char *libname ) 518void KLibLoader::unloadLibrary( const char *libname )
520{ 519{
521 KLibWrapPrivate *wrap = m_libs[ libname ]; 520 KLibWrapPrivate *wrap = m_libs[ libname ];
522 if (!wrap) 521 if (!wrap)
523 return; 522 return;
524 if (--wrap->ref_count) 523 if (--wrap->ref_count)
525 return; 524 return;
526 525
527// kdDebug(150) << "closing library " << libname << endl; 526// kdDebug(150) << "closing library " << libname << endl;
528 527
529 m_libs.remove( libname ); 528 m_libs.remove( libname );
530 529
531 disconnect( wrap->lib, SIGNAL( destroyed() ), 530 disconnect( wrap->lib, SIGNAL( destroyed() ),
532 this, SLOT( slotLibraryDestroyed() ) ); 531 this, SLOT( slotLibraryDestroyed() ) );
533 close_pending( wrap ); 532 close_pending( wrap );
534} 533}
535 534
536KLibFactory* KLibLoader::factory( const char* name ) 535KLibFactory* KLibLoader::factory( const char* name )
537{ 536{
538 KLibrary* lib = library( name ); 537 KLibrary* lib = library( name );
539 if ( !lib ) 538 if ( !lib )
540 return 0; 539 return 0;
541 540
542 return lib->factory(); 541 return lib->factory();
543} 542}
544 543
545void KLibLoader::slotLibraryDestroyed() 544void KLibLoader::slotLibraryDestroyed()
546{ 545{
547 const KLibrary *lib = static_cast<const KLibrary *>( sender() ); 546 const KLibrary *lib = static_cast<const KLibrary *>( sender() );
548 547
549 QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); 548 QAsciiDictIterator<KLibWrapPrivate> it( m_libs );
550 for (; it.current(); ++it ) 549 for (; it.current(); ++it )
551 if ( it.current()->lib == lib ) 550 if ( it.current()->lib == lib )
552 { 551 {
553 KLibWrapPrivate *wrap = it.current(); 552 KLibWrapPrivate *wrap = it.current();
554 wrap->lib = 0; /* the KLibrary object is already away */ 553 wrap->lib = 0; /* the KLibrary object is already away */
555 m_libs.remove( it.currentKey() ); 554 m_libs.remove( it.currentKey() );
556 close_pending( wrap ); 555 close_pending( wrap );
557 return; 556 return;
558 } 557 }
559} 558}
560 559
561void KLibLoader::close_pending(KLibWrapPrivate *wrap) 560void KLibLoader::close_pending(KLibWrapPrivate *wrap)
562{ 561{
563 if (wrap && !d->pending_close.containsRef( wrap )) 562 if (wrap && !d->pending_close.containsRef( wrap ))
564 d->pending_close.append( wrap ); 563 d->pending_close.append( wrap );
565 564
566 /* First delete all KLibrary objects in pending_close, but _don't_ unload 565 /* First delete all KLibrary objects in pending_close, but _don't_ unload
567 the DSO behind it. */ 566 the DSO behind it. */
568 QPtrListIterator<KLibWrapPrivate> it(d->pending_close); 567 QPtrListIterator<KLibWrapPrivate> it(d->pending_close);
569 for (; it.current(); ++it) { 568 for (; it.current(); ++it) {
570 wrap = it.current(); 569 wrap = it.current();
571 if (wrap->lib) { 570 if (wrap->lib) {
572 disconnect( wrap->lib, SIGNAL( destroyed() ), 571 disconnect( wrap->lib, SIGNAL( destroyed() ),
573 this, SLOT( slotLibraryDestroyed() ) ); 572 this, SLOT( slotLibraryDestroyed() ) );
574 delete wrap->lib; 573 delete wrap->lib;
575 wrap->lib = 0; 574 wrap->lib = 0;
576 } 575 }
577 } 576 }
578 577
579 if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return; 578 if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return;
580 579
581 bool deleted_one = false; 580 bool deleted_one = false;
582 while ((wrap = d->loaded_stack.first())) { 581 while ((wrap = d->loaded_stack.first())) {
583 /* Let's first see, if we want to try to unload this lib. 582 /* Let's first see, if we want to try to unload this lib.
584 If the env. var KDE_DOUNLOAD is set, we try to unload every lib. 583 If the env. var KDE_DOUNLOAD is set, we try to unload every lib.
585 If not, we look at the lib itself, and unload it only, if it exports 584 If not, we look at the lib itself, and unload it only, if it exports
586 the symbol __kde_do_unload. */ 585 the symbol __kde_do_unload. */
587 if (d->unload_mode != KLibLoaderPrivate::UNLOAD 586 if (d->unload_mode != KLibLoaderPrivate::UNLOAD
588 && wrap->unload_mode != KLibWrapPrivate::UNLOAD) 587 && wrap->unload_mode != KLibWrapPrivate::UNLOAD)
589 break; 588 break;
590 589
591 /* Now ensure, that the libs are only unloaded in the reverse direction 590 /* Now ensure, that the libs are only unloaded in the reverse direction
592 they were loaded. */ 591 they were loaded. */
593 if (!d->pending_close.containsRef( wrap )) { 592 if (!d->pending_close.containsRef( wrap )) {
594 if (!deleted_one) 593 if (!deleted_one)
595 /* Only diagnose, if we really haven't deleted anything. */ 594 /* Only diagnose, if we really haven't deleted anything. */
596// kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; 595// kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl;
597 break; 596 break;
598 } 597 }
599 598
600// kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; 599// kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl;
601 600
601#if 0
602#ifndef Q_WS_QWS 602#ifndef Q_WS_QWS
603 if ( !deleted_one ) { 603 if ( !deleted_one ) {
604 /* Only do the hack once in this loop. 604 /* Only do the hack once in this loop.
605 WABA: *HACK* 605 WABA: *HACK*
606 We need to make sure to clear the clipboard before unloading a DSO 606 We need to make sure to clear the clipboard before unloading a DSO
607 because the DSO could have defined an object derived from QMimeSource 607 because the DSO could have defined an object derived from QMimeSource
608 and placed that on the clipboard. */ 608 and placed that on the clipboard. */
609 /*kapp->clipboard()->clear();*/ 609 /*kapp->clipboard()->clear();*/
610 610
611 /* Well.. let's do something more subtle... convert the clipboard context 611 /* Well.. let's do something more subtle... convert the clipboard context
612 to text. That should be safe as it only uses objects defined by Qt. */ 612 to text. That should be safe as it only uses objects defined by Qt. */
613 613
614 QWidgetList *widgetlist = QApplication::topLevelWidgets(); 614 QWidgetList *widgetlist = QApplication::topLevelWidgets();
615 QWidget *co = widgetlist->first(); 615 QWidget *co = widgetlist->first();
616 while (co) { 616 while (co) {
617 if (qstrcmp(co->name(), "internal clipboard owner") == 0) { 617 if (qstrcmp(co->name(), "internal clipboard owner") == 0) {
618 if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId()) 618 if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId())
619 kapp->clipboard()->setText(kapp->clipboard()->text()); 619 kapp->clipboard()->setText(kapp->clipboard()->text());
620 620
621 break; 621 break;
622 } 622 }
623 co = widgetlist->next(); 623 co = widgetlist->next();
624 } 624 }
625 delete widgetlist; 625 delete widgetlist;
626 } 626 }
627#else 627#else
628 // FIXME(E): Implement in Qt Embedded 628 // FIXME(E): Implement in Qt Embedded
629#endif 629#endif
630 630
631#endif // 0
631 deleted_one = true; 632 deleted_one = true;
632//US lt_dlclose(wrap->handle); 633//US lt_dlclose(wrap->handle);
633 wrap->handle->unload(); 634 wrap->handle->unload();
634 635
635 d->pending_close.removeRef(wrap); 636 d->pending_close.removeRef(wrap);
636 /* loaded_stack is AutoDelete, so wrap is freed */ 637 /* loaded_stack is AutoDelete, so wrap is freed */
637 d->loaded_stack.remove(); 638 d->loaded_stack.remove();
638 } 639 }
639} 640}
640 641
641void KLibLoader::virtual_hook( int, void* ) 642void KLibLoader::virtual_hook( int, void* )
642{ /*BASE::virtual_hook( id, data );*/ } 643{ /*BASE::virtual_hook( id, data );*/ }
643 644
644void KLibFactory::virtual_hook( int, void* ) 645void KLibFactory::virtual_hook( int, void* )
645{ /*BASE::virtual_hook( id, data );*/ } 646{ /*BASE::virtual_hook( id, data );*/ }
646 647
647//US #include "klibloader.moc" 648//US #include "klibloader.moc"
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp
index 1a1e027..7f51d78 100644
--- a/microkde/kdecore/kstandarddirs.cpp
+++ b/microkde/kdecore/kstandarddirs.cpp
@@ -1,1625 +1,1624 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> 2 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org>
3 Copyright (C) 1999 Stephan Kulow <coolo@kde.org> 3 Copyright (C) 1999 Stephan Kulow <coolo@kde.org>
4 Copyright (C) 1999 Waldo Bastian <bastian@kde.org> 4 Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation. 8 License version 2 as published by the Free Software Foundation.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22 * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> 22 * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org>
23 * Version:$Id$ 23 * Version:$Id$
24 * Generated:Thu Mar 5 16:05:28 EST 1998 24 * Generated:Thu Mar 5 16:05:28 EST 1998
25 */ 25 */
26 26
27//US #include "config.h" 27//US #include "config.h"
28 28
29#include <stdlib.h> 29#include <stdlib.h>
30#include <assert.h> 30#include <assert.h>
31//US#include <errno.h> 31//US#include <errno.h>
32//US #ifdef HAVE_SYS_STAT_H 32//US #ifdef HAVE_SYS_STAT_H
33//US #include <sys/stat.h> 33//US #include <sys/stat.h>
34//US #endif 34//US #endif
35//US#include <sys/types.h> 35//US#include <sys/types.h>
36//US#include <dirent.h> 36//US#include <dirent.h>
37//US#include <pwd.h> 37//US#include <pwd.h>
38 38
39#include <qregexp.h> 39#include <qregexp.h>
40#include <qasciidict.h> 40#include <qasciidict.h>
41#include <qdict.h> 41#include <qdict.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qfileinfo.h> 43#include <qfileinfo.h>
44#include <qstring.h> 44#include <qstring.h>
45#include <qstringlist.h> 45#include <qstringlist.h>
46#include <qpe/qpeapplication.h>
47 46
48#include "kstandarddirs.h" 47#include "kstandarddirs.h"
49#include "kconfig.h" 48#include "kconfig.h"
50#include "kdebug.h" 49#include "kdebug.h"
51//US #include "kinstance.h" 50//US #include "kinstance.h"
52#include "kshell.h" 51#include "kshell.h"
53//US#include <sys/param.h> 52//US#include <sys/param.h>
54//US#include <unistd.h> 53//US#include <unistd.h>
55 54
56//US 55//US
57QString KStandardDirs::mAppDir = QString::null; 56QString KStandardDirs::mAppDir = QString::null;
58 57
59 58
60template class QDict<QStringList>; 59template class QDict<QStringList>;
61 60
62#if 0 61#if 0
63#include <qtextedit.h> 62#include <qtextedit.h>
64void ddd( QString op ) 63void ddd( QString op )
65{ 64{
66 static QTextEdit * dot = 0; 65 static QTextEdit * dot = 0;
67 if ( ! dot ) 66 if ( ! dot )
68 dot = new QTextEdit(); 67 dot = new QTextEdit();
69 68
70 dot->show(); 69 dot->show();
71 70
72 dot->append( op ); 71 dot->append( op );
73 72
74} 73}
75#endif 74#endif
76class KStandardDirs::KStandardDirsPrivate 75class KStandardDirs::KStandardDirsPrivate
77{ 76{
78public: 77public:
79 KStandardDirsPrivate() 78 KStandardDirsPrivate()
80 : restrictionsActive(false), 79 : restrictionsActive(false),
81 dataRestrictionActive(false) 80 dataRestrictionActive(false)
82 { } 81 { }
83 82
84 bool restrictionsActive; 83 bool restrictionsActive;
85 bool dataRestrictionActive; 84 bool dataRestrictionActive;
86 QAsciiDict<bool> restrictions; 85 QAsciiDict<bool> restrictions;
87 QStringList xdgdata_prefixes; 86 QStringList xdgdata_prefixes;
88 QStringList xdgconf_prefixes; 87 QStringList xdgconf_prefixes;
89}; 88};
90 89
91static const char* const types[] = {"html", "icon", "apps", "sound", 90static const char* const types[] = {"html", "icon", "apps", "sound",
92 "data", "locale", "services", "mime", 91 "data", "locale", "services", "mime",
93 "servicetypes", "config", "exe", 92 "servicetypes", "config", "exe",
94 "wallpaper", "lib", "pixmap", "templates", 93 "wallpaper", "lib", "pixmap", "templates",
95 "module", "qtplugins", 94 "module", "qtplugins",
96 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; 95 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 };
97 96
98static int tokenize( QStringList& token, const QString& str, 97static int tokenize( QStringList& token, const QString& str,
99 const QString& delim ); 98 const QString& delim );
100 99
101KStandardDirs::KStandardDirs( ) : addedCustoms(false) 100KStandardDirs::KStandardDirs( ) : addedCustoms(false)
102{ 101{
103 d = new KStandardDirsPrivate; 102 d = new KStandardDirsPrivate;
104 dircache.setAutoDelete(true); 103 dircache.setAutoDelete(true);
105 relatives.setAutoDelete(true); 104 relatives.setAutoDelete(true);
106 absolutes.setAutoDelete(true); 105 absolutes.setAutoDelete(true);
107 savelocations.setAutoDelete(true); 106 savelocations.setAutoDelete(true);
108 addKDEDefaults(); 107 addKDEDefaults();
109} 108}
110 109
111KStandardDirs::~KStandardDirs() 110KStandardDirs::~KStandardDirs()
112{ 111{
113 delete d; 112 delete d;
114} 113}
115 114
116bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const 115bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const
117{ 116{
118 if (!d || !d->restrictionsActive) 117 if (!d || !d->restrictionsActive)
119 return false; 118 return false;
120 119
121 if (d->restrictions[type]) 120 if (d->restrictions[type])
122 return true; 121 return true;
123 122
124 if (strcmp(type, "data")==0) 123 if (strcmp(type, "data")==0)
125 { 124 {
126 applyDataRestrictions(relPath); 125 applyDataRestrictions(relPath);
127 if (d->dataRestrictionActive) 126 if (d->dataRestrictionActive)
128 { 127 {
129 d->dataRestrictionActive = false; 128 d->dataRestrictionActive = false;
130 return true; 129 return true;
131 } 130 }
132 } 131 }
133 return false; 132 return false;
134} 133}
135 134
136void KStandardDirs::applyDataRestrictions(const QString &relPath) const 135void KStandardDirs::applyDataRestrictions(const QString &relPath) const
137{ 136{
138 QString key; 137 QString key;
139 int i = relPath.find('/'); 138 int i = relPath.find('/');
140 if (i != -1) 139 if (i != -1)
141 key = "data_"+relPath.left(i); 140 key = "data_"+relPath.left(i);
142 else 141 else
143 key = "data_"+relPath; 142 key = "data_"+relPath;
144 143
145 if (d && d->restrictions[key.latin1()]) 144 if (d && d->restrictions[key.latin1()])
146 d->dataRestrictionActive = true; 145 d->dataRestrictionActive = true;
147} 146}
148 147
149 148
150QStringList KStandardDirs::allTypes() const 149QStringList KStandardDirs::allTypes() const
151{ 150{
152 QStringList list; 151 QStringList list;
153 for (int i = 0; types[i] != 0; ++i) 152 for (int i = 0; types[i] != 0; ++i)
154 list.append(QString::fromLatin1(types[i])); 153 list.append(QString::fromLatin1(types[i]));
155 return list; 154 return list;
156} 155}
157 156
158void KStandardDirs::addPrefix( const QString& _dir ) 157void KStandardDirs::addPrefix( const QString& _dir )
159{ 158{
160 if (_dir.isNull()) 159 if (_dir.isNull())
161 return; 160 return;
162 161
163 QString dir = _dir; 162 QString dir = _dir;
164 if (dir.at(dir.length() - 1) != '/') 163 if (dir.at(dir.length() - 1) != '/')
165 dir += '/'; 164 dir += '/';
166 165
167 if (!prefixes.contains(dir)) { 166 if (!prefixes.contains(dir)) {
168 prefixes.append(dir); 167 prefixes.append(dir);
169 dircache.clear(); 168 dircache.clear();
170 } 169 }
171} 170}
172 171
173void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) 172void KStandardDirs::addXdgConfigPrefix( const QString& _dir )
174{ 173{
175 if (_dir.isNull()) 174 if (_dir.isNull())
176 return; 175 return;
177 176
178 QString dir = _dir; 177 QString dir = _dir;
179 if (dir.at(dir.length() - 1) != '/') 178 if (dir.at(dir.length() - 1) != '/')
180 dir += '/'; 179 dir += '/';
181 180
182 if (!d->xdgconf_prefixes.contains(dir)) { 181 if (!d->xdgconf_prefixes.contains(dir)) {
183 d->xdgconf_prefixes.append(dir); 182 d->xdgconf_prefixes.append(dir);
184 dircache.clear(); 183 dircache.clear();
185 } 184 }
186} 185}
187 186
188void KStandardDirs::addXdgDataPrefix( const QString& _dir ) 187void KStandardDirs::addXdgDataPrefix( const QString& _dir )
189{ 188{
190 if (_dir.isNull()) 189 if (_dir.isNull())
191 return; 190 return;
192 191
193 QString dir = _dir; 192 QString dir = _dir;
194 if (dir.at(dir.length() - 1) != '/') 193 if (dir.at(dir.length() - 1) != '/')
195 dir += '/'; 194 dir += '/';
196 195
197 if (!d->xdgdata_prefixes.contains(dir)) { 196 if (!d->xdgdata_prefixes.contains(dir)) {
198 d->xdgdata_prefixes.append(dir); 197 d->xdgdata_prefixes.append(dir);
199 dircache.clear(); 198 dircache.clear();
200 } 199 }
201} 200}
202 201
203 202
204QString KStandardDirs::kfsstnd_prefixes() 203QString KStandardDirs::kfsstnd_prefixes()
205{ 204{
206 return prefixes.join(":"); 205 return prefixes.join(":");
207} 206}
208 207
209bool KStandardDirs::addResourceType( const char *type, 208bool KStandardDirs::addResourceType( const char *type,
210 const QString& relativename ) 209 const QString& relativename )
211{ 210{
212 if (relativename.isNull()) 211 if (relativename.isNull())
213 return false; 212 return false;
214 213
215 QStringList *rels = relatives.find(type); 214 QStringList *rels = relatives.find(type);
216 if (!rels) { 215 if (!rels) {
217 rels = new QStringList(); 216 rels = new QStringList();
218 relatives.insert(type, rels); 217 relatives.insert(type, rels);
219 } 218 }
220 QString copy = relativename; 219 QString copy = relativename;
221 if (copy.at(copy.length() - 1) != '/') 220 if (copy.at(copy.length() - 1) != '/')
222 copy += '/'; 221 copy += '/';
223 if (!rels->contains(copy)) { 222 if (!rels->contains(copy)) {
224 rels->prepend(copy); 223 rels->prepend(copy);
225 dircache.remove(type); // clean the cache 224 dircache.remove(type); // clean the cache
226 return true; 225 return true;
227 } 226 }
228 return false; 227 return false;
229} 228}
230 229
231bool KStandardDirs::addResourceDir( const char *type, 230bool KStandardDirs::addResourceDir( const char *type,
232 const QString& absdir) 231 const QString& absdir)
233{ 232{
234 QStringList *paths = absolutes.find(type); 233 QStringList *paths = absolutes.find(type);
235 if (!paths) { 234 if (!paths) {
236 paths = new QStringList(); 235 paths = new QStringList();
237 absolutes.insert(type, paths); 236 absolutes.insert(type, paths);
238 } 237 }
239 QString copy = absdir; 238 QString copy = absdir;
240 if (copy.at(copy.length() - 1) != '/') 239 if (copy.at(copy.length() - 1) != '/')
241 copy += '/'; 240 copy += '/';
242 241
243 if (!paths->contains(copy)) { 242 if (!paths->contains(copy)) {
244 paths->append(copy); 243 paths->append(copy);
245 dircache.remove(type); // clean the cache 244 dircache.remove(type); // clean the cache
246 return true; 245 return true;
247 } 246 }
248 return false; 247 return false;
249} 248}
250 249
251QString KStandardDirs::findResource( const char *type, 250QString KStandardDirs::findResource( const char *type,
252 const QString& filename ) const 251 const QString& filename ) const
253{ 252{
254 if (filename.at(0) == '/') 253 if (filename.at(0) == '/')
255 return filename; // absolute dirs are absolute dirs, right? :-/ 254 return filename; // absolute dirs are absolute dirs, right? :-/
256 255
257#if 0 256#if 0
258kdDebug() << "Find resource: " << type << endl; 257kdDebug() << "Find resource: " << type << endl;
259for (QStringList::ConstIterator pit = prefixes.begin(); 258for (QStringList::ConstIterator pit = prefixes.begin();
260 pit != prefixes.end(); 259 pit != prefixes.end();
261 pit++) 260 pit++)
262{ 261{
263 kdDebug() << "Prefix: " << *pit << endl; 262 kdDebug() << "Prefix: " << *pit << endl;
264} 263}
265#endif 264#endif
266 265
267 QString dir = findResourceDir(type, filename); 266 QString dir = findResourceDir(type, filename);
268 if (dir.isNull()) 267 if (dir.isNull())
269 return dir; 268 return dir;
270 else return dir + filename; 269 else return dir + filename;
271} 270}
272/*US 271/*US
273static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) 272static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash)
274{ 273{
275 QCString cFile = QFile::encodeName(file); 274 QCString cFile = QFile::encodeName(file);
276//US struct stat buff; 275//US struct stat buff;
277//US if ((access(cFile, R_OK) == 0) && 276//US if ((access(cFile, R_OK) == 0) &&
278//US (stat( cFile, &buff ) == 0) && 277//US (stat( cFile, &buff ) == 0) &&
279//US (S_ISREG( buff.st_mode ))) 278//US (S_ISREG( buff.st_mode )))
280 QFileInfo pathfnInfo(cFile); 279 QFileInfo pathfnInfo(cFile);
281 if (( pathfnInfo.isReadable() == true ) && 280 if (( pathfnInfo.isReadable() == true ) &&
282 ( pathfnInfo.isFile()) ) 281 ( pathfnInfo.isFile()) )
283 { 282 {
284//US hash = hash + (Q_UINT32) buff.st_ctime; 283//US hash = hash + (Q_UINT32) buff.st_ctime;
285 hash = hash + (Q_UINT32) pathfnInfo.lastModified(); 284 hash = hash + (Q_UINT32) pathfnInfo.lastModified();
286 } 285 }
287 return hash; 286 return hash;
288} 287}
289*/ 288*/
290/*US 289/*US
291Q_UINT32 KStandardDirs::calcResourceHash( const char *type, 290Q_UINT32 KStandardDirs::calcResourceHash( const char *type,
292 const QString& filename, bool deep) const 291 const QString& filename, bool deep) const
293{ 292{
294 Q_UINT32 hash = 0; 293 Q_UINT32 hash = 0;
295 294
296 if (filename.at(0) == '/') 295 if (filename.at(0) == '/')
297 { 296 {
298 // absolute dirs are absolute dirs, right? :-/ 297 // absolute dirs are absolute dirs, right? :-/
299 return updateHash(filename, hash); 298 return updateHash(filename, hash);
300 } 299 }
301 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 300 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
302 applyDataRestrictions(filename); 301 applyDataRestrictions(filename);
303 QStringList candidates = resourceDirs(type); 302 QStringList candidates = resourceDirs(type);
304 QString fullPath; 303 QString fullPath;
305 304
306 for (QStringList::ConstIterator it = candidates.begin(); 305 for (QStringList::ConstIterator it = candidates.begin();
307 it != candidates.end(); it++) 306 it != candidates.end(); it++)
308 { 307 {
309 hash = updateHash(*it + filename, hash); 308 hash = updateHash(*it + filename, hash);
310 if (!deep && hash) 309 if (!deep && hash)
311 return hash; 310 return hash;
312 } 311 }
313 return hash; 312 return hash;
314} 313}
315*/ 314*/
316 315
317QStringList KStandardDirs::findDirs( const char *type, 316QStringList KStandardDirs::findDirs( const char *type,
318 const QString& reldir ) const 317 const QString& reldir ) const
319{ 318{
320 QStringList list; 319 QStringList list;
321 320
322 checkConfig(); 321 checkConfig();
323 322
324 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 323 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
325 applyDataRestrictions(reldir); 324 applyDataRestrictions(reldir);
326 QStringList candidates = resourceDirs(type); 325 QStringList candidates = resourceDirs(type);
327 QDir testdir; 326 QDir testdir;
328 327
329 for (QStringList::ConstIterator it = candidates.begin(); 328 for (QStringList::ConstIterator it = candidates.begin();
330 it != candidates.end(); it++) { 329 it != candidates.end(); it++) {
331 testdir.setPath(*it + reldir); 330 testdir.setPath(*it + reldir);
332 if (testdir.exists()) 331 if (testdir.exists())
333 list.append(testdir.absPath() + '/'); 332 list.append(testdir.absPath() + '/');
334 } 333 }
335 334
336 return list; 335 return list;
337} 336}
338 337
339QString KStandardDirs::findResourceDir( const char *type, 338QString KStandardDirs::findResourceDir( const char *type,
340 const QString& filename) const 339 const QString& filename) const
341{ 340{
342#ifndef NDEBUG 341#ifndef NDEBUG
343 if (filename.isEmpty()) { 342 if (filename.isEmpty()) {
344 kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl; 343 kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl;
345 return QString::null; 344 return QString::null;
346 } 345 }
347#endif 346#endif
348 347
349 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 348 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
350 applyDataRestrictions(filename); 349 applyDataRestrictions(filename);
351 QStringList candidates = resourceDirs(type); 350 QStringList candidates = resourceDirs(type);
352 QString fullPath; 351 QString fullPath;
353 352
354 for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) 353 for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++)
355 { 354 {
356 if (exists(*it + filename)) 355 if (exists(*it + filename))
357 return *it; 356 return *it;
358 } 357 }
359 358
360#ifndef NDEBUG 359#ifndef NDEBUG
361 if(false && type != "locale") 360 if(false && type != "locale")
362 kdDebug() << "KStdDirs::findResDir(): can't find \"" << filename << "\" in type \"" << type << "\"." << endl; 361 kdDebug() << "KStdDirs::findResDir(): can't find \"" << filename << "\" in type \"" << type << "\"." << endl;
363#endif 362#endif
364 363
365 return QString::null; 364 return QString::null;
366} 365}
367 366
368bool KStandardDirs::exists(const QString &fullPath) 367bool KStandardDirs::exists(const QString &fullPath)
369{ 368{
370//US struct stat buff; 369//US struct stat buff;
371 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 370 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
372 371
373//US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) 372//US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable())
374 if (fullPathInfo.isReadable()) 373 if (fullPathInfo.isReadable())
375 { 374 {
376 if (fullPath.at(fullPath.length() - 1) != '/') { 375 if (fullPath.at(fullPath.length() - 1) != '/') {
377 //US if (S_ISREG( buff.st_mode )) 376 //US if (S_ISREG( buff.st_mode ))
378 if (fullPathInfo.isFile()) 377 if (fullPathInfo.isFile())
379 return true; 378 return true;
380 } 379 }
381 else { 380 else {
382 //US if (S_ISDIR( buff.st_mode )) 381 //US if (S_ISDIR( buff.st_mode ))
383 if (fullPathInfo.isDir()) 382 if (fullPathInfo.isDir())
384 return true; 383 return true;
385 } 384 }
386 } 385 }
387 return false; 386 return false;
388} 387}
389 388
390static void lookupDirectory(const QString& path, const QString &relPart, 389static void lookupDirectory(const QString& path, const QString &relPart,
391 const QRegExp &regexp, 390 const QRegExp &regexp,
392 QStringList& list, 391 QStringList& list,
393 QStringList& relList, 392 QStringList& relList,
394 bool recursive, bool uniq) 393 bool recursive, bool uniq)
395{ 394{
396 QString pattern = regexp.pattern(); 395 QString pattern = regexp.pattern();
397 if (recursive || pattern.contains('?') || pattern.contains('*')) 396 if (recursive || pattern.contains('?') || pattern.contains('*'))
398 { 397 {
399 // We look for a set of files. 398 // We look for a set of files.
400//US DIR *dp = opendir( QFile::encodeName(path)); 399//US DIR *dp = opendir( QFile::encodeName(path));
401 QDir dp(QFile::encodeName(path)); 400 QDir dp(QFile::encodeName(path));
402 401
403 if (!dp.exists()) 402 if (!dp.exists())
404 return; 403 return;
405 static int iii = 0; 404 static int iii = 0;
406 ++iii; 405 ++iii;
407 if ( iii == 5 ) 406 if ( iii == 5 )
408 abort(); 407 abort();
409 assert(path.at(path.length() - 1) == '/'); 408 assert(path.at(path.length() - 1) == '/');
410 409
411//US struct dirent *ep; 410//US struct dirent *ep;
412//US struct stat buff; 411//US struct stat buff;
413 412
414 QString _dot("."); 413 QString _dot(".");
415 QString _dotdot(".."); 414 QString _dotdot("..");
416 415
417//US while( ( ep = readdir( dp ) ) != 0L ) 416//US while( ( ep = readdir( dp ) ) != 0L )
418 QStringList direntries = dp.entryList(); 417 QStringList direntries = dp.entryList();
419 QStringList::Iterator it = direntries.begin(); 418 QStringList::Iterator it = direntries.begin();
420 419
421 while ( it != list.end() ) // for each file... 420 while ( it != list.end() ) // for each file...
422 { 421 {
423 422
424//US QString fn( QFile::decodeName(ep->d_name)); 423//US QString fn( QFile::decodeName(ep->d_name));
425 QString fn = (*it); // dp.entryList already decodes 424 QString fn = (*it); // dp.entryList already decodes
426 it++; 425 it++;
427 if ( fn.isNull() ) 426 if ( fn.isNull() )
428 break; 427 break;
429 428
430 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) 429 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' )
431 continue; 430 continue;
432 431
433/*US 432/*US
434 if (!recursive && !regexp.exactMatch(fn)) 433 if (!recursive && !regexp.exactMatch(fn))
435 continue; // No match 434 continue; // No match
436*/ 435*/
437//US this should do the same: 436//US this should do the same:
438 int pos = regexp.match(fn); 437 int pos = regexp.match(fn);
439 if (!recursive && !pos == 0) 438 if (!recursive && !pos == 0)
440 continue; // No match 439 continue; // No match
441 440
442 QString pathfn = path + fn; 441 QString pathfn = path + fn;
443/*US 442/*US
444 if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { 443 if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) {
445 kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; 444 kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl;
446 continue; // Couldn't stat (e.g. no read permissions) 445 continue; // Couldn't stat (e.g. no read permissions)
447 } 446 }
448 447
449 if ( recursive ) 448 if ( recursive )
450 { 449 {
451 if ( S_ISDIR( buff.st_mode )) { 450 if ( S_ISDIR( buff.st_mode )) {
452 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); 451 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq);
453 } 452 }
454*/ 453*/
455//US replacement: 454//US replacement:
456 QFileInfo pathfnInfo(QFile::encodeName(pathfn)); 455 QFileInfo pathfnInfo(QFile::encodeName(pathfn));
457 if ( pathfnInfo.isReadable() == false ) 456 if ( pathfnInfo.isReadable() == false )
458 { 457 {
459//US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; 458//US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl;
460 continue; // Couldn't stat (e.g. no read permissions) 459 continue; // Couldn't stat (e.g. no read permissions)
461 } 460 }
462 461
463 if ( recursive ) 462 if ( recursive )
464 { 463 {
465 if ( pathfnInfo.isDir()) { 464 if ( pathfnInfo.isDir()) {
466 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); 465 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq);
467 } 466 }
468 467
469 468
470/*US 469/*US
471 if (!regexp.exactMatch(fn)) 470 if (!regexp.exactMatch(fn))
472 continue; // No match 471 continue; // No match
473*/ 472*/
474//US this should do the same: 473//US this should do the same:
475 pos = regexp.match(fn); 474 pos = regexp.match(fn);
476 if (!pos == 0) 475 if (!pos == 0)
477 continue; // No match 476 continue; // No match
478 } 477 }
479 478
480//US if ( S_ISREG( buff.st_mode)) 479//US if ( S_ISREG( buff.st_mode))
481 if ( pathfnInfo.isFile()) 480 if ( pathfnInfo.isFile())
482 { 481 {
483 if (!uniq || !relList.contains(relPart + fn)) 482 if (!uniq || !relList.contains(relPart + fn))
484 { 483 {
485 list.append( pathfn ); 484 list.append( pathfn );
486 relList.append( relPart + fn ); 485 relList.append( relPart + fn );
487 } 486 }
488 } 487 }
489 } 488 }
490//US closedir( dp ); 489//US closedir( dp );
491 } 490 }
492 else 491 else
493 { 492 {
494 // We look for a single file. 493 // We look for a single file.
495 QString fn = pattern; 494 QString fn = pattern;
496 QString pathfn = path + fn; 495 QString pathfn = path + fn;
497//US struct stat buff; 496//US struct stat buff;
498 QFileInfo pathfnInfo(QFile::encodeName(pathfn)); 497 QFileInfo pathfnInfo(QFile::encodeName(pathfn));
499 498
500 499
501//US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) 500//US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 )
502 if ( pathfnInfo.isReadable() == false ) 501 if ( pathfnInfo.isReadable() == false )
503 return; // File not found 502 return; // File not found
504 503
505//US if ( S_ISREG( buff.st_mode)) 504//US if ( S_ISREG( buff.st_mode))
506 if ( pathfnInfo.isFile()) 505 if ( pathfnInfo.isFile())
507 { 506 {
508 if (!uniq || !relList.contains(relPart + fn)) 507 if (!uniq || !relList.contains(relPart + fn))
509 { 508 {
510 list.append( pathfn ); 509 list.append( pathfn );
511 relList.append( relPart + fn ); 510 relList.append( relPart + fn );
512 } 511 }
513 } 512 }
514 } 513 }
515} 514}
516 515
517static void lookupPrefix(const QString& prefix, const QString& relpath, 516static void lookupPrefix(const QString& prefix, const QString& relpath,
518 const QString& relPart, 517 const QString& relPart,
519 const QRegExp &regexp, 518 const QRegExp &regexp,
520 QStringList& list, 519 QStringList& list,
521 QStringList& relList, 520 QStringList& relList,
522 bool recursive, bool uniq) 521 bool recursive, bool uniq)
523{ 522{
524 if (relpath.isNull()) { 523 if (relpath.isNull()) {
525 lookupDirectory(prefix, relPart, regexp, list, 524 lookupDirectory(prefix, relPart, regexp, list,
526 relList, recursive, uniq); 525 relList, recursive, uniq);
527 return; 526 return;
528 } 527 }
529 QString path; 528 QString path;
530 QString rest; 529 QString rest;
531 530
532 if (relpath.length()) 531 if (relpath.length())
533 { 532 {
534 int slash = relpath.find('/'); 533 int slash = relpath.find('/');
535 if (slash < 0) 534 if (slash < 0)
536 rest = relpath.left(relpath.length() - 1); 535 rest = relpath.left(relpath.length() - 1);
537 else { 536 else {
538 path = relpath.left(slash); 537 path = relpath.left(slash);
539 rest = relpath.mid(slash + 1); 538 rest = relpath.mid(slash + 1);
540 } 539 }
541 } 540 }
542 assert(prefix.at(prefix.length() - 1) == '/'); 541 assert(prefix.at(prefix.length() - 1) == '/');
543 542
544//US struct stat buff; 543//US struct stat buff;
545 544
546 if (path.contains('*') || path.contains('?')) { 545 if (path.contains('*') || path.contains('?')) {
547 QRegExp pathExp(path, true, true); 546 QRegExp pathExp(path, true, true);
548 //USDIR *dp = opendir( QFile::encodeName(prefix) ); 547 //USDIR *dp = opendir( QFile::encodeName(prefix) );
549 QDir dp(QFile::encodeName(prefix)); 548 QDir dp(QFile::encodeName(prefix));
550 549
551 //USif (!dp) 550 //USif (!dp)
552 if (!dp.exists()) 551 if (!dp.exists())
553 { 552 {
554 return; 553 return;
555 } 554 }
556 555
557 //USstruct dirent *ep; 556 //USstruct dirent *ep;
558 557
559 QString _dot("."); 558 QString _dot(".");
560 QString _dotdot(".."); 559 QString _dotdot("..");
561 560
562 //USwhile( ( ep = readdir( dp ) ) != 0L ) 561 //USwhile( ( ep = readdir( dp ) ) != 0L )
563 QStringList direntries = dp.entryList(); 562 QStringList direntries = dp.entryList();
564 QStringList::Iterator it = direntries.begin(); 563 QStringList::Iterator it = direntries.begin();
565 564
566 while ( it != list.end() ) // for each file... 565 while ( it != list.end() ) // for each file...
567 { 566 {
568//US QString fn( QFile::decodeName(ep->d_name)); 567//US QString fn( QFile::decodeName(ep->d_name));
569 QString fn = (*it); // dp.entryList() already encodes the strings 568 QString fn = (*it); // dp.entryList() already encodes the strings
570 it++; 569 it++;
571 570
572 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~') 571 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~')
573 continue; 572 continue;
574 573
575#ifdef DESKTOP_VERSION 574#ifdef DESKTOP_VERSION
576 575
577 if (pathExp.search(fn) == -1) 576 if (pathExp.search(fn) == -1)
578 continue; // No match 577 continue; // No match
579 578
580#else 579#else
581//US this should do the same: 580//US this should do the same:
582 if (pathExp.find(fn, 0) == -1) 581 if (pathExp.find(fn, 0) == -1)
583 continue; // No match 582 continue; // No match
584#endif 583#endif
585 QString rfn = relPart+fn; 584 QString rfn = relPart+fn;
586 fn = prefix + fn; 585 fn = prefix + fn;
587//US if ( stat( QFile::encodeName(fn), &buff ) != 0 ) 586//US if ( stat( QFile::encodeName(fn), &buff ) != 0 )
588 QFileInfo fnInfo(QFile::encodeName(fn)); 587 QFileInfo fnInfo(QFile::encodeName(fn));
589 if ( fnInfo.isReadable() == false ) 588 if ( fnInfo.isReadable() == false )
590 { 589 {
591//US kdDebug() << "Error statting " << fn << " : " << perror << endl; 590//US kdDebug() << "Error statting " << fn << " : " << perror << endl;
592 continue; // Couldn't stat (e.g. no permissions) 591 continue; // Couldn't stat (e.g. no permissions)
593 } 592 }
594 //US if ( S_ISDIR( buff.st_mode )) 593 //US if ( S_ISDIR( buff.st_mode ))
595 if ( fnInfo.isDir() ) 594 if ( fnInfo.isDir() )
596 595
597 lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq); 596 lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq);
598 } 597 }
599 598
600 //USclosedir( dp ); 599 //USclosedir( dp );
601 } else { 600 } else {
602 // Don't stat, if the dir doesn't exist we will find out 601 // Don't stat, if the dir doesn't exist we will find out
603 // when we try to open it. 602 // when we try to open it.
604 lookupPrefix(prefix + path + '/', rest, 603 lookupPrefix(prefix + path + '/', rest,
605 relPart + path + '/', regexp, list, 604 relPart + path + '/', regexp, list,
606 relList, recursive, uniq); 605 relList, recursive, uniq);
607 } 606 }
608} 607}
609 608
610QStringList 609QStringList
611KStandardDirs::findAllResources( const char *type, 610KStandardDirs::findAllResources( const char *type,
612 const QString& filter, 611 const QString& filter,
613 bool recursive, 612 bool recursive,
614 bool uniq, 613 bool uniq,
615 QStringList &relList) const 614 QStringList &relList) const
616{ 615{
617 QStringList list; 616 QStringList list;
618 if (filter.at(0) == '/') // absolute paths we return 617 if (filter.at(0) == '/') // absolute paths we return
619 { 618 {
620 list.append( filter); 619 list.append( filter);
621 return list; 620 return list;
622 } 621 }
623 622
624 QString filterPath; 623 QString filterPath;
625 QString filterFile; 624 QString filterFile;
626 625
627 if (filter.length()) 626 if (filter.length())
628 { 627 {
629 int slash = filter.findRev('/'); 628 int slash = filter.findRev('/');
630 if (slash < 0) 629 if (slash < 0)
631 filterFile = filter; 630 filterFile = filter;
632 else { 631 else {
633 filterPath = filter.left(slash + 1); 632 filterPath = filter.left(slash + 1);
634 filterFile = filter.mid(slash + 1); 633 filterFile = filter.mid(slash + 1);
635 } 634 }
636 } 635 }
637 checkConfig(); 636 checkConfig();
638 637
639 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 638 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
640 applyDataRestrictions(filter); 639 applyDataRestrictions(filter);
641 QStringList candidates = resourceDirs(type); 640 QStringList candidates = resourceDirs(type);
642 if (filterFile.isEmpty()) 641 if (filterFile.isEmpty())
643 filterFile = "*"; 642 filterFile = "*";
644 643
645 QRegExp regExp(filterFile, true, true); 644 QRegExp regExp(filterFile, true, true);
646 for (QStringList::ConstIterator it = candidates.begin(); 645 for (QStringList::ConstIterator it = candidates.begin();
647 it != candidates.end(); it++) 646 it != candidates.end(); it++)
648 { 647 {
649 lookupPrefix(*it, filterPath, "", regExp, list, 648 lookupPrefix(*it, filterPath, "", regExp, list,
650 relList, recursive, uniq); 649 relList, recursive, uniq);
651 } 650 }
652 return list; 651 return list;
653} 652}
654 653
655QStringList 654QStringList
656KStandardDirs::findAllResources( const char *type, 655KStandardDirs::findAllResources( const char *type,
657 const QString& filter, 656 const QString& filter,
658 bool recursive, 657 bool recursive,
659 bool uniq) const 658 bool uniq) const
660{ 659{
661 QStringList relList; 660 QStringList relList;
662 return findAllResources(type, filter, recursive, uniq, relList); 661 return findAllResources(type, filter, recursive, uniq, relList);
663} 662}
664 663
665QString 664QString
666KStandardDirs::realPath(const QString &dirname) 665KStandardDirs::realPath(const QString &dirname)
667{ 666{
668#ifdef _WIN32_ 667#ifdef _WIN32_
669 return dirname; 668 return dirname;
670#else 669#else
671//US char realpath_buffer[MAXPATHLEN + 1]; 670//US char realpath_buffer[MAXPATHLEN + 1];
672//US memset(realpath_buffer, 0, MAXPATHLEN + 1); 671//US memset(realpath_buffer, 0, MAXPATHLEN + 1);
673 char realpath_buffer[250 + 1]; 672 char realpath_buffer[250 + 1];
674 memset(realpath_buffer, 0, 250 + 1); 673 memset(realpath_buffer, 0, 250 + 1);
675 674
676 /* If the path contains symlinks, get the real name */ 675 /* If the path contains symlinks, get the real name */
677 if (realpath( QFile::encodeName(dirname).data(), realpath_buffer) != 0) { 676 if (realpath( QFile::encodeName(dirname).data(), realpath_buffer) != 0) {
678 // succes, use result from realpath 677 // succes, use result from realpath
679 int len = strlen(realpath_buffer); 678 int len = strlen(realpath_buffer);
680 realpath_buffer[len] = '/'; 679 realpath_buffer[len] = '/';
681 realpath_buffer[len+1] = 0; 680 realpath_buffer[len+1] = 0;
682 return QFile::decodeName(realpath_buffer); 681 return QFile::decodeName(realpath_buffer);
683 } 682 }
684 683
685 return dirname; 684 return dirname;
686#endif 685#endif
687} 686}
688/*US 687/*US
689void KStandardDirs::createSpecialResource(const char *type) 688void KStandardDirs::createSpecialResource(const char *type)
690{ 689{
691 char hostname[256]; 690 char hostname[256];
692 hostname[0] = 0; 691 hostname[0] = 0;
693 gethostname(hostname, 255); 692 gethostname(hostname, 255);
694 QString dir = QString("%1%2-%3").arg(localkdedir()).arg(type).arg(hostname); 693 QString dir = QString("%1%2-%3").arg(localkdedir()).arg(type).arg(hostname);
695 char link[1024]; 694 char link[1024];
696 link[1023] = 0; 695 link[1023] = 0;
697 int result = readlink(QFile::encodeName(dir).data(), link, 1023); 696 int result = readlink(QFile::encodeName(dir).data(), link, 1023);
698 if ((result == -1) && (errno == ENOENT)) 697 if ((result == -1) && (errno == ENOENT))
699 { 698 {
700 QString srv = findExe(QString::fromLatin1("lnusertemp"), KDEDIR+QString::fromLatin1("/bin")); 699 QString srv = findExe(QString::fromLatin1("lnusertemp"), KDEDIR+QString::fromLatin1("/bin"));
701 if (srv.isEmpty()) 700 if (srv.isEmpty())
702 srv = findExe(QString::fromLatin1("lnusertemp")); 701 srv = findExe(QString::fromLatin1("lnusertemp"));
703 if (!srv.isEmpty()) 702 if (!srv.isEmpty())
704 { 703 {
705 system(QFile::encodeName(srv)+" "+type); 704 system(QFile::encodeName(srv)+" "+type);
706 result = readlink(QFile::encodeName(dir).data(), link, 1023); 705 result = readlink(QFile::encodeName(dir).data(), link, 1023);
707 } 706 }
708 } 707 }
709 if (result > 0) 708 if (result > 0)
710 { 709 {
711 link[result] = 0; 710 link[result] = 0;
712 if (link[0] == '/') 711 if (link[0] == '/')
713 dir = QFile::decodeName(link); 712 dir = QFile::decodeName(link);
714 else 713 else
715 dir = QDir::cleanDirPath(dir+QFile::decodeName(link)); 714 dir = QDir::cleanDirPath(dir+QFile::decodeName(link));
716 } 715 }
717 addResourceDir(type, dir+'/'); 716 addResourceDir(type, dir+'/');
718} 717}
719*/ 718*/
720 719
721QStringList KStandardDirs::resourceDirs(const char *type) const 720QStringList KStandardDirs::resourceDirs(const char *type) const
722{ 721{
723 QStringList *candidates = dircache.find(type); 722 QStringList *candidates = dircache.find(type);
724 723
725 if (!candidates) { // filling cache 724 if (!candidates) { // filling cache
726/*US 725/*US
727 if (strcmp(type, "socket") == 0) 726 if (strcmp(type, "socket") == 0)
728 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 727 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
729 else if (strcmp(type, "tmp") == 0) 728 else if (strcmp(type, "tmp") == 0)
730 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 729 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
731 else if (strcmp(type, "cache") == 0) 730 else if (strcmp(type, "cache") == 0)
732 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 731 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
733*/ 732*/
734 QDir testdir; 733 QDir testdir;
735 734
736 candidates = new QStringList(); 735 candidates = new QStringList();
737 QStringList *dirs; 736 QStringList *dirs;
738 737
739 bool restrictionActive = false; 738 bool restrictionActive = false;
740 if (d && d->restrictionsActive) 739 if (d && d->restrictionsActive)
741 { 740 {
742 if (d->dataRestrictionActive) 741 if (d->dataRestrictionActive)
743 restrictionActive = true; 742 restrictionActive = true;
744 else if (d->restrictions["all"]) 743 else if (d->restrictions["all"])
745 restrictionActive = true; 744 restrictionActive = true;
746 else if (d->restrictions[type]) 745 else if (d->restrictions[type])
747 restrictionActive = true; 746 restrictionActive = true;
748 d->dataRestrictionActive = false; // Reset 747 d->dataRestrictionActive = false; // Reset
749 } 748 }
750 749
751 dirs = relatives.find(type); 750 dirs = relatives.find(type);
752 if (dirs) 751 if (dirs)
753 { 752 {
754 bool local = true; 753 bool local = true;
755 const QStringList *prefixList = 0; 754 const QStringList *prefixList = 0;
756 if (strncmp(type, "xdgdata-", 8) == 0) 755 if (strncmp(type, "xdgdata-", 8) == 0)
757 prefixList = &(d->xdgdata_prefixes); 756 prefixList = &(d->xdgdata_prefixes);
758 else if (strncmp(type, "xdgconf-", 8) == 0) 757 else if (strncmp(type, "xdgconf-", 8) == 0)
759 prefixList = &(d->xdgconf_prefixes); 758 prefixList = &(d->xdgconf_prefixes);
760 else 759 else
761 prefixList = &prefixes; 760 prefixList = &prefixes;
762 761
763 for (QStringList::ConstIterator pit = prefixList->begin(); 762 for (QStringList::ConstIterator pit = prefixList->begin();
764 pit != prefixList->end(); 763 pit != prefixList->end();
765 pit++) 764 pit++)
766 { 765 {
767 for (QStringList::ConstIterator it = dirs->begin(); 766 for (QStringList::ConstIterator it = dirs->begin();
768 it != dirs->end(); ++it) { 767 it != dirs->end(); ++it) {
769 QString path = realPath(*pit + *it); 768 QString path = realPath(*pit + *it);
770 testdir.setPath(path); 769 testdir.setPath(path);
771 if (local && restrictionActive) 770 if (local && restrictionActive)
772 continue; 771 continue;
773 if ((local || testdir.exists()) && !candidates->contains(path)) 772 if ((local || testdir.exists()) && !candidates->contains(path))
774 candidates->append(path); 773 candidates->append(path);
775 } 774 }
776 local = false; 775 local = false;
777 } 776 }
778 } 777 }
779 dirs = absolutes.find(type); 778 dirs = absolutes.find(type);
780 if (dirs) 779 if (dirs)
781 for (QStringList::ConstIterator it = dirs->begin(); 780 for (QStringList::ConstIterator it = dirs->begin();
782 it != dirs->end(); ++it) 781 it != dirs->end(); ++it)
783 { 782 {
784 testdir.setPath(*it); 783 testdir.setPath(*it);
785 if (testdir.exists()) 784 if (testdir.exists())
786 { 785 {
787 QString filename = realPath(*it); 786 QString filename = realPath(*it);
788 if (!candidates->contains(filename)) 787 if (!candidates->contains(filename))
789 candidates->append(filename); 788 candidates->append(filename);
790 } 789 }
791 } 790 }
792 dircache.insert(type, candidates); 791 dircache.insert(type, candidates);
793 } 792 }
794 793
795#if 0 794#if 0
796 kdDebug() << "found dirs for resource " << type << ":" << endl; 795 kdDebug() << "found dirs for resource " << type << ":" << endl;
797 for (QStringList::ConstIterator pit = candidates->begin(); 796 for (QStringList::ConstIterator pit = candidates->begin();
798 pit != candidates->end(); 797 pit != candidates->end();
799 pit++) 798 pit++)
800 { 799 {
801 fprintf(stderr, "%s\n", (*pit).latin1()); 800 fprintf(stderr, "%s\n", (*pit).latin1());
802 } 801 }
803#endif 802#endif
804 803
805 804
806 return *candidates; 805 return *candidates;
807} 806}
808 807
809/*US 808/*US
810QString KStandardDirs::findExe( const QString& appname, 809QString KStandardDirs::findExe( const QString& appname,
811 const QString& pstr, bool ignore) 810 const QString& pstr, bool ignore)
812{ 811{
813 QFileInfo info; 812 QFileInfo info;
814 813
815 // absolute path ? 814 // absolute path ?
816 if (appname.startsWith(QString::fromLatin1("/"))) 815 if (appname.startsWith(QString::fromLatin1("/")))
817 { 816 {
818 info.setFile( appname ); 817 info.setFile( appname );
819 if( info.exists() && ( ignore || info.isExecutable() ) 818 if( info.exists() && ( ignore || info.isExecutable() )
820 && info.isFile() ) { 819 && info.isFile() ) {
821 return appname; 820 return appname;
822 } 821 }
823 return QString::null; 822 return QString::null;
824 } 823 }
825 824
826//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname); 825//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname);
827 QString p = QString("%1/%2").arg(appname).arg(appname); 826 QString p = QString("%1/%2").arg(appname).arg(appname);
828 qDebug("KStandardDirs::findExe this is probably wrong"); 827 qDebug("KStandardDirs::findExe this is probably wrong");
829 828
830 info.setFile( p ); 829 info.setFile( p );
831 if( info.exists() && ( ignore || info.isExecutable() ) 830 if( info.exists() && ( ignore || info.isExecutable() )
832 && ( info.isFile() || info.isSymLink() ) ) { 831 && ( info.isFile() || info.isSymLink() ) ) {
833 return p; 832 return p;
834 } 833 }
835 834
836 QStringList tokens; 835 QStringList tokens;
837 p = pstr; 836 p = pstr;
838 837
839 if( p.isNull() ) { 838 if( p.isNull() ) {
840 p = getenv( "PATH" ); 839 p = getenv( "PATH" );
841 } 840 }
842 841
843 tokenize( tokens, p, ":\b" ); 842 tokenize( tokens, p, ":\b" );
844 843
845 // split path using : or \b as delimiters 844 // split path using : or \b as delimiters
846 for( unsigned i = 0; i < tokens.count(); i++ ) { 845 for( unsigned i = 0; i < tokens.count(); i++ ) {
847 p = tokens[ i ]; 846 p = tokens[ i ];
848 847
849 if ( p[ 0 ] == '~' ) 848 if ( p[ 0 ] == '~' )
850 { 849 {
851 int len = p.find( '/' ); 850 int len = p.find( '/' );
852 if ( len == -1 ) 851 if ( len == -1 )
853 len = p.length(); 852 len = p.length();
854 if ( len == 1 ) 853 if ( len == 1 )
855 p.replace( 0, 1, QDir::homeDirPath() ); 854 p.replace( 0, 1, QDir::homeDirPath() );
856 else 855 else
857 { 856 {
858 QString user = p.mid( 1, len - 1 ); 857 QString user = p.mid( 1, len - 1 );
859 struct passwd *dir = getpwnam( user.local8Bit().data() ); 858 struct passwd *dir = getpwnam( user.local8Bit().data() );
860 if ( dir && strlen( dir->pw_dir ) ) 859 if ( dir && strlen( dir->pw_dir ) )
861 p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) ); 860 p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) );
862 } 861 }
863 } 862 }
864 863
865 p += "/"; 864 p += "/";
866 p += appname; 865 p += appname;
867 866
868 // Check for executable in this tokenized path 867 // Check for executable in this tokenized path
869 info.setFile( p ); 868 info.setFile( p );
870 869
871 if( info.exists() && ( ignore || info.isExecutable() ) 870 if( info.exists() && ( ignore || info.isExecutable() )
872 && ( info.isFile() || info.isSymLink() ) ) { 871 && ( info.isFile() || info.isSymLink() ) ) {
873 return p; 872 return p;
874 } 873 }
875 } 874 }
876 875
877 // If we reach here, the executable wasn't found. 876 // If we reach here, the executable wasn't found.
878 // So return empty string. 877 // So return empty string.
879 878
880 return QString::null; 879 return QString::null;
881} 880}
882 881
883int KStandardDirs::findAllExe( QStringList& list, const QString& appname, 882int KStandardDirs::findAllExe( QStringList& list, const QString& appname,
884 const QString& pstr, bool ignore ) 883 const QString& pstr, bool ignore )
885{ 884{
886 QString p = pstr; 885 QString p = pstr;
887 QFileInfo info; 886 QFileInfo info;
888 QStringList tokens; 887 QStringList tokens;
889 888
890 if( p.isNull() ) { 889 if( p.isNull() ) {
891 p = getenv( "PATH" ); 890 p = getenv( "PATH" );
892 } 891 }
893 892
894 list.clear(); 893 list.clear();
895 tokenize( tokens, p, ":\b" ); 894 tokenize( tokens, p, ":\b" );
896 895
897 for ( unsigned i = 0; i < tokens.count(); i++ ) { 896 for ( unsigned i = 0; i < tokens.count(); i++ ) {
898 p = tokens[ i ]; 897 p = tokens[ i ];
899 p += "/"; 898 p += "/";
900 p += appname; 899 p += appname;
901 900
902 info.setFile( p ); 901 info.setFile( p );
903 902
904 if( info.exists() && (ignore || info.isExecutable()) 903 if( info.exists() && (ignore || info.isExecutable())
905 && info.isFile() ) { 904 && info.isFile() ) {
906 list.append( p ); 905 list.append( p );
907 } 906 }
908 907
909 } 908 }
910 909
911 return list.count(); 910 return list.count();
912} 911}
913*/ 912*/
914 913
915static int tokenize( QStringList& tokens, const QString& str, 914static int tokenize( QStringList& tokens, const QString& str,
916 const QString& delim ) 915 const QString& delim )
917{ 916{
918 int len = str.length(); 917 int len = str.length();
919 QString token = ""; 918 QString token = "";
920 919
921 for( int index = 0; index < len; index++) 920 for( int index = 0; index < len; index++)
922 { 921 {
923 if ( delim.find( str[ index ] ) >= 0 ) 922 if ( delim.find( str[ index ] ) >= 0 )
924 { 923 {
925 tokens.append( token ); 924 tokens.append( token );
926 token = ""; 925 token = "";
927 } 926 }
928 else 927 else
929 { 928 {
930 token += str[ index ]; 929 token += str[ index ];
931 } 930 }
932 } 931 }
933 if ( token.length() > 0 ) 932 if ( token.length() > 0 )
934 { 933 {
935 tokens.append( token ); 934 tokens.append( token );
936 } 935 }
937 936
938 return tokens.count(); 937 return tokens.count();
939} 938}
940 939
941QString KStandardDirs::kde_default(const char *type) { 940QString KStandardDirs::kde_default(const char *type) {
942 if (!strcmp(type, "data")) 941 if (!strcmp(type, "data"))
943 return "apps/"; 942 return "apps/";
944 if (!strcmp(type, "html")) 943 if (!strcmp(type, "html"))
945 return "share/doc/HTML/"; 944 return "share/doc/HTML/";
946 if (!strcmp(type, "icon")) 945 if (!strcmp(type, "icon"))
947 return "share/icons/"; 946 return "share/icons/";
948 if (!strcmp(type, "config")) 947 if (!strcmp(type, "config"))
949 return "config/"; 948 return "config/";
950 if (!strcmp(type, "pixmap")) 949 if (!strcmp(type, "pixmap"))
951 return "share/pixmaps/"; 950 return "share/pixmaps/";
952 if (!strcmp(type, "apps")) 951 if (!strcmp(type, "apps"))
953 return "share/applnk/"; 952 return "share/applnk/";
954 if (!strcmp(type, "sound")) 953 if (!strcmp(type, "sound"))
955 return "share/sounds/"; 954 return "share/sounds/";
956 if (!strcmp(type, "locale")) 955 if (!strcmp(type, "locale"))
957 return "share/locale/"; 956 return "share/locale/";
958 if (!strcmp(type, "services")) 957 if (!strcmp(type, "services"))
959 return "share/services/"; 958 return "share/services/";
960 if (!strcmp(type, "servicetypes")) 959 if (!strcmp(type, "servicetypes"))
961 return "share/servicetypes/"; 960 return "share/servicetypes/";
962 if (!strcmp(type, "mime")) 961 if (!strcmp(type, "mime"))
963 return "share/mimelnk/"; 962 return "share/mimelnk/";
964 if (!strcmp(type, "cgi")) 963 if (!strcmp(type, "cgi"))
965 return "cgi-bin/"; 964 return "cgi-bin/";
966 if (!strcmp(type, "wallpaper")) 965 if (!strcmp(type, "wallpaper"))
967 return "share/wallpapers/"; 966 return "share/wallpapers/";
968 if (!strcmp(type, "templates")) 967 if (!strcmp(type, "templates"))
969 return "share/templates/"; 968 return "share/templates/";
970 if (!strcmp(type, "exe")) 969 if (!strcmp(type, "exe"))
971 return "bin/"; 970 return "bin/";
972 if (!strcmp(type, "lib")) 971 if (!strcmp(type, "lib"))
973 return "lib/"; 972 return "lib/";
974 if (!strcmp(type, "module")) 973 if (!strcmp(type, "module"))
975 return "lib/kde3/"; 974 return "lib/kde3/";
976 if (!strcmp(type, "qtplugins")) 975 if (!strcmp(type, "qtplugins"))
977 return "lib/kde3/plugins"; 976 return "lib/kde3/plugins";
978 if (!strcmp(type, "xdgdata-apps")) 977 if (!strcmp(type, "xdgdata-apps"))
979 return "applications/"; 978 return "applications/";
980 if (!strcmp(type, "xdgdata-dirs")) 979 if (!strcmp(type, "xdgdata-dirs"))
981 return "desktop-directories/"; 980 return "desktop-directories/";
982 if (!strcmp(type, "xdgconf-menu")) 981 if (!strcmp(type, "xdgconf-menu"))
983 return "menus/"; 982 return "menus/";
984 qFatal("unknown resource type %s", type); 983 qFatal("unknown resource type %s", type);
985 return QString::null; 984 return QString::null;
986} 985}
987 986
988QString KStandardDirs::saveLocation(const char *type, 987QString KStandardDirs::saveLocation(const char *type,
989 const QString& suffix, 988 const QString& suffix,
990 bool create) const 989 bool create) const
991{ 990{
992 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); 991 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() );
993 //return ""; 992 //return "";
994 checkConfig(); 993 checkConfig();
995 994
996 QString *pPath = savelocations.find(type); 995 QString *pPath = savelocations.find(type);
997 if (!pPath) 996 if (!pPath)
998 { 997 {
999 QStringList *dirs = relatives.find(type); 998 QStringList *dirs = relatives.find(type);
1000 if (!dirs && ( 999 if (!dirs && (
1001 (strcmp(type, "socket") == 0) || 1000 (strcmp(type, "socket") == 0) ||
1002 (strcmp(type, "tmp") == 0) || 1001 (strcmp(type, "tmp") == 0) ||
1003 (strcmp(type, "cache") == 0) )) 1002 (strcmp(type, "cache") == 0) ))
1004 { 1003 {
1005 (void) resourceDirs(type); // Generate socket|tmp|cache resource. 1004 (void) resourceDirs(type); // Generate socket|tmp|cache resource.
1006 dirs = relatives.find(type); // Search again. 1005 dirs = relatives.find(type); // Search again.
1007 } 1006 }
1008 if (dirs) 1007 if (dirs)
1009 { 1008 {
1010 // Check for existance of typed directory + suffix 1009 // Check for existance of typed directory + suffix
1011 if (strncmp(type, "xdgdata-", 8) == 0) 1010 if (strncmp(type, "xdgdata-", 8) == 0)
1012 pPath = new QString(realPath(localxdgdatadir() + dirs->last())); 1011 pPath = new QString(realPath(localxdgdatadir() + dirs->last()));
1013 else if (strncmp(type, "xdgconf-", 8) == 0) 1012 else if (strncmp(type, "xdgconf-", 8) == 0)
1014 pPath = new QString(realPath(localxdgconfdir() + dirs->last())); 1013 pPath = new QString(realPath(localxdgconfdir() + dirs->last()));
1015 else 1014 else
1016 pPath = new QString(realPath(localkdedir() + dirs->last())); 1015 pPath = new QString(realPath(localkdedir() + dirs->last()));
1017 } 1016 }
1018 else { 1017 else {
1019 dirs = absolutes.find(type); 1018 dirs = absolutes.find(type);
1020 if (!dirs) 1019 if (!dirs)
1021 qFatal("KStandardDirs: The resource type %s is not registered", type); 1020 qFatal("KStandardDirs: The resource type %s is not registered", type);
1022 pPath = new QString(realPath(dirs->last())); 1021 pPath = new QString(realPath(dirs->last()));
1023 } 1022 }
1024 1023
1025 savelocations.insert(type, pPath); 1024 savelocations.insert(type, pPath);
1026 } 1025 }
1027 1026
1028 QString fullPath = *pPath + suffix; 1027 QString fullPath = *pPath + suffix;
1029//US struct stat st; 1028//US struct stat st;
1030//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) 1029//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode)))
1031 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 1030 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
1032 if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) 1031 if (fullPathInfo.isReadable() || !fullPathInfo.isDir())
1033 1032
1034 1033
1035 { 1034 {
1036 if(!create) { 1035 if(!create) {
1037#ifndef NDEBUG 1036#ifndef NDEBUG
1038 qDebug("save location %s doesn't exist", fullPath.latin1()); 1037 qDebug("save location %s doesn't exist", fullPath.latin1());
1039#endif 1038#endif
1040 return fullPath; 1039 return fullPath;
1041 } 1040 }
1042 if(!makeDir(fullPath, 0700)) { 1041 if(!makeDir(fullPath, 0700)) {
1043 qWarning("failed to create %s", fullPath.latin1()); 1042 qWarning("failed to create %s", fullPath.latin1());
1044 return fullPath; 1043 return fullPath;
1045 } 1044 }
1046 dircache.remove(type); 1045 dircache.remove(type);
1047 } 1046 }
1048 return fullPath; 1047 return fullPath;
1049} 1048}
1050 1049
1051QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) 1050QString KStandardDirs::relativeLocation(const char *type, const QString &absPath)
1052{ 1051{
1053 QString fullPath = absPath; 1052 QString fullPath = absPath;
1054 int i = absPath.findRev('/'); 1053 int i = absPath.findRev('/');
1055 if (i != -1) 1054 if (i != -1)
1056 { 1055 {
1057 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize 1056 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize
1058 } 1057 }
1059 1058
1060 QStringList candidates = resourceDirs(type); 1059 QStringList candidates = resourceDirs(type);
1061 1060
1062 for (QStringList::ConstIterator it = candidates.begin(); 1061 for (QStringList::ConstIterator it = candidates.begin();
1063 it != candidates.end(); it++) 1062 it != candidates.end(); it++)
1064 if (fullPath.startsWith(*it)) 1063 if (fullPath.startsWith(*it))
1065 { 1064 {
1066 return fullPath.mid((*it).length()); 1065 return fullPath.mid((*it).length());
1067 } 1066 }
1068 1067
1069 return absPath; 1068 return absPath;
1070} 1069}
1071 1070
1072 1071
1073bool KStandardDirs::makeDir(const QString& dir2, int mode) 1072bool KStandardDirs::makeDir(const QString& dir2, int mode)
1074{ 1073{
1075 QString dir = QDir::convertSeparators( dir2 ); 1074 QString dir = QDir::convertSeparators( dir2 );
1076#if 0 1075#if 0
1077 //LR 1076 //LR
1078 1077
1079 // we want an absolute path 1078 // we want an absolute path
1080 if (dir.at(0) != '/') 1079 if (dir.at(0) != '/')
1081 return false; 1080 return false;
1082 1081
1083 QString target = dir; 1082 QString target = dir;
1084 uint len = target.length(); 1083 uint len = target.length();
1085 1084
1086 // append trailing slash if missing 1085 // append trailing slash if missing
1087 if (dir.at(len - 1) != '/') 1086 if (dir.at(len - 1) != '/')
1088 target += '/'; 1087 target += '/';
1089 1088
1090 QString base(""); 1089 QString base("");
1091 uint i = 1; 1090 uint i = 1;
1092 1091
1093 while( i < len ) 1092 while( i < len )
1094 { 1093 {
1095//US struct stat st; 1094//US struct stat st;
1096 int pos = target.find('/', i); 1095 int pos = target.find('/', i);
1097 base += target.mid(i - 1, pos - i + 1); 1096 base += target.mid(i - 1, pos - i + 1);
1098 QCString baseEncoded = QFile::encodeName(base); 1097 QCString baseEncoded = QFile::encodeName(base);
1099 // bail out if we encountered a problem 1098 // bail out if we encountered a problem
1100//US if (stat(baseEncoded, &st) != 0) 1099//US if (stat(baseEncoded, &st) != 0)
1101 QFileInfo baseEncodedInfo(baseEncoded); 1100 QFileInfo baseEncodedInfo(baseEncoded);
1102 if (!baseEncodedInfo.exists()) 1101 if (!baseEncodedInfo.exists())
1103 { 1102 {
1104 // Directory does not exist.... 1103 // Directory does not exist....
1105 // Or maybe a dangling symlink ? 1104 // Or maybe a dangling symlink ?
1106//US if (lstat(baseEncoded, &st) == 0) 1105//US if (lstat(baseEncoded, &st) == 0)
1107 if (baseEncodedInfo.isSymLink()) { 1106 if (baseEncodedInfo.isSymLink()) {
1108//US (void)unlink(baseEncoded); // try removing 1107//US (void)unlink(baseEncoded); // try removing
1109 QFile(baseEncoded).remove(); 1108 QFile(baseEncoded).remove();
1110 } 1109 }
1111 1110
1112 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) 1111 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0)
1113 QDir dirObj; 1112 QDir dirObj;
1114 if ( dirObj.mkdir(baseEncoded) != true ) 1113 if ( dirObj.mkdir(baseEncoded) != true )
1115 { 1114 {
1116 //US perror("trying to create local folder"); 1115 //US perror("trying to create local folder");
1117 return false; // Couldn't create it :-( 1116 return false; // Couldn't create it :-(
1118 } 1117 }
1119 } 1118 }
1120 i = pos + 1; 1119 i = pos + 1;
1121 } 1120 }
1122 return true; 1121 return true;
1123#endif 1122#endif
1124 1123
1125 // ******************************************** 1124 // ********************************************
1126 // new code for WIN32 1125 // new code for WIN32
1127 QDir dirObj; 1126 QDir dirObj;
1128 1127
1129 1128
1130 // we want an absolute path 1129 // we want an absolute path
1131#ifndef _WIN32_ 1130#ifndef _WIN32_
1132 if (dir.at(0) != '/') 1131 if (dir.at(0) != '/')
1133 return false; 1132 return false;
1134#endif 1133#endif
1135 1134
1136 QString target = dir; 1135 QString target = dir;
1137 uint len = target.length(); 1136 uint len = target.length();
1138#ifndef _WIN32_ 1137#ifndef _WIN32_
1139 // append trailing slash if missing 1138 // append trailing slash if missing
1140 if (dir.at(len - 1) != '/') 1139 if (dir.at(len - 1) != '/')
1141 target += '/'; 1140 target += '/';
1142#endif 1141#endif
1143 1142
1144 QString base(""); 1143 QString base("");
1145 uint i = 1; 1144 uint i = 1;
1146 1145
1147 while( i < len ) 1146 while( i < len )
1148 { 1147 {
1149//US struct stat st; 1148//US struct stat st;
1150#ifndef _WIN32_ 1149#ifndef _WIN32_
1151 int pos = target.find('/', i); 1150 int pos = target.find('/', i);
1152#else 1151#else
1153 int pos = target.find('\\', i); 1152 int pos = target.find('\\', i);
1154#endif 1153#endif
1155 if ( pos < 0 ) 1154 if ( pos < 0 )
1156 return true; 1155 return true;
1157 base += target.mid(i - 1, pos - i + 1); 1156 base += target.mid(i - 1, pos - i + 1);
1158 //QMessageBox::information( 0,"cap111", base, 1 ); 1157 //QMessageBox::information( 0,"cap111", base, 1 );
1159/*US 1158/*US
1160 QCString baseEncoded = QFile::encodeName(base); 1159 QCString baseEncoded = QFile::encodeName(base);
1161 // bail out if we encountered a problem 1160 // bail out if we encountered a problem
1162 if (stat(baseEncoded, &st) != 0) 1161 if (stat(baseEncoded, &st) != 0)
1163 { 1162 {
1164 // Directory does not exist.... 1163 // Directory does not exist....
1165 // Or maybe a dangling symlink ? 1164 // Or maybe a dangling symlink ?
1166 if (lstat(baseEncoded, &st) == 0) 1165 if (lstat(baseEncoded, &st) == 0)
1167 (void)unlink(baseEncoded); // try removing 1166 (void)unlink(baseEncoded); // try removing
1168 1167
1169 1168
1170 if ( mkdir(baseEncoded, (mode_t) mode) != 0) { 1169 if ( mkdir(baseEncoded, (mode_t) mode) != 0) {
1171 perror("trying to create local folder"); 1170 perror("trying to create local folder");
1172 return false; // Couldn't create it :-( 1171 return false; // Couldn't create it :-(
1173 } 1172 }
1174 } 1173 }
1175*/ 1174*/
1176 1175
1177 if (dirObj.exists(base) == false) 1176 if (dirObj.exists(base) == false)
1178 { 1177 {
1179 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); 1178 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1());
1180 if (dirObj.mkdir(base) != true) 1179 if (dirObj.mkdir(base) != true)
1181 { 1180 {
1182 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); 1181 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1());
1183 return false; 1182 return false;
1184 } 1183 }
1185 } 1184 }
1186 1185
1187 i = pos + 1; 1186 i = pos + 1;
1188 } 1187 }
1189 return true; 1188 return true;
1190 1189
1191} 1190}
1192 1191
1193static QString readEnvPath(const char *env) 1192static QString readEnvPath(const char *env)
1194{ 1193{
1195#ifdef _WIN32_ 1194#ifdef _WIN32_
1196 return ""; 1195 return "";
1197#else 1196#else
1198 QCString c_path = getenv(env); 1197 QCString c_path = getenv(env);
1199 if (c_path.isEmpty()) 1198 if (c_path.isEmpty())
1200 return QString::null; 1199 return QString::null;
1201 return QFile::decodeName(c_path); 1200 return QFile::decodeName(c_path);
1202#endif 1201#endif
1203} 1202}
1204 1203
1205void KStandardDirs::addKDEDefaults() 1204void KStandardDirs::addKDEDefaults()
1206{ 1205{
1207 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); 1206 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called ");
1208 //return; 1207 //return;
1209 QStringList kdedirList; 1208 QStringList kdedirList;
1210 1209
1211 // begin KDEDIRS 1210 // begin KDEDIRS
1212 QString kdedirs = readEnvPath("MICROKDEDIRS"); 1211 QString kdedirs = readEnvPath("MICROKDEDIRS");
1213 if (!kdedirs.isEmpty()) 1212 if (!kdedirs.isEmpty())
1214 { 1213 {
1215 tokenize(kdedirList, kdedirs, ":"); 1214 tokenize(kdedirList, kdedirs, ":");
1216 } 1215 }
1217 else 1216 else
1218 { 1217 {
1219 QString kdedir = readEnvPath("MICROKDEDIR"); 1218 QString kdedir = readEnvPath("MICROKDEDIR");
1220 if (!kdedir.isEmpty()) 1219 if (!kdedir.isEmpty())
1221 { 1220 {
1222 kdedir = KShell::tildeExpand(kdedir); 1221 kdedir = KShell::tildeExpand(kdedir);
1223 kdedirList.append(kdedir); 1222 kdedirList.append(kdedir);
1224 } 1223 }
1225 } 1224 }
1226//US kdedirList.append(KDEDIR); 1225//US kdedirList.append(KDEDIR);
1227//US for embedded, add qtopia dir as kdedir 1226//US for embedded, add qtopia dir as kdedir
1228 kdedirList.append(QPEApplication::qpeDir()); 1227 kdedirList.append(readEnvPath("QPEDIR" ));
1229 1228
1230#ifdef __KDE_EXECPREFIX 1229#ifdef __KDE_EXECPREFIX
1231 QString execPrefix(__KDE_EXECPREFIX); 1230 QString execPrefix(__KDE_EXECPREFIX);
1232 if (execPrefix!="NONE") 1231 if (execPrefix!="NONE")
1233 kdedirList.append(execPrefix); 1232 kdedirList.append(execPrefix);
1234#endif 1233#endif
1235 1234
1236 QString localKdeDir; 1235 QString localKdeDir;
1237 1236
1238//US if (getuid()) 1237//US if (getuid())
1239 if (true) 1238 if (true)
1240 { 1239 {
1241 localKdeDir = readEnvPath("MICROKDEHOME"); 1240 localKdeDir = readEnvPath("MICROKDEHOME");
1242 if (!localKdeDir.isEmpty()) 1241 if (!localKdeDir.isEmpty())
1243 { 1242 {
1244 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1243 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1245 localKdeDir += '/'; 1244 localKdeDir += '/';
1246 } 1245 }
1247 else 1246 else
1248 { 1247 {
1249 localKdeDir = QDir::homeDirPath() + "/kdepim/"; 1248 localKdeDir = QDir::homeDirPath() + "/kdepim/";
1250 } 1249 }
1251 } 1250 }
1252 else 1251 else
1253 { 1252 {
1254 // We treat root different to prevent root messing up the 1253 // We treat root different to prevent root messing up the
1255 // file permissions in the users home directory. 1254 // file permissions in the users home directory.
1256 localKdeDir = readEnvPath("MICROKDEROOTHOME"); 1255 localKdeDir = readEnvPath("MICROKDEROOTHOME");
1257 if (!localKdeDir.isEmpty()) 1256 if (!localKdeDir.isEmpty())
1258 { 1257 {
1259 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1258 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1260 localKdeDir += '/'; 1259 localKdeDir += '/';
1261 } 1260 }
1262 else 1261 else
1263 { 1262 {
1264//US struct passwd *pw = getpwuid(0); 1263//US struct passwd *pw = getpwuid(0);
1265//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; 1264//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/";
1266 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); 1265 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed");
1267 } 1266 }
1268 1267
1269 } 1268 }
1270 1269
1271//US localKdeDir = appDir(); 1270//US localKdeDir = appDir();
1272 1271
1273//US 1272//US
1274// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); 1273// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1());
1275 if (localKdeDir != "-/") 1274 if (localKdeDir != "-/")
1276 { 1275 {
1277 localKdeDir = KShell::tildeExpand(localKdeDir); 1276 localKdeDir = KShell::tildeExpand(localKdeDir);
1278 addPrefix(localKdeDir); 1277 addPrefix(localKdeDir);
1279 } 1278 }
1280 1279
1281 for (QStringList::ConstIterator it = kdedirList.begin(); 1280 for (QStringList::ConstIterator it = kdedirList.begin();
1282 it != kdedirList.end(); it++) 1281 it != kdedirList.end(); it++)
1283 { 1282 {
1284 QString dir = KShell::tildeExpand(*it); 1283 QString dir = KShell::tildeExpand(*it);
1285 addPrefix(dir); 1284 addPrefix(dir);
1286 } 1285 }
1287 // end KDEDIRS 1286 // end KDEDIRS
1288 1287
1289 // begin XDG_CONFIG_XXX 1288 // begin XDG_CONFIG_XXX
1290 QStringList xdgdirList; 1289 QStringList xdgdirList;
1291 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); 1290 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS");
1292 if (!xdgdirs.isEmpty()) 1291 if (!xdgdirs.isEmpty())
1293 { 1292 {
1294 tokenize(xdgdirList, xdgdirs, ":"); 1293 tokenize(xdgdirList, xdgdirs, ":");
1295 } 1294 }
1296 else 1295 else
1297 { 1296 {
1298 xdgdirList.clear(); 1297 xdgdirList.clear();
1299 xdgdirList.append("/etc/xdg"); 1298 xdgdirList.append("/etc/xdg");
1300 } 1299 }
1301 1300
1302 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); 1301 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME");
1303 if (!localXdgDir.isEmpty()) 1302 if (!localXdgDir.isEmpty())
1304 { 1303 {
1305 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1304 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1306 localXdgDir += '/'; 1305 localXdgDir += '/';
1307 } 1306 }
1308 else 1307 else
1309 { 1308 {
1310//US if (getuid()) 1309//US if (getuid())
1311 if (true) 1310 if (true)
1312 { 1311 {
1313 localXdgDir = QDir::homeDirPath() + "/.config/"; 1312 localXdgDir = QDir::homeDirPath() + "/.config/";
1314 } 1313 }
1315 else 1314 else
1316 { 1315 {
1317//US struct passwd *pw = getpwuid(0); 1316//US struct passwd *pw = getpwuid(0);
1318//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; 1317//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/";
1319 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); 1318 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed");
1320 } 1319 }
1321 } 1320 }
1322 1321
1323 localXdgDir = KShell::tildeExpand(localXdgDir); 1322 localXdgDir = KShell::tildeExpand(localXdgDir);
1324 addXdgConfigPrefix(localXdgDir); 1323 addXdgConfigPrefix(localXdgDir);
1325 1324
1326 for (QStringList::ConstIterator it = xdgdirList.begin(); 1325 for (QStringList::ConstIterator it = xdgdirList.begin();
1327 it != xdgdirList.end(); it++) 1326 it != xdgdirList.end(); it++)
1328 { 1327 {
1329 QString dir = KShell::tildeExpand(*it); 1328 QString dir = KShell::tildeExpand(*it);
1330 addXdgConfigPrefix(dir); 1329 addXdgConfigPrefix(dir);
1331 } 1330 }
1332 // end XDG_CONFIG_XXX 1331 // end XDG_CONFIG_XXX
1333 1332
1334 // begin XDG_DATA_XXX 1333 // begin XDG_DATA_XXX
1335 xdgdirs = readEnvPath("XDG_DATA_DIRS"); 1334 xdgdirs = readEnvPath("XDG_DATA_DIRS");
1336 if (!xdgdirs.isEmpty()) 1335 if (!xdgdirs.isEmpty())
1337 { 1336 {
1338 tokenize(xdgdirList, xdgdirs, ":"); 1337 tokenize(xdgdirList, xdgdirs, ":");
1339 } 1338 }
1340 else 1339 else
1341 { 1340 {
1342 xdgdirList.clear(); 1341 xdgdirList.clear();
1343 for (QStringList::ConstIterator it = kdedirList.begin(); 1342 for (QStringList::ConstIterator it = kdedirList.begin();
1344 it != kdedirList.end(); it++) 1343 it != kdedirList.end(); it++)
1345 { 1344 {
1346 QString dir = *it; 1345 QString dir = *it;
1347 if (dir.at(dir.length()-1) != '/') 1346 if (dir.at(dir.length()-1) != '/')
1348 dir += '/'; 1347 dir += '/';
1349 xdgdirList.append(dir+"share/"); 1348 xdgdirList.append(dir+"share/");
1350 } 1349 }
1351 1350
1352 xdgdirList.append("/usr/local/share/"); 1351 xdgdirList.append("/usr/local/share/");
1353 xdgdirList.append("/usr/share/"); 1352 xdgdirList.append("/usr/share/");
1354 } 1353 }
1355 1354
1356 localXdgDir = readEnvPath("XDG_DATA_HOME"); 1355 localXdgDir = readEnvPath("XDG_DATA_HOME");
1357 if (!localXdgDir.isEmpty()) 1356 if (!localXdgDir.isEmpty())
1358 { 1357 {
1359 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1358 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1360 localXdgDir += '/'; 1359 localXdgDir += '/';
1361 } 1360 }
1362 else 1361 else
1363 { 1362 {
1364//US if (getuid()) 1363//US if (getuid())
1365 if (true) 1364 if (true)
1366 { 1365 {
1367 localXdgDir = QDir::homeDirPath() + "/.local/share/"; 1366 localXdgDir = QDir::homeDirPath() + "/.local/share/";
1368 } 1367 }
1369 else 1368 else
1370 { 1369 {
1371//US struct passwd *pw = getpwuid(0); 1370//US struct passwd *pw = getpwuid(0);
1372//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; 1371//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/";
1373 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); 1372 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed");
1374 } 1373 }
1375 } 1374 }
1376 1375
1377 localXdgDir = KShell::tildeExpand(localXdgDir); 1376 localXdgDir = KShell::tildeExpand(localXdgDir);
1378 addXdgDataPrefix(localXdgDir); 1377 addXdgDataPrefix(localXdgDir);
1379 1378
1380 for (QStringList::ConstIterator it = xdgdirList.begin(); 1379 for (QStringList::ConstIterator it = xdgdirList.begin();
1381 it != xdgdirList.end(); it++) 1380 it != xdgdirList.end(); it++)
1382 { 1381 {
1383 QString dir = KShell::tildeExpand(*it); 1382 QString dir = KShell::tildeExpand(*it);
1384 1383
1385 addXdgDataPrefix(dir); 1384 addXdgDataPrefix(dir);
1386 } 1385 }
1387 // end XDG_DATA_XXX 1386 // end XDG_DATA_XXX
1388 1387
1389 1388
1390 uint index = 0; 1389 uint index = 0;
1391 while (types[index] != 0) { 1390 while (types[index] != 0) {
1392 addResourceType(types[index], kde_default(types[index])); 1391 addResourceType(types[index], kde_default(types[index]));
1393 index++; 1392 index++;
1394 } 1393 }
1395 1394
1396 addResourceDir("home", QDir::homeDirPath()); 1395 addResourceDir("home", QDir::homeDirPath());
1397} 1396}
1398 1397
1399void KStandardDirs::checkConfig() const 1398void KStandardDirs::checkConfig() const
1400{ 1399{
1401/*US 1400/*US
1402 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) 1401 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config)
1403 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); 1402 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config);
1404*/ 1403*/
1405 if (!addedCustoms && KGlobal::config()) 1404 if (!addedCustoms && KGlobal::config())
1406 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); 1405 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config());
1407} 1406}
1408 1407
1409bool KStandardDirs::addCustomized(KConfig *config) 1408bool KStandardDirs::addCustomized(KConfig *config)
1410{ 1409{
1411 if (addedCustoms) // there are already customized entries 1410 if (addedCustoms) // there are already customized entries
1412 return false; // we just quite and hope they are the right ones 1411 return false; // we just quite and hope they are the right ones
1413 1412
1414 // save the numbers of config directories. If this changes, 1413 // save the numbers of config directories. If this changes,
1415 // we will return true to give KConfig a chance to reparse 1414 // we will return true to give KConfig a chance to reparse
1416 uint configdirs = resourceDirs("config").count(); 1415 uint configdirs = resourceDirs("config").count();
1417 1416
1418 // reading the prefixes in 1417 // reading the prefixes in
1419 QString oldGroup = config->group(); 1418 QString oldGroup = config->group();
1420 config->setGroup("Directories"); 1419 config->setGroup("Directories");
1421 1420
1422 QStringList list; 1421 QStringList list;
1423 QStringList::ConstIterator it; 1422 QStringList::ConstIterator it;
1424 list = config->readListEntry("prefixes"); 1423 list = config->readListEntry("prefixes");
1425 for (it = list.begin(); it != list.end(); it++) 1424 for (it = list.begin(); it != list.end(); it++)
1426 addPrefix(*it); 1425 addPrefix(*it);
1427 1426
1428 // iterating over all entries in the group Directories 1427 // iterating over all entries in the group Directories
1429 // to find entries that start with dir_$type 1428 // to find entries that start with dir_$type
1430/*US 1429/*US
1431 QMap<QString, QString> entries = config->entryMap("Directories"); 1430 QMap<QString, QString> entries = config->entryMap("Directories");
1432 1431
1433 QMap<QString, QString>::ConstIterator it2; 1432 QMap<QString, QString>::ConstIterator it2;
1434 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1433 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1435 { 1434 {
1436 QString key = it2.key(); 1435 QString key = it2.key();
1437 if (key.left(4) == "dir_") { 1436 if (key.left(4) == "dir_") {
1438 // generate directory list, there may be more than 1. 1437 // generate directory list, there may be more than 1.
1439 QStringList dirs = QStringList::split(',', *it2); 1438 QStringList dirs = QStringList::split(',', *it2);
1440 QStringList::Iterator sIt(dirs.begin()); 1439 QStringList::Iterator sIt(dirs.begin());
1441 QString resType = key.mid(4, key.length()); 1440 QString resType = key.mid(4, key.length());
1442 for (; sIt != dirs.end(); ++sIt) { 1441 for (; sIt != dirs.end(); ++sIt) {
1443 addResourceDir(resType.latin1(), *sIt); 1442 addResourceDir(resType.latin1(), *sIt);
1444 } 1443 }
1445 } 1444 }
1446 } 1445 }
1447 1446
1448 // Process KIOSK restrictions. 1447 // Process KIOSK restrictions.
1449 config->setGroup("KDE Resource Restrictions"); 1448 config->setGroup("KDE Resource Restrictions");
1450 entries = config->entryMap("KDE Resource Restrictions"); 1449 entries = config->entryMap("KDE Resource Restrictions");
1451 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1450 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1452 { 1451 {
1453 QString key = it2.key(); 1452 QString key = it2.key();
1454 if (!config->readBoolEntry(key, true)) 1453 if (!config->readBoolEntry(key, true))
1455 { 1454 {
1456 d->restrictionsActive = true; 1455 d->restrictionsActive = true;
1457 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do 1456 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do
1458 dircache.remove(key.latin1()); 1457 dircache.remove(key.latin1());
1459 } 1458 }
1460 } 1459 }
1461*/ 1460*/
1462 // save it for future calls - that will return 1461 // save it for future calls - that will return
1463 addedCustoms = true; 1462 addedCustoms = true;
1464 config->setGroup(oldGroup); 1463 config->setGroup(oldGroup);
1465 1464
1466 // return true if the number of config dirs changed 1465 // return true if the number of config dirs changed
1467 return (resourceDirs("config").count() != configdirs); 1466 return (resourceDirs("config").count() != configdirs);
1468} 1467}
1469 1468
1470QString KStandardDirs::localkdedir() const 1469QString KStandardDirs::localkdedir() const
1471{ 1470{
1472 // Return the prefix to use for saving 1471 // Return the prefix to use for saving
1473 return prefixes.first(); 1472 return prefixes.first();
1474} 1473}
1475 1474
1476QString KStandardDirs::localxdgdatadir() const 1475QString KStandardDirs::localxdgdatadir() const
1477{ 1476{
1478 // Return the prefix to use for saving 1477 // Return the prefix to use for saving
1479 return d->xdgdata_prefixes.first(); 1478 return d->xdgdata_prefixes.first();
1480} 1479}
1481 1480
1482QString KStandardDirs::localxdgconfdir() const 1481QString KStandardDirs::localxdgconfdir() const
1483{ 1482{
1484 // Return the prefix to use for saving 1483 // Return the prefix to use for saving
1485 return d->xdgconf_prefixes.first(); 1484 return d->xdgconf_prefixes.first();
1486} 1485}
1487 1486
1488void KStandardDirs::setAppDir( const QString &appDir ) 1487void KStandardDirs::setAppDir( const QString &appDir )
1489{ 1488{
1490 mAppDir = appDir; 1489 mAppDir = appDir;
1491 1490
1492 if ( mAppDir.right( 1 ) != "/" ) 1491 if ( mAppDir.right( 1 ) != "/" )
1493 mAppDir += "/"; 1492 mAppDir += "/";
1494} 1493}
1495 1494
1496QString KStandardDirs::appDir() 1495QString KStandardDirs::appDir()
1497{ 1496{
1498 return mAppDir; 1497 return mAppDir;
1499} 1498}
1500 1499
1501// just to make code more readable without macros 1500// just to make code more readable without macros
1502QString locate( const char *type, 1501QString locate( const char *type,
1503 const QString& filename/*US , const KInstance* inst*/ ) 1502 const QString& filename/*US , const KInstance* inst*/ )
1504{ 1503{
1505//US return inst->dirs()->findResource(type, filename); 1504//US return inst->dirs()->findResource(type, filename);
1506 return KGlobal::dirs()->findResource(type, filename); 1505 return KGlobal::dirs()->findResource(type, filename);
1507} 1506}
1508 1507
1509QString locateLocal( const char *type, 1508QString locateLocal( const char *type,
1510 const QString& filename/*US , const KInstance* inst*/ ) 1509 const QString& filename/*US , const KInstance* inst*/ )
1511{ 1510{
1512 1511
1513 QString path = locateLocal(type, filename, true /*US, inst*/); 1512 QString path = locateLocal(type, filename, true /*US, inst*/);
1514 1513
1515 1514
1516/* 1515/*
1517 static int ccc = 0; 1516 static int ccc = 0;
1518 ++ccc; 1517 ++ccc;
1519 if ( ccc > 13 ) 1518 if ( ccc > 13 )
1520 abort(); 1519 abort();
1521*/ 1520*/
1522 qDebug("locatelocal: %s" , path.latin1()); 1521 qDebug("locatelocal: %s" , path.latin1());
1523 return path; 1522 return path;
1524 1523
1525/*US why do we put all files into one directory. It is quit complicated. 1524/*US why do we put all files into one directory. It is quit complicated.
1526why not staying with the original directorystructure ? 1525why not staying with the original directorystructure ?
1527 1526
1528 1527
1529 QString escapedFilename = filename; 1528 QString escapedFilename = filename;
1530 escapedFilename.replace( QRegExp( "/" ), "_" ); 1529 escapedFilename.replace( QRegExp( "/" ), "_" );
1531 1530
1532 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1531 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1533 1532
1534 kdDebug() << "locate: '" << path << "'" << endl; 1533 kdDebug() << "locate: '" << path << "'" << endl;
1535 qDebug("locate: %s" , path.latin1()); 1534 qDebug("locate: %s" , path.latin1());
1536 return path; 1535 return path;
1537*/ 1536*/
1538//US so my proposal is this: 1537//US so my proposal is this:
1539 1538
1540// QString escapedFilename = filename; 1539// QString escapedFilename = filename;
1541// escapedFilename.replace( QRegExp( "/" ), "_" ); 1540// escapedFilename.replace( QRegExp( "/" ), "_" );
1542 1541
1543#if 0 1542#if 0
1544#ifdef _WIN32_ 1543#ifdef _WIN32_
1545 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1544 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1546#else 1545#else
1547 QString path = KStandardDirs::appDir() + type + "/" + filename; 1546 QString path = KStandardDirs::appDir() + type + "/" + filename;
1548#endif 1547#endif
1549 1548
1550 //US Create the containing dir if needed 1549 //US Create the containing dir if needed
1551 QFileInfo fi ( path ); 1550 QFileInfo fi ( path );
1552 1551
1553 // QString dir=pathurl.directory(); 1552 // QString dir=pathurl.directory();
1554 //QMessageBox::information( 0,"path", path, 1 ); 1553 //QMessageBox::information( 0,"path", path, 1 );
1555 1554
1556#ifdef _WIN32_ 1555#ifdef _WIN32_
1557 KStandardDirs::makeDir(path); 1556 KStandardDirs::makeDir(path);
1558#else 1557#else
1559 KStandardDirs::makeDir(fi.dirPath( true )); 1558 KStandardDirs::makeDir(fi.dirPath( true ));
1560#endif 1559#endif
1561 1560
1562 qDebug("locate22: %s" , path.latin1()); 1561 qDebug("locate22: %s" , path.latin1());
1563 return path; 1562 return path;
1564 1563
1565#endif 1564#endif
1566 1565
1567} 1566}
1568 1567
1569QString locateLocal( const char *type, 1568QString locateLocal( const char *type,
1570 const QString& filename, bool createDir/*US , const KInstance* inst*/ ) 1569 const QString& filename, bool createDir/*US , const KInstance* inst*/ )
1571{ 1570{
1572 // try to find slashes. If there are some, we have to 1571 // try to find slashes. If there are some, we have to
1573 // create the subdir first 1572 // create the subdir first
1574 int slash = filename.findRev('/')+1; 1573 int slash = filename.findRev('/')+1;
1575 if (!slash) // only one filename 1574 if (!slash) // only one filename
1576 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename; 1575 //USreturn inst->dirs()->saveLocation(type, QString::null, createDir) + filename;
1577 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename; 1576 return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename;
1578 1577
1579 // split path from filename 1578 // split path from filename
1580 QString dir = filename.left(slash); 1579 QString dir = filename.left(slash);
1581 QString file = filename.mid(slash); 1580 QString file = filename.mid(slash);
1582//US return inst->dirs()->saveLocation(type, dir, createDir) + file; 1581//US return inst->dirs()->saveLocation(type, dir, createDir) + file;
1583 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file; 1582 return KGlobal::dirs()->saveLocation(type, dir, createDir) + file;
1584 1583
1585 // *************************************************************** 1584 // ***************************************************************
1586#if 0 1585#if 0
1587 1586
1588/*US why do we put all files into one directory. It is quit complicated. 1587/*US why do we put all files into one directory. It is quit complicated.
1589why not staying with the original directorystructure ? 1588why not staying with the original directorystructure ?
1590 1589
1591 1590
1592 QString escapedFilename = filename; 1591 QString escapedFilename = filename;
1593 escapedFilename.replace( QRegExp( "/" ), "_" ); 1592 escapedFilename.replace( QRegExp( "/" ), "_" );
1594 1593
1595 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; 1594 QString path = KStandardDirs::appDir() + type + "_" + escapedFilename;
1596 1595
1597 kdDebug() << "locate: '" << path << "'" << endl; 1596 kdDebug() << "locate: '" << path << "'" << endl;
1598 qDebug("locate: %s" , path.latin1()); 1597 qDebug("locate: %s" , path.latin1());
1599 return path; 1598 return path;
1600*/ 1599*/
1601//US so my proposal is this: 1600//US so my proposal is this:
1602 1601
1603// QString escapedFilename = filename; 1602// QString escapedFilename = filename;
1604// escapedFilename.replace( QRegExp( "/" ), "_" ); 1603// escapedFilename.replace( QRegExp( "/" ), "_" );
1605 1604
1606#ifdef _WIN32_ 1605#ifdef _WIN32_
1607 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); 1606 QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename);
1608#else 1607#else
1609 QString path = KStandardDirs::appDir() + type + "/" + filename; 1608 QString path = KStandardDirs::appDir() + type + "/" + filename;
1610#endif 1609#endif
1611 1610
1612 //US Create the containing dir if needed 1611 //US Create the containing dir if needed
1613 KURL pathurl; 1612 KURL pathurl;
1614 pathurl.setPath(path); 1613 pathurl.setPath(path);
1615 QString dir=pathurl.directory(); 1614 QString dir=pathurl.directory();
1616 //QMessageBox::information( 0,"path", path, 1 ); 1615 //QMessageBox::information( 0,"path", path, 1 );
1617#ifdef _WIN32_ 1616#ifdef _WIN32_
1618 KStandardDirs::makeDir(path); 1617 KStandardDirs::makeDir(path);
1619#else 1618#else
1620 KStandardDirs::makeDir(dir); 1619 KStandardDirs::makeDir(dir);
1621#endif 1620#endif
1622 1621
1623 return path; 1622 return path;
1624#endif 1623#endif
1625} 1624}
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index 92cb8d2..79b0f9d 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -3,2049 +3,2049 @@
3 (C) 2000 Reginald Stadlbauer (reggie@kde.org) 3 (C) 2000 Reginald Stadlbauer (reggie@kde.org)
4 (C) 1997, 1998 Stephan Kulow (coolo@kde.org) 4 (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) 5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
6 (C) 1997, 1998 Sven Radej (radej@kde.org) 6 (C) 1997, 1998 Sven Radej (radej@kde.org)
7 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) 7 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
8 (C) 1999 Chris Schlaeger (cs@kde.org) 8 (C) 1999 Chris Schlaeger (cs@kde.org)
9 (C) 1999 Kurt Granroth (granroth@kde.org) 9 (C) 1999 Kurt Granroth (granroth@kde.org)
10 10
11 This library is free software; you can redistribute it and/or 11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public 12 modify it under the terms of the GNU Library General Public
13 License version 2 as published by the Free Software Foundation. 13 License version 2 as published by the Free Software Foundation.
14 14
15 This library is distributed in the hope that it will be useful, 15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details. 18 Library General Public License for more details.
19 19
20 You should have received a copy of the GNU Library General Public License 20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to 21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. 23 Boston, MA 02111-1307, USA.
24*/ 24*/
25 25
26#ifdef KDE_USE_FINAL 26#ifdef KDE_USE_FINAL
27#undef Always 27#undef Always
28#include <qdockwindow.h> 28#include <qdockwindow.h>
29#endif 29#endif
30 30
31 31
32 32
33#include "ktoolbar.h" 33#include "ktoolbar.h"
34#include "kmainwindow.h" 34#include "kmainwindow.h"
35 35
36#include <string.h> 36#include <string.h>
37 37
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qtooltip.h> 39#include <qtooltip.h>
40#include <qdrawutil.h> 40#include <qdrawutil.h>
41#include <qstring.h> 41#include <qstring.h>
42#include <qrect.h> 42#include <qrect.h>
43#include <qobjectlist.h> 43#include <qobjectlist.h>
44#include <qtimer.h> 44#include <qtimer.h>
45#include <qstyle.h> 45#include <qstyle.h>
46#include <qapplication.h> 46#include <qapplication.h>
47 47
48//US #include <config.h> 48//US #include <config.h>
49 49
50#include "klineedit.h" 50#include "klineedit.h"
51#include "kseparator.h" 51#include "kseparator.h"
52#include <klocale.h> 52#include <klocale.h>
53#include <kapplication.h> 53#include <kapplication.h>
54#include <kaction.h> 54#include <kaction.h>
55#include <kstdaction.h> 55#include <kstdaction.h>
56#include <kglobal.h> 56#include <kglobal.h>
57#include <kconfig.h> 57#include <kconfig.h>
58#include <kiconloader.h> 58#include <kiconloader.h>
59#include <kcombobox.h> 59#include <kcombobox.h>
60//US #include <kpopupmenu.h> 60//US #include <kpopupmenu.h>
61//US #include <kanimwidget.h> 61//US #include <kanimwidget.h>
62//US #include <kipc.h> 62//US #include <kipc.h>
63//US #include <kwin.h> 63//US #include <kwin.h>
64#include <kdebug.h> 64#include <kdebug.h>
65#include <qlayout.h> 65#include <qlayout.h>
66 66
67#include "ktoolbarbutton.h" 67#include "ktoolbarbutton.h"
68 68
69//US 69//US
70#include "kconfigbase.h" 70#include "kconfigbase.h"
71 71
72#include <qpopupmenu.h> 72#include <qpopupmenu.h>
73#include <qmainwindow.h> 73#include <qmainwindow.h>
74 74
75enum { 75enum {
76 CONTEXT_TOP = 0, 76 CONTEXT_TOP = 0,
77 CONTEXT_LEFT = 1, 77 CONTEXT_LEFT = 1,
78 CONTEXT_RIGHT = 2, 78 CONTEXT_RIGHT = 2,
79 CONTEXT_BOTTOM = 3, 79 CONTEXT_BOTTOM = 3,
80 CONTEXT_FLOAT = 4, 80 CONTEXT_FLOAT = 4,
81 CONTEXT_FLAT = 5, 81 CONTEXT_FLAT = 5,
82 CONTEXT_ICONS = 6, 82 CONTEXT_ICONS = 6,
83 CONTEXT_TEXT = 7, 83 CONTEXT_TEXT = 7,
84 CONTEXT_TEXTRIGHT = 8, 84 CONTEXT_TEXTRIGHT = 8,
85 CONTEXT_TEXTUNDER = 9, 85 CONTEXT_TEXTUNDER = 9,
86 CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before 86 CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before
87}; 87};
88 88
89class KToolBarPrivate 89class KToolBarPrivate
90{ 90{
91public: 91public:
92 KToolBarPrivate() { 92 KToolBarPrivate() {
93 m_iconSize = 0; 93 m_iconSize = 0;
94 m_iconText = KToolBar::IconOnly; 94 m_iconText = KToolBar::IconOnly;
95 m_highlight = true; 95 m_highlight = true;
96 m_transparent = true; 96 m_transparent = true;
97 m_honorStyle = false; 97 m_honorStyle = false;
98 98
99 m_enableContext = true; 99 m_enableContext = true;
100 100
101 m_xmlguiClient = 0; 101 m_xmlguiClient = 0;
102 m_configurePlugged = false; 102 m_configurePlugged = false;
103 103
104//US oldPos = Qt::DockUnmanaged; 104//US oldPos = Qt::DockUnmanaged;
105 oldPos = QMainWindow::Unmanaged; 105 oldPos = QMainWindow::Unmanaged;
106 106
107 modified = m_isHorizontal = positioned = FALSE; 107 modified = m_isHorizontal = positioned = FALSE;
108 108
109 HiddenDefault = false; 109 HiddenDefault = false;
110 IconSizeDefault = 0; 110 IconSizeDefault = 0;
111 IconTextDefault = "IconOnly"; 111 IconTextDefault = "IconOnly";
112 IndexDefault = -1; 112 IndexDefault = -1;
113 NewLineDefault = false; 113 NewLineDefault = false;
114 OffsetDefault = -1; 114 OffsetDefault = -1;
115 PositionDefault = "Top"; 115 PositionDefault = "Top";
116 idleButtons.setAutoDelete(true); 116 idleButtons.setAutoDelete(true);
117 } 117 }
118 118
119 int m_iconSize; 119 int m_iconSize;
120 KToolBar::IconText m_iconText; 120 KToolBar::IconText m_iconText;
121 bool m_highlight : 1; 121 bool m_highlight : 1;
122 bool m_transparent : 1; 122 bool m_transparent : 1;
123 bool m_honorStyle : 1; 123 bool m_honorStyle : 1;
124 bool m_isHorizontal : 1; 124 bool m_isHorizontal : 1;
125 bool m_enableContext : 1; 125 bool m_enableContext : 1;
126 bool m_configurePlugged : 1; 126 bool m_configurePlugged : 1;
127 bool modified : 1; 127 bool modified : 1;
128 bool positioned : 1; 128 bool positioned : 1;
129 129
130 QWidget *m_parent; 130 QWidget *m_parent;
131 131
132 QMainWindow::ToolBarDock oldPos; 132 QMainWindow::ToolBarDock oldPos;
133 133
134 KXMLGUIClient *m_xmlguiClient; 134 KXMLGUIClient *m_xmlguiClient;
135 135
136 struct ToolBarInfo 136 struct ToolBarInfo
137 { 137 {
138//US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} 138//US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {}
139 ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {} 139 ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {}
140//US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} 140//US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {}
141 ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} 141 ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {}
142 int index, offset; 142 int index, offset;
143 bool newline; 143 bool newline;
144//US Qt::Dock dock; 144//US Qt::Dock dock;
145 QMainWindow::ToolBarDock dock; 145 QMainWindow::ToolBarDock dock;
146 }; 146 };
147 147
148 ToolBarInfo toolBarInfo; 148 ToolBarInfo toolBarInfo;
149 QValueList<int> iconSizes; 149 QValueList<int> iconSizes;
150 QTimer repaintTimer; 150 QTimer repaintTimer;
151 151
152 // Default Values. 152 // Default Values.
153 bool HiddenDefault; 153 bool HiddenDefault;
154 int IconSizeDefault; 154 int IconSizeDefault;
155 QString IconTextDefault; 155 QString IconTextDefault;
156 int IndexDefault; 156 int IndexDefault;
157 bool NewLineDefault; 157 bool NewLineDefault;
158 int OffsetDefault; 158 int OffsetDefault;
159 QString PositionDefault; 159 QString PositionDefault;
160 160
161 QPtrList<QWidget> idleButtons; 161 QPtrList<QWidget> idleButtons;
162}; 162};
163 163
164KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, 164KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent,
165 const char* name ) 165 const char* name )
166 :QFrame( parent, name ), line( l ) 166 :QFrame( parent, name ), line( l )
167{ 167{
168 connect( parent, SIGNAL(orientationChanged(Orientation)), 168 connect( parent, SIGNAL(orientationChanged(Orientation)),
169 this, SLOT(setOrientation(Orientation)) ); 169 this, SLOT(setOrientation(Orientation)) );
170 setOrientation( o ); 170 setOrientation( o );
171 setBackgroundMode( parent->backgroundMode() ); 171 setBackgroundMode( parent->backgroundMode() );
172 setBackgroundOrigin( ParentOrigin ); 172 setBackgroundOrigin( ParentOrigin );
173} 173}
174 174
175void KToolBarSeparator::setOrientation( Orientation o ) 175void KToolBarSeparator::setOrientation( Orientation o )
176{ 176{
177 orient = o; 177 orient = o;
178 if ( line ) { 178 if ( line ) {
179 if ( orientation() == Vertical ) 179 if ( orientation() == Vertical )
180 setFrameStyle( HLine + Sunken ); 180 setFrameStyle( HLine + Sunken );
181 else 181 else
182 setFrameStyle( VLine + Sunken ); 182 setFrameStyle( VLine + Sunken );
183 } else { 183 } else {
184 setFrameStyle( NoFrame ); 184 setFrameStyle( NoFrame );
185 } 185 }
186} 186}
187 187
188void KToolBarSeparator::styleChange( QStyle& ) 188void KToolBarSeparator::styleChange( QStyle& )
189{ 189{
190 setOrientation( orient ); 190 setOrientation( orient );
191} 191}
192 192
193QSize KToolBarSeparator::sizeHint() const 193QSize KToolBarSeparator::sizeHint() const
194{ 194{
195 return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); 195 return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 );
196} 196}
197 197
198QSizePolicy KToolBarSeparator::sizePolicy() const 198QSizePolicy KToolBarSeparator::sizePolicy() const
199{ 199{
200 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); 200 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
201} 201}
202 202
203KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) 203KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig )
204#ifdef DESKTOP_VERSION 204#ifdef DESKTOP_VERSION
205 : QToolBar( QString::fromLatin1( name ), 205 : QToolBar( QString::fromLatin1( name ),
206 parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, 206 parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0,
207 parent, FALSE, 207 parent, FALSE,
208 name ? name : "mainToolBar") 208 name ? name : "mainToolBar")
209#else 209#else
210 : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, 210 : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0,
211 QString::fromLatin1( name )) 211 QString::fromLatin1( name ))
212 212
213 213
214#endif 214#endif
215{ 215{
216 init( readConfig, honorStyle ); 216 init( readConfig, honorStyle );
217} 217}
218 218
219KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) 219KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig )
220#ifdef DESKTOP_VERSION 220#ifdef DESKTOP_VERSION
221 : QToolBar( QString::fromLatin1( name ), 221 : QToolBar( QString::fromLatin1( name ),
222 parentWindow, dock, newLine, 222 parentWindow, dock, newLine,
223 name ? name : "mainToolBar") 223 name ? name : "mainToolBar")
224#else 224#else
225 : QPEToolBar( parentWindow,QString::fromLatin1( name )) 225 : QPEToolBar( parentWindow,QString::fromLatin1( name ))
226 226
227 227
228#endif 228#endif
229 229
230{ 230{
231 init( readConfig, honorStyle ); 231 init( readConfig, honorStyle );
232} 232}
233 233
234KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) 234KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig )
235#ifdef DESKTOP_VERSION 235#ifdef DESKTOP_VERSION
236 : QToolBar( QString::fromLatin1( name ), 236 : QToolBar( QString::fromLatin1( name ),
237 parentWindow, dock, newLine, 237 parentWindow, dock, newLine,
238 name ? name : "mainToolBar") 238 name ? name : "mainToolBar")
239#else 239#else
240 : QPEToolBar( parentWindow,QString::fromLatin1( name )) 240 : QPEToolBar( parentWindow,QString::fromLatin1( name ))
241 241
242 242
243#endif 243#endif
244 244
245{ 245{
246 init( readConfig, honorStyle ); 246 init( readConfig, honorStyle );
247} 247}
248 248
249KToolBar::~KToolBar() 249KToolBar::~KToolBar()
250{ 250{
251 inshutdownprocess = true; 251 inshutdownprocess = true;
252 emit toolbarDestroyed(); 252 emit toolbarDestroyed();
253 delete d; 253 delete d;
254} 254}
255 255
256void KToolBar::init( bool readConfig, bool honorStyle ) 256void KToolBar::init( bool readConfig, bool honorStyle )
257{ 257{
258 inshutdownprocess = false; 258 inshutdownprocess = false;
259 d = new KToolBarPrivate; 259 d = new KToolBarPrivate;
260 setFullSize( TRUE ); 260 setFullSize( TRUE );
261 d->m_honorStyle = honorStyle; 261 d->m_honorStyle = honorStyle;
262 context = 0; 262 context = 0;
263 layoutTimer = new QTimer( this ); 263 layoutTimer = new QTimer( this );
264 connect( layoutTimer, SIGNAL( timeout() ), 264 connect( layoutTimer, SIGNAL( timeout() ),
265 this, SLOT( rebuildLayout() ) ); 265 this, SLOT( rebuildLayout() ) );
266 connect( &(d->repaintTimer), SIGNAL( timeout() ), 266 connect( &(d->repaintTimer), SIGNAL( timeout() ),
267 this, SLOT( slotRepaint() ) ); 267 this, SLOT( slotRepaint() ) );
268/*US 268/*US
269 if ( kapp ) { // may be null when started inside designer 269 if ( kapp ) { // may be null when started inside designer
270 connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); 270 connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged()));
271 // request notification of changes in icon style 271 // request notification of changes in icon style
272 kapp->addKipcEventMask(KIPC::IconChanged); 272 kapp->addKipcEventMask(KIPC::IconChanged);
273 connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); 273 connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int)));
274 } 274 }
275*/ 275*/
276 // finally, read in our configurable settings 276 // finally, read in our configurable settings
277 if ( readConfig ) 277 if ( readConfig )
278 slotReadConfig(); 278 slotReadConfig();
279 279
280 if ( mainWindow() ) 280 if ( mainWindow() )
281 connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), 281 connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ),
282 this, SLOT( toolBarPosChanged( QToolBar * ) ) ); 282 this, SLOT( toolBarPosChanged( QToolBar * ) ) );
283 283
284 // Hack to make sure we recalculate our size when we dock. 284 // Hack to make sure we recalculate our size when we dock.
285//US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); 285//US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) );
286} 286}
287 287
288int KToolBar::insertButton(const QString& icon, int id, bool enabled, 288int KToolBar::insertButton(const QString& icon, int id, bool enabled,
289 const QString& text, int index/*US, KInstance *_instance*/ ) 289 const QString& text, int index/*US, KInstance *_instance*/ )
290{ 290{
291 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); 291 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ );
292 292
293 insertWidgetInternal( button, index, id ); 293 insertWidgetInternal( button, index, id );
294 button->setEnabled( enabled ); 294 button->setEnabled( enabled );
295 doConnections( button ); 295 doConnections( button );
296 return index; 296 return index;
297} 297}
298 298
299 299
300int KToolBar::insertButton(const QString& icon, int id, const char *signal, 300int KToolBar::insertButton(const QString& icon, int id, const char *signal,
301 const QObject *receiver, const char *slot, 301 const QObject *receiver, const char *slot,
302 bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) 302 bool enabled, const QString& text, int index/*US, KInstance *_instance*/ )
303{ 303{
304 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); 304 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/);
305 insertWidgetInternal( button, index, id ); 305 insertWidgetInternal( button, index, id );
306 button->setEnabled( enabled ); 306 button->setEnabled( enabled );
307 connect( button, signal, receiver, slot ); 307 connect( button, signal, receiver, slot );
308 doConnections( button ); 308 doConnections( button );
309 return index; 309 return index;
310} 310}
311 311
312 312
313int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, 313int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled,
314 const QString& text, int index ) 314 const QString& text, int index )
315{ 315{
316 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); 316 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text);
317 insertWidgetInternal( button, index, id ); 317 insertWidgetInternal( button, index, id );
318 button->setEnabled( enabled ); 318 button->setEnabled( enabled );
319 doConnections( button ); 319 doConnections( button );
320 return index; 320 return index;
321} 321}
322#if 0 322#if 0
323 bar->insertButton( icon, id_, SIGNAL( clicked() ), this, 323 bar->insertButton( icon, id_, SIGNAL( clicked() ), this,
324 SLOT( slotActivated() ), 324 SLOT( slotActivated() ),
325 d->isEnabled(), d->plainText(), index/*US, instance*/ ); 325 d->isEnabled(), d->plainText(), index/*US, instance*/ );
326#endif 326#endif
327 327
328int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, 328int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal,
329 const QObject *receiver, const char *slot, 329 const QObject *receiver, const char *slot,
330 bool enabled, const QString& text, 330 bool enabled, const QString& text,
331 int index ) 331 int index )
332{ 332{
333 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); 333 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text);
334 insertWidgetInternal( button, index, id ); 334 insertWidgetInternal( button, index, id );
335 button->setEnabled( enabled ); 335 button->setEnabled( enabled );
336 connect( button, signal, receiver, slot ); 336 connect( button, signal, receiver, slot );
337 doConnections( button ); 337 doConnections( button );
338 return index; 338 return index;
339} 339}
340 340
341 341
342int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, 342int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup,
343 bool enabled, const QString &text, int index ) 343 bool enabled, const QString &text, int index )
344{ 344{
345 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); 345 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text );
346 insertWidgetInternal( button, index, id ); 346 insertWidgetInternal( button, index, id );
347 button->setEnabled( enabled ); 347 button->setEnabled( enabled );
348 button->setPopup( popup ); 348 button->setPopup( popup );
349 doConnections( button ); 349 doConnections( button );
350 return index; 350 return index;
351} 351}
352 352
353 353
354int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, 354int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup,
355 bool enabled, const QString &text, int index ) 355 bool enabled, const QString &text, int index )
356{ 356{
357 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); 357 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text );
358 insertWidgetInternal( button, index, id ); 358 insertWidgetInternal( button, index, id );
359 button->setEnabled( enabled ); 359 button->setEnabled( enabled );
360 button->setPopup( popup ); 360 button->setPopup( popup );
361 doConnections( button ); 361 doConnections( button );
362 return index; 362 return index;
363} 363}
364 364
365 365
366int KToolBar::insertLined (const QString& text, int id, 366int KToolBar::insertLined (const QString& text, int id,
367 const char *signal, 367 const char *signal,
368 const QObject *receiver, const char *slot, 368 const QObject *receiver, const char *slot,
369 bool enabled , 369 bool enabled ,
370 const QString& toolTipText, 370 const QString& toolTipText,
371 int size, int index ) 371 int size, int index )
372{ 372{
373 KLineEdit *lined = new KLineEdit ( this, 0 ); 373 KLineEdit *lined = new KLineEdit ( this, 0 );
374 if ( !toolTipText.isEmpty() ) 374 if ( !toolTipText.isEmpty() )
375 QToolTip::add( lined, toolTipText ); 375 QToolTip::add( lined, toolTipText );
376 if ( size > 0 ) 376 if ( size > 0 )
377 lined->setMinimumWidth( size ); 377 lined->setMinimumWidth( size );
378 insertWidgetInternal( lined, index, id ); 378 insertWidgetInternal( lined, index, id );
379 connect( lined, signal, receiver, slot ); 379 connect( lined, signal, receiver, slot );
380 lined->setText(text); 380 lined->setText(text);
381 lined->setEnabled( enabled ); 381 lined->setEnabled( enabled );
382 return index; 382 return index;
383} 383}
384 384
385int KToolBar::insertCombo (const QStringList &list, int id, bool writable, 385int KToolBar::insertCombo (const QStringList &list, int id, bool writable,
386 const char *signal, const QObject *receiver, 386 const char *signal, const QObject *receiver,
387 const char *slot, bool enabled, 387 const char *slot, bool enabled,
388 const QString& tooltiptext, 388 const QString& tooltiptext,
389 int size, int index, 389 int size, int index,
390 QComboBox::Policy policy ) 390 QComboBox::Policy policy )
391{ 391{
392//US KComboBox *combo = new KComboBox ( writable, this ); 392//US KComboBox *combo = new KComboBox ( writable, this );
393 KComboBox *combo = new KComboBox ( this ); 393 KComboBox *combo = new KComboBox ( this );
394 combo->setEditable(writable); 394 combo->setEditable(writable);
395 395
396 insertWidgetInternal( combo, index, id ); 396 insertWidgetInternal( combo, index, id );
397 combo->insertStringList (list); 397 combo->insertStringList (list);
398 combo->setInsertionPolicy(policy); 398 combo->setInsertionPolicy(policy);
399 combo->setEnabled( enabled ); 399 combo->setEnabled( enabled );
400 if ( !tooltiptext.isEmpty() ) 400 if ( !tooltiptext.isEmpty() )
401 QToolTip::add( combo, tooltiptext ); 401 QToolTip::add( combo, tooltiptext );
402 if ( size > 0 ) 402 if ( size > 0 )
403 combo->setMinimumWidth( size ); 403 combo->setMinimumWidth( size );
404 if (!tooltiptext.isNull()) 404 if (!tooltiptext.isNull())
405 QToolTip::add( combo, tooltiptext ); 405 QToolTip::add( combo, tooltiptext );
406 406
407 if ( signal && receiver && slot ) 407 if ( signal && receiver && slot )
408 connect ( combo, signal, receiver, slot ); 408 connect ( combo, signal, receiver, slot );
409 return index; 409 return index;
410} 410}
411 411
412 412
413int KToolBar::insertCombo (const QString& text, int id, bool writable, 413int KToolBar::insertCombo (const QString& text, int id, bool writable,
414 const char *signal, QObject *receiver, 414 const char *signal, QObject *receiver,
415 const char *slot, bool enabled, 415 const char *slot, bool enabled,
416 const QString& tooltiptext, 416 const QString& tooltiptext,
417 int size, int index, 417 int size, int index,
418 QComboBox::Policy policy ) 418 QComboBox::Policy policy )
419{ 419{
420//US KComboBox *combo = new KComboBox ( writable, this ); 420//US KComboBox *combo = new KComboBox ( writable, this );
421 KComboBox *combo = new KComboBox ( this ); 421 KComboBox *combo = new KComboBox ( this );
422 combo->setEditable(writable); 422 combo->setEditable(writable);
423 423
424 insertWidgetInternal( combo, index, id ); 424 insertWidgetInternal( combo, index, id );
425 combo->insertItem (text); 425 combo->insertItem (text);
426 combo->setInsertionPolicy(policy); 426 combo->setInsertionPolicy(policy);
427 combo->setEnabled( enabled ); 427 combo->setEnabled( enabled );
428 if ( !tooltiptext.isEmpty() ) 428 if ( !tooltiptext.isEmpty() )
429 QToolTip::add( combo, tooltiptext ); 429 QToolTip::add( combo, tooltiptext );
430 if ( size > 0 ) 430 if ( size > 0 )
431 combo->setMinimumWidth( size ); 431 combo->setMinimumWidth( size );
432 if (!tooltiptext.isNull()) 432 if (!tooltiptext.isNull())
433 QToolTip::add( combo, tooltiptext ); 433 QToolTip::add( combo, tooltiptext );
434 connect (combo, signal, receiver, slot); 434 connect (combo, signal, receiver, slot);
435 return index; 435 return index;
436} 436}
437 437
438int KToolBar::insertSeparator(int index, int id) 438int KToolBar::insertSeparator(int index, int id)
439{ 439{
440 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); 440 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" );
441 insertWidgetInternal( w, index, id ); 441 insertWidgetInternal( w, index, id );
442 return index; 442 return index;
443} 443}
444 444
445int KToolBar::insertLineSeparator(int index, int id) 445int KToolBar::insertLineSeparator(int index, int id)
446{ 446{
447 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); 447 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" );
448 insertWidgetInternal( w, index, id ); 448 insertWidgetInternal( w, index, id );
449 return index; 449 return index;
450} 450}
451 451
452 452
453int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) 453int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index)
454{ 454{
455 // removeWidgetInternal( widget ); // in case we already have it ? 455 // removeWidgetInternal( widget ); // in case we already have it ?
456 insertWidgetInternal( widget, index, id ); 456 insertWidgetInternal( widget, index, id );
457 return index; 457 return index;
458} 458}
459/*US 459/*US
460int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, 460int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot,
461 const QString& icons, int index ) 461 const QString& icons, int index )
462{ 462{
463 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); 463 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this );
464 insertWidgetInternal( anim, index, id ); 464 insertWidgetInternal( anim, index, id );
465 465
466 if ( receiver ) 466 if ( receiver )
467 connect( anim, SIGNAL(clicked()), receiver, slot); 467 connect( anim, SIGNAL(clicked()), receiver, slot);
468 468
469 return index; 469 return index;
470} 470}
471 471
472KAnimWidget *KToolBar::animatedWidget( int id ) 472KAnimWidget *KToolBar::animatedWidget( int id )
473{ 473{
474 Id2WidgetMap::Iterator it = id2widget.find( id ); 474 Id2WidgetMap::Iterator it = id2widget.find( id );
475 if ( it == id2widget.end() ) 475 if ( it == id2widget.end() )
476 return 0; 476 return 0;
477 if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) 477 if ( (*it) && (*it)->inherits( "KAnimWidget" ) )
478 return (KAnimWidget*)(*it); 478 return (KAnimWidget*)(*it);
479 QObjectList *l = queryList( "KAnimWidget" ); 479 QObjectList *l = queryList( "KAnimWidget" );
480 if ( !l || !l->first() ) { 480 if ( !l || !l->first() ) {
481 delete l; 481 delete l;
482 return 0; 482 return 0;
483 } 483 }
484 484
485 for ( QObject *o = l->first(); o; o = l->next() ) { 485 for ( QObject *o = l->first(); o; o = l->next() ) {
486 if ( o->inherits( "KAnimWidget" ) ) 486 if ( o->inherits( "KAnimWidget" ) )
487 { 487 {
488 delete l; 488 delete l;
489 return (KAnimWidget*)o; 489 return (KAnimWidget*)o;
490 } 490 }
491 } 491 }
492 492
493 delete l; 493 delete l;
494 return 0; 494 return 0;
495} 495}
496*/ 496*/
497 497
498void KToolBar::addConnection (int id, const char *signal, 498void KToolBar::addConnection (int id, const char *signal,
499 const QObject *receiver, const char *slot) 499 const QObject *receiver, const char *slot)
500{ 500{
501 Id2WidgetMap::Iterator it = id2widget.find( id ); 501 Id2WidgetMap::Iterator it = id2widget.find( id );
502 if ( it == id2widget.end() ) 502 if ( it == id2widget.end() )
503 return; 503 return;
504 if ( (*it) ) 504 if ( (*it) )
505 connect( (*it), signal, receiver, slot ); 505 connect( (*it), signal, receiver, slot );
506} 506}
507 507
508void KToolBar::setItemEnabled( int id, bool enabled ) 508void KToolBar::setItemEnabled( int id, bool enabled )
509{ 509{
510 Id2WidgetMap::Iterator it = id2widget.find( id ); 510 Id2WidgetMap::Iterator it = id2widget.find( id );
511 if ( it == id2widget.end() ) 511 if ( it == id2widget.end() )
512 return; 512 return;
513 if ( (*it) ) 513 if ( (*it) )
514 (*it)->setEnabled( enabled ); 514 (*it)->setEnabled( enabled );
515} 515}
516 516
517 517
518void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) 518void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap )
519{ 519{
520 Id2WidgetMap::Iterator it = id2widget.find( id ); 520 Id2WidgetMap::Iterator it = id2widget.find( id );
521 if ( it == id2widget.end() ) 521 if ( it == id2widget.end() )
522 return; 522 return;
523//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 523//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
524 KToolBarButton * button = (KToolBarButton *)( *it ); 524 KToolBarButton * button = (KToolBarButton *)( *it );
525 if ( button ) 525 if ( button )
526 button->setPixmap( _pixmap ); 526 button->setPixmap( _pixmap );
527} 527}
528 528
529 529
530void KToolBar::setButtonIcon( int id, const QString& _icon ) 530void KToolBar::setButtonIcon( int id, const QString& _icon )
531{ 531{
532 Id2WidgetMap::Iterator it = id2widget.find( id ); 532 Id2WidgetMap::Iterator it = id2widget.find( id );
533 if ( it == id2widget.end() ) 533 if ( it == id2widget.end() )
534 return; 534 return;
535//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 535//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
536 KToolBarButton * button = (KToolBarButton *)( *it ); 536 KToolBarButton * button = (KToolBarButton *)( *it );
537 if ( button ) 537 if ( button )
538 button->setIcon( _icon ); 538 button->setIcon( _icon );
539} 539}
540 540
541void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) 541void KToolBar::setButtonIconSet( int id, const QIconSet& iconset )
542{ 542{
543 Id2WidgetMap::Iterator it = id2widget.find( id ); 543 Id2WidgetMap::Iterator it = id2widget.find( id );
544 if ( it == id2widget.end() ) 544 if ( it == id2widget.end() )
545 return; 545 return;
546//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 546//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
547 KToolBarButton * button = (KToolBarButton *)( *it ); 547 KToolBarButton * button = (KToolBarButton *)( *it );
548 if ( button ) 548 if ( button )
549 button->setIconSet( iconset ); 549 button->setIconSet( iconset );
550} 550}
551 551
552 552
553void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) 553void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle )
554{ 554{
555 Id2WidgetMap::Iterator it = id2widget.find( id ); 555 Id2WidgetMap::Iterator it = id2widget.find( id );
556 if ( it == id2widget.end() ) 556 if ( it == id2widget.end() )
557 return; 557 return;
558//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 558//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
559 KToolBarButton * button = (KToolBarButton *)( *it ); 559 KToolBarButton * button = (KToolBarButton *)( *it );
560 if ( button ) 560 if ( button )
561 button->setDelayedPopup( _popup, toggle ); 561 button->setDelayedPopup( _popup, toggle );
562} 562}
563 563
564 564
565void KToolBar::setAutoRepeat (int id, bool flag) 565void KToolBar::setAutoRepeat (int id, bool flag)
566{ 566{
567 Id2WidgetMap::Iterator it = id2widget.find( id ); 567 Id2WidgetMap::Iterator it = id2widget.find( id );
568 if ( it == id2widget.end() ) 568 if ( it == id2widget.end() )
569 return; 569 return;
570//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 570//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
571 KToolBarButton * button = (KToolBarButton *)( *it ); 571 KToolBarButton * button = (KToolBarButton *)( *it );
572 if ( button ) 572 if ( button )
573 button->setAutoRepeat( flag ); 573 button->setAutoRepeat( flag );
574} 574}
575 575
576 576
577void KToolBar::setToggle (int id, bool flag ) 577void KToolBar::setToggle (int id, bool flag )
578{ 578{
579 Id2WidgetMap::Iterator it = id2widget.find( id ); 579 Id2WidgetMap::Iterator it = id2widget.find( id );
580 if ( it == id2widget.end() ) 580 if ( it == id2widget.end() )
581 return; 581 return;
582//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 582//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
583 KToolBarButton * button = (KToolBarButton *)( *it ); 583 KToolBarButton * button = (KToolBarButton *)( *it );
584 if ( button ) 584 if ( button )
585 button->setToggle( flag ); 585 button->setToggle( flag );
586} 586}
587 587
588 588
589void KToolBar::toggleButton (int id) 589void KToolBar::toggleButton (int id)
590{ 590{
591 Id2WidgetMap::Iterator it = id2widget.find( id ); 591 Id2WidgetMap::Iterator it = id2widget.find( id );
592 if ( it == id2widget.end() ) 592 if ( it == id2widget.end() )
593 return; 593 return;
594//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 594//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
595 KToolBarButton * button = (KToolBarButton *)( *it ); 595 KToolBarButton * button = (KToolBarButton *)( *it );
596 if ( button ) 596 if ( button )
597 button->toggle(); 597 button->toggle();
598} 598}
599 599
600 600
601void KToolBar::setButton (int id, bool flag) 601void KToolBar::setButton (int id, bool flag)
602{ 602{
603 Id2WidgetMap::Iterator it = id2widget.find( id ); 603 Id2WidgetMap::Iterator it = id2widget.find( id );
604 if ( it == id2widget.end() ) 604 if ( it == id2widget.end() )
605 return; 605 return;
606//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 606//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
607 KToolBarButton * button = (KToolBarButton *)( *it ); 607 KToolBarButton * button = (KToolBarButton *)( *it );
608 if ( button ) 608 if ( button )
609 button->on( flag ); 609 button->on( flag );
610} 610}
611 611
612 612
613bool KToolBar::isButtonOn (int id) const 613bool KToolBar::isButtonOn (int id) const
614{ 614{
615 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 615 Id2WidgetMap::ConstIterator it = id2widget.find( id );
616 if ( it == id2widget.end() ) 616 if ( it == id2widget.end() )
617 return false; 617 return false;
618//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 618//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
619 KToolBarButton * button = (KToolBarButton *)( *it ); 619 KToolBarButton * button = (KToolBarButton *)( *it );
620 return button ? button->isOn() : false; 620 return button ? button->isOn() : false;
621} 621}
622 622
623 623
624void KToolBar::setLinedText (int id, const QString& text) 624void KToolBar::setLinedText (int id, const QString& text)
625{ 625{
626 Id2WidgetMap::Iterator it = id2widget.find( id ); 626 Id2WidgetMap::Iterator it = id2widget.find( id );
627 if ( it == id2widget.end() ) 627 if ( it == id2widget.end() )
628 return; 628 return;
629//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 629//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
630 QLineEdit * lineEdit = (QLineEdit *)( *it ); 630 QLineEdit * lineEdit = (QLineEdit *)( *it );
631 if ( lineEdit ) 631 if ( lineEdit )
632 lineEdit->setText( text ); 632 lineEdit->setText( text );
633} 633}
634 634
635 635
636QString KToolBar::getLinedText (int id) const 636QString KToolBar::getLinedText (int id) const
637{ 637{
638 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 638 Id2WidgetMap::ConstIterator it = id2widget.find( id );
639 if ( it == id2widget.end() ) 639 if ( it == id2widget.end() )
640 return QString::null; 640 return QString::null;
641//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 641//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
642 QLineEdit * lineEdit = (QLineEdit *)( *it ); 642 QLineEdit * lineEdit = (QLineEdit *)( *it );
643 return lineEdit ? lineEdit->text() : QString::null; 643 return lineEdit ? lineEdit->text() : QString::null;
644} 644}
645 645
646 646
647void KToolBar::insertComboItem (int id, const QString& text, int index) 647void KToolBar::insertComboItem (int id, const QString& text, int index)
648{ 648{
649 Id2WidgetMap::Iterator it = id2widget.find( id ); 649 Id2WidgetMap::Iterator it = id2widget.find( id );
650 if ( it == id2widget.end() ) 650 if ( it == id2widget.end() )
651 return; 651 return;
652//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 652//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
653 QComboBox * comboBox = (QComboBox *)( *it ); 653 QComboBox * comboBox = (QComboBox *)( *it );
654 if (comboBox) 654 if (comboBox)
655 comboBox->insertItem( text, index ); 655 comboBox->insertItem( text, index );
656} 656}
657 657
658void KToolBar::insertComboList (int id, const QStringList &list, int index) 658void KToolBar::insertComboList (int id, const QStringList &list, int index)
659{ 659{
660 Id2WidgetMap::Iterator it = id2widget.find( id ); 660 Id2WidgetMap::Iterator it = id2widget.find( id );
661 if ( it == id2widget.end() ) 661 if ( it == id2widget.end() )
662 return; 662 return;
663//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 663//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
664 QComboBox * comboBox = (QComboBox *)( *it ); 664 QComboBox * comboBox = (QComboBox *)( *it );
665 if (comboBox) 665 if (comboBox)
666 comboBox->insertStringList( list, index ); 666 comboBox->insertStringList( list, index );
667} 667}
668 668
669 669
670void KToolBar::removeComboItem (int id, int index) 670void KToolBar::removeComboItem (int id, int index)
671{ 671{
672 Id2WidgetMap::Iterator it = id2widget.find( id ); 672 Id2WidgetMap::Iterator it = id2widget.find( id );
673 if ( it == id2widget.end() ) 673 if ( it == id2widget.end() )
674 return; 674 return;
675//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 675//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
676 QComboBox * comboBox = (QComboBox *)( *it ); 676 QComboBox * comboBox = (QComboBox *)( *it );
677 if (comboBox) 677 if (comboBox)
678 comboBox->removeItem( index ); 678 comboBox->removeItem( index );
679} 679}
680 680
681 681
682void KToolBar::setCurrentComboItem (int id, int index) 682void KToolBar::setCurrentComboItem (int id, int index)
683{ 683{
684 Id2WidgetMap::Iterator it = id2widget.find( id ); 684 Id2WidgetMap::Iterator it = id2widget.find( id );
685 if ( it == id2widget.end() ) 685 if ( it == id2widget.end() )
686 return; 686 return;
687//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 687//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
688 QComboBox * comboBox = (QComboBox *)( *it ); 688 QComboBox * comboBox = (QComboBox *)( *it );
689 if (comboBox) 689 if (comboBox)
690 comboBox->setCurrentItem( index ); 690 comboBox->setCurrentItem( index );
691} 691}
692 692
693 693
694void KToolBar::changeComboItem (int id, const QString& text, int index) 694void KToolBar::changeComboItem (int id, const QString& text, int index)
695{ 695{
696 Id2WidgetMap::Iterator it = id2widget.find( id ); 696 Id2WidgetMap::Iterator it = id2widget.find( id );
697 if ( it == id2widget.end() ) 697 if ( it == id2widget.end() )
698 return; 698 return;
699//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 699//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
700 QComboBox * comboBox = (QComboBox *)( *it ); 700 QComboBox * comboBox = (QComboBox *)( *it );
701 if (comboBox) 701 if (comboBox)
702 comboBox->changeItem( text, index ); 702 comboBox->changeItem( text, index );
703} 703}
704 704
705 705
706void KToolBar::clearCombo (int id) 706void KToolBar::clearCombo (int id)
707{ 707{
708 Id2WidgetMap::Iterator it = id2widget.find( id ); 708 Id2WidgetMap::Iterator it = id2widget.find( id );
709 if ( it == id2widget.end() ) 709 if ( it == id2widget.end() )
710 return; 710 return;
711//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 711//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
712 QComboBox * comboBox = (QComboBox *)( *it ); 712 QComboBox * comboBox = (QComboBox *)( *it );
713 if (comboBox) 713 if (comboBox)
714 comboBox->clear(); 714 comboBox->clear();
715} 715}
716 716
717 717
718QString KToolBar::getComboItem (int id, int index) const 718QString KToolBar::getComboItem (int id, int index) const
719{ 719{
720 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 720 Id2WidgetMap::ConstIterator it = id2widget.find( id );
721 if ( it == id2widget.end() ) 721 if ( it == id2widget.end() )
722 return QString::null; 722 return QString::null;
723//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 723//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
724 QComboBox * comboBox = (QComboBox *)( *it ); 724 QComboBox * comboBox = (QComboBox *)( *it );
725 return comboBox ? comboBox->text( index ) : QString::null; 725 return comboBox ? comboBox->text( index ) : QString::null;
726} 726}
727 727
728 728
729KComboBox * KToolBar::getCombo(int id) 729KComboBox * KToolBar::getCombo(int id)
730{ 730{
731 Id2WidgetMap::Iterator it = id2widget.find( id ); 731 Id2WidgetMap::Iterator it = id2widget.find( id );
732 if ( it == id2widget.end() ) 732 if ( it == id2widget.end() )
733 return 0; 733 return 0;
734//US return dynamic_cast<KComboBox *>( *it ); 734//US return dynamic_cast<KComboBox *>( *it );
735 return (KComboBox *)( *it ); 735 return (KComboBox *)( *it );
736} 736}
737 737
738 738
739KLineEdit * KToolBar::getLined (int id) 739KLineEdit * KToolBar::getLined (int id)
740{ 740{
741 Id2WidgetMap::Iterator it = id2widget.find( id ); 741 Id2WidgetMap::Iterator it = id2widget.find( id );
742 if ( it == id2widget.end() ) 742 if ( it == id2widget.end() )
743 return 0; 743 return 0;
744//US return dynamic_cast<KLineEdit *>( *it ); 744//US return dynamic_cast<KLineEdit *>( *it );
745 return (KLineEdit *)( *it ); 745 return (KLineEdit *)( *it );
746} 746}
747 747
748 748
749KToolBarButton * KToolBar::getButton (int id) 749KToolBarButton * KToolBar::getButton (int id)
750{ 750{
751 Id2WidgetMap::Iterator it = id2widget.find( id ); 751 Id2WidgetMap::Iterator it = id2widget.find( id );
752 if ( it == id2widget.end() ) 752 if ( it == id2widget.end() )
753 return 0; 753 return 0;
754//US return dynamic_cast<KToolBarButton *>( *it ); 754//US return dynamic_cast<KToolBarButton *>( *it );
755 return (KToolBarButton *)( *it ); 755 return (KToolBarButton *)( *it );
756} 756}
757 757
758 758
759void KToolBar::alignItemRight (int id, bool right ) 759void KToolBar::alignItemRight (int id, bool right )
760{ 760{
761 Id2WidgetMap::Iterator it = id2widget.find( id ); 761 Id2WidgetMap::Iterator it = id2widget.find( id );
762 if ( it == id2widget.end() ) 762 if ( it == id2widget.end() )
763 return; 763 return;
764 if ( rightAligned && !right && (*it) == rightAligned ) 764 if ( rightAligned && !right && (*it) == rightAligned )
765 rightAligned = 0; 765 rightAligned = 0;
766 if ( (*it) && right ) 766 if ( (*it) && right )
767 rightAligned = (*it); 767 rightAligned = (*it);
768} 768}
769 769
770 770
771QWidget *KToolBar::getWidget (int id) 771QWidget *KToolBar::getWidget (int id)
772{ 772{
773 Id2WidgetMap::Iterator it = id2widget.find( id ); 773 Id2WidgetMap::Iterator it = id2widget.find( id );
774 return ( it == id2widget.end() ) ? 0 : (*it); 774 return ( it == id2widget.end() ) ? 0 : (*it);
775} 775}
776 776
777 777
778void KToolBar::setItemAutoSized (int id, bool yes ) 778void KToolBar::setItemAutoSized (int id, bool yes )
779{ 779{
780 QWidget *w = getWidget(id); 780 QWidget *w = getWidget(id);
781 if ( w && yes ) 781 if ( w && yes )
782 setStretchableWidget( w ); 782 setStretchableWidget( w );
783} 783}
784 784
785 785
786void KToolBar::clear () 786void KToolBar::clear ()
787{ 787{
788 QToolBar::clear(); 788 QToolBar::clear();
789 widget2id.clear(); 789 widget2id.clear();
790 id2widget.clear(); 790 id2widget.clear();
791} 791}
792 792
793 793
794void KToolBar::removeItem(int id) 794void KToolBar::removeItem(int id)
795{ 795{
796 Id2WidgetMap::Iterator it = id2widget.find( id ); 796 Id2WidgetMap::Iterator it = id2widget.find( id );
797 if ( it == id2widget.end() ) 797 if ( it == id2widget.end() )
798 { 798 {
799 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 799 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
800 return; 800 return;
801 } 801 }
802 QWidget * w = (*it); 802 QWidget * w = (*it);
803 id2widget.remove( id ); 803 id2widget.remove( id );
804 widget2id.remove( w ); 804 widget2id.remove( w );
805 widgets.removeRef( w ); 805 widgets.removeRef( w );
806 delete w; 806 delete w;
807} 807}
808 808
809 809
810void KToolBar::removeItemDelayed(int id) 810void KToolBar::removeItemDelayed(int id)
811{ 811{
812 Id2WidgetMap::Iterator it = id2widget.find( id ); 812 Id2WidgetMap::Iterator it = id2widget.find( id );
813 if ( it == id2widget.end() ) 813 if ( it == id2widget.end() )
814 { 814 {
815 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 815 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
816 return; 816 return;
817 } 817 }
818 QWidget * w = (*it); 818 QWidget * w = (*it);
819 id2widget.remove( id ); 819 id2widget.remove( id );
820 widget2id.remove( w ); 820 widget2id.remove( w );
821 widgets.removeRef( w ); 821 widgets.removeRef( w );
822 822
823 w->blockSignals(true); 823 w->blockSignals(true);
824 d->idleButtons.append(w); 824 d->idleButtons.append(w);
825 layoutTimer->start( 50, TRUE ); 825 layoutTimer->start( 50, TRUE );
826} 826}
827 827
828 828
829void KToolBar::hideItem (int id) 829void KToolBar::hideItem (int id)
830{ 830{
831 QWidget *w = getWidget(id); 831 QWidget *w = getWidget(id);
832 if ( w ) 832 if ( w )
833 w->hide(); 833 w->hide();
834} 834}
835 835
836 836
837void KToolBar::showItem (int id) 837void KToolBar::showItem (int id)
838{ 838{
839 QWidget *w = getWidget(id); 839 QWidget *w = getWidget(id);
840 if ( w ) 840 if ( w )
841 w->show(); 841 w->show();
842} 842}
843 843
844 844
845int KToolBar::itemIndex (int id) 845int KToolBar::itemIndex (int id)
846{ 846{
847 QWidget *w = getWidget(id); 847 QWidget *w = getWidget(id);
848 return w ? widgets.findRef(w) : -1; 848 return w ? widgets.findRef(w) : -1;
849} 849}
850 850
851 851
852void KToolBar::setFullSize(bool flag ) 852void KToolBar::setFullSize(bool flag )
853{ 853{
854 setHorizontalStretchable( flag ); 854 setHorizontalStretchable( flag );
855 setVerticalStretchable( flag ); 855 setVerticalStretchable( flag );
856} 856}
857 857
858 858
859bool KToolBar::fullSize() const 859bool KToolBar::fullSize() const
860{ 860{
861 return isHorizontalStretchable() || isVerticalStretchable(); 861 return isHorizontalStretchable() || isVerticalStretchable();
862} 862}
863 863
864 864
865void KToolBar::enableMoving(bool flag ) 865void KToolBar::enableMoving(bool flag )
866{ 866{
867//US setMovingEnabled(flag); 867//US setMovingEnabled(flag);
868 this->mainWindow()->setToolBarsMovable(flag); 868 this->mainWindow()->setToolBarsMovable(flag);
869} 869}
870 870
871 871
872void KToolBar::setBarPos (BarPosition bpos) 872void KToolBar::setBarPos (BarPosition bpos)
873{ 873{
874 if ( !mainWindow() ) 874 if ( !mainWindow() )
875 return; 875 return;
876//US mainWindow()->moveDockWindow( this, (Dock)bpos ); 876//US mainWindow()->moveDockWindow( this, (Dock)bpos );
877 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); 877 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos );
878} 878}
879 879
880 880
881KToolBar::BarPosition KToolBar::barPos() 881KToolBar::BarPosition KToolBar::barPos()
882{ 882{
883 if ( !(QMainWindow*)mainWindow() ) 883 if ( !(QMainWindow*)mainWindow() )
884 return KToolBar::Top; 884 return KToolBar::Top;
885//US Dock dock; 885//US Dock dock;
886 QMainWindow::ToolBarDock dock; 886 QMainWindow::ToolBarDock dock;
887 int dm1, dm2; 887 int dm1, dm2;
888 bool dm3; 888 bool dm3;
889 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); 889 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 );
890//US if ( dock == DockUnmanaged ) { 890//US if ( dock == DockUnmanaged ) {
891 if ( dock == QMainWindow::Unmanaged ) { 891 if ( dock == QMainWindow::Unmanaged ) {
892 return (KToolBar::BarPosition)Top; 892 return (KToolBar::BarPosition)Top;
893 } 893 }
894 return (BarPosition)dock; 894 return (BarPosition)dock;
895} 895}
896 896
897 897
898bool KToolBar::enable(BarStatus stat) 898bool KToolBar::enable(BarStatus stat)
899{ 899{
900 bool mystat = isVisible(); 900 bool mystat = isVisible();
901 901
902 if ( (stat == Toggle && mystat) || stat == Hide ) 902 if ( (stat == Toggle && mystat) || stat == Hide )
903 hide(); 903 hide();
904 else 904 else
905 show(); 905 show();
906 906
907 return isVisible() == mystat; 907 return isVisible() == mystat;
908} 908}
909 909
910 910
911void KToolBar::setMaxHeight ( int h ) 911void KToolBar::setMaxHeight ( int h )
912{ 912{
913 setMaximumHeight( h ); 913 setMaximumHeight( h );
914} 914}
915 915
916int KToolBar::maxHeight() 916int KToolBar::maxHeight()
917{ 917{
918 return maximumHeight(); 918 return maximumHeight();
919} 919}
920 920
921 921
922void KToolBar::setMaxWidth (int dw) 922void KToolBar::setMaxWidth (int dw)
923{ 923{
924 setMaximumWidth( dw ); 924 setMaximumWidth( dw );
925} 925}
926 926
927 927
928int KToolBar::maxWidth() 928int KToolBar::maxWidth()
929{ 929{
930 return maximumWidth(); 930 return maximumWidth();
931} 931}
932 932
933 933
934void KToolBar::setTitle (const QString& _title) 934void KToolBar::setTitle (const QString& _title)
935{ 935{
936 setLabel( _title ); 936 setLabel( _title );
937} 937}
938 938
939 939
940void KToolBar::enableFloating (bool ) 940void KToolBar::enableFloating (bool )
941{ 941{
942} 942}
943 943
944 944
945void KToolBar::setIconText(IconText it) 945void KToolBar::setIconText(IconText it)
946{ 946{
947 setIconText( it, true ); 947 setIconText( it, true );
948} 948}
949 949
950 950
951void KToolBar::setIconText(IconText icontext, bool update) 951void KToolBar::setIconText(IconText icontext, bool update)
952{ 952{
953 bool doUpdate=false; 953 bool doUpdate=false;
954 954
955 if (icontext != d->m_iconText) { 955 if (icontext != d->m_iconText) {
956 d->m_iconText = icontext; 956 d->m_iconText = icontext;
957 doUpdate=true; 957 doUpdate=true;
958 } 958 }
959 959
960 if (update == false) 960 if (update == false)
961 return; 961 return;
962 962
963 if (doUpdate) 963 if (doUpdate)
964 emit modechange(); // tell buttons what happened 964 emit modechange(); // tell buttons what happened
965 965
966 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 966 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
967 if ( mainWindow() ) { 967 if ( mainWindow() ) {
968 QMainWindow *mw = mainWindow(); 968 QMainWindow *mw = mainWindow();
969 mw->setUpdatesEnabled( FALSE ); 969 mw->setUpdatesEnabled( FALSE );
970 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 970 mw->setToolBarsMovable( !mw->toolBarsMovable() );
971 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 971 mw->setToolBarsMovable( !mw->toolBarsMovable() );
972 mw->setUpdatesEnabled( TRUE ); 972 mw->setUpdatesEnabled( TRUE );
973 } 973 }
974} 974}
975 975
976 976
977KToolBar::IconText KToolBar::iconText() const 977KToolBar::IconText KToolBar::iconText() const
978{ 978{
979 return d->m_iconText; 979 return d->m_iconText;
980} 980}
981 981
982 982
983void KToolBar::setIconSize(int size) 983void KToolBar::setIconSize(int size)
984{ 984{
985 setIconSize( size, true ); 985 setIconSize( size, true );
986} 986}
987 987
988void KToolBar::setIconSize(int size, bool update) 988void KToolBar::setIconSize(int size, bool update)
989{ 989{
990 bool doUpdate=false; 990 bool doUpdate=false;
991 991
992 if ( size != d->m_iconSize ) { 992 if ( size != d->m_iconSize ) {
993 d->m_iconSize = size; 993 d->m_iconSize = size;
994 doUpdate=true; 994 doUpdate=true;
995 } 995 }
996 996
997 if (update == false) 997 if (update == false)
998 return; 998 return;
999 999
1000 if (doUpdate) 1000 if (doUpdate)
1001 emit modechange(); // tell buttons what happened 1001 emit modechange(); // tell buttons what happened
1002 1002
1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
1004 if ( mainWindow() ) { 1004 if ( mainWindow() ) {
1005 QMainWindow *mw = mainWindow(); 1005 QMainWindow *mw = mainWindow();
1006 mw->setUpdatesEnabled( FALSE ); 1006 mw->setUpdatesEnabled( FALSE );
1007 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1007 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1008 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1008 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1009 mw->setUpdatesEnabled( TRUE ); 1009 mw->setUpdatesEnabled( TRUE );
1010 } 1010 }
1011} 1011}
1012 1012
1013 1013
1014int KToolBar::iconSize() const 1014int KToolBar::iconSize() const
1015{ 1015{
1016/*US 1016/*US
1017 if ( !d->m_iconSize ) // default value? 1017 if ( !d->m_iconSize ) // default value?
1018 { 1018 {
1019 if (!::qstrcmp(QObject::name(), "mainToolBar")) 1019 if (!::qstrcmp(QObject::name(), "mainToolBar"))
1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); 1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar);
1021 else 1021 else
1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); 1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar);
1023 } 1023 }
1024 return d->m_iconSize; 1024 return d->m_iconSize;
1025*/ 1025*/
1026 int ret = 18; 1026 int ret = 18;
1027 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) 1027 if ( QApplication::desktop()->width() > 320 )
1028 ret = 30; 1028 ret = 30;
1029 return ret; 1029 return ret;
1030} 1030}
1031 1031
1032 1032
1033void KToolBar::setEnableContextMenu(bool enable ) 1033void KToolBar::setEnableContextMenu(bool enable )
1034{ 1034{
1035 d->m_enableContext = enable; 1035 d->m_enableContext = enable;
1036} 1036}
1037 1037
1038 1038
1039bool KToolBar::contextMenuEnabled() const 1039bool KToolBar::contextMenuEnabled() const
1040{ 1040{
1041 return d->m_enableContext; 1041 return d->m_enableContext;
1042} 1042}
1043 1043
1044 1044
1045void KToolBar::setItemNoStyle(int id, bool no_style ) 1045void KToolBar::setItemNoStyle(int id, bool no_style )
1046{ 1046{
1047 Id2WidgetMap::Iterator it = id2widget.find( id ); 1047 Id2WidgetMap::Iterator it = id2widget.find( id );
1048 if ( it == id2widget.end() ) 1048 if ( it == id2widget.end() )
1049 return; 1049 return;
1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
1051 KToolBarButton * button = (KToolBarButton *)( *it ); 1051 KToolBarButton * button = (KToolBarButton *)( *it );
1052 if (button) 1052 if (button)
1053 button->setNoStyle( no_style ); 1053 button->setNoStyle( no_style );
1054} 1054}
1055 1055
1056 1056
1057void KToolBar::setFlat (bool flag) 1057void KToolBar::setFlat (bool flag)
1058{ 1058{
1059 if ( !mainWindow() ) 1059 if ( !mainWindow() )
1060 return; 1060 return;
1061 if ( flag ) 1061 if ( flag )
1062//US mainWindow()->moveDockWindow( this, DockMinimized ); 1062//US mainWindow()->moveDockWindow( this, DockMinimized );
1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized ); 1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized );
1064 else 1064 else
1065//US mainWindow()->moveDockWindow( this, DockTop ); 1065//US mainWindow()->moveDockWindow( this, DockTop );
1066 mainWindow()->moveToolBar( this, QMainWindow::Top ); 1066 mainWindow()->moveToolBar( this, QMainWindow::Top );
1067 // And remember to save the new look later 1067 // And remember to save the new look later
1068/*US 1068/*US
1069 if ( mainWindow()->inherits( "KMainWindow" ) ) 1069 if ( mainWindow()->inherits( "KMainWindow" ) )
1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1071*/ 1071*/
1072} 1072}
1073 1073
1074 1074
1075int KToolBar::count() const 1075int KToolBar::count() const
1076{ 1076{
1077 return id2widget.count(); 1077 return id2widget.count();
1078} 1078}
1079 1079
1080 1080
1081void KToolBar::saveState() 1081void KToolBar::saveState()
1082{ 1082{
1083/*US 1083/*US
1084 // first, try to save to the xml file 1084 // first, try to save to the xml file
1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { 1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
1086 // go down one level to get to the right tags 1086 // go down one level to get to the right tags
1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); 1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement();
1088 elem = elem.firstChild().toElement(); 1088 elem = elem.firstChild().toElement();
1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); 1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
1090 QDomElement current; 1090 QDomElement current;
1091 // now try to find our toolbar 1091 // now try to find our toolbar
1092 d->modified = false; 1092 d->modified = false;
1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1094 current = elem; 1094 current = elem;
1095 1095
1096 if ( current.tagName().lower() != "toolbar" ) 1096 if ( current.tagName().lower() != "toolbar" )
1097 continue; 1097 continue;
1098 1098
1099 QString curname(current.attribute( "name" )); 1099 QString curname(current.attribute( "name" ));
1100 1100
1101 if ( curname == barname ) { 1101 if ( curname == barname ) {
1102 saveState( current ); 1102 saveState( current );
1103 break; 1103 break;
1104 } 1104 }
1105 } 1105 }
1106 // if we didn't make changes, then just return 1106 // if we didn't make changes, then just return
1107 if ( !d->modified ) 1107 if ( !d->modified )
1108 return; 1108 return;
1109 1109
1110 // now we load in the (non-merged) local file 1110 // now we load in the (non-merged) local file
1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); 1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
1112 QDomDocument local; 1112 QDomDocument local;
1113 local.setContent(local_xml); 1113 local.setContent(local_xml);
1114 1114
1115 // make sure we don't append if this toolbar already exists locally 1115 // make sure we don't append if this toolbar already exists locally
1116 bool just_append = true; 1116 bool just_append = true;
1117 elem = local.documentElement().toElement(); 1117 elem = local.documentElement().toElement();
1118 KXMLGUIFactory::removeDOMComments( elem ); 1118 KXMLGUIFactory::removeDOMComments( elem );
1119 elem = elem.firstChild().toElement(); 1119 elem = elem.firstChild().toElement();
1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1121 if ( elem.tagName().lower() != "toolbar" ) 1121 if ( elem.tagName().lower() != "toolbar" )
1122 continue; 1122 continue;
1123 1123
1124 QString curname(elem.attribute( "name" )); 1124 QString curname(elem.attribute( "name" ));
1125 1125
1126 if ( curname == barname ) { 1126 if ( curname == barname ) {
1127 just_append = false; 1127 just_append = false;
1128 local.documentElement().replaceChild( current, elem ); 1128 local.documentElement().replaceChild( current, elem );
1129 break; 1129 break;
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 if (just_append) 1133 if (just_append)
1134 local.documentElement().appendChild( current ); 1134 local.documentElement().appendChild( current );
1135 1135
1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); 1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
1137 1137
1138 return; 1138 return;
1139 } 1139 }
1140*/ 1140*/
1141 // if that didn't work, we save to the config file 1141 // if that didn't work, we save to the config file
1142 KConfig *config = KGlobal::config(); 1142 KConfig *config = KGlobal::config();
1143 saveSettings(config, QString::null); 1143 saveSettings(config, QString::null);
1144 config->sync(); 1144 config->sync();
1145} 1145}
1146 1146
1147QString KToolBar::settingsGroup() 1147QString KToolBar::settingsGroup()
1148{ 1148{
1149 QString configGroup; 1149 QString configGroup;
1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) 1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
1151 configGroup = "Toolbar style"; 1151 configGroup = "Toolbar style";
1152 else 1152 else
1153 configGroup = QString(name()) + " Toolbar style"; 1153 configGroup = QString(name()) + " Toolbar style";
1154 if ( this->mainWindow() ) 1154 if ( this->mainWindow() )
1155 { 1155 {
1156 configGroup.prepend(" "); 1156 configGroup.prepend(" ");
1157 configGroup.prepend( this->mainWindow()->name() ); 1157 configGroup.prepend( this->mainWindow()->name() );
1158 } 1158 }
1159 return configGroup; 1159 return configGroup;
1160} 1160}
1161 1161
1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) 1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup)
1163{ 1163{
1164 QString configGroup = _configGroup; 1164 QString configGroup = _configGroup;
1165 if (configGroup.isEmpty()) 1165 if (configGroup.isEmpty())
1166 configGroup = settingsGroup(); 1166 configGroup = settingsGroup();
1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; 1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl;
1168 1168
1169 QString position, icontext; 1169 QString position, icontext;
1170 int index; 1170 int index;
1171 getAttributes( position, icontext, index ); 1171 getAttributes( position, icontext, index );
1172 1172
1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; 1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl;
1174 1174
1175 KConfigGroupSaver saver(config, configGroup); 1175 KConfigGroupSaver saver(config, configGroup);
1176 1176
1177 if ( position != d->PositionDefault ) 1177 if ( position != d->PositionDefault )
1178 config->writeEntry("Position", position); 1178 config->writeEntry("Position", position);
1179 else 1179 else
1180 config->deleteEntry("Position"); 1180 config->deleteEntry("Position");
1181 1181
1182 if ( icontext != d->IconTextDefault ) 1182 if ( icontext != d->IconTextDefault )
1183 config->writeEntry("IconText", icontext); 1183 config->writeEntry("IconText", icontext);
1184 else 1184 else
1185 config->deleteEntry("IconText"); 1185 config->deleteEntry("IconText");
1186 1186
1187 if ( iconSize() != d->IconSizeDefault ) 1187 if ( iconSize() != d->IconSizeDefault )
1188 config->writeEntry("IconSize", iconSize()); 1188 config->writeEntry("IconSize", iconSize());
1189 else 1189 else
1190 config->deleteEntry("IconSize"); 1190 config->deleteEntry("IconSize");
1191 1191
1192 if ( isHidden() != d->HiddenDefault ) 1192 if ( isHidden() != d->HiddenDefault )
1193 config->writeEntry("Hidden", isHidden()); 1193 config->writeEntry("Hidden", isHidden());
1194 else 1194 else
1195 config->deleteEntry("Hidden"); 1195 config->deleteEntry("Hidden");
1196 1196
1197 if ( index != d->IndexDefault ) 1197 if ( index != d->IndexDefault )
1198 config->writeEntry( "Index", index ); 1198 config->writeEntry( "Index", index );
1199 else 1199 else
1200 config->deleteEntry("Index"); 1200 config->deleteEntry("Index");
1201//US the older version of KDE (used on the Zaurus) has no Offset property 1201//US the older version of KDE (used on the Zaurus) has no Offset property
1202/* if ( offset() != d->OffsetDefault ) 1202/* if ( offset() != d->OffsetDefault )
1203 config->writeEntry( "Offset", offset() ); 1203 config->writeEntry( "Offset", offset() );
1204 else 1204 else
1205*/ 1205*/
1206 config->deleteEntry("Offset"); 1206 config->deleteEntry("Offset");
1207 1207
1208//US the older version of KDE (used on the Zaurus) has no NewLine property 1208//US the older version of KDE (used on the Zaurus) has no NewLine property
1209/* 1209/*
1210 if ( newLine() != d->NewLineDefault ) 1210 if ( newLine() != d->NewLineDefault )
1211 config->writeEntry( "NewLine", newLine() ); 1211 config->writeEntry( "NewLine", newLine() );
1212 else 1212 else
1213*/ 1213*/
1214 config->deleteEntry("NewLine"); 1214 config->deleteEntry("NewLine");
1215} 1215}
1216 1216
1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) 1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client )
1218{ 1218{
1219 d->m_xmlguiClient = client; 1219 d->m_xmlguiClient = client;
1220} 1220}
1221 1221
1222void KToolBar::setText( const QString & txt ) 1222void KToolBar::setText( const QString & txt )
1223{ 1223{
1224//US setLabel( txt + " ( " + kapp->caption() + " ) " ); 1224//US setLabel( txt + " ( " + kapp->caption() + " ) " );
1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); 1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " );
1226} 1226}
1227 1227
1228 1228
1229QString KToolBar::text() const 1229QString KToolBar::text() const
1230{ 1230{
1231 return label(); 1231 return label();
1232} 1232}
1233 1233
1234 1234
1235void KToolBar::doConnections( KToolBarButton *button ) 1235void KToolBar::doConnections( KToolBarButton *button )
1236{ 1236{
1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); 1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); 1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); 1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); 1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); 1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); 1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
1243} 1243}
1244 1244
1245void KToolBar::mousePressEvent ( QMouseEvent *m ) 1245void KToolBar::mousePressEvent ( QMouseEvent *m )
1246{ 1246{
1247 if ( !mainWindow() ) 1247 if ( !mainWindow() )
1248 return; 1248 return;
1249 QMainWindow *mw = mainWindow(); 1249 QMainWindow *mw = mainWindow();
1250 if ( mw->toolBarsMovable() && d->m_enableContext ) { 1250 if ( mw->toolBarsMovable() && d->m_enableContext ) {
1251 if ( m->button() == RightButton ) { 1251 if ( m->button() == RightButton ) {
1252 int i = contextMenu()->exec( m->globalPos(), 0 ); 1252 int i = contextMenu()->exec( m->globalPos(), 0 );
1253 switch ( i ) { 1253 switch ( i ) {
1254 case -1: 1254 case -1:
1255 return; // popup cancelled 1255 return; // popup cancelled
1256 case CONTEXT_LEFT: 1256 case CONTEXT_LEFT:
1257//US mw->moveDockWindow( this, DockLeft ); 1257//US mw->moveDockWindow( this, DockLeft );
1258 mw->moveToolBar( this, QMainWindow::Left ); 1258 mw->moveToolBar( this, QMainWindow::Left );
1259 break; 1259 break;
1260 case CONTEXT_RIGHT: 1260 case CONTEXT_RIGHT:
1261//US mw->moveDockWindow( this, DockRight ); 1261//US mw->moveDockWindow( this, DockRight );
1262 mw->moveToolBar( this, QMainWindow::Right ); 1262 mw->moveToolBar( this, QMainWindow::Right );
1263 break; 1263 break;
1264 case CONTEXT_TOP: 1264 case CONTEXT_TOP:
1265//US mw->moveDockWindow( this, DockTop ); 1265//US mw->moveDockWindow( this, DockTop );
1266 mw->moveToolBar( this, QMainWindow::Top ); 1266 mw->moveToolBar( this, QMainWindow::Top );
1267 break; 1267 break;
1268 case CONTEXT_BOTTOM: 1268 case CONTEXT_BOTTOM:
1269//US mw->moveDockWindow( this, DockBottom ); 1269//US mw->moveDockWindow( this, DockBottom );
1270 mw->moveToolBar( this, QMainWindow::Bottom ); 1270 mw->moveToolBar( this, QMainWindow::Bottom );
1271 break; 1271 break;
1272 case CONTEXT_FLOAT: 1272 case CONTEXT_FLOAT:
1273 break; 1273 break;
1274 case CONTEXT_FLAT: 1274 case CONTEXT_FLAT:
1275//US mw->moveDockWindow( this, DockMinimized ); 1275//US mw->moveDockWindow( this, DockMinimized );
1276 mw->moveToolBar( this, QMainWindow::Minimized ); 1276 mw->moveToolBar( this, QMainWindow::Minimized );
1277 break; 1277 break;
1278 case CONTEXT_ICONS: 1278 case CONTEXT_ICONS:
1279 setIconText( IconOnly ); 1279 setIconText( IconOnly );
1280 break; 1280 break;
1281 case CONTEXT_TEXTRIGHT: 1281 case CONTEXT_TEXTRIGHT:
1282 setIconText( IconTextRight ); 1282 setIconText( IconTextRight );
1283 break; 1283 break;
1284 case CONTEXT_TEXT: 1284 case CONTEXT_TEXT:
1285 setIconText( TextOnly ); 1285 setIconText( TextOnly );
1286 break; 1286 break;
1287 case CONTEXT_TEXTUNDER: 1287 case CONTEXT_TEXTUNDER:
1288 setIconText( IconTextBottom ); 1288 setIconText( IconTextBottom );
1289 break; 1289 break;
1290 default: 1290 default:
1291 if ( i >= CONTEXT_ICONSIZES ) 1291 if ( i >= CONTEXT_ICONSIZES )
1292 setIconSize( i - CONTEXT_ICONSIZES ); 1292 setIconSize( i - CONTEXT_ICONSIZES );
1293 else 1293 else
1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty() 1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty()
1295 } 1295 }
1296/*US 1296/*US
1297 if ( mw->inherits("KMainWindow") ) 1297 if ( mw->inherits("KMainWindow") )
1298 static_cast<KMainWindow *>(mw)->setSettingsDirty(); 1298 static_cast<KMainWindow *>(mw)->setSettingsDirty();
1299*/ 1299*/
1300 } 1300 }
1301 } 1301 }
1302} 1302}
1303 1303
1304 1304
1305void KToolBar::rebuildLayout() 1305void KToolBar::rebuildLayout()
1306{ 1306{
1307 1307
1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) 1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
1309 w->blockSignals(false); 1309 w->blockSignals(false);
1310 d->idleButtons.clear(); 1310 d->idleButtons.clear();
1311 1311
1312 layoutTimer->stop(); 1312 layoutTimer->stop();
1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1314 QBoxLayout *l = boxLayout(); 1314 QBoxLayout *l = boxLayout();
1315 l->setMargin( 1 ); 1315 l->setMargin( 1 );
1316 // clear the old layout 1316 // clear the old layout
1317 QLayoutIterator it = l->iterator(); 1317 QLayoutIterator it = l->iterator();
1318 1318
1319 while ( it.current() ) { 1319 while ( it.current() ) {
1320 it.deleteCurrent(); 1320 it.deleteCurrent();
1321 } 1321 }
1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { 1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
1323 if ( w == rightAligned ) { 1323 if ( w == rightAligned ) {
1324 continue; 1324 continue;
1325 } 1325 }
1326 if ( w->inherits( "KToolBarSeparator" ) && 1326 if ( w->inherits( "KToolBarSeparator" ) &&
1327 !( (KToolBarSeparator*)w )->showLine() ) { 1327 !( (KToolBarSeparator*)w )->showLine() ) {
1328 l->addSpacing( 6 ); 1328 l->addSpacing( 6 );
1329 w->hide(); 1329 w->hide();
1330 continue; 1330 continue;
1331 } 1331 }
1332 if ( w->inherits( "QPopupMenu" ) ) 1332 if ( w->inherits( "QPopupMenu" ) )
1333 continue; 1333 continue;
1334 l->addWidget( w ); 1334 l->addWidget( w );
1335 w->show(); 1335 w->show();
1336 } 1336 }
1337 if ( rightAligned ) { 1337 if ( rightAligned ) {
1338 l->addStretch(); 1338 l->addStretch();
1339 l->addWidget( rightAligned ); 1339 l->addWidget( rightAligned );
1340 rightAligned->show(); 1340 rightAligned->show();
1341 } 1341 }
1342 1342
1343 if ( fullSize() ) { 1343 if ( fullSize() ) {
1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). 1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword).
1345 //if ( !stretchableWidget && widgets.last() && 1345 //if ( !stretchableWidget && widgets.last() &&
1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) 1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) )
1347 // setStretchableWidget( widgets.last() ); 1347 // setStretchableWidget( widgets.last() );
1348 if ( !rightAligned ) 1348 if ( !rightAligned )
1349 l->addStretch(); 1349 l->addStretch();
1350 if ( stretchableWidget ) 1350 if ( stretchableWidget )
1351 l->setStretchFactor( stretchableWidget, 10 ); 1351 l->setStretchFactor( stretchableWidget, 10 );
1352 } 1352 }
1353 l->invalidate(); 1353 l->invalidate();
1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); 1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) );
1355 //#endif //DESKTOP_VERSION 1355 //#endif //DESKTOP_VERSION
1356} 1356}
1357 1357
1358void KToolBar::childEvent( QChildEvent *e ) 1358void KToolBar::childEvent( QChildEvent *e )
1359{ 1359{
1360 1360
1361 if ( e->child()->isWidgetType() ) { 1361 if ( e->child()->isWidgetType() ) {
1362 QWidget * w = (QWidget*)e->child(); 1362 QWidget * w = (QWidget*)e->child();
1363 if ( e->type() == QEvent::ChildInserted ) { 1363 if ( e->type() == QEvent::ChildInserted ) {
1364 if ( !e->child()->inherits( "QPopupMenu" ) && 1364 if ( !e->child()->inherits( "QPopupMenu" ) &&
1365 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { 1365 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) {
1366 1366
1367 // prevent items that have been explicitly inserted by insert*() from 1367 // prevent items that have been explicitly inserted by insert*() from
1368 // being inserted again 1368 // being inserted again
1369 if ( !widget2id.contains( w ) ) 1369 if ( !widget2id.contains( w ) )
1370 { 1370 {
1371 int dummy = -1; 1371 int dummy = -1;
1372 insertWidgetInternal( w, dummy, -1 ); 1372 insertWidgetInternal( w, dummy, -1 );
1373 } 1373 }
1374 } 1374 }
1375 } else { 1375 } else {
1376 removeWidgetInternal( w ); 1376 removeWidgetInternal( w );
1377 } 1377 }
1378 if ( isVisibleTo( 0 ) ) 1378 if ( isVisibleTo( 0 ) )
1379 { 1379 {
1380 QBoxLayout *l = boxLayout(); 1380 QBoxLayout *l = boxLayout();
1381 // QLayout *l = layout(); 1381 // QLayout *l = layout();
1382 1382
1383 // clear the old layout so that we don't get unnecassery layout 1383 // clear the old layout so that we don't get unnecassery layout
1384 // changes till we have rebuild the thing 1384 // changes till we have rebuild the thing
1385 QLayoutIterator it = l->iterator(); 1385 QLayoutIterator it = l->iterator();
1386 while ( it.current() ) { 1386 while ( it.current() ) {
1387 it.deleteCurrent(); 1387 it.deleteCurrent();
1388 } 1388 }
1389 layoutTimer->start( 50, TRUE ); 1389 layoutTimer->start( 50, TRUE );
1390 } 1390 }
1391 } 1391 }
1392 QToolBar::childEvent( e ); 1392 QToolBar::childEvent( e );
1393} 1393}
1394 1394
1395void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) 1395void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id )
1396{ 1396{
1397 // we can't have it in widgets, or something is really wrong 1397 // we can't have it in widgets, or something is really wrong
1398 //widgets.removeRef( w ); 1398 //widgets.removeRef( w );
1399 1399
1400 connect( w, SIGNAL( destroyed() ), 1400 connect( w, SIGNAL( destroyed() ),
1401 this, SLOT( widgetDestroyed() ) ); 1401 this, SLOT( widgetDestroyed() ) );
1402 if ( index == -1 || index > (int)widgets.count() ) { 1402 if ( index == -1 || index > (int)widgets.count() ) {
1403 widgets.append( w ); 1403 widgets.append( w );
1404 index = (int)widgets.count(); 1404 index = (int)widgets.count();
1405 } 1405 }
1406 else 1406 else
1407 widgets.insert( index, w ); 1407 widgets.insert( index, w );
1408 if ( id == -1 ) 1408 if ( id == -1 )
1409 id = id2widget.count(); 1409 id = id2widget.count();
1410 id2widget.insert( id, w ); 1410 id2widget.insert( id, w );
1411 widget2id.insert( w, id ); 1411 widget2id.insert( w, id );
1412} 1412}
1413 1413
1414void KToolBar::showEvent( QShowEvent *e ) 1414void KToolBar::showEvent( QShowEvent *e )
1415{ 1415{
1416 QToolBar::showEvent( e ); 1416 QToolBar::showEvent( e );
1417 rebuildLayout(); 1417 rebuildLayout();
1418} 1418}
1419 1419
1420void KToolBar::setStretchableWidget( QWidget *w ) 1420void KToolBar::setStretchableWidget( QWidget *w )
1421{ 1421{
1422 QToolBar::setStretchableWidget( w ); 1422 QToolBar::setStretchableWidget( w );
1423 stretchableWidget = w; 1423 stretchableWidget = w;
1424} 1424}
1425 1425
1426QSizePolicy KToolBar::sizePolicy() const 1426QSizePolicy KToolBar::sizePolicy() const
1427{ 1427{
1428 if ( orientation() == Horizontal ) 1428 if ( orientation() == Horizontal )
1429 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); 1429 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
1430 else 1430 else
1431 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); 1431 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
1432} 1432}
1433 1433
1434QSize KToolBar::sizeHint() const 1434QSize KToolBar::sizeHint() const
1435{ 1435{
1436 return QToolBar::sizeHint(); 1436 return QToolBar::sizeHint();
1437#if 0 1437#if 0
1438 QWidget::polish(); 1438 QWidget::polish();
1439 static int iii = 0; 1439 static int iii = 0;
1440 ++iii; 1440 ++iii;
1441 qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); 1441 qDebug("++++++++ KToolBar::sizeHint() %d ", iii );
1442 int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); 1442 int margin = static_cast<QWidget*>(ncThis)->layout()->margin();
1443 switch( barPos() ) 1443 switch( barPos() )
1444 { 1444 {
1445 case KToolBar::Top: 1445 case KToolBar::Top:
1446 case KToolBar::Bottom: 1446 case KToolBar::Bottom:
1447 for ( QWidget *w = widgets.first(); w; w =widgets.next() ) 1447 for ( QWidget *w = widgets.first(); w; w =widgets.next() )
1448 { 1448 {
1449 if ( w->inherits( "KToolBarSeparator" ) && 1449 if ( w->inherits( "KToolBarSeparator" ) &&
1450 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1450 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1451 { 1451 {
1452 minSize += QSize(6, 0); 1452 minSize += QSize(6, 0);
1453 } 1453 }
1454 else 1454 else
1455 { 1455 {
1456 QSize sh = w->sizeHint(); 1456 QSize sh = w->sizeHint();
1457 if (!sh.isValid()) 1457 if (!sh.isValid())
1458 sh = w->minimumSize(); 1458 sh = w->minimumSize();
1459 minSize = minSize.expandedTo(QSize(0, sh.height())); 1459 minSize = minSize.expandedTo(QSize(0, sh.height()));
1460 minSize += QSize(sh.width()+1, 0); 1460 minSize += QSize(sh.width()+1, 0);
1461 } 1461 }
1462 } 1462 }
1463/*US 1463/*US
1464 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); 1464 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0);
1465*/ 1465*/
1466 minSize += QSize(margin*2, margin*2); 1466 minSize += QSize(margin*2, margin*2);
1467 break; 1467 break;
1468 1468
1469 case KToolBar::Left: 1469 case KToolBar::Left:
1470 case KToolBar::Right: 1470 case KToolBar::Right:
1471 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) 1471 for ( QWidget *w = widgets.first(); w; w = widgets.next() )
1472 { 1472 {
1473 if ( w->inherits( "KToolBarSeparator" ) && 1473 if ( w->inherits( "KToolBarSeparator" ) &&
1474 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1474 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1475 { 1475 {
1476 minSize += QSize(0, 6); 1476 minSize += QSize(0, 6);
1477 } 1477 }
1478 else 1478 else
1479 { 1479 {
1480 QSize sh = w->sizeHint(); 1480 QSize sh = w->sizeHint();
1481 if (!sh.isValid()) 1481 if (!sh.isValid())
1482 sh = w->minimumSize(); 1482 sh = w->minimumSize();
1483 minSize = minSize.expandedTo(QSize(sh.width(), 0)); 1483 minSize = minSize.expandedTo(QSize(sh.width(), 0));
1484 minSize += QSize(0, sh.height()+1); 1484 minSize += QSize(0, sh.height()+1);
1485 } 1485 }
1486 } 1486 }
1487/*US 1487/*US
1488 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 1488 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
1489*/ 1489*/
1490 minSize += QSize(margin*2, margin*2); 1490 minSize += QSize(margin*2, margin*2);
1491 break; 1491 break;
1492 1492
1493 default: 1493 default:
1494 minSize = QToolBar::sizeHint(); 1494 minSize = QToolBar::sizeHint();
1495 break; 1495 break;
1496 } 1496 }
1497 return minSize; 1497 return minSize;
1498#endif 1498#endif
1499} 1499}
1500 1500
1501QSize KToolBar::minimumSize() const 1501QSize KToolBar::minimumSize() const
1502{ 1502{
1503 return minimumSizeHint(); 1503 return minimumSizeHint();
1504} 1504}
1505 1505
1506QSize KToolBar::minimumSizeHint() const 1506QSize KToolBar::minimumSizeHint() const
1507{ 1507{
1508 return sizeHint(); 1508 return sizeHint();
1509} 1509}
1510 1510
1511bool KToolBar::highlight() const 1511bool KToolBar::highlight() const
1512{ 1512{
1513 return d->m_highlight; 1513 return d->m_highlight;
1514} 1514}
1515 1515
1516void KToolBar::hide() 1516void KToolBar::hide()
1517{ 1517{
1518 QToolBar::hide(); 1518 QToolBar::hide();
1519} 1519}
1520 1520
1521void KToolBar::show() 1521void KToolBar::show()
1522{ 1522{
1523 QToolBar::show(); 1523 QToolBar::show();
1524} 1524}
1525 1525
1526void KToolBar::resizeEvent( QResizeEvent *e ) 1526void KToolBar::resizeEvent( QResizeEvent *e )
1527{ 1527{
1528 bool b = isUpdatesEnabled(); 1528 bool b = isUpdatesEnabled();
1529 setUpdatesEnabled( FALSE ); 1529 setUpdatesEnabled( FALSE );
1530 QToolBar::resizeEvent( e ); 1530 QToolBar::resizeEvent( e );
1531 if (b) 1531 if (b)
1532 d->repaintTimer.start( 100, true ); 1532 d->repaintTimer.start( 100, true );
1533} 1533}
1534 1534
1535void KToolBar::slotIconChanged(int group) 1535void KToolBar::slotIconChanged(int group)
1536{ 1536{
1537 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) 1537 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar))
1538 return; 1538 return;
1539 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) 1539 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar"))
1540 return; 1540 return;
1541 1541
1542 emit modechange(); 1542 emit modechange();
1543 if (isVisible()) 1543 if (isVisible())
1544 updateGeometry(); 1544 updateGeometry();
1545} 1545}
1546 1546
1547void KToolBar::slotReadConfig() 1547void KToolBar::slotReadConfig()
1548{ 1548{
1549 //kdDebug(220) << "KToolBar::slotReadConfig" << endl; 1549 //kdDebug(220) << "KToolBar::slotReadConfig" << endl;
1550 // Read appearance settings (hmm, we used to do both here, 1550 // Read appearance settings (hmm, we used to do both here,
1551 // but a well behaved application will call applyMainWindowSettings 1551 // but a well behaved application will call applyMainWindowSettings
1552 // anyway, right ?) 1552 // anyway, right ?)
1553 applyAppearanceSettings(KGlobal::config(), QString::null ); 1553 applyAppearanceSettings(KGlobal::config(), QString::null );
1554} 1554}
1555 1555
1556void KToolBar::slotAppearanceChanged() 1556void KToolBar::slotAppearanceChanged()
1557{ 1557{
1558 // Read appearance settings from global file. 1558 // Read appearance settings from global file.
1559 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); 1559 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ );
1560 // And remember to save the new look later 1560 // And remember to save the new look later
1561/*US 1561/*US
1562 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1562 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1563 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1563 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1564*/ 1564*/
1565} 1565}
1566 1566
1567//static 1567//static
1568bool KToolBar::highlightSetting() 1568bool KToolBar::highlightSetting()
1569{ 1569{
1570 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1570 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1571 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1571 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1572 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); 1572 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true);
1573} 1573}
1574 1574
1575//static 1575//static
1576bool KToolBar::transparentSetting() 1576bool KToolBar::transparentSetting()
1577{ 1577{
1578 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1578 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1579 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1579 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1580 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); 1580 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true);
1581} 1581}
1582 1582
1583//static 1583//static
1584KToolBar::IconText KToolBar::iconTextSetting() 1584KToolBar::IconText KToolBar::iconTextSetting()
1585{ 1585{
1586 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1586 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1587 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1587 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1588 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); 1588 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly"));
1589 if ( icontext == "IconTextRight" ) 1589 if ( icontext == "IconTextRight" )
1590 return IconTextRight; 1590 return IconTextRight;
1591 else if ( icontext == "IconTextBottom" ) 1591 else if ( icontext == "IconTextBottom" )
1592 return IconTextBottom; 1592 return IconTextBottom;
1593 else if ( icontext == "TextOnly" ) 1593 else if ( icontext == "TextOnly" )
1594 return TextOnly; 1594 return TextOnly;
1595 else 1595 else
1596 return IconOnly; 1596 return IconOnly;
1597} 1597}
1598 1598
1599void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) 1599void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal)
1600{ 1600{
1601 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1601 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1602 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; 1602 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl;
1603 // We have application-specific settings in the XML file, 1603 // We have application-specific settings in the XML file,
1604 // and nothing in the application's config file 1604 // and nothing in the application's config file
1605 // -> don't apply the global defaults, the XML ones are preferred 1605 // -> don't apply the global defaults, the XML ones are preferred
1606 // See applySettings for a full explanation 1606 // See applySettings for a full explanation
1607/*US :we do not support xml files 1607/*US :we do not support xml files
1608 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && 1608 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() &&
1609 !config->hasGroup(configGroup) ) 1609 !config->hasGroup(configGroup) )
1610 { 1610 {
1611 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1611 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1612 return; 1612 return;
1613 } 1613 }
1614*/ 1614*/
1615 if ( !config->hasGroup(configGroup) ) 1615 if ( !config->hasGroup(configGroup) )
1616 { 1616 {
1617 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1617 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1618 return; 1618 return;
1619 } 1619 }
1620 1620
1621 1621
1622 KConfig *gconfig = KGlobal::config(); 1622 KConfig *gconfig = KGlobal::config();
1623/*US 1623/*US
1624 static const QString &attrIconText = KGlobal::staticQString("IconText"); 1624 static const QString &attrIconText = KGlobal::staticQString("IconText");
1625 static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); 1625 static const QString &attrHighlight = KGlobal::staticQString("Highlighting");
1626 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); 1626 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving");
1627 static const QString &attrSize = KGlobal::staticQString("IconSize"); 1627 static const QString &attrSize = KGlobal::staticQString("IconSize");
1628*/ 1628*/
1629 // we actually do this in two steps. 1629 // we actually do this in two steps.
1630 // First, we read in the global styles [Toolbar style] (from the KControl module). 1630 // First, we read in the global styles [Toolbar style] (from the KControl module).
1631 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] 1631 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style]
1632 bool highlight; 1632 bool highlight;
1633 int transparent; 1633 int transparent;
1634 QString icontext; 1634 QString icontext;
1635 int iconsize = 0; 1635 int iconsize = 0;
1636 1636
1637 // this is the first iteration 1637 // this is the first iteration
1638 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1638 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1639 { // start block for KConfigGroupSaver 1639 { // start block for KConfigGroupSaver
1640 KConfigGroupSaver saver(gconfig, grpToolbar); 1640 KConfigGroupSaver saver(gconfig, grpToolbar);
1641 1641
1642 // first, get the generic settings 1642 // first, get the generic settings
1643//US highlight = gconfig->readBoolEntry(attrHighlight, true); 1643//US highlight = gconfig->readBoolEntry(attrHighlight, true);
1644 highlight = gconfig->readBoolEntry("Highlighting", true); 1644 highlight = gconfig->readBoolEntry("Highlighting", true);
1645//US transparent = gconfig->readBoolEntry(attrTrans, true); 1645//US transparent = gconfig->readBoolEntry(attrTrans, true);
1646 transparent = gconfig->readBoolEntry("TransparentMoving", true); 1646 transparent = gconfig->readBoolEntry("TransparentMoving", true);
1647 1647
1648 // we read in the IconText property *only* if we intend on actually 1648 // we read in the IconText property *only* if we intend on actually
1649 // honoring it 1649 // honoring it
1650 if (d->m_honorStyle) 1650 if (d->m_honorStyle)
1651//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); 1651//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault);
1652 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); 1652 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault);
1653 else 1653 else
1654 d->IconTextDefault = "IconOnly"; 1654 d->IconTextDefault = "IconOnly";
1655 1655
1656 // Use the default icon size for toolbar icons. 1656 // Use the default icon size for toolbar icons.
1657//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); 1657//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault);
1658 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); 1658 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault);
1659 1659
1660 if ( !forceGlobal && config->hasGroup(configGroup) ) 1660 if ( !forceGlobal && config->hasGroup(configGroup) )
1661 { 1661 {
1662 config->setGroup(configGroup); 1662 config->setGroup(configGroup);
1663 1663
1664 // first, get the generic settings 1664 // first, get the generic settings
1665//US highlight = config->readBoolEntry(attrHighlight, highlight); 1665//US highlight = config->readBoolEntry(attrHighlight, highlight);
1666 highlight = config->readBoolEntry("Highlighting", highlight); 1666 highlight = config->readBoolEntry("Highlighting", highlight);
1667//US transparent = config->readBoolEntry(attrTrans, transparent); 1667//US transparent = config->readBoolEntry(attrTrans, transparent);
1668 transparent = config->readBoolEntry("TransparentMoving", transparent); 1668 transparent = config->readBoolEntry("TransparentMoving", transparent);
1669 // now we always read in the IconText property 1669 // now we always read in the IconText property
1670//US icontext = config->readEntry(attrIconText, d->IconTextDefault); 1670//US icontext = config->readEntry(attrIconText, d->IconTextDefault);
1671 icontext = config->readEntry("IconText", d->IconTextDefault); 1671 icontext = config->readEntry("IconText", d->IconTextDefault);
1672 1672
1673 // now get the size 1673 // now get the size
1674//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); 1674//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault);
1675 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); 1675 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault);
1676 } 1676 }
1677 else 1677 else
1678 { 1678 {
1679 iconsize = d->IconSizeDefault; 1679 iconsize = d->IconSizeDefault;
1680 icontext = d->IconTextDefault; 1680 icontext = d->IconTextDefault;
1681 } 1681 }
1682 1682
1683 // revert back to the old group 1683 // revert back to the old group
1684 } // end block for KConfigGroupSaver 1684 } // end block for KConfigGroupSaver
1685 1685
1686 bool doUpdate = false; 1686 bool doUpdate = false;
1687 1687
1688 IconText icon_text; 1688 IconText icon_text;
1689 if ( icontext == "IconTextRight" ) 1689 if ( icontext == "IconTextRight" )
1690 icon_text = IconTextRight; 1690 icon_text = IconTextRight;
1691 else if ( icontext == "IconTextBottom" ) 1691 else if ( icontext == "IconTextBottom" )
1692 icon_text = IconTextBottom; 1692 icon_text = IconTextBottom;
1693 else if ( icontext == "TextOnly" ) 1693 else if ( icontext == "TextOnly" )
1694 icon_text = TextOnly; 1694 icon_text = TextOnly;
1695 else 1695 else
1696 icon_text = IconOnly; 1696 icon_text = IconOnly;
1697 1697
1698 // check if the icon/text has changed 1698 // check if the icon/text has changed
1699 if (icon_text != d->m_iconText) { 1699 if (icon_text != d->m_iconText) {
1700 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; 1700 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl;
1701 setIconText(icon_text, false); 1701 setIconText(icon_text, false);
1702 doUpdate = true; 1702 doUpdate = true;
1703 } 1703 }
1704 1704
1705 // ...and check if the icon size has changed 1705 // ...and check if the icon size has changed
1706 if (iconsize != d->m_iconSize) { 1706 if (iconsize != d->m_iconSize) {
1707 setIconSize(iconsize, false); 1707 setIconSize(iconsize, false);
1708 doUpdate = true; 1708 doUpdate = true;
1709 } 1709 }
1710 1710
1711 QMainWindow *mw = mainWindow(); 1711 QMainWindow *mw = mainWindow();
1712 1712
1713 // ...and if we should highlight 1713 // ...and if we should highlight
1714 if ( highlight != d->m_highlight ) { 1714 if ( highlight != d->m_highlight ) {
1715 d->m_highlight = highlight; 1715 d->m_highlight = highlight;
1716 doUpdate = true; 1716 doUpdate = true;
1717 } 1717 }
1718 1718
1719 // ...and if we should move transparently 1719 // ...and if we should move transparently
1720 if ( mw && transparent != (!mw->opaqueMoving()) ) { 1720 if ( mw && transparent != (!mw->opaqueMoving()) ) {
1721 mw->setOpaqueMoving( !transparent ); 1721 mw->setOpaqueMoving( !transparent );
1722 } 1722 }
1723 1723
1724 if (doUpdate) 1724 if (doUpdate)
1725 emit modechange(); // tell buttons what happened 1725 emit modechange(); // tell buttons what happened
1726 if (isVisible ()) 1726 if (isVisible ())
1727 updateGeometry(); 1727 updateGeometry();
1728} 1728}
1729 1729
1730void KToolBar::applySettings(KConfig *config, const QString &_configGroup) 1730void KToolBar::applySettings(KConfig *config, const QString &_configGroup)
1731{ 1731{
1732 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; 1732 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl;
1733 1733
1734 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1734 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1735 1735
1736 /* 1736 /*
1737 Let's explain this a bit more in details. 1737 Let's explain this a bit more in details.
1738 The order in which we apply settings is : 1738 The order in which we apply settings is :
1739 Global config / <appnamerc> user settings if no XMLGUI is used 1739 Global config / <appnamerc> user settings if no XMLGUI is used
1740 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used 1740 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used
1741 1741
1742 So in the first case, we simply read everything from KConfig as below, 1742 So in the first case, we simply read everything from KConfig as below,
1743 but in the second case we don't do anything here if there is no app-specific config, 1743 but in the second case we don't do anything here if there is no app-specific config,
1744 and the XMLGUI uses the static methods of this class to get the global defaults. 1744 and the XMLGUI uses the static methods of this class to get the global defaults.
1745 1745
1746 Global config doesn't include position (index, offset, newline and hidden/shown). 1746 Global config doesn't include position (index, offset, newline and hidden/shown).
1747 */ 1747 */
1748 1748
1749 // First the appearance stuff - the one which has a global config 1749 // First the appearance stuff - the one which has a global config
1750 applyAppearanceSettings( config, _configGroup ); 1750 applyAppearanceSettings( config, _configGroup );
1751 1751
1752 // ...and now the position stuff 1752 // ...and now the position stuff
1753 if ( config->hasGroup(configGroup) ) 1753 if ( config->hasGroup(configGroup) )
1754 { 1754 {
1755 KConfigGroupSaver cgs(config, configGroup); 1755 KConfigGroupSaver cgs(config, configGroup);
1756/*US 1756/*US
1757 static const QString &attrPosition = KGlobal::staticQString("Position"); 1757 static const QString &attrPosition = KGlobal::staticQString("Position");
1758 static const QString &attrIndex = KGlobal::staticQString("Index"); 1758 static const QString &attrIndex = KGlobal::staticQString("Index");
1759 static const QString &attrOffset = KGlobal::staticQString("Offset"); 1759 static const QString &attrOffset = KGlobal::staticQString("Offset");
1760 static const QString &attrNewLine = KGlobal::staticQString("NewLine"); 1760 static const QString &attrNewLine = KGlobal::staticQString("NewLine");
1761 static const QString &attrHidden = KGlobal::staticQString("Hidden"); 1761 static const QString &attrHidden = KGlobal::staticQString("Hidden");
1762 1762
1763 QString position = config->readEntry(attrPosition, d->PositionDefault); 1763 QString position = config->readEntry(attrPosition, d->PositionDefault);
1764 int index = config->readNumEntry(attrIndex, d->IndexDefault); 1764 int index = config->readNumEntry(attrIndex, d->IndexDefault);
1765 int offset = config->readNumEntry(attrOffset, d->OffsetDefault); 1765 int offset = config->readNumEntry(attrOffset, d->OffsetDefault);
1766 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); 1766 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault);
1767 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); 1767 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault);
1768*/ 1768*/
1769 1769
1770 QString position = config->readEntry("Position", d->PositionDefault); 1770 QString position = config->readEntry("Position", d->PositionDefault);
1771 int index = config->readNumEntry("Index", d->IndexDefault); 1771 int index = config->readNumEntry("Index", d->IndexDefault);
1772 int offset = config->readNumEntry("Offset", d->OffsetDefault); 1772 int offset = config->readNumEntry("Offset", d->OffsetDefault);
1773 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); 1773 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault);
1774 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); 1774 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault);
1775 1775
1776/*US Dock pos(DockTop); 1776/*US Dock pos(DockTop);
1777 if ( position == "Top" ) 1777 if ( position == "Top" )
1778 pos = DockTop; 1778 pos = DockTop;
1779 else if ( position == "Bottom" ) 1779 else if ( position == "Bottom" )
1780 pos = DockBottom; 1780 pos = DockBottom;
1781 else if ( position == "Left" ) 1781 else if ( position == "Left" )
1782 pos = DockLeft; 1782 pos = DockLeft;
1783 else if ( position == "Right" ) 1783 else if ( position == "Right" )
1784 pos = DockRight; 1784 pos = DockRight;
1785 else if ( position == "Floating" ) 1785 else if ( position == "Floating" )
1786 pos = DockTornOff; 1786 pos = DockTornOff;
1787 else if ( position == "Flat" ) 1787 else if ( position == "Flat" )
1788 pos = DockMinimized; 1788 pos = DockMinimized;
1789*/ 1789*/
1790 QMainWindow::ToolBarDock pos(QMainWindow::Top); 1790 QMainWindow::ToolBarDock pos(QMainWindow::Top);
1791 if ( position == "Top" ) 1791 if ( position == "Top" )
1792 pos = QMainWindow::Top; 1792 pos = QMainWindow::Top;
1793 else if ( position == "Bottom" ) 1793 else if ( position == "Bottom" )
1794 pos = QMainWindow::Bottom; 1794 pos = QMainWindow::Bottom;
1795 else if ( position == "Left" ) 1795 else if ( position == "Left" )
1796 pos = QMainWindow::Left; 1796 pos = QMainWindow::Left;
1797 else if ( position == "Right" ) 1797 else if ( position == "Right" )
1798 pos = QMainWindow::Right; 1798 pos = QMainWindow::Right;
1799 else if ( position == "Floating" ) 1799 else if ( position == "Floating" )
1800 pos = QMainWindow::TornOff; 1800 pos = QMainWindow::TornOff;
1801 else if ( position == "Flat" ) 1801 else if ( position == "Flat" )
1802 pos = QMainWindow::Minimized; 1802 pos = QMainWindow::Minimized;
1803 1803
1804 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; 1804 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl;
1805 if (hidden) 1805 if (hidden)
1806 hide(); 1806 hide();
1807 else 1807 else
1808 show(); 1808 show();
1809 1809
1810 if ( mainWindow() ) 1810 if ( mainWindow() )
1811 { 1811 {
1812 QMainWindow *mw = mainWindow(); 1812 QMainWindow *mw = mainWindow();
1813 1813
1814 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; 1814 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl;
1815 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); 1815 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset );
1816 1816
1817 // moveDockWindow calls QDockArea which does a reparent() on us with 1817 // moveDockWindow calls QDockArea which does a reparent() on us with
1818 // showIt = true, so we loose our visibility status 1818 // showIt = true, so we loose our visibility status
1819 bool doHide = isHidden(); 1819 bool doHide = isHidden();
1820 1820
1821//US mw->moveDockWindow( this, pos, newLine, index, offset ); 1821//US mw->moveDockWindow( this, pos, newLine, index, offset );
1822 mw->moveToolBar( this, pos, newLine, index, offset ); 1822 mw->moveToolBar( this, pos, newLine, index, offset );
1823 1823
1824 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; 1824 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl;
1825 if ( doHide ) 1825 if ( doHide )
1826 hide(); 1826 hide();
1827 } 1827 }
1828 if (isVisible ()) 1828 if (isVisible ())
1829 updateGeometry(); 1829 updateGeometry();
1830 } 1830 }
1831} 1831}
1832 1832
1833bool KToolBar::event( QEvent *e ) 1833bool KToolBar::event( QEvent *e )
1834{ 1834{
1835 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) 1835 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() )
1836 d->repaintTimer.start( 100, true ); 1836 d->repaintTimer.start( 100, true );
1837 1837
1838 if (e->type() == QEvent::ChildInserted ) 1838 if (e->type() == QEvent::ChildInserted )
1839 { 1839 {
1840 // By pass QToolBar::event, 1840 // By pass QToolBar::event,
1841 // it will show() the inserted child and we don't want to 1841 // it will show() the inserted child and we don't want to
1842 // do that until we have rebuild the layout. 1842 // do that until we have rebuild the layout.
1843 childEvent((QChildEvent *)e); 1843 childEvent((QChildEvent *)e);
1844 return true; 1844 return true;
1845 } 1845 }
1846 1846
1847 return QToolBar::event( e ); 1847 return QToolBar::event( e );
1848} 1848}
1849 1849
1850void KToolBar::slotRepaint() 1850void KToolBar::slotRepaint()
1851{ 1851{
1852 setUpdatesEnabled( FALSE ); 1852 setUpdatesEnabled( FALSE );
1853 // Send a resizeEvent to update the "toolbar extension arrow" 1853 // Send a resizeEvent to update the "toolbar extension arrow"
1854 // (The button you get when your toolbar-items don't fit in 1854 // (The button you get when your toolbar-items don't fit in
1855 // the available space) 1855 // the available space)
1856 QResizeEvent ev(size(), size()); 1856 QResizeEvent ev(size(), size());
1857 resizeEvent(&ev); 1857 resizeEvent(&ev);
1858 //#ifdef DESKTOP_VERSION 1858 //#ifdef DESKTOP_VERSION
1859 QApplication::sendPostedEvents( this, QEvent::LayoutHint ); 1859 QApplication::sendPostedEvents( this, QEvent::LayoutHint );
1860 //#endif //DESKTOP_VERSION 1860 //#endif //DESKTOP_VERSION
1861 setUpdatesEnabled( TRUE ); 1861 setUpdatesEnabled( TRUE );
1862 repaint( TRUE ); 1862 repaint( TRUE );
1863} 1863}
1864 1864
1865void KToolBar::toolBarPosChanged( QToolBar *tb ) 1865void KToolBar::toolBarPosChanged( QToolBar *tb )
1866{ 1866{
1867 if ( tb != this ) 1867 if ( tb != this )
1868 return; 1868 return;
1869//US if ( d->oldPos == DockMinimized ) 1869//US if ( d->oldPos == DockMinimized )
1870 if ( d->oldPos == QMainWindow::Minimized ) 1870 if ( d->oldPos == QMainWindow::Minimized )
1871 rebuildLayout(); 1871 rebuildLayout();
1872 d->oldPos = (QMainWindow::ToolBarDock)barPos(); 1872 d->oldPos = (QMainWindow::ToolBarDock)barPos();
1873/*US 1873/*US
1874 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1874 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1875 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1875 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1876*/ 1876*/
1877} 1877}
1878 1878
1879/*US 1879/*US
1880void KToolBar::loadState( const QDomElement &element ) 1880void KToolBar::loadState( const QDomElement &element )
1881{ 1881{
1882 //kdDebug(220) << "KToolBar::loadState " << this << endl; 1882 //kdDebug(220) << "KToolBar::loadState " << this << endl;
1883 if ( !mainWindow() ) 1883 if ( !mainWindow() )
1884 return; 1884 return;
1885 1885
1886 { 1886 {
1887 QCString text = element.namedItem( "text" ).toElement().text().utf8(); 1887 QCString text = element.namedItem( "text" ).toElement().text().utf8();
1888 if ( text.isEmpty() ) 1888 if ( text.isEmpty() )
1889 text = element.namedItem( "Text" ).toElement().text().utf8(); 1889 text = element.namedItem( "Text" ).toElement().text().utf8();
1890 if ( !text.isEmpty() ) 1890 if ( !text.isEmpty() )
1891 setText( i18n( text ) ); 1891 setText( i18n( text ) );
1892 } 1892 }
1893 1893
1894 { 1894 {
1895 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); 1895 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1();
1896 if ( !attrFullWidth.isEmpty() ) 1896 if ( !attrFullWidth.isEmpty() )
1897 setFullSize( attrFullWidth == "true" ); 1897 setFullSize( attrFullWidth == "true" );
1898 } 1898 }
1899 1899
1900 Dock dock = DockTop; 1900 Dock dock = DockTop;
1901 { 1901 {
1902 QCString attrPosition = element.attribute( "position" ).lower().latin1(); 1902 QCString attrPosition = element.attribute( "position" ).lower().latin1();
1903 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; 1903 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl;
1904 if ( !attrPosition.isEmpty() ) { 1904 if ( !attrPosition.isEmpty() ) {
1905 if ( attrPosition == "top" ) 1905 if ( attrPosition == "top" )
1906 dock = DockTop; 1906 dock = DockTop;
1907 else if ( attrPosition == "left" ) 1907 else if ( attrPosition == "left" )
1908 dock = DockLeft; 1908 dock = DockLeft;
1909 else if ( attrPosition == "right" ) 1909 else if ( attrPosition == "right" )
1910 dock = DockRight; 1910 dock = DockRight;
1911 else if ( attrPosition == "bottom" ) 1911 else if ( attrPosition == "bottom" )
1912 dock = DockBottom; 1912 dock = DockBottom;
1913 else if ( attrPosition == "floating" ) 1913 else if ( attrPosition == "floating" )
1914 dock = DockTornOff; 1914 dock = DockTornOff;
1915 else if ( attrPosition == "flat" ) 1915 else if ( attrPosition == "flat" )
1916 dock = DockMinimized; 1916 dock = DockMinimized;
1917 } 1917 }
1918 } 1918 }
1919 1919
1920 { 1920 {
1921 QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); 1921 QCString attrIconText = element.attribute( "iconText" ).lower().latin1();
1922 if ( !attrIconText.isEmpty() ) { 1922 if ( !attrIconText.isEmpty() ) {
1923 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; 1923 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl;
1924 if ( attrIconText == "icontextright" ) 1924 if ( attrIconText == "icontextright" )
1925 setIconText( KToolBar::IconTextRight ); 1925 setIconText( KToolBar::IconTextRight );
1926 else if ( attrIconText == "textonly" ) 1926 else if ( attrIconText == "textonly" )
1927 setIconText( KToolBar::TextOnly ); 1927 setIconText( KToolBar::TextOnly );
1928 else if ( attrIconText == "icontextbottom" ) 1928 else if ( attrIconText == "icontextbottom" )
1929 setIconText( KToolBar::IconTextBottom ); 1929 setIconText( KToolBar::IconTextBottom );
1930 else if ( attrIconText == "icononly" ) 1930 else if ( attrIconText == "icononly" )
1931 setIconText( KToolBar::IconOnly ); 1931 setIconText( KToolBar::IconOnly );
1932 } else 1932 } else
1933 // Use global setting 1933 // Use global setting
1934 setIconText( iconTextSetting() ); 1934 setIconText( iconTextSetting() );
1935 } 1935 }
1936 1936
1937 { 1937 {
1938 QString attrIconSize = element.attribute( "iconSize" ).lower(); 1938 QString attrIconSize = element.attribute( "iconSize" ).lower();
1939 if ( !attrIconSize.isEmpty() ) 1939 if ( !attrIconSize.isEmpty() )
1940 d->IconSizeDefault = attrIconSize.toInt(); 1940 d->IconSizeDefault = attrIconSize.toInt();
1941 setIconSize( d->IconSizeDefault ); 1941 setIconSize( d->IconSizeDefault );
1942 } 1942 }
1943 1943
1944 { 1944 {
1945 QString attrIndex = element.attribute( "index" ).lower(); 1945 QString attrIndex = element.attribute( "index" ).lower();
1946 if ( !attrIndex.isEmpty() ) 1946 if ( !attrIndex.isEmpty() )
1947 d->IndexDefault = attrIndex.toInt(); 1947 d->IndexDefault = attrIndex.toInt();
1948 } 1948 }
1949 1949
1950 { 1950 {
1951 QString attrOffset = element.attribute( "offset" ).lower(); 1951 QString attrOffset = element.attribute( "offset" ).lower();
1952 if ( !attrOffset.isEmpty() ) 1952 if ( !attrOffset.isEmpty() )
1953 d->OffsetDefault = attrOffset.toInt(); 1953 d->OffsetDefault = attrOffset.toInt();
1954 } 1954 }
1955 1955
1956 { 1956 {
1957 QString attrNewLine = element.attribute( "newline" ).lower(); 1957 QString attrNewLine = element.attribute( "newline" ).lower();
1958 if ( !attrNewLine.isEmpty() ) 1958 if ( !attrNewLine.isEmpty() )
1959 d->NewLineDefault = attrNewLine == "true"; 1959 d->NewLineDefault = attrNewLine == "true";
1960 } 1960 }
1961 1961
1962 { 1962 {
1963 QString attrHidden = element.attribute( "hidden" ).lower(); 1963 QString attrHidden = element.attribute( "hidden" ).lower();
1964 if ( !attrHidden.isEmpty() ) 1964 if ( !attrHidden.isEmpty() )
1965 d->HiddenDefault = attrHidden == "true"; 1965 d->HiddenDefault = attrHidden == "true";
1966 } 1966 }
1967 1967
1968 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); 1968 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault );
1969 mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); 1969 mainWindow()->addDockWindow( this, dock, d->NewLineDefault );
1970//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 1970//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1971 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 1971 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1972 1972
1973 // Apply the highlight button setting 1973 // Apply the highlight button setting
1974 d->m_highlight = highlightSetting(); 1974 d->m_highlight = highlightSetting();
1975 1975
1976 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow, 1976 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow,
1977 // but we do it only if there are toolbars...) 1977 // but we do it only if there are toolbars...)
1978 if ( transparentSetting() != !mainWindow()->opaqueMoving() ) 1978 if ( transparentSetting() != !mainWindow()->opaqueMoving() )
1979 mainWindow()->setOpaqueMoving( !transparentSetting() ); 1979 mainWindow()->setOpaqueMoving( !transparentSetting() );
1980 1980
1981 if ( d->HiddenDefault ) 1981 if ( d->HiddenDefault )
1982 hide(); 1982 hide();
1983 else 1983 else
1984 show(); 1984 show();
1985 1985
1986 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); 1986 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault );
1987} 1987}
1988*/ 1988*/
1989 1989
1990void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) 1990void KToolBar::getAttributes( QString &position, QString &icontext, int &index )
1991{ 1991{
1992 // get all of the stuff to save 1992 // get all of the stuff to save
1993 switch ( barPos() ) { 1993 switch ( barPos() ) {
1994 case KToolBar::Flat: 1994 case KToolBar::Flat:
1995 position = "Flat"; 1995 position = "Flat";
1996 break; 1996 break;
1997 case KToolBar::Bottom: 1997 case KToolBar::Bottom:
1998 position = "Bottom"; 1998 position = "Bottom";
1999 break; 1999 break;
2000 case KToolBar::Left: 2000 case KToolBar::Left:
2001 position = "Left"; 2001 position = "Left";
2002 break; 2002 break;
2003 case KToolBar::Right: 2003 case KToolBar::Right:
2004 position = "Right"; 2004 position = "Right";
2005 break; 2005 break;
2006 case KToolBar::Floating: 2006 case KToolBar::Floating:
2007 position = "Floating"; 2007 position = "Floating";
2008 break; 2008 break;
2009 case KToolBar::Top: 2009 case KToolBar::Top:
2010 default: 2010 default:
2011 position = "Top"; 2011 position = "Top";
2012 break; 2012 break;
2013 } 2013 }
2014 2014
2015 if ( mainWindow() ) { 2015 if ( mainWindow() ) {
2016 QMainWindow::ToolBarDock dock; 2016 QMainWindow::ToolBarDock dock;
2017 bool newLine; 2017 bool newLine;
2018 int offset; 2018 int offset;
2019 mainWindow()->getLocation( this, dock, index, newLine, offset ); 2019 mainWindow()->getLocation( this, dock, index, newLine, offset );
2020 } 2020 }
2021 2021
2022 switch (d->m_iconText) { 2022 switch (d->m_iconText) {
2023 case KToolBar::IconTextRight: 2023 case KToolBar::IconTextRight:
2024 icontext = "IconTextRight"; 2024 icontext = "IconTextRight";
2025 break; 2025 break;
2026 case KToolBar::IconTextBottom: 2026 case KToolBar::IconTextBottom:
2027 icontext = "IconTextBottom"; 2027 icontext = "IconTextBottom";
2028 break; 2028 break;
2029 case KToolBar::TextOnly: 2029 case KToolBar::TextOnly:
2030 icontext = "TextOnly"; 2030 icontext = "TextOnly";
2031 break; 2031 break;
2032 case KToolBar::IconOnly: 2032 case KToolBar::IconOnly:
2033 default: 2033 default:
2034 icontext = "IconOnly"; 2034 icontext = "IconOnly";
2035 break; 2035 break;
2036 } 2036 }
2037} 2037}
2038/*US 2038/*US
2039void KToolBar::saveState( QDomElement &current ) 2039void KToolBar::saveState( QDomElement &current )
2040{ 2040{
2041 QString position, icontext; 2041 QString position, icontext;
2042 int index = -1; 2042 int index = -1;
2043 getAttributes( position, icontext, index ); 2043 getAttributes( position, icontext, index );
2044 2044
2045 current.setAttribute( "noMerge", "1" ); 2045 current.setAttribute( "noMerge", "1" );
2046 current.setAttribute( "position", position ); 2046 current.setAttribute( "position", position );
2047 current.setAttribute( "iconText", icontext ); 2047 current.setAttribute( "iconText", icontext );
2048 current.setAttribute( "index", index ); 2048 current.setAttribute( "index", index );
2049 current.setAttribute( "offset", offset() ); 2049 current.setAttribute( "offset", offset() );
2050 current.setAttribute( "newline", newLine() ); 2050 current.setAttribute( "newline", newLine() );
2051 if ( isHidden() ) 2051 if ( isHidden() )
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 827ec38..2253de4 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -1,242 +1,243 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <kdebug.h> 24#include <kdebug.h>
25#include <klocale.h> 25#include <klocale.h>
26#include <ksimpleconfig.h> 26#include <ksimpleconfig.h>
27#include <kstandarddirs.h> 27#include <kstandarddirs.h>
28#include <kstaticdeleter.h> 28#include <kstaticdeleter.h>
29//#ifndef DESKTOP_VERSION
29#include <klibloader.h> 30#include <klibloader.h>
30 31//#endif
31#include <qfile.h> 32#include <qfile.h>
32 33
33#include "resource.h" 34#include "resource.h"
34#include "factory.h" 35#include "factory.h"
35 36
36using namespace KRES; 37using namespace KRES;
37 38
38QDict<Factory> *Factory::mSelves = 0; 39QDict<Factory> *Factory::mSelves = 0;
39static KStaticDeleter< QDict<Factory> > staticDeleter; 40static KStaticDeleter< QDict<Factory> > staticDeleter;
40 41
41Factory *Factory::self( const QString& resourceFamily ) 42Factory *Factory::self( const QString& resourceFamily )
42{ 43{
43 44
44 45
45 Factory *factory = 0; 46 Factory *factory = 0;
46 if ( !mSelves ) 47 if ( !mSelves )
47 { 48 {
48 mSelves = staticDeleter.setObject( new QDict<Factory> ); 49 mSelves = staticDeleter.setObject( new QDict<Factory> );
49 } 50 }
50 51
51 factory = mSelves->find( resourceFamily ); 52 factory = mSelves->find( resourceFamily );
52 53
53 if ( !factory ) { 54 if ( !factory ) {
54 factory = new Factory( resourceFamily ); 55 factory = new Factory( resourceFamily );
55 mSelves->insert( resourceFamily, factory ); 56 mSelves->insert( resourceFamily, factory );
56 } 57 }
57 58
58 return factory; 59 return factory;
59} 60}
60 61
61Factory::Factory( const QString& resourceFamily ) : 62Factory::Factory( const QString& resourceFamily ) :
62 mResourceFamily( resourceFamily ) 63 mResourceFamily( resourceFamily )
63{ 64{
64//US so far we have three types available for resourceFamily "contact" 65//US so far we have three types available for resourceFamily "contact"
65// and that are "file", "dir", "ldap" 66// and that are "file", "dir", "ldap"
66/*US 67/*US
67 68
68 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) 69 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
69 .arg( resourceFamily ) ); 70 .arg( resourceFamily ) );
70 KTrader::OfferList::ConstIterator it; 71 KTrader::OfferList::ConstIterator it;
71 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 72 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
72 QVariant type = (*it)->property( "X-KDE-ResourceType" ); 73 QVariant type = (*it)->property( "X-KDE-ResourceType" );
73 if ( !type.toString().isEmpty() ) 74 if ( !type.toString().isEmpty() )
74 mTypeMap.insert( type.toString(), *it ); 75 mTypeMap.insert( type.toString(), *it );
75 } 76 }
76*/ 77*/
77 78
78//US new 79//US new
79 PluginInfo* info = new PluginInfo; 80 PluginInfo* info = new PluginInfo;
80 info->library = "microkabc_file"; 81 info->library = "microkabc_file";
81 info->nameLabel = i18n( "file" ); 82 info->nameLabel = i18n( "file" );
82 info->descriptionLabel = i18n( "Choose one file" ); 83 info->descriptionLabel = i18n( "Choose one file" );
83 mTypeMap.insert( "file", info ); 84 mTypeMap.insert( "file", info );
84 85
85 info = new PluginInfo; 86 info = new PluginInfo;
86 info->library = "microkabc_dir"; 87 info->library = "microkabc_dir";
87 info->nameLabel = i18n( "dir" ); 88 info->nameLabel = i18n( "dir" );
88 info->descriptionLabel = i18n( "Choose a directory with may files" ); 89 info->descriptionLabel = i18n( "Choose a directory with may files" );
89 mTypeMap.insert( "dir", info ); 90 mTypeMap.insert( "dir", info );
90 91
91 info = new PluginInfo; 92 info = new PluginInfo;
92 info->library = "microkabc_ldap"; 93 info->library = "microkabc_ldap";
93 info->nameLabel = i18n( "ldap" ); 94 info->nameLabel = i18n( "ldap" );
94 info->descriptionLabel = i18n( "No description available" ); 95 info->descriptionLabel = i18n( "No description available" );
95 mTypeMap.insert( "ldap", info ); 96 mTypeMap.insert( "ldap", info );
96 97
97 //US add opie plugin only, if the library exists 98 //US add opie plugin only, if the library exists
98 QString libname = "microkabc_opie"; 99 QString libname = "microkabc_opie";
99 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 100 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
100 if ( !path.isEmpty() ) 101 if ( !path.isEmpty() )
101 { 102 {
102 info = new PluginInfo; 103 info = new PluginInfo;
103 info->library = libname; 104 info->library = libname;
104 info->nameLabel = i18n( "opie" ); 105 info->nameLabel = i18n( "opie" );
105 info->descriptionLabel = i18n( "Opie PIM Addressbook." ); 106 info->descriptionLabel = i18n( "Opie PIM Addressbook." );
106 mTypeMap.insert( "opie", info ); 107 mTypeMap.insert( "opie", info );
107 } 108 }
108 109
109 //US add qtopia plugin only, if the library exists 110 //US add qtopia plugin only, if the library exists
110 libname = "microkabc_qtopia"; 111 libname = "microkabc_qtopia";
111 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 112 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
112 if ( !path.isEmpty() ) 113 if ( !path.isEmpty() )
113 { 114 {
114 info = new PluginInfo; 115 info = new PluginInfo;
115 info->library = libname; 116 info->library = libname;
116 info->nameLabel = i18n( "qtopia" ); 117 info->nameLabel = i18n( "qtopia" );
117 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); 118 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." );
118 mTypeMap.insert( "qtopia", info ); 119 mTypeMap.insert( "qtopia", info );
119 } 120 }
120 121
121 122
122} 123}
123 124
124Factory::~Factory() 125Factory::~Factory()
125{ 126{
126} 127}
127 128
128QStringList Factory::typeNames() const 129QStringList Factory::typeNames() const
129{ 130{
130//US method QMap::keys() not available yet. SO collect the data manually 131//US method QMap::keys() not available yet. SO collect the data manually
131//US return mTypeMap.keys(); 132//US return mTypeMap.keys();
132 133
133 QStringList result; 134 QStringList result;
134 135
135 QMap<QString, PluginInfo*>::ConstIterator it; 136 QMap<QString, PluginInfo*>::ConstIterator it;
136 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { 137 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) {
137 result << it.key().latin1(); 138 result << it.key().latin1();
138// qDebug("Factory::typeNames() : %s ", it.key().latin1()); 139// qDebug("Factory::typeNames() : %s ", it.key().latin1());
139 140
140 } 141 }
141 return result; 142 return result;
142} 143}
143 144
144ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) 145ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
145{ 146{
146 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 147 if ( type.isEmpty() || !mTypeMap.contains( type ) )
147 return 0; 148 return 0;
148 149
149//US KService::Ptr ptr = mTypeMap[ type ]; 150//US KService::Ptr ptr = mTypeMap[ type ];
150//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 151//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
151 PluginInfo* pi = mTypeMap[ type ]; 152 PluginInfo* pi = mTypeMap[ type ];
152 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 153 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
153 if ( !factory ) { 154 if ( !factory ) {
154 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); 155 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
155 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; 156 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
156 return 0; 157 return 0;
157 } 158 }
158 159
159 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 160 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
160 161
161 if ( !pluginFactory ) { 162 if ( !pluginFactory ) {
162 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); 163 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
163 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; 164 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
164 return 0; 165 return 0;
165 } 166 }
166 167
167 ConfigWidget *wdg = pluginFactory->configWidget( parent ); 168 ConfigWidget *wdg = pluginFactory->configWidget( parent );
168 if ( !wdg ) { 169 if ( !wdg ) {
169//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 170//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
170 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 171 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
171 return 0; 172 return 0;
172 } 173 }
173 return wdg; 174 return wdg;
174 175
175} 176}
176 177
177QString Factory::typeName( const QString &type ) const 178QString Factory::typeName( const QString &type ) const
178{ 179{
179 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 180 if ( type.isEmpty() || !mTypeMap.contains( type ) )
180 return QString(); 181 return QString();
181 182
182 183
183//US KService::Ptr ptr = mTypeMap[ type ]; 184//US KService::Ptr ptr = mTypeMap[ type ];
184//US return ptr->name(); 185//US return ptr->name();
185 PluginInfo* pi = mTypeMap[ type ]; 186 PluginInfo* pi = mTypeMap[ type ];
186 return pi->nameLabel; 187 return pi->nameLabel;
187 188
188} 189}
189 190
190QString Factory::typeDescription( const QString &type ) const 191QString Factory::typeDescription( const QString &type ) const
191{ 192{
192 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 193 if ( type.isEmpty() || !mTypeMap.contains( type ) )
193 return QString(); 194 return QString();
194 195
195//US KService::Ptr ptr = mTypeMap[ type ]; 196//US KService::Ptr ptr = mTypeMap[ type ];
196//US return ptr->comment(); 197//US return ptr->comment();
197 PluginInfo* pi = mTypeMap[ type ]; 198 PluginInfo* pi = mTypeMap[ type ];
198 return pi->descriptionLabel; 199 return pi->descriptionLabel;
199} 200}
200 201
201Resource *Factory::resource( const QString& type, const KConfig *config ) 202Resource *Factory::resource( const QString& type, const KConfig *config )
202{ 203{
203 204
204 205
205 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 206 if ( type.isEmpty() || !mTypeMap.contains( type ) )
206 return 0; 207 return 0;
207 208
208/*US load the lib not dynamicly. !! 209/*US load the lib not dynamicly. !!
209 KService::Ptr ptr = mTypeMap[ type ]; 210 KService::Ptr ptr = mTypeMap[ type ];
210 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 211 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
211 if ( !factory ) { 212 if ( !factory ) {
212 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 213 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
213 return 0; 214 return 0;
214 } 215 }
215*/ 216*/
216 PluginInfo* pi = mTypeMap[ type ]; 217 PluginInfo* pi = mTypeMap[ type ];
217 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 218 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
218 if ( !factory ) { 219 if ( !factory ) {
219 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); 220 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
220 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 221 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
221 return 0; 222 return 0;
222 } 223 }
223 224
224 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 225 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
225 226
226 if ( !pluginFactory ) { 227 if ( !pluginFactory ) {
227 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); 228 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
228 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; 229 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
229 return 0; 230 return 0;
230 } 231 }
231 232
232 Resource *resource = pluginFactory->resource( config ); 233 Resource *resource = pluginFactory->resource( config );
233 if ( !resource ) { 234 if ( !resource ) {
234//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 235//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
235 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 236 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
236 return 0; 237 return 0;
237 } 238 }
238 239
239 resource->setType( type ); 240 resource->setType( type );
240 241
241 return resource; 242 return resource;
242} 243}
diff --git a/microkde/microkde.pro b/microkde/microkde.pro
index 1e9b022..05833a9 100644
--- a/microkde/microkde.pro
+++ b/microkde/microkde.pro
@@ -1,170 +1,168 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3#INCLUDEPATH += $(QTDIR)/include . 3#INCLUDEPATH += $(QTDIR)/include .
4#DEPENDPATH += $(QTDIR)/include 4#DEPENDPATH += $(QTDIR)/include
5INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile 5INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile
6#LIBS += -lqtcompat 6#LIBS += -lqtcompat
7 7
8 TARGET = microkde 8 TARGET = microkde
9DESTDIR= ../bin 9DESTDIR= ../bin
10DEFINES += DESKTOP_VERSION KDE_QT_ONLY 10DEFINES += DESKTOP_VERSION KDE_QT_ONLY
11unix : { 11unix : {
12OBJECTS_DIR = obj/unix 12OBJECTS_DIR = obj/unix
13MOC_DIR = moc/unix 13MOC_DIR = moc/unix
14} 14}
15win32: { 15win32: {
16DEFINES += _WIN32_ 16DEFINES += _WIN32_
17OBJECTS_DIR = obj/win 17OBJECTS_DIR = obj/win
18MOC_DIR = moc/win 18MOC_DIR = moc/win
19} 19}
20include( ../variables.pri ) 20include( ../variables.pri )
21 21
22 22
23 23
24HEADERS = \ 24HEADERS = \
25qlayoutengine_p.h \ 25qlayoutengine_p.h \
26KDGanttMinimizeSplitter.h \ 26KDGanttMinimizeSplitter.h \
27 kapplication.h \ 27 kapplication.h \
28 kaudioplayer.h \ 28 kaudioplayer.h \
29 kcalendarsystem.h \ 29 kcalendarsystem.h \
30 kcalendarsystemgregorian.h \ 30 kcalendarsystemgregorian.h \
31 kcolorbutton.h \ 31 kcolorbutton.h \
32 kcolordialog.h \ 32 kcolordialog.h \
33 kcombobox.h \ 33 kcombobox.h \
34 kconfig.h \ 34 kconfig.h \
35 kdatetbl.h \ 35 kdatetbl.h \
36 kdebug.h \ 36 kdebug.h \
37 kdialog.h \ 37 kdialog.h \
38 kdialogbase.h \ 38 kdialogbase.h \
39 kdirwatch.h \ 39 kdirwatch.h \
40 keditlistbox.h \ 40 keditlistbox.h \
41 kemailsettings.h \ 41 kemailsettings.h \
42 kfiledialog.h \ 42 kfiledialog.h \
43 kfontdialog.h \ 43 kfontdialog.h \
44 kglobal.h \ 44 kglobal.h \
45 kglobalsettings.h \ 45 kglobalsettings.h \
46 kiconloader.h \ 46 kiconloader.h \
47 klineedit.h \ 47 klineedit.h \
48 klineeditdlg.h \ 48 klineeditdlg.h \
49 kmessagebox.h \ 49 kmessagebox.h \
50 knotifyclient.h \ 50 knotifyclient.h \
51 kprinter.h \ 51 kprinter.h \
52 kprocess.h \ 52 kprocess.h \
53 krestrictedline.h \ 53 krestrictedline.h \
54 krun.h \ 54 krun.h \
55 ksimpleconfig.h \ 55 ksimpleconfig.h \
56 kstaticdeleter.h \ 56 kstaticdeleter.h \
57 ksystemtray.h \ 57 ksystemtray.h \
58 ktempfile.h \ 58 ktempfile.h \
59 ktextedit.h \ 59 ktextedit.h \
60 kunload.h \ 60 kunload.h \
61 kurl.h \ 61 kurl.h \
62 kdeui/kguiitem.h \ 62 kdeui/kguiitem.h \
63 kdeui/kcmodule.h \ 63 kdeui/kcmodule.h \
64 kdeui/kbuttonbox.h \ 64 kdeui/kbuttonbox.h \
65 kdeui/klistbox.h \ 65 kdeui/klistbox.h \
66 kdeui/klistview.h \ 66 kdeui/klistview.h \
67 kdeui/kjanuswidget.h \ 67 kdeui/kjanuswidget.h \
68 kdeui/kseparator.h \ 68 kdeui/kseparator.h \
69 kdeui/knuminput.h \ 69 kdeui/knuminput.h \
70 kdeui/knumvalidator.h \ 70 kdeui/knumvalidator.h \
71 kdeui/ksqueezedtextlabel.h \ 71 kdeui/ksqueezedtextlabel.h \
72 kio/job.h \ 72 kio/job.h \
73 kio/kfile/kurlrequester.h \ 73 kio/kfile/kurlrequester.h \
74 kresources/resource.h \ 74 kresources/resource.h \
75 kresources/factory.h \ 75 kresources/factory.h \
76 kresources/managerimpl.h \ 76 kresources/managerimpl.h \
77 kresources/manager.h \ 77 kresources/manager.h \
78 kresources/selectdialog.h \ 78 kresources/selectdialog.h \
79 kresources/configpage.h \ 79 kresources/configpage.h \
80 kresources/configwidget.h \ 80 kresources/configwidget.h \
81 kresources/configdialog.h \ 81 kresources/configdialog.h \
82 kresources/kcmkresources.h \ 82 kresources/kcmkresources.h \
83 kdecore/kmdcodec.h \ 83 kdecore/kmdcodec.h \
84 kdecore/kconfigbase.h \ 84 kdecore/kconfigbase.h \
85 kdecore/klocale.h \ 85 kdecore/klocale.h \
86 kdecore/kcatalogue.h \ 86 kdecore/kcatalogue.h \
87 kdecore/ksharedptr.h \ 87 kdecore/ksharedptr.h \
88 kdecore/kshell.h \ 88 kdecore/kshell.h \
89 kdecore/kstandarddirs.h \ 89 kdecore/kstandarddirs.h \
90 kdecore/kstringhandler.h \ 90 kdecore/kstringhandler.h \
91 kdecore/kshortcut.h \ 91 kdecore/kshortcut.h \
92 kutils/kcmultidialog.h \ 92 kutils/kcmultidialog.h \
93 kdeui/kxmlguiclient.h \ 93 kdeui/kxmlguiclient.h \
94 kdeui/kstdaction.h \ 94 kdeui/kstdaction.h \
95 kdeui/kmainwindow.h \ 95 kdeui/kmainwindow.h \
96 kdeui/ktoolbar.h \ 96 kdeui/ktoolbar.h \
97 kdeui/ktoolbarbutton.h \ 97 kdeui/ktoolbarbutton.h \
98 kdeui/ktoolbarhandler.h \ 98 kdeui/ktoolbarhandler.h \
99 kdeui/kaction.h \ 99 kdeui/kaction.h \
100 kdeui/kactionclasses.h \ 100 kdeui/kactionclasses.h \
101 kdeui/kactioncollection.h 101 kdeui/kactioncollection.h \
102 kdecore/klibloader.h
102 103
103 104
104# kdecore/klibloader.h \ 105# kdecore/klibloader.h \
105 106
106 107
107SOURCES = \ 108SOURCES = \
108KDGanttMinimizeSplitter.cpp \ 109KDGanttMinimizeSplitter.cpp \
109 kapplication.cpp \ 110 kapplication.cpp \
110 kcalendarsystem.cpp \ 111 kcalendarsystem.cpp \
111 kcalendarsystemgregorian.cpp \ 112 kcalendarsystemgregorian.cpp \
112 kcolorbutton.cpp \ 113 kcolorbutton.cpp \
113 kcolordialog.cpp \ 114 kcolordialog.cpp \
114 kconfig.cpp \ 115 kconfig.cpp \
115 kdatetbl.cpp \ 116 kdatetbl.cpp \
116 kdialog.cpp \ 117 kdialog.cpp \
117 kdialogbase.cpp \ 118 kdialogbase.cpp \
118 keditlistbox.cpp \ 119 keditlistbox.cpp \
119 kemailsettings.cpp \ 120 kemailsettings.cpp \
120 kfontdialog.cpp \ 121 kfontdialog.cpp \
121 kfiledialog.cpp \ 122 kfiledialog.cpp \
122 kglobal.cpp \ 123 kglobal.cpp \
123 kglobalsettings.cpp \ 124 kglobalsettings.cpp \
124 kiconloader.cpp \ 125 kiconloader.cpp \
125 kmessagebox.cpp \ 126 kmessagebox.cpp \
126 ktextedit.cpp \ 127 ktextedit.cpp \
127 kprocess.cpp \ 128 kprocess.cpp \
128 krun.cpp \ 129 krun.cpp \
129 ksystemtray.cpp \ 130 ksystemtray.cpp \
130 ktempfile.cpp \ 131 ktempfile.cpp \
131 kurl.cpp \ 132 kurl.cpp \
132 kdecore/kcatalogue.cpp \ 133 kdecore/kcatalogue.cpp \
133 kdecore/klocale.cpp \ 134 kdecore/klocale.cpp \
134 kdecore/kmdcodec.cpp \ 135 kdecore/kmdcodec.cpp \
135 kdecore/kshell.cpp \ 136 kdecore/kshell.cpp \
136 kdecore/kstandarddirs.cpp \ 137 kdecore/kstandarddirs.cpp \
137 kdecore/kstringhandler.cpp \ 138 kdecore/kstringhandler.cpp \
138 kdeui/kbuttonbox.cpp \ 139 kdeui/kbuttonbox.cpp \
139 kdeui/kcmodule.cpp \ 140 kdeui/kcmodule.cpp \
140 kdeui/kguiitem.cpp \ 141 kdeui/kguiitem.cpp \
141 kdeui/kjanuswidget.cpp \ 142 kdeui/kjanuswidget.cpp \
142 kdeui/klistbox.cpp \ 143 kdeui/klistbox.cpp \
143 kdeui/klistview.cpp \ 144 kdeui/klistview.cpp \
144 kdeui/knuminput.cpp \ 145 kdeui/knuminput.cpp \
145 kdeui/knumvalidator.cpp \ 146 kdeui/knumvalidator.cpp \
146 kdeui/kseparator.cpp \ 147 kdeui/kseparator.cpp \
147 kdeui/ksqueezedtextlabel.cpp \ 148 kdeui/ksqueezedtextlabel.cpp \
148 kio/kfile/kurlrequester.cpp \ 149 kio/kfile/kurlrequester.cpp \
149 kresources/configpage.cpp \ 150 kresources/configpage.cpp \
150 kresources/configdialog.cpp \ 151 kresources/configdialog.cpp \
151 kresources/configwidget.cpp \ 152 kresources/configwidget.cpp \
152 kresources/factory.cpp \ 153 kresources/factory.cpp \
153 kresources/kcmkresources.cpp \ 154 kresources/kcmkresources.cpp \
154 kresources/managerimpl.cpp \ 155 kresources/managerimpl.cpp \
155 kresources/resource.cpp \ 156 kresources/resource.cpp \
156 kresources/selectdialog.cpp \ 157 kresources/selectdialog.cpp \
157 kutils/kcmultidialog.cpp \ 158 kutils/kcmultidialog.cpp \
158 kdeui/kaction.cpp \ 159 kdeui/kaction.cpp \
159 kdeui/kactionclasses.cpp \ 160 kdeui/kactionclasses.cpp \
160 kdeui/kactioncollection.cpp \ 161 kdeui/kactioncollection.cpp \
161 kdeui/kmainwindow.cpp \ 162 kdeui/kmainwindow.cpp \
162 kdeui/ktoolbar.cpp \ 163 kdeui/ktoolbar.cpp \
163 kdeui/ktoolbarbutton.cpp \ 164 kdeui/ktoolbarbutton.cpp \
164 kdeui/ktoolbarhandler.cpp \ 165 kdeui/ktoolbarhandler.cpp \
165 kdeui/kstdaction.cpp \ 166 kdeui/kstdaction.cpp \
166 kdeui/kxmlguiclient.cpp 167 kdeui/kxmlguiclient.cpp \
167 168 kdecore/klibloader.cpp \ No newline at end of file
168
169
170# kdecore/klibloader.cpp \ \ No newline at end of file