summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/mainwin.cpp
Unidiff
Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 6f5c712..6b31cd1 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -7,402 +7,402 @@
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 "categoryfilterimpl.h" 30#include "categoryfilterimpl.h"
31#include "datamgr.h" 31#include "datamgr.h"
32#include "global.h" 32#include "global.h"
33#include "inputdlg.h" 33#include "inputdlg.h"
34#include "ipkg.h" 34#include "ipkg.h"
35#include "installdlgimpl.h" 35#include "installdlgimpl.h"
36#include "letterpushbutton.h" 36#include "letterpushbutton.h"
37#include "mainwin.h" 37#include "mainwin.h"
38#include "packagewin.h" 38#include "packagewin.h"
39#include "settingsimpl.h" 39#include "settingsimpl.h"
40#include "utils.h" 40#include "utils.h"
41 41
42/* OPIE */ 42/* OPIE */
43#include <qpe/qcopenvelope_qws.h> 43#include <qpe/qcopenvelope_qws.h>
44#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
45#include <qpe/config.h> 45#include <qpe/config.h>
46#include <qpe/resource.h> 46#include <qpe/resource.h>
47 47
48/* QT */ 48/* QT */
49#include <qmenubar.h> 49#include <qmenubar.h>
50#include <qtoolbar.h> 50#include <qtoolbar.h>
51#include <qaction.h> 51#include <qaction.h>
52#include <qcombobox.h> 52#include <qcombobox.h>
53#include <qfile.h> 53#include <qfile.h>
54#include <qlabel.h> 54#include <qlabel.h>
55#include <qlayout.h> 55#include <qlayout.h>
56#include <qlineedit.h> 56#include <qlineedit.h>
57#include <qlistview.h> 57#include <qlistview.h>
58#include <qmenubar.h> 58#include <qmenubar.h>
59#include <qmessagebox.h> 59#include <qmessagebox.h>
60#include <qpopupmenu.h> 60#include <qpopupmenu.h>
61#include <qprogressbar.h> 61#include <qprogressbar.h>
62#include <qtimer.h> 62#include <qtimer.h>
63#include <qwhatsthis.h> 63#include <qwhatsthis.h>
64#include <qwidgetstack.h> 64#include <qwidgetstack.h>
65 65
66/* STD */ 66/* STD */
67#include <linux/limits.h> 67#include <linux/limits.h>
68#include <unistd.h> 68#include <unistd.h>
69 69
70extern int compareVersions( const char *v1, const char *v2 ); 70extern int compareVersions( const char *v1, const char *v2 );
71 71
72MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) 72MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl )
73 :QMainWindow( parent, name, fl || WStyle_ContextHelp ) 73 :QMainWindow( parent, name, fl || WStyle_ContextHelp )
74{ 74{
75 // Disable suspend mode 75 // Disable suspend mode
76 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; 76 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend;
77 77
78 LOCAL_SERVER = QObject::tr( "Installed packages" ); 78 LOCAL_SERVER = QObject::tr( "Installed packages" );
79 LOCAL_IPKGS = QObject::tr( "Local packages" ); 79 LOCAL_IPKGS = QObject::tr( "Local packages" );
80 80
81 setCaption( tr( "AQPkg - Package Manager" ) ); 81 setCaption( tr( "AQPkg - Package Manager" ) );
82 82
83 // Create UI widgets 83 // Create UI widgets
84 initMainWidget(); 84 initMainWidget();
85 initProgressWidget(); 85 initProgressWidget();
86 86
87 // Build menu and tool bars 87 // Build menu and tool bars
88 setToolBarsMovable( FALSE ); 88 setToolBarsMovable( FALSE );
89 89
90 QToolBar *bar = new QToolBar( this ); 90 QToolBar *bar = new QToolBar( this );
91 bar->setHorizontalStretchable( TRUE ); 91 bar->setHorizontalStretchable( TRUE );
92 QMenuBar *mb = new QMenuBar( bar ); 92 QMenuBar *mb = new QMenuBar( bar );
93 mb->setMargin( 0 ); 93 mb->setMargin( 0 );
94 bar = new QToolBar( this ); 94 bar = new QToolBar( this );
95 95
96 // Find toolbar 96 // Find toolbar
97 findBar = new QToolBar( this ); 97 findBar = new QToolBar( this );
98 addToolBar( findBar, QMainWindow::Top, true ); 98 addToolBar( findBar, QMainWindow::Top, true );
99 findBar->setHorizontalStretchable( true ); 99 findBar->setHorizontalStretchable( true );
100 findEdit = new QLineEdit( findBar ); 100 findEdit = new QLineEdit( findBar );
101 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); 101 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
102 findBar->setStretchableWidget( findEdit ); 102 findBar->setStretchableWidget( findEdit );
103 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); 103 connect( findEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( findPackage(const QString&) ) );
104 104
105 // Quick jump toolbar 105 // Quick jump toolbar
106 jumpBar = new QToolBar( this ); 106 jumpBar = new QToolBar( this );
107 addToolBar( jumpBar, QMainWindow::Top, true ); 107 addToolBar( jumpBar, QMainWindow::Top, true );
108 jumpBar->setHorizontalStretchable( true ); 108 jumpBar->setHorizontalStretchable( true );
109 QWidget *w = new QWidget( jumpBar ); 109 QWidget *w = new QWidget( jumpBar );
110 jumpBar->setStretchableWidget( w ); 110 jumpBar->setStretchableWidget( w );
111 111
112 QGridLayout *layout = new QGridLayout( w ); 112 QGridLayout *layout = new QGridLayout( w );
113 113
114 char text[2]; 114 char text[2];
115 text[1] = '\0'; 115 text[1] = '\0';
116 for ( int i = 0 ; i < 26 ; ++i ) 116 for ( int i = 0 ; i < 26 ; ++i )
117 { 117 {
118 text[0] = 'A' + i; 118 text[0] = 'A' + i;
119 LetterPushButton *b = new LetterPushButton( text, w ); 119 LetterPushButton *b = new LetterPushButton( text, w );
120 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 120 connect( b, SIGNAL( released(QString) ), this, SLOT( letterPushed(QString) ) );
121 layout->addWidget( b, i / 13, i % 13); 121 layout->addWidget( b, i / 13, i % 13);
122 } 122 }
123 123
124 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); 124 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
125 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); 125 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
126 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); 126 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
127 a->addTo( jumpBar ); 127 a->addTo( jumpBar );
128 jumpBar->hide(); 128 jumpBar->hide();
129 129
130 // Packages menu 130 // Packages menu
131 QPopupMenu *popup = new QPopupMenu( this ); 131 QPopupMenu *popup = new QPopupMenu( this );
132 132
133 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); 133 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
134 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 134 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
135 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); 135 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
136 a->addTo( popup ); 136 a->addTo( popup );
137 a->addTo( bar ); 137 a->addTo( bar );
138 138
139 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); 139 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
140 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 140 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
141 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); 141 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
142 actionUpgrade->addTo( popup ); 142 actionUpgrade->addTo( popup );
143 actionUpgrade->addTo( bar ); 143 actionUpgrade->addTo( bar );
144 144
145 iconDownload = Resource::loadPixmap( "aqpkg/download" ); 145 iconDownload = Resource::loadPixmap( "aqpkg/download" );
146 iconRemove = Resource::loadPixmap( "aqpkg/remove" ); 146 iconRemove = Resource::loadPixmap( "aqpkg/remove" );
147 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 147 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
148 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 148 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
149 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); 149 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
150 actionDownload->addTo( popup ); 150 actionDownload->addTo( popup );
151 actionDownload->addTo( bar ); 151 actionDownload->addTo( bar );
152 152
153 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); 153 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
154 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 154 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
155 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); 155 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
156 a->addTo( popup ); 156 a->addTo( popup );
157 a->addTo( bar ); 157 a->addTo( bar );
158 158
159 popup->insertSeparator(); 159 popup->insertSeparator();
160 160
161 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 161 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
162 a->setWhatsThis( tr( "Click here to configure this application." ) ); 162 a->setWhatsThis( tr( "Click here to configure this application." ) );
163 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); 163 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
164 a->addTo( popup ); 164 a->addTo( popup );
165 mb->insertItem( tr( "Actions" ), popup ); 165 mb->insertItem( tr( "Actions" ), popup );
166 166
167 // View menu 167 // View menu
168 popup = new QPopupMenu( this ); 168 popup = new QPopupMenu( this );
169 169
170 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 170 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
171 actionUninstalled->setToggleAction( TRUE ); 171 actionUninstalled->setToggleAction( TRUE );
172 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 172 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
173 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); 173 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
174 actionUninstalled->addTo( popup ); 174 actionUninstalled->addTo( popup );
175 175
176 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 176 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
177 actionInstalled->setToggleAction( TRUE ); 177 actionInstalled->setToggleAction( TRUE );
178 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 178 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
179 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); 179 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
180 actionInstalled->addTo( popup ); 180 actionInstalled->addTo( popup );
181 181
182 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 182 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
183 actionUpdated->setToggleAction( TRUE ); 183 actionUpdated->setToggleAction( TRUE );
184 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 184 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
185 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); 185 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
186 actionUpdated->addTo( popup ); 186 actionUpdated->addTo( popup );
187 187
188 popup->insertSeparator(); 188 popup->insertSeparator();
189 189
190 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); 190 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
191 actionFilter->setToggleAction( TRUE ); 191 actionFilter->setToggleAction( TRUE );
192 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); 192 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
193 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); 193 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
194 actionFilter->addTo( popup ); 194 actionFilter->addTo( popup );
195 195
196 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); 196 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
197 a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); 197 a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
198 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); 198 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
199 a->addTo( popup ); 199 a->addTo( popup );
200 200
201 popup->insertSeparator(); 201 popup->insertSeparator();
202 202
203 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 203 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
204 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 204 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
205 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); 205 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
206 a->addTo( popup ); 206 a->addTo( popup );
207 207
208 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 208 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
209 actionFindNext->setEnabled( FALSE ); 209 actionFindNext->setEnabled( FALSE );
210 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 210 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
211 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); 211 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
212 actionFindNext->addTo( popup ); 212 actionFindNext->addTo( popup );
213 actionFindNext->addTo( findBar ); 213 actionFindNext->addTo( findBar );
214 214
215 215
216 popup->insertSeparator(); 216 popup->insertSeparator();
217 217
218 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); 218 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 );
219 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); 219 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) );
220 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); 220 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) );
221 a->addTo( popup ); 221 a->addTo( popup );
222 222
223 mb->insertItem( tr( "View" ), popup ); 223 mb->insertItem( tr( "View" ), popup );
224 224
225 // Finish find toolbar creation 225 // Finish find toolbar creation
226 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 226 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
227 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); 227 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
228 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); 228 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
229 a->addTo( findBar ); 229 a->addTo( findBar );
230 findBar->hide(); 230 findBar->hide();
231 231
232 // Create widget stack and add UI widgets 232 // Create widget stack and add UI widgets
233 stack = new QWidgetStack( this ); 233 stack = new QWidgetStack( this );
234 stack->addWidget( progressWindow, 2 ); 234 stack->addWidget( progressWindow, 2 );
235 stack->addWidget( networkPkgWindow, 1 ); 235 stack->addWidget( networkPkgWindow, 1 );
236 setCentralWidget( stack ); 236 setCentralWidget( stack );
237 stack->raiseWidget( progressWindow ); 237 stack->raiseWidget( progressWindow );
238 238
239 // Delayed call to finish initialization 239 // Delayed call to finish initialization
240 QTimer::singleShot( 100, this, SLOT( init() ) ); 240 QTimer::singleShot( 100, this, SLOT( init() ) );
241} 241}
242 242
243MainWindow :: ~MainWindow() 243MainWindow :: ~MainWindow()
244{ 244{
245 delete mgr; 245 delete mgr;
246 246
247 // Reenable suspend mode 247 // Reenable suspend mode
248 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 248 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
249} 249}
250 250
251void MainWindow :: initMainWidget() 251void MainWindow :: initMainWidget()
252{ 252{
253 networkPkgWindow = new QWidget( this ); 253 networkPkgWindow = new QWidget( this );
254 254
255 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); 255 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
256 256
257 serversList = new QComboBox( networkPkgWindow ); 257 serversList = new QComboBox( networkPkgWindow );
258 connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); 258 connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) );
259 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); 259 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
260 260
261 installedIcon = Resource::loadPixmap( "installed" ); 261 installedIcon = Resource::loadPixmap( "installed" );
262 updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); 262 updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
263 263
264 packagesList = new QListView( networkPkgWindow ); 264 packagesList = new QListView( networkPkgWindow );
265 packagesList->addColumn( tr( "Packages" ), 225 ); 265 packagesList->addColumn( tr( "Packages" ), 225 );
266 QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\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\nClick inside the box at the left to select a package." ) ); 266 QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\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\nClick inside the box at the left to select a package." ) );
267 QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); 267 QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold );
268 connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), 268 connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),
269 this, SLOT(slotDisplayPackage(QListViewItem *)) ); 269 this, SLOT(slotDisplayPackage(QListViewItem*)) );
270 270
271 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); 271 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 );
272 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); 272 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
273 hbox1->addWidget( l ); 273 hbox1->addWidget( l );
274 hbox1->addWidget( serversList ); 274 hbox1->addWidget( serversList );
275 275
276 vbox->addWidget( packagesList ); 276 vbox->addWidget( packagesList );
277 277
278 downloadEnabled = TRUE; 278 downloadEnabled = TRUE;
279} 279}
280 280
281void MainWindow :: initProgressWidget() 281void MainWindow :: initProgressWidget()
282{ 282{
283 progressWindow = new QWidget( this ); 283 progressWindow = new QWidget( this );
284 284
285 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); 285 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
286 286
287 m_status = new QLabel( progressWindow ); 287 m_status = new QLabel( progressWindow );
288 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 288 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
289 layout->addWidget( m_status ); 289 layout->addWidget( m_status );
290 290
291 m_progress = new QProgressBar( progressWindow ); 291 m_progress = new QProgressBar( progressWindow );
292 layout->addWidget( m_progress ); 292 layout->addWidget( m_progress );
293} 293}
294 294
295void MainWindow :: init() 295void MainWindow :: init()
296{ 296{
297#ifdef QWS 297#ifdef QWS
298 // read download directory from config file 298 // read download directory from config file
299 Config cfg( "aqpkg" ); 299 Config cfg( "aqpkg" );
300 cfg.setGroup( "settings" ); 300 cfg.setGroup( "settings" );
301 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 301 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
302 // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 302 // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
303 303
304#endif 304#endif
305 305
306 stack->raiseWidget( progressWindow ); 306 stack->raiseWidget( progressWindow );
307 307
308 mgr = new DataManager(); 308 mgr = new DataManager();
309 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); 309 connect( mgr, SIGNAL( progressSetSteps(int) ), this, SLOT( setProgressSteps(int) ) );
310 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 310 connect( mgr, SIGNAL( progressSetMessage(const QString&) ),
311 this, SLOT( setProgressMessage( const QString & ) ) ); 311 this, SLOT( setProgressMessage(const QString&) ) );
312 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); 312 connect( mgr, SIGNAL( progressUpdate(int) ), this, SLOT( updateProgress(int) ) );
313 mgr->loadServers(); 313 mgr->loadServers();
314 314
315 showUninstalledPkgs = false; 315 showUninstalledPkgs = false;
316 showInstalledPkgs = false; 316 showInstalledPkgs = false;
317 showUpgradedPkgs = false; 317 showUpgradedPkgs = false;
318 categoryFilterEnabled = false; 318 categoryFilterEnabled = false;
319 319
320 updateData(); 320 updateData();
321 321
322 stack->raiseWidget( networkPkgWindow ); 322 stack->raiseWidget( networkPkgWindow );
323} 323}
324 324
325void MainWindow :: setDocument( const QString &doc ) 325void MainWindow :: setDocument( const QString &doc )
326{ 326{
327 // Remove path from package 327 // Remove path from package
328 QString package = Utils::getPackageNameFromIpkFilename( doc ); 328 QString package = Utils::getPackageNameFromIpkFilename( doc );
329 329
330 // First select local server 330 // First select local server
331 for ( int i = 0 ; i < serversList->count() ; ++i ) 331 for ( int i = 0 ; i < serversList->count() ; ++i )
332 { 332 {
333 if ( serversList->text( i ) == LOCAL_IPKGS ) 333 if ( serversList->text( i ) == LOCAL_IPKGS )
334 { 334 {
335 serversList->setCurrentItem( i ); 335 serversList->setCurrentItem( i );
336 break; 336 break;
337 } 337 }
338 } 338 }
339 serverSelected( 0 ); 339 serverSelected( 0 );
340 340
341 // Now set the check box of the selected package 341 // Now set the check box of the selected package
342 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 342 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
343 item != 0 ; 343 item != 0 ;
344 item = (QCheckListItem *)item->nextSibling() ) 344 item = (QCheckListItem *)item->nextSibling() )
345 { 345 {
346 if ( item->text().startsWith( package ) ) 346 if ( item->text().startsWith( package ) )
347 { 347 {
348 item->setOn( true ); 348 item->setOn( true );
349 break; 349 break;
350 } 350 }
351 } 351 }
352} 352}
353 353
354void MainWindow :: displaySettings() 354void MainWindow :: displaySettings()
355{ 355{
356 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 356 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
357 if ( dlg->showDlg() ) 357 if ( dlg->showDlg() )
358 { 358 {
359 stack->raiseWidget( progressWindow ); 359 stack->raiseWidget( progressWindow );
360 updateData(); 360 updateData();
361 stack->raiseWidget( networkPkgWindow ); 361 stack->raiseWidget( networkPkgWindow );
362 } 362 }
363 delete dlg; 363 delete dlg;
364} 364}
365 365
366void MainWindow :: closeEvent( QCloseEvent *e ) 366void MainWindow :: closeEvent( QCloseEvent *e )
367{ 367{
368 // If install dialog is visible, return to main view, otherwise close app 368 // If install dialog is visible, return to main view, otherwise close app
369 QWidget *widget = stack->visibleWidget(); 369 QWidget *widget = stack->visibleWidget();
370 370
371 if ( widget != networkPkgWindow && widget != progressWindow ) 371 if ( widget != networkPkgWindow && widget != progressWindow )
372 { 372 {
373 if ( widget ) delete widget; 373 if ( widget ) delete widget;
374 stack->raiseWidget( networkPkgWindow ); 374 stack->raiseWidget( networkPkgWindow );
375 e->ignore(); 375 e->ignore();
376 } 376 }
377 else 377 else
378 { 378 {
379 e->accept(); 379 e->accept();
380 } 380 }
381} 381}
382 382
383void MainWindow :: displayFindBar() 383void MainWindow :: displayFindBar()
384{ 384{
385 findBar->show(); 385 findBar->show();
386 findEdit->setFocus(); 386 findEdit->setFocus();
387} 387}
388 388
389void MainWindow :: displayJumpBar() 389void MainWindow :: displayJumpBar()
390{ 390{
391 jumpBar->show(); 391 jumpBar->show();
392} 392}
393 393
394void MainWindow :: repeatFind() 394void MainWindow :: repeatFind()
395{ 395{
396 searchForPackage( findEdit->text() ); 396 searchForPackage( findEdit->text() );
397} 397}
398 398
399void MainWindow :: findPackage( const QString &text ) 399void MainWindow :: findPackage( const QString &text )
400{ 400{
401 actionFindNext->setEnabled( !text.isEmpty() ); 401 actionFindNext->setEnabled( !text.isEmpty() );
402 searchForPackage( text ); 402 searchForPackage( text );
403} 403}
404 404
405void MainWindow :: hideFindBar() 405void MainWindow :: hideFindBar()
406{ 406{
407 findBar->hide(); 407 findBar->hide();
408} 408}
@@ -677,411 +677,411 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
677 677
678 // If the local server, only display installed packages 678 // If the local server, only display installed packages
679 if ( serverName == LOCAL_SERVER && !package->isInstalled() ) 679 if ( serverName == LOCAL_SERVER && !package->isInstalled() )
680 continue; 680 continue;
681 681
682 682
683 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), 683 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
684 QCheckListItem::CheckBox ); 684 QCheckListItem::CheckBox );
685 685
686 if ( package->isInstalled() ) 686 if ( package->isInstalled() )
687 { 687 {
688 // If a different version of package is available, show update available icon 688 // If a different version of package is available, show update available icon
689 // Otherwise, show installed icon 689 // Otherwise, show installed icon
690 if ( package->getNewVersionAvailable()) 690 if ( package->getNewVersionAvailable())
691 { 691 {
692 692
693 item->setPixmap( 0, updatedIcon ); 693 item->setPixmap( 0, updatedIcon );
694 } 694 }
695 else 695 else
696 { 696 {
697 item->setPixmap( 0, installedIcon ); 697 item->setPixmap( 0, installedIcon );
698 } 698 }
699 } 699 }
700 else 700 else
701 { 701 {
702 item->setPixmap( 0, nullIcon ); 702 item->setPixmap( 0, nullIcon );
703 } 703 }
704 704
705 packagesList->insertItem( item ); 705 packagesList->insertItem( item );
706 } 706 }
707 707
708 // If the local server or the local ipkgs server disable the download button 708 // If the local server or the local ipkgs server disable the download button
709 if ( serverName == LOCAL_SERVER ) 709 if ( serverName == LOCAL_SERVER )
710 { 710 {
711 downloadEnabled = TRUE; 711 downloadEnabled = TRUE;
712 actionUpgrade->setEnabled( FALSE ); 712 actionUpgrade->setEnabled( FALSE );
713 } 713 }
714 else if ( serverName == LOCAL_IPKGS ) 714 else if ( serverName == LOCAL_IPKGS )
715 { 715 {
716 downloadEnabled = FALSE; 716 downloadEnabled = FALSE;
717 actionUpgrade->setEnabled( FALSE ); 717 actionUpgrade->setEnabled( FALSE );
718 } 718 }
719 else 719 else
720 { 720 {
721 downloadEnabled = TRUE; 721 downloadEnabled = TRUE;
722 actionUpgrade->setEnabled( TRUE ); 722 actionUpgrade->setEnabled( TRUE );
723 } 723 }
724 enableDownload( downloadEnabled ); 724 enableDownload( downloadEnabled );
725 725
726 // Display this widget once everything is done 726 // Display this widget once everything is done
727 if ( doProgress && raiseProgress ) 727 if ( doProgress && raiseProgress )
728 { 728 {
729 stack->raiseWidget( networkPkgWindow ); 729 stack->raiseWidget( networkPkgWindow );
730 } 730 }
731} 731}
732 732
733void MainWindow :: searchForPackage( const QString &text ) 733void MainWindow :: searchForPackage( const QString &text )
734{ 734{
735 if ( !text.isEmpty() ) 735 if ( !text.isEmpty() )
736 { 736 {
737 // look through package list for text startng at current position 737 // look through package list for text startng at current position
738 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 738 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
739 739
740 if ( start == 0 ) 740 if ( start == 0 )
741 start = (QCheckListItem *)packagesList->firstChild(); 741 start = (QCheckListItem *)packagesList->firstChild();
742 742
743 for ( QCheckListItem *item = start; item != 0 ; 743 for ( QCheckListItem *item = start; item != 0 ;
744 item = (QCheckListItem *)item->nextSibling() ) 744 item = (QCheckListItem *)item->nextSibling() )
745 { 745 {
746 if ( item->text().lower().find( text ) != -1 ) 746 if ( item->text().lower().find( text ) != -1 )
747 { 747 {
748 packagesList->ensureItemVisible( item ); 748 packagesList->ensureItemVisible( item );
749 packagesList->setCurrentItem( item ); 749 packagesList->setCurrentItem( item );
750 break; 750 break;
751 } 751 }
752 } 752 }
753 } 753 }
754} 754}
755 755
756void MainWindow :: updateServer() 756void MainWindow :: updateServer()
757{ 757{
758 QString serverName = serversList->currentText(); 758 QString serverName = serversList->currentText();
759 759
760 // Update the current server 760 // Update the current server
761 // Display dialog 761 // Display dialog
762 762
763 // Disable buttons to stop silly people clicking lots on them :) 763 // Disable buttons to stop silly people clicking lots on them :)
764 764
765 // First, write out ipkg_conf file so that ipkg can use it 765 // First, write out ipkg_conf file so that ipkg can use it
766 mgr->writeOutIpkgConf(); 766 mgr->writeOutIpkgConf();
767 767
768 Ipkg *ipkg = new Ipkg; 768 Ipkg *ipkg = new Ipkg;
769 ipkg->setOption( "update" ); 769 ipkg->setOption( "update" );
770 770
771 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), 771 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
772 tr( "Update lists" ) ); 772 tr( "Update lists" ) );
773 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 773 connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) );
774 reloadDocuments = FALSE; 774 reloadDocuments = FALSE;
775 stack->addWidget( dlg, 3 ); 775 stack->addWidget( dlg, 3 );
776 stack->raiseWidget( dlg ); 776 stack->raiseWidget( dlg );
777 777
778 // delete progDlg; 778 // delete progDlg;
779} 779}
780 780
781void MainWindow :: upgradePackages() 781void MainWindow :: upgradePackages()
782{ 782{
783 // We're gonna do an upgrade of all packages 783 // We're gonna do an upgrade of all packages
784 // First warn user that this isn't recommended 784 // First warn user that this isn't recommended
785 // TODO - ODevice???? 785 // TODO - ODevice????
786 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 786 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
787 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 787 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
788 QMessageBox::Yes, 788 QMessageBox::Yes,
789 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 789 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
790 0, this ); 790 0, this );
791 warn.adjustSize(); 791 warn.adjustSize();
792 792
793 if ( warn.exec() == QMessageBox::Yes ) 793 if ( warn.exec() == QMessageBox::Yes )
794 { 794 {
795 // First, write out ipkg_conf file so that ipkg can use it 795 // First, write out ipkg_conf file so that ipkg can use it
796 mgr->writeOutIpkgConf(); 796 mgr->writeOutIpkgConf();
797 797
798 // Now run upgrade 798 // Now run upgrade
799 Ipkg *ipkg = new Ipkg; 799 Ipkg *ipkg = new Ipkg;
800 ipkg->setOption( "upgrade" ); 800 ipkg->setOption( "upgrade" );
801 801
802 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), 802 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
803 tr ( "Upgrade" ) ); 803 tr ( "Upgrade" ) );
804 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 804 connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) );
805 reloadDocuments = TRUE; 805 reloadDocuments = TRUE;
806 stack->addWidget( dlg, 3 ); 806 stack->addWidget( dlg, 3 );
807 stack->raiseWidget( dlg ); 807 stack->raiseWidget( dlg );
808 } 808 }
809} 809}
810 810
811void MainWindow :: downloadPackage() 811void MainWindow :: downloadPackage()
812{ 812{
813 bool doUpdate = true; 813 bool doUpdate = true;
814 if ( downloadEnabled ) 814 if ( downloadEnabled )
815 { 815 {
816 // See if any packages are selected 816 // See if any packages are selected
817 bool found = false; 817 bool found = false;
818 if ( serversList->currentText() != LOCAL_SERVER ) 818 if ( serversList->currentText() != LOCAL_SERVER )
819 { 819 {
820 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 820 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
821 item != 0 && !found; 821 item != 0 && !found;
822 item = (QCheckListItem *)item->nextSibling() ) 822 item = (QCheckListItem *)item->nextSibling() )
823 { 823 {
824 if ( item->isOn() ) 824 if ( item->isOn() )
825 found = true; 825 found = true;
826 } 826 }
827 } 827 }
828 828
829 // If user selected some packages then download the and store the locally 829 // If user selected some packages then download the and store the locally
830 // otherwise, display dialog asking user what package to download from an http server 830 // otherwise, display dialog asking user what package to download from an http server
831 // and whether to install it 831 // and whether to install it
832 if ( found ) 832 if ( found )
833 downloadSelectedPackages(); 833 downloadSelectedPackages();
834 else 834 else
835 downloadRemotePackage(); 835 downloadRemotePackage();
836 836
837 } 837 }
838 else 838 else
839 { 839 {
840 doUpdate = false; 840 doUpdate = false;
841 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 841 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
842 item != 0 ; 842 item != 0 ;
843 item = (QCheckListItem *)item->nextSibling() ) 843 item = (QCheckListItem *)item->nextSibling() )
844 { 844 {
845 if ( item->isOn() ) 845 if ( item->isOn() )
846 { 846 {
847 QString name = item->text(); 847 QString name = item->text();
848 int pos = name.find( "*" ); 848 int pos = name.find( "*" );
849 name.truncate( pos ); 849 name.truncate( pos );
850 850
851 // if (there is a (installed), remove it 851 // if (there is a (installed), remove it
852 pos = name.find( "(installed)" ); 852 pos = name.find( "(installed)" );
853 if ( pos > 0 ) 853 if ( pos > 0 )
854 name.truncate( pos - 1 ); 854 name.truncate( pos - 1 );
855 855
856 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); 856 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
857 857
858 QString msgtext; 858 QString msgtext;
859 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); 859 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
860 if ( QMessageBox::information( this, tr( "Are you sure?" ), 860 if ( QMessageBox::information( this, tr( "Are you sure?" ),
861 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) 861 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
862 { 862 {
863 doUpdate = true; 863 doUpdate = true;
864 QFile f( p->getFilename() ); 864 QFile f( p->getFilename() );
865 f.remove(); 865 f.remove();
866 } 866 }
867 } 867 }
868 } 868 }
869 } 869 }
870 870
871 if ( doUpdate ) 871 if ( doUpdate )
872 { 872 {
873 reloadData( 0x0 ); 873 reloadData( 0x0 );
874 } 874 }
875} 875}
876 876
877void MainWindow :: downloadSelectedPackages() 877void MainWindow :: downloadSelectedPackages()
878{ 878{
879 // First, write out ipkg_conf file so that ipkg can use it 879 // First, write out ipkg_conf file so that ipkg can use it
880 mgr->writeOutIpkgConf(); 880 mgr->writeOutIpkgConf();
881 881
882 // Display dialog to user asking where to download the files to 882 // Display dialog to user asking where to download the files to
883 bool ok = FALSE; 883 bool ok = FALSE;
884 QString dir = ""; 884 QString dir = "";
885#ifdef QWS 885#ifdef QWS
886 // read download directory from config file 886 // read download directory from config file
887 Config cfg( "aqpkg" ); 887 Config cfg( "aqpkg" );
888 cfg.setGroup( "settings" ); 888 cfg.setGroup( "settings" );
889 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 889 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
890#endif 890#endif
891 891
892 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 892 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
893 if ( ok && !text.isEmpty() ) 893 if ( ok && !text.isEmpty() )
894 dir = text; // user entered something and pressed ok 894 dir = text; // user entered something and pressed ok
895 else 895 else
896 return; // user entered nothing or pressed cancel 896 return; // user entered nothing or pressed cancel
897 897
898#ifdef QWS 898#ifdef QWS
899 // Store download directory in config file 899 // Store download directory in config file
900 cfg.writeEntry( "downloadDir", dir ); 900 cfg.writeEntry( "downloadDir", dir );
901#endif 901#endif
902 902
903 // Get starting directory 903 // Get starting directory
904 char initDir[PATH_MAX]; 904 char initDir[PATH_MAX];
905 getcwd( initDir, PATH_MAX ); 905 getcwd( initDir, PATH_MAX );
906 906
907 // Download each package 907 // Download each package
908 Ipkg ipkg; 908 Ipkg ipkg;
909 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 909 connect( &ipkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&)));
910 910
911 ipkg.setOption( "download" ); 911 ipkg.setOption( "download" );
912 ipkg.setRuntimeDirectory( dir ); 912 ipkg.setRuntimeDirectory( dir );
913 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 913 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
914 item != 0 ; 914 item != 0 ;
915 item = (QCheckListItem *)item->nextSibling() ) 915 item = (QCheckListItem *)item->nextSibling() )
916 { 916 {
917 if ( item->isOn() ) 917 if ( item->isOn() )
918 { 918 {
919 ipkg.setPackage( item->text() ); 919 ipkg.setPackage( item->text() );
920 ipkg.runIpkg( ); 920 ipkg.runIpkg( );
921 } 921 }
922 } 922 }
923} 923}
924 924
925void MainWindow :: downloadRemotePackage() 925void MainWindow :: downloadRemotePackage()
926{ 926{
927 // Display dialog 927 // Display dialog
928 bool ok; 928 bool ok;
929 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 929 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
930 if ( !ok || package.isEmpty() ) 930 if ( !ok || package.isEmpty() )
931 return; 931 return;
932 // DownloadRemoteDlgImpl dlg( this, "Install", true ); 932 // DownloadRemoteDlgImpl dlg( this, "Install", true );
933 // if ( dlg.exec() == QDialog::Rejected ) 933 // if ( dlg.exec() == QDialog::Rejected )
934 // return; 934 // return;
935 935
936 // grab details from dialog 936 // grab details from dialog
937 // QString package = dlg.getPackageLocation(); 937 // QString package = dlg.getPackageLocation();
938 938
939 InstallData *item = new InstallData(); 939 InstallData *item = new InstallData();
940 item->option = "I"; 940 item->option = "I";
941 item->packageName = package; 941 item->packageName = package;
942 QList<InstallData> workingPackages; 942 QList<InstallData> workingPackages;
943 workingPackages.setAutoDelete( TRUE ); 943 workingPackages.setAutoDelete( TRUE );
944 workingPackages.append( item ); 944 workingPackages.append( item );
945 945
946 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); 946 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
947 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 947 connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) );
948 reloadDocuments = TRUE; 948 reloadDocuments = TRUE;
949 stack->addWidget( dlg, 3 ); 949 stack->addWidget( dlg, 3 );
950 stack->raiseWidget( dlg ); 950 stack->raiseWidget( dlg );
951} 951}
952 952
953 953
954void MainWindow :: applyChanges() 954void MainWindow :: applyChanges()
955{ 955{
956 stickyOption = ""; 956 stickyOption = "";
957 957
958 // First, write out ipkg_conf file so that ipkg can use it 958 // First, write out ipkg_conf file so that ipkg can use it
959 mgr->writeOutIpkgConf(); 959 mgr->writeOutIpkgConf();
960 960
961 // Now for each selected item 961 // Now for each selected item
962 // deal with it 962 // deal with it
963 963
964 QList<InstallData> workingPackages; 964 QList<InstallData> workingPackages;
965 workingPackages.setAutoDelete( TRUE ); 965 workingPackages.setAutoDelete( TRUE );
966 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 966 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
967 item != 0 ; 967 item != 0 ;
968 item = (QCheckListItem *)item->nextSibling() ) 968 item = (QCheckListItem *)item->nextSibling() )
969 { 969 {
970 if ( item->isOn() ) 970 if ( item->isOn() )
971 { 971 {
972 InstallData *instdata = dealWithItem( item ); 972 InstallData *instdata = dealWithItem( item );
973 if ( instdata ) 973 if ( instdata )
974 workingPackages.append( instdata ); 974 workingPackages.append( instdata );
975 else 975 else
976 return; 976 return;
977 } 977 }
978 } 978 }
979 979
980 if ( workingPackages.count() == 0 ) 980 if ( workingPackages.count() == 0 )
981 { 981 {
982 // Nothing to do 982 // Nothing to do
983 QMessageBox::information( this, tr( "Nothing to do" ), 983 QMessageBox::information( this, tr( "Nothing to do" ),
984 tr( "No packages selected" ), tr( "OK" ) ); 984 tr( "No packages selected" ), tr( "OK" ) );
985 985
986 return; 986 return;
987 } 987 }
988 988
989 // do the stuff 989 // do the stuff
990 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); 990 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
991 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 991 connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) );
992 reloadDocuments = TRUE; 992 reloadDocuments = TRUE;
993 stack->addWidget( dlg, 3 ); 993 stack->addWidget( dlg, 3 );
994 stack->raiseWidget( dlg ); 994 stack->raiseWidget( dlg );
995} 995}
996 996
997// decide what to do - either remove, upgrade or install 997// decide what to do - either remove, upgrade or install
998// Current rules: 998// Current rules:
999// If not installed - install 999// If not installed - install
1000// If installed and different version available - upgrade 1000// If installed and different version available - upgrade
1001// If installed and version up to date - remove 1001// If installed and version up to date - remove
1002InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 1002InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
1003{ 1003{
1004 QString name = item->text(); 1004 QString name = item->text();
1005 1005
1006 // Get package 1006 // Get package
1007 Server *s = mgr->getServer( serversList->currentText() ); 1007 Server *s = mgr->getServer( serversList->currentText() );
1008 Package *p = s->getPackage( name ); 1008 Package *p = s->getPackage( name );
1009 1009
1010 // If the package has a filename then it is a local file 1010 // If the package has a filename then it is a local file
1011 if ( p->isPackageStoredLocally() ) 1011 if ( p->isPackageStoredLocally() )
1012 name = p->getFilename(); 1012 name = p->getFilename();
1013 1013
1014 QString option; 1014 QString option;
1015 QString dest = "root"; 1015 QString dest = "root";
1016 if ( !p->isInstalled() ) 1016 if ( !p->isInstalled() )
1017 { 1017 {
1018 InstallData *newitem = new InstallData(); 1018 InstallData *newitem = new InstallData();
1019 newitem->option = "I"; 1019 newitem->option = "I";
1020 newitem->packageName = name; 1020 newitem->packageName = name;
1021 return newitem; 1021 return newitem;
1022 } 1022 }
1023 else 1023 else
1024 { 1024 {
1025 InstallData *newitem = new InstallData(); 1025 InstallData *newitem = new InstallData();
1026 newitem->option = "D"; 1026 newitem->option = "D";
1027 // If local file, remove using package name, not filename 1027 // If local file, remove using package name, not filename
1028 if ( p->isPackageStoredLocally() ) 1028 if ( p->isPackageStoredLocally() )
1029 name = item->text(); 1029 name = item->text();
1030 1030
1031 if ( !p->isPackageStoredLocally() ) 1031 if ( !p->isPackageStoredLocally() )
1032 newitem->packageName = p->getInstalledPackageName(); 1032 newitem->packageName = p->getInstalledPackageName();
1033 else 1033 else
1034 newitem->packageName = name; 1034 newitem->packageName = name;
1035 1035
1036 if ( p->getInstalledTo() ) 1036 if ( p->getInstalledTo() )
1037 { 1037 {
1038 newitem->destination = p->getInstalledTo(); 1038 newitem->destination = p->getInstalledTo();
1039 } 1039 }
1040 else 1040 else
1041 { 1041 {
1042 newitem->destination = p->getLocalPackage()->getInstalledTo(); 1042 newitem->destination = p->getLocalPackage()->getInstalledTo();
1043 } 1043 }
1044 1044
1045 // Now see if version is newer or not 1045 // Now see if version is newer or not
1046 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1046 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1047 1047
1048 // If the version requested is older and user selected a local ipk file, then reinstall the file 1048 // If the version requested is older and user selected a local ipk file, then reinstall the file
1049 if ( p->isPackageStoredLocally() && val == -1 ) 1049 if ( p->isPackageStoredLocally() && val == -1 )
1050 val = 0; 1050 val = 0;
1051 1051
1052 if ( val == -2 ) 1052 if ( val == -2 )
1053 { 1053 {
1054 // Error - should handle 1054 // Error - should handle
1055 } 1055 }
1056 else if ( val == -1 ) 1056 else if ( val == -1 )
1057 { 1057 {
1058 // Version available is older - remove only 1058 // Version available is older - remove only
1059 newitem->option = "D"; 1059 newitem->option = "D";
1060 // If local file, remove using package name, not filename 1060 // If local file, remove using package name, not filename
1061 if ( p->isPackageStoredLocally() ) 1061 if ( p->isPackageStoredLocally() )
1062 name = item->text(); 1062 name = item->text();
1063 } 1063 }
1064 else 1064 else
1065 { 1065 {
1066 QString caption; 1066 QString caption;
1067 QString text; 1067 QString text;
1068 QString secondButton; 1068 QString secondButton;
1069 QString secondOption; 1069 QString secondOption;
1070 if ( val == 0 ) 1070 if ( val == 0 )
1071 { 1071 {
1072 // Version available is the same - option to remove or reinstall 1072 // Version available is the same - option to remove or reinstall
1073 caption = tr( "Do you wish to remove or reinstall\n%1?" ); 1073 caption = tr( "Do you wish to remove or reinstall\n%1?" );
1074 text = tr( "Remove or ReInstall" ); 1074 text = tr( "Remove or ReInstall" );
1075 secondButton = tr( "ReInstall" ); 1075 secondButton = tr( "ReInstall" );
1076 secondOption = "R"; // Internal action code, do not translate 1076 secondOption = "R"; // Internal action code, do not translate
1077 } 1077 }
1078 else if ( val == 1 ) 1078 else if ( val == 1 )
1079 { 1079 {
1080 // Version available is newer - option to remove or upgrade 1080 // Version available is newer - option to remove or upgrade
1081 caption = tr( "Do you wish to remove or upgrade\n%1?" ); 1081 caption = tr( "Do you wish to remove or upgrade\n%1?" );
1082 text = tr( "Remove or Upgrade" ); 1082 text = tr( "Remove or Upgrade" );
1083 secondButton = tr( "Upgrade" ); 1083 secondButton = tr( "Upgrade" );
1084 secondOption = "U"; // Internal action code, do not translate 1084 secondOption = "U"; // Internal action code, do not translate
1085 } 1085 }
1086 1086
1087 // Sticky option not implemented yet, but will eventually allow 1087 // Sticky option not implemented yet, but will eventually allow