summaryrefslogtreecommitdiff
path: root/noncore/apps/zsafe/zsafe.cpp
authoralwin <alwin>2004-03-02 12:21:11 (UTC)
committer alwin <alwin>2004-03-02 12:21:11 (UTC)
commitb6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff)
treed3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/apps/zsafe/zsafe.cpp
parent0d59c780513da78033f4d9040475dee9db0256d4 (diff)
downloadopie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2
applied the patch generated by the optimize_connect script from
TT.
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
@@ -645,102 +645,102 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
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 }
@@ -2534,98 +2534,98 @@ void ZSafe::quitMe ()
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
@@ -2941,98 +2941,98 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category)
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 {