summaryrefslogtreecommitdiff
authorandyq <andyq>2002-11-03 01:19:52 (UTC)
committer andyq <andyq>2002-11-03 01:19:52 (UTC)
commit485fae36510cb42690c9df55fae64312b1e656ae (patch) (side-by-side diff)
treea629829c2fdee60af78cb78184f4d6c27f384c89
parentd04882e254eb91aa26fb46bf49c438d12fcda862 (diff)
downloadopie-485fae36510cb42690c9df55fae64312b1e656ae.zip
opie-485fae36510cb42690c9df55fae64312b1e656ae.tar.gz
opie-485fae36510cb42690c9df55fae64312b1e656ae.tar.bz2
Added search for package feature
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp9
-rw-r--r--noncore/settings/aqpkg/mainwin.h1
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp34
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h2
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 @@
#include "datamgr.h"
#include "networkpkgmgr.h"
#include "settingsimpl.h"
#include "helpwindow.h"
#include "utils.h"
#include "global.h"
MainWindow :: MainWindow( QWidget *p, char *name )
: QMainWindow( p, name )
{
#ifdef QWS
showMaximized();
#endif
setCaption( "AQPkg - Package Manager" );
// 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 );
QPopupMenu *settings = new QPopupMenu( this );
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 );
+
// Create the main menu
QMenuBar *menu = menuBar(); //new QMenuBar( this );
menu->insertItem( "&Settings", settings );
+ menu->insertItem( "&Edit", edit );
menu->insertItem( "&Help", help );
mgr = new DataManager();
mgr->loadServers();
stack = new QWidgetStack( this );
networkPkgWindow = new NetworkPackageManager( mgr, stack );
stack->addWidget( networkPkgWindow, 1 );
setCentralWidget( stack );
stack->raiseWidget( networkPkgWindow );
}
MainWindow :: ~MainWindow()
{
delete networkPkgWindow;
}
void MainWindow :: setDocument( const QString &doc )
{
// Remove path from package
QString package = Utils::getPackageNameFromIpkFilename( doc );
cout << "Selecting package " << package << endl;
networkPkgWindow->selectLocalPackage( package );
}
void MainWindow :: displaySettings()
{
SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
if ( dlg->showDlg( 0 ) )
networkPkgWindow->updateData();
delete dlg;
}
void MainWindow :: displayHelp()
{
HelpWindow *dlg = new HelpWindow( this );
dlg->exec();
delete dlg;
}
+void MainWindow :: searchForPackage()
+{
+ networkPkgWindow->searchForPackage();
+}
+
void MainWindow :: displayAbout()
{
QMessageBox::about( this, "About AQPkg", VERSION_TEXT );
}
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 @@
#include <qmainwindow.h>
#include <qwidgetstack.h>
class NetworkPackageManager;
class DataManager;
class MainWindow :public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *p = 0, char *name = 0 );
~MainWindow();
private:
DataManager *mgr;
QWidgetStack *stack;
NetworkPackageManager *networkPkgWindow;
public slots:
void setDocument( const QString &doc );
void displayHelp();
+ void searchForPackage();
void displayAbout();
void displaySettings();
};
#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()
f.remove();
}
}
}
}
if ( doUpdate )
{
dataMgr->reloadServerData();
serverSelected( -1 );
}
}
void NetworkPackageManager :: applyChanges()
{
stickyOption = "";
// First, write out ipkg_conf file so that ipkg can use it
dataMgr->writeOutIpkgConf();
// Now for each selected item
// deal with it
- vector<InstallData> workingPackages;
+ vector<InstallData> workingPackages;
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
InstallData data = dealWithItem( item );
workingPackages.push_back( data );
}
}
if ( workingPackages.size() == 0 )
{
// Nothing to do
QMessageBox::information( this, "Nothing to do",
"No packages selected", "OK" );
return;
}
// do the stuff
InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
dlg.showDlg();
@@ -652,24 +652,56 @@ void NetworkPackageManager :: letterPushed( QString t )
if ( start == 0 )
{
item = (QCheckListItem *)packagesList->firstChild();
start = top;
}
else
item = (QCheckListItem *)start->nextSibling();
if ( item == 0 )
item = (QCheckListItem *)packagesList->firstChild();
do
{
if ( item->text().lower().startsWith( t.lower() ) )
{
packagesList->setSelected( item, true );
packagesList->ensureItemVisible( item );
break;
}
item = (QCheckListItem *)item->nextSibling();
if ( !item )
item = (QCheckListItem *)packagesList->firstChild();
} while ( item != start);
}
+
+
+void NetworkPackageManager :: searchForPackage()
+{
+ bool ok = FALSE;
+ QString searchText = InputDialog::getText( "Search for package", "Enter package to search for", QString::null, &ok, this ).lower();
+ if ( ok && !searchText.isEmpty() )
+ {
+ cout << "searching for " << searchText << endl;
+ // look through package list for text startng at current position
+ vector<InstallData> workingPackages;
+ QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
+ if ( start != 0 )
+ start = (QCheckListItem *)start->nextSibling();
+
+ if ( start == 0 )
+ start = (QCheckListItem *)packagesList->firstChild();
+
+ for ( QCheckListItem *item = start; item != 0 ;
+ item = (QCheckListItem *)item->nextSibling() )
+ {
+ cout << "checking " << item->text().lower() << endl;
+ if ( item->text().lower().find( searchText ) != -1 )
+ {
+ cout << "matched " << item->text() << endl;
+ packagesList->ensureItemVisible( item );
+ packagesList->setCurrentItem( item );
+ break;
+ }
+ }
+ }
+} \ 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 @@
#define NETWORKPKGMGR_H
#include <qlayout.h>
#include <qpushbutton.h>
#include <qwidget.h>
#include <qcombobox.h>
#include <qlistview.h>
#include "datamgr.h"
#include "progressdlg.h"
class InstallData;
/** NetworkPackageManager is the base class of the project */
class NetworkPackageManager : public QWidget
{
Q_OBJECT
public:
/** construtor */
NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0);
/** destructor */
~NetworkPackageManager();
void selectLocalPackage( const QString &pkg );
void updateData();
-
+ void searchForPackage();
private:
DataManager *dataMgr;
QComboBox *serversList;
QListView *packagesList;
QPushButton *update;
QPushButton *upgrade;
QPushButton *download;
QPushButton *apply;
ProgressDlg *progressDlg;
QString currentlySelectedServer;
bool showJumpTo;
int timerId;
void timerEvent ( QTimerEvent * );
void initGui();
void setupConnections();
void showProgressDialog( char *initialText );
InstallData dealWithItem( QCheckListItem *item );
QString stickyOption;