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 @@ | |||
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 |
62 | m_package = m_packman->findPackage( package ); | ||
63 | if ( !m_package ) | ||
64 | { | ||
65 | m_information.setText( tr( "Unable to retrieve package information." ) ); | ||
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 | { | ||
64 | QWidget *filesWidget = new QWidget( tabWidget ); | 82 | QWidget *filesWidget = new QWidget( tabWidget ); |
65 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 4, 0 ); | 83 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); |
66 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); | 84 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); |
67 | m_files.setReadOnly( true ); | 85 | m_files.setReadOnly( true ); |
68 | filesLayout->addWidget( &m_files ); | 86 | filesLayout->addWidget( &m_files ); |
69 | 87 | ||
70 | btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Retrieve file list" ), | 88 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), |
71 | filesWidget ); | 89 | tr( "Retrieve file list" ), filesWidget ); |
72 | filesLayout->addWidget( btn ); | 90 | filesLayout->addWidget( btn ); |
73 | // TODO connect( btn, SIGNAL(clicked()), this, SLOT(slotFileScan()) ); | 91 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); |
74 | tabWidget->addTab( filesWidget, "binary", tr( "Files" ) ); | 92 | tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); |
75 | 93 | ||
76 | tabWidget->setCurrentTab( tr( "Information" ) ); | 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 | |||
104 | PackageInfoDlg::~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() ); | ||
112 | |||
113 | // Cache package file list | ||
114 | if ( !m_files.text().isNull() ) | ||
115 | m_package->setFiles( m_files.text() ); | ||
116 | } | ||
117 | |||
118 | void 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 ); | ||
124 | } | ||
125 | |||
126 | void PackageInfoDlg::slotInfo( char *info ) | ||
127 | { | ||
128 | m_information.append( info ); | ||
77 | } | 129 | } |
78 | 130 | ||
79 | void PackageInfoDlg::slotBtnClose() | 131 | void PackageInfoDlg::slotFiles( char *filelist ) |
80 | { | 132 | { |
81 | emit closeInfoDlg(); | 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 | } |