author | zecke <zecke> | 2004-11-15 17:08:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-15 17:08:58 (UTC) |
commit | 6d7b1a9a5f32a0b69c5ee9cc963e8a43a76327cf (patch) (unidiff) | |
tree | 45e30376ec8035174fc5fd9154ed35b4d405d5ed /noncore/apps/zsafe | |
parent | 97fb9b69240d0daa5222fa9264587cde8b25c117 (diff) | |
download | opie-6d7b1a9a5f32a0b69c5ee9cc963e8a43a76327cf.zip opie-6d7b1a9a5f32a0b69c5ee9cc963e8a43a76327cf.tar.gz opie-6d7b1a9a5f32a0b69c5ee9cc963e8a43a76327cf.tar.bz2 |
Remove many many many #ifdefs
"I always knew it would come like this"
-Make it a QWidget instead of a QDialog
-Introduce appName
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 671 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.h | 10 |
2 files changed, 62 insertions, 619 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 1ae3b15..2b182f9 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -1,83 +1,57 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** | 2 | ** |
3 | ** Created: Sat Apr 6 17:57:45 2002 | 3 | ** Created: Sat Apr 6 17:57:45 2002 |
4 | ** | 4 | ** |
5 | ** Author: Carsten Schneider <CarstenSchneider@t-online.de> | 5 | ** Author: Carsten Schneider <CarstenSchneider@t-online.de> |
6 | ** | 6 | ** |
7 | ** $Id$ | 7 | ** $Id$ |
8 | ** | 8 | ** |
9 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html | 9 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html |
10 | ** | 10 | ** |
11 | ** Compile Flags: | ||
12 | ** Zaurus arm : -DNO_OPIE | ||
13 | ** Zaurus Opie arm: none | ||
14 | ** Linux Desktop : -DDESKTOP -DNO_OPIE | ||
15 | ** Windows Desktop: -DDESKTOP -DNO_OPIE | ||
16 | ** use qmake | ||
17 | ** for japanese version additional use: -DJPATCH_HDE | ||
18 | ** | 11 | ** |
19 | ****************************************************************************/ | 12 | ****************************************************************************/ |
20 | #include "zsafe.h" | 13 | #include "zsafe.h" |
21 | #include "newdialog.h" | 14 | #include "newdialog.h" |
22 | #include "searchdialog.h" | 15 | #include "searchdialog.h" |
23 | #include "categorydialog.h" | 16 | #include "categorydialog.h" |
24 | #include "passworddialog.h" | 17 | #include "passworddialog.h" |
25 | #include "infoform.h" | 18 | #include "infoform.h" |
26 | #include "zlistview.h" | 19 | #include "zlistview.h" |
27 | #include "shadedlistitem.h" | 20 | #include "shadedlistitem.h" |
28 | 21 | ||
29 | #ifndef DESKTOP | ||
30 | #ifndef NO_OPIE | ||
31 | #include <opie2/ofiledialog.h> | 22 | #include <opie2/ofiledialog.h> |
32 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
33 | using namespace Opie::Core; | 24 | using namespace Opie::Core; |
34 | using namespace Opie::Ui; | 25 | using namespace Opie::Ui; |
35 | #else | ||
36 | #include "scqtfileedit.h" | ||
37 | #endif | ||
38 | #endif | ||
39 | 26 | ||
40 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
41 | 28 | ||
42 | #include <sys/types.h> | 29 | #include <sys/types.h> |
43 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
44 | #include <fcntl.h> | 31 | #include <fcntl.h> |
45 | #include <stdlib.h> | 32 | #include <stdlib.h> |
46 | #ifndef Q_WS_WIN | ||
47 | #include <unistd.h> | 33 | #include <unistd.h> |
48 | #endif | ||
49 | #include <string.h> | 34 | #include <string.h> |
50 | #include <errno.h> | 35 | #include <errno.h> |
51 | 36 | ||
52 | #include <qmenubar.h> | 37 | #include <qmenubar.h> |
53 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
54 | 39 | ||
55 | #ifdef DESKTOP | ||
56 | #include <qfiledialog.h> | ||
57 | #include <qdragobject.h> | ||
58 | #ifndef Q_WS_WIN | ||
59 | #include <qsettings.h> | ||
60 | #else | ||
61 | #include "qsettings.h" | ||
62 | #endif | ||
63 | #include <qapplication.h> | ||
64 | #else | ||
65 | #include <qfile.h> | 40 | #include <qfile.h> |
66 | #include <qpe/fileselector.h> | 41 | #include <qpe/fileselector.h> |
67 | #include <qpe/global.h> | 42 | #include <qpe/global.h> |
68 | #include <qpe/qpeapplication.h> | 43 | #include <qpe/qpeapplication.h> |
69 | #include <qpe/resource.h> | 44 | #include <qpe/resource.h> |
70 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
71 | #endif | ||
72 | 46 | ||
73 | #include <qtimer.h> | 47 | #include <qtimer.h> |
74 | #include <qlayout.h> | 48 | #include <qlayout.h> |
75 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
76 | #include <qfile.h> | 50 | #include <qfile.h> |
77 | #include <qtextstream.h> | 51 | #include <qtextstream.h> |
78 | #include <qheader.h> | 52 | #include <qheader.h> |
79 | #include <qlistview.h> | 53 | #include <qlistview.h> |
80 | #include <qtoolbutton.h> | 54 | #include <qtoolbutton.h> |
81 | #include <qvariant.h> | 55 | #include <qvariant.h> |
82 | #include <qtooltip.h> | 56 | #include <qtooltip.h> |
83 | #include <qwhatsthis.h> | 57 | #include <qwhatsthis.h> |
@@ -86,45 +60,29 @@ using namespace Opie::Ui; | |||
86 | #include <qlineedit.h> | 60 | #include <qlineedit.h> |
87 | #include <qmultilineedit.h> | 61 | #include <qmultilineedit.h> |
88 | #include <qregexp.h> | 62 | #include <qregexp.h> |
89 | #include <qdir.h> | 63 | #include <qdir.h> |
90 | #include <qtextbrowser.h> | 64 | #include <qtextbrowser.h> |
91 | #include <qlabel.h> | 65 | #include <qlabel.h> |
92 | #include <qcombobox.h> | 66 | #include <qcombobox.h> |
93 | 67 | ||
94 | #include "krc2.h" | 68 | #include "krc2.h" |
95 | 69 | ||
96 | #include "wait.h" | 70 | #include "wait.h" |
97 | 71 | ||
98 | extern int DeskW, DeskH; | 72 | int DeskW, DeskH; |
99 | #ifdef DESKTOP | 73 | QApplication *appl; |
100 | extern QApplication *appl; | 74 | ZSafe *zs; |
101 | #else | ||
102 | extern QPEApplication *appl; | ||
103 | #endif | ||
104 | |||
105 | #ifdef JPATCH_HDE | ||
106 | #define tr(arg) arg | ||
107 | #endif | ||
108 | |||
109 | 75 | ||
110 | #ifdef DESKTOP | ||
111 | #ifndef Q_WS_WIN | ||
112 | const QString APP_KEY="/.zsafe/"; | ||
113 | #else | ||
114 | const QString APP_KEY=""; | ||
115 | #endif | ||
116 | #else | ||
117 | const QString APP_KEY=""; | 76 | const QString APP_KEY=""; |
118 | #endif | ||
119 | 77 | ||
120 | // include xmp images | 78 | // include xmp images |
121 | #include "pics/zsafe/copy.xpm" | 79 | #include "pics/zsafe/copy.xpm" |
122 | #include "pics/zsafe/cut.xpm" | 80 | #include "pics/zsafe/cut.xpm" |
123 | #include "pics/zsafe/edit.xpm" | 81 | #include "pics/zsafe/edit.xpm" |
124 | #include "pics/zsafe/editdelete.xpm" | 82 | #include "pics/zsafe/editdelete.xpm" |
125 | #include "pics/zsafe/find.xpm" | 83 | #include "pics/zsafe/find.xpm" |
126 | #include "pics/zsafe/folder_open.xpm" | 84 | #include "pics/zsafe/folder_open.xpm" |
127 | #include "pics/zsafe/help_icon.xpm" | 85 | #include "pics/zsafe/help_icon.xpm" |
128 | #include "pics/zsafe/new.xpm" | 86 | #include "pics/zsafe/new.xpm" |
129 | #include "pics/zsafe/paste.xpm" | 87 | #include "pics/zsafe/paste.xpm" |
130 | #include "pics/zsafe/quit_icon.xpm" | 88 | #include "pics/zsafe/quit_icon.xpm" |
@@ -355,243 +313,161 @@ static const char* const general_data[] = { | |||
355 | 313 | ||
356 | exit (ec); | 314 | exit (ec); |
357 | } | 315 | } |
358 | 316 | ||
359 | 317 | ||
360 | // save the configuration into the file | 318 | // save the configuration into the file |
361 | void ZSafe::saveConf () | 319 | void ZSafe::saveConf () |
362 | { | 320 | { |
363 | if (conf) | 321 | if (conf) |
364 | { | 322 | { |
365 | delete conf; | 323 | delete conf; |
366 | 324 | ||
367 | #ifdef DESKTOP | 325 | conf = new Config ("zsafe"); |
368 | #ifndef Q_WS_WIN | 326 | conf->setGroup ("zsafe"); |
369 | conf = new QSettings(); | ||
370 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | ||
371 | #else | ||
372 | conf = new QSettings (cfgFile); | ||
373 | conf->insertSearchPath (QSettings::Unix, cfgFile); | ||
374 | #endif | ||
375 | #else | ||
376 | conf = new Config (cfgFile, Config::File); | ||
377 | conf->setGroup ("zsafePrefs"); | ||
378 | #endif | ||
379 | } | 327 | } |
380 | } | 328 | } |
381 | 329 | ||
382 | 330 | ||
383 | /* | 331 | /* |
384 | * Constructs a ZSafe which is a child of 'parent', with the | 332 | * Constructs a ZSafe which is a child of 'parent', with the |
385 | * name 'name' and widget flags set to 'f' | 333 | * name 'name' and widget flags set to 'f' |
386 | * | 334 | * |
387 | * The dialog will by default be modeless, unless you set 'modal' to | 335 | * The dialog will by default be modeless, unless you set 'modal' to |
388 | * TRUE to construct a modal dialog. | 336 | * TRUE to construct a modal dialog. |
389 | */ | 337 | */ |
390 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | 338 | ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) |
391 | : QDialog( parent, name, modal, fl ), | 339 | : QWidget( parent, name, fl), |
392 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) | 340 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) |
393 | { | 341 | { |
342 | zs = this; | ||
343 | appl = qApp; | ||
344 | DeskW = qApp->desktop()->width(); | ||
345 | DeskH = qApp->desktop()->height(); | ||
346 | |||
394 | IsCut = false; | 347 | IsCut = false; |
395 | IsCopy = false; | 348 | IsCopy = false; |
396 | modified = false; | 349 | modified = false; |
397 | showpwd = false; | 350 | showpwd = false; |
398 | 351 | ||
399 | // set the config file | 352 | // set the config file |
400 | cfgFile=QDir::homeDirPath(); | 353 | cfgFile=QDir::homeDirPath(); |
401 | cfgFile += "/.zsafe.cfg"; | 354 | cfgFile += "/.zsafe.cfg"; |
402 | // set the icon path | 355 | // set the icon path |
403 | #ifdef NO_OPIE | ||
404 | QString qpedir ((const char *)getenv("QPEDIR")); | ||
405 | #else | ||
406 | QString qpedir ((const char *)getenv("OPIEDIR")); | ||
407 | #endif | ||
408 | 356 | ||
409 | #ifdef DESKTOP | 357 | QString qpeDir = QPEApplication::qpeDir(); |
410 | iconPath = QDir::homeDirPath() + "/pics/"; | ||
411 | #else | ||
412 | if (qpedir.isEmpty()) | ||
413 | iconPath = "/home/QtPalmtop/pics/"; | ||
414 | else | ||
415 | iconPath = qpedir + "/pics/"; | ||
416 | #endif | ||
417 | 358 | ||
418 | // create a zsafe configuration object | 359 | conf = new Config ("zsafe"); |
419 | #ifdef DESKTOP | ||
420 | #ifndef Q_WS_WIN | ||
421 | conf = new QSettings (); | ||
422 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | ||
423 | #else | ||
424 | conf = new QSettings (cfgFile); | ||
425 | conf->insertSearchPath (QSettings::Unix, cfgFile); | ||
426 | #endif | ||
427 | #else | ||
428 | conf = new Config (cfgFile, Config::File); | ||
429 | conf->setGroup ("zsafePrefs"); | 360 | conf->setGroup ("zsafePrefs"); |
430 | #endif | 361 | |
431 | #ifdef DESKTOP | ||
432 | // #ifndef Q_WS_WIN | ||
433 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); | ||
434 | // #endif | ||
435 | #else | ||
436 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); | 362 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); |
437 | #endif | ||
438 | #ifndef DESKTOP | ||
439 | conf->setGroup ("zsafe"); | 363 | conf->setGroup ("zsafe"); |
440 | #endif | ||
441 | 364 | ||
442 | QPixmap copy_img((const char**) copy_xpm); | 365 | QPixmap copy_img((const char**) copy_xpm); |
443 | QPixmap cut_img((const char**) cut_xpm); | 366 | QPixmap cut_img((const char**) cut_xpm); |
444 | QPixmap edit_img((const char**) edit_xpm); | 367 | QPixmap edit_img((const char**) edit_xpm); |
445 | QPixmap editdelete_img((const char**) editdelete_xpm); | 368 | QPixmap editdelete_img((const char**) editdelete_xpm); |
446 | QPixmap find_img((const char**) find_xpm); | 369 | QPixmap find_img((const char**) find_xpm); |
447 | QPixmap folder_open_img((const char**) folder_open_xpm); | 370 | QPixmap folder_open_img((const char**) folder_open_xpm); |
448 | QPixmap help_icon_img((const char**) help_icon_xpm); | 371 | QPixmap help_icon_img((const char**) help_icon_xpm); |
449 | QPixmap new_img((const char**) new_xpm); | 372 | QPixmap new_img((const char**) new_xpm); |
450 | QPixmap paste_img((const char**) paste_xpm); | 373 | QPixmap paste_img((const char**) paste_xpm); |
451 | QPixmap quit_icon_img((const char**) quit_icon_xpm); | 374 | QPixmap quit_icon_img((const char**) quit_icon_xpm); |
452 | QPixmap save_img((const char**) save_xpm); | 375 | QPixmap save_img((const char**) save_xpm); |
453 | QPixmap trash_img((const char**) trash_xpm); | 376 | QPixmap trash_img((const char**) trash_xpm); |
454 | QPixmap expand_img((const char**) expand_xpm); | 377 | QPixmap expand_img((const char**) expand_xpm); |
455 | QPixmap export_img((const char**) export_xpm); | 378 | QPixmap export_img((const char**) export_xpm); |
456 | QPixmap import_img((const char**) import_xpm); | 379 | QPixmap import_img((const char**) import_xpm); |
457 | 380 | ||
458 | QPixmap bank_cards( ( const char** ) bank_cards_data ); | 381 | QPixmap bank_cards( ( const char** ) bank_cards_data ); |
459 | QPixmap passwords( ( const char** ) passwords_data ); | 382 | QPixmap passwords( ( const char** ) passwords_data ); |
460 | QPixmap software( ( const char** ) software_data ); | 383 | QPixmap software( ( const char** ) software_data ); |
461 | QPixmap general( ( const char** ) general_data ); | 384 | QPixmap general( ( const char** ) general_data ); |
462 | QPixmap image0( ( const char** ) zsafe_xpm ); | 385 | QPixmap image0( ( const char** ) zsafe_xpm ); |
386 | |||
463 | if ( !name ) | 387 | if ( !name ) |
464 | setName( "ZSafe" ); | 388 | setName( "ZSafe" ); |
465 | 389 | ||
466 | #ifdef DESKTOP | ||
467 | #ifdef Q_WS_WIN | ||
468 | setGeometry(100, 150, DeskW, DeskH-30 ); | ||
469 | #else | ||
470 | resize( DeskW, DeskH-30 ); | ||
471 | #endif | ||
472 | |||
473 | #else | ||
474 | |||
475 | #ifdef JPATCH_HDE | ||
476 | int DeskS; | ||
477 | if(DeskW > DeskH) | ||
478 | { | ||
479 | DeskS = DeskW; | ||
480 | } | ||
481 | else | ||
482 | { | ||
483 | DeskS = DeskH; | ||
484 | } | ||
485 | resize( DeskW, DeskH ); | ||
486 | setMinimumSize( QSize( DeskS, DeskS ) ); | ||
487 | setMaximumSize( QSize( DeskS, DeskS ) ); | ||
488 | #else | ||
489 | resize( DeskW, DeskH-30 ); | ||
490 | #endif | ||
491 | |||
492 | #endif | ||
493 | setCaption( tr( "ZSafe" ) ); | 390 | setCaption( tr( "ZSafe" ) ); |
494 | QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; | 391 | QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; |
392 | |||
495 | filename = conf->readEntry(APP_KEY+"document"); | 393 | filename = conf->readEntry(APP_KEY+"document"); |
496 | if ( !QFileInfo(filename).exists() || !QDir(zsafeAppDirPath).exists() ) | 394 | if ( !QFileInfo(filename).exists() || !QDir(zsafeAppDirPath).exists() ) |
497 | { | 395 | { |
498 | // check if the directory application exists, if not | 396 | // check if the directory application exists, if not |
499 | // create it | 397 | // create it |
500 | // #ifndef Q_WS_WIN | ||
501 | // QString d1("Documents/application"); | ||
502 | // #else | ||
503 | QString d1(QDir::homeDirPath() + "/Documents/application"); | 398 | QString d1(QDir::homeDirPath() + "/Documents/application"); |
504 | // #endif | ||
505 | QDir pd1(d1); | 399 | QDir pd1(d1); |
506 | if (!pd1.exists()) | 400 | if (!pd1.exists()) |
507 | { | 401 | { |
508 | QDir pd2(QDir::homeDirPath() + "/Documents"); | 402 | QDir pd2(QDir::homeDirPath() + "/Documents"); |
509 | if (!pd2.exists()) { | 403 | if (!pd2.exists()) { |
510 | QDir pd3(QDir::homeDirPath()); | 404 | QDir pd3(QDir::homeDirPath()); |
511 | if (!pd3.mkdir("Documents", FALSE)) { | 405 | if (!pd3.mkdir("Documents", FALSE)) { |
512 | } | 406 | } |
513 | } | 407 | } |
514 | 408 | ||
515 | if (!pd2.mkdir("application", FALSE)) | 409 | if (!pd2.mkdir("application", FALSE)) |
516 | { | 410 | { |
517 | QMessageBox::critical( 0, tr("ZSafe"), | 411 | QMessageBox::critical( 0, tr("ZSafe"), |
518 | #ifdef JPATCH_HDE | ||
519 | tr("<P>Can't create directory ..."+d1+"</P><P>ZSafe will now exit.</P>")); | ||
520 | #else | ||
521 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1)); | 412 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1)); |
522 | #endif | ||
523 | exitZs (1); | 413 | exitZs (1); |
524 | } | 414 | } |
525 | } | 415 | } |
526 | // #ifndef Q_WS_WIN | ||
527 | // QString d2("Documents/application/zsafe"); | ||
528 | // #else | ||
529 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); | 416 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); |
530 | // #endif | ||
531 | QDir pd2(d2); | 417 | QDir pd2(d2); |
532 | if (!pd2.exists()) | 418 | if (!pd2.exists()) |
533 | { | 419 | { |
534 | if (!pd1.mkdir("zsafe", FALSE)) | 420 | if (!pd1.mkdir("zsafe", FALSE)) |
535 | { | 421 | { |
536 | QMessageBox::critical( 0, tr("ZSafe"), | 422 | QMessageBox::critical( 0, tr("ZSafe"), |
537 | #ifdef JPATCH_HDE | ||
538 | tr("<P>Can't create directory ...//Documents/application/zsafe</P><P>ZSafe will now exit.</P")); | ||
539 | #else | ||
540 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2)); | 423 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2)); |
541 | #endif | ||
542 | exitZs (1); | 424 | exitZs (1); |
543 | } | 425 | } |
544 | } | 426 | } |
545 | 427 | ||
546 | filename = zsafeAppDirPath + "/passwords.zsf"; | 428 | filename = zsafeAppDirPath + "/passwords.zsf"; |
547 | 429 | ||
548 | // save the current filename to the config file | 430 | // save the current filename to the config file |
549 | conf->writeEntry(APP_KEY+"document", filename); | 431 | conf->writeEntry(APP_KEY+"document", filename); |
550 | saveConf(); | 432 | saveConf(); |
551 | } | 433 | } |
552 | //if (filename == "INVALIDPWD") | 434 | //if (filename == "INVALIDPWD") |
553 | //filename = ""; | 435 | //filename = ""; |
554 | 436 | ||
555 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 437 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
556 | #ifdef Q_WS_WIN | 438 | this->setCaption(tr("ZSafe: ") + ti); |
557 | this->setCaption("Qt ZSafe: " + ti); | ||
558 | #else | ||
559 | this->setCaption("ZSafe: " + ti); | ||
560 | #endif | ||
561 | 439 | ||
562 | selectedItem = NULL; | 440 | selectedItem = NULL; |
563 | lastSearchedCategory = NULL; | 441 | lastSearchedCategory = NULL; |
564 | lastSearchedItem = NULL; | 442 | lastSearchedItem = NULL; |
565 | lastSearchedName = ""; | 443 | lastSearchedName = ""; |
566 | lastSearchedUsername = ""; | 444 | lastSearchedUsername = ""; |
567 | lastSearchedComment = ""; | 445 | lastSearchedComment = ""; |
568 | 446 | ||
569 | infoForm = new InfoForm(this, "show_info", TRUE); | 447 | infoForm = new InfoForm(this, "show_info", TRUE); |
570 | categoryDialog = NULL; | 448 | categoryDialog = NULL; |
571 | infoForm->setIcon( image0); | 449 | infoForm->setIcon( image0); |
572 | 450 | ||
573 | // add a menu bar | 451 | // add a menu bar |
574 | QMenuBar *menu = new QMenuBar( this ); | 452 | QMenuBar *menu = new QMenuBar( this ); |
575 | 453 | ||
576 | // add file menu | 454 | // add file menu |
577 | // QPopupMenu *file = new QPopupMenu( this ); | 455 | // QPopupMenu *file = new QPopupMenu( this ); |
578 | file = new QPopupMenu( this ); | 456 | file = new QPopupMenu( this ); |
579 | 457 | ||
580 | // #ifdef DESKTOP | ||
581 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); | 458 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); |
582 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); | 459 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); |
583 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); | 460 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); |
584 | file->insertSeparator(); | 461 | file->insertSeparator(); |
585 | // #endif | ||
586 | 462 | ||
587 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); | 463 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); |
588 | file->insertItem( save_img, tr("S&ave document with new Password"), this, | 464 | file->insertItem( save_img, tr("S&ave document with new Password"), this, |
589 | SLOT(saveDocumentWithPwd()) ); | 465 | SLOT(saveDocumentWithPwd()) ); |
590 | file->insertSeparator(); | 466 | file->insertSeparator(); |
591 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); | 467 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); |
592 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); | 468 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); |
593 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); | 469 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); |
594 | file->insertSeparator(); | 470 | file->insertSeparator(); |
595 | file->insertItem( expand_img, tr("&Open entries expanded"), this, | 471 | file->insertItem( expand_img, tr("&Open entries expanded"), this, |
596 | SLOT(setExpandFlag()), 0, 'o'); | 472 | SLOT(setExpandFlag()), 0, 'o'); |
597 | file->setItemChecked('o', expandTree); | 473 | file->setItemChecked('o', expandTree); |
@@ -656,74 +532,58 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
656 | h->addWidget (Find); | 532 | h->addWidget (Find); |
657 | */ | 533 | */ |
658 | 534 | ||
659 | ListView = new ZListView( this, "ListView" ); | 535 | ListView = new ZListView( this, "ListView" ); |
660 | ListView->addColumn( tr( "Name" ) ); | 536 | ListView->addColumn( tr( "Name" ) ); |
661 | ListView->addColumn( tr( "Field 2" ) ); | 537 | ListView->addColumn( tr( "Field 2" ) ); |
662 | ListView->addColumn( tr( "Field 3" ) ); | 538 | ListView->addColumn( tr( "Field 3" ) ); |
663 | ListView->addColumn( tr( "Comment" ) ); | 539 | ListView->addColumn( tr( "Comment" ) ); |
664 | ListView->addColumn( tr( "Field 4" ) ); | 540 | ListView->addColumn( tr( "Field 4" ) ); |
665 | ListView->addColumn( tr( "Field 5" ) ); | 541 | ListView->addColumn( tr( "Field 5" ) ); |
666 | ListView->setAllColumnsShowFocus(TRUE); | 542 | ListView->setAllColumnsShowFocus(TRUE); |
667 | 543 | ||
668 | #ifdef DESKTOP | ||
669 | // ListView->setResizePolicy(QScrollView::AutoOneFit); | ||
670 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); | ||
671 | #else | ||
672 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 544 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
673 | // ListView->setGeometry( QRect( 0, 22, | 545 | // ListView->setGeometry( QRect( 0, 22, |
674 | // this->width(), this->height() - 30 ) ); | 546 | // this->width(), this->height() - 30 ) ); |
675 | // ListView->setMaximumSize( QSize( 440, 290 ) ); | 547 | // ListView->setMaximumSize( QSize( 440, 290 ) ); |
676 | #endif | ||
677 | // ListView->setVScrollBarMode( QListView::Auto ); | 548 | // ListView->setVScrollBarMode( QListView::Auto ); |
678 | 549 | ||
679 | QBoxLayout * l = new QVBoxLayout( this ); | 550 | QBoxLayout * l = new QVBoxLayout( this ); |
680 | l->addWidget (menu); | 551 | l->addWidget (menu); |
681 | l->addWidget (ListView); | 552 | l->addWidget (ListView); |
682 | 553 | ||
683 | #ifndef DESKTOP | ||
684 | // start a timer (100 ms) to load the default document | 554 | // start a timer (100 ms) to load the default document |
685 | docuTimer.start( 100, true ); | 555 | docuTimer.start( 100, true ); |
686 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); | 556 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); |
687 | raiseFlag = true; | 557 | raiseFlag = true; |
688 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); | 558 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); |
689 | #else | ||
690 | // open the default document | ||
691 | openDocument(filename); | ||
692 | #endif | ||
693 | 559 | ||
694 | // signals and slots connections for QTollButton | 560 | // signals and slots connections for QTollButton |
695 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); | 561 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); |
696 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); | 562 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); |
697 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); | 563 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); |
698 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); | 564 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); |
699 | // signals and slots connections for QListView | 565 | // signals and slots connections for QListView |
700 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), | 566 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), |
701 | this, SLOT( listViewSelected(QListViewItem*) ) ); | 567 | this, SLOT( listViewSelected(QListViewItem*) ) ); |
702 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), | 568 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), |
703 | this, SLOT( showInfo(QListViewItem*) ) ); | 569 | this, SLOT( showInfo(QListViewItem*) ) ); |
704 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), | 570 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), |
705 | this, SLOT( showInfo(QListViewItem*) ) ); | 571 | this, SLOT( showInfo(QListViewItem*) ) ); |
706 | 572 | ||
707 | #ifndef DESKTOP | ||
708 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | 573 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
709 | #endif | ||
710 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 574 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
711 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 575 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
712 | 576 | ||
713 | this->setIcon( image0); | 577 | this->setIcon( image0); |
714 | #ifdef Q_WS_WIN | ||
715 | ListView->setSelected( ListView->firstChild() , true); | ||
716 | ListView->setSelected( ListView->firstChild() , false); | ||
717 | #endif | ||
718 | } | 578 | } |
719 | 579 | ||
720 | const QColor *ZSafe::evenRowColor = &Qt::white; | 580 | const QColor *ZSafe::evenRowColor = &Qt::white; |
721 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; | 581 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; |
722 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); | 582 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); |
723 | 583 | ||
724 | /* | 584 | /* |
725 | * Destroys the object and frees any allocated resources | 585 | * Destroys the object and frees any allocated resources |
726 | */ | 586 | */ |
727 | ZSafe::~ZSafe() | 587 | ZSafe::~ZSafe() |
728 | { | 588 | { |
729 | // no need to delete child widgets, Qt does it all for us | 589 | // no need to delete child widgets, Qt does it all for us |
@@ -763,64 +623,46 @@ void ZSafe::deletePwd() | |||
763 | delCategory(); | 623 | delCategory(); |
764 | } | 624 | } |
765 | } | 625 | } |
766 | 626 | ||
767 | void ZSafe::editPwd() | 627 | void ZSafe::editPwd() |
768 | { | 628 | { |
769 | if (!selectedItem) | 629 | if (!selectedItem) |
770 | return; | 630 | return; |
771 | if (!isCategory(selectedItem)) | 631 | if (!isCategory(selectedItem)) |
772 | { | 632 | { |
773 | // open the 'New Entry' dialog | 633 | // open the 'New Entry' dialog |
774 | NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE); | 634 | NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE); |
775 | #ifdef Q_WS_WIN | ||
776 | dialog->setCaption ("Qt " + tr("Edit Entry")); | ||
777 | dialog->setGeometry(200, 250, 220, 310 ); | ||
778 | #endif | ||
779 | 635 | ||
780 | // set the labels | 636 | // set the labels |
781 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 637 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
782 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 638 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
783 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 639 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
784 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 640 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
785 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 641 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
786 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 642 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
787 | 643 | ||
788 | // set the fields | 644 | // set the fields |
789 | dialog->NameField->setText(selectedItem->text (0)); | 645 | dialog->NameField->setText(selectedItem->text (0)); |
790 | dialog->UsernameField->setText(selectedItem->text (1)); | 646 | dialog->UsernameField->setText(selectedItem->text (1)); |
791 | dialog->PasswordField->setText(selectedItem->text (2)); | 647 | dialog->PasswordField->setText(selectedItem->text (2)); |
792 | QString comment = selectedItem->text (3); | 648 | QString comment = selectedItem->text (3); |
793 | comment.replace (QRegExp("<br>"), "\n"); | 649 | comment.replace (QRegExp("<br>"), "\n"); |
794 | dialog->Field5->setText(selectedItem->text (4)); | 650 | dialog->Field5->setText(selectedItem->text (4)); |
795 | dialog->Field6->setText(selectedItem->text (5)); | 651 | dialog->Field6->setText(selectedItem->text (5)); |
796 | dialog->CommentField->insertLine(comment); | 652 | dialog->CommentField->insertLine(comment); |
797 | dialog->CommentField->setCursorPosition(0,0); | 653 | dialog->CommentField->setCursorPosition(0,0); |
798 | 654 | ||
799 | #ifdef Q_WS_QWS | 655 | QDialog::DialogCode result = (QDialog::DialogCode) QPEApplication::execDialog( dialog ); |
800 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 656 | if (result == QDialog::Accepted) |
801 | #endif | ||
802 | |||
803 | #ifdef DESKTOP | ||
804 | #ifndef Q_QW_QWIN | ||
805 | dialog->show(); | ||
806 | #endif | ||
807 | #else | ||
808 | dialog->showMaximized(); | ||
809 | #endif | ||
810 | #ifdef DESKTOP | ||
811 | int result = dialog->exec(); | ||
812 | result = QDialog::Accepted; | ||
813 | #endif | ||
814 | if (result == Accepted) | ||
815 | { | 657 | { |
816 | modified = true; | 658 | modified = true; |
817 | // edit the selected item | 659 | // edit the selected item |
818 | QString name = dialog->NameField->text(); | 660 | QString name = dialog->NameField->text(); |
819 | selectedItem->setText (0, tr (name)); | 661 | selectedItem->setText (0, tr (name)); |
820 | QString user = dialog->UsernameField->text(); | 662 | QString user = dialog->UsernameField->text(); |
821 | selectedItem->setText (1, tr (user)); | 663 | selectedItem->setText (1, tr (user)); |
822 | QString pwd = dialog->PasswordField->text(); | 664 | QString pwd = dialog->PasswordField->text(); |
823 | selectedItem->setText (2, tr (pwd)); | 665 | selectedItem->setText (2, tr (pwd)); |
824 | QString comment = dialog->CommentField->text(); | 666 | QString comment = dialog->CommentField->text(); |
825 | comment.replace (QRegExp("\n"), "<br>"); | 667 | comment.replace (QRegExp("\n"), "<br>"); |
826 | selectedItem->setText (3, tr (comment)); | 668 | selectedItem->setText (3, tr (comment)); |
@@ -843,54 +685,37 @@ void ZSafe::newPwd() | |||
843 | if (!selectedItem) | 685 | if (!selectedItem) |
844 | return; | 686 | return; |
845 | qWarning("new item"); | 687 | qWarning("new item"); |
846 | if (!isCategory(selectedItem)) | 688 | if (!isCategory(selectedItem)) |
847 | selectedItem = selectedItem->parent(); | 689 | selectedItem = selectedItem->parent(); |
848 | 690 | ||
849 | if (isCategory(selectedItem)) | 691 | if (isCategory(selectedItem)) |
850 | { | 692 | { |
851 | QString cat = selectedItem->text(0); | 693 | QString cat = selectedItem->text(0); |
852 | qWarning(cat); | 694 | qWarning(cat); |
853 | // open the 'New Entry' dialog | 695 | // open the 'New Entry' dialog |
854 | NewDialog *dialog = new NewDialog(this, "new_entry", TRUE); | 696 | NewDialog *dialog = new NewDialog(this, "new_entry", TRUE); |
855 | #ifdef Q_WS_WIN | ||
856 | dialog->setCaption ("Qt " + tr("New Entry")); | ||
857 | dialog->setGeometry(200, 250, 220, 310 ); | ||
858 | #endif | ||
859 | // set the labels | 697 | // set the labels |
860 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 698 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
861 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 699 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
862 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 700 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
863 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 701 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
864 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 702 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
865 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 703 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
866 | retype: | 704 | retype: |
867 | 705 | ||
868 | #ifdef Q_WS_QWS | 706 | #ifdef Q_WS_QWS |
869 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 707 | QDialog::DialogCode result = (QDialog::DialogCode) QPEApplication::execDialog( dialog ); |
870 | #endif | ||
871 | |||
872 | #ifdef DESKTOP | ||
873 | #ifndef Q_QW_QWIN | ||
874 | dialog->show(); | ||
875 | #endif | ||
876 | #else | ||
877 | dialog->showMaximized(); | ||
878 | #endif | ||
879 | #ifdef DESKTOP | ||
880 | int result = dialog->exec(); | ||
881 | result = QDialog::Accepted; | ||
882 | #endif | 708 | #endif |
883 | 709 | if (result == QDialog::Accepted) | |
884 | if (result == Accepted) | ||
885 | { | 710 | { |
886 | 711 | ||
887 | QString name = dialog->NameField->text(); | 712 | QString name = dialog->NameField->text(); |
888 | if (cat == name) | 713 | if (cat == name) |
889 | { | 714 | { |
890 | QMessageBox::critical( 0, tr("ZSafe"), | 715 | QMessageBox::critical( 0, tr("ZSafe"), |
891 | tr("Entry name must be different\nfrom the category name.") ); | 716 | tr("Entry name must be different\nfrom the category name.") ); |
892 | goto retype; // it's not a good programming style :-) | 717 | goto retype; // it's not a good programming style :-) |
893 | } | 718 | } |
894 | 719 | ||
895 | modified = true; | 720 | modified = true; |
896 | // add the new item | 721 | // add the new item |
@@ -911,60 +736,47 @@ retype: | |||
911 | i->setText (5, tr (f6)); | 736 | i->setText (5, tr (f6)); |
912 | } | 737 | } |
913 | 738 | ||
914 | delete dialog; | 739 | delete dialog; |
915 | } | 740 | } |
916 | } | 741 | } |
917 | 742 | ||
918 | void ZSafe::findPwd() | 743 | void ZSafe::findPwd() |
919 | { | 744 | { |
920 | 745 | ||
921 | // open the 'Search' dialog | 746 | // open the 'Search' dialog |
922 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); | 747 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); |
923 | #ifdef Q_WS_WIN | ||
924 | dialog->setCaption ("Qt " + tr("Search")); | ||
925 | #endif | ||
926 | 748 | ||
927 | #ifdef DESKTOP | ||
928 | #endif | ||
929 | if (lastSearchedName) | 749 | if (lastSearchedName) |
930 | dialog->NameField->setText(lastSearchedName); | 750 | dialog->NameField->setText(lastSearchedName); |
931 | else | 751 | else |
932 | dialog->NameField->setText(""); | 752 | dialog->NameField->setText(""); |
933 | if (lastSearchedUsername) | 753 | if (lastSearchedUsername) |
934 | dialog->UsernameField->setText(lastSearchedUsername); | 754 | dialog->UsernameField->setText(lastSearchedUsername); |
935 | else | 755 | else |
936 | dialog->UsernameField->setText(""); | 756 | dialog->UsernameField->setText(""); |
937 | if (lastSearchedComment) | 757 | if (lastSearchedComment) |
938 | dialog->CommentField->setText(lastSearchedComment); | 758 | dialog->CommentField->setText(lastSearchedComment); |
939 | else | 759 | else |
940 | dialog->CommentField->setText(""); | 760 | dialog->CommentField->setText(""); |
941 | DialogCode result = (DialogCode) dialog->exec(); | 761 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); |
942 | #ifdef DESKTOP | ||
943 | result = Accepted; | ||
944 | #endif | ||
945 | 762 | ||
946 | QString name; | 763 | QString name; |
947 | QString username; | 764 | QString username; |
948 | QString comment; | 765 | QString comment; |
949 | if (result == Accepted) | 766 | if (result == QDialog::Accepted) |
950 | { | 767 | { |
951 | name = dialog->NameField->text(); | 768 | name = dialog->NameField->text(); |
952 | username = dialog->UsernameField->text(); | 769 | username = dialog->UsernameField->text(); |
953 | comment = dialog->CommentField->text(); | 770 | comment = dialog->CommentField->text(); |
954 | #ifndef NO_OPIE | ||
955 | owarn << name << oendl; | ||
956 | #else | ||
957 | qWarning (name); | ||
958 | #endif | ||
959 | } | 771 | } |
960 | else | 772 | else |
961 | { | 773 | { |
962 | delete dialog; | 774 | delete dialog; |
963 | return; | 775 | return; |
964 | } | 776 | } |
965 | 777 | ||
966 | if (!name.isEmpty() && name != lastSearchedName || | 778 | if (!name.isEmpty() && name != lastSearchedName || |
967 | lastSearchedName.isEmpty() && !name.isEmpty()) | 779 | lastSearchedName.isEmpty() && !name.isEmpty()) |
968 | { | 780 | { |
969 | // set search at the beginning if a new name is given | 781 | // set search at the beginning if a new name is given |
970 | lastSearchedCategory = NULL; | 782 | lastSearchedCategory = NULL; |
@@ -992,66 +804,53 @@ void ZSafe::findPwd() | |||
992 | 804 | ||
993 | bool found=FALSE; | 805 | bool found=FALSE; |
994 | // step through all categories | 806 | // step through all categories |
995 | QListViewItem *i; | 807 | QListViewItem *i; |
996 | if (lastSearchedCategory) | 808 | if (lastSearchedCategory) |
997 | i = lastSearchedCategory; | 809 | i = lastSearchedCategory; |
998 | else | 810 | else |
999 | i = ListView->firstChild(); | 811 | i = ListView->firstChild(); |
1000 | for (; | 812 | for (; |
1001 | i != NULL; | 813 | i != NULL; |
1002 | i = i->nextSibling()) | 814 | i = i->nextSibling()) |
1003 | { | 815 | { |
1004 | #ifndef NO_OPIE | ||
1005 | owarn << i->text(0) << oendl; | ||
1006 | #endif | ||
1007 | i->setSelected(FALSE); | 816 | i->setSelected(FALSE); |
1008 | 817 | ||
1009 | // step through all subitems | 818 | // step through all subitems |
1010 | QListViewItem *si; | 819 | QListViewItem *si; |
1011 | if (lastSearchedItem) | 820 | if (lastSearchedItem) |
1012 | si = lastSearchedItem; | 821 | si = lastSearchedItem; |
1013 | else | 822 | else |
1014 | si = i->firstChild(); | 823 | si = i->firstChild(); |
1015 | // for (si = i->firstChild(); | 824 | // for (si = i->firstChild(); |
1016 | for (; | 825 | for (; |
1017 | si != NULL; | 826 | si != NULL; |
1018 | si = si->nextSibling()) | 827 | si = si->nextSibling()) |
1019 | { | 828 | { |
1020 | #ifndef NO_OPIE | ||
1021 | owarn << si->text(0) << oendl; | ||
1022 | #else | ||
1023 | qWarning (si->text(0)); | ||
1024 | #endif | ||
1025 | if (si->isSelected()) | 829 | if (si->isSelected()) |
1026 | si->setSelected(FALSE); | 830 | si->setSelected(FALSE); |
1027 | // ListView->repaintItem(si); | 831 | // ListView->repaintItem(si); |
1028 | 832 | ||
1029 | bool n=TRUE; | 833 | bool n=TRUE; |
1030 | bool u=TRUE; | 834 | bool u=TRUE; |
1031 | bool c=TRUE; | 835 | bool c=TRUE; |
1032 | if (!name.isEmpty()) | 836 | if (!name.isEmpty()) |
1033 | n = (si->text(0)).contains (name, FALSE); | 837 | n = (si->text(0)).contains (name, FALSE); |
1034 | if (!username.isEmpty()) | 838 | if (!username.isEmpty()) |
1035 | u = (si->text(1)).contains (username, FALSE); | 839 | u = (si->text(1)).contains (username, FALSE); |
1036 | if (!comment.isEmpty()) | 840 | if (!comment.isEmpty()) |
1037 | c = (si->text(3)).contains (comment, FALSE); | 841 | c = (si->text(3)).contains (comment, FALSE); |
1038 | 842 | ||
1039 | if ((n && u && c ) && !found) | 843 | if ((n && u && c ) && !found) |
1040 | { | 844 | { |
1041 | #ifndef NO_OPIE | ||
1042 | owarn << "Found" << oendl; | ||
1043 | #else | ||
1044 | qWarning ("Found"); | ||
1045 | #endif | ||
1046 | selectedItem = si; | 845 | selectedItem = si; |
1047 | si->setSelected(TRUE); | 846 | si->setSelected(TRUE); |
1048 | ListView->setCurrentItem(si); | 847 | ListView->setCurrentItem(si); |
1049 | ListView->ensureItemVisible(si); | 848 | ListView->ensureItemVisible(si); |
1050 | ListView->triggerUpdate(); | 849 | ListView->triggerUpdate(); |
1051 | 850 | ||
1052 | lastSearchedCategory = i; | 851 | lastSearchedCategory = i; |
1053 | // set to the next item | 852 | // set to the next item |
1054 | lastSearchedItem = si->nextSibling(); | 853 | lastSearchedItem = si->nextSibling(); |
1055 | if (!lastSearchedItem) | 854 | if (!lastSearchedItem) |
1056 | { | 855 | { |
1057 | // no next item within category -> set next category | 856 | // no next item within category -> set next category |
@@ -1090,64 +889,42 @@ QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) | |||
1090 | else | 889 | else |
1091 | { | 890 | { |
1092 | QListViewItem *cat = _item->parent(); | 891 | QListViewItem *cat = _item->parent(); |
1093 | category = cat->text(0); | 892 | category = cat->text(0); |
1094 | } | 893 | } |
1095 | } | 894 | } |
1096 | else | 895 | else |
1097 | { | 896 | { |
1098 | return def; | 897 | return def; |
1099 | } | 898 | } |
1100 | 899 | ||
1101 | QString app_key = APP_KEY; | 900 | QString app_key = APP_KEY; |
1102 | #ifndef DESKTOP | 901 | |
1103 | #ifndef Q_WS_WIN | ||
1104 | conf->setGroup ("fieldDefs"); | 902 | conf->setGroup ("fieldDefs"); |
1105 | #endif | ||
1106 | #else | ||
1107 | #ifndef Q_WS_WIN | ||
1108 | app_key += "/fieldDefs/"; | ||
1109 | #endif | ||
1110 | #endif | ||
1111 | // #ifndef Q_WS_WIN | ||
1112 | QString label = conf->readEntry(app_key+category+"-field"+field,def); | 903 | QString label = conf->readEntry(app_key+category+"-field"+field,def); |
1113 | // #else | ||
1114 | // QString label(def); | ||
1115 | // #endif | ||
1116 | |||
1117 | #ifndef DESKTOP | ||
1118 | conf->setGroup ("zsafe"); | 904 | conf->setGroup ("zsafe"); |
1119 | #endif | ||
1120 | return label; | 905 | return label; |
1121 | } | 906 | } |
1122 | 907 | ||
1123 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) | 908 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) |
1124 | { | 909 | { |
1125 | QString app_key = APP_KEY; | 910 | QString app_key = APP_KEY; |
1126 | #ifndef DESKTOP | ||
1127 | conf->setGroup ("fieldDefs"); | ||
1128 | #else | ||
1129 | #ifndef Q_WS_WIN | ||
1130 | app_key += "/fieldDefs/"; | ||
1131 | #endif | ||
1132 | #endif | ||
1133 | // #ifndef Q_WS_WIN | 911 | // #ifndef Q_WS_WIN |
912 | conf->setGroup( "fieldDefs" ); | ||
1134 | QString label = conf->readEntry(app_key+category+"-field"+field, | 913 | QString label = conf->readEntry(app_key+category+"-field"+field, |
1135 | def); | 914 | def); |
1136 | // #else | 915 | // #else |
1137 | // QString label(def); | 916 | // QString label(def); |
1138 | // #endif | 917 | // #endif |
1139 | #ifndef DESKTOP | ||
1140 | conf->setGroup ("zsafe"); | 918 | conf->setGroup ("zsafe"); |
1141 | #endif | ||
1142 | return label; | 919 | return label; |
1143 | } | 920 | } |
1144 | 921 | ||
1145 | void ZSafe::showInfo( QListViewItem *_item) | 922 | void ZSafe::showInfo( QListViewItem *_item) |
1146 | { | 923 | { |
1147 | if (!_item) | 924 | if (!_item) |
1148 | return; | 925 | return; |
1149 | if (selectedItem != NULL) | 926 | if (selectedItem != NULL) |
1150 | selectedItem->setSelected(FALSE); | 927 | selectedItem->setSelected(FALSE); |
1151 | 928 | ||
1152 | selectedItem = _item; | 929 | selectedItem = _item; |
1153 | selectedItem->setSelected(TRUE); | 930 | selectedItem->setSelected(TRUE); |
@@ -1226,140 +1003,99 @@ void ZSafe::showInfo( QListViewItem *_item) | |||
1226 | text += comment; | 1003 | text += comment; |
1227 | // text += "<br>"; | 1004 | // text += "<br>"; |
1228 | } | 1005 | } |
1229 | 1006 | ||
1230 | text += "</body></html>"; | 1007 | text += "</body></html>"; |
1231 | 1008 | ||
1232 | infoForm->InfoText->setText(text); | 1009 | infoForm->InfoText->setText(text); |
1233 | // infoForm->hide(); | 1010 | // infoForm->hide(); |
1234 | #ifdef Q_WS_QWS | 1011 | #ifdef Q_WS_QWS |
1235 | QPEApplication::showDialog( infoForm ); | 1012 | QPEApplication::showDialog( infoForm ); |
1236 | #endif | 1013 | #endif |
1237 | 1014 | ||
1238 | #ifdef DESKTOP | ||
1239 | infoForm->show(); | ||
1240 | #endif | ||
1241 | } | 1015 | } |
1242 | } | 1016 | } |
1243 | 1017 | ||
1244 | void ZSafe::listViewSelected( QListViewItem *_item) | 1018 | void ZSafe::listViewSelected( QListViewItem *_item) |
1245 | { | 1019 | { |
1246 | if (!_item) | 1020 | if (!_item) |
1247 | return; | 1021 | return; |
1248 | if (selectedItem != NULL) | 1022 | if (selectedItem != NULL) |
1249 | selectedItem->setSelected(FALSE); | 1023 | selectedItem->setSelected(FALSE); |
1250 | 1024 | ||
1251 | selectedItem = _item; | 1025 | selectedItem = _item; |
1252 | 1026 | ||
1253 | #ifndef DESKTOP | ||
1254 | // set the column text dependent on the selected item | ||
1255 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); | ||
1256 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); | ||
1257 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); | ||
1258 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); | ||
1259 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); | ||
1260 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); | ||
1261 | #endif | ||
1262 | #ifdef Q_WS_WIN | ||
1263 | // set the column text dependent on the selected item | 1027 | // set the column text dependent on the selected item |
1264 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); | 1028 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); |
1265 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); | 1029 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); |
1266 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); | 1030 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); |
1267 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); | 1031 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); |
1268 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); | 1032 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); |
1269 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); | 1033 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); |
1270 | #endif | ||
1271 | |||
1272 | } | 1034 | } |
1273 | 1035 | ||
1274 | bool ZSafe::isCategory(QListViewItem *_item) | 1036 | bool ZSafe::isCategory(QListViewItem *_item) |
1275 | { | 1037 | { |
1276 | if (_item == NULL) | 1038 | if (_item == NULL) |
1277 | return FALSE; | 1039 | return FALSE; |
1278 | 1040 | ||
1279 | QString categoryName = _item->text (0); | 1041 | QString categoryName = _item->text (0); |
1280 | if (categories.find (categoryName)) | 1042 | if (categories.find (categoryName)) |
1281 | return TRUE; | 1043 | return TRUE; |
1282 | else | 1044 | else |
1283 | return FALSE; | 1045 | return FALSE; |
1284 | } | 1046 | } |
1285 | 1047 | ||
1286 | void ZSafe::removeAsciiFile() | 1048 | void ZSafe::removeAsciiFile() |
1287 | { | 1049 | { |
1288 | // QString fn = filename + ".txt"; | 1050 | // QString fn = filename + ".txt"; |
1289 | // open the file dialog | 1051 | // open the file dialog |
1290 | #ifndef DESKTOP | ||
1291 | #ifndef NO_OPIE | ||
1292 | QMap<QString, QStringList> mimeTypes; | 1052 | QMap<QString, QStringList> mimeTypes; |
1293 | mimeTypes.insert(tr("All"), QStringList() ); | 1053 | mimeTypes.insert(tr("All"), QStringList() ); |
1294 | mimeTypes.insert(tr("Text"), "text/*" ); | 1054 | mimeTypes.insert(tr("Text"), "text/*" ); |
1295 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 1055 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
1296 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1056 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1297 | QString::null, | 1057 | QString::null, |
1298 | mimeTypes, | 1058 | mimeTypes, |
1299 | this, | 1059 | this, |
1300 | tr ("Remove text file")); | 1060 | tr ("Remove text file")); |
1301 | #else | ||
1302 | QString fn = ScQtFileEdit::getOpenFileName(this, | ||
1303 | tr ("Remove text file"), | ||
1304 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1305 | "*.txt"); | ||
1306 | #endif | ||
1307 | #else | ||
1308 | QString fn = QFileDialog::getOpenFileName( | ||
1309 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1310 | "ZSafe (*.txt)", | ||
1311 | this, | ||
1312 | "ZSafe File Dialog" | ||
1313 | "Choose a text file" ); | ||
1314 | #endif | ||
1315 | 1061 | ||
1316 | if (fn && fn.length() > 0 ) | 1062 | if (fn && fn.length() > 0 ) |
1317 | { | 1063 | { |
1318 | QFile f( fn ); | 1064 | QFile f( fn ); |
1319 | if ( !f.remove() ) | 1065 | if ( !f.remove() ) |
1320 | { | 1066 | { |
1321 | #ifndef NO_OPIE | ||
1322 | owarn << "Could not remove file " << fn << oendl; | ||
1323 | #else | ||
1324 | qWarning( QString("Could not remove file %1").arg(fn),2000 ); | ||
1325 | #endif | ||
1326 | QMessageBox::critical( 0, tr("ZSafe"), | 1067 | QMessageBox::critical( 0, tr("ZSafe"), |
1327 | tr("Could not remove text file.") ); | 1068 | tr("Could not remove text file.") ); |
1328 | return; | 1069 | return; |
1329 | } | 1070 | } |
1330 | } | 1071 | } |
1331 | } | 1072 | } |
1332 | 1073 | ||
1333 | void ZSafe::writeAllEntries() | 1074 | void ZSafe::writeAllEntries() |
1334 | { | 1075 | { |
1335 | if (filename.isEmpty()) | 1076 | if (filename.isEmpty()) |
1336 | { | 1077 | { |
1337 | QMessageBox::critical( 0, tr("ZSafe"), | 1078 | QMessageBox::critical( 0, tr("ZSafe"), |
1338 | tr("No document defined.\nYou have to create a new document")); | 1079 | tr("No document defined.\nYou have to create a new document")); |
1339 | return; | 1080 | return; |
1340 | } | 1081 | } |
1341 | 1082 | ||
1342 | // open the file dialog | 1083 | // open the file dialog |
1343 | QString fn = zsaveDialog(); | 1084 | QString fn = zsaveDialog(); |
1344 | // open the new document | 1085 | // open the new document |
1345 | if (fn && fn.length() > 0 ) | 1086 | if (fn && fn.length() > 0 ) |
1346 | { | 1087 | { |
1347 | QFile f( fn ); | 1088 | QFile f( fn ); |
1348 | if ( !f.open( IO_WriteOnly ) ) { | 1089 | if ( !f.open( IO_WriteOnly ) ) { |
1349 | #ifndef NO_OPIE | ||
1350 | owarn << "Could not write to file " << fn << oendl; | ||
1351 | #else | ||
1352 | qWarning( QString("Could not write to file %1").arg(fn),2000 ); | ||
1353 | #endif | ||
1354 | QMessageBox::critical( 0, "ZSafe", | 1090 | QMessageBox::critical( 0, "ZSafe", |
1355 | QString("Could not export to text file.") ); | 1091 | QString("Could not export to text file.") ); |
1356 | return; | 1092 | return; |
1357 | } | 1093 | } |
1358 | QTextStream t( &f ); | 1094 | QTextStream t( &f ); |
1359 | 1095 | ||
1360 | QListViewItem *i; | 1096 | QListViewItem *i; |
1361 | // step through all categories | 1097 | // step through all categories |
1362 | for (i = ListView->firstChild(); | 1098 | for (i = ListView->firstChild(); |
1363 | i != NULL; | 1099 | i != NULL; |
1364 | i = i->nextSibling()) | 1100 | i = i->nextSibling()) |
1365 | { | 1101 | { |
@@ -1404,60 +1140,39 @@ void ZSafe::writeAllEntries() | |||
1404 | } | 1140 | } |
1405 | 1141 | ||
1406 | void ZSafe::readAllEntries() | 1142 | void ZSafe::readAllEntries() |
1407 | { | 1143 | { |
1408 | if (filename.isEmpty()) | 1144 | if (filename.isEmpty()) |
1409 | { | 1145 | { |
1410 | QMessageBox::critical( 0, tr("ZSafe"), | 1146 | QMessageBox::critical( 0, tr("ZSafe"), |
1411 | tr("No document defined.\nYou have to create a new document")); | 1147 | tr("No document defined.\nYou have to create a new document")); |
1412 | return; | 1148 | return; |
1413 | } | 1149 | } |
1414 | 1150 | ||
1415 | // open the file dialog | 1151 | // open the file dialog |
1416 | #ifndef DESKTOP | ||
1417 | #ifndef NO_OPIE | ||
1418 | QMap<QString, QStringList> mimeTypes; | 1152 | QMap<QString, QStringList> mimeTypes; |
1419 | mimeTypes.insert(tr("All"), QStringList() ); | 1153 | mimeTypes.insert(tr("All"), QStringList() ); |
1420 | mimeTypes.insert(tr("Text"), "text/*" ); | 1154 | mimeTypes.insert(tr("Text"), "text/*" ); |
1421 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 1155 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
1422 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1156 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1423 | QString::null, | 1157 | QString::null, |
1424 | mimeTypes, | 1158 | mimeTypes, |
1425 | this, | 1159 | this, |
1426 | tr ("Import text file")); | 1160 | tr ("Import text file")); |
1427 | #else | ||
1428 | QString fn = ScQtFileEdit::getOpenFileName(this, | ||
1429 | tr ("Import text file"), | ||
1430 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1431 | "*.txt"); | ||
1432 | #endif | ||
1433 | #else | ||
1434 | QString fn = QFileDialog::getOpenFileName( | ||
1435 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1436 | "ZSafe (*.txt)", | ||
1437 | this, | ||
1438 | "ZSafe File Dialog" | ||
1439 | "Choose a text file" ); | ||
1440 | #endif | ||
1441 | 1161 | ||
1442 | if (fn && fn.length() > 0 ) | 1162 | if (fn && fn.length() > 0 ) |
1443 | { | 1163 | { |
1444 | QFile f( fn ); | 1164 | QFile f( fn ); |
1445 | if ( !f.open( IO_ReadOnly ) ) | 1165 | if ( !f.open( IO_ReadOnly ) ) |
1446 | { | 1166 | { |
1447 | #ifndef NO_OPIE | ||
1448 | owarn << "Could not read file " << fn << oendl; | ||
1449 | #else | ||
1450 | qWarning( QString("Could not read file %1").arg(fn), 2000 ); | ||
1451 | #endif | ||
1452 | QMessageBox::critical( 0, "ZSafe", | 1167 | QMessageBox::critical( 0, "ZSafe", |
1453 | QString("Could not import text file.") ); | 1168 | QString("Could not import text file.") ); |
1454 | return; | 1169 | return; |
1455 | } | 1170 | } |
1456 | 1171 | ||
1457 | modified = true; | 1172 | modified = true; |
1458 | 1173 | ||
1459 | // clear the password list | 1174 | // clear the password list |
1460 | selectedItem = NULL; | 1175 | selectedItem = NULL; |
1461 | QListViewItem *i; | 1176 | QListViewItem *i; |
1462 | // step through all categories | 1177 | // step through all categories |
1463 | for (i = ListView->firstChild(); | 1178 | for (i = ListView->firstChild(); |
@@ -1468,41 +1183,31 @@ void ZSafe::readAllEntries() | |||
1468 | QListViewItem *si; | 1183 | QListViewItem *si; |
1469 | for (si = i->firstChild(); | 1184 | for (si = i->firstChild(); |
1470 | si != NULL; ) | 1185 | si != NULL; ) |
1471 | // si = si->nextSibling()) | 1186 | // si = si->nextSibling()) |
1472 | { | 1187 | { |
1473 | QListViewItem *_si = si; | 1188 | QListViewItem *_si = si; |
1474 | si = si->nextSibling(); | 1189 | si = si->nextSibling(); |
1475 | i->takeItem(_si); // remove from view list | 1190 | i->takeItem(_si); // remove from view list |
1476 | if (_si) delete _si; | 1191 | if (_si) delete _si; |
1477 | } | 1192 | } |
1478 | } | 1193 | } |
1479 | 1194 | ||
1480 | #ifndef NO_OPIE | ||
1481 | owarn << "ReadAllEntries(): " << oendl; | ||
1482 | #else | ||
1483 | qWarning ("ReadAllEntries(): "); | ||
1484 | #endif | ||
1485 | |||
1486 | QTextStream t(&f); | 1195 | QTextStream t(&f); |
1487 | while ( !t.eof() ) | 1196 | while ( !t.eof() ) |
1488 | { | 1197 | { |
1489 | QString s = t.readLine(); | 1198 | QString s = t.readLine(); |
1490 | s.replace (QRegExp("\";\""), "\"|\""); | 1199 | s.replace (QRegExp("\";\""), "\"|\""); |
1491 | // char buffer[1024]; | 1200 | // char buffer[1024]; |
1492 | #ifndef Q_WS_WIN | ||
1493 | char buffer[s.length()+1]; | 1201 | char buffer[s.length()+1]; |
1494 | #else | ||
1495 | char buffer[4048]; | ||
1496 | #endif | ||
1497 | 1202 | ||
1498 | 1203 | ||
1499 | /* modify QString -> QCString::utf8 */ | 1204 | /* modify QString -> QCString::utf8 */ |
1500 | 1205 | ||
1501 | strcpy (buffer, s.utf8()); | 1206 | strcpy (buffer, s.utf8()); |
1502 | 1207 | ||
1503 | QString name; | 1208 | QString name; |
1504 | QString user; | 1209 | QString user; |
1505 | QString password; | 1210 | QString password; |
1506 | QString comment; | 1211 | QString comment; |
1507 | QString field5=""; | 1212 | QString field5=""; |
1508 | QString field6=""; | 1213 | QString field6=""; |
@@ -1630,29 +1335,24 @@ void ZSafe::writeAllEntries() | |||
1630 | { | 1335 | { |
1631 | if (filename.isEmpty()) | 1336 | if (filename.isEmpty()) |
1632 | { | 1337 | { |
1633 | QMessageBox::critical( 0, tr("ZSafe"), | 1338 | QMessageBox::critical( 0, tr("ZSafe"), |
1634 | tr("<P>No document defined. You have to create a new document</P>")); | 1339 | tr("<P>No document defined. You have to create a new document</P>")); |
1635 | return; | 1340 | return; |
1636 | } | 1341 | } |
1637 | 1342 | ||
1638 | // open the file for writing | 1343 | // open the file for writing |
1639 | QString fn = filename + ".txt"; | 1344 | QString fn = filename + ".txt"; |
1640 | QFile f( fn ); | 1345 | QFile f( fn ); |
1641 | if ( !f.open( IO_WriteOnly ) ) { | 1346 | if ( !f.open( IO_WriteOnly ) ) { |
1642 | #ifndef NO_OPIE | ||
1643 | owarn << "Could not write to file " << fn << oendl; | ||
1644 | #else | ||
1645 | qWarning( QString("Could not write to file %1").arg(fn), 2000 ); | ||
1646 | #endif | ||
1647 | QMessageBox::critical( 0, tr("ZSafe"), | 1347 | QMessageBox::critical( 0, tr("ZSafe"), |
1648 | tr("Could not export to text file.") ); | 1348 | tr("Could not export to text file.") ); |
1649 | return; | 1349 | return; |
1650 | } | 1350 | } |
1651 | QTextStream t( &f ); | 1351 | QTextStream t( &f ); |
1652 | 1352 | ||
1653 | QListViewItem *i; | 1353 | QListViewItem *i; |
1654 | // step through all categories | 1354 | // step through all categories |
1655 | for (i = ListView->firstChild(); | 1355 | for (i = ListView->firstChild(); |
1656 | i != NULL; | 1356 | i != NULL; |
1657 | i = i->nextSibling()) | 1357 | i = i->nextSibling()) |
1658 | { | 1358 | { |
@@ -1687,29 +1387,24 @@ void ZSafe::writeAllEntries() | |||
1687 | // owarn << si->text(0) << oendl; | 1387 | // owarn << si->text(0) << oendl; |
1688 | } | 1388 | } |
1689 | } | 1389 | } |
1690 | f.close(); | 1390 | f.close(); |
1691 | } | 1391 | } |
1692 | 1392 | ||
1693 | void ZSafe::readAllEntries() | 1393 | void ZSafe::readAllEntries() |
1694 | { | 1394 | { |
1695 | QString fn = filename + ".txt"; | 1395 | QString fn = filename + ".txt"; |
1696 | QFile f( fn ); | 1396 | QFile f( fn ); |
1697 | if ( !f.open( IO_ReadOnly ) ) | 1397 | if ( !f.open( IO_ReadOnly ) ) |
1698 | { | 1398 | { |
1699 | #ifndef NO_OPIE | ||
1700 | owarn << "Could not read file " << fn << oendl; | ||
1701 | #else | ||
1702 | qWarning( QString("Could not read file %1").arg(fn), 2000 ); | ||
1703 | #endif | ||
1704 | QMessageBox::critical( 0, tr("ZSafe"), | 1399 | QMessageBox::critical( 0, tr("ZSafe"), |
1705 | tr("Could not import text file.") ); | 1400 | tr("Could not import text file.") ); |
1706 | return; | 1401 | return; |
1707 | } | 1402 | } |
1708 | 1403 | ||
1709 | modified = true; | 1404 | modified = true; |
1710 | 1405 | ||
1711 | // clear the password list | 1406 | // clear the password list |
1712 | selectedItem = NULL; | 1407 | selectedItem = NULL; |
1713 | QListViewItem *i; | 1408 | QListViewItem *i; |
1714 | // step through all categories | 1409 | // step through all categories |
1715 | for (i = ListView->firstChild(); | 1410 | for (i = ListView->firstChild(); |
@@ -1720,41 +1415,32 @@ void ZSafe::readAllEntries() | |||
1720 | QListViewItem *si; | 1415 | QListViewItem *si; |
1721 | for (si = i->firstChild(); | 1416 | for (si = i->firstChild(); |
1722 | si != NULL; ) | 1417 | si != NULL; ) |
1723 | // si = si->nextSibling()) | 1418 | // si = si->nextSibling()) |
1724 | { | 1419 | { |
1725 | QListViewItem *_si = si; | 1420 | QListViewItem *_si = si; |
1726 | si = si->nextSibling(); | 1421 | si = si->nextSibling(); |
1727 | i->takeItem(_si); // remove from view list | 1422 | i->takeItem(_si); // remove from view list |
1728 | if (_si) delete _si; | 1423 | if (_si) delete _si; |
1729 | } | 1424 | } |
1730 | } | 1425 | } |
1731 | 1426 | ||
1732 | #ifndef NO_OPIE | ||
1733 | owarn << "ReadAllEntries(): " << oendl; | ||
1734 | #else | ||
1735 | qWarning ("ReadAllEntries(): "); | ||
1736 | #endif | ||
1737 | QTextStream t(&f); | 1427 | QTextStream t(&f); |
1738 | while ( !t.eof() ) | 1428 | while ( !t.eof() ) |
1739 | { | 1429 | { |
1740 | QString s = t.readLine(); | 1430 | QString s = t.readLine(); |
1741 | s.replace (QRegExp("\";\""), "\"|\""); | 1431 | s.replace (QRegExp("\";\""), "\"|\""); |
1742 | // char buffer[1024]; | 1432 | // char buffer[1024]; |
1743 | int len=s.length()+1; | 1433 | int len=s.length()+1; |
1744 | #ifdef Q_WS_WIN | ||
1745 | char buffer[512]; | ||
1746 | #else | ||
1747 | char buffer[len]; | 1434 | char buffer[len]; |
1748 | #endif | ||
1749 | strcpy (buffer, s); | 1435 | strcpy (buffer, s); |
1750 | 1436 | ||
1751 | QString name; | 1437 | QString name; |
1752 | QString user; | 1438 | QString user; |
1753 | QString password; | 1439 | QString password; |
1754 | QString comment; | 1440 | QString comment; |
1755 | 1441 | ||
1756 | // separete the entries | 1442 | // separete the entries |
1757 | char *i = strtok (buffer, "|"); | 1443 | char *i = strtok (buffer, "|"); |
1758 | QString category(&i[1]); | 1444 | QString category(&i[1]); |
1759 | category.truncate(category.length() -1); | 1445 | category.truncate(category.length() -1); |
1760 | 1446 | ||
@@ -1847,27 +1533,24 @@ void ZSafe::readAllEntries() | |||
1847 | c1->initListItem(); | 1533 | c1->initListItem(); |
1848 | categories.insert (c1->getCategoryName(), c1); | 1534 | categories.insert (c1->getCategoryName(), c1); |
1849 | } | 1535 | } |
1850 | 1536 | ||
1851 | } | 1537 | } |
1852 | f.close(); | 1538 | f.close(); |
1853 | 1539 | ||
1854 | } | 1540 | } |
1855 | #endif // UNUSED | 1541 | #endif // UNUSED |
1856 | 1542 | ||
1857 | void ZSafe::resume(int) | 1543 | void ZSafe::resume(int) |
1858 | { | 1544 | { |
1859 | #ifndef NO_OPIE | ||
1860 | owarn << "Resume" << oendl; | ||
1861 | #endif | ||
1862 | // hide the main window | 1545 | // hide the main window |
1863 | 1546 | ||
1864 | if ( !showpwd ) | 1547 | if ( !showpwd ) |
1865 | { | 1548 | { |
1866 | infoForm->hide(); | 1549 | infoForm->hide(); |
1867 | // open zsafe again | 1550 | // open zsafe again |
1868 | m_password = ""; | 1551 | m_password = ""; |
1869 | selectedItem = NULL; | 1552 | selectedItem = NULL; |
1870 | 1553 | ||
1871 | // clear the password list | 1554 | // clear the password list |
1872 | QListViewItem *i; | 1555 | QListViewItem *i; |
1873 | // step through all categories | 1556 | // step through all categories |
@@ -1910,52 +1593,38 @@ bool ZSafe::openDocument(const char* _filename, const char* ) | |||
1910 | int pwdOk = 0; | 1593 | int pwdOk = 0; |
1911 | int numberOfTries = 3; | 1594 | int numberOfTries = 3; |
1912 | for (int i=0; i < numberOfTries; i++) | 1595 | for (int i=0; i < numberOfTries; i++) |
1913 | { | 1596 | { |
1914 | QFile f(_filename); | 1597 | QFile f(_filename); |
1915 | if (f.exists()) | 1598 | if (f.exists()) |
1916 | { | 1599 | { |
1917 | // ask with a dialog for the password | 1600 | // ask with a dialog for the password |
1918 | if (m_password.isEmpty()) | 1601 | if (m_password.isEmpty()) |
1919 | getDocPassword(tr("Enter Password")); | 1602 | getDocPassword(tr("Enter Password")); |
1920 | if (m_password.isEmpty() && validationFlag == 0) | 1603 | if (m_password.isEmpty() && validationFlag == 0) |
1921 | { | 1604 | { |
1922 | #ifndef NO_OPIE | ||
1923 | owarn << "Wrong password" << oendl; | ||
1924 | #else | ||
1925 | qWarning ("Wrong password"); | ||
1926 | #endif | ||
1927 | QMessageBox::critical( 0, tr("ZSafe"), | 1605 | QMessageBox::critical( 0, tr("ZSafe"), |
1928 | tr("Wrong password.\n\nZSafe will now exit.") ); | 1606 | tr("Wrong password.\n\nZSafe will now exit.") ); |
1929 | exitZs (1); | 1607 | exitZs (1); |
1930 | } | 1608 | } |
1931 | 1609 | ||
1932 | retval = loadInit(_filename, m_password); | 1610 | retval = loadInit(_filename, m_password); |
1933 | if (retval != PWERR_GOOD) | 1611 | if (retval != PWERR_GOOD) |
1934 | { | 1612 | { |
1935 | #ifndef NO_OPIE | ||
1936 | owarn << "Error loading Document" << oendl; | ||
1937 | #else | ||
1938 | qWarning ("Error loading Document"); | ||
1939 | #endif | ||
1940 | return false; | 1613 | return false; |
1941 | } | 1614 | } |
1942 | } | 1615 | } |
1943 | else | 1616 | else |
1944 | { | 1617 | { |
1945 | #ifdef Q_WS_WIN | 1618 | this->setCaption(tr("ZSafe")); |
1946 | this->setCaption("Qt ZSafe"); | ||
1947 | #else | ||
1948 | this->setCaption("ZSafe"); | ||
1949 | #endif | ||
1950 | filename = ""; | 1619 | filename = ""; |
1951 | switch( QMessageBox::warning( this, tr("ZSafe"), | 1620 | switch( QMessageBox::warning( this, tr("ZSafe"), |
1952 | tr("<P>You must create a new document first. Ok to create?</P>"), | 1621 | tr("<P>You must create a new document first. Ok to create?</P>"), |
1953 | tr("&Yes"), tr("&No."), | 1622 | tr("&Yes"), tr("&No."), |
1954 | 0 | 1623 | 0 |
1955 | ) ) | 1624 | ) ) |
1956 | { | 1625 | { |
1957 | case 1: // No | 1626 | case 1: // No |
1958 | return false; | 1627 | return false; |
1959 | break; | 1628 | break; |
1960 | case 0: // Yes | 1629 | case 0: // Yes |
1961 | newDocument(); | 1630 | newDocument(); |
@@ -2427,56 +2096,46 @@ bool ZSafe::saveDocument(const char* _filename, | |||
2427 | } | 2096 | } |
2428 | 2097 | ||
2429 | PasswordForm *newPwdDialog; | 2098 | PasswordForm *newPwdDialog; |
2430 | bool newPwdDialogResult = false; | 2099 | bool newPwdDialogResult = false; |
2431 | void ZSafe::setPasswordDialogDone() | 2100 | void ZSafe::setPasswordDialogDone() |
2432 | { | 2101 | { |
2433 | newPwdDialogResult = true; | 2102 | newPwdDialogResult = true; |
2434 | newPwdDialog->close(); | 2103 | newPwdDialog->close(); |
2435 | } | 2104 | } |
2436 | 2105 | ||
2437 | void ZSafe::getDocPassword(QString title) | 2106 | void ZSafe::getDocPassword(QString title) |
2438 | { | 2107 | { |
2439 | #ifndef NO_OPIE | ||
2440 | owarn << "getDocPassword" << oendl; | ||
2441 | #endif | ||
2442 | // open the 'Password' dialog | 2108 | // open the 'Password' dialog |
2443 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); | 2109 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); |
2444 | newPwdDialog = dialog; | 2110 | newPwdDialog = dialog; |
2445 | newPwdDialogResult = false; | 2111 | newPwdDialogResult = false; |
2446 | 2112 | ||
2447 | QPixmap image0( ( const char** ) zsafe_xpm ); | 2113 | QPixmap image0( ( const char** ) zsafe_xpm ); |
2448 | dialog->setIcon( image0); | 2114 | dialog->setIcon( image0); |
2449 | 2115 | ||
2450 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), | 2116 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), |
2451 | this, SLOT( setPasswordDialogDone() ) ); | 2117 | this, SLOT( setPasswordDialogDone() ) ); |
2452 | 2118 | ||
2453 | // CS: !!! | 2119 | // CS: !!! |
2454 | // int pos = filename.findRev ('/'); | 2120 | // int pos = filename.findRev ('/'); |
2455 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 2121 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
2456 | #ifdef Q_WS_WIN | ||
2457 | dialog->setCaption("Qt " + ti); | ||
2458 | #else | ||
2459 | dialog->setCaption(ti); | 2122 | dialog->setCaption(ti); |
2460 | #endif | ||
2461 | // dialog->setCaption(title); | 2123 | // dialog->setCaption(title); |
2462 | 2124 | ||
2463 | dialog->PasswordField->setFocus(); | 2125 | dialog->PasswordField->setFocus(); |
2464 | DialogCode result = (DialogCode) dialog->exec(); | 2126 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); |
2465 | #ifdef DESKTOP | ||
2466 | result = Accepted; | ||
2467 | #endif | ||
2468 | 2127 | ||
2469 | QString password; | 2128 | QString password; |
2470 | if (result == Accepted || newPwdDialogResult) | 2129 | if (result == QDialog::Accepted || newPwdDialogResult) |
2471 | { | 2130 | { |
2472 | m_password = dialog->PasswordField->text(); | 2131 | m_password = dialog->PasswordField->text(); |
2473 | } | 2132 | } |
2474 | else | 2133 | else |
2475 | { | 2134 | { |
2476 | exitZs (1); | 2135 | exitZs (1); |
2477 | } | 2136 | } |
2478 | } | 2137 | } |
2479 | 2138 | ||
2480 | int ZSafe::saveInit(const char *_filename, const char *password) | 2139 | int ZSafe::saveInit(const char *_filename, const char *password) |
2481 | { | 2140 | { |
2482 | char key[128]; | 2141 | char key[128]; |
@@ -2611,28 +2270,24 @@ int ZSafe::saveFinalize(void) | |||
2611 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; | 2270 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; |
2612 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; | 2271 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; |
2613 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; | 2272 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; |
2614 | } | 2273 | } |
2615 | 2274 | ||
2616 | fclose (fd); | 2275 | fclose (fd); |
2617 | free(buffer); | 2276 | free(buffer); |
2618 | return retval; | 2277 | return retval; |
2619 | } | 2278 | } |
2620 | 2279 | ||
2621 | void ZSafe::quitMe () | 2280 | void ZSafe::quitMe () |
2622 | { | 2281 | { |
2623 | #ifndef NO_OPIE | ||
2624 | owarn << "QUIT..." << oendl; | ||
2625 | #endif | ||
2626 | |||
2627 | if (modified) | 2282 | if (modified) |
2628 | { | 2283 | { |
2629 | switch( QMessageBox::information( this, tr("ZSafe"), | 2284 | switch( QMessageBox::information( this, tr("ZSafe"), |
2630 | tr("Do you want to save\nbefore exiting?"), | 2285 | tr("Do you want to save\nbefore exiting?"), |
2631 | tr("&Save"), | 2286 | tr("&Save"), |
2632 | tr("S&ave with\nnew\npassword"), | 2287 | tr("S&ave with\nnew\npassword"), |
2633 | tr("&Don't Save"), | 2288 | tr("&Don't Save"), |
2634 | 0 // Enter == button 0 | 2289 | 0 // Enter == button 0 |
2635 | ) ) | 2290 | ) ) |
2636 | { // Escape == button 2 | 2291 | { // Escape == button 2 |
2637 | case 0: // Save clicked, Alt-S or Enter pressed. | 2292 | case 0: // Save clicked, Alt-S or Enter pressed. |
2638 | // save | 2293 | // save |
@@ -2674,89 +2329,56 @@ void ZSafe::addCategory() | |||
2674 | { | 2329 | { |
2675 | // open the 'Category' dialog | 2330 | // open the 'Category' dialog |
2676 | bool initIcons = false; | 2331 | bool initIcons = false; |
2677 | // open the 'Category' dialog | 2332 | // open the 'Category' dialog |
2678 | CategoryDialog *dialog; | 2333 | CategoryDialog *dialog; |
2679 | if (categoryDialog) | 2334 | if (categoryDialog) |
2680 | { | 2335 | { |
2681 | dialog = categoryDialog; | 2336 | dialog = categoryDialog; |
2682 | } | 2337 | } |
2683 | else | 2338 | else |
2684 | { | 2339 | { |
2685 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2340 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2686 | #ifdef Q_WS_WIN | ||
2687 | categoryDialog->setCaption ("Qt " + tr("Category")); | ||
2688 | #endif | ||
2689 | dialog = categoryDialog; | 2341 | dialog = categoryDialog; |
2690 | connect( dialog->CategoryField, | 2342 | connect( dialog->CategoryField, |
2691 | SIGNAL( activated(const QString&)), | 2343 | SIGNAL( activated(const QString&)), |
2692 | this, SLOT( categoryFieldActivated(const QString&) ) ); | 2344 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
2693 | initIcons = true; | 2345 | initIcons = true; |
2694 | } | 2346 | } |
2695 | 2347 | ||
2696 | #ifdef DESKTOP | ||
2697 | #ifndef Q_WS_WIN | ||
2698 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | ||
2699 | #else | ||
2700 | // read all categories from the config file and store | 2348 | // read all categories from the config file and store |
2701 | // into a list | 2349 | // into a list |
2702 | QFile f (cfgFile); | 2350 | QFile f (cfgFile); |
2703 | QStringList list; | 2351 | QStringList list; |
2704 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2352 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2705 | QTextStream t( &f ); // use a text stream | 2353 | QTextStream t( &f ); // use a text stream |
2706 | QString s; | 2354 | QString s; |
2707 | int n = 1; | ||
2708 | while ( !t.eof() ) { // until end of file... | 2355 | while ( !t.eof() ) { // until end of file... |
2709 | s = t.readLine(); // line of text excluding '\n' | 2356 | s = t.readLine(); // line of text excluding '\n' |
2710 | list.append(s); | 2357 | list.append(s); |
2711 | } | 2358 | } |
2712 | f.close(); | 2359 | f.close(); |
2713 | } | 2360 | } |
2714 | #endif | ||
2715 | #else | ||
2716 | // read all categories from the config file and store | ||
2717 | // into a list | ||
2718 | QFile f (cfgFile); | ||
2719 | QStringList list; | ||
2720 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | ||
2721 | QTextStream t( &f ); // use a text stream | ||
2722 | QString s; | ||
2723 | while ( !t.eof() ) { // until end of file... | ||
2724 | s = t.readLine(); // line of text excluding '\n' | ||
2725 | list.append(s); | ||
2726 | } | ||
2727 | f.close(); | ||
2728 | } | ||
2729 | #endif | ||
2730 | QStringList::Iterator it = list.begin(); | 2361 | QStringList::Iterator it = list.begin(); |
2731 | QString categ; | 2362 | QString categ; |
2732 | QString firstCategory; | 2363 | QString firstCategory; |
2733 | dialog->CategoryField->clear(); // remove all items | 2364 | dialog->CategoryField->clear(); // remove all items |
2734 | while( it != list.end() ) | 2365 | while( it != list.end() ) |
2735 | { | 2366 | { |
2736 | QString *cat = new QString (*it); | 2367 | QString *cat = new QString (*it); |
2737 | if (cat->contains("-field1", FALSE)) | 2368 | if (cat->contains("-field1", FALSE)) |
2738 | { | 2369 | { |
2739 | #ifdef DESKTOP | ||
2740 | #ifndef Q_WS_WIN | ||
2741 | categ = cat->section ("-field1", 0, 0); | ||
2742 | #else | ||
2743 | int pos = cat->find ("-field1"); | ||
2744 | categ = cat->left (pos); | ||
2745 | #endif | ||
2746 | #else | ||
2747 | int pos = cat->find ("-field1"); | 2370 | int pos = cat->find ("-field1"); |
2748 | cat->truncate(pos); | 2371 | cat->truncate(pos); |
2749 | categ = *cat; | 2372 | categ = *cat; |
2750 | #endif | ||
2751 | if (!categ.isEmpty()) | 2373 | if (!categ.isEmpty()) |
2752 | { | 2374 | { |
2753 | dialog->CategoryField->insertItem (categ, -1); | 2375 | dialog->CategoryField->insertItem (categ, -1); |
2754 | if (firstCategory.isEmpty()) | 2376 | if (firstCategory.isEmpty()) |
2755 | firstCategory = categ; | 2377 | firstCategory = categ; |
2756 | } | 2378 | } |
2757 | } | 2379 | } |
2758 | ++it; | 2380 | ++it; |
2759 | } | 2381 | } |
2760 | 2382 | ||
2761 | 2383 | ||
2762 | if (firstCategory.isEmpty()) | 2384 | if (firstCategory.isEmpty()) |
@@ -2764,81 +2386,58 @@ void ZSafe::addCategory() | |||
2764 | else | 2386 | else |
2765 | setCategoryDialogFields(dialog, firstCategory); | 2387 | setCategoryDialogFields(dialog, firstCategory); |
2766 | 2388 | ||
2767 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); | 2389 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); |
2768 | 2390 | ||
2769 | if (initIcons) | 2391 | if (initIcons) |
2770 | { | 2392 | { |
2771 | Wait waitDialog(this, tr("Wait dialog")); | 2393 | Wait waitDialog(this, tr("Wait dialog")); |
2772 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2394 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
2773 | waitDialog.show(); | 2395 | waitDialog.show(); |
2774 | qApp->processEvents(); | 2396 | qApp->processEvents(); |
2775 | 2397 | ||
2776 | #ifdef DESKTOP | ||
2777 | QDir d(iconPath); | ||
2778 | #else | ||
2779 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2398 | QDir d(QPEApplication::qpeDir() + "pics/"); |
2780 | #endif | ||
2781 | d.setFilter( QDir::Files); | 2399 | d.setFilter( QDir::Files); |
2782 | 2400 | ||
2783 | const QFileInfoList *list = d.entryInfoList(); | 2401 | const QFileInfoList *list = d.entryInfoList(); |
2784 | QFileInfoListIterator it( *list ); // create list iterator | 2402 | QFileInfoListIterator it( *list ); // create list iterator |
2785 | QFileInfo *fi; // pointer for traversing | 2403 | QFileInfo *fi; // pointer for traversing |
2786 | 2404 | ||
2787 | dialog->IconField->insertItem("predefined"); | 2405 | dialog->IconField->insertItem("predefined"); |
2788 | while ( (fi=it.current()) ) { // for each file... | 2406 | while ( (fi=it.current()) ) { // for each file... |
2789 | QString fileName = fi->fileName(); | 2407 | QString fileName = fi->fileName(); |
2790 | if(fileName.right(4) == ".png"){ | 2408 | if(fileName.right(4) == ".png"){ |
2791 | fileName = fileName.mid(0,fileName.length()-4); | 2409 | fileName = fileName.mid(0,fileName.length()-4); |
2792 | #ifdef DESKTOP | ||
2793 | QPixmap imageOfFile; | ||
2794 | imageOfFile.load(iconPath + fi->fileName()); | ||
2795 | #else | ||
2796 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2410 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
2797 | #endif | ||
2798 | QImage foo = imageOfFile.convertToImage(); | 2411 | QImage foo = imageOfFile.convertToImage(); |
2799 | foo = foo.smoothScale(16,16); | 2412 | foo = foo.smoothScale(16,16); |
2800 | imageOfFile.convertFromImage(foo); | 2413 | imageOfFile.convertFromImage(foo); |
2801 | dialog->IconField->insertItem(imageOfFile,fileName); | 2414 | dialog->IconField->insertItem(imageOfFile,fileName); |
2802 | } | 2415 | } |
2803 | ++it; | 2416 | ++it; |
2804 | } | 2417 | } |
2805 | waitDialog.hide(); | 2418 | waitDialog.hide(); |
2806 | } | 2419 | } |
2807 | 2420 | ||
2808 | #ifndef Q_WS_WIN | 2421 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); |
2809 | dialog->show(); | ||
2810 | #endif | ||
2811 | #ifndef DESKTOP | ||
2812 | // dialog->move (20, 100); | ||
2813 | #endif | ||
2814 | DialogCode result = (DialogCode) dialog->exec(); | ||
2815 | #ifdef DESKTOP | ||
2816 | result = Accepted; | ||
2817 | #endif | ||
2818 | |||
2819 | QString category; | 2422 | QString category; |
2820 | QString icon; | 2423 | QString icon; |
2821 | QString fullIconPath; | 2424 | QString fullIconPath; |
2822 | QPixmap *pix; | 2425 | QPixmap *pix; |
2823 | if (result == Accepted) | 2426 | if (result == QDialog::Accepted) |
2824 | { | 2427 | { |
2825 | modified = true; | 2428 | modified = true; |
2826 | category = dialog->CategoryField->currentText(); | 2429 | category = dialog->CategoryField->currentText(); |
2827 | icon = dialog->IconField->currentText()+".png"; | 2430 | icon = dialog->IconField->currentText()+".png"; |
2828 | 2431 | ||
2829 | #ifndef NO_OPIE | ||
2830 | owarn << category << oendl; | ||
2831 | #endif | ||
2832 | |||
2833 | QListViewItem *li = new ShadedListItem( 1, ListView ); | 2432 | QListViewItem *li = new ShadedListItem( 1, ListView ); |
2834 | Category *c1 = new Category(); | 2433 | Category *c1 = new Category(); |
2835 | c1->setCategoryName(category); | 2434 | c1->setCategoryName(category); |
2836 | 2435 | ||
2837 | // if (!icon.isEmpty() && !icon.isNull()) | 2436 | // if (!icon.isEmpty() && !icon.isNull()) |
2838 | if (icon != "predefined.png") | 2437 | if (icon != "predefined.png") |
2839 | { | 2438 | { |
2840 | // build the full path | 2439 | // build the full path |
2841 | fullIconPath = iconPath + icon; | 2440 | fullIconPath = iconPath + icon; |
2842 | pix = new QPixmap (fullIconPath); | 2441 | pix = new QPixmap (fullIconPath); |
2843 | // pix->resize(14, 14); | 2442 | // pix->resize(14, 14); |
2844 | if (!pix->isNull()) | 2443 | if (!pix->isNull()) |
@@ -2948,29 +2547,25 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | |||
2948 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); | 2547 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); |
2949 | } | 2548 | } |
2950 | else | 2549 | else |
2951 | { | 2550 | { |
2952 | dialog->Field1->setText(tr("Name")); | 2551 | dialog->Field1->setText(tr("Name")); |
2953 | dialog->Field2->setText(tr("Username")); | 2552 | dialog->Field2->setText(tr("Username")); |
2954 | dialog->Field3->setText(tr("Password")); | 2553 | dialog->Field3->setText(tr("Password")); |
2955 | dialog->Field4->setText(tr("Comment")); | 2554 | dialog->Field4->setText(tr("Comment")); |
2956 | dialog->Field5->setText(tr("Field 4")); | 2555 | dialog->Field5->setText(tr("Field 4")); |
2957 | dialog->Field6->setText(tr("Field 5")); | 2556 | dialog->Field6->setText(tr("Field 5")); |
2958 | } | 2557 | } |
2959 | 2558 | ||
2960 | #ifdef DESKTOP | ||
2961 | QDir d(iconPath); | ||
2962 | #else | ||
2963 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2559 | QDir d(QPEApplication::qpeDir() + "pics/"); |
2964 | #endif | ||
2965 | d.setFilter( QDir::Files); | 2560 | d.setFilter( QDir::Files); |
2966 | 2561 | ||
2967 | const QFileInfoList *list = d.entryInfoList(); | 2562 | const QFileInfoList *list = d.entryInfoList(); |
2968 | int i=0; | 2563 | int i=0; |
2969 | QFileInfoListIterator it( *list ); // create list iterator | 2564 | QFileInfoListIterator it( *list ); // create list iterator |
2970 | QFileInfo *fi; // pointer for traversing | 2565 | QFileInfo *fi; // pointer for traversing |
2971 | if (icon.isEmpty() || icon.isNull()) | 2566 | if (icon.isEmpty() || icon.isNull()) |
2972 | { | 2567 | { |
2973 | dialog->IconField->setCurrentItem(0); | 2568 | dialog->IconField->setCurrentItem(0); |
2974 | } | 2569 | } |
2975 | else | 2570 | else |
2976 | { | 2571 | { |
@@ -3005,29 +2600,25 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | |||
3005 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); | 2600 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); |
3006 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); | 2601 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); |
3007 | 2602 | ||
3008 | QString icon; | 2603 | QString icon; |
3009 | Category *cat= categories.find (category); | 2604 | Category *cat= categories.find (category); |
3010 | if (cat) | 2605 | if (cat) |
3011 | { | 2606 | { |
3012 | icon = cat->getIconName(); | 2607 | icon = cat->getIconName(); |
3013 | } | 2608 | } |
3014 | else | 2609 | else |
3015 | icon = conf->readEntry(APP_KEY+category); | 2610 | icon = conf->readEntry(APP_KEY+category); |
3016 | 2611 | ||
3017 | #ifdef DESKTOP | ||
3018 | QDir d(iconPath); | ||
3019 | #else | ||
3020 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2612 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3021 | #endif | ||
3022 | d.setFilter( QDir::Files); | 2613 | d.setFilter( QDir::Files); |
3023 | 2614 | ||
3024 | const QFileInfoList *list = d.entryInfoList(); | 2615 | const QFileInfoList *list = d.entryInfoList(); |
3025 | int i=0; | 2616 | int i=0; |
3026 | QFileInfoListIterator it( *list ); // create list iterator | 2617 | QFileInfoListIterator it( *list ); // create list iterator |
3027 | QFileInfo *fi; // pointer for traversing | 2618 | QFileInfo *fi; // pointer for traversing |
3028 | if (icon.isEmpty() || icon.isNull()) | 2619 | if (icon.isEmpty() || icon.isNull()) |
3029 | { | 2620 | { |
3030 | dialog->IconField->setCurrentItem(0); | 2621 | dialog->IconField->setCurrentItem(0); |
3031 | } | 2622 | } |
3032 | else | 2623 | else |
3033 | { | 2624 | { |
@@ -3044,130 +2635,89 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | |||
3044 | break; | 2635 | break; |
3045 | } | 2636 | } |
3046 | ++i; | 2637 | ++i; |
3047 | } | 2638 | } |
3048 | ++it; | 2639 | ++it; |
3049 | } | 2640 | } |
3050 | } | 2641 | } |
3051 | } | 2642 | } |
3052 | 2643 | ||
3053 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) | 2644 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) |
3054 | { | 2645 | { |
3055 | QString app_key = APP_KEY; | 2646 | QString app_key = APP_KEY; |
3056 | #ifndef DESKTOP | ||
3057 | conf->setGroup ("fieldDefs"); | 2647 | conf->setGroup ("fieldDefs"); |
3058 | #else | ||
3059 | #ifndef Q_WS_WIN | ||
3060 | app_key += "/fieldDefs/"; | ||
3061 | #endif | ||
3062 | #endif | ||
3063 | QString category = dialog->CategoryField->currentText(); | 2648 | QString category = dialog->CategoryField->currentText(); |
3064 | // #ifndef Q_WS_WIN | 2649 | // #ifndef Q_WS_WIN |
3065 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); | 2650 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); |
3066 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); | 2651 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); |
3067 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); | 2652 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); |
3068 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); | 2653 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); |
3069 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); | 2654 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); |
3070 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); | 2655 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); |
3071 | // #endif | 2656 | // #endif |
3072 | saveConf(); | 2657 | saveConf(); |
3073 | #ifndef DESKTOP | ||
3074 | conf->setGroup ("zsafe"); | 2658 | conf->setGroup ("zsafe"); |
3075 | #endif | ||
3076 | } | 2659 | } |
3077 | 2660 | ||
3078 | void ZSafe::editCategory() | 2661 | void ZSafe::editCategory() |
3079 | { | 2662 | { |
3080 | if (!selectedItem) | 2663 | if (!selectedItem) |
3081 | return; | 2664 | return; |
3082 | if (isCategory(selectedItem)) | 2665 | if (isCategory(selectedItem)) |
3083 | { | 2666 | { |
3084 | QString category = selectedItem->text(0); | 2667 | QString category = selectedItem->text(0); |
3085 | bool initIcons = false; | 2668 | bool initIcons = false; |
3086 | // open the 'Category' dialog | 2669 | // open the 'Category' dialog |
3087 | CategoryDialog *dialog; | 2670 | CategoryDialog *dialog; |
3088 | if (categoryDialog) | 2671 | if (categoryDialog) |
3089 | { | 2672 | { |
3090 | dialog = categoryDialog; | 2673 | dialog = categoryDialog; |
3091 | } | 2674 | } |
3092 | else | 2675 | else |
3093 | { | 2676 | { |
3094 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2677 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
3095 | #ifdef Q_WS_WIN | ||
3096 | categoryDialog->setCaption ("Qt " + tr("Category")); | ||
3097 | #endif | ||
3098 | dialog = categoryDialog; | 2678 | dialog = categoryDialog; |
3099 | connect( dialog->CategoryField, | 2679 | connect( dialog->CategoryField, |
3100 | SIGNAL( activated(const QString&)), | 2680 | SIGNAL( activated(const QString&)), |
3101 | this, SLOT( categoryFieldActivated(const QString&) ) ); | 2681 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
3102 | initIcons = true; | 2682 | initIcons = true; |
3103 | } | 2683 | } |
3104 | setCategoryDialogFields(dialog); | 2684 | setCategoryDialogFields(dialog); |
3105 | 2685 | ||
3106 | #ifdef DESKTOP | ||
3107 | #ifndef Q_WS_WIN | ||
3108 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | ||
3109 | #else | ||
3110 | // read all categories from the config file and store | ||
3111 | // into a list | ||
3112 | QFile f (cfgFile); | ||
3113 | QStringList list; | ||
3114 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | ||
3115 | QTextStream t( &f ); // use a text stream | ||
3116 | QString s; | ||
3117 | int n = 1; | ||
3118 | while ( !t.eof() ) { // until end of file... | ||
3119 | s = t.readLine(); // line of text excluding '\n' | ||
3120 | list.append(s); | ||
3121 | } | ||
3122 | f.close(); | ||
3123 | } | ||
3124 | #endif | ||
3125 | #else | ||
3126 | // read all categories from the config file and store | 2686 | // read all categories from the config file and store |
3127 | // into a list | 2687 | // into a list |
3128 | QFile f (cfgFile); | 2688 | QFile f (cfgFile); |
3129 | QStringList list; | 2689 | QStringList list; |
3130 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2690 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3131 | QTextStream t( &f ); // use a text stream | 2691 | QTextStream t( &f ); // use a text stream |
3132 | QString s; | 2692 | QString s; |
3133 | while ( !t.eof() ) { // until end of file... | 2693 | while ( !t.eof() ) { // until end of file... |
3134 | s = t.readLine(); // line of text excluding '\n' | 2694 | s = t.readLine(); // line of text excluding '\n' |
3135 | list.append(s); | 2695 | list.append(s); |
3136 | } | 2696 | } |
3137 | f.close(); | 2697 | f.close(); |
3138 | } | 2698 | } |
3139 | #endif | ||
3140 | QStringList::Iterator it = list.begin(); | 2699 | QStringList::Iterator it = list.begin(); |
3141 | QString categ; | 2700 | QString categ; |
3142 | dialog->CategoryField->clear(); // remove all items | 2701 | dialog->CategoryField->clear(); // remove all items |
3143 | int i=0; | 2702 | int i=0; |
3144 | bool foundCategory = false; | 2703 | bool foundCategory = false; |
3145 | while( it != list.end() ) | 2704 | while( it != list.end() ) |
3146 | { | 2705 | { |
3147 | QString *cat = new QString (*it); | 2706 | QString *cat = new QString (*it); |
3148 | if (cat->contains("-field1", FALSE)) | 2707 | if (cat->contains("-field1", FALSE)) |
3149 | { | 2708 | { |
3150 | #ifdef DESKTOP | ||
3151 | #ifndef Q_WS_WIN | ||
3152 | categ = cat->section ("-field1", 0, 0); | ||
3153 | #else | ||
3154 | int pos = cat->find ("-field1"); | ||
3155 | categ = cat->left (pos); | ||
3156 | #endif | ||
3157 | #else | ||
3158 | int pos = cat->find ("-field1"); | 2709 | int pos = cat->find ("-field1"); |
3159 | cat->truncate(pos); | 2710 | cat->truncate(pos); |
3160 | categ = *cat; | 2711 | categ = *cat; |
3161 | #endif | ||
3162 | if (!categ.isEmpty()) | 2712 | if (!categ.isEmpty()) |
3163 | { | 2713 | { |
3164 | dialog->CategoryField->insertItem (categ, i); | 2714 | dialog->CategoryField->insertItem (categ, i); |
3165 | if (category.compare(categ) == 0) | 2715 | if (category.compare(categ) == 0) |
3166 | { | 2716 | { |
3167 | dialog->CategoryField->setCurrentItem(i); | 2717 | dialog->CategoryField->setCurrentItem(i); |
3168 | foundCategory = true; | 2718 | foundCategory = true; |
3169 | } | 2719 | } |
3170 | i++; | 2720 | i++; |
3171 | } | 2721 | } |
3172 | } | 2722 | } |
3173 | ++it; | 2723 | ++it; |
@@ -3184,72 +2734,58 @@ void ZSafe::editCategory() | |||
3184 | { | 2734 | { |
3185 | icon = cat->getIconName(); | 2735 | icon = cat->getIconName(); |
3186 | } | 2736 | } |
3187 | 2737 | ||
3188 | if (initIcons) | 2738 | if (initIcons) |
3189 | { | 2739 | { |
3190 | 2740 | ||
3191 | Wait waitDialog(this, tr("Wait dialog")); | 2741 | Wait waitDialog(this, tr("Wait dialog")); |
3192 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2742 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
3193 | waitDialog.show(); | 2743 | waitDialog.show(); |
3194 | qApp->processEvents(); | 2744 | qApp->processEvents(); |
3195 | 2745 | ||
3196 | #ifdef DESKTOP | ||
3197 | QDir d(iconPath); | ||
3198 | #else | ||
3199 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2746 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3200 | #endif | ||
3201 | d.setFilter( QDir::Files); | 2747 | d.setFilter( QDir::Files); |
3202 | 2748 | ||
3203 | const QFileInfoList *list = d.entryInfoList(); | 2749 | const QFileInfoList *list = d.entryInfoList(); |
3204 | int i=0; | 2750 | int i=0; |
3205 | QFileInfoListIterator it( *list ); // create list iterator | 2751 | QFileInfoListIterator it( *list ); // create list iterator |
3206 | QFileInfo *fi; // pointer for traversing | 2752 | QFileInfo *fi; // pointer for traversing |
3207 | if (icon.isEmpty() || icon.isNull()) | 2753 | if (icon.isEmpty() || icon.isNull()) |
3208 | { | 2754 | { |
3209 | dialog->IconField->setCurrentItem(0); | 2755 | dialog->IconField->setCurrentItem(0); |
3210 | } | 2756 | } |
3211 | 2757 | ||
3212 | dialog->IconField->insertItem("predefined"); | 2758 | dialog->IconField->insertItem("predefined"); |
3213 | while ( (fi=it.current()) ) { // for each file... | 2759 | while ( (fi=it.current()) ) { // for each file... |
3214 | QString fileName = fi->fileName(); | 2760 | QString fileName = fi->fileName(); |
3215 | if(fileName.right(4) == ".png") | 2761 | if(fileName.right(4) == ".png") |
3216 | { | 2762 | { |
3217 | fileName = fileName.mid(0,fileName.length()-4); | 2763 | fileName = fileName.mid(0,fileName.length()-4); |
3218 | #ifdef DESKTOP | ||
3219 | QPixmap imageOfFile; | ||
3220 | imageOfFile.load(iconPath + fi->fileName()); | ||
3221 | #else | ||
3222 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2764 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
3223 | #endif | ||
3224 | QImage foo = imageOfFile.convertToImage(); | 2765 | QImage foo = imageOfFile.convertToImage(); |
3225 | foo = foo.smoothScale(16,16); | 2766 | foo = foo.smoothScale(16,16); |
3226 | imageOfFile.convertFromImage(foo); | 2767 | imageOfFile.convertFromImage(foo); |
3227 | dialog->IconField->insertItem(imageOfFile,fileName); | 2768 | dialog->IconField->insertItem(imageOfFile,fileName); |
3228 | if(fileName+".png"==icon) | 2769 | if(fileName+".png"==icon) |
3229 | dialog->IconField->setCurrentItem(i+1); | 2770 | dialog->IconField->setCurrentItem(i+1); |
3230 | ++i; | 2771 | ++i; |
3231 | } | 2772 | } |
3232 | ++it; | 2773 | ++it; |
3233 | } | 2774 | } |
3234 | waitDialog.hide(); | 2775 | waitDialog.hide(); |
3235 | } | 2776 | } |
3236 | else | 2777 | else |
3237 | { | 2778 | { |
3238 | #ifdef DESKTOP | ||
3239 | // QDir d(QDir::homeDirPath() + "/pics/"); | ||
3240 | QDir d(iconPath); | ||
3241 | #else | ||
3242 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2779 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3243 | #endif | ||
3244 | d.setFilter( QDir::Files); | 2780 | d.setFilter( QDir::Files); |
3245 | 2781 | ||
3246 | const QFileInfoList *list = d.entryInfoList(); | 2782 | const QFileInfoList *list = d.entryInfoList(); |
3247 | int i=0; | 2783 | int i=0; |
3248 | QFileInfoListIterator it( *list ); // create list iterator | 2784 | QFileInfoListIterator it( *list ); // create list iterator |
3249 | QFileInfo *fi; // pointer for traversing | 2785 | QFileInfo *fi; // pointer for traversing |
3250 | if (icon.isEmpty() || icon.isNull()) | 2786 | if (icon.isEmpty() || icon.isNull()) |
3251 | { | 2787 | { |
3252 | dialog->IconField->setCurrentItem(0); | 2788 | dialog->IconField->setCurrentItem(0); |
3253 | } | 2789 | } |
3254 | else | 2790 | else |
3255 | { | 2791 | { |
@@ -3266,57 +2802,45 @@ void ZSafe::editCategory() | |||
3266 | { | 2802 | { |
3267 | dialog->IconField->setCurrentItem(i+1); | 2803 | dialog->IconField->setCurrentItem(i+1); |
3268 | break; | 2804 | break; |
3269 | } | 2805 | } |
3270 | ++i; | 2806 | ++i; |
3271 | } | 2807 | } |
3272 | ++it; | 2808 | ++it; |
3273 | } | 2809 | } |
3274 | } | 2810 | } |
3275 | } | 2811 | } |
3276 | 2812 | ||
3277 | // dialog->show(); | 2813 | // dialog->show(); |
3278 | #ifndef DESKTOP | 2814 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); |
3279 | // dialog->move (20, 100); | ||
3280 | #endif | ||
3281 | DialogCode result = (DialogCode) dialog->exec(); | ||
3282 | #ifdef DESKTOP | ||
3283 | result = Accepted; | ||
3284 | #endif | ||
3285 | 2815 | ||
3286 | QString fullIconPath; | 2816 | QString fullIconPath; |
3287 | QPixmap *pix; | 2817 | QPixmap *pix; |
3288 | if (result == Accepted) | 2818 | if (result == QDialog::Accepted) |
3289 | { | 2819 | { |
3290 | modified = true; | 2820 | modified = true; |
3291 | if (category != dialog->CategoryField->currentText()) | 2821 | if (category != dialog->CategoryField->currentText()) |
3292 | { | 2822 | { |
3293 | categories.remove (category); | 2823 | categories.remove (category); |
3294 | // #ifndef Q_WS_WIN | 2824 | // #ifndef Q_WS_WIN |
3295 | conf->removeEntry(category); | 2825 | conf->removeEntry(category); |
3296 | // #endif | 2826 | // #endif |
3297 | saveConf(); | 2827 | saveConf(); |
3298 | } | 2828 | } |
3299 | 2829 | ||
3300 | category = dialog->CategoryField->currentText(); | 2830 | category = dialog->CategoryField->currentText(); |
3301 | icon = dialog->IconField->currentText()+".png"; | 2831 | icon = dialog->IconField->currentText()+".png"; |
3302 | 2832 | ||
3303 | if (cat) | 2833 | if (cat) |
3304 | { | 2834 | { |
3305 | #ifndef NO_OPIE | ||
3306 | owarn << "Category found" << oendl; | ||
3307 | #else | ||
3308 | qWarning("Category found"); | ||
3309 | #endif | ||
3310 | |||
3311 | // if (!icon.isEmpty() && !icon.isNull()) | 2835 | // if (!icon.isEmpty() && !icon.isNull()) |
3312 | if (icon != "predefined.png") | 2836 | if (icon != "predefined.png") |
3313 | { | 2837 | { |
3314 | // build the full path | 2838 | // build the full path |
3315 | fullIconPath = iconPath + icon; | 2839 | fullIconPath = iconPath + icon; |
3316 | pix = new QPixmap (fullIconPath); | 2840 | pix = new QPixmap (fullIconPath); |
3317 | if (!pix->isNull()) | 2841 | if (!pix->isNull()) |
3318 | { | 2842 | { |
3319 | // save the full pixmap name into the config file | 2843 | // save the full pixmap name into the config file |
3320 | // #ifndef Q_WS_WIN | 2844 | // #ifndef Q_WS_WIN |
3321 | conf->writeEntry(APP_KEY+category, icon); | 2845 | conf->writeEntry(APP_KEY+category, icon); |
3322 | // #endif | 2846 | // #endif |
@@ -3331,29 +2855,24 @@ void ZSafe::editCategory() | |||
3331 | { | 2855 | { |
3332 | // #ifndef Q_WS_WIN | 2856 | // #ifndef Q_WS_WIN |
3333 | conf->removeEntry (category); | 2857 | conf->removeEntry (category); |
3334 | // #endif | 2858 | // #endif |
3335 | saveConf(); | 2859 | saveConf(); |
3336 | cat->setIcon (*getPredefinedIcon(category)); | 2860 | cat->setIcon (*getPredefinedIcon(category)); |
3337 | } | 2861 | } |
3338 | 2862 | ||
3339 | // change the category name of the selected category | 2863 | // change the category name of the selected category |
3340 | QListViewItem *catItem = cat->getListItem(); | 2864 | QListViewItem *catItem = cat->getListItem(); |
3341 | if (catItem) | 2865 | if (catItem) |
3342 | { | 2866 | { |
3343 | #ifndef NO_OPIE | ||
3344 | owarn << category << oendl; | ||
3345 | #else | ||
3346 | qWarning (category); | ||
3347 | #endif | ||
3348 | catItem->setText( 0, tr( category ) ); | 2867 | catItem->setText( 0, tr( category ) ); |
3349 | cat->setCategoryName (tr(category)); | 2868 | cat->setCategoryName (tr(category)); |
3350 | 2869 | ||
3351 | cat->initListItem(); | 2870 | cat->initListItem(); |
3352 | categories.insert (category, cat); | 2871 | categories.insert (category, cat); |
3353 | } | 2872 | } |
3354 | } | 2873 | } |
3355 | saveCategoryDialogFields(dialog); | 2874 | saveCategoryDialogFields(dialog); |
3356 | } | 2875 | } |
3357 | else | 2876 | else |
3358 | { | 2877 | { |
3359 | // delete dialog; | 2878 | // delete dialog; |
@@ -3472,71 +2991,52 @@ void ZSafe::newDocument() | |||
3472 | if (_si) delete _si; | 2991 | if (_si) delete _si; |
3473 | } | 2992 | } |
3474 | } | 2993 | } |
3475 | if (c) delete c; // delete the previous category | 2994 | if (c) delete c; // delete the previous category |
3476 | categories.clear(); | 2995 | categories.clear(); |
3477 | 2996 | ||
3478 | // m_password = ""; | 2997 | // m_password = ""; |
3479 | selectedItem = NULL; | 2998 | selectedItem = NULL; |
3480 | 2999 | ||
3481 | filename = newFile; | 3000 | filename = newFile; |
3482 | 3001 | ||
3483 | // save the current filename to the config file | 3002 | // save the current filename to the config file |
3003 | conf->setGroup("zsafe"); | ||
3484 | conf->writeEntry(APP_KEY+"document", filename); | 3004 | conf->writeEntry(APP_KEY+"document", filename); |
3485 | saveConf(); | 3005 | saveConf(); |
3486 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3006 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3487 | #ifdef Q_WS_WIN | 3007 | this->setCaption(tr("ZSafe: ") + ti); |
3488 | this->setCaption("Qt ZSafe: " + ti); | ||
3489 | #else | ||
3490 | this->setCaption("ZSafe: " + ti); | ||
3491 | #endif | ||
3492 | 3008 | ||
3493 | // openDocument(filename); | 3009 | // openDocument(filename); |
3494 | 3010 | ||
3495 | QMessageBox::information( this, tr("ZSafe"), | 3011 | QMessageBox::information( this, tr("ZSafe"), |
3496 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3012 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3497 | 3013 | ||
3498 | saveDocumentWithPwd(); | 3014 | saveDocumentWithPwd(); |
3499 | } | 3015 | } |
3500 | } | 3016 | } |
3501 | 3017 | ||
3502 | void ZSafe::loadDocument() | 3018 | void ZSafe::loadDocument() |
3503 | { | 3019 | { |
3504 | 3020 | ||
3505 | // open the file dialog | 3021 | // open the file dialog |
3506 | #ifndef DESKTOP | ||
3507 | #ifndef NO_OPIE | ||
3508 | QMap<QString, QStringList> mimeTypes; | 3022 | QMap<QString, QStringList> mimeTypes; |
3509 | mimeTypes.insert(tr("All"), QStringList() ); | 3023 | mimeTypes.insert(tr("All"), QStringList() ); |
3510 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3024 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3511 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 3025 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
3512 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3026 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3513 | QString::null, | 3027 | QString::null, |
3514 | mimeTypes, | 3028 | mimeTypes, |
3515 | this, | 3029 | this, |
3516 | tr ("Open ZSafe document")); | 3030 | tr ("Open ZSafe document")); |
3517 | #else | ||
3518 | QString newFile = ScQtFileEdit::getOpenFileName(this, | ||
3519 | tr ("Open ZSafe document"), | ||
3520 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3521 | "*.zsf"); | ||
3522 | #endif | ||
3523 | #else | ||
3524 | QString newFile = QFileDialog::getOpenFileName( | ||
3525 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3526 | "ZSafe (*.zsf)", | ||
3527 | this, | ||
3528 | "ZSafe File Dialog" | ||
3529 | "Choose a ZSafe file" ); | ||
3530 | #endif | ||
3531 | 3031 | ||
3532 | // open the new document | 3032 | // open the new document |
3533 | if (newFile && newFile.length() > 0 ) | 3033 | if (newFile && newFile.length() > 0 ) |
3534 | { | 3034 | { |
3535 | // save the previous opened document | 3035 | // save the previous opened document |
3536 | if (!filename.isEmpty()) | 3036 | if (!filename.isEmpty()) |
3537 | saveDocument(filename, FALSE); | 3037 | saveDocument(filename, FALSE); |
3538 | 3038 | ||
3539 | // clear the password list | 3039 | // clear the password list |
3540 | QListViewItem *i; | 3040 | QListViewItem *i; |
3541 | QListViewItem *c = NULL; | 3041 | QListViewItem *c = NULL; |
3542 | // step through all categories | 3042 | // step through all categories |
@@ -3556,162 +3056,127 @@ void ZSafe::loadDocument() | |||
3556 | si = si->nextSibling(); | 3056 | si = si->nextSibling(); |
3557 | i->takeItem(_si); // remove from view list | 3057 | i->takeItem(_si); // remove from view list |
3558 | if (_si) delete _si; | 3058 | if (_si) delete _si; |
3559 | } | 3059 | } |
3560 | } | 3060 | } |
3561 | if (c) delete c; // delete the previous category | 3061 | if (c) delete c; // delete the previous category |
3562 | categories.clear(); | 3062 | categories.clear(); |
3563 | m_password = ""; | 3063 | m_password = ""; |
3564 | selectedItem = NULL; | 3064 | selectedItem = NULL; |
3565 | filename = newFile; | 3065 | filename = newFile; |
3566 | 3066 | ||
3567 | // save the current filename to the config file | 3067 | // save the current filename to the config file |
3068 | conf->setGroup("zsafe"); | ||
3568 | conf->writeEntry(APP_KEY+"document", filename); | 3069 | conf->writeEntry(APP_KEY+"document", filename); |
3569 | saveConf(); | 3070 | saveConf(); |
3570 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3071 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3571 | #ifdef Q_WS_WIN | 3072 | this->setCaption(tr("ZSafe: ") + ti); |
3572 | this->setCaption("Qt ZSafe: " + ti); | ||
3573 | #else | ||
3574 | this->setCaption("ZSafe: " + ti); | ||
3575 | #endif | ||
3576 | 3073 | ||
3577 | openDocument(filename); | 3074 | openDocument(filename); |
3578 | } | 3075 | } |
3579 | } | 3076 | } |
3580 | 3077 | ||
3581 | void ZSafe::saveDocumentAs() | 3078 | void ZSafe::saveDocumentAs() |
3582 | { | 3079 | { |
3583 | 3080 | ||
3584 | QString newFile = zsaveDialog(); | 3081 | QString newFile = zsaveDialog(); |
3585 | // open the new document | 3082 | // open the new document |
3586 | if (newFile && newFile.length() > 0 ) | 3083 | if (newFile && newFile.length() > 0 ) |
3587 | { | 3084 | { |
3588 | // save the previous opened document | 3085 | // save the previous opened document |
3589 | if (!filename.isEmpty()) | 3086 | if (!filename.isEmpty()) |
3590 | saveDocument(filename, FALSE); | 3087 | saveDocument(filename, FALSE); |
3591 | 3088 | ||
3592 | selectedItem = NULL; | 3089 | selectedItem = NULL; |
3593 | filename = newFile; | 3090 | filename = newFile; |
3594 | 3091 | ||
3595 | // save the current filename to the config file | 3092 | // save the current filename to the config file |
3093 | conf->setGroup("zsafe"); | ||
3596 | conf->writeEntry(APP_KEY+"document", filename); | 3094 | conf->writeEntry(APP_KEY+"document", filename); |
3597 | saveConf(); | 3095 | saveConf(); |
3598 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3096 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3599 | #ifdef Q_WS_WIN | 3097 | this->setCaption(tr("ZSafe: ") + ti); |
3600 | this->setCaption("Qt ZSafe: " + ti); | ||
3601 | #else | ||
3602 | this->setCaption("ZSafe: " + ti); | ||
3603 | #endif | ||
3604 | 3098 | ||
3605 | QMessageBox::information( this, tr("ZSafe"), | 3099 | QMessageBox::information( this, tr("ZSafe"), |
3606 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3100 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3607 | 3101 | ||
3608 | saveDocumentWithPwd(); | 3102 | saveDocumentWithPwd(); |
3609 | } | 3103 | } |
3610 | } | 3104 | } |
3611 | 3105 | ||
3612 | void ZSafe::saveDocumentWithoutPwd() | 3106 | void ZSafe::saveDocumentWithoutPwd() |
3613 | { | 3107 | { |
3614 | saveDocument(filename, FALSE); | 3108 | saveDocument(filename, FALSE); |
3615 | } | 3109 | } |
3616 | 3110 | ||
3617 | void ZSafe::saveDocumentWithPwd() | 3111 | void ZSafe::saveDocumentWithPwd() |
3618 | { | 3112 | { |
3619 | saveDocument(filename, TRUE); | 3113 | saveDocument(filename, TRUE); |
3620 | } | 3114 | } |
3621 | 3115 | ||
3622 | void ZSafe::about() | 3116 | void ZSafe::about() |
3623 | { | 3117 | { |
3624 | QString info; | 3118 | QString info; |
3625 | #ifdef JPATCH_HDE | 3119 | info = tr("<html><body><div align=""center"">" |
3626 | info = "<html><body><div align=""center"">"; | 3120 | "<b>" |
3627 | info += "<b>"; | 3121 | "Zaurus Password Manager<br>" |
3628 | info += tr("Zaurus Password Manager<br>"); | 3122 | "ZSafe version 2.1.2<br>" |
3629 | info += tr("ZSafe version 2.1.2-jv01b<br>"); | 3123 | "</b>" |
3630 | info += "</b>"; | 3124 | "by Carsten Schneider<br>" |
3631 | info += tr("by Carsten Schneider<br>"); | 3125 | "zcarsten@gmx.net<br>" |
3632 | info += "zcarsten@gmx.net<br>"; | 3126 | "http://z-soft.z-portal.info/zsafe" |
3633 | info += "http://z-soft.z-portal.info/zsafe"; | 3127 | "<br>" |
3634 | info += "<br>"; | 3128 | "Translations by Robert Ernst<br>" |
3635 | info += tr("Translations by Robert Ernst<br>"); | 3129 | "robert.ernst@linux-solutions.at<br>" |
3636 | info += "robert.ernst@linux-solutions.at<br>"; | 3130 | "<br></div>" |
3637 | 3131 | "</body></html>"); | |
3638 | info += "<br><br>"; | ||
3639 | info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>"); | ||
3640 | info += "HADECO R&D<br>"; | ||
3641 | info += "r&d@hadeco.co.jp<br>"; | ||
3642 | info += "http://www.hadeco.co.jp/r&d/<br>"; | ||
3643 | info += "<br></div>"; | ||
3644 | info += "</body></html>"; | ||
3645 | #else | ||
3646 | info = "<html><body><div align=""center"">"; | ||
3647 | info += "<b>"; | ||
3648 | info += tr("Zaurus Password Manager<br>"); | ||
3649 | info += tr("ZSafe version 2.1.2<br>"); | ||
3650 | info += "</b>"; | ||
3651 | info += tr("by Carsten Schneider<br>"); | ||
3652 | info += "zcarsten@gmx.net<br>"; | ||
3653 | info += "http://z-soft.z-portal.info/zsafe"; | ||
3654 | info += "<br>"; | ||
3655 | info += tr("Translations by Robert Ernst<br>"); | ||
3656 | info += "robert.ernst@linux-solutions.at<br>"; | ||
3657 | info += "<br></div>"; | ||
3658 | info += "</body></html>"; | ||
3659 | #endif | ||
3660 | 3132 | ||
3661 | // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); | 3133 | // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); |
3662 | 3134 | ||
3663 | QMessageBox mb( this, tr("ZSafe")); | 3135 | QMessageBox mb( this, tr("ZSafe")); |
3664 | mb.setText (info); | 3136 | mb.setText (info); |
3665 | mb.setButtonText (QMessageBox::Ok, tr ("&OK")); | 3137 | mb.setButtonText (QMessageBox::Ok, tr ("&OK")); |
3666 | QPixmap zsafe_img((const char**) zsafe_xpm); | 3138 | QPixmap zsafe_img((const char**) zsafe_xpm); |
3667 | mb.setIconPixmap (zsafe_img); | 3139 | mb.setIconPixmap (zsafe_img); |
3668 | mb.exec(); | 3140 | mb.exec(); |
3669 | } | 3141 | } |
3670 | 3142 | ||
3671 | void ZSafe::setExpandFlag() | 3143 | void ZSafe::setExpandFlag() |
3672 | { | 3144 | { |
3673 | expandTree = !expandTree; | 3145 | expandTree = !expandTree; |
3674 | file->setItemChecked('o', expandTree); | 3146 | file->setItemChecked('o', expandTree); |
3675 | #ifndef DESKTOP | ||
3676 | conf->setGroup ("zsafePrefs"); | 3147 | conf->setGroup ("zsafePrefs"); |
3677 | #endif | ||
3678 | // #ifndef Q_WS_WIN | 3148 | // #ifndef Q_WS_WIN |
3679 | conf->writeEntry (APP_KEY+"expandTree", expandTree); | 3149 | conf->writeEntry (APP_KEY+"expandTree", expandTree); |
3680 | // #endif | 3150 | // #endif |
3681 | saveConf(); | 3151 | saveConf(); |
3682 | 3152 | ||
3683 | } | 3153 | } |
3684 | 3154 | ||
3685 | void ZSafe::paintEvent( QPaintEvent * ) | 3155 | void ZSafe::paintEvent( QPaintEvent * ) |
3686 | { | 3156 | { |
3687 | if (raiseFlag) | 3157 | if (raiseFlag) |
3688 | { | 3158 | { |
3689 | raiseFlag = false; | 3159 | raiseFlag = false; |
3690 | raiseTimer.start (1, true); | 3160 | raiseTimer.start (1, true); |
3691 | if (infoForm->isVisible()) | 3161 | if (infoForm->isVisible()) |
3692 | infoForm->raise(); | 3162 | infoForm->raise(); |
3693 | } | 3163 | } |
3694 | } | 3164 | } |
3695 | 3165 | ||
3696 | void ZSafe::resizeEvent ( QResizeEvent * ) | 3166 | void ZSafe::resizeEvent ( QResizeEvent * ) |
3697 | { | 3167 | { |
3698 | // owarn << "resizeEvent" << oendl; | 3168 | // owarn << "resizeEvent" << oendl; |
3699 | #ifndef DESKTOP | ||
3700 | DeskW = appl->desktop()->width(); | 3169 | DeskW = appl->desktop()->width(); |
3701 | DeskH = appl->desktop()->height(); | 3170 | DeskH = appl->desktop()->height(); |
3702 | #else | ||
3703 | DeskW = this->width(); | ||
3704 | DeskH = this->height(); | ||
3705 | #endif | ||
3706 | 3171 | ||
3707 | if (New) | 3172 | if (New) |
3708 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); | 3173 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); |
3709 | if (Edit) | 3174 | if (Edit) |
3710 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); | 3175 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); |
3711 | if (Delete) | 3176 | if (Delete) |
3712 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 3177 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
3713 | if (Find) | 3178 | if (Find) |
3714 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); | 3179 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); |
3715 | } | 3180 | } |
3716 | 3181 | ||
3717 | void ZSafe::slotRaiseTimer() | 3182 | void ZSafe::slotRaiseTimer() |
@@ -3730,50 +3195,46 @@ QPixmap * ZSafe::getPredefinedIcon(QString category) | |||
3730 | pm = new QPixmap((const char**)passwords_data); | 3195 | pm = new QPixmap((const char**)passwords_data); |
3731 | else if (category == "Software") | 3196 | else if (category == "Software") |
3732 | pm = new QPixmap((const char**)software_data); | 3197 | pm = new QPixmap((const char**)software_data); |
3733 | else if (category == "General") | 3198 | else if (category == "General") |
3734 | pm = new QPixmap((const char**)general_data); | 3199 | pm = new QPixmap((const char**)general_data); |
3735 | else | 3200 | else |
3736 | pm = new QPixmap((const char**)general_data); | 3201 | pm = new QPixmap((const char**)general_data); |
3737 | return pm; | 3202 | return pm; |
3738 | } | 3203 | } |
3739 | 3204 | ||
3740 | void ZSafe::setDocument(const QString& fileref) | 3205 | void ZSafe::setDocument(const QString& fileref) |
3741 | { | 3206 | { |
3742 | #ifndef DESKTOP | ||
3743 | // stop the timer to prevent loading of the default document | 3207 | // stop the timer to prevent loading of the default document |
3744 | docuTimer.stop(); | 3208 | docuTimer.stop(); |
3745 | 3209 | ||
3746 | DocLnk link(fileref); | 3210 | DocLnk link(fileref); |
3747 | if ( link.isValid() ) | 3211 | if ( link.isValid() ) |
3748 | { | 3212 | { |
3749 | // if (filename != link.file()) | 3213 | // if (filename != link.file()) |
3750 | // saveDocument(filename, FALSE); | 3214 | // saveDocument(filename, FALSE); |
3751 | filename = link.file(); | 3215 | filename = link.file(); |
3752 | } | 3216 | } |
3753 | else | 3217 | else |
3754 | { | 3218 | { |
3755 | // if (filename != fileref) | 3219 | // if (filename != fileref) |
3756 | // saveDocument(filename, FALSE); | 3220 | // saveDocument(filename, FALSE); |
3757 | filename = fileref; | 3221 | filename = fileref; |
3758 | } | 3222 | } |
3759 | // save the current filename to the config file | 3223 | // save the current filename to the config file |
3224 | conf->setGroup("zsafe"); | ||
3760 | conf->writeEntry(APP_KEY+"document", filename); | 3225 | conf->writeEntry(APP_KEY+"document", filename); |
3761 | saveConf(); | 3226 | saveConf(); |
3762 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3227 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3763 | #ifdef Q_WS_WIN | 3228 | this->setCaption(tr("ZSafe: ") + ti); |
3764 | this->setCaption("Qt ZSafe: " + ti); | ||
3765 | #else | ||
3766 | this->setCaption("ZSafe: " + ti); | ||
3767 | #endif | ||
3768 | 3229 | ||
3769 | // clear the password list | 3230 | // clear the password list |
3770 | QListViewItem *i; | 3231 | QListViewItem *i; |
3771 | QListViewItem *c = NULL; | 3232 | QListViewItem *c = NULL; |
3772 | // step through all categories | 3233 | // step through all categories |
3773 | for (i = ListView->firstChild(); | 3234 | for (i = ListView->firstChild(); |
3774 | i != NULL; | 3235 | i != NULL; |
3775 | i = i->nextSibling()) | 3236 | i = i->nextSibling()) |
3776 | { | 3237 | { |
3777 | if (c) delete c; // delete the previous category | 3238 | if (c) delete c; // delete the previous category |
3778 | 3239 | ||
3779 | c = i; | 3240 | c = i; |
@@ -3786,40 +3247,31 @@ void ZSafe::setDocument(const QString& fileref) | |||
3786 | si = si->nextSibling(); | 3247 | si = si->nextSibling(); |
3787 | i->takeItem(_si); // remove from view list | 3248 | i->takeItem(_si); // remove from view list |
3788 | if (_si) delete _si; | 3249 | if (_si) delete _si; |
3789 | } | 3250 | } |
3790 | } | 3251 | } |
3791 | if (c) delete c; // delete the previous category | 3252 | if (c) delete c; // delete the previous category |
3792 | categories.clear(); | 3253 | categories.clear(); |
3793 | 3254 | ||
3794 | m_password = ""; | 3255 | m_password = ""; |
3795 | selectedItem = NULL; | 3256 | selectedItem = NULL; |
3796 | 3257 | ||
3797 | openDocument(filename); | 3258 | openDocument(filename); |
3798 | #else | ||
3799 | Q_UNUSED(fileref); | ||
3800 | #endif | ||
3801 | } | 3259 | } |
3802 | 3260 | ||
3803 | 3261 | ||
3804 | void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int column) { | 3262 | void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int column) { |
3805 | if(item ==0) return; | 3263 | if(item ==0) return; |
3806 | switch (mouse) { | 3264 | switch (mouse) { |
3807 | case 1: | 3265 | case 1: |
3808 | { | ||
3809 | #ifdef DESKTOP | ||
3810 | QDragObject *d = new QTextDrag( item->text(column) , this ); | ||
3811 | d->dragCopy(); | ||
3812 | #endif | ||
3813 | } | ||
3814 | break; | 3266 | break; |
3815 | case 2: | 3267 | case 2: |
3816 | { | 3268 | { |
3817 | QClipboard *cb = QApplication::clipboard(); | 3269 | QClipboard *cb = QApplication::clipboard(); |
3818 | 3270 | ||
3819 | QIconSet copy_img((const char**) copy_xpm); | 3271 | QIconSet copy_img((const char**) copy_xpm); |
3820 | QIconSet edit_img((const char**) edit_xpm); | 3272 | QIconSet edit_img((const char**) edit_xpm); |
3821 | QPixmap folder_open_img((const char**) folder_open_xpm); | 3273 | QPixmap folder_open_img((const char**) folder_open_xpm); |
3822 | QPixmap editdelete_img((const char**) editdelete_xpm); | 3274 | QPixmap editdelete_img((const char**) editdelete_xpm); |
3823 | 3275 | ||
3824 | QPopupMenu *m = new QPopupMenu(this); | 3276 | QPopupMenu *m = new QPopupMenu(this); |
3825 | int copyItem = m->insertItem( copy_img, tr( "Copy to Clipboard" )); | 3277 | int copyItem = m->insertItem( copy_img, tr( "Copy to Clipboard" )); |
@@ -3842,38 +3294,23 @@ void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int colum | |||
3842 | }; | 3294 | }; |
3843 | } | 3295 | } |
3844 | 3296 | ||
3845 | void ZSafe::copyClip( const QString &text) { | 3297 | void ZSafe::copyClip( const QString &text) { |
3846 | QClipboard *cb = QApplication::clipboard(); | 3298 | QClipboard *cb = QApplication::clipboard(); |
3847 | cb->setText( text); | 3299 | cb->setText( text); |
3848 | } | 3300 | } |
3849 | 3301 | ||
3850 | 3302 | ||
3851 | QString ZSafe::zsaveDialog() { | 3303 | QString ZSafe::zsaveDialog() { |
3852 | 3304 | ||
3853 | QString fn; | 3305 | QString fn; |
3854 | #ifndef DESKTOP | ||
3855 | #ifndef NO_OPIE | ||
3856 | QMap<QString, QStringList> mimeTypes; | 3306 | QMap<QString, QStringList> mimeTypes; |
3857 | mimeTypes.insert(tr("All"), QStringList() ); | 3307 | mimeTypes.insert(tr("All"), QStringList() ); |
3858 | mimeTypes.insert(tr("Text"), "text/*" ); | 3308 | mimeTypes.insert(tr("Text"), "text/*" ); |
3859 | fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 3309 | fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
3860 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3310 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3861 | QString::null, | 3311 | QString::null, |
3862 | mimeTypes, | 3312 | mimeTypes, |
3863 | this, | 3313 | this, |
3864 | tr ("Export text file")); | 3314 | tr ("Export text file")); |
3865 | #else | ||
3866 | fn = ScQtFileEdit::getSaveAsFileName(this, | ||
3867 | tr ("Export text file"), | ||
3868 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3869 | "*.txt"); | ||
3870 | #endif | ||
3871 | #else | ||
3872 | fn = QFileDialog::getSaveFileName( | ||
3873 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3874 | "ZSafe (*.txt)", | ||
3875 | this, | ||
3876 | "ZSafe"); | ||
3877 | #endif | ||
3878 | return fn; | 3315 | return fn; |
3879 | } | 3316 | } |
diff --git a/noncore/apps/zsafe/zsafe.h b/noncore/apps/zsafe/zsafe.h index 7419797..3d812f8 100644 --- a/noncore/apps/zsafe/zsafe.h +++ b/noncore/apps/zsafe/zsafe.h | |||
@@ -37,38 +37,39 @@ class QPopupMenu; | |||
37 | // #ifndef WIN32 | 37 | // #ifndef WIN32 |
38 | class QSettings; | 38 | class QSettings; |
39 | // #endif | 39 | // #endif |
40 | #else | 40 | #else |
41 | class Config; | 41 | class Config; |
42 | #endif | 42 | #endif |
43 | class CategoryDialog; | 43 | class CategoryDialog; |
44 | class QPixmap; | 44 | class QPixmap; |
45 | 45 | ||
46 | // number of fields for one entry | 46 | // number of fields for one entry |
47 | #define FIELD_SIZE 7 | 47 | #define FIELD_SIZE 7 |
48 | 48 | ||
49 | class ZSafe : public QDialog | 49 | class ZSafe : public QWidget |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | 52 | ||
53 | protected: | 53 | protected: |
54 | void paintEvent( QPaintEvent * e ); | 54 | void paintEvent( QPaintEvent * e ); |
55 | void resizeEvent ( QResizeEvent * ); | 55 | void resizeEvent ( QResizeEvent * ); |
56 | 56 | ||
57 | bool raiseFlag; | 57 | bool raiseFlag; |
58 | QTimer raiseTimer; | 58 | QTimer raiseTimer; |
59 | 59 | ||
60 | public: | 60 | public: |
61 | ZSafe( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = WDestructiveClose ); | 61 | ZSafe( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
62 | ~ZSafe(); | 62 | ~ZSafe(); |
63 | static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); } | ||
63 | 64 | ||
64 | static const QColor *evenRowColor; | 65 | static const QColor *evenRowColor; |
65 | static const QColor *oddRowColor; | 66 | static const QColor *oddRowColor; |
66 | 67 | ||
67 | QToolButton* Edit; | 68 | QToolButton* Edit; |
68 | QToolButton* Delete; | 69 | QToolButton* Delete; |
69 | QToolButton* Find; | 70 | QToolButton* Find; |
70 | QToolButton* New; | 71 | QToolButton* New; |
71 | ZListView* ListView; | 72 | ZListView* ListView; |
72 | 73 | ||
73 | QString cfgFile; | 74 | QString cfgFile; |
74 | QString iconPath; | 75 | QString iconPath; |
@@ -186,13 +187,18 @@ public slots: | |||
186 | virtual void categoryFieldActivated( const QString& str); | 187 | virtual void categoryFieldActivated( const QString& str); |
187 | 188 | ||
188 | virtual void ListPressed(int, QListViewItem *, const QPoint&, int); | 189 | virtual void ListPressed(int, QListViewItem *, const QPoint&, int); |
189 | virtual void copyClip( const QString &text); | 190 | virtual void copyClip( const QString &text); |
190 | 191 | ||
191 | private slots: | 192 | private slots: |
192 | void setDocument(const QString& fileref); | 193 | void setDocument(const QString& fileref); |
193 | void slotLoadDocu(); | 194 | void slotLoadDocu(); |
194 | void slotRaiseTimer(); | 195 | void slotRaiseTimer(); |
195 | 196 | ||
196 | }; | 197 | }; |
197 | 198 | ||
199 | |||
200 | extern ZSafe *zs; | ||
201 | extern QApplication *appl; | ||
202 | extern int DeskW; | ||
203 | extern int DeskH; | ||
198 | #endif // ZSAFE_H | 204 | #endif // ZSAFE_H |