author | drw <drw> | 2004-11-17 00:43:35 (UTC) |
---|---|---|
committer | drw <drw> | 2004-11-17 00:43:35 (UTC) |
commit | 718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40 (patch) (unidiff) | |
tree | a6bf4f10db4141ba7098d76d0444bd4d1dd759c1 /noncore/settings/packagemanager/packageinfodlg.cpp | |
parent | 216434aff5921f3c3c2efc9adb58e653a5d224b3 (diff) | |
download | opie-718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40.zip opie-718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40.tar.gz opie-718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40.tar.bz2 |
Some code clean-up items (thanks to zecke)
Diffstat (limited to 'noncore/settings/packagemanager/packageinfodlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/packageinfodlg.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp index d27eacb..c5924fd 100644 --- a/noncore/settings/packagemanager/packageinfodlg.cpp +++ b/noncore/settings/packagemanager/packageinfodlg.cpp | |||
@@ -1,144 +1,144 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "packageinfodlg.h" | 30 | #include "packageinfodlg.h" |
31 | #include "opackage.h" | 31 | #include "opackage.h" |
32 | #include "opackagemanager.h" | 32 | #include "opackagemanager.h" |
33 | 33 | ||
34 | #include <opie2/otabwidget.h> | 34 | #include <opie2/otabwidget.h> |
35 | 35 | ||
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | 37 | ||
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
40 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
41 | 41 | ||
42 | PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) | 42 | PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) |
43 | : QWidget( 0x0 ) | 43 | : QWidget( 0x0 ) |
44 | , m_packman( pm ) | 44 | , m_packman( pm ) |
45 | , m_information( this ) | 45 | , m_information( this ) |
46 | , m_files( this ) | 46 | , m_files( this ) |
47 | { | 47 | { |
48 | // Initialize UI | 48 | // Initialize UI |
49 | if ( parent ) | 49 | if ( parent ) |
50 | parent->setCaption( package ); | 50 | parent->setCaption( package ); |
51 | 51 | ||
52 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); | 52 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); |
53 | 53 | ||
54 | Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this ); | 54 | Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this ); |
55 | layout->addWidget( tabWidget ); | 55 | layout->addWidget( tabWidget ); |
56 | 56 | ||
57 | // Information tab | 57 | // Information tab |
58 | QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) ); | 58 | QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) ); |
59 | m_information.reparent( tabWidget, QPoint( 0, 0 ) ); | 59 | m_information.reparent( tabWidget, QPoint( 0, 0 ) ); |
60 | m_information.setReadOnly( true ); | 60 | m_information.setReadOnly( true ); |
61 | tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); | 61 | tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); |
62 | 62 | ||
63 | // Retrive package information | 63 | // Retrive package information |
64 | m_package = m_packman->findPackage( package ); | 64 | m_package = m_packman->findPackage( package ); |
65 | if ( !m_package ) | 65 | if ( !m_package ) |
66 | { | 66 | { |
67 | m_information.setText( tr( "Unable to retrieve package information." ) ); | 67 | m_information.setText( tr( "Unable to retrieve package information." ) ); |
68 | return; | 68 | return; |
69 | } | 69 | } |
70 | 70 | ||
71 | // Display package information | 71 | // Display package information |
72 | if ( !m_package->information().isNull() ) | 72 | if ( !m_package->information().isNull() ) |
73 | m_information.setText( m_package->information() ); | 73 | m_information.setText( m_package->information() ); |
74 | else | 74 | else |
75 | { | 75 | { |
76 | // Package information is not cached, retrieve it | 76 | // Package information is not cached, retrieve it |
77 | QStringList list( package ); | 77 | QStringList list( package ); |
78 | m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true ); | 78 | m_packman->executeCommand( OPackage::Info, list, QString::null, this, SLOT(slotInfo(char*)), true ); |
79 | } | 79 | } |
80 | 80 | ||
81 | // Files tab (display only if package is installed) | 81 | // Files tab (display only if package is installed) |
82 | if ( !m_package->versionInstalled().isNull() ) | 82 | if ( !m_package->versionInstalled().isNull() ) |
83 | { | 83 | { |
84 | QWidget *filesWidget = new QWidget( tabWidget ); | 84 | QWidget *filesWidget = new QWidget( tabWidget ); |
85 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); | 85 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); |
86 | QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) ); | 86 | QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) ); |
87 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); | 87 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); |
88 | m_files.setReadOnly( true ); | 88 | m_files.setReadOnly( true ); |
89 | filesLayout->addWidget( &m_files ); | 89 | filesLayout->addWidget( &m_files ); |
90 | 90 | ||
91 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), | 91 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), |
92 | tr( "Retrieve file list" ), filesWidget ); | 92 | tr( "Retrieve file list" ), filesWidget ); |
93 | QWhatsThis::add( btn, tr( "Tap here to retrieve list of files contained in this package." ) ); | 93 | QWhatsThis::add( btn, tr( "Tap here to retrieve list of files contained in this package." ) ); |
94 | filesLayout->addWidget( btn ); | 94 | filesLayout->addWidget( btn ); |
95 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); | 95 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); |
96 | tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); | 96 | tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); |
97 | 97 | ||
98 | tabWidget->setCurrentTab( tr( "Information" ) ); | 98 | tabWidget->setCurrentTab( tr( "Information" ) ); |
99 | 99 | ||
100 | // If file list is already cached, display | 100 | // If file list is already cached, display |
101 | if ( !m_package->files().isNull() ) | 101 | if ( !m_package->files().isNull() ) |
102 | m_files.setText( m_package->files() ); | 102 | m_files.setText( m_package->files() ); |
103 | } | 103 | } |
104 | else | 104 | else |
105 | m_files.hide(); | 105 | m_files.hide(); |
106 | } | 106 | } |
107 | 107 | ||
108 | PackageInfoDlg::~PackageInfoDlg() | 108 | PackageInfoDlg::~PackageInfoDlg() |
109 | { | 109 | { |
110 | if ( !m_package ) | 110 | if ( !m_package ) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Cache package information | 113 | // Cache package information |
114 | if ( !m_information.text().isNull() ) | 114 | if ( !m_information.text().isNull() ) |
115 | m_package->setInformation( m_information.text() ); | 115 | m_package->setInformation( m_information.text() ); |
116 | 116 | ||
117 | // Cache package file list | 117 | // Cache package file list |
118 | if ( !m_files.text().isNull() ) | 118 | if ( !m_files.text().isNull() ) |
119 | m_package->setFiles( m_files.text() ); | 119 | m_package->setFiles( m_files.text() ); |
120 | } | 120 | } |
121 | 121 | ||
122 | void PackageInfoDlg::slotBtnFileScan() | 122 | void PackageInfoDlg::slotBtnFileScan() |
123 | { | 123 | { |
124 | m_files.clear(); | 124 | m_files.clear(); |
125 | 125 | ||
126 | QStringList list( m_package->name() ); | 126 | QStringList list( m_package->name() ); |
127 | m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true ); | 127 | m_packman->executeCommand( OPackage::Files, list, QString::null, this, SLOT(slotFiles(char*)), true ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void PackageInfoDlg::slotInfo( char *info ) | 130 | void PackageInfoDlg::slotInfo( char *info ) |
131 | { | 131 | { |
132 | m_information.append( info ); | 132 | m_information.append( info ); |
133 | } | 133 | } |
134 | 134 | ||
135 | void PackageInfoDlg::slotFiles( char *filelist ) | 135 | void PackageInfoDlg::slotFiles( char *filelist ) |
136 | { | 136 | { |
137 | QString str = filelist; | 137 | QString str = filelist; |
138 | 138 | ||
139 | // Skip first line of output ("Package xxx is installed...") | 139 | // Skip first line of output ("Package xxx is installed...") |
140 | if ( str.startsWith( "Package " ) ) | 140 | if ( str.startsWith( "Package " ) ) |
141 | str = str.right( str.length() - str.find( '\n' ) - 1 ); | 141 | str = str.right( str.length() - str.find( '\n' ) - 1 ); |
142 | 142 | ||
143 | m_files.append( str ); | 143 | m_files.append( str ); |
144 | } | 144 | } |