summaryrefslogtreecommitdiff
authordrw <drw>2003-01-23 01:47:41 (UTC)
committer drw <drw>2003-01-23 01:47:41 (UTC)
commitc464d34970bedca56a518310deef7ce08474033c (patch) (side-by-side diff)
tree8f0e9c1c75daf0cdd53bdd5e3cdaf22a3b5b60b3
parent454eba9982f1a898e914b558f2ceac913fdf3b5c (diff)
downloadopie-c464d34970bedca56a518310deef7ce08474033c.zip
opie-c464d34970bedca56a518310deef7ce08474033c.tar.gz
opie-c464d34970bedca56a518310deef7ce08474033c.tar.bz2
Minor fix for find function and more liberal use of progress widget to give feedback to user
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp40
-rw-r--r--noncore/settings/aqpkg/mainwin.h3
2 files changed, 24 insertions, 19 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index c9963bc..8090646 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -251,132 +251,136 @@ void MainWindow :: initMainWidget()
LetterPushButton *b = new LetterPushButton( text, networkPkgWindow );
connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
if ( i < 13 )
hbox3->addWidget( b );
else
hbox4->addWidget( b );
}
}
vbox->addWidget( packagesList );
downloadEnabled = TRUE;
}
void MainWindow :: initProgressWidget()
{
progressWindow = new QWidget( this );
QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
m_status = new QLabel( progressWindow );
m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
layout->addWidget( m_status );
m_progress = new QProgressBar( progressWindow );
layout->addWidget( m_progress );
}
void MainWindow :: init()
{
stack->raiseWidget( progressWindow );
mgr = new DataManager();
connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
this, SLOT( setProgressMessage( const QString & ) ) );
connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
mgr->loadServers();
showUninstalledPkgs = false;
showInstalledPkgs = false;
showUpgradedPkgs = false;
categoryFilterEnabled = false;
updateData();
stack->raiseWidget( networkPkgWindow );
}
-
+/*
void MainWindow :: setDocument( const QString &doc )
{
// Remove path from package
QString package = Utils::getPackageNameFromIpkFilename( doc );
// std::cout << "Selecting package " << package << std::endl;
// First select local server
for ( int i = 0 ; i < serversList->count() ; ++i )
{
if ( serversList->text( i ) == LOCAL_IPKGS )
{
serversList->setCurrentItem( i );
break;
}
}
serverSelected( 0 );
// Now set the check box of the selected package
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->text().startsWith( package ) )
{
item->setOn( true );
break;
}
}
}
-
+*/
void MainWindow :: displaySettings()
{
SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
if ( dlg->showDlg( 0 ) )
+ {
+ stack->raiseWidget( progressWindow );
updateData();
+ stack->raiseWidget( networkPkgWindow );
+ }
delete dlg;
}
void MainWindow :: displayHelp()
{
HelpWindow *dlg = new HelpWindow( this );
dlg->exec();
delete dlg;
}
void MainWindow :: displayFindBar()
{
findBar->show();
findEdit->setFocus();
}
void MainWindow :: repeatFind()
{
searchForPackage( findEdit->text() );
}
void MainWindow :: findPackage( const QString &text )
{
actionFindNext->setEnabled( !text.isEmpty() );
searchForPackage( text );
}
void MainWindow :: hideFindBar()
{
findBar->hide();
}
void MainWindow :: displayAbout()
{
QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) );
}
void MainWindow :: filterUninstalledPackages()
{
showUninstalledPkgs = actionUninstalled->isOn();
if ( showUninstalledPkgs )
{
showInstalledPkgs = FALSE;
showUpgradedPkgs = FALSE;
}
serverSelected( -1 );
actionInstalled->setOn( FALSE );
@@ -683,359 +687,351 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) );
}
else
{
new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) );
if ( it->getLocalPackage() )
{
if ( it->isInstalled() )
new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) );
}
}
packagesList->insertItem( item );
}
// If the local server or the local ipkgs server disable the download button
if ( serverName == LOCAL_SERVER )
{
downloadEnabled = TRUE;
actionUpgrade->setEnabled( FALSE );
}
else if ( serverName == LOCAL_IPKGS )
{
downloadEnabled = FALSE;
actionUpgrade->setEnabled( FALSE );
}
else
{
downloadEnabled = TRUE;
actionUpgrade->setEnabled( TRUE );
}
enableDownload( downloadEnabled );
// Display this widget once everything is done
if ( doProgress && raiseProgress )
{
stack->raiseWidget( networkPkgWindow );
}
}
void MainWindow :: searchForPackage( const QString &text )
{
if ( !text.isEmpty() )
{
// cout << "searching for " << text << 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 *)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( text ) != -1 )
{
// cout << "matched " << item->text() << endl;
packagesList->ensureItemVisible( item );
packagesList->setCurrentItem( item );
break;
}
}
}
}
void MainWindow :: updateServer()
{
QString serverName = serversList->currentText();
// Update the current server
// Display dialog
// Disable buttons to stop silly people clicking lots on them :)
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
Ipkg ipkg;
ipkg.setOption( "update" );
InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true );
dlg.showDlg();
- // Reload data
- mgr->reloadServerData();
- serverSelected(-1);
+ reloadData();
+
// delete progDlg;
}
void MainWindow :: upgradePackages()
{
// We're gonna do an upgrade of all packages
// First warn user that this isn't recommended
// TODO - ODevice????
QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
0, this );
warn.adjustSize();
if ( warn.exec() == QMessageBox::Yes )
{
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Now run upgrade
Ipkg ipkg;
ipkg.setOption( "upgrade" );
InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true );
dlg.showDlg();
- // Reload data
- mgr->reloadServerData();
- serverSelected(-1);
+ reloadData();
}
}
void MainWindow :: downloadPackage()
{
bool doUpdate = true;
if ( downloadEnabled )
{
// See if any packages are selected
bool found = false;
if ( serversList->currentText() != LOCAL_SERVER )
{
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 && !found;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
found = true;
}
}
// If user selected some packages then download the and store the locally
// otherwise, display dialog asking user what package to download from an http server
// and whether to install it
if ( found )
downloadSelectedPackages();
else
downloadRemotePackage();
}
else
{
doUpdate = false;
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 );
// if (there is a (installed), remove it
pos = name.find( "(installed)" );
if ( pos > 0 )
name.truncate( pos - 1 );
Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
QString msgtext;
msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
if ( QMessageBox::information( this, tr( "Are you sure?" ),
msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
{
doUpdate = true;
QFile f( p->getFilename() );
f.remove();
}
}
}
}
if ( doUpdate )
{
- mgr->reloadServerData();
- serverSelected( -1 );
+ reloadData();
}
}
void MainWindow :: downloadSelectedPackages()
{
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Display dialog to user asking where to download the files to
bool ok = FALSE;
QString dir = "";
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
#endif
QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
if ( ok && !text.isEmpty() )
dir = text; // user entered something and pressed ok
else
return; // user entered nothing or pressed cancel
#ifdef QWS
// Store download directory in config file
cfg.writeEntry( "downloadDir", dir );
#endif
// Get starting directory
char initDir[PATH_MAX];
getcwd( initDir, PATH_MAX );
// Download each package
Ipkg ipkg;
connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
ipkg.setOption( "download" );
ipkg.setRuntimeDirectory( dir );
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
ipkg.setPackage( item->text() );
ipkg.runIpkg( );
}
}
}
void MainWindow :: downloadRemotePackage()
{
// Display dialog
bool ok;
QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
if ( !ok || package.isEmpty() )
return;
// DownloadRemoteDlgImpl dlg( this, "Install", true );
// if ( dlg.exec() == QDialog::Rejected )
// return;
// grab details from dialog
// QString package = dlg.getPackageLocation();
InstallData item;
item.option = "I";
item.packageName = package;
vector<InstallData> workingPackages;
workingPackages.push_back( item );
InstallDlgImpl dlg2( workingPackages, mgr, this, "Install", true );
dlg2.showDlg();
- // Reload data
- mgr->reloadServerData();
- serverSelected(-1);
+ reloadData();
#ifdef QWS
// Finally let the main system update itself
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
e << lf;
#endif
}
void MainWindow :: applyChanges()
{
stickyOption = "";
// First, write out ipkg_conf file so that ipkg can use it
mgr->writeOutIpkgConf();
// Now for each selected item
// deal with it
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, tr( "Nothing to do" ),
tr( "No packages selected" ), tr( "OK" ) );
return;
}
// do the stuff
InstallDlgImpl dlg( workingPackages, mgr, this, "Install", true );
dlg.showDlg();
- // Reload data
- mgr->reloadServerData();
- serverSelected(-1);
+ reloadData();
#ifdef QWS
// Finally let the main system update itself
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
e << lf;
#endif
}
// decide what to do - either remove, upgrade or install
// Current rules:
// If not installed - install
// If installed and different version available - upgrade
// If installed and version up to date - remove
InstallData MainWindow :: dealWithItem( QCheckListItem *item )
{
QString name = item->text();
// Get package
vector<Server>::iterator s = mgr->getServer( serversList->currentText() );
Package *p = s->getPackage( name );
// If the package has a filename then it is a local file
if ( p->isPackageStoredLocally() )
name = p->getFilename();
QString option;
QString dest = "root";
if ( !p->isInstalled() )
{
InstallData item;
item.option = "I";
item.packageName = name;
return item;
}
else
{
InstallData item;
item.option = "D";
if ( !p->isPackageStoredLocally() )
item.packageName = p->getInstalledPackageName();
else
item.packageName = name;
if ( p->getInstalledTo() )
{
item.destination = p->getInstalledTo();
// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
@@ -1076,80 +1072,88 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
secondButton = tr( "ReInstall" );
secondOption = tr( "R" );
}
else if ( val == 1 )
{
// Version available is newer - option to remove or upgrade
caption = tr( "Do you wish to remove or upgrade\n%1?" );
text = tr( "Remove or Upgrade" );
secondButton = tr( "Upgrade" );
secondOption = tr( "U" );
}
// Sticky option not implemented yet, but will eventually allow
// the user to say something like 'remove all'
if ( stickyOption == "" )
{
QString msgtext;
msgtext = caption.arg( ( const char * )name );
switch( QMessageBox::information( this, text,
msgtext, tr( "Remove" ), secondButton ) )
{
case 0: // Try again or Enter
// option 0 = Remove
item.option = "D";
break;
case 1: // Quit or Escape
item.option = secondOption;
break;
}
}
else
{
// item.option = stickyOption;
}
}
// Check if we are reinstalling the same version
if ( item.option != "R" )
item.recreateLinks = true;
else
item.recreateLinks = false;
// User hit cancel (on dlg - assume remove)
return item;
}
}
+void MainWindow :: reloadData()
+{
+ stack->raiseWidget( progressWindow );
+ mgr->reloadServerData();
+ serverSelected( -1, FALSE );
+ stack->raiseWidget( networkPkgWindow );
+}
+
void MainWindow :: letterPushed( QString t )
{
QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
if ( packagesList->firstChild() == 0 )
return;
QCheckListItem *item;
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);
}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index 46b5fae..be30668 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -46,88 +46,89 @@ private:
DataManager *mgr;
QWidgetStack *stack;
QPEToolBar *findBar;
QLineEdit *findEdit;
QAction *actionFindNext;
QAction *actionFilter;
QAction *actionUpgrade;
QAction *actionDownload;
QAction *actionUninstalled;
QAction *actionInstalled;
QAction *actionUpdated;
QPixmap iconDownload;
QPixmap iconRemove;
int mnuShowUninstalledPkgsId;
int mnuShowInstalledPkgsId;
int mnuShowUpgradedPkgsId;
int mnuFilterByCategory;
int mnuSetFilterCategory;
// Main package list widget
QWidget *networkPkgWindow;
QComboBox *serversList;
QListView *packagesList;
QPixmap installedIcon;
QPixmap updatedIcon;
QString currentlySelectedServer;
QString categoryFilter;
QString stickyOption;
bool categoryFilterEnabled;
bool showJumpTo;
bool showUninstalledPkgs;
bool showInstalledPkgs;
bool showUpgradedPkgs;
bool downloadEnabled;
void initMainWidget();
void updateData();
void serverSelected( int index, bool showProgress );
void searchForPackage( const QString & );
bool filterByCategory( bool val );
void downloadSelectedPackages();
void downloadRemotePackage();
InstallData dealWithItem( QCheckListItem *item );
+ void reloadData();
// Progress widget
QWidget *progressWindow;
QLabel *m_status;
QProgressBar *m_progress;
void initProgressWidget();
public slots:
- void setDocument( const QString &doc );
+// void setDocument( const QString &doc );
void displayHelp();
void displayFindBar();
void repeatFind();
void findPackage( const QString & );
void hideFindBar();
void displayAbout();
void displaySettings();
void filterUninstalledPackages();
void filterInstalledPackages();
void filterUpgradedPackages();
void filterCategory();
bool setFilterCategory();
void raiseMainWidget();
void raiseProgressWidget();
void enableUpgrade( bool );
void enableDownload( bool );
private slots:
void init();
void setProgressSteps( int );
void setProgressMessage( const QString & );
void updateProgress( int );
void serverSelected( int index );
void updateServer();
void upgradePackages();
void downloadPackage();
void applyChanges();
void letterPushed( QString t );
};
#endif