author | chicken <chicken> | 2004-03-01 15:58:07 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-01 15:58:07 (UTC) |
commit | 931c55406a043195712955c732a875e17899df90 (patch) (unidiff) | |
tree | 8097c88ee3e96f8fb613ccca1ebf36bf73070dcc | |
parent | 87676b131aad1bfe979570a48107527db4040020 (diff) | |
download | opie-931c55406a043195712955c732a875e17899df90.zip opie-931c55406a043195712955c732a875e17899df90.tar.gz opie-931c55406a043195712955c732a875e17899df90.tar.bz2 |
fix includes
25 files changed, 1 insertions, 67 deletions
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp index 4505ce7..a40ef53 100644 --- a/libopie2/opiecore/odebug.cpp +++ b/libopie2/opiecore/odebug.cpp | |||
@@ -1,255 +1,244 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) | 3 | (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) |
4 | (C) 2002 Holger Freyther (freyther@kde.org) | 4 | (C) 2002 Holger Freyther (freyther@kde.org) |
5 | (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) | 5 | (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) |
6 | =. | 6 | =. |
7 | .=l. | 7 | .=l. |
8 | .>+-= | 8 | .>+-= |
9 | _;:, .> :=|. This program is free software; you can | 9 | _;:, .> :=|. This program is free software; you can |
10 | .> <`_, > . <= redistribute it and/or modify it under | 10 | .> <`_, > . <= redistribute it and/or modify it under |
11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
12 | .="- .-=="i, .._ License as published by the Free Software | 12 | .="- .-=="i, .._ License as published by the Free Software |
13 | - . .-<_> .<> Foundation; either version 2 of the License, | 13 | - . .-<_> .<> Foundation; either version 2 of the License, |
14 | ._= =} : or (at your option) any later version. | 14 | ._= =} : or (at your option) any later version. |
15 | .%`+i> _;_. | 15 | .%`+i> _;_. |
16 | .i_,=:_. -<s. This program is distributed in the hope that | 16 | .i_,=:_. -<s. This program is distributed in the hope that |
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
18 | : .. .:, . . . without even the implied warranty of | 18 | : .. .:, . . . without even the implied warranty of |
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
21 | ..}^=.= = ; Library General Public License for more | 21 | ..}^=.= = ; Library General Public License for more |
22 | ++= -. .` .: details. | 22 | ++= -. .` .: details. |
23 | : = ...= . :.=- | 23 | : = ...= . :.=- |
24 | -. .:....=;==+<; You should have received a copy of the GNU | 24 | -. .:....=;==+<; You should have received a copy of the GNU |
25 | -_. . . )=. = Library General Public License along with | 25 | -_. . . )=. = Library General Public License along with |
26 | -- :-=` this library; see the file COPYING.LIB. | 26 | -- :-=` this library; see the file COPYING.LIB. |
27 | If not, write to the Free Software Foundation, | 27 | If not, write to the Free Software Foundation, |
28 | Inc., 59 Temple Place - Suite 330, | 28 | Inc., 59 Temple Place - Suite 330, |
29 | Boston, MA 02111-1307, USA. | 29 | Boston, MA 02111-1307, USA. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | // Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo | 32 | // Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo |
33 | // functions inlined to noops (which would then conflict with their definition here). | 33 | // functions inlined to noops (which would then conflict with their definition here). |
34 | 34 | ||
35 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
36 | 36 | ||
37 | #ifdef OPIE_NO_DEBUG | 37 | #ifdef OPIE_NO_DEBUG |
38 | #undef odDebug | 38 | #undef odDebug |
39 | #undef odBacktrace | 39 | #undef odBacktrace |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | /* OPIE */ | 42 | /* OPIE */ |
43 | 43 | ||
44 | #include <opie2/oapplication.h> | 44 | #include <opie2/oapplication.h> |
45 | #include <opie2/oglobalsettings.h> | 45 | #include <opie2/oglobalsettings.h> |
46 | #include <opie2/oconfig.h> | 46 | #include <opie2/oconfig.h> |
47 | 47 | ||
48 | /* QT */ | 48 | /* QT */ |
49 | 49 | ||
50 | #include <qbrush.h> | ||
51 | #include <qdatetime.h> | ||
52 | #include <qfile.h> | 50 | #include <qfile.h> |
53 | #include <qhostaddress.h> | ||
54 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
55 | #include <qintdict.h> | ||
56 | #include <qpoint.h> | ||
57 | #include <qrect.h> | ||
58 | #include <qregion.h> | ||
59 | #include <qsize.h> | ||
60 | #include <qsocketdevice.h> | 52 | #include <qsocketdevice.h> |
61 | #include <qstring.h> | ||
62 | #include <qstringlist.h> | ||
63 | #include <qtextstream.h> | ||
64 | 53 | ||
65 | /* UNIX */ | 54 | /* UNIX */ |
66 | 55 | ||
67 | #include <stdlib.h> // abort | 56 | #include <stdlib.h> // abort |
68 | #include <unistd.h> // getpid | 57 | #include <unistd.h> // getpid |
69 | #include <stdarg.h> // vararg stuff | 58 | #include <stdarg.h> // vararg stuff |
70 | #include <ctype.h> // isprint | 59 | #include <ctype.h> // isprint |
71 | #include <syslog.h> | 60 | #include <syslog.h> |
72 | #include <errno.h> | 61 | #include <errno.h> |
73 | #include <string.h> | 62 | #include <string.h> |
74 | 63 | ||
75 | #ifndef OPIE_NO_BACKTRACE | 64 | #ifndef OPIE_NO_BACKTRACE |
76 | #include <execinfo.h> | 65 | #include <execinfo.h> |
77 | #endif | 66 | #endif |
78 | 67 | ||
79 | 68 | ||
80 | /*====================================================================================== | 69 | /*====================================================================================== |
81 | * debug levels | 70 | * debug levels |
82 | *======================================================================================*/ | 71 | *======================================================================================*/ |
83 | 72 | ||
84 | enum DebugLevels { | 73 | enum DebugLevels { |
85 | ODEBUG_INFO = 0, | 74 | ODEBUG_INFO = 0, |
86 | ODEBUG_WARN = 1, | 75 | ODEBUG_WARN = 1, |
87 | ODEBUG_ERROR = 2, | 76 | ODEBUG_ERROR = 2, |
88 | ODEBUG_FATAL = 3 | 77 | ODEBUG_FATAL = 3 |
89 | }; | 78 | }; |
90 | 79 | ||
91 | /*====================================================================================== | 80 | /*====================================================================================== |
92 | * oDebug private data | 81 | * oDebug private data |
93 | *======================================================================================*/ | 82 | *======================================================================================*/ |
94 | 83 | ||
95 | /*====================================================================================== | 84 | /*====================================================================================== |
96 | * the main debug function | 85 | * the main debug function |
97 | *======================================================================================*/ | 86 | *======================================================================================*/ |
98 | 87 | ||
99 | static void oDebugBackend( unsigned short level, unsigned int area, const char *data) | 88 | static void oDebugBackend( unsigned short level, unsigned int area, const char *data) |
100 | { | 89 | { |
101 | //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); | 90 | //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); |
102 | 91 | ||
103 | // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an | 92 | // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an |
104 | // ML: example use. I think it's not necessary to implement such a strategy here. | 93 | // ML: example use. I think it's not necessary to implement such a strategy here. |
105 | // ML: Comments? | 94 | // ML: Comments? |
106 | 95 | ||
107 | int priority = 0; | 96 | int priority = 0; |
108 | QString caption; | 97 | QString caption; |
109 | QString lev; | 98 | QString lev; |
110 | switch( level ) | 99 | switch( level ) |
111 | { | 100 | { |
112 | case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; | 101 | case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; |
113 | case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; | 102 | case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; |
114 | case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; | 103 | case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; |
115 | default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); | 104 | default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); |
116 | case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; | 105 | case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; |
117 | } | 106 | } |
118 | 107 | ||
119 | short output = OGlobalSettings::debugMode(); | 108 | short output = OGlobalSettings::debugMode(); |
120 | if (!oApp && (output == 1)) | 109 | if (!oApp && (output == 1)) |
121 | { | 110 | { |
122 | qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); | 111 | qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); |
123 | output = 2; // need an application object to use MsgBox | 112 | output = 2; // need an application object to use MsgBox |
124 | } | 113 | } |
125 | 114 | ||
126 | // gcc 2.9x is dumb and sucks... can you hear it? | 115 | // gcc 2.9x is dumb and sucks... can you hear it? |
127 | //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; | 116 | //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; |
128 | QString areaName; | 117 | QString areaName; |
129 | if ( oApp ) areaName = oApp->appName(); | 118 | if ( oApp ) areaName = oApp->appName(); |
130 | else areaName = "<unknown>"; | 119 | else areaName = "<unknown>"; |
131 | 120 | ||
132 | // Output | 121 | // Output |
133 | switch( output ) | 122 | switch( output ) |
134 | { | 123 | { |
135 | case -1: // ignore | 124 | case -1: // ignore |
136 | { | 125 | { |
137 | return; | 126 | return; |
138 | } | 127 | } |
139 | case 0: // File | 128 | case 0: // File |
140 | { | 129 | { |
141 | QString outputFilename = OGlobalSettings::debugOutput(); | 130 | QString outputFilename = OGlobalSettings::debugOutput(); |
142 | 131 | ||
143 | const int BUFSIZE = 4096; | 132 | const int BUFSIZE = 4096; |
144 | char buf[BUFSIZE] = ""; | 133 | char buf[BUFSIZE] = ""; |
145 | buf[BUFSIZE-1] = '\0'; | 134 | buf[BUFSIZE-1] = '\0'; |
146 | int nSize; | 135 | int nSize; |
147 | 136 | ||
148 | nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data); | 137 | nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data); |
149 | 138 | ||
150 | QFile outputFile( outputFilename ); | 139 | QFile outputFile( outputFilename ); |
151 | if ( outputFile.open( IO_WriteOnly | IO_Append ) ) | 140 | if ( outputFile.open( IO_WriteOnly | IO_Append ) ) |
152 | { | 141 | { |
153 | if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) ) | 142 | if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) ) |
154 | { | 143 | { |
155 | outputFile.writeBlock( buf, BUFSIZE-1 ); | 144 | outputFile.writeBlock( buf, BUFSIZE-1 ); |
156 | } | 145 | } |
157 | else | 146 | else |
158 | { | 147 | { |
159 | outputFile.writeBlock( buf, nSize ); | 148 | outputFile.writeBlock( buf, nSize ); |
160 | } | 149 | } |
161 | } | 150 | } |
162 | else | 151 | else |
163 | { | 152 | { |
164 | qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) ); | 153 | qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) ); |
165 | } | 154 | } |
166 | break; | 155 | break; |
167 | } // automatic close of file here | 156 | } // automatic close of file here |
168 | 157 | ||
169 | case 1: // Message Box | 158 | case 1: // Message Box |
170 | { | 159 | { |
171 | // Since we are in opiecore here, we cannot use OMsgBox and use | 160 | // Since we are in opiecore here, we cannot use OMsgBox and use |
172 | // QMessageBox instead | 161 | // QMessageBox instead |
173 | 162 | ||
174 | caption += QString("(") + areaName + ")"; | 163 | caption += QString("(") + areaName + ")"; |
175 | QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr? | 164 | QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr? |
176 | break; | 165 | break; |
177 | } | 166 | } |
178 | 167 | ||
179 | case 2: // Shell | 168 | case 2: // Shell |
180 | { | 169 | { |
181 | FILE *output = stderr; | 170 | FILE *output = stderr; |
182 | fprintf( output, "%s: ", (const char*) areaName ); | 171 | fprintf( output, "%s: ", (const char*) areaName ); |
183 | fputs( data, output); | 172 | fputs( data, output); |
184 | break; | 173 | break; |
185 | } | 174 | } |
186 | 175 | ||
187 | case 3: // syslog | 176 | case 3: // syslog |
188 | { | 177 | { |
189 | syslog( priority, "%s", data); | 178 | syslog( priority, "%s", data); |
190 | break; | 179 | break; |
191 | } | 180 | } |
192 | 181 | ||
193 | case 4: // socket | 182 | case 4: // socket |
194 | { | 183 | { |
195 | QString destination = OGlobalSettings::debugOutput(); | 184 | QString destination = OGlobalSettings::debugOutput(); |
196 | if ( destination && destination.find(":") != -1 ) | 185 | if ( destination && destination.find(":") != -1 ) |
197 | { | 186 | { |
198 | QString host = destination.left( destination.find(":") ); | 187 | QString host = destination.left( destination.find(":") ); |
199 | QString port = destination.right( destination.length()-host.length()-1 ); | 188 | QString port = destination.right( destination.length()-host.length()-1 ); |
200 | QHostAddress addr; | 189 | QHostAddress addr; |
201 | addr.setAddress( host ); | 190 | addr.setAddress( host ); |
202 | // TODO: sanity check the address | 191 | // TODO: sanity check the address |
203 | QString line; | 192 | QString line; |
204 | line.sprintf( "%s: %s", (const char*) areaName, (const char*) data ); | 193 | line.sprintf( "%s: %s", (const char*) areaName, (const char*) data ); |
205 | QSocketDevice s( QSocketDevice::Datagram ); | 194 | QSocketDevice s( QSocketDevice::Datagram ); |
206 | int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() ); | 195 | int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() ); |
207 | if ( result == -1 ) | 196 | if ( result == -1 ) |
208 | { | 197 | { |
209 | qDebug( "ODebug: can't send to address '%s:%d' (%s)", (const char*) host, port.toInt(), strerror(errno) ); | 198 | qDebug( "ODebug: can't send to address '%s:%d' (%s)", (const char*) host, port.toInt(), strerror(errno) ); |
210 | } | 199 | } |
211 | } | 200 | } |
212 | break; | 201 | break; |
213 | } | 202 | } |
214 | } | 203 | } |
215 | 204 | ||
216 | // check if we should abort | 205 | // check if we should abort |
217 | 206 | ||
218 | /* | 207 | /* |
219 | 208 | ||
220 | if( ( nLevel == ODEBUG_FATAL ) | 209 | if( ( nLevel == ODEBUG_FATAL ) |
221 | && ( !oDebug_data->config || oDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) ) | 210 | && ( !oDebug_data->config || oDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) ) |
222 | abort(); | 211 | abort(); |
223 | 212 | ||
224 | */ | 213 | */ |
225 | } | 214 | } |
226 | 215 | ||
227 | /*====================================================================================== | 216 | /*====================================================================================== |
228 | * odbgstream | 217 | * odbgstream |
229 | *======================================================================================*/ | 218 | *======================================================================================*/ |
230 | 219 | ||
231 | odbgstream& perror( odbgstream &s) | 220 | odbgstream& perror( odbgstream &s) |
232 | { | 221 | { |
233 | return s << QString::fromLocal8Bit(strerror(errno)); | 222 | return s << QString::fromLocal8Bit(strerror(errno)); |
234 | } | 223 | } |
235 | 224 | ||
236 | odbgstream odDebug(int area) | 225 | odbgstream odDebug(int area) |
237 | { | 226 | { |
238 | return odbgstream(area, ODEBUG_INFO); | 227 | return odbgstream(area, ODEBUG_INFO); |
239 | } | 228 | } |
240 | odbgstream odDebug(bool cond, int area) | 229 | odbgstream odDebug(bool cond, int area) |
241 | { | 230 | { |
242 | if (cond) return odbgstream(area, ODEBUG_INFO); | 231 | if (cond) return odbgstream(area, ODEBUG_INFO); |
243 | else return odbgstream(0, 0, false); | 232 | else return odbgstream(0, 0, false); |
244 | } | 233 | } |
245 | 234 | ||
246 | odbgstream odError(int area) | 235 | odbgstream odError(int area) |
247 | { | 236 | { |
248 | return odbgstream("ERROR: ", area, ODEBUG_ERROR); | 237 | return odbgstream("ERROR: ", area, ODEBUG_ERROR); |
249 | } | 238 | } |
250 | 239 | ||
251 | odbgstream odError(bool cond, int area) | 240 | odbgstream odError(bool cond, int area) |
252 | { | 241 | { |
253 | if (cond) return odbgstream("ERROR: ", area, ODEBUG_ERROR); else return odbgstream(0,0,false); | 242 | if (cond) return odbgstream("ERROR: ", area, ODEBUG_ERROR); else return odbgstream(0,0,false); |
254 | } | 243 | } |
255 | 244 | ||
diff --git a/libopie2/opiecore/oglobal.cpp b/libopie2/opiecore/oglobal.cpp index 879e80f..1aa206e 100644 --- a/libopie2/opiecore/oglobal.cpp +++ b/libopie2/opiecore/oglobal.cpp | |||
@@ -1,224 +1,223 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@handhelds.org> | 4 | =. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@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/oglobal.h> | 30 | #include <opie2/oglobal.h> |
31 | 31 | ||
32 | #include <qfile.h> | ||
33 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
34 | #include <qdir.h> | 33 | #include <qdir.h> |
35 | #include <qpe/mimetype.h> | 34 | #include <qpe/mimetype.h> |
36 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
38 | 37 | ||
39 | #include <unistd.h> | 38 | #include <unistd.h> |
40 | #include <sys/types.h> | 39 | #include <sys/types.h> |
41 | 40 | ||
42 | static const char Base64EncMap[64] = | 41 | static const char Base64EncMap[64] = |
43 | { | 42 | { |
44 | 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, | 43 | 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, |
45 | 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, | 44 | 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, |
46 | 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, | 45 | 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, |
47 | 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, | 46 | 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, |
48 | 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, | 47 | 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, |
49 | 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, | 48 | 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, |
50 | 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, | 49 | 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, |
51 | 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F | 50 | 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F |
52 | }; | 51 | }; |
53 | 52 | ||
54 | static char Base64DecMap[128] = | 53 | static char Base64DecMap[128] = |
55 | { | 54 | { |
56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
57 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
58 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 57 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 58 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
61 | 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, | 60 | 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, |
62 | 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, | 61 | 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, |
63 | 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 62 | 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
64 | 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, | 63 | 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, |
65 | 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, | 64 | 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, |
66 | 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, | 65 | 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, |
67 | 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, | 66 | 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, |
68 | 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, | 67 | 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, |
69 | 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, | 68 | 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, |
70 | 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, | 69 | 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, |
71 | 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00 | 70 | 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00 |
72 | }; | 71 | }; |
73 | 72 | ||
74 | 73 | ||
75 | OConfig* OGlobal::_config = 0; | 74 | OConfig* OGlobal::_config = 0; |
76 | OConfig* OGlobal::_qpe_config = 0; | 75 | OConfig* OGlobal::_qpe_config = 0; |
77 | 76 | ||
78 | OConfig* OGlobal::config() | 77 | OConfig* OGlobal::config() |
79 | { | 78 | { |
80 | if ( !OGlobal::_config ) | 79 | if ( !OGlobal::_config ) |
81 | { | 80 | { |
82 | // odebug classes are reading config, so can't use them here! | 81 | // odebug classes are reading config, so can't use them here! |
83 | qDebug( "OGlobal::creating global configuration instance." ); | 82 | qDebug( "OGlobal::creating global configuration instance." ); |
84 | OGlobal::_config = new OConfig( "global" ); | 83 | OGlobal::_config = new OConfig( "global" ); |
85 | } | 84 | } |
86 | return OGlobal::_config; | 85 | return OGlobal::_config; |
87 | } | 86 | } |
88 | 87 | ||
89 | 88 | ||
90 | /** | 89 | /** |
91 | * Return the internal builtin Global::Command object | 90 | * Return the internal builtin Global::Command object |
92 | * | 91 | * |
93 | */ | 92 | */ |
94 | Global::Command* OGlobal::builtinCommands() { | 93 | Global::Command* OGlobal::builtinCommands() { |
95 | return builtin; | 94 | return builtin; |
96 | } | 95 | } |
97 | 96 | ||
98 | 97 | ||
99 | /** | 98 | /** |
100 | * Return the internal builtin QGuardedPtr<QWidget> object | 99 | * Return the internal builtin QGuardedPtr<QWidget> object |
101 | */ | 100 | */ |
102 | QGuardedPtr<QWidget>* OGlobal::builtinRunning() { | 101 | QGuardedPtr<QWidget>* OGlobal::builtinRunning() { |
103 | return running; | 102 | return running; |
104 | } | 103 | } |
105 | 104 | ||
106 | 105 | ||
107 | /** | 106 | /** |
108 | * \brief generate a new UUID as QString | 107 | * \brief generate a new UUID as QString |
109 | * Return a new UUID as QString. UUID are global unique | 108 | * Return a new UUID as QString. UUID are global unique |
110 | * | 109 | * |
111 | * | 110 | * |
112 | * @return the UUID or QString::null | 111 | * @return the UUID or QString::null |
113 | */ | 112 | */ |
114 | QString OGlobal::generateUuid() { | 113 | QString OGlobal::generateUuid() { |
115 | QFile file( "/proc/sys/kernel/random/uuid" ); | 114 | QFile file( "/proc/sys/kernel/random/uuid" ); |
116 | if (!file.open(IO_ReadOnly ) ) | 115 | if (!file.open(IO_ReadOnly ) ) |
117 | return QString::null; | 116 | return QString::null; |
118 | 117 | ||
119 | QTextStream stream(&file); | 118 | QTextStream stream(&file); |
120 | 119 | ||
121 | return "{" + stream.read().stripWhiteSpace() + "}"; | 120 | return "{" + stream.read().stripWhiteSpace() + "}"; |
122 | } | 121 | } |
123 | 122 | ||
124 | 123 | ||
125 | /** | 124 | /** |
126 | * \brief Encode a QByteArray in base64 | 125 | * \brief Encode a QByteArray in base64 |
127 | * | 126 | * |
128 | * An Implementation of the RF1521 base64 encoding. | 127 | * An Implementation of the RF1521 base64 encoding. |
129 | * | 128 | * |
130 | * The boolean argument determines if the encoded data is | 129 | * The boolean argument determines if the encoded data is |
131 | * going to be restricted to 76 characters or less per line | 130 | * going to be restricted to 76 characters or less per line |
132 | * as specified by RFC 2045. If @p insertLFs is true, then | 131 | * as specified by RFC 2045. If @p insertLFs is true, then |
133 | * there will be 76 characters or less per line. | 132 | * there will be 76 characters or less per line. |
134 | * | 133 | * |
135 | * If you use this to create a QCString remember that it is null terminated! | 134 | * If you use this to create a QCString remember that it is null terminated! |
136 | * \code | 135 | * \code |
137 | * QByteArray ar = OGlobal::encodeBase64(&array); | 136 | * QByteArray ar = OGlobal::encodeBase64(&array); |
138 | * QCString str(ar.data(),ar.size()+1); // the NUL at the end | 137 | * QCString str(ar.data(),ar.size()+1); // the NUL at the end |
139 | * | 138 | * |
140 | * \endcode | 139 | * \endcode |
141 | * | 140 | * |
142 | * @param in The QByteArray to encode | 141 | * @param in The QByteArray to encode |
143 | * @param insertLFs Limit number of characters per line | 142 | * @param insertLFs Limit number of characters per line |
144 | * @return The argument as base64 encoded or QByteArray() if in.isEmpty() | 143 | * @return The argument as base64 encoded or QByteArray() if in.isEmpty() |
145 | * @see QByteArray | 144 | * @see QByteArray |
146 | * @see QArray | 145 | * @see QArray |
147 | * @see QMemArray | 146 | * @see QMemArray |
148 | * @see QCString | 147 | * @see QCString |
149 | */ | 148 | */ |
150 | /* | 149 | /* |
151 | * LGPL by Rik Hemsely of the KDE Project. taken from kmdcodec.cpp | 150 | * LGPL by Rik Hemsely of the KDE Project. taken from kmdcodec.cpp |
152 | */ | 151 | */ |
153 | QByteArray OGlobal::encodeBase64(const QByteArray& in, bool insertLFs ) { | 152 | QByteArray OGlobal::encodeBase64(const QByteArray& in, bool insertLFs ) { |
154 | if ( in.isEmpty() ) | 153 | if ( in.isEmpty() ) |
155 | return QByteArray(); | 154 | return QByteArray(); |
156 | 155 | ||
157 | unsigned int sidx = 0; | 156 | unsigned int sidx = 0; |
158 | unsigned int didx = 0; | 157 | unsigned int didx = 0; |
159 | const char* data = in.data(); | 158 | const char* data = in.data(); |
160 | const unsigned int len = in.size(); | 159 | const unsigned int len = in.size(); |
161 | 160 | ||
162 | unsigned int out_len = ((len+2)/3)*4; | 161 | unsigned int out_len = ((len+2)/3)*4; |
163 | 162 | ||
164 | // Deal with the 76 characters or less per | 163 | // Deal with the 76 characters or less per |
165 | // line limit specified in RFC 2045 on a | 164 | // line limit specified in RFC 2045 on a |
166 | // pre request basis. | 165 | // pre request basis. |
167 | insertLFs = (insertLFs && out_len > 76); | 166 | insertLFs = (insertLFs && out_len > 76); |
168 | if ( insertLFs ) | 167 | if ( insertLFs ) |
169 | out_len += ((out_len-1)/76); | 168 | out_len += ((out_len-1)/76); |
170 | 169 | ||
171 | int count = 0; | 170 | int count = 0; |
172 | QByteArray out( out_len ); | 171 | QByteArray out( out_len ); |
173 | 172 | ||
174 | // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion | 173 | // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion |
175 | if ( len > 1 ) | 174 | if ( len > 1 ) |
176 | { | 175 | { |
177 | while (sidx < len-2) | 176 | while (sidx < len-2) |
178 | { | 177 | { |
179 | if ( insertLFs ) | 178 | if ( insertLFs ) |
180 | { | 179 | { |
181 | if ( count && (count%76) == 0 ) | 180 | if ( count && (count%76) == 0 ) |
182 | out[didx++] = '\n'; | 181 | out[didx++] = '\n'; |
183 | count += 4; | 182 | count += 4; |
184 | } | 183 | } |
185 | out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; | 184 | out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; |
186 | out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | | 185 | out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | |
187 | (data[sidx] << 4) & 077]; | 186 | (data[sidx] << 4) & 077]; |
188 | out[didx++] = Base64EncMap[(data[sidx+2] >> 6) & 003 | | 187 | out[didx++] = Base64EncMap[(data[sidx+2] >> 6) & 003 | |
189 | (data[sidx+1] << 2) & 077]; | 188 | (data[sidx+1] << 2) & 077]; |
190 | out[didx++] = Base64EncMap[data[sidx+2] & 077]; | 189 | out[didx++] = Base64EncMap[data[sidx+2] & 077]; |
191 | sidx += 3; | 190 | sidx += 3; |
192 | } | 191 | } |
193 | } | 192 | } |
194 | 193 | ||
195 | if (sidx < len) | 194 | if (sidx < len) |
196 | { | 195 | { |
197 | if ( insertLFs && (count > 0) && (count%76) == 0 ) | 196 | if ( insertLFs && (count > 0) && (count%76) == 0 ) |
198 | out[didx++] = '\n'; | 197 | out[didx++] = '\n'; |
199 | 198 | ||
200 | out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; | 199 | out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077]; |
201 | if (sidx < len-1) | 200 | if (sidx < len-1) |
202 | { | 201 | { |
203 | out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | | 202 | out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 | |
204 | (data[sidx] << 4) & 077]; | 203 | (data[sidx] << 4) & 077]; |
205 | out[didx++] = Base64EncMap[(data[sidx+1] << 2) & 077]; | 204 | out[didx++] = Base64EncMap[(data[sidx+1] << 2) & 077]; |
206 | } | 205 | } |
207 | else | 206 | else |
208 | { | 207 | { |
209 | out[didx++] = Base64EncMap[(data[sidx] << 4) & 077]; | 208 | out[didx++] = Base64EncMap[(data[sidx] << 4) & 077]; |
210 | } | 209 | } |
211 | } | 210 | } |
212 | 211 | ||
213 | // Add padding | 212 | // Add padding |
214 | while (didx < out.size()) | 213 | while (didx < out.size()) |
215 | { | 214 | { |
216 | out[didx] = '='; | 215 | out[didx] = '='; |
217 | didx++; | 216 | didx++; |
218 | } | 217 | } |
219 | 218 | ||
220 | return out; | 219 | return out; |
221 | } | 220 | } |
222 | 221 | ||
223 | /** | 222 | /** |
224 | * Decodes the given data that was encoded with the base64 | 223 | * Decodes the given data that was encoded with the base64 |
diff --git a/libopie2/opiecore/oglobalsettings.cpp b/libopie2/opiecore/oglobalsettings.cpp index 66adbd0..192e55b 100644 --- a/libopie2/opiecore/oglobalsettings.cpp +++ b/libopie2/opiecore/oglobalsettings.cpp | |||
@@ -1,236 +1,233 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | Inspired by the KDE globalsettings which are | 5 | Inspired by the KDE globalsettings which are |
6 | Copyright (C) 2000 David Faure <faure@kde.org> | 6 | Copyright (C) 2000 David Faure <faure@kde.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | 34 | ||
35 | #include <opie2/oglobalsettings.h> | 35 | #include <opie2/oglobalsettings.h> |
36 | #include <opie2/oconfig.h> | 36 | #include <opie2/oconfig.h> |
37 | #include <opie2/oglobal.h> | 37 | #include <opie2/oglobal.h> |
38 | 38 | ||
39 | /* QT */ | 39 | /* QT */ |
40 | 40 | ||
41 | #include <qobject.h> | ||
42 | #include <qdir.h> | 41 | #include <qdir.h> |
43 | #include <qpixmap.h> | ||
44 | #include <qfontinfo.h> | ||
45 | 42 | ||
46 | /* UNIX */ | 43 | /* UNIX */ |
47 | 44 | ||
48 | #include <stdlib.h> | 45 | #include <stdlib.h> |
49 | 46 | ||
50 | QString* OGlobalSettings::s_desktopPath = 0; | 47 | QString* OGlobalSettings::s_desktopPath = 0; |
51 | QString* OGlobalSettings::s_autostartPath = 0; | 48 | QString* OGlobalSettings::s_autostartPath = 0; |
52 | QString* OGlobalSettings::s_trashPath = 0; | 49 | QString* OGlobalSettings::s_trashPath = 0; |
53 | QString* OGlobalSettings::s_documentPath = 0; | 50 | QString* OGlobalSettings::s_documentPath = 0; |
54 | QFont *OGlobalSettings::_generalFont = 0; | 51 | QFont *OGlobalSettings::_generalFont = 0; |
55 | QFont *OGlobalSettings::_fixedFont = 0; | 52 | QFont *OGlobalSettings::_fixedFont = 0; |
56 | QFont *OGlobalSettings::_toolBarFont = 0; | 53 | QFont *OGlobalSettings::_toolBarFont = 0; |
57 | QFont *OGlobalSettings::_menuFont = 0; | 54 | QFont *OGlobalSettings::_menuFont = 0; |
58 | QFont *OGlobalSettings::_windowTitleFont = 0; | 55 | QFont *OGlobalSettings::_windowTitleFont = 0; |
59 | QFont *OGlobalSettings::_taskbarFont = 0; | 56 | QFont *OGlobalSettings::_taskbarFont = 0; |
60 | 57 | ||
61 | QColor *OGlobalSettings::OpieGray = 0; | 58 | QColor *OGlobalSettings::OpieGray = 0; |
62 | QColor *OGlobalSettings::OpieHighlight = 0; | 59 | QColor *OGlobalSettings::OpieHighlight = 0; |
63 | QColor *OGlobalSettings::OpieAlternate = 0; | 60 | QColor *OGlobalSettings::OpieAlternate = 0; |
64 | 61 | ||
65 | OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; | 62 | OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; |
66 | 63 | ||
67 | //FIXME: Add manipulators to the accessors | 64 | //FIXME: Add manipulators to the accessors |
68 | 65 | ||
69 | int OGlobalSettings::dndEventDelay() | 66 | int OGlobalSettings::dndEventDelay() |
70 | { | 67 | { |
71 | OConfig *c = OGlobal::config(); | 68 | OConfig *c = OGlobal::config(); |
72 | OConfigGroupSaver cgs( c, "General" ); | 69 | OConfigGroupSaver cgs( c, "General" ); |
73 | return c->readNumEntry("DndDelay", 2); | 70 | return c->readNumEntry("DndDelay", 2); |
74 | } | 71 | } |
75 | 72 | ||
76 | bool OGlobalSettings::singleClick() | 73 | bool OGlobalSettings::singleClick() |
77 | { | 74 | { |
78 | OConfig *c = OGlobal::config(); | 75 | OConfig *c = OGlobal::config(); |
79 | OConfigGroupSaver cgs( c, "OPIE" ); | 76 | OConfigGroupSaver cgs( c, "OPIE" ); |
80 | return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); | 77 | return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); |
81 | } | 78 | } |
82 | 79 | ||
83 | bool OGlobalSettings::insertTearOffHandle() | 80 | bool OGlobalSettings::insertTearOffHandle() |
84 | { | 81 | { |
85 | OConfig *c = OGlobal::config(); | 82 | OConfig *c = OGlobal::config(); |
86 | OConfigGroupSaver cgs( c, "OPIE" ); | 83 | OConfigGroupSaver cgs( c, "OPIE" ); |
87 | return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); | 84 | return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); |
88 | } | 85 | } |
89 | 86 | ||
90 | bool OGlobalSettings::changeCursorOverIcon() | 87 | bool OGlobalSettings::changeCursorOverIcon() |
91 | { | 88 | { |
92 | OConfig *c = OGlobal::config(); | 89 | OConfig *c = OGlobal::config(); |
93 | OConfigGroupSaver cgs( c, "OPIE" ); | 90 | OConfigGroupSaver cgs( c, "OPIE" ); |
94 | return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); | 91 | return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); |
95 | } | 92 | } |
96 | 93 | ||
97 | bool OGlobalSettings::visualActivate() | 94 | bool OGlobalSettings::visualActivate() |
98 | { | 95 | { |
99 | OConfig *c = OGlobal::config(); | 96 | OConfig *c = OGlobal::config(); |
100 | OConfigGroupSaver cgs( c, "OPIE" ); | 97 | OConfigGroupSaver cgs( c, "OPIE" ); |
101 | return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE); | 98 | return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE); |
102 | } | 99 | } |
103 | 100 | ||
104 | unsigned int OGlobalSettings::visualActivateSpeed() | 101 | unsigned int OGlobalSettings::visualActivateSpeed() |
105 | { | 102 | { |
106 | OConfig *c = OGlobal::config(); | 103 | OConfig *c = OGlobal::config(); |
107 | OConfigGroupSaver cgs( c, "OPIE" ); | 104 | OConfigGroupSaver cgs( c, "OPIE" ); |
108 | return | 105 | return |
109 | c->readNumEntry( | 106 | c->readNumEntry( |
110 | "VisualActivateSpeed", | 107 | "VisualActivateSpeed", |
111 | OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED | 108 | OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED |
112 | ); | 109 | ); |
113 | } | 110 | } |
114 | 111 | ||
115 | int OGlobalSettings::autoSelectDelay() | 112 | int OGlobalSettings::autoSelectDelay() |
116 | { | 113 | { |
117 | OConfig *c = OGlobal::config(); | 114 | OConfig *c = OGlobal::config(); |
118 | OConfigGroupSaver cgs( c, "OPIE" ); | 115 | OConfigGroupSaver cgs( c, "OPIE" ); |
119 | return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY); | 116 | return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY); |
120 | } | 117 | } |
121 | 118 | ||
122 | OGlobalSettings::Completion OGlobalSettings::completionMode() | 119 | OGlobalSettings::Completion OGlobalSettings::completionMode() |
123 | { | 120 | { |
124 | int completion; | 121 | int completion; |
125 | OConfig *c = OGlobal::config(); | 122 | OConfig *c = OGlobal::config(); |
126 | OConfigGroupSaver cgs( c, "General" ); | 123 | OConfigGroupSaver cgs( c, "General" ); |
127 | completion = c->readNumEntry("completionMode", -1); | 124 | completion = c->readNumEntry("completionMode", -1); |
128 | if ((completion < (int) CompletionNone) || | 125 | if ((completion < (int) CompletionNone) || |
129 | (completion > (int) CompletionPopupAuto)) | 126 | (completion > (int) CompletionPopupAuto)) |
130 | { | 127 | { |
131 | completion = (int) CompletionPopup; // Default | 128 | completion = (int) CompletionPopup; // Default |
132 | } | 129 | } |
133 | return (Completion) completion; | 130 | return (Completion) completion; |
134 | } | 131 | } |
135 | 132 | ||
136 | 133 | ||
137 | bool OGlobalSettings::showContextMenusOnPress () | 134 | bool OGlobalSettings::showContextMenusOnPress () |
138 | { | 135 | { |
139 | OConfig *c = OGlobal::config(); | 136 | OConfig *c = OGlobal::config(); |
140 | OConfigGroupSaver cgs (c, "ContextMenus"); | 137 | OConfigGroupSaver cgs (c, "ContextMenus"); |
141 | 138 | ||
142 | return cgs.config()->readBoolEntry("ShowOnPress", true); | 139 | return cgs.config()->readBoolEntry("ShowOnPress", true); |
143 | } | 140 | } |
144 | 141 | ||
145 | 142 | ||
146 | int OGlobalSettings::contextMenuKey () | 143 | int OGlobalSettings::contextMenuKey () |
147 | { | 144 | { |
148 | OConfig *c = OGlobal::config(); | 145 | OConfig *c = OGlobal::config(); |
149 | OConfigGroupSaver cgs (c, "Shortcuts"); | 146 | OConfigGroupSaver cgs (c, "Shortcuts"); |
150 | 147 | ||
151 | //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu")); | 148 | //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu")); |
152 | //return cut.keyCodeQt(); | 149 | //return cut.keyCodeQt(); |
153 | 150 | ||
154 | return 0; // FIXME | 151 | return 0; // FIXME |
155 | } | 152 | } |
156 | 153 | ||
157 | 154 | ||
158 | OGlobalSettings::Debug OGlobalSettings::debugMode() | 155 | OGlobalSettings::Debug OGlobalSettings::debugMode() |
159 | { | 156 | { |
160 | OConfig *c = OGlobal::config(); | 157 | OConfig *c = OGlobal::config(); |
161 | OConfigGroupSaver cgs( c, "General" ); | 158 | OConfigGroupSaver cgs( c, "General" ); |
162 | int debug = c->readNumEntry( "debugMode", -1 ); | 159 | int debug = c->readNumEntry( "debugMode", -1 ); |
163 | if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) ) | 160 | if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) ) |
164 | { | 161 | { |
165 | debug = (int) DebugStdErr; // Default | 162 | debug = (int) DebugStdErr; // Default |
166 | } | 163 | } |
167 | return (Debug) debug; | 164 | return (Debug) debug; |
168 | } | 165 | } |
169 | 166 | ||
170 | 167 | ||
171 | QString OGlobalSettings::debugOutput() | 168 | QString OGlobalSettings::debugOutput() |
172 | { | 169 | { |
173 | OConfig *c = OGlobal::config(); | 170 | OConfig *c = OGlobal::config(); |
174 | OConfigGroupSaver cgs( c, "General" ); | 171 | OConfigGroupSaver cgs( c, "General" ); |
175 | QString deflt = QString::null; | 172 | QString deflt = QString::null; |
176 | switch( debugMode() ) | 173 | switch( debugMode() ) |
177 | { | 174 | { |
178 | case DebugNone: break; // no additional information needed | 175 | case DebugNone: break; // no additional information needed |
179 | case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in | 176 | case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in |
180 | case DebugMsgBox: break; // no additional information needed | 177 | case DebugMsgBox: break; // no additional information needed |
181 | case DebugStdErr: break; // no additional information needed | 178 | case DebugStdErr: break; // no additional information needed |
182 | case DebugSysLog: break; // no additional information needed | 179 | case DebugSysLog: break; // no additional information needed |
183 | case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to | 180 | case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to |
184 | } | 181 | } |
185 | 182 | ||
186 | return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt ); | 183 | return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt ); |
187 | } | 184 | } |
188 | 185 | ||
189 | 186 | ||
190 | QColor OGlobalSettings::toolBarHighlightColor() | 187 | QColor OGlobalSettings::toolBarHighlightColor() |
191 | { | 188 | { |
192 | initColors(); | 189 | initColors(); |
193 | OConfig *c = OGlobal::config(); | 190 | OConfig *c = OGlobal::config(); |
194 | OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") ); | 191 | OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") ); |
195 | return c->readColorEntry("HighlightColor", OpieHighlight); | 192 | return c->readColorEntry("HighlightColor", OpieHighlight); |
196 | } | 193 | } |
197 | 194 | ||
198 | QColor OGlobalSettings::inactiveTitleColor() | 195 | QColor OGlobalSettings::inactiveTitleColor() |
199 | { | 196 | { |
200 | if (!OpieGray) OpieGray = new QColor(220, 220, 220); | 197 | if (!OpieGray) OpieGray = new QColor(220, 220, 220); |
201 | OConfig *c = OGlobal::config(); | 198 | OConfig *c = OGlobal::config(); |
202 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); | 199 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); |
203 | return c->readColorEntry( "inactiveBackground", OpieGray ); | 200 | return c->readColorEntry( "inactiveBackground", OpieGray ); |
204 | } | 201 | } |
205 | 202 | ||
206 | QColor OGlobalSettings::inactiveTextColor() | 203 | QColor OGlobalSettings::inactiveTextColor() |
207 | { | 204 | { |
208 | OConfig *c = OGlobal::config(); | 205 | OConfig *c = OGlobal::config(); |
209 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); | 206 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); |
210 | return c->readColorEntry( "inactiveForeground", &Qt::darkGray ); | 207 | return c->readColorEntry( "inactiveForeground", &Qt::darkGray ); |
211 | } | 208 | } |
212 | 209 | ||
213 | QColor OGlobalSettings::activeTitleColor() | 210 | QColor OGlobalSettings::activeTitleColor() |
214 | { | 211 | { |
215 | initColors(); | 212 | initColors(); |
216 | OConfig *c = OGlobal::config(); | 213 | OConfig *c = OGlobal::config(); |
217 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); | 214 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); |
218 | return c->readColorEntry( "activeBackground", OpieHighlight); | 215 | return c->readColorEntry( "activeBackground", OpieHighlight); |
219 | } | 216 | } |
220 | 217 | ||
221 | QColor OGlobalSettings::activeTextColor() | 218 | QColor OGlobalSettings::activeTextColor() |
222 | { | 219 | { |
223 | OConfig *c = OGlobal::config(); | 220 | OConfig *c = OGlobal::config(); |
224 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); | 221 | OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); |
225 | return c->readColorEntry( "activeForeground", &Qt::white ); | 222 | return c->readColorEntry( "activeForeground", &Qt::white ); |
226 | } | 223 | } |
227 | 224 | ||
228 | int OGlobalSettings::contrast() | 225 | int OGlobalSettings::contrast() |
229 | { | 226 | { |
230 | OConfig *c = OGlobal::config(); | 227 | OConfig *c = OGlobal::config(); |
231 | OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") ); | 228 | OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") ); |
232 | return c->readNumEntry( "contrast", 7 ); | 229 | return c->readNumEntry( "contrast", 7 ); |
233 | } | 230 | } |
234 | 231 | ||
235 | // following functions should work in OPIE - how to sync with appearance changes? | 232 | // following functions should work in OPIE - how to sync with appearance changes? |
236 | 233 | ||
diff --git a/libopie2/opiecore/oprocctrl.cpp b/libopie2/opiecore/oprocctrl.cpp index b3d57c8..0403526 100644 --- a/libopie2/opiecore/oprocctrl.cpp +++ b/libopie2/opiecore/oprocctrl.cpp | |||
@@ -1,234 +1,233 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) | 2 | Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | // | 19 | // |
20 | // KPROCESSCONTROLLER -- A helper class for KProcess | 20 | // KPROCESSCONTROLLER -- A helper class for KProcess |
21 | // | 21 | // |
22 | // version 0.3.1, Jan, 8th 1997 | 22 | // version 0.3.1, Jan, 8th 1997 |
23 | // | 23 | // |
24 | // (C) Christian Czezatke | 24 | // (C) Christian Czezatke |
25 | // e9025461@student.tuwien.ac.at | 25 | // e9025461@student.tuwien.ac.at |
26 | // Ported by Holger Freyther | 26 | // Ported by Holger Freyther |
27 | // | 27 | // |
28 | 28 | ||
29 | //#include <config.h> | 29 | //#include <config.h> |
30 | 30 | ||
31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
32 | #include <sys/socket.h> | 32 | #include <sys/socket.h> |
33 | 33 | ||
34 | #include <errno.h> | 34 | #include <errno.h> |
35 | #include <fcntl.h> | 35 | #include <fcntl.h> |
36 | #include <stdio.h> | 36 | #include <stdio.h> |
37 | #include <string.h> | 37 | #include <string.h> |
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <assert.h> | 39 | #include <assert.h> |
40 | 40 | ||
41 | #include <qsocketnotifier.h> | 41 | #include <qsocketnotifier.h> |
42 | #include "oprocess.h" | ||
43 | #include "oprocctrl.h" | 42 | #include "oprocctrl.h" |
44 | 43 | ||
45 | OProcessController *OProcessController::theOProcessController = 0; | 44 | OProcessController *OProcessController::theOProcessController = 0; |
46 | 45 | ||
47 | struct sigaction OProcessController::oldChildHandlerData; | 46 | struct sigaction OProcessController::oldChildHandlerData; |
48 | bool OProcessController::handlerSet = false; | 47 | bool OProcessController::handlerSet = false; |
49 | 48 | ||
50 | OProcessController::OProcessController() | 49 | OProcessController::OProcessController() |
51 | { | 50 | { |
52 | assert( theOProcessController == 0 ); | 51 | assert( theOProcessController == 0 ); |
53 | 52 | ||
54 | if (0 > pipe(fd)) | 53 | if (0 > pipe(fd)) |
55 | printf(strerror(errno)); | 54 | printf(strerror(errno)); |
56 | 55 | ||
57 | notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read); | 56 | notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read); |
58 | notifier->setEnabled(true); | 57 | notifier->setEnabled(true); |
59 | QObject::connect(notifier, SIGNAL(activated(int)), | 58 | QObject::connect(notifier, SIGNAL(activated(int)), |
60 | this, SLOT(slotDoHousekeeping(int))); | 59 | this, SLOT(slotDoHousekeeping(int))); |
61 | connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()), | 60 | connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()), |
62 | SLOT( delayedChildrenCleanup())); | 61 | SLOT( delayedChildrenCleanup())); |
63 | 62 | ||
64 | theOProcessController = this; | 63 | theOProcessController = this; |
65 | 64 | ||
66 | setupHandlers(); | 65 | setupHandlers(); |
67 | } | 66 | } |
68 | 67 | ||
69 | 68 | ||
70 | void OProcessController::setupHandlers() | 69 | void OProcessController::setupHandlers() |
71 | { | 70 | { |
72 | if( handlerSet ) | 71 | if( handlerSet ) |
73 | return; | 72 | return; |
74 | struct sigaction act; | 73 | struct sigaction act; |
75 | act.sa_handler=theSigCHLDHandler; | 74 | act.sa_handler=theSigCHLDHandler; |
76 | sigemptyset(&(act.sa_mask)); | 75 | sigemptyset(&(act.sa_mask)); |
77 | sigaddset(&(act.sa_mask), SIGCHLD); | 76 | sigaddset(&(act.sa_mask), SIGCHLD); |
78 | // Make sure we don't block this signal. gdb tends to do that :-( | 77 | // Make sure we don't block this signal. gdb tends to do that :-( |
79 | sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0); | 78 | sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0); |
80 | 79 | ||
81 | act.sa_flags = SA_NOCLDSTOP; | 80 | act.sa_flags = SA_NOCLDSTOP; |
82 | 81 | ||
83 | // CC: take care of SunOS which automatically restarts interrupted system | 82 | // CC: take care of SunOS which automatically restarts interrupted system |
84 | // calls (and thus does not have SA_RESTART) | 83 | // calls (and thus does not have SA_RESTART) |
85 | 84 | ||
86 | #ifdef SA_RESTART | 85 | #ifdef SA_RESTART |
87 | act.sa_flags |= SA_RESTART; | 86 | act.sa_flags |= SA_RESTART; |
88 | #endif | 87 | #endif |
89 | 88 | ||
90 | sigaction( SIGCHLD, &act, &oldChildHandlerData ); | 89 | sigaction( SIGCHLD, &act, &oldChildHandlerData ); |
91 | 90 | ||
92 | act.sa_handler=SIG_IGN; | 91 | act.sa_handler=SIG_IGN; |
93 | sigemptyset(&(act.sa_mask)); | 92 | sigemptyset(&(act.sa_mask)); |
94 | sigaddset(&(act.sa_mask), SIGPIPE); | 93 | sigaddset(&(act.sa_mask), SIGPIPE); |
95 | act.sa_flags = 0; | 94 | act.sa_flags = 0; |
96 | sigaction( SIGPIPE, &act, 0L); | 95 | sigaction( SIGPIPE, &act, 0L); |
97 | handlerSet = true; | 96 | handlerSet = true; |
98 | } | 97 | } |
99 | 98 | ||
100 | void OProcessController::resetHandlers() | 99 | void OProcessController::resetHandlers() |
101 | { | 100 | { |
102 | if( !handlerSet ) | 101 | if( !handlerSet ) |
103 | return; | 102 | return; |
104 | sigaction( SIGCHLD, &oldChildHandlerData, 0 ); | 103 | sigaction( SIGCHLD, &oldChildHandlerData, 0 ); |
105 | // there should be no problem with SIGPIPE staying SIG_IGN | 104 | // there should be no problem with SIGPIPE staying SIG_IGN |
106 | handlerSet = false; | 105 | handlerSet = false; |
107 | } | 106 | } |
108 | 107 | ||
109 | // block SIGCHLD handler, because it accesses processList | 108 | // block SIGCHLD handler, because it accesses processList |
110 | void OProcessController::addOProcess( OProcess* p ) | 109 | void OProcessController::addOProcess( OProcess* p ) |
111 | { | 110 | { |
112 | sigset_t newset, oldset; | 111 | sigset_t newset, oldset; |
113 | sigemptyset( &newset ); | 112 | sigemptyset( &newset ); |
114 | sigaddset( &newset, SIGCHLD ); | 113 | sigaddset( &newset, SIGCHLD ); |
115 | sigprocmask( SIG_BLOCK, &newset, &oldset ); | 114 | sigprocmask( SIG_BLOCK, &newset, &oldset ); |
116 | processList.append( p ); | 115 | processList.append( p ); |
117 | sigprocmask( SIG_SETMASK, &oldset, 0 ); | 116 | sigprocmask( SIG_SETMASK, &oldset, 0 ); |
118 | } | 117 | } |
119 | 118 | ||
120 | void OProcessController::removeOProcess( OProcess* p ) | 119 | void OProcessController::removeOProcess( OProcess* p ) |
121 | { | 120 | { |
122 | sigset_t newset, oldset; | 121 | sigset_t newset, oldset; |
123 | sigemptyset( &newset ); | 122 | sigemptyset( &newset ); |
124 | sigaddset( &newset, SIGCHLD ); | 123 | sigaddset( &newset, SIGCHLD ); |
125 | sigprocmask( SIG_BLOCK, &newset, &oldset ); | 124 | sigprocmask( SIG_BLOCK, &newset, &oldset ); |
126 | processList.remove( p ); | 125 | processList.remove( p ); |
127 | sigprocmask( SIG_SETMASK, &oldset, 0 ); | 126 | sigprocmask( SIG_SETMASK, &oldset, 0 ); |
128 | } | 127 | } |
129 | 128 | ||
130 | //using a struct which contains both the pid and the status makes it easier to write | 129 | //using a struct which contains both the pid and the status makes it easier to write |
131 | //and read the data into the pipe | 130 | //and read the data into the pipe |
132 | //especially this solves a problem which appeared on my box where slotDoHouseKeeping() received | 131 | //especially this solves a problem which appeared on my box where slotDoHouseKeeping() received |
133 | //only 4 bytes (with some debug output around the write()'s it received all 8 bytes) | 132 | //only 4 bytes (with some debug output around the write()'s it received all 8 bytes) |
134 | //don't know why this happened, but when writing all 8 bytes at once it works here, aleXXX | 133 | //don't know why this happened, but when writing all 8 bytes at once it works here, aleXXX |
135 | struct waitdata | 134 | struct waitdata |
136 | { | 135 | { |
137 | pid_t pid; | 136 | pid_t pid; |
138 | int status; | 137 | int status; |
139 | }; | 138 | }; |
140 | 139 | ||
141 | void OProcessController::theSigCHLDHandler(int arg) | 140 | void OProcessController::theSigCHLDHandler(int arg) |
142 | { | 141 | { |
143 | struct waitdata wd; | 142 | struct waitdata wd; |
144 | // int status; | 143 | // int status; |
145 | // pid_t this_pid; | 144 | // pid_t this_pid; |
146 | int saved_errno; | 145 | int saved_errno; |
147 | 146 | ||
148 | saved_errno = errno; | 147 | saved_errno = errno; |
149 | // since waitpid and write change errno, we have to save it and restore it | 148 | // since waitpid and write change errno, we have to save it and restore it |
150 | // (Richard Stevens, Advanced programming in the Unix Environment) | 149 | // (Richard Stevens, Advanced programming in the Unix Environment) |
151 | 150 | ||
152 | bool found = false; | 151 | bool found = false; |
153 | if( theOProcessController != 0 ) | 152 | if( theOProcessController != 0 ) |
154 | { | 153 | { |
155 | // iterating the list doesn't perform any system call | 154 | // iterating the list doesn't perform any system call |
156 | for( QValueList<OProcess*>::ConstIterator it = theOProcessController->processList.begin(); | 155 | for( QValueList<OProcess*>::ConstIterator it = theOProcessController->processList.begin(); |
157 | it != theOProcessController->processList.end(); | 156 | it != theOProcessController->processList.end(); |
158 | ++it ) | 157 | ++it ) |
159 | { | 158 | { |
160 | if( !(*it)->isRunning()) | 159 | if( !(*it)->isRunning()) |
161 | continue; | 160 | continue; |
162 | wd.pid = waitpid( (*it)->pid(), &wd.status, WNOHANG ); | 161 | wd.pid = waitpid( (*it)->pid(), &wd.status, WNOHANG ); |
163 | if ( wd.pid > 0 ) | 162 | if ( wd.pid > 0 ) |
164 | { | 163 | { |
165 | ::write(theOProcessController->fd[1], &wd, sizeof(wd)); | 164 | ::write(theOProcessController->fd[1], &wd, sizeof(wd)); |
166 | found = true; | 165 | found = true; |
167 | } | 166 | } |
168 | } | 167 | } |
169 | } | 168 | } |
170 | if( !found && oldChildHandlerData.sa_handler != SIG_IGN | 169 | if( !found && oldChildHandlerData.sa_handler != SIG_IGN |
171 | && oldChildHandlerData.sa_handler != SIG_DFL ) | 170 | && oldChildHandlerData.sa_handler != SIG_DFL ) |
172 | oldChildHandlerData.sa_handler( arg ); // call the old handler | 171 | oldChildHandlerData.sa_handler( arg ); // call the old handler |
173 | // handle the rest | 172 | // handle the rest |
174 | if( theOProcessController != 0 ) | 173 | if( theOProcessController != 0 ) |
175 | { | 174 | { |
176 | static const struct waitdata dwd = { 0, 0 } | 175 | static const struct waitdata dwd = { 0, 0 } |
177 | ; // delayed waitpid() | 176 | ; // delayed waitpid() |
178 | ::write(theOProcessController->fd[1], &dwd, sizeof(dwd)); | 177 | ::write(theOProcessController->fd[1], &dwd, sizeof(dwd)); |
179 | } | 178 | } |
180 | else | 179 | else |
181 | { | 180 | { |
182 | int dummy; | 181 | int dummy; |
183 | while( waitpid( -1, &dummy, WNOHANG ) > 0 ) | 182 | while( waitpid( -1, &dummy, WNOHANG ) > 0 ) |
184 | ; | 183 | ; |
185 | } | 184 | } |
186 | 185 | ||
187 | errno = saved_errno; | 186 | errno = saved_errno; |
188 | } | 187 | } |
189 | 188 | ||
190 | 189 | ||
191 | 190 | ||
192 | void OProcessController::slotDoHousekeeping(int ) | 191 | void OProcessController::slotDoHousekeeping(int ) |
193 | { | 192 | { |
194 | unsigned int bytes_read = 0; | 193 | unsigned int bytes_read = 0; |
195 | unsigned int errcnt=0; | 194 | unsigned int errcnt=0; |
196 | // read pid and status from the pipe. | 195 | // read pid and status from the pipe. |
197 | struct waitdata wd; | 196 | struct waitdata wd; |
198 | while ((bytes_read < sizeof(wd)) && (errcnt < 50)) | 197 | while ((bytes_read < sizeof(wd)) && (errcnt < 50)) |
199 | { | 198 | { |
200 | int r = ::read(fd[0], ((char *)&wd) + bytes_read, sizeof(wd) - bytes_read); | 199 | int r = ::read(fd[0], ((char *)&wd) + bytes_read, sizeof(wd) - bytes_read); |
201 | if (r > 0) bytes_read += r; | 200 | if (r > 0) bytes_read += r; |
202 | else if (r < 0) errcnt++; | 201 | else if (r < 0) errcnt++; |
203 | } | 202 | } |
204 | if (errcnt >= 50) | 203 | if (errcnt >= 50) |
205 | { | 204 | { |
206 | fprintf(stderr, | 205 | fprintf(stderr, |
207 | "Error: Max. error count for pipe read " | 206 | "Error: Max. error count for pipe read " |
208 | "exceeded in OProcessController::slotDoHousekeeping\n"); | 207 | "exceeded in OProcessController::slotDoHousekeeping\n"); |
209 | return; // it makes no sense to continue here! | 208 | return; // it makes no sense to continue here! |
210 | } | 209 | } |
211 | if (bytes_read != sizeof(wd)) | 210 | if (bytes_read != sizeof(wd)) |
212 | { | 211 | { |
213 | fprintf(stderr, | 212 | fprintf(stderr, |
214 | "Error: Could not read info from signal handler %d <> %d!\n", | 213 | "Error: Could not read info from signal handler %d <> %d!\n", |
215 | bytes_read, sizeof(wd)); | 214 | bytes_read, sizeof(wd)); |
216 | return; // it makes no sense to continue here! | 215 | return; // it makes no sense to continue here! |
217 | } | 216 | } |
218 | if (wd.pid==0) | 217 | if (wd.pid==0) |
219 | { // special case, see delayedChildrenCleanup() | 218 | { // special case, see delayedChildrenCleanup() |
220 | delayedChildrenCleanupTimer.start( 1000, true ); | 219 | delayedChildrenCleanupTimer.start( 1000, true ); |
221 | return; | 220 | return; |
222 | } | 221 | } |
223 | 222 | ||
224 | for( QValueList<OProcess*>::ConstIterator it = processList.begin(); | 223 | for( QValueList<OProcess*>::ConstIterator it = processList.begin(); |
225 | it != processList.end(); | 224 | it != processList.end(); |
226 | ++it ) | 225 | ++it ) |
227 | { | 226 | { |
228 | OProcess* proc = *it; | 227 | OProcess* proc = *it; |
229 | if (proc->pid() == wd.pid) | 228 | if (proc->pid() == wd.pid) |
230 | { | 229 | { |
231 | // process has exited, so do emit the respective events | 230 | // process has exited, so do emit the respective events |
232 | if (proc->run_mode == OProcess::Block) | 231 | if (proc->run_mode == OProcess::Block) |
233 | { | 232 | { |
234 | // If the reads are done blocking then set the status in proc | 233 | // If the reads are done blocking then set the status in proc |
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp index 83677aa..0a361a1 100644 --- a/libopie2/opiecore/oprocess.cpp +++ b/libopie2/opiecore/oprocess.cpp | |||
@@ -1,234 +1,232 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2002-2004 Holger Freyther <zecke@handhelds.org> | 3 | Copyright (C) 2002-2004 Holger Freyther <zecke@handhelds.org> |
4 | and The Opie Team <opie-devel@handhelds.org> | 4 | and The Opie Team <opie-devel@handhelds.org> |
5 | =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at) | 5 | =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at) |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "oprocctrl.h" | 31 | #include "oprocctrl.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/oprocess.h> | 34 | #include <opie2/oprocess.h> |
35 | 35 | ||
36 | /* QT */ | 36 | /* QT */ |
37 | 37 | ||
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qfile.h> | ||
41 | #include <qmap.h> | 40 | #include <qmap.h> |
42 | #include <qregexp.h> | ||
43 | #include <qsocketnotifier.h> | 41 | #include <qsocketnotifier.h> |
44 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
45 | 43 | ||
46 | /* STD */ | 44 | /* STD */ |
47 | #include <errno.h> | 45 | #include <errno.h> |
48 | #include <fcntl.h> | 46 | #include <fcntl.h> |
49 | #include <pwd.h> | 47 | #include <pwd.h> |
50 | #include <stdlib.h> | 48 | #include <stdlib.h> |
51 | #include <signal.h> | 49 | #include <signal.h> |
52 | #include <stdio.h> | 50 | #include <stdio.h> |
53 | #include <string.h> | 51 | #include <string.h> |
54 | #include <sys/time.h> | 52 | #include <sys/time.h> |
55 | #include <sys/types.h> | 53 | #include <sys/types.h> |
56 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
57 | #include <sys/socket.h> | 55 | #include <sys/socket.h> |
58 | #include <unistd.h> | 56 | #include <unistd.h> |
59 | #ifdef HAVE_SYS_SELECT_H | 57 | #ifdef HAVE_SYS_SELECT_H |
60 | #include <sys/select.h> | 58 | #include <sys/select.h> |
61 | #endif | 59 | #endif |
62 | #ifdef HAVE_INITGROUPS | 60 | #ifdef HAVE_INITGROUPS |
63 | #include <grp.h> | 61 | #include <grp.h> |
64 | #endif | 62 | #endif |
65 | 63 | ||
66 | class OProcessPrivate | 64 | class OProcessPrivate |
67 | { | 65 | { |
68 | public: | 66 | public: |
69 | OProcessPrivate() : useShell( false ) | 67 | OProcessPrivate() : useShell( false ) |
70 | { } | 68 | { } |
71 | 69 | ||
72 | bool useShell; | 70 | bool useShell; |
73 | QMap<QString, QString> env; | 71 | QMap<QString, QString> env; |
74 | QString wd; | 72 | QString wd; |
75 | QCString shell; | 73 | QCString shell; |
76 | }; | 74 | }; |
77 | 75 | ||
78 | 76 | ||
79 | OProcess::OProcess( QObject *parent, const char *name ) | 77 | OProcess::OProcess( QObject *parent, const char *name ) |
80 | : QObject( parent, name ) | 78 | : QObject( parent, name ) |
81 | { | 79 | { |
82 | init ( ); | 80 | init ( ); |
83 | } | 81 | } |
84 | 82 | ||
85 | OProcess::OProcess( const QString &arg0, QObject *parent, const char *name ) | 83 | OProcess::OProcess( const QString &arg0, QObject *parent, const char *name ) |
86 | : QObject( parent, name ) | 84 | : QObject( parent, name ) |
87 | { | 85 | { |
88 | init ( ); | 86 | init ( ); |
89 | *this << arg0; | 87 | *this << arg0; |
90 | } | 88 | } |
91 | 89 | ||
92 | OProcess::OProcess( const QStringList &args, QObject *parent, const char *name ) | 90 | OProcess::OProcess( const QStringList &args, QObject *parent, const char *name ) |
93 | : QObject( parent, name ) | 91 | : QObject( parent, name ) |
94 | { | 92 | { |
95 | init ( ); | 93 | init ( ); |
96 | *this << args; | 94 | *this << args; |
97 | } | 95 | } |
98 | 96 | ||
99 | void OProcess::init ( ) | 97 | void OProcess::init ( ) |
100 | { | 98 | { |
101 | run_mode = NotifyOnExit; | 99 | run_mode = NotifyOnExit; |
102 | runs = false; | 100 | runs = false; |
103 | pid_ = 0; | 101 | pid_ = 0; |
104 | status = 0; | 102 | status = 0; |
105 | keepPrivs = false; | 103 | keepPrivs = false; |
106 | innot = 0; | 104 | innot = 0; |
107 | outnot = 0; | 105 | outnot = 0; |
108 | errnot = 0; | 106 | errnot = 0; |
109 | communication = NoCommunication; | 107 | communication = NoCommunication; |
110 | input_data = 0; | 108 | input_data = 0; |
111 | input_sent = 0; | 109 | input_sent = 0; |
112 | input_total = 0; | 110 | input_total = 0; |
113 | d = 0; | 111 | d = 0; |
114 | 112 | ||
115 | if ( 0 == OProcessController::theOProcessController ) | 113 | if ( 0 == OProcessController::theOProcessController ) |
116 | { | 114 | { |
117 | ( void ) new OProcessController(); | 115 | ( void ) new OProcessController(); |
118 | CHECK_PTR( OProcessController::theOProcessController ); | 116 | CHECK_PTR( OProcessController::theOProcessController ); |
119 | } | 117 | } |
120 | 118 | ||
121 | OProcessController::theOProcessController->addOProcess( this ); | 119 | OProcessController::theOProcessController->addOProcess( this ); |
122 | out[ 0 ] = out[ 1 ] = -1; | 120 | out[ 0 ] = out[ 1 ] = -1; |
123 | in[ 0 ] = in[ 1 ] = -1; | 121 | in[ 0 ] = in[ 1 ] = -1; |
124 | err[ 0 ] = err[ 1 ] = -1; | 122 | err[ 0 ] = err[ 1 ] = -1; |
125 | } | 123 | } |
126 | 124 | ||
127 | void OProcess::setEnvironment( const QString &name, const QString &value ) | 125 | void OProcess::setEnvironment( const QString &name, const QString &value ) |
128 | { | 126 | { |
129 | if ( !d ) | 127 | if ( !d ) |
130 | d = new OProcessPrivate; | 128 | d = new OProcessPrivate; |
131 | d->env.insert( name, value ); | 129 | d->env.insert( name, value ); |
132 | } | 130 | } |
133 | 131 | ||
134 | void OProcess::setWorkingDirectory( const QString &dir ) | 132 | void OProcess::setWorkingDirectory( const QString &dir ) |
135 | { | 133 | { |
136 | if ( !d ) | 134 | if ( !d ) |
137 | d = new OProcessPrivate; | 135 | d = new OProcessPrivate; |
138 | d->wd = dir; | 136 | d->wd = dir; |
139 | } | 137 | } |
140 | 138 | ||
141 | void OProcess::setupEnvironment() | 139 | void OProcess::setupEnvironment() |
142 | { | 140 | { |
143 | if ( d ) | 141 | if ( d ) |
144 | { | 142 | { |
145 | QMap<QString, QString>::Iterator it; | 143 | QMap<QString, QString>::Iterator it; |
146 | for ( it = d->env.begin(); it != d->env.end(); ++it ) | 144 | for ( it = d->env.begin(); it != d->env.end(); ++it ) |
147 | setenv( QFile::encodeName( it.key() ).data(), | 145 | setenv( QFile::encodeName( it.key() ).data(), |
148 | QFile::encodeName( it.data() ).data(), 1 ); | 146 | QFile::encodeName( it.data() ).data(), 1 ); |
149 | if ( !d->wd.isEmpty() ) | 147 | if ( !d->wd.isEmpty() ) |
150 | chdir( QFile::encodeName( d->wd ).data() ); | 148 | chdir( QFile::encodeName( d->wd ).data() ); |
151 | } | 149 | } |
152 | } | 150 | } |
153 | 151 | ||
154 | void OProcess::setRunPrivileged( bool keepPrivileges ) | 152 | void OProcess::setRunPrivileged( bool keepPrivileges ) |
155 | { | 153 | { |
156 | keepPrivs = keepPrivileges; | 154 | keepPrivs = keepPrivileges; |
157 | } | 155 | } |
158 | 156 | ||
159 | bool OProcess::runPrivileged() const | 157 | bool OProcess::runPrivileged() const |
160 | { | 158 | { |
161 | return keepPrivs; | 159 | return keepPrivs; |
162 | } | 160 | } |
163 | 161 | ||
164 | OProcess::~OProcess() | 162 | OProcess::~OProcess() |
165 | { | 163 | { |
166 | // destroying the OProcess instance sends a SIGKILL to the | 164 | // destroying the OProcess instance sends a SIGKILL to the |
167 | // child process (if it is running) after removing it from the | 165 | // child process (if it is running) after removing it from the |
168 | // list of valid processes (if the process is not started as | 166 | // list of valid processes (if the process is not started as |
169 | // "DontCare") | 167 | // "DontCare") |
170 | 168 | ||
171 | OProcessController::theOProcessController->removeOProcess( this ); | 169 | OProcessController::theOProcessController->removeOProcess( this ); |
172 | // this must happen before we kill the child | 170 | // this must happen before we kill the child |
173 | // TODO: block the signal while removing the current process from the process list | 171 | // TODO: block the signal while removing the current process from the process list |
174 | 172 | ||
175 | if ( runs && ( run_mode != DontCare ) ) | 173 | if ( runs && ( run_mode != DontCare ) ) |
176 | kill( SIGKILL ); | 174 | kill( SIGKILL ); |
177 | 175 | ||
178 | // Clean up open fd's and socket notifiers. | 176 | // Clean up open fd's and socket notifiers. |
179 | closeStdin(); | 177 | closeStdin(); |
180 | closeStdout(); | 178 | closeStdout(); |
181 | closeStderr(); | 179 | closeStderr(); |
182 | 180 | ||
183 | // TODO: restore SIGCHLD and SIGPIPE handler if this is the last OProcess | 181 | // TODO: restore SIGCHLD and SIGPIPE handler if this is the last OProcess |
184 | delete d; | 182 | delete d; |
185 | } | 183 | } |
186 | 184 | ||
187 | void OProcess::detach() | 185 | void OProcess::detach() |
188 | { | 186 | { |
189 | OProcessController::theOProcessController->removeOProcess( this ); | 187 | OProcessController::theOProcessController->removeOProcess( this ); |
190 | 188 | ||
191 | runs = false; | 189 | runs = false; |
192 | pid_ = 0; | 190 | pid_ = 0; |
193 | 191 | ||
194 | // Clean up open fd's and socket notifiers. | 192 | // Clean up open fd's and socket notifiers. |
195 | closeStdin(); | 193 | closeStdin(); |
196 | closeStdout(); | 194 | closeStdout(); |
197 | closeStderr(); | 195 | closeStderr(); |
198 | } | 196 | } |
199 | 197 | ||
200 | bool OProcess::setExecutable( const QString& proc ) | 198 | bool OProcess::setExecutable( const QString& proc ) |
201 | { | 199 | { |
202 | if ( runs ) | 200 | if ( runs ) |
203 | return false; | 201 | return false; |
204 | 202 | ||
205 | if ( proc.isEmpty() ) | 203 | if ( proc.isEmpty() ) |
206 | return false; | 204 | return false; |
207 | 205 | ||
208 | if ( !arguments.isEmpty() ) | 206 | if ( !arguments.isEmpty() ) |
209 | arguments.remove( arguments.begin() ); | 207 | arguments.remove( arguments.begin() ); |
210 | arguments.prepend( QFile::encodeName( proc ) ); | 208 | arguments.prepend( QFile::encodeName( proc ) ); |
211 | 209 | ||
212 | return true; | 210 | return true; |
213 | } | 211 | } |
214 | 212 | ||
215 | OProcess &OProcess::operator<<( const QStringList& args ) | 213 | OProcess &OProcess::operator<<( const QStringList& args ) |
216 | { | 214 | { |
217 | QStringList::ConstIterator it = args.begin(); | 215 | QStringList::ConstIterator it = args.begin(); |
218 | for ( ; it != args.end() ; ++it ) | 216 | for ( ; it != args.end() ; ++it ) |
219 | arguments.append( QFile::encodeName( *it ) ); | 217 | arguments.append( QFile::encodeName( *it ) ); |
220 | return *this; | 218 | return *this; |
221 | } | 219 | } |
222 | 220 | ||
223 | OProcess &OProcess::operator<<( const QCString& arg ) | 221 | OProcess &OProcess::operator<<( const QCString& arg ) |
224 | { | 222 | { |
225 | return operator<< ( arg.data() ); | 223 | return operator<< ( arg.data() ); |
226 | } | 224 | } |
227 | 225 | ||
228 | OProcess &OProcess::operator<<( const char* arg ) | 226 | OProcess &OProcess::operator<<( const char* arg ) |
229 | { | 227 | { |
230 | arguments.append( arg ); | 228 | arguments.append( arg ); |
231 | return *this; | 229 | return *this; |
232 | } | 230 | } |
233 | 231 | ||
234 | OProcess &OProcess::operator<<( const QString& arg ) | 232 | OProcess &OProcess::operator<<( const QString& arg ) |
diff --git a/libopie2/opiedb/osqlbackendmanager.cpp b/libopie2/opiedb/osqlbackendmanager.cpp index 0f261b9..95ed77b 100644 --- a/libopie2/opiedb/osqlbackendmanager.cpp +++ b/libopie2/opiedb/osqlbackendmanager.cpp | |||
@@ -1,99 +1,98 @@ | |||
1 | #include <qdir.h> | 1 | #include <qdir.h> |
2 | #include <qfile.h> | ||
3 | #include <qmap.h> | 2 | #include <qmap.h> |
4 | 3 | ||
5 | #include "osqlbackendmanager.h" | 4 | #include "osqlbackendmanager.h" |
6 | 5 | ||
7 | namespace { | 6 | namespace { |
8 | class Config { | 7 | class Config { |
9 | typedef QMap<QString, QString> List; | 8 | typedef QMap<QString, QString> List; |
10 | public: | 9 | public: |
11 | Config( const QString& fileName ); | 10 | Config( const QString& fileName ); |
12 | /** | 11 | /** |
13 | * Quite simple layout in nature | 12 | * Quite simple layout in nature |
14 | * BeginFile | 13 | * BeginFile |
15 | * Key = Value | 14 | * Key = Value |
16 | */ | 15 | */ |
17 | bool load(); | 16 | bool load(); |
18 | QString value( const QString& key ); | 17 | QString value( const QString& key ); |
19 | private: | 18 | private: |
20 | List m_list; | 19 | List m_list; |
21 | QString m_fileName; | 20 | QString m_fileName; |
22 | }; | 21 | }; |
23 | Config::Config( const QString& fileName ) | 22 | Config::Config( const QString& fileName ) |
24 | : m_fileName( fileName ) { | 23 | : m_fileName( fileName ) { |
25 | } | 24 | } |
26 | 25 | ||
27 | bool Config::load() { | 26 | bool Config::load() { |
28 | if (!QFile::exists( m_fileName ) ) | 27 | if (!QFile::exists( m_fileName ) ) |
29 | return false; | 28 | return false; |
30 | QFile file( m_fileName ); | 29 | QFile file( m_fileName ); |
31 | if (!file.open(IO_ReadOnly ) ) | 30 | if (!file.open(IO_ReadOnly ) ) |
32 | return false; | 31 | return false; |
33 | QStringList list = QStringList::split( '\n', file.readAll() ); | 32 | QStringList list = QStringList::split( '\n', file.readAll() ); |
34 | QStringList::Iterator it; | 33 | QStringList::Iterator it; |
35 | QString line; | 34 | QString line; |
36 | for (it = list.begin(); it != list.end(); ++it ) { | 35 | for (it = list.begin(); it != list.end(); ++it ) { |
37 | line = (*it).stripWhiteSpace(); | 36 | line = (*it).stripWhiteSpace(); |
38 | qWarning("Anonymous::Config:" + line ); | 37 | qWarning("Anonymous::Config:" + line ); |
39 | QStringList test = QStringList::split(' ', line ); | 38 | QStringList test = QStringList::split(' ', line ); |
40 | m_list.insert( test[0], test[2] ); | 39 | m_list.insert( test[0], test[2] ); |
41 | } | 40 | } |
42 | return true; | 41 | return true; |
43 | } | 42 | } |
44 | QString Config::value( const QString& key ) { | 43 | QString Config::value( const QString& key ) { |
45 | return m_list[key]; | 44 | return m_list[key]; |
46 | } | 45 | } |
47 | }; | 46 | }; |
48 | OSQLBackEndManager::OSQLBackEndManager( const QStringList& path ) | 47 | OSQLBackEndManager::OSQLBackEndManager( const QStringList& path ) |
49 | :m_path( path ) | 48 | :m_path( path ) |
50 | { | 49 | { |
51 | } | 50 | } |
52 | OSQLBackEndManager::~OSQLBackEndManager() { | 51 | OSQLBackEndManager::~OSQLBackEndManager() { |
53 | } | 52 | } |
54 | /** | 53 | /** |
55 | * scan dirs | 54 | * scan dirs |
56 | */ | 55 | */ |
57 | OSQLBackEnd::ValueList OSQLBackEndManager::scan() { | 56 | OSQLBackEnd::ValueList OSQLBackEndManager::scan() { |
58 | OSQLBackEnd::ValueList list; | 57 | OSQLBackEnd::ValueList list; |
59 | if (!m_path.isEmpty() ) { | 58 | if (!m_path.isEmpty() ) { |
60 | QStringList::Iterator it; | 59 | QStringList::Iterator it; |
61 | for ( it = m_path.begin(); it != m_path.end(); ++it ) { | 60 | for ( it = m_path.begin(); it != m_path.end(); ++it ) { |
62 | list += scanDir( (*it) ); | 61 | list += scanDir( (*it) ); |
63 | } | 62 | } |
64 | } | 63 | } |
65 | return list; | 64 | return list; |
66 | } | 65 | } |
67 | /** | 66 | /** |
68 | * scan a specified dir for *.osql | 67 | * scan a specified dir for *.osql |
69 | */ | 68 | */ |
70 | OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) { | 69 | OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) { |
71 | OSQLBackEnd::ValueList list; | 70 | OSQLBackEnd::ValueList list; |
72 | QDir dir( dirName ); | 71 | QDir dir( dirName ); |
73 | if (dir.exists() ) { | 72 | if (dir.exists() ) { |
74 | QStringList files = dir.entryList( "*.osql" ); | 73 | QStringList files = dir.entryList( "*.osql" ); |
75 | QStringList::Iterator it; | 74 | QStringList::Iterator it; |
76 | for ( it = files.begin(); it != files.end(); ++it ) { | 75 | for ( it = files.begin(); it != files.end(); ++it ) { |
77 | list.append( file2backend( (*it) ) ); | 76 | list.append( file2backend( (*it) ) ); |
78 | } | 77 | } |
79 | } | 78 | } |
80 | return list; | 79 | return list; |
81 | } | 80 | } |
82 | 81 | ||
83 | /** | 82 | /** |
84 | * read a config file and convert it to a OSQLBackEnd | 83 | * read a config file and convert it to a OSQLBackEnd |
85 | */ | 84 | */ |
86 | OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { | 85 | OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { |
87 | OSQLBackEnd end; | 86 | OSQLBackEnd end; |
88 | qWarning("fileName: " + file ); | 87 | qWarning("fileName: " + file ); |
89 | Config cfg( file ); | 88 | Config cfg( file ); |
90 | if (cfg.load() ) { | 89 | if (cfg.load() ) { |
91 | end.setName( cfg.value( "Name") ); | 90 | end.setName( cfg.value( "Name") ); |
92 | end.setVendor( cfg.value("Vendor") ); | 91 | end.setVendor( cfg.value("Vendor") ); |
93 | end.setLicense( cfg.value("License") ); | 92 | end.setLicense( cfg.value("License") ); |
94 | end.setLibrary( cfg.value("Library").local8Bit() ); | 93 | end.setLibrary( cfg.value("Library").local8Bit() ); |
95 | end.setDefault( cfg.value("Default").toInt() ); | 94 | end.setDefault( cfg.value("Default").toInt() ); |
96 | end.setPreference( cfg.value("Preference").toInt() ); | 95 | end.setPreference( cfg.value("Preference").toInt() ); |
97 | } | 96 | } |
98 | return end; | 97 | return end; |
99 | } | 98 | } |
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp index b857534..6141504 100644 --- a/libopie2/opiedb/osqlitedriver.cpp +++ b/libopie2/opiedb/osqlitedriver.cpp | |||
@@ -1,189 +1,188 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | =. | 4 | =. |
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 | 30 | ||
31 | #include "osqlresult.h" | ||
32 | #include "osqlquery.h" | 31 | #include "osqlquery.h" |
33 | #include "osqlitedriver.h" | 32 | #include "osqlitedriver.h" |
34 | 33 | ||
35 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
36 | 35 | ||
37 | #include <stdlib.h> | 36 | #include <stdlib.h> |
38 | 37 | ||
39 | // fromLocal8Bit() does not work as expected. Thus it | 38 | // fromLocal8Bit() does not work as expected. Thus it |
40 | // is replaced by fromLatin1() (eilers) | 39 | // is replaced by fromLatin1() (eilers) |
41 | #define __BUGGY_LOCAL8BIT_ | 40 | #define __BUGGY_LOCAL8BIT_ |
42 | 41 | ||
43 | 42 | ||
44 | namespace { | 43 | namespace { |
45 | struct Query { | 44 | struct Query { |
46 | OSQLError::ValueList errors; | 45 | OSQLError::ValueList errors; |
47 | OSQLResultItem::ValueList items; | 46 | OSQLResultItem::ValueList items; |
48 | OSQLiteDriver *driver; | 47 | OSQLiteDriver *driver; |
49 | }; | 48 | }; |
50 | } | 49 | } |
51 | 50 | ||
52 | 51 | ||
53 | OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) | 52 | OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) |
54 | : OSQLDriver( lib ) | 53 | : OSQLDriver( lib ) |
55 | { | 54 | { |
56 | m_sqlite = 0l; | 55 | m_sqlite = 0l; |
57 | } | 56 | } |
58 | 57 | ||
59 | 58 | ||
60 | OSQLiteDriver::~OSQLiteDriver() { | 59 | OSQLiteDriver::~OSQLiteDriver() { |
61 | close(); | 60 | close(); |
62 | } | 61 | } |
63 | 62 | ||
64 | 63 | ||
65 | QString OSQLiteDriver::id()const { | 64 | QString OSQLiteDriver::id()const { |
66 | return QString::fromLatin1("SQLite"); | 65 | return QString::fromLatin1("SQLite"); |
67 | } | 66 | } |
68 | 67 | ||
69 | void OSQLiteDriver::setUserName( const QString& ) {} | 68 | void OSQLiteDriver::setUserName( const QString& ) {} |
70 | 69 | ||
71 | 70 | ||
72 | void OSQLiteDriver::setPassword( const QString& ) {} | 71 | void OSQLiteDriver::setPassword( const QString& ) {} |
73 | 72 | ||
74 | 73 | ||
75 | void OSQLiteDriver::setUrl( const QString& url ) { | 74 | void OSQLiteDriver::setUrl( const QString& url ) { |
76 | m_url = url; | 75 | m_url = url; |
77 | } | 76 | } |
78 | 77 | ||
79 | 78 | ||
80 | void OSQLiteDriver::setOptions( const QStringList& ) { | 79 | void OSQLiteDriver::setOptions( const QStringList& ) { |
81 | } | 80 | } |
82 | 81 | ||
83 | 82 | ||
84 | /* | 83 | /* |
85 | * try to open a db specified via setUrl | 84 | * try to open a db specified via setUrl |
86 | * and options | 85 | * and options |
87 | */ | 86 | */ |
88 | bool OSQLiteDriver::open() { | 87 | bool OSQLiteDriver::open() { |
89 | char *error; | 88 | char *error; |
90 | odebug << "OSQLiteDriver::open: about to open" << oendl; | 89 | odebug << "OSQLiteDriver::open: about to open" << oendl; |
91 | m_sqlite = sqlite_open(m_url.local8Bit(), | 90 | m_sqlite = sqlite_open(m_url.local8Bit(), |
92 | 0, | 91 | 0, |
93 | &error ); | 92 | &error ); |
94 | 93 | ||
95 | /* failed to open */ | 94 | /* failed to open */ |
96 | if (m_sqlite == 0l ) { | 95 | if (m_sqlite == 0l ) { |
97 | // FIXME set the last error | 96 | // FIXME set the last error |
98 | owarn << "OSQLiteDriver::open: " << error << oendl; | 97 | owarn << "OSQLiteDriver::open: " << error << oendl; |
99 | free( error ); | 98 | free( error ); |
100 | return false; | 99 | return false; |
101 | } | 100 | } |
102 | return true; | 101 | return true; |
103 | } | 102 | } |
104 | 103 | ||
105 | 104 | ||
106 | /* close the db | 105 | /* close the db |
107 | * sqlite closes them without | 106 | * sqlite closes them without |
108 | * telling failure or success | 107 | * telling failure or success |
109 | */ | 108 | */ |
110 | bool OSQLiteDriver::close() { | 109 | bool OSQLiteDriver::close() { |
111 | if (m_sqlite ) | 110 | if (m_sqlite ) |
112 | sqlite_close( m_sqlite ), m_sqlite=0l; | 111 | sqlite_close( m_sqlite ), m_sqlite=0l; |
113 | 112 | ||
114 | return true; | 113 | return true; |
115 | } | 114 | } |
116 | 115 | ||
117 | 116 | ||
118 | /* Query */ | 117 | /* Query */ |
119 | OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { | 118 | OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { |
120 | if ( !m_sqlite ) { | 119 | if ( !m_sqlite ) { |
121 | // FIXME set error code | 120 | // FIXME set error code |
122 | OSQLResult result( OSQLResult::Failure ); | 121 | OSQLResult result( OSQLResult::Failure ); |
123 | return result; | 122 | return result; |
124 | } | 123 | } |
125 | Query query; | 124 | Query query; |
126 | query.driver = this; | 125 | query.driver = this; |
127 | char *err; | 126 | char *err; |
128 | /* SQLITE_OK 0 if return code > 0 == failure */ | 127 | /* SQLITE_OK 0 if return code > 0 == failure */ |
129 | if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { | 128 | if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { |
130 | owarn << "OSQLiteDriver::query: Error while executing" << oendl; | 129 | owarn << "OSQLiteDriver::query: Error while executing" << oendl; |
131 | free(err ); | 130 | free(err ); |
132 | // FixMe Errors | 131 | // FixMe Errors |
133 | } | 132 | } |
134 | 133 | ||
135 | OSQLResult result(OSQLResult::Success, | 134 | OSQLResult result(OSQLResult::Success, |
136 | query.items, | 135 | query.items, |
137 | query.errors ); | 136 | query.errors ); |
138 | return result; | 137 | return result; |
139 | } | 138 | } |
140 | 139 | ||
141 | 140 | ||
142 | OSQLTable::ValueList OSQLiteDriver::tables() const { | 141 | OSQLTable::ValueList OSQLiteDriver::tables() const { |
143 | 142 | ||
144 | } | 143 | } |
145 | 144 | ||
146 | 145 | ||
147 | OSQLError OSQLiteDriver::lastError() { | 146 | OSQLError OSQLiteDriver::lastError() { |
148 | OSQLError error; | 147 | OSQLError error; |
149 | return error; | 148 | return error; |
150 | }; | 149 | }; |
151 | 150 | ||
152 | 151 | ||
153 | /* handle a callback add the row to the global | 152 | /* handle a callback add the row to the global |
154 | * OSQLResultItem | 153 | * OSQLResultItem |
155 | */ | 154 | */ |
156 | int OSQLiteDriver::handleCallBack( int, char**, char** ) { | 155 | int OSQLiteDriver::handleCallBack( int, char**, char** ) { |
157 | return 0; | 156 | return 0; |
158 | } | 157 | } |
159 | 158 | ||
160 | 159 | ||
161 | /* callback_handler add the values to the list*/ | 160 | /* callback_handler add the values to the list*/ |
162 | int OSQLiteDriver::call_back( void* voi, int argc, | 161 | int OSQLiteDriver::call_back( void* voi, int argc, |
163 | char** argv, char** columns) { | 162 | char** argv, char** columns) { |
164 | Query* qu = (Query*)voi; | 163 | Query* qu = (Query*)voi; |
165 | 164 | ||
166 | //copy them over to a OSQLResultItem | 165 | //copy them over to a OSQLResultItem |
167 | QMap<QString, QString> tableString; | 166 | QMap<QString, QString> tableString; |
168 | QMap<int, QString> tableInt; | 167 | QMap<int, QString> tableInt; |
169 | for (int i = 0; i < argc; i++ ) { | 168 | for (int i = 0; i < argc; i++ ) { |
170 | 169 | ||
171 | #ifdef __BUGGY_LOCAL8BIT_ | 170 | #ifdef __BUGGY_LOCAL8BIT_ |
172 | tableInt.insert( i, QString::fromLatin1( argv[i] ) ); | 171 | tableInt.insert( i, QString::fromLatin1( argv[i] ) ); |
173 | tableString.insert( QString::fromLatin1( columns[i] ), | 172 | tableString.insert( QString::fromLatin1( columns[i] ), |
174 | QString::fromLatin1( argv[i] ) ); | 173 | QString::fromLatin1( argv[i] ) ); |
175 | #else | 174 | #else |
176 | tableInt.insert( i, QString::fromLocal8Bit( argv[i] ) ); | 175 | tableInt.insert( i, QString::fromLocal8Bit( argv[i] ) ); |
177 | tableString.insert( QString::fromLocal8Bit( columns[i] ), | 176 | tableString.insert( QString::fromLocal8Bit( columns[i] ), |
178 | QString::fromLocal8Bit( argv[i] ) ); | 177 | QString::fromLocal8Bit( argv[i] ) ); |
179 | #endif | 178 | #endif |
180 | } | 179 | } |
181 | OSQLResultItem item( tableString, tableInt ); | 180 | OSQLResultItem item( tableString, tableInt ); |
182 | qu->items.append( item ); | 181 | qu->items.append( item ); |
183 | 182 | ||
184 | return ((Query*)voi)->driver->handleCallBack( argc, | 183 | return ((Query*)voi)->driver->handleCallBack( argc, |
185 | argv, | 184 | argv, |
186 | columns ); | 185 | columns ); |
187 | 186 | ||
188 | 187 | ||
189 | } | 188 | } |
diff --git a/libopie2/opiedb/osqlmanager.cpp b/libopie2/opiedb/osqlmanager.cpp index b0fea04..766ebe1 100644 --- a/libopie2/opiedb/osqlmanager.cpp +++ b/libopie2/opiedb/osqlmanager.cpp | |||
@@ -1,83 +1,81 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include "osqlbackend.h" | ||
5 | #include "osqldriver.h" | ||
6 | #include "osqlmanager.h" | 4 | #include "osqlmanager.h" |
7 | #include "osqlbackendmanager.h" | 5 | #include "osqlbackendmanager.h" |
8 | #include "osqlitedriver.h" | 6 | #include "osqlitedriver.h" |
9 | 7 | ||
10 | OSQLManager::OSQLManager() { | 8 | OSQLManager::OSQLManager() { |
11 | } | 9 | } |
12 | OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { | 10 | OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { |
13 | m_list.clear(); | 11 | m_list.clear(); |
14 | QString opie = QString::fromLatin1( getenv("OPIEDIR") ); | 12 | QString opie = QString::fromLatin1( getenv("OPIEDIR") ); |
15 | QString qpe = QString::fromLatin1( getenv("QPEDIR") ); | 13 | QString qpe = QString::fromLatin1( getenv("QPEDIR") ); |
16 | 14 | ||
17 | if ( !m_path.contains(opie) && !opie.isEmpty() ) | 15 | if ( !m_path.contains(opie) && !opie.isEmpty() ) |
18 | m_path << opie; | 16 | m_path << opie; |
19 | if ( !m_path.contains(qpe) && !qpe.isEmpty() ) | 17 | if ( !m_path.contains(qpe) && !qpe.isEmpty() ) |
20 | m_path << qpe; | 18 | m_path << qpe; |
21 | 19 | ||
22 | OSQLBackEndManager mng( m_path ); | 20 | OSQLBackEndManager mng( m_path ); |
23 | m_list = mng.scan(); | 21 | m_list = mng.scan(); |
24 | m_list += builtIn(); | 22 | m_list += builtIn(); |
25 | 23 | ||
26 | return m_list; | 24 | return m_list; |
27 | } | 25 | } |
28 | /* | 26 | /* |
29 | * loading dso's is currently not enabled due problems with QLibrary | 27 | * loading dso's is currently not enabled due problems with QLibrary |
30 | * beeing in libqpe and not libqte | 28 | * beeing in libqpe and not libqte |
31 | */ | 29 | */ |
32 | OSQLDriver* OSQLManager::load( const QString& name ) { | 30 | OSQLDriver* OSQLManager::load( const QString& name ) { |
33 | OSQLDriver* driver = 0l; | 31 | OSQLDriver* driver = 0l; |
34 | 32 | ||
35 | if ( name == "SQLite" ) { | 33 | if ( name == "SQLite" ) { |
36 | driver = new OSQLiteDriver(); | 34 | driver = new OSQLiteDriver(); |
37 | } | 35 | } |
38 | return driver; | 36 | return driver; |
39 | } | 37 | } |
40 | /* | 38 | /* |
41 | * same as above | 39 | * same as above |
42 | */ | 40 | */ |
43 | OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { | 41 | OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { |
44 | OSQLDriver *driver = 0l; | 42 | OSQLDriver *driver = 0l; |
45 | if ( end.library() == "builtin" && | 43 | if ( end.library() == "builtin" && |
46 | end.name() == "SQLite" ) | 44 | end.name() == "SQLite" ) |
47 | driver = new OSQLiteDriver(); | 45 | driver = new OSQLiteDriver(); |
48 | 46 | ||
49 | return driver; | 47 | return driver; |
50 | } | 48 | } |
51 | /* | 49 | /* |
52 | * let's find the a default with the highes preference | 50 | * let's find the a default with the highes preference |
53 | */ | 51 | */ |
54 | OSQLDriver* OSQLManager::standard() { | 52 | OSQLDriver* OSQLManager::standard() { |
55 | OSQLDriver* driver =0l; | 53 | OSQLDriver* driver =0l; |
56 | if ( m_list.isEmpty() ) queryBackEnd(); | 54 | if ( m_list.isEmpty() ) queryBackEnd(); |
57 | OSQLBackEnd::ValueList::Iterator it; | 55 | OSQLBackEnd::ValueList::Iterator it; |
58 | OSQLBackEnd back; | 56 | OSQLBackEnd back; |
59 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 57 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
60 | if ( (*it).isDefault() && | 58 | if ( (*it).isDefault() && |
61 | back.preference() < (*it).preference() ) { | 59 | back.preference() < (*it).preference() ) { |
62 | back = (*it); | 60 | back = (*it); |
63 | } | 61 | } |
64 | } | 62 | } |
65 | driver = load( back ); | 63 | driver = load( back ); |
66 | return driver; | 64 | return driver; |
67 | } | 65 | } |
68 | void OSQLManager::registerPath( const QString& path ) { | 66 | void OSQLManager::registerPath( const QString& path ) { |
69 | m_path << path; | 67 | m_path << path; |
70 | } | 68 | } |
71 | bool OSQLManager::unregisterPath( const QString& path ) { | 69 | bool OSQLManager::unregisterPath( const QString& path ) { |
72 | m_path.remove( path ); | 70 | m_path.remove( path ); |
73 | return true; | 71 | return true; |
74 | } | 72 | } |
75 | OSQLBackEnd::ValueList OSQLManager::builtIn()const { | 73 | OSQLBackEnd::ValueList OSQLManager::builtIn()const { |
76 | OSQLBackEnd::ValueList list; | 74 | OSQLBackEnd::ValueList list; |
77 | // create the OSQLiteBackend | 75 | // create the OSQLiteBackend |
78 | OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); | 76 | OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); |
79 | back.setDefault( true ); | 77 | back.setDefault( true ); |
80 | back.setPreference( 50 ); | 78 | back.setPreference( 50 ); |
81 | list.append( back ); | 79 | list.append( back ); |
82 | return list; | 80 | return list; |
83 | } | 81 | } |
diff --git a/libopie2/opiedb/osqlresult.cpp b/libopie2/opiedb/osqlresult.cpp index 490fb45..42da356 100644 --- a/libopie2/opiedb/osqlresult.cpp +++ b/libopie2/opiedb/osqlresult.cpp | |||
@@ -1,127 +1,126 @@ | |||
1 | 1 | ||
2 | #include "osqlquery.h" | ||
3 | #include "osqlresult.h" | 2 | #include "osqlresult.h" |
4 | 3 | ||
5 | OSQLResultItem::OSQLResultItem( const TableString& string, | 4 | OSQLResultItem::OSQLResultItem( const TableString& string, |
6 | const TableInt& Int) | 5 | const TableInt& Int) |
7 | : m_string( string ), m_int( Int ) | 6 | : m_string( string ), m_int( Int ) |
8 | { | 7 | { |
9 | 8 | ||
10 | } | 9 | } |
11 | OSQLResultItem::~OSQLResultItem() { | 10 | OSQLResultItem::~OSQLResultItem() { |
12 | } | 11 | } |
13 | OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) { | 12 | OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) { |
14 | *this = item; | 13 | *this = item; |
15 | } | 14 | } |
16 | OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) { | 15 | OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) { |
17 | m_string = other.m_string; | 16 | m_string = other.m_string; |
18 | m_int = other.m_int; | 17 | m_int = other.m_int; |
19 | return *this; | 18 | return *this; |
20 | } | 19 | } |
21 | OSQLResultItem::TableString OSQLResultItem::tableString()const{ | 20 | OSQLResultItem::TableString OSQLResultItem::tableString()const{ |
22 | return m_string; | 21 | return m_string; |
23 | } | 22 | } |
24 | OSQLResultItem::TableInt OSQLResultItem::tableInt()const { | 23 | OSQLResultItem::TableInt OSQLResultItem::tableInt()const { |
25 | return m_int; | 24 | return m_int; |
26 | } | 25 | } |
27 | QString OSQLResultItem::data( const QString& columnName, bool *ok ) { | 26 | QString OSQLResultItem::data( const QString& columnName, bool *ok ) { |
28 | TableString::Iterator it = m_string.find( columnName ); | 27 | TableString::Iterator it = m_string.find( columnName ); |
29 | 28 | ||
30 | /* if found */ | 29 | /* if found */ |
31 | if ( it != m_string.end() ) { | 30 | if ( it != m_string.end() ) { |
32 | if ( ok ) *ok = true; | 31 | if ( ok ) *ok = true; |
33 | return it.data(); | 32 | return it.data(); |
34 | }else{ | 33 | }else{ |
35 | if ( ok ) *ok = false; | 34 | if ( ok ) *ok = false; |
36 | return QString::null; | 35 | return QString::null; |
37 | } | 36 | } |
38 | 37 | ||
39 | } | 38 | } |
40 | QString OSQLResultItem::data( int column, bool *ok ) { | 39 | QString OSQLResultItem::data( int column, bool *ok ) { |
41 | TableInt::Iterator it = m_int.find( column ); | 40 | TableInt::Iterator it = m_int.find( column ); |
42 | 41 | ||
43 | /* if found */ | 42 | /* if found */ |
44 | if ( it != m_int.end() ) { | 43 | if ( it != m_int.end() ) { |
45 | if ( ok ) *ok = true; | 44 | if ( ok ) *ok = true; |
46 | return it.data(); | 45 | return it.data(); |
47 | }else{ | 46 | }else{ |
48 | if ( ok ) *ok = false; | 47 | if ( ok ) *ok = false; |
49 | return QString::null; | 48 | return QString::null; |
50 | } | 49 | } |
51 | } | 50 | } |
52 | /* | 51 | /* |
53 | * DateFormat is 'YYYY-MM-DD' | 52 | * DateFormat is 'YYYY-MM-DD' |
54 | */ | 53 | */ |
55 | QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) { | 54 | QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) { |
56 | QDate date = QDate::currentDate(); | 55 | QDate date = QDate::currentDate(); |
57 | QString str = data( column, ok ); | 56 | QString str = data( column, ok ); |
58 | if (!str.isEmpty() ) { | 57 | if (!str.isEmpty() ) { |
59 | ;// convert | 58 | ;// convert |
60 | } | 59 | } |
61 | return date; | 60 | return date; |
62 | } | 61 | } |
63 | QDate OSQLResultItem::dataToDate( int column, bool *ok ) { | 62 | QDate OSQLResultItem::dataToDate( int column, bool *ok ) { |
64 | QDate date = QDate::currentDate(); | 63 | QDate date = QDate::currentDate(); |
65 | QString str = data( column, ok ); | 64 | QString str = data( column, ok ); |
66 | if (!str.isEmpty() ) { | 65 | if (!str.isEmpty() ) { |
67 | ;// convert | 66 | ;// convert |
68 | } | 67 | } |
69 | return date; | 68 | return date; |
70 | 69 | ||
71 | } | 70 | } |
72 | QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) { | 71 | QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) { |
73 | QDateTime time = QDateTime::currentDateTime(); | 72 | QDateTime time = QDateTime::currentDateTime(); |
74 | return time; | 73 | return time; |
75 | } | 74 | } |
76 | QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) { | 75 | QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) { |
77 | QDateTime time = QDateTime::currentDateTime(); | 76 | QDateTime time = QDateTime::currentDateTime(); |
78 | return time; | 77 | return time; |
79 | } | 78 | } |
80 | 79 | ||
81 | OSQLResult::OSQLResult( enum State state, | 80 | OSQLResult::OSQLResult( enum State state, |
82 | const OSQLResultItem::ValueList& list, | 81 | const OSQLResultItem::ValueList& list, |
83 | const OSQLError::ValueList& error ) | 82 | const OSQLError::ValueList& error ) |
84 | : m_state( state ), m_list( list ), m_error( error ) | 83 | : m_state( state ), m_list( list ), m_error( error ) |
85 | { | 84 | { |
86 | 85 | ||
87 | } | 86 | } |
88 | OSQLResult::~OSQLResult() { | 87 | OSQLResult::~OSQLResult() { |
89 | 88 | ||
90 | } | 89 | } |
91 | OSQLResult::State OSQLResult::state()const { | 90 | OSQLResult::State OSQLResult::state()const { |
92 | return m_state; | 91 | return m_state; |
93 | } | 92 | } |
94 | void OSQLResult::setState( OSQLResult::State state ) { | 93 | void OSQLResult::setState( OSQLResult::State state ) { |
95 | m_state = state; | 94 | m_state = state; |
96 | } | 95 | } |
97 | OSQLError::ValueList OSQLResult::errors()const { | 96 | OSQLError::ValueList OSQLResult::errors()const { |
98 | return m_error; | 97 | return m_error; |
99 | } | 98 | } |
100 | void OSQLResult::setErrors( const OSQLError::ValueList& err ) { | 99 | void OSQLResult::setErrors( const OSQLError::ValueList& err ) { |
101 | m_error = err; | 100 | m_error = err; |
102 | } | 101 | } |
103 | OSQLResultItem::ValueList OSQLResult::results()const { | 102 | OSQLResultItem::ValueList OSQLResult::results()const { |
104 | return m_list; | 103 | return m_list; |
105 | } | 104 | } |
106 | void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) { | 105 | void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) { |
107 | m_list = result; | 106 | m_list = result; |
108 | } | 107 | } |
109 | OSQLResultItem OSQLResult::first() { | 108 | OSQLResultItem OSQLResult::first() { |
110 | it = m_list.begin(); | 109 | it = m_list.begin(); |
111 | return (*it); | 110 | return (*it); |
112 | } | 111 | } |
113 | OSQLResultItem OSQLResult::next(){ | 112 | OSQLResultItem OSQLResult::next(){ |
114 | ++it; | 113 | ++it; |
115 | return (*it); | 114 | return (*it); |
116 | } | 115 | } |
117 | bool OSQLResult::atEnd(){ | 116 | bool OSQLResult::atEnd(){ |
118 | if ( it == m_list.end() ) | 117 | if ( it == m_list.end() ) |
119 | return true; | 118 | return true; |
120 | 119 | ||
121 | return false; | 120 | return false; |
122 | } | 121 | } |
123 | OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const { | 122 | OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const { |
124 | OSQLResultItem::ValueList::ConstIterator it; | 123 | OSQLResultItem::ValueList::ConstIterator it; |
125 | it = m_list.begin(); | 124 | it = m_list.begin(); |
126 | return it; | 125 | return it; |
127 | } | 126 | } |
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp index ca63389..51e088c 100644 --- a/libopie2/opiemm/osoundsystem.cpp +++ b/libopie2/opiemm/osoundsystem.cpp | |||
@@ -1,235 +1,234 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <opie2/osoundsystem.h> | 32 | #include <opie2/osoundsystem.h> |
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | 34 | ||
35 | #include <errno.h> | 35 | #include <errno.h> |
36 | #include <fcntl.h> | 36 | #include <fcntl.h> |
37 | #include <string.h> | 37 | #include <string.h> |
38 | #include <sys/ioctl.h> | 38 | #include <sys/ioctl.h> |
39 | #include <sys/types.h> | 39 | #include <sys/types.h> |
40 | #include <sys/soundcard.h> | 40 | #include <sys/soundcard.h> |
41 | #include <sys/stat.h> | 41 | #include <sys/stat.h> |
42 | 42 | ||
43 | #include <qstringlist.h> | ||
44 | 43 | ||
45 | /*====================================================================================== | 44 | /*====================================================================================== |
46 | * OSoundSystem | 45 | * OSoundSystem |
47 | *======================================================================================*/ | 46 | *======================================================================================*/ |
48 | 47 | ||
49 | OSoundSystem* OSoundSystem::_instance = 0; | 48 | OSoundSystem* OSoundSystem::_instance = 0; |
50 | 49 | ||
51 | OSoundSystem::OSoundSystem() | 50 | OSoundSystem::OSoundSystem() |
52 | { | 51 | { |
53 | odebug << "OSoundSystem::OSoundSystem()" << oendl; | 52 | odebug << "OSoundSystem::OSoundSystem()" << oendl; |
54 | synchronize(); | 53 | synchronize(); |
55 | } | 54 | } |
56 | 55 | ||
57 | void OSoundSystem::synchronize() | 56 | void OSoundSystem::synchronize() |
58 | { | 57 | { |
59 | // gather available interfaces by inspecting /dev | 58 | // gather available interfaces by inspecting /dev |
60 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 59 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
61 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 60 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
62 | 61 | ||
63 | _interfaces.clear(); | 62 | _interfaces.clear(); |
64 | _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); | 63 | _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); |
65 | 64 | ||
66 | 65 | ||
67 | /* | 66 | /* |
68 | 67 | ||
69 | QString str; | 68 | QString str; |
70 | QFile f( "/dev/sound" ); | 69 | QFile f( "/dev/sound" ); |
71 | bool hasFile = f.open( IO_ReadOnly ); | 70 | bool hasFile = f.open( IO_ReadOnly ); |
72 | if ( !hasFile ) | 71 | if ( !hasFile ) |
73 | { | 72 | { |
74 | odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; | 73 | odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; |
75 | return; | 74 | return; |
76 | } | 75 | } |
77 | QTextStream s( &f ); | 76 | QTextStream s( &f ); |
78 | s.readLine(); | 77 | s.readLine(); |
79 | s.readLine(); | 78 | s.readLine(); |
80 | while ( !s.atEnd() ) | 79 | while ( !s.atEnd() ) |
81 | { | 80 | { |
82 | s >> str; | 81 | s >> str; |
83 | str.truncate( str.find( ':' ) ); | 82 | str.truncate( str.find( ':' ) ); |
84 | qDebug( "OSoundSystem: found interface '%s'", (const char*) str ); | 83 | qDebug( "OSoundSystem: found interface '%s'", (const char*) str ); |
85 | OAudioInterface* iface; | 84 | OAudioInterface* iface; |
86 | iface = new OAudioInterface( this, (const char*) str ); | 85 | iface = new OAudioInterface( this, (const char*) str ); |
87 | 86 | ||
88 | _interfaces.insert( str, iface ); | 87 | _interfaces.insert( str, iface ); |
89 | s.readLine(); | 88 | s.readLine(); |
90 | } | 89 | } |
91 | */ | 90 | */ |
92 | } | 91 | } |
93 | 92 | ||
94 | 93 | ||
95 | int OSoundSystem::count() const | 94 | int OSoundSystem::count() const |
96 | { | 95 | { |
97 | return _interfaces.count(); | 96 | return _interfaces.count(); |
98 | } | 97 | } |
99 | 98 | ||
100 | 99 | ||
101 | OSoundCard* OSoundSystem::card( const QString& iface ) const | 100 | OSoundCard* OSoundSystem::card( const QString& iface ) const |
102 | { | 101 | { |
103 | return _interfaces[iface]; | 102 | return _interfaces[iface]; |
104 | } | 103 | } |
105 | 104 | ||
106 | 105 | ||
107 | OSoundSystem* OSoundSystem::instance() | 106 | OSoundSystem* OSoundSystem::instance() |
108 | { | 107 | { |
109 | if ( !_instance ) _instance = new OSoundSystem(); | 108 | if ( !_instance ) _instance = new OSoundSystem(); |
110 | return _instance; | 109 | return _instance; |
111 | } | 110 | } |
112 | 111 | ||
113 | 112 | ||
114 | OSoundSystem::CardIterator OSoundSystem::iterator() const | 113 | OSoundSystem::CardIterator OSoundSystem::iterator() const |
115 | { | 114 | { |
116 | return OSoundSystem::CardIterator( _interfaces ); | 115 | return OSoundSystem::CardIterator( _interfaces ); |
117 | } | 116 | } |
118 | 117 | ||
119 | 118 | ||
120 | /*====================================================================================== | 119 | /*====================================================================================== |
121 | * OSoundCard | 120 | * OSoundCard |
122 | *======================================================================================*/ | 121 | *======================================================================================*/ |
123 | 122 | ||
124 | OSoundCard::OSoundCard( QObject* parent, const char* name ) | 123 | OSoundCard::OSoundCard( QObject* parent, const char* name ) |
125 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) | 124 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) |
126 | { | 125 | { |
127 | odebug << "OSoundCard::OSoundCard()" << oendl; | 126 | odebug << "OSoundCard::OSoundCard()" << oendl; |
128 | init(); | 127 | init(); |
129 | } | 128 | } |
130 | 129 | ||
131 | 130 | ||
132 | OSoundCard::~OSoundCard() | 131 | OSoundCard::~OSoundCard() |
133 | { | 132 | { |
134 | } | 133 | } |
135 | 134 | ||
136 | 135 | ||
137 | void OSoundCard::init() | 136 | void OSoundCard::init() |
138 | { | 137 | { |
139 | _audio = new OAudioInterface( this, "/dev/dsp" ); | 138 | _audio = new OAudioInterface( this, "/dev/dsp" ); |
140 | _mixer = new OMixerInterface( this, "/dev/mixer" ); | 139 | _mixer = new OMixerInterface( this, "/dev/mixer" ); |
141 | } | 140 | } |
142 | 141 | ||
143 | 142 | ||
144 | /*====================================================================================== | 143 | /*====================================================================================== |
145 | * OAudioInterface | 144 | * OAudioInterface |
146 | *======================================================================================*/ | 145 | *======================================================================================*/ |
147 | 146 | ||
148 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) | 147 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) |
149 | :QObject( parent, name ) | 148 | :QObject( parent, name ) |
150 | { | 149 | { |
151 | odebug << "OAudioInterface::OAudioInterface()" << oendl; | 150 | odebug << "OAudioInterface::OAudioInterface()" << oendl; |
152 | init(); | 151 | init(); |
153 | } | 152 | } |
154 | 153 | ||
155 | 154 | ||
156 | OAudioInterface::~OAudioInterface() | 155 | OAudioInterface::~OAudioInterface() |
157 | { | 156 | { |
158 | } | 157 | } |
159 | 158 | ||
160 | 159 | ||
161 | void OAudioInterface::init() | 160 | void OAudioInterface::init() |
162 | { | 161 | { |
163 | 162 | ||
164 | 163 | ||
165 | } | 164 | } |
166 | 165 | ||
167 | 166 | ||
168 | /*====================================================================================== | 167 | /*====================================================================================== |
169 | * OMixerInterface | 168 | * OMixerInterface |
170 | *======================================================================================*/ | 169 | *======================================================================================*/ |
171 | 170 | ||
172 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) | 171 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) |
173 | :QObject( parent, name ) | 172 | :QObject( parent, name ) |
174 | { | 173 | { |
175 | odebug << "OMixerInterface::OMixerInterface()" << oendl; | 174 | odebug << "OMixerInterface::OMixerInterface()" << oendl; |
176 | init(); | 175 | init(); |
177 | } | 176 | } |
178 | 177 | ||
179 | 178 | ||
180 | OMixerInterface::~OMixerInterface() | 179 | OMixerInterface::~OMixerInterface() |
181 | { | 180 | { |
182 | } | 181 | } |
183 | 182 | ||
184 | 183 | ||
185 | void OMixerInterface::init() | 184 | void OMixerInterface::init() |
186 | { | 185 | { |
187 | // open the device | 186 | // open the device |
188 | _fd = ::open( name(), O_RDWR ); | 187 | _fd = ::open( name(), O_RDWR ); |
189 | if ( _fd == -1 ) | 188 | if ( _fd == -1 ) |
190 | { | 189 | { |
191 | owarn << "OMixerInterface::init(): Can't open mixer." << oendl; | 190 | owarn << "OMixerInterface::init(): Can't open mixer." << oendl; |
192 | return; | 191 | return; |
193 | } | 192 | } |
194 | 193 | ||
195 | // construct the device capabilities | 194 | // construct the device capabilities |
196 | int devmask = 0; | 195 | int devmask = 0; |
197 | if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) | 196 | if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) |
198 | { | 197 | { |
199 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); | 198 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); |
200 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); | 199 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); |
201 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); | 200 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); |
202 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); | 201 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); |
203 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); | 202 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); |
204 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); | 203 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); |
205 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); | 204 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); |
206 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); | 205 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); |
207 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); | 206 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); |
208 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); | 207 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); |
209 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); | 208 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); |
210 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); | 209 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); |
211 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); | 210 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); |
212 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); | 211 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); |
213 | //odebug << "devmask available and constructed." << oendl; | 212 | //odebug << "devmask available and constructed." << oendl; |
214 | } | 213 | } |
215 | 214 | ||
216 | devmask = 0; | 215 | devmask = 0; |
217 | if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) | 216 | if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) |
218 | { | 217 | { |
219 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); | 218 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); |
220 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); | 219 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); |
221 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); | 220 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); |
222 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); | 221 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); |
223 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); | 222 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); |
224 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); | 223 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); |
225 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); | 224 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); |
226 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); | 225 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); |
227 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); | 226 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); |
228 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); | 227 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); |
229 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); | 228 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); |
230 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); | 229 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); |
231 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); | 230 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); |
232 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); | 231 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); |
233 | //odebug << "recmask available and constructed." << oendl; | 232 | //odebug << "recmask available and constructed." << oendl; |
234 | } | 233 | } |
235 | 234 | ||
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp index 2da549c..b93b752 100644 --- a/libopie2/opienet/omanufacturerdb.cpp +++ b/libopie2/opienet/omanufacturerdb.cpp | |||
@@ -1,136 +1,135 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | 4 | =. |
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 | 30 | ||
31 | #include "omanufacturerdb.h" | 31 | #include "omanufacturerdb.h" |
32 | 32 | ||
33 | #define OPIE_IMPROVE_GUI_LATENCY 1 | 33 | #define OPIE_IMPROVE_GUI_LATENCY 1 |
34 | 34 | ||
35 | /* OPIE */ | 35 | /* OPIE */ |
36 | #include <opie2/odebug.h> | 36 | #include <opie2/odebug.h> |
37 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 37 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | #include <qapplication.h> | 42 | #include <qapplication.h> |
43 | #include <qstring.h> | ||
44 | #include <qfile.h> | 43 | #include <qfile.h> |
45 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
46 | 45 | ||
47 | OManufacturerDB* OManufacturerDB::_instance = 0; | 46 | OManufacturerDB* OManufacturerDB::_instance = 0; |
48 | 47 | ||
49 | OManufacturerDB* OManufacturerDB::instance() | 48 | OManufacturerDB* OManufacturerDB::instance() |
50 | { | 49 | { |
51 | if ( !OManufacturerDB::_instance ) | 50 | if ( !OManufacturerDB::_instance ) |
52 | { | 51 | { |
53 | odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; | 52 | odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; |
54 | _instance = new OManufacturerDB(); | 53 | _instance = new OManufacturerDB(); |
55 | } | 54 | } |
56 | return _instance; | 55 | return _instance; |
57 | } | 56 | } |
58 | 57 | ||
59 | 58 | ||
60 | OManufacturerDB::OManufacturerDB() | 59 | OManufacturerDB::OManufacturerDB() |
61 | { | 60 | { |
62 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 61 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
63 | Global::statusMessage( "Reading Manufacturers..." ); | 62 | Global::statusMessage( "Reading Manufacturers..." ); |
64 | #endif | 63 | #endif |
65 | QString filename( "/etc/manufacturers" ); | 64 | QString filename( "/etc/manufacturers" ); |
66 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 65 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
67 | if ( !QFile::exists( filename ) ) | 66 | if ( !QFile::exists( filename ) ) |
68 | { | 67 | { |
69 | filename = "/opt/QtPalmtop/etc/manufacturers"; | 68 | filename = "/opt/QtPalmtop/etc/manufacturers"; |
70 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 69 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
71 | if ( !QFile::exists( filename ) ) | 70 | if ( !QFile::exists( filename ) ) |
72 | { | 71 | { |
73 | filename = "/usr/share/wellenreiter/manufacturers"; | 72 | filename = "/usr/share/wellenreiter/manufacturers"; |
74 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 73 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
75 | } | 74 | } |
76 | } | 75 | } |
77 | 76 | ||
78 | QFile file( filename ); | 77 | QFile file( filename ); |
79 | bool hasFile = file.open( IO_ReadOnly ); | 78 | bool hasFile = file.open( IO_ReadOnly ); |
80 | if (!hasFile) | 79 | if (!hasFile) |
81 | { | 80 | { |
82 | owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; | 81 | owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; |
83 | } | 82 | } |
84 | else | 83 | else |
85 | { | 84 | { |
86 | odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; | 85 | odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; |
87 | QTextStream s( &file ); | 86 | QTextStream s( &file ); |
88 | QString addr; | 87 | QString addr; |
89 | QString manu; | 88 | QString manu; |
90 | QString extManu; | 89 | QString extManu; |
91 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 90 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
92 | int counter = 0; | 91 | int counter = 0; |
93 | #endif | 92 | #endif |
94 | while (!s.atEnd()) | 93 | while (!s.atEnd()) |
95 | { | 94 | { |
96 | s >> addr; | 95 | s >> addr; |
97 | s >> manu; | 96 | s >> manu; |
98 | s >> extManu; | 97 | s >> extManu; |
99 | 98 | ||
100 | manufacturers.insert( addr, manu ); | 99 | manufacturers.insert( addr, manu ); |
101 | manufacturersExt.insert( addr, extManu ); | 100 | manufacturersExt.insert( addr, extManu ); |
102 | // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; | 101 | // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; |
103 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 102 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
104 | counter++; | 103 | counter++; |
105 | if ( counter == 50 ) | 104 | if ( counter == 50 ) |
106 | { | 105 | { |
107 | qApp->processEvents(); | 106 | qApp->processEvents(); |
108 | counter = 0; | 107 | counter = 0; |
109 | } | 108 | } |
110 | #endif | 109 | #endif |
111 | } | 110 | } |
112 | odebug << "OManufacturerDB: manufacturer list completed." << oendl; | 111 | odebug << "OManufacturerDB: manufacturer list completed." << oendl; |
113 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 112 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
114 | Global::statusMessage( "Manufacturers Complete..." ); | 113 | Global::statusMessage( "Manufacturers Complete..." ); |
115 | #endif | 114 | #endif |
116 | } | 115 | } |
117 | } | 116 | } |
118 | 117 | ||
119 | 118 | ||
120 | OManufacturerDB::~OManufacturerDB() | 119 | OManufacturerDB::~OManufacturerDB() |
121 | { | 120 | { |
122 | } | 121 | } |
123 | 122 | ||
124 | 123 | ||
125 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const | 124 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const |
126 | { | 125 | { |
127 | return manufacturers[macaddr.upper().left(8)]; | 126 | return manufacturers[macaddr.upper().left(8)]; |
128 | } | 127 | } |
129 | 128 | ||
130 | 129 | ||
131 | const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const | 130 | const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const |
132 | { | 131 | { |
133 | QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); | 132 | QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); |
134 | return it == manufacturersExt.end() ? lookup( macaddr ) : *it; | 133 | return it == manufacturersExt.end() ? lookup( macaddr ) : *it; |
135 | } | 134 | } |
136 | 135 | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp index 0adba68..5d92b8f 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp | |||
@@ -1,234 +1,232 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | 3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) |
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 | * XML Backend for the OPIE-Contact Database. | 30 | * XML Backend for the OPIE-Contact Database. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <opie2/ocontactaccessbackend_xml.h> | 33 | #include <opie2/ocontactaccessbackend_xml.h> |
34 | 34 | ||
35 | #include <qasciidict.h> | 35 | #include <qasciidict.h> |
36 | #include <qdatetime.h> | ||
37 | #include <qfile.h> | 36 | #include <qfile.h> |
38 | #include <qfileinfo.h> | 37 | #include <qfileinfo.h> |
39 | #include <qregexp.h> | 38 | #include <qregexp.h> |
40 | #include <qarray.h> | 39 | #include <qarray.h> |
41 | #include <qmap.h> | 40 | #include <qmap.h> |
42 | #include <qdatetime.h> | ||
43 | 41 | ||
44 | #include <qpe/global.h> | 42 | #include <qpe/global.h> |
45 | 43 | ||
46 | #include <opie2/xmltree.h> | 44 | #include <opie2/xmltree.h> |
47 | #include <opie2/ocontactaccessbackend.h> | 45 | #include <opie2/ocontactaccessbackend.h> |
48 | #include <opie2/ocontactaccess.h> | 46 | #include <opie2/ocontactaccess.h> |
49 | 47 | ||
50 | #include <stdlib.h> | 48 | #include <stdlib.h> |
51 | #include <errno.h> | 49 | #include <errno.h> |
52 | 50 | ||
53 | using namespace Opie; | 51 | using namespace Opie; |
54 | 52 | ||
55 | 53 | ||
56 | namespace Opie { | 54 | namespace Opie { |
57 | OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ): | 55 | OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ): |
58 | m_changed( false ) | 56 | m_changed( false ) |
59 | { | 57 | { |
60 | // Just m_contactlist should call delete if an entry | 58 | // Just m_contactlist should call delete if an entry |
61 | // is removed. | 59 | // is removed. |
62 | m_contactList.setAutoDelete( true ); | 60 | m_contactList.setAutoDelete( true ); |
63 | m_uidToContact.setAutoDelete( false ); | 61 | m_uidToContact.setAutoDelete( false ); |
64 | 62 | ||
65 | m_appName = appname; | 63 | m_appName = appname; |
66 | 64 | ||
67 | /* Set journalfile name ... */ | 65 | /* Set journalfile name ... */ |
68 | m_journalName = getenv("HOME"); | 66 | m_journalName = getenv("HOME"); |
69 | m_journalName +="/.abjournal" + appname; | 67 | m_journalName +="/.abjournal" + appname; |
70 | 68 | ||
71 | /* Expecting to access the default filename if nothing else is set */ | 69 | /* Expecting to access the default filename if nothing else is set */ |
72 | if ( filename.isEmpty() ){ | 70 | if ( filename.isEmpty() ){ |
73 | m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); | 71 | m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); |
74 | } else | 72 | } else |
75 | m_fileName = filename; | 73 | m_fileName = filename; |
76 | 74 | ||
77 | /* Load Database now */ | 75 | /* Load Database now */ |
78 | load (); | 76 | load (); |
79 | } | 77 | } |
80 | 78 | ||
81 | bool OPimContactAccessBackend_XML::save() | 79 | bool OPimContactAccessBackend_XML::save() |
82 | { | 80 | { |
83 | 81 | ||
84 | if ( !m_changed ) | 82 | if ( !m_changed ) |
85 | return true; | 83 | return true; |
86 | 84 | ||
87 | QString strNewFile = m_fileName + ".new"; | 85 | QString strNewFile = m_fileName + ".new"; |
88 | QFile f( strNewFile ); | 86 | QFile f( strNewFile ); |
89 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) | 87 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) |
90 | return false; | 88 | return false; |
91 | 89 | ||
92 | int total_written; | 90 | int total_written; |
93 | int idx_offset = 0; | 91 | int idx_offset = 0; |
94 | QString out; | 92 | QString out; |
95 | 93 | ||
96 | // Write Header | 94 | // Write Header |
97 | out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" | 95 | out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" |
98 | " <Groups>\n" | 96 | " <Groups>\n" |
99 | " </Groups>\n" | 97 | " </Groups>\n" |
100 | " <Contacts>\n"; | 98 | " <Contacts>\n"; |
101 | QCString cstr = out.utf8(); | 99 | QCString cstr = out.utf8(); |
102 | f.writeBlock( cstr.data(), cstr.length() ); | 100 | f.writeBlock( cstr.data(), cstr.length() ); |
103 | idx_offset += cstr.length(); | 101 | idx_offset += cstr.length(); |
104 | out = ""; | 102 | out = ""; |
105 | 103 | ||
106 | // Write all contacts | 104 | // Write all contacts |
107 | QListIterator<OPimContact> it( m_contactList ); | 105 | QListIterator<OPimContact> it( m_contactList ); |
108 | for ( ; it.current(); ++it ) { | 106 | for ( ; it.current(); ++it ) { |
109 | // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); | 107 | // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); |
110 | out += "<Contact "; | 108 | out += "<Contact "; |
111 | (*it)->save( out ); | 109 | (*it)->save( out ); |
112 | out += "/>\n"; | 110 | out += "/>\n"; |
113 | cstr = out.utf8(); | 111 | cstr = out.utf8(); |
114 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | 112 | total_written = f.writeBlock( cstr.data(), cstr.length() ); |
115 | idx_offset += cstr.length(); | 113 | idx_offset += cstr.length(); |
116 | if ( total_written != int(cstr.length()) ) { | 114 | if ( total_written != int(cstr.length()) ) { |
117 | f.close(); | 115 | f.close(); |
118 | QFile::remove( strNewFile ); | 116 | QFile::remove( strNewFile ); |
119 | return false; | 117 | return false; |
120 | } | 118 | } |
121 | out = ""; | 119 | out = ""; |
122 | } | 120 | } |
123 | out += " </Contacts>\n</AddressBook>\n"; | 121 | out += " </Contacts>\n</AddressBook>\n"; |
124 | 122 | ||
125 | // Write Footer | 123 | // Write Footer |
126 | cstr = out.utf8(); | 124 | cstr = out.utf8(); |
127 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | 125 | total_written = f.writeBlock( cstr.data(), cstr.length() ); |
128 | if ( total_written != int( cstr.length() ) ) { | 126 | if ( total_written != int( cstr.length() ) ) { |
129 | f.close(); | 127 | f.close(); |
130 | QFile::remove( strNewFile ); | 128 | QFile::remove( strNewFile ); |
131 | return false; | 129 | return false; |
132 | } | 130 | } |
133 | f.close(); | 131 | f.close(); |
134 | 132 | ||
135 | // move the file over, I'm just going to use the system call | 133 | // move the file over, I'm just going to use the system call |
136 | // because, I don't feel like using QDir. | 134 | // because, I don't feel like using QDir. |
137 | if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) { | 135 | if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) { |
138 | qWarning( "problem renaming file %s to %s, errno: %d", | 136 | qWarning( "problem renaming file %s to %s, errno: %d", |
139 | strNewFile.latin1(), m_journalName.latin1(), errno ); | 137 | strNewFile.latin1(), m_journalName.latin1(), errno ); |
140 | // remove the tmp file... | 138 | // remove the tmp file... |
141 | QFile::remove( strNewFile ); | 139 | QFile::remove( strNewFile ); |
142 | } | 140 | } |
143 | 141 | ||
144 | /* The journalfile should be removed now... */ | 142 | /* The journalfile should be removed now... */ |
145 | removeJournal(); | 143 | removeJournal(); |
146 | 144 | ||
147 | m_changed = false; | 145 | m_changed = false; |
148 | return true; | 146 | return true; |
149 | } | 147 | } |
150 | 148 | ||
151 | bool OPimContactAccessBackend_XML::load () | 149 | bool OPimContactAccessBackend_XML::load () |
152 | { | 150 | { |
153 | m_contactList.clear(); | 151 | m_contactList.clear(); |
154 | m_uidToContact.clear(); | 152 | m_uidToContact.clear(); |
155 | 153 | ||
156 | /* Load XML-File and journal if it exists */ | 154 | /* Load XML-File and journal if it exists */ |
157 | if ( !load ( m_fileName, false ) ) | 155 | if ( !load ( m_fileName, false ) ) |
158 | return false; | 156 | return false; |
159 | /* The returncode of the journalfile is ignored due to the | 157 | /* The returncode of the journalfile is ignored due to the |
160 | * fact that it does not exist when this class is instantiated ! | 158 | * fact that it does not exist when this class is instantiated ! |
161 | * But there may such a file exist, if the application crashed. | 159 | * But there may such a file exist, if the application crashed. |
162 | * Therefore we try to load it to get the changes before the # | 160 | * Therefore we try to load it to get the changes before the # |
163 | * crash happened... | 161 | * crash happened... |
164 | */ | 162 | */ |
165 | load (m_journalName, true); | 163 | load (m_journalName, true); |
166 | 164 | ||
167 | return true; | 165 | return true; |
168 | } | 166 | } |
169 | 167 | ||
170 | void OPimContactAccessBackend_XML::clear () | 168 | void OPimContactAccessBackend_XML::clear () |
171 | { | 169 | { |
172 | m_contactList.clear(); | 170 | m_contactList.clear(); |
173 | m_uidToContact.clear(); | 171 | m_uidToContact.clear(); |
174 | 172 | ||
175 | m_changed = false; | 173 | m_changed = false; |
176 | } | 174 | } |
177 | 175 | ||
178 | bool OPimContactAccessBackend_XML::wasChangedExternally() | 176 | bool OPimContactAccessBackend_XML::wasChangedExternally() |
179 | { | 177 | { |
180 | QFileInfo fi( m_fileName ); | 178 | QFileInfo fi( m_fileName ); |
181 | 179 | ||
182 | QDateTime lastmod = fi.lastModified (); | 180 | QDateTime lastmod = fi.lastModified (); |
183 | 181 | ||
184 | return (lastmod != m_readtime); | 182 | return (lastmod != m_readtime); |
185 | } | 183 | } |
186 | 184 | ||
187 | QArray<int> OPimContactAccessBackend_XML::allRecords() const | 185 | QArray<int> OPimContactAccessBackend_XML::allRecords() const |
188 | { | 186 | { |
189 | QArray<int> uid_list( m_contactList.count() ); | 187 | QArray<int> uid_list( m_contactList.count() ); |
190 | 188 | ||
191 | uint counter = 0; | 189 | uint counter = 0; |
192 | QListIterator<OPimContact> it( m_contactList ); | 190 | QListIterator<OPimContact> it( m_contactList ); |
193 | for( ; it.current(); ++it ){ | 191 | for( ; it.current(); ++it ){ |
194 | uid_list[counter++] = (*it)->uid(); | 192 | uid_list[counter++] = (*it)->uid(); |
195 | } | 193 | } |
196 | 194 | ||
197 | return ( uid_list ); | 195 | return ( uid_list ); |
198 | } | 196 | } |
199 | 197 | ||
200 | OPimContact OPimContactAccessBackend_XML::find ( int uid ) const | 198 | OPimContact OPimContactAccessBackend_XML::find ( int uid ) const |
201 | { | 199 | { |
202 | OPimContact foundContact; //Create empty contact | 200 | OPimContact foundContact; //Create empty contact |
203 | 201 | ||
204 | OPimContact* found = m_uidToContact.find( QString().setNum( uid ) ); | 202 | OPimContact* found = m_uidToContact.find( QString().setNum( uid ) ); |
205 | 203 | ||
206 | if ( found ){ | 204 | if ( found ){ |
207 | foundContact = *found; | 205 | foundContact = *found; |
208 | } | 206 | } |
209 | 207 | ||
210 | return ( foundContact ); | 208 | return ( foundContact ); |
211 | } | 209 | } |
212 | 210 | ||
213 | QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings, | 211 | QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings, |
214 | const QDateTime& d ) | 212 | const QDateTime& d ) |
215 | { | 213 | { |
216 | 214 | ||
217 | QArray<int> m_currentQuery( m_contactList.count() ); | 215 | QArray<int> m_currentQuery( m_contactList.count() ); |
218 | QListIterator<OPimContact> it( m_contactList ); | 216 | QListIterator<OPimContact> it( m_contactList ); |
219 | uint arraycounter = 0; | 217 | uint arraycounter = 0; |
220 | 218 | ||
221 | for( ; it.current(); ++it ){ | 219 | for( ; it.current(); ++it ){ |
222 | /* Search all fields and compare them with query object. Store them into list | 220 | /* Search all fields and compare them with query object. Store them into list |
223 | * if all fields matches. | 221 | * if all fields matches. |
224 | */ | 222 | */ |
225 | QDate* queryDate = 0l; | 223 | QDate* queryDate = 0l; |
226 | QDate* checkDate = 0l; | 224 | QDate* checkDate = 0l; |
227 | bool allcorrect = true; | 225 | bool allcorrect = true; |
228 | for ( int i = 0; i < Qtopia::Groups; i++ ) { | 226 | for ( int i = 0; i < Qtopia::Groups; i++ ) { |
229 | // Birthday and anniversary are special nonstring fields and should | 227 | // Birthday and anniversary are special nonstring fields and should |
230 | // be handled specially | 228 | // be handled specially |
231 | switch ( i ){ | 229 | switch ( i ){ |
232 | case Qtopia::Birthday: | 230 | case Qtopia::Birthday: |
233 | queryDate = new QDate( query.birthday() ); | 231 | queryDate = new QDate( query.birthday() ); |
234 | checkDate = new QDate( (*it)->birthday() ); | 232 | checkDate = new QDate( (*it)->birthday() ); |
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp index a5df597..4a774e8 100644 --- a/libopie2/opiepim/core/opimcontact.cpp +++ b/libopie2/opiepim/core/opimcontact.cpp | |||
@@ -1,238 +1,234 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
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 | #define QTOPIA_INTERNAL_CONTACT_MRE | 30 | #define QTOPIA_INTERNAL_CONTACT_MRE |
31 | 31 | ||
32 | #include "opimcontact.h" | 32 | #include "opimcontact.h" |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | #include <opie2/opimresolver.h> | 35 | #include <opie2/opimresolver.h> |
36 | #include <opie2/opimdateconversion.h> | 36 | #include <opie2/opimdateconversion.h> |
37 | #include <qpe/stringutil.h> | 37 | #include <qpe/stringutil.h> |
38 | #include <qpe/timestring.h> | 38 | #include <qpe/timestring.h> |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | #include <qobject.h> | ||
43 | #include <qregexp.h> | ||
44 | #include <qstylesheet.h> | 42 | #include <qstylesheet.h> |
45 | #include <qfileinfo.h> | ||
46 | #include <qmap.h> | ||
47 | 43 | ||
48 | /* STD */ | 44 | /* STD */ |
49 | #include <stdio.h> | 45 | #include <stdio.h> |
50 | 46 | ||
51 | /*! | 47 | /*! |
52 | \class Contact contact.h | 48 | \class Contact contact.h |
53 | \brief The Contact class holds the data of an address book entry. | 49 | \brief The Contact class holds the data of an address book entry. |
54 | 50 | ||
55 | This data includes information the name of the person, contact | 51 | This data includes information the name of the person, contact |
56 | information, and business information such as deparment and job title. | 52 | information, and business information such as deparment and job title. |
57 | 53 | ||
58 | \ingroup qtopiaemb | 54 | \ingroup qtopiaemb |
59 | \ingroup qtopiadesktop | 55 | \ingroup qtopiadesktop |
60 | */ | 56 | */ |
61 | 57 | ||
62 | 58 | ||
63 | namespace Opie | 59 | namespace Opie |
64 | { | 60 | { |
65 | /*! | 61 | /*! |
66 | Creates a new, empty contact. | 62 | Creates a new, empty contact. |
67 | */ | 63 | */ |
68 | OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 ) | 64 | OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 ) |
69 | {} | 65 | {} |
70 | 66 | ||
71 | /*! | 67 | /*! |
72 | \internal | 68 | \internal |
73 | Creates a new contact. The properties of the contact are | 69 | Creates a new contact. The properties of the contact are |
74 | set from \a fromMap. | 70 | set from \a fromMap. |
75 | */ | 71 | */ |
76 | OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) | 72 | OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) |
77 | { | 73 | { |
78 | QString cats = mMap[ Qtopia::AddressCategory ]; | 74 | QString cats = mMap[ Qtopia::AddressCategory ]; |
79 | if ( !cats.isEmpty() ) | 75 | if ( !cats.isEmpty() ) |
80 | setCategories( idsFromString( cats ) ); | 76 | setCategories( idsFromString( cats ) ); |
81 | 77 | ||
82 | QString uidStr = find( Qtopia::AddressUid ); | 78 | QString uidStr = find( Qtopia::AddressUid ); |
83 | 79 | ||
84 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) | 80 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) |
85 | { | 81 | { |
86 | qWarning( "Invalid UID found. Generate new one.." ); | 82 | qWarning( "Invalid UID found. Generate new one.." ); |
87 | setUid( uidGen().generate() ); | 83 | setUid( uidGen().generate() ); |
88 | } | 84 | } |
89 | else | 85 | else |
90 | setUid( uidStr.toInt() ); | 86 | setUid( uidStr.toInt() ); |
91 | 87 | ||
92 | // if ( !uidStr.isEmpty() ) | 88 | // if ( !uidStr.isEmpty() ) |
93 | // setUid( uidStr.toInt() ); | 89 | // setUid( uidStr.toInt() ); |
94 | } | 90 | } |
95 | 91 | ||
96 | /*! | 92 | /*! |
97 | Destroys a contact. | 93 | Destroys a contact. |
98 | */ | 94 | */ |
99 | OPimContact::~OPimContact() | 95 | OPimContact::~OPimContact() |
100 | {} | 96 | {} |
101 | 97 | ||
102 | /*! \fn void OPimContact::setTitle( const QString &str ) | 98 | /*! \fn void OPimContact::setTitle( const QString &str ) |
103 | Sets the title of the contact to \a str. | 99 | Sets the title of the contact to \a str. |
104 | */ | 100 | */ |
105 | 101 | ||
106 | /*! \fn void OPimContact::setFirstName( const QString &str ) | 102 | /*! \fn void OPimContact::setFirstName( const QString &str ) |
107 | Sets the first name of the contact to \a str. | 103 | Sets the first name of the contact to \a str. |
108 | */ | 104 | */ |
109 | 105 | ||
110 | /*! \fn void OPimContact::setMiddleName( const QString &str ) | 106 | /*! \fn void OPimContact::setMiddleName( const QString &str ) |
111 | Sets the middle name of the contact to \a str. | 107 | Sets the middle name of the contact to \a str. |
112 | */ | 108 | */ |
113 | 109 | ||
114 | /*! \fn void OPimContact::setLastName( const QString &str ) | 110 | /*! \fn void OPimContact::setLastName( const QString &str ) |
115 | Sets the last name of the contact to \a str. | 111 | Sets the last name of the contact to \a str. |
116 | */ | 112 | */ |
117 | 113 | ||
118 | /*! \fn void OPimContact::setSuffix( const QString &str ) | 114 | /*! \fn void OPimContact::setSuffix( const QString &str ) |
119 | Sets the suffix of the contact to \a str. | 115 | Sets the suffix of the contact to \a str. |
120 | */ | 116 | */ |
121 | 117 | ||
122 | /*! \fn void OPimContact::setFileAs( const QString &str ) | 118 | /*! \fn void OPimContact::setFileAs( const QString &str ) |
123 | Sets the contact to filed as \a str. | 119 | Sets the contact to filed as \a str. |
124 | */ | 120 | */ |
125 | 121 | ||
126 | /*! \fn void OPimContact::setDefaultEmail( const QString &str ) | 122 | /*! \fn void OPimContact::setDefaultEmail( const QString &str ) |
127 | Sets the default email of the contact to \a str. | 123 | Sets the default email of the contact to \a str. |
128 | */ | 124 | */ |
129 | 125 | ||
130 | /*! \fn void OPimContact::setHomeStreet( const QString &str ) | 126 | /*! \fn void OPimContact::setHomeStreet( const QString &str ) |
131 | Sets the home street address of the contact to \a str. | 127 | Sets the home street address of the contact to \a str. |
132 | */ | 128 | */ |
133 | 129 | ||
134 | /*! \fn void OPimContact::setHomeCity( const QString &str ) | 130 | /*! \fn void OPimContact::setHomeCity( const QString &str ) |
135 | Sets the home city of the contact to \a str. | 131 | Sets the home city of the contact to \a str. |
136 | */ | 132 | */ |
137 | 133 | ||
138 | /*! \fn void OPimContact::setHomeState( const QString &str ) | 134 | /*! \fn void OPimContact::setHomeState( const QString &str ) |
139 | Sets the home state of the contact to \a str. | 135 | Sets the home state of the contact to \a str. |
140 | */ | 136 | */ |
141 | 137 | ||
142 | /*! \fn void OPimContact::setHomeZip( const QString &str ) | 138 | /*! \fn void OPimContact::setHomeZip( const QString &str ) |
143 | Sets the home zip code of the contact to \a str. | 139 | Sets the home zip code of the contact to \a str. |
144 | */ | 140 | */ |
145 | 141 | ||
146 | /*! \fn void OPimContact::setHomeCountry( const QString &str ) | 142 | /*! \fn void OPimContact::setHomeCountry( const QString &str ) |
147 | Sets the home country of the contact to \a str. | 143 | Sets the home country of the contact to \a str. |
148 | */ | 144 | */ |
149 | 145 | ||
150 | /*! \fn void OPimContact::setHomePhone( const QString &str ) | 146 | /*! \fn void OPimContact::setHomePhone( const QString &str ) |
151 | Sets the home phone number of the contact to \a str. | 147 | Sets the home phone number of the contact to \a str. |
152 | */ | 148 | */ |
153 | 149 | ||
154 | /*! \fn void OPimContact::setHomeFax( const QString &str ) | 150 | /*! \fn void OPimContact::setHomeFax( const QString &str ) |
155 | Sets the home fax number of the contact to \a str. | 151 | Sets the home fax number of the contact to \a str. |
156 | */ | 152 | */ |
157 | 153 | ||
158 | /*! \fn void OPimContact::setHomeMobile( const QString &str ) | 154 | /*! \fn void OPimContact::setHomeMobile( const QString &str ) |
159 | Sets the home mobile phone number of the contact to \a str. | 155 | Sets the home mobile phone number of the contact to \a str. |
160 | */ | 156 | */ |
161 | 157 | ||
162 | /*! \fn void OPimContact::setHomeWebpage( const QString &str ) | 158 | /*! \fn void OPimContact::setHomeWebpage( const QString &str ) |
163 | Sets the home webpage of the contact to \a str. | 159 | Sets the home webpage of the contact to \a str. |
164 | */ | 160 | */ |
165 | 161 | ||
166 | /*! \fn void OPimContact::setCompany( const QString &str ) | 162 | /*! \fn void OPimContact::setCompany( const QString &str ) |
167 | Sets the company for contact to \a str. | 163 | Sets the company for contact to \a str. |
168 | */ | 164 | */ |
169 | 165 | ||
170 | /*! \fn void OPimContact::setJobTitle( const QString &str ) | 166 | /*! \fn void OPimContact::setJobTitle( const QString &str ) |
171 | Sets the job title of the contact to \a str. | 167 | Sets the job title of the contact to \a str. |
172 | */ | 168 | */ |
173 | 169 | ||
174 | /*! \fn void OPimContact::setDepartment( const QString &str ) | 170 | /*! \fn void OPimContact::setDepartment( const QString &str ) |
175 | Sets the department for contact to \a str. | 171 | Sets the department for contact to \a str. |
176 | */ | 172 | */ |
177 | 173 | ||
178 | /*! \fn void OPimContact::setOffice( const QString &str ) | 174 | /*! \fn void OPimContact::setOffice( const QString &str ) |
179 | Sets the office for contact to \a str. | 175 | Sets the office for contact to \a str. |
180 | */ | 176 | */ |
181 | 177 | ||
182 | /*! \fn void OPimContact::setBusinessStreet( const QString &str ) | 178 | /*! \fn void OPimContact::setBusinessStreet( const QString &str ) |
183 | Sets the business street address of the contact to \a str. | 179 | Sets the business street address of the contact to \a str. |
184 | */ | 180 | */ |
185 | 181 | ||
186 | /*! \fn void OPimContact::setBusinessCity( const QString &str ) | 182 | /*! \fn void OPimContact::setBusinessCity( const QString &str ) |
187 | Sets the business city of the contact to \a str. | 183 | Sets the business city of the contact to \a str. |
188 | */ | 184 | */ |
189 | 185 | ||
190 | /*! \fn void OPimContact::setBusinessState( const QString &str ) | 186 | /*! \fn void OPimContact::setBusinessState( const QString &str ) |
191 | Sets the business state of the contact to \a str. | 187 | Sets the business state of the contact to \a str. |
192 | */ | 188 | */ |
193 | 189 | ||
194 | /*! \fn void OPimContact::setBusinessZip( const QString &str ) | 190 | /*! \fn void OPimContact::setBusinessZip( const QString &str ) |
195 | Sets the business zip code of the contact to \a str. | 191 | Sets the business zip code of the contact to \a str. |
196 | */ | 192 | */ |
197 | 193 | ||
198 | /*! \fn void OPimContact::setBusinessCountry( const QString &str ) | 194 | /*! \fn void OPimContact::setBusinessCountry( const QString &str ) |
199 | Sets the business country of the contact to \a str. | 195 | Sets the business country of the contact to \a str. |
200 | */ | 196 | */ |
201 | 197 | ||
202 | /*! \fn void OPimContact::setBusinessPhone( const QString &str ) | 198 | /*! \fn void OPimContact::setBusinessPhone( const QString &str ) |
203 | Sets the business phone number of the contact to \a str. | 199 | Sets the business phone number of the contact to \a str. |
204 | */ | 200 | */ |
205 | 201 | ||
206 | /*! \fn void OPimContact::setBusinessFax( const QString &str ) | 202 | /*! \fn void OPimContact::setBusinessFax( const QString &str ) |
207 | Sets the business fax number of the contact to \a str. | 203 | Sets the business fax number of the contact to \a str. |
208 | */ | 204 | */ |
209 | 205 | ||
210 | /*! \fn void OPimContact::setBusinessMobile( const QString &str ) | 206 | /*! \fn void OPimContact::setBusinessMobile( const QString &str ) |
211 | Sets the business mobile phone number of the contact to \a str. | 207 | Sets the business mobile phone number of the contact to \a str. |
212 | */ | 208 | */ |
213 | 209 | ||
214 | /*! \fn void OPimContact::setBusinessPager( const QString &str ) | 210 | /*! \fn void OPimContact::setBusinessPager( const QString &str ) |
215 | Sets the business pager number of the contact to \a str. | 211 | Sets the business pager number of the contact to \a str. |
216 | */ | 212 | */ |
217 | 213 | ||
218 | /*! \fn void OPimContact::setBusinessWebpage( const QString &str ) | 214 | /*! \fn void OPimContact::setBusinessWebpage( const QString &str ) |
219 | Sets the business webpage of the contact to \a str. | 215 | Sets the business webpage of the contact to \a str. |
220 | */ | 216 | */ |
221 | 217 | ||
222 | /*! \fn void OPimContact::setProfession( const QString &str ) | 218 | /*! \fn void OPimContact::setProfession( const QString &str ) |
223 | Sets the profession of the contact to \a str. | 219 | Sets the profession of the contact to \a str. |
224 | */ | 220 | */ |
225 | 221 | ||
226 | /*! \fn void OPimContact::setAssistant( const QString &str ) | 222 | /*! \fn void OPimContact::setAssistant( const QString &str ) |
227 | Sets the assistant of the contact to \a str. | 223 | Sets the assistant of the contact to \a str. |
228 | */ | 224 | */ |
229 | 225 | ||
230 | /*! \fn void OPimContact::setManager( const QString &str ) | 226 | /*! \fn void OPimContact::setManager( const QString &str ) |
231 | Sets the manager of the contact to \a str. | 227 | Sets the manager of the contact to \a str. |
232 | */ | 228 | */ |
233 | 229 | ||
234 | /*! \fn void OPimContact::setSpouse( const QString &str ) | 230 | /*! \fn void OPimContact::setSpouse( const QString &str ) |
235 | Sets the spouse of the contact to \a str. | 231 | Sets the spouse of the contact to \a str. |
236 | */ | 232 | */ |
237 | 233 | ||
238 | /*! \fn void OPimContact::setGender( const QString &str ) | 234 | /*! \fn void OPimContact::setGender( const QString &str ) |
diff --git a/libopie2/opiepim/core/opimcontactfields.cpp b/libopie2/opiepim/core/opimcontactfields.cpp index 4b0ba3b..120beb6 100644 --- a/libopie2/opiepim/core/opimcontactfields.cpp +++ b/libopie2/opiepim/core/opimcontactfields.cpp | |||
@@ -1,231 +1,229 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
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 "opimcontactfields.h" | 30 | #include "opimcontactfields.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/opimcontact.h> | 33 | #include <opie2/opimcontact.h> |
34 | #include <qpe/recordfields.h> // We should use our own enum in the future .. | ||
35 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
36 | 35 | ||
37 | /* QT */ | 36 | /* QT */ |
38 | #include <qobject.h> | 37 | #include <qobject.h> |
39 | #include <qstringlist.h> | ||
40 | 38 | ||
41 | 39 | ||
42 | namespace Opie | 40 | namespace Opie |
43 | { | 41 | { |
44 | /*! | 42 | /*! |
45 | \internal | 43 | \internal |
46 | Returns a list of personal field names for a contact. | 44 | Returns a list of personal field names for a contact. |
47 | */ | 45 | */ |
48 | QStringList OPimContactFields::personalfields( bool sorted, bool translated ) | 46 | QStringList OPimContactFields::personalfields( bool sorted, bool translated ) |
49 | { | 47 | { |
50 | QStringList list; | 48 | QStringList list; |
51 | QMap<int, QString> mapIdToStr; | 49 | QMap<int, QString> mapIdToStr; |
52 | if ( translated ) | 50 | if ( translated ) |
53 | mapIdToStr = idToTrFields(); | 51 | mapIdToStr = idToTrFields(); |
54 | else | 52 | else |
55 | mapIdToStr = idToUntrFields(); | 53 | mapIdToStr = idToUntrFields(); |
56 | 54 | ||
57 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); | 55 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); |
58 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); | 56 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); |
59 | 57 | ||
60 | list.append( mapIdToStr[ Qtopia::Title ] ); | 58 | list.append( mapIdToStr[ Qtopia::Title ] ); |
61 | list.append( mapIdToStr[ Qtopia::FirstName ] ); | 59 | list.append( mapIdToStr[ Qtopia::FirstName ] ); |
62 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); | 60 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); |
63 | list.append( mapIdToStr[ Qtopia::LastName ] ); | 61 | list.append( mapIdToStr[ Qtopia::LastName ] ); |
64 | list.append( mapIdToStr[ Qtopia::Suffix ] ); | 62 | list.append( mapIdToStr[ Qtopia::Suffix ] ); |
65 | list.append( mapIdToStr[ Qtopia::FileAs ] ); | 63 | list.append( mapIdToStr[ Qtopia::FileAs ] ); |
66 | 64 | ||
67 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); | 65 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); |
68 | list.append( mapIdToStr[ Qtopia::Department ] ); | 66 | list.append( mapIdToStr[ Qtopia::Department ] ); |
69 | list.append( mapIdToStr[ Qtopia::Company ] ); | 67 | list.append( mapIdToStr[ Qtopia::Company ] ); |
70 | 68 | ||
71 | list.append( mapIdToStr[ Qtopia::Notes ] ); | 69 | list.append( mapIdToStr[ Qtopia::Notes ] ); |
72 | list.append( mapIdToStr[ Qtopia::Groups ] ); | 70 | list.append( mapIdToStr[ Qtopia::Groups ] ); |
73 | 71 | ||
74 | if ( sorted ) list.sort(); | 72 | if ( sorted ) list.sort(); |
75 | return list; | 73 | return list; |
76 | } | 74 | } |
77 | 75 | ||
78 | /*! | 76 | /*! |
79 | \internal | 77 | \internal |
80 | Returns a list of details field names for a contact. | 78 | Returns a list of details field names for a contact. |
81 | */ | 79 | */ |
82 | QStringList OPimContactFields::detailsfields( bool sorted, bool translated ) | 80 | QStringList OPimContactFields::detailsfields( bool sorted, bool translated ) |
83 | { | 81 | { |
84 | QStringList list; | 82 | QStringList list; |
85 | QMap<int, QString> mapIdToStr; | 83 | QMap<int, QString> mapIdToStr; |
86 | if ( translated ) | 84 | if ( translated ) |
87 | mapIdToStr = idToTrFields(); | 85 | mapIdToStr = idToTrFields(); |
88 | else | 86 | else |
89 | mapIdToStr = idToUntrFields(); | 87 | mapIdToStr = idToUntrFields(); |
90 | 88 | ||
91 | list.append( mapIdToStr[ Qtopia::Office ] ); | 89 | list.append( mapIdToStr[ Qtopia::Office ] ); |
92 | list.append( mapIdToStr[ Qtopia::Profession ] ); | 90 | list.append( mapIdToStr[ Qtopia::Profession ] ); |
93 | list.append( mapIdToStr[ Qtopia::Assistant ] ); | 91 | list.append( mapIdToStr[ Qtopia::Assistant ] ); |
94 | list.append( mapIdToStr[ Qtopia::Manager ] ); | 92 | list.append( mapIdToStr[ Qtopia::Manager ] ); |
95 | 93 | ||
96 | list.append( mapIdToStr[ Qtopia::Spouse ] ); | 94 | list.append( mapIdToStr[ Qtopia::Spouse ] ); |
97 | list.append( mapIdToStr[ Qtopia::Gender ] ); | 95 | list.append( mapIdToStr[ Qtopia::Gender ] ); |
98 | list.append( mapIdToStr[ Qtopia::Birthday ] ); | 96 | list.append( mapIdToStr[ Qtopia::Birthday ] ); |
99 | list.append( mapIdToStr[ Qtopia::Anniversary ] ); | 97 | list.append( mapIdToStr[ Qtopia::Anniversary ] ); |
100 | list.append( mapIdToStr[ Qtopia::Nickname ] ); | 98 | list.append( mapIdToStr[ Qtopia::Nickname ] ); |
101 | list.append( mapIdToStr[ Qtopia::Children ] ); | 99 | list.append( mapIdToStr[ Qtopia::Children ] ); |
102 | 100 | ||
103 | if ( sorted ) list.sort(); | 101 | if ( sorted ) list.sort(); |
104 | return list; | 102 | return list; |
105 | } | 103 | } |
106 | 104 | ||
107 | /*! | 105 | /*! |
108 | \internal | 106 | \internal |
109 | Returns a list of phone field names for a contact. | 107 | Returns a list of phone field names for a contact. |
110 | */ | 108 | */ |
111 | QStringList OPimContactFields::phonefields( bool sorted, bool translated ) | 109 | QStringList OPimContactFields::phonefields( bool sorted, bool translated ) |
112 | { | 110 | { |
113 | QStringList list; | 111 | QStringList list; |
114 | QMap<int, QString> mapIdToStr; | 112 | QMap<int, QString> mapIdToStr; |
115 | if ( translated ) | 113 | if ( translated ) |
116 | mapIdToStr = idToTrFields(); | 114 | mapIdToStr = idToTrFields(); |
117 | else | 115 | else |
118 | mapIdToStr = idToUntrFields(); | 116 | mapIdToStr = idToUntrFields(); |
119 | 117 | ||
120 | list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); | 118 | list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); |
121 | list.append( mapIdToStr[ Qtopia::BusinessFax ] ); | 119 | list.append( mapIdToStr[ Qtopia::BusinessFax ] ); |
122 | list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); | 120 | list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); |
123 | list.append( mapIdToStr[ Qtopia::BusinessPager ] ); | 121 | list.append( mapIdToStr[ Qtopia::BusinessPager ] ); |
124 | list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); | 122 | list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); |
125 | 123 | ||
126 | list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); | 124 | list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); |
127 | list.append( mapIdToStr[ Qtopia::Emails ] ); | 125 | list.append( mapIdToStr[ Qtopia::Emails ] ); |
128 | 126 | ||
129 | list.append( mapIdToStr[ Qtopia::HomePhone ] ); | 127 | list.append( mapIdToStr[ Qtopia::HomePhone ] ); |
130 | list.append( mapIdToStr[ Qtopia::HomeFax ] ); | 128 | list.append( mapIdToStr[ Qtopia::HomeFax ] ); |
131 | list.append( mapIdToStr[ Qtopia::HomeMobile ] ); | 129 | list.append( mapIdToStr[ Qtopia::HomeMobile ] ); |
132 | // list.append( mapIdToStr[Qtopia::HomePager] ); | 130 | // list.append( mapIdToStr[Qtopia::HomePager] ); |
133 | list.append( mapIdToStr[ Qtopia::HomeWebPage ] ); | 131 | list.append( mapIdToStr[ Qtopia::HomeWebPage ] ); |
134 | 132 | ||
135 | if ( sorted ) list.sort(); | 133 | if ( sorted ) list.sort(); |
136 | 134 | ||
137 | return list; | 135 | return list; |
138 | } | 136 | } |
139 | 137 | ||
140 | /*! | 138 | /*! |
141 | \internal | 139 | \internal |
142 | Returns a list of field names for a contact. | 140 | Returns a list of field names for a contact. |
143 | */ | 141 | */ |
144 | QStringList OPimContactFields::fields( bool sorted, bool translated ) | 142 | QStringList OPimContactFields::fields( bool sorted, bool translated ) |
145 | { | 143 | { |
146 | QStringList list; | 144 | QStringList list; |
147 | QMap<int, QString> mapIdToStr; | 145 | QMap<int, QString> mapIdToStr; |
148 | if ( translated ) | 146 | if ( translated ) |
149 | mapIdToStr = idToTrFields(); | 147 | mapIdToStr = idToTrFields(); |
150 | else | 148 | else |
151 | mapIdToStr = idToUntrFields(); | 149 | mapIdToStr = idToUntrFields(); |
152 | 150 | ||
153 | list += personalfields( sorted, translated ); | 151 | list += personalfields( sorted, translated ); |
154 | 152 | ||
155 | list += phonefields( sorted, translated ); | 153 | list += phonefields( sorted, translated ); |
156 | 154 | ||
157 | list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); | 155 | list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); |
158 | list.append( mapIdToStr[ Qtopia::BusinessCity ] ); | 156 | list.append( mapIdToStr[ Qtopia::BusinessCity ] ); |
159 | list.append( mapIdToStr[ Qtopia::BusinessState ] ); | 157 | list.append( mapIdToStr[ Qtopia::BusinessState ] ); |
160 | list.append( mapIdToStr[ Qtopia::BusinessZip ] ); | 158 | list.append( mapIdToStr[ Qtopia::BusinessZip ] ); |
161 | list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); | 159 | list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); |
162 | 160 | ||
163 | list.append( mapIdToStr[ Qtopia::HomeStreet ] ); | 161 | list.append( mapIdToStr[ Qtopia::HomeStreet ] ); |
164 | list.append( mapIdToStr[ Qtopia::HomeCity ] ); | 162 | list.append( mapIdToStr[ Qtopia::HomeCity ] ); |
165 | list.append( mapIdToStr[ Qtopia::HomeState ] ); | 163 | list.append( mapIdToStr[ Qtopia::HomeState ] ); |
166 | list.append( mapIdToStr[ Qtopia::HomeZip ] ); | 164 | list.append( mapIdToStr[ Qtopia::HomeZip ] ); |
167 | list.append( mapIdToStr[ Qtopia::HomeCountry ] ); | 165 | list.append( mapIdToStr[ Qtopia::HomeCountry ] ); |
168 | 166 | ||
169 | list += detailsfields( sorted, translated ); | 167 | list += detailsfields( sorted, translated ); |
170 | 168 | ||
171 | if ( sorted ) list.sort(); | 169 | if ( sorted ) list.sort(); |
172 | 170 | ||
173 | return list; | 171 | return list; |
174 | } | 172 | } |
175 | 173 | ||
176 | 174 | ||
177 | /*! | 175 | /*! |
178 | \internal | 176 | \internal |
179 | Returns an untranslated list of personal field names for a contact. | 177 | Returns an untranslated list of personal field names for a contact. |
180 | */ | 178 | */ |
181 | QStringList OPimContactFields::untrpersonalfields( bool sorted ) | 179 | QStringList OPimContactFields::untrpersonalfields( bool sorted ) |
182 | { | 180 | { |
183 | return personalfields( sorted, false ); | 181 | return personalfields( sorted, false ); |
184 | } | 182 | } |
185 | 183 | ||
186 | 184 | ||
187 | /*! | 185 | /*! |
188 | \internal | 186 | \internal |
189 | Returns a translated list of personal field names for a contact. | 187 | Returns a translated list of personal field names for a contact. |
190 | */ | 188 | */ |
191 | QStringList OPimContactFields::trpersonalfields( bool sorted ) | 189 | QStringList OPimContactFields::trpersonalfields( bool sorted ) |
192 | { | 190 | { |
193 | return personalfields( sorted, true ); | 191 | return personalfields( sorted, true ); |
194 | } | 192 | } |
195 | 193 | ||
196 | 194 | ||
197 | /*! | 195 | /*! |
198 | \internal | 196 | \internal |
199 | Returns an untranslated list of details field names for a contact. | 197 | Returns an untranslated list of details field names for a contact. |
200 | */ | 198 | */ |
201 | QStringList OPimContactFields::untrdetailsfields( bool sorted ) | 199 | QStringList OPimContactFields::untrdetailsfields( bool sorted ) |
202 | { | 200 | { |
203 | return detailsfields( sorted, false ); | 201 | return detailsfields( sorted, false ); |
204 | } | 202 | } |
205 | 203 | ||
206 | 204 | ||
207 | /*! | 205 | /*! |
208 | \internal | 206 | \internal |
209 | Returns a translated list of details field names for a contact. | 207 | Returns a translated list of details field names for a contact. |
210 | */ | 208 | */ |
211 | QStringList OPimContactFields::trdetailsfields( bool sorted ) | 209 | QStringList OPimContactFields::trdetailsfields( bool sorted ) |
212 | { | 210 | { |
213 | return detailsfields( sorted, true ); | 211 | return detailsfields( sorted, true ); |
214 | } | 212 | } |
215 | 213 | ||
216 | 214 | ||
217 | /*! | 215 | /*! |
218 | \internal | 216 | \internal |
219 | Returns a translated list of phone field names for a contact. | 217 | Returns a translated list of phone field names for a contact. |
220 | */ | 218 | */ |
221 | QStringList OPimContactFields::trphonefields( bool sorted ) | 219 | QStringList OPimContactFields::trphonefields( bool sorted ) |
222 | { | 220 | { |
223 | return phonefields( sorted, true ); | 221 | return phonefields( sorted, true ); |
224 | } | 222 | } |
225 | 223 | ||
226 | /*! | 224 | /*! |
227 | \internal | 225 | \internal |
228 | Returns an untranslated list of phone field names for a contact. | 226 | Returns an untranslated list of phone field names for a contact. |
229 | */ | 227 | */ |
230 | QStringList OPimContactFields::untrphonefields( bool sorted ) | 228 | QStringList OPimContactFields::untrphonefields( bool sorted ) |
231 | { | 229 | { |
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp index 3ddbf85..77730e9 100644 --- a/libopie2/opiepim/core/opimevent.cpp +++ b/libopie2/opiepim/core/opimevent.cpp | |||
@@ -1,234 +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) Stefan Eilers <Eilers.Stefan@epost.de> | 3 | Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> |
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 "opimevent.h" | 30 | #include "opimevent.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/opimrecurrence.h> | 33 | #include <opie2/opimrecurrence.h> |
34 | #include <opie2/opimresolver.h> | 34 | #include <opie2/opimresolver.h> |
35 | #include <opie2/opimnotifymanager.h> | 35 | #include <opie2/opimnotifymanager.h> |
36 | #include <qpe/categories.h> | 36 | #include <qpe/categories.h> |
37 | #include <qpe/palmtopuidgen.h> | ||
38 | #include <qpe/stringutil.h> | 37 | #include <qpe/stringutil.h> |
39 | 38 | ||
40 | /* QT */ | 39 | /* QT */ |
41 | #include <qshared.h> | ||
42 | #include <qarray.h> | ||
43 | 40 | ||
44 | namespace Opie | 41 | namespace Opie |
45 | { | 42 | { |
46 | 43 | ||
47 | int OCalendarHelper::week( const QDate& date ) | 44 | int OCalendarHelper::week( const QDate& date ) |
48 | { | 45 | { |
49 | // Calculates the week this date is in within that | 46 | // Calculates the week this date is in within that |
50 | // month. Equals the "row" is is in in the month view | 47 | // month. Equals the "row" is is in in the month view |
51 | int week = 1; | 48 | int week = 1; |
52 | QDate tmp( date.year(), date.month(), 1 ); | 49 | QDate tmp( date.year(), date.month(), 1 ); |
53 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) | 50 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) |
54 | ++week; | 51 | ++week; |
55 | 52 | ||
56 | week += ( date.day() - 1 ) / 7; | 53 | week += ( date.day() - 1 ) / 7; |
57 | 54 | ||
58 | return week; | 55 | return week; |
59 | } | 56 | } |
60 | 57 | ||
61 | 58 | ||
62 | int OCalendarHelper::ocurrence( const QDate& date ) | 59 | int OCalendarHelper::ocurrence( const QDate& date ) |
63 | { | 60 | { |
64 | // calculates the number of occurrances of this day of the | 61 | // calculates the number of occurrances of this day of the |
65 | // week till the given date (e.g 3rd Wednesday of the month) | 62 | // week till the given date (e.g 3rd Wednesday of the month) |
66 | return ( date.day() - 1 ) / 7 + 1; | 63 | return ( date.day() - 1 ) / 7 + 1; |
67 | } | 64 | } |
68 | 65 | ||
69 | 66 | ||
70 | int OCalendarHelper::dayOfWeek( char day ) | 67 | int OCalendarHelper::dayOfWeek( char day ) |
71 | { | 68 | { |
72 | int dayOfWeek = 1; | 69 | int dayOfWeek = 1; |
73 | char i = OPimRecurrence::MON; | 70 | char i = OPimRecurrence::MON; |
74 | while ( !( i & day ) && i <= OPimRecurrence::SUN ) | 71 | while ( !( i & day ) && i <= OPimRecurrence::SUN ) |
75 | { | 72 | { |
76 | i <<= 1; | 73 | i <<= 1; |
77 | ++dayOfWeek; | 74 | ++dayOfWeek; |
78 | } | 75 | } |
79 | return dayOfWeek; | 76 | return dayOfWeek; |
80 | } | 77 | } |
81 | 78 | ||
82 | 79 | ||
83 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) | 80 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) |
84 | { | 81 | { |
85 | return ( second.year() - first.year() ) * 12 + | 82 | return ( second.year() - first.year() ) * 12 + |
86 | second.month() - first.month(); | 83 | second.month() - first.month(); |
87 | } | 84 | } |
88 | 85 | ||
89 | 86 | ||
90 | struct OPimEvent::Data : public QShared | 87 | struct OPimEvent::Data : public QShared |
91 | { | 88 | { |
92 | Data() : QShared() | 89 | Data() : QShared() |
93 | { | 90 | { |
94 | child = 0; | 91 | child = 0; |
95 | recur = 0; | 92 | recur = 0; |
96 | manager = 0; | 93 | manager = 0; |
97 | isAllDay = false; | 94 | isAllDay = false; |
98 | parent = 0; | 95 | parent = 0; |
99 | } | 96 | } |
100 | ~Data() | 97 | ~Data() |
101 | { | 98 | { |
102 | delete manager; | 99 | delete manager; |
103 | delete recur; | 100 | delete recur; |
104 | } | 101 | } |
105 | QString description; | 102 | QString description; |
106 | QString location; | 103 | QString location; |
107 | OPimNotifyManager* manager; | 104 | OPimNotifyManager* manager; |
108 | OPimRecurrence* recur; | 105 | OPimRecurrence* recur; |
109 | QString note; | 106 | QString note; |
110 | QDateTime created; | 107 | QDateTime created; |
111 | QDateTime start; | 108 | QDateTime start; |
112 | QDateTime end; | 109 | QDateTime end; |
113 | bool isAllDay : 1; | 110 | bool isAllDay : 1; |
114 | QString timezone; | 111 | QString timezone; |
115 | QArray<int>* child; | 112 | QArray<int>* child; |
116 | int parent; | 113 | int parent; |
117 | }; | 114 | }; |
118 | 115 | ||
119 | 116 | ||
120 | OPimEvent::OPimEvent( int uid ) | 117 | OPimEvent::OPimEvent( int uid ) |
121 | : OPimRecord( uid ) | 118 | : OPimRecord( uid ) |
122 | { | 119 | { |
123 | data = new Data; | 120 | data = new Data; |
124 | } | 121 | } |
125 | 122 | ||
126 | 123 | ||
127 | OPimEvent::OPimEvent( const OPimEvent& ev ) | 124 | OPimEvent::OPimEvent( const OPimEvent& ev ) |
128 | : OPimRecord( ev ), data( ev.data ) | 125 | : OPimRecord( ev ), data( ev.data ) |
129 | { | 126 | { |
130 | data->ref(); | 127 | data->ref(); |
131 | } | 128 | } |
132 | 129 | ||
133 | 130 | ||
134 | OPimEvent::OPimEvent( const QMap<int, QString> map ) | 131 | OPimEvent::OPimEvent( const QMap<int, QString> map ) |
135 | : OPimRecord( 0 ) | 132 | : OPimRecord( 0 ) |
136 | { | 133 | { |
137 | data = new Data; | 134 | data = new Data; |
138 | 135 | ||
139 | fromMap( map ); | 136 | fromMap( map ); |
140 | } | 137 | } |
141 | 138 | ||
142 | 139 | ||
143 | OPimEvent::~OPimEvent() | 140 | OPimEvent::~OPimEvent() |
144 | { | 141 | { |
145 | if ( data->deref() ) | 142 | if ( data->deref() ) |
146 | { | 143 | { |
147 | delete data; | 144 | delete data; |
148 | data = 0; | 145 | data = 0; |
149 | } | 146 | } |
150 | } | 147 | } |
151 | 148 | ||
152 | 149 | ||
153 | OPimEvent& OPimEvent::operator=( const OPimEvent& ev ) | 150 | OPimEvent& OPimEvent::operator=( const OPimEvent& ev ) |
154 | { | 151 | { |
155 | if ( this == &ev ) return * this; | 152 | if ( this == &ev ) return * this; |
156 | 153 | ||
157 | OPimRecord::operator=( ev ); | 154 | OPimRecord::operator=( ev ); |
158 | ev.data->ref(); | 155 | ev.data->ref(); |
159 | deref(); | 156 | deref(); |
160 | data = ev.data; | 157 | data = ev.data; |
161 | 158 | ||
162 | 159 | ||
163 | return *this; | 160 | return *this; |
164 | } | 161 | } |
165 | 162 | ||
166 | 163 | ||
167 | QString OPimEvent::description() const | 164 | QString OPimEvent::description() const |
168 | { | 165 | { |
169 | return data->description; | 166 | return data->description; |
170 | } | 167 | } |
171 | 168 | ||
172 | 169 | ||
173 | void OPimEvent::setDescription( const QString& description ) | 170 | void OPimEvent::setDescription( const QString& description ) |
174 | { | 171 | { |
175 | changeOrModify(); | 172 | changeOrModify(); |
176 | data->description = description; | 173 | data->description = description; |
177 | } | 174 | } |
178 | 175 | ||
179 | 176 | ||
180 | void OPimEvent::setLocation( const QString& loc ) | 177 | void OPimEvent::setLocation( const QString& loc ) |
181 | { | 178 | { |
182 | changeOrModify(); | 179 | changeOrModify(); |
183 | data->location = loc; | 180 | data->location = loc; |
184 | } | 181 | } |
185 | 182 | ||
186 | 183 | ||
187 | QString OPimEvent::location() const | 184 | QString OPimEvent::location() const |
188 | { | 185 | { |
189 | return data->location; | 186 | return data->location; |
190 | } | 187 | } |
191 | 188 | ||
192 | 189 | ||
193 | OPimNotifyManager &OPimEvent::notifiers() const | 190 | OPimNotifyManager &OPimEvent::notifiers() const |
194 | { | 191 | { |
195 | // I hope we can skip the changeOrModify here | 192 | // I hope we can skip the changeOrModify here |
196 | // the notifier should take care of it | 193 | // the notifier should take care of it |
197 | // and OPimNotify is shared too | 194 | // and OPimNotify is shared too |
198 | if ( !data->manager ) | 195 | if ( !data->manager ) |
199 | data->manager = new OPimNotifyManager; | 196 | data->manager = new OPimNotifyManager; |
200 | 197 | ||
201 | return *data->manager; | 198 | return *data->manager; |
202 | } | 199 | } |
203 | 200 | ||
204 | 201 | ||
205 | bool OPimEvent::hasNotifiers() const | 202 | bool OPimEvent::hasNotifiers() const |
206 | { | 203 | { |
207 | if ( !data->manager ) | 204 | if ( !data->manager ) |
208 | return false; | 205 | return false; |
209 | if ( data->manager->reminders().isEmpty() && | 206 | if ( data->manager->reminders().isEmpty() && |
210 | data->manager->alarms().isEmpty() ) | 207 | data->manager->alarms().isEmpty() ) |
211 | return false; | 208 | return false; |
212 | 209 | ||
213 | return true; | 210 | return true; |
214 | } | 211 | } |
215 | 212 | ||
216 | 213 | ||
217 | OPimRecurrence OPimEvent::recurrence() const | 214 | OPimRecurrence OPimEvent::recurrence() const |
218 | { | 215 | { |
219 | if ( !data->recur ) | 216 | if ( !data->recur ) |
220 | data->recur = new OPimRecurrence; | 217 | data->recur = new OPimRecurrence; |
221 | 218 | ||
222 | return *data->recur; | 219 | return *data->recur; |
223 | } | 220 | } |
224 | 221 | ||
225 | 222 | ||
226 | void OPimEvent::setRecurrence( const OPimRecurrence& rec ) | 223 | void OPimEvent::setRecurrence( const OPimRecurrence& rec ) |
227 | { | 224 | { |
228 | changeOrModify(); | 225 | changeOrModify(); |
229 | if ( data->recur ) | 226 | if ( data->recur ) |
230 | ( *data->recur ) = rec; | 227 | ( *data->recur ) = rec; |
231 | else | 228 | else |
232 | data->recur = new OPimRecurrence( rec ); | 229 | data->recur = new OPimRecurrence( rec ); |
233 | } | 230 | } |
234 | 231 | ||
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp index 43858f0..417b0b9 100644 --- a/libopie2/opiepim/core/opimnotify.cpp +++ b/libopie2/opiepim/core/opimnotify.cpp | |||
@@ -1,225 +1,224 @@ | |||
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 "opimnotify.h" | 30 | #include "opimnotify.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qshared.h> | ||
34 | 33 | ||
35 | namespace Opie | 34 | namespace Opie |
36 | { | 35 | { |
37 | 36 | ||
38 | struct OPimNotify::Data : public QShared | 37 | struct OPimNotify::Data : public QShared |
39 | { | 38 | { |
40 | Data() : QShared(), dur( -1 ), parent( 0 ) | 39 | Data() : QShared(), dur( -1 ), parent( 0 ) |
41 | { | 40 | { |
42 | } | 41 | } |
43 | QDateTime start; | 42 | QDateTime start; |
44 | int dur; | 43 | int dur; |
45 | QString application; | 44 | QString application; |
46 | int parent; | 45 | int parent; |
47 | }; | 46 | }; |
48 | 47 | ||
49 | OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) | 48 | OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) |
50 | { | 49 | { |
51 | data = new Data; | 50 | data = new Data; |
52 | data->start = start; | 51 | data->start = start; |
53 | data->dur = duration; | 52 | data->dur = duration; |
54 | data->parent = parent; | 53 | data->parent = parent; |
55 | } | 54 | } |
56 | 55 | ||
57 | 56 | ||
58 | OPimNotify::OPimNotify( const OPimNotify& noti ) | 57 | OPimNotify::OPimNotify( const OPimNotify& noti ) |
59 | : data( noti.data ) | 58 | : data( noti.data ) |
60 | { | 59 | { |
61 | data->ref(); | 60 | data->ref(); |
62 | } | 61 | } |
63 | 62 | ||
64 | 63 | ||
65 | OPimNotify::~OPimNotify() | 64 | OPimNotify::~OPimNotify() |
66 | { | 65 | { |
67 | if ( data->deref() ) | 66 | if ( data->deref() ) |
68 | { | 67 | { |
69 | delete data; | 68 | delete data; |
70 | data = 0l; | 69 | data = 0l; |
71 | } | 70 | } |
72 | } | 71 | } |
73 | 72 | ||
74 | 73 | ||
75 | OPimNotify &OPimNotify::operator=( const OPimNotify& noti ) | 74 | OPimNotify &OPimNotify::operator=( const OPimNotify& noti ) |
76 | { | 75 | { |
77 | noti.data->ref(); | 76 | noti.data->ref(); |
78 | deref(); | 77 | deref(); |
79 | data = noti.data; | 78 | data = noti.data; |
80 | 79 | ||
81 | return *this; | 80 | return *this; |
82 | } | 81 | } |
83 | 82 | ||
84 | 83 | ||
85 | bool OPimNotify::operator==( const OPimNotify& noti ) | 84 | bool OPimNotify::operator==( const OPimNotify& noti ) |
86 | { | 85 | { |
87 | if ( data == noti.data ) return true; | 86 | if ( data == noti.data ) return true; |
88 | if ( data->dur != noti.data->dur ) return false; | 87 | if ( data->dur != noti.data->dur ) return false; |
89 | if ( data->parent != noti.data->parent ) return false; | 88 | if ( data->parent != noti.data->parent ) return false; |
90 | if ( data->application != noti.data->application ) return false; | 89 | if ( data->application != noti.data->application ) return false; |
91 | if ( data->start != noti.data->start ) return false; | 90 | if ( data->start != noti.data->start ) return false; |
92 | 91 | ||
93 | return true; | 92 | return true; |
94 | } | 93 | } |
95 | 94 | ||
96 | 95 | ||
97 | QDateTime OPimNotify::dateTime() const | 96 | QDateTime OPimNotify::dateTime() const |
98 | { | 97 | { |
99 | return data->start; | 98 | return data->start; |
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
103 | QString OPimNotify::service() const | 102 | QString OPimNotify::service() const |
104 | { | 103 | { |
105 | return data->application; | 104 | return data->application; |
106 | } | 105 | } |
107 | 106 | ||
108 | 107 | ||
109 | int OPimNotify::parent() const | 108 | int OPimNotify::parent() const |
110 | { | 109 | { |
111 | return data->parent; | 110 | return data->parent; |
112 | } | 111 | } |
113 | 112 | ||
114 | 113 | ||
115 | int OPimNotify::duration() const | 114 | int OPimNotify::duration() const |
116 | { | 115 | { |
117 | return data->dur; | 116 | return data->dur; |
118 | } | 117 | } |
119 | 118 | ||
120 | 119 | ||
121 | QDateTime OPimNotify::endTime() const | 120 | QDateTime OPimNotify::endTime() const |
122 | { | 121 | { |
123 | return QDateTime( data->start.date(), data->start.time().addSecs( data->dur ) ); | 122 | return QDateTime( data->start.date(), data->start.time().addSecs( data->dur ) ); |
124 | } | 123 | } |
125 | 124 | ||
126 | 125 | ||
127 | void OPimNotify::setDateTime( const QDateTime& time ) | 126 | void OPimNotify::setDateTime( const QDateTime& time ) |
128 | { | 127 | { |
129 | copyIntern(); | 128 | copyIntern(); |
130 | data->start = time; | 129 | data->start = time; |
131 | } | 130 | } |
132 | 131 | ||
133 | 132 | ||
134 | void OPimNotify::setDuration( int dur ) | 133 | void OPimNotify::setDuration( int dur ) |
135 | { | 134 | { |
136 | copyIntern(); | 135 | copyIntern(); |
137 | data->dur = dur; | 136 | data->dur = dur; |
138 | } | 137 | } |
139 | 138 | ||
140 | 139 | ||
141 | void OPimNotify::setParent( int uid ) | 140 | void OPimNotify::setParent( int uid ) |
142 | { | 141 | { |
143 | copyIntern(); | 142 | copyIntern(); |
144 | data->parent = uid; | 143 | data->parent = uid; |
145 | } | 144 | } |
146 | 145 | ||
147 | 146 | ||
148 | void OPimNotify::setService( const QString& str ) | 147 | void OPimNotify::setService( const QString& str ) |
149 | { | 148 | { |
150 | copyIntern(); | 149 | copyIntern(); |
151 | data->application = str; | 150 | data->application = str; |
152 | } | 151 | } |
153 | 152 | ||
154 | 153 | ||
155 | void OPimNotify::copyIntern() | 154 | void OPimNotify::copyIntern() |
156 | { | 155 | { |
157 | if ( data->count != 1 ) | 156 | if ( data->count != 1 ) |
158 | { | 157 | { |
159 | data->deref(); | 158 | data->deref(); |
160 | Data* dat = new Data; | 159 | Data* dat = new Data; |
161 | dat->start = data->start; | 160 | dat->start = data->start; |
162 | dat->dur = data->dur; | 161 | dat->dur = data->dur; |
163 | dat->application = data->application; | 162 | dat->application = data->application; |
164 | dat->parent = data->parent; | 163 | dat->parent = data->parent; |
165 | data = dat; | 164 | data = dat; |
166 | } | 165 | } |
167 | } | 166 | } |
168 | 167 | ||
169 | 168 | ||
170 | void OPimNotify::deref() | 169 | void OPimNotify::deref() |
171 | { | 170 | { |
172 | if ( data->deref() ) | 171 | if ( data->deref() ) |
173 | { | 172 | { |
174 | delete data; | 173 | delete data; |
175 | data = 0; | 174 | data = 0; |
176 | } | 175 | } |
177 | } | 176 | } |
178 | 177 | ||
179 | 178 | ||
180 | /***********************************************************/ | 179 | /***********************************************************/ |
181 | struct OPimAlarm::Data : public QShared | 180 | struct OPimAlarm::Data : public QShared |
182 | { | 181 | { |
183 | Data() : QShared() | 182 | Data() : QShared() |
184 | { | 183 | { |
185 | sound = 1; | 184 | sound = 1; |
186 | } | 185 | } |
187 | int sound; | 186 | int sound; |
188 | QString file; | 187 | QString file; |
189 | }; | 188 | }; |
190 | 189 | ||
191 | 190 | ||
192 | OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) | 191 | OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) |
193 | : OPimNotify( start, duration, parent ) | 192 | : OPimNotify( start, duration, parent ) |
194 | { | 193 | { |
195 | data = new Data; | 194 | data = new Data; |
196 | data->sound = sound; | 195 | data->sound = sound; |
197 | } | 196 | } |
198 | 197 | ||
199 | 198 | ||
200 | OPimAlarm::OPimAlarm( const OPimAlarm& al ) | 199 | OPimAlarm::OPimAlarm( const OPimAlarm& al ) |
201 | : OPimNotify( al ), data( al.data ) | 200 | : OPimNotify( al ), data( al.data ) |
202 | { | 201 | { |
203 | data->ref(); | 202 | data->ref(); |
204 | } | 203 | } |
205 | 204 | ||
206 | 205 | ||
207 | OPimAlarm::~OPimAlarm() | 206 | OPimAlarm::~OPimAlarm() |
208 | { | 207 | { |
209 | if ( data->deref() ) | 208 | if ( data->deref() ) |
210 | { | 209 | { |
211 | delete data; | 210 | delete data; |
212 | data = 0l; | 211 | data = 0l; |
213 | } | 212 | } |
214 | } | 213 | } |
215 | 214 | ||
216 | 215 | ||
217 | OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al ) | 216 | OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al ) |
218 | { | 217 | { |
219 | OPimNotify::operator=( al ); | 218 | OPimNotify::operator=( al ); |
220 | deref(); | 219 | deref(); |
221 | al.data->ref(); | 220 | al.data->ref(); |
222 | 221 | ||
223 | data = al.data; | 222 | data = al.data; |
224 | 223 | ||
225 | 224 | ||
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index c603f44..67eed41 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -1,229 +1,228 @@ | |||
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 "opimrecord.h" | 30 | #include "opimrecord.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <qpe/categories.h> | 33 | #include <qpe/categories.h> |
34 | #include <qpe/categoryselect.h> | 34 | #include <qpe/categoryselect.h> |
35 | 35 | ||
36 | /* QT */ | 36 | /* QT */ |
37 | #include <qarray.h> | ||
38 | 37 | ||
39 | namespace Opie | 38 | namespace Opie |
40 | { | 39 | { |
41 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); | 40 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); |
42 | 41 | ||
43 | 42 | ||
44 | OPimRecord::OPimRecord( int uid ) | 43 | OPimRecord::OPimRecord( int uid ) |
45 | : Qtopia::Record() | 44 | : Qtopia::Record() |
46 | { | 45 | { |
47 | 46 | ||
48 | m_lastHit = -1; | 47 | m_lastHit = -1; |
49 | setUid( uid ); | 48 | setUid( uid ); |
50 | } | 49 | } |
51 | 50 | ||
52 | 51 | ||
53 | OPimRecord::~OPimRecord() | 52 | OPimRecord::~OPimRecord() |
54 | {} | 53 | {} |
55 | 54 | ||
56 | 55 | ||
57 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 56 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
58 | : Qtopia::Record( rec ) | 57 | : Qtopia::Record( rec ) |
59 | { | 58 | { |
60 | ( *this ) = rec; | 59 | ( *this ) = rec; |
61 | } | 60 | } |
62 | 61 | ||
63 | 62 | ||
64 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec ) | 63 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec ) |
65 | { | 64 | { |
66 | if ( this == &rec ) return * this; | 65 | if ( this == &rec ) return * this; |
67 | 66 | ||
68 | Qtopia::Record::operator=( rec ); | 67 | Qtopia::Record::operator=( rec ); |
69 | m_xrefman = rec.m_xrefman; | 68 | m_xrefman = rec.m_xrefman; |
70 | m_lastHit = rec.m_lastHit; | 69 | m_lastHit = rec.m_lastHit; |
71 | 70 | ||
72 | return *this; | 71 | return *this; |
73 | } | 72 | } |
74 | 73 | ||
75 | 74 | ||
76 | /* | 75 | /* |
77 | * category names | 76 | * category names |
78 | */ | 77 | */ |
79 | QStringList OPimRecord::categoryNames( const QString& appname ) const | 78 | QStringList OPimRecord::categoryNames( const QString& appname ) const |
80 | { | 79 | { |
81 | QStringList list; | 80 | QStringList list; |
82 | QArray<int> cats = categories(); | 81 | QArray<int> cats = categories(); |
83 | Categories catDB; | 82 | Categories catDB; |
84 | catDB.load( categoryFileName() ); | 83 | catDB.load( categoryFileName() ); |
85 | 84 | ||
86 | for ( uint i = 0; i < cats.count(); i++ ) | 85 | for ( uint i = 0; i < cats.count(); i++ ) |
87 | { | 86 | { |
88 | list << catDB.label( appname, cats[ i ] ); | 87 | list << catDB.label( appname, cats[ i ] ); |
89 | } | 88 | } |
90 | 89 | ||
91 | return list; | 90 | return list; |
92 | } | 91 | } |
93 | 92 | ||
94 | 93 | ||
95 | void OPimRecord::setCategoryNames( const QStringList& ) | 94 | void OPimRecord::setCategoryNames( const QStringList& ) |
96 | { | 95 | { |
97 | } | 96 | } |
98 | 97 | ||
99 | 98 | ||
100 | void OPimRecord::addCategoryName( const QString& ) | 99 | void OPimRecord::addCategoryName( const QString& ) |
101 | { | 100 | { |
102 | Categories catDB; | 101 | Categories catDB; |
103 | catDB.load( categoryFileName() ); | 102 | catDB.load( categoryFileName() ); |
104 | 103 | ||
105 | 104 | ||
106 | } | 105 | } |
107 | 106 | ||
108 | 107 | ||
109 | bool OPimRecord::isEmpty() const | 108 | bool OPimRecord::isEmpty() const |
110 | { | 109 | { |
111 | return ( uid() == 0 ); | 110 | return ( uid() == 0 ); |
112 | } | 111 | } |
113 | 112 | ||
114 | 113 | ||
115 | /*QString OPimRecord::crossToString()const { | 114 | /*QString OPimRecord::crossToString()const { |
116 | QString str; | 115 | QString str; |
117 | QMap<QString, QArray<int> >::ConstIterator it; | 116 | QMap<QString, QArray<int> >::ConstIterator it; |
118 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | 117 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { |
119 | QArray<int> id = it.data(); | 118 | QArray<int> id = it.data(); |
120 | for ( uint i = 0; i < id.size(); ++i ) { | 119 | for ( uint i = 0; i < id.size(); ++i ) { |
121 | str += it.key() + "," + QString::number( i ) + ";"; | 120 | str += it.key() + "," + QString::number( i ) + ";"; |
122 | } | 121 | } |
123 | } | 122 | } |
124 | str = str.remove( str.length()-1, 1); // strip the ; | 123 | str = str.remove( str.length()-1, 1); // strip the ; |
125 | //qWarning("IDS " + str ); | 124 | //qWarning("IDS " + str ); |
126 | 125 | ||
127 | return str; | 126 | return str; |
128 | }*/ | 127 | }*/ |
129 | /* if uid = 1 assign a new one */ | 128 | /* if uid = 1 assign a new one */ |
130 | void OPimRecord::setUid( int uid ) | 129 | void OPimRecord::setUid( int uid ) |
131 | { | 130 | { |
132 | if ( uid == 1 ) | 131 | if ( uid == 1 ) |
133 | uid = uidGen().generate(); | 132 | uid = uidGen().generate(); |
134 | 133 | ||
135 | Qtopia::Record::setUid( uid ); | 134 | Qtopia::Record::setUid( uid ); |
136 | }; | 135 | }; |
137 | 136 | ||
138 | 137 | ||
139 | Qtopia::UidGen &OPimRecord::uidGen() | 138 | Qtopia::UidGen &OPimRecord::uidGen() |
140 | { | 139 | { |
141 | return m_uidGen; | 140 | return m_uidGen; |
142 | } | 141 | } |
143 | 142 | ||
144 | 143 | ||
145 | OPimXRefManager &OPimRecord::xrefmanager() | 144 | OPimXRefManager &OPimRecord::xrefmanager() |
146 | { | 145 | { |
147 | return m_xrefman; | 146 | return m_xrefman; |
148 | } | 147 | } |
149 | 148 | ||
150 | 149 | ||
151 | int OPimRecord::rtti() | 150 | int OPimRecord::rtti() |
152 | { | 151 | { |
153 | return 0; | 152 | return 0; |
154 | } | 153 | } |
155 | 154 | ||
156 | /** | 155 | /** |
157 | * now let's put our data into the stream | 156 | * now let's put our data into the stream |
158 | */ | 157 | */ |
159 | /* | 158 | /* |
160 | * First read UID | 159 | * First read UID |
161 | * Categories | 160 | * Categories |
162 | * XRef | 161 | * XRef |
163 | */ | 162 | */ |
164 | bool OPimRecord::loadFromStream( QDataStream& stream ) | 163 | bool OPimRecord::loadFromStream( QDataStream& stream ) |
165 | { | 164 | { |
166 | int Int; | 165 | int Int; |
167 | uint UInt; | 166 | uint UInt; |
168 | stream >> Int; | 167 | stream >> Int; |
169 | setUid( Int ); | 168 | setUid( Int ); |
170 | 169 | ||
171 | /** Categories */ | 170 | /** Categories */ |
172 | stream >> UInt; | 171 | stream >> UInt; |
173 | QArray<int> array( UInt ); | 172 | QArray<int> array( UInt ); |
174 | for ( uint i = 0; i < UInt; i++ ) | 173 | for ( uint i = 0; i < UInt; i++ ) |
175 | { | 174 | { |
176 | stream >> array[ i ]; | 175 | stream >> array[ i ]; |
177 | } | 176 | } |
178 | setCategories( array ); | 177 | setCategories( array ); |
179 | 178 | ||
180 | /* | 179 | /* |
181 | * now we do the X-Ref stuff | 180 | * now we do the X-Ref stuff |
182 | */ | 181 | */ |
183 | OPimXRef xref; | 182 | OPimXRef xref; |
184 | stream >> UInt; | 183 | stream >> UInt; |
185 | for ( uint i = 0; i < UInt; i++ ) | 184 | for ( uint i = 0; i < UInt; i++ ) |
186 | { | 185 | { |
187 | xref.setPartner( OPimXRef::One, partner( stream ) ); | 186 | xref.setPartner( OPimXRef::One, partner( stream ) ); |
188 | xref.setPartner( OPimXRef::Two, partner( stream ) ); | 187 | xref.setPartner( OPimXRef::Two, partner( stream ) ); |
189 | m_xrefman.add( xref ); | 188 | m_xrefman.add( xref ); |
190 | } | 189 | } |
191 | 190 | ||
192 | return true; | 191 | return true; |
193 | } | 192 | } |
194 | 193 | ||
195 | 194 | ||
196 | bool OPimRecord::saveToStream( QDataStream& stream ) const | 195 | bool OPimRecord::saveToStream( QDataStream& stream ) const |
197 | { | 196 | { |
198 | /** UIDs */ | 197 | /** UIDs */ |
199 | 198 | ||
200 | stream << uid(); | 199 | stream << uid(); |
201 | 200 | ||
202 | /** Categories */ | 201 | /** Categories */ |
203 | stream << categories().count(); | 202 | stream << categories().count(); |
204 | for ( uint i = 0; i < categories().count(); i++ ) | 203 | for ( uint i = 0; i < categories().count(); i++ ) |
205 | { | 204 | { |
206 | stream << categories() [ i ]; | 205 | stream << categories() [ i ]; |
207 | } | 206 | } |
208 | 207 | ||
209 | /* | 208 | /* |
210 | * first the XRef count | 209 | * first the XRef count |
211 | * then the xrefs | 210 | * then the xrefs |
212 | */ | 211 | */ |
213 | stream << m_xrefman.list().count(); | 212 | stream << m_xrefman.list().count(); |
214 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); | 213 | for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); |
215 | it != m_xrefman.list().end(); ++it ) | 214 | it != m_xrefman.list().end(); ++it ) |
216 | { | 215 | { |
217 | flush( ( *it ).partner( OPimXRef::One ), stream ); | 216 | flush( ( *it ).partner( OPimXRef::One ), stream ); |
218 | flush( ( *it ).partner( OPimXRef::Two ), stream ); | 217 | flush( ( *it ).partner( OPimXRef::Two ), stream ); |
219 | } | 218 | } |
220 | return true; | 219 | return true; |
221 | } | 220 | } |
222 | 221 | ||
223 | 222 | ||
224 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const | 223 | void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const |
225 | { | 224 | { |
226 | str << par.service(); | 225 | str << par.service(); |
227 | str << par.uid(); | 226 | str << par.uid(); |
228 | str << par.field(); | 227 | str << par.field(); |
229 | } | 228 | } |
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp index 34df807..f246bfd 100644 --- a/libopie2/opiepim/core/opimtodo.cpp +++ b/libopie2/opiepim/core/opimtodo.cpp | |||
@@ -1,235 +1,234 @@ | |||
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 "opimtodo.h" | 30 | #include "opimtodo.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/opimstate.h> | 33 | #include <opie2/opimstate.h> |
34 | #include <opie2/opimrecurrence.h> | 34 | #include <opie2/opimrecurrence.h> |
35 | #include <opie2/opimmaintainer.h> | 35 | #include <opie2/opimmaintainer.h> |
36 | #include <opie2/opimnotifymanager.h> | 36 | #include <opie2/opimnotifymanager.h> |
37 | #include <opie2/opimresolver.h> | 37 | #include <opie2/opimresolver.h> |
38 | #include <qpe/palmtopuidgen.h> | 38 | #include <qpe/palmtopuidgen.h> |
39 | #include <qpe/stringutil.h> | ||
40 | #include <qpe/palmtoprecord.h> | 39 | #include <qpe/palmtoprecord.h> |
41 | #include <qpe/stringutil.h> | ||
42 | #include <qpe/categories.h> | 40 | #include <qpe/categories.h> |
43 | #include <qpe/categoryselect.h> | 41 | #include <qpe/categoryselect.h> |
42 | #include <qpe/stringutil.h> | ||
44 | 43 | ||
45 | /* QT */ | 44 | /* QT */ |
46 | #include <qobject.h> | 45 | #include <qobject.h> |
47 | #include <qshared.h> | 46 | #include <qshared.h> |
48 | 47 | ||
49 | namespace Opie | 48 | namespace Opie |
50 | { | 49 | { |
51 | 50 | ||
52 | struct OPimTodo::OPimTodoData : public QShared | 51 | struct OPimTodo::OPimTodoData : public QShared |
53 | { | 52 | { |
54 | OPimTodoData() : QShared() | 53 | OPimTodoData() : QShared() |
55 | { | 54 | { |
56 | recur = 0; | 55 | recur = 0; |
57 | state = 0; | 56 | state = 0; |
58 | maintainer = 0; | 57 | maintainer = 0; |
59 | notifiers = 0; | 58 | notifiers = 0; |
60 | }; | 59 | }; |
61 | ~OPimTodoData() | 60 | ~OPimTodoData() |
62 | { | 61 | { |
63 | delete recur; | 62 | delete recur; |
64 | delete maintainer; | 63 | delete maintainer; |
65 | delete notifiers; | 64 | delete notifiers; |
66 | } | 65 | } |
67 | 66 | ||
68 | QDate date; | 67 | QDate date; |
69 | bool isCompleted: 1; | 68 | bool isCompleted: 1; |
70 | bool hasDate: 1; | 69 | bool hasDate: 1; |
71 | int priority; | 70 | int priority; |
72 | QString desc; | 71 | QString desc; |
73 | QString sum; | 72 | QString sum; |
74 | QMap<QString, QString> extra; | 73 | QMap<QString, QString> extra; |
75 | ushort prog; | 74 | ushort prog; |
76 | OPimState *state; | 75 | OPimState *state; |
77 | OPimRecurrence *recur; | 76 | OPimRecurrence *recur; |
78 | OPimMaintainer *maintainer; | 77 | OPimMaintainer *maintainer; |
79 | QDate start; | 78 | QDate start; |
80 | QDate completed; | 79 | QDate completed; |
81 | OPimNotifyManager *notifiers; | 80 | OPimNotifyManager *notifiers; |
82 | }; | 81 | }; |
83 | 82 | ||
84 | 83 | ||
85 | OPimTodo::OPimTodo( const OPimTodo &event ) | 84 | OPimTodo::OPimTodo( const OPimTodo &event ) |
86 | : OPimRecord( event ), data( event.data ) | 85 | : OPimRecord( event ), data( event.data ) |
87 | { | 86 | { |
88 | data->ref(); | 87 | data->ref(); |
89 | // qWarning("ref up"); | 88 | // qWarning("ref up"); |
90 | } | 89 | } |
91 | 90 | ||
92 | 91 | ||
93 | OPimTodo::~OPimTodo() | 92 | OPimTodo::~OPimTodo() |
94 | { | 93 | { |
95 | 94 | ||
96 | // qWarning("~OPimTodo " ); | 95 | // qWarning("~OPimTodo " ); |
97 | if ( data->deref() ) | 96 | if ( data->deref() ) |
98 | { | 97 | { |
99 | // qWarning("OPimTodo::dereffing"); | 98 | // qWarning("OPimTodo::dereffing"); |
100 | delete data; | 99 | delete data; |
101 | data = 0l; | 100 | data = 0l; |
102 | } | 101 | } |
103 | } | 102 | } |
104 | 103 | ||
105 | 104 | ||
106 | OPimTodo::OPimTodo( bool completed, int priority, | 105 | OPimTodo::OPimTodo( bool completed, int priority, |
107 | const QArray<int> &category, | 106 | const QArray<int> &category, |
108 | const QString& summary, | 107 | const QString& summary, |
109 | const QString &description, | 108 | const QString &description, |
110 | ushort progress, | 109 | ushort progress, |
111 | bool hasDate, QDate date, int uid ) | 110 | bool hasDate, QDate date, int uid ) |
112 | : OPimRecord( uid ) | 111 | : OPimRecord( uid ) |
113 | { | 112 | { |
114 | // qWarning("OPimTodoData " + summary); | 113 | // qWarning("OPimTodoData " + summary); |
115 | setCategories( category ); | 114 | setCategories( category ); |
116 | 115 | ||
117 | data = new OPimTodoData; | 116 | data = new OPimTodoData; |
118 | 117 | ||
119 | data->date = date; | 118 | data->date = date; |
120 | data->isCompleted = completed; | 119 | data->isCompleted = completed; |
121 | data->hasDate = hasDate; | 120 | data->hasDate = hasDate; |
122 | data->priority = priority; | 121 | data->priority = priority; |
123 | data->sum = summary; | 122 | data->sum = summary; |
124 | data->prog = progress; | 123 | data->prog = progress; |
125 | data->desc = Qtopia::simplifyMultiLineSpace( description ); | 124 | data->desc = Qtopia::simplifyMultiLineSpace( description ); |
126 | } | 125 | } |
127 | 126 | ||
128 | 127 | ||
129 | OPimTodo::OPimTodo( bool completed, int priority, | 128 | OPimTodo::OPimTodo( bool completed, int priority, |
130 | const QStringList &category, | 129 | const QStringList &category, |
131 | const QString& summary, | 130 | const QString& summary, |
132 | const QString &description, | 131 | const QString &description, |
133 | ushort progress, | 132 | ushort progress, |
134 | bool hasDate, QDate date, int uid ) | 133 | bool hasDate, QDate date, int uid ) |
135 | : OPimRecord( uid ) | 134 | : OPimRecord( uid ) |
136 | { | 135 | { |
137 | // qWarning("OPimTodoData" + summary); | 136 | // qWarning("OPimTodoData" + summary); |
138 | setCategories( idsFromString( category.join( ";" ) ) ); | 137 | setCategories( idsFromString( category.join( ";" ) ) ); |
139 | 138 | ||
140 | data = new OPimTodoData; | 139 | data = new OPimTodoData; |
141 | 140 | ||
142 | data->date = date; | 141 | data->date = date; |
143 | data->isCompleted = completed; | 142 | data->isCompleted = completed; |
144 | data->hasDate = hasDate; | 143 | data->hasDate = hasDate; |
145 | data->priority = priority; | 144 | data->priority = priority; |
146 | data->sum = summary; | 145 | data->sum = summary; |
147 | data->prog = progress; | 146 | data->prog = progress; |
148 | data->desc = Qtopia::simplifyMultiLineSpace( description ); | 147 | data->desc = Qtopia::simplifyMultiLineSpace( description ); |
149 | } | 148 | } |
150 | 149 | ||
151 | 150 | ||
152 | bool OPimTodo::match( const QRegExp ®Exp ) const | 151 | bool OPimTodo::match( const QRegExp ®Exp ) const |
153 | { | 152 | { |
154 | if ( QString::number( data->priority ).find( regExp ) != -1 ) | 153 | if ( QString::number( data->priority ).find( regExp ) != -1 ) |
155 | { | 154 | { |
156 | setLastHitField( Priority ); | 155 | setLastHitField( Priority ); |
157 | return true; | 156 | return true; |
158 | } | 157 | } |
159 | else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) | 158 | else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) |
160 | { | 159 | { |
161 | setLastHitField( HasDate ); | 160 | setLastHitField( HasDate ); |
162 | return true; | 161 | return true; |
163 | } | 162 | } |
164 | else if ( data->desc.find( regExp ) != -1 ) | 163 | else if ( data->desc.find( regExp ) != -1 ) |
165 | { | 164 | { |
166 | setLastHitField( Description ); | 165 | setLastHitField( Description ); |
167 | return true; | 166 | return true; |
168 | } | 167 | } |
169 | else if ( data->sum.find( regExp ) != -1 ) | 168 | else if ( data->sum.find( regExp ) != -1 ) |
170 | { | 169 | { |
171 | setLastHitField( Summary ); | 170 | setLastHitField( Summary ); |
172 | return true; | 171 | return true; |
173 | } | 172 | } |
174 | return false; | 173 | return false; |
175 | } | 174 | } |
176 | 175 | ||
177 | 176 | ||
178 | bool OPimTodo::isCompleted() const | 177 | bool OPimTodo::isCompleted() const |
179 | { | 178 | { |
180 | return data->isCompleted; | 179 | return data->isCompleted; |
181 | } | 180 | } |
182 | 181 | ||
183 | 182 | ||
184 | bool OPimTodo::hasDueDate() const | 183 | bool OPimTodo::hasDueDate() const |
185 | { | 184 | { |
186 | return data->hasDate; | 185 | return data->hasDate; |
187 | } | 186 | } |
188 | 187 | ||
189 | 188 | ||
190 | bool OPimTodo::hasStartDate() const | 189 | bool OPimTodo::hasStartDate() const |
191 | { | 190 | { |
192 | return data->start.isValid(); | 191 | return data->start.isValid(); |
193 | } | 192 | } |
194 | 193 | ||
195 | 194 | ||
196 | bool OPimTodo::hasCompletedDate() const | 195 | bool OPimTodo::hasCompletedDate() const |
197 | { | 196 | { |
198 | return data->completed.isValid(); | 197 | return data->completed.isValid(); |
199 | } | 198 | } |
200 | 199 | ||
201 | 200 | ||
202 | int OPimTodo::priority() const | 201 | int OPimTodo::priority() const |
203 | { | 202 | { |
204 | return data->priority; | 203 | return data->priority; |
205 | } | 204 | } |
206 | 205 | ||
207 | 206 | ||
208 | QString OPimTodo::summary() const | 207 | QString OPimTodo::summary() const |
209 | { | 208 | { |
210 | return data->sum; | 209 | return data->sum; |
211 | } | 210 | } |
212 | 211 | ||
213 | 212 | ||
214 | ushort OPimTodo::progress() const | 213 | ushort OPimTodo::progress() const |
215 | { | 214 | { |
216 | return data->prog; | 215 | return data->prog; |
217 | } | 216 | } |
218 | 217 | ||
219 | 218 | ||
220 | QDate OPimTodo::dueDate() const | 219 | QDate OPimTodo::dueDate() const |
221 | { | 220 | { |
222 | return data->date; | 221 | return data->date; |
223 | } | 222 | } |
224 | 223 | ||
225 | 224 | ||
226 | QDate OPimTodo::startDate() const | 225 | QDate OPimTodo::startDate() const |
227 | { | 226 | { |
228 | return data->start; | 227 | return data->start; |
229 | } | 228 | } |
230 | 229 | ||
231 | 230 | ||
232 | QDate OPimTodo::completedDate() const | 231 | QDate OPimTodo::completedDate() const |
233 | { | 232 | { |
234 | return data->completed; | 233 | return data->completed; |
235 | } | 234 | } |
diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp index 49628c9..49ddeb6 100644 --- a/libopie2/opieui/ofontselector.cpp +++ b/libopie2/opieui/ofontselector.cpp | |||
@@ -1,231 +1,230 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Robert Griebl <sandman@handhelds.org> | 3 | Copyright (C) Robert Griebl <sandman@handhelds.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 | /* OPIE */ | 30 | /* OPIE */ |
31 | #include <opie2/ofontselector.h> | 31 | #include <opie2/ofontselector.h> |
32 | #include <qpe/fontdatabase.h> | 32 | #include <qpe/fontdatabase.h> |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qlistbox.h> | 36 | #include <qlistbox.h> |
37 | #include <qcombobox.h> | 37 | #include <qcombobox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qfont.h> | ||
40 | #include <qmultilineedit.h> | 39 | #include <qmultilineedit.h> |
41 | 40 | ||
42 | using namespace Opie; | 41 | using namespace Opie; |
43 | 42 | ||
44 | namespace Opie | 43 | namespace Opie |
45 | { | 44 | { |
46 | 45 | ||
47 | class OFontSelectorPrivate | 46 | class OFontSelectorPrivate |
48 | { | 47 | { |
49 | public: | 48 | public: |
50 | QListBox * m_font_family_list; | 49 | QListBox * m_font_family_list; |
51 | QComboBox * m_font_style_list; | 50 | QComboBox * m_font_style_list; |
52 | QComboBox * m_font_size_list; | 51 | QComboBox * m_font_size_list; |
53 | QMultiLineEdit *m_preview; | 52 | QMultiLineEdit *m_preview; |
54 | 53 | ||
55 | bool m_pointbug : 1; | 54 | bool m_pointbug : 1; |
56 | 55 | ||
57 | FontDatabase m_fdb; | 56 | FontDatabase m_fdb; |
58 | }; | 57 | }; |
59 | 58 | ||
60 | }; | 59 | }; |
61 | 60 | ||
62 | namespace | 61 | namespace |
63 | { | 62 | { |
64 | 63 | ||
65 | class FontListItem : public QListBoxText | 64 | class FontListItem : public QListBoxText |
66 | { | 65 | { |
67 | public: | 66 | public: |
68 | FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() | 67 | FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() |
69 | { | 68 | { |
70 | m_name = t; | 69 | m_name = t; |
71 | m_styles = styles; | 70 | m_styles = styles; |
72 | m_sizes = sizes; | 71 | m_sizes = sizes; |
73 | 72 | ||
74 | QString str = t; | 73 | QString str = t; |
75 | str [0] = str [0]. upper(); | 74 | str [0] = str [0]. upper(); |
76 | setText ( str ); | 75 | setText ( str ); |
77 | } | 76 | } |
78 | 77 | ||
79 | QString family() const | 78 | QString family() const |
80 | { | 79 | { |
81 | return m_name; | 80 | return m_name; |
82 | } | 81 | } |
83 | 82 | ||
84 | const QStringList &styles() const | 83 | const QStringList &styles() const |
85 | { | 84 | { |
86 | return m_styles; | 85 | return m_styles; |
87 | } | 86 | } |
88 | 87 | ||
89 | const QValueList<int> &sizes() const | 88 | const QValueList<int> &sizes() const |
90 | { | 89 | { |
91 | return m_sizes; | 90 | return m_sizes; |
92 | } | 91 | } |
93 | 92 | ||
94 | private: | 93 | private: |
95 | QStringList m_styles; | 94 | QStringList m_styles; |
96 | QValueList<int> m_sizes; | 95 | QValueList<int> m_sizes; |
97 | QString m_name; | 96 | QString m_name; |
98 | }; | 97 | }; |
99 | 98 | ||
100 | 99 | ||
101 | static int findItemCB( QComboBox *box, const QString &str ) | 100 | static int findItemCB( QComboBox *box, const QString &str ) |
102 | { | 101 | { |
103 | for ( int i = 0; i < box->count(); i++ ) | 102 | for ( int i = 0; i < box->count(); i++ ) |
104 | { | 103 | { |
105 | if ( box->text ( i ) == str ) | 104 | if ( box->text ( i ) == str ) |
106 | return i; | 105 | return i; |
107 | } | 106 | } |
108 | return -1; | 107 | return -1; |
109 | } | 108 | } |
110 | 109 | ||
111 | } | 110 | } |
112 | /* static same as anon. namespace */ | 111 | /* static same as anon. namespace */ |
113 | static int qt_version() | 112 | static int qt_version() |
114 | { | 113 | { |
115 | const char *qver = qVersion(); | 114 | const char *qver = qVersion(); |
116 | 115 | ||
117 | return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); | 116 | return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); |
118 | } | 117 | } |
119 | 118 | ||
120 | /** | 119 | /** |
121 | * Constructs the Selector object | 120 | * Constructs the Selector object |
122 | * @param withpreview If a font preview should be given | 121 | * @param withpreview If a font preview should be given |
123 | * @param parent The parent of the Font Selector | 122 | * @param parent The parent of the Font Selector |
124 | * @param name The name of the object | 123 | * @param name The name of the object |
125 | * @param fl WidgetFlags | 124 | * @param fl WidgetFlags |
126 | */ | 125 | */ |
127 | OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) | 126 | OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) |
128 | { | 127 | { |
129 | d = new OFontSelectorPrivate(); | 128 | d = new OFontSelectorPrivate(); |
130 | 129 | ||
131 | QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); | 130 | QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); |
132 | gridLayout->setRowStretch( 4, 10 ); | 131 | gridLayout->setRowStretch( 4, 10 ); |
133 | 132 | ||
134 | d->m_font_family_list = new QListBox( this, "FontListBox" ); | 133 | d->m_font_family_list = new QListBox( this, "FontListBox" ); |
135 | gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); | 134 | gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); |
136 | connect( d->m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); | 135 | connect( d->m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); |
137 | 136 | ||
138 | QLabel *label = new QLabel( tr( "Style" ), this ); | 137 | QLabel *label = new QLabel( tr( "Style" ), this ); |
139 | gridLayout->addWidget( label, 0, 1 ); | 138 | gridLayout->addWidget( label, 0, 1 ); |
140 | 139 | ||
141 | d->m_font_style_list = new QComboBox( this, "StyleListBox" ); | 140 | d->m_font_style_list = new QComboBox( this, "StyleListBox" ); |
142 | connect( d->m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); | 141 | connect( d->m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); |
143 | gridLayout->addWidget( d->m_font_style_list, 1, 1 ); | 142 | gridLayout->addWidget( d->m_font_style_list, 1, 1 ); |
144 | 143 | ||
145 | label = new QLabel( tr( "Size" ), this ); | 144 | label = new QLabel( tr( "Size" ), this ); |
146 | gridLayout->addWidget( label, 2, 1 ); | 145 | gridLayout->addWidget( label, 2, 1 ); |
147 | 146 | ||
148 | d->m_font_size_list = new QComboBox( this, "SizeListBox" ); | 147 | d->m_font_size_list = new QComboBox( this, "SizeListBox" ); |
149 | connect( d->m_font_size_list, SIGNAL( activated( int ) ), | 148 | connect( d->m_font_size_list, SIGNAL( activated( int ) ), |
150 | this, SLOT( fontSizeClicked( int ) ) ); | 149 | this, SLOT( fontSizeClicked( int ) ) ); |
151 | gridLayout->addWidget( d->m_font_size_list, 3, 1 ); | 150 | gridLayout->addWidget( d->m_font_size_list, 3, 1 ); |
152 | 151 | ||
153 | d->m_pointbug = ( qt_version() <= 233 ); | 152 | d->m_pointbug = ( qt_version() <= 233 ); |
154 | 153 | ||
155 | if ( withpreview ) | 154 | if ( withpreview ) |
156 | { | 155 | { |
157 | d->m_preview = new QMultiLineEdit ( this, "Preview" ); | 156 | d->m_preview = new QMultiLineEdit ( this, "Preview" ); |
158 | d->m_preview->setAlignment ( AlignCenter ); | 157 | d->m_preview->setAlignment ( AlignCenter ); |
159 | d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); | 158 | d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); |
160 | d->m_preview->setMargin ( 3 ); | 159 | d->m_preview->setMargin ( 3 ); |
161 | d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); | 160 | d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); |
162 | gridLayout->addRowSpacing ( 5, 4 ); | 161 | gridLayout->addRowSpacing ( 5, 4 ); |
163 | gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); | 162 | gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); |
164 | gridLayout->setRowStretch ( 6, 5 ); | 163 | gridLayout->setRowStretch ( 6, 5 ); |
165 | } | 164 | } |
166 | else | 165 | else |
167 | d->m_preview = 0; | 166 | d->m_preview = 0; |
168 | 167 | ||
169 | loadFonts ( d->m_font_family_list ); | 168 | loadFonts ( d->m_font_family_list ); |
170 | } | 169 | } |
171 | 170 | ||
172 | OFontSelector::~OFontSelector() | 171 | OFontSelector::~OFontSelector() |
173 | { | 172 | { |
174 | delete d; | 173 | delete d; |
175 | } | 174 | } |
176 | 175 | ||
177 | /** | 176 | /** |
178 | * This methods tries to set the font | 177 | * This methods tries to set the font |
179 | * @param f The wishes font | 178 | * @param f The wishes font |
180 | * @return success or failure | 179 | * @return success or failure |
181 | */ | 180 | */ |
182 | bool OFontSelector::setSelectedFont ( const QFont &f ) | 181 | bool OFontSelector::setSelectedFont ( const QFont &f ) |
183 | { | 182 | { |
184 | return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); | 183 | return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); |
185 | } | 184 | } |
186 | 185 | ||
187 | 186 | ||
188 | /** | 187 | /** |
189 | * This is an overloaded method @see setSelectedFont | 188 | * This is an overloaded method @see setSelectedFont |
190 | * @param familyStr The family of the font | 189 | * @param familyStr The family of the font |
191 | * @param styleStr The style of the font | 190 | * @param styleStr The style of the font |
192 | * @param sizeVal The size of font | 191 | * @param sizeVal The size of font |
193 | * @param charset The charset to be used. Will be deprecated by QT3 | 192 | * @param charset The charset to be used. Will be deprecated by QT3 |
194 | */ | 193 | */ |
195 | bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) | 194 | bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) |
196 | { | 195 | { |
197 | QString sizeStr = QString::number ( sizeVal ); | 196 | QString sizeStr = QString::number ( sizeVal ); |
198 | 197 | ||
199 | QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); | 198 | QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); |
200 | if ( !family ) | 199 | if ( !family ) |
201 | family = d->m_font_family_list->findItem ( "Helvetica" ); | 200 | family = d->m_font_family_list->findItem ( "Helvetica" ); |
202 | if ( !family ) | 201 | if ( !family ) |
203 | family = d->m_font_family_list->firstItem(); | 202 | family = d->m_font_family_list->firstItem(); |
204 | d->m_font_family_list->setCurrentItem ( family ); | 203 | d->m_font_family_list->setCurrentItem ( family ); |
205 | fontFamilyClicked ( d->m_font_family_list->index ( family )); | 204 | fontFamilyClicked ( d->m_font_family_list->index ( family )); |
206 | 205 | ||
207 | int style = findItemCB ( d->m_font_style_list, styleStr ); | 206 | int style = findItemCB ( d->m_font_style_list, styleStr ); |
208 | if ( style < 0 ) | 207 | if ( style < 0 ) |
209 | style = findItemCB ( d->m_font_style_list, "Regular" ); | 208 | style = findItemCB ( d->m_font_style_list, "Regular" ); |
210 | if ( style < 0 && d->m_font_style_list->count() > 0 ) | 209 | if ( style < 0 && d->m_font_style_list->count() > 0 ) |
211 | style = 0; | 210 | style = 0; |
212 | d->m_font_style_list->setCurrentItem ( style ); | 211 | d->m_font_style_list->setCurrentItem ( style ); |
213 | fontStyleClicked ( style ); | 212 | fontStyleClicked ( style ); |
214 | 213 | ||
215 | int size = findItemCB ( d->m_font_size_list, sizeStr ); | 214 | int size = findItemCB ( d->m_font_size_list, sizeStr ); |
216 | if ( size < 0 ) | 215 | if ( size < 0 ) |
217 | size = findItemCB ( d->m_font_size_list, "10" ); | 216 | size = findItemCB ( d->m_font_size_list, "10" ); |
218 | if ( size < 0 && d->m_font_size_list->count() > 0 ) | 217 | if ( size < 0 && d->m_font_size_list->count() > 0 ) |
219 | size = 0; | 218 | size = 0; |
220 | d->m_font_size_list->setCurrentItem ( size ); | 219 | d->m_font_size_list->setCurrentItem ( size ); |
221 | fontSizeClicked ( size ); | 220 | fontSizeClicked ( size ); |
222 | 221 | ||
223 | return (( family ) && ( style >= 0 ) && ( size >= 0 )); | 222 | return (( family ) && ( style >= 0 ) && ( size >= 0 )); |
224 | } | 223 | } |
225 | 224 | ||
226 | /** | 225 | /** |
227 | * This method returns the name, style and size of the currently selected | 226 | * This method returns the name, style and size of the currently selected |
228 | * font or false if no font is selected | 227 | * font or false if no font is selected |
229 | * @param family The font family will be written there | 228 | * @param family The font family will be written there |
230 | * @param style The style will be written there | 229 | * @param style The style will be written there |
231 | * @param size The size will be written there | 230 | * @param size The size will be written there |
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index 38f3fe2..84617f8 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp | |||
@@ -1,226 +1,223 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | 31 | ||
32 | #include <qcolor.h> | ||
33 | #include <qheader.h> | ||
34 | #include <qpainter.h> | ||
35 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
36 | 33 | ||
37 | /* OPIE */ | 34 | /* OPIE */ |
38 | 35 | ||
39 | #include <opie2/odebug.h> | 36 | #include <opie2/odebug.h> |
40 | #include <opie2/olistview.h> | 37 | #include <opie2/olistview.h> |
41 | 38 | ||
42 | /*====================================================================================== | 39 | /*====================================================================================== |
43 | * OListView | 40 | * OListView |
44 | *======================================================================================*/ | 41 | *======================================================================================*/ |
45 | 42 | ||
46 | OListView::OListView( QWidget *parent, const char *name ) | 43 | OListView::OListView( QWidget *parent, const char *name ) |
47 | :QListView( parent, name ) | 44 | :QListView( parent, name ) |
48 | { | 45 | { |
49 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* | 46 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* |
50 | 47 | ||
51 | m_alternateBackground = QColor( 238, 246, 255 ); | 48 | m_alternateBackground = QColor( 238, 246, 255 ); |
52 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); | 49 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); |
53 | m_fullWidth = true; | 50 | m_fullWidth = true; |
54 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); | 51 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); |
55 | } | 52 | } |
56 | 53 | ||
57 | OListView::~OListView() | 54 | OListView::~OListView() |
58 | { | 55 | { |
59 | } | 56 | } |
60 | 57 | ||
61 | void OListView::setFullWidth( bool fullWidth ) | 58 | void OListView::setFullWidth( bool fullWidth ) |
62 | { | 59 | { |
63 | m_fullWidth = m_fullWidth; | 60 | m_fullWidth = m_fullWidth; |
64 | #if QT_VERSION > 290 | 61 | #if QT_VERSION > 290 |
65 | header()->setStretchEnabled( fullWidth, columns()-1 ); | 62 | header()->setStretchEnabled( fullWidth, columns()-1 ); |
66 | #endif | 63 | #endif |
67 | } | 64 | } |
68 | 65 | ||
69 | bool OListView::fullWidth() const | 66 | bool OListView::fullWidth() const |
70 | { | 67 | { |
71 | return m_fullWidth; | 68 | return m_fullWidth; |
72 | } | 69 | } |
73 | 70 | ||
74 | int OListView::addColumn( const QString& label, int width ) | 71 | int OListView::addColumn( const QString& label, int width ) |
75 | { | 72 | { |
76 | int result = QListView::addColumn( label, width ); | 73 | int result = QListView::addColumn( label, width ); |
77 | #if QT_VERSION > 290 | 74 | #if QT_VERSION > 290 |
78 | if (m_fullWidth) { | 75 | if (m_fullWidth) { |
79 | header()->setStretchEnabled( false, columns()-2 ); | 76 | header()->setStretchEnabled( false, columns()-2 ); |
80 | header()->setStretchEnabled( true, columns()-1 ); | 77 | header()->setStretchEnabled( true, columns()-1 ); |
81 | } | 78 | } |
82 | #endif | 79 | #endif |
83 | return result; | 80 | return result; |
84 | } | 81 | } |
85 | 82 | ||
86 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) | 83 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) |
87 | { | 84 | { |
88 | int result = QListView::addColumn( iconset, label, width ); | 85 | int result = QListView::addColumn( iconset, label, width ); |
89 | #if QT_VERSION > 290 | 86 | #if QT_VERSION > 290 |
90 | if (m_fullWidth) { | 87 | if (m_fullWidth) { |
91 | header()->setStretchEnabled( false, columns()-2 ); | 88 | header()->setStretchEnabled( false, columns()-2 ); |
92 | header()->setStretchEnabled( true, columns()-1 ); | 89 | header()->setStretchEnabled( true, columns()-1 ); |
93 | } | 90 | } |
94 | #endif | 91 | #endif |
95 | return result; | 92 | return result; |
96 | } | 93 | } |
97 | 94 | ||
98 | void OListView::removeColumn( int index ) | 95 | void OListView::removeColumn( int index ) |
99 | { | 96 | { |
100 | QListView::removeColumn(index); | 97 | QListView::removeColumn(index); |
101 | #if QT_VERSION > 290 | 98 | #if QT_VERSION > 290 |
102 | if ( m_fullWidth && index == columns() ) | 99 | if ( m_fullWidth && index == columns() ) |
103 | { | 100 | { |
104 | header()->setStretchEnabled( true, columns()-1 ); | 101 | header()->setStretchEnabled( true, columns()-1 ); |
105 | } | 102 | } |
106 | #endif | 103 | #endif |
107 | } | 104 | } |
108 | 105 | ||
109 | const QColor& OListView::alternateBackground() const | 106 | const QColor& OListView::alternateBackground() const |
110 | { | 107 | { |
111 | return m_alternateBackground; | 108 | return m_alternateBackground; |
112 | } | 109 | } |
113 | 110 | ||
114 | void OListView::setAlternateBackground( const QColor &c ) | 111 | void OListView::setAlternateBackground( const QColor &c ) |
115 | { | 112 | { |
116 | m_alternateBackground = c; | 113 | m_alternateBackground = c; |
117 | repaint(); | 114 | repaint(); |
118 | } | 115 | } |
119 | 116 | ||
120 | const QPen& OListView::columnSeparator() const | 117 | const QPen& OListView::columnSeparator() const |
121 | { | 118 | { |
122 | return m_columnSeparator; | 119 | return m_columnSeparator; |
123 | } | 120 | } |
124 | 121 | ||
125 | void OListView::setColumnSeparator( const QPen& p ) | 122 | void OListView::setColumnSeparator( const QPen& p ) |
126 | { | 123 | { |
127 | m_columnSeparator = p; | 124 | m_columnSeparator = p; |
128 | repaint(); | 125 | repaint(); |
129 | } | 126 | } |
130 | 127 | ||
131 | void OListView::expand(QListViewItem *item) | 128 | void OListView::expand(QListViewItem *item) |
132 | { | 129 | { |
133 | ((OListViewItem*)item)->expand(); | 130 | ((OListViewItem*)item)->expand(); |
134 | } | 131 | } |
135 | 132 | ||
136 | OListViewItem* OListView::childFactory() | 133 | OListViewItem* OListView::childFactory() |
137 | { | 134 | { |
138 | return new OListViewItem( this ); | 135 | return new OListViewItem( this ); |
139 | } | 136 | } |
140 | 137 | ||
141 | #ifndef QT_NO_DATASTREAM | 138 | #ifndef QT_NO_DATASTREAM |
142 | void OListView::serializeTo( QDataStream& s ) const | 139 | void OListView::serializeTo( QDataStream& s ) const |
143 | { | 140 | { |
144 | #warning Caution... the binary format is still under construction... | 141 | #warning Caution... the binary format is still under construction... |
145 | odebug << "storing OListView..." << oendl; | 142 | odebug << "storing OListView..." << oendl; |
146 | 143 | ||
147 | // store number of columns and the labels | 144 | // store number of columns and the labels |
148 | s << columns(); | 145 | s << columns(); |
149 | for ( int i = 0; i < columns(); ++i ) | 146 | for ( int i = 0; i < columns(); ++i ) |
150 | s << columnText( i ); | 147 | s << columnText( i ); |
151 | 148 | ||
152 | // calculate the number of top-level items to serialize | 149 | // calculate the number of top-level items to serialize |
153 | int items = 0; | 150 | int items = 0; |
154 | QListViewItem* item = firstChild(); | 151 | QListViewItem* item = firstChild(); |
155 | while ( item ) | 152 | while ( item ) |
156 | { | 153 | { |
157 | item = item->nextSibling(); | 154 | item = item->nextSibling(); |
158 | items++; | 155 | items++; |
159 | } | 156 | } |
160 | 157 | ||
161 | // store number of items and the items itself | 158 | // store number of items and the items itself |
162 | s << items; | 159 | s << items; |
163 | item = firstChild(); | 160 | item = firstChild(); |
164 | for ( int i = 0; i < items; ++i ) | 161 | for ( int i = 0; i < items; ++i ) |
165 | { | 162 | { |
166 | s << *static_cast<OListViewItem*>( item ); | 163 | s << *static_cast<OListViewItem*>( item ); |
167 | item = item->nextSibling(); | 164 | item = item->nextSibling(); |
168 | } | 165 | } |
169 | 166 | ||
170 | odebug << "OListview stored." << oendl; | 167 | odebug << "OListview stored." << oendl; |
171 | } | 168 | } |
172 | 169 | ||
173 | void OListView::serializeFrom( QDataStream& s ) | 170 | void OListView::serializeFrom( QDataStream& s ) |
174 | { | 171 | { |
175 | #warning Caution... the binary format is still under construction... | 172 | #warning Caution... the binary format is still under construction... |
176 | odebug << "loading OListView..." << oendl; | 173 | odebug << "loading OListView..." << oendl; |
177 | 174 | ||
178 | int cols; | 175 | int cols; |
179 | s >> cols; | 176 | s >> cols; |
180 | qDebug( "read number of columns = %d", cols ); | 177 | qDebug( "read number of columns = %d", cols ); |
181 | 178 | ||
182 | while ( columns() < cols ) addColumn( QString::null ); | 179 | while ( columns() < cols ) addColumn( QString::null ); |
183 | 180 | ||
184 | for ( int i = 0; i < cols; ++i ) | 181 | for ( int i = 0; i < cols; ++i ) |
185 | { | 182 | { |
186 | QString coltext; | 183 | QString coltext; |
187 | s >> coltext; | 184 | s >> coltext; |
188 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | 185 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); |
189 | setColumnText( i, coltext ); | 186 | setColumnText( i, coltext ); |
190 | } | 187 | } |
191 | 188 | ||
192 | int items; | 189 | int items; |
193 | s >> items; | 190 | s >> items; |
194 | qDebug( "read number of items = %d", items ); | 191 | qDebug( "read number of items = %d", items ); |
195 | 192 | ||
196 | for ( int i = 0; i < items; ++i ) | 193 | for ( int i = 0; i < items; ++i ) |
197 | { | 194 | { |
198 | OListViewItem* item = childFactory(); | 195 | OListViewItem* item = childFactory(); |
199 | s >> *item; | 196 | s >> *item; |
200 | } | 197 | } |
201 | 198 | ||
202 | odebug << "OListView loaded." << oendl; | 199 | odebug << "OListView loaded." << oendl; |
203 | 200 | ||
204 | } | 201 | } |
205 | 202 | ||
206 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) | 203 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) |
207 | { | 204 | { |
208 | lv.serializeTo( s ); | 205 | lv.serializeTo( s ); |
209 | } | 206 | } |
210 | 207 | ||
211 | QDataStream& operator>>( QDataStream& s, OListView& lv ) | 208 | QDataStream& operator>>( QDataStream& s, OListView& lv ) |
212 | { | 209 | { |
213 | lv.serializeFrom( s ); | 210 | lv.serializeFrom( s ); |
214 | } | 211 | } |
215 | #endif // QT_NO_DATASTREAM | 212 | #endif // QT_NO_DATASTREAM |
216 | 213 | ||
217 | /*====================================================================================== | 214 | /*====================================================================================== |
218 | * OListViewItem | 215 | * OListViewItem |
219 | *======================================================================================*/ | 216 | *======================================================================================*/ |
220 | 217 | ||
221 | OListViewItem::OListViewItem(QListView *parent) | 218 | OListViewItem::OListViewItem(QListView *parent) |
222 | : QListViewItem(parent) | 219 | : QListViewItem(parent) |
223 | { | 220 | { |
224 | init(); | 221 | init(); |
225 | } | 222 | } |
226 | 223 | ||
diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp index ac73188..d5cc575 100644 --- a/libopie2/opieui/opopupmenu.cpp +++ b/libopie2/opieui/opopupmenu.cpp | |||
@@ -1,222 +1,215 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> | 2 | Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> |
3 | Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au> | 3 | Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License version 2 as published by the Free Software Foundation. | 7 | License version 2 as published by the Free Software Foundation. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* QT */ | 20 | /* QT */ |
21 | 21 | ||
22 | #include <qapplication.h> | ||
23 | #include <qcursor.h> | ||
24 | #include <qpainter.h> | ||
25 | #include <qdrawutil.h> | 22 | #include <qdrawutil.h> |
26 | #include <qtimer.h> | 23 | #include <qtimer.h> |
27 | #include <qfont.h> | ||
28 | #include <qfontmetrics.h> | ||
29 | #include <qregexp.h> | ||
30 | #include <qstyle.h> | ||
31 | 24 | ||
32 | /* OPIE */ | 25 | /* OPIE */ |
33 | 26 | ||
34 | #include <opie2/opopupmenu.h> | 27 | #include <opie2/opopupmenu.h> |
35 | #include <opie2/oconfig.h> | 28 | #include <opie2/oconfig.h> |
36 | 29 | ||
37 | OPopupTitle::OPopupTitle(QWidget *parent, const char *name) | 30 | OPopupTitle::OPopupTitle(QWidget *parent, const char *name) |
38 | : QWidget(parent, name) | 31 | : QWidget(parent, name) |
39 | { | 32 | { |
40 | setMinimumSize(16, fontMetrics().height()+8); | 33 | setMinimumSize(16, fontMetrics().height()+8); |
41 | } | 34 | } |
42 | 35 | ||
43 | OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, | 36 | OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, |
44 | const QColor &/* color */, const QColor &/* textColor */, | 37 | const QColor &/* color */, const QColor &/* textColor */, |
45 | QWidget *parent, const char *name) | 38 | QWidget *parent, const char *name) |
46 | : QWidget(parent, name) | 39 | : QWidget(parent, name) |
47 | { | 40 | { |
48 | setMinimumSize(16, fontMetrics().height()+8); | 41 | setMinimumSize(16, fontMetrics().height()+8); |
49 | } | 42 | } |
50 | 43 | ||
51 | OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, | 44 | OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, |
52 | const QColor &/* textColor */, QWidget *parent, | 45 | const QColor &/* textColor */, QWidget *parent, |
53 | const char *name) | 46 | const char *name) |
54 | : QWidget(parent, name) | 47 | : QWidget(parent, name) |
55 | { | 48 | { |
56 | setMinimumSize(16, fontMetrics().height()+8); | 49 | setMinimumSize(16, fontMetrics().height()+8); |
57 | } | 50 | } |
58 | 51 | ||
59 | void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) | 52 | void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) |
60 | { | 53 | { |
61 | titleStr = text; | 54 | titleStr = text; |
62 | if (icon) | 55 | if (icon) |
63 | miniicon = *icon; | 56 | miniicon = *icon; |
64 | else | 57 | else |
65 | miniicon.resize(0, 0); | 58 | miniicon.resize(0, 0); |
66 | 59 | ||
67 | int w = miniicon.width()+fontMetrics().width(titleStr); | 60 | int w = miniicon.width()+fontMetrics().width(titleStr); |
68 | int h = QMAX( fontMetrics().height(), miniicon.height() ); | 61 | int h = QMAX( fontMetrics().height(), miniicon.height() ); |
69 | setMinimumSize( w+16, h+8 ); | 62 | setMinimumSize( w+16, h+8 ); |
70 | } | 63 | } |
71 | 64 | ||
72 | void OPopupTitle::setText( const QString &text ) | 65 | void OPopupTitle::setText( const QString &text ) |
73 | { | 66 | { |
74 | titleStr = text; | 67 | titleStr = text; |
75 | int w = miniicon.width()+fontMetrics().width(titleStr); | 68 | int w = miniicon.width()+fontMetrics().width(titleStr); |
76 | int h = QMAX( fontMetrics().height(), miniicon.height() ); | 69 | int h = QMAX( fontMetrics().height(), miniicon.height() ); |
77 | setMinimumSize( w+16, h+8 ); | 70 | setMinimumSize( w+16, h+8 ); |
78 | } | 71 | } |
79 | 72 | ||
80 | void OPopupTitle::setIcon( const QPixmap &pix ) | 73 | void OPopupTitle::setIcon( const QPixmap &pix ) |
81 | { | 74 | { |
82 | miniicon = pix; | 75 | miniicon = pix; |
83 | int w = miniicon.width()+fontMetrics().width(titleStr); | 76 | int w = miniicon.width()+fontMetrics().width(titleStr); |
84 | int h = QMAX( fontMetrics().height(), miniicon.height() ); | 77 | int h = QMAX( fontMetrics().height(), miniicon.height() ); |
85 | setMinimumSize( w+16, h+8 ); | 78 | setMinimumSize( w+16, h+8 ); |
86 | } | 79 | } |
87 | 80 | ||
88 | void OPopupTitle::paintEvent(QPaintEvent *) | 81 | void OPopupTitle::paintEvent(QPaintEvent *) |
89 | { | 82 | { |
90 | QRect r(rect()); | 83 | QRect r(rect()); |
91 | QPainter p(this); | 84 | QPainter p(this); |
92 | #if QT_VERSION > 290 | 85 | #if QT_VERSION > 290 |
93 | qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active()); | 86 | qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active()); |
94 | #else | 87 | #else |
95 | #warning OPopupMenu is not fully functional on Qt2 | 88 | #warning OPopupMenu is not fully functional on Qt2 |
96 | #endif | 89 | #endif |
97 | 90 | ||
98 | if (!miniicon.isNull()) | 91 | if (!miniicon.isNull()) |
99 | p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon); | 92 | p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon); |
100 | 93 | ||
101 | if (!titleStr.isNull()) | 94 | if (!titleStr.isNull()) |
102 | { | 95 | { |
103 | p.setPen(palette().active().text()); | 96 | p.setPen(palette().active().text()); |
104 | QFont f = p.font(); | 97 | QFont f = p.font(); |
105 | f.setBold(true); | 98 | f.setBold(true); |
106 | p.setFont(f); | 99 | p.setFont(f); |
107 | if(!miniicon.isNull()) | 100 | if(!miniicon.isNull()) |
108 | { | 101 | { |
109 | p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8), | 102 | p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8), |
110 | height(), AlignLeft | AlignVCenter | SingleLine, | 103 | height(), AlignLeft | AlignVCenter | SingleLine, |
111 | titleStr); | 104 | titleStr); |
112 | } | 105 | } |
113 | else | 106 | else |
114 | { | 107 | { |
115 | p.drawText(0, 0, width(), height(), | 108 | p.drawText(0, 0, width(), height(), |
116 | AlignCenter | SingleLine, titleStr); | 109 | AlignCenter | SingleLine, titleStr); |
117 | } | 110 | } |
118 | } | 111 | } |
119 | 112 | ||
120 | p.setPen(palette().active().highlight()); | 113 | p.setPen(palette().active().highlight()); |
121 | p.drawLine(0, 0, r.right(), 0); | 114 | p.drawLine(0, 0, r.right(), 0); |
122 | } | 115 | } |
123 | 116 | ||
124 | QSize OPopupTitle::sizeHint() const | 117 | QSize OPopupTitle::sizeHint() const |
125 | { | 118 | { |
126 | return(minimumSize()); | 119 | return(minimumSize()); |
127 | } | 120 | } |
128 | 121 | ||
129 | class OPopupMenu::OPopupMenuPrivate | 122 | class OPopupMenu::OPopupMenuPrivate |
130 | { | 123 | { |
131 | public: | 124 | public: |
132 | OPopupMenuPrivate () | 125 | OPopupMenuPrivate () |
133 | : noMatches(false) | 126 | : noMatches(false) |
134 | , shortcuts(false) | 127 | , shortcuts(false) |
135 | , autoExec(false) | 128 | , autoExec(false) |
136 | , lastHitIndex(-1) | 129 | , lastHitIndex(-1) |
137 | , m_ctxMenu(0) | 130 | , m_ctxMenu(0) |
138 | {} | 131 | {} |
139 | 132 | ||
140 | ~OPopupMenuPrivate () | 133 | ~OPopupMenuPrivate () |
141 | { | 134 | { |
142 | delete m_ctxMenu; | 135 | delete m_ctxMenu; |
143 | } | 136 | } |
144 | 137 | ||
145 | QString m_lastTitle; | 138 | QString m_lastTitle; |
146 | 139 | ||
147 | // variables for keyboard navigation | 140 | // variables for keyboard navigation |
148 | QTimer clearTimer; | 141 | QTimer clearTimer; |
149 | 142 | ||
150 | bool noMatches : 1; | 143 | bool noMatches : 1; |
151 | bool shortcuts : 1; | 144 | bool shortcuts : 1; |
152 | bool autoExec : 1; | 145 | bool autoExec : 1; |
153 | 146 | ||
154 | QString keySeq; | 147 | QString keySeq; |
155 | QString originalText; | 148 | QString originalText; |
156 | 149 | ||
157 | int lastHitIndex; | 150 | int lastHitIndex; |
158 | 151 | ||
159 | // support for RMB menus on menus | 152 | // support for RMB menus on menus |
160 | QPopupMenu* m_ctxMenu; | 153 | QPopupMenu* m_ctxMenu; |
161 | static bool s_continueCtxMenuShow; | 154 | static bool s_continueCtxMenuShow; |
162 | static int s_highlightedItem; | 155 | static int s_highlightedItem; |
163 | static OPopupMenu* s_contextedMenu; | 156 | static OPopupMenu* s_contextedMenu; |
164 | }; | 157 | }; |
165 | 158 | ||
166 | int OPopupMenu::OPopupMenuPrivate::s_highlightedItem(-1); | 159 | int OPopupMenu::OPopupMenuPrivate::s_highlightedItem(-1); |
167 | OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0); | 160 | OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0); |
168 | bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true); | 161 | bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true); |
169 | 162 | ||
170 | OPopupMenu::OPopupMenu(QWidget *parent, const char *name) | 163 | OPopupMenu::OPopupMenu(QWidget *parent, const char *name) |
171 | : QPopupMenu(parent, name) | 164 | : QPopupMenu(parent, name) |
172 | { | 165 | { |
173 | d = new OPopupMenuPrivate; | 166 | d = new OPopupMenuPrivate; |
174 | resetKeyboardVars(); | 167 | resetKeyboardVars(); |
175 | connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars())); | 168 | connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars())); |
176 | } | 169 | } |
177 | 170 | ||
178 | OPopupMenu::~OPopupMenu() | 171 | OPopupMenu::~OPopupMenu() |
179 | { | 172 | { |
180 | if (OPopupMenuPrivate::s_contextedMenu == this) | 173 | if (OPopupMenuPrivate::s_contextedMenu == this) |
181 | { | 174 | { |
182 | OPopupMenuPrivate::s_contextedMenu = 0; | 175 | OPopupMenuPrivate::s_contextedMenu = 0; |
183 | OPopupMenuPrivate::s_highlightedItem = -1; | 176 | OPopupMenuPrivate::s_highlightedItem = -1; |
184 | } | 177 | } |
185 | 178 | ||
186 | delete d; | 179 | delete d; |
187 | } | 180 | } |
188 | 181 | ||
189 | int OPopupMenu::insertTitle(const QString &text, int id, int index) | 182 | int OPopupMenu::insertTitle(const QString &text, int id, int index) |
190 | { | 183 | { |
191 | OPopupTitle *titleItem = new OPopupTitle(); | 184 | OPopupTitle *titleItem = new OPopupTitle(); |
192 | titleItem->setTitle(text); | 185 | titleItem->setTitle(text); |
193 | int ret = insertItem(titleItem, id, index); | 186 | int ret = insertItem(titleItem, id, index); |
194 | setItemEnabled(id, false); | 187 | setItemEnabled(id, false); |
195 | return ret; | 188 | return ret; |
196 | } | 189 | } |
197 | 190 | ||
198 | int OPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id, | 191 | int OPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id, |
199 | int index) | 192 | int index) |
200 | { | 193 | { |
201 | OPopupTitle *titleItem = new OPopupTitle(); | 194 | OPopupTitle *titleItem = new OPopupTitle(); |
202 | titleItem->setTitle(text, &icon); | 195 | titleItem->setTitle(text, &icon); |
203 | int ret = insertItem(titleItem, id, index); | 196 | int ret = insertItem(titleItem, id, index); |
204 | setItemEnabled(id, false); | 197 | setItemEnabled(id, false); |
205 | return ret; | 198 | return ret; |
206 | } | 199 | } |
207 | 200 | ||
208 | void OPopupMenu::changeTitle(int id, const QString &text) | 201 | void OPopupMenu::changeTitle(int id, const QString &text) |
209 | { | 202 | { |
210 | QMenuItem *item = findItem(id); | 203 | QMenuItem *item = findItem(id); |
211 | if(item){ | 204 | if(item){ |
212 | if(item->widget()) | 205 | if(item->widget()) |
213 | ((OPopupTitle *)item->widget())->setTitle(text); | 206 | ((OPopupTitle *)item->widget())->setTitle(text); |
214 | #ifndef NDEBUG | 207 | #ifndef NDEBUG |
215 | else | 208 | else |
216 | qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); | 209 | qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); |
217 | #endif | 210 | #endif |
218 | } | 211 | } |
219 | #ifndef NDEBUG | 212 | #ifndef NDEBUG |
220 | else | 213 | else |
221 | qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); | 214 | qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); |
222 | #endif | 215 | #endif |
diff --git a/libopie2/opieui/oselector.cpp b/libopie2/opieui/oselector.cpp index ec5af6b..23b3ce3 100644 --- a/libopie2/opieui/oselector.cpp +++ b/libopie2/opieui/oselector.cpp | |||
@@ -1,215 +1,214 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 | Copyright (C) 1997 Martin Jones (mjones@kde.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* QT */ | 20 | /* QT */ |
21 | 21 | ||
22 | #include <qimage.h> | 22 | #include <qimage.h> |
23 | #include <qpainter.h> | ||
24 | #include <qdrawutil.h> | 23 | #include <qdrawutil.h> |
25 | 24 | ||
26 | /* OPIE */ | 25 | /* OPIE */ |
27 | 26 | ||
28 | #include <opie2/oimageeffect.h> | 27 | #include <opie2/oimageeffect.h> |
29 | #include <opie2/oselector.h> | 28 | #include <opie2/oselector.h> |
30 | 29 | ||
31 | #define STORE_W 8 | 30 | #define STORE_W 8 |
32 | #define STORE_W2 STORE_W * 2 | 31 | #define STORE_W2 STORE_W * 2 |
33 | 32 | ||
34 | //----------------------------------------------------------------------------- | 33 | //----------------------------------------------------------------------------- |
35 | /* | 34 | /* |
36 | * 2D value selector. | 35 | * 2D value selector. |
37 | * The contents of the selector are drawn by derived class. | 36 | * The contents of the selector are drawn by derived class. |
38 | */ | 37 | */ |
39 | 38 | ||
40 | OXYSelector::OXYSelector( QWidget *parent, const char *name ) | 39 | OXYSelector::OXYSelector( QWidget *parent, const char *name ) |
41 | : QWidget( parent, name ) | 40 | : QWidget( parent, name ) |
42 | { | 41 | { |
43 | xPos = 0; | 42 | xPos = 0; |
44 | yPos = 0; | 43 | yPos = 0; |
45 | minX = 0; | 44 | minX = 0; |
46 | minY = 0; | 45 | minY = 0; |
47 | maxX = 100; | 46 | maxX = 100; |
48 | maxY = 100; | 47 | maxY = 100; |
49 | store.setOptimization( QPixmap::BestOptim ); | 48 | store.setOptimization( QPixmap::BestOptim ); |
50 | store.resize( STORE_W2, STORE_W2 ); | 49 | store.resize( STORE_W2, STORE_W2 ); |
51 | } | 50 | } |
52 | 51 | ||
53 | 52 | ||
54 | OXYSelector::~OXYSelector() | 53 | OXYSelector::~OXYSelector() |
55 | {} | 54 | {} |
56 | 55 | ||
57 | 56 | ||
58 | void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY ) | 57 | void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY ) |
59 | { | 58 | { |
60 | px = 2; | 59 | px = 2; |
61 | py = 2; | 60 | py = 2; |
62 | minX = _minX; | 61 | minX = _minX; |
63 | minY = _minY; | 62 | minY = _minY; |
64 | maxX = _maxX; | 63 | maxX = _maxX; |
65 | maxY = _maxY; | 64 | maxY = _maxY; |
66 | } | 65 | } |
67 | 66 | ||
68 | void OXYSelector::setValues( int _xPos, int _yPos ) | 67 | void OXYSelector::setValues( int _xPos, int _yPos ) |
69 | { | 68 | { |
70 | xPos = _xPos; | 69 | xPos = _xPos; |
71 | yPos = _yPos; | 70 | yPos = _yPos; |
72 | 71 | ||
73 | if ( xPos > maxX ) | 72 | if ( xPos > maxX ) |
74 | xPos = maxX; | 73 | xPos = maxX; |
75 | else if ( xPos < minX ) | 74 | else if ( xPos < minX ) |
76 | xPos = minX; | 75 | xPos = minX; |
77 | 76 | ||
78 | if ( yPos > maxY ) | 77 | if ( yPos > maxY ) |
79 | yPos = maxY; | 78 | yPos = maxY; |
80 | else if ( yPos < minY ) | 79 | else if ( yPos < minY ) |
81 | yPos = minY; | 80 | yPos = minY; |
82 | 81 | ||
83 | int xp = 2 + (width() - 4) * xPos / (maxX - minX); | 82 | int xp = 2 + (width() - 4) * xPos / (maxX - minX); |
84 | int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY); | 83 | int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY); |
85 | 84 | ||
86 | setPosition( xp, yp ); | 85 | setPosition( xp, yp ); |
87 | } | 86 | } |
88 | 87 | ||
89 | QRect OXYSelector::contentsRect() const | 88 | QRect OXYSelector::contentsRect() const |
90 | { | 89 | { |
91 | return QRect( 2, 2, width()-4, height()-4 ); | 90 | return QRect( 2, 2, width()-4, height()-4 ); |
92 | } | 91 | } |
93 | 92 | ||
94 | void OXYSelector::paintEvent( QPaintEvent *ev ) | 93 | void OXYSelector::paintEvent( QPaintEvent *ev ) |
95 | { | 94 | { |
96 | QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2); | 95 | QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2); |
97 | QRect paintRect = ev->rect(); | 96 | QRect paintRect = ev->rect(); |
98 | 97 | ||
99 | QPainter painter; | 98 | QPainter painter; |
100 | painter.begin( this ); | 99 | painter.begin( this ); |
101 | 100 | ||
102 | QBrush brush; | 101 | QBrush brush; |
103 | qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(), | 102 | qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(), |
104 | TRUE, 2, &brush ); | 103 | TRUE, 2, &brush ); |
105 | 104 | ||
106 | drawContents( &painter ); | 105 | drawContents( &painter ); |
107 | if (paintRect.contains(cursorRect)) | 106 | if (paintRect.contains(cursorRect)) |
108 | { | 107 | { |
109 | bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W, | 108 | bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W, |
110 | STORE_W2, STORE_W2, CopyROP ); | 109 | STORE_W2, STORE_W2, CopyROP ); |
111 | drawCursor( &painter, px, py ); | 110 | drawCursor( &painter, px, py ); |
112 | } | 111 | } |
113 | else if (paintRect.intersects(cursorRect)) | 112 | else if (paintRect.intersects(cursorRect)) |
114 | { | 113 | { |
115 | repaint( cursorRect, false); | 114 | repaint( cursorRect, false); |
116 | } | 115 | } |
117 | 116 | ||
118 | painter.end(); | 117 | painter.end(); |
119 | } | 118 | } |
120 | 119 | ||
121 | void OXYSelector::mousePressEvent( QMouseEvent *e ) | 120 | void OXYSelector::mousePressEvent( QMouseEvent *e ) |
122 | { | 121 | { |
123 | int xVal, yVal; | 122 | int xVal, yVal; |
124 | valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); | 123 | valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); |
125 | setValues( xVal, yVal ); | 124 | setValues( xVal, yVal ); |
126 | 125 | ||
127 | emit valueChanged( xPos, yPos ); | 126 | emit valueChanged( xPos, yPos ); |
128 | } | 127 | } |
129 | 128 | ||
130 | void OXYSelector::mouseMoveEvent( QMouseEvent *e ) | 129 | void OXYSelector::mouseMoveEvent( QMouseEvent *e ) |
131 | { | 130 | { |
132 | int xVal, yVal; | 131 | int xVal, yVal; |
133 | valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); | 132 | valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); |
134 | setValues( xVal, yVal ); | 133 | setValues( xVal, yVal ); |
135 | 134 | ||
136 | emit valueChanged( xPos, yPos ); | 135 | emit valueChanged( xPos, yPos ); |
137 | } | 136 | } |
138 | 137 | ||
139 | void OXYSelector::wheelEvent( QWheelEvent *e ) | 138 | void OXYSelector::wheelEvent( QWheelEvent *e ) |
140 | { | 139 | { |
141 | #if QT_VERSION > 290 | 140 | #if QT_VERSION > 290 |
142 | if ( e->orientation() == Qt::Horizontal ) | 141 | if ( e->orientation() == Qt::Horizontal ) |
143 | setValues( xValue() + e->delta()/120, yValue() ); | 142 | setValues( xValue() + e->delta()/120, yValue() ); |
144 | else | 143 | else |
145 | setValues( xValue(), yValue() + e->delta()/120 ); | 144 | setValues( xValue(), yValue() + e->delta()/120 ); |
146 | 145 | ||
147 | emit valueChanged( xPos, yPos ); | 146 | emit valueChanged( xPos, yPos ); |
148 | #endif | 147 | #endif |
149 | } | 148 | } |
150 | 149 | ||
151 | void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const | 150 | void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const |
152 | { | 151 | { |
153 | xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 ); | 152 | xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 ); |
154 | yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) ); | 153 | yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) ); |
155 | 154 | ||
156 | if ( xVal > maxX ) | 155 | if ( xVal > maxX ) |
157 | xVal = maxX; | 156 | xVal = maxX; |
158 | else if ( xVal < minX ) | 157 | else if ( xVal < minX ) |
159 | xVal = minX; | 158 | xVal = minX; |
160 | 159 | ||
161 | if ( yVal > maxY ) | 160 | if ( yVal > maxY ) |
162 | yVal = maxY; | 161 | yVal = maxY; |
163 | else if ( yVal < minY ) | 162 | else if ( yVal < minY ) |
164 | yVal = minY; | 163 | yVal = minY; |
165 | } | 164 | } |
166 | 165 | ||
167 | void OXYSelector::setPosition( int xp, int yp ) | 166 | void OXYSelector::setPosition( int xp, int yp ) |
168 | { | 167 | { |
169 | if ( xp < 2 ) | 168 | if ( xp < 2 ) |
170 | xp = 2; | 169 | xp = 2; |
171 | else if ( xp > width() - 2 ) | 170 | else if ( xp > width() - 2 ) |
172 | xp = width() - 2; | 171 | xp = width() - 2; |
173 | 172 | ||
174 | if ( yp < 2 ) | 173 | if ( yp < 2 ) |
175 | yp = 2; | 174 | yp = 2; |
176 | else if ( yp > height() - 2 ) | 175 | else if ( yp > height() - 2 ) |
177 | yp = height() - 2; | 176 | yp = height() - 2; |
178 | 177 | ||
179 | QPainter painter; | 178 | QPainter painter; |
180 | painter.begin( this ); | 179 | painter.begin( this ); |
181 | 180 | ||
182 | bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0, | 181 | bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0, |
183 | STORE_W2, STORE_W2, CopyROP ); | 182 | STORE_W2, STORE_W2, CopyROP ); |
184 | bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W, | 183 | bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W, |
185 | STORE_W2, STORE_W2, CopyROP ); | 184 | STORE_W2, STORE_W2, CopyROP ); |
186 | drawCursor( &painter, xp, yp ); | 185 | drawCursor( &painter, xp, yp ); |
187 | px = xp; | 186 | px = xp; |
188 | py = yp; | 187 | py = yp; |
189 | 188 | ||
190 | painter.end(); | 189 | painter.end(); |
191 | } | 190 | } |
192 | 191 | ||
193 | void OXYSelector::drawContents( QPainter * ) | 192 | void OXYSelector::drawContents( QPainter * ) |
194 | {} | 193 | {} |
195 | 194 | ||
196 | 195 | ||
197 | void OXYSelector::drawCursor( QPainter *p, int xp, int yp ) | 196 | void OXYSelector::drawCursor( QPainter *p, int xp, int yp ) |
198 | { | 197 | { |
199 | p->setPen( QPen( white ) ); | 198 | p->setPen( QPen( white ) ); |
200 | 199 | ||
201 | p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 ); | 200 | p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 ); |
202 | p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 ); | 201 | p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 ); |
203 | p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 ); | 202 | p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 ); |
204 | p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 ); | 203 | p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 ); |
205 | } | 204 | } |
206 | 205 | ||
207 | //----------------------------------------------------------------------------- | 206 | //----------------------------------------------------------------------------- |
208 | /* | 207 | /* |
209 | * 1D value selector with contents drawn by derived class. | 208 | * 1D value selector with contents drawn by derived class. |
210 | * See OColorDialog for example. | 209 | * See OColorDialog for example. |
211 | */ | 210 | */ |
212 | 211 | ||
213 | 212 | ||
214 | OSelector::OSelector( QWidget *parent, const char *name ) | 213 | OSelector::OSelector( QWidget *parent, const char *name ) |
215 | : QWidget( parent, name ), QRangeControl() | 214 | : QWidget( parent, name ), QRangeControl() |
diff --git a/libopie2/opieui/oseparator.cpp b/libopie2/opieui/oseparator.cpp index 98d42c7..b93c225 100644 --- a/libopie2/opieui/oseparator.cpp +++ b/libopie2/opieui/oseparator.cpp | |||
@@ -1,128 +1,127 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 3 | Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
4 | Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> | 4 | Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | 33 | ||
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <opie2/oseparator.h> | 35 | #include <opie2/oseparator.h> |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | 38 | ||
39 | #include <qstyle.h> | ||
40 | 39 | ||
41 | OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f) | 40 | OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f) |
42 | : QFrame(parent, name, f) | 41 | : QFrame(parent, name, f) |
43 | { | 42 | { |
44 | setLineWidth(1); | 43 | setLineWidth(1); |
45 | setMidLineWidth(0); | 44 | setMidLineWidth(0); |
46 | setOrientation( HLine ); | 45 | setOrientation( HLine ); |
47 | } | 46 | } |
48 | 47 | ||
49 | 48 | ||
50 | 49 | ||
51 | OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f) | 50 | OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f) |
52 | : QFrame(parent, name, f) | 51 | : QFrame(parent, name, f) |
53 | { | 52 | { |
54 | setLineWidth(1); | 53 | setLineWidth(1); |
55 | setMidLineWidth(0); | 54 | setMidLineWidth(0); |
56 | setOrientation( orientation ); | 55 | setOrientation( orientation ); |
57 | } | 56 | } |
58 | 57 | ||
59 | 58 | ||
60 | 59 | ||
61 | void OSeparator::setOrientation(int orientation) | 60 | void OSeparator::setOrientation(int orientation) |
62 | { | 61 | { |
63 | switch(orientation) | 62 | switch(orientation) |
64 | { | 63 | { |
65 | case Vertical: | 64 | case Vertical: |
66 | case VLine: | 65 | case VLine: |
67 | setFrameStyle( QFrame::VLine | QFrame::Sunken ); | 66 | setFrameStyle( QFrame::VLine | QFrame::Sunken ); |
68 | setMinimumSize(2, 0); | 67 | setMinimumSize(2, 0); |
69 | break; | 68 | break; |
70 | 69 | ||
71 | default: | 70 | default: |
72 | owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl; | 71 | owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl; |
73 | 72 | ||
74 | case Horizontal: | 73 | case Horizontal: |
75 | case HLine: | 74 | case HLine: |
76 | setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 75 | setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
77 | setMinimumSize(0, 2); | 76 | setMinimumSize(0, 2); |
78 | break; | 77 | break; |
79 | } | 78 | } |
80 | } | 79 | } |
81 | 80 | ||
82 | 81 | ||
83 | 82 | ||
84 | int OSeparator::orientation() const | 83 | int OSeparator::orientation() const |
85 | { | 84 | { |
86 | if ( frameStyle() & VLine ) | 85 | if ( frameStyle() & VLine ) |
87 | return VLine; | 86 | return VLine; |
88 | 87 | ||
89 | if ( frameStyle() & HLine ) | 88 | if ( frameStyle() & HLine ) |
90 | return HLine; | 89 | return HLine; |
91 | 90 | ||
92 | return 0; | 91 | return 0; |
93 | } | 92 | } |
94 | 93 | ||
95 | void OSeparator::drawFrame(QPainter *p) | 94 | void OSeparator::drawFrame(QPainter *p) |
96 | { | 95 | { |
97 | QPointp1, p2; | 96 | QPointp1, p2; |
98 | QRectr = frameRect(); | 97 | QRectr = frameRect(); |
99 | const QColorGroup & g = colorGroup(); | 98 | const QColorGroup & g = colorGroup(); |
100 | 99 | ||
101 | if ( frameStyle() & HLine ) { | 100 | if ( frameStyle() & HLine ) { |
102 | p1 = QPoint( r.x(), r.height()/2 ); | 101 | p1 = QPoint( r.x(), r.height()/2 ); |
103 | p2 = QPoint( r.x()+r.width(), p1.y() ); | 102 | p2 = QPoint( r.x()+r.width(), p1.y() ); |
104 | } | 103 | } |
105 | else { | 104 | else { |
106 | p1 = QPoint( r.x()+r.width()/2, 0 ); | 105 | p1 = QPoint( r.x()+r.width()/2, 0 ); |
107 | p2 = QPoint( p1.x(), r.height() ); | 106 | p2 = QPoint( p1.x(), r.height() ); |
108 | } | 107 | } |
109 | 108 | ||
110 | #if QT_VERSION < 300 | 109 | #if QT_VERSION < 300 |
111 | style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() ); | 110 | style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() ); |
112 | #else | 111 | #else |
113 | QStyleOption opt( lineWidth(), midLineWidth() ); | 112 | QStyleOption opt( lineWidth(), midLineWidth() ); |
114 | style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt ); | 113 | style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt ); |
115 | #endif | 114 | #endif |
116 | } | 115 | } |
117 | 116 | ||
118 | 117 | ||
119 | QSize OSeparator::sizeHint() const | 118 | QSize OSeparator::sizeHint() const |
120 | { | 119 | { |
121 | if ( frameStyle() & VLine ) | 120 | if ( frameStyle() & VLine ) |
122 | return QSize(2, 0); | 121 | return QSize(2, 0); |
123 | 122 | ||
124 | if ( frameStyle() & HLine ) | 123 | if ( frameStyle() & HLine ) |
125 | return QSize(0, 2); | 124 | return QSize(0, 2); |
126 | 125 | ||
127 | return QSize(-1, -1); | 126 | return QSize(-1, -1); |
128 | } | 127 | } |
diff --git a/libopie2/opieui/otimepicker.cpp b/libopie2/opieui/otimepicker.cpp index 9f9f2c2..d4712a4 100644 --- a/libopie2/opieui/otimepicker.cpp +++ b/libopie2/opieui/otimepicker.cpp | |||
@@ -1,227 +1,224 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
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 | /* QT */ | 30 | /* QT */ |
31 | #include <qbuttongroup.h> | ||
32 | #include <qlayout.h> | 31 | #include <qlayout.h> |
33 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
34 | #include <qstring.h> | ||
35 | #include <qtoolbutton.h> | ||
36 | 33 | ||
37 | /* OPIE */ | 34 | /* OPIE */ |
38 | #include <opie2/otimepicker.h> | 35 | #include <opie2/otimepicker.h> |
39 | 36 | ||
40 | using namespace Opie; | 37 | using namespace Opie; |
41 | 38 | ||
42 | /** | 39 | /** |
43 | * Constructs the widget | 40 | * Constructs the widget |
44 | * @param parent The parent of the OTimePicker | 41 | * @param parent The parent of the OTimePicker |
45 | * @param name The name of the object | 42 | * @param name The name of the object |
46 | * @param fl Window Flags | 43 | * @param fl Window Flags |
47 | */ | 44 | */ |
48 | OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) | 45 | OTimePicker::OTimePicker(QWidget* parent, const char* name, Qt::WFlags fl) |
49 | :QWidget(parent,name,fl) | 46 | :QWidget(parent,name,fl) |
50 | { | 47 | { |
51 | QVBoxLayout *vbox=new QVBoxLayout(this); | 48 | QVBoxLayout *vbox=new QVBoxLayout(this); |
52 | 49 | ||
53 | OClickableLabel *r; | 50 | OClickableLabel *r; |
54 | QString s; | 51 | QString s; |
55 | 52 | ||
56 | // Hour Row | 53 | // Hour Row |
57 | QWidget *row=new QWidget(this); | 54 | QWidget *row=new QWidget(this); |
58 | QHBoxLayout *l=new QHBoxLayout(row); | 55 | QHBoxLayout *l=new QHBoxLayout(row); |
59 | vbox->addWidget(row); | 56 | vbox->addWidget(row); |
60 | 57 | ||
61 | for (int i=0; i<24; i++) | 58 | for (int i=0; i<24; i++) |
62 | { | 59 | { |
63 | r=new OClickableLabel(row); | 60 | r=new OClickableLabel(row); |
64 | hourLst.append(r); | 61 | hourLst.append(r); |
65 | s.sprintf("%.2d",i); | 62 | s.sprintf("%.2d",i); |
66 | r->setText(s); | 63 | r->setText(s); |
67 | r->setToggleButton(true); | 64 | r->setToggleButton(true); |
68 | r->setAlignment(AlignHCenter | AlignVCenter); | 65 | r->setAlignment(AlignHCenter | AlignVCenter); |
69 | l->addWidget(r); | 66 | l->addWidget(r); |
70 | connect(r, SIGNAL(toggled(bool)), | 67 | connect(r, SIGNAL(toggled(bool)), |
71 | this, SLOT(slotHour(bool))); | 68 | this, SLOT(slotHour(bool))); |
72 | 69 | ||
73 | if (i==11) | 70 | if (i==11) |
74 | { // Second row | 71 | { // Second row |
75 | row=new QWidget(this); | 72 | row=new QWidget(this); |
76 | l=new QHBoxLayout(row); | 73 | l=new QHBoxLayout(row); |
77 | vbox->addWidget(row); | 74 | vbox->addWidget(row); |
78 | } | 75 | } |
79 | } | 76 | } |
80 | 77 | ||
81 | // Minute Row | 78 | // Minute Row |
82 | row=new QWidget(this); | 79 | row=new QWidget(this); |
83 | l=new QHBoxLayout(row); | 80 | l=new QHBoxLayout(row); |
84 | vbox->addWidget(row); | 81 | vbox->addWidget(row); |
85 | 82 | ||
86 | for (int i=0; i<60; i+=5) | 83 | for (int i=0; i<60; i+=5) |
87 | { | 84 | { |
88 | r=new OClickableLabel(row); | 85 | r=new OClickableLabel(row); |
89 | minuteLst.append(r); | 86 | minuteLst.append(r); |
90 | s.sprintf("%.2d",i); | 87 | s.sprintf("%.2d",i); |
91 | r->setText(s); | 88 | r->setText(s); |
92 | r->setToggleButton(true); | 89 | r->setToggleButton(true); |
93 | r->setAlignment(AlignHCenter | AlignVCenter); | 90 | r->setAlignment(AlignHCenter | AlignVCenter); |
94 | l->addWidget(r); | 91 | l->addWidget(r); |
95 | connect(r, SIGNAL(toggled(bool)), | 92 | connect(r, SIGNAL(toggled(bool)), |
96 | this, SLOT(slotMinute(bool))); | 93 | this, SLOT(slotMinute(bool))); |
97 | } | 94 | } |
98 | } | 95 | } |
99 | 96 | ||
100 | /** | 97 | /** |
101 | * This method return the current time | 98 | * This method return the current time |
102 | * @return the time | 99 | * @return the time |
103 | */ | 100 | */ |
104 | QTime OTimePicker::time()const | 101 | QTime OTimePicker::time()const |
105 | { | 102 | { |
106 | return tm; | 103 | return tm; |
107 | } | 104 | } |
108 | 105 | ||
109 | void OTimePicker::slotHour(bool b) | 106 | void OTimePicker::slotHour(bool b) |
110 | { | 107 | { |
111 | 108 | ||
112 | OClickableLabel *r = (OClickableLabel *) sender(); | 109 | OClickableLabel *r = (OClickableLabel *) sender(); |
113 | 110 | ||
114 | if (b) | 111 | if (b) |
115 | { | 112 | { |
116 | QValueListIterator<OClickableLabel *> it; | 113 | QValueListIterator<OClickableLabel *> it; |
117 | for (it=hourLst.begin(); it!=hourLst.end(); it++) | 114 | for (it=hourLst.begin(); it!=hourLst.end(); it++) |
118 | { | 115 | { |
119 | if (*it != r) (*it)->setOn(false); | 116 | if (*it != r) (*it)->setOn(false); |
120 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); | 117 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); |
121 | } | 118 | } |
122 | emit timeChanged(tm); | 119 | emit timeChanged(tm); |
123 | } | 120 | } |
124 | else | 121 | else |
125 | { | 122 | { |
126 | r->setOn(true); | 123 | r->setOn(true); |
127 | } | 124 | } |
128 | 125 | ||
129 | } | 126 | } |
130 | 127 | ||
131 | void OTimePicker::slotMinute(bool b) | 128 | void OTimePicker::slotMinute(bool b) |
132 | { | 129 | { |
133 | 130 | ||
134 | OClickableLabel *r = (OClickableLabel *) sender(); | 131 | OClickableLabel *r = (OClickableLabel *) sender(); |
135 | 132 | ||
136 | if (b) | 133 | if (b) |
137 | { | 134 | { |
138 | QValueListIterator<OClickableLabel *> it; | 135 | QValueListIterator<OClickableLabel *> it; |
139 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) | 136 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) |
140 | { | 137 | { |
141 | if (*it != r) (*it)->setOn(false); | 138 | if (*it != r) (*it)->setOn(false); |
142 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); | 139 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); |
143 | } | 140 | } |
144 | emit timeChanged(tm); | 141 | emit timeChanged(tm); |
145 | } | 142 | } |
146 | else | 143 | else |
147 | { | 144 | { |
148 | r->setOn(true); | 145 | r->setOn(true); |
149 | } | 146 | } |
150 | 147 | ||
151 | } | 148 | } |
152 | 149 | ||
153 | /** | 150 | /** |
154 | * Method to set the time. No signal gets emitted during this method call | 151 | * Method to set the time. No signal gets emitted during this method call |
155 | * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) | 152 | * Minutes must be within 5 minutes step starting at 0 ( 0,5,10,15,20... ) |
156 | * @param t The time to be set | 153 | * @param t The time to be set |
157 | */ | 154 | */ |
158 | void OTimePicker::setTime( const QTime& t) | 155 | void OTimePicker::setTime( const QTime& t) |
159 | { | 156 | { |
160 | setTime( t.hour(), t.minute() ); | 157 | setTime( t.hour(), t.minute() ); |
161 | } | 158 | } |
162 | 159 | ||
163 | /** | 160 | /** |
164 | * Method to set the time. No signal gets emitted during this method call | 161 | * Method to set the time. No signal gets emitted during this method call |
165 | * @param h The hour | 162 | * @param h The hour |
166 | * @param m The minute. Minutes need to set by 5 minute steps | 163 | * @param m The minute. Minutes need to set by 5 minute steps |
167 | */ | 164 | */ |
168 | void OTimePicker::setTime( int h, int m ) | 165 | void OTimePicker::setTime( int h, int m ) |
169 | { | 166 | { |
170 | setHour(h); | 167 | setHour(h); |
171 | setMinute(m); | 168 | setMinute(m); |
172 | } | 169 | } |
173 | 170 | ||
174 | /* | 171 | /* |
175 | * FIXME round minutes to the 5 minute arrangement -zecke | 172 | * FIXME round minutes to the 5 minute arrangement -zecke |
176 | */ | 173 | */ |
177 | /** | 174 | /** |
178 | * Method to set the minutes | 175 | * Method to set the minutes |
179 | * @param m minutes | 176 | * @param m minutes |
180 | */ | 177 | */ |
181 | void OTimePicker::setMinute(int m) | 178 | void OTimePicker::setMinute(int m) |
182 | { | 179 | { |
183 | 180 | ||
184 | QString minute; | 181 | QString minute; |
185 | minute.sprintf("%.2d",m); | 182 | minute.sprintf("%.2d",m); |
186 | 183 | ||
187 | QValueListIterator<OClickableLabel *> it; | 184 | QValueListIterator<OClickableLabel *> it; |
188 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) | 185 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) |
189 | { | 186 | { |
190 | if ((*it)->text() == minute) (*it)->setOn(true); | 187 | if ((*it)->text() == minute) (*it)->setOn(true); |
191 | else (*it)->setOn(false); | 188 | else (*it)->setOn(false); |
192 | } | 189 | } |
193 | 190 | ||
194 | tm.setHMS(tm.hour(),m,0); | 191 | tm.setHMS(tm.hour(),m,0); |
195 | } | 192 | } |
196 | 193 | ||
197 | /** | 194 | /** |
198 | * Method to set the hour | 195 | * Method to set the hour |
199 | */ | 196 | */ |
200 | void OTimePicker::setHour(int h) | 197 | void OTimePicker::setHour(int h) |
201 | { | 198 | { |
202 | 199 | ||
203 | QString hour; | 200 | QString hour; |
204 | hour.sprintf("%.2d",h); | 201 | hour.sprintf("%.2d",h); |
205 | 202 | ||
206 | QValueListIterator<OClickableLabel *> it; | 203 | QValueListIterator<OClickableLabel *> it; |
207 | for (it=hourLst.begin(); it!=hourLst.end(); it++) | 204 | for (it=hourLst.begin(); it!=hourLst.end(); it++) |
208 | { | 205 | { |
209 | if ((*it)->text() == hour) (*it)->setOn(true); | 206 | if ((*it)->text() == hour) (*it)->setOn(true); |
210 | else (*it)->setOn(false); | 207 | else (*it)->setOn(false); |
211 | } | 208 | } |
212 | tm.setHMS(h,tm.minute(),0); | 209 | tm.setHMS(h,tm.minute(),0); |
213 | } | 210 | } |
214 | 211 | ||
215 | 212 | ||
216 | /** | 213 | /** |
217 | * This is a modal Dialog. | 214 | * This is a modal Dialog. |
218 | * | 215 | * |
219 | * @param parent The parent widget | 216 | * @param parent The parent widget |
220 | * @param name The name of the object | 217 | * @param name The name of the object |
221 | * @param fl Possible window flags | 218 | * @param fl Possible window flags |
222 | */ | 219 | */ |
223 | OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) | 220 | OTimePickerDialog::OTimePickerDialog ( QWidget* parent, const char* name, WFlags fl ) |
224 | : OTimePickerDialogBase (parent , name, true , fl) | 221 | : OTimePickerDialogBase (parent , name, true , fl) |
225 | { | 222 | { |
226 | 223 | ||
227 | connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ), | 224 | connect ( m_timePicker, SIGNAL( timeChanged( const QTime& ) ), |
diff --git a/libopie2/opieui/oversatileview.cpp b/libopie2/opieui/oversatileview.cpp index 65fe3d8..8839456 100644 --- a/libopie2/opieui/oversatileview.cpp +++ b/libopie2/opieui/oversatileview.cpp | |||
@@ -1,244 +1,233 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
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 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | 32 | ||
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | #include <opie2/oversatileview.h> | 34 | #include <opie2/oversatileview.h> |
35 | #include <opie2/oversatileviewitem.h> | 35 | #include <opie2/oversatileviewitem.h> |
36 | #include <opie2/olistview.h> | 36 | #include <opie2/olistview.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | 39 | ||
40 | #include <qaction.h> | 40 | #include <qaction.h> |
41 | #include <qbrush.h> | ||
42 | #include <qfont.h> | ||
43 | #include <qiconset.h> | ||
44 | #include <qiconview.h> | ||
45 | #include <qlistview.h> | ||
46 | #include <qpalette.h> | ||
47 | #include <qpoint.h> | ||
48 | #include <qpopupmenu.h> | 41 | #include <qpopupmenu.h> |
49 | #include <qrect.h> | ||
50 | #include <qsize.h> | ||
51 | #include <qstring.h> | ||
52 | #include <qwidgetstack.h> | ||
53 | 42 | ||
54 | /* XPM */ | 43 | /* XPM */ |
55 | static const char * view_icon_xpm[] = { | 44 | static const char * view_icon_xpm[] = { |
56 | "16 16 16 1", | 45 | "16 16 16 1", |
57 | " c None", | 46 | " c None", |
58 | ".c #87BD88", | 47 | ".c #87BD88", |
59 | "+c #8BBE8B", | 48 | "+c #8BBE8B", |
60 | "@c #81BA81", | 49 | "@c #81BA81", |
61 | "#c #6DAF6D", | 50 | "#c #6DAF6D", |
62 | "$c #87BD87", | 51 | "$c #87BD87", |
63 | "%c #FCFDFC", | 52 | "%c #FCFDFC", |
64 | "&c #AED0AE", | 53 | "&c #AED0AE", |
65 | "*c #4E9C4C", | 54 | "*c #4E9C4C", |
66 | "=c #91BD91", | 55 | "=c #91BD91", |
67 | "-c #72B172", | 56 | "-c #72B172", |
68 | ";c #448643", | 57 | ";c #448643", |
69 | ">c #519F50", | 58 | ">c #519F50", |
70 | ",c #499247", | 59 | ",c #499247", |
71 | "'c #356A35", | 60 | "'c #356A35", |
72 | ")c #686868", | 61 | ")c #686868", |
73 | " ", | 62 | " ", |
74 | " .+@# .+@# ", | 63 | " .+@# .+@# ", |
75 | " $%&* $%&* ", | 64 | " $%&* $%&* ", |
76 | " @=-; @=-; ", | 65 | " @=-; @=-; ", |
77 | " #>,' #>,' ", | 66 | " #>,' #>,' ", |
78 | " ", | 67 | " ", |
79 | " )))))) )))))) ", | 68 | " )))))) )))))) ", |
80 | " ", | 69 | " ", |
81 | " ", | 70 | " ", |
82 | " .+@# .+@# ", | 71 | " .+@# .+@# ", |
83 | " $%&* $%&* ", | 72 | " $%&* $%&* ", |
84 | " @=-; @=-; ", | 73 | " @=-; @=-; ", |
85 | " #>,' #>,' ", | 74 | " #>,' #>,' ", |
86 | " ", | 75 | " ", |
87 | " )))))) )))))) ", | 76 | " )))))) )))))) ", |
88 | " "}; | 77 | " "}; |
89 | 78 | ||
90 | /* XPM */ | 79 | /* XPM */ |
91 | static const char * view_tree_xpm[] = { | 80 | static const char * view_tree_xpm[] = { |
92 | "16 16 17 1", | 81 | "16 16 17 1", |
93 | " c None", | 82 | " c None", |
94 | ".c #3A3A3A", | 83 | ".c #3A3A3A", |
95 | "+c #87BD88", | 84 | "+c #87BD88", |
96 | "@c #8BBE8B", | 85 | "@c #8BBE8B", |
97 | "#c #81BA81", | 86 | "#c #81BA81", |
98 | "$c #6DAF6D", | 87 | "$c #6DAF6D", |
99 | "%c #87BD87", | 88 | "%c #87BD87", |
100 | "&c #FCFDFC", | 89 | "&c #FCFDFC", |
101 | "*c #AED0AE", | 90 | "*c #AED0AE", |
102 | "=c #4E9C4C", | 91 | "=c #4E9C4C", |
103 | "-c #91BD91", | 92 | "-c #91BD91", |
104 | ";c #72B172", | 93 | ";c #72B172", |
105 | ">c #448643", | 94 | ">c #448643", |
106 | ",c #686868", | 95 | ",c #686868", |
107 | "'c #519F50", | 96 | "'c #519F50", |
108 | ")c #499247", | 97 | ")c #499247", |
109 | "!c #356A35", | 98 | "!c #356A35", |
110 | " . ", | 99 | " . ", |
111 | " . ", | 100 | " . ", |
112 | " . +@#$ ", | 101 | " . +@#$ ", |
113 | " . %&*= ", | 102 | " . %&*= ", |
114 | " .. #-;> ,, ,,,", | 103 | " .. #-;> ,, ,,,", |
115 | " . $')! ", | 104 | " . $')! ", |
116 | " . ", | 105 | " . ", |
117 | " . ", | 106 | " . ", |
118 | " . ", | 107 | " . ", |
119 | " . +@#$ ", | 108 | " . +@#$ ", |
120 | " . %&*= ", | 109 | " . %&*= ", |
121 | " .. #-;> ,, ,,,", | 110 | " .. #-;> ,, ,,,", |
122 | " $')! ", | 111 | " $')! ", |
123 | " ", | 112 | " ", |
124 | " ", | 113 | " ", |
125 | " "}; | 114 | " "}; |
126 | 115 | ||
127 | OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode ) | 116 | OVersatileView::OVersatileView( QWidget* parent, const char* name, int mode ) |
128 | :QWidgetStack( parent, name ), | 117 | :QWidgetStack( parent, name ), |
129 | _viewmode( mode ), _warningpolicy( None ), | 118 | _viewmode( mode ), _warningpolicy( None ), |
130 | _treeleaf(), _treeopened(), _treeclosed(), | 119 | _treeleaf(), _treeopened(), _treeclosed(), |
131 | _iconleaf(), _iconopened(), _iconclosed() | 120 | _iconleaf(), _iconopened(), _iconclosed() |
132 | { | 121 | { |
133 | // | 122 | // |
134 | // Create child widgets and set some reasonable default styles | 123 | // Create child widgets and set some reasonable default styles |
135 | // | 124 | // |
136 | 125 | ||
137 | _listview = new OListView( this, "oversatileview embedded listview" ); | 126 | _listview = new OListView( this, "oversatileview embedded listview" ); |
138 | _iconview = new QIconView( this, "oversatileview embedded iconview" ); | 127 | _iconview = new QIconView( this, "oversatileview embedded iconview" ); |
139 | 128 | ||
140 | _listview->setAllColumnsShowFocus( true ); | 129 | _listview->setAllColumnsShowFocus( true ); |
141 | _listview->setRootIsDecorated( true ); | 130 | _listview->setRootIsDecorated( true ); |
142 | _listview->setShowSortIndicator( true ); | 131 | _listview->setShowSortIndicator( true ); |
143 | _iconview->setGridX( 90 ); | 132 | _iconview->setGridX( 90 ); |
144 | _iconview->setGridY( 42 ); | 133 | _iconview->setGridY( 42 ); |
145 | _iconview->setAutoArrange( true ); | 134 | _iconview->setAutoArrange( true ); |
146 | 135 | ||
147 | #ifdef QWS // TODO: Let this depend on current geometry (rotation) | 136 | #ifdef QWS // TODO: Let this depend on current geometry (rotation) |
148 | _iconview->setArrangement( QIconView::TopToBottom ); | 137 | _iconview->setArrangement( QIconView::TopToBottom ); |
149 | #else | 138 | #else |
150 | _iconview->setArrangement( QIconView::LeftToRight ); | 139 | _iconview->setArrangement( QIconView::LeftToRight ); |
151 | #endif | 140 | #endif |
152 | 141 | ||
153 | _iconview->setResizeMode( QIconView::Adjust ); | 142 | _iconview->setResizeMode( QIconView::Adjust ); |
154 | 143 | ||
155 | // qt-embedded: map stylus right on hold to right button press | 144 | // qt-embedded: map stylus right on hold to right button press |
156 | 145 | ||
157 | #ifdef QWS | 146 | #ifdef QWS |
158 | ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold ); | 147 | ( (QPEApplication*) qApp)->setStylusOperation( _iconview->viewport(), QPEApplication::RightOnHold ); |
159 | ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold ); | 148 | ( (QPEApplication*) qApp)->setStylusOperation( _listview->viewport(), QPEApplication::RightOnHold ); |
160 | #endif | 149 | #endif |
161 | 150 | ||
162 | setViewMode( mode ); // TODO: Read last style from config | 151 | setViewMode( mode ); // TODO: Read last style from config |
163 | // setSynchronization( true ); // TODO: Implement this | 152 | // setSynchronization( true ); // TODO: Implement this |
164 | 153 | ||
165 | // create context menu allowing to switch between the views | 154 | // create context menu allowing to switch between the views |
166 | 155 | ||
167 | _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" ); | 156 | _contextmenu = new QPopupMenu( 0, "oversatileview contextmenu" ); |
168 | _contextmenu->setCaption( "Style" ); | 157 | _contextmenu->setCaption( "Style" ); |
169 | _contextmenu->setCheckable( true ); | 158 | _contextmenu->setCheckable( true ); |
170 | QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" ); | 159 | QActionGroup* ag = new QActionGroup( _contextmenu, "style option group" ); |
171 | QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ), | 160 | QAction* a1 = new QAction( "View Items in Icon Style", QIconSet( QPixmap( view_icon_xpm ) ), |
172 | "View Icons", 0, ag, "viewicon action", true ); | 161 | "View Icons", 0, ag, "viewicon action", true ); |
173 | QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ), | 162 | QAction* a2 = new QAction( "View Items in Tree Style", QIconSet( QPixmap( view_tree_xpm ) ), |
174 | "View Tree", 0, ag, "viewtree action", true ); | 163 | "View Tree", 0, ag, "viewtree action", true ); |
175 | ag->addTo( _contextmenu ); | 164 | ag->addTo( _contextmenu ); |
176 | if ( mode == Icons ) | 165 | if ( mode == Icons ) |
177 | a1->setOn( true ); | 166 | a1->setOn( true ); |
178 | else if ( mode == Tree ) | 167 | else if ( mode == Tree ) |
179 | a2->setOn( true ); | 168 | a2->setOn( true ); |
180 | connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) ); | 169 | connect( a1, SIGNAL( activated() ), this, SLOT( setIconViewMode() ) ); |
181 | connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) ); | 170 | connect( a2, SIGNAL( activated() ), this, SLOT( setTreeViewMode() ) ); |
182 | 171 | ||
183 | #if (QT_VERSION >= 0x030000) | 172 | #if (QT_VERSION >= 0x030000) |
184 | connect( _listview, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); | 173 | connect( _listview, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); |
185 | connect( _iconview, SIGNAL( contextMenuRequested( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); | 174 | connect( _iconview, SIGNAL( contextMenuRequested( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); |
186 | #else | 175 | #else |
187 | connect( _listview, SIGNAL( rightButtonPressed( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); | 176 | connect( _listview, SIGNAL( rightButtonPressed( QListViewItem*, const QPoint&, int ) ), this, SLOT( contextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); |
188 | connect( _iconview, SIGNAL( rightButtonPressed( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); | 177 | connect( _iconview, SIGNAL( rightButtonPressed( QIconViewItem*, const QPoint& ) ), this, SLOT( contextMenuRequested( QIconViewItem*, const QPoint& ) ) ); |
189 | #endif | 178 | #endif |
190 | 179 | ||
191 | // | 180 | // |
192 | // signal forwarders | 181 | // signal forwarders |
193 | // | 182 | // |
194 | // unfortunately we can't short-circuit all the QListView and QIconView signals | 183 | // unfortunately we can't short-circuit all the QListView and QIconView signals |
195 | // to OVersatileView signals, because the signal/slot mechanism doesn't allow | 184 | // to OVersatileView signals, because the signal/slot mechanism doesn't allow |
196 | // type-conversion :-( | 185 | // type-conversion :-( |
197 | 186 | ||
198 | // common signals for listview | 187 | // common signals for listview |
199 | 188 | ||
200 | connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); | 189 | connect( _listview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); |
201 | connect( _listview, SIGNAL( selectionChanged( QListViewItem * ) ), this, SLOT( selectionChanged( QListViewItem * ) ) ); | 190 | connect( _listview, SIGNAL( selectionChanged( QListViewItem * ) ), this, SLOT( selectionChanged( QListViewItem * ) ) ); |
202 | connect( _listview, SIGNAL( currentChanged( QListViewItem * ) ), this, SLOT( currentChanged( QListViewItem * ) ) ); | 191 | connect( _listview, SIGNAL( currentChanged( QListViewItem * ) ), this, SLOT( currentChanged( QListViewItem * ) ) ); |
203 | connect( _listview, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( clicked( QListViewItem * ) ) ); | 192 | connect( _listview, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( clicked( QListViewItem * ) ) ); |
204 | connect( _listview, SIGNAL( pressed( QListViewItem * ) ), this, SLOT( pressed( QListViewItem * ) ) ); | 193 | connect( _listview, SIGNAL( pressed( QListViewItem * ) ), this, SLOT( pressed( QListViewItem * ) ) ); |
205 | 194 | ||
206 | connect( _listview, SIGNAL( doubleClicked( QListViewItem * ) ), this, SLOT( doubleClicked( QListViewItem * ) ) ); | 195 | connect( _listview, SIGNAL( doubleClicked( QListViewItem * ) ), this, SLOT( doubleClicked( QListViewItem * ) ) ); |
207 | connect( _listview, SIGNAL( returnPressed( QListViewItem * ) ), this, SLOT( returnPressed( QListViewItem * ) ) ); | 196 | connect( _listview, SIGNAL( returnPressed( QListViewItem * ) ), this, SLOT( returnPressed( QListViewItem * ) ) ); |
208 | 197 | ||
209 | connect( _listview, SIGNAL( onItem( QListViewItem * ) ), this, SLOT( onItem( QListViewItem * ) ) ); | 198 | connect( _listview, SIGNAL( onItem( QListViewItem * ) ), this, SLOT( onItem( QListViewItem * ) ) ); |
210 | connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); | 199 | connect( _listview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); |
211 | 200 | ||
212 | // common signals for iconview | 201 | // common signals for iconview |
213 | 202 | ||
214 | connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); | 203 | connect( _iconview, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); |
215 | connect( _iconview, SIGNAL( selectionChanged( QIconViewItem * ) ), this, SLOT( selectionChanged( QIconViewItem * ) ) ); | 204 | connect( _iconview, SIGNAL( selectionChanged( QIconViewItem * ) ), this, SLOT( selectionChanged( QIconViewItem * ) ) ); |
216 | connect( _iconview, SIGNAL( currentChanged( QIconViewItem * ) ), this, SLOT( currentChanged( QIconViewItem * ) ) ); | 205 | connect( _iconview, SIGNAL( currentChanged( QIconViewItem * ) ), this, SLOT( currentChanged( QIconViewItem * ) ) ); |
217 | connect( _iconview, SIGNAL( clicked( QIconViewItem * ) ), this, SLOT( clicked( QIconViewItem * ) ) ); | 206 | connect( _iconview, SIGNAL( clicked( QIconViewItem * ) ), this, SLOT( clicked( QIconViewItem * ) ) ); |
218 | connect( _iconview, SIGNAL( pressed( QIconViewItem * ) ), this, SLOT( pressed( QIconViewItem * ) ) ); | 207 | connect( _iconview, SIGNAL( pressed( QIconViewItem * ) ), this, SLOT( pressed( QIconViewItem * ) ) ); |
219 | 208 | ||
220 | connect( _iconview, SIGNAL( doubleClicked( QIconViewItem * ) ), this, SLOT( doubleClicked( QIconViewItem * ) ) ); | 209 | connect( _iconview, SIGNAL( doubleClicked( QIconViewItem * ) ), this, SLOT( doubleClicked( QIconViewItem * ) ) ); |
221 | connect( _iconview, SIGNAL( returnPressed( QIconViewItem * ) ), this, SLOT( returnPressed( QIconViewItem * ) ) ); | 210 | connect( _iconview, SIGNAL( returnPressed( QIconViewItem * ) ), this, SLOT( returnPressed( QIconViewItem * ) ) ); |
222 | 211 | ||
223 | connect( _iconview, SIGNAL( onItem( QIconViewItem * ) ), this, SLOT( onItem( QIconViewItem * ) ) ); | 212 | connect( _iconview, SIGNAL( onItem( QIconViewItem * ) ), this, SLOT( onItem( QIconViewItem * ) ) ); |
224 | connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); | 213 | connect( _iconview, SIGNAL( onViewport() ), this, SIGNAL( onViewport() ) ); |
225 | 214 | ||
226 | // listview only signals | 215 | // listview only signals |
227 | 216 | ||
228 | connect( _listview, SIGNAL( expanded( QListViewItem * ) ), this, SLOT( expanded( QListViewItem * ) ) ); | 217 | connect( _listview, SIGNAL( expanded( QListViewItem * ) ), this, SLOT( expanded( QListViewItem * ) ) ); |
229 | connect( _listview, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( collapsed( QListViewItem * ) ) ); | 218 | connect( _listview, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( collapsed( QListViewItem * ) ) ); |
230 | 219 | ||
231 | // iconview only signals | 220 | // iconview only signals |
232 | 221 | ||
233 | connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) ); | 222 | connect( _iconview, SIGNAL( moved() ), this, SIGNAL( moved() ) ); |
234 | } | 223 | } |
235 | 224 | ||
236 | OVersatileView::~OVersatileView() | 225 | OVersatileView::~OVersatileView() |
237 | { | 226 | { |
238 | } | 227 | } |
239 | 228 | ||
240 | QPopupMenu* OVersatileView::contextMenu() const | 229 | QPopupMenu* OVersatileView::contextMenu() const |
241 | { | 230 | { |
242 | return _contextmenu; | 231 | return _contextmenu; |
243 | } | 232 | } |
244 | 233 | ||