-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 392d04d..dfe6d9c 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,753 +1,753 @@ | |||
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 | ||
54 | extern int compareVersions( const char *v1, const char *v2 ); | 54 | extern int compareVersions( const char *v1, const char *v2 ); |
55 | 55 | ||
56 | MainWindow :: MainWindow() | 56 | MainWindow :: 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 | mb->insertItem( tr( "Actions" ), popup ); | 137 | mb->insertItem( tr( "Actions" ), popup ); |
138 | 138 | ||
139 | // View menu | 139 | // View menu |
140 | popup = new QPopupMenu( this ); | 140 | popup = new QPopupMenu( this ); |
141 | 141 | ||
142 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 142 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
143 | actionUninstalled->setToggleAction( TRUE ); | 143 | actionUninstalled->setToggleAction( TRUE ); |
144 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 144 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
145 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 145 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
146 | actionUninstalled->addTo( popup ); | 146 | actionUninstalled->addTo( popup ); |
147 | 147 | ||
148 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 148 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
149 | actionInstalled->setToggleAction( TRUE ); | 149 | actionInstalled->setToggleAction( TRUE ); |
150 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 150 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
151 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 151 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
152 | actionInstalled->addTo( popup ); | 152 | actionInstalled->addTo( popup ); |
153 | 153 | ||
154 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 154 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
155 | actionUpdated->setToggleAction( TRUE ); | 155 | actionUpdated->setToggleAction( TRUE ); |
156 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 156 | 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() ) ); | 157 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
158 | actionUpdated->addTo( popup ); | 158 | actionUpdated->addTo( popup ); |
159 | 159 | ||
160 | popup->insertSeparator(); | 160 | popup->insertSeparator(); |
161 | 161 | ||
162 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 162 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); |
163 | actionFilter->setToggleAction( TRUE ); | 163 | actionFilter->setToggleAction( TRUE ); |
164 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 164 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
165 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 165 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
166 | actionFilter->addTo( popup ); | 166 | actionFilter->addTo( popup ); |
167 | 167 | ||
168 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 168 | 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." ) ); | 169 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
170 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 170 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
171 | a->addTo( popup ); | 171 | a->addTo( popup ); |
172 | 172 | ||
173 | popup->insertSeparator(); | 173 | popup->insertSeparator(); |
174 | 174 | ||
175 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 175 | 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." ) ); | 176 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
177 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 177 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
178 | a->addTo( popup ); | 178 | a->addTo( popup ); |
179 | 179 | ||
180 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 180 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
181 | actionFindNext->setEnabled( FALSE ); | 181 | actionFindNext->setEnabled( FALSE ); |
182 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 182 | 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() ) ); | 183 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
184 | actionFindNext->addTo( popup ); | 184 | actionFindNext->addTo( popup ); |
185 | actionFindNext->addTo( findBar ); | 185 | actionFindNext->addTo( findBar ); |
186 | 186 | ||
187 | 187 | ||
188 | popup->insertSeparator(); | 188 | popup->insertSeparator(); |
189 | 189 | ||
190 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); | 190 | 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." ) ); | 191 | 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() ) ); | 192 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); |
193 | a->addTo( popup ); | 193 | a->addTo( popup ); |
194 | 194 | ||
195 | mb->insertItem( tr( "View" ), popup ); | 195 | mb->insertItem( tr( "View" ), popup ); |
196 | 196 | ||
197 | 197 | ||
198 | // Options menu | 198 | // Options menu |
199 | popup = new QPopupMenu( this ); | 199 | popup = new QPopupMenu( this ); |
200 | 200 | ||
201 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); | 201 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
202 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 202 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
203 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 203 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
204 | a->addTo( popup ); | 204 | a->addTo( popup ); |
205 | 205 | ||
206 | mb->insertItem( tr( "Options" ), popup ); | 206 | mb->insertItem( tr( "Options" ), popup ); |
207 | 207 | ||
208 | // Finish find toolbar creation | 208 | // Finish find toolbar creation |
209 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 209 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
210 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 210 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
211 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 211 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
212 | a->addTo( findBar ); | 212 | a->addTo( findBar ); |
213 | findBar->hide(); | 213 | findBar->hide(); |
214 | 214 | ||
215 | // Create widget stack and add UI widgets | 215 | // Create widget stack and add UI widgets |
216 | stack = new QWidgetStack( this ); | 216 | stack = new QWidgetStack( this ); |
217 | stack->addWidget( progressWindow, 2 ); | 217 | stack->addWidget( progressWindow, 2 ); |
218 | stack->addWidget( networkPkgWindow, 1 ); | 218 | stack->addWidget( networkPkgWindow, 1 ); |
219 | setCentralWidget( stack ); | 219 | setCentralWidget( stack ); |
220 | stack->raiseWidget( progressWindow ); | 220 | stack->raiseWidget( progressWindow ); |
221 | 221 | ||
222 | // Delayed call to finish initialization | 222 | // Delayed call to finish initialization |
223 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 223 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
224 | } | 224 | } |
225 | 225 | ||
226 | MainWindow :: ~MainWindow() | 226 | MainWindow :: ~MainWindow() |
227 | { | 227 | { |
228 | delete mgr; | 228 | delete mgr; |
229 | } | 229 | } |
230 | 230 | ||
231 | void MainWindow :: initMainWidget() | 231 | void MainWindow :: initMainWidget() |
232 | { | 232 | { |
233 | networkPkgWindow = new QWidget( this ); | 233 | networkPkgWindow = new QWidget( this ); |
234 | 234 | ||
235 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 235 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
236 | 236 | ||
237 | serversList = new QComboBox( networkPkgWindow ); | 237 | serversList = new QComboBox( networkPkgWindow ); |
238 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); | 238 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); |
239 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 239 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
240 | 240 | ||
241 | installedIcon = Resource::loadPixmap( "aqpkg/installed" ); | 241 | installedIcon = Resource::loadPixmap( "installed" ); |
242 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 242 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
243 | 243 | ||
244 | packagesList = new QListView( networkPkgWindow ); | 244 | packagesList = new QListView( networkPkgWindow ); |
245 | packagesList->addColumn( tr( "Packages" ), 225 ); | 245 | 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." ) ); | 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." ) ); |
247 | 247 | ||
248 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 248 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
249 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 249 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
250 | hbox1->addWidget( l ); | 250 | hbox1->addWidget( l ); |
251 | hbox1->addWidget( serversList ); | 251 | hbox1->addWidget( serversList ); |
252 | 252 | ||
253 | vbox->addWidget( packagesList ); | 253 | vbox->addWidget( packagesList ); |
254 | 254 | ||
255 | downloadEnabled = TRUE; | 255 | downloadEnabled = TRUE; |
256 | } | 256 | } |
257 | 257 | ||
258 | void MainWindow :: initProgressWidget() | 258 | void MainWindow :: initProgressWidget() |
259 | { | 259 | { |
260 | progressWindow = new QWidget( this ); | 260 | progressWindow = new QWidget( this ); |
261 | 261 | ||
262 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 262 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
263 | 263 | ||
264 | m_status = new QLabel( progressWindow ); | 264 | m_status = new QLabel( progressWindow ); |
265 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 265 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
266 | layout->addWidget( m_status ); | 266 | layout->addWidget( m_status ); |
267 | 267 | ||
268 | m_progress = new QProgressBar( progressWindow ); | 268 | m_progress = new QProgressBar( progressWindow ); |
269 | layout->addWidget( m_progress ); | 269 | layout->addWidget( m_progress ); |
270 | } | 270 | } |
271 | 271 | ||
272 | void MainWindow :: init() | 272 | void MainWindow :: init() |
273 | { | 273 | { |
274 | #ifdef QWS | 274 | #ifdef QWS |
275 | // read download directory from config file | 275 | // read download directory from config file |
276 | Config cfg( "aqpkg" ); | 276 | Config cfg( "aqpkg" ); |
277 | cfg.setGroup( "settings" ); | 277 | cfg.setGroup( "settings" ); |
278 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 278 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
279 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 279 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
280 | 280 | ||
281 | #endif | 281 | #endif |
282 | 282 | ||
283 | stack->raiseWidget( progressWindow ); | 283 | stack->raiseWidget( progressWindow ); |
284 | 284 | ||
285 | mgr = new DataManager(); | 285 | mgr = new DataManager(); |
286 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 286 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
287 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 287 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
288 | this, SLOT( setProgressMessage( const QString & ) ) ); | 288 | this, SLOT( setProgressMessage( const QString & ) ) ); |
289 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 289 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); |
290 | mgr->loadServers(); | 290 | mgr->loadServers(); |
291 | 291 | ||
292 | showUninstalledPkgs = false; | 292 | showUninstalledPkgs = false; |
293 | showInstalledPkgs = false; | 293 | showInstalledPkgs = false; |
294 | showUpgradedPkgs = false; | 294 | showUpgradedPkgs = false; |
295 | categoryFilterEnabled = false; | 295 | categoryFilterEnabled = false; |
296 | 296 | ||
297 | updateData(); | 297 | updateData(); |
298 | 298 | ||
299 | stack->raiseWidget( networkPkgWindow ); | 299 | stack->raiseWidget( networkPkgWindow ); |
300 | } | 300 | } |
301 | /* | 301 | /* |
302 | void MainWindow :: setDocument( const QString &doc ) | 302 | void MainWindow :: setDocument( const QString &doc ) |
303 | { | 303 | { |
304 | // Remove path from package | 304 | // Remove path from package |
305 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 305 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
306 | // std::cout << "Selecting package " << package << std::endl; | 306 | // std::cout << "Selecting package " << package << std::endl; |
307 | 307 | ||
308 | // First select local server | 308 | // First select local server |
309 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 309 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
310 | { | 310 | { |
311 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 311 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
312 | { | 312 | { |
313 | serversList->setCurrentItem( i ); | 313 | serversList->setCurrentItem( i ); |
314 | break; | 314 | break; |
315 | } | 315 | } |
316 | } | 316 | } |
317 | serverSelected( 0 ); | 317 | serverSelected( 0 ); |
318 | 318 | ||
319 | // Now set the check box of the selected package | 319 | // Now set the check box of the selected package |
320 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 320 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
321 | item != 0 ; | 321 | item != 0 ; |
322 | item = (QCheckListItem *)item->nextSibling() ) | 322 | item = (QCheckListItem *)item->nextSibling() ) |
323 | { | 323 | { |
324 | if ( item->text().startsWith( package ) ) | 324 | if ( item->text().startsWith( package ) ) |
325 | { | 325 | { |
326 | item->setOn( true ); | 326 | item->setOn( true ); |
327 | break; | 327 | break; |
328 | } | 328 | } |
329 | } | 329 | } |
330 | } | 330 | } |
331 | */ | 331 | */ |
332 | void MainWindow :: displaySettings() | 332 | void MainWindow :: displaySettings() |
333 | { | 333 | { |
334 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 334 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
335 | if ( dlg->showDlg() ) | 335 | if ( dlg->showDlg() ) |
336 | { | 336 | { |
337 | stack->raiseWidget( progressWindow ); | 337 | stack->raiseWidget( progressWindow ); |
338 | updateData(); | 338 | updateData(); |
339 | stack->raiseWidget( networkPkgWindow ); | 339 | stack->raiseWidget( networkPkgWindow ); |
340 | } | 340 | } |
341 | delete dlg; | 341 | delete dlg; |
342 | } | 342 | } |
343 | 343 | ||
344 | void MainWindow :: displayFindBar() | 344 | void MainWindow :: displayFindBar() |
345 | { | 345 | { |
346 | findBar->show(); | 346 | findBar->show(); |
347 | findEdit->setFocus(); | 347 | findEdit->setFocus(); |
348 | } | 348 | } |
349 | 349 | ||
350 | void MainWindow :: displayJumpBar() | 350 | void MainWindow :: displayJumpBar() |
351 | { | 351 | { |
352 | jumpBar->show(); | 352 | jumpBar->show(); |
353 | } | 353 | } |
354 | 354 | ||
355 | void MainWindow :: repeatFind() | 355 | void MainWindow :: repeatFind() |
356 | { | 356 | { |
357 | searchForPackage( findEdit->text() ); | 357 | searchForPackage( findEdit->text() ); |
358 | } | 358 | } |
359 | 359 | ||
360 | void MainWindow :: findPackage( const QString &text ) | 360 | void MainWindow :: findPackage( const QString &text ) |
361 | { | 361 | { |
362 | actionFindNext->setEnabled( !text.isEmpty() ); | 362 | actionFindNext->setEnabled( !text.isEmpty() ); |
363 | searchForPackage( text ); | 363 | searchForPackage( text ); |
364 | } | 364 | } |
365 | 365 | ||
366 | void MainWindow :: hideFindBar() | 366 | void MainWindow :: hideFindBar() |
367 | { | 367 | { |
368 | findBar->hide(); | 368 | findBar->hide(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void MainWindow :: hideJumpBar() | 371 | void MainWindow :: hideJumpBar() |
372 | { | 372 | { |
373 | jumpBar->hide(); | 373 | jumpBar->hide(); |
374 | } | 374 | } |
375 | 375 | ||
376 | void MainWindow :: filterUninstalledPackages() | 376 | void MainWindow :: filterUninstalledPackages() |
377 | { | 377 | { |
378 | showUninstalledPkgs = actionUninstalled->isOn(); | 378 | showUninstalledPkgs = actionUninstalled->isOn(); |
379 | if ( showUninstalledPkgs ) | 379 | if ( showUninstalledPkgs ) |
380 | { | 380 | { |
381 | showInstalledPkgs = FALSE; | 381 | showInstalledPkgs = FALSE; |
382 | showUpgradedPkgs = FALSE; | 382 | showUpgradedPkgs = FALSE; |
383 | } | 383 | } |
384 | serverSelected( -1 ); | 384 | serverSelected( -1 ); |
385 | 385 | ||
386 | actionInstalled->setOn( FALSE ); | 386 | actionInstalled->setOn( FALSE ); |
387 | actionUpdated->setOn( FALSE ); | 387 | actionUpdated->setOn( FALSE ); |
388 | } | 388 | } |
389 | 389 | ||
390 | void MainWindow :: filterInstalledPackages() | 390 | void MainWindow :: filterInstalledPackages() |
391 | { | 391 | { |
392 | showInstalledPkgs = actionInstalled->isOn(); | 392 | showInstalledPkgs = actionInstalled->isOn(); |
393 | if ( showInstalledPkgs ) | 393 | if ( showInstalledPkgs ) |
394 | { | 394 | { |
395 | showUninstalledPkgs = FALSE; | 395 | showUninstalledPkgs = FALSE; |
396 | showUpgradedPkgs = FALSE; | 396 | showUpgradedPkgs = FALSE; |
397 | } | 397 | } |
398 | serverSelected( -1 ); | 398 | serverSelected( -1 ); |
399 | 399 | ||
400 | actionUninstalled->setOn( FALSE ); | 400 | actionUninstalled->setOn( FALSE ); |
401 | actionUpdated->setOn( FALSE ); | 401 | actionUpdated->setOn( FALSE ); |
402 | } | 402 | } |
403 | 403 | ||
404 | void MainWindow :: filterUpgradedPackages() | 404 | void MainWindow :: filterUpgradedPackages() |
405 | { | 405 | { |
406 | showUpgradedPkgs = actionUpdated->isOn(); | 406 | showUpgradedPkgs = actionUpdated->isOn(); |
407 | if ( showUpgradedPkgs ) | 407 | if ( showUpgradedPkgs ) |
408 | { | 408 | { |
409 | showUninstalledPkgs = FALSE; | 409 | showUninstalledPkgs = FALSE; |
410 | showInstalledPkgs = FALSE; | 410 | showInstalledPkgs = FALSE; |
411 | } | 411 | } |
412 | serverSelected( -1 ); | 412 | serverSelected( -1 ); |
413 | 413 | ||
414 | actionUninstalled->setOn( FALSE ); | 414 | actionUninstalled->setOn( FALSE ); |
415 | actionInstalled->setOn( FALSE ); | 415 | actionInstalled->setOn( FALSE ); |
416 | } | 416 | } |
417 | 417 | ||
418 | bool MainWindow :: setFilterCategory() | 418 | bool MainWindow :: setFilterCategory() |
419 | { | 419 | { |
420 | // Get categories; | 420 | // Get categories; |
421 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | 421 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); |
422 | if ( dlg.exec() == QDialog::Accepted ) | 422 | if ( dlg.exec() == QDialog::Accepted ) |
423 | { | 423 | { |
424 | categoryFilter = dlg.getSelectedFilter(); | 424 | categoryFilter = dlg.getSelectedFilter(); |
425 | 425 | ||
426 | if ( categoryFilter == "" ) | 426 | if ( categoryFilter == "" ) |
427 | return false; | 427 | return false; |
428 | 428 | ||
429 | categoryFilterEnabled = true; | 429 | categoryFilterEnabled = true; |
430 | serverSelected( -1 ); | 430 | serverSelected( -1 ); |
431 | actionFilter->setOn( TRUE ); | 431 | actionFilter->setOn( TRUE ); |
432 | return true; | 432 | return true; |
433 | } | 433 | } |
434 | 434 | ||
435 | return false; | 435 | return false; |
436 | } | 436 | } |
437 | 437 | ||
438 | void MainWindow :: filterCategory() | 438 | void MainWindow :: filterCategory() |
439 | { | 439 | { |
440 | if ( !actionFilter->isOn() ) | 440 | if ( !actionFilter->isOn() ) |
441 | { | 441 | { |
442 | filterByCategory( FALSE ); | 442 | filterByCategory( FALSE ); |
443 | } | 443 | } |
444 | else | 444 | else |
445 | { | 445 | { |
446 | actionFilter->setOn( filterByCategory( TRUE ) ); | 446 | actionFilter->setOn( filterByCategory( TRUE ) ); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | 449 | ||
450 | bool MainWindow :: filterByCategory( bool val ) | 450 | bool MainWindow :: filterByCategory( bool val ) |
451 | { | 451 | { |
452 | if ( val ) | 452 | if ( val ) |
453 | { | 453 | { |
454 | if ( categoryFilter == "" ) | 454 | if ( categoryFilter == "" ) |
455 | { | 455 | { |
456 | if ( !setFilterCategory() ) | 456 | if ( !setFilterCategory() ) |
457 | return false; | 457 | return false; |
458 | } | 458 | } |
459 | 459 | ||
460 | categoryFilterEnabled = true; | 460 | categoryFilterEnabled = true; |
461 | serverSelected( -1 ); | 461 | serverSelected( -1 ); |
462 | return true; | 462 | return true; |
463 | } | 463 | } |
464 | else | 464 | else |
465 | { | 465 | { |
466 | // Turn off filter | 466 | // Turn off filter |
467 | categoryFilterEnabled = false; | 467 | categoryFilterEnabled = false; |
468 | serverSelected( -1 ); | 468 | serverSelected( -1 ); |
469 | return false; | 469 | return false; |
470 | } | 470 | } |
471 | } | 471 | } |
472 | 472 | ||
473 | void MainWindow :: raiseMainWidget() | 473 | void MainWindow :: raiseMainWidget() |
474 | { | 474 | { |
475 | stack->raiseWidget( networkPkgWindow ); | 475 | stack->raiseWidget( networkPkgWindow ); |
476 | } | 476 | } |
477 | 477 | ||
478 | void MainWindow :: raiseProgressWidget() | 478 | void MainWindow :: raiseProgressWidget() |
479 | { | 479 | { |
480 | stack->raiseWidget( progressWindow ); | 480 | stack->raiseWidget( progressWindow ); |
481 | } | 481 | } |
482 | 482 | ||
483 | void MainWindow :: enableUpgrade( bool enabled ) | 483 | void MainWindow :: enableUpgrade( bool enabled ) |
484 | { | 484 | { |
485 | actionUpgrade->setEnabled( enabled ); | 485 | actionUpgrade->setEnabled( enabled ); |
486 | } | 486 | } |
487 | 487 | ||
488 | void MainWindow :: enableDownload( bool enabled ) | 488 | void MainWindow :: enableDownload( bool enabled ) |
489 | { | 489 | { |
490 | if ( enabled ) | 490 | if ( enabled ) |
491 | { | 491 | { |
492 | actionDownload->setIconSet( iconDownload ); | 492 | actionDownload->setIconSet( iconDownload ); |
493 | actionDownload->setText( tr( "Download" ) ); | 493 | actionDownload->setText( tr( "Download" ) ); |
494 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 494 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
495 | } | 495 | } |
496 | else | 496 | else |
497 | { | 497 | { |
498 | actionDownload->setIconSet( iconRemove ); | 498 | actionDownload->setIconSet( iconRemove ); |
499 | actionDownload->setText( tr( "Remove" ) ); | 499 | actionDownload->setText( tr( "Remove" ) ); |
500 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 500 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | void MainWindow :: setProgressSteps( int numsteps ) | 504 | void MainWindow :: setProgressSteps( int numsteps ) |
505 | { | 505 | { |
506 | m_progress->setTotalSteps( numsteps ); | 506 | m_progress->setTotalSteps( numsteps ); |
507 | } | 507 | } |
508 | 508 | ||
509 | void MainWindow :: setProgressMessage( const QString &msg ) | 509 | void MainWindow :: setProgressMessage( const QString &msg ) |
510 | { | 510 | { |
511 | m_status->setText( msg ); | 511 | m_status->setText( msg ); |
512 | } | 512 | } |
513 | 513 | ||
514 | void MainWindow :: updateProgress( int progress ) | 514 | void MainWindow :: updateProgress( int progress ) |
515 | { | 515 | { |
516 | m_progress->setProgress( progress ); | 516 | m_progress->setProgress( progress ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void MainWindow :: updateData() | 519 | void MainWindow :: updateData() |
520 | { | 520 | { |
521 | m_progress->setTotalSteps( mgr->getServerList().count() ); | 521 | m_progress->setTotalSteps( mgr->getServerList().count() ); |
522 | 522 | ||
523 | serversList->clear(); | 523 | serversList->clear(); |
524 | packagesList->clear(); | 524 | packagesList->clear(); |
525 | 525 | ||
526 | int activeItem = -1; | 526 | int activeItem = -1; |
527 | int i = 0; | 527 | int i = 0; |
528 | QString serverName; | 528 | QString serverName; |
529 | 529 | ||
530 | QListIterator<Server> it( mgr->getServerList() ); | 530 | QListIterator<Server> it( mgr->getServerList() ); |
531 | Server *server; | 531 | Server *server; |
532 | 532 | ||
533 | for ( ; it.current(); ++it, ++i ) | 533 | for ( ; it.current(); ++it, ++i ) |
534 | { | 534 | { |
535 | server = it.current(); | 535 | server = it.current(); |
536 | serverName = server->getServerName(); | 536 | serverName = server->getServerName(); |
537 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 537 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
538 | m_progress->setProgress( i ); | 538 | m_progress->setProgress( i ); |
539 | qApp->processEvents(); | 539 | qApp->processEvents(); |
540 | 540 | ||
541 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; | 541 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; |
542 | if ( !server->isServerActive() ) | 542 | if ( !server->isServerActive() ) |
543 | { | 543 | { |
544 | // cout << serverName << " is not active" << endl; | 544 | // cout << serverName << " is not active" << endl; |
545 | i--; | 545 | i--; |
546 | continue; | 546 | continue; |
547 | } | 547 | } |
548 | 548 | ||
549 | serversList->insertItem( serverName ); | 549 | serversList->insertItem( serverName ); |
550 | if ( serverName == currentlySelectedServer ) | 550 | if ( serverName == currentlySelectedServer ) |
551 | activeItem = i; | 551 | activeItem = i; |
552 | } | 552 | } |
553 | 553 | ||
554 | // set selected server to be active server | 554 | // set selected server to be active server |
555 | if ( activeItem != -1 ) | 555 | if ( activeItem != -1 ) |
556 | serversList->setCurrentItem( activeItem ); | 556 | serversList->setCurrentItem( activeItem ); |
557 | serverSelected( 0, FALSE ); | 557 | serverSelected( 0, FALSE ); |
558 | } | 558 | } |
559 | 559 | ||
560 | void MainWindow :: serverSelected( int index ) | 560 | void MainWindow :: serverSelected( int index ) |
561 | { | 561 | { |
562 | serverSelected( index, TRUE ); | 562 | serverSelected( index, TRUE ); |
563 | } | 563 | } |
564 | 564 | ||
565 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 565 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
566 | { | 566 | { |
567 | QPixmap nullIcon( installedIcon.size() ); | 567 | QPixmap nullIcon( installedIcon.size() ); |
568 | nullIcon.fill( colorGroup().base() ); | 568 | nullIcon.fill( colorGroup().base() ); |
569 | 569 | ||
570 | // display packages | 570 | // display packages |
571 | QString serverName = serversList->currentText(); | 571 | QString serverName = serversList->currentText(); |
572 | currentlySelectedServer = serverName; | 572 | currentlySelectedServer = serverName; |
573 | 573 | ||
574 | Server *s = mgr->getServer( serverName ); | 574 | Server *s = mgr->getServer( serverName ); |
575 | 575 | ||
576 | QList<Package> &list = s->getPackageList(); | 576 | QList<Package> &list = s->getPackageList(); |
577 | QListIterator<Package> it( list ); | 577 | QListIterator<Package> it( list ); |
578 | 578 | ||
579 | // Display progress widget while loading list | 579 | // Display progress widget while loading list |
580 | bool doProgress = ( list.count() > 200 ); | 580 | bool doProgress = ( list.count() > 200 ); |
581 | if ( doProgress ) | 581 | if ( doProgress ) |
582 | { | 582 | { |
583 | if ( raiseProgress ) | 583 | if ( raiseProgress ) |
584 | { | 584 | { |
585 | stack->raiseWidget( progressWindow ); | 585 | stack->raiseWidget( progressWindow ); |
586 | } | 586 | } |
587 | m_progress->setTotalSteps( list.count() ); | 587 | m_progress->setTotalSteps( list.count() ); |
588 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 588 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
589 | } | 589 | } |
590 | 590 | ||
591 | packagesList->clear(); | 591 | packagesList->clear(); |
592 | 592 | ||
593 | #ifdef QWS | 593 | #ifdef QWS |
594 | // read download directory from config file | 594 | // read download directory from config file |
595 | Config cfg( "aqpkg" ); | 595 | Config cfg( "aqpkg" ); |
596 | cfg.setGroup( "settings" ); | 596 | cfg.setGroup( "settings" ); |
597 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 597 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
598 | #endif | 598 | #endif |
599 | 599 | ||
600 | int i = 0; | 600 | int i = 0; |
601 | Package *package; | 601 | Package *package; |
602 | for ( ; it.current(); ++it ) | 602 | for ( ; it.current(); ++it ) |
603 | { | 603 | { |
604 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 604 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
605 | i++; | 605 | i++; |
606 | if ( ( i % 100 ) == 0 ) | 606 | if ( ( i % 100 ) == 0 ) |
607 | { | 607 | { |
608 | if ( doProgress ) | 608 | if ( doProgress ) |
609 | { | 609 | { |
610 | m_progress->setProgress( i ); | 610 | m_progress->setProgress( i ); |
611 | } | 611 | } |
612 | qApp->processEvents(); | 612 | qApp->processEvents(); |
613 | } | 613 | } |
614 | 614 | ||
615 | QString text = ""; | 615 | QString text = ""; |
616 | 616 | ||
617 | package = it.current(); | 617 | package = it.current(); |
618 | 618 | ||
619 | // Apply show only uninstalled packages filter | 619 | // Apply show only uninstalled packages filter |
620 | if ( showUninstalledPkgs && package->isInstalled() ) | 620 | if ( showUninstalledPkgs && package->isInstalled() ) |
621 | continue; | 621 | continue; |
622 | 622 | ||
623 | // Apply show only installed packages filter | 623 | // Apply show only installed packages filter |
624 | if ( showInstalledPkgs && !package->isInstalled() ) | 624 | if ( showInstalledPkgs && !package->isInstalled() ) |
625 | continue; | 625 | continue; |
626 | 626 | ||
627 | // Apply show only new installed packages filter | 627 | // Apply show only new installed packages filter |
628 | if ( showUpgradedPkgs ) | 628 | if ( showUpgradedPkgs ) |
629 | { | 629 | { |
630 | if ( !package->isInstalled() || | 630 | if ( !package->isInstalled() || |
631 | compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 ) | 631 | compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 ) |
632 | continue; | 632 | continue; |
633 | } | 633 | } |
634 | 634 | ||
635 | // Apply the section filter | 635 | // Apply the section filter |
636 | if ( categoryFilterEnabled && categoryFilter != "" ) | 636 | if ( categoryFilterEnabled && categoryFilter != "" ) |
637 | { | 637 | { |
638 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) | 638 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) |
639 | continue; | 639 | continue; |
640 | } | 640 | } |
641 | 641 | ||
642 | // If the local server, only display installed packages | 642 | // If the local server, only display installed packages |
643 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) | 643 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
644 | continue; | 644 | continue; |
645 | 645 | ||
646 | 646 | ||
647 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), | 647 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
648 | QCheckListItem::CheckBox ); | 648 | QCheckListItem::CheckBox ); |
649 | 649 | ||
650 | if ( package->isInstalled() ) | 650 | if ( package->isInstalled() ) |
651 | { | 651 | { |
652 | // If a different version of package is available, show update available icon | 652 | // If a different version of package is available, show update available icon |
653 | // Otherwise, show installed icon | 653 | // Otherwise, show installed icon |
654 | if ( package->getVersion() != package->getInstalledVersion() && | 654 | if ( package->getVersion() != package->getInstalledVersion() && |
655 | compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1) | 655 | compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1) |
656 | { | 656 | { |
657 | 657 | ||
658 | item->setPixmap( 0, updatedIcon ); | 658 | item->setPixmap( 0, updatedIcon ); |
659 | } | 659 | } |
660 | else | 660 | else |
661 | { | 661 | { |
662 | item->setPixmap( 0, installedIcon ); | 662 | item->setPixmap( 0, installedIcon ); |
663 | } | 663 | } |
664 | 664 | ||
665 | QString destName = ""; | 665 | QString destName = ""; |
666 | if ( package->getLocalPackage() ) | 666 | if ( package->getLocalPackage() ) |
667 | { | 667 | { |
668 | if ( package->getLocalPackage()->getInstalledTo() ) | 668 | if ( package->getLocalPackage()->getInstalledTo() ) |
669 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); | 669 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); |
670 | } | 670 | } |
671 | else | 671 | else |
672 | { | 672 | { |
673 | if ( package->getInstalledTo() ) | 673 | if ( package->getInstalledTo() ) |
674 | destName = package->getInstalledTo()->getDestinationName(); | 674 | destName = package->getInstalledTo()->getDestinationName(); |
675 | } | 675 | } |
676 | if ( destName != "" ) | 676 | if ( destName != "" ) |
677 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); | 677 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); |
678 | } | 678 | } |
679 | else | 679 | else |
680 | { | 680 | { |
681 | item->setPixmap( 0, nullIcon ); | 681 | item->setPixmap( 0, nullIcon ); |
682 | } | 682 | } |
683 | 683 | ||
684 | if ( !package->isPackageStoredLocally() ) | 684 | if ( !package->isPackageStoredLocally() ) |
685 | { | 685 | { |
686 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) ); | 686 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) ); |
687 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) ); | 687 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) ); |
688 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) ); | 688 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) ); |
689 | } | 689 | } |
690 | else | 690 | else |
691 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) ); | 691 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) ); |
692 | 692 | ||
693 | if ( serverName == LOCAL_SERVER ) | 693 | if ( serverName == LOCAL_SERVER ) |
694 | { | 694 | { |
695 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) ); | 695 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) ); |
696 | } | 696 | } |
697 | else | 697 | else |
698 | { | 698 | { |
699 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) ); | 699 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) ); |
700 | if ( package->getLocalPackage() ) | 700 | if ( package->getLocalPackage() ) |
701 | { | 701 | { |
702 | if ( package->isInstalled() ) | 702 | if ( package->isInstalled() ) |
703 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) ); | 703 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) ); |
704 | } | 704 | } |
705 | } | 705 | } |
706 | 706 | ||
707 | packagesList->insertItem( item ); | 707 | packagesList->insertItem( item ); |
708 | } | 708 | } |
709 | 709 | ||
710 | // If the local server or the local ipkgs server disable the download button | 710 | // If the local server or the local ipkgs server disable the download button |
711 | if ( serverName == LOCAL_SERVER ) | 711 | if ( serverName == LOCAL_SERVER ) |
712 | { | 712 | { |
713 | downloadEnabled = TRUE; | 713 | downloadEnabled = TRUE; |
714 | actionUpgrade->setEnabled( FALSE ); | 714 | actionUpgrade->setEnabled( FALSE ); |
715 | } | 715 | } |
716 | else if ( serverName == LOCAL_IPKGS ) | 716 | else if ( serverName == LOCAL_IPKGS ) |
717 | { | 717 | { |
718 | downloadEnabled = FALSE; | 718 | downloadEnabled = FALSE; |
719 | actionUpgrade->setEnabled( FALSE ); | 719 | actionUpgrade->setEnabled( FALSE ); |
720 | } | 720 | } |
721 | else | 721 | else |
722 | { | 722 | { |
723 | downloadEnabled = TRUE; | 723 | downloadEnabled = TRUE; |
724 | actionUpgrade->setEnabled( TRUE ); | 724 | actionUpgrade->setEnabled( TRUE ); |
725 | } | 725 | } |
726 | enableDownload( downloadEnabled ); | 726 | enableDownload( downloadEnabled ); |
727 | 727 | ||
728 | // Display this widget once everything is done | 728 | // Display this widget once everything is done |
729 | if ( doProgress && raiseProgress ) | 729 | if ( doProgress && raiseProgress ) |
730 | { | 730 | { |
731 | stack->raiseWidget( networkPkgWindow ); | 731 | stack->raiseWidget( networkPkgWindow ); |
732 | } | 732 | } |
733 | } | 733 | } |
734 | 734 | ||
735 | void MainWindow :: searchForPackage( const QString &text ) | 735 | void MainWindow :: searchForPackage( const QString &text ) |
736 | { | 736 | { |
737 | if ( !text.isEmpty() ) | 737 | if ( !text.isEmpty() ) |
738 | { | 738 | { |
739 | // cout << "searching for " << text << endl; | 739 | // cout << "searching for " << text << endl; |
740 | // look through package list for text startng at current position | 740 | // look through package list for text startng at current position |
741 | // vector<InstallData> workingPackages; | 741 | // vector<InstallData> workingPackages; |
742 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 742 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
743 | // if ( start != 0 ) | 743 | // if ( start != 0 ) |
744 | // start = (QCheckListItem *)start->nextSibling(); | 744 | // start = (QCheckListItem *)start->nextSibling(); |
745 | 745 | ||
746 | if ( start == 0 ) | 746 | if ( start == 0 ) |
747 | start = (QCheckListItem *)packagesList->firstChild(); | 747 | start = (QCheckListItem *)packagesList->firstChild(); |
748 | 748 | ||
749 | for ( QCheckListItem *item = start; item != 0 ; | 749 | for ( QCheckListItem *item = start; item != 0 ; |
750 | item = (QCheckListItem *)item->nextSibling() ) | 750 | item = (QCheckListItem *)item->nextSibling() ) |
751 | { | 751 | { |
752 | // cout << "checking " << item->text().lower() << endl; | 752 | // cout << "checking " << item->text().lower() << endl; |
753 | if ( item->text().lower().find( text ) != -1 ) | 753 | if ( item->text().lower().find( text ) != -1 ) |