summaryrefslogtreecommitdiff
authordrw <drw>2004-11-18 15:49:02 (UTC)
committer drw <drw>2004-11-18 15:49:02 (UTC)
commit7ac32658ba09d8456cc75e5cf80707caa616848b (patch) (unidiff)
tree56bae9b9c75eae7a9096013830fe98d28a4de0ed
parent718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40 (diff)
downloadopie-7ac32658ba09d8456cc75e5cf80707caa616848b.zip
opie-7ac32658ba09d8456cc75e5cf80707caa616848b.tar.gz
opie-7ac32658ba09d8456cc75e5cf80707caa616848b.tar.bz2
UI tweaks for Installation dialog - 1. Show destination selection only when installing apps, 2. Update available disk space after each package is processed, 3. Disable destination selection once start button has been clicked
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp61
-rw-r--r--noncore/settings/packagemanager/installdlg.h14
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp2
3 files changed, 63 insertions, 14 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 945dfed..781f8f5 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -1,297 +1,336 @@
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 "installdlg.h" 30#include "installdlg.h"
31 31
32#include <opie2/ofiledialog.h> 32#include <opie2/ofiledialog.h>
33#include <opie2/oprocess.h>
33 34
34#include <qpe/fileselector.h> 35#include <qpe/fileselector.h>
35#include <qpe/resource.h> 36#include <qpe/resource.h>
36#include <qpe/storage.h> 37#include <qpe/storage.h>
37 38
38#include <qapplication.h> 39#include <qapplication.h>
39#include <qcombobox.h> 40#include <qcombobox.h>
40#include <qfileinfo.h> 41#include <qfileinfo.h>
41#include <qgroupbox.h> 42#include <qgroupbox.h>
42#include <qlabel.h> 43#include <qlabel.h>
43#include <qlayout.h> 44#include <qlayout.h>
44#include <qmap.h> 45#include <qmap.h>
45#include <qmultilineedit.h> 46#include <qmultilineedit.h>
46#include <qpushbutton.h> 47#include <qpushbutton.h>
47 48
48#include <sys/vfs.h> 49#include <sys/vfs.h>
49 50
50#include "opackagemanager.h" 51#include "opackagemanager.h"
51 52
52InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, 53InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo,
53 OPackage::Command command1, const QStringList &packages1, 54 OPackage::Command command1, const QStringList &packages1,
54 OPackage::Command command2, const QStringList &packages2, 55 OPackage::Command command2, const QStringList &packages2,
55 OPackage::Command command3, const QStringList &packages3 ) 56 OPackage::Command command3, const QStringList &packages3 )
56 : QWidget( 0x0 ) 57 : QWidget( 0x0 )
57 , m_packman( pm ) 58 , m_packman( pm )
58 , m_numCommands( 0 ) 59 , m_numCommands( 0 )
59 , m_currCommand( 0 ) 60 , m_currCommand( 0 )
61 , m_destItem( 0x0 )
60{ 62{
61 // Save command/package list information 63 // Save command/package list information
62 if ( command1 != OPackage::NotDefined ) 64 if ( command1 != OPackage::NotDefined )
63 { 65 {
64 m_command[ m_numCommands ] = command1; 66 m_command[ m_numCommands ] = command1;
65 m_packages[ m_numCommands ] = packages1; 67 m_packages[ m_numCommands ] = packages1;
66 ++m_numCommands; 68 ++m_numCommands;
67 } 69 }
68 if ( command2 != OPackage::NotDefined ) 70 if ( command2 != OPackage::NotDefined )
69 { 71 {
70 m_command[ m_numCommands ] = command2; 72 m_command[ m_numCommands ] = command2;
71 m_packages[ m_numCommands ] = packages2; 73 m_packages[ m_numCommands ] = packages2;
72 ++m_numCommands; 74 ++m_numCommands;
73 } 75 }
74 if ( command3 != OPackage::NotDefined ) 76 if ( command3 != OPackage::NotDefined )
75 { 77 {
76 m_command[ m_numCommands ] = command3; 78 m_command[ m_numCommands ] = command3;
77 m_packages[ m_numCommands ] = packages3; 79 m_packages[ m_numCommands ] = packages3;
78 ++m_numCommands; 80 ++m_numCommands;
79 } 81 }
80 82
81 // Initialize UI 83 // Initialize UI
82 if ( parent ) 84 if ( parent )
83 parent->setCaption( caption ); 85 parent->setCaption( caption );
84 86
85 QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); 87 QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 );
86 88
87 if ( showDestInfo ) 89 if ( showDestInfo )
88 { 90 {
89 QLabel *label = new QLabel( tr( "Destination" ), this ); 91 QLabel *label = new QLabel( tr( "Destination" ), this );
90 layout->addWidget( label, 0, 0 ); 92 layout->addWidget( label, 0, 0 );
91 m_destination = new QComboBox( this ); 93 m_destination = new QComboBox( this );
92 m_destination->insertStringList( m_packman->destinations() ); 94 m_destination->insertStringList( m_packman->destinations() );
93 layout->addWidget( m_destination, 0, 1 ); 95 layout->addWidget( m_destination, 0, 1 );
94 connect( m_destination, SIGNAL(highlighted(const QString&)), 96 connect( m_destination, SIGNAL(highlighted(const QString&)),
95 this, SLOT(slotDisplayAvailSpace(const QString&)) ); 97 this, SLOT(slotDisplayAvailSpace(const QString&)) );
96 98
97 label = new QLabel( tr( "Space Avail" ), this ); 99 label = new QLabel( tr( "Space Avail" ), this );
98 layout->addWidget( label, 1, 0 ); 100 layout->addWidget( label, 1, 0 );
99 m_availSpace = new QLabel( this ); 101 m_availSpace = new QLabel( this );
100 layout->addWidget( m_availSpace, 1, 1 ); 102 layout->addWidget( m_availSpace, 1, 1 );
101 103
102 // TODO - select correct destination 104 // TODO - select correct destination
103 slotDisplayAvailSpace( m_destination->currentText() ); 105 slotDisplayAvailSpace( m_destination->currentText() );
104 } 106 }
105 else 107 else
106 { 108 {
107 m_destination = 0x0; 109 m_destination = 0x0;
108 m_availSpace = 0x0; 110 m_availSpace = 0x0;
109 } 111 }
110 112
111 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 113 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
112 groupBox->layout()->setSpacing( 0 ); 114 groupBox->layout()->setSpacing( 0 );
113 groupBox->layout()->setMargin( 4 ); 115 groupBox->layout()->setMargin( 4 );
114 116
115 QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); 117 QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() );
116 m_output = new QMultiLineEdit( groupBox ); 118 m_output = new QMultiLineEdit( groupBox );
117 m_output->setReadOnly( true ); 119 m_output->setReadOnly( true );
118 groupBoxLayout->addWidget( m_output ); 120 groupBoxLayout->addWidget( m_output );
119 layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); 121 layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 );
120 122
121 m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); 123 m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this );
122 layout->addWidget( m_btnStart, 3, 0 ); 124 layout->addWidget( m_btnStart, 3, 0 );
123 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); 125 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) );
124 126
125 m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); 127 m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
126 layout->addWidget( m_btnOptions, 3, 1 ); 128 layout->addWidget( m_btnOptions, 3, 1 );
127 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); 129 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) );
128 130
129 // Display packages being acted upon in output widget 131 // Display packages being acted upon in output widget
130 for( int i = 0; i < m_numCommands; i++ ) 132 for( int i = 0; i < m_numCommands; i++ )
131 { 133 {
132 if ( !m_packages[ i ].isEmpty() ) 134 if ( !m_packages[ i ].isEmpty() )
133 { 135 {
134 QString lineStr = tr( "Packages to " ); 136 QString lineStr = tr( "Packages to " );
135 137
136 switch( m_command[ i ] ) 138 switch( m_command[ i ] )
137 { 139 {
138 case OPackage::Install : lineStr.append( tr( "install" ) ); 140 case OPackage::Install : lineStr.append( tr( "install" ) );
139 break; 141 break;
140 case OPackage::Remove : lineStr.append( tr( "remove" ) ); 142 case OPackage::Remove : lineStr.append( tr( "remove" ) );
141 break; 143 break;
142 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); 144 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) );
143 break; 145 break;
144 case OPackage::Download : lineStr.append( tr( "download" ) ); 146 case OPackage::Download : lineStr.append( tr( "download" ) );
145 break; 147 break;
146 default : 148 default :
147 break; 149 break;
148 }; 150 };
149 lineStr.append( ":\n" ); 151 lineStr.append( ":\n" );
150 152
151 QStringList tmpPackage = m_packages[ i ]; 153 QStringList tmpPackage = m_packages[ i ];
152 for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it ) 154 for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it )
153 { 155 {
154 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); 156 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) );
155 } 157 }
156 158
157 m_output->append( lineStr ); 159 m_output->append( lineStr );
158 } 160 }
159 } 161 }
160 162
161 m_output->append( tr( "Press the start button to begin.\n" ) ); 163 m_output->append( tr( "Press the start button to begin.\n" ) );
162 m_output->setCursorPosition( m_output->numLines(), 0 ); 164 m_output->setCursorPosition( m_output->numLines(), 0 );
163 165
164} 166}
165 167
166InstallDlg::~InstallDlg()
167{
168}
169
170void InstallDlg::slotDisplayAvailSpace( const QString &destination ) 168void InstallDlg::slotDisplayAvailSpace( const QString &destination )
171{ 169{
172 // If available space is not displayed, exit 170 // If available space is not displayed, exit
173 if ( !m_availSpace ) 171 if ( !m_availSpace )
174 return; 172 return;
175 173
176 QString space = tr( "Unknown" ); 174 QString space = tr( "Unknown" );
177 175
178 // Get destination 176 // Get destination
179 OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); 177 if ( !destination.isNull() )
178 m_destItem = m_packman->findConfItem( OConfItem::Destination, destination );
180 179
181 if ( dest ) 180 if ( m_destItem )
182 { 181 {
183 // Calculate available space 182 // Calculate available space
184 struct statfs fs; 183 struct statfs fs;
185 if ( !statfs( dest->value(), &fs ) ) 184 if ( !statfs( m_destItem->value(), &fs ) )
186 { 185 {
187 long mult = fs.f_bsize / 1024; 186 long mult = fs.f_bsize / 1024;
188 long div = 1024 / fs.f_bsize; 187 long div = 1024 / fs.f_bsize;
189 188
190 if ( !mult ) mult = 1; 189 if ( !mult ) mult = 1;
191 if ( !div ) div = 1; 190 if ( !div ) div = 1;
192 long avail = fs.f_bavail * mult / div; 191 long avail = fs.f_bavail * mult / div;
193 192
194 space = tr( "%1 Kb" ).arg( avail ); 193 space = tr( "%1 Kb" ).arg( avail );
195 } 194 }
196 } 195 }
197 196
198 // Display available space 197 // Display available space
199 m_availSpace->setText( space ); 198 m_availSpace->setText( space );
200} 199}
201 200
202void InstallDlg::slotBtnStart() 201void InstallDlg::slotBtnStart()
203{ 202{
204 QString btnText = m_btnStart->text(); 203 QString btnText = m_btnStart->text();
205 if ( btnText == tr( "Abort" ) ) 204 if ( btnText == tr( "Abort" ) )
206 { 205 {
207 // Prevent unexecuted commands from executing 206 // Prevent unexecuted commands from executing
208 m_currCommand = 999; 207 m_currCommand = 999;
209 208
210 // Allow user to close dialog 209 // Allow user to close dialog
211 m_btnStart->setText( tr( "Close" ) ); 210 m_btnStart->setText( tr( "Close" ) );
212 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 211 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
213 return; 212 return;
214 } 213 }
215 else if ( btnText == tr( "Close" ) ) 214 else if ( btnText == tr( "Close" ) )
216 { 215 {
217 // TODO - force reload of package data 216 // TODO - force reload of package data
218 emit closeInstallDlg(); 217 emit closeInstallDlg();
219 return; 218 return;
220 } 219 }
221 220
222 // Start was clicked, start executing 221 // Start was clicked, start executing
222 QString dest;
223 if ( m_destination )
224 {
225 dest = m_destination->currentText();
226 m_destination->setEnabled( false );
227 }
228
223 m_btnOptions->setEnabled( false ); 229 m_btnOptions->setEnabled( false );
224 if ( m_numCommands > 1 ) 230 if ( m_numCommands > 1 )
225 { 231 {
226 m_btnStart->setText( tr( "Abort" ) ); 232 m_btnStart->setText( tr( "Abort" ) );
227 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); 233 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
228 } 234 }
229 else 235 else
230 { 236 {
231 m_btnStart->setEnabled( false ); 237 m_btnStart->setEnabled( false );
232 } 238 }
233 239
234 QString dest;
235 if ( m_destination )
236 dest = m_destination->currentText();
237
238 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) 240 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
239 { 241 {
240 // Execute next command 242 // Execute next command
241 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, 243 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
242 this, SLOT(slotOutput(char*)), true ); 244 this, SLOT(slotOutput(char*)), true );
243 } 245 }
246 slotProcessDone(0l);
247
248 // Get destination
249/*
250 if ( dest == "root" )
251 {
252 slotProcessDone(0l);
253 return;
254 }
255
256 m_destItem = m_packman->findConfItem( OConfItem::Destination, dest );
257 if ( m_destItem )
258 {
259 QString path = m_destItem->value();
260 Opie::Core::OProcess *process = new Opie::Core::OProcess( this, "ipkg-link process" );
261 connect( process, SIGNAL(processExited(Opie::Core::OProcess*)),
262 this, SLOT(slotProcessDone(Opie::Core::OProcess*)) );
263
264 *process << "ipkg-link" << "mount" << path;
265 if ( !process->start( Opie::Core::OProcess::NotifyOnExit,
266 Opie::Core::OProcess::NoCommunication ) )
267 slotProcessDone( 0l );
268 m_output->append( tr( "Starting ipkg-link to link installed applications." ) );
269 m_output->setCursorPosition( m_output->numLines(), 0 );
270 }
271*/
272}
273
274void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc )
275{
276 delete proc;
277
278 m_output->append( tr( "The package linking is done." ) );
279 m_output->setCursorPosition( m_output->numLines(), 0 );
244 280
245 // All commands executed, allow user to close dialog 281 // All commands executed, allow user to close dialog
246 m_btnStart->setEnabled( true ); 282 m_btnStart->setEnabled( true );
247 m_btnStart->setText( tr( "Close" ) ); 283 m_btnStart->setText( tr( "Close" ) );
248 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 284 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
249 285
250 m_btnOptions->setEnabled( true ); 286 m_btnOptions->setEnabled( true );
251 m_btnOptions->setText( tr( "Save output" ) ); 287 m_btnOptions->setText( tr( "Save output" ) );
252 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); 288 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
253} 289}
254 290
255void InstallDlg::slotBtnOptions() 291void InstallDlg::slotBtnOptions()
256{ 292{
257 QString btnText = m_btnOptions->text(); 293 QString btnText = m_btnOptions->text();
258 if ( btnText == tr( "Options" ) ) 294 if ( btnText == tr( "Options" ) )
259 { 295 {
260 // Display configuration dialog (only options tab is enabled) 296 // Display configuration dialog (only options tab is enabled)
261 m_packman->configureDlg( true ); 297 m_packman->configureDlg( true );
262 return; 298 return;
263 } 299 }
264 300
265 // Save output was clicked 301 // Save output was clicked
266 QMap<QString, QStringList> map; 302 QMap<QString, QStringList> map;
267 map.insert( tr( "All" ), QStringList() ); 303 map.insert( tr( "All" ), QStringList() );
268 QStringList text; 304 QStringList text;
269 text << "text/*"; 305 text << "text/*";
270 map.insert(tr( "Text" ), text ); 306 map.insert(tr( "Text" ), text );
271 text << "*"; 307 text << "*";
272 map.insert( tr( "All" ), text ); 308 map.insert( tr( "All" ), text );
273 309
274 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); 310 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
275 if( !filename.isEmpty() ) 311 if( !filename.isEmpty() )
276 { 312 {
277 QString currentFileName = QFileInfo( filename ).fileName(); 313 QString currentFileName = QFileInfo( filename ).fileName();
278 DocLnk doc; 314 DocLnk doc;
279 doc.setType( "text/plain" ); 315 doc.setType( "text/plain" );
280 doc.setFile( filename ); 316 doc.setFile( filename );
281 doc.setName( currentFileName ); 317 doc.setName( currentFileName );
282 FileManager fm; 318 FileManager fm;
283 fm.saveFile( doc, m_output->text() ); 319 fm.saveFile( doc, m_output->text() );
284 } 320 }
285} 321}
286 322
287void InstallDlg::slotOutput( char *msg ) 323void InstallDlg::slotOutput( char *msg )
288{ 324{
289 // Allow processing of other events 325 // Allow processing of other events
290 qApp->processEvents(); 326 qApp->processEvents();
291 327
292 QString lineStr = msg; 328 QString lineStr = msg;
293 if ( lineStr[lineStr.length()-1] == '\n' ) 329 if ( lineStr[lineStr.length()-1] == '\n' )
294 lineStr.truncate( lineStr.length() - 1 ); 330 lineStr.truncate( lineStr.length() - 1 );
295 m_output->append( lineStr ); 331 m_output->append( lineStr );
296 m_output->setCursorPosition( m_output->numLines(), 0 ); 332 m_output->setCursorPosition( m_output->numLines(), 0 );
333
334 // Update available space
335 slotDisplayAvailSpace( QString::null );
297} 336}
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h
index cddc911..f45c17c 100644
--- a/noncore/settings/packagemanager/installdlg.h
+++ b/noncore/settings/packagemanager/installdlg.h
@@ -1,88 +1,98 @@
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#ifndef INSTALLDLG_H 30#ifndef INSTALLDLG_H
31#define INSTALLDLG_H 31#define INSTALLDLG_H
32 32
33#include <qwidget.h> 33#include <qwidget.h>
34 34
35#include "opackage.h" 35#include "opackage.h"
36 36
37class QComboBox; 37class QComboBox;
38class QLabel; 38class QLabel;
39class QMultiLineEdit; 39class QMultiLineEdit;
40class QPushButton; 40class QPushButton;
41 41
42class OConfItem;
42class OPackageManager; 43class OPackageManager;
43 44
45namespace Opie
46{
47 namespace Core
48 {
49 class OProcess;
50 }
51}
52
44class InstallDlg : public QWidget 53class InstallDlg : public QWidget
45{ 54{
46 Q_OBJECT 55 Q_OBJECT
47 56
48public: 57public:
49 InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null, 58 InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null,
50 bool showDestInfo = true, 59 bool showDestInfo = true,
51 OPackage::Command command1 = OPackage::NotDefined, 60 OPackage::Command command1 = OPackage::NotDefined,
52 const QStringList &packages1 = QStringList(), 61 const QStringList &packages1 = QStringList(),
53 OPackage::Command command2 = OPackage::NotDefined, 62 OPackage::Command command2 = OPackage::NotDefined,
54 const QStringList &packages2 = QStringList(), 63 const QStringList &packages2 = QStringList(),
55 OPackage::Command command3 = OPackage::NotDefined, 64 OPackage::Command command3 = OPackage::NotDefined,
56 const QStringList &packages3 = QStringList() ); 65 const QStringList &packages3 = QStringList() );
57 ~InstallDlg();
58 66
59private: 67private:
60 OPackageManager *m_packman; // Pointer to application instance of package manager 68 OPackageManager *m_packman; // Pointer to application instance of package manager
61 69
62 // UI controls 70 // UI controls
63 QComboBox *m_destination; // Destination selection list 71 QComboBox *m_destination; // Destination selection list
64 QLabel *m_availSpace; // Text label to display available space on selected destination 72 QLabel *m_availSpace; // Text label to display available space on selected destination
65 QMultiLineEdit *m_output; // Multi-line edit to display status 73 QMultiLineEdit *m_output; // Multi-line edit to display status
66 QPushButton *m_btnStart; // Start/abort/close button 74 QPushButton *m_btnStart; // Start/abort/close button
67 QPushButton *m_btnOptions; // Installation options button 75 QPushButton *m_btnOptions; // Installation options button
68 76
69 // Commands and packages to execute 77 // Commands and packages to execute
70 int m_numCommands; // Number of commands to be executed 78 int m_numCommands; // Number of commands to be executed
71 int m_currCommand; // Number of currently executing command 79 int m_currCommand; // Number of currently executing command
72 OPackage::Command m_command[3]; // List of commands to be executed 80 OPackage::Command m_command[3]; // List of commands to be executed
73 QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) 81 QStringList m_packages[3]; // Lists of package names associated to commands (m_command[])
82 OConfItem *m_destItem; // Pointer to destination for package installation
74 83
75private slots: 84private slots:
76 // UI control slots 85 // UI control slots
77 void slotDisplayAvailSpace( const QString &destination ); 86 void slotDisplayAvailSpace( const QString &destination );
78 void slotBtnStart(); 87 void slotBtnStart();
79 void slotBtnOptions(); 88 void slotBtnOptions();
80 89 void slotProcessDone( Opie::Core::OProcess *proc );
90
81 // Execution slots 91 // Execution slots
82 void slotOutput( char *msg ); 92 void slotOutput( char *msg );
83 93
84signals: 94signals:
85 void closeInstallDlg(); 95 void closeInstallDlg();
86}; 96};
87 97
88#endif 98#endif
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 5e15874..459a75b 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -438,193 +438,193 @@ void MainWindow::slotDownload()
438 else 438 else
439 return; // user entered nothing or pressed cancel 439 return; // user entered nothing or pressed cancel
440 440
441 // Store download directory in config file 441 // Store download directory in config file
442 m_config.writeEntry( "DownloadDir", workingDir ); 442 m_config.writeEntry( "DownloadDir", workingDir );
443 443
444 // Get starting directory 444 // Get starting directory
445 QDir::setCurrent( workingDir ); 445 QDir::setCurrent( workingDir );
446 446
447 // Create package manager output widget 447 // Create package manager output widget
448 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, 448 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
449 OPackage::Download, workingPackages ); 449 OPackage::Download, workingPackages );
450 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 450 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
451 451
452 // Display widget 452 // Display widget
453 m_widgetStack.addWidget( dlg, 3 ); 453 m_widgetStack.addWidget( dlg, 3 );
454 m_widgetStack.raiseWidget( dlg ); 454 m_widgetStack.raiseWidget( dlg );
455 } 455 }
456} 456}
457 457
458void MainWindow::slotApply() 458void MainWindow::slotApply()
459{ 459{
460 QStringList removeList; 460 QStringList removeList;
461 QStringList installList; 461 QStringList installList;
462 QStringList upgradeList; 462 QStringList upgradeList;
463 463
464 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 464 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
465 item != 0 ; 465 item != 0 ;
466 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 466 item = static_cast<QCheckListItem *>(item->nextSibling()) )
467 { 467 {
468 if ( item->isOn() ) 468 if ( item->isOn() )
469 { 469 {
470 OPackage *package = m_packman.findPackage( item->text() ); 470 OPackage *package = m_packman.findPackage( item->text() );
471 if ( package ) 471 if ( package )
472 { 472 {
473 if ( !package->versionInstalled().isNull() ) 473 if ( !package->versionInstalled().isNull() )
474 { 474 {
475 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) 475 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
476 { 476 {
477 // Remove/upgrade package 477 // Remove/upgrade package
478 int answer = PromptDlg::ask( tr( "Remove or upgrade" ), 478 int answer = PromptDlg::ask( tr( "Remove or upgrade" ),
479 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), 479 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ),
480 tr( "Remove" ), tr( "Upgrade" ), this ); 480 tr( "Remove" ), tr( "Upgrade" ), this );
481 if ( answer == 1 ) // Remove 481 if ( answer == 1 ) // Remove
482 { 482 {
483 removeList.append( item->text() ); 483 removeList.append( item->text() );
484 } 484 }
485 else if ( answer == 2 ) // Upgrade 485 else if ( answer == 2 ) // Upgrade
486 { 486 {
487 upgradeList.append( item->text() ); 487 upgradeList.append( item->text() );
488 } 488 }
489 } 489 }
490 else 490 else
491 { 491 {
492 // Remove/reinstall package 492 // Remove/reinstall package
493 int answer = PromptDlg::ask( tr( "Remove or reinstall" ), 493 int answer = PromptDlg::ask( tr( "Remove or reinstall" ),
494 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), 494 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ),
495 tr( "Remove" ), tr( "Reinstall" ), this ); 495 tr( "Remove" ), tr( "Reinstall" ), this );
496 if ( answer == 1 ) // Remove 496 if ( answer == 1 ) // Remove
497 { 497 {
498 removeList.append( item->text() ); 498 removeList.append( item->text() );
499 } 499 }
500 else if ( answer == 2 ) // Reinstall 500 else if ( answer == 2 ) // Reinstall
501 { 501 {
502 installList.append( item->text() ); 502 installList.append( item->text() );
503 } 503 }
504 } 504 }
505 } 505 }
506 else 506 else
507 { 507 {
508 // Install package 508 // Install package
509 installList.append( item->text() ); 509 installList.append( item->text() );
510 } 510 }
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 // If nothing is selected, display message and exit 515 // If nothing is selected, display message and exit
516 if ( removeList.isEmpty() && installList.isEmpty() && upgradeList.isEmpty() ) 516 if ( removeList.isEmpty() && installList.isEmpty() && upgradeList.isEmpty() )
517 { 517 {
518 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); 518 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
519 return; 519 return;
520 } 520 }
521 521
522 // Send command only if there are packages to process 522 // Send command only if there are packages to process
523 OPackage::Command removeCmd = OPackage::NotDefined; 523 OPackage::Command removeCmd = OPackage::NotDefined;
524 if ( !removeList.isEmpty() ) 524 if ( !removeList.isEmpty() )
525 removeCmd = OPackage::Remove; 525 removeCmd = OPackage::Remove;
526 OPackage::Command installCmd = OPackage::NotDefined; 526 OPackage::Command installCmd = OPackage::NotDefined;
527 if ( !installList.isEmpty() ) 527 if ( !installList.isEmpty() )
528 installCmd = OPackage::Install; 528 installCmd = OPackage::Install;
529 OPackage::Command upgradeCmd = OPackage::NotDefined; 529 OPackage::Command upgradeCmd = OPackage::NotDefined;
530 if ( !upgradeList.isEmpty() ) 530 if ( !upgradeList.isEmpty() )
531 upgradeCmd = OPackage::Upgrade; 531 upgradeCmd = OPackage::Upgrade;
532 532
533 // Create package manager output widget 533 // Create package manager output widget
534 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, 534 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), !installList.isEmpty(),
535 removeCmd, removeList, 535 removeCmd, removeList,
536 installCmd, installList, 536 installCmd, installList,
537 upgradeCmd, upgradeList ); 537 upgradeCmd, upgradeList );
538 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 538 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
539 539
540 // Display widget 540 // Display widget
541 m_widgetStack.addWidget( dlg, 3 ); 541 m_widgetStack.addWidget( dlg, 3 );
542 m_widgetStack.raiseWidget( dlg ); 542 m_widgetStack.raiseWidget( dlg );
543} 543}
544 544
545void MainWindow::slotInstallLocal() 545void MainWindow::slotInstallLocal()
546{ 546{
547 // Display file open dialog with only package files 547 // Display file open dialog with only package files
548 MimeTypes type; 548 MimeTypes type;
549 QStringList packages; 549 QStringList packages;
550 packages << "application/ipkg"; 550 packages << "application/ipkg";
551 type.insert( tr( "Application Packages" ), packages ); 551 type.insert( tr( "Application Packages" ), packages );
552 QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, 552 QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL,
553 "/", QString::null, type ); 553 "/", QString::null, type );
554 if ( !package.isNull() ) 554 if ( !package.isNull() )
555 installLocalPackage( package ); 555 installLocalPackage( package );
556} 556}
557 557
558void MainWindow::slotCloseDlg() 558void MainWindow::slotCloseDlg()
559{ 559{
560 // Close install dialog 560 // Close install dialog
561 delete m_widgetStack.visibleWidget(); 561 delete m_widgetStack.visibleWidget();
562 562
563 // Reload package list 563 // Reload package list
564 initPackageInfo(); 564 initPackageInfo();
565 565
566 // Update Opie launcher links 566 // Update Opie launcher links
567 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 567 QCopEnvelope e("QPE/System", "linkChanged(QString)");
568 QString lf = QString::null; 568 QString lf = QString::null;
569 e << lf; 569 e << lf;
570 570
571 // Reapply any filters previously set 571 // Reapply any filters previously set
572 if ( m_actionShowNotInstalled->isOn() ) 572 if ( m_actionShowNotInstalled->isOn() )
573 slotShowNotInstalled(); 573 slotShowNotInstalled();
574 else if ( m_actionShowInstalled->isOn() ) 574 else if ( m_actionShowInstalled->isOn() )
575 slotShowInstalled(); 575 slotShowInstalled();
576 else if ( m_actionShowUpdated->isOn() ) 576 else if ( m_actionShowUpdated->isOn() )
577 slotShowUpdated(); 577 slotShowUpdated();
578 else if ( m_actionFilter->isOn() ) 578 else if ( m_actionFilter->isOn() )
579 slotFilter( true ); 579 slotFilter( true );
580} 580}
581 581
582void MainWindow::slotConfigure() 582void MainWindow::slotConfigure()
583{ 583{
584 if ( m_packman.configureDlg( false ) ) 584 if ( m_packman.configureDlg( false ) )
585 { 585 {
586 if ( PromptDlg::ask( tr( "Config updated" ), 586 if ( PromptDlg::ask( tr( "Config updated" ),
587 tr( "The configuration has been updated. Do you want to update server and package information now?" ), 587 tr( "The configuration has been updated. Do you want to update server and package information now?" ),
588 tr( "Yes" ), tr( "No" ), this ) == 1 ) 588 tr( "Yes" ), tr( "No" ), this ) == 1 )
589 { 589 {
590 // Update package list and reload package info 590 // Update package list and reload package info
591 slotUpdate(); 591 slotUpdate();
592 } 592 }
593 } 593 }
594} 594}
595 595
596void MainWindow::slotShowNotInstalled() 596void MainWindow::slotShowNotInstalled()
597{ 597{
598 OPackageList *packageList; 598 OPackageList *packageList;
599 if ( m_actionShowNotInstalled->isOn() ) 599 if ( m_actionShowNotInstalled->isOn() )
600 { 600 {
601 m_actionShowInstalled->setOn( false ); 601 m_actionShowInstalled->setOn( false );
602 m_actionShowUpdated->setOn( false ); 602 m_actionShowUpdated->setOn( false );
603 m_actionFilter->setOn( false ); 603 m_actionFilter->setOn( false );
604 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 604 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
605 OPackageManager::NotInstalled, QString::null ); 605 OPackageManager::NotInstalled, QString::null );
606 } 606 }
607 else 607 else
608 packageList = m_packman.packages(); 608 packageList = m_packman.packages();
609 609
610 if ( packageList ) 610 if ( packageList )
611 { 611 {
612 loadPackageList( packageList, true ); 612 loadPackageList( packageList, true );
613 delete packageList; 613 delete packageList;
614 } 614 }
615} 615}
616 616
617void MainWindow::slotShowInstalled() 617void MainWindow::slotShowInstalled()
618{ 618{
619 OPackageList *packageList; 619 OPackageList *packageList;
620 if ( m_actionShowInstalled->isOn() ) 620 if ( m_actionShowInstalled->isOn() )
621 { 621 {
622 m_actionShowNotInstalled->setOn( false ); 622 m_actionShowNotInstalled->setOn( false );
623 m_actionShowUpdated->setOn( false ); 623 m_actionShowUpdated->setOn( false );
624 m_actionFilter->setOn( false ); 624 m_actionFilter->setOn( false );
625 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 625 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
626 OPackageManager::Installed, QString::null ); 626 OPackageManager::Installed, QString::null );
627 } 627 }
628 else 628 else
629 packageList = m_packman.packages(); 629 packageList = m_packman.packages();
630 630