summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp97
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h2
2 files changed, 75 insertions, 24 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
@@ -36,20 +36,29 @@ using namespace std;
#include "datamgr.h"
#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;
timerId = startTimer( 100 );
}
@@ -77,13 +86,13 @@ void NetworkPackageManager :: updateData()
vector<Server>::iterator it;
int activeItem = -1;
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
if ( activeItem != -1 )
serversList->setCurrentItem( activeItem );
@@ -103,12 +112,28 @@ void NetworkPackageManager :: initGui()
QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
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" );
hbox2->addWidget( update );
hbox2->addWidget( download );
@@ -137,14 +162,23 @@ void NetworkPackageManager :: showProgressDialog( char *initialText )
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 )
{
QString text = "";
@@ -203,27 +237,26 @@ void NetworkPackageManager :: updateServer()
{
QString serverName = serversList->currentText();
// 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;
connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
ipkg.setOption( option );
@@ -299,16 +332,17 @@ void NetworkPackageManager :: downloadPackage()
getcwd( initDir, PATH_MAX );
// 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();
int pos = name.find( "*" );
name.truncate( pos );
@@ -318,20 +352,19 @@ void NetworkPackageManager :: downloadPackage()
if ( pos > 0 )
name.truncate( pos - 1 );
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();
int pos = name.find( "*" );
name.truncate( pos );
@@ -342,43 +375,41 @@ void NetworkPackageManager :: downloadPackage()
name.truncate( pos - 1 );
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 );
}
void NetworkPackageManager :: applyChanges()
{
// Disable buttons to stop silly people clicking lots on them :)
-
+
// First, write out ipkg_conf file so that ipkg can use it
dataMgr->writeOutIpkgConf();
// 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();
// Reload data
@@ -448,6 +479,24 @@ 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
@@ -47,12 +47,13 @@ private:
QPushButton *update;
QPushButton *upgrade;
QPushButton *download;
QPushButton *apply;
ProgressDlg *progressDlg;
+ QString currentlySelectedServer;
int timerId;
void timerEvent ( QTimerEvent * );
void initGui();
@@ -64,9 +65,10 @@ public slots:
void serverSelected( int index );
void applyChanges();
void upgradePackages();
void downloadPackage();
void updateServer();
void displayText( const QString &t );
+ void letterPushed( QString t );
};
#endif