summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/packageinfodlg.cpp
Unidiff
Diffstat (limited to 'noncore/settings/packagemanager/packageinfodlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.cpp96
1 files changed, 77 insertions, 19 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 @@
28*/ 28*/
29 29
30#include "packageinfodlg.h" 30#include "packageinfodlg.h"
31#include "opackage.h"
32#include "opackagemanager.h"
31 33
32#include <qlayout.h> 34#include <qlayout.h>
33#include <qpushbutton.h> 35#include <qpushbutton.h>
@@ -46,37 +48,93 @@ PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QStr
46 if ( parent ) 48 if ( parent )
47 parent->setCaption( package ); 49 parent->setCaption( package );
48 50
49 QVBoxLayout *layout = new QVBoxLayout( this, 4, 0 ); 51 QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 );
50 52
51 OTabWidget *tabWidget = new OTabWidget( this ); 53 OTabWidget *tabWidget = new OTabWidget( this );
52 layout->addWidget( tabWidget ); 54 layout->addWidget( tabWidget );
53 55
54 QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this );
55 layout->addWidget( btn );
56 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnClose()) );
57
58 // Information tab 56 // Information tab
59 m_information.reparent( tabWidget, QPoint( 0, 0 ) ); 57 m_information.reparent( tabWidget, QPoint( 0, 0 ) );
60 m_information.setReadOnly( true ); 58 m_information.setReadOnly( true );
61 tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); 59 tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) );
62 60
63 // Files tab 61 // Retrive package information
64 QWidget *filesWidget = new QWidget( tabWidget ); 62 m_package = m_packman->findPackage( package );
65 QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 4, 0 ); 63 if ( !m_package )
66 m_files.reparent( filesWidget, QPoint( 0, 0 ) ); 64 {
67 m_files.setReadOnly( true ); 65 m_information.setText( tr( "Unable to retrieve package information." ) );
68 filesLayout->addWidget( &m_files ); 66 return;
67 }
68
69 // Display package information
70 if ( !m_package->information().isNull() )
71 m_information.setText( m_package->information() );
72 else
73 {
74 // Package information is not cached, retrieve it
75 QStringList list( package );
76 m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true );
77 }
78
79 // Files tab (display only if package is installed)
80 if ( !m_package->versionInstalled().isNull() )
81 {
82 QWidget *filesWidget = new QWidget( tabWidget );
83 QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 );
84 m_files.reparent( filesWidget, QPoint( 0, 0 ) );
85 m_files.setReadOnly( true );
86 filesLayout->addWidget( &m_files );
87
88 QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ),
89 tr( "Retrieve file list" ), filesWidget );
90 filesLayout->addWidget( btn );
91 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) );
92 tabWidget->addTab( filesWidget, "binary", tr( "File list" ) );
93
94 tabWidget->setCurrentTab( tr( "Information" ) );
95
96 // If file list is already cached, display
97 if ( !m_package->files().isNull() )
98 m_files.setText( m_package->files() );
99 }
100 else
101 m_files.hide();
102}
103
104PackageInfoDlg::~PackageInfoDlg()
105{
106 if ( !m_package )
107 return;
108
109 // Cache package information
110 if ( !m_information.text().isNull() )
111 m_package->setInformation( m_information.text() );
69 112
70 btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Retrieve file list" ), 113 // Cache package file list
71 filesWidget ); 114 if ( !m_files.text().isNull() )
72 filesLayout->addWidget( btn ); 115 m_package->setFiles( m_files.text() );
73// TODO connect( btn, SIGNAL(clicked()), this, SLOT(slotFileScan()) ); 116}
74 tabWidget->addTab( filesWidget, "binary", tr( "Files" ) );
75 117
76 tabWidget->setCurrentTab( tr( "Information" ) ); 118void PackageInfoDlg::slotBtnFileScan()
119{
120 m_files.clear();
121
122 QStringList list( m_package->name() );
123 m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true );
77} 124}
78 125
79void PackageInfoDlg::slotBtnClose() 126void PackageInfoDlg::slotInfo( char *info )
80{ 127{
81 emit closeInfoDlg(); 128 m_information.append( info );
129}
130
131void PackageInfoDlg::slotFiles( char *filelist )
132{
133 QString str = filelist;
134
135 // Skip first line of output ("Package xxx is installed...")
136 if ( str.startsWith( "Package " ) )
137 str = str.right( str.length() - str.find( '\n' ) - 1 );
138
139 m_files.append( str );
82} 140}