summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/packagemanager/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 4611404..486561d 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -7,64 +7,67 @@
 _;:,     .>    :=|. This file is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qaction.h>
+#include <qdir.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qtimer.h>
#include <qtoolbar.h>
#include <qwhatsthis.h>
+#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include "mainwindow.h"
#include "installdlg.h"
#include "filterdlg.h"
#include "promptdlg.h"
+#include "entrydlg.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl )
: QMainWindow( parent, name, fl || WStyle_ContextHelp )
, m_config( "packman" )
, m_packman( &m_config, this )
, m_menuBar( this )
, m_toolBar( this )
, m_findBar( this )
, m_widgetStack( this )
, m_packageList( this )
, m_statusWidget( this )
, m_statusText( &m_statusWidget )
, m_statusBar( &m_statusWidget )
, m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) )
, m_iconInstalled( Resource::loadPixmap( "installed" ) )
, m_iconNull( m_iconUpdated.size() )
, m_filterName( QString::null )
, m_filterServer( QString::null )
, m_filterDest( QString::null )
, m_filterStatus( OPackageManager::NotDefined )
, m_filterCategory( QString::null )
{
// setCaption( tr( "Package Manager" ) );
@@ -141,57 +144,55 @@ void MainWindow::initUI()
// Find toolbar
addToolBar( &m_findBar, QMainWindow::Top, true );
m_findBar.setHorizontalStretchable( true );
m_findEdit = new QLineEdit( &m_findBar );
QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) );
m_findBar.setStretchableWidget( m_findEdit );
connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) );
// Packages menu
QPopupMenu *popup = new QPopupMenu( this );
QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) );
a->addTo( popup );
a->addTo( &m_toolBar );
QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 );
actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
actionUpgrade->addTo( popup );
actionUpgrade->addTo( &m_toolBar );
-/*
QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
actionDownload->addTo( popup );
actionDownload->addTo( &m_toolBar );
-*/
a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
a->addTo( popup );
a->addTo( &m_toolBar );
popup->insertSeparator();
a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to configure this application." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
a->addTo( popup );
mb->insertItem( tr( "Actions" ), popup );
// View menu
popup = new QPopupMenu( this );
m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
m_actionShowNotInstalled->setToggleAction( true );
m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) );
m_actionShowNotInstalled->addTo( popup );
@@ -349,99 +350,95 @@ void MainWindow::slotStatusBar( int currStep )
void MainWindow::slotUpdate()
{
// Create package manager output widget
InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false,
OPackage::Update );
connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
// Display widget
m_widgetStack.addWidget( dlg, 3 );
m_widgetStack.raiseWidget( dlg );
}
void MainWindow::slotUpgrade()
{
// Create package manager output widget
InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false,
OPackage::Upgrade );
connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
// 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();
for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
item != 0 ;
item = static_cast<QCheckListItem *>(item->nextSibling()) )
{
if ( item->isOn() )
workingPackages->append( item->text() );
}
if ( workingPackages->isEmpty() )
{
- // No packages were selected, prompt for URL of package to download
+ QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
+ return;
}
else
{
// Download selected packages
m_config.setGroup( "settings" );
QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
-// QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), workingDir, &ok, this );
-// if ( ok && !text.isEmpty() )
-// workingDir = text; // user entered something and pressed ok
-// else
-// return; // user entered nothing or pressed cancel
+ bool ok = false;
+ QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this );
+ if ( ok && !text.isEmpty() )
+ workingDir = text; // user entered something and pressed ok
+ else
+ return; // user entered nothing or pressed cancel
-// // Store download directory in config file
-// m_config.writeEntry( "DownloadDir", workingDir );
+ // Store download directory in config file
+ m_config.writeEntry( "DownloadDir", workingDir );
// Get starting directory
-// char initDir[PATH_MAX];
-// getcwd( initDir, PATH_MAX );
-
- // Download packages
-
- }
+ QDir::setCurrent( workingDir );
// Create package manager output widget
InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
OPackage::Download, workingPackages );
connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
// Display widget
m_widgetStack.addWidget( dlg, 3 );
m_widgetStack.raiseWidget( dlg );
}
-*/
+}
void MainWindow::slotApply()
{
QStringList *removeList = 0x0;
QStringList *installList = 0x0;
QStringList *upgradeList = 0x0;
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() );
if ( package )
{
if ( !package->versionInstalled().isNull() )
{
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 );
@@ -505,48 +502,53 @@ void MainWindow::slotApply()
installCmd = OPackage::Install;
OPackage::Command upgradeCmd = OPackage::NotDefined;
if ( upgradeList && !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(slotCloseInstallDlg()) );
// Display widget
m_widgetStack.addWidget( dlg, 3 );
m_widgetStack.raiseWidget( dlg );
}
void MainWindow::slotCloseInstallDlg()
{
// Close install dialog
delete m_widgetStack.visibleWidget();
// Reload package list
initPackageInfo();
+
+ // Update Opie launcher links
+ QCopEnvelope e("QPE/System", "linkChanged(QString)");
+ QString lf = QString::null;
+ e << lf;
}
void MainWindow::slotConfigure()
{
if ( m_packman.configureDlg( false ) )
{
if ( PromptDlg::ask( tr( "Config updated" ),
tr( "The configuration has been updated. Do you want to update server and package information now?" ),
tr( "Yes" ), tr( "No" ), this ) == 1 )
{
// Update package list and reload package info
slotUpdate();
}
}
}
void MainWindow::slotShowNotInstalled()
{
OPackageList *packageList;
if ( m_actionShowNotInstalled->isOn() )
{
m_actionShowInstalled->setOn( false );
m_actionShowUpdated->setOn( false );
packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,