From b9aad2af4da88816effbc09f8d609bcabaf1f492 Mon Sep 17 00:00:00 2001 From: andyq Date: Sun, 03 Nov 2002 12:41:54 +0000 Subject: Added find next facility --- diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 0b5a5eb..3c72f2b 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -38,6 +38,7 @@ MainWindow :: MainWindow( QWidget *p, char *name ) // Create our menu QPopupMenu *help = new QPopupMenu( this ); + help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H ); help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); @@ -45,7 +46,8 @@ MainWindow :: MainWindow( QWidget *p, char *name ) settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); QPopupMenu *edit = new QPopupMenu( this ); - edit->insertItem( "&Search", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_F ); + edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_F ); + edit->insertItem( "&Find Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_R ); // Create the main menu QMenuBar *menu = menuBar(); //new QMenuBar( this ); @@ -95,7 +97,12 @@ void MainWindow :: displayHelp() void MainWindow :: searchForPackage() { - networkPkgWindow->searchForPackage(); + networkPkgWindow->searchForPackage( false ); +} + +void MainWindow :: repeatSearchForPackage() +{ + networkPkgWindow->searchForPackage( true ); } void MainWindow :: displayAbout() diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index 9fa0eca..267233f 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h @@ -43,6 +43,7 @@ public slots: void setDocument( const QString &doc ); void displayHelp(); void searchForPackage(); + void repeatSearchForPackage(); void displayAbout(); void displaySettings(); }; diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 78d3df5..a058285 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -675,13 +675,17 @@ void NetworkPackageManager :: letterPushed( QString t ) } -void NetworkPackageManager :: searchForPackage() +void NetworkPackageManager :: searchForPackage( bool findNext ) { - bool ok = FALSE; - QString searchText = InputDialog::getText( "Search for package", "Enter package to search for", QString::null, &ok, this ).lower(); - if ( ok && !searchText.isEmpty() ) + bool ok = false; + if ( !findNext || lastSearchText.isEmpty() ) + lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower(); + else + ok = true; + + if ( ok && !lastSearchText.isEmpty() ) { - cout << "searching for " << searchText << endl; + cout << "searching for " << lastSearchText << endl; // look through package list for text startng at current position vector workingPackages; QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); @@ -695,7 +699,7 @@ void NetworkPackageManager :: searchForPackage() item = (QCheckListItem *)item->nextSibling() ) { cout << "checking " << item->text().lower() << endl; - if ( item->text().lower().find( searchText ) != -1 ) + if ( item->text().lower().find( lastSearchText ) != -1 ) { cout << "matched " << item->text() << endl; packagesList->ensureItemVisible( item ); diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index 3a111ff..20f6e2d 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h @@ -40,7 +40,7 @@ public: void selectLocalPackage( const QString &pkg ); void updateData(); - void searchForPackage(); + void searchForPackage( bool findNext ); private: DataManager *dataMgr; @@ -53,6 +53,7 @@ private: ProgressDlg *progressDlg; QString currentlySelectedServer; + QString lastSearchText; bool showJumpTo; int timerId; -- cgit v0.9.0.2