author | drw <drw> | 2004-11-17 00:43:35 (UTC) |
---|---|---|
committer | drw <drw> | 2004-11-17 00:43:35 (UTC) |
commit | 718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40 (patch) (side-by-side diff) | |
tree | a6bf4f10db4141ba7098d76d0444bd4d1dd759c1 /noncore/settings/packagemanager/mainwindow.cpp | |
parent | 216434aff5921f3c3c2efc9adb58e653a5d224b3 (diff) | |
download | opie-718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40.zip opie-718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40.tar.gz opie-718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40.tar.bz2 |
Some code clean-up items (thanks to zecke)
Diffstat (limited to 'noncore/settings/packagemanager/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 349094d..5e15874 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp @@ -308,17 +308,17 @@ void MainWindow::searchForPackage( const QString &text ) } } } void MainWindow::installLocalPackage( const QString &ipkFile ) { // Install selected file InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true, - OPackage::Install, new QStringList( ipkFile ) ); + OPackage::Install, ipkFile ); connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } void MainWindow::setDocument( const QString &ipkFile ) @@ -405,27 +405,27 @@ void MainWindow::slotUpgrade() // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } void MainWindow::slotDownload() { // Retrieve list of packages selected for download (if any) - QStringList *workingPackages = new QStringList(); + QStringList workingPackages; for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); item != 0 ; item = static_cast<QCheckListItem *>(item->nextSibling()) ) { if ( item->isOn() ) - workingPackages->append( item->text() ); + workingPackages.append( item->text() ); } - if ( workingPackages->isEmpty() ) + if ( workingPackages.isEmpty() ) { QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); return; } else { // Download selected packages m_config.setGroup( "settings" ); @@ -452,19 +452,19 @@ void MainWindow::slotDownload() // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } } void MainWindow::slotApply() { - QStringList *removeList = 0x0; - QStringList *installList = 0x0; - QStringList *upgradeList = 0x0; + QStringList removeList; + QStringList installList; + QStringList upgradeList; for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); item != 0 ; item = static_cast<QCheckListItem *>(item->nextSibling()) ) { if ( item->isOn() ) { OPackage *package = m_packman.findPackage( item->text() ); @@ -475,74 +475,64 @@ void MainWindow::slotApply() if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) { // Remove/upgrade package int answer = PromptDlg::ask( tr( "Remove or upgrade" ), tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), tr( "Remove" ), tr( "Upgrade" ), this ); if ( answer == 1 ) // Remove { - if ( !removeList ) - removeList = new QStringList(); - removeList->append( item->text() ); + removeList.append( item->text() ); } else if ( answer == 2 ) // Upgrade { - if ( !upgradeList ) - upgradeList = new QStringList(); - upgradeList->append( item->text() ); + upgradeList.append( item->text() ); } } else { // Remove/reinstall package int answer = PromptDlg::ask( tr( "Remove or reinstall" ), tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), tr( "Remove" ), tr( "Reinstall" ), this ); if ( answer == 1 ) // Remove { - if ( !removeList ) - removeList = new QStringList(); - removeList->append( item->text() ); + removeList.append( item->text() ); } else if ( answer == 2 ) // Reinstall { - if ( !installList ) - installList = new QStringList(); - installList->append( item->text() ); + installList.append( item->text() ); } } } else { // Install package - if ( !installList ) - installList = new QStringList(); - installList->append( item->text() ); + installList.append( item->text() ); } } } } // If nothing is selected, display message and exit - if ( !removeList && !installList && !upgradeList ) + if ( removeList.isEmpty() && installList.isEmpty() && upgradeList.isEmpty() ) { QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); return; } // Send command only if there are packages to process OPackage::Command removeCmd = OPackage::NotDefined; - if ( removeList && !removeList->isEmpty() ) + if ( !removeList.isEmpty() ) removeCmd = OPackage::Remove; OPackage::Command installCmd = OPackage::NotDefined; - if ( installList && !installList->isEmpty() ) + if ( !installList.isEmpty() ) installCmd = OPackage::Install; OPackage::Command upgradeCmd = OPackage::NotDefined; - if ( upgradeList && !upgradeList->isEmpty() ) + if ( !upgradeList.isEmpty() ) upgradeCmd = OPackage::Upgrade; // Create package manager output widget InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, removeCmd, removeList, installCmd, installList, upgradeCmd, upgradeList ); connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |