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