author | kergoth <kergoth> | 2003-01-23 20:12:55 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-01-23 20:12:55 (UTC) |
commit | 2b0157e5c600f6880ef10a1df187df45ac25f051 (patch) (unidiff) | |
tree | f9049b5aac89d9605146efeeb221e2b8dcb26b85 | |
parent | 5100d4dc5012d5ff65bf1afc814e0552fe2d98fa (diff) | |
download | opie-2b0157e5c600f6880ef10a1df187df45ac25f051.zip opie-2b0157e5c600f6880ef10a1df187df45ac25f051.tar.gz opie-2b0157e5c600f6880ef10a1df187df45ac25f051.tar.bz2 |
Compile fix, if you use PATH_MAX, include linux/limits.h.
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 8090646..ae073ef 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,785 +1,786 @@ | |||
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 <unistd.h> | 19 | #include <unistd.h> |
19 | 20 | ||
20 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
21 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
25 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
26 | 27 | ||
27 | #include <qaction.h> | 28 | #include <qaction.h> |
28 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
29 | #include <qfile.h> | 30 | #include <qfile.h> |
30 | #include <qlabel.h> | 31 | #include <qlabel.h> |
31 | #include <qlayout.h> | 32 | #include <qlayout.h> |
32 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
33 | #include <qlistview.h> | 34 | #include <qlistview.h> |
34 | #include <qmenubar.h> | 35 | #include <qmenubar.h> |
35 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
36 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
37 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
38 | #include <qtimer.h> | 39 | #include <qtimer.h> |
39 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
40 | #include <qwidgetstack.h> | 41 | #include <qwidgetstack.h> |
41 | 42 | ||
42 | #include "categoryfilterimpl.h" | 43 | #include "categoryfilterimpl.h" |
43 | #include "datamgr.h" | 44 | #include "datamgr.h" |
44 | #include "global.h" | 45 | #include "global.h" |
45 | #include "helpwindow.h" | 46 | #include "helpwindow.h" |
46 | #include "inputdlg.h" | 47 | #include "inputdlg.h" |
47 | #include "installdlgimpl.h" | 48 | #include "installdlgimpl.h" |
48 | #include "letterpushbutton.h" | 49 | #include "letterpushbutton.h" |
49 | #include "mainwin.h" | 50 | #include "mainwin.h" |
50 | #include "settingsimpl.h" | 51 | #include "settingsimpl.h" |
51 | #include "utils.h" | 52 | #include "utils.h" |
52 | 53 | ||
53 | extern int compareVersions( const char *v1, const char *v2 ); | 54 | extern int compareVersions( const char *v1, const char *v2 ); |
54 | 55 | ||
55 | MainWindow :: MainWindow() | 56 | MainWindow :: MainWindow() |
56 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 57 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
57 | { | 58 | { |
58 | setCaption( tr( "AQPkg - Package Manager" ) ); | 59 | setCaption( tr( "AQPkg - Package Manager" ) ); |
59 | 60 | ||
60 | #ifdef QWS | 61 | #ifdef QWS |
61 | // read download directory from config file | 62 | // read download directory from config file |
62 | Config cfg( "aqpkg" ); | 63 | Config cfg( "aqpkg" ); |
63 | cfg.setGroup( "settings" ); | 64 | cfg.setGroup( "settings" ); |
64 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 65 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
65 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 66 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
66 | 67 | ||
67 | #endif | 68 | #endif |
68 | 69 | ||
69 | // Create UI widgets | 70 | // Create UI widgets |
70 | initMainWidget(); | 71 | initMainWidget(); |
71 | initProgressWidget(); | 72 | initProgressWidget(); |
72 | 73 | ||
73 | // Build menu and tool bars | 74 | // Build menu and tool bars |
74 | setToolBarsMovable( FALSE ); | 75 | setToolBarsMovable( FALSE ); |
75 | 76 | ||
76 | QPEToolBar *bar = new QPEToolBar( this ); | 77 | QPEToolBar *bar = new QPEToolBar( this ); |
77 | bar->setHorizontalStretchable( TRUE ); | 78 | bar->setHorizontalStretchable( TRUE ); |
78 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 79 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
79 | mb->setMargin( 0 ); | 80 | mb->setMargin( 0 ); |
80 | bar = new QPEToolBar( this ); | 81 | bar = new QPEToolBar( this ); |
81 | 82 | ||
82 | // Find toolbar | 83 | // Find toolbar |
83 | findBar = new QPEToolBar( this ); | 84 | findBar = new QPEToolBar( this ); |
84 | addToolBar( findBar, QMainWindow::Top, true ); | 85 | addToolBar( findBar, QMainWindow::Top, true ); |
85 | findBar->setHorizontalStretchable( true ); | 86 | findBar->setHorizontalStretchable( true ); |
86 | findEdit = new QLineEdit( findBar ); | 87 | findEdit = new QLineEdit( findBar ); |
87 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 88 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
88 | findBar->setStretchableWidget( findEdit ); | 89 | findBar->setStretchableWidget( findEdit ); |
89 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 90 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); |
90 | 91 | ||
91 | // Packages menu | 92 | // Packages menu |
92 | QPopupMenu *popup = new QPopupMenu( this ); | 93 | QPopupMenu *popup = new QPopupMenu( this ); |
93 | 94 | ||
94 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 95 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
95 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 96 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
96 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 97 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
97 | a->addTo( popup ); | 98 | a->addTo( popup ); |
98 | a->addTo( bar ); | 99 | a->addTo( bar ); |
99 | 100 | ||
100 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 101 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
101 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 102 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
102 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 103 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
103 | actionUpgrade->addTo( popup ); | 104 | actionUpgrade->addTo( popup ); |
104 | actionUpgrade->addTo( bar ); | 105 | actionUpgrade->addTo( bar ); |
105 | 106 | ||
106 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 107 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
107 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 108 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
108 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 109 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
109 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 110 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
110 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 111 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
111 | actionDownload->addTo( popup ); | 112 | actionDownload->addTo( popup ); |
112 | actionDownload->addTo( bar ); | 113 | actionDownload->addTo( bar ); |
113 | 114 | ||
114 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 115 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
115 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 116 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
116 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 117 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
117 | a->addTo( popup ); | 118 | a->addTo( popup ); |
118 | a->addTo( bar ); | 119 | a->addTo( bar ); |
119 | 120 | ||
120 | mb->insertItem( tr( "Actions" ), popup ); | 121 | mb->insertItem( tr( "Actions" ), popup ); |
121 | 122 | ||
122 | // View menu | 123 | // View menu |
123 | popup = new QPopupMenu( this ); | 124 | popup = new QPopupMenu( this ); |
124 | 125 | ||
125 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 126 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
126 | actionUninstalled->setToggleAction( TRUE ); | 127 | actionUninstalled->setToggleAction( TRUE ); |
127 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 128 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
128 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 129 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
129 | actionUninstalled->addTo( popup ); | 130 | actionUninstalled->addTo( popup ); |
130 | 131 | ||
131 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 132 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
132 | actionInstalled->setToggleAction( TRUE ); | 133 | actionInstalled->setToggleAction( TRUE ); |
133 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 134 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
134 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 135 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
135 | actionInstalled->addTo( popup ); | 136 | actionInstalled->addTo( popup ); |
136 | 137 | ||
137 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 138 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
138 | actionUpdated->setToggleAction( TRUE ); | 139 | actionUpdated->setToggleAction( TRUE ); |
139 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 140 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
140 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 141 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
141 | actionUpdated->addTo( popup ); | 142 | actionUpdated->addTo( popup ); |
142 | 143 | ||
143 | popup->insertSeparator(); | 144 | popup->insertSeparator(); |
144 | 145 | ||
145 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 146 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); |
146 | actionFilter->setToggleAction( TRUE ); | 147 | actionFilter->setToggleAction( TRUE ); |
147 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 148 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
148 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 149 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
149 | actionFilter->addTo( popup ); | 150 | actionFilter->addTo( popup ); |
150 | 151 | ||
151 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 152 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); |
152 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | 153 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
153 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 154 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
154 | a->addTo( popup ); | 155 | a->addTo( popup ); |
155 | 156 | ||
156 | popup->insertSeparator(); | 157 | popup->insertSeparator(); |
157 | 158 | ||
158 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
159 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 160 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
160 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 161 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
161 | a->addTo( popup ); | 162 | a->addTo( popup ); |
162 | 163 | ||
163 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 164 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
164 | actionFindNext->setEnabled( FALSE ); | 165 | actionFindNext->setEnabled( FALSE ); |
165 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 166 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
166 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 167 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
167 | actionFindNext->addTo( popup ); | 168 | actionFindNext->addTo( popup ); |
168 | actionFindNext->addTo( findBar ); | 169 | actionFindNext->addTo( findBar ); |
169 | 170 | ||
170 | mb->insertItem( tr( "View" ), popup ); | 171 | mb->insertItem( tr( "View" ), popup ); |
171 | 172 | ||
172 | 173 | ||
173 | // Options menu | 174 | // Options menu |
174 | popup = new QPopupMenu( this ); | 175 | popup = new QPopupMenu( this ); |
175 | 176 | ||
176 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); | 177 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "aqpkg/config" ), QString::null, 0, this, 0 ); |
177 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 178 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
178 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 179 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
179 | a->addTo( popup ); | 180 | a->addTo( popup ); |
180 | 181 | ||
181 | popup->insertSeparator(); | 182 | popup->insertSeparator(); |
182 | 183 | ||
183 | a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 ); | 184 | a = new QAction( tr( "Help" ), Resource::loadPixmap( "help_icon" ), QString::null, 0, this, 0 ); |
184 | a->setWhatsThis( tr( "Click here for help." ) ); | 185 | a->setWhatsThis( tr( "Click here for help." ) ); |
185 | connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) ); | 186 | connect( a, SIGNAL( activated() ), this, SLOT( displayHelp() ) ); |
186 | a->addTo( popup ); | 187 | a->addTo( popup ); |
187 | 188 | ||
188 | a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 ); | 189 | a = new QAction( tr( "About" ), Resource::loadPixmap( "UtilsIcon" ), QString::null, 0, this, 0 ); |
189 | a->setWhatsThis( tr( "Click here for software version information." ) ); | 190 | a->setWhatsThis( tr( "Click here for software version information." ) ); |
190 | connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) ); | 191 | connect( a, SIGNAL( activated() ), this, SLOT( displayAbout() ) ); |
191 | a->addTo( popup ); | 192 | a->addTo( popup ); |
192 | 193 | ||
193 | mb->insertItem( tr( "Options" ), popup ); | 194 | mb->insertItem( tr( "Options" ), popup ); |
194 | 195 | ||
195 | // Finish find toolbar creation | 196 | // Finish find toolbar creation |
196 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 197 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
197 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 198 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
198 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 199 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
199 | a->addTo( findBar ); | 200 | a->addTo( findBar ); |
200 | findBar->hide(); | 201 | findBar->hide(); |
201 | 202 | ||
202 | // Create widget stack and add UI widgets | 203 | // Create widget stack and add UI widgets |
203 | stack = new QWidgetStack( this ); | 204 | stack = new QWidgetStack( this ); |
204 | stack->addWidget( progressWindow, 2 ); | 205 | stack->addWidget( progressWindow, 2 ); |
205 | stack->addWidget( networkPkgWindow, 1 ); | 206 | stack->addWidget( networkPkgWindow, 1 ); |
206 | setCentralWidget( stack ); | 207 | setCentralWidget( stack ); |
207 | stack->raiseWidget( progressWindow ); | 208 | stack->raiseWidget( progressWindow ); |
208 | 209 | ||
209 | // Delayed call to finish initialization | 210 | // Delayed call to finish initialization |
210 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 211 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
211 | } | 212 | } |
212 | 213 | ||
213 | MainWindow :: ~MainWindow() | 214 | MainWindow :: ~MainWindow() |
214 | { | 215 | { |
215 | delete mgr; | 216 | delete mgr; |
216 | } | 217 | } |
217 | 218 | ||
218 | void MainWindow :: initMainWidget() | 219 | void MainWindow :: initMainWidget() |
219 | { | 220 | { |
220 | networkPkgWindow = new QWidget( this ); | 221 | networkPkgWindow = new QWidget( this ); |
221 | 222 | ||
222 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 223 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
223 | 224 | ||
224 | serversList = new QComboBox( networkPkgWindow ); | 225 | serversList = new QComboBox( networkPkgWindow ); |
225 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); | 226 | connect( serversList, SIGNAL( activated( int ) ), this, SLOT( serverSelected( int ) ) ); |
226 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 227 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
227 | 228 | ||
228 | installedIcon = Resource::loadPixmap( "aqpkg/installed" ); | 229 | installedIcon = Resource::loadPixmap( "aqpkg/installed" ); |
229 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 230 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
230 | 231 | ||
231 | packagesList = new QListView( networkPkgWindow ); | 232 | packagesList = new QListView( networkPkgWindow ); |
232 | packagesList->addColumn( tr( "Packages" ), 225 ); | 233 | packagesList->addColumn( tr( "Packages" ), 225 ); |
233 | 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." ) ); | 234 | 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." ) ); |
234 | 235 | ||
235 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 236 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
236 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 237 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
237 | hbox1->addWidget( l ); | 238 | hbox1->addWidget( l ); |
238 | hbox1->addWidget( serversList ); | 239 | hbox1->addWidget( serversList ); |
239 | 240 | ||
240 | 241 | ||
241 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); | 242 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); |
242 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); | 243 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); |
243 | 244 | ||
244 | if ( showJumpTo ) | 245 | if ( showJumpTo ) |
245 | { | 246 | { |
246 | char text[2]; | 247 | char text[2]; |
247 | text[1] = '\0'; | 248 | text[1] = '\0'; |
248 | for ( int i = 0 ; i < 26 ; ++i ) | 249 | for ( int i = 0 ; i < 26 ; ++i ) |
249 | { | 250 | { |
250 | text[0] = 'A' + i; | 251 | text[0] = 'A' + i; |
251 | LetterPushButton *b = new LetterPushButton( text, networkPkgWindow ); | 252 | LetterPushButton *b = new LetterPushButton( text, networkPkgWindow ); |
252 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 253 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
253 | if ( i < 13 ) | 254 | if ( i < 13 ) |
254 | hbox3->addWidget( b ); | 255 | hbox3->addWidget( b ); |
255 | else | 256 | else |
256 | hbox4->addWidget( b ); | 257 | hbox4->addWidget( b ); |
257 | } | 258 | } |
258 | } | 259 | } |
259 | 260 | ||
260 | vbox->addWidget( packagesList ); | 261 | vbox->addWidget( packagesList ); |
261 | 262 | ||
262 | downloadEnabled = TRUE; | 263 | downloadEnabled = TRUE; |
263 | } | 264 | } |
264 | 265 | ||
265 | void MainWindow :: initProgressWidget() | 266 | void MainWindow :: initProgressWidget() |
266 | { | 267 | { |
267 | progressWindow = new QWidget( this ); | 268 | progressWindow = new QWidget( this ); |
268 | 269 | ||
269 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 270 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
270 | 271 | ||
271 | m_status = new QLabel( progressWindow ); | 272 | m_status = new QLabel( progressWindow ); |
272 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 273 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
273 | layout->addWidget( m_status ); | 274 | layout->addWidget( m_status ); |
274 | 275 | ||
275 | m_progress = new QProgressBar( progressWindow ); | 276 | m_progress = new QProgressBar( progressWindow ); |
276 | layout->addWidget( m_progress ); | 277 | layout->addWidget( m_progress ); |
277 | } | 278 | } |
278 | 279 | ||
279 | void MainWindow :: init() | 280 | void MainWindow :: init() |
280 | { | 281 | { |
281 | stack->raiseWidget( progressWindow ); | 282 | stack->raiseWidget( progressWindow ); |
282 | 283 | ||
283 | mgr = new DataManager(); | 284 | mgr = new DataManager(); |
284 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 285 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
285 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 286 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
286 | this, SLOT( setProgressMessage( const QString & ) ) ); | 287 | this, SLOT( setProgressMessage( const QString & ) ) ); |
287 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 288 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); |
288 | mgr->loadServers(); | 289 | mgr->loadServers(); |
289 | 290 | ||
290 | showUninstalledPkgs = false; | 291 | showUninstalledPkgs = false; |
291 | showInstalledPkgs = false; | 292 | showInstalledPkgs = false; |
292 | showUpgradedPkgs = false; | 293 | showUpgradedPkgs = false; |
293 | categoryFilterEnabled = false; | 294 | categoryFilterEnabled = false; |
294 | 295 | ||
295 | updateData(); | 296 | updateData(); |
296 | 297 | ||
297 | stack->raiseWidget( networkPkgWindow ); | 298 | stack->raiseWidget( networkPkgWindow ); |
298 | } | 299 | } |
299 | /* | 300 | /* |
300 | void MainWindow :: setDocument( const QString &doc ) | 301 | void MainWindow :: setDocument( const QString &doc ) |
301 | { | 302 | { |
302 | // Remove path from package | 303 | // Remove path from package |
303 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 304 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
304 | // std::cout << "Selecting package " << package << std::endl; | 305 | // std::cout << "Selecting package " << package << std::endl; |
305 | 306 | ||
306 | // First select local server | 307 | // First select local server |
307 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 308 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
308 | { | 309 | { |
309 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 310 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
310 | { | 311 | { |
311 | serversList->setCurrentItem( i ); | 312 | serversList->setCurrentItem( i ); |
312 | break; | 313 | break; |
313 | } | 314 | } |
314 | } | 315 | } |
315 | serverSelected( 0 ); | 316 | serverSelected( 0 ); |
316 | 317 | ||
317 | // Now set the check box of the selected package | 318 | // Now set the check box of the selected package |
318 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 319 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
319 | item != 0 ; | 320 | item != 0 ; |
320 | item = (QCheckListItem *)item->nextSibling() ) | 321 | item = (QCheckListItem *)item->nextSibling() ) |
321 | { | 322 | { |
322 | if ( item->text().startsWith( package ) ) | 323 | if ( item->text().startsWith( package ) ) |
323 | { | 324 | { |
324 | item->setOn( true ); | 325 | item->setOn( true ); |
325 | break; | 326 | break; |
326 | } | 327 | } |
327 | } | 328 | } |
328 | } | 329 | } |
329 | */ | 330 | */ |
330 | void MainWindow :: displaySettings() | 331 | void MainWindow :: displaySettings() |
331 | { | 332 | { |
332 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 333 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
333 | if ( dlg->showDlg( 0 ) ) | 334 | if ( dlg->showDlg( 0 ) ) |
334 | { | 335 | { |
335 | stack->raiseWidget( progressWindow ); | 336 | stack->raiseWidget( progressWindow ); |
336 | updateData(); | 337 | updateData(); |
337 | stack->raiseWidget( networkPkgWindow ); | 338 | stack->raiseWidget( networkPkgWindow ); |
338 | } | 339 | } |
339 | delete dlg; | 340 | delete dlg; |
340 | } | 341 | } |
341 | 342 | ||
342 | void MainWindow :: displayHelp() | 343 | void MainWindow :: displayHelp() |
343 | { | 344 | { |
344 | HelpWindow *dlg = new HelpWindow( this ); | 345 | HelpWindow *dlg = new HelpWindow( this ); |
345 | dlg->exec(); | 346 | dlg->exec(); |
346 | delete dlg; | 347 | delete dlg; |
347 | } | 348 | } |
348 | 349 | ||
349 | void MainWindow :: displayFindBar() | 350 | void MainWindow :: displayFindBar() |
350 | { | 351 | { |
351 | findBar->show(); | 352 | findBar->show(); |
352 | findEdit->setFocus(); | 353 | findEdit->setFocus(); |
353 | } | 354 | } |
354 | 355 | ||
355 | void MainWindow :: repeatFind() | 356 | void MainWindow :: repeatFind() |
356 | { | 357 | { |
357 | searchForPackage( findEdit->text() ); | 358 | searchForPackage( findEdit->text() ); |
358 | } | 359 | } |
359 | 360 | ||
360 | void MainWindow :: findPackage( const QString &text ) | 361 | void MainWindow :: findPackage( const QString &text ) |
361 | { | 362 | { |
362 | actionFindNext->setEnabled( !text.isEmpty() ); | 363 | actionFindNext->setEnabled( !text.isEmpty() ); |
363 | searchForPackage( text ); | 364 | searchForPackage( text ); |
364 | } | 365 | } |
365 | 366 | ||
366 | void MainWindow :: hideFindBar() | 367 | void MainWindow :: hideFindBar() |
367 | { | 368 | { |
368 | findBar->hide(); | 369 | findBar->hide(); |
369 | } | 370 | } |
370 | 371 | ||
371 | void MainWindow :: displayAbout() | 372 | void MainWindow :: displayAbout() |
372 | { | 373 | { |
373 | QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) ); | 374 | QMessageBox::about( this, tr( "About AQPkg" ), tr( VERSION_TEXT ) ); |
374 | } | 375 | } |
375 | 376 | ||
376 | void MainWindow :: filterUninstalledPackages() | 377 | void MainWindow :: filterUninstalledPackages() |
377 | { | 378 | { |
378 | showUninstalledPkgs = actionUninstalled->isOn(); | 379 | showUninstalledPkgs = actionUninstalled->isOn(); |
379 | if ( showUninstalledPkgs ) | 380 | if ( showUninstalledPkgs ) |
380 | { | 381 | { |
381 | showInstalledPkgs = FALSE; | 382 | showInstalledPkgs = FALSE; |
382 | showUpgradedPkgs = FALSE; | 383 | showUpgradedPkgs = FALSE; |
383 | } | 384 | } |
384 | serverSelected( -1 ); | 385 | serverSelected( -1 ); |
385 | 386 | ||
386 | actionInstalled->setOn( FALSE ); | 387 | actionInstalled->setOn( FALSE ); |
387 | actionUpdated->setOn( FALSE ); | 388 | actionUpdated->setOn( FALSE ); |
388 | } | 389 | } |
389 | 390 | ||
390 | void MainWindow :: filterInstalledPackages() | 391 | void MainWindow :: filterInstalledPackages() |
391 | { | 392 | { |
392 | showInstalledPkgs = actionInstalled->isOn(); | 393 | showInstalledPkgs = actionInstalled->isOn(); |
393 | if ( showInstalledPkgs ) | 394 | if ( showInstalledPkgs ) |
394 | { | 395 | { |
395 | showUninstalledPkgs = FALSE; | 396 | showUninstalledPkgs = FALSE; |
396 | showUpgradedPkgs = FALSE; | 397 | showUpgradedPkgs = FALSE; |
397 | } | 398 | } |
398 | serverSelected( -1 ); | 399 | serverSelected( -1 ); |
399 | 400 | ||
400 | actionUninstalled->setOn( FALSE ); | 401 | actionUninstalled->setOn( FALSE ); |
401 | actionUpdated->setOn( FALSE ); | 402 | actionUpdated->setOn( FALSE ); |
402 | } | 403 | } |
403 | 404 | ||
404 | void MainWindow :: filterUpgradedPackages() | 405 | void MainWindow :: filterUpgradedPackages() |
405 | { | 406 | { |
406 | showUpgradedPkgs = actionUpdated->isOn(); | 407 | showUpgradedPkgs = actionUpdated->isOn(); |
407 | if ( showUpgradedPkgs ) | 408 | if ( showUpgradedPkgs ) |
408 | { | 409 | { |
409 | showUninstalledPkgs = FALSE; | 410 | showUninstalledPkgs = FALSE; |
410 | showInstalledPkgs = FALSE; | 411 | showInstalledPkgs = FALSE; |
411 | } | 412 | } |
412 | serverSelected( -1 ); | 413 | serverSelected( -1 ); |
413 | 414 | ||
414 | actionUninstalled->setOn( FALSE ); | 415 | actionUninstalled->setOn( FALSE ); |
415 | actionInstalled->setOn( FALSE ); | 416 | actionInstalled->setOn( FALSE ); |
416 | } | 417 | } |
417 | 418 | ||
418 | bool MainWindow :: setFilterCategory() | 419 | bool MainWindow :: setFilterCategory() |
419 | { | 420 | { |
420 | // Get categories; | 421 | // Get categories; |
421 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | 422 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); |
422 | if ( dlg.exec() == QDialog::Accepted ) | 423 | if ( dlg.exec() == QDialog::Accepted ) |
423 | { | 424 | { |
424 | categoryFilter = dlg.getSelectedFilter(); | 425 | categoryFilter = dlg.getSelectedFilter(); |
425 | 426 | ||
426 | if ( categoryFilter == "" ) | 427 | if ( categoryFilter == "" ) |
427 | return false; | 428 | return false; |
428 | 429 | ||
429 | categoryFilterEnabled = true; | 430 | categoryFilterEnabled = true; |
430 | serverSelected( -1 ); | 431 | serverSelected( -1 ); |
431 | actionFilter->setOn( TRUE ); | 432 | actionFilter->setOn( TRUE ); |
432 | return true; | 433 | return true; |
433 | } | 434 | } |
434 | 435 | ||
435 | return false; | 436 | return false; |
436 | } | 437 | } |
437 | 438 | ||
438 | void MainWindow :: filterCategory() | 439 | void MainWindow :: filterCategory() |
439 | { | 440 | { |
440 | if ( !actionFilter->isOn() ) | 441 | if ( !actionFilter->isOn() ) |
441 | { | 442 | { |
442 | filterByCategory( FALSE ); | 443 | filterByCategory( FALSE ); |
443 | } | 444 | } |
444 | else | 445 | else |
445 | { | 446 | { |
446 | actionFilter->setOn( filterByCategory( TRUE ) ); | 447 | actionFilter->setOn( filterByCategory( TRUE ) ); |
447 | } | 448 | } |
448 | } | 449 | } |
449 | 450 | ||
450 | bool MainWindow :: filterByCategory( bool val ) | 451 | bool MainWindow :: filterByCategory( bool val ) |
451 | { | 452 | { |
452 | if ( val ) | 453 | if ( val ) |
453 | { | 454 | { |
454 | if ( categoryFilter == "" ) | 455 | if ( categoryFilter == "" ) |
455 | { | 456 | { |
456 | if ( !setFilterCategory() ) | 457 | if ( !setFilterCategory() ) |
457 | return false; | 458 | return false; |
458 | } | 459 | } |
459 | 460 | ||
460 | categoryFilterEnabled = true; | 461 | categoryFilterEnabled = true; |
461 | serverSelected( -1 ); | 462 | serverSelected( -1 ); |
462 | return true; | 463 | return true; |
463 | } | 464 | } |
464 | else | 465 | else |
465 | { | 466 | { |
466 | // Turn off filter | 467 | // Turn off filter |
467 | categoryFilterEnabled = false; | 468 | categoryFilterEnabled = false; |
468 | serverSelected( -1 ); | 469 | serverSelected( -1 ); |
469 | return false; | 470 | return false; |
470 | } | 471 | } |
471 | } | 472 | } |
472 | 473 | ||
473 | void MainWindow :: raiseMainWidget() | 474 | void MainWindow :: raiseMainWidget() |
474 | { | 475 | { |
475 | stack->raiseWidget( networkPkgWindow ); | 476 | stack->raiseWidget( networkPkgWindow ); |
476 | } | 477 | } |
477 | 478 | ||
478 | void MainWindow :: raiseProgressWidget() | 479 | void MainWindow :: raiseProgressWidget() |
479 | { | 480 | { |
480 | stack->raiseWidget( progressWindow ); | 481 | stack->raiseWidget( progressWindow ); |
481 | } | 482 | } |
482 | 483 | ||
483 | void MainWindow :: enableUpgrade( bool enabled ) | 484 | void MainWindow :: enableUpgrade( bool enabled ) |
484 | { | 485 | { |
485 | actionUpgrade->setEnabled( enabled ); | 486 | actionUpgrade->setEnabled( enabled ); |
486 | } | 487 | } |
487 | 488 | ||
488 | void MainWindow :: enableDownload( bool enabled ) | 489 | void MainWindow :: enableDownload( bool enabled ) |
489 | { | 490 | { |
490 | if ( enabled ) | 491 | if ( enabled ) |
491 | { | 492 | { |
492 | actionDownload->setIconSet( iconDownload ); | 493 | actionDownload->setIconSet( iconDownload ); |
493 | actionDownload->setText( tr( "Download" ) ); | 494 | actionDownload->setText( tr( "Download" ) ); |
494 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 495 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
495 | } | 496 | } |
496 | else | 497 | else |
497 | { | 498 | { |
498 | actionDownload->setIconSet( iconRemove ); | 499 | actionDownload->setIconSet( iconRemove ); |
499 | actionDownload->setText( tr( "Remove" ) ); | 500 | actionDownload->setText( tr( "Remove" ) ); |
500 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 501 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
501 | } | 502 | } |
502 | } | 503 | } |
503 | 504 | ||
504 | void MainWindow :: setProgressSteps( int numsteps ) | 505 | void MainWindow :: setProgressSteps( int numsteps ) |
505 | { | 506 | { |
506 | m_progress->setTotalSteps( numsteps ); | 507 | m_progress->setTotalSteps( numsteps ); |
507 | } | 508 | } |
508 | 509 | ||
509 | void MainWindow :: setProgressMessage( const QString &msg ) | 510 | void MainWindow :: setProgressMessage( const QString &msg ) |
510 | { | 511 | { |
511 | m_status->setText( msg ); | 512 | m_status->setText( msg ); |
512 | } | 513 | } |
513 | 514 | ||
514 | void MainWindow :: updateProgress( int progress ) | 515 | void MainWindow :: updateProgress( int progress ) |
515 | { | 516 | { |
516 | m_progress->setProgress( progress ); | 517 | m_progress->setProgress( progress ); |
517 | } | 518 | } |
518 | 519 | ||
519 | void MainWindow :: updateData() | 520 | void MainWindow :: updateData() |
520 | { | 521 | { |
521 | m_progress->setTotalSteps( mgr->getServerList().size() ); | 522 | m_progress->setTotalSteps( mgr->getServerList().size() ); |
522 | 523 | ||
523 | serversList->clear(); | 524 | serversList->clear(); |
524 | packagesList->clear(); | 525 | packagesList->clear(); |
525 | 526 | ||
526 | vector<Server>::iterator it; | 527 | vector<Server>::iterator it; |
527 | int activeItem = -1; | 528 | int activeItem = -1; |
528 | int i; | 529 | int i; |
529 | QString serverName; | 530 | QString serverName; |
530 | for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i ) | 531 | for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i ) |
531 | { | 532 | { |
532 | serverName = it->getServerName(); | 533 | serverName = it->getServerName(); |
533 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 534 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
534 | m_progress->setProgress( i ); | 535 | m_progress->setProgress( i ); |
535 | qApp->processEvents(); | 536 | qApp->processEvents(); |
536 | 537 | ||
537 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; | 538 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; |
538 | if ( !it->isServerActive() ) | 539 | if ( !it->isServerActive() ) |
539 | { | 540 | { |
540 | // cout << serverName << " is not active" << endl; | 541 | // cout << serverName << " is not active" << endl; |
541 | i--; | 542 | i--; |
542 | continue; | 543 | continue; |
543 | } | 544 | } |
544 | 545 | ||
545 | serversList->insertItem( serverName ); | 546 | serversList->insertItem( serverName ); |
546 | if ( serverName == currentlySelectedServer ) | 547 | if ( serverName == currentlySelectedServer ) |
547 | activeItem = i; | 548 | activeItem = i; |
548 | } | 549 | } |
549 | 550 | ||
550 | // set selected server to be active server | 551 | // set selected server to be active server |
551 | if ( activeItem != -1 ) | 552 | if ( activeItem != -1 ) |
552 | serversList->setCurrentItem( activeItem ); | 553 | serversList->setCurrentItem( activeItem ); |
553 | serverSelected( 0, FALSE ); | 554 | serverSelected( 0, FALSE ); |
554 | } | 555 | } |
555 | 556 | ||
556 | void MainWindow :: serverSelected( int index ) | 557 | void MainWindow :: serverSelected( int index ) |
557 | { | 558 | { |
558 | serverSelected( index, TRUE ); | 559 | serverSelected( index, TRUE ); |
559 | } | 560 | } |
560 | 561 | ||
561 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 562 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
562 | { | 563 | { |
563 | QPixmap nullIcon( installedIcon.size() ); | 564 | QPixmap nullIcon( installedIcon.size() ); |
564 | nullIcon.fill( colorGroup().base() ); | 565 | nullIcon.fill( colorGroup().base() ); |
565 | 566 | ||
566 | // display packages | 567 | // display packages |
567 | QString serverName = serversList->currentText(); | 568 | QString serverName = serversList->currentText(); |
568 | currentlySelectedServer = serverName; | 569 | currentlySelectedServer = serverName; |
569 | 570 | ||
570 | vector<Server>::iterator s = mgr->getServer( serverName ); | 571 | vector<Server>::iterator s = mgr->getServer( serverName ); |
571 | 572 | ||
572 | vector<Package> &list = s->getPackageList(); | 573 | vector<Package> &list = s->getPackageList(); |
573 | vector<Package>::iterator it; | 574 | vector<Package>::iterator it; |
574 | 575 | ||
575 | // Display progress widget while loading list | 576 | // Display progress widget while loading list |
576 | bool doProgress = ( list.size() > 200 ); | 577 | bool doProgress = ( list.size() > 200 ); |
577 | if ( doProgress ) | 578 | if ( doProgress ) |
578 | { | 579 | { |
579 | if ( raiseProgress ) | 580 | if ( raiseProgress ) |
580 | { | 581 | { |
581 | stack->raiseWidget( progressWindow ); | 582 | stack->raiseWidget( progressWindow ); |
582 | } | 583 | } |
583 | m_progress->setTotalSteps( list.size() ); | 584 | m_progress->setTotalSteps( list.size() ); |
584 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 585 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
585 | } | 586 | } |
586 | 587 | ||
587 | packagesList->clear(); | 588 | packagesList->clear(); |
588 | 589 | ||
589 | #ifdef QWS | 590 | #ifdef QWS |
590 | // read download directory from config file | 591 | // read download directory from config file |
591 | Config cfg( "aqpkg" ); | 592 | Config cfg( "aqpkg" ); |
592 | cfg.setGroup( "settings" ); | 593 | cfg.setGroup( "settings" ); |
593 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 594 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
594 | #endif | 595 | #endif |
595 | 596 | ||
596 | int i = 0; | 597 | int i = 0; |
597 | for ( it = list.begin() ; it != list.end() ; ++it ) | 598 | for ( it = list.begin() ; it != list.end() ; ++it ) |
598 | { | 599 | { |
599 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 600 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
600 | i++; | 601 | i++; |
601 | if ( ( i % 100 ) == 0 ) | 602 | if ( ( i % 100 ) == 0 ) |
602 | { | 603 | { |
603 | if ( doProgress ) | 604 | if ( doProgress ) |
604 | { | 605 | { |
605 | m_progress->setProgress( i ); | 606 | m_progress->setProgress( i ); |
606 | } | 607 | } |
607 | qApp->processEvents(); | 608 | qApp->processEvents(); |
608 | } | 609 | } |
609 | 610 | ||
610 | QString text = ""; | 611 | QString text = ""; |
611 | 612 | ||
612 | // Apply show only uninstalled packages filter | 613 | // Apply show only uninstalled packages filter |
613 | if ( showUninstalledPkgs && it->isInstalled() ) | 614 | if ( showUninstalledPkgs && it->isInstalled() ) |
614 | continue; | 615 | continue; |
615 | 616 | ||
616 | // Apply show only installed packages filter | 617 | // Apply show only installed packages filter |
617 | if ( showInstalledPkgs && !it->isInstalled() ) | 618 | if ( showInstalledPkgs && !it->isInstalled() ) |
618 | continue; | 619 | continue; |
619 | 620 | ||
620 | // Apply show only new installed packages filter | 621 | // Apply show only new installed packages filter |
621 | if ( showUpgradedPkgs ) | 622 | if ( showUpgradedPkgs ) |
622 | { | 623 | { |
623 | if ( !it->isInstalled() || | 624 | if ( !it->isInstalled() || |
624 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) | 625 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) |
625 | continue; | 626 | continue; |
626 | } | 627 | } |
627 | 628 | ||
628 | // Apply the section filter | 629 | // Apply the section filter |
629 | if ( categoryFilterEnabled && categoryFilter != "" ) | 630 | if ( categoryFilterEnabled && categoryFilter != "" ) |
630 | { | 631 | { |
631 | if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) | 632 | if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) |
632 | continue; | 633 | continue; |
633 | } | 634 | } |
634 | 635 | ||
635 | // If the local server, only display installed packages | 636 | // If the local server, only display installed packages |
636 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 637 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) |
637 | continue; | 638 | continue; |
638 | 639 | ||
639 | 640 | ||
640 | QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); | 641 | QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); |
641 | 642 | ||
642 | if ( it->isInstalled() ) | 643 | if ( it->isInstalled() ) |
643 | { | 644 | { |
644 | // If a different version of package is available, show update available icon | 645 | // If a different version of package is available, show update available icon |
645 | // Otherwise, show installed icon | 646 | // Otherwise, show installed icon |
646 | if ( it->getVersion() != it->getInstalledVersion() && | 647 | if ( it->getVersion() != it->getInstalledVersion() && |
647 | compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) | 648 | compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) |
648 | { | 649 | { |
649 | 650 | ||
650 | item->setPixmap( 0, updatedIcon ); | 651 | item->setPixmap( 0, updatedIcon ); |
651 | } | 652 | } |
652 | else | 653 | else |
653 | { | 654 | { |
654 | item->setPixmap( 0, installedIcon ); | 655 | item->setPixmap( 0, installedIcon ); |
655 | } | 656 | } |
656 | 657 | ||
657 | QString destName = ""; | 658 | QString destName = ""; |
658 | if ( it->getLocalPackage() ) | 659 | if ( it->getLocalPackage() ) |
659 | { | 660 | { |
660 | if ( it->getLocalPackage()->getInstalledTo() ) | 661 | if ( it->getLocalPackage()->getInstalledTo() ) |
661 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 662 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); |
662 | } | 663 | } |
663 | else | 664 | else |
664 | { | 665 | { |
665 | if ( it->getInstalledTo() ) | 666 | if ( it->getInstalledTo() ) |
666 | destName = it->getInstalledTo()->getDestinationName(); | 667 | destName = it->getInstalledTo()->getDestinationName(); |
667 | } | 668 | } |
668 | if ( destName != "" ) | 669 | if ( destName != "" ) |
669 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); | 670 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); |
670 | } | 671 | } |
671 | else | 672 | else |
672 | { | 673 | { |
673 | item->setPixmap( 0, nullIcon ); | 674 | item->setPixmap( 0, nullIcon ); |
674 | } | 675 | } |
675 | 676 | ||
676 | if ( !it->isPackageStoredLocally() ) | 677 | if ( !it->isPackageStoredLocally() ) |
677 | { | 678 | { |
678 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); | 679 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); |
679 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); | 680 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); |
680 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); | 681 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); |
681 | } | 682 | } |
682 | else | 683 | else |
683 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); | 684 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); |
684 | 685 | ||
685 | if ( serverName == LOCAL_SERVER ) | 686 | if ( serverName == LOCAL_SERVER ) |
686 | { | 687 | { |
687 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); | 688 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); |
688 | } | 689 | } |
689 | else | 690 | else |
690 | { | 691 | { |
691 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); | 692 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); |
692 | if ( it->getLocalPackage() ) | 693 | if ( it->getLocalPackage() ) |
693 | { | 694 | { |
694 | if ( it->isInstalled() ) | 695 | if ( it->isInstalled() ) |
695 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); | 696 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); |
696 | } | 697 | } |
697 | } | 698 | } |
698 | 699 | ||
699 | packagesList->insertItem( item ); | 700 | packagesList->insertItem( item ); |
700 | } | 701 | } |
701 | 702 | ||
702 | // If the local server or the local ipkgs server disable the download button | 703 | // If the local server or the local ipkgs server disable the download button |
703 | if ( serverName == LOCAL_SERVER ) | 704 | if ( serverName == LOCAL_SERVER ) |
704 | { | 705 | { |
705 | downloadEnabled = TRUE; | 706 | downloadEnabled = TRUE; |
706 | actionUpgrade->setEnabled( FALSE ); | 707 | actionUpgrade->setEnabled( FALSE ); |
707 | } | 708 | } |
708 | else if ( serverName == LOCAL_IPKGS ) | 709 | else if ( serverName == LOCAL_IPKGS ) |
709 | { | 710 | { |
710 | downloadEnabled = FALSE; | 711 | downloadEnabled = FALSE; |
711 | actionUpgrade->setEnabled( FALSE ); | 712 | actionUpgrade->setEnabled( FALSE ); |
712 | } | 713 | } |
713 | else | 714 | else |
714 | { | 715 | { |
715 | downloadEnabled = TRUE; | 716 | downloadEnabled = TRUE; |
716 | actionUpgrade->setEnabled( TRUE ); | 717 | actionUpgrade->setEnabled( TRUE ); |
717 | } | 718 | } |
718 | enableDownload( downloadEnabled ); | 719 | enableDownload( downloadEnabled ); |
719 | 720 | ||
720 | // Display this widget once everything is done | 721 | // Display this widget once everything is done |
721 | if ( doProgress && raiseProgress ) | 722 | if ( doProgress && raiseProgress ) |
722 | { | 723 | { |
723 | stack->raiseWidget( networkPkgWindow ); | 724 | stack->raiseWidget( networkPkgWindow ); |
724 | } | 725 | } |
725 | } | 726 | } |
726 | 727 | ||
727 | void MainWindow :: searchForPackage( const QString &text ) | 728 | void MainWindow :: searchForPackage( const QString &text ) |
728 | { | 729 | { |
729 | if ( !text.isEmpty() ) | 730 | if ( !text.isEmpty() ) |
730 | { | 731 | { |
731 | // cout << "searching for " << text << endl; | 732 | // cout << "searching for " << text << endl; |
732 | // look through package list for text startng at current position | 733 | // look through package list for text startng at current position |
733 | vector<InstallData> workingPackages; | 734 | vector<InstallData> workingPackages; |
734 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 735 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
735 | // if ( start != 0 ) | 736 | // if ( start != 0 ) |
736 | // start = (QCheckListItem *)start->nextSibling(); | 737 | // start = (QCheckListItem *)start->nextSibling(); |
737 | 738 | ||
738 | if ( start == 0 ) | 739 | if ( start == 0 ) |
739 | start = (QCheckListItem *)packagesList->firstChild(); | 740 | start = (QCheckListItem *)packagesList->firstChild(); |
740 | 741 | ||
741 | for ( QCheckListItem *item = start; item != 0 ; | 742 | for ( QCheckListItem *item = start; item != 0 ; |
742 | item = (QCheckListItem *)item->nextSibling() ) | 743 | item = (QCheckListItem *)item->nextSibling() ) |
743 | { | 744 | { |
744 | // cout << "checking " << item->text().lower() << endl; | 745 | // cout << "checking " << item->text().lower() << endl; |
745 | if ( item->text().lower().find( text ) != -1 ) | 746 | if ( item->text().lower().find( text ) != -1 ) |
746 | { | 747 | { |
747 | // cout << "matched " << item->text() << endl; | 748 | // cout << "matched " << item->text() << endl; |
748 | packagesList->ensureItemVisible( item ); | 749 | packagesList->ensureItemVisible( item ); |
749 | packagesList->setCurrentItem( item ); | 750 | packagesList->setCurrentItem( item ); |
750 | break; | 751 | break; |
751 | } | 752 | } |
752 | } | 753 | } |
753 | } | 754 | } |
754 | } | 755 | } |
755 | 756 | ||
756 | void MainWindow :: updateServer() | 757 | void MainWindow :: updateServer() |
757 | { | 758 | { |
758 | QString serverName = serversList->currentText(); | 759 | QString serverName = serversList->currentText(); |
759 | 760 | ||
760 | // Update the current server | 761 | // Update the current server |
761 | // Display dialog | 762 | // Display dialog |
762 | 763 | ||
763 | // Disable buttons to stop silly people clicking lots on them :) | 764 | // Disable buttons to stop silly people clicking lots on them :) |
764 | 765 | ||
765 | // First, write out ipkg_conf file so that ipkg can use it | 766 | // First, write out ipkg_conf file so that ipkg can use it |
766 | mgr->writeOutIpkgConf(); | 767 | mgr->writeOutIpkgConf(); |
767 | 768 | ||
768 | Ipkg ipkg; | 769 | Ipkg ipkg; |
769 | ipkg.setOption( "update" ); | 770 | ipkg.setOption( "update" ); |
770 | 771 | ||
771 | InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true ); | 772 | InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true ); |
772 | dlg.showDlg(); | 773 | dlg.showDlg(); |
773 | 774 | ||
774 | reloadData(); | 775 | reloadData(); |
775 | 776 | ||
776 | // delete progDlg; | 777 | // delete progDlg; |
777 | } | 778 | } |
778 | 779 | ||
779 | void MainWindow :: upgradePackages() | 780 | void MainWindow :: upgradePackages() |
780 | { | 781 | { |
781 | // We're gonna do an upgrade of all packages | 782 | // We're gonna do an upgrade of all packages |
782 | // First warn user that this isn't recommended | 783 | // First warn user that this isn't recommended |
783 | // TODO - ODevice???? | 784 | // TODO - ODevice???? |
784 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | 785 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); |
785 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 786 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |