summaryrefslogtreecommitdiff
Unidiff
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
@@ -22,744 +22,744 @@ _;:, .> :=|. This file is free software; you can
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 "mainwindow.h" 30#include "mainwindow.h"
31#include "installdlg.h" 31#include "installdlg.h"
32#include "filterdlg.h" 32#include "filterdlg.h"
33#include "promptdlg.h" 33#include "promptdlg.h"
34#include "entrydlg.h" 34#include "entrydlg.h"
35#include "packageinfodlg.h" 35#include "packageinfodlg.h"
36 36
37#include <opie2/ofiledialog.h> 37#include <opie2/ofiledialog.h>
38 38
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42 42
43#include <qaction.h> 43#include <qaction.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qlayout.h> 45#include <qlayout.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qmenubar.h> 47#include <qmenubar.h>
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qpopupmenu.h> 49#include <qpopupmenu.h>
50#include <qtimer.h> 50#include <qtimer.h>
51#include <qtoolbar.h> 51#include <qtoolbar.h>
52#include <qwhatsthis.h> 52#include <qwhatsthis.h>
53 53
54MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) 54MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ )
55 : QMainWindow( parent, name, WStyle_ContextHelp ) 55 : QMainWindow( parent, name, WStyle_ContextHelp )
56 , m_config( "packman" ) 56 , m_config( "packman" )
57 , m_packman( &m_config, this ) 57 , m_packman( &m_config, this )
58 , m_menuBar( this ) 58 , m_menuBar( this )
59 , m_toolBar( this ) 59 , m_toolBar( this )
60 , m_findBar( this ) 60 , m_findBar( this )
61 , m_widgetStack( this ) 61 , m_widgetStack( this )
62 , m_packageList( this ) 62 , m_packageList( this )
63 , m_statusWidget( this ) 63 , m_statusWidget( this )
64 , m_statusText( &m_statusWidget ) 64 , m_statusText( &m_statusWidget )
65 , m_statusBar( &m_statusWidget ) 65 , m_statusBar( &m_statusWidget )
66 , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) 66 , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) )
67 , m_iconInstalled( Resource::loadPixmap( "installed" ) ) 67 , m_iconInstalled( Resource::loadPixmap( "installed" ) )
68 , m_iconNull( m_iconUpdated.size() ) 68 , m_iconNull( m_iconUpdated.size() )
69 , m_filterName( QString::null ) 69 , m_filterName( QString::null )
70 , m_filterServer( QString::null ) 70 , m_filterServer( QString::null )
71 , m_filterDest( QString::null ) 71 , m_filterDest( QString::null )
72 , m_filterStatus( OPackageManager::NotDefined ) 72 , m_filterStatus( OPackageManager::NotDefined )
73 , m_filterCategory( QString::null ) 73 , m_filterCategory( QString::null )
74 74
75{ 75{
76// setCaption( tr( "Package Manager" ) ); 76// setCaption( tr( "Package Manager" ) );
77 77
78 m_iconNull.fill( colorGroup().base() ); 78 m_iconNull.fill( colorGroup().base() );
79 79
80 connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); 80 connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) );
81 81
82 // Initialize widget stack, package list and status widget 82 // Initialize widget stack, package list and status widget
83 initStatusWidget(); 83 initStatusWidget();
84 initPackageList(); 84 initPackageList();
85 85
86 m_widgetStack.addWidget( &m_statusWidget, 2 ); 86 m_widgetStack.addWidget( &m_statusWidget, 2 );
87 m_widgetStack.addWidget( &m_packageList, 1 ); 87 m_widgetStack.addWidget( &m_packageList, 1 );
88 setCentralWidget( &m_widgetStack ); 88 setCentralWidget( &m_widgetStack );
89 89
90 // Initialize remaining user interface items 90 // Initialize remaining user interface items
91 initUI(); 91 initUI();
92 92
93 // Initialize package information 93 // Initialize package information
94 QTimer::singleShot( -1, this, SLOT( initPackageInfo() ) ); 94 QTimer::singleShot( -1, this, SLOT( initPackageInfo() ) );
95} 95}
96 96
97void MainWindow::closeEvent( QCloseEvent *event ) 97void MainWindow::closeEvent( QCloseEvent *event )
98{ 98{
99 // Close app only if either the package or status widgets are currently active 99 // Close app only if either the package or status widgets are currently active
100 bool close = m_widgetStack.visibleWidget() == &m_packageList || 100 bool close = m_widgetStack.visibleWidget() == &m_packageList ||
101 m_widgetStack.visibleWidget() == &m_statusWidget; 101 m_widgetStack.visibleWidget() == &m_statusWidget;
102 if ( close ) 102 if ( close )
103 { 103 {
104 // TODO - write out application configuration settings 104 // TODO - write out application configuration settings
105 105
106 // Write out package manager configuration settings 106 // Write out package manager configuration settings
107 m_packman.saveSettings(); 107 m_packman.saveSettings();
108 event->accept(); 108 event->accept();
109 } 109 }
110 else 110 else
111 { 111 {
112 delete m_widgetStack.visibleWidget(); 112 delete m_widgetStack.visibleWidget();
113 m_widgetStack.raiseWidget( &m_packageList ); 113 m_widgetStack.raiseWidget( &m_packageList );
114 event->ignore(); 114 event->ignore();
115 } 115 }
116} 116}
117 117
118void MainWindow::initPackageList() 118void MainWindow::initPackageList()
119{ 119{
120 m_packageList.addColumn( tr( "Packages" ) ); 120 m_packageList.addColumn( tr( "Packages" ) );
121 QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); 121 QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) );
122 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); 122 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold );
123 connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), 123 connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),
124 this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); 124 this, SLOT(slotDisplayPackageInfo(QListViewItem*)) );
125} 125}
126 126
127void MainWindow::initStatusWidget() 127void MainWindow::initStatusWidget()
128{ 128{
129 QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); 129 QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 );
130 130
131 m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 131 m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
132 layout->addWidget( &m_statusText ); 132 layout->addWidget( &m_statusText );
133 133
134 connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); 134 connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) );
135 connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); 135 connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) );
136 connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); 136 connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) );
137 137
138 layout->addWidget( &m_statusBar ); 138 layout->addWidget( &m_statusBar );
139} 139}
140 140
141void MainWindow::initUI() 141void MainWindow::initUI()
142{ 142{
143 // Build menu and tool bars 143 // Build menu and tool bars
144 setToolBarsMovable( false ); 144 setToolBarsMovable( false );
145 145
146 m_menuBar.setHorizontalStretchable( true ); 146 m_menuBar.setHorizontalStretchable( true );
147 QMenuBar *mb = new QMenuBar( &m_menuBar ); 147 QMenuBar *mb = new QMenuBar( &m_menuBar );
148 mb->setMargin( 0 ); 148 mb->setMargin( 0 );
149 149
150 // Find toolbar 150 // Find toolbar
151 addToolBar( &m_findBar, QMainWindow::Top, true ); 151 addToolBar( &m_findBar, QMainWindow::Top, true );
152 m_findBar.setHorizontalStretchable( true ); 152 m_findBar.setHorizontalStretchable( true );
153 m_findEdit = new QLineEdit( &m_findBar ); 153 m_findEdit = new QLineEdit( &m_findBar );
154 QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); 154 QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) );
155 m_findBar.setStretchableWidget( m_findEdit ); 155 m_findBar.setStretchableWidget( m_findEdit );
156 connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); 156 connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) );
157 157
158 // Packages menu 158 // Packages menu
159 QPopupMenu *popup = new QPopupMenu( this ); 159 QPopupMenu *popup = new QPopupMenu( this );
160 160
161 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); 161 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 );
162 a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); 162 a->setWhatsThis( tr( "Tap here to update package lists from servers." ) );
163 connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); 163 connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) );
164 a->addTo( popup ); 164 a->addTo( popup );
165 a->addTo( &m_toolBar ); 165 a->addTo( &m_toolBar );
166 166
167 QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); 167 QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 );
168 actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); 168 actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) );
169 connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); 169 connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
170 actionUpgrade->addTo( popup ); 170 actionUpgrade->addTo( popup );
171 actionUpgrade->addTo( &m_toolBar ); 171 actionUpgrade->addTo( &m_toolBar );
172 172
173 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); 173 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
174 QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); 174 QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
175 QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 175 QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
176 actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); 176 actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) );
177 connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); 177 connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
178 actionDownload->addTo( popup ); 178 actionDownload->addTo( popup );
179 actionDownload->addTo( &m_toolBar ); 179 actionDownload->addTo( &m_toolBar );
180 180
181 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); 181 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
182 a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); 182 a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) );
183 connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); 183 connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
184 a->addTo( popup ); 184 a->addTo( popup );
185 a->addTo( &m_toolBar ); 185 a->addTo( &m_toolBar );
186 186
187 a = new QAction( tr( "Install local package" ), Resource::loadPixmap( "folder" ), QString::null, 0, this, 0 ); 187 a = new QAction( tr( "Install local package" ), Resource::loadPixmap( "folder" ), QString::null, 0, this, 0 );
188 a->setWhatsThis( tr( "Tap here to install a package file located on device." ) ); 188 a->setWhatsThis( tr( "Tap here to install a package file located on device." ) );
189 connect( a, SIGNAL(activated()), this, SLOT(slotInstallLocal()) ); 189 connect( a, SIGNAL(activated()), this, SLOT(slotInstallLocal()) );
190 a->addTo( popup ); 190 a->addTo( popup );
191 //a->addTo( &m_toolBar ); 191 //a->addTo( &m_toolBar );
192 192
193 popup->insertSeparator(); 193 popup->insertSeparator();
194 194
195 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 195 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
196 a->setWhatsThis( tr( "Tap here to configure this application." ) ); 196 a->setWhatsThis( tr( "Tap here to configure this application." ) );
197 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); 197 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
198 a->addTo( popup ); 198 a->addTo( popup );
199 mb->insertItem( tr( "Actions" ), popup ); 199 mb->insertItem( tr( "Actions" ), popup );
200 200
201 // View menu 201 // View menu
202 popup = new QPopupMenu( this ); 202 popup = new QPopupMenu( this );
203 203
204 m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 204 m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
205 m_actionShowNotInstalled->setToggleAction( true ); 205 m_actionShowNotInstalled->setToggleAction( true );
206 m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); 206 m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) );
207 connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); 207 connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) );
208 m_actionShowNotInstalled->addTo( popup ); 208 m_actionShowNotInstalled->addTo( popup );
209 209
210 m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 210 m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
211 m_actionShowInstalled->setToggleAction( true ); 211 m_actionShowInstalled->setToggleAction( true );
212 m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); 212 m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) );
213 connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); 213 connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) );
214 m_actionShowInstalled->addTo( popup ); 214 m_actionShowInstalled->addTo( popup );
215 215
216 m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 216 m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
217 m_actionShowUpdated->setToggleAction( true ); 217 m_actionShowUpdated->setToggleAction( true );
218 m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); 218 m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) );
219 connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); 219 connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) );
220 m_actionShowUpdated->addTo( popup ); 220 m_actionShowUpdated->addTo( popup );
221 221
222 popup->insertSeparator(); 222 popup->insertSeparator();
223 223
224 m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), 224 m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ),
225 QString::null, 0, this, 0 ); 225 QString::null, 0, this, 0 );
226 m_actionFilter->setToggleAction( true ); 226 m_actionFilter->setToggleAction( true );
227 m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); 227 m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) );
228 connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); 228 connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) );
229 m_actionFilter->addTo( popup ); 229 m_actionFilter->addTo( popup );
230 230
231 a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); 231 a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 );
232 a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); 232 a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) );
233 connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); 233 connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) );
234 a->addTo( popup ); 234 a->addTo( popup );
235 235
236 popup->insertSeparator(); 236 popup->insertSeparator();
237 237
238 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 238 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
239 a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); 239 a->setWhatsThis( tr( "Tap here to search for text in package names." ) );
240 connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); 240 connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) );
241 a->addTo( popup ); 241 a->addTo( popup );
242 242
243 m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 243 m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
244 m_actionFindNext->setEnabled( false ); 244 m_actionFindNext->setEnabled( false );
245 m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) ); 245 m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) );
246 connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); 246 connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) );
247 m_actionFindNext->addTo( popup ); 247 m_actionFindNext->addTo( popup );
248 m_actionFindNext->addTo( &m_findBar ); 248 m_actionFindNext->addTo( &m_findBar );
249 249
250 mb->insertItem( tr( "View" ), popup ); 250 mb->insertItem( tr( "View" ), popup );
251 251
252 // Finish find toolbar creation 252 // Finish find toolbar creation
253 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 253 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
254 a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) ); 254 a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) );
255 connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); 255 connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) );
256 a->addTo( &m_findBar ); 256 a->addTo( &m_findBar );
257 m_findBar.hide(); 257 m_findBar.hide();
258} 258}
259 259
260void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) 260void MainWindow::loadPackageList( OPackageList *packages, bool clearList )
261{ 261{
262 if ( clearList ) 262 if ( clearList )
263 m_packageList.clear(); 263 m_packageList.clear();
264 264
265 if ( packages ) 265 if ( packages )
266 { 266 {
267 for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) 267 for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt )
268 { 268 {
269 OPackage *package = packageIt.current(); 269 OPackage *package = packageIt.current();
270 QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), 270 QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(),
271 QCheckListItem::CheckBox ); 271 QCheckListItem::CheckBox );
272 m_packageList.insertItem( item ); 272 m_packageList.insertItem( item );
273 273
274 // If a different version of package is available, show update available icon 274 // If a different version of package is available, show update available icon
275 // Otherwise, show installed icon 275 // Otherwise, show installed icon
276 if ( !package->versionInstalled().isNull() ) 276 if ( !package->versionInstalled().isNull() )
277 { 277 {
278 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) 278 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
279 item->setPixmap( 0, m_iconUpdated ); 279 item->setPixmap( 0, m_iconUpdated );
280 else 280 else
281 item->setPixmap( 0, m_iconInstalled ); 281 item->setPixmap( 0, m_iconInstalled );
282 } 282 }
283 else 283 else
284 item->setPixmap( 0, m_iconNull ); 284 item->setPixmap( 0, m_iconNull );
285 } 285 }
286 } 286 }
287} 287}
288 288
289void MainWindow::searchForPackage( const QString &text ) 289void MainWindow::searchForPackage( const QString &text )
290{ 290{
291 if ( !text.isEmpty() ) 291 if ( !text.isEmpty() )
292 { 292 {
293 // look through package list for text startng at current position 293 // look through package list for text startng at current position
294 QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); 294 QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem());
295 if ( start == 0 ) 295 if ( start == 0 )
296 start = static_cast<QCheckListItem *>(m_packageList.firstChild()); 296 start = static_cast<QCheckListItem *>(m_packageList.firstChild());
297 297
298// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; 298// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ;
299 for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; 299 for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ;
300 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 300 item = static_cast<QCheckListItem *>(item->nextSibling()) )
301 { 301 {
302 if ( item->text().lower().find( text ) != -1 ) 302 if ( item->text().lower().find( text ) != -1 )
303 { 303 {
304 m_packageList.ensureItemVisible( item ); 304 m_packageList.ensureItemVisible( item );
305 m_packageList.setCurrentItem( item ); 305 m_packageList.setCurrentItem( item );
306 break; 306 break;
307 } 307 }
308 } 308 }
309 } 309 }
310} 310}
311 311
312void MainWindow::installLocalPackage( const QString &ipkFile ) 312void MainWindow::installLocalPackage( const QString &ipkFile )
313{ 313{
314 // Install selected file 314 // Install selected file
315 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true, 315 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true,
316 OPackage::Install, ipkFile ); 316 OPackage::Install, ipkFile );
317 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 317 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
318 318
319 // Display widget 319 // Display widget
320 m_widgetStack.addWidget( dlg, 3 ); 320 m_widgetStack.addWidget( dlg, 3 );
321 m_widgetStack.raiseWidget( dlg ); 321 m_widgetStack.raiseWidget( dlg );
322} 322}
323 323
324void MainWindow::setDocument( const QString &ipkFile ) 324void MainWindow::setDocument( const QString &ipkFile )
325{ 325{
326 QString file = ipkFile; 326 QString file = ipkFile;
327 DocLnk lnk( ipkFile ); 327 DocLnk lnk( ipkFile );
328 if ( lnk.isValid() ) 328 if ( lnk.isValid() )
329 file = lnk.file(); 329 file = lnk.file();
330 330
331 installLocalPackage( file ); 331 installLocalPackage( file );
332} 332}
333 333
334void MainWindow::initPackageInfo() 334void MainWindow::initPackageInfo()
335{ 335{
336 m_widgetStack.raiseWidget( &m_statusWidget ); 336 m_widgetStack.raiseWidget( &m_statusWidget );
337 337
338 // Load package list 338 // Load package list
339 m_packman.loadAvailablePackages(); 339 m_packman.loadAvailablePackages();
340 m_packman.loadInstalledPackages(); 340 m_packman.loadInstalledPackages();
341 341
342 OPackageList *packageList = m_packman.packages(); 342 OPackageList *packageList = m_packman.packages();
343 if ( packageList ) 343 if ( packageList )
344 { 344 {
345 loadPackageList( packageList, true ); 345 loadPackageList( packageList, true );
346 delete packageList; 346 delete packageList;
347 } 347 }
348 348
349 QWidget *widget = m_widgetStack.widget( 3 ); 349 QWidget *widget = m_widgetStack.widget( 3 );
350 if ( !widget ) 350 if ( !widget )
351 widget = &m_packageList; 351 widget = &m_packageList;
352 m_widgetStack.raiseWidget( widget ); 352 m_widgetStack.raiseWidget( widget );
353} 353}
354 354
355void MainWindow::slotWidgetStackShow( QWidget *widget ) 355void MainWindow::slotWidgetStackShow( QWidget *widget )
356{ 356{
357 if ( widget == &m_packageList ) 357 if ( widget == &m_packageList )
358 { 358 {
359 setCaption( tr( "Package Manager" ) ); 359 setCaption( tr( "Package Manager" ) );
360 360
361 m_menuBar.show(); 361 m_menuBar.show();
362 m_toolBar.show(); 362 m_toolBar.show();
363 } 363 }
364 else 364 else
365 { 365 {
366 m_menuBar.hide(); 366 m_menuBar.hide();
367 m_toolBar.hide(); 367 m_toolBar.hide();
368 } 368 }
369} 369}
370 370
371void MainWindow::slotInitStatusBar( int numSteps ) 371void MainWindow::slotInitStatusBar( int numSteps )
372{ 372{
373 m_statusBar.setTotalSteps( numSteps ); 373 m_statusBar.setTotalSteps( numSteps );
374} 374}
375 375
376void MainWindow::slotStatusText( const QString &status ) 376void MainWindow::slotStatusText( const QString &status )
377{ 377{
378 m_statusText.setText( status ); 378 m_statusText.setText( status );
379} 379}
380 380
381void MainWindow::slotStatusBar( int currStep ) 381void MainWindow::slotStatusBar( int currStep )
382{ 382{
383 m_statusBar.setProgress( currStep ); 383 m_statusBar.setProgress( currStep );
384} 384}
385 385
386void MainWindow::slotUpdate() 386void MainWindow::slotUpdate()
387{ 387{
388 // Create package manager output widget 388 // Create package manager output widget
389 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, 389 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false,
390 OPackage::Update ); 390 OPackage::Update );
391 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 391 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
392 392
393 // Display widget 393 // Display widget
394 m_widgetStack.addWidget( dlg, 3 ); 394 m_widgetStack.addWidget( dlg, 3 );
395 m_widgetStack.raiseWidget( dlg ); 395 m_widgetStack.raiseWidget( dlg );
396} 396}
397 397
398void MainWindow::slotUpgrade() 398void MainWindow::slotUpgrade()
399{ 399{
400 // Create package manager output widget 400 // Create package manager output widget
401 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, 401 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false,
402 OPackage::Upgrade ); 402 OPackage::Upgrade );
403 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 403 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
404 404
405 // Display widget 405 // Display widget
406 m_widgetStack.addWidget( dlg, 3 ); 406 m_widgetStack.addWidget( dlg, 3 );
407 m_widgetStack.raiseWidget( dlg ); 407 m_widgetStack.raiseWidget( dlg );
408} 408}
409 409
410void MainWindow::slotDownload() 410void MainWindow::slotDownload()
411{ 411{
412 // Retrieve list of packages selected for download (if any) 412 // Retrieve list of packages selected for download (if any)
413 QStringList workingPackages; 413 QStringList workingPackages;
414 414
415 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 415 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
416 item != 0 ; 416 item != 0 ;
417 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 417 item = static_cast<QCheckListItem *>(item->nextSibling()) )
418 { 418 {
419 if ( item->isOn() ) 419 if ( item->isOn() )
420 workingPackages.append( item->text() ); 420 workingPackages.append( item->text() );
421 } 421 }
422 422
423 if ( workingPackages.isEmpty() ) 423 if ( workingPackages.isEmpty() )
424 { 424 {
425 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); 425 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
426 return; 426 return;
427 } 427 }
428 else 428 else
429 { 429 {
430 // Download selected packages 430 // Download selected packages
431 m_config.setGroup( "settings" ); 431 m_config.setGroup( "settings" );
432 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); 432 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
433 433
434 bool ok = false; 434 bool ok = false;
435 QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); 435 QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this );
436 if ( ok && !text.isEmpty() ) 436 if ( ok && !text.isEmpty() )
437 workingDir = text; // user entered something and pressed ok 437 workingDir = text; // user entered something and pressed ok
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
631 if ( packageList ) 631 if ( packageList )
632 { 632 {
633 loadPackageList( packageList, true ); 633 loadPackageList( packageList, true );
634 delete packageList; 634 delete packageList;
635 } 635 }
636} 636}
637 637
638void MainWindow::slotShowUpdated() 638void MainWindow::slotShowUpdated()
639{ 639{
640 OPackageList *packageList; 640 OPackageList *packageList;
641 if ( m_actionShowUpdated->isOn() ) 641 if ( m_actionShowUpdated->isOn() )
642 { 642 {
643 m_actionShowInstalled->setOn( false ); 643 m_actionShowInstalled->setOn( false );
644 m_actionShowNotInstalled->setOn( false ); 644 m_actionShowNotInstalled->setOn( false );
645 m_actionFilter->setOn( false ); 645 m_actionFilter->setOn( false );
646 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 646 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
647 OPackageManager::Updated, QString::null ); 647 OPackageManager::Updated, QString::null );
648 } 648 }
649 else 649 else
650 packageList = m_packman.packages(); 650 packageList = m_packman.packages();
651 651
652 if ( packageList ) 652 if ( packageList )
653 { 653 {
654 loadPackageList( packageList, true ); 654 loadPackageList( packageList, true );
655 delete packageList; 655 delete packageList;
656 } 656 }
657} 657}
658 658
659void MainWindow::slotFilterChange() 659void MainWindow::slotFilterChange()
660{ 660{
661 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, 661 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus,
662 m_filterCategory ); 662 m_filterCategory );
663 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) 663 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
664 { 664 {
665 m_filterName = dlg.name(); 665 m_filterName = dlg.name();
666 m_filterServer = dlg.server(); 666 m_filterServer = dlg.server();
667 m_filterDest = dlg.destination(); 667 m_filterDest = dlg.destination();
668 m_filterStatus = dlg.status(); 668 m_filterStatus = dlg.status();
669 m_filterCategory = dlg.category(); 669 m_filterCategory = dlg.category();
670 m_actionFilter->setOn( true ); 670 m_actionFilter->setOn( true );
671 slotFilter( true ); 671 slotFilter( true );
672 } 672 }
673 else 673 else
674 { 674 {
675 m_actionFilter->setOn( false ); 675 m_actionFilter->setOn( false );
676 slotFilter( false ); 676 slotFilter( false );
677 } 677 }
678} 678}
679 679
680void MainWindow::slotFilter( bool isOn ) 680void MainWindow::slotFilter( bool isOn )
681{ 681{
682 OPackageList *packageList; 682 OPackageList *packageList;
683 if ( isOn ) 683 if ( isOn )
684 { 684 {
685 // Turn off other filtering options 685 // Turn off other filtering options
686 m_actionShowNotInstalled->setOn( false ); 686 m_actionShowNotInstalled->setOn( false );
687 m_actionShowInstalled->setOn( false ); 687 m_actionShowInstalled->setOn( false );
688 m_actionShowUpdated->setOn( false ); 688 m_actionShowUpdated->setOn( false );
689 689
690 // If the filter settings have not been set yet, display filter dialog 690 // If the filter settings have not been set yet, display filter dialog
691 if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() && 691 if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() &&
692 m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() ) 692 m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() )
693 { 693 {
694 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, 694 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus,
695 m_filterCategory ); 695 m_filterCategory );
696 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) 696 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
697 { 697 {
698 m_filterName = dlg.name(); 698 m_filterName = dlg.name();
699 m_filterServer = dlg.server(); 699 m_filterServer = dlg.server();
700 m_filterDest = dlg.destination(); 700 m_filterDest = dlg.destination();
701 m_filterStatus = dlg.status(); 701 m_filterStatus = dlg.status();
702 m_filterCategory = dlg.category(); 702 m_filterCategory = dlg.category();
703 m_actionFilter->setOn( true ); 703 m_actionFilter->setOn( true );
704 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, 704 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest,
705 m_filterStatus, m_filterCategory ); 705 m_filterStatus, m_filterCategory );
706 } 706 }
707 else 707 else
708 { 708 {
709 m_actionFilter->setOn( false ); 709 m_actionFilter->setOn( false );
710 packageList = m_packman.packages(); 710 packageList = m_packman.packages();
711 } 711 }
712 } 712 }
713 else 713 else
714 { 714 {
715 m_actionFilter->setOn( true ); 715 m_actionFilter->setOn( true );
716 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, 716 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest,
717 m_filterStatus, m_filterCategory ); 717 m_filterStatus, m_filterCategory );
718 } 718 }
719 719
720 720
721 } 721 }
722 else 722 else
723 packageList = m_packman.packages(); 723 packageList = m_packman.packages();
724 724
725 if ( packageList ) 725 if ( packageList )
726 { 726 {
727 loadPackageList( packageList, true ); 727 loadPackageList( packageList, true );
728 delete packageList; 728 delete packageList;
729 } 729 }
730} 730}
731 731
732void MainWindow::slotFindShowToolbar() 732void MainWindow::slotFindShowToolbar()
733{ 733{
734 m_findBar.show(); 734 m_findBar.show();
735 m_findEdit->setFocus(); 735 m_findEdit->setFocus();
736} 736}
737 737
738void MainWindow::slotFindHideToolbar() 738void MainWindow::slotFindHideToolbar()
739{ 739{
740 m_findBar.hide(); 740 m_findBar.hide();
741} 741}
742 742
743void MainWindow::slotFindChanged( const QString &findText ) 743void MainWindow::slotFindChanged( const QString &findText )
744{ 744{
745 745
746 m_actionFindNext->setEnabled( !findText.isEmpty() ); 746 m_actionFindNext->setEnabled( !findText.isEmpty() );
747 searchForPackage( findText ); 747 searchForPackage( findText );
748} 748}
749 749
750void MainWindow::slotFindNext() 750void MainWindow::slotFindNext()
751{ 751{
752 searchForPackage( m_findEdit->text() ); 752 searchForPackage( m_findEdit->text() );
753} 753}
754 754
755void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) 755void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem )
756{ 756{
757 QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); 757 QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() );
758 758
759 // Create package manager output widget 759 // Create package manager output widget
760 PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); 760 PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName );
761 761
762 // Display widget 762 // Display widget
763 m_widgetStack.addWidget( dlg, 3 ); 763 m_widgetStack.addWidget( dlg, 3 );
764 m_widgetStack.raiseWidget( dlg ); 764 m_widgetStack.raiseWidget( dlg );
765} 765}