author | llornkcor <llornkcor> | 2004-07-27 00:53:35 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-07-27 00:53:35 (UTC) |
commit | 2f332574ddbd31fe9709c1ec93049ecef9bd00a4 (patch) (unidiff) | |
tree | b4d2fb110e398d6fa2491bd754a1d3f2e651fe97 | |
parent | 8ff9840e3cbb28a1a644eb165465c60903e651a1 (diff) | |
download | opie-2f332574ddbd31fe9709c1ec93049ecef9bd00a4.zip opie-2f332574ddbd31fe9709c1ec93049ecef9bd00a4.tar.gz opie-2f332574ddbd31fe9709c1ec93049ecef9bd00a4.tar.bz2 |
workaround weird windows listview bug
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 2dd94aa..6aa6392 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -157,1069 +157,1073 @@ static const char* const bank_cards_data[] = { | |||
157 | ".###########..", | 157 | ".###########..", |
158 | ".#ababababa#..", | 158 | ".#ababababa#..", |
159 | ".#babbbabbb#..", | 159 | ".#babbbabbb#..", |
160 | ".#ccccccccc#..", | 160 | ".#ccccccccc#..", |
161 | ".#cdcefcghc#..", | 161 | ".#cdcefcghc#..", |
162 | ".#ccccccccc#..", | 162 | ".#ccccccccc#..", |
163 | ".#cicjkclic#..", | 163 | ".#cicjkclic#..", |
164 | ".#ccccccccc#..", | 164 | ".#ccccccccc#..", |
165 | ".#cmchlcnec#..", | 165 | ".#cmchlcnec#..", |
166 | ".#ccccccccc#..", | 166 | ".#ccccccccc#..", |
167 | ".###########..", | 167 | ".###########..", |
168 | "..............", | 168 | "..............", |
169 | ".............."}; | 169 | ".............."}; |
170 | 170 | ||
171 | 171 | ||
172 | static const char* const passwords_data[] = { | 172 | static const char* const passwords_data[] = { |
173 | "16 16 20 1", | 173 | "16 16 20 1", |
174 | ". c None", | 174 | ". c None", |
175 | "# c #000000", | 175 | "# c #000000", |
176 | "r c #000083", | 176 | "r c #000083", |
177 | "p c #0000c5", | 177 | "p c #0000c5", |
178 | "q c #0000ff", | 178 | "q c #0000ff", |
179 | "n c #008100", | 179 | "n c #008100", |
180 | "l c #00c200", | 180 | "l c #00c200", |
181 | "m c #00ff00", | 181 | "m c #00ff00", |
182 | "j c #838100", | 182 | "j c #838100", |
183 | "a c #c55900", | 183 | "a c #c55900", |
184 | "h c #c5c200", | 184 | "h c #c5c200", |
185 | "o c #c5c2ff", | 185 | "o c #c5c2ff", |
186 | "k c #c5ffc5", | 186 | "k c #c5ffc5", |
187 | "f c #ff0000", | 187 | "f c #ff0000", |
188 | "d c #ff8100", | 188 | "d c #ff8100", |
189 | "b c #ffaa5a", | 189 | "b c #ffaa5a", |
190 | "e c #ffc2c5", | 190 | "e c #ffc2c5", |
191 | "c c #ffdeac", | 191 | "c c #ffdeac", |
192 | "i c #ffff00", | 192 | "i c #ffff00", |
193 | "g c #ffffc5", | 193 | "g c #ffffc5", |
194 | "............###.", | 194 | "............###.", |
195 | "...........#abb#", | 195 | "...........#abb#", |
196 | "..........#cbab#", | 196 | "..........#cbab#", |
197 | ".........#cbdd#.", | 197 | ".........#cbdd#.", |
198 | "######..#cbdd#..", | 198 | "######..#cbdd#..", |
199 | "#eeff#..#add#...", | 199 | "#eeff#..#add#...", |
200 | "#eeff#######....", | 200 | "#eeff#######....", |
201 | "#ccdbdd#........", | 201 | "#ccdbdd#........", |
202 | "#dddbdd###......", | 202 | "#dddbdd###......", |
203 | "#gghihhjj#......", | 203 | "#gghihhjj#......", |
204 | "#hhhihhjj###....", | 204 | "#hhhihhjj###....", |
205 | "#kklmllnnnn#....", | 205 | "#kklmllnnnn#....", |
206 | "#lllmllnnnn#....", | 206 | "#lllmllnnnn#....", |
207 | "#oopqpprprr#....", | 207 | "#oopqpprprr#....", |
208 | "#oopqpprprr#....", | 208 | "#oopqpprprr#....", |
209 | "############...."}; | 209 | "############...."}; |
210 | 210 | ||
211 | static const char* const software_data[] = { | 211 | static const char* const software_data[] = { |
212 | "16 16 5 1", | 212 | "16 16 5 1", |
213 | ". c None", | 213 | ". c None", |
214 | "# c #000000", | 214 | "# c #000000", |
215 | "b c #838183", | 215 | "b c #838183", |
216 | "c c #c5ffff", | 216 | "c c #c5ffff", |
217 | "a c #ffffff", | 217 | "a c #ffffff", |
218 | "................", | 218 | "................", |
219 | ".##############.", | 219 | ".##############.", |
220 | "#aaaaaaaaaaaaaa#", | 220 | "#aaaaaaaaaaaaaa#", |
221 | "#abbbbbbbbbbbbb#", | 221 | "#abbbbbbbbbbbbb#", |
222 | "#ab##########ab#", | 222 | "#ab##########ab#", |
223 | "#ab#c########ab#", | 223 | "#ab#c########ab#", |
224 | "#ab#c#c######ab#", | 224 | "#ab#c#c######ab#", |
225 | "#ab##########ab#", | 225 | "#ab##########ab#", |
226 | "#ab##########ab#", | 226 | "#ab##########ab#", |
227 | "#ab##########ab#", | 227 | "#ab##########ab#", |
228 | "#ab##########ab#", | 228 | "#ab##########ab#", |
229 | "#ab##########ab#", | 229 | "#ab##########ab#", |
230 | "#aaaaaaaaaaaaab#", | 230 | "#aaaaaaaaaaaaab#", |
231 | "#bbbbbbbbbbbbbb#", | 231 | "#bbbbbbbbbbbbbb#", |
232 | ".##############.", | 232 | ".##############.", |
233 | "................"}; | 233 | "................"}; |
234 | 234 | ||
235 | static const char* const general_data[] = { | 235 | static const char* const general_data[] = { |
236 | "14 14 98 2", | 236 | "14 14 98 2", |
237 | "Qt c None", | 237 | "Qt c None", |
238 | ".k c #000000", | 238 | ".k c #000000", |
239 | "#x c #080808", | 239 | "#x c #080808", |
240 | "#F c #101008", | 240 | "#F c #101008", |
241 | "#q c #101010", | 241 | "#q c #101010", |
242 | "#i c #101410", | 242 | "#i c #101410", |
243 | "## c #101810", | 243 | "## c #101810", |
244 | ".m c #181818", | 244 | ".m c #181818", |
245 | ".3 c #181c18", | 245 | ".3 c #181c18", |
246 | ".I c #182018", | 246 | ".I c #182018", |
247 | ".T c #202420", | 247 | ".T c #202420", |
248 | "#D c #202820", | 248 | "#D c #202820", |
249 | "#y c #292c29", | 249 | "#y c #292c29", |
250 | ".c c #293029", | 250 | ".c c #293029", |
251 | ".d c #313031", | 251 | ".d c #313031", |
252 | "#E c #313429", | 252 | "#E c #313429", |
253 | "#r c #313831", | 253 | "#r c #313831", |
254 | ".j c #393c31", | 254 | ".j c #393c31", |
255 | "#j c #394039", | 255 | "#j c #394039", |
256 | "#C c #414841", | 256 | "#C c #414841", |
257 | ".w c #4a554a", | 257 | ".w c #4a554a", |
258 | ".a c #4a594a", | 258 | ".a c #4a594a", |
259 | ".# c #525052", | 259 | ".# c #525052", |
260 | ".l c #52594a", | 260 | ".l c #52594a", |
261 | "#f c #525952", | 261 | "#f c #525952", |
262 | "#v c #525d52", | 262 | "#v c #525d52", |
263 | ".O c #5a4c4a", | 263 | ".O c #5a4c4a", |
264 | ".9 c #5a595a", | 264 | ".9 c #5a595a", |
265 | ".A c #5a5d52", | 265 | ".A c #5a5d52", |
266 | ".B c #624c52", | 266 | ".B c #624c52", |
267 | ".0 c #625552", | 267 | ".0 c #625552", |
268 | "#o c #626562", | 268 | "#o c #626562", |
269 | ".R c #626962", | 269 | ".R c #626962", |
270 | "#. c #626d5a", | 270 | "#. c #626d5a", |
271 | "#p c #626d62", | 271 | "#p c #626d62", |
272 | ".2 c #627162", | 272 | ".2 c #627162", |
273 | "#h c #6a6d62", | 273 | "#h c #6a6d62", |
274 | "#z c #6a7562", | 274 | "#z c #6a7562", |
275 | "#w c #6a756a", | 275 | "#w c #6a756a", |
276 | ".C c #73656a", | 276 | ".C c #73656a", |
277 | ".P c #73696a", | 277 | ".P c #73696a", |
278 | "#a c #737d6a", | 278 | "#a c #737d6a", |
279 | ".U c #738573", | 279 | ".U c #738573", |
280 | ".E c #7b817b", | 280 | ".E c #7b817b", |
281 | "#B c #7b857b", | 281 | "#B c #7b857b", |
282 | "#s c #7b897b", | 282 | "#s c #7b897b", |
283 | "#n c #7b917b", | 283 | "#n c #7b917b", |
284 | ".b c #838d83", | 284 | ".b c #838d83", |
285 | ".7 c #839583", | 285 | ".7 c #839583", |
286 | ".n c #8b7d7b", | 286 | ".n c #8b7d7b", |
287 | "#g c #8b8583", | 287 | "#g c #8b8583", |
288 | ".g c #8b858b", | 288 | ".g c #8b858b", |
289 | ".r c #8b898b", | 289 | ".r c #8b898b", |
290 | ".s c #8b8d8b", | 290 | ".s c #8b8d8b", |
291 | ".i c #8b9183", | 291 | ".i c #8b9183", |
292 | ".8 c #8b918b", | 292 | ".8 c #8b918b", |
293 | "#A c #8b9d8b", | 293 | "#A c #8b9d8b", |
294 | ".S c #8ba183", | 294 | ".S c #8ba183", |
295 | ".Z c #94918b", | 295 | ".Z c #94918b", |
296 | ".N c #949994", | 296 | ".N c #949994", |
297 | ".F c #949d94", | 297 | ".F c #949d94", |
298 | ".x c #94a18b", | 298 | ".x c #94a18b", |
299 | ".v c #94a194", | 299 | ".v c #94a194", |
300 | ".Y c #94aa94", | 300 | ".Y c #94aa94", |
301 | ".h c #9c999c", | 301 | ".h c #9c999c", |
302 | ".Q c #9ca19c", | 302 | ".Q c #9ca19c", |
303 | "#u c #9ca59c", | 303 | "#u c #9ca59c", |
304 | ".H c #9caa9c", | 304 | ".H c #9caa9c", |
305 | "#e c #9cb29c", | 305 | "#e c #9cb29c", |
306 | "#m c #a4b29c", | 306 | "#m c #a4b29c", |
307 | "#t c #a4b2a4", | 307 | "#t c #a4b2a4", |
308 | ".M c #a4b69c", | 308 | ".M c #a4b69c", |
309 | "#l c #a4b6a4", | 309 | "#l c #a4b6a4", |
310 | ".z c #a4baa4", | 310 | ".z c #a4baa4", |
311 | ".f c #aca5ac", | 311 | ".f c #aca5ac", |
312 | ".q c #acaaac", | 312 | ".q c #acaaac", |
313 | "#d c #acbeac", | 313 | "#d c #acbeac", |
314 | ".6 c #acc2ac", | 314 | ".6 c #acc2ac", |
315 | ".o c #b4b2b4", | 315 | ".o c #b4b2b4", |
316 | ".t c #b4beb4", | 316 | ".t c #b4beb4", |
317 | "#k c #b4c2ac", | 317 | "#k c #b4c2ac", |
318 | ".5 c #b4cab4", | 318 | ".5 c #b4cab4", |
319 | ".D c #bdb6bd", | 319 | ".D c #bdb6bd", |
320 | ".G c #bdc6b4", | 320 | ".G c #bdc6b4", |
321 | "#c c #bdceb4", | 321 | "#c c #bdceb4", |
322 | ".X c #bdd2bd", | 322 | ".X c #bdd2bd", |
323 | ".4 c #bdd6bd", | 323 | ".4 c #bdd6bd", |
324 | ".1 c #c5bec5", | 324 | ".1 c #c5bec5", |
325 | ".e c #c5c2c5", | 325 | ".e c #c5c2c5", |
326 | ".u c #c5cac5", | 326 | ".u c #c5cac5", |
327 | "#b c #c5d6c5", | 327 | "#b c #c5d6c5", |
328 | ".J c #c5dec5", | 328 | ".J c #c5dec5", |
329 | ".p c #cdcacd", | 329 | ".p c #cdcacd", |
330 | ".W c #cddecd", | 330 | ".W c #cddecd", |
331 | ".L c #cde2cd", | 331 | ".L c #cde2cd", |
332 | ".K c #d5eacd", | 332 | ".K c #d5eacd", |
333 | ".V c #d5ead5", | 333 | ".V c #d5ead5", |
334 | ".y c #d5eed5", | 334 | ".y c #d5eed5", |
335 | "QtQtQtQtQtQtQtQtQtQtQtQtQtQt", | 335 | "QtQtQtQtQtQtQtQtQtQtQtQtQtQt", |
336 | "QtQtQt.#.a.b.cQtQtQtQtQtQtQt", | 336 | "QtQtQt.#.a.b.cQtQtQtQtQtQtQt", |
337 | "QtQt.d.e.f.g.h.i.c.j.dQt.kQt", | 337 | "QtQt.d.e.f.g.h.i.c.j.dQt.kQt", |
338 | ".a.l.m.n.o.p.q.r.s.t.u.v.wQt", | 338 | ".a.l.m.n.o.p.q.r.s.t.u.v.wQt", |
339 | ".x.y.z.A.B.C.D.p.q.E.F.G.H.I", | 339 | ".x.y.z.A.B.C.D.p.q.E.F.G.H.I", |
340 | ".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", | 340 | ".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", |
341 | "Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", | 341 | "Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", |
342 | "Qt.3.X.W.4.X.5.6.7.8.9.s#.##", | 342 | "Qt.3.X.W.4.X.5.6.7.8.9.s#.##", |
343 | "QtQt#a.X#b#c.5.6#d#e#f#g#h#i", | 343 | "QtQt#a.X#b#c.5.6#d#e#f#g#h#i", |
344 | "QtQtQt#j.7#k.6#d#l#m#n#o#p#q", | 344 | "QtQtQt#j.7#k.6#d#l#m#n#o#p#q", |
345 | "QtQtQtQt.k#r#s#m#t.H#u#v#w#x", | 345 | "QtQtQtQt.k#r#s#m#t.H#u#v#w#x", |
346 | "QtQtQtQtQtQt.k#y#z.v#A#B#C#x", | 346 | "QtQtQtQtQtQt.k#y#z.v#A#B#C#x", |
347 | "QtQtQtQtQtQtQtQt.k#D.w#s#E.k", | 347 | "QtQtQtQtQtQtQtQt.k#D.w#s#E.k", |
348 | "QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; | 348 | "QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; |
349 | 349 | ||
350 | // exit ZSafe and clear the clipboard for security reasons | 350 | // exit ZSafe and clear the clipboard for security reasons |
351 | void ZSafe::exitZs (int ec) | 351 | void ZSafe::exitZs (int ec) |
352 | { | 352 | { |
353 | QClipboard *cb = QApplication::clipboard(); | 353 | QClipboard *cb = QApplication::clipboard(); |
354 | cb->clear(); | 354 | cb->clear(); |
355 | 355 | ||
356 | exit (ec); | 356 | exit (ec); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | // save the configuration into the file | 360 | // save the configuration into the file |
361 | void ZSafe::saveConf () | 361 | void ZSafe::saveConf () |
362 | { | 362 | { |
363 | if (conf) | 363 | if (conf) |
364 | { | 364 | { |
365 | delete conf; | 365 | delete conf; |
366 | 366 | ||
367 | #ifdef DESKTOP | 367 | #ifdef DESKTOP |
368 | #ifndef Q_WS_WIN | 368 | #ifndef Q_WS_WIN |
369 | conf = new QSettings(); | 369 | conf = new QSettings(); |
370 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 370 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
371 | #else | 371 | #else |
372 | conf = new QSettings (cfgFile); | 372 | conf = new QSettings (cfgFile); |
373 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 373 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
374 | #endif | 374 | #endif |
375 | #else | 375 | #else |
376 | conf = new Config (cfgFile, Config::File); | 376 | conf = new Config (cfgFile, Config::File); |
377 | conf->setGroup ("zsafePrefs"); | 377 | conf->setGroup ("zsafePrefs"); |
378 | #endif | 378 | #endif |
379 | } | 379 | } |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | /* | 383 | /* |
384 | * Constructs a ZSafe which is a child of 'parent', with the | 384 | * Constructs a ZSafe which is a child of 'parent', with the |
385 | * name 'name' and widget flags set to 'f' | 385 | * name 'name' and widget flags set to 'f' |
386 | * | 386 | * |
387 | * The dialog will by default be modeless, unless you set 'modal' to | 387 | * The dialog will by default be modeless, unless you set 'modal' to |
388 | * TRUE to construct a modal dialog. | 388 | * TRUE to construct a modal dialog. |
389 | */ | 389 | */ |
390 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | 390 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) |
391 | : QDialog( parent, name, modal, fl ), | 391 | : QDialog( parent, name, modal, fl ), |
392 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) | 392 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) |
393 | { | 393 | { |
394 | IsCut = false; | 394 | IsCut = false; |
395 | IsCopy = false; | 395 | IsCopy = false; |
396 | modified = false; | 396 | modified = false; |
397 | showpwd = false; | 397 | showpwd = false; |
398 | 398 | ||
399 | // set the config file | 399 | // set the config file |
400 | cfgFile=QDir::homeDirPath(); | 400 | cfgFile=QDir::homeDirPath(); |
401 | cfgFile += "/.zsafe.cfg"; | 401 | cfgFile += "/.zsafe.cfg"; |
402 | // set the icon path | 402 | // set the icon path |
403 | #ifdef NO_OPIE | 403 | #ifdef NO_OPIE |
404 | QString qpedir ((const char *)getenv("QPEDIR")); | 404 | QString qpedir ((const char *)getenv("QPEDIR")); |
405 | #else | 405 | #else |
406 | QString qpedir ((const char *)getenv("OPIEDIR")); | 406 | QString qpedir ((const char *)getenv("OPIEDIR")); |
407 | #endif | 407 | #endif |
408 | 408 | ||
409 | #ifdef DESKTOP | 409 | #ifdef DESKTOP |
410 | iconPath = QDir::homeDirPath() + "/pics/"; | 410 | iconPath = QDir::homeDirPath() + "/pics/"; |
411 | #else | 411 | #else |
412 | if (qpedir.isEmpty()) | 412 | if (qpedir.isEmpty()) |
413 | iconPath = "/home/QtPalmtop/pics/"; | 413 | iconPath = "/home/QtPalmtop/pics/"; |
414 | else | 414 | else |
415 | iconPath = qpedir + "/pics/"; | 415 | iconPath = qpedir + "/pics/"; |
416 | #endif | 416 | #endif |
417 | 417 | ||
418 | // create a zsafe configuration object | 418 | // create a zsafe configuration object |
419 | #ifdef DESKTOP | 419 | #ifdef DESKTOP |
420 | #ifndef Q_WS_WIN | 420 | #ifndef Q_WS_WIN |
421 | conf = new QSettings (); | 421 | conf = new QSettings (); |
422 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 422 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
423 | #else | 423 | #else |
424 | conf = new QSettings (cfgFile); | 424 | conf = new QSettings (cfgFile); |
425 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 425 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
426 | #endif | 426 | #endif |
427 | #else | 427 | #else |
428 | conf = new Config (cfgFile, Config::File); | 428 | conf = new Config (cfgFile, Config::File); |
429 | conf->setGroup ("zsafePrefs"); | 429 | conf->setGroup ("zsafePrefs"); |
430 | #endif | 430 | #endif |
431 | #ifdef DESKTOP | 431 | #ifdef DESKTOP |
432 | // #ifndef Q_WS_WIN | 432 | // #ifndef Q_WS_WIN |
433 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); | 433 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); |
434 | // #endif | 434 | // #endif |
435 | #else | 435 | #else |
436 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); | 436 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); |
437 | #endif | 437 | #endif |
438 | #ifndef DESKTOP | 438 | #ifndef DESKTOP |
439 | conf->setGroup ("zsafe"); | 439 | conf->setGroup ("zsafe"); |
440 | #endif | 440 | #endif |
441 | 441 | ||
442 | QPixmap copy_img((const char**) copy_xpm); | 442 | QPixmap copy_img((const char**) copy_xpm); |
443 | QPixmap cut_img((const char**) cut_xpm); | 443 | QPixmap cut_img((const char**) cut_xpm); |
444 | QPixmap edit_img((const char**) edit_xpm); | 444 | QPixmap edit_img((const char**) edit_xpm); |
445 | QPixmap editdelete_img((const char**) editdelete_xpm); | 445 | QPixmap editdelete_img((const char**) editdelete_xpm); |
446 | QPixmap find_img((const char**) find_xpm); | 446 | QPixmap find_img((const char**) find_xpm); |
447 | QPixmap folder_open_img((const char**) folder_open_xpm); | 447 | QPixmap folder_open_img((const char**) folder_open_xpm); |
448 | QPixmap help_icon_img((const char**) help_icon_xpm); | 448 | QPixmap help_icon_img((const char**) help_icon_xpm); |
449 | QPixmap new_img((const char**) new_xpm); | 449 | QPixmap new_img((const char**) new_xpm); |
450 | QPixmap paste_img((const char**) paste_xpm); | 450 | QPixmap paste_img((const char**) paste_xpm); |
451 | QPixmap quit_icon_img((const char**) quit_icon_xpm); | 451 | QPixmap quit_icon_img((const char**) quit_icon_xpm); |
452 | QPixmap save_img((const char**) save_xpm); | 452 | QPixmap save_img((const char**) save_xpm); |
453 | QPixmap trash_img((const char**) trash_xpm); | 453 | QPixmap trash_img((const char**) trash_xpm); |
454 | QPixmap expand_img((const char**) expand_xpm); | 454 | QPixmap expand_img((const char**) expand_xpm); |
455 | QPixmap export_img((const char**) export_xpm); | 455 | QPixmap export_img((const char**) export_xpm); |
456 | QPixmap import_img((const char**) import_xpm); | 456 | QPixmap import_img((const char**) import_xpm); |
457 | 457 | ||
458 | QPixmap bank_cards( ( const char** ) bank_cards_data ); | 458 | QPixmap bank_cards( ( const char** ) bank_cards_data ); |
459 | QPixmap passwords( ( const char** ) passwords_data ); | 459 | QPixmap passwords( ( const char** ) passwords_data ); |
460 | QPixmap software( ( const char** ) software_data ); | 460 | QPixmap software( ( const char** ) software_data ); |
461 | QPixmap general( ( const char** ) general_data ); | 461 | QPixmap general( ( const char** ) general_data ); |
462 | QPixmap image0( ( const char** ) zsafe_xpm ); | 462 | QPixmap image0( ( const char** ) zsafe_xpm ); |
463 | if ( !name ) | 463 | if ( !name ) |
464 | setName( "ZSafe" ); | 464 | setName( "ZSafe" ); |
465 | 465 | ||
466 | #ifdef DESKTOP | 466 | #ifdef DESKTOP |
467 | #ifdef Q_WS_WIN | 467 | #ifdef Q_WS_WIN |
468 | setGeometry(100, 150, DeskW, DeskH-30 ); | 468 | setGeometry(100, 150, DeskW, DeskH-30 ); |
469 | #else | 469 | #else |
470 | resize( DeskW, DeskH-30 ); | 470 | resize( DeskW, DeskH-30 ); |
471 | #endif | 471 | #endif |
472 | 472 | ||
473 | #else | 473 | #else |
474 | 474 | ||
475 | #ifdef JPATCH_HDE | 475 | #ifdef JPATCH_HDE |
476 | int DeskS; | 476 | int DeskS; |
477 | if(DeskW > DeskH) | 477 | if(DeskW > DeskH) |
478 | { | 478 | { |
479 | DeskS = DeskW; | 479 | DeskS = DeskW; |
480 | } | 480 | } |
481 | else | 481 | else |
482 | { | 482 | { |
483 | DeskS = DeskH; | 483 | DeskS = DeskH; |
484 | } | 484 | } |
485 | resize( DeskW, DeskH ); | 485 | resize( DeskW, DeskH ); |
486 | setMinimumSize( QSize( DeskS, DeskS ) ); | 486 | setMinimumSize( QSize( DeskS, DeskS ) ); |
487 | setMaximumSize( QSize( DeskS, DeskS ) ); | 487 | setMaximumSize( QSize( DeskS, DeskS ) ); |
488 | #else | 488 | #else |
489 | resize( DeskW, DeskH-30 ); | 489 | resize( DeskW, DeskH-30 ); |
490 | #endif | 490 | #endif |
491 | 491 | ||
492 | #endif | 492 | #endif |
493 | setCaption( tr( "ZSafe" ) ); | 493 | setCaption( tr( "ZSafe" ) ); |
494 | QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; | 494 | QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; |
495 | filename = conf->readEntry(APP_KEY+"document"); | 495 | filename = conf->readEntry(APP_KEY+"document"); |
496 | if ( !QFileInfo(filename).exists() || !QDir(zsafeAppDirPath).exists() ) | 496 | if ( !QFileInfo(filename).exists() || !QDir(zsafeAppDirPath).exists() ) |
497 | { | 497 | { |
498 | // check if the directory application exists, if not | 498 | // check if the directory application exists, if not |
499 | // create it | 499 | // create it |
500 | // #ifndef Q_WS_WIN | 500 | // #ifndef Q_WS_WIN |
501 | // QString d1("Documents/application"); | 501 | // QString d1("Documents/application"); |
502 | // #else | 502 | // #else |
503 | QString d1(QDir::homeDirPath() + "/Documents/application"); | 503 | QString d1(QDir::homeDirPath() + "/Documents/application"); |
504 | // #endif | 504 | // #endif |
505 | QDir pd1(d1); | 505 | QDir pd1(d1); |
506 | if (!pd1.exists()) | 506 | if (!pd1.exists()) |
507 | { | 507 | { |
508 | QDir pd2(QDir::homeDirPath() + "/Documents"); | 508 | QDir pd2(QDir::homeDirPath() + "/Documents"); |
509 | if (!pd2.exists()) { | 509 | if (!pd2.exists()) { |
510 | QDir pd3(QDir::homeDirPath()); | 510 | QDir pd3(QDir::homeDirPath()); |
511 | if (!pd3.mkdir("Documents", FALSE)) { | 511 | if (!pd3.mkdir("Documents", FALSE)) { |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | if (!pd2.mkdir("application", FALSE)) | 515 | if (!pd2.mkdir("application", FALSE)) |
516 | { | 516 | { |
517 | QMessageBox::critical( 0, tr("ZSafe"), | 517 | QMessageBox::critical( 0, tr("ZSafe"), |
518 | #ifdef JPATCH_HDE | 518 | #ifdef JPATCH_HDE |
519 | tr("<P>Can't create directory ..."+d1+"</P><P>ZSafe will now exit.</P>")); | 519 | tr("<P>Can't create directory ..."+d1+"</P><P>ZSafe will now exit.</P>")); |
520 | #else | 520 | #else |
521 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1)); | 521 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1)); |
522 | #endif | 522 | #endif |
523 | exitZs (1); | 523 | exitZs (1); |
524 | } | 524 | } |
525 | } | 525 | } |
526 | // #ifndef Q_WS_WIN | 526 | // #ifndef Q_WS_WIN |
527 | // QString d2("Documents/application/zsafe"); | 527 | // QString d2("Documents/application/zsafe"); |
528 | // #else | 528 | // #else |
529 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); | 529 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); |
530 | // #endif | 530 | // #endif |
531 | QDir pd2(d2); | 531 | QDir pd2(d2); |
532 | if (!pd2.exists()) | 532 | if (!pd2.exists()) |
533 | { | 533 | { |
534 | if (!pd1.mkdir("zsafe", FALSE)) | 534 | if (!pd1.mkdir("zsafe", FALSE)) |
535 | { | 535 | { |
536 | QMessageBox::critical( 0, tr("ZSafe"), | 536 | QMessageBox::critical( 0, tr("ZSafe"), |
537 | #ifdef JPATCH_HDE | 537 | #ifdef JPATCH_HDE |
538 | tr("<P>Can't create directory ...//Documents/application/zsafe</P><P>ZSafe will now exit.</P")); | 538 | tr("<P>Can't create directory ...//Documents/application/zsafe</P><P>ZSafe will now exit.</P")); |
539 | #else | 539 | #else |
540 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2)); | 540 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2)); |
541 | #endif | 541 | #endif |
542 | exitZs (1); | 542 | exitZs (1); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | 545 | ||
546 | filename = zsafeAppDirPath + "/passwords.zsf"; | 546 | filename = zsafeAppDirPath + "/passwords.zsf"; |
547 | 547 | ||
548 | // save the current filename to the config file | 548 | // save the current filename to the config file |
549 | conf->writeEntry(APP_KEY+"document", filename); | 549 | conf->writeEntry(APP_KEY+"document", filename); |
550 | saveConf(); | 550 | saveConf(); |
551 | } | 551 | } |
552 | //if (filename == "INVALIDPWD") | 552 | //if (filename == "INVALIDPWD") |
553 | //filename = ""; | 553 | //filename = ""; |
554 | 554 | ||
555 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 555 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
556 | #ifdef Q_WS_WIN | 556 | #ifdef Q_WS_WIN |
557 | this->setCaption("Qt ZSafe: " + ti); | 557 | this->setCaption("Qt ZSafe: " + ti); |
558 | #else | 558 | #else |
559 | this->setCaption("ZSafe: " + ti); | 559 | this->setCaption("ZSafe: " + ti); |
560 | #endif | 560 | #endif |
561 | 561 | ||
562 | selectedItem = NULL; | 562 | selectedItem = NULL; |
563 | lastSearchedCategory = NULL; | 563 | lastSearchedCategory = NULL; |
564 | lastSearchedItem = NULL; | 564 | lastSearchedItem = NULL; |
565 | lastSearchedName = ""; | 565 | lastSearchedName = ""; |
566 | lastSearchedUsername = ""; | 566 | lastSearchedUsername = ""; |
567 | lastSearchedComment = ""; | 567 | lastSearchedComment = ""; |
568 | 568 | ||
569 | infoForm = new InfoForm(this, "show_info", TRUE); | 569 | infoForm = new InfoForm(this, "show_info", TRUE); |
570 | categoryDialog = NULL; | 570 | categoryDialog = NULL; |
571 | infoForm->setIcon( image0); | 571 | infoForm->setIcon( image0); |
572 | 572 | ||
573 | // add a menu bar | 573 | // add a menu bar |
574 | QMenuBar *menu = new QMenuBar( this ); | 574 | QMenuBar *menu = new QMenuBar( this ); |
575 | 575 | ||
576 | // add file menu | 576 | // add file menu |
577 | // QPopupMenu *file = new QPopupMenu( this ); | 577 | // QPopupMenu *file = new QPopupMenu( this ); |
578 | file = new QPopupMenu( this ); | 578 | file = new QPopupMenu( this ); |
579 | 579 | ||
580 | // #ifdef DESKTOP | 580 | // #ifdef DESKTOP |
581 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); | 581 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); |
582 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); | 582 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); |
583 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); | 583 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); |
584 | file->insertSeparator(); | 584 | file->insertSeparator(); |
585 | // #endif | 585 | // #endif |
586 | 586 | ||
587 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); | 587 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); |
588 | file->insertItem( save_img, tr("S&ave document with new Password"), this, | 588 | file->insertItem( save_img, tr("S&ave document with new Password"), this, |
589 | SLOT(saveDocumentWithPwd()) ); | 589 | SLOT(saveDocumentWithPwd()) ); |
590 | file->insertSeparator(); | 590 | file->insertSeparator(); |
591 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); | 591 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); |
592 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); | 592 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); |
593 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); | 593 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); |
594 | file->insertSeparator(); | 594 | file->insertSeparator(); |
595 | file->insertItem( expand_img, tr("&Open entries expanded"), this, | 595 | file->insertItem( expand_img, tr("&Open entries expanded"), this, |
596 | SLOT(setExpandFlag()), 0, 'o'); | 596 | SLOT(setExpandFlag()), 0, 'o'); |
597 | file->setItemChecked('o', expandTree); | 597 | file->setItemChecked('o', expandTree); |
598 | file->insertSeparator(); | 598 | file->insertSeparator(); |
599 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); | 599 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); |
600 | menu->insertItem( tr("&File"), file ); | 600 | menu->insertItem( tr("&File"), file ); |
601 | 601 | ||
602 | QPopupMenu *cat = new QPopupMenu( this ); | 602 | QPopupMenu *cat = new QPopupMenu( this ); |
603 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); | 603 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); |
604 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); | 604 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); |
605 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); | 605 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); |
606 | menu->insertItem( tr("&Category"), cat ); | 606 | menu->insertItem( tr("&Category"), cat ); |
607 | 607 | ||
608 | QPopupMenu *it = new QPopupMenu( this ); | 608 | QPopupMenu *it = new QPopupMenu( this ); |
609 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); | 609 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); |
610 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); | 610 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); |
611 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); | 611 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); |
612 | it->insertSeparator(); | 612 | it->insertSeparator(); |
613 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); | 613 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); |
614 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); | 614 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); |
615 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); | 615 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); |
616 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); | 616 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); |
617 | menu->insertItem( tr("&Entry"), it ); | 617 | menu->insertItem( tr("&Entry"), it ); |
618 | 618 | ||
619 | QPopupMenu *help = new QPopupMenu( this ); | 619 | QPopupMenu *help = new QPopupMenu( this ); |
620 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); | 620 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); |
621 | menu->insertItem( tr("&Help"), help ); | 621 | menu->insertItem( tr("&Help"), help ); |
622 | 622 | ||
623 | // toolbar icons | 623 | // toolbar icons |
624 | 624 | ||
625 | New = new QToolButton( menu, "New" ); | 625 | New = new QToolButton( menu, "New" ); |
626 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); | 626 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); |
627 | New->setMouseTracking( TRUE ); | 627 | New->setMouseTracking( TRUE ); |
628 | New->setText( "" ); | 628 | New->setText( "" ); |
629 | New->setPixmap( new_img ); | 629 | New->setPixmap( new_img ); |
630 | QToolTip::add( New, tr( "New entry" ) ); | 630 | QToolTip::add( New, tr( "New entry" ) ); |
631 | 631 | ||
632 | Edit = new QToolButton( menu, "Edit" ); | 632 | Edit = new QToolButton( menu, "Edit" ); |
633 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); | 633 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); |
634 | Edit->setText( "" ); | 634 | Edit->setText( "" ); |
635 | Edit->setPixmap( edit_img ); | 635 | Edit->setPixmap( edit_img ); |
636 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); | 636 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); |
637 | 637 | ||
638 | Delete = new QToolButton( menu, "Delete" ); | 638 | Delete = new QToolButton( menu, "Delete" ); |
639 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 639 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
640 | Delete->setText( "" ); | 640 | Delete->setText( "" ); |
641 | Delete->setPixmap( trash_img ); | 641 | Delete->setPixmap( trash_img ); |
642 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); | 642 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); |
643 | 643 | ||
644 | Find = new QToolButton( menu, "Find" ); | 644 | Find = new QToolButton( menu, "Find" ); |
645 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); | 645 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); |
646 | Find->setText( "" ); | 646 | Find->setText( "" ); |
647 | Find->setPixmap( find_img ); | 647 | Find->setPixmap( find_img ); |
648 | QToolTip::add( Find, tr( "Find entry" ) ); | 648 | QToolTip::add( Find, tr( "Find entry" ) ); |
649 | 649 | ||
650 | /* | 650 | /* |
651 | QBoxLayout * h = new QHBoxLayout( this ); | 651 | QBoxLayout * h = new QHBoxLayout( this ); |
652 | h->addWidget (menu); | 652 | h->addWidget (menu); |
653 | h->addWidget (New); | 653 | h->addWidget (New); |
654 | h->addWidget (Edit); | 654 | h->addWidget (Edit); |
655 | h->addWidget (Delete); | 655 | h->addWidget (Delete); |
656 | h->addWidget (Find); | 656 | h->addWidget (Find); |
657 | */ | 657 | */ |
658 | 658 | ||
659 | ListView = new ZListView( this, "ListView" ); | 659 | ListView = new ZListView( this, "ListView" ); |
660 | ListView->addColumn( tr( "Name" ) ); | 660 | ListView->addColumn( tr( "Name" ) ); |
661 | ListView->addColumn( tr( "Field 2" ) ); | 661 | ListView->addColumn( tr( "Field 2" ) ); |
662 | ListView->addColumn( tr( "Field 3" ) ); | 662 | ListView->addColumn( tr( "Field 3" ) ); |
663 | ListView->addColumn( tr( "Comment" ) ); | 663 | ListView->addColumn( tr( "Comment" ) ); |
664 | ListView->addColumn( tr( "Field 4" ) ); | 664 | ListView->addColumn( tr( "Field 4" ) ); |
665 | ListView->addColumn( tr( "Field 5" ) ); | 665 | ListView->addColumn( tr( "Field 5" ) ); |
666 | ListView->setAllColumnsShowFocus(TRUE); | 666 | ListView->setAllColumnsShowFocus(TRUE); |
667 | 667 | ||
668 | #ifdef DESKTOP | 668 | #ifdef DESKTOP |
669 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 669 | // ListView->setResizePolicy(QScrollView::AutoOneFit); |
670 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); | 670 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); |
671 | #else | 671 | #else |
672 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 672 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
673 | // ListView->setGeometry( QRect( 0, 22, | 673 | // ListView->setGeometry( QRect( 0, 22, |
674 | // this->width(), this->height() - 30 ) ); | 674 | // this->width(), this->height() - 30 ) ); |
675 | // ListView->setMaximumSize( QSize( 440, 290 ) ); | 675 | // ListView->setMaximumSize( QSize( 440, 290 ) ); |
676 | #endif | 676 | #endif |
677 | ListView->setVScrollBarMode( QListView::Auto ); | 677 | // ListView->setVScrollBarMode( QListView::Auto ); |
678 | 678 | ||
679 | QBoxLayout * l = new QVBoxLayout( this ); | 679 | QBoxLayout * l = new QVBoxLayout( this ); |
680 | l->addWidget (menu); | 680 | l->addWidget (menu); |
681 | l->addWidget (ListView); | 681 | l->addWidget (ListView); |
682 | 682 | ||
683 | #ifndef DESKTOP | 683 | #ifndef DESKTOP |
684 | // start a timer (100 ms) to load the default document | 684 | // start a timer (100 ms) to load the default document |
685 | docuTimer.start( 100, true ); | 685 | docuTimer.start( 100, true ); |
686 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); | 686 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); |
687 | raiseFlag = true; | 687 | raiseFlag = true; |
688 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); | 688 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); |
689 | #else | 689 | #else |
690 | // open the default document | 690 | // open the default document |
691 | openDocument(filename); | 691 | openDocument(filename); |
692 | #endif | 692 | #endif |
693 | 693 | ||
694 | // signals and slots connections for QTollButton | 694 | // signals and slots connections for QTollButton |
695 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); | 695 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); |
696 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); | 696 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); |
697 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); | 697 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); |
698 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); | 698 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); |
699 | // signals and slots connections for QListView | 699 | // signals and slots connections for QListView |
700 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), | 700 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), |
701 | this, SLOT( listViewSelected(QListViewItem*) ) ); | 701 | this, SLOT( listViewSelected(QListViewItem*) ) ); |
702 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), | 702 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), |
703 | this, SLOT( showInfo(QListViewItem*) ) ); | 703 | this, SLOT( showInfo(QListViewItem*) ) ); |
704 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), | 704 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), |
705 | this, SLOT( showInfo(QListViewItem*) ) ); | 705 | this, SLOT( showInfo(QListViewItem*) ) ); |
706 | 706 | ||
707 | #ifndef DESKTOP | 707 | #ifndef DESKTOP |
708 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | 708 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
709 | #endif | 709 | #endif |
710 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 710 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
711 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 711 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
712 | 712 | ||
713 | this->setIcon( image0); | 713 | this->setIcon( image0); |
714 | #ifdef Q_WS_WIN | ||
715 | ListView->setSelected( ListView->firstChild() , true); | ||
716 | ListView->setSelected( ListView->firstChild() , false); | ||
717 | #endif | ||
714 | } | 718 | } |
715 | 719 | ||
716 | const QColor *ZSafe::evenRowColor = &Qt::white; | 720 | const QColor *ZSafe::evenRowColor = &Qt::white; |
717 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; | 721 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; |
718 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); | 722 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); |
719 | 723 | ||
720 | /* | 724 | /* |
721 | * Destroys the object and frees any allocated resources | 725 | * Destroys the object and frees any allocated resources |
722 | */ | 726 | */ |
723 | ZSafe::~ZSafe() | 727 | ZSafe::~ZSafe() |
724 | { | 728 | { |
725 | // no need to delete child widgets, Qt does it all for us | 729 | // no need to delete child widgets, Qt does it all for us |
726 | quitMe(); | 730 | quitMe(); |
727 | } | 731 | } |
728 | 732 | ||
729 | // load the default document | 733 | // load the default document |
730 | void ZSafe::slotLoadDocu() | 734 | void ZSafe::slotLoadDocu() |
731 | { | 735 | { |
732 | openDocument (filename); | 736 | openDocument (filename); |
733 | } | 737 | } |
734 | 738 | ||
735 | void ZSafe::deletePwd() | 739 | void ZSafe::deletePwd() |
736 | { | 740 | { |
737 | 741 | ||
738 | if (!selectedItem) | 742 | if (!selectedItem) |
739 | return; | 743 | return; |
740 | if (!isCategory(selectedItem)) | 744 | if (!isCategory(selectedItem)) |
741 | { | 745 | { |
742 | switch( QMessageBox::information( this, tr("ZSafe"), | 746 | switch( QMessageBox::information( this, tr("ZSafe"), |
743 | tr("Do you want to delete?"), | 747 | tr("Do you want to delete?"), |
744 | tr("&Delete"), tr("D&on't Delete"), | 748 | tr("&Delete"), tr("D&on't Delete"), |
745 | 0 // Enter == button 0 | 749 | 0 // Enter == button 0 |
746 | ) ) { // Escape == button 2 | 750 | ) ) { // Escape == button 2 |
747 | case 0: // Delete clicked, Alt-S or Enter pressed. | 751 | case 0: // Delete clicked, Alt-S or Enter pressed. |
748 | // Delete | 752 | // Delete |
749 | modified = true; | 753 | modified = true; |
750 | selectedItem->parent()->takeItem(selectedItem); | 754 | selectedItem->parent()->takeItem(selectedItem); |
751 | selectedItem = NULL; | 755 | selectedItem = NULL; |
752 | break; | 756 | break; |
753 | case 1: // Don't delete | 757 | case 1: // Don't delete |
754 | break; | 758 | break; |
755 | } | 759 | } |
756 | } | 760 | } |
757 | else | 761 | else |
758 | { | 762 | { |
759 | delCategory(); | 763 | delCategory(); |
760 | } | 764 | } |
761 | } | 765 | } |
762 | 766 | ||
763 | void ZSafe::editPwd() | 767 | void ZSafe::editPwd() |
764 | { | 768 | { |
765 | if (!selectedItem) | 769 | if (!selectedItem) |
766 | return; | 770 | return; |
767 | if (!isCategory(selectedItem)) | 771 | if (!isCategory(selectedItem)) |
768 | { | 772 | { |
769 | // open the 'New Entry' dialog | 773 | // open the 'New Entry' dialog |
770 | NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE); | 774 | NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE); |
771 | #ifdef Q_WS_WIN | 775 | #ifdef Q_WS_WIN |
772 | dialog->setCaption ("Qt " + tr("Edit Entry")); | 776 | dialog->setCaption ("Qt " + tr("Edit Entry")); |
773 | dialog->setGeometry(200, 250, 220, 310 ); | 777 | dialog->setGeometry(200, 250, 220, 310 ); |
774 | #endif | 778 | #endif |
775 | 779 | ||
776 | // set the labels | 780 | // set the labels |
777 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 781 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
778 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 782 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
779 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 783 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
780 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 784 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
781 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 785 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
782 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 786 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
783 | 787 | ||
784 | // set the fields | 788 | // set the fields |
785 | dialog->NameField->setText(selectedItem->text (0)); | 789 | dialog->NameField->setText(selectedItem->text (0)); |
786 | dialog->UsernameField->setText(selectedItem->text (1)); | 790 | dialog->UsernameField->setText(selectedItem->text (1)); |
787 | dialog->PasswordField->setText(selectedItem->text (2)); | 791 | dialog->PasswordField->setText(selectedItem->text (2)); |
788 | QString comment = selectedItem->text (3); | 792 | QString comment = selectedItem->text (3); |
789 | comment.replace (QRegExp("<br>"), "\n"); | 793 | comment.replace (QRegExp("<br>"), "\n"); |
790 | dialog->Field5->setText(selectedItem->text (4)); | 794 | dialog->Field5->setText(selectedItem->text (4)); |
791 | dialog->Field6->setText(selectedItem->text (5)); | 795 | dialog->Field6->setText(selectedItem->text (5)); |
792 | dialog->CommentField->insertLine(comment); | 796 | dialog->CommentField->insertLine(comment); |
793 | dialog->CommentField->setCursorPosition(0,0); | 797 | dialog->CommentField->setCursorPosition(0,0); |
794 | 798 | ||
795 | #ifdef Q_WS_QWS | 799 | #ifdef Q_WS_QWS |
796 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 800 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); |
797 | #endif | 801 | #endif |
798 | 802 | ||
799 | #ifdef DESKTOP | 803 | #ifdef DESKTOP |
800 | #ifndef Q_QW_QWIN | 804 | #ifndef Q_QW_QWIN |
801 | dialog->show(); | 805 | dialog->show(); |
802 | #endif | 806 | #endif |
803 | #else | 807 | #else |
804 | dialog->showMaximized(); | 808 | dialog->showMaximized(); |
805 | #endif | 809 | #endif |
806 | #ifdef DESKTOP | 810 | #ifdef DESKTOP |
807 | int result = dialog->exec(); | 811 | int result = dialog->exec(); |
808 | result = QDialog::Accepted; | 812 | result = QDialog::Accepted; |
809 | #endif | 813 | #endif |
810 | if (result == Accepted) | 814 | if (result == Accepted) |
811 | { | 815 | { |
812 | modified = true; | 816 | modified = true; |
813 | // edit the selected item | 817 | // edit the selected item |
814 | QString name = dialog->NameField->text(); | 818 | QString name = dialog->NameField->text(); |
815 | selectedItem->setText (0, tr (name)); | 819 | selectedItem->setText (0, tr (name)); |
816 | QString user = dialog->UsernameField->text(); | 820 | QString user = dialog->UsernameField->text(); |
817 | selectedItem->setText (1, tr (user)); | 821 | selectedItem->setText (1, tr (user)); |
818 | QString pwd = dialog->PasswordField->text(); | 822 | QString pwd = dialog->PasswordField->text(); |
819 | selectedItem->setText (2, tr (pwd)); | 823 | selectedItem->setText (2, tr (pwd)); |
820 | QString comment = dialog->CommentField->text(); | 824 | QString comment = dialog->CommentField->text(); |
821 | comment.replace (QRegExp("\n"), "<br>"); | 825 | comment.replace (QRegExp("\n"), "<br>"); |
822 | selectedItem->setText (3, tr (comment)); | 826 | selectedItem->setText (3, tr (comment)); |
823 | QString f5 = dialog->Field5->text(); | 827 | QString f5 = dialog->Field5->text(); |
824 | selectedItem->setText (4, tr (f5)); | 828 | selectedItem->setText (4, tr (f5)); |
825 | QString f6 = dialog->Field6->text(); | 829 | QString f6 = dialog->Field6->text(); |
826 | selectedItem->setText (5, tr (f6)); | 830 | selectedItem->setText (5, tr (f6)); |
827 | } | 831 | } |
828 | 832 | ||
829 | delete dialog; | 833 | delete dialog; |
830 | } | 834 | } |
831 | else | 835 | else |
832 | { | 836 | { |
833 | editCategory(); | 837 | editCategory(); |
834 | } | 838 | } |
835 | } | 839 | } |
836 | 840 | ||
837 | void ZSafe::newPwd() | 841 | void ZSafe::newPwd() |
838 | { | 842 | { |
839 | if (!selectedItem) | 843 | if (!selectedItem) |
840 | return; | 844 | return; |
841 | qWarning("new item"); | 845 | qWarning("new item"); |
842 | if (!isCategory(selectedItem)) | 846 | if (!isCategory(selectedItem)) |
843 | selectedItem = selectedItem->parent(); | 847 | selectedItem = selectedItem->parent(); |
844 | 848 | ||
845 | if (isCategory(selectedItem)) | 849 | if (isCategory(selectedItem)) |
846 | { | 850 | { |
847 | QString cat = selectedItem->text(0); | 851 | QString cat = selectedItem->text(0); |
848 | qWarning(cat); | 852 | qWarning(cat); |
849 | // open the 'New Entry' dialog | 853 | // open the 'New Entry' dialog |
850 | NewDialog *dialog = new NewDialog(this, "new_entry", TRUE); | 854 | NewDialog *dialog = new NewDialog(this, "new_entry", TRUE); |
851 | #ifdef Q_WS_WIN | 855 | #ifdef Q_WS_WIN |
852 | dialog->setCaption ("Qt " + tr("New Entry")); | 856 | dialog->setCaption ("Qt " + tr("New Entry")); |
853 | dialog->setGeometry(200, 250, 220, 310 ); | 857 | dialog->setGeometry(200, 250, 220, 310 ); |
854 | #endif | 858 | #endif |
855 | // set the labels | 859 | // set the labels |
856 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 860 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
857 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 861 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
858 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 862 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
859 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 863 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
860 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 864 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
861 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 865 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
862 | retype: | 866 | retype: |
863 | 867 | ||
864 | #ifdef Q_WS_QWS | 868 | #ifdef Q_WS_QWS |
865 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 869 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); |
866 | #endif | 870 | #endif |
867 | 871 | ||
868 | #ifdef DESKTOP | 872 | #ifdef DESKTOP |
869 | #ifndef Q_QW_QWIN | 873 | #ifndef Q_QW_QWIN |
870 | dialog->show(); | 874 | dialog->show(); |
871 | #endif | 875 | #endif |
872 | #else | 876 | #else |
873 | dialog->showMaximized(); | 877 | dialog->showMaximized(); |
874 | #endif | 878 | #endif |
875 | #ifdef DESKTOP | 879 | #ifdef DESKTOP |
876 | int result = dialog->exec(); | 880 | int result = dialog->exec(); |
877 | result = QDialog::Accepted; | 881 | result = QDialog::Accepted; |
878 | #endif | 882 | #endif |
879 | 883 | ||
880 | if (result == Accepted) | 884 | if (result == Accepted) |
881 | { | 885 | { |
882 | 886 | ||
883 | QString name = dialog->NameField->text(); | 887 | QString name = dialog->NameField->text(); |
884 | if (cat == name) | 888 | if (cat == name) |
885 | { | 889 | { |
886 | QMessageBox::critical( 0, tr("ZSafe"), | 890 | QMessageBox::critical( 0, tr("ZSafe"), |
887 | tr("Entry name must be different\nfrom the category name.") ); | 891 | tr("Entry name must be different\nfrom the category name.") ); |
888 | goto retype; // it's not a good programming style :-) | 892 | goto retype; // it's not a good programming style :-) |
889 | } | 893 | } |
890 | 894 | ||
891 | modified = true; | 895 | modified = true; |
892 | // add the new item | 896 | // add the new item |
893 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 897 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
894 | i->setOpen (TRUE); | 898 | i->setOpen (TRUE); |
895 | 899 | ||
896 | i->setText (0, tr (name)); | 900 | i->setText (0, tr (name)); |
897 | QString user = dialog->UsernameField->text(); | 901 | QString user = dialog->UsernameField->text(); |
898 | i->setText (1, tr (user)); | 902 | i->setText (1, tr (user)); |
899 | QString pwd = dialog->PasswordField->text(); | 903 | QString pwd = dialog->PasswordField->text(); |
900 | i->setText (2, tr (pwd)); | 904 | i->setText (2, tr (pwd)); |
901 | QString comment = dialog->CommentField->text(); | 905 | QString comment = dialog->CommentField->text(); |
902 | comment.replace (QRegExp("\n"), "<br>"); | 906 | comment.replace (QRegExp("\n"), "<br>"); |
903 | i->setText (3, tr (comment)); | 907 | i->setText (3, tr (comment)); |
904 | QString f5 = dialog->Field5->text(); | 908 | QString f5 = dialog->Field5->text(); |
905 | i->setText (4, tr (f5)); | 909 | i->setText (4, tr (f5)); |
906 | QString f6 = dialog->Field6->text(); | 910 | QString f6 = dialog->Field6->text(); |
907 | i->setText (5, tr (f6)); | 911 | i->setText (5, tr (f6)); |
908 | } | 912 | } |
909 | 913 | ||
910 | delete dialog; | 914 | delete dialog; |
911 | } | 915 | } |
912 | } | 916 | } |
913 | 917 | ||
914 | void ZSafe::findPwd() | 918 | void ZSafe::findPwd() |
915 | { | 919 | { |
916 | 920 | ||
917 | // open the 'Search' dialog | 921 | // open the 'Search' dialog |
918 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); | 922 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); |
919 | #ifdef Q_WS_WIN | 923 | #ifdef Q_WS_WIN |
920 | dialog->setCaption ("Qt " + tr("Search")); | 924 | dialog->setCaption ("Qt " + tr("Search")); |
921 | #endif | 925 | #endif |
922 | 926 | ||
923 | #ifdef DESKTOP | 927 | #ifdef DESKTOP |
924 | #endif | 928 | #endif |
925 | if (lastSearchedName) | 929 | if (lastSearchedName) |
926 | dialog->NameField->setText(lastSearchedName); | 930 | dialog->NameField->setText(lastSearchedName); |
927 | else | 931 | else |
928 | dialog->NameField->setText(""); | 932 | dialog->NameField->setText(""); |
929 | if (lastSearchedUsername) | 933 | if (lastSearchedUsername) |
930 | dialog->UsernameField->setText(lastSearchedUsername); | 934 | dialog->UsernameField->setText(lastSearchedUsername); |
931 | else | 935 | else |
932 | dialog->UsernameField->setText(""); | 936 | dialog->UsernameField->setText(""); |
933 | if (lastSearchedComment) | 937 | if (lastSearchedComment) |
934 | dialog->CommentField->setText(lastSearchedComment); | 938 | dialog->CommentField->setText(lastSearchedComment); |
935 | else | 939 | else |
936 | dialog->CommentField->setText(""); | 940 | dialog->CommentField->setText(""); |
937 | DialogCode result = (DialogCode) dialog->exec(); | 941 | DialogCode result = (DialogCode) dialog->exec(); |
938 | #ifdef DESKTOP | 942 | #ifdef DESKTOP |
939 | result = Accepted; | 943 | result = Accepted; |
940 | #endif | 944 | #endif |
941 | 945 | ||
942 | QString name; | 946 | QString name; |
943 | QString username; | 947 | QString username; |
944 | QString comment; | 948 | QString comment; |
945 | if (result == Accepted) | 949 | if (result == Accepted) |
946 | { | 950 | { |
947 | name = dialog->NameField->text(); | 951 | name = dialog->NameField->text(); |
948 | username = dialog->UsernameField->text(); | 952 | username = dialog->UsernameField->text(); |
949 | comment = dialog->CommentField->text(); | 953 | comment = dialog->CommentField->text(); |
950 | #ifndef NO_OPIE | 954 | #ifndef NO_OPIE |
951 | owarn << name << oendl; | 955 | owarn << name << oendl; |
952 | #else | 956 | #else |
953 | qWarning (name); | 957 | qWarning (name); |
954 | #endif | 958 | #endif |
955 | } | 959 | } |
956 | else | 960 | else |
957 | { | 961 | { |
958 | delete dialog; | 962 | delete dialog; |
959 | return; | 963 | return; |
960 | } | 964 | } |
961 | 965 | ||
962 | if (!name.isEmpty() && name != lastSearchedName || | 966 | if (!name.isEmpty() && name != lastSearchedName || |
963 | lastSearchedName.isEmpty() && !name.isEmpty()) | 967 | lastSearchedName.isEmpty() && !name.isEmpty()) |
964 | { | 968 | { |
965 | // set search at the beginning if a new name is given | 969 | // set search at the beginning if a new name is given |
966 | lastSearchedCategory = NULL; | 970 | lastSearchedCategory = NULL; |
967 | lastSearchedItem = NULL; | 971 | lastSearchedItem = NULL; |
968 | } | 972 | } |
969 | lastSearchedName = name; | 973 | lastSearchedName = name; |
970 | if (!username.isEmpty() && username != lastSearchedUsername || | 974 | if (!username.isEmpty() && username != lastSearchedUsername || |
971 | lastSearchedUsername.isEmpty() && !username.isEmpty()) | 975 | lastSearchedUsername.isEmpty() && !username.isEmpty()) |
972 | { | 976 | { |
973 | // set search at the beginning if a new name is given | 977 | // set search at the beginning if a new name is given |
974 | lastSearchedCategory = NULL; | 978 | lastSearchedCategory = NULL; |
975 | lastSearchedItem = NULL; | 979 | lastSearchedItem = NULL; |
976 | } | 980 | } |
977 | lastSearchedUsername = username; | 981 | lastSearchedUsername = username; |
978 | if (!comment.isEmpty() && comment != lastSearchedComment || | 982 | if (!comment.isEmpty() && comment != lastSearchedComment || |
979 | lastSearchedComment.isEmpty() && !comment.isEmpty()) | 983 | lastSearchedComment.isEmpty() && !comment.isEmpty()) |
980 | { | 984 | { |
981 | // set search at the beginning if a new name is given | 985 | // set search at the beginning if a new name is given |
982 | lastSearchedCategory = NULL; | 986 | lastSearchedCategory = NULL; |
983 | lastSearchedItem = NULL; | 987 | lastSearchedItem = NULL; |
984 | } | 988 | } |
985 | lastSearchedComment = comment; | 989 | lastSearchedComment = comment; |
986 | 990 | ||
987 | ListView->clearSelection(); | 991 | ListView->clearSelection(); |
988 | 992 | ||
989 | bool found=FALSE; | 993 | bool found=FALSE; |
990 | // step through all categories | 994 | // step through all categories |
991 | QListViewItem *i; | 995 | QListViewItem *i; |
992 | if (lastSearchedCategory) | 996 | if (lastSearchedCategory) |
993 | i = lastSearchedCategory; | 997 | i = lastSearchedCategory; |
994 | else | 998 | else |
995 | i = ListView->firstChild(); | 999 | i = ListView->firstChild(); |
996 | for (; | 1000 | for (; |
997 | i != NULL; | 1001 | i != NULL; |
998 | i = i->nextSibling()) | 1002 | i = i->nextSibling()) |
999 | { | 1003 | { |
1000 | #ifndef NO_OPIE | 1004 | #ifndef NO_OPIE |
1001 | owarn << i->text(0) << oendl; | 1005 | owarn << i->text(0) << oendl; |
1002 | #endif | 1006 | #endif |
1003 | i->setSelected(FALSE); | 1007 | i->setSelected(FALSE); |
1004 | 1008 | ||
1005 | // step through all subitems | 1009 | // step through all subitems |
1006 | QListViewItem *si; | 1010 | QListViewItem *si; |
1007 | if (lastSearchedItem) | 1011 | if (lastSearchedItem) |
1008 | si = lastSearchedItem; | 1012 | si = lastSearchedItem; |
1009 | else | 1013 | else |
1010 | si = i->firstChild(); | 1014 | si = i->firstChild(); |
1011 | // for (si = i->firstChild(); | 1015 | // for (si = i->firstChild(); |
1012 | for (; | 1016 | for (; |
1013 | si != NULL; | 1017 | si != NULL; |
1014 | si = si->nextSibling()) | 1018 | si = si->nextSibling()) |
1015 | { | 1019 | { |
1016 | #ifndef NO_OPIE | 1020 | #ifndef NO_OPIE |
1017 | owarn << si->text(0) << oendl; | 1021 | owarn << si->text(0) << oendl; |
1018 | #else | 1022 | #else |
1019 | qWarning (si->text(0)); | 1023 | qWarning (si->text(0)); |
1020 | #endif | 1024 | #endif |
1021 | if (si->isSelected()) | 1025 | if (si->isSelected()) |
1022 | si->setSelected(FALSE); | 1026 | si->setSelected(FALSE); |
1023 | // ListView->repaintItem(si); | 1027 | // ListView->repaintItem(si); |
1024 | 1028 | ||
1025 | bool n=TRUE; | 1029 | bool n=TRUE; |
1026 | bool u=TRUE; | 1030 | bool u=TRUE; |
1027 | bool c=TRUE; | 1031 | bool c=TRUE; |
1028 | if (!name.isEmpty()) | 1032 | if (!name.isEmpty()) |
1029 | n = (si->text(0)).contains (name, FALSE); | 1033 | n = (si->text(0)).contains (name, FALSE); |
1030 | if (!username.isEmpty()) | 1034 | if (!username.isEmpty()) |
1031 | u = (si->text(1)).contains (username, FALSE); | 1035 | u = (si->text(1)).contains (username, FALSE); |
1032 | if (!comment.isEmpty()) | 1036 | if (!comment.isEmpty()) |
1033 | c = (si->text(3)).contains (comment, FALSE); | 1037 | c = (si->text(3)).contains (comment, FALSE); |
1034 | 1038 | ||
1035 | if ((n && u && c ) && !found) | 1039 | if ((n && u && c ) && !found) |
1036 | { | 1040 | { |
1037 | #ifndef NO_OPIE | 1041 | #ifndef NO_OPIE |
1038 | owarn << "Found" << oendl; | 1042 | owarn << "Found" << oendl; |
1039 | #else | 1043 | #else |
1040 | qWarning ("Found"); | 1044 | qWarning ("Found"); |
1041 | #endif | 1045 | #endif |
1042 | selectedItem = si; | 1046 | selectedItem = si; |
1043 | si->setSelected(TRUE); | 1047 | si->setSelected(TRUE); |
1044 | ListView->setCurrentItem(si); | 1048 | ListView->setCurrentItem(si); |
1045 | ListView->ensureItemVisible(si); | 1049 | ListView->ensureItemVisible(si); |
1046 | ListView->triggerUpdate(); | 1050 | ListView->triggerUpdate(); |
1047 | 1051 | ||
1048 | lastSearchedCategory = i; | 1052 | lastSearchedCategory = i; |
1049 | // set to the next item | 1053 | // set to the next item |
1050 | lastSearchedItem = si->nextSibling(); | 1054 | lastSearchedItem = si->nextSibling(); |
1051 | if (!lastSearchedItem) | 1055 | if (!lastSearchedItem) |
1052 | { | 1056 | { |
1053 | // no next item within category -> set next category | 1057 | // no next item within category -> set next category |
1054 | lastSearchedCategory = i->nextSibling(); | 1058 | lastSearchedCategory = i->nextSibling(); |
1055 | if (!lastSearchedCategory) | 1059 | if (!lastSearchedCategory) |
1056 | lastSearchedItem = NULL; // END | 1060 | lastSearchedItem = NULL; // END |
1057 | } | 1061 | } |
1058 | 1062 | ||
1059 | found = TRUE; | 1063 | found = TRUE; |
1060 | delete dialog; | 1064 | delete dialog; |
1061 | update(); | 1065 | update(); |
1062 | return; | 1066 | return; |
1063 | } | 1067 | } |
1064 | } | 1068 | } |
1065 | lastSearchedCategory = i->nextSibling(); | 1069 | lastSearchedCategory = i->nextSibling(); |
1066 | lastSearchedItem = NULL; | 1070 | lastSearchedItem = NULL; |
1067 | } | 1071 | } |
1068 | lastSearchedCategory = NULL; | 1072 | lastSearchedCategory = NULL; |
1069 | lastSearchedItem = NULL; | 1073 | lastSearchedItem = NULL; |
1070 | delete dialog; | 1074 | delete dialog; |
1071 | update(); | 1075 | update(); |
1072 | QMessageBox::information( this, tr("ZSafe"), | 1076 | QMessageBox::information( this, tr("ZSafe"), |
1073 | tr("Entry not found"), tr("&OK"), 0); | 1077 | tr("Entry not found"), tr("&OK"), 0); |
1074 | 1078 | ||
1075 | } | 1079 | } |
1076 | 1080 | ||
1077 | QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) | 1081 | QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) |
1078 | { | 1082 | { |
1079 | QString category; | 1083 | QString category; |
1080 | if (_item) | 1084 | if (_item) |
1081 | { | 1085 | { |
1082 | if (isCategory(_item)) | 1086 | if (isCategory(_item)) |
1083 | { | 1087 | { |
1084 | category = _item->text(0); | 1088 | category = _item->text(0); |
1085 | } | 1089 | } |
1086 | else | 1090 | else |
1087 | { | 1091 | { |
1088 | QListViewItem *cat = _item->parent(); | 1092 | QListViewItem *cat = _item->parent(); |
1089 | category = cat->text(0); | 1093 | category = cat->text(0); |
1090 | } | 1094 | } |
1091 | } | 1095 | } |
1092 | else | 1096 | else |
1093 | { | 1097 | { |
1094 | return def; | 1098 | return def; |
1095 | } | 1099 | } |
1096 | 1100 | ||
1097 | QString app_key = APP_KEY; | 1101 | QString app_key = APP_KEY; |
1098 | #ifndef DESKTOP | 1102 | #ifndef DESKTOP |
1099 | #ifndef Q_WS_WIN | 1103 | #ifndef Q_WS_WIN |
1100 | conf->setGroup ("fieldDefs"); | 1104 | conf->setGroup ("fieldDefs"); |
1101 | #endif | 1105 | #endif |
1102 | #else | 1106 | #else |
1103 | #ifndef Q_WS_WIN | 1107 | #ifndef Q_WS_WIN |
1104 | app_key += "/fieldDefs/"; | 1108 | app_key += "/fieldDefs/"; |
1105 | #endif | 1109 | #endif |
1106 | #endif | 1110 | #endif |
1107 | // #ifndef Q_WS_WIN | 1111 | // #ifndef Q_WS_WIN |
1108 | QString label = conf->readEntry(app_key+category+"-field"+field,def); | 1112 | QString label = conf->readEntry(app_key+category+"-field"+field,def); |
1109 | // #else | 1113 | // #else |
1110 | // QString label(def); | 1114 | // QString label(def); |
1111 | // #endif | 1115 | // #endif |
1112 | 1116 | ||
1113 | #ifndef DESKTOP | 1117 | #ifndef DESKTOP |
1114 | conf->setGroup ("zsafe"); | 1118 | conf->setGroup ("zsafe"); |
1115 | #endif | 1119 | #endif |
1116 | return label; | 1120 | return label; |
1117 | } | 1121 | } |
1118 | 1122 | ||
1119 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) | 1123 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) |
1120 | { | 1124 | { |
1121 | QString app_key = APP_KEY; | 1125 | QString app_key = APP_KEY; |
1122 | #ifndef DESKTOP | 1126 | #ifndef DESKTOP |
1123 | conf->setGroup ("fieldDefs"); | 1127 | conf->setGroup ("fieldDefs"); |
1124 | #else | 1128 | #else |
1125 | #ifndef Q_WS_WIN | 1129 | #ifndef Q_WS_WIN |
1126 | app_key += "/fieldDefs/"; | 1130 | app_key += "/fieldDefs/"; |
1127 | #endif | 1131 | #endif |
1128 | #endif | 1132 | #endif |
1129 | // #ifndef Q_WS_WIN | 1133 | // #ifndef Q_WS_WIN |
1130 | QString label = conf->readEntry(app_key+category+"-field"+field, | 1134 | QString label = conf->readEntry(app_key+category+"-field"+field, |
1131 | def); | 1135 | def); |
1132 | // #else | 1136 | // #else |
1133 | // QString label(def); | 1137 | // QString label(def); |
1134 | // #endif | 1138 | // #endif |
1135 | #ifndef DESKTOP | 1139 | #ifndef DESKTOP |
1136 | conf->setGroup ("zsafe"); | 1140 | conf->setGroup ("zsafe"); |
1137 | #endif | 1141 | #endif |
1138 | return label; | 1142 | return label; |
1139 | } | 1143 | } |
1140 | 1144 | ||
1141 | void ZSafe::showInfo( QListViewItem *_item) | 1145 | void ZSafe::showInfo( QListViewItem *_item) |
1142 | { | 1146 | { |
1143 | if (!_item) | 1147 | if (!_item) |
1144 | return; | 1148 | return; |
1145 | if (selectedItem != NULL) | 1149 | if (selectedItem != NULL) |
1146 | selectedItem->setSelected(FALSE); | 1150 | selectedItem->setSelected(FALSE); |
1147 | 1151 | ||
1148 | selectedItem = _item; | 1152 | selectedItem = _item; |
1149 | selectedItem->setSelected(TRUE); | 1153 | selectedItem->setSelected(TRUE); |
1150 | 1154 | ||
1151 | if (!isCategory(_item)) | 1155 | if (!isCategory(_item)) |
1152 | { | 1156 | { |
1153 | /* | 1157 | /* |
1154 | QString label=selectedItem->text(0); | 1158 | QString label=selectedItem->text(0); |
1155 | label+="\n"; | 1159 | label+="\n"; |
1156 | label+=selectedItem->text(1); | 1160 | label+=selectedItem->text(1); |
1157 | label+="\n"; | 1161 | label+="\n"; |
1158 | label+=selectedItem->text(2); | 1162 | label+=selectedItem->text(2); |
1159 | label+="\n"; | 1163 | label+="\n"; |
1160 | label+=selectedItem->text(3); | 1164 | label+=selectedItem->text(3); |
1161 | */ | 1165 | */ |
1162 | 1166 | ||
1163 | QString text; | 1167 | QString text; |
1164 | QString entry; | 1168 | QString entry; |
1165 | 1169 | ||
1166 | text = "<html><body><div align=""center""><u><b>"; | 1170 | text = "<html><body><div align=""center""><u><b>"; |
1167 | text += selectedItem->text(0); | 1171 | text += selectedItem->text(0); |
1168 | text += "</b></u><br></div><br>"; | 1172 | text += "</b></u><br></div><br>"; |
1169 | 1173 | ||
1170 | entry = selectedItem->text(1); | 1174 | entry = selectedItem->text(1); |
1171 | if (!entry.isEmpty() && entry.compare(" ")) | 1175 | if (!entry.isEmpty() && entry.compare(" ")) |
1172 | { | 1176 | { |
1173 | text += "<u><b>"; | 1177 | text += "<u><b>"; |
1174 | text += getFieldLabel (selectedItem, "2", tr("Username")); | 1178 | text += getFieldLabel (selectedItem, "2", tr("Username")); |
1175 | text += ":<br></b></u><blockquote>"; | 1179 | text += ":<br></b></u><blockquote>"; |
1176 | text += entry; | 1180 | text += entry; |
1177 | text += "</blockquote>"; | 1181 | text += "</blockquote>"; |
1178 | // text += "<br>"; | 1182 | // text += "<br>"; |
1179 | } | 1183 | } |
1180 | 1184 | ||
1181 | entry = selectedItem->text(2); | 1185 | entry = selectedItem->text(2); |
1182 | if (!entry.isEmpty() && entry.compare(" ")) | 1186 | if (!entry.isEmpty() && entry.compare(" ")) |
1183 | { | 1187 | { |
1184 | text += "<u><b>"; | 1188 | text += "<u><b>"; |
1185 | text += getFieldLabel (selectedItem, "3", tr("Password")); | 1189 | text += getFieldLabel (selectedItem, "3", tr("Password")); |
1186 | text += ":<br> </b></u><blockquote>"; | 1190 | text += ":<br> </b></u><blockquote>"; |
1187 | text += entry; | 1191 | text += entry; |
1188 | text += "</blockquote>"; | 1192 | text += "</blockquote>"; |
1189 | // text += "<br>"; | 1193 | // text += "<br>"; |
1190 | } | 1194 | } |
1191 | 1195 | ||
1192 | entry = selectedItem->text(4); | 1196 | entry = selectedItem->text(4); |
1193 | if (!entry.isEmpty() && entry.compare(" ")) | 1197 | if (!entry.isEmpty() && entry.compare(" ")) |
1194 | { | 1198 | { |
1195 | text += "<u><b>"; | 1199 | text += "<u><b>"; |
1196 | text += getFieldLabel (selectedItem, "5", tr("Field 4")); | 1200 | text += getFieldLabel (selectedItem, "5", tr("Field 4")); |
1197 | text += ":<br> </b></u><blockquote>"; | 1201 | text += ":<br> </b></u><blockquote>"; |
1198 | text += entry; | 1202 | text += entry; |
1199 | text += "</blockquote>"; | 1203 | text += "</blockquote>"; |
1200 | // text += "<br>"; | 1204 | // text += "<br>"; |
1201 | } | 1205 | } |
1202 | 1206 | ||
1203 | entry = selectedItem->text(5); | 1207 | entry = selectedItem->text(5); |
1204 | if (!entry.isEmpty() && entry.compare(" ")) | 1208 | if (!entry.isEmpty() && entry.compare(" ")) |
1205 | { | 1209 | { |
1206 | text += "<u><b>"; | 1210 | text += "<u><b>"; |
1207 | text += getFieldLabel (selectedItem, "6", tr("Field 5")); | 1211 | text += getFieldLabel (selectedItem, "6", tr("Field 5")); |
1208 | text += ":<br> </b></u><blockquote>"; | 1212 | text += ":<br> </b></u><blockquote>"; |
1209 | text += entry; | 1213 | text += entry; |
1210 | text += "</blockquote>"; | 1214 | text += "</blockquote>"; |
1211 | // text += "<br>"; | 1215 | // text += "<br>"; |
1212 | } | 1216 | } |
1213 | 1217 | ||
1214 | entry = selectedItem->text(3); | 1218 | entry = selectedItem->text(3); |
1215 | if (!entry.isEmpty() && entry.compare(" ")) | 1219 | if (!entry.isEmpty() && entry.compare(" ")) |
1216 | { | 1220 | { |
1217 | text += "<u><b>"; | 1221 | text += "<u><b>"; |
1218 | text += getFieldLabel (selectedItem, "4", tr("Comment")); | 1222 | text += getFieldLabel (selectedItem, "4", tr("Comment")); |
1219 | text += ":<br> </b></u>"; | 1223 | text += ":<br> </b></u>"; |
1220 | QString comment = selectedItem->text(3); | 1224 | QString comment = selectedItem->text(3); |
1221 | comment.replace (QRegExp("\n"), "<br>"); | 1225 | comment.replace (QRegExp("\n"), "<br>"); |
1222 | text += comment; | 1226 | text += comment; |
1223 | // text += "<br>"; | 1227 | // text += "<br>"; |
1224 | } | 1228 | } |
1225 | 1229 | ||