summaryrefslogtreecommitdiff
authorandyq <andyq>2002-10-16 21:25:25 (UTC)
committer andyq <andyq>2002-10-16 21:25:25 (UTC)
commitbf58f7bc221ba10f6681d9a1a5193bd208d9920e (patch) (side-by-side diff)
treeba87cbc5c490b60e6c447eadded833408d829438
parent6c5cf5e778ce7cce306b5e02c1ce66a536d3a11c (diff)
downloadopie-bf58f7bc221ba10f6681d9a1a5193bd208d9920e.zip
opie-bf58f7bc221ba10f6681d9a1a5193bd208d9920e.tar.gz
opie-bf58f7bc221ba10f6681d9a1a5193bd208d9920e.tar.bz2
Now allows for multiple servers active
Added basic search facility (lots of buttons)
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp95
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h2
2 files changed, 74 insertions, 23 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 0bc01df..318b26d 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -38,16 +38,25 @@ using namespace std;
#include "networkpkgmgr.h"
#include "installdlgimpl.h"
#include "ipkg.h"
#include "inputdlg.h"
+#include "letterpushbutton.h"
#include "global.h"
NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
: QWidget(parent, name)
{
dataMgr = dataManager;
+#ifdef QWS
+ // read download directory from config file
+ Config cfg( "aqpkg" );
+ cfg.setGroup( "settings" );
+ currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
+#endif
+
+
initGui();
setupConnections();
progressDlg = 0;
@@ -79,9 +88,9 @@ void NetworkPackageManager :: updateData()
int i;
for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
{
serversList->insertItem( it->getServerName() );
- if ( it->getServerName() == dataMgr->getActiveServer() )
+ if ( it->getServerName() == currentlySelectedServer )
activeItem = i;
}
// set selected server to be active server
@@ -105,8 +114,24 @@ void NetworkPackageManager :: initGui()
QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
hbox1->addWidget( l );
hbox1->addWidget( serversList );
+ QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
+ QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
+
+ char text[2];
+ text[1] = '\0';
+ for ( int i = 0 ; i < 26 ; ++i )
+ {
+ text[0] = 'A' + i;
+ LetterPushButton *b = new LetterPushButton( text, this );
+ connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
+ if ( i < 16 )
+ hbox3->addWidget( b );
+ else
+ hbox4->addWidget( b );
+ }
+
vbox->addWidget( packagesList );
packagesList->addColumn( "Packages" );
QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
@@ -139,10 +164,19 @@ void NetworkPackageManager :: serverSelected( int )
packagesList->clear();
// display packages
QString serverName = serversList->currentText();
+ currentlySelectedServer = serverName;
+
+#ifdef QWS
+ // read download directory from config file
+ Config cfg( "aqpkg" );
+ cfg.setGroup( "settings" );
+ cfg.writeEntry( "selectedServer", currentlySelectedServer );
+#endif
+
Server *s = dataMgr->getServer( serverName );
- dataMgr->setActiveServer( serverName );
+// dataMgr->setActiveServer( serverName );
vector<Package> &list = s->getPackageList();
vector<Package>::iterator it;
for ( it = list.begin() ; it != list.end() ; ++it )
@@ -205,23 +239,22 @@ void NetworkPackageManager :: updateServer()
// Update the current server
// Display dialog
ProgressDlg *dlg = new ProgressDlg( this );
- QString status = "Updating package list for ";
- status += serverName;
+ QString status = "Updating package lists...";
dlg->show();
dlg->setText( status );
// Disable buttons to stop silly people clicking lots on them :)
// First, write out ipkg_conf file so that ipkg can use it
dataMgr->writeOutIpkgConf();
- if ( serverName == LOCAL_SERVER )
- ;
- else if ( serverName == LOCAL_IPKGS )
- ;
- else
+// if ( serverName == LOCAL_SERVER )
+// ;
+// else if ( serverName == LOCAL_IPKGS )
+// ;
+// else
{
QString option = "update";
QString dummy = "";
Ipkg ipkg;
@@ -301,12 +334,13 @@ void NetworkPackageManager :: downloadPackage()
// Download each package
Ipkg ipkg;
connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
- QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
ipkg.setOption( "download" );
ipkg.setRuntimeDirectory( dir );
- do
+ for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
+ item != 0 ;
+ item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
QString name = item->text();
@@ -320,16 +354,15 @@ void NetworkPackageManager :: downloadPackage()
ipkg.setPackage( name );
ipkg.runIpkg( );
}
-
- item = (QCheckListItem *)item->nextSibling();
- } while ( item );
+ }
}
else if ( download->text() == "Remove" )
{
- QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
- do
+ for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
+ item != 0 ;
+ item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
QString name = item->text();
@@ -344,10 +377,9 @@ void NetworkPackageManager :: downloadPackage()
Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
QFile f( p->getFilename() );
f.remove();
}
- item = (QCheckListItem *)item->nextSibling();
- } while ( item );
+ }
}
dataMgr->reloadServerData( LOCAL_IPKGS );
serverSelected( -1 );
@@ -364,19 +396,18 @@ void NetworkPackageManager :: applyChanges()
// Now for each selected item
// deal with it
vector<QString> workingPackages;
- QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
- do
+ for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
+ item != 0 ;
+ item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
QString p = dealWithItem( item );
workingPackages.push_back( p );
}
-
- item = (QCheckListItem *)item->nextSibling();
- } while ( item );
+ }
// do the stuff
InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
dlg.showDlg();
@@ -450,4 +481,22 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
void NetworkPackageManager :: displayText( const QString &t )
{
cout << t << endl;
}
+
+
+void NetworkPackageManager :: letterPushed( QString t )
+{
+ QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
+ do
+ {
+ if ( item->text().lower().startsWith( t.lower() ) )
+ {
+ cout << "Found - item->text()" << endl;
+ packagesList->setSelected( item, true );
+ packagesList->ensureItemVisible( item );
+ break;
+ }
+
+ item = (QCheckListItem *)item->nextSibling();
+ } while ( item );
+}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
index 8a88b35..0ae64a6 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.h
+++ b/noncore/settings/aqpkg/networkpkgmgr.h
@@ -49,8 +49,9 @@ private:
QPushButton *download;
QPushButton *apply;
ProgressDlg *progressDlg;
+ QString currentlySelectedServer;
int timerId;
void timerEvent ( QTimerEvent * );
@@ -66,7 +67,8 @@ public slots:
void upgradePackages();
void downloadPackage();
void updateServer();
void displayText( const QString &t );
+ void letterPushed( QString t );
};
#endif