-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 17 |
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,718 +1,713 @@ | |||
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 | 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 | ||
226 | MainWindow :: ~MainWindow() | 221 | MainWindow :: ~MainWindow() |
227 | { | 222 | { |
228 | delete mgr; | 223 | delete mgr; |
229 | } | 224 | } |
230 | 225 | ||
231 | void MainWindow :: initMainWidget() | 226 | void 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 | ||
258 | void MainWindow :: initProgressWidget() | 253 | void 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 | ||
272 | void MainWindow :: init() | 267 | void 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 | /* |
302 | void MainWindow :: setDocument( const QString &doc ) | 297 | void 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 | */ |
332 | void MainWindow :: displaySettings() | 327 | void 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 | ||
344 | void MainWindow :: closeEvent( QCloseEvent *e ) | 339 | void 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 | ||
361 | void MainWindow :: displayFindBar() | 356 | void MainWindow :: displayFindBar() |
362 | { | 357 | { |
363 | findBar->show(); | 358 | findBar->show(); |
364 | findEdit->setFocus(); | 359 | findEdit->setFocus(); |
365 | } | 360 | } |
366 | 361 | ||
367 | void MainWindow :: displayJumpBar() | 362 | void MainWindow :: displayJumpBar() |
368 | { | 363 | { |
369 | jumpBar->show(); | 364 | jumpBar->show(); |
370 | } | 365 | } |
371 | 366 | ||
372 | void MainWindow :: repeatFind() | 367 | void MainWindow :: repeatFind() |
373 | { | 368 | { |
374 | searchForPackage( findEdit->text() ); | 369 | searchForPackage( findEdit->text() ); |
375 | } | 370 | } |
376 | 371 | ||
377 | void MainWindow :: findPackage( const QString &text ) | 372 | void 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 | ||
383 | void MainWindow :: hideFindBar() | 378 | void MainWindow :: hideFindBar() |
384 | { | 379 | { |
385 | findBar->hide(); | 380 | findBar->hide(); |
386 | } | 381 | } |
387 | 382 | ||
388 | void MainWindow :: hideJumpBar() | 383 | void MainWindow :: hideJumpBar() |
389 | { | 384 | { |
390 | jumpBar->hide(); | 385 | jumpBar->hide(); |
391 | } | 386 | } |
392 | 387 | ||
393 | void MainWindow :: filterUninstalledPackages() | 388 | void 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 | ||
407 | void MainWindow :: filterInstalledPackages() | 402 | void 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 | ||
421 | void MainWindow :: filterUpgradedPackages() | 416 | void 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 | ||
435 | bool MainWindow :: setFilterCategory() | 430 | bool 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 | ||
455 | void MainWindow :: filterCategory() | 450 | void 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 | ||
467 | bool MainWindow :: filterByCategory( bool val ) | 462 | bool 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 | ||
490 | void MainWindow :: raiseMainWidget() | 485 | void MainWindow :: raiseMainWidget() |
491 | { | 486 | { |
492 | stack->raiseWidget( networkPkgWindow ); | 487 | stack->raiseWidget( networkPkgWindow ); |
493 | } | 488 | } |
494 | 489 | ||
495 | void MainWindow :: raiseProgressWidget() | 490 | void MainWindow :: raiseProgressWidget() |
496 | { | 491 | { |
497 | stack->raiseWidget( progressWindow ); | 492 | stack->raiseWidget( progressWindow ); |
498 | } | 493 | } |
499 | 494 | ||
500 | void MainWindow :: enableUpgrade( bool enabled ) | 495 | void MainWindow :: enableUpgrade( bool enabled ) |
501 | { | 496 | { |
502 | actionUpgrade->setEnabled( enabled ); | 497 | actionUpgrade->setEnabled( enabled ); |
503 | } | 498 | } |
504 | 499 | ||
505 | void MainWindow :: enableDownload( bool enabled ) | 500 | void 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 | ||
521 | void MainWindow :: setProgressSteps( int numsteps ) | 516 | void MainWindow :: setProgressSteps( int numsteps ) |
522 | { | 517 | { |
523 | m_progress->setTotalSteps( numsteps ); | 518 | m_progress->setTotalSteps( numsteps ); |
524 | } | 519 | } |
525 | 520 | ||
526 | void MainWindow :: setProgressMessage( const QString &msg ) | 521 | void MainWindow :: setProgressMessage( const QString &msg ) |
527 | { | 522 | { |
528 | m_status->setText( msg ); | 523 | m_status->setText( msg ); |
529 | } | 524 | } |
530 | 525 | ||
531 | void MainWindow :: updateProgress( int progress ) | 526 | void MainWindow :: updateProgress( int progress ) |
532 | { | 527 | { |
533 | m_progress->setProgress( progress ); | 528 | m_progress->setProgress( progress ); |
534 | } | 529 | } |
535 | 530 | ||
536 | void MainWindow :: updateData() | 531 | void 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 | ||
577 | void MainWindow :: serverSelected( int index ) | 572 | void MainWindow :: serverSelected( int index ) |
578 | { | 573 | { |
579 | serverSelected( index, TRUE ); | 574 | serverSelected( index, TRUE ); |
580 | } | 575 | } |
581 | 576 | ||
582 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 577 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
583 | { | 578 | { |
584 | QPixmap nullIcon( installedIcon.size() ); | 579 | QPixmap nullIcon( installedIcon.size() ); |
585 | nullIcon.fill( colorGroup().base() ); | 580 | nullIcon.fill( colorGroup().base() ); |
586 | 581 | ||
587 | // display packages | 582 | // display packages |
588 | QString serverName = serversList->currentText(); | 583 | QString serverName = serversList->currentText(); |
589 | currentlySelectedServer = serverName; | 584 | currentlySelectedServer = serverName; |
590 | 585 | ||
591 | Server *s = mgr->getServer( serverName ); | 586 | Server *s = mgr->getServer( serverName ); |
592 | 587 | ||
593 | QList<Package> &list = s->getPackageList(); | 588 | QList<Package> &list = s->getPackageList(); |
594 | QListIterator<Package> it( list ); | 589 | QListIterator<Package> it( list ); |
595 | 590 | ||
596 | // Display progress widget while loading list | 591 | // Display progress widget while loading list |
597 | bool doProgress = ( list.count() > 200 ); | 592 | bool doProgress = ( list.count() > 200 ); |
598 | if ( doProgress ) | 593 | if ( doProgress ) |
599 | { | 594 | { |
600 | if ( raiseProgress ) | 595 | if ( raiseProgress ) |
601 | { | 596 | { |
602 | stack->raiseWidget( progressWindow ); | 597 | stack->raiseWidget( progressWindow ); |
603 | } | 598 | } |
604 | m_progress->setTotalSteps( list.count() ); | 599 | m_progress->setTotalSteps( list.count() ); |
605 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 600 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
606 | } | 601 | } |
607 | 602 | ||
608 | packagesList->clear(); | 603 | packagesList->clear(); |
609 | 604 | ||
610 | #ifdef QWS | 605 | #ifdef QWS |
611 | // read download directory from config file | 606 | // read download directory from config file |
612 | Config cfg( "aqpkg" ); | 607 | Config cfg( "aqpkg" ); |
613 | cfg.setGroup( "settings" ); | 608 | cfg.setGroup( "settings" ); |
614 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 609 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
615 | #endif | 610 | #endif |
616 | 611 | ||
617 | int i = 0; | 612 | int i = 0; |
618 | Package *package; | 613 | Package *package; |
619 | for ( ; it.current(); ++it ) | 614 | for ( ; it.current(); ++it ) |
620 | { | 615 | { |
621 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 616 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
622 | i++; | 617 | i++; |
623 | if ( ( i % 100 ) == 0 ) | 618 | if ( ( i % 100 ) == 0 ) |
624 | { | 619 | { |
625 | if ( doProgress ) | 620 | if ( doProgress ) |
626 | { | 621 | { |
627 | m_progress->setProgress( i ); | 622 | m_progress->setProgress( i ); |
628 | } | 623 | } |
629 | qApp->processEvents(); | 624 | qApp->processEvents(); |
630 | } | 625 | } |
631 | 626 | ||
632 | QString text = ""; | 627 | QString text = ""; |
633 | 628 | ||
634 | package = it.current(); | 629 | package = it.current(); |
635 | 630 | ||
636 | // Apply show only uninstalled packages filter | 631 | // Apply show only uninstalled packages filter |
637 | if ( showUninstalledPkgs && package->isInstalled() ) | 632 | if ( showUninstalledPkgs && package->isInstalled() ) |
638 | continue; | 633 | continue; |
639 | 634 | ||
640 | // Apply show only installed packages filter | 635 | // Apply show only installed packages filter |
641 | if ( showInstalledPkgs && !package->isInstalled() ) | 636 | if ( showInstalledPkgs && !package->isInstalled() ) |
642 | continue; | 637 | continue; |
643 | 638 | ||
644 | // Apply show only new installed packages filter | 639 | // Apply show only new installed packages filter |
645 | if ( showUpgradedPkgs ) | 640 | if ( showUpgradedPkgs ) |
646 | { | 641 | { |
647 | if ( !package->isInstalled() || | 642 | if ( !package->isInstalled() || |
648 | compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 ) | 643 | compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 ) |
649 | continue; | 644 | continue; |
650 | } | 645 | } |
651 | 646 | ||
652 | // Apply the section filter | 647 | // Apply the section filter |
653 | if ( categoryFilterEnabled && categoryFilter != "" ) | 648 | if ( categoryFilterEnabled && categoryFilter != "" ) |
654 | { | 649 | { |
655 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) | 650 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) |
656 | continue; | 651 | continue; |
657 | } | 652 | } |
658 | 653 | ||
659 | // If the local server, only display installed packages | 654 | // If the local server, only display installed packages |
660 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) | 655 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
661 | continue; | 656 | continue; |
662 | 657 | ||
663 | 658 | ||
664 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), | 659 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
665 | QCheckListItem::CheckBox ); | 660 | QCheckListItem::CheckBox ); |
666 | 661 | ||
667 | if ( package->isInstalled() ) | 662 | if ( package->isInstalled() ) |
668 | { | 663 | { |
669 | // If a different version of package is available, show update available icon | 664 | // If a different version of package is available, show update available icon |
670 | // Otherwise, show installed icon | 665 | // Otherwise, show installed icon |
671 | if ( package->getVersion() != package->getInstalledVersion() && | 666 | if ( package->getVersion() != package->getInstalledVersion() && |
672 | compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1) | 667 | compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1) |
673 | { | 668 | { |
674 | 669 | ||
675 | item->setPixmap( 0, updatedIcon ); | 670 | item->setPixmap( 0, updatedIcon ); |
676 | } | 671 | } |
677 | else | 672 | else |
678 | { | 673 | { |
679 | item->setPixmap( 0, installedIcon ); | 674 | item->setPixmap( 0, installedIcon ); |
680 | } | 675 | } |
681 | 676 | ||
682 | QString destName = ""; | 677 | QString destName = ""; |
683 | if ( package->getLocalPackage() ) | 678 | if ( package->getLocalPackage() ) |
684 | { | 679 | { |
685 | if ( package->getLocalPackage()->getInstalledTo() ) | 680 | if ( package->getLocalPackage()->getInstalledTo() ) |
686 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); | 681 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); |
687 | } | 682 | } |
688 | else | 683 | else |
689 | { | 684 | { |
690 | if ( package->getInstalledTo() ) | 685 | if ( package->getInstalledTo() ) |
691 | destName = package->getInstalledTo()->getDestinationName(); | 686 | destName = package->getInstalledTo()->getDestinationName(); |
692 | } | 687 | } |
693 | if ( destName != "" ) | 688 | if ( destName != "" ) |
694 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); | 689 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); |
695 | } | 690 | } |
696 | else | 691 | else |
697 | { | 692 | { |
698 | item->setPixmap( 0, nullIcon ); | 693 | item->setPixmap( 0, nullIcon ); |
699 | } | 694 | } |
700 | 695 | ||
701 | if ( !package->isPackageStoredLocally() ) | 696 | if ( !package->isPackageStoredLocally() ) |
702 | { | 697 | { |
703 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) ); | 698 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) ); |
704 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) ); | 699 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) ); |
705 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) ); | 700 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) ); |
706 | } | 701 | } |
707 | else | 702 | else |
708 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) ); | 703 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) ); |
709 | 704 | ||
710 | if ( serverName == LOCAL_SERVER ) | 705 | if ( serverName == LOCAL_SERVER ) |
711 | { | 706 | { |
712 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) ); | 707 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) ); |
713 | } | 708 | } |
714 | else | 709 | else |
715 | { | 710 | { |
716 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) ); | 711 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) ); |
717 | if ( package->getLocalPackage() ) | 712 | if ( package->getLocalPackage() ) |
718 | { | 713 | { |