author | andyq <andyq> | 2002-11-03 01:19:52 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-03 01:19:52 (UTC) |
commit | 485fae36510cb42690c9df55fae64312b1e656ae (patch) (unidiff) | |
tree | a629829c2fdee60af78cb78184f4d6c27f384c89 /noncore/settings | |
parent | d04882e254eb91aa26fb46bf49c438d12fcda862 (diff) | |
download | opie-485fae36510cb42690c9df55fae64312b1e656ae.zip opie-485fae36510cb42690c9df55fae64312b1e656ae.tar.gz opie-485fae36510cb42690c9df55fae64312b1e656ae.tar.bz2 |
Added search for package feature
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 1 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 34 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 2 |
4 files changed, 44 insertions, 2 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 9f19dfa..0b5a5eb 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -23,73 +23,82 @@ | |||
23 | #include "datamgr.h" | 23 | #include "datamgr.h" |
24 | #include "networkpkgmgr.h" | 24 | #include "networkpkgmgr.h" |
25 | #include "settingsimpl.h" | 25 | #include "settingsimpl.h" |
26 | #include "helpwindow.h" | 26 | #include "helpwindow.h" |
27 | #include "utils.h" | 27 | #include "utils.h" |
28 | #include "global.h" | 28 | #include "global.h" |
29 | 29 | ||
30 | MainWindow :: MainWindow( QWidget *p, char *name ) | 30 | MainWindow :: MainWindow( QWidget *p, char *name ) |
31 | :QMainWindow( p, name ) | 31 | :QMainWindow( p, name ) |
32 | { | 32 | { |
33 | #ifdef QWS | 33 | #ifdef QWS |
34 | showMaximized(); | 34 | showMaximized(); |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | setCaption( "AQPkg - Package Manager" ); | 37 | setCaption( "AQPkg - Package Manager" ); |
38 | 38 | ||
39 | // Create our menu | 39 | // Create our menu |
40 | QPopupMenu *help = new QPopupMenu( this ); | 40 | QPopupMenu *help = new QPopupMenu( this ); |
41 | help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H ); | 41 | help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_H ); |
42 | help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); | 42 | help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); |
43 | 43 | ||
44 | QPopupMenu *settings = new QPopupMenu( this ); | 44 | QPopupMenu *settings = new QPopupMenu( this ); |
45 | settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); | 45 | settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); |
46 | 46 | ||
47 | QPopupMenu *edit = new QPopupMenu( this ); | ||
48 | edit->insertItem( "&Search", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_F ); | ||
49 | |||
47 | // Create the main menu | 50 | // Create the main menu |
48 | QMenuBar *menu = menuBar(); //new QMenuBar( this ); | 51 | QMenuBar *menu = menuBar(); //new QMenuBar( this ); |
49 | menu->insertItem( "&Settings", settings ); | 52 | menu->insertItem( "&Settings", settings ); |
53 | menu->insertItem( "&Edit", edit ); | ||
50 | menu->insertItem( "&Help", help ); | 54 | menu->insertItem( "&Help", help ); |
51 | 55 | ||
52 | mgr = new DataManager(); | 56 | mgr = new DataManager(); |
53 | mgr->loadServers(); | 57 | mgr->loadServers(); |
54 | 58 | ||
55 | stack = new QWidgetStack( this ); | 59 | stack = new QWidgetStack( this ); |
56 | 60 | ||
57 | networkPkgWindow = new NetworkPackageManager( mgr, stack ); | 61 | networkPkgWindow = new NetworkPackageManager( mgr, stack ); |
58 | stack->addWidget( networkPkgWindow, 1 ); | 62 | stack->addWidget( networkPkgWindow, 1 ); |
59 | 63 | ||
60 | setCentralWidget( stack ); | 64 | setCentralWidget( stack ); |
61 | stack->raiseWidget( networkPkgWindow ); | 65 | stack->raiseWidget( networkPkgWindow ); |
62 | } | 66 | } |
63 | 67 | ||
64 | MainWindow :: ~MainWindow() | 68 | MainWindow :: ~MainWindow() |
65 | { | 69 | { |
66 | delete networkPkgWindow; | 70 | delete networkPkgWindow; |
67 | } | 71 | } |
68 | 72 | ||
69 | void MainWindow :: setDocument( const QString &doc ) | 73 | void MainWindow :: setDocument( const QString &doc ) |
70 | { | 74 | { |
71 | // Remove path from package | 75 | // Remove path from package |
72 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 76 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
73 | cout << "Selecting package " << package << endl; | 77 | cout << "Selecting package " << package << endl; |
74 | networkPkgWindow->selectLocalPackage( package ); | 78 | networkPkgWindow->selectLocalPackage( package ); |
75 | } | 79 | } |
76 | 80 | ||
77 | void MainWindow :: displaySettings() | 81 | void MainWindow :: displaySettings() |
78 | { | 82 | { |
79 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 83 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
80 | if ( dlg->showDlg( 0 ) ) | 84 | if ( dlg->showDlg( 0 ) ) |
81 | networkPkgWindow->updateData(); | 85 | networkPkgWindow->updateData(); |
82 | delete dlg; | 86 | delete dlg; |
83 | } | 87 | } |
84 | 88 | ||
85 | void MainWindow :: displayHelp() | 89 | void MainWindow :: displayHelp() |
86 | { | 90 | { |
87 | HelpWindow *dlg = new HelpWindow( this ); | 91 | HelpWindow *dlg = new HelpWindow( this ); |
88 | dlg->exec(); | 92 | dlg->exec(); |
89 | delete dlg; | 93 | delete dlg; |
90 | } | 94 | } |
91 | 95 | ||
96 | void MainWindow :: searchForPackage() | ||
97 | { | ||
98 | networkPkgWindow->searchForPackage(); | ||
99 | } | ||
100 | |||
92 | void MainWindow :: displayAbout() | 101 | void MainWindow :: displayAbout() |
93 | { | 102 | { |
94 | QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); | 103 | QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); |
95 | } | 104 | } |
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index a9e290c..9fa0eca 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h | |||
@@ -21,28 +21,29 @@ | |||
21 | #include <qmainwindow.h> | 21 | #include <qmainwindow.h> |
22 | #include <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
23 | 23 | ||
24 | 24 | ||
25 | class NetworkPackageManager; | 25 | class NetworkPackageManager; |
26 | class DataManager; | 26 | class DataManager; |
27 | 27 | ||
28 | class MainWindow :public QMainWindow | 28 | class MainWindow :public QMainWindow |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | public: | 31 | public: |
32 | 32 | ||
33 | MainWindow( QWidget *p = 0, char *name = 0 ); | 33 | MainWindow( QWidget *p = 0, char *name = 0 ); |
34 | ~MainWindow(); | 34 | ~MainWindow(); |
35 | 35 | ||
36 | private: | 36 | private: |
37 | DataManager *mgr; | 37 | DataManager *mgr; |
38 | 38 | ||
39 | QWidgetStack *stack; | 39 | QWidgetStack *stack; |
40 | NetworkPackageManager *networkPkgWindow; | 40 | NetworkPackageManager *networkPkgWindow; |
41 | 41 | ||
42 | public slots: | 42 | public slots: |
43 | void setDocument( const QString &doc ); | 43 | void setDocument( const QString &doc ); |
44 | void displayHelp(); | 44 | void displayHelp(); |
45 | void searchForPackage(); | ||
45 | void displayAbout(); | 46 | void displayAbout(); |
46 | void displaySettings(); | 47 | void displaySettings(); |
47 | }; | 48 | }; |
48 | #endif | 49 | #endif |
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index ccce401..78d3df5 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -449,49 +449,49 @@ void NetworkPackageManager :: downloadPackage() | |||
449 | f.remove(); | 449 | f.remove(); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | if ( doUpdate ) | 455 | if ( doUpdate ) |
456 | { | 456 | { |
457 | dataMgr->reloadServerData(); | 457 | dataMgr->reloadServerData(); |
458 | serverSelected( -1 ); | 458 | serverSelected( -1 ); |
459 | } | 459 | } |
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
463 | void NetworkPackageManager :: applyChanges() | 463 | void NetworkPackageManager :: applyChanges() |
464 | { | 464 | { |
465 | stickyOption = ""; | 465 | stickyOption = ""; |
466 | 466 | ||
467 | // First, write out ipkg_conf file so that ipkg can use it | 467 | // First, write out ipkg_conf file so that ipkg can use it |
468 | dataMgr->writeOutIpkgConf(); | 468 | dataMgr->writeOutIpkgConf(); |
469 | 469 | ||
470 | // Now for each selected item | 470 | // Now for each selected item |
471 | // deal with it | 471 | // deal with it |
472 | 472 | ||
473 | vector<InstallData> workingPackages; | 473 | vector<InstallData> workingPackages; |
474 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 474 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
475 | item != 0 ; | 475 | item != 0 ; |
476 | item = (QCheckListItem *)item->nextSibling() ) | 476 | item = (QCheckListItem *)item->nextSibling() ) |
477 | { | 477 | { |
478 | if ( item->isOn() ) | 478 | if ( item->isOn() ) |
479 | { | 479 | { |
480 | InstallData data = dealWithItem( item ); | 480 | InstallData data = dealWithItem( item ); |
481 | workingPackages.push_back( data ); | 481 | workingPackages.push_back( data ); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | 484 | ||
485 | if ( workingPackages.size() == 0 ) | 485 | if ( workingPackages.size() == 0 ) |
486 | { | 486 | { |
487 | // Nothing to do | 487 | // Nothing to do |
488 | QMessageBox::information( this, "Nothing to do", | 488 | QMessageBox::information( this, "Nothing to do", |
489 | "No packages selected", "OK" ); | 489 | "No packages selected", "OK" ); |
490 | 490 | ||
491 | return; | 491 | return; |
492 | } | 492 | } |
493 | 493 | ||
494 | // do the stuff | 494 | // do the stuff |
495 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); | 495 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); |
496 | dlg.showDlg(); | 496 | dlg.showDlg(); |
497 | 497 | ||
@@ -652,24 +652,56 @@ void NetworkPackageManager :: letterPushed( QString t ) | |||
652 | if ( start == 0 ) | 652 | if ( start == 0 ) |
653 | { | 653 | { |
654 | item = (QCheckListItem *)packagesList->firstChild(); | 654 | item = (QCheckListItem *)packagesList->firstChild(); |
655 | start = top; | 655 | start = top; |
656 | } | 656 | } |
657 | else | 657 | else |
658 | item = (QCheckListItem *)start->nextSibling(); | 658 | item = (QCheckListItem *)start->nextSibling(); |
659 | 659 | ||
660 | if ( item == 0 ) | 660 | if ( item == 0 ) |
661 | item = (QCheckListItem *)packagesList->firstChild(); | 661 | item = (QCheckListItem *)packagesList->firstChild(); |
662 | do | 662 | do |
663 | { | 663 | { |
664 | if ( item->text().lower().startsWith( t.lower() ) ) | 664 | if ( item->text().lower().startsWith( t.lower() ) ) |
665 | { | 665 | { |
666 | packagesList->setSelected( item, true ); | 666 | packagesList->setSelected( item, true ); |
667 | packagesList->ensureItemVisible( item ); | 667 | packagesList->ensureItemVisible( item ); |
668 | break; | 668 | break; |
669 | } | 669 | } |
670 | 670 | ||
671 | item = (QCheckListItem *)item->nextSibling(); | 671 | item = (QCheckListItem *)item->nextSibling(); |
672 | if ( !item ) | 672 | if ( !item ) |
673 | item = (QCheckListItem *)packagesList->firstChild(); | 673 | item = (QCheckListItem *)packagesList->firstChild(); |
674 | } while ( item != start); | 674 | } while ( item != start); |
675 | } | 675 | } |
676 | |||
677 | |||
678 | void NetworkPackageManager :: searchForPackage() | ||
679 | { | ||
680 | bool ok = FALSE; | ||
681 | QString searchText = InputDialog::getText( "Search for package", "Enter package to search for", QString::null, &ok, this ).lower(); | ||
682 | if ( ok && !searchText.isEmpty() ) | ||
683 | { | ||
684 | cout << "searching for " << searchText << endl; | ||
685 | // look through package list for text startng at current position | ||
686 | vector<InstallData> workingPackages; | ||
687 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | ||
688 | if ( start != 0 ) | ||
689 | start = (QCheckListItem *)start->nextSibling(); | ||
690 | |||
691 | if ( start == 0 ) | ||
692 | start = (QCheckListItem *)packagesList->firstChild(); | ||
693 | |||
694 | for ( QCheckListItem *item = start; item != 0 ; | ||
695 | item = (QCheckListItem *)item->nextSibling() ) | ||
696 | { | ||
697 | cout << "checking " << item->text().lower() << endl; | ||
698 | if ( item->text().lower().find( searchText ) != -1 ) | ||
699 | { | ||
700 | cout << "matched " << item->text() << endl; | ||
701 | packagesList->ensureItemVisible( item ); | ||
702 | packagesList->setCurrentItem( item ); | ||
703 | break; | ||
704 | } | ||
705 | } | ||
706 | } | ||
707 | } \ No newline at end of file | ||
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index 3c437b4..3a111ff 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h | |||
@@ -19,49 +19,49 @@ | |||
19 | #define NETWORKPKGMGR_H | 19 | #define NETWORKPKGMGR_H |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | 26 | ||
27 | #include "datamgr.h" | 27 | #include "datamgr.h" |
28 | #include "progressdlg.h" | 28 | #include "progressdlg.h" |
29 | class InstallData; | 29 | class InstallData; |
30 | 30 | ||
31 | /** NetworkPackageManager is the base class of the project */ | 31 | /** NetworkPackageManager is the base class of the project */ |
32 | class NetworkPackageManager : public QWidget | 32 | class NetworkPackageManager : public QWidget |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | /** construtor */ | 36 | /** construtor */ |
37 | NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); | 37 | NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); |
38 | /** destructor */ | 38 | /** destructor */ |
39 | ~NetworkPackageManager(); | 39 | ~NetworkPackageManager(); |
40 | 40 | ||
41 | void selectLocalPackage( const QString &pkg ); | 41 | void selectLocalPackage( const QString &pkg ); |
42 | void updateData(); | 42 | void updateData(); |
43 | 43 | void searchForPackage(); | |
44 | private: | 44 | private: |
45 | DataManager *dataMgr; | 45 | DataManager *dataMgr; |
46 | 46 | ||
47 | QComboBox *serversList; | 47 | QComboBox *serversList; |
48 | QListView *packagesList; | 48 | QListView *packagesList; |
49 | QPushButton *update; | 49 | QPushButton *update; |
50 | QPushButton *upgrade; | 50 | QPushButton *upgrade; |
51 | QPushButton *download; | 51 | QPushButton *download; |
52 | QPushButton *apply; | 52 | QPushButton *apply; |
53 | 53 | ||
54 | ProgressDlg *progressDlg; | 54 | ProgressDlg *progressDlg; |
55 | QString currentlySelectedServer; | 55 | QString currentlySelectedServer; |
56 | 56 | ||
57 | bool showJumpTo; | 57 | bool showJumpTo; |
58 | int timerId; | 58 | int timerId; |
59 | 59 | ||
60 | void timerEvent ( QTimerEvent * ); | 60 | void timerEvent ( QTimerEvent * ); |
61 | 61 | ||
62 | void initGui(); | 62 | void initGui(); |
63 | void setupConnections(); | 63 | void setupConnections(); |
64 | void showProgressDialog( char *initialText ); | 64 | void showProgressDialog( char *initialText ); |
65 | InstallData dealWithItem( QCheckListItem *item ); | 65 | InstallData dealWithItem( QCheckListItem *item ); |
66 | QString stickyOption; | 66 | QString stickyOption; |
67 | 67 | ||