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