author | drw <drw> | 2004-02-05 16:34:04 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-05 16:34:04 (UTC) |
commit | ef8ece225a663f0ff1262989085fc214500beebe (patch) (side-by-side diff) | |
tree | 2d6902575eb29de18a0ed7f3a33acadabd37021b /noncore/settings/packagemanager/packageinfodlg.cpp | |
parent | 823399a552c04821fb0b49d816d733fa21a12a21 (diff) | |
download | opie-ef8ece225a663f0ff1262989085fc214500beebe.zip opie-ef8ece225a663f0ff1262989085fc214500beebe.tar.gz opie-ef8ece225a663f0ff1262989085fc214500beebe.tar.bz2 |
Completed package information dialog and a couple of other minor tweaks
Diffstat (limited to 'noncore/settings/packagemanager/packageinfodlg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/packageinfodlg.cpp | 84 |
1 files changed, 71 insertions, 13 deletions
diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp index 26356b9..7daf336 100644 --- a/noncore/settings/packagemanager/packageinfodlg.cpp +++ b/noncore/settings/packagemanager/packageinfodlg.cpp @@ -28,6 +28,8 @@ */ #include "packageinfodlg.h" +#include "opackage.h" +#include "opackagemanager.h" #include <qlayout.h> #include <qpushbutton.h> @@ -46,37 +48,93 @@ PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QStr if ( parent ) parent->setCaption( package ); - QVBoxLayout *layout = new QVBoxLayout( this, 4, 0 ); + QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); OTabWidget *tabWidget = new OTabWidget( this ); layout->addWidget( tabWidget ); - QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this ); - layout->addWidget( btn ); - 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 + // Retrive package information + m_package = m_packman->findPackage( package ); + if ( !m_package ) + { + m_information.setText( tr( "Unable to retrieve package information." ) ); + return; + } + + // Display package information + if ( !m_package->information().isNull() ) + m_information.setText( m_package->information() ); + else + { + // Package information is not cached, retrieve it + QStringList list( package ); + m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true ); + } + + // Files tab (display only if package is installed) + if ( !m_package->versionInstalled().isNull() ) + { QWidget *filesWidget = new QWidget( tabWidget ); - QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 4, 0 ); + QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); 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 ); + QPushButton *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" ) ); + connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); + tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); tabWidget->setCurrentTab( tr( "Information" ) ); + + // If file list is already cached, display + if ( !m_package->files().isNull() ) + m_files.setText( m_package->files() ); + } + else + m_files.hide(); +} + +PackageInfoDlg::~PackageInfoDlg() +{ + if ( !m_package ) + return; + + // Cache package information + if ( !m_information.text().isNull() ) + m_package->setInformation( m_information.text() ); + + // Cache package file list + if ( !m_files.text().isNull() ) + m_package->setFiles( m_files.text() ); +} + +void PackageInfoDlg::slotBtnFileScan() +{ + m_files.clear(); + + QStringList list( m_package->name() ); + m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true ); +} + +void PackageInfoDlg::slotInfo( char *info ) +{ + m_information.append( info ); } -void PackageInfoDlg::slotBtnClose() +void PackageInfoDlg::slotFiles( char *filelist ) { - emit closeInfoDlg(); + QString str = filelist; + + // Skip first line of output ("Package xxx is installed...") + if ( str.startsWith( "Package " ) ) + str = str.right( str.length() - str.find( '\n' ) - 1 ); + + m_files.append( str ); } |