summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 7fa311d..b597e03 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,590 +1,585 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.cpp - description 2 mainwin.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <linux/limits.h> 18#include <linux/limits.h>
19#include <unistd.h> 19#include <unistd.h>
20 20
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27 27
28#include <qaction.h> 28#include <qaction.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qlineedit.h> 33#include <qlineedit.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qmenubar.h> 35#include <qmenubar.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qtimer.h> 39#include <qtimer.h>
40#include <qwhatsthis.h> 40#include <qwhatsthis.h>
41#include <qwidgetstack.h> 41#include <qwidgetstack.h>
42 42
43#include "categoryfilterimpl.h" 43#include "categoryfilterimpl.h"
44#include "datamgr.h" 44#include "datamgr.h"
45#include "global.h" 45#include "global.h"
46#include "inputdlg.h" 46#include "inputdlg.h"
47#include "ipkg.h" 47#include "ipkg.h"
48#include "installdlgimpl.h" 48#include "installdlgimpl.h"
49#include "letterpushbutton.h" 49#include "letterpushbutton.h"
50#include "mainwin.h" 50#include "mainwin.h"
51#include "settingsimpl.h" 51#include "settingsimpl.h"
52#include "utils.h" 52#include "utils.h"
53 53
54extern int compareVersions( const char *v1, const char *v2 ); 54extern int compareVersions( const char *v1, const char *v2 );
55 55
56MainWindow :: MainWindow() 56MainWindow :: MainWindow()
57 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) 57 :QMainWindow( 0x0, 0x0, WStyle_ContextHelp )
58{ 58{
59 setCaption( tr( "AQPkg - Package Manager" ) ); 59 setCaption( tr( "AQPkg - Package Manager" ) );
60 60
61 // Create UI widgets 61 // Create UI widgets
62 initMainWidget(); 62 initMainWidget();
63 initProgressWidget(); 63 initProgressWidget();
64 64
65 // Build menu and tool bars 65 // Build menu and tool bars
66 setToolBarsMovable( FALSE ); 66 setToolBarsMovable( FALSE );
67 67
68 QPEToolBar *bar = new QPEToolBar( this ); 68 QPEToolBar *bar = new QPEToolBar( this );
69 bar->setHorizontalStretchable( TRUE ); 69 bar->setHorizontalStretchable( TRUE );
70 QPEMenuBar *mb = new QPEMenuBar( bar ); 70 QPEMenuBar *mb = new QPEMenuBar( bar );
71 mb->setMargin( 0 ); 71 mb->setMargin( 0 );
72 bar = new QPEToolBar( this ); 72 bar = new QPEToolBar( this );
73 73
74 // Find toolbar 74 // Find toolbar
75 findBar = new QPEToolBar( this ); 75 findBar = new QPEToolBar( this );
76 addToolBar( findBar, QMainWindow::Top, true ); 76 addToolBar( findBar, QMainWindow::Top, true );
77 findBar->setHorizontalStretchable( true ); 77 findBar->setHorizontalStretchable( true );
78 findEdit = new QLineEdit( findBar ); 78 findEdit = new QLineEdit( findBar );
79 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); 79 QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) );
80 findBar->setStretchableWidget( findEdit ); 80 findBar->setStretchableWidget( findEdit );
81 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); 81 connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) );
82 82
83 // Quick jump toolbar 83 // Quick jump toolbar
84 jumpBar = new QPEToolBar( this ); 84 jumpBar = new QPEToolBar( this );
85 addToolBar( jumpBar, QMainWindow::Top, true ); 85 addToolBar( jumpBar, QMainWindow::Top, true );
86 jumpBar->setHorizontalStretchable( true ); 86 jumpBar->setHorizontalStretchable( true );
87 QWidget *w = new QWidget( jumpBar ); 87 QWidget *w = new QWidget( jumpBar );
88 jumpBar->setStretchableWidget( w ); 88 jumpBar->setStretchableWidget( w );
89 89
90 QGridLayout *layout = new QGridLayout( w ); 90 QGridLayout *layout = new QGridLayout( w );
91 91
92 char text[2]; 92 char text[2];
93 text[1] = '\0'; 93 text[1] = '\0';
94 for ( int i = 0 ; i < 26 ; ++i ) 94 for ( int i = 0 ; i < 26 ; ++i )
95 { 95 {
96 text[0] = 'A' + i; 96 text[0] = 'A' + i;
97 LetterPushButton *b = new LetterPushButton( text, w ); 97 LetterPushButton *b = new LetterPushButton( text, w );
98 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 98 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
99 layout->addWidget( b, i / 13, i % 13); 99 layout->addWidget( b, i / 13, i % 13);
100 } 100 }
101 101
102 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); 102 QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 );
103 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); 103 a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) );
104 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); 104 connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) );
105 a->addTo( jumpBar ); 105 a->addTo( jumpBar );
106 jumpBar->hide(); 106 jumpBar->hide();
107 107
108 // Packages menu 108 // Packages menu
109 QPopupMenu *popup = new QPopupMenu( this ); 109 QPopupMenu *popup = new QPopupMenu( this );
110 110
111 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); 111 a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 );
112 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 112 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
113 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); 113 connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) );
114 a->addTo( popup ); 114 a->addTo( popup );
115 a->addTo( bar ); 115 a->addTo( bar );
116 116
117 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); 117 actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 );
118 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 118 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
119 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); 119 connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) );
120 actionUpgrade->addTo( popup ); 120 actionUpgrade->addTo( popup );
121 actionUpgrade->addTo( bar ); 121 actionUpgrade->addTo( bar );
122 122
123 iconDownload = Resource::loadPixmap( "aqpkg/download" ); 123 iconDownload = Resource::loadPixmap( "aqpkg/download" );
124 iconRemove = Resource::loadPixmap( "aqpkg/remove" ); 124 iconRemove = Resource::loadPixmap( "aqpkg/remove" );
125 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 125 actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
126 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 126 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
127 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); 127 connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) );
128 actionDownload->addTo( popup ); 128 actionDownload->addTo( popup );
129 actionDownload->addTo( bar ); 129 actionDownload->addTo( bar );
130 130
131 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); 131 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 );
132 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 132 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
133 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); 133 connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) );
134 a->addTo( popup ); 134 a->addTo( popup );
135 a->addTo( bar ); 135 a->addTo( bar );
136 136
137 popup->insertSeparator();
138
139 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
140 a->setWhatsThis( tr( "Click here to configure this application." ) );
141 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
142 a->addTo( popup );
137 mb->insertItem( tr( "Actions" ), popup ); 143 mb->insertItem( tr( "Actions" ), popup );
138 144
139 // View menu 145 // View menu
140 popup = new QPopupMenu( this ); 146 popup = new QPopupMenu( this );
141 147
142 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 148 actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
143 actionUninstalled->setToggleAction( TRUE ); 149 actionUninstalled->setToggleAction( TRUE );
144 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 150 actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
145 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); 151 connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) );
146 actionUninstalled->addTo( popup ); 152 actionUninstalled->addTo( popup );
147 153
148 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 154 actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
149 actionInstalled->setToggleAction( TRUE ); 155 actionInstalled->setToggleAction( TRUE );
150 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 156 actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
151 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); 157 connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) );
152 actionInstalled->addTo( popup ); 158 actionInstalled->addTo( popup );
153 159
154 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 160 actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
155 actionUpdated->setToggleAction( TRUE ); 161 actionUpdated->setToggleAction( TRUE );
156 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 162 actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
157 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); 163 connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) );
158 actionUpdated->addTo( popup ); 164 actionUpdated->addTo( popup );
159 165
160 popup->insertSeparator(); 166 popup->insertSeparator();
161 167
162 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); 168 actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 );
163 actionFilter->setToggleAction( TRUE ); 169 actionFilter->setToggleAction( TRUE );
164 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); 170 actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) );
165 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); 171 connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) );
166 actionFilter->addTo( popup ); 172 actionFilter->addTo( popup );
167 173
168 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); 174 a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 );
169 a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); 175 a->setWhatsThis( tr( "Click here to change package category to used filter." ) );
170 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); 176 connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) );
171 a->addTo( popup ); 177 a->addTo( popup );
172 178
173 popup->insertSeparator(); 179 popup->insertSeparator();
174 180
175 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 181 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
176 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 182 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
177 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); 183 connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) );
178 a->addTo( popup ); 184 a->addTo( popup );
179 185
180 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 186 actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
181 actionFindNext->setEnabled( FALSE ); 187 actionFindNext->setEnabled( FALSE );
182 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 188 actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
183 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); 189 connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) );
184 actionFindNext->addTo( popup ); 190 actionFindNext->addTo( popup );
185 actionFindNext->addTo( findBar ); 191 actionFindNext->addTo( findBar );
186 192
187 193
188 popup->insertSeparator(); 194 popup->insertSeparator();
189 195
190 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); 196 a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 );
191 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); 197 a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) );
192 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); 198 connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) );
193 a->addTo( popup ); 199 a->addTo( popup );
194 200
195 mb->insertItem( tr( "View" ), popup ); 201 mb->insertItem( tr( "View" ), popup );
196
197
198 // Options menu
199 popup = new QPopupMenu( this );
200
201 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
202 a->setWhatsThis( tr( "Click here to configure this application." ) );
203 connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) );
204 a->addTo( popup );
205
206 mb->insertItem( tr( "Options" ), popup );
207 202
208 // Finish find toolbar creation 203 // Finish find toolbar creation
209 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 204 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
210 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); 205 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
211 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); 206 connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) );
212 a->addTo( findBar ); 207 a->addTo( findBar );
213 findBar->hide(); 208 findBar->hide();
214 209
215 // Create widget stack and add UI widgets 210 // Create widget stack and add UI widgets
216 stack = new QWidgetStack( this ); 211 stack = new QWidgetStack( this );
217 stack->addWidget( progressWindow, 2 ); 212 stack->addWidget( progressWindow, 2 );
218 stack->addWidget( networkPkgWindow, 1 ); 213 stack->addWidget( networkPkgWindow, 1 );
219 setCentralWidget( stack ); 214 setCentralWidget( stack );
220 stack->raiseWidget( progressWindow ); 215 stack->raiseWidget( progressWindow );
221 216
222 // Delayed call to finish initialization 217 // Delayed call to finish initialization
223 QTimer::singleShot( 100, this, SLOT( init() ) ); 218 QTimer::singleShot( 100, this, SLOT( init() ) );
224} 219}
225 220
226MainWindow :: ~MainWindow() 221MainWindow :: ~MainWindow()
227{ 222{
228 delete mgr; 223 delete mgr;
229} 224}
230 225
231void MainWindow :: initMainWidget() 226void MainWindow :: initMainWidget()
232{ 227{
233 networkPkgWindow = new QWidget( this ); 228 networkPkgWindow = new QWidget( this );
234 229
235 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); 230 QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow );
236 231
237 serversList = new QComboBox( networkPkgWindow ); 232 serversList = new QComboBox( networkPkgWindow );
238 connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); 233 connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) );
239 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); 234 QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) );
240 235
241 installedIcon = Resource::loadPixmap( "installed" ); 236 installedIcon = Resource::loadPixmap( "installed" );
242 updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); 237 updatedIcon = Resource::loadPixmap( "aqpkg/updated" );
243 238
244 packagesList = new QListView( networkPkgWindow ); 239 packagesList = new QListView( networkPkgWindow );
245 packagesList->addColumn( tr( "Packages" ), 225 ); 240 packagesList->addColumn( tr( "Packages" ), 225 );
246 QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); 241 QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) );
247 242
248 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); 243 QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 );
249 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); 244 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 );
250 hbox1->addWidget( l ); 245 hbox1->addWidget( l );
251 hbox1->addWidget( serversList ); 246 hbox1->addWidget( serversList );
252 247
253 vbox->addWidget( packagesList ); 248 vbox->addWidget( packagesList );
254 249
255 downloadEnabled = TRUE; 250 downloadEnabled = TRUE;
256} 251}
257 252
258void MainWindow :: initProgressWidget() 253void MainWindow :: initProgressWidget()
259{ 254{
260 progressWindow = new QWidget( this ); 255 progressWindow = new QWidget( this );
261 256
262 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); 257 QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 );
263 258
264 m_status = new QLabel( progressWindow ); 259 m_status = new QLabel( progressWindow );
265 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 260 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
266 layout->addWidget( m_status ); 261 layout->addWidget( m_status );
267 262
268 m_progress = new QProgressBar( progressWindow ); 263 m_progress = new QProgressBar( progressWindow );
269 layout->addWidget( m_progress ); 264 layout->addWidget( m_progress );
270} 265}
271 266
272void MainWindow :: init() 267void MainWindow :: init()
273{ 268{
274#ifdef QWS 269#ifdef QWS
275 // read download directory from config file 270 // read download directory from config file
276 Config cfg( "aqpkg" ); 271 Config cfg( "aqpkg" );
277 cfg.setGroup( "settings" ); 272 cfg.setGroup( "settings" );
278 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 273 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
279// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 274// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
280 275
281#endif 276#endif
282 277
283 stack->raiseWidget( progressWindow ); 278 stack->raiseWidget( progressWindow );
284 279
285 mgr = new DataManager(); 280 mgr = new DataManager();
286 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); 281 connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) );
287 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), 282 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
288 this, SLOT( setProgressMessage( const QString & ) ) ); 283 this, SLOT( setProgressMessage( const QString & ) ) );
289 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); 284 connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
290 mgr->loadServers(); 285 mgr->loadServers();
291 286
292 showUninstalledPkgs = false; 287 showUninstalledPkgs = false;
293 showInstalledPkgs = false; 288 showInstalledPkgs = false;
294 showUpgradedPkgs = false; 289 showUpgradedPkgs = false;
295 categoryFilterEnabled = false; 290 categoryFilterEnabled = false;
296 291
297 updateData(); 292 updateData();
298 293
299 stack->raiseWidget( networkPkgWindow ); 294 stack->raiseWidget( networkPkgWindow );
300} 295}
301/* 296/*
302void MainWindow :: setDocument( const QString &doc ) 297void MainWindow :: setDocument( const QString &doc )
303{ 298{
304 // Remove path from package 299 // Remove path from package
305 QString package = Utils::getPackageNameFromIpkFilename( doc ); 300 QString package = Utils::getPackageNameFromIpkFilename( doc );
306// std::cout << "Selecting package " << package << std::endl; 301// std::cout << "Selecting package " << package << std::endl;
307 302
308 // First select local server 303 // First select local server
309 for ( int i = 0 ; i < serversList->count() ; ++i ) 304 for ( int i = 0 ; i < serversList->count() ; ++i )
310 { 305 {
311 if ( serversList->text( i ) == LOCAL_IPKGS ) 306 if ( serversList->text( i ) == LOCAL_IPKGS )
312 { 307 {
313 serversList->setCurrentItem( i ); 308 serversList->setCurrentItem( i );
314 break; 309 break;
315 } 310 }
316 } 311 }
317 serverSelected( 0 ); 312 serverSelected( 0 );
318 313
319 // Now set the check box of the selected package 314 // Now set the check box of the selected package
320 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 315 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
321 item != 0 ; 316 item != 0 ;
322 item = (QCheckListItem *)item->nextSibling() ) 317 item = (QCheckListItem *)item->nextSibling() )
323 { 318 {
324 if ( item->text().startsWith( package ) ) 319 if ( item->text().startsWith( package ) )
325 { 320 {
326 item->setOn( true ); 321 item->setOn( true );
327 break; 322 break;
328 } 323 }
329 } 324 }
330} 325}
331*/ 326*/
332void MainWindow :: displaySettings() 327void MainWindow :: displaySettings()
333{ 328{
334 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 329 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
335 if ( dlg->showDlg() ) 330 if ( dlg->showDlg() )
336 { 331 {
337 stack->raiseWidget( progressWindow ); 332 stack->raiseWidget( progressWindow );
338 updateData(); 333 updateData();
339 stack->raiseWidget( networkPkgWindow ); 334 stack->raiseWidget( networkPkgWindow );
340 } 335 }
341 delete dlg; 336 delete dlg;
342} 337}
343 338
344void MainWindow :: closeEvent( QCloseEvent *e ) 339void MainWindow :: closeEvent( QCloseEvent *e )
345{ 340{
346 // If install dialog is visible, return to main view, otherwise close app 341 // If install dialog is visible, return to main view, otherwise close app
347 QWidget *widget = stack->visibleWidget(); 342 QWidget *widget = stack->visibleWidget();
348 343
349 if ( widget != networkPkgWindow && widget != progressWindow ) 344 if ( widget != networkPkgWindow && widget != progressWindow )
350 { 345 {
351 if ( widget ) delete widget; 346 if ( widget ) delete widget;
352 stack->raiseWidget( networkPkgWindow ); 347 stack->raiseWidget( networkPkgWindow );
353 e->ignore(); 348 e->ignore();
354 } 349 }
355 else 350 else
356 { 351 {
357 e->accept(); 352 e->accept();
358 } 353 }
359} 354}
360 355
361void MainWindow :: displayFindBar() 356void MainWindow :: displayFindBar()
362{ 357{
363 findBar->show(); 358 findBar->show();
364 findEdit->setFocus(); 359 findEdit->setFocus();
365} 360}
366 361
367void MainWindow :: displayJumpBar() 362void MainWindow :: displayJumpBar()
368{ 363{
369 jumpBar->show(); 364 jumpBar->show();
370} 365}
371 366
372void MainWindow :: repeatFind() 367void MainWindow :: repeatFind()
373{ 368{
374 searchForPackage( findEdit->text() ); 369 searchForPackage( findEdit->text() );
375} 370}
376 371
377void MainWindow :: findPackage( const QString &text ) 372void MainWindow :: findPackage( const QString &text )
378{ 373{
379 actionFindNext->setEnabled( !text.isEmpty() ); 374 actionFindNext->setEnabled( !text.isEmpty() );
380 searchForPackage( text ); 375 searchForPackage( text );
381} 376}
382 377
383void MainWindow :: hideFindBar() 378void MainWindow :: hideFindBar()
384{ 379{
385 findBar->hide(); 380 findBar->hide();
386} 381}
387 382
388void MainWindow :: hideJumpBar() 383void MainWindow :: hideJumpBar()
389{ 384{
390 jumpBar->hide(); 385 jumpBar->hide();
391} 386}
392 387
393void MainWindow :: filterUninstalledPackages() 388void MainWindow :: filterUninstalledPackages()
394{ 389{
395 showUninstalledPkgs = actionUninstalled->isOn(); 390 showUninstalledPkgs = actionUninstalled->isOn();
396 if ( showUninstalledPkgs ) 391 if ( showUninstalledPkgs )
397 { 392 {
398 showInstalledPkgs = FALSE; 393 showInstalledPkgs = FALSE;
399 showUpgradedPkgs = FALSE; 394 showUpgradedPkgs = FALSE;
400 } 395 }
401 serverSelected( -1 ); 396 serverSelected( -1 );
402 397
403 actionInstalled->setOn( FALSE ); 398 actionInstalled->setOn( FALSE );
404 actionUpdated->setOn( FALSE ); 399 actionUpdated->setOn( FALSE );
405} 400}
406 401
407void MainWindow :: filterInstalledPackages() 402void MainWindow :: filterInstalledPackages()
408{ 403{
409 showInstalledPkgs = actionInstalled->isOn(); 404 showInstalledPkgs = actionInstalled->isOn();
410 if ( showInstalledPkgs ) 405 if ( showInstalledPkgs )
411 { 406 {
412 showUninstalledPkgs = FALSE; 407 showUninstalledPkgs = FALSE;
413 showUpgradedPkgs = FALSE; 408 showUpgradedPkgs = FALSE;
414 } 409 }
415 serverSelected( -1 ); 410 serverSelected( -1 );
416 411
417 actionUninstalled->setOn( FALSE ); 412 actionUninstalled->setOn( FALSE );
418 actionUpdated->setOn( FALSE ); 413 actionUpdated->setOn( FALSE );
419} 414}
420 415
421void MainWindow :: filterUpgradedPackages() 416void MainWindow :: filterUpgradedPackages()
422{ 417{
423 showUpgradedPkgs = actionUpdated->isOn(); 418 showUpgradedPkgs = actionUpdated->isOn();
424 if ( showUpgradedPkgs ) 419 if ( showUpgradedPkgs )
425 { 420 {
426 showUninstalledPkgs = FALSE; 421 showUninstalledPkgs = FALSE;
427 showInstalledPkgs = FALSE; 422 showInstalledPkgs = FALSE;
428 } 423 }
429 serverSelected( -1 ); 424 serverSelected( -1 );
430 425
431 actionUninstalled->setOn( FALSE ); 426 actionUninstalled->setOn( FALSE );
432 actionInstalled->setOn( FALSE ); 427 actionInstalled->setOn( FALSE );
433} 428}
434 429
435bool MainWindow :: setFilterCategory() 430bool MainWindow :: setFilterCategory()
436{ 431{
437 // Get categories; 432 // Get categories;
438 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); 433 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
439 if ( dlg.exec() == QDialog::Accepted ) 434 if ( dlg.exec() == QDialog::Accepted )
440 { 435 {
441 categoryFilter = dlg.getSelectedFilter(); 436 categoryFilter = dlg.getSelectedFilter();
442 437
443 if ( categoryFilter == "" ) 438 if ( categoryFilter == "" )
444 return false; 439 return false;
445 440
446 categoryFilterEnabled = true; 441 categoryFilterEnabled = true;
447 serverSelected( -1 ); 442 serverSelected( -1 );
448 actionFilter->setOn( TRUE ); 443 actionFilter->setOn( TRUE );
449 return true; 444 return true;
450 } 445 }
451 446
452 return false; 447 return false;
453} 448}
454 449
455void MainWindow :: filterCategory() 450void MainWindow :: filterCategory()
456{ 451{
457 if ( !actionFilter->isOn() ) 452 if ( !actionFilter->isOn() )
458 { 453 {
459 filterByCategory( FALSE ); 454 filterByCategory( FALSE );
460 } 455 }
461 else 456 else
462 { 457 {
463 actionFilter->setOn( filterByCategory( TRUE ) ); 458 actionFilter->setOn( filterByCategory( TRUE ) );
464 } 459 }
465} 460}
466 461
467bool MainWindow :: filterByCategory( bool val ) 462bool MainWindow :: filterByCategory( bool val )
468{ 463{
469 if ( val ) 464 if ( val )
470 { 465 {
471 if ( categoryFilter == "" ) 466 if ( categoryFilter == "" )
472 { 467 {
473 if ( !setFilterCategory() ) 468 if ( !setFilterCategory() )
474 return false; 469 return false;
475 } 470 }
476 471
477 categoryFilterEnabled = true; 472 categoryFilterEnabled = true;
478 serverSelected( -1 ); 473 serverSelected( -1 );
479 return true; 474 return true;
480 } 475 }
481 else 476 else
482 { 477 {
483 // Turn off filter 478 // Turn off filter
484 categoryFilterEnabled = false; 479 categoryFilterEnabled = false;
485 serverSelected( -1 ); 480 serverSelected( -1 );
486 return false; 481 return false;
487 } 482 }
488} 483}
489 484
490void MainWindow :: raiseMainWidget() 485void MainWindow :: raiseMainWidget()
491{ 486{
492 stack->raiseWidget( networkPkgWindow ); 487 stack->raiseWidget( networkPkgWindow );
493} 488}
494 489
495void MainWindow :: raiseProgressWidget() 490void MainWindow :: raiseProgressWidget()
496{ 491{
497 stack->raiseWidget( progressWindow ); 492 stack->raiseWidget( progressWindow );
498} 493}
499 494
500void MainWindow :: enableUpgrade( bool enabled ) 495void MainWindow :: enableUpgrade( bool enabled )
501{ 496{
502 actionUpgrade->setEnabled( enabled ); 497 actionUpgrade->setEnabled( enabled );
503} 498}
504 499
505void MainWindow :: enableDownload( bool enabled ) 500void MainWindow :: enableDownload( bool enabled )
506{ 501{
507 if ( enabled ) 502 if ( enabled )
508 { 503 {
509 actionDownload->setIconSet( iconDownload ); 504 actionDownload->setIconSet( iconDownload );
510 actionDownload->setText( tr( "Download" ) ); 505 actionDownload->setText( tr( "Download" ) );
511 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 506 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
512 } 507 }
513 else 508 else
514 { 509 {
515 actionDownload->setIconSet( iconRemove ); 510 actionDownload->setIconSet( iconRemove );
516 actionDownload->setText( tr( "Remove" ) ); 511 actionDownload->setText( tr( "Remove" ) );
517 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); 512 actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) );
518 } 513 }
519} 514}
520 515
521void MainWindow :: setProgressSteps( int numsteps ) 516void MainWindow :: setProgressSteps( int numsteps )
522{ 517{
523 m_progress->setTotalSteps( numsteps ); 518 m_progress->setTotalSteps( numsteps );
524} 519}
525 520
526void MainWindow :: setProgressMessage( const QString &msg ) 521void MainWindow :: setProgressMessage( const QString &msg )
527{ 522{
528 m_status->setText( msg ); 523 m_status->setText( msg );
529} 524}
530 525
531void MainWindow :: updateProgress( int progress ) 526void MainWindow :: updateProgress( int progress )
532{ 527{
533 m_progress->setProgress( progress ); 528 m_progress->setProgress( progress );
534} 529}
535 530
536void MainWindow :: updateData() 531void MainWindow :: updateData()
537{ 532{
538 m_progress->setTotalSteps( mgr->getServerList().count() ); 533 m_progress->setTotalSteps( mgr->getServerList().count() );
539 534
540 serversList->clear(); 535 serversList->clear();
541 packagesList->clear(); 536 packagesList->clear();
542 537
543 int activeItem = -1; 538 int activeItem = -1;
544 int i = 0; 539 int i = 0;
545 QString serverName; 540 QString serverName;
546 541
547 QListIterator<Server> it( mgr->getServerList() ); 542 QListIterator<Server> it( mgr->getServerList() );
548 Server *server; 543 Server *server;
549 544
550 for ( ; it.current(); ++it, ++i ) 545 for ( ; it.current(); ++it, ++i )
551 { 546 {
552 server = it.current(); 547 server = it.current();
553 serverName = server->getServerName(); 548 serverName = server->getServerName();
554 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); 549 m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) );
555 m_progress->setProgress( i ); 550 m_progress->setProgress( i );
556 qApp->processEvents(); 551 qApp->processEvents();
557 552
558// cout << "Adding " << it->getServerName() << " to combobox" << endl; 553// cout << "Adding " << it->getServerName() << " to combobox" << endl;
559 if ( !server->isServerActive() ) 554 if ( !server->isServerActive() )
560 { 555 {
561// cout << serverName << " is not active" << endl; 556// cout << serverName << " is not active" << endl;
562 i--; 557 i--;
563 continue; 558 continue;
564 } 559 }
565 560
566 serversList->insertItem( serverName ); 561 serversList->insertItem( serverName );
567 if ( serverName == currentlySelectedServer ) 562 if ( serverName == currentlySelectedServer )
568 activeItem = i; 563 activeItem = i;
569 } 564 }
570 565
571 // set selected server to be active server 566 // set selected server to be active server
572 if ( activeItem != -1 ) 567 if ( activeItem != -1 )
573 serversList->setCurrentItem( activeItem ); 568 serversList->setCurrentItem( activeItem );
574 serverSelected( 0, FALSE ); 569 serverSelected( 0, FALSE );
575} 570}
576 571
577void MainWindow :: serverSelected( int index ) 572void MainWindow :: serverSelected( int index )
578{ 573{
579 serverSelected( index, TRUE ); 574 serverSelected( index, TRUE );
580} 575}
581 576
582void MainWindow :: serverSelected( int, bool raiseProgress ) 577void MainWindow :: serverSelected( int, bool raiseProgress )
583{ 578{
584 QPixmap nullIcon( installedIcon.size() ); 579 QPixmap nullIcon( installedIcon.size() );
585 nullIcon.fill( colorGroup().base() ); 580 nullIcon.fill( colorGroup().base() );
586 581
587 // display packages 582 // display packages
588 QString serverName = serversList->currentText(); 583 QString serverName = serversList->currentText();
589 currentlySelectedServer = serverName; 584 currentlySelectedServer = serverName;
590 585