-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 26 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.h | 5 | ||||
-rw-r--r-- | noncore/settings/packagemanager/packageinfodlg.cpp | 34 | ||||
-rw-r--r-- | noncore/settings/packagemanager/packageinfodlg.h | 9 |
4 files changed, 63 insertions, 11 deletions
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 486561d..05f21bc 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp @@ -18,64 +18,65 @@ _.=:. : :=>`: 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" +#include "packageinfodlg.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" ) ); m_iconNull.fill( colorGroup().base() ); connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); // Initialize widget stack, package list and status widget initStatusWidget(); initPackageList(); @@ -88,64 +89,66 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) initUI(); // Initialize package information QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); } void MainWindow::closeEvent( QCloseEvent *event ) { // Close app only if either the package or status widgets are currently active bool close = m_widgetStack.visibleWidget() == &m_packageList || m_widgetStack.visibleWidget() == &m_statusWidget; if ( close ) { // TODO - write out application configuration settings // Write out package manager configuration settings m_packman.saveSettings(); event->accept(); } else { delete m_widgetStack.visibleWidget(); m_widgetStack.raiseWidget( &m_packageList ); event->ignore(); } } void MainWindow::initPackageList() { m_packageList.addColumn( tr( "Packages" ) ); QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); + connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), + this, SLOT(slotDisplayPackageInfo(QListViewItem *)) ); } void MainWindow::initStatusWidget() { QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); layout->addWidget( &m_statusText ); connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) ); connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); layout->addWidget( &m_statusBar ); } void MainWindow::initUI() { // Build menu and tool bars setToolBarsMovable( false ); m_menuBar.setHorizontalStretchable( true ); QMenuBar *mb = new QMenuBar( &m_menuBar ); mb->setMargin( 0 ); // 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 &)) ); @@ -323,124 +326,124 @@ void MainWindow::slotWidgetStackShow( QWidget *widget ) setCaption( tr( "Package Manager" ) ); m_menuBar.show(); m_toolBar.show(); } else { m_menuBar.hide(); m_toolBar.hide(); } } void MainWindow::slotInitStatusBar( int numSteps ) { m_statusBar.setTotalSteps( numSteps ); } void MainWindow::slotStatusText( const QString &status ) { m_statusText.setText( status ); } void MainWindow::slotStatusBar( int currStep ) { m_statusBar.setProgress( 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()) ); + connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // 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()) ); + connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // 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() ) { 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" ); 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 ); // Get starting directory 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()) ); + connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // 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 ); if ( answer == 1 ) // Remove { @@ -480,72 +483,72 @@ void MainWindow::slotApply() // Install package if ( !installList ) installList = new QStringList(); installList->append( item->text() ); } } } } // If nothing is selected, display message and exit if ( !removeList && !installList && !upgradeList ) { 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() ) removeCmd = OPackage::Remove; OPackage::Command installCmd = OPackage::NotDefined; if ( installList && !installList->isEmpty() ) 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()) ); + connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } -void MainWindow::slotCloseInstallDlg() +void MainWindow::slotCloseDlg() { // 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() ) { @@ -636,32 +639,45 @@ void MainWindow::slotFilter( bool isOn ) else packageList = m_packman.packages(); if ( packageList ) { loadPackageList( packageList, true ); delete packageList; } } void MainWindow::slotFindShowToolbar() { m_findBar.show(); m_findEdit->setFocus(); } void MainWindow::slotFindHideToolbar() { m_findBar.hide(); } void MainWindow::slotFindChanged( const QString &findText ) { m_actionFindNext->setEnabled( !findText.isEmpty() ); searchForPackage( findText ); } void MainWindow::slotFindNext() { searchForPackage( m_findEdit->text() ); } + +void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) +{ + QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); + + // Create package manager output widget + PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); + connect( dlg, SIGNAL(closeInfoDlg()), this, SLOT(slotCloseDlg()) ); + + // Display widget + m_widgetStack.addWidget( dlg, 3 ); + m_widgetStack.raiseWidget( dlg ); +} diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h index 285cddf..fb555c5 100644 --- a/noncore/settings/packagemanager/mainwindow.h +++ b/noncore/settings/packagemanager/mainwindow.h @@ -87,50 +87,53 @@ private: QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available QAction *m_actionFilter; // Action to filter packages QAction *m_actionFindNext; // Action to find next match // Cached filter settings QString m_filterName; // Cached name filter value QString m_filterServer; // Cached server name filter value QString m_filterDest; // Cached destination name filter value OPackageManager::Status m_filterStatus; // Cached status filter value QString m_filterCategory; // Cached category filter value void initPackageList(); void initStatusWidget(); void initUI(); void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); void searchForPackage( const QString &text ); private slots: void initPackageInfo(); void slotWidgetStackShow( QWidget *widget ); // Status widget slots void slotInitStatusBar( int numSteps ); void slotStatusText( const QString &status ); void slotStatusBar( int currStep ); // Actions menu action slots void slotUpdate(); void slotUpgrade(); void slotDownload(); void slotApply(); - void slotCloseInstallDlg(); + void slotCloseDlg(); void slotConfigure(); // View menu action slots void slotShowNotInstalled(); void slotShowInstalled(); void slotShowUpdated(); void slotFilterChange(); void slotFilter( bool isOn ); // Find action slots void slotFindShowToolbar(); void slotFindHideToolbar(); void slotFindChanged( const QString &findText ); void slotFindNext(); + + // Other slots + void slotDisplayPackageInfo( QListViewItem * ); }; #endif diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp index 71f17eb..26356b9 100644 --- a/noncore/settings/packagemanager/packageinfodlg.cpp +++ b/noncore/settings/packagemanager/packageinfodlg.cpp @@ -5,52 +5,78 @@ .=l. .>+-= _;:, .> :=|. 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 "packageinfodlg.h" #include <qlayout.h> #include <qpushbutton.h> #include <qpe/resource.h> +#include <opie/otabwidget.h> + PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) : QWidget( 0x0 ) , m_packman( pm ) - , m_output( this ) + , m_information( this ) + , m_files( this ) { // Initialize UI if ( parent ) parent->setCaption( package ); QVBoxLayout *layout = new QVBoxLayout( this, 4, 0 ); - m_output.setReadOnly( true ); - layout->addWidget( &m_output ); + OTabWidget *tabWidget = new OTabWidget( this ); + layout->addWidget( tabWidget ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this ); layout->addWidget( btn ); -// TODO connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnClose()) ); + connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnClose()) ); + + // Information tab + m_information.reparent( tabWidget, QPoint( 0, 0 ) ); + m_information.setReadOnly( true ); + tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); + + // Files tab + QWidget *filesWidget = new QWidget( tabWidget ); + QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 4, 0 ); + m_files.reparent( filesWidget, QPoint( 0, 0 ) ); + m_files.setReadOnly( true ); + filesLayout->addWidget( &m_files ); + btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Retrieve file list" ), + filesWidget ); + filesLayout->addWidget( btn ); +// TODO connect( btn, SIGNAL(clicked()), this, SLOT(slotFileScan()) ); + tabWidget->addTab( filesWidget, "binary", tr( "Files" ) ); + tabWidget->setCurrentTab( tr( "Information" ) ); +} + +void PackageInfoDlg::slotBtnClose() +{ + emit closeInfoDlg(); } diff --git a/noncore/settings/packagemanager/packageinfodlg.h b/noncore/settings/packagemanager/packageinfodlg.h index 3bb9a7a..09af6f4 100644 --- a/noncore/settings/packagemanager/packageinfodlg.h +++ b/noncore/settings/packagemanager/packageinfodlg.h @@ -23,36 +23,43 @@ -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef PACKAGEINFODLG_H #define PACKAGEINFODLG_H #include <qmultilineedit.h> #include <qwidget.h> #include <opie/oprocess.h> #include "opackage.h" class QPushButton; class OPackageManager; class PackageInfoDlg : public QWidget { Q_OBJECT public: PackageInfoDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &package = QString::null ); private: OPackageManager *m_packman; // Pointer to application instance of package manager // UI controls - QMultiLineEdit m_output; // Multi-line edit to display package information + QMultiLineEdit m_information; // Multi-line edit to display package information + QMultiLineEdit m_files; // Multi-line edit to display package file list + +private slots: + void slotBtnClose(); + +signals: + void closeInfoDlg(); }; #endif |