summaryrefslogtreecommitdiff
authordrw <drw>2003-03-29 20:46:43 (UTC)
committer drw <drw>2003-03-29 20:46:43 (UTC)
commit4e17e397c6df9e4e1ac6ee8315bbbced3e3b3b49 (patch) (unidiff)
treec2e356050c9b8b6a17f917c0e7c90c169ee1ce0d
parent4bf2c892cebbf80e825a717b6240d0377a2060ac (diff)
downloadopie-4e17e397c6df9e4e1ac6ee8315bbbced3e3b3b49.zip
opie-4e17e397c6df9e4e1ac6ee8315bbbced3e3b3b49.tar.gz
opie-4e17e397c6df9e4e1ac6ee8315bbbced3e3b3b49.tar.bz2
Move Configure option under the Actions menu, allowing me to remove the top-level menu 'Options' (which only had the Config entry under it).
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 7fa311d..b597e03 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,1191 +1,1186 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.cpp - description 2 mainwin.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <linux/limits.h> 18#include <linux/limits.h>
19#include <unistd.h> 19#include <unistd.h>
20 20
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27 27
28#include <qaction.h> 28#include <qaction.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qlineedit.h> 33#include <qlineedit.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qmenubar.h> 35#include <qmenubar.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qtimer.h> 39#include <qtimer.h>
40#include <qwhatsthis.h> 40#include <qwhatsthis.h>
41#include <qwidgetstack.h> 41#include <qwidgetstack.h>
42 42
43#include "categoryfilterimpl.h" 43#include "categoryfilterimpl.h"
44#include "datamgr.h" 44#include "datamgr.h"
45#include "global.h" 45#include "global.h"
46#include "inputdlg.h" 46#include "inputdlg.h"
47#include "ipkg.h" 47#include "ipkg.h"
48#include "installdlgimpl.h" 48#include "installdlgimpl.h"
49#include "letterpushbutton.h" 49#include "letterpushbutton.h"
50#include "mainwin.h" 50#include "mainwin.h"
51#include "settingsimpl.h" 51#include "settingsimpl.h"
52#include "utils.h" 52#include "utils.h"
53 53
54extern int compareVersions( const char *v1, const char *v2 ); 54extern int compareVersions( const char *v1, const char *v2 );
55 55
56MainWindow :: MainWindow() 56MainWindow :: MainWindow()
57 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) 57 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
58{ 58{
59 setCaption( tr( "AQPkg - Package Manager" ) ); 59 setCaption( tr( "AQPkg - Package Manager" ) );
60 60
61 // Create UI widgets 61 // Create UI widgets
62 initMainWidget(); 62 initMainWidget();
63 initProgressWidget(); 63 initProgressWidget();
64 64
65 // Build menu and tool bars 65 // Build menu and tool bars
66 setToolBarsMovable( FALSE ); 66 setToolBarsMovable( FALSE );
67 67
68 QPEToolBar *bar = new QPEToolBar( this ); 68 QPEToolBar *bar = new QPEToolBar( this );
69 bar->setHorizontalStretchable( TRUE ); 69 bar->setHorizontalStretchable( TRUE );
70 QPEMenuBar *mb = new QPEMenuBar( bar ); 70 QPEMenuBar *mb = new QPEMenuBar( bar );
71 mb->setMargin( 0 ); 71 mb->setMargin( 0 );
72 bar = new QPEToolBar( this ); 72 bar = new QPEToolBar( this );
73 73
74 // Find toolbar 74 // Find toolbar
75 findBar = new QPEToolBar( this ); 75 findBar = new QPEToolBar( this );
76 addToolBar( findBar, QMainWindow::Top, true ); 76 addToolBar( findBar, QMainWindow::Top, true );
77 findBar->setHorizontalStretchable( true ); 77 findBar->setHorizontalStretchable( true );
78 findEdit = new QLineEdit( findBar ); 78 findEdit = new QLineEdit( findBar );
79 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); 79 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
80 findBar->setStretchableWidget( findEdit ); 80 findBar->setStretchableWidget( findEdit );
81 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); 81 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
82 82
83 // Quick jump toolbar 83 // Quick jump toolbar
84 jumpBar = new QPEToolBar( this ); 84 jumpBar = new QPEToolBar( this );
85 addToolBar( jumpBar, QMainWindow::Top, true ); 85 addToolBar( jumpBar, QMainWindow::Top, true );
86 jumpBar->setHorizontalStretchable( true ); 86 jumpBar->setHorizontalStretchable( true );
87 QWidget *w = new QWidget( jumpBar ); 87 QWidget *w = new QWidget( jumpBar );
88 jumpBar->setStretchableWidget( w ); 88 jumpBar->setStretchableWidget( w );
89 89
90 QGridLayout *layout = new QGridLayout( w ); 90 QGridLayout *layout = new QGridLayout( w );
91 91
92 char text[2]; 92 char text[2];
93 text[1] = '\0'; 93 text[1] = '\0';
94 for ( int i = 0 ; i < 26 ; ++i ) 94 for ( int i = 0 ; i < 26 ; ++i )
95 { 95 {
96 text[0] = 'A' + i; 96 text[0] = 'A' + i;
97 LetterPushButton *b = new LetterPushButton( text, w ); 97 LetterPushButton *b = new LetterPushButton( text, w );
98 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 98 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
99 layout->addWidget( b, i / 13, i % 13); 99 layout->addWidget( b, i / 13, i % 13);
100 } 100 }
101 101
102 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); 102 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
103 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); 103 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
104 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); 104 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
105 a->addTo( jumpBar ); 105 a->addTo( jumpBar );
106 jumpBar->hide(); 106 jumpBar->hide();
107 107
108 // Packages menu 108 // Packages menu
109 QPopupMenu *popup = new QPopupMenu( this ); 109 QPopupMenu *popup = new QPopupMenu( this );
110 110
111 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); 111 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
112 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 112 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
113 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); 113 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
114 a->addTo( popup ); 114 a->addTo( popup );
115 a->addTo( bar ); 115 a->addTo( bar );
116 116
117 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); 117 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
118 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 118 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
119 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); 119 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
120 actionUpgrade->addTo( popup ); 120 actionUpgrade->addTo( popup );
121 actionUpgrade->addTo( bar ); 121 actionUpgrade->addTo( bar );
122 122
123 iconDownload = Resource::loadPixmap( "aqpkg/download" ); 123 iconDownload = Resource::loadPixmap( "aqpkg/download" );
124 iconRemove = Resource::loadPixmap( "aqpkg/remove" ); 124 iconRemove = Resource::loadPixmap( "aqpkg/remove" );
125 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 125 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
126 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 126 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
127 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); 127 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
128 actionDownload->addTo( popup ); 128 actionDownload->addTo( popup );
129 actionDownload->addTo( bar ); 129 actionDownload->addTo( bar );
130 130
131 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); 131 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
132 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 132 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
133 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); 133 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
134 a->addTo( popup ); 134 a->addTo( popup );
135 a->addTo( bar ); 135 a->addTo( bar );
136 136
137 popup->insertSeparator();
138
139 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
140 a->setWhatsThis( tr( "Click here to configure this application." ) );
141 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
142 a->addTo( popup );
137 mb->insertItem( tr( "Actions" ), popup ); 143 mb->insertItem( tr( "Actions" ), popup );
138 144
139 // View menu 145 // View menu
140 popup = new QPopupMenu( this ); 146 popup = new QPopupMenu( this );
141 147
142 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 148 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
143 actionUninstalled->setToggleAction( TRUE ); 149 actionUninstalled->setToggleAction( TRUE );
144 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 150 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
145 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); 151 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
146 actionUninstalled->addTo( popup ); 152 actionUninstalled->addTo( popup );
147 153
148 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 154 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
149 actionInstalled->setToggleAction( TRUE ); 155 actionInstalled->setToggleAction( TRUE );
150 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 156 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
151 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); 157 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
152 actionInstalled->addTo( popup ); 158 actionInstalled->addTo( popup );
153 159
154 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 160 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
155 actionUpdated->setToggleAction( TRUE ); 161 actionUpdated->setToggleAction( TRUE );
156 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 162 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
157 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); 163 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
158 actionUpdated->addTo( popup ); 164 actionUpdated->addTo( popup );
159 165
160 popup->insertSeparator(); 166 popup->insertSeparator();
161 167
162 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); 168 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
163 actionFilter->setToggleAction( TRUE ); 169 actionFilter->setToggleAction( TRUE );
164 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); 170 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
165 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); 171 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
166 actionFilter->addTo( popup ); 172 actionFilter->addTo( popup );
167 173
168 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); 174 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
169 a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); 175 a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
170 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); 176 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
171 a->addTo( popup ); 177 a->addTo( popup );
172 178
173 popup->insertSeparator(); 179 popup->insertSeparator();
174 180
175 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 181 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
176 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 182 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
177 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); 183 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
178 a->addTo( popup ); 184 a->addTo( popup );
179 185
180 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 186 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
181 actionFindNext->setEnabled( FALSE ); 187 actionFindNext->setEnabled( FALSE );
182 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 188 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
183 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); 189 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
184 actionFindNext->addTo( popup ); 190 actionFindNext->addTo( popup );
185 actionFindNext->addTo( findBar ); 191 actionFindNext->addTo( findBar );
186 192
187 193
188 popup->insertSeparator(); 194 popup->insertSeparator();
189 195
190 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); 196 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 );
191 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); 197 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) );
192 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); 198 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) );
193 a->addTo( popup ); 199 a->addTo( popup );
194 200
195 mb->insertItem( tr( "View" ), popup ); 201 mb->insertItem( tr( "View" ), popup );
196
197
198 // Options menu
199 popup = new QPopupMenu( this );
200
201 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
202 a->setWhatsThis( tr( "Click here to configure this application." ) );
203 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
204 a->addTo( popup );
205
206 mb->insertItem( tr( "Options" ), popup );
207 202
208 // Finish find toolbar creation 203 // Finish find toolbar creation
209 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 204 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
210 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); 205 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
211 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); 206 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
212 a->addTo( findBar ); 207 a->addTo( findBar );
213 findBar->hide(); 208 findBar->hide();
214 209
215 // Create widget stack and add UI widgets 210 // Create widget stack and add UI widgets
216 stack = new QWidgetStack( this ); 211 stack = new QWidgetStack( this );
217 stack->addWidget( progressWindow, 2 ); 212 stack->addWidget( progressWindow, 2 );
218 stack->addWidget( networkPkgWindow, 1 ); 213 stack->addWidget( networkPkgWindow, 1 );
219 setCentralWidget( stack ); 214 setCentralWidget( stack );
220 stack->raiseWidget( progressWindow ); 215 stack->raiseWidget( progressWindow );
221 216
222 // Delayed call to finish initialization 217 // Delayed call to finish initialization
223 QTimer::singleShot( 100, this, SLOT( init() ) ); 218 QTimer::singleShot( 100, this, SLOT( init() ) );
224} 219}
225 220
226MainWindow :: ~MainWindow() 221MainWindow :: ~MainWindow()
227{ 222{
228 delete mgr; 223 delete mgr;
229} 224}
230 225
231void MainWindow :: initMainWidget() 226void MainWindow :: initMainWidget()
232{ 227{
233 networkPkgWindow = new QWidget( this ); 228 networkPkgWindow = new QWidget( this );
234 229
235 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); 230 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
236 231
237 serversList = new QComboBox( networkPkgWindow ); 232 serversList = new QComboBox( networkPkgWindow );
238 connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); 233 connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) );
239 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); 234 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
240 235
241 installedIcon = Resource::loadPixmap( "installed" ); 236 installedIcon = Resource::loadPixmap( "installed" );
242 updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); 237 updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
243 238
244 packagesList = new QListView( networkPkgWindow ); 239 packagesList = new QListView( networkPkgWindow );
245 packagesList->addColumn( tr( "Packages" ), 225 ); 240 packagesList->addColumn( tr( "Packages" ), 225 );
246 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." ) ); 241 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." ) );
247 242
248 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); 243 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 );
249 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); 244 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
250 hbox1->addWidget( l ); 245 hbox1->addWidget( l );
251 hbox1->addWidget( serversList ); 246 hbox1->addWidget( serversList );
252 247
253 vbox->addWidget( packagesList ); 248 vbox->addWidget( packagesList );
254 249
255 downloadEnabled = TRUE; 250 downloadEnabled = TRUE;
256} 251}
257 252
258void MainWindow :: initProgressWidget() 253void MainWindow :: initProgressWidget()
259{ 254{
260 progressWindow = new QWidget( this ); 255 progressWindow = new QWidget( this );
261 256
262 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); 257 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
263 258
264 m_status = new QLabel( progressWindow ); 259 m_status = new QLabel( progressWindow );
265 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 260 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
266 layout->addWidget( m_status ); 261 layout->addWidget( m_status );
267 262
268 m_progress = new QProgressBar( progressWindow ); 263 m_progress = new QProgressBar( progressWindow );
269 layout->addWidget( m_progress ); 264 layout->addWidget( m_progress );
270} 265}
271 266
272void MainWindow :: init() 267void MainWindow :: init()
273{ 268{
274#ifdef QWS 269#ifdef QWS
275 // read download directory from config file 270 // read download directory from config file
276 Config cfg( "aqpkg" ); 271 Config cfg( "aqpkg" );
277 cfg.setGroup( "settings" ); 272 cfg.setGroup( "settings" );
278 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 273 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
279// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 274// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
280 275
281#endif 276#endif
282 277
283 stack->raiseWidget( progressWindow ); 278 stack->raiseWidget( progressWindow );
284 279
285 mgr = new DataManager(); 280 mgr = new DataManager();
286 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); 281 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
287 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 282 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
288 this, SLOT( setProgressMessage( const QString & ) ) ); 283 this, SLOT( setProgressMessage( const QString & ) ) );
289 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); 284 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
290 mgr->loadServers(); 285 mgr->loadServers();
291 286
292 showUninstalledPkgs = false; 287 showUninstalledPkgs = false;
293 showInstalledPkgs = false; 288 showInstalledPkgs = false;
294 showUpgradedPkgs = false; 289 showUpgradedPkgs = false;
295 categoryFilterEnabled = false; 290 categoryFilterEnabled = false;
296 291
297 updateData(); 292 updateData();
298 293
299 stack->raiseWidget( networkPkgWindow ); 294 stack->raiseWidget( networkPkgWindow );
300} 295}
301/* 296/*
302void MainWindow :: setDocument( const QString &doc ) 297void MainWindow :: setDocument( const QString &doc )
303{ 298{
304 // Remove path from package 299 // Remove path from package
305 QString package = Utils::getPackageNameFromIpkFilename( doc ); 300 QString package = Utils::getPackageNameFromIpkFilename( doc );
306// std::cout << "Selecting package " << package << std::endl; 301// std::cout << "Selecting package " << package << std::endl;
307 302
308 // First select local server 303 // First select local server
309 for ( int i = 0 ; i < serversList->count() ; ++i ) 304 for ( int i = 0 ; i < serversList->count() ; ++i )
310 { 305 {
311 if ( serversList->text( i ) == LOCAL_IPKGS ) 306 if ( serversList->text( i ) == LOCAL_IPKGS )
312 { 307 {
313 serversList->setCurrentItem( i ); 308 serversList->setCurrentItem( i );
314 break; 309 break;
315 } 310 }
316 } 311 }
317 serverSelected( 0 ); 312 serverSelected( 0 );
318 313
319 // Now set the check box of the selected package 314 // Now set the check box of the selected package
320 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 315 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
321 item != 0 ; 316 item != 0 ;
322 item = (QCheckListItem *)item->nextSibling() ) 317 item = (QCheckListItem *)item->nextSibling() )
323 { 318 {
324 if ( item->text().startsWith( package ) ) 319 if ( item->text().startsWith( package ) )
325 { 320 {
326 item->setOn( true ); 321 item->setOn( true );
327 break; 322 break;
328 } 323 }
329 } 324 }
330} 325}
331*/ 326*/
332void MainWindow :: displaySettings() 327void MainWindow :: displaySettings()
333{ 328{
334 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 329 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
335 if ( dlg->showDlg() ) 330 if ( dlg->showDlg() )
336 { 331 {
337 stack->raiseWidget( progressWindow ); 332 stack->raiseWidget( progressWindow );
338 updateData(); 333 updateData();
339 stack->raiseWidget( networkPkgWindow ); 334 stack->raiseWidget( networkPkgWindow );
340 } 335 }
341 delete dlg; 336 delete dlg;
342} 337}
343 338
344void MainWindow :: closeEvent( QCloseEvent *e ) 339void MainWindow :: closeEvent( QCloseEvent *e )
345{ 340{
346 // If install dialog is visible, return to main view, otherwise close app 341 // If install dialog is visible, return to main view, otherwise close app
347 QWidget *widget = stack->visibleWidget(); 342 QWidget *widget = stack->visibleWidget();
348 343
349 if ( widget != networkPkgWindow && widget != progressWindow ) 344 if ( widget != networkPkgWindow && widget != progressWindow )
350 { 345 {
351 if ( widget ) delete widget; 346 if ( widget ) delete widget;
352 stack->raiseWidget( networkPkgWindow ); 347 stack->raiseWidget( networkPkgWindow );
353 e->ignore(); 348 e->ignore();
354 } 349 }
355 else 350 else
356 { 351 {
357 e->accept(); 352 e->accept();
358 } 353 }
359} 354}
360 355
361void MainWindow :: displayFindBar() 356void MainWindow :: displayFindBar()
362{ 357{
363 findBar->show(); 358 findBar->show();
364 findEdit->setFocus(); 359 findEdit->setFocus();
365} 360}
366 361
367void MainWindow :: displayJumpBar() 362void MainWindow :: displayJumpBar()
368{ 363{
369 jumpBar->show(); 364 jumpBar->show();
370} 365}
371 366
372void MainWindow :: repeatFind() 367void MainWindow :: repeatFind()
373{ 368{
374 searchForPackage( findEdit->text() ); 369 searchForPackage( findEdit->text() );
375} 370}
376 371
377void MainWindow :: findPackage( const QString &text ) 372void MainWindow :: findPackage( const QString &text )
378{ 373{
379 actionFindNext->setEnabled( !text.isEmpty() ); 374 actionFindNext->setEnabled( !text.isEmpty() );
380 searchForPackage( text ); 375 searchForPackage( text );
381} 376}
382 377
383void MainWindow :: hideFindBar() 378void MainWindow :: hideFindBar()
384{ 379{
385 findBar->hide(); 380 findBar->hide();
386} 381}
387 382
388void MainWindow :: hideJumpBar() 383void MainWindow :: hideJumpBar()
389{ 384{
390 jumpBar->hide(); 385 jumpBar->hide();
391} 386}
392 387
393void MainWindow :: filterUninstalledPackages() 388void MainWindow :: filterUninstalledPackages()
394{ 389{
395 showUninstalledPkgs = actionUninstalled->isOn(); 390 showUninstalledPkgs = actionUninstalled->isOn();
396 if ( showUninstalledPkgs ) 391 if ( showUninstalledPkgs )
397 { 392 {
398 showInstalledPkgs = FALSE; 393 showInstalledPkgs = FALSE;
399 showUpgradedPkgs = FALSE; 394 showUpgradedPkgs = FALSE;
400 } 395 }
401 serverSelected( -1 ); 396 serverSelected( -1 );
402 397
403 actionInstalled->setOn( FALSE ); 398 actionInstalled->setOn( FALSE );
404 actionUpdated->setOn( FALSE ); 399 actionUpdated->setOn( FALSE );
405} 400}
406 401
407void MainWindow :: filterInstalledPackages() 402void MainWindow :: filterInstalledPackages()
408{ 403{
409 showInstalledPkgs = actionInstalled->isOn(); 404 showInstalledPkgs = actionInstalled->isOn();
410 if ( showInstalledPkgs ) 405 if ( showInstalledPkgs )
411 { 406 {
412 showUninstalledPkgs = FALSE; 407 showUninstalledPkgs = FALSE;
413 showUpgradedPkgs = FALSE; 408 showUpgradedPkgs = FALSE;
414 } 409 }
415 serverSelected( -1 ); 410 serverSelected( -1 );
416 411
417 actionUninstalled->setOn( FALSE ); 412 actionUninstalled->setOn( FALSE );
418 actionUpdated->setOn( FALSE ); 413 actionUpdated->setOn( FALSE );
419} 414}
420 415
421void MainWindow :: filterUpgradedPackages() 416void MainWindow :: filterUpgradedPackages()
422{ 417{
423 showUpgradedPkgs = actionUpdated->isOn(); 418 showUpgradedPkgs = actionUpdated->isOn();
424 if ( showUpgradedPkgs ) 419 if ( showUpgradedPkgs )
425 { 420 {
426 showUninstalledPkgs = FALSE; 421 showUninstalledPkgs = FALSE;
427 showInstalledPkgs = FALSE; 422 showInstalledPkgs = FALSE;
428 } 423 }
429 serverSelected( -1 ); 424 serverSelected( -1 );
430 425
431 actionUninstalled->setOn( FALSE ); 426 actionUninstalled->setOn( FALSE );
432 actionInstalled->setOn( FALSE ); 427 actionInstalled->setOn( FALSE );
433} 428}
434 429
435bool MainWindow :: setFilterCategory() 430bool MainWindow :: setFilterCategory()
436{ 431{
437 // Get categories; 432 // Get categories;
438 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); 433 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
439 if ( dlg.exec() == QDialog::Accepted ) 434 if ( dlg.exec() == QDialog::Accepted )
440 { 435 {
441 categoryFilter = dlg.getSelectedFilter(); 436 categoryFilter = dlg.getSelectedFilter();
442 437
443 if ( categoryFilter == "" ) 438 if ( categoryFilter == "" )
444 return false; 439 return false;
445 440
446 categoryFilterEnabled = true; 441 categoryFilterEnabled = true;
447 serverSelected( -1 ); 442 serverSelected( -1 );
448 actionFilter->setOn( TRUE ); 443 actionFilter->setOn( TRUE );
449 return true; 444 return true;
450 } 445 }
451 446
452 return false; 447 return false;
453} 448}
454 449
455void MainWindow :: filterCategory() 450void MainWindow :: filterCategory()
456{ 451{
457 if ( !actionFilter->isOn() ) 452 if ( !actionFilter->isOn() )
458 { 453 {
459 filterByCategory( FALSE ); 454 filterByCategory( FALSE );
460 } 455 }
461 else 456 else
462 { 457 {
463 actionFilter->setOn( filterByCategory( TRUE ) ); 458 actionFilter->setOn( filterByCategory( TRUE ) );
464 } 459 }
465} 460}
466 461
467bool MainWindow :: filterByCategory( bool val ) 462bool MainWindow :: filterByCategory( bool val )
468{ 463{
469 if ( val ) 464 if ( val )
470 { 465 {
471 if ( categoryFilter == "" ) 466 if ( categoryFilter == "" )
472 { 467 {
473 if ( !setFilterCategory() ) 468 if ( !setFilterCategory() )
474 return false; 469 return false;
475 } 470 }
476 471
477 categoryFilterEnabled = true; 472 categoryFilterEnabled = true;
478 serverSelected( -1 ); 473 serverSelected( -1 );
479 return true; 474 return true;
480 } 475 }
481 else 476 else
482 { 477 {
483 // Turn off filter 478 // Turn off filter
484 categoryFilterEnabled = false; 479 categoryFilterEnabled = false;
485 serverSelected( -1 ); 480 serverSelected( -1 );
486 return false; 481 return false;
487 } 482 }
488} 483}
489 484
490void MainWindow :: raiseMainWidget() 485void MainWindow :: raiseMainWidget()
491{ 486{
492 stack->raiseWidget( networkPkgWindow ); 487 stack->raiseWidget( networkPkgWindow );
493} 488}
494 489
495void MainWindow :: raiseProgressWidget() 490void MainWindow :: raiseProgressWidget()
496{ 491{
497 stack->raiseWidget( progressWindow ); 492 stack->raiseWidget( progressWindow );
498} 493}
499 494
500void MainWindow :: enableUpgrade( bool enabled ) 495void MainWindow :: enableUpgrade( bool enabled )
501{ 496{
502 actionUpgrade->setEnabled( enabled ); 497 actionUpgrade->setEnabled( enabled );
503} 498}
504 499
505void MainWindow :: enableDownload( bool enabled ) 500void MainWindow :: enableDownload( bool enabled )
506{ 501{
507 if ( enabled ) 502 if ( enabled )
508 { 503 {
509 actionDownload->setIconSet( iconDownload ); 504 actionDownload->setIconSet( iconDownload );
510 actionDownload->setText( tr( "Download" ) ); 505 actionDownload->setText( tr( "Download" ) );
511 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 506 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
512 } 507 }
513 else 508 else
514 { 509 {
515 actionDownload->setIconSet( iconRemove ); 510 actionDownload->setIconSet( iconRemove );
516 actionDownload->setText( tr( "Remove" ) ); 511 actionDownload->setText( tr( "Remove" ) );
517 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); 512 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
518 } 513 }
519} 514}
520 515
521void MainWindow :: setProgressSteps( int numsteps ) 516void MainWindow :: setProgressSteps( int numsteps )
522{ 517{
523 m_progress->setTotalSteps( numsteps ); 518 m_progress->setTotalSteps( numsteps );
524} 519}
525 520
526void MainWindow :: setProgressMessage( const QString &msg ) 521void MainWindow :: setProgressMessage( const QString &msg )
527{ 522{
528 m_status->setText( msg ); 523 m_status->setText( msg );
529} 524}
530 525
531void MainWindow :: updateProgress( int progress ) 526void MainWindow :: updateProgress( int progress )
532{ 527{
533 m_progress->setProgress( progress ); 528 m_progress->setProgress( progress );
534} 529}
535 530
536void MainWindow :: updateData() 531void MainWindow :: updateData()
537{ 532{
538 m_progress->setTotalSteps( mgr->getServerList().count() ); 533 m_progress->setTotalSteps( mgr->getServerList().count() );
539 534
540 serversList->clear(); 535 serversList->clear();
541 packagesList->clear(); 536 packagesList->clear();
542 537
543 int activeItem = -1; 538 int activeItem = -1;
544 int i = 0; 539 int i = 0;
545 QString serverName; 540 QString serverName;
546 541
547 QListIterator<Server> it( mgr->getServerList() ); 542 QListIterator<Server> it( mgr->getServerList() );
548 Server *server; 543 Server *server;
549 544
550 for ( ; it.current(); ++it, ++i ) 545 for ( ; it.current(); ++it, ++i )
551 { 546 {
552 server = it.current(); 547 server = it.current();
553 serverName = server->getServerName(); 548 serverName = server->getServerName();
554 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 549 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
555 m_progress->setProgress( i ); 550 m_progress->setProgress( i );
556 qApp->processEvents(); 551 qApp->processEvents();
557 552
558// cout << "Adding " << it->getServerName() << " to combobox" << endl; 553// cout << "Adding " << it->getServerName() << " to combobox" << endl;
559 if ( !server->isServerActive() ) 554 if ( !server->isServerActive() )
560 { 555 {
561// cout << serverName << " is not active" << endl; 556// cout << serverName << " is not active" << endl;
562 i--; 557 i--;
563 continue; 558 continue;
564 } 559 }
565 560
566 serversList->insertItem( serverName ); 561 serversList->insertItem( serverName );
567 if ( serverName == currentlySelectedServer ) 562 if ( serverName == currentlySelectedServer )
568 activeItem = i; 563 activeItem = i;
569 } 564 }
570 565
571 // set selected server to be active server 566 // set selected server to be active server
572 if ( activeItem != -1 ) 567 if ( activeItem != -1 )
573 serversList->setCurrentItem( activeItem ); 568 serversList->setCurrentItem( activeItem );
574 serverSelected( 0, FALSE ); 569 serverSelected( 0, FALSE );
575} 570}
576 571
577void MainWindow :: serverSelected( int index ) 572void MainWindow :: serverSelected( int index )
578{ 573{
579 serverSelected( index, TRUE ); 574 serverSelected( index, TRUE );
580} 575}
581 576
582void MainWindow :: serverSelected( int, bool raiseProgress ) 577void MainWindow :: serverSelected( int, bool raiseProgress )
583{ 578{
584 QPixmap nullIcon( installedIcon.size() ); 579 QPixmap nullIcon( installedIcon.size() );
585 nullIcon.fill( colorGroup().base() ); 580 nullIcon.fill( colorGroup().base() );
586 581
587 // display packages 582 // display packages
588 QString serverName = serversList->currentText(); 583 QString serverName = serversList->currentText();
589 currentlySelectedServer = serverName; 584 currentlySelectedServer = serverName;
590 585
591 Server *s = mgr->getServer( serverName ); 586 Server *s = mgr->getServer( serverName );
592 587
593 QList<Package> &list = s->getPackageList(); 588 QList<Package> &list = s->getPackageList();
594 QListIterator<Package> it( list ); 589 QListIterator<Package> it( list );
595 590
596 // Display progress widget while loading list 591 // Display progress widget while loading list
597 bool doProgress = ( list.count() > 200 ); 592 bool doProgress = ( list.count() > 200 );
598 if ( doProgress ) 593 if ( doProgress )
599 { 594 {
600 if ( raiseProgress ) 595 if ( raiseProgress )
601 { 596 {
602 stack->raiseWidget( progressWindow ); 597 stack->raiseWidget( progressWindow );
603 } 598 }
604 m_progress->setTotalSteps( list.count() ); 599 m_progress->setTotalSteps( list.count() );
605 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); 600 m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
606 } 601 }
607 602
608 packagesList->clear(); 603 packagesList->clear();
609 604
610#ifdef QWS 605#ifdef QWS
611 // read download directory from config file 606 // read download directory from config file
612 Config cfg( "aqpkg" ); 607 Config cfg( "aqpkg" );
613 cfg.setGroup( "settings" ); 608 cfg.setGroup( "settings" );
614 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 609 cfg.writeEntry( "selectedServer", currentlySelectedServer );
615#endif 610#endif
616 611
617 int i = 0; 612 int i = 0;
618 Package *package; 613 Package *package;
619 for ( ; it.current(); ++it ) 614 for ( ; it.current(); ++it )
620 { 615 {
621 // Update progress after every 100th package (arbitrary value, seems to give good balance) 616 // Update progress after every 100th package (arbitrary value, seems to give good balance)
622 i++; 617 i++;
623 if ( ( i % 100 ) == 0 ) 618 if ( ( i % 100 ) == 0 )
624 { 619 {
625 if ( doProgress ) 620 if ( doProgress )
626 { 621 {
627 m_progress->setProgress( i ); 622 m_progress->setProgress( i );
628 } 623 }
629 qApp->processEvents(); 624 qApp->processEvents();
630 } 625 }
631 626
632 QString text = ""; 627 QString text = "";
633 628
634 package = it.current(); 629 package = it.current();
635 630
636 // Apply show only uninstalled packages filter 631 // Apply show only uninstalled packages filter
637 if ( showUninstalledPkgs && package->isInstalled() ) 632 if ( showUninstalledPkgs && package->isInstalled() )
638 continue; 633 continue;
639 634
640 // Apply show only installed packages filter 635 // Apply show only installed packages filter
641 if ( showInstalledPkgs && !package->isInstalled() ) 636 if ( showInstalledPkgs && !package->isInstalled() )
642 continue; 637 continue;
643 638
644 // Apply show only new installed packages filter 639 // Apply show only new installed packages filter
645 if ( showUpgradedPkgs ) 640 if ( showUpgradedPkgs )
646 { 641 {
647 if ( !package->isInstalled() || 642 if ( !package->isInstalled() ||
648 compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 ) 643 compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 )
649 continue; 644 continue;
650 } 645 }
651 646
652 // Apply the section filter 647 // Apply the section filter
653 if ( categoryFilterEnabled && categoryFilter != "" ) 648 if ( categoryFilterEnabled && categoryFilter != "" )
654 { 649 {
655 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) 650 if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 )
656 continue; 651 continue;
657 } 652 }
658 653
659 // If the local server, only display installed packages 654 // If the local server, only display installed packages
660 if ( serverName == LOCAL_SERVER && !package->isInstalled() ) 655 if ( serverName == LOCAL_SERVER && !package->isInstalled() )
661 continue; 656 continue;
662 657
663 658
664 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), 659 QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(),
665 QCheckListItem::CheckBox ); 660 QCheckListItem::CheckBox );
666 661
667 if ( package->isInstalled() ) 662 if ( package->isInstalled() )
668 { 663 {
669 // If a different version of package is available, show update available icon 664 // If a different version of package is available, show update available icon
670 // Otherwise, show installed icon 665 // Otherwise, show installed icon
671 if ( package->getVersion() != package->getInstalledVersion() && 666 if ( package->getVersion() != package->getInstalledVersion() &&
672 compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1) 667 compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1)
673 { 668 {
674 669
675 item->setPixmap( 0, updatedIcon ); 670 item->setPixmap( 0, updatedIcon );
676 } 671 }
677 else 672 else
678 { 673 {
679 item->setPixmap( 0, installedIcon ); 674 item->setPixmap( 0, installedIcon );
680 } 675 }
681 676
682 QString destName = ""; 677 QString destName = "";
683 if ( package->getLocalPackage() ) 678 if ( package->getLocalPackage() )
684 { 679 {
685 if ( package->getLocalPackage()->getInstalledTo() ) 680 if ( package->getLocalPackage()->getInstalledTo() )
686 destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); 681 destName = package->getLocalPackage()->getInstalledTo()->getDestinationName();
687 } 682 }
688 else 683 else
689 { 684 {
690 if ( package->getInstalledTo() ) 685 if ( package->getInstalledTo() )
691 destName = package->getInstalledTo()->getDestinationName(); 686 destName = package->getInstalledTo()->getDestinationName();
692 } 687 }
693 if ( destName != "" ) 688 if ( destName != "" )
694 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); 689 new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) );
695 } 690 }
696 else 691 else
697 { 692 {
698 item->setPixmap( 0, nullIcon ); 693 item->setPixmap( 0, nullIcon );
699 } 694 }
700 695
701 if ( !package->isPackageStoredLocally() ) 696 if ( !package->isPackageStoredLocally() )
702 { 697 {
703 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) ); 698 new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) );
704 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) ); 699 new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) );
705 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) ); 700 new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) );
706 } 701 }
707 else 702 else
708 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) ); 703 new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) );
709 704
710 if ( serverName == LOCAL_SERVER ) 705 if ( serverName == LOCAL_SERVER )
711 { 706 {
712 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) ); 707 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) );
713 } 708 }
714 else 709 else
715 { 710 {
716 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) ); 711 new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) );
717 if ( package->getLocalPackage() ) 712 if ( package->getLocalPackage() )
718 { 713 {
719 if ( package->isInstalled() ) 714 if ( package->isInstalled() )
720 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) ); 715 new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) );
721 } 716 }
722 } 717 }
723 718
724 packagesList->insertItem( item ); 719 packagesList->insertItem( item );
725 } 720 }
726 721
727 // If the local server or the local ipkgs server disable the download button 722 // If the local server or the local ipkgs server disable the download button
728 if ( serverName == LOCAL_SERVER ) 723 if ( serverName == LOCAL_SERVER )
729 { 724 {
730 downloadEnabled = TRUE; 725 downloadEnabled = TRUE;
731 actionUpgrade->setEnabled( FALSE ); 726 actionUpgrade->setEnabled( FALSE );
732 } 727 }
733 else if ( serverName == LOCAL_IPKGS ) 728 else if ( serverName == LOCAL_IPKGS )
734 { 729 {
735 downloadEnabled = FALSE; 730 downloadEnabled = FALSE;
736 actionUpgrade->setEnabled( FALSE ); 731 actionUpgrade->setEnabled( FALSE );
737 } 732 }
738 else 733 else
739 { 734 {
740 downloadEnabled = TRUE; 735 downloadEnabled = TRUE;
741 actionUpgrade->setEnabled( TRUE ); 736 actionUpgrade->setEnabled( TRUE );
742 } 737 }
743 enableDownload( downloadEnabled ); 738 enableDownload( downloadEnabled );
744 739
745 // Display this widget once everything is done 740 // Display this widget once everything is done
746 if ( doProgress && raiseProgress ) 741 if ( doProgress && raiseProgress )
747 { 742 {
748 stack->raiseWidget( networkPkgWindow ); 743 stack->raiseWidget( networkPkgWindow );
749 } 744 }
750} 745}
751 746
752void MainWindow :: searchForPackage( const QString &text ) 747void MainWindow :: searchForPackage( const QString &text )
753{ 748{
754 if ( !text.isEmpty() ) 749 if ( !text.isEmpty() )
755 { 750 {
756// cout << "searching for " << text << endl; 751// cout << "searching for " << text << endl;
757 // look through package list for text startng at current position 752 // look through package list for text startng at current position
758// vector<InstallData> workingPackages; 753// vector<InstallData> workingPackages;
759 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 754 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
760// if ( start != 0 ) 755// if ( start != 0 )
761// start = (QCheckListItem *)start->nextSibling(); 756// start = (QCheckListItem *)start->nextSibling();
762 757
763 if ( start == 0 ) 758 if ( start == 0 )
764 start = (QCheckListItem *)packagesList->firstChild(); 759 start = (QCheckListItem *)packagesList->firstChild();
765 760
766 for ( QCheckListItem *item = start; item != 0 ; 761 for ( QCheckListItem *item = start; item != 0 ;
767 item = (QCheckListItem *)item->nextSibling() ) 762 item = (QCheckListItem *)item->nextSibling() )
768 { 763 {
769// cout << "checking " << item->text().lower() << endl; 764// cout << "checking " << item->text().lower() << endl;
770 if ( item->text().lower().find( text ) != -1 ) 765 if ( item->text().lower().find( text ) != -1 )
771 { 766 {
772// cout << "matched " << item->text() << endl; 767// cout << "matched " << item->text() << endl;
773 packagesList->ensureItemVisible( item ); 768 packagesList->ensureItemVisible( item );
774 packagesList->setCurrentItem( item ); 769 packagesList->setCurrentItem( item );
775 break; 770 break;
776 } 771 }
777 } 772 }
778 } 773 }
779} 774}
780 775
781void MainWindow :: updateServer() 776void MainWindow :: updateServer()
782{ 777{
783 QString serverName = serversList->currentText(); 778 QString serverName = serversList->currentText();
784 779
785 // Update the current server 780 // Update the current server
786 // Display dialog 781 // Display dialog
787 782
788 // Disable buttons to stop silly people clicking lots on them :) 783 // Disable buttons to stop silly people clicking lots on them :)
789 784
790 // First, write out ipkg_conf file so that ipkg can use it 785 // First, write out ipkg_conf file so that ipkg can use it
791 mgr->writeOutIpkgConf(); 786 mgr->writeOutIpkgConf();
792 787
793 Ipkg *ipkg = new Ipkg; 788 Ipkg *ipkg = new Ipkg;
794 ipkg->setOption( "update" ); 789 ipkg->setOption( "update" );
795 790
796 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), 791 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ),
797 tr( "Update lists" ) ); 792 tr( "Update lists" ) );
798 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 793 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
799 stack->addWidget( dlg, 3 ); 794 stack->addWidget( dlg, 3 );
800 stack->raiseWidget( dlg ); 795 stack->raiseWidget( dlg );
801 796
802// delete progDlg; 797// delete progDlg;
803} 798}
804 799
805void MainWindow :: upgradePackages() 800void MainWindow :: upgradePackages()
806{ 801{
807 // We're gonna do an upgrade of all packages 802 // We're gonna do an upgrade of all packages
808 // First warn user that this isn't recommended 803 // First warn user that this isn't recommended
809 // TODO - ODevice???? 804 // TODO - ODevice????
810 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); 805 QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" );
811 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, 806 QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning,
812 QMessageBox::Yes, 807 QMessageBox::Yes,
813 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 808 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
814 0, this ); 809 0, this );
815 warn.adjustSize(); 810 warn.adjustSize();
816 811
817 if ( warn.exec() == QMessageBox::Yes ) 812 if ( warn.exec() == QMessageBox::Yes )
818 { 813 {
819 // First, write out ipkg_conf file so that ipkg can use it 814 // First, write out ipkg_conf file so that ipkg can use it
820 mgr->writeOutIpkgConf(); 815 mgr->writeOutIpkgConf();
821 816
822 // Now run upgrade 817 // Now run upgrade
823 Ipkg *ipkg = new Ipkg; 818 Ipkg *ipkg = new Ipkg;
824 ipkg->setOption( "upgrade" ); 819 ipkg->setOption( "upgrade" );
825 820
826 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), 821 InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ),
827 tr ( "Upgrade" ) ); 822 tr ( "Upgrade" ) );
828 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 823 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
829 stack->addWidget( dlg, 3 ); 824 stack->addWidget( dlg, 3 );
830 stack->raiseWidget( dlg ); 825 stack->raiseWidget( dlg );
831 } 826 }
832} 827}
833 828
834void MainWindow :: downloadPackage() 829void MainWindow :: downloadPackage()
835{ 830{
836 bool doUpdate = true; 831 bool doUpdate = true;
837 if ( downloadEnabled ) 832 if ( downloadEnabled )
838 { 833 {
839 // See if any packages are selected 834 // See if any packages are selected
840 bool found = false; 835 bool found = false;
841 if ( serversList->currentText() != LOCAL_SERVER ) 836 if ( serversList->currentText() != LOCAL_SERVER )
842 { 837 {
843 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 838 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
844 item != 0 && !found; 839 item != 0 && !found;
845 item = (QCheckListItem *)item->nextSibling() ) 840 item = (QCheckListItem *)item->nextSibling() )
846 { 841 {
847 if ( item->isOn() ) 842 if ( item->isOn() )
848 found = true; 843 found = true;
849 } 844 }
850 } 845 }
851 846
852 // If user selected some packages then download the and store the locally 847 // If user selected some packages then download the and store the locally
853 // otherwise, display dialog asking user what package to download from an http server 848 // otherwise, display dialog asking user what package to download from an http server
854 // and whether to install it 849 // and whether to install it
855 if ( found ) 850 if ( found )
856 downloadSelectedPackages(); 851 downloadSelectedPackages();
857 else 852 else
858 downloadRemotePackage(); 853 downloadRemotePackage();
859 854
860 } 855 }
861 else 856 else
862 { 857 {
863 doUpdate = false; 858 doUpdate = false;
864 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 859 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
865 item != 0 ; 860 item != 0 ;
866 item = (QCheckListItem *)item->nextSibling() ) 861 item = (QCheckListItem *)item->nextSibling() )
867 { 862 {
868 if ( item->isOn() ) 863 if ( item->isOn() )
869 { 864 {
870 QString name = item->text(); 865 QString name = item->text();
871 int pos = name.find( "*" ); 866 int pos = name.find( "*" );
872 name.truncate( pos ); 867 name.truncate( pos );
873 868
874 // if (there is a (installed), remove it 869 // if (there is a (installed), remove it
875 pos = name.find( "(installed)" ); 870 pos = name.find( "(installed)" );
876 if ( pos > 0 ) 871 if ( pos > 0 )
877 name.truncate( pos - 1 ); 872 name.truncate( pos - 1 );
878 873
879 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); 874 Package *p = mgr->getServer( serversList->currentText() )->getPackage( name );
880 875
881 QString msgtext; 876 QString msgtext;
882 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); 877 msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() );
883 if ( QMessageBox::information( this, tr( "Are you sure?" ), 878 if ( QMessageBox::information( this, tr( "Are you sure?" ),
884 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) 879 msgtext, tr( "No" ), tr( "Yes" ) ) == 1 )
885 { 880 {
886 doUpdate = true; 881 doUpdate = true;
887 QFile f( p->getFilename() ); 882 QFile f( p->getFilename() );
888 f.remove(); 883 f.remove();
889 } 884 }
890 } 885 }
891 } 886 }
892 } 887 }
893 888
894 if ( doUpdate ) 889 if ( doUpdate )
895 { 890 {
896 reloadData( 0x0 ); 891 reloadData( 0x0 );
897 } 892 }
898} 893}
899 894
900void MainWindow :: downloadSelectedPackages() 895void MainWindow :: downloadSelectedPackages()
901{ 896{
902 // First, write out ipkg_conf file so that ipkg can use it 897 // First, write out ipkg_conf file so that ipkg can use it
903 mgr->writeOutIpkgConf(); 898 mgr->writeOutIpkgConf();
904 899
905 // Display dialog to user asking where to download the files to 900 // Display dialog to user asking where to download the files to
906 bool ok = FALSE; 901 bool ok = FALSE;
907 QString dir = ""; 902 QString dir = "";
908#ifdef QWS 903#ifdef QWS
909 // read download directory from config file 904 // read download directory from config file
910 Config cfg( "aqpkg" ); 905 Config cfg( "aqpkg" );
911 cfg.setGroup( "settings" ); 906 cfg.setGroup( "settings" );
912 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 907 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
913#endif 908#endif
914 909
915 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 910 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
916 if ( ok && !text.isEmpty() ) 911 if ( ok && !text.isEmpty() )
917 dir = text; // user entered something and pressed ok 912 dir = text; // user entered something and pressed ok
918 else 913 else
919 return; // user entered nothing or pressed cancel 914 return; // user entered nothing or pressed cancel
920 915
921#ifdef QWS 916#ifdef QWS
922 // Store download directory in config file 917 // Store download directory in config file
923 cfg.writeEntry( "downloadDir", dir ); 918 cfg.writeEntry( "downloadDir", dir );
924#endif 919#endif
925 920
926 // Get starting directory 921 // Get starting directory
927 char initDir[PATH_MAX]; 922 char initDir[PATH_MAX];
928 getcwd( initDir, PATH_MAX ); 923 getcwd( initDir, PATH_MAX );
929 924
930 // Download each package 925 // Download each package
931 Ipkg ipkg; 926 Ipkg ipkg;
932 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 927 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
933 928
934 ipkg.setOption( "download" ); 929 ipkg.setOption( "download" );
935 ipkg.setRuntimeDirectory( dir ); 930 ipkg.setRuntimeDirectory( dir );
936 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 931 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
937 item != 0 ; 932 item != 0 ;
938 item = (QCheckListItem *)item->nextSibling() ) 933 item = (QCheckListItem *)item->nextSibling() )
939 { 934 {
940 if ( item->isOn() ) 935 if ( item->isOn() )
941 { 936 {
942 ipkg.setPackage( item->text() ); 937 ipkg.setPackage( item->text() );
943 ipkg.runIpkg( ); 938 ipkg.runIpkg( );
944 } 939 }
945 } 940 }
946} 941}
947 942
948void MainWindow :: downloadRemotePackage() 943void MainWindow :: downloadRemotePackage()
949{ 944{
950 // Display dialog 945 // Display dialog
951 bool ok; 946 bool ok;
952 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); 947 QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this );
953 if ( !ok || package.isEmpty() ) 948 if ( !ok || package.isEmpty() )
954 return; 949 return;
955// DownloadRemoteDlgImpl dlg( this, "Install", true ); 950// DownloadRemoteDlgImpl dlg( this, "Install", true );
956// if ( dlg.exec() == QDialog::Rejected ) 951// if ( dlg.exec() == QDialog::Rejected )
957// return; 952// return;
958 953
959 // grab details from dialog 954 // grab details from dialog
960// QString package = dlg.getPackageLocation(); 955// QString package = dlg.getPackageLocation();
961 956
962 InstallData *item = new InstallData(); 957 InstallData *item = new InstallData();
963 item->option = "I"; 958 item->option = "I";
964 item->packageName = package; 959 item->packageName = package;
965 QList<InstallData> workingPackages; 960 QList<InstallData> workingPackages;
966 workingPackages.setAutoDelete( TRUE ); 961 workingPackages.setAutoDelete( TRUE );
967 workingPackages.append( item ); 962 workingPackages.append( item );
968 963
969 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); 964 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) );
970 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 965 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
971 stack->addWidget( dlg, 3 ); 966 stack->addWidget( dlg, 3 );
972 stack->raiseWidget( dlg ); 967 stack->raiseWidget( dlg );
973} 968}
974 969
975 970
976void MainWindow :: applyChanges() 971void MainWindow :: applyChanges()
977{ 972{
978 stickyOption = ""; 973 stickyOption = "";
979 974
980 // First, write out ipkg_conf file so that ipkg can use it 975 // First, write out ipkg_conf file so that ipkg can use it
981 mgr->writeOutIpkgConf(); 976 mgr->writeOutIpkgConf();
982 977
983 // Now for each selected item 978 // Now for each selected item
984 // deal with it 979 // deal with it
985 980
986 QList<InstallData> workingPackages; 981 QList<InstallData> workingPackages;
987 workingPackages.setAutoDelete( TRUE ); 982 workingPackages.setAutoDelete( TRUE );
988 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 983 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
989 item != 0 ; 984 item != 0 ;
990 item = (QCheckListItem *)item->nextSibling() ) 985 item = (QCheckListItem *)item->nextSibling() )
991 { 986 {
992 if ( item->isOn() ) 987 if ( item->isOn() )
993 { 988 {
994 workingPackages.append( dealWithItem( item ) ); 989 workingPackages.append( dealWithItem( item ) );
995 } 990 }
996 } 991 }
997 992
998 if ( workingPackages.count() == 0 ) 993 if ( workingPackages.count() == 0 )
999 { 994 {
1000 // Nothing to do 995 // Nothing to do
1001 QMessageBox::information( this, tr( "Nothing to do" ), 996 QMessageBox::information( this, tr( "Nothing to do" ),
1002 tr( "No packages selected" ), tr( "OK" ) ); 997 tr( "No packages selected" ), tr( "OK" ) );
1003 998
1004 return; 999 return;
1005 } 1000 }
1006 1001
1007 // do the stuff 1002 // do the stuff
1008 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); 1003 InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) );
1009 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); 1004 connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) );
1010 stack->addWidget( dlg, 3 ); 1005 stack->addWidget( dlg, 3 );
1011 stack->raiseWidget( dlg ); 1006 stack->raiseWidget( dlg );
1012} 1007}
1013 1008
1014// decide what to do - either remove, upgrade or install 1009// decide what to do - either remove, upgrade or install
1015// Current rules: 1010// Current rules:
1016// If not installed - install 1011// If not installed - install
1017// If installed and different version available - upgrade 1012// If installed and different version available - upgrade
1018// If installed and version up to date - remove 1013// If installed and version up to date - remove
1019InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) 1014InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
1020{ 1015{
1021 QString name = item->text(); 1016 QString name = item->text();
1022 1017
1023 // Get package 1018 // Get package
1024 Server *s = mgr->getServer( serversList->currentText() ); 1019 Server *s = mgr->getServer( serversList->currentText() );
1025 Package *p = s->getPackage( name ); 1020 Package *p = s->getPackage( name );
1026 1021
1027 // If the package has a filename then it is a local file 1022 // If the package has a filename then it is a local file
1028 if ( p->isPackageStoredLocally() ) 1023 if ( p->isPackageStoredLocally() )
1029 name = p->getFilename(); 1024 name = p->getFilename();
1030 1025
1031 QString option; 1026 QString option;
1032 QString dest = "root"; 1027 QString dest = "root";
1033 if ( !p->isInstalled() ) 1028 if ( !p->isInstalled() )
1034 { 1029 {
1035 InstallData *newitem = new InstallData();; 1030 InstallData *newitem = new InstallData();;
1036 newitem->option = "I"; 1031 newitem->option = "I";
1037 newitem->packageName = name; 1032 newitem->packageName = name;
1038 return newitem; 1033 return newitem;
1039 } 1034 }
1040 else 1035 else
1041 { 1036 {
1042 InstallData *newitem = new InstallData();; 1037 InstallData *newitem = new InstallData();;
1043 newitem->option = "D"; 1038 newitem->option = "D";
1044 if ( !p->isPackageStoredLocally() ) 1039 if ( !p->isPackageStoredLocally() )
1045 newitem->packageName = p->getInstalledPackageName(); 1040 newitem->packageName = p->getInstalledPackageName();
1046 else 1041 else
1047 newitem->packageName = name; 1042 newitem->packageName = name;
1048 1043
1049 if ( p->getInstalledTo() ) 1044 if ( p->getInstalledTo() )
1050 { 1045 {
1051 newitem->destination = p->getInstalledTo(); 1046 newitem->destination = p->getInstalledTo();
1052// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 1047// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
1053// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 1048// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
1054 } 1049 }
1055 else 1050 else
1056 { 1051 {
1057 newitem->destination = p->getLocalPackage()->getInstalledTo(); 1052 newitem->destination = p->getLocalPackage()->getInstalledTo();
1058 } 1053 }
1059 1054
1060 // Now see if version is newer or not 1055 // Now see if version is newer or not
1061 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1056 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1062 1057
1063 // If the version requested is older and user selected a local ipk file, then reinstall the file 1058 // If the version requested is older and user selected a local ipk file, then reinstall the file
1064 if ( p->isPackageStoredLocally() && val == -1 ) 1059 if ( p->isPackageStoredLocally() && val == -1 )
1065 val = 0; 1060 val = 0;
1066 1061
1067 if ( val == -2 ) 1062 if ( val == -2 )
1068 { 1063 {
1069 // Error - should handle 1064 // Error - should handle
1070 } 1065 }
1071 else if ( val == -1 ) 1066 else if ( val == -1 )
1072 { 1067 {
1073 // Version available is older - remove only 1068 // Version available is older - remove only
1074 newitem->option = "D"; 1069 newitem->option = "D";
1075 } 1070 }
1076 else 1071 else
1077 { 1072 {
1078 QString caption; 1073 QString caption;
1079 QString text; 1074 QString text;
1080 QString secondButton; 1075 QString secondButton;
1081 QString secondOption; 1076 QString secondOption;
1082 if ( val == 0 ) 1077 if ( val == 0 )
1083 { 1078 {
1084 // Version available is the same - option to remove or reinstall 1079 // Version available is the same - option to remove or reinstall
1085 caption = tr( "Do you wish to remove or reinstall\n%1?" ); 1080 caption = tr( "Do you wish to remove or reinstall\n%1?" );
1086 text = tr( "Remove or ReInstall" ); 1081 text = tr( "Remove or ReInstall" );
1087 secondButton = tr( "ReInstall" ); 1082 secondButton = tr( "ReInstall" );
1088 secondOption = tr( "R" ); 1083 secondOption = tr( "R" );
1089 } 1084 }
1090 else if ( val == 1 ) 1085 else if ( val == 1 )
1091 { 1086 {
1092 // Version available is newer - option to remove or upgrade 1087 // Version available is newer - option to remove or upgrade
1093 caption = tr( "Do you wish to remove or upgrade\n%1?" ); 1088 caption = tr( "Do you wish to remove or upgrade\n%1?" );
1094 text = tr( "Remove or Upgrade" ); 1089 text = tr( "Remove or Upgrade" );
1095 secondButton = tr( "Upgrade" ); 1090 secondButton = tr( "Upgrade" );
1096 secondOption = tr( "U" ); 1091 secondOption = tr( "U" );
1097 } 1092 }
1098 1093
1099 // Sticky option not implemented yet, but will eventually allow 1094 // Sticky option not implemented yet, but will eventually allow
1100 // the user to say something like 'remove all' 1095 // the user to say something like 'remove all'
1101 if ( stickyOption == "" ) 1096 if ( stickyOption == "" )
1102 { 1097 {
1103 QString msgtext; 1098 QString msgtext;
1104 msgtext = caption.arg( ( const char * )name ); 1099 msgtext = caption.arg( ( const char * )name );
1105 switch( QMessageBox::information( this, text, 1100 switch( QMessageBox::information( this, text,
1106 msgtext, tr( "Remove" ), secondButton ) ) 1101 msgtext, tr( "Remove" ), secondButton ) )
1107 { 1102 {
1108 case 0: // Try again or Enter 1103 case 0: // Try again or Enter
1109 // option 0 = Remove 1104 // option 0 = Remove
1110 newitem->option = "D"; 1105 newitem->option = "D";
1111 break; 1106 break;
1112 case 1: // Quit or Escape 1107 case 1: // Quit or Escape
1113 newitem->option = secondOption; 1108 newitem->option = secondOption;
1114 break; 1109 break;
1115 } 1110 }
1116 } 1111 }
1117 else 1112 else
1118 { 1113 {
1119// newitem->option = stickyOption; 1114// newitem->option = stickyOption;
1120 } 1115 }
1121 } 1116 }
1122 1117
1123 1118
1124 // Check if we are reinstalling the same version 1119 // Check if we are reinstalling the same version
1125 if ( newitem->option != "R" ) 1120 if ( newitem->option != "R" )
1126 newitem->recreateLinks = true; 1121 newitem->recreateLinks = true;
1127 else 1122 else
1128 newitem->recreateLinks = false; 1123 newitem->recreateLinks = false;
1129 1124
1130 // User hit cancel (on dlg - assume remove) 1125 // User hit cancel (on dlg - assume remove)
1131 return newitem; 1126 return newitem;
1132 } 1127 }
1133} 1128}
1134 1129
1135void MainWindow :: reloadData( InstallDlgImpl *dlg ) 1130void MainWindow :: reloadData( InstallDlgImpl *dlg )
1136{ 1131{
1137 stack->raiseWidget( progressWindow ); 1132 stack->raiseWidget( progressWindow );
1138 1133
1139 if ( dlg ) 1134 if ( dlg )
1140 { 1135 {
1141 dlg->close(); 1136 dlg->close();
1142 delete dlg; 1137 delete dlg;
1143 } 1138 }
1144 1139
1145 mgr->reloadServerData(); 1140 mgr->reloadServerData();
1146 serverSelected( -1, FALSE ); 1141 serverSelected( -1, FALSE );
1147 1142
1148#ifdef QWS 1143#ifdef QWS
1149 m_status->setText( tr( "Updating Launcher..." ) ); 1144 m_status->setText( tr( "Updating Launcher..." ) );
1150 1145
1151 // Finally let the main system update itself 1146 // Finally let the main system update itself
1152 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 1147 QCopEnvelope e("QPE/System", "linkChanged(QString)");
1153 QString lf = QString::null; 1148 QString lf = QString::null;
1154 e << lf; 1149 e << lf;
1155#endif 1150#endif
1156 1151
1157 stack->raiseWidget( networkPkgWindow ); 1152 stack->raiseWidget( networkPkgWindow );
1158} 1153}
1159 1154
1160void MainWindow :: letterPushed( QString t ) 1155void MainWindow :: letterPushed( QString t )
1161{ 1156{
1162 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 1157 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
1163 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 1158 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
1164 if ( packagesList->firstChild() == 0 ) 1159 if ( packagesList->firstChild() == 0 )
1165 return; 1160 return;
1166 1161
1167 QCheckListItem *item; 1162 QCheckListItem *item;
1168 if ( start == 0 ) 1163 if ( start == 0 )
1169 { 1164 {
1170 item = (QCheckListItem *)packagesList->firstChild(); 1165 item = (QCheckListItem *)packagesList->firstChild();
1171 start = top; 1166 start = top;
1172 } 1167 }
1173 else 1168 else
1174 item = (QCheckListItem *)start->nextSibling(); 1169 item = (QCheckListItem *)start->nextSibling();
1175 1170
1176 if ( item == 0 ) 1171 if ( item == 0 )
1177 item = (QCheckListItem *)packagesList->firstChild(); 1172 item = (QCheckListItem *)packagesList->firstChild();
1178 do 1173 do
1179 { 1174 {
1180 if ( item->text().lower().startsWith( t.lower() ) ) 1175 if ( item->text().lower().startsWith( t.lower() ) )
1181 { 1176 {
1182 packagesList->setSelected( item, true ); 1177 packagesList->setSelected( item, true );
1183 packagesList->ensureItemVisible( item ); 1178 packagesList->ensureItemVisible( item );
1184 break; 1179 break;
1185 } 1180 }
1186 1181
1187 item = (QCheckListItem *)item->nextSibling(); 1182 item = (QCheckListItem *)item->nextSibling();
1188 if ( !item ) 1183 if ( !item )
1189 item = (QCheckListItem *)packagesList->firstChild(); 1184 item = (QCheckListItem *)packagesList->firstChild();
1190 } while ( item != start); 1185 } while ( item != start);
1191} 1186}