Diffstat (limited to 'noncore/settings/aqpkg/installdlgimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 132 |
1 files changed, 93 insertions, 39 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 | |||
@@ -16,28 +16,36 @@ | |||
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; |
@@ -59,7 +67,7 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d | |||
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 | ||
@@ -78,7 +86,7 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d | |||
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 | { |
@@ -87,29 +95,33 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d | |||
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 |
103 | } | 111 | type = tr( "(Upgrade)" ); |
112 | upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) ); | ||
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 ); |
@@ -119,12 +131,50 @@ InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent | |||
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 ) |
124 | { | 138 | { |
125 | showMaximized(); | 139 | QGridLayout *layout = new QGridLayout( this ); |
126 | bool ret = exec(); | 140 | layout->setSpacing( 4 ); |
141 | layout->setMargin( 4 ); | ||
127 | 142 | ||
128 | return ret; | 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 | ||
158 | { | ||
159 | destination = 0x0; | ||
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() ) ); | ||
175 | |||
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 | ||
@@ -146,19 +196,20 @@ void InstallDlgImpl :: optionsSelected() | |||
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 | } |
@@ -168,10 +219,9 @@ void InstallDlgImpl :: installSelected() | |||
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(); |
@@ -243,4 +293,5 @@ void InstallDlgImpl :: installSelected() | |||
243 | 293 | ||
244 | delete pIpkg; | 294 | delete pIpkg; |
295 | pIpkg = 0; | ||
245 | } | 296 | } |
246 | 297 | ||
@@ -248,6 +299,7 @@ void InstallDlgImpl :: installSelected() | |||
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 | } |
@@ -256,6 +308,7 @@ void InstallDlgImpl :: installSelected() | |||
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 | } |
@@ -285,7 +338,8 @@ void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | |||
285 | } | 338 | } |
286 | else | 339 | else |
287 | space = "Unknown"; | 340 | space = tr( "Unknown" ); |
288 | 341 | ||
289 | txtAvailableSpace->setText( space ); | 342 | if ( txtAvailableSpace ) |
343 | txtAvailableSpace->setText( space ); | ||
290 | } | 344 | } |
291 | 345 | ||