summaryrefslogtreecommitdiff
path: root/noncore/apps/zsafe/zsafe.cpp
Unidiff
Diffstat (limited to 'noncore/apps/zsafe/zsafe.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/zsafe.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index a3e805e..a3467e5 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -597,198 +597,198 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
597 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); 597 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) );
598 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); 598 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) );
599 menu->insertItem( tr("&Category"), cat ); 599 menu->insertItem( tr("&Category"), cat );
600 600
601 QPopupMenu *it = new QPopupMenu( this ); 601 QPopupMenu *it = new QPopupMenu( this );
602 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); 602 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) );
603 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); 603 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) );
604 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); 604 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) );
605 it->insertSeparator(); 605 it->insertSeparator();
606 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); 606 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) );
607 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); 607 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) );
608 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); 608 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) );
609 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); 609 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) );
610 menu->insertItem( tr("&Entry"), it ); 610 menu->insertItem( tr("&Entry"), it );
611 611
612 QPopupMenu *help = new QPopupMenu( this ); 612 QPopupMenu *help = new QPopupMenu( this );
613 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); 613 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) );
614 menu->insertItem( tr("&Help"), help ); 614 menu->insertItem( tr("&Help"), help );
615 615
616 // toolbar icons 616 // toolbar icons
617 617
618 New = new QToolButton( menu, "New" ); 618 New = new QToolButton( menu, "New" );
619 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); 619 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) );
620 New->setMouseTracking( TRUE ); 620 New->setMouseTracking( TRUE );
621 New->setText( tr( "" ) ); 621 New->setText( tr( "" ) );
622 New->setPixmap( new_img ); 622 New->setPixmap( new_img );
623 QToolTip::add( New, tr( "New entry" ) ); 623 QToolTip::add( New, tr( "New entry" ) );
624 624
625 Edit = new QToolButton( menu, "Edit" ); 625 Edit = new QToolButton( menu, "Edit" );
626 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); 626 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) );
627 Edit->setText( tr( "" ) ); 627 Edit->setText( tr( "" ) );
628 Edit->setPixmap( edit_img ); 628 Edit->setPixmap( edit_img );
629 QToolTip::add( Edit, tr( "Edit category or entry" ) ); 629 QToolTip::add( Edit, tr( "Edit category or entry" ) );
630 630
631 Delete = new QToolButton( menu, "Delete" ); 631 Delete = new QToolButton( menu, "Delete" );
632 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); 632 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
633 Delete->setText( tr( "" ) ); 633 Delete->setText( tr( "" ) );
634 Delete->setPixmap( trash_img ); 634 Delete->setPixmap( trash_img );
635 QToolTip::add( Delete, tr( "Delete category or entry" ) ); 635 QToolTip::add( Delete, tr( "Delete category or entry" ) );
636 636
637 Find = new QToolButton( menu, "Find" ); 637 Find = new QToolButton( menu, "Find" );
638 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); 638 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) );
639 Find->setText( tr( "" ) ); 639 Find->setText( tr( "" ) );
640 Find->setPixmap( find_img ); 640 Find->setPixmap( find_img );
641 QToolTip::add( Find, tr( "Find entry" ) ); 641 QToolTip::add( Find, tr( "Find entry" ) );
642 642
643/* 643/*
644 QBoxLayout * h = new QHBoxLayout( this ); 644 QBoxLayout * h = new QHBoxLayout( this );
645 h->addWidget (menu); 645 h->addWidget (menu);
646 h->addWidget (New); 646 h->addWidget (New);
647 h->addWidget (Edit); 647 h->addWidget (Edit);
648 h->addWidget (Delete); 648 h->addWidget (Delete);
649 h->addWidget (Find); 649 h->addWidget (Find);
650*/ 650*/
651 651
652 ListView = new ZListView( this, "ListView" ); 652 ListView = new ZListView( this, "ListView" );
653 ListView->addColumn( tr( "Name" ) ); 653 ListView->addColumn( tr( "Name" ) );
654 ListView->addColumn( tr( "Field 2" ) ); 654 ListView->addColumn( tr( "Field 2" ) );
655 ListView->addColumn( tr( "Field 3" ) ); 655 ListView->addColumn( tr( "Field 3" ) );
656 ListView->addColumn( tr( "Comment" ) ); 656 ListView->addColumn( tr( "Comment" ) );
657 ListView->addColumn( tr( "Field 4" ) ); 657 ListView->addColumn( tr( "Field 4" ) );
658 ListView->addColumn( tr( "Field 5" ) ); 658 ListView->addColumn( tr( "Field 5" ) );
659 ListView->setAllColumnsShowFocus(TRUE); 659 ListView->setAllColumnsShowFocus(TRUE);
660 660
661#ifdef DESKTOP 661#ifdef DESKTOP
662 ListView->setResizePolicy(QScrollView::AutoOneFit); 662 ListView->setResizePolicy(QScrollView::AutoOneFit);
663 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); 663 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) );
664#else 664#else
665 ListView->setResizePolicy(QScrollView::AutoOneFit); 665 ListView->setResizePolicy(QScrollView::AutoOneFit);
666 // ListView->setGeometry( QRect( 0, 22, 666 // ListView->setGeometry( QRect( 0, 22,
667 // this->width(), this->height() - 30 ) ); 667 // this->width(), this->height() - 30 ) );
668 // ListView->setMaximumSize( QSize( 440, 290 ) ); 668 // ListView->setMaximumSize( QSize( 440, 290 ) );
669#endif 669#endif
670 ListView->setVScrollBarMode( QListView::Auto ); 670 ListView->setVScrollBarMode( QListView::Auto );
671 671
672 QBoxLayout * l = new QVBoxLayout( this ); 672 QBoxLayout * l = new QVBoxLayout( this );
673 l->addWidget (menu); 673 l->addWidget (menu);
674 l->addWidget (ListView); 674 l->addWidget (ListView);
675 675
676#ifndef DESKTOP 676#ifndef DESKTOP
677 // start a timer (100 ms) to load the default document 677 // start a timer (100 ms) to load the default document
678 docuTimer.start( 100, true ); 678 docuTimer.start( 100, true );
679 connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); 679 connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) );
680 raiseFlag = true; 680 raiseFlag = true;
681 connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); 681 connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) );
682#else 682#else
683 // open the default document 683 // open the default document
684 openDocument(filename); 684 openDocument(filename);
685#endif 685#endif
686 686
687 // signals and slots connections for QTollButton 687 // signals and slots connections for QTollButton
688 connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); 688 connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) );
689 connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); 689 connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) );
690 connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); 690 connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) );
691 connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); 691 connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) );
692 // signals and slots connections for QListView 692 // signals and slots connections for QListView
693 connect( ListView, SIGNAL( selectionChanged( QListViewItem* ) ), 693 connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ),
694 this, SLOT( listViewSelected( QListViewItem* ) ) ); 694 this, SLOT( listViewSelected(QListViewItem*) ) );
695 connect( ListView, SIGNAL( doubleClicked( QListViewItem* ) ), 695 connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ),
696 this, SLOT( showInfo( QListViewItem* ) ) ); 696 this, SLOT( showInfo(QListViewItem*) ) );
697 connect( ListView, SIGNAL( returnPressed( QListViewItem* ) ), 697 connect( ListView, SIGNAL( returnPressed(QListViewItem*) ),
698 this, SLOT( showInfo( QListViewItem* ) ) ); 698 this, SLOT( showInfo(QListViewItem*) ) );
699 699
700} 700}
701 701
702const QColor *ZSafe::evenRowColor = &Qt::white; 702const QColor *ZSafe::evenRowColor = &Qt::white;
703// const QColor *ZSafe::oddRowColor = &Qt::lightGray; 703// const QColor *ZSafe::oddRowColor = &Qt::lightGray;
704const QColor *ZSafe::oddRowColor = new QColor(216,240,255); 704const QColor *ZSafe::oddRowColor = new QColor(216,240,255);
705 705
706/* 706/*
707 * Destroys the object and frees any allocated resources 707 * Destroys the object and frees any allocated resources
708 */ 708 */
709ZSafe::~ZSafe() 709ZSafe::~ZSafe()
710{ 710{
711 // no need to delete child widgets, Qt does it all for us 711 // no need to delete child widgets, Qt does it all for us
712 quitMe(); 712 quitMe();
713} 713}
714 714
715// load the default document 715// load the default document
716void ZSafe::slotLoadDocu() 716void ZSafe::slotLoadDocu()
717{ 717{
718 openDocument (filename); 718 openDocument (filename);
719} 719}
720 720
721void ZSafe::deletePwd() 721void ZSafe::deletePwd()
722{ 722{
723 723
724 if (!selectedItem) 724 if (!selectedItem)
725 return; 725 return;
726 if (!isCategory(selectedItem)) 726 if (!isCategory(selectedItem))
727 { 727 {
728 switch( QMessageBox::information( this, tr("ZSafe"), 728 switch( QMessageBox::information( this, tr("ZSafe"),
729 tr("Do you want to delete?"), 729 tr("Do you want to delete?"),
730 tr("&Delete"), tr("D&on't Delete"), 730 tr("&Delete"), tr("D&on't Delete"),
731 0 // Enter == button 0 731 0 // Enter == button 0
732 ) ) { // Escape == button 2 732 ) ) { // Escape == button 2
733 case 0: // Delete clicked, Alt-S or Enter pressed. 733 case 0: // Delete clicked, Alt-S or Enter pressed.
734 // Delete 734 // Delete
735 modified = true; 735 modified = true;
736 selectedItem->parent()->takeItem(selectedItem); 736 selectedItem->parent()->takeItem(selectedItem);
737 selectedItem = NULL; 737 selectedItem = NULL;
738 break; 738 break;
739 case 1: // Don't delete 739 case 1: // Don't delete
740 break; 740 break;
741 } 741 }
742 } 742 }
743 else 743 else
744 { 744 {
745 delCategory(); 745 delCategory();
746 } 746 }
747} 747}
748 748
749void ZSafe::editPwd() 749void ZSafe::editPwd()
750{ 750{
751 if (!selectedItem) 751 if (!selectedItem)
752 return; 752 return;
753 if (!isCategory(selectedItem)) 753 if (!isCategory(selectedItem))
754 { 754 {
755 // open the 'New Entry' dialog 755 // open the 'New Entry' dialog
756 NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); 756 NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE);
757#ifdef WIN32 757#ifdef WIN32
758 dialog->setCaption ("Qt " + tr("Edit Entry")); 758 dialog->setCaption ("Qt " + tr("Edit Entry"));
759 dialog->setGeometry(200, 250, 220, 310 ); 759 dialog->setGeometry(200, 250, 220, 310 );
760#endif 760#endif
761 761
762 // set the labels 762 // set the labels
763 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); 763 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
764 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); 764 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
765 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); 765 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
766 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); 766 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
767 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); 767 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
768 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); 768 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
769 769
770 // set the fields 770 // set the fields
771 dialog->NameField->setText(selectedItem->text (0)); 771 dialog->NameField->setText(selectedItem->text (0));
772 dialog->UsernameField->setText(selectedItem->text (1)); 772 dialog->UsernameField->setText(selectedItem->text (1));
773 dialog->PasswordField->setText(selectedItem->text (2)); 773 dialog->PasswordField->setText(selectedItem->text (2));
774 QString comment = selectedItem->text (3); 774 QString comment = selectedItem->text (3);
775 comment.replace (QRegExp("<br>"), "\n"); 775 comment.replace (QRegExp("<br>"), "\n");
776 dialog->Field5->setText(selectedItem->text (4)); 776 dialog->Field5->setText(selectedItem->text (4));
777 dialog->Field6->setText(selectedItem->text (5)); 777 dialog->Field6->setText(selectedItem->text (5));
778 dialog->CommentField->insertLine(comment); 778 dialog->CommentField->insertLine(comment);
779 dialog->CommentField->setCursorPosition(0,0); 779 dialog->CommentField->setCursorPosition(0,0);
780 780
781 DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); 781 DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
782 782
783#ifdef DESKTOP 783#ifdef DESKTOP
784 result = Accepted; 784 result = Accepted;
785#endif 785#endif
786 if (result == Accepted) 786 if (result == Accepted)
787 { 787 {
788 modified = true; 788 modified = true;
789 // edit the selected item 789 // edit the selected item
790 QString name = dialog->NameField->text(); 790 QString name = dialog->NameField->text();
791 selectedItem->setText (0, tr (name)); 791 selectedItem->setText (0, tr (name));
792 QString user = dialog->UsernameField->text(); 792 QString user = dialog->UsernameField->text();
793 selectedItem->setText (1, tr (user)); 793 selectedItem->setText (1, tr (user));
794 QString pwd = dialog->PasswordField->text(); 794 QString pwd = dialog->PasswordField->text();
@@ -2486,194 +2486,194 @@ int ZSafe::saveFinalize(void)
2486 Krc2* krc2 = new Krc2(); 2486 Krc2* krc2 = new Krc2();
2487 2487
2488 /* Tack on the PKCS 5 padding 2488 /* Tack on the PKCS 5 padding
2489 * How it works is we fill up the last n bytes with the value n 2489 * How it works is we fill up the last n bytes with the value n
2490 * 2490 *
2491 * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left 2491 * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left
2492 * over, leaving us 3 short, so we fill it in with 3's. 2492 * over, leaving us 3 short, so we fill it in with 3's.
2493 * 2493 *
2494 * If we come out even, we fill it with 8 8s 2494 * If we come out even, we fill it with 8 8s
2495 * 2495 *
2496 * um, except that in this instance we are using 4 shorts instead of 8 bytes. 2496 * um, except that in this instance we are using 4 shorts instead of 8 bytes.
2497 * so, half everything 2497 * so, half everything
2498 */ 2498 */
2499 for (count1 = bufferIndex; count1 < 4; count1++) { 2499 for (count1 = bufferIndex; count1 < 4; count1++) {
2500 plaintext[count1] = (4 - bufferIndex); 2500 plaintext[count1] = (4 - bufferIndex);
2501 } 2501 }
2502 krc2->rc2_encrypt (plaintext); 2502 krc2->rc2_encrypt (plaintext);
2503 for (count1 = 0; count1 < 4; count1++) { 2503 for (count1 = 0; count1 < 4; count1++) {
2504 ciphertext[count1] = iv[count1] ^ plaintext[count1]; 2504 ciphertext[count1] = iv[count1] ^ plaintext[count1];
2505 if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; 2505 if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA;
2506 if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; 2506 if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA;
2507 } 2507 }
2508 2508
2509 fclose (fd); 2509 fclose (fd);
2510 free(buffer); 2510 free(buffer);
2511 return retval; 2511 return retval;
2512} 2512}
2513 2513
2514void ZSafe::quitMe () 2514void ZSafe::quitMe ()
2515{ 2515{
2516 qWarning ("QUIT..."); 2516 qWarning ("QUIT...");
2517 2517
2518 if (modified) 2518 if (modified)
2519 { 2519 {
2520 switch( QMessageBox::information( this, tr("ZSafe"), 2520 switch( QMessageBox::information( this, tr("ZSafe"),
2521 tr("Do you want to save\nbefore exiting?"), 2521 tr("Do you want to save\nbefore exiting?"),
2522 tr("&Save"), 2522 tr("&Save"),
2523 tr("S&ave with\nnew\npassword"), 2523 tr("S&ave with\nnew\npassword"),
2524 tr("&Don't Save"), 2524 tr("&Don't Save"),
2525 0 // Enter == button 0 2525 0 // Enter == button 0
2526 ) ) 2526 ) )
2527 { // Escape == button 2 2527 { // Escape == button 2
2528 case 0: // Save clicked, Alt-S or Enter pressed. 2528 case 0: // Save clicked, Alt-S or Enter pressed.
2529 // save 2529 // save
2530 modified = false; 2530 modified = false;
2531 saveDocument(filename, FALSE); 2531 saveDocument(filename, FALSE);
2532 exitZs (1); 2532 exitZs (1);
2533 break; 2533 break;
2534 case 1: // 2534 case 1: //
2535 // Save with new password 2535 // Save with new password
2536 modified = false; 2536 modified = false;
2537 saveDocument(filename, TRUE); 2537 saveDocument(filename, TRUE);
2538 exitZs (1); 2538 exitZs (1);
2539 break; 2539 break;
2540 case 2: // Don't Save clicked or Alt-D pressed 2540 case 2: // Don't Save clicked or Alt-D pressed
2541 // don't save but exitZs 2541 // don't save but exitZs
2542 exitZs (1); 2542 exitZs (1);
2543 break; 2543 break;
2544 } 2544 }
2545 } 2545 }
2546 exitZs (1); 2546 exitZs (1);
2547 2547
2548} 2548}
2549 2549
2550void ZSafe::categoryFieldActivated( const QString& category) 2550void ZSafe::categoryFieldActivated( const QString& category)
2551{ 2551{
2552 if (categoryDialog) 2552 if (categoryDialog)
2553 setCategoryDialogFields(categoryDialog, category); 2553 setCategoryDialogFields(categoryDialog, category);
2554} 2554}
2555 2555
2556void ZSafe::addCategory() 2556void ZSafe::addCategory()
2557{ 2557{
2558 if (filename.isEmpty()) 2558 if (filename.isEmpty())
2559 { 2559 {
2560 QMessageBox::critical( 0, tr("ZSafe"), 2560 QMessageBox::critical( 0, tr("ZSafe"),
2561 tr("No document defined.\nYou have to create a new document")); 2561 tr("No document defined.\nYou have to create a new document"));
2562 return; 2562 return;
2563 } 2563 }
2564 else 2564 else
2565 { 2565 {
2566 // open the 'Category' dialog 2566 // open the 'Category' dialog
2567 bool initIcons = false; 2567 bool initIcons = false;
2568 // open the 'Category' dialog 2568 // open the 'Category' dialog
2569 CategoryDialog *dialog; 2569 CategoryDialog *dialog;
2570 if (categoryDialog) 2570 if (categoryDialog)
2571 { 2571 {
2572 dialog = categoryDialog; 2572 dialog = categoryDialog;
2573 } 2573 }
2574 else 2574 else
2575 { 2575 {
2576 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); 2576 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
2577#ifdef WIN32 2577#ifdef WIN32
2578 categoryDialog->setCaption ("Qt " + tr("Category")); 2578 categoryDialog->setCaption ("Qt " + tr("Category"));
2579#endif 2579#endif
2580 dialog = categoryDialog; 2580 dialog = categoryDialog;
2581 connect( dialog->CategoryField, 2581 connect( dialog->CategoryField,
2582 SIGNAL( activated ( const QString &)), 2582 SIGNAL( activated(const QString&)),
2583 this, SLOT( categoryFieldActivated( const QString & ) ) ); 2583 this, SLOT( categoryFieldActivated(const QString&) ) );
2584 initIcons = true; 2584 initIcons = true;
2585 } 2585 }
2586 2586
2587#ifdef DESKTOP 2587#ifdef DESKTOP
2588#ifndef WIN32 2588#ifndef WIN32
2589 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); 2589 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
2590#else 2590#else
2591 // read all categories from the config file and store 2591 // read all categories from the config file and store
2592 // into a list 2592 // into a list
2593 QFile f (cfgFile); 2593 QFile f (cfgFile);
2594 QStringList list; 2594 QStringList list;
2595 if ( f.open(IO_ReadOnly) ) { // file opened successfully 2595 if ( f.open(IO_ReadOnly) ) { // file opened successfully
2596 QTextStream t( &f ); // use a text stream 2596 QTextStream t( &f ); // use a text stream
2597 QString s; 2597 QString s;
2598 int n = 1; 2598 int n = 1;
2599 while ( !t.eof() ) { // until end of file... 2599 while ( !t.eof() ) { // until end of file...
2600 s = t.readLine(); // line of text excluding '\n' 2600 s = t.readLine(); // line of text excluding '\n'
2601 list.append(s); 2601 list.append(s);
2602 } 2602 }
2603 f.close(); 2603 f.close();
2604 } 2604 }
2605#endif 2605#endif
2606#else 2606#else
2607 // read all categories from the config file and store 2607 // read all categories from the config file and store
2608 // into a list 2608 // into a list
2609 QFile f (cfgFile); 2609 QFile f (cfgFile);
2610 QStringList list; 2610 QStringList list;
2611 if ( f.open(IO_ReadOnly) ) { // file opened successfully 2611 if ( f.open(IO_ReadOnly) ) { // file opened successfully
2612 QTextStream t( &f ); // use a text stream 2612 QTextStream t( &f ); // use a text stream
2613 QString s; 2613 QString s;
2614 while ( !t.eof() ) { // until end of file... 2614 while ( !t.eof() ) { // until end of file...
2615 s = t.readLine(); // line of text excluding '\n' 2615 s = t.readLine(); // line of text excluding '\n'
2616 list.append(s); 2616 list.append(s);
2617 } 2617 }
2618 f.close(); 2618 f.close();
2619 } 2619 }
2620#endif 2620#endif
2621 QStringList::Iterator it = list.begin(); 2621 QStringList::Iterator it = list.begin();
2622 QString categ; 2622 QString categ;
2623 QString firstCategory; 2623 QString firstCategory;
2624 dialog->CategoryField->clear(); // remove all items 2624 dialog->CategoryField->clear(); // remove all items
2625 while( it != list.end() ) 2625 while( it != list.end() )
2626 { 2626 {
2627 QString *cat = new QString (*it); 2627 QString *cat = new QString (*it);
2628 if (cat->contains("-field1", FALSE)) 2628 if (cat->contains("-field1", FALSE))
2629 { 2629 {
2630#ifdef DESKTOP 2630#ifdef DESKTOP
2631#ifndef WIN32 2631#ifndef WIN32
2632 categ = cat->section ("-field1", 0, 0); 2632 categ = cat->section ("-field1", 0, 0);
2633#else 2633#else
2634 int pos = cat->find ("-field1"); 2634 int pos = cat->find ("-field1");
2635 categ = cat->left (pos); 2635 categ = cat->left (pos);
2636#endif 2636#endif
2637#else 2637#else
2638 int pos = cat->find ("-field1"); 2638 int pos = cat->find ("-field1");
2639 cat->truncate(pos); 2639 cat->truncate(pos);
2640 categ = *cat; 2640 categ = *cat;
2641#endif 2641#endif
2642 if (!categ.isEmpty()) 2642 if (!categ.isEmpty())
2643 { 2643 {
2644 dialog->CategoryField->insertItem (categ, -1); 2644 dialog->CategoryField->insertItem (categ, -1);
2645 if (firstCategory.isEmpty()) 2645 if (firstCategory.isEmpty())
2646 firstCategory = categ; 2646 firstCategory = categ;
2647 } 2647 }
2648 } 2648 }
2649 ++it; 2649 ++it;
2650 } 2650 }
2651 2651
2652 2652
2653 if (firstCategory.isEmpty()) 2653 if (firstCategory.isEmpty())
2654 setCategoryDialogFields(dialog); 2654 setCategoryDialogFields(dialog);
2655 else 2655 else
2656 setCategoryDialogFields(dialog, firstCategory); 2656 setCategoryDialogFields(dialog, firstCategory);
2657 2657
2658 // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); 2658 // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE);
2659 2659
2660 if (initIcons) 2660 if (initIcons)
2661 { 2661 {
2662 Wait waitDialog(this, tr("Wait dialog")); 2662 Wait waitDialog(this, tr("Wait dialog"));
2663 waitDialog.waitLabel->setText(tr("Gathering icons...")); 2663 waitDialog.waitLabel->setText(tr("Gathering icons..."));
2664 waitDialog.show(); 2664 waitDialog.show();
2665 qApp->processEvents(); 2665 qApp->processEvents();
2666 2666
2667#ifdef DESKTOP 2667#ifdef DESKTOP
2668 QDir d(iconPath); 2668 QDir d(iconPath);
2669#else 2669#else
2670 QDir d(QPEApplication::qpeDir() + "/pics/"); 2670 QDir d(QPEApplication::qpeDir() + "/pics/");
2671#endif 2671#endif
2672 d.setFilter( QDir::Files); 2672 d.setFilter( QDir::Files);
2673 2673
2674 const QFileInfoList *list = d.entryInfoList(); 2674 const QFileInfoList *list = d.entryInfoList();
2675 QFileInfoListIterator it( *list ); // create list iterator 2675 QFileInfoListIterator it( *list ); // create list iterator
2676 QFileInfo *fi; // pointer for traversing 2676 QFileInfo *fi; // pointer for traversing
2677 2677
2678 dialog->IconField->insertItem("predefined"); 2678 dialog->IconField->insertItem("predefined");
2679 while ( (fi=it.current()) ) { // for each file... 2679 while ( (fi=it.current()) ) { // for each file...
@@ -2893,194 +2893,194 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category)
2893 dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); 2893 dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment")));
2894 dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); 2894 dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4")));
2895 dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); 2895 dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5")));
2896 2896
2897 QString icon; 2897 QString icon;
2898 Category *cat= categories.find (category); 2898 Category *cat= categories.find (category);
2899 if (cat) 2899 if (cat)
2900 { 2900 {
2901 icon = cat->getIconName(); 2901 icon = cat->getIconName();
2902 } 2902 }
2903 else 2903 else
2904 icon = conf->readEntry(APP_KEY+category); 2904 icon = conf->readEntry(APP_KEY+category);
2905 2905
2906#ifdef DESKTOP 2906#ifdef DESKTOP
2907 QDir d(iconPath); 2907 QDir d(iconPath);
2908#else 2908#else
2909 QDir d(QPEApplication::qpeDir() + "/pics/"); 2909 QDir d(QPEApplication::qpeDir() + "/pics/");
2910#endif 2910#endif
2911 d.setFilter( QDir::Files); 2911 d.setFilter( QDir::Files);
2912 2912
2913 const QFileInfoList *list = d.entryInfoList(); 2913 const QFileInfoList *list = d.entryInfoList();
2914 int i=0; 2914 int i=0;
2915 QFileInfoListIterator it( *list ); // create list iterator 2915 QFileInfoListIterator it( *list ); // create list iterator
2916 QFileInfo *fi; // pointer for traversing 2916 QFileInfo *fi; // pointer for traversing
2917 if (icon.isEmpty() || icon.isNull()) 2917 if (icon.isEmpty() || icon.isNull())
2918 { 2918 {
2919 dialog->IconField->setCurrentItem(0); 2919 dialog->IconField->setCurrentItem(0);
2920 } 2920 }
2921 else 2921 else
2922 { 2922 {
2923 while ( (fi=it.current()) ) 2923 while ( (fi=it.current()) )
2924 { // for each file... 2924 { // for each file...
2925 QString fileName = fi->fileName(); 2925 QString fileName = fi->fileName();
2926 if(fileName.right(4) == ".png") 2926 if(fileName.right(4) == ".png")
2927 { 2927 {
2928 fileName = fileName.mid(0,fileName.length()-4); 2928 fileName = fileName.mid(0,fileName.length()-4);
2929 2929
2930 if(fileName+".png"==icon) 2930 if(fileName+".png"==icon)
2931 { 2931 {
2932 dialog->IconField->setCurrentItem(i+1); 2932 dialog->IconField->setCurrentItem(i+1);
2933 break; 2933 break;
2934 } 2934 }
2935 ++i; 2935 ++i;
2936 } 2936 }
2937 ++it; 2937 ++it;
2938 } 2938 }
2939 } 2939 }
2940} 2940}
2941 2941
2942void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) 2942void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog)
2943{ 2943{
2944 QString app_key = APP_KEY; 2944 QString app_key = APP_KEY;
2945#ifndef DESKTOP 2945#ifndef DESKTOP
2946 conf->setGroup ("fieldDefs"); 2946 conf->setGroup ("fieldDefs");
2947#else 2947#else
2948#ifndef WIN32 2948#ifndef WIN32
2949 app_key += "/fieldDefs/"; 2949 app_key += "/fieldDefs/";
2950#endif 2950#endif
2951#endif 2951#endif
2952 QString category = dialog->CategoryField->currentText(); 2952 QString category = dialog->CategoryField->currentText();
2953// #ifndef WIN32 2953// #ifndef WIN32
2954 conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); 2954 conf->writeEntry(app_key+category+"-field1", dialog->Field1->text());
2955 conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); 2955 conf->writeEntry(app_key+category+"-field2", dialog->Field2->text());
2956 conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); 2956 conf->writeEntry(app_key+category+"-field3", dialog->Field3->text());
2957 conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); 2957 conf->writeEntry(app_key+category+"-field4", dialog->Field4->text());
2958 conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); 2958 conf->writeEntry(app_key+category+"-field5", dialog->Field5->text());
2959 conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); 2959 conf->writeEntry(app_key+category+"-field6", dialog->Field6->text());
2960// #endif 2960// #endif
2961 saveConf(); 2961 saveConf();
2962#ifndef DESKTOP 2962#ifndef DESKTOP
2963 conf->setGroup ("zsafe"); 2963 conf->setGroup ("zsafe");
2964#endif 2964#endif
2965} 2965}
2966 2966
2967void ZSafe::editCategory() 2967void ZSafe::editCategory()
2968{ 2968{
2969 if (!selectedItem) 2969 if (!selectedItem)
2970 return; 2970 return;
2971 if (isCategory(selectedItem)) 2971 if (isCategory(selectedItem))
2972 { 2972 {
2973 QString category = selectedItem->text(0); 2973 QString category = selectedItem->text(0);
2974 bool initIcons = false; 2974 bool initIcons = false;
2975 // open the 'Category' dialog 2975 // open the 'Category' dialog
2976 CategoryDialog *dialog; 2976 CategoryDialog *dialog;
2977 if (categoryDialog) 2977 if (categoryDialog)
2978 { 2978 {
2979 dialog = categoryDialog; 2979 dialog = categoryDialog;
2980 } 2980 }
2981 else 2981 else
2982 { 2982 {
2983 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); 2983 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
2984#ifdef WIN32 2984#ifdef WIN32
2985 categoryDialog->setCaption ("Qt " + tr("Category")); 2985 categoryDialog->setCaption ("Qt " + tr("Category"));
2986#endif 2986#endif
2987 dialog = categoryDialog; 2987 dialog = categoryDialog;
2988 connect( dialog->CategoryField, 2988 connect( dialog->CategoryField,
2989 SIGNAL( activated ( const QString &)), 2989 SIGNAL( activated(const QString&)),
2990 this, SLOT( categoryFieldActivated( const QString & ) ) ); 2990 this, SLOT( categoryFieldActivated(const QString&) ) );
2991 initIcons = true; 2991 initIcons = true;
2992 } 2992 }
2993 setCategoryDialogFields(dialog); 2993 setCategoryDialogFields(dialog);
2994 2994
2995#ifdef DESKTOP 2995#ifdef DESKTOP
2996#ifndef WIN32 2996#ifndef WIN32
2997 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); 2997 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
2998#else 2998#else
2999 // read all categories from the config file and store 2999 // read all categories from the config file and store
3000 // into a list 3000 // into a list
3001 QFile f (cfgFile); 3001 QFile f (cfgFile);
3002 QStringList list; 3002 QStringList list;
3003 if ( f.open(IO_ReadOnly) ) { // file opened successfully 3003 if ( f.open(IO_ReadOnly) ) { // file opened successfully
3004 QTextStream t( &f ); // use a text stream 3004 QTextStream t( &f ); // use a text stream
3005 QString s; 3005 QString s;
3006 int n = 1; 3006 int n = 1;
3007 while ( !t.eof() ) { // until end of file... 3007 while ( !t.eof() ) { // until end of file...
3008 s = t.readLine(); // line of text excluding '\n' 3008 s = t.readLine(); // line of text excluding '\n'
3009 list.append(s); 3009 list.append(s);
3010 } 3010 }
3011 f.close(); 3011 f.close();
3012 } 3012 }
3013#endif 3013#endif
3014#else 3014#else
3015 // read all categories from the config file and store 3015 // read all categories from the config file and store
3016 // into a list 3016 // into a list
3017 QFile f (cfgFile); 3017 QFile f (cfgFile);
3018 QStringList list; 3018 QStringList list;
3019 if ( f.open(IO_ReadOnly) ) { // file opened successfully 3019 if ( f.open(IO_ReadOnly) ) { // file opened successfully
3020 QTextStream t( &f ); // use a text stream 3020 QTextStream t( &f ); // use a text stream
3021 QString s; 3021 QString s;
3022 while ( !t.eof() ) { // until end of file... 3022 while ( !t.eof() ) { // until end of file...
3023 s = t.readLine(); // line of text excluding '\n' 3023 s = t.readLine(); // line of text excluding '\n'
3024 list.append(s); 3024 list.append(s);
3025 } 3025 }
3026 f.close(); 3026 f.close();
3027 } 3027 }
3028#endif 3028#endif
3029 QStringList::Iterator it = list.begin(); 3029 QStringList::Iterator it = list.begin();
3030 QString categ; 3030 QString categ;
3031 dialog->CategoryField->clear(); // remove all items 3031 dialog->CategoryField->clear(); // remove all items
3032 int i=0; 3032 int i=0;
3033 bool foundCategory = false; 3033 bool foundCategory = false;
3034 while( it != list.end() ) 3034 while( it != list.end() )
3035 { 3035 {
3036 QString *cat = new QString (*it); 3036 QString *cat = new QString (*it);
3037 if (cat->contains("-field1", FALSE)) 3037 if (cat->contains("-field1", FALSE))
3038 { 3038 {
3039#ifdef DESKTOP 3039#ifdef DESKTOP
3040#ifndef WIN32 3040#ifndef WIN32
3041 categ = cat->section ("-field1", 0, 0); 3041 categ = cat->section ("-field1", 0, 0);
3042#else 3042#else
3043 int pos = cat->find ("-field1"); 3043 int pos = cat->find ("-field1");
3044 categ = cat->left (pos); 3044 categ = cat->left (pos);
3045#endif 3045#endif
3046#else 3046#else
3047 int pos = cat->find ("-field1"); 3047 int pos = cat->find ("-field1");
3048 cat->truncate(pos); 3048 cat->truncate(pos);
3049 categ = *cat; 3049 categ = *cat;
3050#endif 3050#endif
3051 if (!categ.isEmpty()) 3051 if (!categ.isEmpty())
3052 { 3052 {
3053 dialog->CategoryField->insertItem (categ, i); 3053 dialog->CategoryField->insertItem (categ, i);
3054 if (category.compare(categ) == 0) 3054 if (category.compare(categ) == 0)
3055 { 3055 {
3056 dialog->CategoryField->setCurrentItem(i); 3056 dialog->CategoryField->setCurrentItem(i);
3057 foundCategory = true; 3057 foundCategory = true;
3058 } 3058 }
3059 i++; 3059 i++;
3060 } 3060 }
3061 } 3061 }
3062 ++it; 3062 ++it;
3063 } 3063 }
3064 if (!foundCategory) 3064 if (!foundCategory)
3065 { 3065 {
3066 dialog->CategoryField->insertItem (category, i); 3066 dialog->CategoryField->insertItem (category, i);
3067 dialog->CategoryField->setCurrentItem(i); 3067 dialog->CategoryField->setCurrentItem(i);
3068 } 3068 }
3069 3069
3070 QString icon; 3070 QString icon;
3071 Category *cat= categories.find (selectedItem->text(0)); 3071 Category *cat= categories.find (selectedItem->text(0));
3072 if (cat) 3072 if (cat)
3073 { 3073 {
3074 icon = cat->getIconName(); 3074 icon = cat->getIconName();
3075 } 3075 }
3076 3076
3077 if (initIcons) 3077 if (initIcons)
3078 { 3078 {
3079 3079
3080 Wait waitDialog(this, tr("Wait dialog")); 3080 Wait waitDialog(this, tr("Wait dialog"));
3081 waitDialog.waitLabel->setText(tr("Gathering icons...")); 3081 waitDialog.waitLabel->setText(tr("Gathering icons..."));
3082 waitDialog.show(); 3082 waitDialog.show();
3083 qApp->processEvents(); 3083 qApp->processEvents();
3084 3084
3085#ifdef DESKTOP 3085#ifdef DESKTOP
3086 QDir d(iconPath); 3086 QDir d(iconPath);