author | mickeyl <mickeyl> | 2004-02-21 12:25:50 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-21 12:25:50 (UTC) |
commit | 6155f1be5c19fc51a4929c9e173f9e5a24d193e6 (patch) (unidiff) | |
tree | c18ca863f82a559c60728f922519ac696387ec53 | |
parent | a570c2824fcecaf1c278e1b5a592fa14cc0647f8 (diff) | |
download | opie-6155f1be5c19fc51a4929c9e173f9e5a24d193e6.zip opie-6155f1be5c19fc51a4929c9e173f9e5a24d193e6.tar.gz opie-6155f1be5c19fc51a4929c9e173f9e5a24d193e6.tar.bz2 |
the usual cosmetics
24 files changed, 851 insertions, 650 deletions
@@ -1,235 +1,237 @@ | |||
1 | .phony: force | 1 | .phony: force |
2 | force: | 2 | force: |
3 | 3 | ||
4 | $(configs) : | 4 | $(configs) : |
5 | $(call makecfg,$@) | 5 | $(call makecfg,$@) |
6 | 6 | ||
7 | $(TOPDIR)/gen.pro : $(TOPDIR)/.config | 7 | $(TOPDIR)/gen.pro : $(TOPDIR)/.config |
8 | echo > $@ | 8 | echo > $@ |
9 | ifneq ($(CONFIG_DEBUG),) | 9 | ifneq ($(CONFIG_DEBUG),) |
10 | echo CONFIG += debug >> $@ | 10 | echo CONFIG += debug >> $@ |
11 | echo CONFIG -= release >> $@ | 11 | echo CONFIG -= release >> $@ |
12 | else | 12 | else |
13 | echo CONFIG -= debug >> $@ | 13 | echo CONFIG -= debug >> $@ |
14 | echo CONFIG += release >> $@ | 14 | echo CONFIG += release >> $@ |
15 | endif | 15 | endif |
16 | ifeq ($(filter 3.%,$(QTE_VERSION)),) # not qt3 | 16 | ifeq ($(filter 3.%,$(QTE_VERSION)),) # not qt3 |
17 | echo CONFIG -= qt3 >> $@ | 17 | echo CONFIG -= qt3 >> $@ |
18 | else | 18 | else |
19 | echo CONFIG += qt3 >> $@ | 19 | echo CONFIG += qt3 >> $@ |
20 | endif | 20 | endif |
21 | ifneq ($(CONFIG_QUICK_LAUNCH),) | 21 | ifneq ($(CONFIG_QUICK_LAUNCH),) |
22 | echo contains\( CONFIG, quick-app \) \{ >> $@ | 22 | echo contains\( CONFIG, quick-app \) \{ >> $@ |
23 | echo CONFIG -= quick-app >> $@ | 23 | echo CONFIG -= quick-app >> $@ |
24 | echo CONFIG += quick-app-lib >> $@ | 24 | echo CONFIG += quick-app-lib >> $@ |
25 | echo QUICKLAUNCH_PATH = $(CONFIG_QUICKLAUNCH_PATH) >> $@ | 25 | echo QUICKLAUNCH_PATH = $(CONFIG_QUICKLAUNCH_PATH) >> $@ |
26 | echo \} >> $@ | 26 | echo \} >> $@ |
27 | else | 27 | else |
28 | echo contains\( CONFIG, quick-app \) \{ >> $@ | 28 | echo contains\( CONFIG, quick-app \) \{ >> $@ |
29 | echo CONFIG -= quick-app >> $@ | 29 | echo CONFIG -= quick-app >> $@ |
30 | echo CONFIG += quick-app-bin >> $@ | 30 | echo CONFIG += quick-app-bin >> $@ |
31 | echo \} >> $@ | 31 | echo \} >> $@ |
32 | endif | 32 | endif |
33 | ifeq ($(CONFIG_OPIE_NO_OVERRIDE_QT),y) | 33 | ifeq ($(CONFIG_OPIE_NO_OVERRIDE_QT),y) |
34 | echo CONFIG += no-override >> $@ | 34 | echo CONFIG += no-override >> $@ |
35 | endif | 35 | endif |
36 | ifeq ($(CONFIG_OPIE_NO_BUILTIN_SHUTDOWN),y) | 36 | ifeq ($(CONFIG_OPIE_NO_BUILTIN_SHUTDOWN),y) |
37 | echo DEFINES += OPIE_NO_BUILTIN_SHUTDOWN >> $@ | 37 | echo DEFINES += OPIE_NO_BUILTIN_SHUTDOWN >> $@ |
38 | endif | 38 | endif |
39 | ifeq ($(CONFIG_OPIE_NO_BUILTIN_CALIBRATE),y) | 39 | ifeq ($(CONFIG_OPIE_NO_BUILTIN_CALIBRATE),y) |
40 | echo DEFINES += OPIE_NO_BUILTIN_CALIBRATE >> $@ | 40 | echo DEFINES += OPIE_NO_BUILTIN_CALIBRATE >> $@ |
41 | endif | 41 | endif |
42 | ifeq ($(CONFIG_USE_REALTIME_AUDIO_THREAD),y) | 42 | ifeq ($(CONFIG_USE_REALTIME_AUDIO_THREAD),y) |
43 | echo DEFINES += USE_REALTIME_AUDIO_THREAD >> $@ | 43 | echo DEFINES += USE_REALTIME_AUDIO_THREAD >> $@ |
44 | endif | 44 | endif |
45 | ifeq ($(CONFIG_QT_QWS_ALLOW_CLOCK),y) | 45 | ifeq ($(CONFIG_QT_QWS_ALLOW_CLOCK),y) |
46 | echo DEFINES += QT_QWS_ALLOW_OVERCLOCK >> $@ | 46 | echo DEFINES += QT_QWS_ALLOW_OVERCLOCK >> $@ |
47 | endif | 47 | endif |
48 | ifeq ($(CONFIG_OPIE_HIGH_RES_SMALL_PHY),y) | 48 | ifeq ($(CONFIG_OPIE_HIGH_RES_SMALL_PHY),y) |
49 | echo DEFINES += OPIE_HIGH_RES_SMALL_PHY >> $@ | 49 | echo DEFINES += OPIE_HIGH_RES_SMALL_PHY >> $@ |
50 | endif | 50 | endif |
51 | ifeq ($(CONFIG_OPIE_NEW_ALLOC),y) | 51 | ifeq ($(CONFIG_OPIE_NEW_ALLOC),y) |
52 | echo DEFINES += OPIE_NEW_MALLOC >> $@ | 52 | echo DEFINES += OPIE_NEW_MALLOC >> $@ |
53 | endif | 53 | endif |
54 | ifeq ($(CONFIG_OPIE_NO_SOUND_PCM_READ_BITS),y) | 54 | ifeq ($(CONFIG_OPIE_NO_SOUND_PCM_READ_BITS),y) |
55 | echo DEFINES += OPIE_NO_SOUND_PCM_READ_BITS >> $@ | 55 | echo DEFINES += OPIE_NO_SOUND_PCM_READ_BITS >> $@ |
56 | endif | 56 | endif |
57 | echo DEFINES += OPIE_SOUND_FRAGMENT_SHIFT=$(CONFIG_OPIE_SOUND_FRAGMENT_SHIFT) >> $@ | 57 | echo DEFINES += OPIE_SOUND_FRAGMENT_SHIFT=$(CONFIG_OPIE_SOUND_FRAGMENT_SHIFT) >> $@ |
58 | $(TOPDIR)/.depends : $(shell if [ -e $(TOPDIR)/config.in ]\; then echo $(TOPDIR)/config.in\; fi\;) $(TOPDIR)/.config $(TOPDIR)/packages | 58 | $(TOPDIR)/.depends : $(shell if [ -e $(TOPDIR)/config.in ]\; then echo $(TOPDIR)/config.in\; fi\;) $(TOPDIR)/.config $(TOPDIR)/packages |
59 | @echo Generating dependency information... | 59 | @echo Generating dependency information... |
60 | # add to subdir-y, and add descend rules | 60 | # add to subdir-y, and add descend rules |
61 | @cat $(TOPDIR)/packages | grep -v '^#' | \ | 61 | @cat $(TOPDIR)/packages | grep -v '^#' | \ |
62 | awk '{print \ | 62 | awk '{print \ |
63 | ".PHONY : " $$2 "\n" \ | 63 | ".PHONY : " $$2 "\n" \ |
64 | "subdir-$$(" $$1 ") += " $$2 "\n\n"; \ | 64 | "subdir-$$(" $$1 ") += " $$2 "\n\n"; \ |
65 | print $$2 " : " $$2 "/Makefile\n\t$$(call descend,$$@,$(filter-out $$@,$$(filter-out $$@,$$(MAKECMDGOALS))))\n"; }' > $(TOPDIR)/.depends | 65 | print $$2 " : " $$2 "/Makefile\n\t$$(call descend,$$@,$(filter-out $$@,$$(filter-out $$@,$$(MAKECMDGOALS))))\n"; }' > $(TOPDIR)/.depends |
66 | cat $(TOPDIR)/packages | grep -v '^#' | \ | 66 | cat $(TOPDIR)/packages | grep -v '^#' | \ |
67 | perl -ne '($$cfg, $$dir, $$pro) = $$_ =~ /^(\S+)\s+(\S+)\s+(\S+)/; if ( -e "$$dir/$$pro" ) { print "$$dir/Makefile : $$dir/$$pro \$$(QMAKE) \$$(OPIEDIR)/gen.pro \$$(OPIEDIR)/.config\n\t\$$(call makefilegen,\$$@)\n\n"; }' \ | 67 | perl -ne '($$cfg, $$dir, $$pro) = $$_ =~ /^(\S+)\s+(\S+)\s+(\S+)/; if ( -e "$$dir/$$pro" ) { print "$$dir/Makefile : $$dir/$$pro \$$(QMAKE) \$$(OPIEDIR)/gen.pro \$$(OPIEDIR)/.config\n\t\$$(call makefilegen,\$$@)\n\n"; }' \ |
68 | >> $(TOPDIR)/.depends | 68 | >> $(TOPDIR)/.depends |
69 | # interpackage dependency generation | 69 | # interpackage dependency generation |
70 | @cat $(TOPDIR)/packages | \ | 70 | @cat $(TOPDIR)/packages | \ |
71 | $(TOPDIR)/scripts/deps.pl >> $(TOPDIR)/.depends | 71 | $(TOPDIR)/scripts/deps.pl >> $(TOPDIR)/.depends |
72 | 72 | ||
73 | $(TOPDIR)/.depends.cfgs: | 73 | $(TOPDIR)/.depends.cfgs: |
74 | # config.in interdependencies | 74 | # config.in interdependencies |
75 | @echo $(configs) | sed -e 's,/config.in,,g' | ( for i in `cat`; do echo $$i; done ) > dirs | 75 | @echo $(configs) | sed -e 's,/config.in,,g' | ( for i in `cat`; do echo $$i; done ) > dirs |
76 | @cat dirs | ( for i in `cat`; do if [ "`cat dirs|grep $$i 2>/dev/null|wc -l`" -ne "1" ]; then deps=`cat dirs|grep $$i| grep -v "^$$i$$"|for i in \`cat|sed -e's,^$(TOPDIR)/,$$(TOPDIR)/,g'\`; do echo $$i/config.in; done`; echo `echo $$i/config.in|sed -e 's,^$(TOPDIR)/,$$(TOPDIR)/,'` : $$deps; fi; done ) >> $@ | 76 | @cat dirs | ( for i in `cat`; do if [ "`cat dirs|grep $$i 2>/dev/null|wc -l`" -ne "1" ]; then deps=`cat dirs|grep $$i| grep -v "^$$i$$"|for i in \`cat|sed -e's,^$(TOPDIR)/,$$(TOPDIR)/,g'\`; do echo $$i/config.in; done`; echo `echo $$i/config.in|sed -e 's,^$(TOPDIR)/,$$(TOPDIR)/,'` : $$deps; fi; done ) >> $@ |
77 | @-rm -f dirs | 77 | @-rm -f dirs |
78 | 78 | ||
79 | $(QTDIR)/stamp-headers : | 79 | $(QTDIR)/stamp-headers : |
80 | @-rm -f $(QTDIR)/stamp-headers* | 80 | @-rm -f $(QTDIR)/stamp-headers* |
81 | ( cd $(QTDIR)/include; \ | 81 | ( cd $(QTDIR)/include; \ |
82 | $(patsubst %,ln -sf ../src/kernel/%;,qgfx_qws.h qwsmouse_qws.h \ | 82 | $(patsubst %,ln -sf ../src/kernel/%;,qgfx_qws.h qwsmouse_qws.h \ |
83 | qcopchannel_qws.h qwindowsystem_qws.h \ | 83 | qcopchannel_qws.h qwindowsystem_qws.h \ |
84 | qfontmanager_qws.h qwsdefaultdecoration_qws.h)) | 84 | qfontmanager_qws.h qwsdefaultdecoration_qws.h)) |
85 | touch $@ | 85 | touch $@ |
86 | 86 | ||
87 | $(QTDIR)/stamp-headers-x11 : | 87 | $(QTDIR)/stamp-headers-x11 : |
88 | @-rm -f $(QTDIR)/stamp-headers* | 88 | @-rm -f $(QTDIR)/stamp-headers* |
89 | cd $(QTDIR)/include; $(patsubst %,ln -sf $(OPIEDIR)/x11/libqpe-x11/qt/%;,qgfx_qws.h qwsmouse_qws.h qcopchannel_qws.h qwindowsystem_qws.h qfontmanager_qws.h qwsdefaultdecoration_qws.h) | 89 | cd $(QTDIR)/include; $(patsubst %,ln -sf $(OPIEDIR)/x11/libqpe-x11/qt/%;,qgfx_qws.h qwsmouse_qws.h qcopchannel_qws.h qwindowsystem_qws.h qfontmanager_qws.h qwsdefaultdecoration_qws.h) |
90 | touch $@ | 90 | touch $@ |
91 | 91 | ||
92 | $(OPIEDIR)/stamp-headers : | 92 | $(OPIEDIR)/stamp-headers : |
93 | @-rm -f $(OPIEDIR)/stamp-headers* | 93 | @-rm -f $(OPIEDIR)/stamp-headers* |
94 | mkdir -p $(TOPDIR)/include/qpe \ | 94 | mkdir -p $(TOPDIR)/include/qpe \ |
95 | $(TOPDIR)/include/qtopia \ | 95 | $(TOPDIR)/include/qtopia \ |
96 | $(TOPDIR)/include/opie \ | 96 | $(TOPDIR)/include/opie \ |
97 | $(TOPDIR)/include/opie2 \ | 97 | $(TOPDIR)/include/opie2 \ |
98 | $(TOPDIR)/include/qtopia/private | 98 | $(TOPDIR)/include/qtopia/private |
99 | ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; ) | 99 | ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; ) |
100 | ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; ) | 100 | ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; ) |
101 | ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; ) | 101 | ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; ) |
102 | # libopie1 | 102 | # libopie1 |
103 | ( cd include/opie && rm -f *.h; ln -sf ../../libopie/*.h .; rm -f *_p.h; ) | 103 | ( cd include/opie && rm -f *.h; ln -sf ../../libopie/*.h .; rm -f *_p.h; ) |
104 | ( cd include/opie && ln -sf ../../libopie/pim/*.h .; ) | 104 | ( cd include/opie && ln -sf ../../libopie/pim/*.h .; ) |
105 | ( cd include/opie && ln -sf ../../libopie/big-screen/*.h .; ) | 105 | ( cd include/opie && ln -sf ../../libopie/big-screen/*.h .; ) |
106 | # libopie2 | 106 | # libopie2 |
107 | ( cd include/opie2 && ln -sf ../../libopie2/opiecore/*.h .; ) | 107 | ( cd include/opie2 && ln -sf ../../libopie2/opiecore/*.h .; ) |
108 | ( cd include/opie2 && ln -sf ../../libopie2/opiecore/device/*.h .; ) | 108 | ( cd include/opie2 && ln -sf ../../libopie2/opiecore/device/*.h .; ) |
109 | ( cd include/opie2 && ln -sf ../../libopie2/opiemm/*.h .; ) | 109 | ( cd include/opie2 && ln -sf ../../libopie2/opiemm/*.h .; ) |
110 | ( cd include/opie2 && ln -sf ../../libopie2/opiedb/*.h .; ) | 110 | ( cd include/opie2 && ln -sf ../../libopie2/opiedb/*.h .; ) |
111 | ( cd include/opie2 && ln -sf ../../libopie2/opienet/*.h .; ) | 111 | ( cd include/opie2 && ln -sf ../../libopie2/opienet/*.h .; ) |
112 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/*.h .; ) | 112 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/*.h .; ) |
113 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/core/*.h .; ) | ||
114 | ( cd include/opie2 && ln -sf ../../libopie2/opiepim/core/backends/*.h .; ) | ||
113 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/*.h .; ) | 115 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/*.h .; ) |
114 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/fileselector/*.h .; ) | 116 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/fileselector/*.h .; ) |
115 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/big-screen/*.h .; ) | 117 | ( cd include/opie2 && ln -sf ../../libopie2/opieui/big-screen/*.h .; ) |
116 | ( cd include/opie2 && ln -sf ../../libqtaux/*.h .; ) | 118 | ( cd include/opie2 && ln -sf ../../libqtaux/*.h .; ) |
117 | # all | 119 | # all |
118 | ( cd include/opie; for generatedHeader in `cd ../../libopie; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ | 120 | ( cd include/opie; for generatedHeader in `cd ../../libopie; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ |
119 | ln -sf ../../libopie/$$generatedHeader $$generatedHeader; done ) | 121 | ln -sf ../../libopie/$$generatedHeader $$generatedHeader; done ) |
120 | ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h | 122 | ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h |
121 | touch $@ | 123 | touch $@ |
122 | 124 | ||
123 | $(OPIEDIR)/stamp-headers-x11 : | 125 | $(OPIEDIR)/stamp-headers-x11 : |
124 | @-rm -f $(OPIEDIR)/stamp-headers* | 126 | @-rm -f $(OPIEDIR)/stamp-headers* |
125 | mkdir -p $(TOPDIR)/include/qpe $(TOPDIR)/include/qtopia \ | 127 | mkdir -p $(TOPDIR)/include/qpe $(TOPDIR)/include/qtopia \ |
126 | $(TOPDIR)/include/opie $(TOPDIR)/include/qtopia/private | 128 | $(TOPDIR)/include/opie $(TOPDIR)/include/qtopia/private |
127 | ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; ) | 129 | ( cd include/qpe && rm -f *.h; ln -sf ../../library/*.h .; ln -sf ../../library/backend/*.h .; rm -f *_p.h; ) |
128 | ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; ) | 130 | ( cd include/qtopia && rm -f *.h; ln -sf ../../library/*.h .; ) |
129 | ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; ) | 131 | ( cd include/qtopia/private && rm -f *.h; ln -sf ../../../library/backend/*.h .; ) |
130 | ( cd include/opie && rm -f *.h; ln -sf ../../libopie/*.h .; rm -f *_p.h; ) | 132 | ( cd include/opie && rm -f *.h; ln -sf ../../libopie/*.h .; rm -f *_p.h; ) |
131 | ( cd include/opie && ln -sf ../../libsql/*.h .; ) | 133 | ( cd include/opie && ln -sf ../../libsql/*.h .; ) |
132 | ( cd include/opie && ln -sf ../../libopie/pim/*.h .; ) | 134 | ( cd include/opie && ln -sf ../../libopie/pim/*.h .; ) |
133 | ( cd include/opie; for generatedHeader in `cd ../../libopie; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ | 135 | ( cd include/opie; for generatedHeader in `cd ../../libopie; ls *.ui | sed -e "s,\.ui,\.h,g"`; do \ |
134 | ln -sf ../../libopie/$$generatedHeader $$generatedHeader; done ) | 136 | ln -sf ../../libopie/$$generatedHeader $$generatedHeader; done ) |
135 | ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h | 137 | ln -sf ../../library/custom.h $(TOPDIR)/include/qpe/custom.h |
136 | ( cd include/qpe; ln -sf ../../x11/libqpe-x11/qpe/*.h .; ) | 138 | ( cd include/qpe; ln -sf ../../x11/libqpe-x11/qpe/*.h .; ) |
137 | touch $@ | 139 | touch $@ |
138 | 140 | ||
139 | $(TOPDIR)/library/custom.h : $(TOPDIR)/.config | 141 | $(TOPDIR)/library/custom.h : $(TOPDIR)/.config |
140 | @-rm -f $@ | 142 | @-rm -f $@ |
141 | @$(if $(patsubst "%",%,$(CONFIG_CUSTOMFILE)),\ | 143 | @$(if $(patsubst "%",%,$(CONFIG_CUSTOMFILE)),\ |
142 | ln -sf $(patsubst "%",%,$(CONFIG_CUSTOMFILE)) $@) | 144 | ln -sf $(patsubst "%",%,$(CONFIG_CUSTOMFILE)) $@) |
143 | @touch $@ | 145 | @touch $@ |
144 | 146 | ||
145 | $(TOPDIR)/scripts/lxdialog/lxdialog $(TOPDIR)/scripts/kconfig/mconf $(TOPDIR)/scripts/kconfig/conf $(TOPDIR)/scripts/kconfig/qconf $(TOPDIR)/scripts/kconfig/libkconfig.so $(TOPDIR)/scripts/kconfig/gconf $(TOPDIR)/qmake/qmake: | 147 | $(TOPDIR)/scripts/lxdialog/lxdialog $(TOPDIR)/scripts/kconfig/mconf $(TOPDIR)/scripts/kconfig/conf $(TOPDIR)/scripts/kconfig/qconf $(TOPDIR)/scripts/kconfig/libkconfig.so $(TOPDIR)/scripts/kconfig/gconf $(TOPDIR)/qmake/qmake: |
146 | @$(call descend,$(shell dirname $@),$(shell basename $@)) | 148 | @$(call descend,$(shell dirname $@),$(shell basename $@)) |
147 | 149 | ||
148 | menuconfig: $(TOPDIR)/scripts/lxdialog/lxdialog $(TOPDIR)/scripts/kconfig/mconf ./config.in | 150 | menuconfig: $(TOPDIR)/scripts/lxdialog/lxdialog $(TOPDIR)/scripts/kconfig/mconf ./config.in |
149 | $(TOPDIR)/scripts/kconfig/mconf ./config.in | 151 | $(TOPDIR)/scripts/kconfig/mconf ./config.in |
150 | @touch ./.config.stamp | 152 | @touch ./.config.stamp |
151 | 153 | ||
152 | xconfig: $(TOPDIR)/scripts/kconfig/qconf $(TOPDIR)/scripts/kconfig/libkconfig.so ./config.in | 154 | xconfig: $(TOPDIR)/scripts/kconfig/qconf $(TOPDIR)/scripts/kconfig/libkconfig.so ./config.in |
153 | $(TOPDIR)/scripts/kconfig/qconf ./config.in | 155 | $(TOPDIR)/scripts/kconfig/qconf ./config.in |
154 | @touch .config.stamp | 156 | @touch .config.stamp |
155 | 157 | ||
156 | gconfig: $(TOPDIR)/scripts/kconfig/gconf $(TOPDIR)/scripts/kconfig/libkconfig.so ./config.in | 158 | gconfig: $(TOPDIR)/scripts/kconfig/gconf $(TOPDIR)/scripts/kconfig/libkconfig.so ./config.in |
157 | $(TOPDIR)/scripts/kconfig/gconf ./config.in | 159 | $(TOPDIR)/scripts/kconfig/gconf ./config.in |
158 | @touch .config.stamp | 160 | @touch .config.stamp |
159 | 161 | ||
160 | config: $(TOPDIR)/scripts/kconfig/conf ./config.in | 162 | config: $(TOPDIR)/scripts/kconfig/conf ./config.in |
161 | $(TOPDIR)/scripts/kconfig/conf ./config.in | 163 | $(TOPDIR)/scripts/kconfig/conf ./config.in |
162 | @touch .config.stamp | 164 | @touch .config.stamp |
163 | 165 | ||
164 | oldconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in | 166 | oldconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in |
165 | $(TOPDIR)/scripts/kconfig/conf -o ./config.in | 167 | $(TOPDIR)/scripts/kconfig/conf -o ./config.in |
166 | @touch .config.stamp | 168 | @touch .config.stamp |
167 | 169 | ||
168 | randconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in | 170 | randconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in |
169 | $(TOPDIR)/scripts/kconfig/conf -r ./config.in | 171 | $(TOPDIR)/scripts/kconfig/conf -r ./config.in |
170 | @touch .config.stamp | 172 | @touch .config.stamp |
171 | 173 | ||
172 | allyesconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in | 174 | allyesconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in |
173 | $(TOPDIR)/scripts/kconfig/conf -y ./config.in | 175 | $(TOPDIR)/scripts/kconfig/conf -y ./config.in |
174 | @touch .config.stamp | 176 | @touch .config.stamp |
175 | 177 | ||
176 | allnoconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in | 178 | allnoconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in |
177 | $(TOPDIR)/scripts/kconfig/conf -n ./config.in | 179 | $(TOPDIR)/scripts/kconfig/conf -n ./config.in |
178 | @touch .config.stamp | 180 | @touch .config.stamp |
179 | 181 | ||
180 | defconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in | 182 | defconfig: $(TOPDIR)/scripts/kconfig/conf ./config.in |
181 | $(TOPDIR)/scripts/kconfig/conf -d ./config.in | 183 | $(TOPDIR)/scripts/kconfig/conf -d ./config.in |
182 | @touch .config.stamp | 184 | @touch .config.stamp |
183 | 185 | ||
184 | $(TOPDIR)/qmake/qmake : $(TOPDIR)/mkspecs/default | 186 | $(TOPDIR)/qmake/qmake : $(TOPDIR)/mkspecs/default |
185 | 187 | ||
186 | $(TOPDIR)/mkspecs/default : | 188 | $(TOPDIR)/mkspecs/default : |
187 | ln -sf linux-g++ $@ | 189 | ln -sf linux-g++ $@ |
188 | 190 | ||
189 | $(TOPDIR)/scripts/subst : force | 191 | $(TOPDIR)/scripts/subst : force |
190 | @( \ | 192 | @( \ |
191 | echo 's,\$$QPE_VERSION,$(QPE_VERSION),g'; \ | 193 | echo 's,\$$QPE_VERSION,$(QPE_VERSION),g'; \ |
192 | echo 's,\$$OPIE_VERSION,$(OPIE_VERSION),g'; \ | 194 | echo 's,\$$OPIE_VERSION,$(OPIE_VERSION),g'; \ |
193 | echo 's,\$$QTE_VERSION,$(QTE_VERSION),g'; \ | 195 | echo 's,\$$QTE_VERSION,$(QTE_VERSION),g'; \ |
194 | echo 's,\$$QTE_REVISION,$(QTE_REVISION),g'; \ | 196 | echo 's,\$$QTE_REVISION,$(QTE_REVISION),g'; \ |
195 | echo 's,\$$SUB_VERSION,$(SUB_VERSION),g'; \ | 197 | echo 's,\$$SUB_VERSION,$(SUB_VERSION),g'; \ |
196 | echo 's,\$$EXTRAVERSION,$(EXTRAVERSION),g'; \ | 198 | echo 's,\$$EXTRAVERSION,$(EXTRAVERSION),g'; \ |
197 | echo 's,\$$QTE_BASEVERSION,$(QTE_BASEVERSION),g'; \ | 199 | echo 's,\$$QTE_BASEVERSION,$(QTE_BASEVERSION),g'; \ |
198 | ) > $@ || ( rm -f $@; exit 1 ) | 200 | ) > $@ || ( rm -f $@; exit 1 ) |
199 | 201 | ||
200 | $(TOPDIR)/scripts/filesubst : force | 202 | $(TOPDIR)/scripts/filesubst : force |
201 | @( \ | 203 | @( \ |
202 | echo 's,\$$OPIEDIR/root/,/,g'; \ | 204 | echo 's,\$$OPIEDIR/root/,/,g'; \ |
203 | echo 's,$(OPIEDIR)/root/,/,g'; \ | 205 | echo 's,$(OPIEDIR)/root/,/,g'; \ |
204 | echo 's,\$$OPIEDIR,$(prefix),g'; \ | 206 | echo 's,\$$OPIEDIR,$(prefix),g'; \ |
205 | echo 's,$(OPIEDIR),$(prefix),g'; \ | 207 | echo 's,$(OPIEDIR),$(prefix),g'; \ |
206 | echo 's,\$$QTDIR,$(prefix),g'; \ | 208 | echo 's,\$$QTDIR,$(prefix),g'; \ |
207 | echo 's,$(QTDIR),$(prefix),g'; \ | 209 | echo 's,$(QTDIR),$(prefix),g'; \ |
208 | echo 's,^\(\./\)*root/,/,g'; \ | 210 | echo 's,^\(\./\)*root/,/,g'; \ |
209 | echo 's,^\(\./\)*etc/,$(prefix)/etc/,g'; \ | 211 | echo 's,^\(\./\)*etc/,$(prefix)/etc/,g'; \ |
210 | echo 's,^\(\./\)*lib/,$(prefix)/lib/,g'; \ | 212 | echo 's,^\(\./\)*lib/,$(prefix)/lib/,g'; \ |
211 | echo 's,^\(\./\)*bin/,$(prefix)/bin/,g'; \ | 213 | echo 's,^\(\./\)*bin/,$(prefix)/bin/,g'; \ |
212 | echo 's,^\(\./\)*pics/,$(prefix)/pics/,g'; \ | 214 | echo 's,^\(\./\)*pics/,$(prefix)/pics/,g'; \ |
213 | echo 's,^\(\./\)*sounds/,$(prefix)/sounds/,g'; \ | 215 | echo 's,^\(\./\)*sounds/,$(prefix)/sounds/,g'; \ |
214 | echo 's,^\(\./\)*i18n/,$(prefix)/i18n/,g'; \ | 216 | echo 's,^\(\./\)*i18n/,$(prefix)/i18n/,g'; \ |
215 | echo 's,^\(\./\)*plugins/,$(prefix)/plugins/,g'; \ | 217 | echo 's,^\(\./\)*plugins/,$(prefix)/plugins/,g'; \ |
216 | echo 's,^\(\./\)*apps/,$(prefix)/apps/,g'; \ | 218 | echo 's,^\(\./\)*apps/,$(prefix)/apps/,g'; \ |
217 | echo 's,^\(\./\)*share/,$(prefix)/share/,g'; \ | 219 | echo 's,^\(\./\)*share/,$(prefix)/share/,g'; \ |
218 | echo 's,^\(\./\)*i18n/,$(prefix)/i18n/,g'; \ | 220 | echo 's,^\(\./\)*i18n/,$(prefix)/i18n/,g'; \ |
219 | echo 's,^\(\./\)*help/,$(prefix)/help/,g'; \ | 221 | echo 's,^\(\./\)*help/,$(prefix)/help/,g'; \ |
220 | ) > $@ || ( rm -f $@; exit 1 ) | 222 | ) > $@ || ( rm -f $@; exit 1 ) |
221 | 223 | ||
222 | ## general rules ## | 224 | ## general rules ## |
223 | 225 | ||
224 | define descend | 226 | define descend |
225 | $(MAKE) $(if $(QMAKE),QMAKE=$(QMAKE)) -C $(1) $(2) | 227 | $(MAKE) $(if $(QMAKE),QMAKE=$(QMAKE)) -C $(1) $(2) |
226 | endef | 228 | endef |
227 | 229 | ||
228 | define makefilegen | 230 | define makefilegen |
229 | cd $(if $(1),$(shell dirname $(1))); $(TOPDIR)/qmake/qmake $(3) -o $(if $(1),$(shell basename $(1))) `cat $(OPIEDIR)/packages | grep " \`echo $(1)|sed -e 's,/Makefile$$,,'\`" | \ | 231 | cd $(if $(1),$(shell dirname $(1))); $(TOPDIR)/qmake/qmake $(3) -o $(if $(1),$(shell basename $(1))) `cat $(OPIEDIR)/packages | grep " \`echo $(1)|sed -e 's,/Makefile$$,,'\`" | \ |
230 | head -1 | awk '{print $$3}'` | 232 | head -1 | awk '{print $$3}'` |
231 | endef | 233 | endef |
232 | 234 | ||
233 | define makecfg | 235 | define makecfg |
234 | $(TOPDIR)/scripts/makecfg.pl $1 $(OPIEDIR) | 236 | $(TOPDIR)/scripts/makecfg.pl $1 $(OPIEDIR) |
235 | endef | 237 | endef |
diff --git a/libopie2/opiepim/core/oconversion.cpp b/libopie2/opiepim/core/oconversion.cpp index b7eebef..160c2c6 100644 --- a/libopie2/opiepim/core/oconversion.cpp +++ b/libopie2/opiepim/core/oconversion.cpp | |||
@@ -1,132 +1,143 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | .=l. |
5 | .=l. | 5 | .>+-= |
6 | .>+-= | 6 | _;:, .> :=|. This program is free software; you can |
7 | _;:, .> :=|. This program is free software; you can | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | ._= =} : or (at your option) any later version. |
12 | ._= =} : or (at your option) any later version. | 12 | .%`+i> _;_. |
13 | .%`+i> _;_. | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | : .. .:, . . . without even the implied warranty of |
16 | : .. .:, . . . without even the implied warranty of | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | ..}^=.= = ; Library General Public License for more |
19 | ..}^=.= = ; Library General Public License for more | 19 | ++= -. .` .: details. |
20 | ++= -. .` .: details. | 20 | : = ...= . :.=- |
21 | : = ...= . :.=- | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -_. . . )=. = Library General Public License along with |
23 | -_. . . )=. = Library General Public License along with | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | If not, write to the Free Software Foundation, |
25 | If not, write to the Free Software Foundation, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Boston, MA 02111-1307, USA. |
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | 27 | */ |
29 | 28 | ||
29 | /* OPIE */ | ||
30 | #include <opie2/oconversion.h> | 30 | #include <opie2/oconversion.h> |
31 | #include <qpe/timeconversion.h> | 31 | #include <qpe/timeconversion.h> |
32 | 32 | ||
33 | 33 | namespace Opie | |
34 | namespace Opie { | 34 | { |
35 | 35 | ||
36 | QString OConversion::dateToString( const QDate &d ) | 36 | QString OConversion::dateToString( const QDate &d ) |
37 | { | 37 | { |
38 | if ( d.isNull() || !d.isValid() ) | 38 | if ( d.isNull() || !d.isValid() ) |
39 | return QString::null; | 39 | return QString::null; |
40 | 40 | ||
41 | // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 | 41 | // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 |
42 | QString year = QString::number( d.year() ); | 42 | QString year = QString::number( d.year() ); |
43 | QString month = QString::number( d.month() ); | 43 | QString month = QString::number( d.month() ); |
44 | month = month.rightJustify( 2, '0' ); | 44 | month = month.rightJustify( 2, '0' ); |
45 | QString day = QString::number( d.day() ); | 45 | QString day = QString::number( d.day() ); |
46 | day = day.rightJustify( 2, '0' ); | 46 | day = day.rightJustify( 2, '0' ); |
47 | 47 | ||
48 | QString str = year + month + day; | 48 | QString str = year + month + day; |
49 | //qDebug( "\tPimContact dateToStr = %s", str.latin1() ); | 49 | //qDebug( "\tPimContact dateToStr = %s", str.latin1() ); |
50 | 50 | ||
51 | return str; | 51 | return str; |
52 | } | 52 | } |
53 | 53 | ||
54 | |||
54 | QDate OConversion::dateFromString( const QString& s ) | 55 | QDate OConversion::dateFromString( const QString& s ) |
55 | { | 56 | { |
56 | QDate date; | 57 | QDate date; |
57 | 58 | ||
58 | if ( s.isEmpty() ) | 59 | if ( s.isEmpty() ) |
59 | return date; | 60 | return date; |
60 | 61 | ||
61 | // Be backward compatible to old Opie format: | 62 | // Be backward compatible to old Opie format: |
62 | // Try to load old format. If it fails, try new ISO-Format! | 63 | // Try to load old format. If it fails, try new ISO-Format! |
63 | date = TimeConversion::fromString ( s ); | 64 | date = TimeConversion::fromString ( s ); |
64 | if ( date.isValid() ) | 65 | if ( date.isValid() ) |
65 | return date; | 66 | return date; |
66 | 67 | ||
67 | // Read ISO-Format (YYYYMMDD) | 68 | // Read ISO-Format (YYYYMMDD) |
68 | int year = s.mid(0, 4).toInt(); | 69 | int year = s.mid( 0, 4 ).toInt(); |
69 | int month = s.mid(4,2).toInt(); | 70 | int month = s.mid( 4, 2 ).toInt(); |
70 | int day = s.mid(6,2).toInt(); | 71 | int day = s.mid( 6, 2 ).toInt(); |
71 | 72 | ||
72 | // do some quick sanity checking -eilers | 73 | // do some quick sanity checking -eilers |
73 | // but we isValid() again? -zecke | 74 | // but we isValid() again? -zecke |
74 | if ( year < 1900 || year > 3000 ) { | 75 | if ( year < 1900 || year > 3000 ) |
75 | qWarning( "PimContact year is not in range"); | 76 | { |
76 | return date; | 77 | qWarning( "PimContact year is not in range" ); |
77 | } | 78 | return date; |
78 | if ( month < 0 || month > 12 ) { | 79 | } |
79 | qWarning( "PimContact month is not in range"); | 80 | if ( month < 0 || month > 12 ) |
80 | return date; | 81 | { |
81 | } | 82 | qWarning( "PimContact month is not in range" ); |
82 | if ( day < 0 || day > 31 ) { | 83 | return date; |
83 | qWarning( "PimContact day is not in range"); | 84 | } |
84 | return date; | 85 | if ( day < 0 || day > 31 ) |
85 | } | 86 | { |
86 | 87 | qWarning( "PimContact day is not in range" ); | |
87 | date.setYMD( year, month, day ); | 88 | return date; |
88 | if ( !date.isValid() ) { | 89 | } |
89 | qWarning( "PimContact date is not valid"); | 90 | |
90 | return date; | 91 | date.setYMD( year, month, day ); |
91 | } | 92 | if ( !date.isValid() ) |
92 | 93 | { | |
93 | return date; | 94 | qWarning( "PimContact date is not valid" ); |
95 | return date; | ||
96 | } | ||
97 | |||
98 | return date; | ||
94 | } | 99 | } |
95 | QString OConversion::dateTimeToString( const QDateTime& dt ) { | ||
96 | if (!dt.isValid() || dt.isNull() ) return QString::null; | ||
97 | 100 | ||
98 | QString year = QString::number( dt.date().year() ); | ||
99 | QString month = QString::number( dt.date().month() ); | ||
100 | QString day = QString::number( dt.date().day() ); | ||
101 | 101 | ||
102 | QString hour = QString::number( dt.time().hour() ); | 102 | QString OConversion::dateTimeToString( const QDateTime& dt ) |
103 | QString min = QString::number( dt.time().minute() ); | 103 | { |
104 | QString sec = QString::number( dt.time().second() ); | 104 | if ( !dt.isValid() || dt.isNull() ) |
105 | return QString::null; | ||
105 | 106 | ||
106 | month = month.rightJustify( 2, '0' ); | 107 | QString year = QString::number( dt.date().year() ); |
107 | day = day. rightJustify( 2, '0' ); | 108 | QString month = QString::number( dt.date().month() ); |
108 | hour = hour. rightJustify( 2, '0' ); | 109 | QString day = QString::number( dt.date().day() ); |
109 | min = min. rightJustify( 2, '0' ); | ||
110 | sec = sec. rightJustify( 2, '0' ); | ||
111 | 110 | ||
112 | QString str = day + month + year + hour + min + sec; | 111 | QString hour = QString::number( dt.time().hour() ); |
112 | QString min = QString::number( dt.time().minute() ); | ||
113 | QString sec = QString::number( dt.time().second() ); | ||
113 | 114 | ||
114 | return str; | 115 | month = month.rightJustify( 2, '0' ); |
116 | day = day. rightJustify( 2, '0' ); | ||
117 | hour = hour. rightJustify( 2, '0' ); | ||
118 | min = min. rightJustify( 2, '0' ); | ||
119 | sec = sec. rightJustify( 2, '0' ); | ||
120 | |||
121 | return day + month + year + hour + min + sec; | ||
115 | } | 122 | } |
116 | QDateTime OConversion::dateTimeFromString( const QString& str) { | ||
117 | 123 | ||
118 | if ( str.isEmpty() ) return QDateTime(); | 124 | |
119 | int day = str.mid(0, 2).toInt(); | 125 | QDateTime OConversion::dateTimeFromString( const QString& str ) |
120 | int month = str.mid(2, 2).toInt(); | 126 | { |
121 | int year = str.mid(4, 4).toInt(); | 127 | |
122 | int hour = str.mid(8, 2).toInt(); | 128 | if ( str.isEmpty() ) |
123 | int min = str.mid(10, 2).toInt(); | 129 | return QDateTime(); |
124 | int sec = str.mid(12, 2).toInt(); | 130 | int day = str.mid( 0, 2 ).toInt(); |
131 | int month = str.mid( 2, 2 ).toInt(); | ||
132 | int year = str.mid( 4, 4 ).toInt(); | ||
133 | int hour = str.mid( 8, 2 ).toInt(); | ||
134 | int min = str.mid( 10, 2 ).toInt(); | ||
135 | int sec = str.mid( 12, 2 ).toInt(); | ||
125 | 136 | ||
126 | QDate date( year, month, day ); | 137 | QDate date( year, month, day ); |
127 | QTime time( hour, min, sec ); | 138 | QTime time( hour, min, sec ); |
128 | QDateTime dt( date, time ); | 139 | QDateTime dt( date, time ); |
129 | return dt; | 140 | return dt; |
130 | } | 141 | } |
131 | 142 | ||
132 | } \ No newline at end of file | 143 | } |
diff --git a/libopie2/opiepim/core/oconversion.h b/libopie2/opiepim/core/oconversion.h index 3c4fdf3..eeb97e5 100644 --- a/libopie2/opiepim/core/oconversion.h +++ b/libopie2/opiepim/core/oconversion.h | |||
@@ -1,62 +1,61 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef __oconversion_h__ | 30 | #ifndef OCONVERSION_H |
31 | #define __oconversion_h__ | 31 | #define OCONVERSION_H |
32 | 32 | ||
33 | /* #include <time.h> */ | 33 | /* QT */ |
34 | /* #include <sys/types.h> */ | ||
35 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
36 | 35 | ||
37 | namespace Opie { | 36 | namespace Opie { |
38 | 37 | ||
39 | class OConversion | 38 | class OConversion |
40 | { | 39 | { |
41 | public: | 40 | public: |
42 | static QString dateToString( const QDate &d ); | 41 | static QString dateToString( const QDate &d ); |
43 | static QDate dateFromString( const QString &datestr ); | 42 | static QDate dateFromString( const QString &datestr ); |
44 | 43 | ||
45 | /** | 44 | /** |
46 | * simple function to store DateTime as string and read from string | 45 | * simple function to store DateTime as string and read from string |
47 | * no timezone changing is done | 46 | * no timezone changing is done |
48 | * DDMMYYYYHHMMSS is the simple format | 47 | * DDMMYYYYHHMMSS is the simple format |
49 | */ | 48 | */ |
50 | static QString dateTimeToString( const QDateTime& ); | 49 | static QString dateTimeToString( const QDateTime& ); |
51 | static QDateTime dateTimeFromString( const QString& ); | 50 | static QDateTime dateTimeFromString( const QString& ); |
52 | 51 | ||
53 | private: | 52 | private: |
54 | class Private; | 53 | class Private; |
55 | Private* d; | 54 | Private* d; |
56 | 55 | ||
57 | }; | 56 | }; |
58 | 57 | ||
59 | } | 58 | } |
60 | 59 | ||
61 | #endif // __oconversion_h__ | 60 | #endif // __oconversion_h__ |
62 | 61 | ||
diff --git a/libopie2/opiepim/core/opimcache.h b/libopie2/opiepim/core/opimcache.h index e70a910..a033574 100644 --- a/libopie2/opiepim/core/opimcache.h +++ b/libopie2/opiepim/core/opimcache.h | |||
@@ -1,162 +1,164 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_CACHE_H | 29 | #ifndef OPIMCACHE_H |
30 | #define OPIE_PIM_CACHE_H | 30 | #define OPIMCACHE_H |
31 | |||
32 | #include <qintcache.h> | ||
33 | 31 | ||
32 | /* OPIE */ | ||
34 | #include <opie2/opimrecord.h> | 33 | #include <opie2/opimrecord.h> |
35 | 34 | ||
35 | /* QT */ | ||
36 | #include <qintcache.h> | ||
37 | |||
36 | namespace Opie { | 38 | namespace Opie { |
37 | class OPimCacheItemPrivate; | 39 | class OPimCacheItemPrivate; |
38 | 40 | ||
39 | template <class T = OPimRecord> | 41 | template <class T = OPimRecord> |
40 | class OPimCacheItem { | 42 | class OPimCacheItem { |
41 | public: | 43 | public: |
42 | OPimCacheItem( const T& t = T() ); | 44 | OPimCacheItem( const T& t = T() ); |
43 | OPimCacheItem( const OPimCacheItem& ); | 45 | OPimCacheItem( const OPimCacheItem& ); |
44 | ~OPimCacheItem(); | 46 | ~OPimCacheItem(); |
45 | 47 | ||
46 | OPimCacheItem &operator=( const OPimCacheItem& ); | 48 | OPimCacheItem &operator=( const OPimCacheItem& ); |
47 | 49 | ||
48 | T record()const; | 50 | T record()const; |
49 | void setRecord( const T& ); | 51 | void setRecord( const T& ); |
50 | private: | 52 | private: |
51 | T m_t; | 53 | T m_t; |
52 | OPimCacheItemPrivate *d; | 54 | OPimCacheItemPrivate *d; |
53 | }; | 55 | }; |
54 | 56 | ||
55 | 57 | ||
56 | class OPimCachePrivate; | 58 | class OPimCachePrivate; |
57 | /** | 59 | /** |
58 | * OPimCache for caching the items | 60 | * OPimCache for caching the items |
59 | * We support adding, removing | 61 | * We support adding, removing |
60 | * and finding | 62 | * and finding |
61 | */ | 63 | */ |
62 | template <class T = OPimRecord> | 64 | template <class T = OPimRecord> |
63 | class OPimCache { | 65 | class OPimCache { |
64 | public: | 66 | public: |
65 | typedef OPimCacheItem<T> Item; | 67 | typedef OPimCacheItem<T> Item; |
66 | OPimCache(); | 68 | OPimCache(); |
67 | OPimCache( const OPimCache& ); | 69 | OPimCache( const OPimCache& ); |
68 | ~OPimCache(); | 70 | ~OPimCache(); |
69 | 71 | ||
70 | OPimCache &operator=( const OPimCache& ); | 72 | OPimCache &operator=( const OPimCache& ); |
71 | 73 | ||
72 | bool contains(int uid)const; | 74 | bool contains(int uid)const; |
73 | void invalidate(); | 75 | void invalidate(); |
74 | void setSize( int size ); | 76 | void setSize( int size ); |
75 | 77 | ||
76 | T find(int uid )const; | 78 | T find(int uid )const; |
77 | void add( const T& ); | 79 | void add( const T& ); |
78 | void remove( int uid ); | 80 | void remove( int uid ); |
79 | void replace( const T& ); | 81 | void replace( const T& ); |
80 | 82 | ||
81 | private: | 83 | private: |
82 | QIntCache<Item> m_cache; | 84 | QIntCache<Item> m_cache; |
83 | OPimCachePrivate* d; | 85 | OPimCachePrivate* d; |
84 | }; | 86 | }; |
85 | 87 | ||
86 | // Implementation | 88 | // Implementation |
87 | template <class T> | 89 | template <class T> |
88 | OPimCacheItem<T>::OPimCacheItem( const T& t ) | 90 | OPimCacheItem<T>::OPimCacheItem( const T& t ) |
89 | : m_t(t) { | 91 | : m_t(t) { |
90 | } | 92 | } |
91 | template <class T> | 93 | template <class T> |
92 | OPimCacheItem<T>::~OPimCacheItem() { | 94 | OPimCacheItem<T>::~OPimCacheItem() { |
93 | 95 | ||
94 | } | 96 | } |
95 | template <class T> | 97 | template <class T> |
96 | T OPimCacheItem<T>::record()const { | 98 | T OPimCacheItem<T>::record()const { |
97 | return m_t; | 99 | return m_t; |
98 | } | 100 | } |
99 | template <class T> | 101 | template <class T> |
100 | void OPimCacheItem<T>::setRecord( const T& t ) { | 102 | void OPimCacheItem<T>::setRecord( const T& t ) { |
101 | m_t = t; | 103 | m_t = t; |
102 | } | 104 | } |
103 | // Cache | 105 | // Cache |
104 | template <class T> | 106 | template <class T> |
105 | OPimCache<T>::OPimCache() | 107 | OPimCache<T>::OPimCache() |
106 | : m_cache(100, 53 ) | 108 | : m_cache(100, 53 ) |
107 | { | 109 | { |
108 | m_cache.setAutoDelete( TRUE ); | 110 | m_cache.setAutoDelete( TRUE ); |
109 | } | 111 | } |
110 | template <class T> | 112 | template <class T> |
111 | OPimCache<T>::~OPimCache() { | 113 | OPimCache<T>::~OPimCache() { |
112 | 114 | ||
113 | } | 115 | } |
114 | template <class T> | 116 | template <class T> |
115 | bool OPimCache<T>::contains(int uid )const { | 117 | bool OPimCache<T>::contains(int uid )const { |
116 | Item* it = m_cache.find( uid, FALSE ); | 118 | Item* it = m_cache.find( uid, FALSE ); |
117 | if (!it) | 119 | if (!it) |
118 | return false; | 120 | return false; |
119 | return true; | 121 | return true; |
120 | } | 122 | } |
121 | template <class T> | 123 | template <class T> |
122 | void OPimCache<T>::invalidate() { | 124 | void OPimCache<T>::invalidate() { |
123 | m_cache.clear(); | 125 | m_cache.clear(); |
124 | } | 126 | } |
125 | template <class T> | 127 | template <class T> |
126 | void OPimCache<T>::setSize( int size ) { | 128 | void OPimCache<T>::setSize( int size ) { |
127 | m_cache.setMaxCost( size ); | 129 | m_cache.setMaxCost( size ); |
128 | } | 130 | } |
129 | template <class T> | 131 | template <class T> |
130 | T OPimCache<T>::find(int uid )const { | 132 | T OPimCache<T>::find(int uid )const { |
131 | Item *it = m_cache.find( uid ); | 133 | Item *it = m_cache.find( uid ); |
132 | if (it) | 134 | if (it) |
133 | return it->record(); | 135 | return it->record(); |
134 | return T(); | 136 | return T(); |
135 | } | 137 | } |
136 | template <class T> | 138 | template <class T> |
137 | void OPimCache<T>::add( const T& t ) { | 139 | void OPimCache<T>::add( const T& t ) { |
138 | Item* it = 0l; | 140 | Item* it = 0l; |
139 | it = m_cache.find(t.uid(), FALSE ); | 141 | it = m_cache.find(t.uid(), FALSE ); |
140 | 142 | ||
141 | if (it ) | 143 | if (it ) |
142 | it->setRecord( t ); | 144 | it->setRecord( t ); |
143 | 145 | ||
144 | it = new Item( t ); | 146 | it = new Item( t ); |
145 | if (!m_cache.insert( t.uid(), it ) ) | 147 | if (!m_cache.insert( t.uid(), it ) ) |
146 | delete it; | 148 | delete it; |
147 | } | 149 | } |
148 | template <class T> | 150 | template <class T> |
149 | void OPimCache<T>::remove( int uid ) { | 151 | void OPimCache<T>::remove( int uid ) { |
150 | m_cache.remove( uid ); | 152 | m_cache.remove( uid ); |
151 | } | 153 | } |
152 | template <class T> | 154 | template <class T> |
153 | void OPimCache<T>::replace( const T& t) { | 155 | void OPimCache<T>::replace( const T& t) { |
154 | Item *it = m_cache.find( t.uid() ); | 156 | Item *it = m_cache.find( t.uid() ); |
155 | if ( it ) { | 157 | if ( it ) { |
156 | it->setRecord( t ); | 158 | it->setRecord( t ); |
157 | } | 159 | } |
158 | } | 160 | } |
159 | 161 | ||
160 | } | 162 | } |
161 | 163 | ||
162 | #endif | 164 | #endif |
diff --git a/libopie2/opiepim/core/opimmaintainer.cpp b/libopie2/opiepim/core/opimmaintainer.cpp index b2eff12..b8d829a 100644 --- a/libopie2/opiepim/core/opimmaintainer.cpp +++ b/libopie2/opiepim/core/opimmaintainer.cpp | |||
@@ -1,69 +1,69 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <opie2/opimmaintainer.h> | 30 | #include "opimmaintainer.h" |
31 | 31 | ||
32 | namespace Opie { | 32 | namespace Opie { |
33 | OPimMaintainer::OPimMaintainer( int mode, int uid ) | 33 | OPimMaintainer::OPimMaintainer( int mode, int uid ) |
34 | : m_mode(mode), m_uid(uid ) | 34 | : m_mode(mode), m_uid(uid ) |
35 | {} | 35 | {} |
36 | OPimMaintainer::~OPimMaintainer() { | 36 | OPimMaintainer::~OPimMaintainer() { |
37 | } | 37 | } |
38 | OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) { | 38 | OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) { |
39 | *this = main; | 39 | *this = main; |
40 | } | 40 | } |
41 | OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) { | 41 | OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) { |
42 | m_mode = main.m_mode; | 42 | m_mode = main.m_mode; |
43 | m_uid = main.m_uid; | 43 | m_uid = main.m_uid; |
44 | 44 | ||
45 | return *this; | 45 | return *this; |
46 | } | 46 | } |
47 | bool OPimMaintainer::operator==( const OPimMaintainer& main ) { | 47 | bool OPimMaintainer::operator==( const OPimMaintainer& main ) { |
48 | if (m_mode != main.m_mode ) return false; | 48 | if (m_mode != main.m_mode ) return false; |
49 | if (m_uid != main.m_uid ) return false; | 49 | if (m_uid != main.m_uid ) return false; |
50 | 50 | ||
51 | return true; | 51 | return true; |
52 | } | 52 | } |
53 | bool OPimMaintainer::operator!=( const OPimMaintainer& main ) { | 53 | bool OPimMaintainer::operator!=( const OPimMaintainer& main ) { |
54 | return !(*this == main ); | 54 | return !(*this == main ); |
55 | } | 55 | } |
56 | int OPimMaintainer::mode()const { | 56 | int OPimMaintainer::mode()const { |
57 | return m_mode; | 57 | return m_mode; |
58 | } | 58 | } |
59 | int OPimMaintainer::uid()const { | 59 | int OPimMaintainer::uid()const { |
60 | return m_uid; | 60 | return m_uid; |
61 | } | 61 | } |
62 | void OPimMaintainer::setMode( int mo) { | 62 | void OPimMaintainer::setMode( int mo) { |
63 | m_mode = mo; | 63 | m_mode = mo; |
64 | } | 64 | } |
65 | void OPimMaintainer::setUid( int uid ) { | 65 | void OPimMaintainer::setUid( int uid ) { |
66 | m_uid = uid; | 66 | m_uid = uid; |
67 | } | 67 | } |
68 | 68 | ||
69 | } | 69 | } |
diff --git a/libopie2/opiepim/core/opimmaintainer.h b/libopie2/opiepim/core/opimmaintainer.h index 46bc9d2..e7e7eeb 100644 --- a/libopie2/opiepim/core/opimmaintainer.h +++ b/libopie2/opiepim/core/opimmaintainer.h | |||
@@ -1,71 +1,72 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_MAINTAINER_H | 29 | #ifndef OPIMMAINTAINER_H |
30 | #define OPIE_PIM_MAINTAINER_H | 30 | #define OPIMMAINTAINER_H |
31 | 31 | ||
32 | /* QT */ | ||
32 | #include <qstring.h> | 33 | #include <qstring.h> |
33 | 34 | ||
34 | namespace Opie { | 35 | namespace Opie { |
35 | /** | 36 | /** |
36 | * Who maintains what? | 37 | * Who maintains what? |
37 | */ | 38 | */ |
38 | class OPimMaintainer { | 39 | class OPimMaintainer { |
39 | public: | 40 | public: |
40 | enum Mode { Undefined = -1, | 41 | enum Mode { Undefined = -1, |
41 | Nothing = 0, | 42 | Nothing = 0, |
42 | Responsible, | 43 | Responsible, |
43 | DoneBy, | 44 | DoneBy, |
44 | Coordinating, | 45 | Coordinating, |
45 | }; | 46 | }; |
46 | OPimMaintainer( int mode = Undefined, int uid = 0); | 47 | OPimMaintainer( int mode = Undefined, int uid = 0); |
47 | OPimMaintainer( const OPimMaintainer& ); | 48 | OPimMaintainer( const OPimMaintainer& ); |
48 | ~OPimMaintainer(); | 49 | ~OPimMaintainer(); |
49 | 50 | ||
50 | OPimMaintainer &operator=( const OPimMaintainer& ); | 51 | OPimMaintainer &operator=( const OPimMaintainer& ); |
51 | bool operator==( const OPimMaintainer& ); | 52 | bool operator==( const OPimMaintainer& ); |
52 | bool operator!=( const OPimMaintainer& ); | 53 | bool operator!=( const OPimMaintainer& ); |
53 | 54 | ||
54 | 55 | ||
55 | int mode()const; | 56 | int mode()const; |
56 | int uid()const; | 57 | int uid()const; |
57 | 58 | ||
58 | void setMode( int mode ); | 59 | void setMode( int mode ); |
59 | void setUid( int uid ); | 60 | void setUid( int uid ); |
60 | 61 | ||
61 | private: | 62 | private: |
62 | int m_mode; | 63 | int m_mode; |
63 | int m_uid; | 64 | int m_uid; |
64 | class Private; | 65 | class Private; |
65 | Private *d; | 66 | Private *d; |
66 | 67 | ||
67 | }; | 68 | }; |
68 | 69 | ||
69 | } | 70 | } |
70 | 71 | ||
71 | #endif | 72 | #endif |
diff --git a/libopie2/opiepim/core/opimresolver.cpp b/libopie2/opiepim/core/opimresolver.cpp index eceabcb..73d7de1 100644 --- a/libopie2/opiepim/core/opimresolver.cpp +++ b/libopie2/opiepim/core/opimresolver.cpp | |||
@@ -1,230 +1,231 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qcopchannel_qws.h> | ||
30 | 29 | ||
31 | #include <qpe/qcopenvelope_qws.h> | 30 | #include "opimresolver.h" |
32 | 31 | ||
33 | #include <opie2/otodoaccess.h> | 32 | /* OPIE */ |
34 | #include <opie2/ocontactaccess.h> | 33 | #include <opie2/ocontactaccess.h> |
34 | #include <opie2/otodoaccess.h> | ||
35 | #include <qpe/qcopenvelope_qws.h> | ||
35 | 36 | ||
36 | //#include "opimfactory.h" | 37 | /* QT */ |
37 | #include <opie2/opimresolver.h> | 38 | #include <qcopchannel_qws.h> |
38 | 39 | ||
39 | namespace Opie { | 40 | namespace Opie { |
40 | 41 | ||
41 | OPimResolver* OPimResolver::m_self = 0l; | 42 | OPimResolver* OPimResolver::m_self = 0l; |
42 | 43 | ||
43 | OPimResolver::OPimResolver() { | 44 | OPimResolver::OPimResolver() { |
44 | /* the built in channels */ | 45 | /* the built in channels */ |
45 | m_builtIns << "Todolist" << "Addressbook" << "Datebook"; | 46 | m_builtIns << "Todolist" << "Addressbook" << "Datebook"; |
46 | } | 47 | } |
47 | OPimResolver* OPimResolver::self() { | 48 | OPimResolver* OPimResolver::self() { |
48 | if (!m_self) | 49 | if (!m_self) |
49 | m_self = new OPimResolver(); | 50 | m_self = new OPimResolver(); |
50 | 51 | ||
51 | return m_self; | 52 | return m_self; |
52 | } | 53 | } |
53 | 54 | ||
54 | /* | 55 | /* |
55 | * FIXME use a cache here too | 56 | * FIXME use a cache here too |
56 | */ | 57 | */ |
57 | OPimRecord* OPimResolver::record( const QString& service, int uid ) { | 58 | OPimRecord* OPimResolver::record( const QString& service, int uid ) { |
58 | OPimRecord* rec = 0l; | 59 | OPimRecord* rec = 0l; |
59 | OPimBase* base = backend( service ); | 60 | OPimBase* base = backend( service ); |
60 | 61 | ||
61 | if ( base ) | 62 | if ( base ) |
62 | rec = base->record( uid ); | 63 | rec = base->record( uid ); |
63 | delete base; | 64 | delete base; |
64 | 65 | ||
65 | return rec; | 66 | return rec; |
66 | } | 67 | } |
67 | OPimRecord* OPimResolver::record( const QString& service ) { | 68 | OPimRecord* OPimResolver::record( const QString& service ) { |
68 | return record( serviceId( service ) ); | 69 | return record( serviceId( service ) ); |
69 | } | 70 | } |
70 | OPimRecord* OPimResolver::record( int rtti ) { | 71 | OPimRecord* OPimResolver::record( int rtti ) { |
71 | OPimRecord* rec = 0l; | 72 | OPimRecord* rec = 0l; |
72 | switch( rtti ) { | 73 | switch( rtti ) { |
73 | case 1: /* todolist */ | 74 | case 1: /* todolist */ |
74 | rec = new OTodo(); | 75 | rec = new OTodo(); |
75 | case 2: /* contact */ | 76 | case 2: /* contact */ |
76 | rec = new OContact(); | 77 | rec = new OContact(); |
77 | default: | 78 | default: |
78 | break; | 79 | break; |
79 | } | 80 | } |
80 | /* | 81 | /* |
81 | * FIXME resolve externally | 82 | * FIXME resolve externally |
82 | */ | 83 | */ |
83 | if (!rec ) { | 84 | if (!rec ) { |
84 | ; | 85 | ; |
85 | } | 86 | } |
86 | return 0l; | 87 | return 0l; |
87 | } | 88 | } |
88 | bool OPimResolver::isBuiltIn( const QString& str) const{ | 89 | bool OPimResolver::isBuiltIn( const QString& str) const{ |
89 | return m_builtIns.contains( str ); | 90 | return m_builtIns.contains( str ); |
90 | } | 91 | } |
91 | QCString OPimResolver::qcopChannel( enum BuiltIn& built)const { | 92 | QCString OPimResolver::qcopChannel( enum BuiltIn& built)const { |
92 | QCString str("QPE/"); | 93 | QCString str("QPE/"); |
93 | switch( built ) { | 94 | switch( built ) { |
94 | case TodoList: | 95 | case TodoList: |
95 | str += "Todolist"; | 96 | str += "Todolist"; |
96 | break; | 97 | break; |
97 | case DateBook: | 98 | case DateBook: |
98 | str += "Datebook"; | 99 | str += "Datebook"; |
99 | break; | 100 | break; |
100 | case AddressBook: | 101 | case AddressBook: |
101 | str += "Addressbook"; | 102 | str += "Addressbook"; |
102 | break; | 103 | break; |
103 | default: | 104 | default: |
104 | break; | 105 | break; |
105 | } | 106 | } |
106 | 107 | ||
107 | return str; | 108 | return str; |
108 | } | 109 | } |
109 | QCString OPimResolver::qcopChannel( const QString& service )const { | 110 | QCString OPimResolver::qcopChannel( const QString& service )const { |
110 | QCString str("QPE/"); | 111 | QCString str("QPE/"); |
111 | str += service.latin1(); | 112 | str += service.latin1(); |
112 | return str; | 113 | return str; |
113 | } | 114 | } |
114 | /* | 115 | /* |
115 | * Implement services!! | 116 | * Implement services!! |
116 | * FIXME | 117 | * FIXME |
117 | */ | 118 | */ |
118 | QCString OPimResolver::applicationChannel( enum BuiltIn& built)const { | 119 | QCString OPimResolver::applicationChannel( enum BuiltIn& built)const { |
119 | QCString str("QPE/Application/"); | 120 | QCString str("QPE/Application/"); |
120 | switch( built ) { | 121 | switch( built ) { |
121 | case TodoList: | 122 | case TodoList: |
122 | str += "todolist"; | 123 | str += "todolist"; |
123 | break; | 124 | break; |
124 | case DateBook: | 125 | case DateBook: |
125 | str += "datebook"; | 126 | str += "datebook"; |
126 | break; | 127 | break; |
127 | case AddressBook: | 128 | case AddressBook: |
128 | str += "addressbook"; | 129 | str += "addressbook"; |
129 | break; | 130 | break; |
130 | } | 131 | } |
131 | 132 | ||
132 | return str; | 133 | return str; |
133 | } | 134 | } |
134 | QCString OPimResolver::applicationChannel( const QString& service )const { | 135 | QCString OPimResolver::applicationChannel( const QString& service )const { |
135 | QCString str("QPE/Application/"); | 136 | QCString str("QPE/Application/"); |
136 | 137 | ||
137 | if ( isBuiltIn( service ) ) { | 138 | if ( isBuiltIn( service ) ) { |
138 | if ( service == "Todolist" ) | 139 | if ( service == "Todolist" ) |
139 | str += "todolist"; | 140 | str += "todolist"; |
140 | else if ( service == "Datebook" ) | 141 | else if ( service == "Datebook" ) |
141 | str += "datebook"; | 142 | str += "datebook"; |
142 | else if ( service == "Addressbook" ) | 143 | else if ( service == "Addressbook" ) |
143 | str += "addressbook"; | 144 | str += "addressbook"; |
144 | }else | 145 | }else |
145 | ; // FIXME for additional stuff | 146 | ; // FIXME for additional stuff |
146 | 147 | ||
147 | return str; | 148 | return str; |
148 | } | 149 | } |
149 | QStringList OPimResolver::services()const { | 150 | QStringList OPimResolver::services()const { |
150 | return m_builtIns; | 151 | return m_builtIns; |
151 | } | 152 | } |
152 | QString OPimResolver::serviceName( int rtti ) const{ | 153 | QString OPimResolver::serviceName( int rtti ) const{ |
153 | QString str; | 154 | QString str; |
154 | switch ( rtti ) { | 155 | switch ( rtti ) { |
155 | case TodoList: | 156 | case TodoList: |
156 | str = "Todolist"; | 157 | str = "Todolist"; |
157 | break; | 158 | break; |
158 | case DateBook: | 159 | case DateBook: |
159 | str = "Datebook"; | 160 | str = "Datebook"; |
160 | break; | 161 | break; |
161 | case AddressBook: | 162 | case AddressBook: |
162 | str = "Addressbook"; | 163 | str = "Addressbook"; |
163 | break; | 164 | break; |
164 | default: | 165 | default: |
165 | break; | 166 | break; |
166 | } | 167 | } |
167 | return str; | 168 | return str; |
168 | // FIXME me for 3rd party | 169 | // FIXME me for 3rd party |
169 | } | 170 | } |
170 | int OPimResolver::serviceId( const QString& service ) { | 171 | int OPimResolver::serviceId( const QString& service ) { |
171 | int rtti = 0; | 172 | int rtti = 0; |
172 | if ( service == "Todolist" ) | 173 | if ( service == "Todolist" ) |
173 | rtti = TodoList; | 174 | rtti = TodoList; |
174 | else if ( service == "Datebook" ) | 175 | else if ( service == "Datebook" ) |
175 | rtti = DateBook; | 176 | rtti = DateBook; |
176 | else if ( service == "Addressbook" ) | 177 | else if ( service == "Addressbook" ) |
177 | rtti = AddressBook; | 178 | rtti = AddressBook; |
178 | 179 | ||
179 | return rtti; | 180 | return rtti; |
180 | } | 181 | } |
181 | /** | 182 | /** |
182 | * check if the 'service' is registered and if so we'll | 183 | * check if the 'service' is registered and if so we'll |
183 | */ | 184 | */ |
184 | bool OPimResolver::add( const QString& service, const OPimRecord& rec) { | 185 | bool OPimResolver::add( const QString& service, const OPimRecord& rec) { |
185 | if ( QCopChannel::isRegistered( applicationChannel( service ) ) ) { | 186 | if ( QCopChannel::isRegistered( applicationChannel( service ) ) ) { |
186 | QByteArray data; | 187 | QByteArray data; |
187 | QDataStream arg(data, IO_WriteOnly ); | 188 | QDataStream arg(data, IO_WriteOnly ); |
188 | if ( rec.saveToStream( arg ) ) { | 189 | if ( rec.saveToStream( arg ) ) { |
189 | QCopEnvelope env( applicationChannel( service ), "add(int,QByteArray)" ); | 190 | QCopEnvelope env( applicationChannel( service ), "add(int,QByteArray)" ); |
190 | env << rec.rtti(); | 191 | env << rec.rtti(); |
191 | env << data; | 192 | env << data; |
192 | }else | 193 | }else |
193 | return false; | 194 | return false; |
194 | }else{ | 195 | }else{ |
195 | OPimBase* base = backend( service ); | 196 | OPimBase* base = backend( service ); |
196 | if (!base ) return false; | 197 | if (!base ) return false; |
197 | 198 | ||
198 | base->load(); | 199 | base->load(); |
199 | base->add( rec ); | 200 | base->add( rec ); |
200 | base->save(); | 201 | base->save(); |
201 | delete base; | 202 | delete base; |
202 | } | 203 | } |
203 | 204 | ||
204 | return true; | 205 | return true; |
205 | } | 206 | } |
206 | OPimBase* OPimResolver::backend( const QString& service ) { | 207 | OPimBase* OPimResolver::backend( const QString& service ) { |
207 | return backend( serviceId( service ) ); | 208 | return backend( serviceId( service ) ); |
208 | } | 209 | } |
209 | OPimBase* OPimResolver::backend( int rtti ) { | 210 | OPimBase* OPimResolver::backend( int rtti ) { |
210 | OPimBase* base = 0l; | 211 | OPimBase* base = 0l; |
211 | switch( rtti ) { | 212 | switch( rtti ) { |
212 | case TodoList: | 213 | case TodoList: |
213 | base = new OTodoAccess(); | 214 | base = new OTodoAccess(); |
214 | break; | 215 | break; |
215 | case DateBook: | 216 | case DateBook: |
216 | break; | 217 | break; |
217 | case AddressBook: | 218 | case AddressBook: |
218 | base = new OContactAccess("Resolver"); | 219 | base = new OContactAccess("Resolver"); |
219 | break; | 220 | break; |
220 | default: | 221 | default: |
221 | break; | 222 | break; |
222 | } | 223 | } |
223 | // FIXME for 3rd party | 224 | // FIXME for 3rd party |
224 | if (!base ) | 225 | if (!base ) |
225 | ; | 226 | ; |
226 | 227 | ||
227 | return base; | 228 | return base; |
228 | } | 229 | } |
229 | 230 | ||
230 | } | 231 | } |
diff --git a/libopie2/opiepim/core/opimresolver.h b/libopie2/opiepim/core/opimresolver.h index adc7c16..dd6f07f 100644 --- a/libopie2/opiepim/core/opimresolver.h +++ b/libopie2/opiepim/core/opimresolver.h | |||
@@ -1,121 +1,125 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_RESOLVER | 29 | #ifndef OPIMRESOLVER_H |
30 | #define OPIE_PIM_RESOLVER | 30 | #define OPIMRESOLVER_H |
31 | 31 | ||
32 | /* OPIE */ | ||
33 | #include <opie2/otemplatebase.h> | ||
34 | |||
35 | /* QT */ | ||
32 | #include <qstring.h> | 36 | #include <qstring.h> |
33 | #include <qvaluelist.h> | 37 | #include <qvaluelist.h> |
34 | 38 | ||
35 | #include <opie2/otemplatebase.h> | ||
36 | |||
37 | namespace Opie { | 39 | namespace Opie { |
38 | /** | 40 | /** |
39 | * OPimResolver is a MetaClass to access | 41 | * OPimResolver is a MetaClass to access |
40 | * available backends read only. | 42 | * available backends read only. |
41 | * It will be used to resolve uids + app names | 43 | * It will be used to resolve uids + app names |
42 | * to full informations | 44 | * to full informations |
43 | * to traverse through a list of alarms, reminders | 45 | * to traverse through a list of alarms, reminders |
44 | * to get access to built in PIM functionality | 46 | * to get access to built in PIM functionality |
45 | * and to more stuff | 47 | * and to more stuff |
46 | * THE PERFORMANCE will depend on THE BACKEND | 48 | * THE PERFORMANCE will depend on THE BACKEND |
47 | * USING XML is a waste of memory!!!!! | 49 | * USING XML is a waste of memory!!!!! |
48 | */ | 50 | */ |
49 | class OPimResolver { | 51 | class OPimResolver { |
50 | public: | 52 | |
53 | public: | ||
51 | enum BuiltIn { TodoList = 0, | 54 | enum BuiltIn { TodoList = 0, |
52 | DateBook, | 55 | DateBook, |
53 | AddressBook | 56 | AddressBook |
54 | }; | 57 | }; |
55 | static OPimResolver* self(); | 58 | static OPimResolver* self(); |
56 | 59 | ||
57 | 60 | ||
58 | /** | 61 | /** |
59 | * return a record for a uid | 62 | * return a record for a uid |
60 | * and an service | 63 | * and an service |
61 | * You've THE OWNERSHIP NOW! | 64 | * You've THE OWNERSHIP NOW! |
62 | */ | 65 | */ |
63 | OPimRecord *record( const QString& service, int uid ); | 66 | OPimRecord *record( const QString& service, int uid ); |
64 | 67 | ||
65 | /** | 68 | /** |
66 | * return the QCopChannel for service | 69 | * return the QCopChannel for service |
67 | * When we will use Qtopia Services it will be used here | 70 | * When we will use Qtopia Services it will be used here |
68 | */ | 71 | */ |
69 | QCString qcopChannel( enum BuiltIn& )const; | 72 | QCString qcopChannel( enum BuiltIn& )const; |
70 | QCString qcopChannel( const QString& service )const; | 73 | QCString qcopChannel( const QString& service )const; |
71 | 74 | ||
72 | /** | 75 | /** |
73 | * The Application channel (QPE/Application/name) | 76 | * The Application channel (QPE/Application/name) |
74 | */ | 77 | */ |
75 | QCString applicationChannel( enum BuiltIn& )const; | 78 | QCString applicationChannel( enum BuiltIn& )const; |
76 | QCString applicationChannel( const QString& service )const; | 79 | QCString applicationChannel( const QString& service )const; |
77 | 80 | ||
78 | /** | 81 | /** |
79 | * return a list of available services | 82 | * return a list of available services |
80 | */ | 83 | */ |
81 | QStringList services()const; | 84 | QStringList services()const; |
82 | inline QString serviceName(int rrti )const; | 85 | inline QString serviceName(int rrti )const; |
83 | int serviceId( const QString& Service); | 86 | int serviceId( const QString& Service); |
84 | /** | 87 | /** |
85 | * add a record to a service... ;) | 88 | * add a record to a service... ;) |
86 | */ | 89 | */ |
87 | bool add( const QString& service, const OPimRecord& ); | 90 | bool add( const QString& service, const OPimRecord& ); |
88 | 91 | ||
89 | 92 | ||
90 | /** | 93 | /** |
91 | * record returns an empty record for a given service. | 94 | * record returns an empty record for a given service. |
92 | * Be sure to delete it!!! | 95 | * Be sure to delete it!!! |
93 | * | 96 | * |
94 | */ | 97 | */ |
95 | OPimRecord* record( const QString& service ); | 98 | OPimRecord* record( const QString& service ); |
96 | OPimRecord* record( int rtti ); | 99 | OPimRecord* record( int rtti ); |
97 | 100 | ||
98 | /** | 101 | /** |
99 | * you can cast to your | 102 | * you can cast to your |
100 | */ | 103 | */ |
101 | OPimBase* backend( const QString& service ); | 104 | OPimBase* backend( const QString& service ); |
102 | OPimBase* backend( int rtti ); | 105 | OPimBase* backend( int rtti ); |
103 | private: | 106 | |
107 | private: | ||
104 | OPimResolver(); | 108 | OPimResolver(); |
105 | void loadData(); | 109 | void loadData(); |
106 | inline bool isBuiltIn( const QString& )const; | 110 | inline bool isBuiltIn( const QString& )const; |
107 | OPimRecord* recordExtern( const QString&, int ); | 111 | OPimRecord* recordExtern( const QString&, int ); |
108 | OPimRecord* recordExtern( const QString& ); | 112 | OPimRecord* recordExtern( const QString& ); |
109 | 113 | ||
110 | static OPimResolver* m_self; | 114 | static OPimResolver* m_self; |
111 | struct Data; | 115 | struct Data; |
112 | class Private; | 116 | class Private; |
113 | 117 | ||
114 | Data* data; | 118 | Data* data; |
115 | Private* d; | 119 | Private* d; |
116 | QStringList m_builtIns; | 120 | QStringList m_builtIns; |
117 | }; | 121 | }; |
118 | 122 | ||
119 | } | 123 | } |
120 | 124 | ||
121 | #endif | 125 | #endif |
diff --git a/libopie2/opiepim/core/opimstate.cpp b/libopie2/opiepim/core/opimstate.cpp index 1013a1c..8aff558 100644 --- a/libopie2/opiepim/core/opimstate.cpp +++ b/libopie2/opiepim/core/opimstate.cpp | |||
@@ -1,95 +1,96 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qshared.h> | ||
30 | |||
31 | #include "opimstate.h" | 29 | #include "opimstate.h" |
32 | 30 | ||
31 | /* QT */ | ||
32 | #include <qshared.h> | ||
33 | |||
33 | namespace Opie { | 34 | namespace Opie { |
34 | /* | 35 | /* |
35 | * for one int this does not make | 36 | * for one int this does not make |
36 | * much sense but never the less | 37 | * much sense but never the less |
37 | * we will do it for the future | 38 | * we will do it for the future |
38 | */ | 39 | */ |
39 | struct OPimState::Data : public QShared { | 40 | struct OPimState::Data : public QShared { |
40 | Data() : QShared(),state(Undefined) { | 41 | Data() : QShared(),state(Undefined) { |
41 | } | 42 | } |
42 | int state; | 43 | int state; |
43 | }; | 44 | }; |
44 | 45 | ||
45 | OPimState::OPimState( int state ) { | 46 | OPimState::OPimState( int state ) { |
46 | data = new Data; | 47 | data = new Data; |
47 | data->state = state; | 48 | data->state = state; |
48 | } | 49 | } |
49 | OPimState::OPimState( const OPimState& st) : | 50 | OPimState::OPimState( const OPimState& st) : |
50 | data( st.data ) { | 51 | data( st.data ) { |
51 | /* ref up */ | 52 | /* ref up */ |
52 | data->ref(); | 53 | data->ref(); |
53 | } | 54 | } |
54 | OPimState::~OPimState() { | 55 | OPimState::~OPimState() { |
55 | if ( data->deref() ) { | 56 | if ( data->deref() ) { |
56 | delete data ; | 57 | delete data ; |
57 | data = 0; | 58 | data = 0; |
58 | } | 59 | } |
59 | } | 60 | } |
60 | bool OPimState::operator==( const OPimState& st) { | 61 | bool OPimState::operator==( const OPimState& st) { |
61 | if ( data->state == st.data->state ) return true; | 62 | if ( data->state == st.data->state ) return true; |
62 | 63 | ||
63 | return false; | 64 | return false; |
64 | } | 65 | } |
65 | OPimState &OPimState::operator=( const OPimState& st) { | 66 | OPimState &OPimState::operator=( const OPimState& st) { |
66 | st.data->ref(); | 67 | st.data->ref(); |
67 | deref(); | 68 | deref(); |
68 | data = st.data; | 69 | data = st.data; |
69 | 70 | ||
70 | return *this; | 71 | return *this; |
71 | } | 72 | } |
72 | void OPimState::setState( int st) { | 73 | void OPimState::setState( int st) { |
73 | copyInternally(); | 74 | copyInternally(); |
74 | data->state = st; | 75 | data->state = st; |
75 | } | 76 | } |
76 | int OPimState::state()const { | 77 | int OPimState::state()const { |
77 | return data->state; | 78 | return data->state; |
78 | } | 79 | } |
79 | void OPimState::deref() { | 80 | void OPimState::deref() { |
80 | if ( data->deref() ) { | 81 | if ( data->deref() ) { |
81 | delete data; | 82 | delete data; |
82 | data = 0l; | 83 | data = 0l; |
83 | } | 84 | } |
84 | } | 85 | } |
85 | void OPimState::copyInternally() { | 86 | void OPimState::copyInternally() { |
86 | /* we need to change it */ | 87 | /* we need to change it */ |
87 | if ( data->count != 1 ) { | 88 | if ( data->count != 1 ) { |
88 | data->deref(); | 89 | data->deref(); |
89 | Data* d2 = new Data; | 90 | Data* d2 = new Data; |
90 | d2->state = data->state; | 91 | d2->state = data->state; |
91 | data = d2; | 92 | data = d2; |
92 | } | 93 | } |
93 | } | 94 | } |
94 | 95 | ||
95 | } | 96 | } |
diff --git a/libopie2/opiepim/core/opimstate.h b/libopie2/opiepim/core/opimstate.h index 78e8cd0..8336b3e 100644 --- a/libopie2/opiepim/core/opimstate.h +++ b/libopie2/opiepim/core/opimstate.h | |||
@@ -1,75 +1,78 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_PIM_STATE_H | 29 | #ifndef OPIMSTATE_H |
30 | #define OPIE_PIM_STATE_H | 30 | #define OPIMSTATE_H |
31 | 31 | ||
32 | /* QT */ | ||
32 | #include <qstring.h> | 33 | #include <qstring.h> |
33 | 34 | ||
34 | namespace Opie { | 35 | namespace Opie { |
35 | /** | 36 | /** |
36 | * The State of a Task | 37 | * The State of a Task |
37 | * This class encapsules the state of a todo | 38 | * This class encapsules the state of a todo |
38 | * and it's shared too | 39 | * and it's shared too |
39 | */ | 40 | */ |
40 | /* | 41 | /* |
41 | * in c a simple struct would be enough ;) | 42 | * in c a simple struct would be enough ;) |
42 | * g_new_state(); | 43 | * g_new_state(); |
43 | * g_do_some_thing( state_t* ); | 44 | * g_do_some_thing( state_t* ); |
44 | * ;) | 45 | * ;) |
45 | */ | 46 | */ |
46 | class OPimState { | 47 | class OPimState { |
47 | public: | 48 | |
49 | public: | ||
48 | enum State { | 50 | enum State { |
49 | Started = 0, | 51 | Started = 0, |
50 | Postponed, | 52 | Postponed, |
51 | Finished, | 53 | Finished, |
52 | NotStarted, | 54 | NotStarted, |
53 | Undefined | 55 | Undefined |
54 | }; | 56 | }; |
55 | OPimState( int state = Undefined ); | 57 | OPimState( int state = Undefined ); |
56 | OPimState( const OPimState& ); | 58 | OPimState( const OPimState& ); |
57 | ~OPimState(); | 59 | ~OPimState(); |
58 | 60 | ||
59 | bool operator==( const OPimState& ); | 61 | bool operator==( const OPimState& ); |
60 | OPimState &operator=( const OPimState& ); | 62 | OPimState &operator=( const OPimState& ); |
61 | void setState( int state); | 63 | void setState( int state); |
62 | int state()const; | 64 | int state()const; |
63 | private: | 65 | |
66 | private: | ||
64 | void deref(); | 67 | void deref(); |
65 | inline void copyInternally(); | 68 | inline void copyInternally(); |
66 | 69 | ||
67 | struct Data; | 70 | struct Data; |
68 | Data* data; | 71 | Data* data; |
69 | 72 | ||
70 | class Private; | 73 | class Private; |
71 | Private *d; | 74 | Private *d; |
72 | }; | 75 | }; |
73 | 76 | ||
74 | } | 77 | } |
75 | #endif | 78 | #endif |
diff --git a/libopie2/opiepim/core/opimxref.cpp b/libopie2/opiepim/core/opimxref.cpp index 85d3345..f58ebb5 100644 --- a/libopie2/opiepim/core/opimxref.cpp +++ b/libopie2/opiepim/core/opimxref.cpp | |||
@@ -1,79 +1,85 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <opie2/opimxref.h> | 29 | #include "opimxref.h" |
30 | 30 | ||
31 | namespace Opie { | 31 | namespace Opie { |
32 | 32 | ||
33 | OPimXRef::OPimXRef( const OPimXRefPartner& one, const OPimXRefPartner& two ) | 33 | OPimXRef::OPimXRef( const OPimXRefPartner& one, const OPimXRefPartner& two ) |
34 | : m_partners(2) | 34 | : m_partners(2) |
35 | { | 35 | { |
36 | m_partners[0] = one; | 36 | m_partners[0] = one; |
37 | m_partners[1] = two; | 37 | m_partners[1] = two; |
38 | } | 38 | } |
39 | OPimXRef::OPimXRef() | 39 | OPimXRef::OPimXRef():m_partners(2) |
40 | : m_partners(2) | ||
41 | { | 40 | { |
42 | 41 | ||
43 | } | 42 | } |
43 | |||
44 | OPimXRef::OPimXRef( const OPimXRef& ref) { | 44 | OPimXRef::OPimXRef( const OPimXRef& ref) { |
45 | *this = ref; | 45 | *this = ref; |
46 | } | 46 | } |
47 | |||
47 | OPimXRef::~OPimXRef() { | 48 | OPimXRef::~OPimXRef() { |
48 | } | 49 | } |
50 | |||
49 | OPimXRef &OPimXRef::operator=( const OPimXRef& ref) { | 51 | OPimXRef &OPimXRef::operator=( const OPimXRef& ref) { |
50 | m_partners = ref.m_partners; | 52 | m_partners = ref.m_partners; |
51 | m_partners.detach(); | 53 | m_partners.detach(); |
52 | 54 | ||
53 | return* this; | 55 | return *this; |
54 | } | 56 | } |
57 | |||
55 | bool OPimXRef::operator==( const OPimXRef& oper ) { | 58 | bool OPimXRef::operator==( const OPimXRef& oper ) { |
56 | if ( m_partners == oper.m_partners ) return true; | 59 | if ( m_partners == oper.m_partners ) return true; |
57 | 60 | ||
58 | return false; | 61 | return false; |
59 | } | 62 | } |
60 | OPimXRefPartner OPimXRef::partner( enum Partners par) const{ | 63 | OPimXRefPartner OPimXRef::partner( enum Partners par) const{ |
61 | return m_partners[par]; | 64 | return m_partners[par]; |
62 | } | 65 | } |
66 | |||
63 | void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { | 67 | void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { |
64 | m_partners[par] = part; | 68 | m_partners[par] = part; |
65 | } | 69 | } |
70 | |||
66 | bool OPimXRef::containsString( const QString& string ) const{ | 71 | bool OPimXRef::containsString( const QString& string ) const{ |
67 | if ( m_partners[One].service() == string || | 72 | if ( m_partners[One].service() == string || |
68 | m_partners[Two].service() == string ) return true; | 73 | m_partners[Two].service() == string ) return true; |
69 | 74 | ||
70 | return false; | 75 | return false; |
71 | } | 76 | } |
77 | |||
72 | bool OPimXRef::containsUid( int uid ) const{ | 78 | bool OPimXRef::containsUid( int uid ) const{ |
73 | if ( m_partners[One].uid() == uid || | 79 | if ( m_partners[One].uid() == uid || |
74 | m_partners[Two].uid() == uid ) return true; | 80 | m_partners[Two].uid() == uid ) return true; |
75 | 81 | ||
76 | return false; | 82 | return false; |
77 | } | 83 | } |
78 | 84 | ||
79 | } | 85 | } |
diff --git a/libopie2/opiepim/core/opimxref.h b/libopie2/opiepim/core/opimxref.h index 820c9c4..f3e814e 100644 --- a/libopie2/opiepim/core/opimxref.h +++ b/libopie2/opiepim/core/opimxref.h | |||
@@ -1,71 +1,73 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OPIM_XREF_H | 30 | #ifndef OPIMXREF_H |
31 | #define OPIM_XREF_H | 31 | #define OPIMXREF_H |
32 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <opie2/opimxrefpartner.h> | ||
35 | |||
36 | /* QT */ | ||
33 | #include <qarray.h> | 37 | #include <qarray.h> |
34 | #include <qvaluelist.h> | 38 | #include <qvaluelist.h> |
35 | 39 | ||
36 | #include <opie2/opimxrefpartner.h> | ||
37 | |||
38 | namespace Opie { | 40 | namespace Opie { |
39 | /** | 41 | /** |
40 | * this is a Cross Referecne between | 42 | * this is a Cross Referecne between |
41 | * two Cross Reference Partners | 43 | * two Cross Reference Partners |
42 | */ | 44 | */ |
43 | class OPimXRef { | 45 | class OPimXRef { |
44 | public: | 46 | public: |
45 | typedef QValueList<OPimXRef> ValueList; | 47 | typedef QValueList<OPimXRef> ValueList; |
46 | enum Partners { One, Two }; | 48 | enum Partners { One, Two }; |
47 | OPimXRef( const OPimXRefPartner& ONE, const OPimXRefPartner& ); | 49 | OPimXRef( const OPimXRefPartner& ONE, const OPimXRefPartner& ); |
48 | OPimXRef(); | 50 | OPimXRef(); |
49 | OPimXRef( const OPimXRef& ); | 51 | OPimXRef( const OPimXRef& ); |
50 | ~OPimXRef(); | 52 | ~OPimXRef(); |
51 | 53 | ||
52 | OPimXRef &operator=( const OPimXRef& ); | 54 | OPimXRef &operator=( const OPimXRef& ); |
53 | bool operator==( const OPimXRef& ); | 55 | bool operator==( const OPimXRef& ); |
54 | 56 | ||
55 | OPimXRefPartner partner( enum Partners )const; | 57 | OPimXRefPartner partner( enum Partners ) const; |
56 | 58 | ||
57 | void setPartner( enum Partners, const OPimXRefPartner& ); | 59 | void setPartner( enum Partners, const OPimXRefPartner& ); |
58 | 60 | ||
59 | bool containsString( const QString& service)const; | 61 | bool containsString( const QString& service) const; |
60 | bool containsUid( int uid )const; | 62 | bool containsUid( int uid ) const; |
61 | 63 | ||
62 | private: | 64 | private: |
63 | QArray<OPimXRefPartner> m_partners; | 65 | QArray<OPimXRefPartner> m_partners; |
64 | 66 | ||
65 | class Private; | 67 | class Private; |
66 | Private *d; | 68 | Private *d; |
67 | }; | 69 | }; |
68 | 70 | ||
69 | } | 71 | } |
70 | 72 | ||
71 | #endif | 73 | #endif |
diff --git a/libopie2/opiepim/core/opimxrefmanager.cpp b/libopie2/opiepim/core/opimxrefmanager.cpp index bf6fed6..e7c6c5a 100644 --- a/libopie2/opiepim/core/opimxrefmanager.cpp +++ b/libopie2/opiepim/core/opimxrefmanager.cpp | |||
@@ -1,102 +1,114 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <opie2/opimxrefmanager.h> | 29 | #include "opimxrefmanager.h" |
30 | 30 | ||
31 | namespace Opie { | 31 | namespace Opie { |
32 | 32 | ||
33 | OPimXRefManager::OPimXRefManager() { | 33 | OPimXRefManager::OPimXRefManager() { |
34 | } | 34 | } |
35 | |||
35 | OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) { | 36 | OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) { |
36 | m_list = ref.m_list; | 37 | m_list = ref.m_list; |
37 | } | 38 | } |
39 | |||
38 | OPimXRefManager::~OPimXRefManager() { | 40 | OPimXRefManager::~OPimXRefManager() { |
39 | } | 41 | } |
42 | |||
40 | OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) { | 43 | OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) { |
41 | m_list = ref.m_list; | 44 | m_list = ref.m_list; |
42 | return *this; | 45 | return *this; |
43 | } | 46 | } |
47 | |||
44 | bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) { | 48 | bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) { |
45 | // if ( m_list == ref.m_list ) return true; | 49 | // if ( m_list == ref.m_list ) return true; |
46 | 50 | ||
47 | return false; | 51 | return false; |
48 | } | 52 | } |
53 | |||
49 | void OPimXRefManager::add( const OPimXRef& ref) { | 54 | void OPimXRefManager::add( const OPimXRef& ref) { |
50 | m_list.append( ref ); | 55 | m_list.append( ref ); |
51 | } | 56 | } |
57 | |||
52 | void OPimXRefManager::remove( const OPimXRef& ref) { | 58 | void OPimXRefManager::remove( const OPimXRef& ref) { |
53 | m_list.remove( ref ); | 59 | m_list.remove( ref ); |
54 | } | 60 | } |
61 | |||
55 | void OPimXRefManager::replace( const OPimXRef& ref) { | 62 | void OPimXRefManager::replace( const OPimXRef& ref) { |
56 | m_list.remove( ref ); | 63 | m_list.remove( ref ); |
57 | m_list.append( ref ); | 64 | m_list.append( ref ); |
58 | } | 65 | } |
66 | |||
59 | void OPimXRefManager::clear() { | 67 | void OPimXRefManager::clear() { |
60 | m_list.clear(); | 68 | m_list.clear(); |
61 | } | 69 | } |
62 | QStringList OPimXRefManager::apps()const { | 70 | |
71 | QStringList OPimXRefManager::apps() const { | ||
63 | OPimXRef::ValueList::ConstIterator it; | 72 | OPimXRef::ValueList::ConstIterator it; |
64 | QStringList list; | 73 | QStringList list; |
65 | 74 | ||
66 | QString str; | 75 | QString str; |
67 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 76 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
68 | str = (*it).partner( OPimXRef::One ).service(); | 77 | str = (*it).partner( OPimXRef::One ).service(); |
69 | if ( !list.contains( str ) ) list << str; | 78 | if ( !list.contains( str ) ) list << str; |
70 | 79 | ||
71 | str = (*it).partner( OPimXRef::Two ).service(); | 80 | str = (*it).partner( OPimXRef::Two ).service(); |
72 | if ( !list.contains( str ) ) list << str; | 81 | if ( !list.contains( str ) ) list << str; |
73 | } | 82 | } |
74 | return list; | 83 | return list; |
75 | } | 84 | } |
76 | OPimXRef::ValueList OPimXRefManager::list()const { | 85 | |
86 | OPimXRef::ValueList OPimXRefManager::list() const { | ||
77 | return m_list; | 87 | return m_list; |
78 | } | 88 | } |
79 | OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{ | 89 | |
90 | OPimXRef::ValueList OPimXRefManager::list( const QString& appName ) const{ | ||
80 | OPimXRef::ValueList list; | 91 | OPimXRef::ValueList list; |
81 | OPimXRef::ValueList::ConstIterator it; | 92 | OPimXRef::ValueList::ConstIterator it; |
82 | 93 | ||
83 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 94 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
84 | if ( (*it).containsString( appName ) ) | 95 | if ( (*it).containsString( appName ) ) |
85 | list.append( (*it) ); | 96 | list.append( (*it) ); |
86 | } | 97 | } |
87 | 98 | ||
88 | return list; | 99 | return list; |
89 | } | 100 | } |
90 | OPimXRef::ValueList OPimXRefManager::list( int uid )const { | 101 | |
102 | OPimXRef::ValueList OPimXRefManager::list( int uid ) const { | ||
91 | OPimXRef::ValueList list; | 103 | OPimXRef::ValueList list; |
92 | OPimXRef::ValueList::ConstIterator it; | 104 | OPimXRef::ValueList::ConstIterator it; |
93 | 105 | ||
94 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 106 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
95 | if ( (*it).containsUid( uid ) ) | 107 | if ( (*it).containsUid( uid ) ) |
96 | list.append( (*it) ); | 108 | list.append( (*it) ); |
97 | } | 109 | } |
98 | 110 | ||
99 | return list; | 111 | return list; |
100 | } | 112 | } |
101 | 113 | ||
102 | } | 114 | } |
diff --git a/libopie2/opiepim/core/opimxrefmanager.h b/libopie2/opiepim/core/opimxrefmanager.h index fa2d7f4..b80a645 100644 --- a/libopie2/opiepim/core/opimxrefmanager.h +++ b/libopie2/opiepim/core/opimxrefmanager.h | |||
@@ -1,74 +1,77 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIM_XREF_MANAGER_H | ||
30 | #define OPIM_XREF_MANAGER_H | ||
31 | 29 | ||
32 | #include <qstringlist.h> | 30 | #ifndef OPIMXREFMANAGER_H |
31 | #define OPIMXREFMANAGER_H | ||
33 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <opie2/opimxref.h> | 34 | #include <opie2/opimxref.h> |
35 | 35 | ||
36 | /* QT */ | ||
37 | #include <qstringlist.h> | ||
38 | |||
36 | namespace Opie { | 39 | namespace Opie { |
37 | /** | 40 | /** |
38 | * This is a simple manager for | 41 | * This is a simple manager for |
39 | * OPimXRefs. | 42 | * OPimXRefs. |
40 | * It allows addition, removing, replacing | 43 | * It allows addition, removing, replacing |
41 | * clearing and 'querying' the XRef... | 44 | * clearing and 'querying' the XRef... |
42 | */ | 45 | */ |
43 | class OPimXRefManager { | 46 | class OPimXRefManager { |
44 | public: | 47 | public: |
45 | OPimXRefManager(); | 48 | OPimXRefManager(); |
46 | OPimXRefManager( const OPimXRefManager& ); | 49 | OPimXRefManager( const OPimXRefManager& ); |
47 | ~OPimXRefManager(); | 50 | ~OPimXRefManager(); |
48 | 51 | ||
49 | OPimXRefManager& operator=( const OPimXRefManager& ); | 52 | OPimXRefManager& operator=( const OPimXRefManager& ); |
50 | bool operator==( const OPimXRefManager& ); | 53 | bool operator==( const OPimXRefManager& ); |
51 | 54 | ||
52 | void add( const OPimXRef& ); | 55 | void add( const OPimXRef& ); |
53 | void remove( const OPimXRef& ); | 56 | void remove( const OPimXRef& ); |
54 | void replace( const OPimXRef& ); | 57 | void replace( const OPimXRef& ); |
55 | 58 | ||
56 | void clear(); | 59 | void clear(); |
57 | 60 | ||
58 | /** | 61 | /** |
59 | * apps participating | 62 | * apps participating |
60 | */ | 63 | */ |
61 | QStringList apps()const; | 64 | QStringList apps()const; |
62 | OPimXRef::ValueList list()const; | 65 | OPimXRef::ValueList list()const; |
63 | OPimXRef::ValueList list( const QString& service )const; | 66 | OPimXRef::ValueList list( const QString& service )const; |
64 | OPimXRef::ValueList list( int uid )const; | 67 | OPimXRef::ValueList list( int uid )const; |
65 | 68 | ||
66 | private: | 69 | private: |
67 | OPimXRef::ValueList m_list; | 70 | OPimXRef::ValueList m_list; |
68 | class Private; | 71 | class Private; |
69 | Private *d; | 72 | Private *d; |
70 | }; | 73 | }; |
71 | 74 | ||
72 | } | 75 | } |
73 | 76 | ||
74 | #endif | 77 | #endif |
diff --git a/libopie2/opiepim/core/opimxrefpartner.cpp b/libopie2/opiepim/core/opimxrefpartner.cpp index f6ccc7f..3741bc3 100644 --- a/libopie2/opiepim/core/opimxrefpartner.cpp +++ b/libopie2/opiepim/core/opimxrefpartner.cpp | |||
@@ -1,75 +1,85 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <opie2/opimxrefpartner.h> | 29 | #include "opimxrefpartner.h" |
30 | 30 | ||
31 | namespace Opie { | 31 | namespace Opie { |
32 | 32 | ||
33 | OPimXRefPartner::OPimXRefPartner( const QString& appName, | 33 | OPimXRefPartner::OPimXRefPartner( const QString& appName, |
34 | int uid, int field ) | 34 | int uid, int field ) |
35 | : m_app(appName), m_uid(uid), m_field( field ) { | 35 | : m_app(appName), m_uid(uid), m_field( field ) { |
36 | } | 36 | } |
37 | |||
37 | OPimXRefPartner::OPimXRefPartner( const OPimXRefPartner& ref ) { | 38 | OPimXRefPartner::OPimXRefPartner( const OPimXRefPartner& ref ) { |
38 | *this = ref; | 39 | *this = ref; |
39 | } | 40 | } |
41 | |||
40 | OPimXRefPartner::~OPimXRefPartner() { | 42 | OPimXRefPartner::~OPimXRefPartner() { |
41 | } | 43 | } |
44 | |||
42 | OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) { | 45 | OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) { |
43 | m_app = par.m_app; | 46 | m_app = par.m_app; |
44 | m_uid = par.m_uid; | 47 | m_uid = par.m_uid; |
45 | m_field = par.m_field; | 48 | m_field = par.m_field; |
46 | 49 | ||
47 | return *this; | 50 | return *this; |
48 | } | 51 | } |
52 | |||
49 | bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { | 53 | bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { |
50 | if ( m_app != par.m_app ) return false; | 54 | if ( m_app != par.m_app ) return false; |
51 | if ( m_uid != par.m_uid ) return false; | 55 | if ( m_uid != par.m_uid ) return false; |
52 | if ( m_field != par.m_field ) return false; | 56 | if ( m_field != par.m_field ) return false; |
53 | 57 | ||
54 | return true; | 58 | return true; |
55 | } | 59 | } |
60 | |||
56 | QString OPimXRefPartner::service()const { | 61 | QString OPimXRefPartner::service()const { |
57 | return m_app; | 62 | return m_app; |
58 | } | 63 | } |
64 | |||
59 | int OPimXRefPartner::uid()const { | 65 | int OPimXRefPartner::uid()const { |
60 | return m_uid; | 66 | return m_uid; |
61 | } | 67 | } |
68 | |||
62 | int OPimXRefPartner::field()const { | 69 | int OPimXRefPartner::field()const { |
63 | return m_field; | 70 | return m_field; |
64 | } | 71 | } |
72 | |||
65 | void OPimXRefPartner::setService( const QString& appName ) { | 73 | void OPimXRefPartner::setService( const QString& appName ) { |
66 | m_app = appName; | 74 | m_app = appName; |
67 | } | 75 | } |
76 | |||
68 | void OPimXRefPartner::setUid( int uid ) { | 77 | void OPimXRefPartner::setUid( int uid ) { |
69 | m_uid = uid; | 78 | m_uid = uid; |
70 | } | 79 | } |
80 | |||
71 | void OPimXRefPartner::setField( int field ) { | 81 | void OPimXRefPartner::setField( int field ) { |
72 | m_field = field; | 82 | m_field = field; |
73 | } | 83 | } |
74 | 84 | ||
75 | } | 85 | } |
diff --git a/libopie2/opiepim/core/opimxrefpartner.h b/libopie2/opiepim/core/opimxrefpartner.h index 6853d5b..005dbc0 100644 --- a/libopie2/opiepim/core/opimxrefpartner.h +++ b/libopie2/opiepim/core/opimxrefpartner.h | |||
@@ -1,70 +1,73 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIM_XREF_PARTNER_H | 29 | #ifndef OPIM_XREF_PARTNER_H |
30 | #define OPIM_XREF_PARTNER_H | 30 | #define OPIM_XREF_PARTNER_H |
31 | 31 | ||
32 | /* QT */ | ||
32 | #include <qstring.h> | 33 | #include <qstring.h> |
33 | 34 | ||
34 | namespace Opie { | 35 | namespace Opie { |
35 | /** | 36 | /** |
36 | * This class represents one partner | 37 | * This class represents one partner |
37 | * of a Cross Reference. | 38 | * of a Cross Reference. |
38 | * In Opie one application | 39 | * In Opie one application |
39 | * can link one uid | 40 | * can link one uid |
40 | * with one tableId( fieldId ) to another. | 41 | * with one tableId( fieldId ) to another. |
41 | */ | 42 | */ |
42 | class OPimXRefPartner { | 43 | class OPimXRefPartner { |
43 | public: | 44 | |
45 | public: | ||
44 | OPimXRefPartner( const QString& service = QString::null, | 46 | OPimXRefPartner( const QString& service = QString::null, |
45 | int uid = 0, int field = -1 ); | 47 | int uid = 0, int field = -1 ); |
46 | OPimXRefPartner( const OPimXRefPartner& ); | 48 | OPimXRefPartner( const OPimXRefPartner& ); |
47 | OPimXRefPartner& operator=( const OPimXRefPartner& ); | 49 | OPimXRefPartner& operator=( const OPimXRefPartner& ); |
48 | ~OPimXRefPartner(); | 50 | ~OPimXRefPartner(); |
49 | 51 | ||
50 | bool operator==(const OPimXRefPartner& ); | 52 | bool operator==(const OPimXRefPartner& ); |
51 | 53 | ||
52 | QString service()const; | 54 | QString service()const; |
53 | int uid()const; | 55 | int uid()const; |
54 | int field()const; | 56 | int field()const; |
55 | 57 | ||
56 | void setService( const QString& service ); | 58 | void setService( const QString& service ); |
57 | void setUid( int uid ); | 59 | void setUid( int uid ); |
58 | void setField( int field ); | 60 | void setField( int field ); |
59 | private: | 61 | |
62 | private: | ||
60 | QString m_app; | 63 | QString m_app; |
61 | int m_uid; | 64 | int m_uid; |
62 | int m_field; | 65 | int m_field; |
63 | 66 | ||
64 | class Private; | 67 | class Private; |
65 | Private* d; | 68 | Private* d; |
66 | }; | 69 | }; |
67 | 70 | ||
68 | } | 71 | } |
69 | 72 | ||
70 | #endif | 73 | #endif |
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp index 033f264..5e2da25 100644 --- a/libopie2/opiepim/core/orecur.cpp +++ b/libopie2/opiepim/core/orecur.cpp | |||
@@ -1,625 +1,691 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <time.h> | 30 | #include "orecur.h" |
31 | 31 | ||
32 | #include <qshared.h> | 32 | /* OPIE */ |
33 | #include <opie2/otimezone.h> | ||
34 | #include <qpe/timeconversion.h> | ||
33 | 35 | ||
34 | #include <qtopia/timeconversion.h> | 36 | /* QT */ |
37 | #include <qshared.h> | ||
35 | 38 | ||
36 | #include <opie2/otimezone.h> | 39 | /* STD */ |
37 | #include <opie2/orecur.h> | 40 | #include <time.h> |
38 | 41 | ||
39 | namespace Opie { | 42 | namespace Opie { |
43 | |||
40 | struct ORecur::Data : public QShared { | 44 | struct ORecur::Data : public QShared { |
41 | Data() : QShared() { | 45 | Data() : QShared() { |
42 | type = ORecur::NoRepeat; | 46 | type = ORecur::NoRepeat; |
43 | freq = -1; | 47 | freq = -1; |
44 | days = 0; | 48 | days = 0; |
45 | pos = 0; | 49 | pos = 0; |
46 | create = QDateTime::currentDateTime(); | 50 | create = QDateTime::currentDateTime(); |
47 | hasEnd = FALSE; | 51 | hasEnd = FALSE; |
48 | end = QDate::currentDate(); | 52 | end = QDate::currentDate(); |
49 | } | 53 | } |
50 | char days; // Q_UINT8 for 8 seven days;) | 54 | char days; // Q_UINT8 for 8 seven days;) |
51 | ORecur::RepeatType type; | 55 | ORecur::RepeatType type; |
52 | int freq; | 56 | int freq; |
53 | int pos; | 57 | int pos; |
54 | bool hasEnd : 1; | 58 | bool hasEnd : 1; |
55 | QDate end; | 59 | QDate end; |
56 | QDateTime create; | 60 | QDateTime create; |
57 | int rep; | 61 | int rep; |
58 | QString app; | 62 | QString app; |
59 | ExceptionList list; | 63 | ExceptionList list; |
60 | QDate start; | 64 | QDate start; |
61 | }; | 65 | }; |
62 | 66 | ||
63 | 67 | ||
64 | ORecur::ORecur() { | 68 | ORecur::ORecur() { |
65 | data = new Data; | 69 | data = new Data; |
66 | } | 70 | } |
67 | 71 | ||
68 | ORecur::ORecur( const QMap<int, QString>& map ) | 72 | ORecur::ORecur( const QMap<int, QString>& map ) |
69 | { | 73 | { |
70 | ORecur(); | 74 | ORecur(); |
71 | fromMap( map ); | 75 | fromMap( map ); |
72 | } | 76 | } |
73 | 77 | ||
74 | 78 | ||
75 | ORecur::ORecur( const ORecur& rec) | 79 | ORecur::ORecur( const ORecur& rec) |
76 | : data( rec.data ) | 80 | : data( rec.data ) |
77 | { | 81 | { |
78 | data->ref(); | 82 | data->ref(); |
79 | } | 83 | } |
84 | |||
85 | |||
80 | ORecur::~ORecur() { | 86 | ORecur::~ORecur() { |
81 | if ( data->deref() ) { | 87 | if ( data->deref() ) { |
82 | delete data; | 88 | delete data; |
83 | data = 0l; | 89 | data = 0l; |
84 | } | 90 | } |
85 | } | 91 | } |
92 | |||
93 | |||
86 | void ORecur::deref() { | 94 | void ORecur::deref() { |
87 | if ( data->deref() ) { | 95 | if ( data->deref() ) { |
88 | delete data; | 96 | delete data; |
89 | data = 0l; | 97 | data = 0l; |
90 | } | 98 | } |
91 | } | 99 | } |
100 | |||
101 | |||
92 | bool ORecur::operator==( const ORecur& )const { | 102 | bool ORecur::operator==( const ORecur& )const { |
93 | return false; | 103 | return false; |
94 | } | 104 | } |
105 | |||
106 | |||
95 | ORecur &ORecur::operator=( const ORecur& re) { | 107 | ORecur &ORecur::operator=( const ORecur& re) { |
96 | if ( *this == re ) return *this; | 108 | if ( *this == re ) return *this; |
97 | 109 | ||
98 | re.data->ref(); | 110 | re.data->ref(); |
99 | deref(); | 111 | deref(); |
100 | data = re.data; | 112 | data = re.data; |
101 | 113 | ||
102 | return *this; | 114 | return *this; |
103 | } | 115 | } |
116 | |||
117 | |||
104 | bool ORecur::doesRecur()const { | 118 | bool ORecur::doesRecur()const { |
105 | return !( type() == NoRepeat ); | 119 | return !( type() == NoRepeat ); |
106 | } | 120 | } |
121 | |||
122 | |||
107 | /* | 123 | /* |
108 | * we try to be smart here | 124 | * we try to be smart here |
109 | * | 125 | * |
110 | */ | 126 | */ |
111 | bool ORecur::doesRecur( const QDate& date ) { | 127 | bool ORecur::doesRecur( const QDate& date ) { |
112 | /* the day before the recurrance */ | 128 | /* the day before the recurrance */ |
113 | QDate da = date.addDays(-1); | 129 | QDate da = date.addDays(-1); |
114 | 130 | ||
115 | QDate recur; | 131 | QDate recur; |
116 | if (!nextOcurrence( da, recur ) ) | 132 | if (!nextOcurrence( da, recur ) ) |
117 | return false; | 133 | return false; |
118 | 134 | ||
119 | return (recur == date); | 135 | return (recur == date); |
120 | } | 136 | } |
137 | |||
138 | |||
121 | // FIXME unuglify! | 139 | // FIXME unuglify! |
122 | // GPL from Datebookdb.cpp | 140 | // GPL from Datebookdb.cpp |
123 | // FIXME exception list! | 141 | // FIXME exception list! |
124 | bool ORecur::nextOcurrence( const QDate& from, QDate& next ) { | 142 | bool ORecur::nextOcurrence( const QDate& from, QDate& next ) { |
125 | bool stillLooking; | 143 | bool stillLooking; |
126 | stillLooking = p_nextOccurrence( from, next ); | 144 | stillLooking = p_nextOccurrence( from, next ); |
127 | while ( stillLooking && data->list.contains(next) ) | 145 | while ( stillLooking && data->list.contains(next) ) |
128 | stillLooking = p_nextOccurrence( next.addDays(1), next ); | 146 | stillLooking = p_nextOccurrence( next.addDays(1), next ); |
129 | 147 | ||
130 | return stillLooking; | 148 | return stillLooking; |
131 | } | 149 | } |
150 | |||
151 | |||
132 | bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { | 152 | bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { |
133 | 153 | ||
134 | // easy checks, first are we too far in the future or too far in the past? | 154 | // easy checks, first are we too far in the future or too far in the past? |
135 | QDate tmpDate; | 155 | QDate tmpDate; |
136 | int freq = frequency(); | 156 | int freq = frequency(); |
137 | int diff, diff2, a; | 157 | int diff, diff2, a; |
138 | int iday, imonth, iyear; | 158 | int iday, imonth, iyear; |
139 | int dayOfWeek = 0; | 159 | int dayOfWeek = 0; |
140 | int firstOfWeek = 0; | 160 | int firstOfWeek = 0; |
141 | int weekOfMonth; | 161 | int weekOfMonth; |
142 | 162 | ||
143 | 163 | ||
144 | if (hasEndDate() && endDate() < from) | 164 | if (hasEndDate() && endDate() < from) |
145 | return FALSE; | 165 | return FALSE; |
146 | 166 | ||
147 | if (start() >= from ) { | 167 | if (start() >= from ) { |
148 | next = start(); | 168 | next = start(); |
149 | return TRUE; | 169 | return TRUE; |
150 | } | 170 | } |
151 | 171 | ||
152 | switch ( type() ) { | 172 | switch ( type() ) { |
153 | case Weekly: | 173 | case Weekly: |
154 | /* weekly is just daily by 7 */ | 174 | /* weekly is just daily by 7 */ |
155 | /* first convert the repeatPattern.Days() mask to the next | 175 | /* first convert the repeatPattern.Days() mask to the next |
156 | day of week valid after from */ | 176 | day of week valid after from */ |
157 | dayOfWeek = from.dayOfWeek(); | 177 | dayOfWeek = from.dayOfWeek(); |
158 | dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ | 178 | dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ |
159 | 179 | ||
160 | /* this is done in case freq > 1 and from in week not | 180 | /* this is done in case freq > 1 and from in week not |
161 | for this round */ | 181 | for this round */ |
162 | // firstOfWeek = 0; this is already done at decl. | 182 | // firstOfWeek = 0; this is already done at decl. |
163 | while(!((1 << firstOfWeek) & days() )) | 183 | while(!((1 << firstOfWeek) & days() )) |
164 | firstOfWeek++; | 184 | firstOfWeek++; |
165 | 185 | ||
166 | /* there is at least one 'day', or there would be no event */ | 186 | /* there is at least one 'day', or there would be no event */ |
167 | while(!((1 << (dayOfWeek % 7)) & days() )) | 187 | while(!((1 << (dayOfWeek % 7)) & days() )) |
168 | dayOfWeek++; | 188 | dayOfWeek++; |
169 | 189 | ||
170 | dayOfWeek = dayOfWeek % 7; /* the actual day of week */ | 190 | dayOfWeek = dayOfWeek % 7; /* the actual day of week */ |
171 | dayOfWeek -= start().dayOfWeek() -1; | 191 | dayOfWeek -= start().dayOfWeek() -1; |
172 | 192 | ||
173 | firstOfWeek = firstOfWeek % 7; /* the actual first of week */ | 193 | firstOfWeek = firstOfWeek % 7; /* the actual first of week */ |
174 | firstOfWeek -= start().dayOfWeek() -1; | 194 | firstOfWeek -= start().dayOfWeek() -1; |
175 | 195 | ||
176 | // dayOfWeek may be negitive now | 196 | // dayOfWeek may be negitive now |
177 | // day of week is number of days to add to start day | 197 | // day of week is number of days to add to start day |
178 | 198 | ||
179 | freq *= 7; | 199 | freq *= 7; |
180 | // FALL-THROUGH !!!!! | 200 | // FALL-THROUGH !!!!! |
181 | case Daily: | 201 | case Daily: |
182 | // the add is for the possible fall through from weekly */ | 202 | // the add is for the possible fall through from weekly */ |
183 | if(start().addDays(dayOfWeek) > from) { | 203 | if(start().addDays(dayOfWeek) > from) { |
184 | /* first week exception */ | 204 | /* first week exception */ |
185 | next = QDate(start().addDays(dayOfWeek) ); | 205 | next = QDate(start().addDays(dayOfWeek) ); |
186 | if ((next > endDate()) | 206 | if ((next > endDate()) |
187 | && hasEndDate() ) | 207 | && hasEndDate() ) |
188 | return FALSE; | 208 | return FALSE; |
189 | return TRUE; | 209 | return TRUE; |
190 | } | 210 | } |
191 | /* if from is middle of a non-week */ | 211 | /* if from is middle of a non-week */ |
192 | 212 | ||
193 | diff = start().addDays(dayOfWeek).daysTo(from) % freq; | 213 | diff = start().addDays(dayOfWeek).daysTo(from) % freq; |
194 | diff2 = start().addDays(firstOfWeek).daysTo(from) % freq; | 214 | diff2 = start().addDays(firstOfWeek).daysTo(from) % freq; |
195 | 215 | ||
196 | if(diff != 0) | 216 | if(diff != 0) |
197 | diff = freq - diff; | 217 | diff = freq - diff; |
198 | if(diff2 != 0) | 218 | if(diff2 != 0) |
199 | diff2 = freq - diff2; | 219 | diff2 = freq - diff2; |
200 | diff = QMIN(diff, diff2); | 220 | diff = QMIN(diff, diff2); |
201 | 221 | ||
202 | next = QDate(from.addDays(diff)); | 222 | next = QDate(from.addDays(diff)); |
203 | if ( (next > endDate()) | 223 | if ( (next > endDate()) |
204 | && hasEndDate() ) | 224 | && hasEndDate() ) |
205 | return FALSE; | 225 | return FALSE; |
206 | return TRUE; | 226 | return TRUE; |
207 | case MonthlyDay: | 227 | case MonthlyDay: |
208 | iday = from.day(); | 228 | iday = from.day(); |
209 | iyear = from.year(); | 229 | iyear = from.year(); |
210 | imonth = from.month(); | 230 | imonth = from.month(); |
211 | /* find equivelent day of month for this month */ | 231 | /* find equivelent day of month for this month */ |
212 | dayOfWeek = start().dayOfWeek(); | 232 | dayOfWeek = start().dayOfWeek(); |
213 | weekOfMonth = (start().day() - 1) / 7; | 233 | weekOfMonth = (start().day() - 1) / 7; |
214 | 234 | ||
215 | /* work out when the next valid month is */ | 235 | /* work out when the next valid month is */ |
216 | a = from.year() - start().year(); | 236 | a = from.year() - start().year(); |
217 | a *= 12; | 237 | a *= 12; |
218 | a = a + (imonth - start().month()); | 238 | a = a + (imonth - start().month()); |
219 | /* a is e.start()monthsFrom(from); */ | 239 | /* a is e.start()monthsFrom(from); */ |
220 | if(a % freq) { | 240 | if(a % freq) { |
221 | a = freq - (a % freq); | 241 | a = freq - (a % freq); |
222 | imonth = from.month() + a; | 242 | imonth = from.month() + a; |
223 | if (imonth > 12) { | 243 | if (imonth > 12) { |
224 | imonth--; | 244 | imonth--; |
225 | iyear += imonth / 12; | 245 | iyear += imonth / 12; |
226 | imonth = imonth % 12; | 246 | imonth = imonth % 12; |
227 | imonth++; | 247 | imonth++; |
228 | } | 248 | } |
229 | } | 249 | } |
230 | /* imonth is now the first month after or on | 250 | /* imonth is now the first month after or on |
231 | from that matches the frequency given */ | 251 | from that matches the frequency given */ |
232 | 252 | ||
233 | /* find for this month */ | 253 | /* find for this month */ |
234 | tmpDate = QDate( iyear, imonth, 1 ); | 254 | tmpDate = QDate( iyear, imonth, 1 ); |
235 | 255 | ||
236 | iday = 1; | 256 | iday = 1; |
237 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; | 257 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; |
238 | iday += 7 * weekOfMonth; | 258 | iday += 7 * weekOfMonth; |
239 | while (iday > tmpDate.daysInMonth()) { | 259 | while (iday > tmpDate.daysInMonth()) { |
240 | imonth += freq; | 260 | imonth += freq; |
241 | if (imonth > 12) { | 261 | if (imonth > 12) { |
242 | imonth--; | 262 | imonth--; |
243 | iyear += imonth / 12; | 263 | iyear += imonth / 12; |
244 | imonth = imonth % 12; | 264 | imonth = imonth % 12; |
245 | imonth++; | 265 | imonth++; |
246 | } | 266 | } |
247 | tmpDate = QDate( iyear, imonth, 1 ); | 267 | tmpDate = QDate( iyear, imonth, 1 ); |
248 | /* these loops could go for a while, check end case now */ | 268 | /* these loops could go for a while, check end case now */ |
249 | if ((tmpDate > endDate()) && hasEndDate() ) | 269 | if ((tmpDate > endDate()) && hasEndDate() ) |
250 | return FALSE; | 270 | return FALSE; |
251 | iday = 1; | 271 | iday = 1; |
252 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; | 272 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; |
253 | iday += 7 * weekOfMonth; | 273 | iday += 7 * weekOfMonth; |
254 | } | 274 | } |
255 | tmpDate = QDate(iyear, imonth, iday); | 275 | tmpDate = QDate(iyear, imonth, iday); |
256 | 276 | ||
257 | if (tmpDate >= from) { | 277 | if (tmpDate >= from) { |
258 | next = tmpDate; | 278 | next = tmpDate; |
259 | if ((next > endDate() ) && hasEndDate() ) | 279 | if ((next > endDate() ) && hasEndDate() ) |
260 | return FALSE; | 280 | return FALSE; |
261 | return TRUE; | 281 | return TRUE; |
262 | } | 282 | } |
263 | 283 | ||
264 | /* need to find the next iteration */ | 284 | /* need to find the next iteration */ |
265 | do { | 285 | do { |
266 | imonth += freq; | 286 | imonth += freq; |
267 | if (imonth > 12) { | 287 | if (imonth > 12) { |
268 | imonth--; | 288 | imonth--; |
269 | iyear += imonth / 12; | 289 | iyear += imonth / 12; |
270 | imonth = imonth % 12; | 290 | imonth = imonth % 12; |
271 | imonth++; | 291 | imonth++; |
272 | } | 292 | } |
273 | tmpDate = QDate( iyear, imonth, 1 ); | 293 | tmpDate = QDate( iyear, imonth, 1 ); |
274 | /* these loops could go for a while, check end case now */ | 294 | /* these loops could go for a while, check end case now */ |
275 | if ((tmpDate > endDate()) && hasEndDate() ) | 295 | if ((tmpDate > endDate()) && hasEndDate() ) |
276 | return FALSE; | 296 | return FALSE; |
277 | iday = 1; | 297 | iday = 1; |
278 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; | 298 | iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; |
279 | iday += 7 * weekOfMonth; | 299 | iday += 7 * weekOfMonth; |
280 | } while (iday > tmpDate.daysInMonth()); | 300 | } while (iday > tmpDate.daysInMonth()); |
281 | tmpDate = QDate(iyear, imonth, iday); | 301 | tmpDate = QDate(iyear, imonth, iday); |
282 | 302 | ||
283 | next = tmpDate; | 303 | next = tmpDate; |
284 | if ((next > endDate()) && hasEndDate() ) | 304 | if ((next > endDate()) && hasEndDate() ) |
285 | return FALSE; | 305 | return FALSE; |
286 | return TRUE; | 306 | return TRUE; |
287 | case MonthlyDate: | 307 | case MonthlyDate: |
288 | iday = start().day(); | 308 | iday = start().day(); |
289 | iyear = from.year(); | 309 | iyear = from.year(); |
290 | imonth = from.month(); | 310 | imonth = from.month(); |
291 | 311 | ||
292 | a = from.year() - start().year(); | 312 | a = from.year() - start().year(); |
293 | a *= 12; | 313 | a *= 12; |
294 | a = a + (imonth - start().month()); | 314 | a = a + (imonth - start().month()); |
295 | /* a is e.start()monthsFrom(from); */ | 315 | /* a is e.start()monthsFrom(from); */ |
296 | if(a % freq) { | 316 | if(a % freq) { |
297 | a = freq - (a % freq); | 317 | a = freq - (a % freq); |
298 | imonth = from.month() + a; | 318 | imonth = from.month() + a; |
299 | if (imonth > 12) { | 319 | if (imonth > 12) { |
300 | imonth--; | 320 | imonth--; |
301 | iyear += imonth / 12; | 321 | iyear += imonth / 12; |
302 | imonth = imonth % 12; | 322 | imonth = imonth % 12; |
303 | imonth++; | 323 | imonth++; |
304 | } | 324 | } |
305 | } | 325 | } |
306 | /* imonth is now the first month after or on | 326 | /* imonth is now the first month after or on |
307 | from that matches the frequencey given */ | 327 | from that matches the frequencey given */ |
308 | 328 | ||
309 | /* this could go for a while, worse case, 4*12 iterations, probably */ | 329 | /* this could go for a while, worse case, 4*12 iterations, probably */ |
310 | while(!QDate::isValid(iyear, imonth, iday) ) { | 330 | while(!QDate::isValid(iyear, imonth, iday) ) { |
311 | imonth += freq; | 331 | imonth += freq; |
312 | if (imonth > 12) { | 332 | if (imonth > 12) { |
313 | imonth--; | 333 | imonth--; |
314 | iyear += imonth / 12; | 334 | iyear += imonth / 12; |
315 | imonth = imonth % 12; | 335 | imonth = imonth % 12; |
316 | imonth++; | 336 | imonth++; |
317 | } | 337 | } |
318 | /* these loops could go for a while, check end case now */ | 338 | /* these loops could go for a while, check end case now */ |
319 | if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) | 339 | if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) |
320 | return FALSE; | 340 | return FALSE; |
321 | } | 341 | } |
322 | 342 | ||
323 | if(QDate(iyear, imonth, iday) >= from) { | 343 | if(QDate(iyear, imonth, iday) >= from) { |
324 | /* done */ | 344 | /* done */ |
325 | next = QDate(iyear, imonth, iday); | 345 | next = QDate(iyear, imonth, iday); |
326 | if ((next > endDate()) && hasEndDate() ) | 346 | if ((next > endDate()) && hasEndDate() ) |
327 | return FALSE; | 347 | return FALSE; |
328 | return TRUE; | 348 | return TRUE; |
329 | } | 349 | } |
330 | 350 | ||
331 | /* ok, need to cycle */ | 351 | /* ok, need to cycle */ |
332 | imonth += freq; | 352 | imonth += freq; |
333 | imonth--; | 353 | imonth--; |
334 | iyear += imonth / 12; | 354 | iyear += imonth / 12; |
335 | imonth = imonth % 12; | 355 | imonth = imonth % 12; |
336 | imonth++; | 356 | imonth++; |
337 | 357 | ||
338 | while(!QDate::isValid(iyear, imonth, iday) ) { | 358 | while(!QDate::isValid(iyear, imonth, iday) ) { |
339 | imonth += freq; | 359 | imonth += freq; |
340 | imonth--; | 360 | imonth--; |
341 | iyear += imonth / 12; | 361 | iyear += imonth / 12; |
342 | imonth = imonth % 12; | 362 | imonth = imonth % 12; |
343 | imonth++; | 363 | imonth++; |
344 | if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) | 364 | if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) |
345 | return FALSE; | 365 | return FALSE; |
346 | } | 366 | } |
347 | 367 | ||
348 | next = QDate(iyear, imonth, iday); | 368 | next = QDate(iyear, imonth, iday); |
349 | if ((next > endDate()) && hasEndDate() ) | 369 | if ((next > endDate()) && hasEndDate() ) |
350 | return FALSE; | 370 | return FALSE; |
351 | return TRUE; | 371 | return TRUE; |
352 | case Yearly: | 372 | case Yearly: |
353 | iday = start().day(); | 373 | iday = start().day(); |
354 | imonth = start().month(); | 374 | imonth = start().month(); |
355 | iyear = from.year(); // after all, we want to start in this year | 375 | iyear = from.year(); // after all, we want to start in this year |
356 | 376 | ||
357 | diff = 1; | 377 | diff = 1; |
358 | if(imonth == 2 && iday > 28) { | 378 | if(imonth == 2 && iday > 28) { |
359 | /* leap year, and it counts, calculate actual frequency */ | 379 | /* leap year, and it counts, calculate actual frequency */ |
360 | if(freq % 4) | 380 | if(freq % 4) |
361 | if (freq % 2) | 381 | if (freq % 2) |
362 | freq = freq * 4; | 382 | freq = freq * 4; |
363 | else | 383 | else |
364 | freq = freq * 2; | 384 | freq = freq * 2; |
365 | /* else divides by 4 already, leave freq alone */ | 385 | /* else divides by 4 already, leave freq alone */ |
366 | diff = 4; | 386 | diff = 4; |
367 | } | 387 | } |
368 | 388 | ||
369 | a = from.year() - start().year(); | 389 | a = from.year() - start().year(); |
370 | if(a % freq) { | 390 | if(a % freq) { |
371 | a = freq - (a % freq); | 391 | a = freq - (a % freq); |
372 | iyear = iyear + a; | 392 | iyear = iyear + a; |
373 | } | 393 | } |
374 | 394 | ||
375 | /* under the assumption we won't hit one of the special not-leap years twice */ | 395 | /* under the assumption we won't hit one of the special not-leap years twice */ |
376 | if(!QDate::isValid(iyear, imonth, iday)) { | 396 | if(!QDate::isValid(iyear, imonth, iday)) { |
377 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ | 397 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ |
378 | iyear += freq; | 398 | iyear += freq; |
379 | } | 399 | } |
380 | 400 | ||
381 | if(QDate(iyear, imonth, iday) >= from) { | 401 | if(QDate(iyear, imonth, iday) >= from) { |
382 | next = QDate(iyear, imonth, iday); | 402 | next = QDate(iyear, imonth, iday); |
383 | 403 | ||
384 | if ((next > endDate()) && hasEndDate() ) | 404 | if ((next > endDate()) && hasEndDate() ) |
385 | return FALSE; | 405 | return FALSE; |
386 | return TRUE; | 406 | return TRUE; |
387 | } | 407 | } |
388 | /* iyear == from.year(), need to advance again */ | 408 | /* iyear == from.year(), need to advance again */ |
389 | iyear += freq; | 409 | iyear += freq; |
390 | /* under the assumption we won't hit one of the special not-leap years twice */ | 410 | /* under the assumption we won't hit one of the special not-leap years twice */ |
391 | if(!QDate::isValid(iyear, imonth, iday)) { | 411 | if(!QDate::isValid(iyear, imonth, iday)) { |
392 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ | 412 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ |
393 | iyear += freq; | 413 | iyear += freq; |
394 | } | 414 | } |
395 | 415 | ||
396 | next = QDate(iyear, imonth, iday); | 416 | next = QDate(iyear, imonth, iday); |
397 | if ((next > endDate()) && hasEndDate() ) | 417 | if ((next > endDate()) && hasEndDate() ) |
398 | return FALSE; | 418 | return FALSE; |
399 | return TRUE; | 419 | return TRUE; |
400 | default: | 420 | default: |
401 | return FALSE; | 421 | return FALSE; |
402 | } | 422 | } |
403 | } | 423 | } |
424 | |||
425 | |||
404 | ORecur::RepeatType ORecur::type()const{ | 426 | ORecur::RepeatType ORecur::type()const{ |
405 | return data->type; | 427 | return data->type; |
406 | } | 428 | } |
429 | |||
430 | |||
407 | int ORecur::frequency()const { | 431 | int ORecur::frequency()const { |
408 | return data->freq; | 432 | return data->freq; |
409 | } | 433 | } |
434 | |||
435 | |||
410 | int ORecur::position()const { | 436 | int ORecur::position()const { |
411 | return data->pos; | 437 | return data->pos; |
412 | } | 438 | } |
439 | |||
440 | |||
413 | char ORecur::days() const{ | 441 | char ORecur::days() const{ |
414 | return data->days; | 442 | return data->days; |
415 | } | 443 | } |
444 | |||
445 | |||
416 | bool ORecur::hasEndDate()const { | 446 | bool ORecur::hasEndDate()const { |
417 | return data->hasEnd; | 447 | return data->hasEnd; |
418 | } | 448 | } |
449 | |||
450 | |||
419 | QDate ORecur::endDate()const { | 451 | QDate ORecur::endDate()const { |
420 | return data->end; | 452 | return data->end; |
421 | } | 453 | } |
454 | |||
455 | |||
422 | QDate ORecur::start()const{ | 456 | QDate ORecur::start()const{ |
423 | return data->start; | 457 | return data->start; |
424 | } | 458 | } |
459 | |||
460 | |||
425 | QDateTime ORecur::createdDateTime()const { | 461 | QDateTime ORecur::createdDateTime()const { |
426 | return data->create; | 462 | return data->create; |
427 | } | 463 | } |
464 | |||
465 | |||
428 | int ORecur::repetition()const { | 466 | int ORecur::repetition()const { |
429 | return data->rep; | 467 | return data->rep; |
430 | } | 468 | } |
469 | |||
470 | |||
431 | QString ORecur::service()const { | 471 | QString ORecur::service()const { |
432 | return data->app; | 472 | return data->app; |
433 | } | 473 | } |
474 | |||
475 | |||
434 | ORecur::ExceptionList& ORecur::exceptions() { | 476 | ORecur::ExceptionList& ORecur::exceptions() { |
435 | return data->list; | 477 | return data->list; |
436 | } | 478 | } |
479 | |||
480 | |||
437 | void ORecur::setType( const RepeatType& z) { | 481 | void ORecur::setType( const RepeatType& z) { |
438 | checkOrModify(); | 482 | checkOrModify(); |
439 | data->type = z; | 483 | data->type = z; |
440 | } | 484 | } |
485 | |||
486 | |||
441 | void ORecur::setFrequency( int freq ) { | 487 | void ORecur::setFrequency( int freq ) { |
442 | checkOrModify(); | 488 | checkOrModify(); |
443 | data->freq = freq; | 489 | data->freq = freq; |
444 | } | 490 | } |
491 | |||
492 | |||
445 | void ORecur::setPosition( int pos ) { | 493 | void ORecur::setPosition( int pos ) { |
446 | checkOrModify(); | 494 | checkOrModify(); |
447 | data->pos = pos; | 495 | data->pos = pos; |
448 | } | 496 | } |
497 | |||
498 | |||
449 | void ORecur::setDays( char c ) { | 499 | void ORecur::setDays( char c ) { |
450 | checkOrModify(); | 500 | checkOrModify(); |
451 | data->days = c; | 501 | data->days = c; |
452 | } | 502 | } |
503 | |||
504 | |||
453 | void ORecur::setEndDate( const QDate& dt) { | 505 | void ORecur::setEndDate( const QDate& dt) { |
454 | checkOrModify(); | 506 | checkOrModify(); |
455 | data->end = dt; | 507 | data->end = dt; |
456 | } | 508 | } |
509 | |||
510 | |||
457 | void ORecur::setCreatedDateTime( const QDateTime& t) { | 511 | void ORecur::setCreatedDateTime( const QDateTime& t) { |
458 | checkOrModify(); | 512 | checkOrModify(); |
459 | data->create = t; | 513 | data->create = t; |
460 | } | 514 | } |
515 | |||
516 | |||
461 | void ORecur::setHasEndDate( bool b) { | 517 | void ORecur::setHasEndDate( bool b) { |
462 | checkOrModify(); | 518 | checkOrModify(); |
463 | data->hasEnd = b; | 519 | data->hasEnd = b; |
464 | } | 520 | } |
521 | |||
522 | |||
465 | void ORecur::setRepitition( int rep ) { | 523 | void ORecur::setRepitition( int rep ) { |
466 | checkOrModify(); | 524 | checkOrModify(); |
467 | data->rep = rep; | 525 | data->rep = rep; |
468 | } | 526 | } |
527 | |||
528 | |||
469 | void ORecur::setService( const QString& app ) { | 529 | void ORecur::setService( const QString& app ) { |
470 | checkOrModify(); | 530 | checkOrModify(); |
471 | data->app = app; | 531 | data->app = app; |
472 | } | 532 | } |
533 | |||
534 | |||
473 | void ORecur::setStart( const QDate& dt ) { | 535 | void ORecur::setStart( const QDate& dt ) { |
474 | checkOrModify(); | 536 | checkOrModify(); |
475 | data->start = dt; | 537 | data->start = dt; |
476 | } | 538 | } |
539 | |||
540 | |||
477 | void ORecur::checkOrModify() { | 541 | void ORecur::checkOrModify() { |
478 | if ( data->count != 1 ) { | 542 | if ( data->count != 1 ) { |
479 | data->deref(); | 543 | data->deref(); |
480 | Data* d2 = new Data; | 544 | Data* d2 = new Data; |
481 | d2->days = data->days; | 545 | d2->days = data->days; |
482 | d2->type = data->type; | 546 | d2->type = data->type; |
483 | d2->freq = data->freq; | 547 | d2->freq = data->freq; |
484 | d2->pos = data->pos; | 548 | d2->pos = data->pos; |
485 | d2->hasEnd = data->hasEnd; | 549 | d2->hasEnd = data->hasEnd; |
486 | d2->end = data->end; | 550 | d2->end = data->end; |
487 | d2->create = data->create; | 551 | d2->create = data->create; |
488 | d2->rep = data->rep; | 552 | d2->rep = data->rep; |
489 | d2->app = data->app; | 553 | d2->app = data->app; |
490 | d2->list = data->list; | 554 | d2->list = data->list; |
491 | d2->start = data->start; | 555 | d2->start = data->start; |
492 | data = d2; | 556 | data = d2; |
493 | } | 557 | } |
494 | } | 558 | } |
559 | |||
560 | |||
495 | QString ORecur::toString()const { | 561 | QString ORecur::toString()const { |
496 | QString buf; | 562 | QString buf; |
497 | QMap<int, QString> recMap = toMap(); | 563 | QMap<int, QString> recMap = toMap(); |
498 | 564 | ||
499 | buf += " rtype=\""; | 565 | buf += " rtype=\""; |
500 | buf += recMap[ORecur::RType]; | 566 | buf += recMap[ORecur::RType]; |
501 | buf += "\""; | 567 | buf += "\""; |
502 | if (data->days > 0 ) | 568 | if (data->days > 0 ) |
503 | buf += " rweekdays=\"" + recMap[ORecur::RWeekdays] + "\""; | 569 | buf += " rweekdays=\"" + recMap[ORecur::RWeekdays] + "\""; |
504 | if ( data->pos != 0 ) | 570 | if ( data->pos != 0 ) |
505 | buf += " rposition=\"" + recMap[ORecur::RPosition] + "\""; | 571 | buf += " rposition=\"" + recMap[ORecur::RPosition] + "\""; |
506 | 572 | ||
507 | buf += " rfreq=\"" + recMap[ORecur::RFreq] + "\""; | 573 | buf += " rfreq=\"" + recMap[ORecur::RFreq] + "\""; |
508 | buf += " rhasenddate=\"" + recMap[ORecur::RHasEndDate]+ "\""; | 574 | buf += " rhasenddate=\"" + recMap[ORecur::RHasEndDate]+ "\""; |
509 | if ( data->hasEnd ) | 575 | if ( data->hasEnd ) |
510 | buf += " enddt=\"" | 576 | buf += " enddt=\"" |
511 | + recMap[ORecur::EndDate] | 577 | + recMap[ORecur::EndDate] |
512 | + "\""; | 578 | + "\""; |
513 | buf += " created=\"" + recMap[ORecur::Created] + "\""; | 579 | buf += " created=\"" + recMap[ORecur::Created] + "\""; |
514 | 580 | ||
515 | if ( data->list.isEmpty() ) return buf; | 581 | if ( data->list.isEmpty() ) return buf; |
516 | buf += " exceptions=\""; | 582 | buf += " exceptions=\""; |
517 | buf += recMap[ORecur::Exceptions]; | 583 | buf += recMap[ORecur::Exceptions]; |
518 | buf += "\" "; | 584 | buf += "\" "; |
519 | 585 | ||
520 | return buf; | 586 | return buf; |
521 | } | 587 | } |
522 | 588 | ||
523 | QString ORecur::rTypeString() const | 589 | QString ORecur::rTypeString() const |
524 | { | 590 | { |
525 | QString retString; | 591 | QString retString; |
526 | switch ( data->type ) { | 592 | switch ( data->type ) { |
527 | case ORecur::Daily: | 593 | case ORecur::Daily: |
528 | retString = "Daily"; | 594 | retString = "Daily"; |
529 | break; | 595 | break; |
530 | case ORecur::Weekly: | 596 | case ORecur::Weekly: |
531 | retString = "Weekly"; | 597 | retString = "Weekly"; |
532 | break; | 598 | break; |
533 | case ORecur::MonthlyDay: | 599 | case ORecur::MonthlyDay: |
534 | retString = "MonthlyDay"; | 600 | retString = "MonthlyDay"; |
535 | break; | 601 | break; |
536 | case ORecur::MonthlyDate: | 602 | case ORecur::MonthlyDate: |
537 | retString = "MonthlyDate"; | 603 | retString = "MonthlyDate"; |
538 | break; | 604 | break; |
539 | case ORecur::Yearly: | 605 | case ORecur::Yearly: |
540 | retString = "Yearly"; | 606 | retString = "Yearly"; |
541 | break; | 607 | break; |
542 | default: | 608 | default: |
543 | retString = "NoRepeat"; | 609 | retString = "NoRepeat"; |
544 | break; | 610 | break; |
545 | 611 | ||
546 | } | 612 | } |
547 | 613 | ||
548 | return retString; | 614 | return retString; |
549 | } | 615 | } |
550 | 616 | ||
551 | QMap<QString, ORecur::RepeatType> ORecur::rTypeValueConvertMap() const | 617 | QMap<QString, ORecur::RepeatType> ORecur::rTypeValueConvertMap() const |
552 | { | 618 | { |
553 | QMap<QString, RepeatType> convertMap; | 619 | QMap<QString, RepeatType> convertMap; |
554 | 620 | ||
555 | convertMap.insert( QString( "Daily" ), ORecur::Daily ); | 621 | convertMap.insert( QString( "Daily" ), ORecur::Daily ); |
556 | convertMap.insert( QString( "Weekly" ), ORecur::Weekly ); | 622 | convertMap.insert( QString( "Weekly" ), ORecur::Weekly ); |
557 | convertMap.insert( QString( "MonthlyDay" ), ORecur::MonthlyDay ); | 623 | convertMap.insert( QString( "MonthlyDay" ), ORecur::MonthlyDay ); |
558 | convertMap.insert( QString( "MonthlyDate" ), ORecur::MonthlyDate ); | 624 | convertMap.insert( QString( "MonthlyDate" ), ORecur::MonthlyDate ); |
559 | convertMap.insert( QString( "Yearly" ), ORecur::Yearly ); | 625 | convertMap.insert( QString( "Yearly" ), ORecur::Yearly ); |
560 | convertMap.insert( QString( "NoRepeat" ), ORecur::NoRepeat ); | 626 | convertMap.insert( QString( "NoRepeat" ), ORecur::NoRepeat ); |
561 | 627 | ||
562 | return convertMap; | 628 | return convertMap; |
563 | } | 629 | } |
564 | 630 | ||
565 | 631 | ||
566 | QMap<int, QString> ORecur::toMap() const | 632 | QMap<int, QString> ORecur::toMap() const |
567 | { | 633 | { |
568 | QMap<int, QString> retMap; | 634 | QMap<int, QString> retMap; |
569 | 635 | ||
570 | retMap.insert( ORecur::RType, rTypeString() ); | 636 | retMap.insert( ORecur::RType, rTypeString() ); |
571 | retMap.insert( ORecur::RWeekdays, QString::number( static_cast<int>( data->days ) ) ); | 637 | retMap.insert( ORecur::RWeekdays, QString::number( static_cast<int>( data->days ) ) ); |
572 | retMap.insert( ORecur::RPosition, QString::number(data->pos ) ); | 638 | retMap.insert( ORecur::RPosition, QString::number(data->pos ) ); |
573 | retMap.insert( ORecur::RFreq, QString::number( data->freq ) ); | 639 | retMap.insert( ORecur::RFreq, QString::number( data->freq ) ); |
574 | retMap.insert( ORecur::RHasEndDate, QString::number( static_cast<int>( data->hasEnd ) ) ); | 640 | retMap.insert( ORecur::RHasEndDate, QString::number( static_cast<int>( data->hasEnd ) ) ); |
575 | if( data -> hasEnd ) | 641 | if( data -> hasEnd ) |
576 | retMap.insert( ORecur::EndDate, QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) ); | 642 | retMap.insert( ORecur::EndDate, QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) ); |
577 | retMap.insert( ORecur::Created, QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) ); | 643 | retMap.insert( ORecur::Created, QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) ); |
578 | 644 | ||
579 | if ( data->list.isEmpty() ) return retMap; | 645 | if ( data->list.isEmpty() ) return retMap; |
580 | 646 | ||
581 | // save exceptions list here!! | 647 | // save exceptions list here!! |
582 | ExceptionList::ConstIterator it; | 648 | ExceptionList::ConstIterator it; |
583 | ExceptionList list = data->list; | 649 | ExceptionList list = data->list; |
584 | QString exceptBuf; | 650 | QString exceptBuf; |
585 | QDate date; | 651 | QDate date; |
586 | for ( it = list.begin(); it != list.end(); ++it ) { | 652 | for ( it = list.begin(); it != list.end(); ++it ) { |
587 | date = (*it); | 653 | date = (*it); |
588 | if ( it != list.begin() ) exceptBuf += " "; | 654 | if ( it != list.begin() ) exceptBuf += " "; |
589 | 655 | ||
590 | exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); | 656 | exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); |
591 | } | 657 | } |
592 | 658 | ||
593 | retMap.insert( ORecur::Exceptions, exceptBuf ); | 659 | retMap.insert( ORecur::Exceptions, exceptBuf ); |
594 | 660 | ||
595 | return retMap; | 661 | return retMap; |
596 | } | 662 | } |
597 | 663 | ||
598 | void ORecur::fromMap( const QMap<int, QString>& map ) | 664 | void ORecur::fromMap( const QMap<int, QString>& map ) |
599 | { | 665 | { |
600 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); | 666 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); |
601 | 667 | ||
602 | data -> type = repTypeMap[ map [ORecur::RType] ]; | 668 | data -> type = repTypeMap[ map [ORecur::RType] ]; |
603 | data -> days = (char) map[ ORecur::RWeekdays ].toInt(); | 669 | data -> days = (char) map[ ORecur::RWeekdays ].toInt(); |
604 | data -> pos = map[ ORecur::RPosition ].toInt(); | 670 | data -> pos = map[ ORecur::RPosition ].toInt(); |
605 | data -> freq = map[ ORecur::RFreq ].toInt(); | 671 | data -> freq = map[ ORecur::RFreq ].toInt(); |
606 | data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; | 672 | data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; |
607 | OTimeZone utc = OTimeZone::utc(); | 673 | OTimeZone utc = OTimeZone::utc(); |
608 | if ( data -> hasEnd ){ | 674 | if ( data -> hasEnd ){ |
609 | data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); | 675 | data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); |
610 | } | 676 | } |
611 | data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); | 677 | data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); |
612 | 678 | ||
613 | #if 0 | 679 | #if 0 |
614 | // FIXME: Exceptions currently not supported... | 680 | // FIXME: Exceptions currently not supported... |
615 | // Convert the list of exceptions from QString into ExceptionList | 681 | // Convert the list of exceptions from QString into ExceptionList |
616 | data -> list.clear(); | 682 | data -> list.clear(); |
617 | QString exceptStr = map[ ORecur::Exceptions ]; | 683 | QString exceptStr = map[ ORecur::Exceptions ]; |
618 | QStringList exceptList = QStringList::split( " ", exceptStr ); | 684 | QStringList exceptList = QStringList::split( " ", exceptStr ); |
619 | ... | 685 | ... |
620 | #endif | 686 | #endif |
621 | 687 | ||
622 | 688 | ||
623 | } | 689 | } |
624 | 690 | ||
625 | } \ No newline at end of file | 691 | } |
diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h index 60508f5..7808897 100644 --- a/libopie2/opiepim/core/orecur.h +++ b/libopie2/opiepim/core/orecur.h | |||
@@ -1,134 +1,137 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OPIE_RECUR_H | 30 | #ifndef ORECUR_H |
31 | #define OPIE_RECUR_H | 31 | #define ORECUR_H |
32 | |||
33 | #include <sys/types.h> | ||
34 | 32 | ||
33 | /* QT */ | ||
35 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
36 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
37 | #include <qmap.h> | 36 | #include <qmap.h> |
38 | 37 | ||
38 | /* STD */ | ||
39 | #include <sys/types.h> | ||
39 | 40 | ||
40 | namespace Opie { | 41 | namespace Opie { |
41 | /** | 42 | /** |
42 | * Class to handle Recurrencies.. | 43 | * Class to handle Recurrencies.. |
43 | */ | 44 | */ |
44 | 45 | ||
45 | class ORecur { | 46 | class ORecur { |
46 | public: | 47 | |
48 | public: | ||
47 | typedef QValueList<QDate> ExceptionList; | 49 | typedef QValueList<QDate> ExceptionList; |
48 | enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay, | 50 | enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay, |
49 | MonthlyDate, Yearly }; | 51 | MonthlyDate, Yearly }; |
50 | enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, | 52 | enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, |
51 | FRI = 0x10, SAT = 0x20, SUN = 0x40 }; | 53 | FRI = 0x10, SAT = 0x20, SUN = 0x40 }; |
52 | enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate, | 54 | enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate, |
53 | EndDate, Created, Exceptions }; | 55 | EndDate, Created, Exceptions }; |
54 | 56 | ||
55 | ORecur(); | 57 | ORecur(); |
56 | ORecur( const QMap<int, QString>& map ); | 58 | ORecur( const QMap<int, QString>& map ); |
57 | ORecur( const ORecur& ); | 59 | ORecur( const ORecur& ); |
58 | ~ORecur(); | 60 | ~ORecur(); |
59 | 61 | ||
60 | ORecur &operator=( const ORecur& ); | 62 | ORecur &operator=( const ORecur& ); |
61 | bool operator==(const ORecur& )const; | 63 | bool operator==(const ORecur& )const; |
62 | 64 | ||
63 | bool doesRecur()const; | 65 | bool doesRecur()const; |
64 | /* if it recurrs on that day */ | 66 | /* if it recurrs on that day */ |
65 | bool doesRecur( const QDate& ); | 67 | bool doesRecur( const QDate& ); |
66 | RepeatType type()const; | 68 | RepeatType type()const; |
67 | int frequency()const; | 69 | int frequency()const; |
68 | int position()const; | 70 | int position()const; |
69 | char days()const; | 71 | char days()const; |
70 | bool hasEndDate()const; | 72 | bool hasEndDate()const; |
71 | QDate start()const; | 73 | QDate start()const; |
72 | QDate endDate()const; | 74 | QDate endDate()const; |
73 | QDateTime createdDateTime()const; | 75 | QDateTime createdDateTime()const; |
74 | /** | 76 | /** |
75 | * starting on monday=0, sunday=6 | 77 | * starting on monday=0, sunday=6 |
76 | * for convience | 78 | * for convience |
77 | */ | 79 | */ |
78 | bool repeatOnWeekDay( int day )const; | 80 | bool repeatOnWeekDay( int day )const; |
79 | 81 | ||
80 | /** | 82 | /** |
81 | * FromWhereToStart is not included!!! | 83 | * FromWhereToStart is not included!!! |
82 | */ | 84 | */ |
83 | bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate ); | 85 | bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate ); |
84 | 86 | ||
85 | /** | 87 | /** |
86 | * The module this ORecur belongs to | 88 | * The module this ORecur belongs to |
87 | */ | 89 | */ |
88 | QString service()const; | 90 | QString service()const; |
89 | 91 | ||
90 | /* | 92 | /* |
91 | * reference to the exception list | 93 | * reference to the exception list |
92 | */ | 94 | */ |
93 | ExceptionList &exceptions(); | 95 | ExceptionList &exceptions(); |
94 | 96 | ||
95 | /** | 97 | /** |
96 | * the current repetition | 98 | * the current repetition |
97 | */ | 99 | */ |
98 | int repetition()const; | 100 | int repetition()const; |
99 | 101 | ||
100 | void setType( const RepeatType& ); | 102 | void setType( const RepeatType& ); |
101 | void setFrequency( int freq ); | 103 | void setFrequency( int freq ); |
102 | void setPosition( int pos ); | 104 | void setPosition( int pos ); |
103 | void setDays( char c); | 105 | void setDays( char c); |
104 | void setEndDate( const QDate& dt ); | 106 | void setEndDate( const QDate& dt ); |
105 | void setStart( const QDate& dt ); | 107 | void setStart( const QDate& dt ); |
106 | void setCreatedDateTime( const QDateTime& ); | 108 | void setCreatedDateTime( const QDateTime& ); |
107 | void setHasEndDate( bool b ); | 109 | void setHasEndDate( bool b ); |
108 | void setRepitition(int ); | 110 | void setRepitition(int ); |
109 | 111 | ||
110 | void setService( const QString& ser ); | 112 | void setService( const QString& ser ); |
111 | 113 | ||
112 | QMap<int, QString> toMap() const; | 114 | QMap<int, QString> toMap() const; |
113 | void fromMap( const QMap<int, QString>& map ); | 115 | void fromMap( const QMap<int, QString>& map ); |
114 | 116 | ||
115 | /* almost internal */ | 117 | /* almost internal */ |
116 | QString toString()const; | 118 | QString toString()const; |
117 | private: | 119 | |
120 | private: | ||
118 | bool p_nextOccurrence( const QDate& from, QDate& next ); | 121 | bool p_nextOccurrence( const QDate& from, QDate& next ); |
119 | void deref(); | 122 | void deref(); |
120 | inline void checkOrModify(); | 123 | inline void checkOrModify(); |
121 | 124 | ||
122 | /* Converts rType to String */ | 125 | /* Converts rType to String */ |
123 | QString rTypeString() const; | 126 | QString rTypeString() const; |
124 | /* Returns a map to convert Stringname for RType to RepeatType */ | 127 | /* Returns a map to convert Stringname for RType to RepeatType */ |
125 | QMap<QString, RepeatType> rTypeValueConvertMap() const; | 128 | QMap<QString, RepeatType> rTypeValueConvertMap() const; |
126 | 129 | ||
127 | class Data; | 130 | class Data; |
128 | Data* data; | 131 | Data* data; |
129 | class ORecurPrivate; | 132 | class ORecurPrivate; |
130 | ORecurPrivate *d; | 133 | ORecurPrivate *d; |
131 | }; | 134 | }; |
132 | 135 | ||
133 | } | 136 | } |
134 | #endif | 137 | #endif |
diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h index 17d9961..58cbfeb 100644 --- a/libopie2/opiepim/core/otemplatebase.h +++ b/libopie2/opiepim/core/otemplatebase.h | |||
@@ -1,129 +1,130 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OPIE_TEMPLATE_BASE_H | 29 | #ifndef OTEMPLATEBASE_H |
30 | #define OPIE_TEMPLATE_BASE_H | 30 | #define OTEMPLATEBASE_H |
31 | |||
32 | #include <qarray.h> | ||
33 | 31 | ||
32 | /* OPIE */ | ||
34 | #include <opie2/opimrecord.h> | 33 | #include <opie2/opimrecord.h> |
35 | 34 | ||
35 | /* QT */ | ||
36 | #include <qarray.h> | ||
36 | 37 | ||
37 | namespace Opie { | 38 | namespace Opie { |
38 | /** | 39 | /** |
39 | * Templates do not have a base class, This is why | 40 | * Templates do not have a base class, This is why |
40 | * we've this class | 41 | * we've this class |
41 | * this is here to give us the possibility | 42 | * this is here to give us the possibility |
42 | * to have a common base class | 43 | * to have a common base class |
43 | * You may not want to use that interface internaly | 44 | * You may not want to use that interface internaly |
44 | * POOR mans interface | 45 | * POOR mans interface |
45 | */ | 46 | */ |
46 | class OPimBasePrivate; | 47 | class OPimBasePrivate; |
47 | struct OPimBase { | 48 | struct OPimBase { |
48 | /** | 49 | /** |
49 | * return the rtti | 50 | * return the rtti |
50 | */ | 51 | */ |
51 | virtual int rtti()= 0; | 52 | virtual int rtti()= 0; |
52 | virtual OPimRecord* record()const = 0; | 53 | virtual OPimRecord* record()const = 0; |
53 | virtual OPimRecord* record(int uid)const = 0; | 54 | virtual OPimRecord* record(int uid)const = 0; |
54 | virtual bool add( const OPimRecord& ) = 0; | 55 | virtual bool add( const OPimRecord& ) = 0; |
55 | virtual bool remove( int uid ) = 0; | 56 | virtual bool remove( int uid ) = 0; |
56 | virtual bool remove( const OPimRecord& ) = 0; | 57 | virtual bool remove( const OPimRecord& ) = 0; |
57 | virtual void clear() = 0; | 58 | virtual void clear() = 0; |
58 | virtual bool load() = 0; | 59 | virtual bool load() = 0; |
59 | virtual bool save() = 0; | 60 | virtual bool save() = 0; |
60 | virtual QArray<int> records()const = 0; | 61 | virtual QArray<int> records()const = 0; |
61 | /* | 62 | /* |
62 | * ADD editing here? | 63 | * ADD editing here? |
63 | * -zecke | 64 | * -zecke |
64 | */ | 65 | */ |
65 | private: | 66 | private: |
66 | OPimBasePrivate* d; | 67 | OPimBasePrivate* d; |
67 | 68 | ||
68 | }; | 69 | }; |
69 | /** | 70 | /** |
70 | * internal template base | 71 | * internal template base |
71 | * T needs to implement the copy c'tor!!! | 72 | * T needs to implement the copy c'tor!!! |
72 | */ | 73 | */ |
73 | class OTemplateBasePrivate; | 74 | class OTemplateBasePrivate; |
74 | template <class T = OPimRecord> | 75 | template <class T = OPimRecord> |
75 | class OTemplateBase : public OPimBase { | 76 | class OTemplateBase : public OPimBase { |
76 | public: | 77 | public: |
77 | enum CacheDirection { Forward=0, Reverse }; | 78 | enum CacheDirection { Forward=0, Reverse }; |
78 | OTemplateBase() { | 79 | OTemplateBase() { |
79 | }; | 80 | }; |
80 | virtual ~OTemplateBase() { | 81 | virtual ~OTemplateBase() { |
81 | } | 82 | } |
82 | virtual T find( int uid )const = 0; | 83 | virtual T find( int uid )const = 0; |
83 | 84 | ||
84 | /** | 85 | /** |
85 | * read ahead find | 86 | * read ahead find |
86 | */ | 87 | */ |
87 | virtual T find( int uid, const QArray<int>& items, | 88 | virtual T find( int uid, const QArray<int>& items, |
88 | uint current, CacheDirection dir = Forward )const = 0; | 89 | uint current, CacheDirection dir = Forward )const = 0; |
89 | virtual void cache( const T& )const = 0; | 90 | virtual void cache( const T& )const = 0; |
90 | virtual void setSaneCacheSize( int ) = 0; | 91 | virtual void setSaneCacheSize( int ) = 0; |
91 | 92 | ||
92 | /* reimplement of OPimBase */ | 93 | /* reimplement of OPimBase */ |
93 | int rtti(); | 94 | int rtti(); |
94 | OPimRecord* record()const; | 95 | OPimRecord* record()const; |
95 | OPimRecord* record(int uid )const; | 96 | OPimRecord* record(int uid )const; |
96 | static T* rec(); | 97 | static T* rec(); |
97 | 98 | ||
98 | private: | 99 | private: |
99 | OTemplateBasePrivate *d; | 100 | OTemplateBasePrivate *d; |
100 | }; | 101 | }; |
101 | 102 | ||
102 | /* | 103 | /* |
103 | * implementation | 104 | * implementation |
104 | */ | 105 | */ |
105 | template <class T> | 106 | template <class T> |
106 | int | 107 | int |
107 | OTemplateBase<T>::rtti() { | 108 | OTemplateBase<T>::rtti() { |
108 | return T::rtti(); | 109 | return T::rtti(); |
109 | } | 110 | } |
110 | template <class T> | 111 | template <class T> |
111 | OPimRecord* OTemplateBase<T>::record()const { | 112 | OPimRecord* OTemplateBase<T>::record()const { |
112 | T* t = new T; | 113 | T* t = new T; |
113 | return t; | 114 | return t; |
114 | } | 115 | } |
115 | template <class T> | 116 | template <class T> |
116 | OPimRecord* OTemplateBase<T>::record(int uid )const { | 117 | OPimRecord* OTemplateBase<T>::record(int uid )const { |
117 | T t2 = find(uid ); | 118 | T t2 = find(uid ); |
118 | T* t1 = new T(t2); | 119 | T* t1 = new T(t2); |
119 | 120 | ||
120 | return t1; | 121 | return t1; |
121 | }; | 122 | }; |
122 | template <class T> | 123 | template <class T> |
123 | T* OTemplateBase<T>::rec() { | 124 | T* OTemplateBase<T>::rec() { |
124 | return new T; | 125 | return new T; |
125 | } | 126 | } |
126 | 127 | ||
127 | } | 128 | } |
128 | 129 | ||
129 | #endif | 130 | #endif |
diff --git a/libopie2/opiepim/core/otimezone.cpp b/libopie2/opiepim/core/otimezone.cpp index dab68af..e67715f 100644 --- a/libopie2/opiepim/core/otimezone.cpp +++ b/libopie2/opiepim/core/otimezone.cpp | |||
@@ -1,146 +1,188 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "otimezone.h" | ||
31 | |||
32 | /* STD */ | ||
30 | #include <stdio.h> | 33 | #include <stdio.h> |
31 | #include <stdlib.h> | 34 | #include <stdlib.h> |
32 | |||
33 | #include <sys/types.h> | 35 | #include <sys/types.h> |
34 | 36 | ||
35 | #include <opie2/otimezone.h> | 37 | namespace Opie |
36 | 38 | { | |
37 | namespace Opie { | ||
38 | 39 | ||
39 | QDateTime utcTime( time_t t) { | 40 | QDateTime utcTime( time_t t ) |
40 | tm* broken = ::gmtime( &t ); | 41 | { |
41 | QDateTime ret; | 42 | tm * broken = ::gmtime( &t ); |
42 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); | 43 | QDateTime ret; |
43 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); | 44 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); |
44 | return ret; | 45 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); |
45 | } | 46 | return ret; |
46 | QDateTime utcTime( time_t t, const QString& zone) { | 47 | } |
47 | QCString org = ::getenv( "TZ" ); | 48 | QDateTime utcTime( time_t t, const QString& zone ) |
49 | { | ||
50 | QCString org = ::getenv( "TZ" ); | ||
48 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac | 51 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac |
49 | ::setenv( "TZ", zone.latin1(), true ); | ||
50 | ::tzset(); | ||
51 | 52 | ||
52 | tm* broken = ::localtime( &t ); | 53 | ::setenv( "TZ", zone.latin1(), true ); |
53 | ::setenv( "TZ", org, true ); | 54 | ::tzset(); |
55 | |||
56 | tm* broken = ::localtime( &t ); | ||
57 | ::setenv( "TZ", org, true ); | ||
54 | #else | 58 | #else |
55 | #warning "Need a replacement for MacOSX!!" | 59 | #warning "Need a replacement for MacOSX!!" |
56 | tm* broken = ::localtime( &t ); | 60 | |
61 | tm* broken = ::localtime( &t ); | ||
57 | #endif | 62 | #endif |
58 | 63 | ||
59 | QDateTime ret; | 64 | QDateTime ret; |
60 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); | 65 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); |
61 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); | 66 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); |
62 | 67 | ||
63 | return ret; | 68 | return ret; |
64 | } | 69 | } |
65 | time_t to_Time_t( const QDateTime& utc, const QString& str ) { | 70 | time_t to_Time_t( const QDateTime& utc, const QString& str ) |
66 | QDate d = utc.date(); | 71 | { |
67 | QTime t = utc.time(); | 72 | QDate d = utc.date(); |
68 | 73 | QTime t = utc.time(); | |
69 | tm broken; | 74 | |
70 | broken.tm_year = d.year() - 1900; | 75 | tm broken; |
71 | broken.tm_mon = d.month() - 1; | 76 | broken.tm_year = d.year() - 1900; |
72 | broken.tm_mday = d.day(); | 77 | broken.tm_mon = d.month() - 1; |
73 | broken.tm_hour = t.hour(); | 78 | broken.tm_mday = d.day(); |
74 | broken.tm_min = t.minute(); | 79 | broken.tm_hour = t.hour(); |
75 | broken.tm_sec = t.second(); | 80 | broken.tm_min = t.minute(); |
76 | 81 | broken.tm_sec = t.second(); | |
77 | QCString org = ::getenv( "TZ" ); | 82 | |
83 | QCString org = ::getenv( "TZ" ); | ||
78 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac | 84 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac |
79 | ::setenv( "TZ", str.latin1(), true ); | ||
80 | ::tzset(); | ||
81 | 85 | ||
82 | time_t ti = ::mktime( &broken ); | 86 | ::setenv( "TZ", str.latin1(), true ); |
83 | ::setenv( "TZ", org, true ); | 87 | ::tzset(); |
88 | |||
89 | time_t ti = ::mktime( &broken ); | ||
90 | ::setenv( "TZ", org, true ); | ||
84 | #else | 91 | #else |
85 | #warning "Need a replacement for MacOSX!!" | 92 | #warning "Need a replacement for MacOSX!!" |
86 | time_t ti = ::mktime( &broken ); | 93 | |
94 | time_t ti = ::mktime( &broken ); | ||
87 | #endif | 95 | #endif |
88 | return ti; | ||
89 | } | ||
90 | } | ||
91 | 96 | ||
92 | namespace Opie { | 97 | return ti; |
93 | OTimeZone::OTimeZone( const ZoneName& zone ) | ||
94 | : m_name(zone) { | ||
95 | } | 98 | } |
96 | OTimeZone::~OTimeZone() { | ||
97 | } | 99 | } |
98 | 100 | ||
99 | bool OTimeZone::isValid()const { | 101 | namespace Opie |
102 | { | ||
103 | OTimeZone::OTimeZone( const ZoneName& zone ) | ||
104 | : m_name( zone ) | ||
105 | {} | ||
106 | |||
107 | |||
108 | OTimeZone::~OTimeZone() | ||
109 | {} | ||
110 | |||
111 | |||
112 | bool OTimeZone::isValid() const | ||
113 | { | ||
100 | return !m_name.isEmpty(); | 114 | return !m_name.isEmpty(); |
101 | } | 115 | } |
102 | 116 | ||
103 | /* | 117 | /* |
104 | * we will get the current timezone | 118 | * we will get the current timezone |
105 | * and ask it to convert to the timezone date | 119 | * and ask it to convert to the timezone date |
106 | */ | 120 | */ |
107 | QDateTime OTimeZone::toLocalDateTime( const QDateTime& dt) { | 121 | QDateTime OTimeZone::toLocalDateTime( const QDateTime& dt ) |
122 | { | ||
108 | return OTimeZone::current().toDateTime( dt, *this ); | 123 | return OTimeZone::current().toDateTime( dt, *this ); |
109 | } | 124 | } |
110 | QDateTime OTimeZone::toUTCDateTime( const QDateTime& dt ) { | 125 | |
126 | |||
127 | QDateTime OTimeZone::toUTCDateTime( const QDateTime& dt ) | ||
128 | { | ||
111 | return OTimeZone::utc().toDateTime( dt, *this ); | 129 | return OTimeZone::utc().toDateTime( dt, *this ); |
112 | } | 130 | } |
113 | QDateTime OTimeZone::fromUTCDateTime( time_t t) { | 131 | |
132 | |||
133 | QDateTime OTimeZone::fromUTCDateTime( time_t t ) | ||
134 | { | ||
114 | return utcTime( t ); | 135 | return utcTime( t ); |
115 | } | 136 | } |
116 | QDateTime OTimeZone::toDateTime( time_t t) { | 137 | |
138 | |||
139 | QDateTime OTimeZone::toDateTime( time_t t ) | ||
140 | { | ||
117 | return utcTime( t, m_name ); | 141 | return utcTime( t, m_name ); |
118 | } | 142 | } |
143 | |||
144 | |||
119 | /* | 145 | /* |
120 | * convert dt to utc using zone.m_name | 146 | * convert dt to utc using zone.m_name |
121 | * convert utc -> timeZoneDT using this->m_name | 147 | * convert utc -> timeZoneDT using this->m_name |
122 | */ | 148 | */ |
123 | QDateTime OTimeZone::toDateTime( const QDateTime& dt, const OTimeZone& zone ) { | 149 | QDateTime OTimeZone::toDateTime( const QDateTime& dt, const OTimeZone& zone ) |
150 | { | ||
124 | time_t utc = to_Time_t( dt, zone.m_name ); | 151 | time_t utc = to_Time_t( dt, zone.m_name ); |
125 | qWarning("%d %s", utc, zone.m_name.latin1() ); | 152 | qWarning( "%d %s", utc, zone.m_name.latin1() ); |
126 | return utcTime( utc, m_name ); | 153 | return utcTime( utc, m_name ); |
127 | } | 154 | } |
128 | time_t OTimeZone::fromDateTime( const QDateTime& time ) { | 155 | |
156 | |||
157 | time_t OTimeZone::fromDateTime( const QDateTime& time ) | ||
158 | { | ||
129 | return to_Time_t( time, m_name ); | 159 | return to_Time_t( time, m_name ); |
130 | } | 160 | } |
131 | time_t OTimeZone::fromUTCDateTime( const QDateTime& time ) { | 161 | |
162 | |||
163 | time_t OTimeZone::fromUTCDateTime( const QDateTime& time ) | ||
164 | { | ||
132 | return to_Time_t( time, "UTC" ); | 165 | return to_Time_t( time, "UTC" ); |
133 | } | 166 | } |
134 | OTimeZone OTimeZone::current() { | 167 | |
135 | QCString str = ::getenv("TZ"); | 168 | |
169 | OTimeZone OTimeZone::current() | ||
170 | { | ||
171 | QCString str = ::getenv( "TZ" ); | ||
136 | OTimeZone zone( str ); | 172 | OTimeZone zone( str ); |
137 | return zone; | 173 | return zone; |
138 | } | 174 | } |
139 | OTimeZone OTimeZone::utc() { | 175 | |
140 | return OTimeZone("UTC"); | 176 | |
177 | OTimeZone OTimeZone::utc() | ||
178 | { | ||
179 | return OTimeZone( "UTC" ); | ||
141 | } | 180 | } |
142 | QString OTimeZone::timeZone()const { | 181 | |
182 | |||
183 | QString OTimeZone::timeZone() const | ||
184 | { | ||
143 | return m_name; | 185 | return m_name; |
144 | } | 186 | } |
145 | 187 | ||
146 | } | 188 | } |
diff --git a/libopie2/opiepim/core/otimezone.h b/libopie2/opiepim/core/otimezone.h index 28ae6cb..f0b4022 100644 --- a/libopie2/opiepim/core/otimezone.h +++ b/libopie2/opiepim/core/otimezone.h | |||
@@ -1,102 +1,107 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OPIE_TIME_ZONE_H | 30 | #ifndef OTIMEZONE_H |
31 | #define OPIE_TIME_ZONE_H | 31 | #define OTIMEZONE_H |
32 | 32 | ||
33 | #include <time.h> | 33 | /* QT */ |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | 35 | ||
36 | /* STD */ | ||
37 | #include <time.h> | ||
38 | |||
36 | namespace Opie | 39 | namespace Opie |
37 | { | 40 | { |
38 | /** | 41 | /** |
39 | * A very primitive class to convert time | 42 | * A very primitive class to convert time |
40 | * from one timezone to another | 43 | * from one timezone to another |
41 | * and to localtime | 44 | * and to localtime |
42 | * and time_t | 45 | * and time_t |
43 | */ | 46 | */ |
44 | class OTimeZone { | 47 | class OTimeZone { |
48 | |||
45 | public: | 49 | public: |
46 | typedef QString ZoneName; | 50 | typedef QString ZoneName; |
47 | OTimeZone( const ZoneName& = ZoneName::null ); | 51 | OTimeZone( const ZoneName& = ZoneName::null ); |
48 | virtual ~OTimeZone(); // just in case. | 52 | virtual ~OTimeZone(); // just in case. |
49 | 53 | ||
50 | bool isValid()const; | 54 | bool isValid()const; |
51 | 55 | ||
52 | /** | 56 | /** |
53 | * converts the QDateTime to a DateTime | 57 | * converts the QDateTime to a DateTime |
54 | * in the local timezone | 58 | * in the local timezone |
55 | * if QDateTime is 25th Jan and takes place in Europe/Berlin at 12h | 59 | * if QDateTime is 25th Jan and takes place in Europe/Berlin at 12h |
56 | * and the current timezone is Europe/London the returned | 60 | * and the current timezone is Europe/London the returned |
57 | * time will be 11h. | 61 | * time will be 11h. |
58 | */ | 62 | */ |
59 | QDateTime toLocalDateTime( const QDateTime& dt ); | 63 | QDateTime toLocalDateTime( const QDateTime& dt ); |
60 | 64 | ||
61 | /** | 65 | /** |
62 | * converts the QDateTime to UTC time | 66 | * converts the QDateTime to UTC time |
63 | */ | 67 | */ |
64 | QDateTime toUTCDateTime( const QDateTime& dt ); | 68 | QDateTime toUTCDateTime( const QDateTime& dt ); |
65 | 69 | ||
66 | /** | 70 | /** |
67 | * reads the time_t into a QDateTime using UTC as timezone! | 71 | * reads the time_t into a QDateTime using UTC as timezone! |
68 | */ | 72 | */ |
69 | QDateTime fromUTCDateTime( time_t ); | 73 | QDateTime fromUTCDateTime( time_t ); |
70 | 74 | ||
71 | /** | 75 | /** |
72 | * converts the time_t to the time in the timezone | 76 | * converts the time_t to the time in the timezone |
73 | */ | 77 | */ |
74 | QDateTime toDateTime( time_t ); | 78 | QDateTime toDateTime( time_t ); |
75 | 79 | ||
76 | /** | 80 | /** |
77 | * converts the QDateTime from one timezone to this timeZone | 81 | * converts the QDateTime from one timezone to this timeZone |
78 | */ | 82 | */ |
79 | QDateTime toDateTime( const QDateTime&, const OTimeZone& timeZone ); | 83 | QDateTime toDateTime( const QDateTime&, const OTimeZone& timeZone ); |
80 | 84 | ||
81 | /** | 85 | /** |
82 | * converts the date time into a time_t. It takes the timezone into account | 86 | * converts the date time into a time_t. It takes the timezone into account |
83 | */ | 87 | */ |
84 | time_t fromDateTime( const QDateTime& ); | 88 | time_t fromDateTime( const QDateTime& ); |
85 | 89 | ||
86 | /** | 90 | /** |
87 | * converts the datetime with timezone UTC | 91 | * converts the datetime with timezone UTC |
88 | */ | 92 | */ |
89 | time_t fromUTCDateTime( const QDateTime& ); | 93 | time_t fromUTCDateTime( const QDateTime& ); |
90 | 94 | ||
91 | static OTimeZone current(); | 95 | static OTimeZone current(); |
92 | static OTimeZone utc(); | 96 | static OTimeZone utc(); |
93 | 97 | ||
94 | QString timeZone()const; | 98 | QString timeZone() const; |
99 | |||
95 | private: | 100 | private: |
96 | ZoneName m_name; | 101 | ZoneName m_name; |
97 | class Private; | 102 | class Private; |
98 | Private* d; | 103 | Private* d; |
99 | }; | 104 | }; |
100 | }; | 105 | }; |
101 | 106 | ||
102 | #endif | 107 | #endif |
diff --git a/libopie2/opieui/otabwidget.h b/libopie2/opieui/otabwidget.h index 51d1c6d..c7d32c2 100644 --- a/libopie2/opieui/otabwidget.h +++ b/libopie2/opieui/otabwidget.h | |||
@@ -1,295 +1,293 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | Copyright (C) 2002 Dan Williams <williamsdr@acm.org> | |
4 | Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | ||
5 | =. | 4 | =. |
6 | .=l. | 5 | .=l. |
7 | .>+-= | 6 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 13 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 21 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
29 | 28 | ||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #ifndef OTABWIDGET_H | 31 | #ifndef OTABWIDGET_H |
33 | #define OTABWIDGET_H | 32 | #define OTABWIDGET_H |
34 | 33 | ||
35 | /* OPIE */ | 34 | /* OPIE */ |
36 | #include <opie2/otabinfo.h> | 35 | #include <opie2/otabinfo.h> |
37 | 36 | ||
38 | /* QT */ | 37 | /* QT */ |
39 | #include <qwidget.h> | 38 | #include <qwidget.h> |
40 | #include <qlist.h> | 39 | #include <qlist.h> |
41 | 40 | ||
42 | using namespace Opie; | 41 | using namespace Opie; |
43 | 42 | ||
44 | class QComboBox; | 43 | class QComboBox; |
45 | class QPixmap; | 44 | class QPixmap; |
46 | class QTabBar; | 45 | class QTabBar; |
47 | class QWidgetStack; | 46 | class QWidgetStack; |
48 | 47 | ||
49 | namespace Opie | 48 | namespace Opie |
50 | { | 49 | { |
51 | 50 | ||
52 | class OTabBar; | 51 | class OTabBar; |
53 | 52 | ||
54 | /** | 53 | /** |
55 | * @class OTabWidget | 54 | * @class OTabWidget |
56 | * @brief The OTabWidget class provides a stack of widgets. | 55 | * @brief The OTabWidget class provides a stack of widgets. |
57 | * | 56 | * |
58 | * OTabWidget is a derivation of TrollTech's QTabWidget which provides | 57 | * OTabWidget is a derivation of TrollTech's QTabWidget which provides |
59 | * a stack of widgets. Widgets can be selected using either a tab bar or | 58 | * a stack of widgets. Widgets can be selected using either a tab bar or |
60 | * drop down list box. | 59 | * drop down list box. |
61 | * | 60 | * |
62 | * The normal way to use OTabWidget is to do the following in the | 61 | * The normal way to use OTabWidget is to do the following in the |
63 | * constructor: | 62 | * constructor: |
64 | * - Create a OTabWidget. | 63 | * - Create a OTabWidget. |
65 | * - Create a QWidget for each of the pages in the control, insert | 64 | * - Create a QWidget for each of the pages in the control, insert |
66 | * children into it, set up geometry management for it, and use addTab() | 65 | * children into it, set up geometry management for it, and use addTab() |
67 | * to add the widget. | 66 | * to add the widget. |
68 | */ | 67 | */ |
69 | class OTabWidget : public QWidget | 68 | class OTabWidget : public QWidget |
70 | { | 69 | { |
71 | Q_OBJECT | 70 | Q_OBJECT |
72 | public: | 71 | |
73 | 72 | public: | |
74 | /** | 73 | /** |
75 | * @enum TabStyle | 74 | * @enum TabStyle |
76 | * @brief Defines how the widget selection control is displayed. | 75 | * @brief Defines how the widget selection control is displayed. |
77 | * | 76 | * |
78 | * Valid values: | 77 | * Valid values: |
79 | * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition) | 78 | * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition) |
80 | * - TextTab: Tabbed widget selection with text labels | 79 | * - TextTab: Tabbed widget selection with text labels |
81 | * - IconTab: Tabbed widget selection with icon labels, text label for active widget | 80 | * - IconTab: Tabbed widget selection with icon labels, text label for active widget |
82 | * (similar to Opie launcher) | 81 | * (similar to Opie launcher) |
83 | * - TextList: Drop down list widget selection with text labels | 82 | * - TextList: Drop down list widget selection with text labels |
84 | * - IconList: Drop down list widget selection with icon & text labels | 83 | * - IconList: Drop down list widget selection with icon & text labels |
85 | */ | 84 | */ |
86 | enum TabStyle { Global, TextTab, IconTab, TextList, IconList }; | 85 | enum TabStyle { Global, TextTab, IconTab, TextList, IconList }; |
87 | 86 | ||
88 | /** | 87 | /** |
89 | * @enum TabPosition | 88 | * @enum TabPosition |
90 | * @brief Defines where the widget selection control is drawn. | 89 | * @brief Defines where the widget selection control is drawn. |
91 | * | 90 | * |
92 | * Valid values: | 91 | * Valid values: |
93 | * - Top: Widget selection control is drawn above widgets | 92 | * - Top: Widget selection control is drawn above widgets |
94 | * - Bottom: Widget selection control is drawn below widgets | 93 | * - Bottom: Widget selection control is drawn below widgets |
95 | */ | 94 | */ |
96 | enum TabPosition { Top, Bottom }; | 95 | enum TabPosition { Top, Bottom }; |
97 | 96 | ||
98 | /** | 97 | /** |
99 | * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top ) | 98 | * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top ) |
100 | * @brief Object constructor. | 99 | * @brief Object constructor. |
101 | * | 100 | * |
102 | * @param parent Pointer to parent of this control. | 101 | * @param parent Pointer to parent of this control. |
103 | * @param name Name of control. | 102 | * @param name Name of control. |
104 | * @param s Style of widget selection control. | 103 | * @param s Style of widget selection control. |
105 | * @param p Position of the widget selection control. | 104 | * @param p Position of the widget selection control. |
106 | * | 105 | * |
107 | * Constructs a new OTabWidget control with parent and name. The style and position parameters | 106 | * Constructs a new OTabWidget control with parent and name. The style and position parameters |
108 | * determine how the widget selection control will be displayed. | 107 | * determine how the widget selection control will be displayed. |
109 | */ | 108 | */ |
110 | // FIXME WFlags? -zecke | ||
111 | OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); | 109 | OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); |
112 | 110 | ||
113 | /** | 111 | /** |
114 | * @fn ~OTabWidget() | 112 | * @fn ~OTabWidget() |
115 | * @brief Object destructor. | 113 | * @brief Object destructor. |
116 | */ | 114 | */ |
117 | ~OTabWidget(); | 115 | ~OTabWidget(); |
118 | 116 | ||
119 | /** | 117 | /** |
120 | * @fn addTab( QWidget *child, const QString &icon, const QString &label ) | 118 | * @fn addTab( QWidget *child, const QString &icon, const QString &label ) |
121 | * @brief Add new widget to control. | 119 | * @brief Add new widget to control. |
122 | * | 120 | * |
123 | * @param child Widget control. | 121 | * @param child Widget control. |
124 | * @param icon Path to icon. | 122 | * @param icon Path to icon. |
125 | * @param label Text label. | 123 | * @param label Text label. |
126 | */ | 124 | */ |
127 | void addTab( QWidget *, const QString &, const QString & ); | 125 | void addTab( QWidget *, const QString &, const QString & ); |
128 | 126 | ||
129 | /** | 127 | /** |
130 | * @fn removePage( QWidget *widget ) | 128 | * @fn removePage( QWidget *widget ) |
131 | * @brief Remove widget from control. Does not delete widget. | 129 | * @brief Remove widget from control. Does not delete widget. |
132 | * | 130 | * |
133 | * @param widget Widget control to be removed. | 131 | * @param widget Widget control to be removed. |
134 | */ | 132 | */ |
135 | /* ### Page vs. Tab.. yes the widget is a Page but then is addTab wrong -zecke */ | 133 | /* ### Page vs. Tab.. yes the widget is a Page but then is addTab wrong -zecke */ |
136 | void removePage( QWidget * ); | 134 | void removePage( QWidget * ); |
137 | 135 | ||
138 | /** | 136 | /** |
139 | * @fn changeTab( QWidget *widget, const QString &icon, const QString &label ) | 137 | * @fn changeTab( QWidget *widget, const QString &icon, const QString &label ) |
140 | * @brief Change text and/or icon for existing tab | 138 | * @brief Change text and/or icon for existing tab |
141 | * | 139 | * |
142 | * @param child Widget control. | 140 | * @param child Widget control. |
143 | * @param icon Path to icon. | 141 | * @param icon Path to icon. |
144 | * @param label Text label. | 142 | * @param label Text label. |
145 | */ | 143 | */ |
146 | void changeTab( QWidget *, const QString &, const QString & ); | 144 | void changeTab( QWidget *, const QString &, const QString & ); |
147 | 145 | ||
148 | /** | 146 | /** |
149 | * @fn tabStyle()const | 147 | * @fn tabStyle()const |
150 | * @brief Returns current widget selection control style. | 148 | * @brief Returns current widget selection control style. |
151 | */ | 149 | */ |
152 | TabStyle tabStyle() const; | 150 | TabStyle tabStyle() const; |
153 | 151 | ||
154 | /** | 152 | /** |
155 | * @fn setTabStyle( TabStyle s ) | 153 | * @fn setTabStyle( TabStyle s ) |
156 | * @brief Set the current widget selection control style. | 154 | * @brief Set the current widget selection control style. |
157 | * | 155 | * |
158 | * @param s New style to be used. | 156 | * @param s New style to be used. |
159 | */ | 157 | */ |
160 | void setTabStyle( TabStyle ); | 158 | void setTabStyle( TabStyle ); |
161 | 159 | ||
162 | /** | 160 | /** |
163 | * @fn tabPosition()const | 161 | * @fn tabPosition()const |
164 | * @brief Returns current widget selection control position. | 162 | * @brief Returns current widget selection control position. |
165 | */ | 163 | */ |
166 | TabPosition tabPosition() const; | 164 | TabPosition tabPosition() const; |
167 | 165 | ||
168 | /** | 166 | /** |
169 | * @fn setTabPosition( TabPosition p ) | 167 | * @fn setTabPosition( TabPosition p ) |
170 | * @brief Set the current widget selection control position. | 168 | * @brief Set the current widget selection control position. |
171 | * | 169 | * |
172 | * @param p New position of widget selection control. | 170 | * @param p New position of widget selection control. |
173 | */ | 171 | */ |
174 | void setTabPosition( TabPosition ); | 172 | void setTabPosition( TabPosition ); |
175 | 173 | ||
176 | /** | 174 | /** |
177 | * @fn setCurrentTab( QWidget *childwidget ) | 175 | * @fn setCurrentTab( QWidget *childwidget ) |
178 | * @brief Selects and brings to top the desired widget by using widget pointer. | 176 | * @brief Selects and brings to top the desired widget by using widget pointer. |
179 | * | 177 | * |
180 | * @param childwidget Widget to select. | 178 | * @param childwidget Widget to select. |
181 | */ | 179 | */ |
182 | void setCurrentTab( QWidget * ); | 180 | void setCurrentTab( QWidget * ); |
183 | 181 | ||
184 | /** | 182 | /** |
185 | * @fn setCurrentTab( const QString &tabname ) | 183 | * @fn setCurrentTab( const QString &tabname ) |
186 | * @brief Selects and brings to top the desired widget, by using label. | 184 | * @brief Selects and brings to top the desired widget, by using label. |
187 | * | 185 | * |
188 | * @param tabname Text label for widget to select. | 186 | * @param tabname Text label for widget to select. |
189 | */ | 187 | */ |
190 | void setCurrentTab( const QString & ); | 188 | void setCurrentTab( const QString & ); |
191 | 189 | ||
192 | /** | 190 | /** |
193 | * @fn setCurrentTab( int ) | 191 | * @fn setCurrentTab( int ) |
194 | * @brief Selects and brings to top the desired widget, by using id. | 192 | * @brief Selects and brings to top the desired widget, by using id. |
195 | * | 193 | * |
196 | * @param tab id for widget to select. | 194 | * @param tab id for widget to select. |
197 | */ | 195 | */ |
198 | void setCurrentTab(int); | 196 | void setCurrentTab(int); |
199 | 197 | ||
200 | /** | 198 | /** |
201 | * @fn sizeHint()const | 199 | * @fn sizeHint()const |
202 | * @brief Reimplemented for internal purposes. | 200 | * @brief Reimplemented for internal purposes. |
203 | */ | 201 | */ |
204 | QSize sizeHint() const; | 202 | QSize sizeHint() const; |
205 | 203 | ||
206 | /** | 204 | /** |
207 | * @fn currentTab( ) | 205 | * @fn currentTab( ) |
208 | * @brief returns current tab id. | 206 | * @brief returns current tab id. |
209 | */ | 207 | */ |
210 | // ### make const | 208 | // ### make const |
211 | int currentTab()/* const */; | 209 | int currentTab()/* const */; |
212 | /** | 210 | /** |
213 | * @brief returns the current page of the active tab | 211 | * @brief returns the current page of the active tab |
214 | * | 212 | * |
215 | * @since 1.2 | 213 | * @since 1.2 |
216 | */ | 214 | */ |
217 | QWidget* currentWidget()const; | 215 | QWidget* currentWidget()const; |
218 | 216 | ||
219 | protected: | 217 | protected: |
220 | 218 | ||
221 | /** | 219 | /** |
222 | * @fn resizeEvent( QResizeEvent * ) | 220 | * @fn resizeEvent( QResizeEvent * ) |
223 | * @brief Reimplemented for internal purposes. | 221 | * @brief Reimplemented for internal purposes. |
224 | */ | 222 | */ |
225 | void resizeEvent( QResizeEvent * ); | 223 | void resizeEvent( QResizeEvent * ); |
226 | 224 | ||
227 | private: | 225 | private: |
228 | OTabInfoList tabs; | 226 | OTabInfoList tabs; |
229 | OTabInfo *currTab; | 227 | OTabInfo *currTab; |
230 | 228 | ||
231 | TabStyle tabBarStyle; | 229 | TabStyle tabBarStyle; |
232 | TabPosition tabBarPosition; | 230 | TabPosition tabBarPosition; |
233 | 231 | ||
234 | QWidgetStack *tabBarStack; | 232 | QWidgetStack *tabBarStack; |
235 | OTabBar *tabBar; | 233 | OTabBar *tabBar; |
236 | QComboBox *tabList; | 234 | QComboBox *tabList; |
237 | 235 | ||
238 | QWidgetStack *widgetStack; | 236 | QWidgetStack *widgetStack; |
239 | class Private; | 237 | class Private; |
240 | Private* d; | 238 | Private* d; |
241 | 239 | ||
242 | /** | 240 | /** |
243 | * @fn loadSmooth( const QString &name ) | 241 | * @fn loadSmooth( const QString &name ) |
244 | * @brief Loads icon for widget. | 242 | * @brief Loads icon for widget. |
245 | * | 243 | * |
246 | * @param name Name of icon image file. | 244 | * @param name Name of icon image file. |
247 | */ | 245 | */ |
248 | QPixmap loadSmooth( const QString & ); | 246 | QPixmap loadSmooth( const QString & ); |
249 | 247 | ||
250 | /** | 248 | /** |
251 | * @fn selectTab( OTabInfo *tab ) | 249 | * @fn selectTab( OTabInfo *tab ) |
252 | * @brief Internal function to select desired widget. | 250 | * @brief Internal function to select desired widget. |
253 | * | 251 | * |
254 | * @param tab Pointer to data for widget. | 252 | * @param tab Pointer to data for widget. |
255 | */ | 253 | */ |
256 | void selectTab( OTabInfo * ); | 254 | void selectTab( OTabInfo * ); |
257 | 255 | ||
258 | /** | 256 | /** |
259 | * @fn setUpLayout() | 257 | * @fn setUpLayout() |
260 | * @brief Internal function to adjust layout. | 258 | * @brief Internal function to adjust layout. |
261 | */ | 259 | */ |
262 | void setUpLayout(); | 260 | void setUpLayout(); |
263 | 261 | ||
264 | 262 | ||
265 | signals: | 263 | signals: |
266 | /** | 264 | /** |
267 | * @fn currentChanegd( QWidget *widget ) | 265 | * @fn currentChanegd( QWidget *widget ) |
268 | * @brief This signal is emitted whenever the widget has changed. | 266 | * @brief This signal is emitted whenever the widget has changed. |
269 | * | 267 | * |
270 | * @param widget Pointer to new current widget. | 268 | * @param widget Pointer to new current widget. |
271 | */ | 269 | */ |
272 | void currentChanged( QWidget * ); | 270 | void currentChanged( QWidget * ); |
273 | 271 | ||
274 | private slots: | 272 | private slots: |
275 | 273 | ||
276 | /** | 274 | /** |
277 | * @fn slotTabBarSelected( int id ) | 275 | * @fn slotTabBarSelected( int id ) |
278 | * @brief Slot which is called when a tab is selected. | 276 | * @brief Slot which is called when a tab is selected. |
279 | * | 277 | * |
280 | * @param id ID of widget selected. | 278 | * @param id ID of widget selected. |
281 | */ | 279 | */ |
282 | void slotTabBarSelected( int ); | 280 | void slotTabBarSelected( int ); |
283 | 281 | ||
284 | /** | 282 | /** |
285 | * @fn slotTabListSelected( int index ) | 283 | * @fn slotTabListSelected( int index ) |
286 | * @brief Slot which is called when a drop down selection is made. | 284 | * @brief Slot which is called when a drop down selection is made. |
287 | * | 285 | * |
288 | * @param id Index of widget selected. | 286 | * @param id Index of widget selected. |
289 | */ | 287 | */ |
290 | void slotTabListSelected( int ); | 288 | void slotTabListSelected( int ); |
291 | }; | 289 | }; |
292 | 290 | ||
293 | }; | 291 | }; |
294 | 292 | ||
295 | #endif | 293 | #endif |
diff --git a/libopie2/opieui/owait.cpp b/libopie2/opieui/owait.cpp index 0fdf08d..8bb4ed6 100644 --- a/libopie2/opieui/owait.cpp +++ b/libopie2/opieui/owait.cpp | |||
@@ -1,93 +1,110 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* |
2 | Copyright (C) 2003 Maximilian Reiss (harlekin@handhelds.org) | 2 | This file is part of the Opie Project |
3 | 3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> | |
4 | This library is free software; you can redistribute it and/or | 4 | =. |
5 | modify it under the terms of the GNU Library General Public | 5 | .=l. |
6 | License as published by the Free Software Foundation; either | 6 | .>+-= |
7 | version 2 of the License, or (at your option) any later version. | 7 | _;:, .> :=|. This program is free software; you can |
8 | 8 | .> <`_, > . <= redistribute it and/or modify it under | |
9 | This library is distributed in the hope that it will be useful, | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | Library General Public License for more details. | 12 | ._= =} : or (at your option) any later version. |
13 | 13 | .%`+i> _;_. | |
14 | You should have received a copy of the GNU Library General Public License | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | : .. .:, . . . without even the implied warranty of |
17 | Boston, MA 02111-1307, USA. | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | */ | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
19 | 28 | ||
20 | #include <qlabel.h> | 29 | */ |
21 | #include <qlayout.h> | ||
22 | #include <qtimer.h> | ||
23 | #include <qpe/qpeapplication.h> | ||
24 | #include <qpainter.h> | ||
25 | 30 | ||
26 | #include "owait.h" | 31 | #include "owait.h" |
27 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <qpe/qpeapplication.h> | ||
28 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
29 | 36 | ||
37 | /* QT */ | ||
38 | #include <qlayout.h> | ||
39 | #include <qpainter.h> | ||
40 | |||
30 | static int frame = 0; | 41 | static int frame = 0; |
31 | 42 | ||
32 | /** | 43 | /** |
33 | * This will construct a modal dialog. | 44 | * This will construct a modal dialog. |
34 | * | 45 | * |
35 | * The default timer length is 10. | 46 | * The default timer length is 10. |
36 | * | 47 | * |
37 | * @param parent The parent of the widget | 48 | * @param parent The parent of the widget |
38 | * @param msg The name of the object | 49 | * @param msg The name of the object |
39 | * @param dispIcon Display Icon? | 50 | * @param dispIcon Display Icon? |
40 | */ | 51 | */ |
41 | OWait::OWait(QWidget *parent, const char* msg, bool dispIcon ) | 52 | OWait::OWait( QWidget *parent, const char* msg, bool dispIcon ) |
42 | :QDialog(parent, msg, TRUE,WStyle_Customize) { | 53 | :QDialog( parent, msg, TRUE, WStyle_Customize ) |
54 | { | ||
43 | 55 | ||
44 | 56 | ||
45 | QHBoxLayout *hbox = new QHBoxLayout( this ); | 57 | QHBoxLayout * hbox = new QHBoxLayout( this ); |
46 | 58 | ||
47 | m_lb = new QLabel( this ); | 59 | m_lb = new QLabel( this ); |
48 | m_lb->setBackgroundMode ( NoBackground ); | 60 | m_lb->setBackgroundMode ( NoBackground ); |
49 | 61 | ||
50 | hbox->addWidget( m_lb ); | 62 | hbox->addWidget( m_lb ); |
51 | hbox->activate(); | 63 | hbox->activate(); |
52 | 64 | ||
53 | m_pix = Resource::loadPixmap( "BigBusy" ); | 65 | m_pix = Resource::loadPixmap( "BigBusy" ); |
54 | m_aniSize = m_pix.height(); | 66 | m_aniSize = m_pix.height(); |
55 | resize( m_aniSize, m_aniSize ); | 67 | resize( m_aniSize, m_aniSize ); |
56 | 68 | ||
57 | m_timerLength = 10; | 69 | m_timerLength = 10; |
58 | 70 | ||
59 | m_waitTimer = new QTimer( this ); | 71 | m_waitTimer = new QTimer( this ); |
60 | connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) ); | 72 | connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) ); |
61 | } | 73 | } |
62 | 74 | ||
63 | void OWait::timerEvent( QTimerEvent * ) { | 75 | void OWait::timerEvent( QTimerEvent * ) |
64 | frame = (++frame) % 4; | 76 | { |
77 | frame = ( ++frame ) % 4; | ||
65 | repaint(); | 78 | repaint(); |
66 | } | 79 | } |
67 | 80 | ||
68 | void OWait::paintEvent( QPaintEvent * ) { | 81 | void OWait::paintEvent( QPaintEvent * ) |
69 | QPainter p( m_lb ); | 82 | { |
70 | p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize ); | 83 | QPainter p( m_lb ); |
84 | p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize ); | ||
71 | } | 85 | } |
72 | 86 | ||
73 | void OWait::show() { | 87 | void OWait::show() |
88 | { | ||
74 | 89 | ||
75 | move( ( ( qApp->desktop()->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop()->height() ) / 2 ) - ( m_aniSize / 2 ) ); | 90 | move( ( ( qApp->desktop() ->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop() ->height() ) / 2 ) - ( m_aniSize / 2 ) ); |
76 | startTimer( 300 ); | 91 | startTimer( 300 ); |
77 | m_waitTimer->start( m_timerLength * 1000, true ); | 92 | m_waitTimer->start( m_timerLength * 1000, true ); |
78 | QDialog::show(); | 93 | QDialog::show(); |
79 | } | 94 | } |
80 | 95 | ||
81 | void OWait::hide() { | 96 | void OWait::hide() |
97 | { | ||
82 | killTimers(); | 98 | killTimers(); |
83 | m_waitTimer->stop(); | 99 | m_waitTimer->stop(); |
84 | frame = 0; | 100 | frame = 0; |
85 | QDialog::hide(); | 101 | QDialog::hide(); |
86 | } | 102 | } |
87 | 103 | ||
88 | void OWait::setTimerLength( int length ) { | 104 | void OWait::setTimerLength( int length ) |
105 | { | ||
89 | m_timerLength = length; | 106 | m_timerLength = length; |
90 | } | 107 | } |
91 | 108 | ||
92 | OWait::~OWait() { | 109 | OWait::~OWait() |
93 | } | 110 | {} |
diff --git a/libopie2/opieui/owait.h b/libopie2/opieui/owait.h index cbfc8d6..3267064 100644 --- a/libopie2/opieui/owait.h +++ b/libopie2/opieui/owait.h | |||
@@ -1,77 +1,86 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* |
2 | Copyright (C) 2003 Maximilian Reiss (harlekin@handhelds.org) | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> | ||
4 | =. | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
3 | 28 | ||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | ||
13 | |||
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 | ||
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | 29 | */ |
19 | 30 | ||
31 | #ifndef OWAIT_H | ||
32 | #define OWAIT_H | ||
20 | 33 | ||
21 | 34 | /* QT */ | |
22 | #ifndef WAITPOPUP_H | ||
23 | #define WAITPOPUP_H | ||
24 | |||
25 | #include <qdialog.h> | 35 | #include <qdialog.h> |
26 | #include <qpixmap.h> | ||
27 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qpixmap.h> | ||
28 | #include <qtimer.h> | 38 | #include <qtimer.h> |
29 | 39 | ||
30 | /** | 40 | /** |
31 | * This class displays a animated waiting icon in the middle of the screen. | 41 | * This class displays a animated waiting icon in the middle of the screen. |
32 | * | 42 | * |
33 | * @short modal hour glass dialog | 43 | * @short modal hour glass dialog |
34 | * @see QDialog | 44 | * @see QDialog |
35 | * @author Maximilian Reiß | 45 | * @author Maximilian Reiß |
36 | */ | 46 | */ |
37 | class OWait : public QDialog { | 47 | class OWait : public QDialog |
38 | 48 | { | |
39 | Q_OBJECT | 49 | Q_OBJECT |
40 | 50 | ||
41 | public: | 51 | public: |
42 | // FIXME Wflags -zecke? | 52 | OWait( QWidget *parent = 0, const char* name = 0, bool dispIcon = TRUE ); |
43 | OWait(QWidget *parent=0,const char* name=0, bool dispIcon=TRUE); | ||
44 | ~OWait(); | 53 | ~OWait(); |
45 | 54 | ||
46 | /** | 55 | /** |
47 | * reimplemented for control reasons | 56 | * reimplemented for control reasons |
48 | */ | 57 | */ |
49 | void show(); | 58 | void show(); |
50 | 59 | ||
51 | /** | 60 | /** |
52 | * Set the time before the icon will be automaticly hidden | 61 | * Set the time before the icon will be automaticly hidden |
53 | * The timer will be started once the widget will be shown. | 62 | * The timer will be started once the widget will be shown. |
54 | * @param length - time in seconds | 63 | * @param length - time in seconds |
55 | */ | 64 | */ |
56 | void setTimerLength( int length ); | 65 | void setTimerLength( int length ); |
57 | 66 | ||
58 | public slots: | 67 | public slots: |
59 | /** | 68 | /** |
60 | * reimplemented for control reasons | 69 | * reimplemented for control reasons |
61 | */ | 70 | */ |
62 | void hide(); | 71 | void hide(); |
63 | 72 | ||
64 | private: | 73 | private: |
65 | void timerEvent( QTimerEvent * ) ; | 74 | void timerEvent( QTimerEvent * ); |
66 | void paintEvent( QPaintEvent * ); | 75 | void paintEvent( QPaintEvent * ); |
67 | 76 | ||
68 | QPixmap m_pix; | 77 | QPixmap m_pix; |
69 | QLabel *m_lb; | 78 | QLabel *m_lb; |
70 | QTimer *m_waitTimer; | 79 | QTimer *m_waitTimer; |
71 | int m_timerLength; | 80 | int m_timerLength; |
72 | int m_aniSize; | 81 | int m_aniSize; |
73 | class Private; | 82 | class Private; |
74 | Private *d; | 83 | Private *d; |
75 | }; | 84 | }; |
76 | 85 | ||
77 | #endif | 86 | #endif |