summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/zsafe.cpp137
-rw-r--r--noncore/apps/zsafe/zsafe.h1
2 files changed, 54 insertions, 84 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index f3d57f8..41c572a 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -241,436 +241,433 @@ static const char* const general_data[] = {
241"#q c #101010", 241"#q c #101010",
242"#i c #101410", 242"#i c #101410",
243"## c #101810", 243"## c #101810",
244".m c #181818", 244".m c #181818",
245".3 c #181c18", 245".3 c #181c18",
246".I c #182018", 246".I c #182018",
247".T c #202420", 247".T c #202420",
248"#D c #202820", 248"#D c #202820",
249"#y c #292c29", 249"#y c #292c29",
250".c c #293029", 250".c c #293029",
251".d c #313031", 251".d c #313031",
252"#E c #313429", 252"#E c #313429",
253"#r c #313831", 253"#r c #313831",
254".j c #393c31", 254".j c #393c31",
255"#j c #394039", 255"#j c #394039",
256"#C c #414841", 256"#C c #414841",
257".w c #4a554a", 257".w c #4a554a",
258".a c #4a594a", 258".a c #4a594a",
259".# c #525052", 259".# c #525052",
260".l c #52594a", 260".l c #52594a",
261"#f c #525952", 261"#f c #525952",
262"#v c #525d52", 262"#v c #525d52",
263".O c #5a4c4a", 263".O c #5a4c4a",
264".9 c #5a595a", 264".9 c #5a595a",
265".A c #5a5d52", 265".A c #5a5d52",
266".B c #624c52", 266".B c #624c52",
267".0 c #625552", 267".0 c #625552",
268"#o c #626562", 268"#o c #626562",
269".R c #626962", 269".R c #626962",
270"#. c #626d5a", 270"#. c #626d5a",
271"#p c #626d62", 271"#p c #626d62",
272".2 c #627162", 272".2 c #627162",
273"#h c #6a6d62", 273"#h c #6a6d62",
274"#z c #6a7562", 274"#z c #6a7562",
275"#w c #6a756a", 275"#w c #6a756a",
276".C c #73656a", 276".C c #73656a",
277".P c #73696a", 277".P c #73696a",
278"#a c #737d6a", 278"#a c #737d6a",
279".U c #738573", 279".U c #738573",
280".E c #7b817b", 280".E c #7b817b",
281"#B c #7b857b", 281"#B c #7b857b",
282"#s c #7b897b", 282"#s c #7b897b",
283"#n c #7b917b", 283"#n c #7b917b",
284".b c #838d83", 284".b c #838d83",
285".7 c #839583", 285".7 c #839583",
286".n c #8b7d7b", 286".n c #8b7d7b",
287"#g c #8b8583", 287"#g c #8b8583",
288".g c #8b858b", 288".g c #8b858b",
289".r c #8b898b", 289".r c #8b898b",
290".s c #8b8d8b", 290".s c #8b8d8b",
291".i c #8b9183", 291".i c #8b9183",
292".8 c #8b918b", 292".8 c #8b918b",
293"#A c #8b9d8b", 293"#A c #8b9d8b",
294".S c #8ba183", 294".S c #8ba183",
295".Z c #94918b", 295".Z c #94918b",
296".N c #949994", 296".N c #949994",
297".F c #949d94", 297".F c #949d94",
298".x c #94a18b", 298".x c #94a18b",
299".v c #94a194", 299".v c #94a194",
300".Y c #94aa94", 300".Y c #94aa94",
301".h c #9c999c", 301".h c #9c999c",
302".Q c #9ca19c", 302".Q c #9ca19c",
303"#u c #9ca59c", 303"#u c #9ca59c",
304".H c #9caa9c", 304".H c #9caa9c",
305"#e c #9cb29c", 305"#e c #9cb29c",
306"#m c #a4b29c", 306"#m c #a4b29c",
307"#t c #a4b2a4", 307"#t c #a4b2a4",
308".M c #a4b69c", 308".M c #a4b69c",
309"#l c #a4b6a4", 309"#l c #a4b6a4",
310".z c #a4baa4", 310".z c #a4baa4",
311".f c #aca5ac", 311".f c #aca5ac",
312".q c #acaaac", 312".q c #acaaac",
313"#d c #acbeac", 313"#d c #acbeac",
314".6 c #acc2ac", 314".6 c #acc2ac",
315".o c #b4b2b4", 315".o c #b4b2b4",
316".t c #b4beb4", 316".t c #b4beb4",
317"#k c #b4c2ac", 317"#k c #b4c2ac",
318".5 c #b4cab4", 318".5 c #b4cab4",
319".D c #bdb6bd", 319".D c #bdb6bd",
320".G c #bdc6b4", 320".G c #bdc6b4",
321"#c c #bdceb4", 321"#c c #bdceb4",
322".X c #bdd2bd", 322".X c #bdd2bd",
323".4 c #bdd6bd", 323".4 c #bdd6bd",
324".1 c #c5bec5", 324".1 c #c5bec5",
325".e c #c5c2c5", 325".e c #c5c2c5",
326".u c #c5cac5", 326".u c #c5cac5",
327"#b c #c5d6c5", 327"#b c #c5d6c5",
328".J c #c5dec5", 328".J c #c5dec5",
329".p c #cdcacd", 329".p c #cdcacd",
330".W c #cddecd", 330".W c #cddecd",
331".L c #cde2cd", 331".L c #cde2cd",
332".K c #d5eacd", 332".K c #d5eacd",
333".V c #d5ead5", 333".V c #d5ead5",
334".y c #d5eed5", 334".y c #d5eed5",
335"QtQtQtQtQtQtQtQtQtQtQtQtQtQt", 335"QtQtQtQtQtQtQtQtQtQtQtQtQtQt",
336"QtQtQt.#.a.b.cQtQtQtQtQtQtQt", 336"QtQtQt.#.a.b.cQtQtQtQtQtQtQt",
337"QtQt.d.e.f.g.h.i.c.j.dQt.kQt", 337"QtQt.d.e.f.g.h.i.c.j.dQt.kQt",
338".a.l.m.n.o.p.q.r.s.t.u.v.wQt", 338".a.l.m.n.o.p.q.r.s.t.u.v.wQt",
339".x.y.z.A.B.C.D.p.q.E.F.G.H.I", 339".x.y.z.A.B.C.D.p.q.E.F.G.H.I",
340".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", 340".I.J.K.L.M.N.O.P.o.p.Q.R.S.T",
341"Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", 341"Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3",
342"Qt.3.X.W.4.X.5.6.7.8.9.s#.##", 342"Qt.3.X.W.4.X.5.6.7.8.9.s#.##",
343"QtQt#a.X#b#c.5.6#d#e#f#g#h#i", 343"QtQt#a.X#b#c.5.6#d#e#f#g#h#i",
344"QtQtQt#j.7#k.6#d#l#m#n#o#p#q", 344"QtQtQt#j.7#k.6#d#l#m#n#o#p#q",
345"QtQtQtQt.k#r#s#m#t.H#u#v#w#x", 345"QtQtQtQt.k#r#s#m#t.H#u#v#w#x",
346"QtQtQtQtQtQt.k#y#z.v#A#B#C#x", 346"QtQtQtQtQtQt.k#y#z.v#A#B#C#x",
347"QtQtQtQtQtQtQtQt.k#D.w#s#E.k", 347"QtQtQtQtQtQtQtQt.k#D.w#s#E.k",
348"QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; 348"QtQtQtQtQtQtQtQtQtQtQt#x#FQt"};
349 349
350// exit ZSafe and clear the clipboard for security reasons 350// exit ZSafe and clear the clipboard for security reasons
351 void ZSafe::exitZs (int ec) 351 void ZSafe::exitZs (int ec)
352 { 352 {
353 QClipboard *cb = QApplication::clipboard(); 353 QClipboard *cb = QApplication::clipboard();
354 cb->clear(); 354 cb->clear();
355 355
356 exit (ec); 356 exit (ec);
357 } 357 }
358 358
359 359
360// save the configuration into the file 360// save the configuration into the file
361 void ZSafe::saveConf () 361 void ZSafe::saveConf ()
362 { 362 {
363 if (conf) 363 if (conf)
364 { 364 {
365 delete conf; 365 delete conf;
366 366
367#ifdef DESKTOP 367#ifdef DESKTOP
368#ifndef Q_WS_WIN 368#ifndef Q_WS_WIN
369 conf = new QSettings (); 369 conf = new QSettings();
370 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); 370 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
371#else 371#else
372 conf = new QSettings (cfgFile); 372 conf = new QSettings (cfgFile);
373 conf->insertSearchPath (QSettings::Unix, cfgFile); 373 conf->insertSearchPath (QSettings::Unix, cfgFile);
374#endif 374#endif
375#else 375#else
376 conf = new Config (cfgFile, Config::File); 376 conf = new Config (cfgFile, Config::File);
377 conf->setGroup ("zsafe"); 377 conf->setGroup ("zsafe");
378#endif 378#endif
379 } 379 }
380 } 380 }
381 381
382 382
383/* 383/*
384 * Constructs a ZSafe which is a child of 'parent', with the 384 * Constructs a ZSafe which is a child of 'parent', with the
385 * name 'name' and widget flags set to 'f' 385 * name 'name' and widget flags set to 'f'
386 * 386 *
387 * The dialog will by default be modeless, unless you set 'modal' to 387 * The dialog will by default be modeless, unless you set 'modal' to
388 * TRUE to construct a modal dialog. 388 * TRUE to construct a modal dialog.
389 */ 389 */
390ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) 390ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
391 : QDialog( parent, name, modal, fl ), 391 : QDialog( parent, name, modal, fl ),
392 Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) 392 Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l)
393{ 393{
394 IsCut = false; 394 IsCut = false;
395 IsCopy = false; 395 IsCopy = false;
396 modified = false; 396 modified = false;
397 showpwd = false; 397 showpwd = false;
398 398
399 // set the config file 399 // set the config file
400 cfgFile=QDir::homeDirPath(); 400 cfgFile=QDir::homeDirPath();
401 cfgFile += "/.zsafe.cfg"; 401 cfgFile += "/.zsafe.cfg";
402 // set the icon path 402 // set the icon path
403#ifdef NO_OPIE 403#ifdef NO_OPIE
404 QString qpedir ((const char *)getenv("QPEDIR")); 404 QString qpedir ((const char *)getenv("QPEDIR"));
405#else 405#else
406 QString qpedir ((const char *)getenv("OPIEDIR")); 406 QString qpedir ((const char *)getenv("OPIEDIR"));
407#endif 407#endif
408 408
409#ifdef DESKTOP 409#ifdef DESKTOP
410 iconPath = QDir::homeDirPath() + "/pics/"; 410 iconPath = QDir::homeDirPath() + "/pics/";
411#else 411#else
412 if (qpedir.isEmpty()) 412 if (qpedir.isEmpty())
413 iconPath = "/home/QtPalmtop/pics/"; 413 iconPath = "/home/QtPalmtop/pics/";
414 else 414 else
415 iconPath = qpedir + "/pics/"; 415 iconPath = qpedir + "/pics/";
416#endif 416#endif
417 417
418 // create a zsafe configuration object 418 // create a zsafe configuration object
419#ifdef DESKTOP 419#ifdef DESKTOP
420#ifndef Q_WS_WIN 420#ifndef Q_WS_WIN
421 conf = new QSettings (); 421 conf = new QSettings ();
422 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); 422 conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
423#else 423#else
424 conf = new QSettings (cfgFile); 424 conf = new QSettings (cfgFile);
425 conf->insertSearchPath (QSettings::Unix, cfgFile); 425 conf->insertSearchPath (QSettings::Unix, cfgFile);
426#endif 426#endif
427#else 427#else
428 conf = new Config (cfgFile, Config::File); 428 conf = new Config (cfgFile, Config::File);
429 conf->setGroup ("zsafePrefs"); 429 conf->setGroup ("zsafePrefs");
430#endif 430#endif
431#ifdef DESKTOP 431#ifdef DESKTOP
432// #ifndef Q_WS_WIN 432// #ifndef Q_WS_WIN
433 expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); 433 expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false);
434// #endif 434// #endif
435#else 435#else
436 expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); 436 expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0);
437#endif 437#endif
438#ifndef DESKTOP 438#ifndef DESKTOP
439 conf->setGroup ("zsafe"); 439 conf->setGroup ("zsafe");
440#endif 440#endif
441 441
442 QPixmap copy_img((const char**) copy_xpm); 442 QPixmap copy_img((const char**) copy_xpm);
443 QPixmap cut_img((const char**) cut_xpm); 443 QPixmap cut_img((const char**) cut_xpm);
444 QPixmap edit_img((const char**) edit_xpm); 444 QPixmap edit_img((const char**) edit_xpm);
445 QPixmap editdelete_img((const char**) editdelete_xpm); 445 QPixmap editdelete_img((const char**) editdelete_xpm);
446 QPixmap find_img((const char**) find_xpm); 446 QPixmap find_img((const char**) find_xpm);
447 QPixmap folder_open_img((const char**) folder_open_xpm); 447 QPixmap folder_open_img((const char**) folder_open_xpm);
448 QPixmap help_icon_img((const char**) help_icon_xpm); 448 QPixmap help_icon_img((const char**) help_icon_xpm);
449 QPixmap new_img((const char**) new_xpm); 449 QPixmap new_img((const char**) new_xpm);
450 QPixmap paste_img((const char**) paste_xpm); 450 QPixmap paste_img((const char**) paste_xpm);
451 QPixmap quit_icon_img((const char**) quit_icon_xpm); 451 QPixmap quit_icon_img((const char**) quit_icon_xpm);
452 QPixmap save_img((const char**) save_xpm); 452 QPixmap save_img((const char**) save_xpm);
453 QPixmap trash_img((const char**) trash_xpm); 453 QPixmap trash_img((const char**) trash_xpm);
454 QPixmap expand_img((const char**) expand_xpm); 454 QPixmap expand_img((const char**) expand_xpm);
455 QPixmap export_img((const char**) export_xpm); 455 QPixmap export_img((const char**) export_xpm);
456 QPixmap import_img((const char**) import_xpm); 456 QPixmap import_img((const char**) import_xpm);
457 457
458 QPixmap bank_cards( ( const char** ) bank_cards_data ); 458 QPixmap bank_cards( ( const char** ) bank_cards_data );
459 QPixmap passwords( ( const char** ) passwords_data ); 459 QPixmap passwords( ( const char** ) passwords_data );
460 QPixmap software( ( const char** ) software_data ); 460 QPixmap software( ( const char** ) software_data );
461 QPixmap general( ( const char** ) general_data ); 461 QPixmap general( ( const char** ) general_data );
462 QPixmap image0( ( const char** ) zsafe_xpm ); 462 QPixmap image0( ( const char** ) zsafe_xpm );
463 if ( !name ) 463 if ( !name )
464 setName( "ZSafe" ); 464 setName( "ZSafe" );
465 465
466#ifdef DESKTOP 466#ifdef DESKTOP
467#ifdef Q_WS_WIN 467#ifdef Q_WS_WIN
468 setGeometry(100, 150, DeskW, DeskH-30 ); 468 setGeometry(100, 150, DeskW, DeskH-30 );
469#else 469#else
470 resize( DeskW, DeskH-30 ); 470 resize( DeskW, DeskH-30 );
471#endif 471#endif
472 472
473#else 473#else
474 474
475#ifdef JPATCH_HDE 475#ifdef JPATCH_HDE
476 int DeskS; 476 int DeskS;
477 if(DeskW > DeskH) 477 if(DeskW > DeskH)
478 { 478 {
479 DeskS = DeskW; 479 DeskS = DeskW;
480 } 480 }
481 else 481 else
482 { 482 {
483 DeskS = DeskH; 483 DeskS = DeskH;
484 } 484 }
485 resize( DeskW, DeskH ); 485 resize( DeskW, DeskH );
486 setMinimumSize( QSize( DeskS, DeskS ) ); 486 setMinimumSize( QSize( DeskS, DeskS ) );
487 setMaximumSize( QSize( DeskS, DeskS ) ); 487 setMaximumSize( QSize( DeskS, DeskS ) );
488#else 488#else
489 resize( DeskW, DeskH-30 ); 489 resize( DeskW, DeskH-30 );
490#endif 490#endif
491 491
492#endif 492#endif
493 setCaption( tr( "ZSafe" ) ); 493 setCaption( tr( "ZSafe" ) );
494 QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; 494 QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe";
495 QString filename = conf->readEntry(APP_KEY+"document"); 495 QString filename = conf->readEntry(APP_KEY+"document");
496 if (filename.isEmpty() || filename.isNull()) 496 if ( !QFileInfo(filename).exists() || !QDir(zsafeAppDirPath).exists() )
497 { 497 {
498
499 // check if the directory application exists, if not 498 // check if the directory application exists, if not
500 // create it 499 // create it
501// #ifndef Q_WS_WIN 500// #ifndef Q_WS_WIN
502 // QString d1("Documents/application"); 501 // QString d1("Documents/application");
503// #else 502// #else
504 QString d1(QDir::homeDirPath() + "/Documents/application"); 503 QString d1(QDir::homeDirPath() + "/Documents/application");
505// #endif 504// #endif
506 QDir pd1(d1); 505 QDir pd1(d1);
507 if (!pd1.exists()) 506 if (!pd1.exists())
508 { 507 {
509
510 QDir pd2(QDir::homeDirPath() + "/Documents"); 508 QDir pd2(QDir::homeDirPath() + "/Documents");
511 if (!pd2.exists()) { 509 if (!pd2.exists()) {
512 QDir pd3(QDir::homeDirPath()); 510 QDir pd3(QDir::homeDirPath());
513 if (!pd3.mkdir("Documents", FALSE)) { 511 if (!pd3.mkdir("Documents", FALSE)) {
514 } 512 }
515 } 513 }
516 514
517 if (!pd2.mkdir("application", FALSE)) 515 if (!pd2.mkdir("application", FALSE))
518 { 516 {
519 QMessageBox::critical( 0, tr("ZSafe"), 517 QMessageBox::critical( 0, tr("ZSafe"),
520#ifdef JPATCH_HDE 518#ifdef JPATCH_HDE
521 tr("<P>Can't create directory ..."+d1+"</P><P>ZSafe will now exit.</P>")); 519 tr("<P>Can't create directory ..."+d1+"</P><P>ZSafe will now exit.</P>"));
522#else 520#else
523 tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1)); 521 tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1));
524#endif 522#endif
525 exitZs (1); 523 exitZs (1);
526 } 524 }
527 } 525 }
528// #ifndef Q_WS_WIN 526// #ifndef Q_WS_WIN
529 // QString d2("Documents/application/zsafe"); 527 // QString d2("Documents/application/zsafe");
530// #else 528// #else
531 QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); 529 QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
532// #endif 530// #endif
533 QDir pd2(d2); 531 QDir pd2(d2);
534 if (!pd2.exists()) 532 if (!pd2.exists())
535 { 533 {
536 if (!pd1.mkdir("zsafe", FALSE)) 534 if (!pd1.mkdir("zsafe", FALSE))
537 { 535 {
538 QMessageBox::critical( 0, tr("ZSafe"), 536 QMessageBox::critical( 0, tr("ZSafe"),
539#ifdef JPATCH_HDE 537#ifdef JPATCH_HDE
540 tr("<P>Can't create directory ...//Documents/application/zsafe</P><P>ZSafe will now exit.</P")); 538 tr("<P>Can't create directory ...//Documents/application/zsafe</P><P>ZSafe will now exit.</P"));
541#else 539#else
542 tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2)); 540 tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2));
543#endif 541#endif
544 exitZs (1); 542 exitZs (1);
545 } 543 }
546 } 544 }
547 545
548 // set the default filename
549 filename = zsafeAppDirPath + "/passwords.zsf"; 546 filename = zsafeAppDirPath + "/passwords.zsf";
550 547
551 // save the current filename to the config file 548 // save the current filename to the config file
552 conf->writeEntry(APP_KEY+"document", filename); 549 conf->writeEntry(APP_KEY+"document", filename);
553 saveConf(); 550 saveConf();
554 } 551 }
555 //if (filename == "INVALIDPWD") 552 //if (filename == "INVALIDPWD")
556 //filename = ""; 553 //filename = "";
557 554
558 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 555 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
559#ifdef Q_WS_WIN 556#ifdef Q_WS_WIN
560 this->setCaption("Qt ZSafe: " + ti); 557 this->setCaption("Qt ZSafe: " + ti);
561#else 558#else
562 this->setCaption("ZSafe: " + ti); 559 this->setCaption("ZSafe: " + ti);
563#endif 560#endif
564 561
565 selectedItem = NULL; 562 selectedItem = NULL;
566 lastSearchedCategory = NULL; 563 lastSearchedCategory = NULL;
567 lastSearchedItem = NULL; 564 lastSearchedItem = NULL;
568 lastSearchedName = ""; 565 lastSearchedName = "";
569 lastSearchedUsername = ""; 566 lastSearchedUsername = "";
570 lastSearchedComment = ""; 567 lastSearchedComment = "";
571 568
572 infoForm = new InfoForm(this, "show_info", TRUE); 569 infoForm = new InfoForm(this, "show_info", TRUE);
573 categoryDialog = NULL; 570 categoryDialog = NULL;
574 infoForm->setIcon( image0); 571 infoForm->setIcon( image0);
575 572
576 // add a menu bar 573 // add a menu bar
577 QMenuBar *menu = new QMenuBar( this ); 574 QMenuBar *menu = new QMenuBar( this );
578 575
579 // add file menu 576 // add file menu
580 // QPopupMenu *file = new QPopupMenu( this ); 577 // QPopupMenu *file = new QPopupMenu( this );
581 file = new QPopupMenu( this ); 578 file = new QPopupMenu( this );
582 579
583// #ifdef DESKTOP 580// #ifdef DESKTOP
584 file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); 581 file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) );
585 file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); 582 file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) );
586 file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); 583 file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) );
587 file->insertSeparator(); 584 file->insertSeparator();
588// #endif 585// #endif
589 586
590 file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); 587 file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) );
591 file->insertItem( save_img, tr("S&ave document with new Password"), this, 588 file->insertItem( save_img, tr("S&ave document with new Password"), this,
592 SLOT(saveDocumentWithPwd()) ); 589 SLOT(saveDocumentWithPwd()) );
593 file->insertSeparator(); 590 file->insertSeparator();
594 file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); 591 file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) );
595 file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); 592 file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) );
596 file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); 593 file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) );
597 file->insertSeparator(); 594 file->insertSeparator();
598 file->insertItem( expand_img, tr("&Open entries expanded"), this, 595 file->insertItem( expand_img, tr("&Open entries expanded"), this,
599 SLOT(setExpandFlag()), 0, 'o'); 596 SLOT(setExpandFlag()), 0, 'o');
600 file->setItemChecked('o', expandTree); 597 file->setItemChecked('o', expandTree);
601 file->insertSeparator(); 598 file->insertSeparator();
602 file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); 599 file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) );
603 menu->insertItem( tr("&File"), file ); 600 menu->insertItem( tr("&File"), file );
604 601
605 QPopupMenu *cat = new QPopupMenu( this ); 602 QPopupMenu *cat = new QPopupMenu( this );
606 cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); 603 cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) );
607 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); 604 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) );
608 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); 605 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) );
609 menu->insertItem( tr("&Category"), cat ); 606 menu->insertItem( tr("&Category"), cat );
610 607
611 QPopupMenu *it = new QPopupMenu( this ); 608 QPopupMenu *it = new QPopupMenu( this );
612 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); 609 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) );
613 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); 610 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) );
614 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); 611 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) );
615 it->insertSeparator(); 612 it->insertSeparator();
616 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); 613 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) );
617 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); 614 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) );
618 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); 615 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) );
619 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); 616 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) );
620 menu->insertItem( tr("&Entry"), it ); 617 menu->insertItem( tr("&Entry"), it );
621 618
622 QPopupMenu *help = new QPopupMenu( this ); 619 QPopupMenu *help = new QPopupMenu( this );
623 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); 620 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) );
624 menu->insertItem( tr("&Help"), help ); 621 menu->insertItem( tr("&Help"), help );
625 622
626 // toolbar icons 623 // toolbar icons
627 624
628 New = new QToolButton( menu, "New" ); 625 New = new QToolButton( menu, "New" );
629 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); 626 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) );
630 New->setMouseTracking( TRUE ); 627 New->setMouseTracking( TRUE );
631 New->setText( "" ); 628 New->setText( "" );
632 New->setPixmap( new_img ); 629 New->setPixmap( new_img );
633 QToolTip::add( New, tr( "New entry" ) ); 630 QToolTip::add( New, tr( "New entry" ) );
634 631
635 Edit = new QToolButton( menu, "Edit" ); 632 Edit = new QToolButton( menu, "Edit" );
636 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); 633 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) );
637 Edit->setText( "" ); 634 Edit->setText( "" );
638 Edit->setPixmap( edit_img ); 635 Edit->setPixmap( edit_img );
639 QToolTip::add( Edit, tr( "Edit category or entry" ) ); 636 QToolTip::add( Edit, tr( "Edit category or entry" ) );
640 637
641 Delete = new QToolButton( menu, "Delete" ); 638 Delete = new QToolButton( menu, "Delete" );
642 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); 639 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
643 Delete->setText( "" ); 640 Delete->setText( "" );
644 Delete->setPixmap( trash_img ); 641 Delete->setPixmap( trash_img );
645 QToolTip::add( Delete, tr( "Delete category or entry" ) ); 642 QToolTip::add( Delete, tr( "Delete category or entry" ) );
646 643
647 Find = new QToolButton( menu, "Find" ); 644 Find = new QToolButton( menu, "Find" );
648 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); 645 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) );
649 Find->setText( "" ); 646 Find->setText( "" );
650 Find->setPixmap( find_img ); 647 Find->setPixmap( find_img );
651 QToolTip::add( Find, tr( "Find entry" ) ); 648 QToolTip::add( Find, tr( "Find entry" ) );
652 649
653/* 650/*
654 QBoxLayout * h = new QHBoxLayout( this ); 651 QBoxLayout * h = new QHBoxLayout( this );
655 h->addWidget (menu); 652 h->addWidget (menu);
656 h->addWidget (New); 653 h->addWidget (New);
657 h->addWidget (Edit); 654 h->addWidget (Edit);
658 h->addWidget (Delete); 655 h->addWidget (Delete);
659 h->addWidget (Find); 656 h->addWidget (Find);
660*/ 657*/
661 658
662 ListView = new ZListView( this, "ListView" ); 659 ListView = new ZListView( this, "ListView" );
663 ListView->addColumn( tr( "Name" ) ); 660 ListView->addColumn( tr( "Name" ) );
664 ListView->addColumn( tr( "Field 2" ) ); 661 ListView->addColumn( tr( "Field 2" ) );
665 ListView->addColumn( tr( "Field 3" ) ); 662 ListView->addColumn( tr( "Field 3" ) );
666 ListView->addColumn( tr( "Comment" ) ); 663 ListView->addColumn( tr( "Comment" ) );
667 ListView->addColumn( tr( "Field 4" ) ); 664 ListView->addColumn( tr( "Field 4" ) );
668 ListView->addColumn( tr( "Field 5" ) ); 665 ListView->addColumn( tr( "Field 5" ) );
669 ListView->setAllColumnsShowFocus(TRUE); 666 ListView->setAllColumnsShowFocus(TRUE);
670 667
671#ifdef DESKTOP 668#ifdef DESKTOP
672 ListView->setResizePolicy(QScrollView::AutoOneFit); 669 ListView->setResizePolicy(QScrollView::AutoOneFit);
673 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); 670 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) );
674#else 671#else
675 ListView->setResizePolicy(QScrollView::AutoOneFit); 672 ListView->setResizePolicy(QScrollView::AutoOneFit);
676 // ListView->setGeometry( QRect( 0, 22, 673 // ListView->setGeometry( QRect( 0, 22,
@@ -1214,282 +1211,257 @@ void ZSafe::showInfo( QListViewItem *_item)
1214 // text += "<br>"; 1211 // text += "<br>";
1215 } 1212 }
1216 1213
1217 entry = selectedItem->text(3); 1214 entry = selectedItem->text(3);
1218 if (!entry.isEmpty() && entry.compare(" ")) 1215 if (!entry.isEmpty() && entry.compare(" "))
1219 { 1216 {
1220 text += "<u><b>"; 1217 text += "<u><b>";
1221 text += getFieldLabel (selectedItem, "4", tr("Comment")); 1218 text += getFieldLabel (selectedItem, "4", tr("Comment"));
1222 text += ":<br> </b></u>"; 1219 text += ":<br> </b></u>";
1223 QString comment = selectedItem->text(3); 1220 QString comment = selectedItem->text(3);
1224 comment.replace (QRegExp("\n"), "<br>"); 1221 comment.replace (QRegExp("\n"), "<br>");
1225 text += comment; 1222 text += comment;
1226 // text += "<br>"; 1223 // text += "<br>";
1227 } 1224 }
1228 1225
1229 text += "</body></html>"; 1226 text += "</body></html>";
1230 1227
1231 infoForm->InfoText->setText(text); 1228 infoForm->InfoText->setText(text);
1232// infoForm->hide(); 1229// infoForm->hide();
1233#ifdef Q_WS_QWS 1230#ifdef Q_WS_QWS
1234 QPEApplication::showDialog( infoForm ); 1231 QPEApplication::showDialog( infoForm );
1235#endif 1232#endif
1236 1233
1237#ifdef DESKTOP 1234#ifdef DESKTOP
1238 infoForm->show(); 1235 infoForm->show();
1239 #endif 1236 #endif
1240 } 1237 }
1241} 1238}
1242 1239
1243void ZSafe::listViewSelected( QListViewItem *_item) 1240void ZSafe::listViewSelected( QListViewItem *_item)
1244{ 1241{
1245 if (!_item) 1242 if (!_item)
1246 return; 1243 return;
1247 if (selectedItem != NULL) 1244 if (selectedItem != NULL)
1248 selectedItem->setSelected(FALSE); 1245 selectedItem->setSelected(FALSE);
1249 1246
1250 selectedItem = _item; 1247 selectedItem = _item;
1251 1248
1252#ifndef DESKTOP 1249#ifndef DESKTOP
1253 // set the column text dependent on the selected item 1250 // set the column text dependent on the selected item
1254 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); 1251 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
1255 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); 1252 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
1256 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); 1253 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
1257 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); 1254 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
1258 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); 1255 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
1259 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); 1256 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
1260#endif 1257#endif
1261#ifdef Q_WS_WIN 1258#ifdef Q_WS_WIN
1262 // set the column text dependent on the selected item 1259 // set the column text dependent on the selected item
1263 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); 1260 ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name")));
1264 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); 1261 ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2")));
1265 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); 1262 ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3")));
1266 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); 1263 ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment")));
1267 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); 1264 ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4")));
1268 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); 1265 ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5")));
1269#endif 1266#endif
1270 1267
1271} 1268}
1272 1269
1273bool ZSafe::isCategory(QListViewItem *_item) 1270bool ZSafe::isCategory(QListViewItem *_item)
1274{ 1271{
1275 if (_item == NULL) 1272 if (_item == NULL)
1276 return FALSE; 1273 return FALSE;
1277 1274
1278 QString categoryName = _item->text (0); 1275 QString categoryName = _item->text (0);
1279 if (categories.find (categoryName)) 1276 if (categories.find (categoryName))
1280 return TRUE; 1277 return TRUE;
1281 else 1278 else
1282 return FALSE; 1279 return FALSE;
1283} 1280}
1284 1281
1285void ZSafe::removeAsciiFile() 1282void ZSafe::removeAsciiFile()
1286{ 1283{
1287 // QString fn = filename + ".txt"; 1284 // QString fn = filename + ".txt";
1288 // open the file dialog 1285 // open the file dialog
1289#ifndef DESKTOP 1286#ifndef DESKTOP
1290#ifndef NO_OPIE 1287#ifndef NO_OPIE
1291 QMap<QString, QStringList> mimeTypes; 1288 QMap<QString, QStringList> mimeTypes;
1292 mimeTypes.insert(tr("All"), QStringList() ); 1289 mimeTypes.insert(tr("All"), QStringList() );
1293 mimeTypes.insert(tr("Text"), "text/*" ); 1290 mimeTypes.insert(tr("Text"), "text/*" );
1294 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 1291 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
1295 QDir::homeDirPath() + "/Documents/application/zsafe", 1292 QDir::homeDirPath() + "/Documents/application/zsafe",
1296 QString::null, 1293 QString::null,
1297 mimeTypes, 1294 mimeTypes,
1298 this, 1295 this,
1299 tr ("Remove text file")); 1296 tr ("Remove text file"));
1300#else 1297#else
1301 QString fn = ScQtFileEdit::getOpenFileName(this, 1298 QString fn = ScQtFileEdit::getOpenFileName(this,
1302 tr ("Remove text file"), 1299 tr ("Remove text file"),
1303 QDir::homeDirPath() + "/Documents/application/zsafe", 1300 QDir::homeDirPath() + "/Documents/application/zsafe",
1304 "*.txt"); 1301 "*.txt");
1305#endif 1302#endif
1306#else 1303#else
1307 QString fn = QFileDialog::getOpenFileName( 1304 QString fn = QFileDialog::getOpenFileName(
1308 QDir::homeDirPath() + "/Documents/application/zsafe", 1305 QDir::homeDirPath() + "/Documents/application/zsafe",
1309 "ZSafe (*.txt)", 1306 "ZSafe (*.txt)",
1310 this, 1307 this,
1311 "ZSafe File Dialog" 1308 "ZSafe File Dialog"
1312 "Choose a text file" ); 1309 "Choose a text file" );
1313#endif 1310#endif
1314 1311
1315 if (fn && fn.length() > 0 ) 1312 if (fn && fn.length() > 0 )
1316 { 1313 {
1317 QFile f( fn ); 1314 QFile f( fn );
1318 if ( !f.remove() ) 1315 if ( !f.remove() )
1319 { 1316 {
1320#ifndef NO_OPIE 1317#ifndef NO_OPIE
1321 owarn << "Could not remove file " << fn << oendl; 1318 owarn << "Could not remove file " << fn << oendl;
1322#else 1319#else
1323 qWarning( QString("Could not remove file %1").arg(fn),2000 ); 1320 qWarning( QString("Could not remove file %1").arg(fn),2000 );
1324#endif 1321#endif
1325 QMessageBox::critical( 0, tr("ZSafe"), 1322 QMessageBox::critical( 0, tr("ZSafe"),
1326 tr("Could not remove text file.") ); 1323 tr("Could not remove text file.") );
1327 return; 1324 return;
1328 } 1325 }
1329 } 1326 }
1330} 1327}
1331 1328
1332void ZSafe::writeAllEntries() 1329void ZSafe::writeAllEntries()
1333{ 1330{
1334 if (filename.isEmpty()) 1331 if (filename.isEmpty())
1335 { 1332 {
1336 QMessageBox::critical( 0, tr("ZSafe"), 1333 QMessageBox::critical( 0, tr("ZSafe"),
1337 tr("No document defined.\nYou have to create a new document")); 1334 tr("No document defined.\nYou have to create a new document"));
1338 return; 1335 return;
1339 } 1336 }
1340 1337
1341 // open the file dialog 1338 // open the file dialog
1342#ifndef DESKTOP 1339 QString fn = zsaveDialog();
1343#ifndef NO_OPIE
1344 QMap<QString, QStringList> mimeTypes;
1345 mimeTypes.insert(tr("All"), QStringList() );
1346 mimeTypes.insert(tr("Text"), "text/*" );
1347 QString fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
1348 QDir::homeDirPath() + "/Documents/application/zsafe",
1349 QString::null,
1350 mimeTypes,
1351 this,
1352 tr ("Export text file"));
1353#else
1354 QString fn = ScQtFileEdit::getSaveAsFileName(this,
1355 tr ("Export text file"),
1356 QDir::homeDirPath() + "/Documents/application/zsafe",
1357 "*.txt");
1358#endif
1359#else
1360 QString fn = QFileDialog::getSaveFileName(
1361 QDir::homeDirPath() + "/Documents/application/zsafe",
1362 "ZSafe (*.txt)",
1363 this,
1364 "ZSafe File Dialog"
1365 "Choose a text file" );
1366#endif
1367
1368 // open the new document 1340 // open the new document
1369 if (fn && fn.length() > 0 ) 1341 if (fn && fn.length() > 0 )
1370 { 1342 {
1371 QFile f( fn ); 1343 QFile f( fn );
1372 if ( !f.open( IO_WriteOnly ) ) { 1344 if ( !f.open( IO_WriteOnly ) ) {
1373#ifndef NO_OPIE 1345#ifndef NO_OPIE
1374 owarn << "Could not write to file " << fn << oendl; 1346 owarn << "Could not write to file " << fn << oendl;
1375#else 1347#else
1376 qWarning( QString("Could not write to file %1").arg(fn),2000 ); 1348 qWarning( QString("Could not write to file %1").arg(fn),2000 );
1377#endif 1349#endif
1378 QMessageBox::critical( 0, "ZSafe", 1350 QMessageBox::critical( 0, "ZSafe",
1379 QString("Could not export to text file.") ); 1351 QString("Could not export to text file.") );
1380 return; 1352 return;
1381 } 1353 }
1382 QTextStream t( &f ); 1354 QTextStream t( &f );
1383 1355
1384 QListViewItem *i; 1356 QListViewItem *i;
1385 // step through all categories 1357 // step through all categories
1386 for (i = ListView->firstChild(); 1358 for (i = ListView->firstChild();
1387 i != NULL; 1359 i != NULL;
1388 i = i->nextSibling()) 1360 i = i->nextSibling())
1389 { 1361 {
1390 // step through all subitems 1362 // step through all subitems
1391 QListViewItem *si; 1363 QListViewItem *si;
1392 for (si = i->firstChild(); 1364 for (si = i->firstChild();
1393 si != NULL; 1365 si != NULL;
1394 si = si->nextSibling()) 1366 si = si->nextSibling())
1395 { 1367 {
1396 QString oneEntry; 1368 QString oneEntry;
1397 oneEntry += "\""; 1369 oneEntry += "\"";
1398 oneEntry += i->text(0); 1370 oneEntry += i->text(0);
1399 oneEntry += "\";"; 1371 oneEntry += "\";";
1400 oneEntry += "\""; 1372 oneEntry += "\"";
1401 oneEntry += si->text(0); 1373 oneEntry += si->text(0);
1402 oneEntry += "\";"; 1374 oneEntry += "\";";
1403 oneEntry += "\""; 1375 oneEntry += "\"";
1404 oneEntry += si->text(1); 1376 oneEntry += si->text(1);
1405 oneEntry += "\";"; 1377 oneEntry += "\";";
1406 oneEntry += "\""; 1378 oneEntry += "\"";
1407 oneEntry += si->text(2); 1379 oneEntry += si->text(2);
1408 oneEntry += "\";"; 1380 oneEntry += "\";";
1409 oneEntry += "\""; 1381 oneEntry += "\"";
1410 QString comment = si->text(3); 1382 QString comment = si->text(3);
1411 comment.replace (QRegExp("\n"), "<br>"); 1383 comment.replace (QRegExp("\n"), "<br>");
1412 oneEntry += comment; 1384 oneEntry += comment;
1413 oneEntry += "\";"; 1385 oneEntry += "\";";
1414 oneEntry += "\""; 1386 oneEntry += "\"";
1415 oneEntry += si->text(4); 1387 oneEntry += si->text(4);
1416 oneEntry += "\";"; 1388 oneEntry += "\";";
1417 oneEntry += "\""; 1389 oneEntry += "\"";
1418 oneEntry += si->text(5); 1390 oneEntry += si->text(5);
1419 oneEntry += "\""; 1391 oneEntry += "\"";
1420 // owarn << oneEntry << oendl; 1392 // owarn << oneEntry << oendl;
1421 t << oneEntry << endl; 1393 t << oneEntry << endl;
1422 1394
1423 // owarn << si->text(0) << oendl; 1395 // owarn << si->text(0) << oendl;
1424 } 1396 }
1425 } 1397 }
1426 f.close(); 1398 f.close();
1427 } 1399 }
1428} 1400}
1429 1401
1430void ZSafe::readAllEntries() 1402void ZSafe::readAllEntries()
1431{ 1403{
1432 if (filename.isEmpty()) 1404 if (filename.isEmpty())
1433 { 1405 {
1434 QMessageBox::critical( 0, tr("ZSafe"), 1406 QMessageBox::critical( 0, tr("ZSafe"),
1435 tr("No document defined.\nYou have to create a new document")); 1407 tr("No document defined.\nYou have to create a new document"));
1436 return; 1408 return;
1437 } 1409 }
1438 1410
1439 // open the file dialog 1411 // open the file dialog
1440#ifndef DESKTOP 1412#ifndef DESKTOP
1441#ifndef NO_OPIE 1413#ifndef NO_OPIE
1442 QMap<QString, QStringList> mimeTypes; 1414 QMap<QString, QStringList> mimeTypes;
1443 mimeTypes.insert(tr("All"), QStringList() ); 1415 mimeTypes.insert(tr("All"), QStringList() );
1444 mimeTypes.insert(tr("Text"), "text/*" ); 1416 mimeTypes.insert(tr("Text"), "text/*" );
1445 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 1417 QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
1446 QDir::homeDirPath() + "/Documents/application/zsafe", 1418 QDir::homeDirPath() + "/Documents/application/zsafe",
1447 QString::null, 1419 QString::null,
1448 mimeTypes, 1420 mimeTypes,
1449 this, 1421 this,
1450 tr ("Import text file")); 1422 tr ("Import text file"));
1451#else 1423#else
1452 QString fn = ScQtFileEdit::getOpenFileName(this, 1424 QString fn = ScQtFileEdit::getOpenFileName(this,
1453 tr ("Import text file"), 1425 tr ("Import text file"),
1454 QDir::homeDirPath() + "/Documents/application/zsafe", 1426 QDir::homeDirPath() + "/Documents/application/zsafe",
1455 "*.txt"); 1427 "*.txt");
1456#endif 1428#endif
1457#else 1429#else
1458 QString fn = QFileDialog::getOpenFileName( 1430 QString fn = QFileDialog::getOpenFileName(
1459 QDir::homeDirPath() + "/Documents/application/zsafe", 1431 QDir::homeDirPath() + "/Documents/application/zsafe",
1460 "ZSafe (*.txt)", 1432 "ZSafe (*.txt)",
1461 this, 1433 this,
1462 "ZSafe File Dialog" 1434 "ZSafe File Dialog"
1463 "Choose a text file" ); 1435 "Choose a text file" );
1464#endif 1436#endif
1465 1437
1466 if (fn && fn.length() > 0 ) 1438 if (fn && fn.length() > 0 )
1467 { 1439 {
1468 QFile f( fn ); 1440 QFile f( fn );
1469 if ( !f.open( IO_ReadOnly ) ) 1441 if ( !f.open( IO_ReadOnly ) )
1470 { 1442 {
1471#ifndef NO_OPIE 1443#ifndef NO_OPIE
1472 owarn << "Could not read file " << fn << oendl; 1444 owarn << "Could not read file " << fn << oendl;
1473#else 1445#else
1474 qWarning( QString("Could not read file %1").arg(fn), 2000 ); 1446 qWarning( QString("Could not read file %1").arg(fn), 2000 );
1475#endif 1447#endif
1476 QMessageBox::critical( 0, "ZSafe", 1448 QMessageBox::critical( 0, "ZSafe",
1477 QString("Could not import text file.") ); 1449 QString("Could not import text file.") );
1478 return; 1450 return;
1479 } 1451 }
1480 1452
1481 modified = true; 1453 modified = true;
1482 1454
1483 // clear the password list 1455 // clear the password list
1484 selectedItem = NULL; 1456 selectedItem = NULL;
1485 QListViewItem *i; 1457 QListViewItem *i;
1486 // step through all categories 1458 // step through all categories
1487 for (i = ListView->firstChild(); 1459 for (i = ListView->firstChild();
1488 i != NULL; 1460 i != NULL;
1489 i = i->nextSibling()) 1461 i = i->nextSibling())
1490 { 1462 {
1491 // step through all subitems 1463 // step through all subitems
1492 QListViewItem *si; 1464 QListViewItem *si;
1493 for (si = i->firstChild(); 1465 for (si = i->firstChild();
1494 si != NULL; ) 1466 si != NULL; )
1495 // si = si->nextSibling()) 1467 // si = si->nextSibling())
@@ -1796,306 +1768,322 @@ void ZSafe::readAllEntries()
1796 // user 1768 // user
1797 user = &i[1]; 1769 user = &i[1];
1798 user.truncate(user.length() -1); 1770 user.truncate(user.length() -1);
1799 break; 1771 break;
1800 case 2: 1772 case 2:
1801 // password 1773 // password
1802 password = &i[1]; 1774 password = &i[1];
1803 password.truncate(password.length() -1); 1775 password.truncate(password.length() -1);
1804 break; 1776 break;
1805 case 3: 1777 case 3:
1806 // comment 1778 // comment
1807 comment = &i[1]; 1779 comment = &i[1];
1808 comment.truncate(comment.length() -1); 1780 comment.truncate(comment.length() -1);
1809 break; 1781 break;
1810 } 1782 }
1811 idx++; 1783 idx++;
1812 } 1784 }
1813 1785
1814 Category *cat= categories.find (category); 1786 Category *cat= categories.find (category);
1815 if (cat) 1787 if (cat)
1816 { 1788 {
1817 // use the existend item 1789 // use the existend item
1818 QListViewItem *catItem = cat->getListItem(); 1790 QListViewItem *catItem = cat->getListItem();
1819 if (catItem) 1791 if (catItem)
1820 { 1792 {
1821 QListViewItem * item = new ShadedListItem( 0, catItem ); 1793 QListViewItem * item = new ShadedListItem( 0, catItem );
1822 item->setText( 0, tr( name ) ); 1794 item->setText( 0, tr( name ) );
1823 item->setText( 1, tr( user ) ); 1795 item->setText( 1, tr( user ) );
1824 item->setText( 2, tr( password ) ); 1796 item->setText( 2, tr( password ) );
1825 item->setText( 3, tr( comment ) ); 1797 item->setText( 3, tr( comment ) );
1826 1798
1827 catItem->setOpen( TRUE ); 1799 catItem->setOpen( TRUE );
1828 } 1800 }
1829 } 1801 }
1830 else 1802 else
1831 { 1803 {
1832 QListViewItem *catI = new ShadedListItem( 1, ListView ); 1804 QListViewItem *catI = new ShadedListItem( 1, ListView );
1833 // create and insert a new item 1805 // create and insert a new item
1834 QListViewItem * item = new ShadedListItem( 0, catI ); 1806 QListViewItem * item = new ShadedListItem( 0, catI );
1835 item->setText( 0, tr( name ) ); 1807 item->setText( 0, tr( name ) );
1836 item->setText( 1, tr( user ) ); 1808 item->setText( 1, tr( user ) );
1837 item->setText( 2, tr( password ) ); 1809 item->setText( 2, tr( password ) );
1838 item->setText( 3, tr( comment ) ); 1810 item->setText( 3, tr( comment ) );
1839 1811
1840 catI->setOpen( TRUE ); 1812 catI->setOpen( TRUE );
1841 1813
1842 Category *c1 = new Category(); 1814 Category *c1 = new Category();
1843 c1->setCategoryName(category); 1815 c1->setCategoryName(category);
1844 1816
1845 QString icon; 1817 QString icon;
1846 QString fullIconPath; 1818 QString fullIconPath;
1847 QPixmap *pix; 1819 QPixmap *pix;
1848// #ifndef Q_WS_WIN 1820// #ifndef Q_WS_WIN
1849 icon = conf->readEntry(APP_KEY+category); 1821 icon = conf->readEntry(APP_KEY+category);
1850// #endif 1822// #endif
1851 bool isIconAv = false; 1823 bool isIconAv = false;
1852 if (!icon.isEmpty() && !icon.isNull()) 1824 if (!icon.isEmpty() && !icon.isNull())
1853 { 1825 {
1854 // build the full path 1826 // build the full path
1855 fullIconPath = iconPath + icon; 1827 fullIconPath = iconPath + icon;
1856 pix = new QPixmap (fullIconPath); 1828 pix = new QPixmap (fullIconPath);
1857 if (!pix->isNull()) 1829 if (!pix->isNull())
1858 { 1830 {
1859 QImage img = pix->convertToImage(); 1831 QImage img = pix->convertToImage();
1860 pix->convertFromImage(img.smoothScale(14,14)); 1832 pix->convertFromImage(img.smoothScale(14,14));
1861 c1->setIconName (icon); 1833 c1->setIconName (icon);
1862 c1->setIcon (*pix); 1834 c1->setIcon (*pix);
1863 isIconAv = true; 1835 isIconAv = true;
1864 } 1836 }
1865 } 1837 }
1866 if (!isIconAv) 1838 if (!isIconAv)
1867 { 1839 {
1868 c1->setIcon (*getPredefinedIcon(category)); 1840 c1->setIcon (*getPredefinedIcon(category));
1869 } 1841 }
1870 c1->setListItem (catI); 1842 c1->setListItem (catI);
1871 c1->initListItem(); 1843 c1->initListItem();
1872 categories.insert (c1->getCategoryName(), c1); 1844 categories.insert (c1->getCategoryName(), c1);
1873 } 1845 }
1874 1846
1875 } 1847 }
1876 f.close(); 1848 f.close();
1877 1849
1878} 1850}
1879#endif // UNUSED 1851#endif // UNUSED
1880 1852
1881void ZSafe::resume(int) 1853void ZSafe::resume(int)
1882{ 1854{
1883#ifndef NO_OPIE 1855#ifndef NO_OPIE
1884 owarn << "Resume" << oendl; 1856 owarn << "Resume" << oendl;
1885#endif 1857#endif
1886 // hide the main window 1858 // hide the main window
1887 1859
1888 if ( !showpwd ) 1860 if ( !showpwd )
1889 { 1861 {
1890 infoForm->hide(); 1862 infoForm->hide();
1891 // open zsafe again 1863 // open zsafe again
1892 m_password = ""; 1864 m_password = "";
1893 selectedItem = NULL; 1865 selectedItem = NULL;
1894 1866
1895 // clear the password list 1867 // clear the password list
1896 QListViewItem *i; 1868 QListViewItem *i;
1897 // step through all categories 1869 // step through all categories
1898 for (i = ListView->firstChild(); 1870 for (i = ListView->firstChild();
1899 i != NULL; 1871 i != NULL;
1900 i = i->nextSibling()) 1872 i = i->nextSibling())
1901 { 1873 {
1902 // step through all subitems 1874 // step through all subitems
1903 QListViewItem *si; 1875 QListViewItem *si;
1904 for (si = i->firstChild(); 1876 for (si = i->firstChild();
1905 si != NULL; ) 1877 si != NULL; )
1906 { 1878 {
1907 QListViewItem *_si = si; 1879 QListViewItem *_si = si;
1908 si = si->nextSibling(); 1880 si = si->nextSibling();
1909 i->takeItem(_si); // remove from view list 1881 i->takeItem(_si); // remove from view list
1910 if (_si) delete _si; 1882 if (_si) delete _si;
1911 } 1883 }
1912 } 1884 }
1913 1885
1914 // ask for password and read again 1886 // ask for password and read again
1915 openDocument(filename); 1887 openDocument(filename);
1916 } 1888 }
1917} 1889}
1918 1890
1919//--------------------------------------------- 1891//---------------------------------------------
1920 1892
1921 1893
1922bool ZSafe::openDocument(const char* _filename, const char* ) 1894bool ZSafe::openDocument(const char* _filename, const char* )
1923{ 1895{
1896 QString name= _filename;
1897 qWarning("openDocument "+name);
1924 int retval; 1898 int retval;
1925 char* entry[FIELD_SIZE]; 1899 char* entry[FIELD_SIZE];
1926// #ifndef Q_WS_WIN 1900// #ifndef Q_WS_WIN
1927 int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); 1901 int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1);
1928// #else 1902// #else
1929 // int validationFlag = 1; 1903 // int validationFlag = 1;
1930// #endif 1904// #endif
1931 1905
1932 int pwdOk = 0; 1906 int pwdOk = 0;
1933 int numberOfTries = 3; 1907 int numberOfTries = 3;
1934 for (int i=0; i < numberOfTries; i++) 1908 for (int i=0; i < numberOfTries; i++)
1935 { 1909 {
1936 QFile f(_filename); 1910 QFile f(_filename);
1937 if (f.exists()) 1911 if (f.exists())
1938 { 1912 {
1939 // ask with a dialog for the password 1913 // ask with a dialog for the password
1940 if (m_password.isEmpty()) 1914 if (m_password.isEmpty())
1941 getDocPassword(tr("Enter Password")); 1915 getDocPassword(tr("Enter Password"));
1942 if (m_password.isEmpty() && validationFlag == 0) 1916 if (m_password.isEmpty() && validationFlag == 0)
1943 { 1917 {
1944#ifndef NO_OPIE 1918#ifndef NO_OPIE
1945 owarn << "Wrong password" << oendl; 1919 owarn << "Wrong password" << oendl;
1946#else 1920#else
1947 qWarning ("Wrong password"); 1921 qWarning ("Wrong password");
1948#endif 1922#endif
1949 QMessageBox::critical( 0, tr("ZSafe"), 1923 QMessageBox::critical( 0, tr("ZSafe"),
1950 tr("Wrong password.\n\nZSafe will now exit.") ); 1924 tr("Wrong password.\n\nZSafe will now exit.") );
1951 exitZs (1); 1925 exitZs (1);
1952 } 1926 }
1953 1927
1954 retval = loadInit(_filename, m_password); 1928 retval = loadInit(_filename, m_password);
1955 if (retval != PWERR_GOOD) 1929 if (retval != PWERR_GOOD)
1956 { 1930 {
1957#ifndef NO_OPIE 1931#ifndef NO_OPIE
1958 owarn << "Error loading Document" << oendl; 1932 owarn << "Error loading Document" << oendl;
1959#else 1933#else
1960 qWarning ("Error loading Document"); 1934 qWarning ("Error loading Document");
1961#endif 1935#endif
1962 return false; 1936 return false;
1963 } 1937 }
1964 } 1938 }
1965 else 1939 else
1966 { 1940 {
1967#ifdef Q_WS_WIN 1941#ifdef Q_WS_WIN
1968 this->setCaption("Qt ZSafe"); 1942 this->setCaption("Qt ZSafe");
1969#else 1943#else
1970 this->setCaption("ZSafe"); 1944 this->setCaption("ZSafe");
1971#endif 1945#endif
1972 filename = ""; 1946 filename = "";
1947 switch( QMessageBox::warning( this, tr("ZSafe"),
1948 tr("<P>You must create a new document first. Ok to create?</P>"),
1949 tr("&Yes"), tr("&No."),
1950 0
1951 ) )
1952 {
1953 case 1: // No
1973 return false; 1954 return false;
1955 break;
1956 case 0: // Yes
1957 newDocument();
1958 return false;
1959 break;
1960 }
1961
1974 } 1962 }
1975 1963
1976 1964
1977 // load the validation entry 1965 // load the validation entry
1978 if (validationFlag == 0) 1966 if (validationFlag == 0)
1979 { 1967 {
1980 pwdOk = 1; 1968 pwdOk = 1;
1981 break; 1969 break;
1982 } 1970 }
1983 1971
1984 retval = loadEntry(entry); 1972 retval = loadEntry(entry);
1985 if (retval == 1 && 1973 if (retval == 1 &&
1986 !strcmp (entry[0], "ZSAFECATEGORY") && 1974 !strcmp (entry[0], "ZSAFECATEGORY") &&
1987 !strcmp (entry[1], "name") && 1975 !strcmp (entry[1], "name") &&
1988 !strcmp (entry[2], "username") && 1976 !strcmp (entry[2], "username") &&
1989 !strcmp (entry[3], "password") && 1977 !strcmp (entry[3], "password") &&
1990 !strcmp (entry[4], "comment") ) 1978 !strcmp (entry[4], "comment") )
1991 { 1979 {
1992 for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); 1980 for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
1993 pwdOk = 1; 1981 pwdOk = 1;
1994 break; 1982 break;
1995 } 1983 }
1996 else 1984 else
1997 // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); 1985 // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]);
1998 fclose (fd); 1986 fclose (fd);
1999 m_password = ""; 1987 m_password = "";
2000 1988
2001 if (i < numberOfTries - 1) 1989 if (i < numberOfTries - 1)
2002 { 1990 {
2003 switch( QMessageBox::warning( this, tr("ZSafe"), 1991 switch( QMessageBox::warning( this, tr("ZSafe"),
2004 tr("Wrong password.\nEnter again?"), 1992 tr("Wrong password.\nEnter again?"),
2005 tr("&Yes"), tr("&No."), 1993 tr("&Yes"), tr("&No."),
2006 0 1994 0
2007 ) ) 1995 ) )
2008 { 1996 {
2009 case 1: // No 1997 case 1: // No
2010 exitZs (1); 1998 exitZs (1);
2011 break; 1999 break;
2012 case 0: // Yes 2000 case 0: // Yes
2013 continue; 2001 continue;
2014 } 2002 }
2015 } 2003 }
2016 } 2004 }
2017 if (pwdOk == 0) 2005 if (pwdOk == 0)
2018 { 2006 {
2019 // unset the document entry 2007 // unset the document entry
2020 conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); 2008 conf->writeEntry(APP_KEY+"document", "INVALIDPWD");
2021 if (conf) 2009 if (conf)
2022 delete conf; 2010 delete conf;
2023 2011
2024 exitZs (1); 2012 exitZs (1);
2025 } 2013 }
2026 2014
2027 2015
2028 retval = loadEntry(entry); 2016 retval = loadEntry(entry);
2029 2017
2030 int numberOfEntries=0; 2018 int numberOfEntries=0;
2031 while (retval == 1) { 2019 while (retval == 1) {
2032 2020
2033 QString category( QString::fromUtf8(entry[0]) ); 2021 QString category( QString::fromUtf8(entry[0]) );
2034 QString name( QString::fromUtf8(entry[1]) ); 2022 QString name( QString::fromUtf8(entry[1]) );
2035 QString user( QString::fromUtf8(entry[2]) ); 2023 QString user( QString::fromUtf8(entry[2]) );
2036 QString password( QString::fromUtf8(entry[3]) ); 2024 QString password( QString::fromUtf8(entry[3]) );
2037 QString comment( QString::fromUtf8(entry[4]) ); 2025 QString comment( QString::fromUtf8(entry[4]) );
2038 QString field5( QString::fromUtf8(entry[5]) ); 2026 QString field5( QString::fromUtf8(entry[5]) );
2039 QString field6( QString::fromUtf8(entry[6]) ); 2027 QString field6( QString::fromUtf8(entry[6]) );
2040 // add the subitems to the categories 2028 // add the subitems to the categories
2041 2029
2042 Category *cat= categories.find (category); 2030 Category *cat= categories.find (category);
2043 if (cat) 2031 if (cat)
2044 { 2032 {
2045 // use the existend item 2033 // use the existend item
2046 QListViewItem *catItem = cat->getListItem(); 2034 QListViewItem *catItem = cat->getListItem();
2047 if (catItem) 2035 if (catItem)
2048 { 2036 {
2049 QListViewItem * item = new ShadedListItem( 0, catItem ); 2037 QListViewItem * item = new ShadedListItem( 0, catItem );
2050 item->setText( 0, tr( name ) ); 2038 item->setText( 0, tr( name ) );
2051 item->setText( 1, tr( user ) ); 2039 item->setText( 1, tr( user ) );
2052 item->setText( 2, tr( password ) ); 2040 item->setText( 2, tr( password ) );
2053 item->setText( 3, tr( comment ) ); 2041 item->setText( 3, tr( comment ) );
2054 item->setText( 4, tr( field5 ) ); 2042 item->setText( 4, tr( field5 ) );
2055 item->setText( 5, tr( field6 ) ); 2043 item->setText( 5, tr( field6 ) );
2056 2044
2057 if (expandTree) 2045 if (expandTree)
2058 catItem->setOpen( TRUE ); 2046 catItem->setOpen( TRUE );
2059 numberOfEntries++; 2047 numberOfEntries++;
2060 } 2048 }
2061 } 2049 }
2062 else 2050 else
2063 { 2051 {
2064 QListViewItem *catI = new ShadedListItem( 1, ListView ); 2052 QListViewItem *catI = new ShadedListItem( 1, ListView );
2065 // create and insert a new item 2053 // create and insert a new item
2066 QListViewItem * item = new ShadedListItem( 0, catI ); 2054 QListViewItem * item = new ShadedListItem( 0, catI );
2067 2055
2068 item->setText( 0, tr( name ) ); 2056 item->setText( 0, tr( name ) );
2069 item->setText( 1, tr( user ) ); 2057 item->setText( 1, tr( user ) );
2070 item->setText( 2, tr( password ) ); 2058 item->setText( 2, tr( password ) );
2071 item->setText( 3, tr( comment ) ); 2059 item->setText( 3, tr( comment ) );
2072 item->setText( 4, tr( field5 ) ); 2060 item->setText( 4, tr( field5 ) );
2073 item->setText( 5, tr( field6 ) ); 2061 item->setText( 5, tr( field6 ) );
2074 2062
2075 if (expandTree) 2063 if (expandTree)
2076 catI->setOpen( TRUE ); 2064 catI->setOpen( TRUE );
2077 2065
2078 Category *c1 = new Category(); 2066 Category *c1 = new Category();
2079 c1->setCategoryName(category); 2067 c1->setCategoryName(category);
2080 2068
2081 QString icon; 2069 QString icon;
2082 QString fullIconPath; 2070 QString fullIconPath;
2083 QPixmap *pix; 2071 QPixmap *pix;
2084// #ifndef Q_WS_WIN 2072// #ifndef Q_WS_WIN
2085 icon = conf->readEntry(APP_KEY+category); 2073 icon = conf->readEntry(APP_KEY+category);
2086// #endif 2074// #endif
2087 bool isIconAv = false; 2075 bool isIconAv = false;
2088 if (!icon.isEmpty() && !icon.isNull()) 2076 if (!icon.isEmpty() && !icon.isNull())
2089 { 2077 {
2090 // build the full path 2078 // build the full path
2091 fullIconPath = iconPath + icon; 2079 fullIconPath = iconPath + icon;
2092 pix = new QPixmap (fullIconPath); 2080 pix = new QPixmap (fullIconPath);
2093 if (!pix->isNull()) 2081 if (!pix->isNull())
2094 { 2082 {
2095 QImage img = pix->convertToImage(); 2083 QImage img = pix->convertToImage();
2096 pix->convertFromImage(img.smoothScale(14,14)); 2084 pix->convertFromImage(img.smoothScale(14,14));
2097 c1->setIconName (icon); 2085 c1->setIconName (icon);
2098 c1->setIcon (*pix); 2086 c1->setIcon (*pix);
2099 isIconAv = true; 2087 isIconAv = true;
2100 } 2088 }
2101 } 2089 }
@@ -3322,585 +3310,566 @@ void ZSafe::editCategory()
3322 // build the full path 3310 // build the full path
3323 fullIconPath = iconPath + icon; 3311 fullIconPath = iconPath + icon;
3324 pix = new QPixmap (fullIconPath); 3312 pix = new QPixmap (fullIconPath);
3325 if (!pix->isNull()) 3313 if (!pix->isNull())
3326 { 3314 {
3327 // save the full pixmap name into the config file 3315 // save the full pixmap name into the config file
3328// #ifndef Q_WS_WIN 3316// #ifndef Q_WS_WIN
3329 conf->writeEntry(APP_KEY+category, icon); 3317 conf->writeEntry(APP_KEY+category, icon);
3330// #endif 3318// #endif
3331 saveConf(); 3319 saveConf();
3332 QImage img = pix->convertToImage(); 3320 QImage img = pix->convertToImage();
3333 pix->convertFromImage(img.smoothScale(14,14)); 3321 pix->convertFromImage(img.smoothScale(14,14));
3334 cat->setIconName (icon); 3322 cat->setIconName (icon);
3335 cat->setIcon (*pix); 3323 cat->setIcon (*pix);
3336 } 3324 }
3337 } 3325 }
3338 else 3326 else
3339 { 3327 {
3340// #ifndef Q_WS_WIN 3328// #ifndef Q_WS_WIN
3341 conf->removeEntry (category); 3329 conf->removeEntry (category);
3342// #endif 3330// #endif
3343 saveConf(); 3331 saveConf();
3344 cat->setIcon (*getPredefinedIcon(category)); 3332 cat->setIcon (*getPredefinedIcon(category));
3345 } 3333 }
3346 3334
3347 // change the category name of the selected category 3335 // change the category name of the selected category
3348 QListViewItem *catItem = cat->getListItem(); 3336 QListViewItem *catItem = cat->getListItem();
3349 if (catItem) 3337 if (catItem)
3350 { 3338 {
3351#ifndef NO_OPIE 3339#ifndef NO_OPIE
3352 owarn << category << oendl; 3340 owarn << category << oendl;
3353#else 3341#else
3354 qWarning (category); 3342 qWarning (category);
3355#endif 3343#endif
3356 catItem->setText( 0, tr( category ) ); 3344 catItem->setText( 0, tr( category ) );
3357 cat->setCategoryName (tr(category)); 3345 cat->setCategoryName (tr(category));
3358 3346
3359 cat->initListItem(); 3347 cat->initListItem();
3360 categories.insert (category, cat); 3348 categories.insert (category, cat);
3361 } 3349 }
3362 } 3350 }
3363 saveCategoryDialogFields(dialog); 3351 saveCategoryDialogFields(dialog);
3364 } 3352 }
3365 else 3353 else
3366 { 3354 {
3367 // delete dialog; 3355 // delete dialog;
3368 dialog->hide(); 3356 dialog->hide();
3369 return; 3357 return;
3370 } 3358 }
3371 3359
3372 } 3360 }
3373} 3361}
3374 3362
3375void ZSafe::cutItem() 3363void ZSafe::cutItem()
3376{ 3364{
3377 if (!selectedItem) 3365 if (!selectedItem)
3378 return; 3366 return;
3379 if (!isCategory(selectedItem)) 3367 if (!isCategory(selectedItem))
3380 { 3368 {
3381 IsCut = true; 3369 IsCut = true;
3382 copiedItem = selectedItem; 3370 copiedItem = selectedItem;
3383 } 3371 }
3384} 3372}
3385 3373
3386void ZSafe::copyItem() 3374void ZSafe::copyItem()
3387{ 3375{
3388 if (!selectedItem) 3376 if (!selectedItem)
3389 return; 3377 return;
3390 if (!isCategory(selectedItem)) 3378 if (!isCategory(selectedItem))
3391 { 3379 {
3392 IsCopy = true; 3380 IsCopy = true;
3393 copiedItem = selectedItem; 3381 copiedItem = selectedItem;
3394 } 3382 }
3395} 3383}
3396 3384
3397// paste item into category 3385// paste item into category
3398void ZSafe::pasteItem() 3386void ZSafe::pasteItem()
3399{ 3387{
3400 if (!selectedItem) 3388 if (!selectedItem)
3401 return; 3389 return;
3402 if (isCategory(selectedItem)) 3390 if (isCategory(selectedItem))
3403 { 3391 {
3404 modified = true; 3392 modified = true;
3405 if (IsCut) 3393 if (IsCut)
3406 { 3394 {
3407 if (copiedItem) 3395 if (copiedItem)
3408 { 3396 {
3409 // add the new item 3397 // add the new item
3410 QListViewItem *i = new ShadedListItem (0, selectedItem); 3398 QListViewItem *i = new ShadedListItem (0, selectedItem);
3411 // i->setOpen (TRUE); 3399 // i->setOpen (TRUE);
3412 i->setText (0, copiedItem->text(0)); 3400 i->setText (0, copiedItem->text(0));
3413 i->setText (1, copiedItem->text(1)); 3401 i->setText (1, copiedItem->text(1));
3414 i->setText (2, copiedItem->text(2)); 3402 i->setText (2, copiedItem->text(2));
3415 i->setText (3, copiedItem->text(3)); 3403 i->setText (3, copiedItem->text(3));
3416 i->setText (4, copiedItem->text(4)); 3404 i->setText (4, copiedItem->text(4));
3417 i->setText (5, copiedItem->text(5)); 3405 i->setText (5, copiedItem->text(5));
3418 selectedItem->setOpen( TRUE ); 3406 selectedItem->setOpen( TRUE );
3419 3407
3420 // remove the cutted item 3408 // remove the cutted item
3421 copiedItem->parent()->takeItem(copiedItem); 3409 copiedItem->parent()->takeItem(copiedItem);
3422 selectedItem = NULL; 3410 selectedItem = NULL;
3423 } 3411 }
3424 } 3412 }
3425 else if (IsCopy) 3413 else if (IsCopy)
3426 { 3414 {
3427 if (copiedItem) 3415 if (copiedItem)
3428 { 3416 {
3429 // add the new item 3417 // add the new item
3430 QListViewItem *i = new ShadedListItem (0, selectedItem); 3418 QListViewItem *i = new ShadedListItem (0, selectedItem);
3431 // i->setOpen (TRUE); 3419 // i->setOpen (TRUE);
3432 i->setText (0, copiedItem->text(0)); 3420 i->setText (0, copiedItem->text(0));
3433 i->setText (1, copiedItem->text(1)); 3421 i->setText (1, copiedItem->text(1));
3434 i->setText (2, copiedItem->text(2)); 3422 i->setText (2, copiedItem->text(2));
3435 i->setText (3, copiedItem->text(3)); 3423 i->setText (3, copiedItem->text(3));
3436 i->setText (4, copiedItem->text(4)); 3424 i->setText (4, copiedItem->text(4));
3437 i->setText (5, copiedItem->text(5)); 3425 i->setText (5, copiedItem->text(5));
3438 selectedItem->setOpen( TRUE ); 3426 selectedItem->setOpen( TRUE );
3439 } 3427 }
3440 } 3428 }
3441 } 3429 }
3442 IsCut = false; 3430 IsCut = false;
3443 IsCopy = false; 3431 IsCopy = false;
3444} 3432}
3445 3433
3446void ZSafe::newDocument() 3434void ZSafe::newDocument()
3447{ 3435{
3448 3436
3449 // open the file dialog 3437 // open the file dialog
3450#ifndef DESKTOP 3438 QString newFile = zsaveDialog();
3451#ifndef NO_OPIE
3452 QMap<QString, QStringList> mimeTypes;
3453 mimeTypes.insert(tr("All"), QStringList() );
3454 mimeTypes.insert(tr("ZSafe"), "zsafe/*" );
3455 QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
3456 QDir::homeDirPath() + "/Documents/application/zsafe",
3457 QString::null,
3458 mimeTypes,
3459 this,
3460 tr ("Create new ZSafe document"));
3461#else
3462 QString newFile = ScQtFileEdit::getSaveAsFileName(this,
3463 tr ("Create new ZSafe document"),
3464 QDir::homeDirPath() + "/Documents/application/zsafe",
3465 "*.zsf");
3466#endif
3467#else
3468 QString newFile = QFileDialog::getSaveFileName(
3469 QDir::homeDirPath() + "/Documents/application/zsafe",
3470 "ZSafe (*.zsf)",
3471 this,
3472 "ZSafe File Dialog"
3473 "Choose a ZSafe file" );
3474#endif
3475 3439
3476 // open the new document 3440 // open the new document
3477 if (newFile && newFile.length() > 0 ) 3441 if (newFile && newFile.length() > 0 )
3478 { 3442 {
3479 // save the previous opened document 3443 // save the previous opened document
3480 if (!filename.isEmpty()) 3444 if (!filename.isEmpty())
3481 saveDocument(filename, FALSE); 3445 saveDocument(filename, FALSE);
3482 3446
3483 modified = true; 3447 modified = true;
3484 3448
3485 // clear the password list 3449 // clear the password list
3486 QListViewItem *i; 3450 QListViewItem *i;
3487 QListViewItem *c = NULL; 3451 QListViewItem *c = NULL;
3488 // step through all categories 3452 // step through all categories
3489 for (i = ListView->firstChild(); 3453 for (i = ListView->firstChild();
3490 i != NULL; 3454 i != NULL;
3491 i = i->nextSibling()) 3455 i = i->nextSibling())
3492 { 3456 {
3493 if (c) delete c; // delete the previous category 3457 if (c) delete c; // delete the previous category
3494 3458
3495 c = i; 3459 c = i;
3496 // step through all subitems 3460 // step through all subitems
3497 QListViewItem *si; 3461 QListViewItem *si;
3498 for (si = i->firstChild(); 3462 for (si = i->firstChild();
3499 si != NULL; ) 3463 si != NULL; )
3500 { 3464 {
3501 QListViewItem *_si = si; 3465 QListViewItem *_si = si;
3502 si = si->nextSibling(); 3466 si = si->nextSibling();
3503 i->takeItem(_si); // remove from view list 3467 i->takeItem(_si); // remove from view list
3504 if (_si) delete _si; 3468 if (_si) delete _si;
3505 } 3469 }
3506 } 3470 }
3507 if (c) delete c; // delete the previous category 3471 if (c) delete c; // delete the previous category
3508 categories.clear(); 3472 categories.clear();
3509 3473
3510 // m_password = ""; 3474 // m_password = "";
3511 selectedItem = NULL; 3475 selectedItem = NULL;
3512 3476
3513 filename = newFile; 3477 filename = newFile;
3514 3478
3515 // save the current filename to the config file 3479 // save the current filename to the config file
3516 conf->writeEntry(APP_KEY+"document", filename); 3480 conf->writeEntry(APP_KEY+"document", filename);
3517 saveConf(); 3481 saveConf();
3518 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 3482 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
3519#ifdef Q_WS_WIN 3483#ifdef Q_WS_WIN
3520 this->setCaption("Qt ZSafe: " + ti); 3484 this->setCaption("Qt ZSafe: " + ti);
3521#else 3485#else
3522 this->setCaption("ZSafe: " + ti); 3486 this->setCaption("ZSafe: " + ti);
3523#endif 3487#endif
3524 3488
3525 // openDocument(filename); 3489 // openDocument(filename);
3526 3490
3527 QMessageBox::information( this, tr("ZSafe"), 3491 QMessageBox::information( this, tr("ZSafe"),
3528 tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); 3492 tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0);
3529 3493
3530 saveDocumentWithPwd(); 3494 saveDocumentWithPwd();
3531 } 3495 }
3532} 3496}
3533 3497
3534void ZSafe::loadDocument() 3498void ZSafe::loadDocument()
3535{ 3499{
3536 3500
3537 // open the file dialog 3501 // open the file dialog
3538#ifndef DESKTOP 3502#ifndef DESKTOP
3539#ifndef NO_OPIE 3503#ifndef NO_OPIE
3540 QMap<QString, QStringList> mimeTypes; 3504 QMap<QString, QStringList> mimeTypes;
3541 mimeTypes.insert(tr("All"), QStringList() ); 3505 mimeTypes.insert(tr("All"), QStringList() );
3542 mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); 3506 mimeTypes.insert(tr("ZSafe"), "zsafe/*" );
3543 QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 3507 QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
3544 QDir::homeDirPath() + "/Documents/application/zsafe", 3508 QDir::homeDirPath() + "/Documents/application/zsafe",
3545 QString::null, 3509 QString::null,
3546 mimeTypes, 3510 mimeTypes,
3547 this, 3511 this,
3548 tr ("Open ZSafe document")); 3512 tr ("Open ZSafe document"));
3549#else 3513#else
3550 QString newFile = ScQtFileEdit::getOpenFileName(this, 3514 QString newFile = ScQtFileEdit::getOpenFileName(this,
3551 tr ("Open ZSafe document"), 3515 tr ("Open ZSafe document"),
3552 QDir::homeDirPath() + "/Documents/application/zsafe", 3516 QDir::homeDirPath() + "/Documents/application/zsafe",
3553 "*.zsf"); 3517 "*.zsf");
3554#endif 3518#endif
3555#else 3519#else
3556 QString newFile = QFileDialog::getOpenFileName( 3520 QString newFile = QFileDialog::getOpenFileName(
3557 QDir::homeDirPath() + "/Documents/application/zsafe", 3521 QDir::homeDirPath() + "/Documents/application/zsafe",
3558 "ZSafe (*.zsf)", 3522 "ZSafe (*.zsf)",
3559 this, 3523 this,
3560 "ZSafe File Dialog" 3524 "ZSafe File Dialog"
3561 "Choose a ZSafe file" ); 3525 "Choose a ZSafe file" );
3562#endif 3526#endif
3563 3527
3564 // open the new document 3528 // open the new document
3565 if (newFile && newFile.length() > 0 ) 3529 if (newFile && newFile.length() > 0 )
3566 { 3530 {
3567 // save the previous opened document 3531 // save the previous opened document
3568 if (!filename.isEmpty()) 3532 if (!filename.isEmpty())
3569 saveDocument(filename, FALSE); 3533 saveDocument(filename, FALSE);
3570 3534
3571 // clear the password list 3535 // clear the password list
3572 QListViewItem *i; 3536 QListViewItem *i;
3573 QListViewItem *c = NULL; 3537 QListViewItem *c = NULL;
3574 // step through all categories 3538 // step through all categories
3575 for (i = ListView->firstChild(); 3539 for (i = ListView->firstChild();
3576 i != NULL; 3540 i != NULL;
3577 i = i->nextSibling()) 3541 i = i->nextSibling())
3578 { 3542 {
3579 if (c) delete c; // delete the previous category 3543 if (c) delete c; // delete the previous category
3580 3544
3581 c = i; 3545 c = i;
3582 // step through all subitems 3546 // step through all subitems
3583 QListViewItem *si; 3547 QListViewItem *si;
3584 for (si = i->firstChild(); 3548 for (si = i->firstChild();
3585 si != NULL; ) 3549 si != NULL; )
3586 { 3550 {
3587 QListViewItem *_si = si; 3551 QListViewItem *_si = si;
3588 si = si->nextSibling(); 3552 si = si->nextSibling();
3589 i->takeItem(_si); // remove from view list 3553 i->takeItem(_si); // remove from view list
3590 if (_si) delete _si; 3554 if (_si) delete _si;
3591 } 3555 }
3592 } 3556 }
3593 if (c) delete c; // delete the previous category 3557 if (c) delete c; // delete the previous category
3594 categories.clear(); 3558 categories.clear();
3595 m_password = ""; 3559 m_password = "";
3596 selectedItem = NULL; 3560 selectedItem = NULL;
3597 filename = newFile; 3561 filename = newFile;
3598 3562
3599 // save the current filename to the config file 3563 // save the current filename to the config file
3600 conf->writeEntry(APP_KEY+"document", filename); 3564 conf->writeEntry(APP_KEY+"document", filename);
3601 saveConf(); 3565 saveConf();
3602 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 3566 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
3603#ifdef Q_WS_WIN 3567#ifdef Q_WS_WIN
3604 this->setCaption("Qt ZSafe: " + ti); 3568 this->setCaption("Qt ZSafe: " + ti);
3605#else 3569#else
3606 this->setCaption("ZSafe: " + ti); 3570 this->setCaption("ZSafe: " + ti);
3607#endif 3571#endif
3608 3572
3609 openDocument(filename); 3573 openDocument(filename);
3610 } 3574 }
3611} 3575}
3612 3576
3613void ZSafe::saveDocumentAs() 3577void ZSafe::saveDocumentAs()
3614{ 3578{
3615 3579
3616#ifndef DESKTOP 3580QString newFile = zsaveDialog();
3617#ifndef NO_OPIE
3618 QMap<QString, QStringList> mimeTypes;
3619 mimeTypes.insert(tr("All"), QStringList() );
3620 mimeTypes.insert(tr("ZSafe"), "zsafe/*" );
3621 QString newFile = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
3622 QDir::homeDirPath() + "/Documents/application/zsafe",
3623 QString::null,
3624 mimeTypes,
3625 this,
3626 tr ("Save ZSafe document as.."));
3627#else
3628 QString newFile = ScQtFileEdit::getSaveAsFileName(this,
3629 tr ("Save ZSafe document as.."),
3630 QDir::homeDirPath() + "/Documents/application/zsafe",
3631 "*.zsf");
3632#endif
3633#else
3634 // open the file dialog
3635 QString newFile = QFileDialog::getSaveFileName(
3636 QDir::homeDirPath() + "/Documents/application/zsafe",
3637 "ZSafe (*.zsf)",
3638 this,
3639 "ZSafe File Dialog"
3640 "Choose a ZSafe file" );
3641#endif
3642
3643 // open the new document 3581 // open the new document
3644 if (newFile && newFile.length() > 0 ) 3582 if (newFile && newFile.length() > 0 )
3645 { 3583 {
3646 // save the previous opened document 3584 // save the previous opened document
3647 if (!filename.isEmpty()) 3585 if (!filename.isEmpty())
3648 saveDocument(filename, FALSE); 3586 saveDocument(filename, FALSE);
3649 3587
3650 selectedItem = NULL; 3588 selectedItem = NULL;
3651 filename = newFile; 3589 filename = newFile;
3652 3590
3653 // save the current filename to the config file 3591 // save the current filename to the config file
3654 conf->writeEntry(APP_KEY+"document", filename); 3592 conf->writeEntry(APP_KEY+"document", filename);
3655 saveConf(); 3593 saveConf();
3656 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 3594 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
3657#ifdef Q_WS_WIN 3595#ifdef Q_WS_WIN
3658 this->setCaption("Qt ZSafe: " + ti); 3596 this->setCaption("Qt ZSafe: " + ti);
3659#else 3597#else
3660 this->setCaption("ZSafe: " + ti); 3598 this->setCaption("ZSafe: " + ti);
3661#endif 3599#endif
3662 3600
3663 QMessageBox::information( this, tr("ZSafe"), 3601 QMessageBox::information( this, tr("ZSafe"),
3664 tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); 3602 tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0);
3665 3603
3666 saveDocumentWithPwd(); 3604 saveDocumentWithPwd();
3667 } 3605 }
3668} 3606}
3669 3607
3670void ZSafe::saveDocumentWithoutPwd() 3608void ZSafe::saveDocumentWithoutPwd()
3671{ 3609{
3672 saveDocument(filename, FALSE); 3610 saveDocument(filename, FALSE);
3673} 3611}
3674 3612
3675void ZSafe::saveDocumentWithPwd() 3613void ZSafe::saveDocumentWithPwd()
3676{ 3614{
3677 saveDocument(filename, TRUE); 3615 saveDocument(filename, TRUE);
3678} 3616}
3679 3617
3680void ZSafe::about() 3618void ZSafe::about()
3681{ 3619{
3682 QString info; 3620 QString info;
3683#ifdef JPATCH_HDE 3621#ifdef JPATCH_HDE
3684 info = "<html><body><div align=""center"">"; 3622 info = "<html><body><div align=""center"">";
3685 info += "<b>"; 3623 info += "<b>";
3686 info += tr("Zaurus Password Manager<br>"); 3624 info += tr("Zaurus Password Manager<br>");
3687 info += tr("ZSafe version 2.1.2-jv01b<br>"); 3625 info += tr("ZSafe version 2.1.2-jv01b<br>");
3688 info += "</b>"; 3626 info += "</b>";
3689 info += tr("by Carsten Schneider<br>"); 3627 info += tr("by Carsten Schneider<br>");
3690 info += "zcarsten@gmx.net<br>"; 3628 info += "zcarsten@gmx.net<br>";
3691 info += "http://z-soft.z-portal.info/zsafe"; 3629 info += "http://z-soft.z-portal.info/zsafe";
3692 info += "<br>"; 3630 info += "<br>";
3693 info += tr("Translations by Robert Ernst<br>"); 3631 info += tr("Translations by Robert Ernst<br>");
3694 info += "robert.ernst@linux-solutions.at<br>"; 3632 info += "robert.ernst@linux-solutions.at<br>";
3695 3633
3696 info += "<br><br>"; 3634 info += "<br><br>";
3697 info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>"); 3635 info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>");
3698 info += "HADECO R&D<br>"; 3636 info += "HADECO R&D<br>";
3699 info += "r&d@hadeco.co.jp<br>"; 3637 info += "r&d@hadeco.co.jp<br>";
3700 info += "http://www.hadeco.co.jp/r&d/<br>"; 3638 info += "http://www.hadeco.co.jp/r&d/<br>";
3701 info += "<br></div>"; 3639 info += "<br></div>";
3702 info += "</body></html>"; 3640 info += "</body></html>";
3703#else 3641#else
3704 info = "<html><body><div align=""center"">"; 3642 info = "<html><body><div align=""center"">";
3705 info += "<b>"; 3643 info += "<b>";
3706 info += tr("Zaurus Password Manager<br>"); 3644 info += tr("Zaurus Password Manager<br>");
3707 info += tr("ZSafe version 2.1.2<br>"); 3645 info += tr("ZSafe version 2.1.2<br>");
3708 info += "</b>"; 3646 info += "</b>";
3709 info += tr("by Carsten Schneider<br>"); 3647 info += tr("by Carsten Schneider<br>");
3710 info += "zcarsten@gmx.net<br>"; 3648 info += "zcarsten@gmx.net<br>";
3711 info += "http://z-soft.z-portal.info/zsafe"; 3649 info += "http://z-soft.z-portal.info/zsafe";
3712 info += "<br>"; 3650 info += "<br>";
3713 info += tr("Translations by Robert Ernst<br>"); 3651 info += tr("Translations by Robert Ernst<br>");
3714 info += "robert.ernst@linux-solutions.at<br>"; 3652 info += "robert.ernst@linux-solutions.at<br>";
3715 info += "<br></div>"; 3653 info += "<br></div>";
3716 info += "</body></html>"; 3654 info += "</body></html>";
3717#endif 3655#endif
3718 3656
3719 // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); 3657 // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0);
3720 3658
3721 QMessageBox mb( this, tr("ZSafe")); 3659 QMessageBox mb( this, tr("ZSafe"));
3722 mb.setText (info); 3660 mb.setText (info);
3723 mb.setButtonText (QMessageBox::Ok, tr ("&OK")); 3661 mb.setButtonText (QMessageBox::Ok, tr ("&OK"));
3724 QPixmap zsafe_img((const char**) zsafe_xpm); 3662 QPixmap zsafe_img((const char**) zsafe_xpm);
3725 mb.setIconPixmap (zsafe_img); 3663 mb.setIconPixmap (zsafe_img);
3726 mb.exec(); 3664 mb.exec();
3727} 3665}
3728 3666
3729void ZSafe::setExpandFlag() 3667void ZSafe::setExpandFlag()
3730{ 3668{
3731 expandTree = !expandTree; 3669 expandTree = !expandTree;
3732 file->setItemChecked('o', expandTree); 3670 file->setItemChecked('o', expandTree);
3733#ifndef DESKTOP 3671#ifndef DESKTOP
3734 conf->setGroup ("zsafePrefs"); 3672 conf->setGroup ("zsafePrefs");
3735#endif 3673#endif
3736// #ifndef Q_WS_WIN 3674// #ifndef Q_WS_WIN
3737 conf->writeEntry (APP_KEY+"expandTree", expandTree); 3675 conf->writeEntry (APP_KEY+"expandTree", expandTree);
3738// #endif 3676// #endif
3739 saveConf(); 3677 saveConf();
3740 3678
3741} 3679}
3742 3680
3743void ZSafe::paintEvent( QPaintEvent * ) 3681void ZSafe::paintEvent( QPaintEvent * )
3744{ 3682{
3745 if (raiseFlag) 3683 if (raiseFlag)
3746 { 3684 {
3747 raiseFlag = false; 3685 raiseFlag = false;
3748 raiseTimer.start (1, true); 3686 raiseTimer.start (1, true);
3749 if (infoForm->isVisible()) 3687 if (infoForm->isVisible())
3750 infoForm->raise(); 3688 infoForm->raise();
3751 } 3689 }
3752} 3690}
3753 3691
3754void ZSafe::resizeEvent ( QResizeEvent * ) 3692void ZSafe::resizeEvent ( QResizeEvent * )
3755{ 3693{
3756 // owarn << "resizeEvent" << oendl; 3694 // owarn << "resizeEvent" << oendl;
3757#ifndef DESKTOP 3695#ifndef DESKTOP
3758 DeskW = appl->desktop()->width(); 3696 DeskW = appl->desktop()->width();
3759 DeskH = appl->desktop()->height(); 3697 DeskH = appl->desktop()->height();
3760#else 3698#else
3761 DeskW = this->width(); 3699 DeskW = this->width();
3762 DeskH = this->height(); 3700 DeskH = this->height();
3763#endif 3701#endif
3764 3702
3765 if (New) 3703 if (New)
3766 New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); 3704 New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) );
3767 if (Edit) 3705 if (Edit)
3768 Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); 3706 Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) );
3769 if (Delete) 3707 if (Delete)
3770 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); 3708 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
3771 if (Find) 3709 if (Find)
3772 Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); 3710 Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) );
3773} 3711}
3774 3712
3775void ZSafe::slotRaiseTimer() 3713void ZSafe::slotRaiseTimer()
3776{ 3714{
3777 if (infoForm->isVisible()) 3715 if (infoForm->isVisible())
3778 infoForm->raise(); 3716 infoForm->raise();
3779 raiseFlag = true; 3717 raiseFlag = true;
3780} 3718}
3781 3719
3782QPixmap * ZSafe::getPredefinedIcon(QString category) 3720QPixmap * ZSafe::getPredefinedIcon(QString category)
3783{ 3721{
3784 QPixmap *pm; 3722 QPixmap *pm;
3785 if (category == "Bank cards") 3723 if (category == "Bank cards")
3786 pm = new QPixmap((const char**)bank_cards_data); 3724 pm = new QPixmap((const char**)bank_cards_data);
3787 else if (category == "Passwords") 3725 else if (category == "Passwords")
3788 pm = new QPixmap((const char**)passwords_data); 3726 pm = new QPixmap((const char**)passwords_data);
3789 else if (category == "Software") 3727 else if (category == "Software")
3790 pm = new QPixmap((const char**)software_data); 3728 pm = new QPixmap((const char**)software_data);
3791 else if (category == "General") 3729 else if (category == "General")
3792 pm = new QPixmap((const char**)general_data); 3730 pm = new QPixmap((const char**)general_data);
3793 else 3731 else
3794 pm = new QPixmap((const char**)general_data); 3732 pm = new QPixmap((const char**)general_data);
3795 return pm; 3733 return pm;
3796} 3734}
3797 3735
3798void ZSafe::setDocument(const QString& fileref) 3736void ZSafe::setDocument(const QString& fileref)
3799{ 3737{
3800#ifndef DESKTOP 3738#ifndef DESKTOP
3801 // stop the timer to prevent loading of the default document 3739 // stop the timer to prevent loading of the default document
3802 docuTimer.stop(); 3740 docuTimer.stop();
3803 3741
3804 DocLnk link(fileref); 3742 DocLnk link(fileref);
3805 if ( link.isValid() ) 3743 if ( link.isValid() )
3806 { 3744 {
3807 // if (filename != link.file()) 3745 // if (filename != link.file())
3808 // saveDocument(filename, FALSE); 3746 // saveDocument(filename, FALSE);
3809 filename = link.file(); 3747 filename = link.file();
3810 } 3748 }
3811 else 3749 else
3812 { 3750 {
3813 // if (filename != fileref) 3751 // if (filename != fileref)
3814 // saveDocument(filename, FALSE); 3752 // saveDocument(filename, FALSE);
3815 filename = fileref; 3753 filename = fileref;
3816 } 3754 }
3817 // save the current filename to the config file 3755 // save the current filename to the config file
3818 conf->writeEntry(APP_KEY+"document", filename); 3756 conf->writeEntry(APP_KEY+"document", filename);
3819 saveConf(); 3757 saveConf();
3820 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); 3758 QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
3821#ifdef Q_WS_WIN 3759#ifdef Q_WS_WIN
3822 this->setCaption("Qt ZSafe: " + ti); 3760 this->setCaption("Qt ZSafe: " + ti);
3823#else 3761#else
3824 this->setCaption("ZSafe: " + ti); 3762 this->setCaption("ZSafe: " + ti);
3825#endif 3763#endif
3826 3764
3827 // clear the password list 3765 // clear the password list
3828 QListViewItem *i; 3766 QListViewItem *i;
3829 QListViewItem *c = NULL; 3767 QListViewItem *c = NULL;
3830 // step through all categories 3768 // step through all categories
3831 for (i = ListView->firstChild(); 3769 for (i = ListView->firstChild();
3832 i != NULL; 3770 i != NULL;
3833 i = i->nextSibling()) 3771 i = i->nextSibling())
3834 { 3772 {
3835 if (c) delete c; // delete the previous category 3773 if (c) delete c; // delete the previous category
3836 3774
3837 c = i; 3775 c = i;
3838 // step through all subitems 3776 // step through all subitems
3839 QListViewItem *si; 3777 QListViewItem *si;
3840 for (si = i->firstChild(); 3778 for (si = i->firstChild();
3841 si != NULL; ) 3779 si != NULL; )
3842 { 3780 {
3843 QListViewItem *_si = si; 3781 QListViewItem *_si = si;
3844 si = si->nextSibling(); 3782 si = si->nextSibling();
3845 i->takeItem(_si); // remove from view list 3783 i->takeItem(_si); // remove from view list
3846 if (_si) delete _si; 3784 if (_si) delete _si;
3847 } 3785 }
3848 } 3786 }
3849 if (c) delete c; // delete the previous category 3787 if (c) delete c; // delete the previous category
3850 categories.clear(); 3788 categories.clear();
3851 3789
3852 m_password = ""; 3790 m_password = "";
3853 selectedItem = NULL; 3791 selectedItem = NULL;
3854 3792
3855 openDocument(filename); 3793 openDocument(filename);
3794#else
3795Q_UNUSED(fileref);
3856#endif 3796#endif
3857} 3797}
3858 3798
3859 3799
3860void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int column) { 3800void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int column) {
3861 if(item ==0) return; 3801 if(item ==0) return;
3862 switch (mouse) { 3802 switch (mouse) {
3863 case 1: 3803 case 1:
3864 { 3804 {
3865#ifdef DESKTOP 3805#ifdef DESKTOP
3866 QDragObject *d = new QTextDrag( item->text(column) , this ); 3806 QDragObject *d = new QTextDrag( item->text(column) , this );
3867 d->dragCopy(); 3807 d->dragCopy();
3868#endif 3808#endif
3869 } 3809 }
3870 break; 3810 break;
3871 case 2: 3811 case 2:
3872 { 3812 {
3873 QClipboard *cb = QApplication::clipboard(); 3813 QClipboard *cb = QApplication::clipboard();
3874 3814
3875 QIconSet copy_img((const char**) copy_xpm); 3815 QIconSet copy_img((const char**) copy_xpm);
3876 QIconSet edit_img((const char**) edit_xpm); 3816 QIconSet edit_img((const char**) edit_xpm);
3877 QPixmap folder_open_img((const char**) folder_open_xpm); 3817 QPixmap folder_open_img((const char**) folder_open_xpm);
3878 QPixmap editdelete_img((const char**) editdelete_xpm); 3818 QPixmap editdelete_img((const char**) editdelete_xpm);
3879 3819
3880 QPopupMenu *m = new QPopupMenu(this); 3820 QPopupMenu *m = new QPopupMenu(this);
3881 int copyItem = m->insertItem( copy_img, tr( "Copy to Clipboard" )); 3821 int copyItem = m->insertItem( copy_img, tr( "Copy to Clipboard" ));
3882 int editItem = m->insertItem(edit_img, tr( "Edit" )); 3822 int editItem = m->insertItem(edit_img, tr( "Edit" ));
3883 int showItem = m->insertItem(folder_open_img, tr( "Show Info" )); 3823 int showItem = m->insertItem(folder_open_img, tr( "Show Info" ));
3884 int cancelItem = m->insertItem( editdelete_img, tr( "Cancel" )); 3824 int cancelItem = m->insertItem( editdelete_img, tr( "Cancel" ));
3885 m->setFocus(); 3825 m->setFocus();
3886 int me=m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y() ) ) ; 3826 int me=m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y() ) ) ;
3887 if(me == copyItem) { 3827 if(me == copyItem) {
3888 copyClip( item->text(column) ) ; 3828 copyClip( item->text(column) ) ;
3889 } else if (me == cancelItem) { 3829 } else if (me == cancelItem) {
3890 cb->clear(); 3830 cb->clear();
3891 } else if (me == editItem) { 3831 } else if (me == editItem) {
3892 editPwd(); 3832 editPwd();
3893 } else if (me == showItem) { 3833 } else if (me == showItem) {
3894 showInfo(item); 3834 showInfo(item);
3895 } 3835 }
3896 } 3836 }
3897 break; 3837 break;
3898 }; 3838 };
3899} 3839}
3900 3840
3901void ZSafe::copyClip( const QString &text) { 3841void ZSafe::copyClip( const QString &text) {
3902 QClipboard *cb = QApplication::clipboard(); 3842 QClipboard *cb = QApplication::clipboard();
3903 cb->setText( text); 3843 cb->setText( text);
3904} 3844}
3905 3845
3906 3846
3847QString ZSafe::zsaveDialog() {
3848
3849 QString fn;
3850#ifndef DESKTOP
3851#ifndef NO_OPIE
3852 QMap<QString, QStringList> mimeTypes;
3853 mimeTypes.insert(tr("All"), QStringList() );
3854 mimeTypes.insert(tr("Text"), "text/*" );
3855 fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL,
3856 QDir::homeDirPath() + "/Documents/application/zsafe",
3857 QString::null,
3858 mimeTypes,
3859 this,
3860 tr ("Export text file"));
3861#else
3862 fn = ScQtFileEdit::getSaveAsFileName(this,
3863 tr ("Export text file"),
3864 QDir::homeDirPath() + "/Documents/application/zsafe",
3865 "*.txt");
3866#endif
3867#else
3868 fn = QFileDialog::getSaveFileName(
3869 QDir::homeDirPath() + "/Documents/application/zsafe",
3870 "ZSafe (*.txt)",
3871 this,
3872 "ZSafe");
3873#endif
3874 return fn;
3875}
diff --git a/noncore/apps/zsafe/zsafe.h b/noncore/apps/zsafe/zsafe.h
index ca041ff..7419797 100644
--- a/noncore/apps/zsafe/zsafe.h
+++ b/noncore/apps/zsafe/zsafe.h
@@ -28,170 +28,171 @@
28class QVBoxLayout; 28class QVBoxLayout;
29class QHBoxLayout; 29class QHBoxLayout;
30class QGridLayout; 30class QGridLayout;
31class ZListView; 31class ZListView;
32class QListViewItem; 32class QListViewItem;
33class QToolButton; 33class QToolButton;
34class QTextBrowser; 34class QTextBrowser;
35class QPopupMenu; 35class QPopupMenu;
36#ifdef DESKTOP 36#ifdef DESKTOP
37// #ifndef WIN32 37// #ifndef WIN32
38class QSettings; 38class QSettings;
39// #endif 39// #endif
40#else 40#else
41class Config; 41class Config;
42#endif 42#endif
43class CategoryDialog; 43class CategoryDialog;
44class QPixmap; 44class 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
49class ZSafe : public QDialog 49class ZSafe : public QDialog
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 52
53protected: 53protected:
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
60public: 60public:
61 ZSafe( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = WDestructiveClose ); 61 ZSafe( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = WDestructiveClose );
62 ~ZSafe(); 62 ~ZSafe();
63 63
64 static const QColor *evenRowColor; 64 static const QColor *evenRowColor;
65 static const QColor *oddRowColor; 65 static const QColor *oddRowColor;
66 66
67 QToolButton* Edit; 67 QToolButton* Edit;
68 QToolButton* Delete; 68 QToolButton* Delete;
69 QToolButton* Find; 69 QToolButton* Find;
70 QToolButton* New; 70 QToolButton* New;
71 ZListView* ListView; 71 ZListView* ListView;
72 72
73 QString cfgFile; 73 QString cfgFile;
74 QString iconPath; 74 QString iconPath;
75 75
76 InfoForm *infoForm; 76 InfoForm *infoForm;
77 CategoryDialog *categoryDialog; 77 CategoryDialog *categoryDialog;
78 78
79 QListViewItem *selectedItem; // current selected item 79 QListViewItem *selectedItem; // current selected item
80 QListViewItem *copiedItem; // copied item 80 QListViewItem *copiedItem; // copied item
81 bool IsCopy; 81 bool IsCopy;
82 bool IsCut; 82 bool IsCut;
83 bool modified; // true if database is modified 83 bool modified; // true if database is modified
84 bool showpwd; // show PWD Dialog 84 bool showpwd; // show PWD Dialog
85 85
86 QListViewItem *lastSearchedCategory; 86 QListViewItem *lastSearchedCategory;
87 QListViewItem *lastSearchedItem; 87 QListViewItem *lastSearchedItem;
88 QString lastSearchedName; 88 QString lastSearchedName;
89 QString lastSearchedUsername; 89 QString lastSearchedUsername;
90 QString lastSearchedComment; 90 QString lastSearchedComment;
91 91
92 92
93 CategoryList categories; // list of categories 93 CategoryList categories; // list of categories
94 94
95 bool isCategory(QListViewItem *_item); 95 bool isCategory(QListViewItem *_item);
96 void getDocPassword(QString title); 96 void getDocPassword(QString title);
97 QString filename; 97 QString filename;
98 98
99 enum { 99 enum {
100 PWERR_GOOD, // success 100 PWERR_GOOD, // success
101 PWERR_OPEN, // can't open filedescriptor / can't create file 101 PWERR_OPEN, // can't open filedescriptor / can't create file
102 PWERR_PERM, // permissions are bad 102 PWERR_PERM, // permissions are bad
103 PWERR_SYML, // is a symlink 103 PWERR_SYML, // is a symlink
104 PWERR_STAT, // can't get file status 104 PWERR_STAT, // can't get file status
105 PWERR_DATA // can't read correct data 105 PWERR_DATA // can't read correct data
106 }; 106 };
107 107
108 long load_buffer_length; 108 long load_buffer_length;
109 long save_buffer_length; 109 long save_buffer_length;
110 110
111 /** password for the file */ 111 /** password for the file */
112 QString m_password; 112 QString m_password;
113 /** globals needed for file loading */ 113 /** globals needed for file loading */
114 int lastcount, size; 114 int lastcount, size;
115 /** these three are needed in all save functions and initialized in save _init() */ 115 /** these three are needed in all save functions and initialized in save _init() */
116 FILE *fd; 116 FILE *fd;
117 unsigned short iv[4]; 117 unsigned short iv[4];
118 char *buffer; 118 char *buffer;
119 /** these two are global because save_entry() and save_finalize() both n eed them */ 119 /** these two are global because save_entry() and save_finalize() both n eed them */
120 int bufferIndex; 120 int bufferIndex;
121 unsigned short plaintext[4]; 121 unsigned short plaintext[4];
122 122
123#ifdef DESKTOP 123#ifdef DESKTOP
124// #ifndef WIN32 124// #ifndef WIN32
125 QSettings *conf; 125 QSettings *conf;
126// #endif 126// #endif
127#else 127#else
128 Config *conf; 128 Config *conf;
129#endif 129#endif
130 bool expandTree; 130 bool expandTree;
131 QPopupMenu *file; 131 QPopupMenu *file;
132 132
133 QTimer docuTimer; 133 QTimer docuTimer;
134 134
135 135
136 bool openDocument(const char* filename, const char* format=0); 136 bool openDocument(const char* filename, const char* format=0);
137 int loadInit(const char* filename, const char *password); 137 int loadInit(const char* filename, const char *password);
138 int loadEntry(char *entry[4]); 138 int loadEntry(char *entry[4]);
139 int loadFinalize(void); 139 int loadFinalize(void);
140 bool saveDocument(const char* filename, bool withPwd, const char* format=0); 140 bool saveDocument(const char* filename, bool withPwd, const char* format=0);
141 int saveInit(const char *filename, const char *password); 141 int saveInit(const char *filename, const char *password);
142 int saveEntry(char *entry[4]); 142 int saveEntry(char *entry[4]);
143 int saveFinalize(void); 143 int saveFinalize(void);
144 void saveConf(); 144 void saveConf();
145 QPixmap * getPredefinedIcon(QString category); 145 QPixmap * getPredefinedIcon(QString category);
146 QString getFieldLabel (QListViewItem *_item, QString field, QString def); 146 QString getFieldLabel (QListViewItem *_item, QString field, QString def);
147 QString getFieldLabel (QString category, QString field, QString def); 147 QString getFieldLabel (QString category, QString field, QString def);
148 void setCategoryDialogFields(CategoryDialog *dialog); 148 void setCategoryDialogFields(CategoryDialog *dialog);
149 void setCategoryDialogFields(CategoryDialog *dialog, QString category); 149 void setCategoryDialogFields(CategoryDialog *dialog, QString category);
150 void saveCategoryDialogFields(CategoryDialog *dialog); 150 void saveCategoryDialogFields(CategoryDialog *dialog);
151 151
152 152
153 void resume(int signum); 153 void resume(int signum);
154 void exitZs (int ec); 154 void exitZs (int ec);
155 155
156 QString zsaveDialog();
156 157
157public slots: 158public slots:
158 virtual void deletePwd(); 159 virtual void deletePwd();
159 virtual void editPwd(); 160 virtual void editPwd();
160 virtual void newPwd(); 161 virtual void newPwd();
161 virtual void findPwd(); 162 virtual void findPwd();
162 virtual void quitMe(); 163 virtual void quitMe();
163 virtual void listViewSelected( QListViewItem *_item); 164 virtual void listViewSelected( QListViewItem *_item);
164 virtual void showInfo( QListViewItem *_item); 165 virtual void showInfo( QListViewItem *_item);
165 virtual void writeAllEntries(); 166 virtual void writeAllEntries();
166 virtual void readAllEntries(); 167 virtual void readAllEntries();
167 virtual void removeAsciiFile(); 168 virtual void removeAsciiFile();
168 virtual void setPasswordDialogDone(); 169 virtual void setPasswordDialogDone();
169 170
170 virtual void addCategory(); 171 virtual void addCategory();
171 virtual void delCategory(); 172 virtual void delCategory();
172 virtual void editCategory(); 173 virtual void editCategory();
173 virtual void cutItem(); 174 virtual void cutItem();
174 virtual void copyItem(); 175 virtual void copyItem();
175 virtual void pasteItem(); 176 virtual void pasteItem();
176 177
177 virtual void newDocument(); 178 virtual void newDocument();
178 virtual void loadDocument(); 179 virtual void loadDocument();
179 virtual void saveDocumentAs(); 180 virtual void saveDocumentAs();
180 virtual void saveDocumentWithoutPwd(); 181 virtual void saveDocumentWithoutPwd();
181 virtual void saveDocumentWithPwd(); 182 virtual void saveDocumentWithPwd();
182 virtual void about(); 183 virtual void about();
183 virtual void setExpandFlag(); 184 virtual void setExpandFlag();
184 185
185 virtual void categoryFieldActivated( const QString& str); 186 virtual void categoryFieldActivated( const QString& str);
186 187
187 virtual void ListPressed(int, QListViewItem *, const QPoint&, int); 188 virtual void ListPressed(int, QListViewItem *, const QPoint&, int);
188 virtual void copyClip( const QString &text); 189 virtual void copyClip( const QString &text);
189 190
190private slots: 191private slots:
191 void setDocument(const QString& fileref); 192 void setDocument(const QString& fileref);
192 void slotLoadDocu(); 193 void slotLoadDocu();
193 void slotRaiseTimer(); 194 void slotRaiseTimer();
194 195
195}; 196};
196 197
197#endif // ZSAFE_H 198#endif // ZSAFE_H