Diffstat (limited to 'noncore/settings/aqpkg/installdlgimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 128 |
1 files changed, 91 insertions, 37 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 75ce1a1..65aaa32 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -12,36 +12,44 @@ | |||
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <stdio.h> | ||
19 | |||
18 | #ifdef QWS | 20 | #ifdef QWS |
19 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
20 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/resource.h> | ||
21 | #include <qpe/storage.h> | 24 | #include <qpe/storage.h> |
22 | #endif | 25 | #endif |
23 | 26 | ||
24 | #include <qmultilineedit.h> | ||
25 | #include <qdialog.h> | ||
26 | #include <qcombobox.h> | ||
27 | #include <qcheckbox.h> | 27 | #include <qcheckbox.h> |
28 | #include <qpushbutton.h> | 28 | #include <qcombobox.h> |
29 | #include <qdialog.h> | ||
30 | #include <qgroupbox.h> | ||
31 | #include <qmultilineedit.h> | ||
29 | #include <qlabel.h> | 32 | #include <qlabel.h> |
30 | 33 | #include <qlayout.h> | |
34 | #include <qpushbutton.h> | ||
31 | 35 | ||
32 | #include "datamgr.h" | 36 | #include "datamgr.h" |
33 | #include "instoptionsimpl.h" | ||
34 | #include "destination.h" | 37 | #include "destination.h" |
38 | #include "instoptionsimpl.h" | ||
35 | #include "installdlgimpl.h" | 39 | #include "installdlgimpl.h" |
40 | #include "ipkg.h" | ||
36 | #include "utils.h" | 41 | #include "utils.h" |
37 | #include "global.h" | 42 | #include "global.h" |
38 | 43 | ||
39 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 44 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ) |
40 | : InstallDlg( parent, name, modal, fl ) | 45 | : QWidget( 0, 0, 0 ) |
41 | { | 46 | { |
47 | setCaption( title ); | ||
48 | init( TRUE ); | ||
49 | |||
42 | pIpkg = 0; | 50 | pIpkg = 0; |
43 | upgradePackages = false; | 51 | upgradePackages = false; |
44 | dataMgr = dataManager; | 52 | dataMgr = dataManager; |
45 | vector<Destination>::iterator dit; | 53 | vector<Destination>::iterator dit; |
46 | 54 | ||
47 | QString defaultDest = "root"; | 55 | QString defaultDest = "root"; |
@@ -55,15 +63,15 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d | |||
55 | #else | 63 | #else |
56 | flags = 0; | 64 | flags = 0; |
57 | #endif | 65 | #endif |
58 | 66 | ||
59 | // Output text is read only | 67 | // Output text is read only |
60 | output->setReadOnly( true ); | 68 | output->setReadOnly( true ); |
61 | QFont f( "helvetica" ); | 69 | //QFont f( "helvetica" ); |
62 | f.setPointSize( 10 ); | 70 | //f.setPointSize( 10 ); |
63 | output->setFont( f ); | 71 | //output->setFont( f ); |
64 | 72 | ||
65 | 73 | ||
66 | // setup destination data | 74 | // setup destination data |
67 | int defIndex = 0; | 75 | int defIndex = 0; |
68 | int i; | 76 | int i; |
69 | for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) | 77 | for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) |
@@ -74,61 +82,103 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d | |||
74 | } | 82 | } |
75 | 83 | ||
76 | destination->setCurrentItem( defIndex ); | 84 | destination->setCurrentItem( defIndex ); |
77 | 85 | ||
78 | vector<InstallData>::iterator it; | 86 | vector<InstallData>::iterator it; |
79 | // setup package data | 87 | // setup package data |
80 | QString remove = "Remove\n"; | 88 | QString remove = tr( "Remove\n" ); |
81 | QString install = "\nInstall\n"; | 89 | QString install = tr( "Install\n" ); |
82 | QString upgrade = "\nUpgrade\n"; | 90 | QString upgrade = tr( "Upgrade\n" ); |
83 | for ( it = packageList.begin() ; it != packageList.end() ; ++it ) | 91 | for ( it = packageList.begin() ; it != packageList.end() ; ++it ) |
84 | { | 92 | { |
85 | InstallData item = *it; | 93 | InstallData item = *it; |
86 | if ( item.option == "I" ) | 94 | if ( item.option == "I" ) |
87 | { | 95 | { |
88 | installList.push_back( item ); | 96 | installList.push_back( item ); |
89 | install += " " + item.packageName + "\n"; | 97 | install.append( QString( " %1\n" ).arg( item.packageName ) ); |
90 | } | 98 | } |
91 | else if ( item.option == "D" ) | 99 | else if ( item.option == "D" ) |
92 | { | 100 | { |
93 | removeList.push_back( item ); | 101 | removeList.push_back( item ); |
94 | remove += " " + item.packageName + "\n"; | 102 | remove.append( QString( " %1\n" ).arg( item.packageName ) ); |
95 | } | 103 | } |
96 | else if ( item.option == "U" || item.option == "R" ) | 104 | else if ( item.option == "U" || item.option == "R" ) |
97 | { | 105 | { |
98 | updateList.push_back( item ); | 106 | updateList.push_back( item ); |
99 | QString type = " (Upgrade)"; | 107 | QString type; |
100 | if ( item.option == "R" ) | 108 | if ( item.option == "R" ) |
101 | type = " (ReInstall)"; | 109 | type = tr( "(ReInstall)" ); |
102 | upgrade += " " + item.packageName + type + "\n"; | 110 | else |
111 | type = tr( "(Upgrade)" ); | ||
112 | upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) ); | ||
103 | } | 113 | } |
104 | } | 114 | } |
105 | 115 | ||
106 | output->setText( remove + install + upgrade ); | 116 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); |
107 | 117 | ||
108 | displayAvailableSpace( destination->currentText() ); | 118 | displayAvailableSpace( destination->currentText() ); |
109 | } | 119 | } |
110 | 120 | ||
111 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) | 121 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ) |
112 | : InstallDlg( parent, name, modal, fl ) | 122 | : QWidget( 0, 0, 0 ) |
113 | { | 123 | { |
124 | setCaption( title ); | ||
125 | init( FALSE ); | ||
114 | pIpkg = ipkg; | 126 | pIpkg = ipkg; |
115 | output->setText( initialText ); | 127 | output->setText( initialText ); |
116 | } | 128 | } |
117 | 129 | ||
118 | 130 | ||
119 | InstallDlgImpl::~InstallDlgImpl() | 131 | InstallDlgImpl::~InstallDlgImpl() |
120 | { | 132 | { |
133 | if ( pIpkg ) | ||
134 | delete pIpkg; | ||
121 | } | 135 | } |
122 | 136 | ||
123 | bool InstallDlgImpl :: showDlg() | 137 | void InstallDlgImpl :: init( bool displayextrainfo ) |
138 | { | ||
139 | QGridLayout *layout = new QGridLayout( this ); | ||
140 | layout->setSpacing( 4 ); | ||
141 | layout->setMargin( 4 ); | ||
142 | |||
143 | if ( displayextrainfo ) | ||
144 | { | ||
145 | QLabel *label = new QLabel( tr( "Destination" ), this ); | ||
146 | layout->addWidget( label, 0, 0 ); | ||
147 | destination = new QComboBox( FALSE, this ); | ||
148 | layout->addWidget( destination, 0, 1 ); | ||
149 | connect( destination, SIGNAL( highlighted( const QString & ) ), | ||
150 | this, SLOT( displayAvailableSpace( const QString & ) ) ); | ||
151 | |||
152 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); | ||
153 | layout->addWidget( label2, 1, 0 ); | ||
154 | txtAvailableSpace = new QLabel( "", this ); | ||
155 | layout->addWidget( txtAvailableSpace, 1, 1 ); | ||
156 | } | ||
157 | else | ||
124 | { | 158 | { |
125 | showMaximized(); | 159 | destination = 0x0; |
126 | bool ret = exec(); | 160 | txtAvailableSpace = 0x0; |
161 | } | ||
162 | |||
163 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | ||
164 | GroupBox2->layout()->setSpacing( 0 ); | ||
165 | GroupBox2->layout()->setMargin( 4 ); | ||
166 | |||
167 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); | ||
168 | output = new QMultiLineEdit( GroupBox2 ); | ||
169 | GroupBox2Layout->addWidget( output ); | ||
170 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); | ||
171 | |||
172 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); | ||
173 | layout->addWidget( btnInstall, 3, 0 ); | ||
174 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); | ||
127 | 175 | ||
128 | return ret; | 176 | btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this ); |
177 | layout->addWidget( btnOptions, 3, 1 ); | ||
178 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); | ||
129 | } | 179 | } |
130 | 180 | ||
131 | void InstallDlgImpl :: optionsSelected() | 181 | void InstallDlgImpl :: optionsSelected() |
132 | { | 182 | { |
133 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); | 183 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); |
134 | opt.exec(); | 184 | opt.exec(); |
@@ -142,40 +192,40 @@ void InstallDlgImpl :: optionsSelected() | |||
142 | cfg.writeEntry( "installFlags", flags ); | 192 | cfg.writeEntry( "installFlags", flags ); |
143 | #endif | 193 | #endif |
144 | } | 194 | } |
145 | 195 | ||
146 | void InstallDlgImpl :: installSelected() | 196 | void InstallDlgImpl :: installSelected() |
147 | { | 197 | { |
148 | if ( btnInstall->text() == "Abort" ) | 198 | if ( btnInstall->text() == tr( "Abort" ) ) |
149 | { | 199 | { |
150 | if ( pIpkg ) | 200 | if ( pIpkg ) |
151 | { | 201 | { |
152 | displayText( "\n**** User Clicked ABORT ***" ); | 202 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); |
153 | pIpkg->abort(); | 203 | pIpkg->abort(); |
154 | displayText( "**** Process Aborted ****" ); | 204 | displayText( tr( "**** Process Aborted ****" ) ); |
155 | } | 205 | } |
156 | 206 | ||
157 | btnInstall->setText( tr( "Close" ) ); | 207 | btnInstall->setText( tr( "Close" ) ); |
208 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | ||
158 | return; | 209 | return; |
159 | } | 210 | } |
160 | else if ( btnInstall->text() == tr( "Close" ) ) | 211 | else if ( btnInstall->text() == tr( "Close" ) ) |
161 | { | 212 | { |
162 | done( 1 ); | 213 | emit reloadData( this ); |
163 | return; | 214 | return; |
164 | } | 215 | } |
165 | 216 | ||
166 | // Disable buttons | 217 | // Disable buttons |
167 | btnOptions->setEnabled( false ); | 218 | btnOptions->setEnabled( false ); |
168 | // btnInstall->setEnabled( false ); | 219 | // btnInstall->setEnabled( false ); |
169 | 220 | ||
170 | btnInstall->setText( "Abort" ); | 221 | btnInstall->setText( tr( "Abort" ) ); |
171 | 222 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); | |
172 | if ( pIpkg ) | 223 | if ( pIpkg ) |
173 | { | 224 | { |
174 | output->setText( "" ); | 225 | output->setText( "" ); |
175 | |||
176 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 226 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
177 | pIpkg->runIpkg(); | 227 | pIpkg->runIpkg(); |
178 | } | 228 | } |
179 | else | 229 | else |
180 | { | 230 | { |
181 | output->setText( "" ); | 231 | output->setText( "" ); |
@@ -239,27 +289,30 @@ void InstallDlgImpl :: installSelected() | |||
239 | tmpFlags |= MAKE_LINKS; | 289 | tmpFlags |= MAKE_LINKS; |
240 | pIpkg->setFlags( tmpFlags ); | 290 | pIpkg->setFlags( tmpFlags ); |
241 | pIpkg->runIpkg(); | 291 | pIpkg->runIpkg(); |
242 | } | 292 | } |
243 | 293 | ||
244 | delete pIpkg; | 294 | delete pIpkg; |
295 | pIpkg = 0; | ||
245 | } | 296 | } |
246 | 297 | ||
247 | btnOptions->setEnabled( true ); | 298 | btnOptions->setEnabled( true ); |
248 | // btnInstall->setEnabled( true ); | 299 | // btnInstall->setEnabled( true ); |
249 | btnInstall->setText( tr( "Close" ) ); | 300 | btnInstall->setText( tr( "Close" ) ); |
301 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | ||
250 | 302 | ||
251 | if ( destination->currentText() != 0 && destination->currentText() != "" ) | 303 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) |
252 | displayAvailableSpace( destination->currentText() ); | 304 | displayAvailableSpace( destination->currentText() ); |
253 | } | 305 | } |
254 | 306 | ||
255 | 307 | ||
256 | void InstallDlgImpl :: displayText(const QString &text ) | 308 | void InstallDlgImpl :: displayText(const QString &text ) |
257 | { | 309 | { |
258 | QString t = output->text() + "\n" + text; | 310 | //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) ); |
259 | output->setText( t ); | 311 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); |
312 | output->setText( newtext ); | ||
260 | output->setCursorPosition( output->numLines(), 0 ); | 313 | output->setCursorPosition( output->numLines(), 0 ); |
261 | } | 314 | } |
262 | 315 | ||
263 | 316 | ||
264 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | 317 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) |
265 | { | 318 | { |
@@ -281,11 +334,12 @@ void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | |||
281 | long avail = availBlocks * mult / div; | 334 | long avail = availBlocks * mult / div; |
282 | // long used = total - avail; | 335 | // long used = total - avail; |
283 | 336 | ||
284 | space.sprintf( "%ld Kb", avail ); | 337 | space.sprintf( "%ld Kb", avail ); |
285 | } | 338 | } |
286 | else | 339 | else |
287 | space = "Unknown"; | 340 | space = tr( "Unknown" ); |
288 | 341 | ||
342 | if ( txtAvailableSpace ) | ||
289 | txtAvailableSpace->setText( space ); | 343 | txtAvailableSpace->setText( space ); |
290 | } | 344 | } |
291 | 345 | ||