summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-27 00:53:35 (UTC)
committer llornkcor <llornkcor>2004-07-27 00:53:35 (UTC)
commit2f332574ddbd31fe9709c1ec93049ecef9bd00a4 (patch) (unidiff)
treeb4d2fb110e398d6fa2491bd754a1d3f2e651fe97
parent8ff9840e3cbb28a1a644eb165465c60903e651a1 (diff)
downloadopie-2f332574ddbd31fe9709c1ec93049ecef9bd00a4.zip
opie-2f332574ddbd31fe9709c1ec93049ecef9bd00a4.tar.gz
opie-2f332574ddbd31fe9709c1ec93049ecef9bd00a4.tar.bz2
workaround weird windows listview bug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/zsafe.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index 2dd94aa..6aa6392 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -573,237 +573,241 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
573 // add a menu bar 573 // add a menu bar
574 QMenuBar *menu = new QMenuBar( this ); 574 QMenuBar *menu = new QMenuBar( this );
575 575
576 // add file menu 576 // add file menu
577 // QPopupMenu *file = new QPopupMenu( this ); 577 // QPopupMenu *file = new QPopupMenu( this );
578 file = new QPopupMenu( this ); 578 file = new QPopupMenu( this );
579 579
580// #ifdef DESKTOP 580// #ifdef DESKTOP
581 file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); 581 file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) );
582 file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); 582 file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) );
583 file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); 583 file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) );
584 file->insertSeparator(); 584 file->insertSeparator();
585// #endif 585// #endif
586 586
587 file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); 587 file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) );
588 file->insertItem( save_img, tr("S&ave document with new Password"), this, 588 file->insertItem( save_img, tr("S&ave document with new Password"), this,
589 SLOT(saveDocumentWithPwd()) ); 589 SLOT(saveDocumentWithPwd()) );
590 file->insertSeparator(); 590 file->insertSeparator();
591 file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); 591 file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) );
592 file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); 592 file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) );
593 file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); 593 file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) );
594 file->insertSeparator(); 594 file->insertSeparator();
595 file->insertItem( expand_img, tr("&Open entries expanded"), this, 595 file->insertItem( expand_img, tr("&Open entries expanded"), this,
596 SLOT(setExpandFlag()), 0, 'o'); 596 SLOT(setExpandFlag()), 0, 'o');
597 file->setItemChecked('o', expandTree); 597 file->setItemChecked('o', expandTree);
598 file->insertSeparator(); 598 file->insertSeparator();
599 file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); 599 file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) );
600 menu->insertItem( tr("&File"), file ); 600 menu->insertItem( tr("&File"), file );
601 601
602 QPopupMenu *cat = new QPopupMenu( this ); 602 QPopupMenu *cat = new QPopupMenu( this );
603 cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); 603 cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) );
604 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); 604 cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) );
605 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); 605 cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) );
606 menu->insertItem( tr("&Category"), cat ); 606 menu->insertItem( tr("&Category"), cat );
607 607
608 QPopupMenu *it = new QPopupMenu( this ); 608 QPopupMenu *it = new QPopupMenu( this );
609 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); 609 it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) );
610 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); 610 it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) );
611 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); 611 it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) );
612 it->insertSeparator(); 612 it->insertSeparator();
613 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); 613 it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) );
614 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); 614 it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) );
615 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); 615 it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) );
616 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); 616 it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) );
617 menu->insertItem( tr("&Entry"), it ); 617 menu->insertItem( tr("&Entry"), it );
618 618
619 QPopupMenu *help = new QPopupMenu( this ); 619 QPopupMenu *help = new QPopupMenu( this );
620 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); 620 help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) );
621 menu->insertItem( tr("&Help"), help ); 621 menu->insertItem( tr("&Help"), help );
622 622
623 // toolbar icons 623 // toolbar icons
624 624
625 New = new QToolButton( menu, "New" ); 625 New = new QToolButton( menu, "New" );
626 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); 626 New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) );
627 New->setMouseTracking( TRUE ); 627 New->setMouseTracking( TRUE );
628 New->setText( "" ); 628 New->setText( "" );
629 New->setPixmap( new_img ); 629 New->setPixmap( new_img );
630 QToolTip::add( New, tr( "New entry" ) ); 630 QToolTip::add( New, tr( "New entry" ) );
631 631
632 Edit = new QToolButton( menu, "Edit" ); 632 Edit = new QToolButton( menu, "Edit" );
633 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); 633 Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) );
634 Edit->setText( "" ); 634 Edit->setText( "" );
635 Edit->setPixmap( edit_img ); 635 Edit->setPixmap( edit_img );
636 QToolTip::add( Edit, tr( "Edit category or entry" ) ); 636 QToolTip::add( Edit, tr( "Edit category or entry" ) );
637 637
638 Delete = new QToolButton( menu, "Delete" ); 638 Delete = new QToolButton( menu, "Delete" );
639 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); 639 Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
640 Delete->setText( "" ); 640 Delete->setText( "" );
641 Delete->setPixmap( trash_img ); 641 Delete->setPixmap( trash_img );
642 QToolTip::add( Delete, tr( "Delete category or entry" ) ); 642 QToolTip::add( Delete, tr( "Delete category or entry" ) );
643 643
644 Find = new QToolButton( menu, "Find" ); 644 Find = new QToolButton( menu, "Find" );
645 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); 645 Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) );
646 Find->setText( "" ); 646 Find->setText( "" );
647 Find->setPixmap( find_img ); 647 Find->setPixmap( find_img );
648 QToolTip::add( Find, tr( "Find entry" ) ); 648 QToolTip::add( Find, tr( "Find entry" ) );
649 649
650/* 650/*
651 QBoxLayout * h = new QHBoxLayout( this ); 651 QBoxLayout * h = new QHBoxLayout( this );
652 h->addWidget (menu); 652 h->addWidget (menu);
653 h->addWidget (New); 653 h->addWidget (New);
654 h->addWidget (Edit); 654 h->addWidget (Edit);
655 h->addWidget (Delete); 655 h->addWidget (Delete);
656 h->addWidget (Find); 656 h->addWidget (Find);
657*/ 657*/
658 658
659 ListView = new ZListView( this, "ListView" ); 659 ListView = new ZListView( this, "ListView" );
660 ListView->addColumn( tr( "Name" ) ); 660 ListView->addColumn( tr( "Name" ) );
661 ListView->addColumn( tr( "Field 2" ) ); 661 ListView->addColumn( tr( "Field 2" ) );
662 ListView->addColumn( tr( "Field 3" ) ); 662 ListView->addColumn( tr( "Field 3" ) );
663 ListView->addColumn( tr( "Comment" ) ); 663 ListView->addColumn( tr( "Comment" ) );
664 ListView->addColumn( tr( "Field 4" ) ); 664 ListView->addColumn( tr( "Field 4" ) );
665 ListView->addColumn( tr( "Field 5" ) ); 665 ListView->addColumn( tr( "Field 5" ) );
666 ListView->setAllColumnsShowFocus(TRUE); 666 ListView->setAllColumnsShowFocus(TRUE);
667 667
668#ifdef DESKTOP 668#ifdef DESKTOP
669 ListView->setResizePolicy(QScrollView::AutoOneFit); 669 // ListView->setResizePolicy(QScrollView::AutoOneFit);
670 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); 670 // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) );
671#else 671#else
672 ListView->setResizePolicy(QScrollView::AutoOneFit); 672 ListView->setResizePolicy(QScrollView::AutoOneFit);
673 // ListView->setGeometry( QRect( 0, 22, 673 // ListView->setGeometry( QRect( 0, 22,
674 // this->width(), this->height() - 30 ) ); 674 // this->width(), this->height() - 30 ) );
675 // ListView->setMaximumSize( QSize( 440, 290 ) ); 675 // ListView->setMaximumSize( QSize( 440, 290 ) );
676#endif 676#endif
677 ListView->setVScrollBarMode( QListView::Auto ); 677 // ListView->setVScrollBarMode( QListView::Auto );
678 678
679 QBoxLayout * l = new QVBoxLayout( this ); 679 QBoxLayout * l = new QVBoxLayout( this );
680 l->addWidget (menu); 680 l->addWidget (menu);
681 l->addWidget (ListView); 681 l->addWidget (ListView);
682 682
683#ifndef DESKTOP 683#ifndef DESKTOP
684 // start a timer (100 ms) to load the default document 684 // start a timer (100 ms) to load the default document
685 docuTimer.start( 100, true ); 685 docuTimer.start( 100, true );
686 connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); 686 connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) );
687 raiseFlag = true; 687 raiseFlag = true;
688 connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); 688 connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) );
689#else 689#else
690 // open the default document 690 // open the default document
691 openDocument(filename); 691 openDocument(filename);
692#endif 692#endif
693 693
694 // signals and slots connections for QTollButton 694 // signals and slots connections for QTollButton
695 connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); 695 connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) );
696 connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); 696 connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) );
697 connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); 697 connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) );
698 connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); 698 connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) );
699 // signals and slots connections for QListView 699 // signals and slots connections for QListView
700 connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), 700 connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ),
701 this, SLOT( listViewSelected(QListViewItem*) ) ); 701 this, SLOT( listViewSelected(QListViewItem*) ) );
702 connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), 702 connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ),
703 this, SLOT( showInfo(QListViewItem*) ) ); 703 this, SLOT( showInfo(QListViewItem*) ) );
704 connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), 704 connect( ListView, SIGNAL( returnPressed(QListViewItem*) ),
705 this, SLOT( showInfo(QListViewItem*) ) ); 705 this, SLOT( showInfo(QListViewItem*) ) );
706 706
707 #ifndef DESKTOP 707 #ifndef DESKTOP
708 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); 708 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold);
709#endif 709#endif
710 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 710 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
711 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 711 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
712 712
713 this->setIcon( image0); 713 this->setIcon( image0);
714#ifdef Q_WS_WIN
715 ListView->setSelected( ListView->firstChild() , true);
716 ListView->setSelected( ListView->firstChild() , false);
717#endif
714} 718}
715 719
716const QColor *ZSafe::evenRowColor = &Qt::white; 720const QColor *ZSafe::evenRowColor = &Qt::white;
717// const QColor *ZSafe::oddRowColor = &Qt::lightGray; 721// const QColor *ZSafe::oddRowColor = &Qt::lightGray;
718const QColor *ZSafe::oddRowColor = new QColor(216,240,255); 722const QColor *ZSafe::oddRowColor = new QColor(216,240,255);
719 723
720/* 724/*
721 * Destroys the object and frees any allocated resources 725 * Destroys the object and frees any allocated resources
722 */ 726 */
723ZSafe::~ZSafe() 727ZSafe::~ZSafe()
724{ 728{
725 // no need to delete child widgets, Qt does it all for us 729 // no need to delete child widgets, Qt does it all for us
726 quitMe(); 730 quitMe();
727} 731}
728 732
729// load the default document 733// load the default document
730void ZSafe::slotLoadDocu() 734void ZSafe::slotLoadDocu()
731{ 735{
732 openDocument (filename); 736 openDocument (filename);
733} 737}
734 738
735void ZSafe::deletePwd() 739void ZSafe::deletePwd()
736{ 740{
737 741
738 if (!selectedItem) 742 if (!selectedItem)
739 return; 743 return;
740 if (!isCategory(selectedItem)) 744 if (!isCategory(selectedItem))
741 { 745 {
742 switch( QMessageBox::information( this, tr("ZSafe"), 746 switch( QMessageBox::information( this, tr("ZSafe"),
743 tr("Do you want to delete?"), 747 tr("Do you want to delete?"),
744 tr("&Delete"), tr("D&on't Delete"), 748 tr("&Delete"), tr("D&on't Delete"),
745 0 // Enter == button 0 749 0 // Enter == button 0
746 ) ) { // Escape == button 2 750 ) ) { // Escape == button 2
747 case 0: // Delete clicked, Alt-S or Enter pressed. 751 case 0: // Delete clicked, Alt-S or Enter pressed.
748 // Delete 752 // Delete
749 modified = true; 753 modified = true;
750 selectedItem->parent()->takeItem(selectedItem); 754 selectedItem->parent()->takeItem(selectedItem);
751 selectedItem = NULL; 755 selectedItem = NULL;
752 break; 756 break;
753 case 1: // Don't delete 757 case 1: // Don't delete
754 break; 758 break;
755 } 759 }
756 } 760 }
757 else 761 else
758 { 762 {
759 delCategory(); 763 delCategory();
760 } 764 }
761} 765}
762 766
763void ZSafe::editPwd() 767void ZSafe::editPwd()
764{ 768{
765 if (!selectedItem) 769 if (!selectedItem)
766 return; 770 return;
767 if (!isCategory(selectedItem)) 771 if (!isCategory(selectedItem))
768 { 772 {
769 // open the 'New Entry' dialog 773 // open the 'New Entry' dialog
770 NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE); 774 NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE);
771#ifdef Q_WS_WIN 775#ifdef Q_WS_WIN
772 dialog->setCaption ("Qt " + tr("Edit Entry")); 776 dialog->setCaption ("Qt " + tr("Edit Entry"));
773 dialog->setGeometry(200, 250, 220, 310 ); 777 dialog->setGeometry(200, 250, 220, 310 );
774#endif 778#endif
775 779
776 // set the labels 780 // set the labels
777 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); 781 dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name")));
778 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); 782 dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username")));
779 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); 783 dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password")));
780 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); 784 dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
781 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); 785 dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4")));
782 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); 786 dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5")));
783 787
784 // set the fields 788 // set the fields
785 dialog->NameField->setText(selectedItem->text (0)); 789 dialog->NameField->setText(selectedItem->text (0));
786 dialog->UsernameField->setText(selectedItem->text (1)); 790 dialog->UsernameField->setText(selectedItem->text (1));
787 dialog->PasswordField->setText(selectedItem->text (2)); 791 dialog->PasswordField->setText(selectedItem->text (2));
788 QString comment = selectedItem->text (3); 792 QString comment = selectedItem->text (3);
789 comment.replace (QRegExp("<br>"), "\n"); 793 comment.replace (QRegExp("<br>"), "\n");
790 dialog->Field5->setText(selectedItem->text (4)); 794 dialog->Field5->setText(selectedItem->text (4));
791 dialog->Field6->setText(selectedItem->text (5)); 795 dialog->Field6->setText(selectedItem->text (5));
792 dialog->CommentField->insertLine(comment); 796 dialog->CommentField->insertLine(comment);
793 dialog->CommentField->setCursorPosition(0,0); 797 dialog->CommentField->setCursorPosition(0,0);
794 798
795#ifdef Q_WS_QWS 799#ifdef Q_WS_QWS
796 DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); 800 DialogCode result = (DialogCode) QPEApplication::execDialog( dialog );
797#endif 801#endif
798 802
799#ifdef DESKTOP 803#ifdef DESKTOP
800#ifndef Q_QW_QWIN 804#ifndef Q_QW_QWIN
801 dialog->show(); 805 dialog->show();
802#endif 806#endif
803#else 807#else
804 dialog->showMaximized(); 808 dialog->showMaximized();
805#endif 809#endif
806#ifdef DESKTOP 810#ifdef DESKTOP
807 int result = dialog->exec(); 811 int result = dialog->exec();
808 result = QDialog::Accepted; 812 result = QDialog::Accepted;
809#endif 813#endif