author | drw <drw> | 2003-02-06 01:19:25 (UTC) |
---|---|---|
committer | drw <drw> | 2003-02-06 01:19:25 (UTC) |
commit | 79588befde53765db0a92977c6890a4d226096e7 (patch) (unidiff) | |
tree | 83b6dd14c49733b9759fad04147bf0bee50793fe | |
parent | bbb3690f12191763a407e6a0edd521113b3c25ac (diff) | |
download | opie-79588befde53765db0a92977c6890a4d226096e7.zip opie-79588befde53765db0a92977c6890a4d226096e7.tar.gz opie-79588befde53765db0a92977c6890a4d226096e7.tar.bz2 |
Change all vector<> to QList<>. First step in removing dependency on libstdc++.
-rw-r--r-- | noncore/settings/aqpkg/datamgr.cpp | 82 | ||||
-rw-r--r-- | noncore/settings/aqpkg/datamgr.h | 15 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 84 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.h | 12 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 143 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 75 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.h | 8 | ||||
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 38 |
9 files changed, 245 insertions, 214 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp index 2c83e28..79f36e1 100644 --- a/noncore/settings/aqpkg/datamgr.cpp +++ b/noncore/settings/aqpkg/datamgr.cpp | |||
@@ -1,289 +1,291 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | datamgr.cpp - description | 2 | datamgr.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Thu Aug 29 2002 | 4 | begin : Thu Aug 29 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 | #include <fstream> | 17 | #include <fstream> |
18 | #include <iostream> | 18 | #include <iostream> |
19 | using namespace std; | 19 | using namespace std; |
20 | 20 | ||
21 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #else | 24 | #else |
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #include <stdio.h> | 28 | #include <stdio.h> |
29 | 29 | ||
30 | #include "datamgr.h" | 30 | #include "datamgr.h" |
31 | #include "global.h" | 31 | #include "global.h" |
32 | 32 | ||
33 | 33 | ||
34 | QString DataManager::availableCategories = ""; | 34 | QString DataManager::availableCategories = ""; |
35 | DataManager::DataManager() | 35 | DataManager::DataManager() |
36 | : QObject( 0x0, 0x0 ) | 36 | : QObject( 0x0, 0x0 ) |
37 | { | 37 | { |
38 | activeServer = ""; | 38 | activeServer = ""; |
39 | availableCategories = "#"; | 39 | availableCategories = "#"; |
40 | |||
41 | serverList.setAutoDelete( TRUE ); | ||
42 | destList.setAutoDelete( TRUE ); | ||
40 | } | 43 | } |
41 | 44 | ||
42 | DataManager::~DataManager() | 45 | DataManager::~DataManager() |
43 | { | 46 | { |
44 | } | 47 | } |
45 | 48 | ||
46 | vector<Server>::iterator DataManager :: getServer( const char *name ) | 49 | Server *DataManager :: getServer( const char *name ) |
47 | { | 50 | { |
48 | vector<Server>::iterator it = serverList.begin(); | 51 | QListIterator<Server> it( serverList ); |
49 | while ( it != serverList.end() ) | 52 | while ( it.current() && it.current()->getServerName() != name ) |
50 | { | 53 | { |
51 | if ( it->getServerName() == name ) | ||
52 | return it; | ||
53 | |||
54 | ++it; | 54 | ++it; |
55 | } | 55 | } |
56 | 56 | ||
57 | return serverList.end(); | 57 | return it.current(); |
58 | } | 58 | } |
59 | 59 | ||
60 | vector<Destination>::iterator DataManager :: getDestination( const char *name ) | 60 | Destination *DataManager :: getDestination( const char *name ) |
61 | { | 61 | { |
62 | vector<Destination>::iterator it = destList.begin(); | 62 | QListIterator<Destination> it( destList ); |
63 | while ( it != destList.end() ) | 63 | while ( it.current() && it.current()->getDestinationName() != name ) |
64 | { | 64 | { |
65 | if ( it->getDestinationName() == name ) | ||
66 | return it; | ||
67 | |||
68 | ++it; | 65 | ++it; |
69 | } | 66 | } |
70 | 67 | ||
71 | return destList.end(); | 68 | return it.current(); |
72 | } | 69 | } |
73 | 70 | ||
74 | void DataManager :: loadServers() | 71 | void DataManager :: loadServers() |
75 | { | 72 | { |
76 | // First add our local server - not really a server but | 73 | // First add our local server - not really a server but |
77 | // the local config (which packages are installed) | 74 | // the local config (which packages are installed) |
78 | serverList.push_back( Server( LOCAL_SERVER, "" ) ); | 75 | serverList.append( new Server( LOCAL_SERVER, "" ) ); |
79 | serverList.push_back( Server( LOCAL_IPKGS, "" ) ); | 76 | serverList.append( new Server( LOCAL_IPKGS, "" ) ); |
80 | 77 | ||
81 | #ifdef QWS | 78 | #ifdef QWS |
82 | Config cfg( "aqpkg" ); | 79 | Config cfg( "aqpkg" ); |
83 | cfg.setGroup( "destinations" ); | 80 | cfg.setGroup( "destinations" ); |
84 | #endif | 81 | #endif |
85 | 82 | ||
86 | // Read file from /etc/ipkg.conf | 83 | // Read file from /etc/ipkg.conf |
87 | QString ipkg_conf = IPKG_CONF; | 84 | QString ipkg_conf = IPKG_CONF; |
88 | FILE *fp; | 85 | FILE *fp; |
89 | fp = fopen( ipkg_conf, "r" ); | 86 | fp = fopen( ipkg_conf, "r" ); |
90 | char line[130]; | 87 | char line[130]; |
91 | QString lineStr; | 88 | QString lineStr; |
92 | if ( fp == NULL ) | 89 | if ( fp == NULL ) |
93 | { | 90 | { |
94 | cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; | 91 | cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; |
95 | return; | 92 | return; |
96 | } | 93 | } |
97 | else | 94 | else |
98 | { | 95 | { |
99 | while ( fgets( line, sizeof line, fp) != NULL ) | 96 | while ( fgets( line, sizeof line, fp) != NULL ) |
100 | { | 97 | { |
101 | lineStr = line; | 98 | lineStr = line; |
102 | if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) | 99 | if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) |
103 | { | 100 | { |
104 | char alias[20]; | 101 | char alias[20]; |
105 | char url[100]; | 102 | char url[100]; |
106 | 103 | ||
107 | // Looks a little wierd but read up to the r of src (throwing it away), | 104 | // Looks a little wierd but read up to the r of src (throwing it away), |
108 | // then read up to the next space and throw that away, the alias | 105 | // then read up to the next space and throw that away, the alias |
109 | // is next. | 106 | // is next. |
110 | // Should Handle #src, # src, src, and combinations of | 107 | // Should Handle #src, # src, src, and combinations of |
111 | sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); | 108 | sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); |
112 | Server s( alias, url ); | 109 | Server *s = new Server( alias, url ); |
113 | if ( lineStr.startsWith( "src" ) ) | 110 | if ( lineStr.startsWith( "src" ) ) |
114 | s.setActive( true ); | 111 | s->setActive( true ); |
115 | else | 112 | else |
116 | s.setActive( false ); | 113 | s->setActive( false ); |
117 | 114 | ||
118 | serverList.push_back( s ); | 115 | serverList.append( s ); |
119 | 116 | ||
120 | } | 117 | } |
121 | else if ( lineStr.startsWith( "dest" ) ) | 118 | else if ( lineStr.startsWith( "dest" ) ) |
122 | { | 119 | { |
123 | char alias[20]; | 120 | char alias[20]; |
124 | char path[50]; | 121 | char path[50]; |
125 | sscanf( lineStr, "%*[^ ] %s %s", alias, path ); | 122 | sscanf( lineStr, "%*[^ ] %s %s", alias, path ); |
126 | Destination d( alias, path ); | 123 | Destination *d = new Destination( alias, path ); |
127 | bool linkToRoot = true; | 124 | bool linkToRoot = true; |
128 | #ifdef QWS | 125 | #ifdef QWS |
129 | QString key = alias; | 126 | QString key = alias; |
130 | key += "_linkToRoot"; | 127 | key += "_linkToRoot"; |
131 | linkToRoot = cfg.readBoolEntry( key, true ); | 128 | linkToRoot = cfg.readBoolEntry( key, true ); |
132 | #endif | 129 | #endif |
133 | d.linkToRoot( linkToRoot ); | 130 | d->linkToRoot( linkToRoot ); |
134 | 131 | ||
135 | destList.push_back( d ); | 132 | destList.append( d ); |
136 | } | 133 | } |
137 | else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) ) | 134 | else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) ) |
138 | { | 135 | { |
139 | char type[20]; | 136 | char type[20]; |
140 | char val[100]; | 137 | char val[100]; |
141 | sscanf( lineStr, "%*[^ ] %s %s", type, val ); | 138 | sscanf( lineStr, "%*[^ ] %s %s", type, val ); |
142 | if ( stricmp( type, "http_proxy" ) == 0 ) | 139 | if ( stricmp( type, "http_proxy" ) == 0 ) |
143 | { | 140 | { |
144 | httpProxy = val; | 141 | httpProxy = val; |
145 | if ( lineStr.startsWith( "#" ) ) | 142 | if ( lineStr.startsWith( "#" ) ) |
146 | httpProxyEnabled = false; | 143 | httpProxyEnabled = false; |
147 | else | 144 | else |
148 | httpProxyEnabled = true; | 145 | httpProxyEnabled = true; |
149 | } | 146 | } |
150 | if ( stricmp( type, "ftp_proxy" ) == 0 ) | 147 | if ( stricmp( type, "ftp_proxy" ) == 0 ) |
151 | { | 148 | { |
152 | ftpProxy = val; | 149 | ftpProxy = val; |
153 | if ( lineStr.startsWith( "#" ) ) | 150 | if ( lineStr.startsWith( "#" ) ) |
154 | ftpProxyEnabled = false; | 151 | ftpProxyEnabled = false; |
155 | else | 152 | else |
156 | ftpProxyEnabled = true; | 153 | ftpProxyEnabled = true; |
157 | } | 154 | } |
158 | if ( stricmp( type, "proxy_username" ) == 0 ) | 155 | if ( stricmp( type, "proxy_username" ) == 0 ) |
159 | proxyUsername = val; | 156 | proxyUsername = val; |
160 | if ( stricmp( type, "proxy_password" ) == 0 ) | 157 | if ( stricmp( type, "proxy_password" ) == 0 ) |
161 | proxyPassword = val; | 158 | proxyPassword = val; |
162 | } | 159 | } |
163 | } | 160 | } |
164 | } | 161 | } |
165 | fclose( fp ); | 162 | fclose( fp ); |
166 | 163 | ||
167 | reloadServerData( ); | 164 | reloadServerData( ); |
168 | } | 165 | } |
169 | 166 | ||
170 | void DataManager :: reloadServerData( ) | 167 | void DataManager :: reloadServerData( ) |
171 | { | 168 | { |
172 | emit progressSetSteps( serverList.size() ); | 169 | emit progressSetSteps( serverList.count() ); |
173 | emit progressSetMessage( tr( "Reading configuration..." ) ); | 170 | emit progressSetMessage( tr( "Reading configuration..." ) ); |
174 | 171 | ||
175 | vector<Server>::iterator it = serverList.begin(); | ||
176 | QString serverName; | 172 | QString serverName; |
177 | int i = 0; | 173 | int i = 0; |
178 | for ( it = serverList.begin() ; it != serverList.end() ; ++it ) | 174 | |
175 | Server *server; | ||
176 | QListIterator<Server> it( serverList ); | ||
177 | for ( ; it.current(); ++it ) | ||
179 | { | 178 | { |
180 | serverName = it->getServerName(); | 179 | server = it.current(); |
180 | serverName = server->getServerName(); | ||
181 | i++; | 181 | i++; |
182 | emit progressUpdate( i ); | 182 | emit progressUpdate( i ); |
183 | qApp->processEvents(); | 183 | qApp->processEvents(); |
184 | 184 | ||
185 | // Now we've read the config file in we need to read the servers | 185 | // Now we've read the config file in we need to read the servers |
186 | // The local server is a special case. This holds the contents of the | 186 | // The local server is a special case. This holds the contents of the |
187 | // status files the number of which depends on how many destinations | 187 | // status files the number of which depends on how many destinations |
188 | // we've set up | 188 | // we've set up |
189 | // The other servers files hold the contents of the server package list | 189 | // The other servers files hold the contents of the server package list |
190 | if ( serverName == LOCAL_SERVER ) | 190 | if ( serverName == LOCAL_SERVER ) |
191 | it->readStatusFile( destList ); | 191 | server->readStatusFile( destList ); |
192 | else if ( serverName == LOCAL_IPKGS ) | 192 | else if ( serverName == LOCAL_IPKGS ) |
193 | it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) ); | 193 | server->readLocalIpks( getServer( LOCAL_SERVER ) ); |
194 | else | 194 | else |
195 | it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) ); | 195 | server->readPackageFile( getServer( LOCAL_SERVER ) ); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | void DataManager :: writeOutIpkgConf() | 199 | void DataManager :: writeOutIpkgConf() |
200 | { | 200 | { |
201 | QString ipkg_conf = IPKG_CONF; | 201 | QString ipkg_conf = IPKG_CONF; |
202 | ofstream out( ipkg_conf ); | 202 | ofstream out( ipkg_conf ); |
203 | 203 | ||
204 | out << "# Written by AQPkg" << endl; | 204 | out << "# Written by AQPkg" << endl; |
205 | out << "# Must have one or more source entries of the form:" << endl; | 205 | out << "# Must have one or more source entries of the form:" << endl; |
206 | out << "#" << endl; | 206 | out << "#" << endl; |
207 | out << "# src <src-name> <source-url>" << endl; | 207 | out << "# src <src-name> <source-url>" << endl; |
208 | out << "#" << endl; | 208 | out << "#" << endl; |
209 | out << "# and one or more destination entries of the form:" << endl; | 209 | out << "# and one or more destination entries of the form:" << endl; |
210 | out << "#" << endl; | 210 | out << "#" << endl; |
211 | out << "# dest <dest-name> <target-path>" << endl; | 211 | out << "# dest <dest-name> <target-path>" << endl; |
212 | out << "#" << endl; | 212 | out << "#" << endl; |
213 | out << "# where <src-name> and <dest-names> are identifiers that" << endl; | 213 | out << "# where <src-name> and <dest-names> are identifiers that" << endl; |
214 | out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; | 214 | out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; |
215 | out << "# URL that points to a directory containing a Familiar" << endl; | 215 | out << "# URL that points to a directory containing a Familiar" << endl; |
216 | out << "# Packages file, and <target-path> should be a directory" << endl; | 216 | out << "# Packages file, and <target-path> should be a directory" << endl; |
217 | out << "# that exists on the target system." << endl << endl; | 217 | out << "# that exists on the target system." << endl << endl; |
218 | 218 | ||
219 | // Write out servers | 219 | // Write out servers |
220 | vector<Server>::iterator it = serverList.begin(); | 220 | Server *server; |
221 | while ( it != serverList.end() ) | 221 | QListIterator<Server> it( serverList ); |
222 | while ( it.current() ) | ||
222 | { | 223 | { |
223 | QString alias = it->getServerName(); | 224 | server = it.current(); |
225 | QString alias = server->getServerName(); | ||
224 | // Don't write out local as its a dummy | 226 | // Don't write out local as its a dummy |
225 | if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) | 227 | if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) |
226 | { | 228 | { |
227 | QString url = it->getServerUrl();; | 229 | QString url = server->getServerUrl();; |
228 | 230 | ||
229 | if ( !it->isServerActive() ) | 231 | if ( !server->isServerActive() ) |
230 | out << "#"; | 232 | out << "#"; |
231 | out << "src " << alias << " " << url << endl; | 233 | out << "src " << alias << " " << url << endl; |
232 | } | 234 | } |
233 | 235 | ||
234 | it++; | 236 | ++it; |
235 | } | 237 | } |
236 | 238 | ||
237 | out << endl; | 239 | out << endl; |
238 | 240 | ||
239 | // Write out destinations | 241 | // Write out destinations |
240 | vector<Destination>::iterator it2 = destList.begin(); | 242 | QListIterator<Destination> it2( destList ); |
241 | while ( it2 != destList.end() ) | 243 | while ( it2.current() ) |
242 | { | 244 | { |
243 | out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; | 245 | out << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; |
244 | it2++; | 246 | ++it2; |
245 | } | 247 | } |
246 | 248 | ||
247 | out << endl; | 249 | out << endl; |
248 | out << "# Proxy Support" << endl; | 250 | out << "# Proxy Support" << endl; |
249 | 251 | ||
250 | if ( !httpProxyEnabled && httpProxy == "" ) | 252 | if ( !httpProxyEnabled && httpProxy == "" ) |
251 | out << "#option http_proxy http://proxy.tld:3128" << endl; | 253 | out << "#option http_proxy http://proxy.tld:3128" << endl; |
252 | else | 254 | else |
253 | { | 255 | { |
254 | if ( !httpProxyEnabled ) | 256 | if ( !httpProxyEnabled ) |
255 | out << "#"; | 257 | out << "#"; |
256 | out << "option http_proxy " << httpProxy << endl; | 258 | out << "option http_proxy " << httpProxy << endl; |
257 | } | 259 | } |
258 | 260 | ||
259 | if ( !ftpProxyEnabled && ftpProxy == "" ) | 261 | if ( !ftpProxyEnabled && ftpProxy == "" ) |
260 | out << "#option ftp_proxy http://proxy.tld:3128" << endl; | 262 | out << "#option ftp_proxy http://proxy.tld:3128" << endl; |
261 | else | 263 | else |
262 | { | 264 | { |
263 | if ( !ftpProxyEnabled ) | 265 | if ( !ftpProxyEnabled ) |
264 | out << "#"; | 266 | out << "#"; |
265 | out << "option ftp_proxy " << ftpProxy << endl; | 267 | out << "option ftp_proxy " << ftpProxy << endl; |
266 | } | 268 | } |
267 | if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) | 269 | if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) |
268 | out << "#option proxy_username <username>" << endl; | 270 | out << "#option proxy_username <username>" << endl; |
269 | else | 271 | else |
270 | out << "option proxy_username " << proxyUsername << endl; | 272 | out << "option proxy_username " << proxyUsername << endl; |
271 | if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) | 273 | if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) |
272 | out << "#option proxy_password <password>" << endl << endl; | 274 | out << "#option proxy_password <password>" << endl << endl; |
273 | else | 275 | else |
274 | out << "option proxy_password " << proxyPassword << endl<< endl; | 276 | out << "option proxy_password " << proxyPassword << endl<< endl; |
275 | 277 | ||
276 | out << "# Offline mode (for use in constructing flash images offline)" << endl; | 278 | out << "# Offline mode (for use in constructing flash images offline)" << endl; |
277 | out << "#option offline_root target" << endl; | 279 | out << "#option offline_root target" << endl; |
278 | 280 | ||
279 | 281 | ||
280 | out.close(); | 282 | out.close(); |
281 | } | 283 | } |
282 | 284 | ||
283 | 285 | ||
284 | void DataManager :: setAvailableCategories( QString section ) | 286 | void DataManager :: setAvailableCategories( QString section ) |
285 | { | 287 | { |
286 | section = section.lower(); | 288 | section = section.lower(); |
287 | if ( availableCategories.find( "#" + section + "#" ) == -1 ) | 289 | if ( availableCategories.find( "#" + section + "#" ) == -1 ) |
288 | availableCategories += section + "#"; | 290 | availableCategories += section + "#"; |
289 | } | 291 | } |
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h index 90328ab..7fa42c1 100644 --- a/noncore/settings/aqpkg/datamgr.h +++ b/noncore/settings/aqpkg/datamgr.h | |||
@@ -1,98 +1,99 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | datamgr.h - description | 2 | datamgr.h - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Thu Aug 29 2002 | 4 | begin : Thu Aug 29 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 | #ifndef DATAMGR_H | 18 | #ifndef DATAMGR_H |
19 | #define DATAMGR_H | 19 | #define DATAMGR_H |
20 | 20 | ||
21 | #include <map> | 21 | #include <map> |
22 | using namespace std; | 22 | using namespace std; |
23 | 23 | ||
24 | #include <qlist.h> | ||
24 | #include <qobject.h> | 25 | #include <qobject.h> |
25 | #include <qstring.h> | 26 | #include <qstring.h> |
26 | 27 | ||
27 | #include "server.h" | 28 | #include "server.h" |
28 | #include "destination.h" | 29 | #include "destination.h" |
29 | 30 | ||
30 | #define LOCAL_SERVER "Installed Pkgs" | 31 | #define LOCAL_SERVER "Installed Pkgs" |
31 | #define LOCAL_IPKGS "local IPKG" | 32 | #define LOCAL_IPKGS "local IPKG" |
32 | 33 | ||
33 | /** | 34 | /** |
34 | *@author Andy Qua | 35 | *@author Andy Qua |
35 | */ | 36 | */ |
36 | 37 | ||
37 | 38 | ||
38 | class DataManager : public QObject | 39 | class DataManager : public QObject |
39 | { | 40 | { |
40 | Q_OBJECT | 41 | Q_OBJECT |
41 | public: | 42 | public: |
42 | DataManager(); | 43 | DataManager(); |
43 | ~DataManager(); | 44 | ~DataManager(); |
44 | 45 | ||
45 | void setActiveServer( const QString &act ) { activeServer = act; } | 46 | void setActiveServer( const QString &act ) { activeServer = act; } |
46 | QString &getActiveServer( ) { return activeServer; } | 47 | QString &getActiveServer( ) { return activeServer; } |
47 | 48 | ||
48 | Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); } | 49 | Server *getLocalServer() { return ( getServer( LOCAL_SERVER ) ); } |
49 | vector<Server> &getServerList() { return serverList; } | 50 | QList<Server> &getServerList() { return serverList; } |
50 | vector<Server>::iterator getServer( const char *name ); | 51 | Server *getServer( const char *name ); |
51 | 52 | ||
52 | vector<Destination> &getDestinationList() { return destList; } | 53 | QList<Destination> &getDestinationList() { return destList; } |
53 | vector<Destination>::iterator getDestination( const char *name ); | 54 | Destination *getDestination( const char *name ); |
54 | 55 | ||
55 | void loadServers(); | 56 | void loadServers(); |
56 | void reloadServerData( ); | 57 | void reloadServerData( ); |
57 | 58 | ||
58 | void writeOutIpkgConf(); | 59 | void writeOutIpkgConf(); |
59 | 60 | ||
60 | static QString getAvailableCategories() { return availableCategories; } | 61 | static QString getAvailableCategories() { return availableCategories; } |
61 | static void setAvailableCategories( QString section ); | 62 | static void setAvailableCategories( QString section ); |
62 | 63 | ||
63 | QString getHttpProxy() { return httpProxy; } | 64 | QString getHttpProxy() { return httpProxy; } |
64 | QString getFtpProxy() { return ftpProxy; } | 65 | QString getFtpProxy() { return ftpProxy; } |
65 | QString getProxyUsername() { return proxyUsername; } | 66 | QString getProxyUsername() { return proxyUsername; } |
66 | QString getProxyPassword() { return proxyPassword; } | 67 | QString getProxyPassword() { return proxyPassword; } |
67 | 68 | ||
68 | bool getHttpProxyEnabled() { return httpProxyEnabled; } | 69 | bool getHttpProxyEnabled() { return httpProxyEnabled; } |
69 | bool getFtpProxyEnabled() { return ftpProxyEnabled; } | 70 | bool getFtpProxyEnabled() { return ftpProxyEnabled; } |
70 | 71 | ||
71 | void setHttpProxy( QString proxy ) { httpProxy = proxy; } | 72 | void setHttpProxy( QString proxy ) { httpProxy = proxy; } |
72 | void setFtpProxy( QString proxy ) { ftpProxy = proxy; } | 73 | void setFtpProxy( QString proxy ) { ftpProxy = proxy; } |
73 | void setProxyUsername( QString name ) { proxyUsername = name; } | 74 | void setProxyUsername( QString name ) { proxyUsername = name; } |
74 | void setProxyPassword( QString pword ) { proxyPassword = pword; } | 75 | void setProxyPassword( QString pword ) { proxyPassword = pword; } |
75 | 76 | ||
76 | void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; } | 77 | void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; } |
77 | void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; } | 78 | void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; } |
78 | private: | 79 | private: |
79 | static QString availableCategories; | 80 | static QString availableCategories; |
80 | QString activeServer; | 81 | QString activeServer; |
81 | QString httpProxy; | 82 | QString httpProxy; |
82 | QString ftpProxy; | 83 | QString ftpProxy; |
83 | QString proxyUsername; | 84 | QString proxyUsername; |
84 | QString proxyPassword; | 85 | QString proxyPassword; |
85 | 86 | ||
86 | bool httpProxyEnabled; | 87 | bool httpProxyEnabled; |
87 | bool ftpProxyEnabled; | 88 | bool ftpProxyEnabled; |
88 | 89 | ||
89 | vector<Server> serverList; | 90 | QList<Server> serverList; |
90 | vector<Destination> destList; | 91 | QList<Destination> destList; |
91 | 92 | ||
92 | signals: | 93 | signals: |
93 | void progressSetSteps( int ); | 94 | void progressSetSteps( int ); |
94 | void progressSetMessage( const QString & ); | 95 | void progressSetMessage( const QString & ); |
95 | void progressUpdate( int ); | 96 | void progressUpdate( int ); |
96 | }; | 97 | }; |
97 | 98 | ||
98 | #endif | 99 | #endif |
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 19fe46a..9339086 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -1,345 +1,355 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | installdlgimpl.cpp - description | 2 | installdlgimpl.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 2002 | 4 | begin : Mon Aug 26 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 <stdio.h> | 18 | #include <stdio.h> |
19 | 19 | ||
20 | #ifdef QWS | 20 | #ifdef QWS |
21 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/storage.h> | 24 | #include <qpe/storage.h> |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #include <qcheckbox.h> | 27 | #include <qcheckbox.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qdialog.h> | 29 | #include <qdialog.h> |
30 | #include <qgroupbox.h> | 30 | #include <qgroupbox.h> |
31 | #include <qmultilineedit.h> | 31 | #include <qmultilineedit.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | 35 | ||
36 | #include "datamgr.h" | 36 | #include "datamgr.h" |
37 | #include "destination.h" | 37 | #include "destination.h" |
38 | #include "instoptionsimpl.h" | 38 | #include "instoptionsimpl.h" |
39 | #include "installdlgimpl.h" | 39 | #include "installdlgimpl.h" |
40 | #include "ipkg.h" | 40 | #include "ipkg.h" |
41 | #include "utils.h" | 41 | #include "utils.h" |
42 | #include "global.h" | 42 | #include "global.h" |
43 | 43 | ||
44 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title ) | 44 | InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title ) |
45 | : QWidget( 0, 0, 0 ) | 45 | : QWidget( 0, 0, 0 ) |
46 | { | 46 | { |
47 | setCaption( title ); | 47 | setCaption( title ); |
48 | init( TRUE ); | 48 | init( TRUE ); |
49 | 49 | ||
50 | pIpkg = 0; | 50 | pIpkg = 0; |
51 | upgradePackages = false; | 51 | upgradePackages = false; |
52 | dataMgr = dataManager; | 52 | dataMgr = dataManager; |
53 | vector<Destination>::iterator dit; | ||
54 | 53 | ||
55 | QString defaultDest = "root"; | 54 | QString defaultDest = "root"; |
56 | #ifdef QWS | 55 | #ifdef QWS |
57 | Config cfg( "aqpkg" ); | 56 | Config cfg( "aqpkg" ); |
58 | cfg.setGroup( "settings" ); | 57 | cfg.setGroup( "settings" ); |
59 | defaultDest = cfg.readEntry( "dest", "root" ); | 58 | defaultDest = cfg.readEntry( "dest", "root" ); |
60 | 59 | ||
61 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) | 60 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) |
62 | flags = cfg.readNumEntry( "installFlags", 0 ); | 61 | flags = cfg.readNumEntry( "installFlags", 0 ); |
63 | #else | 62 | #else |
64 | flags = 0; | 63 | flags = 0; |
65 | #endif | 64 | #endif |
66 | 65 | ||
67 | // Output text is read only | 66 | // Output text is read only |
68 | output->setReadOnly( true ); | 67 | output->setReadOnly( true ); |
69 | //QFont f( "helvetica" ); | 68 | //QFont f( "helvetica" ); |
70 | //f.setPointSize( 10 ); | 69 | //f.setPointSize( 10 ); |
71 | //output->setFont( f ); | 70 | //output->setFont( f ); |
72 | 71 | ||
73 | 72 | ||
74 | // setup destination data | 73 | // setup destination data |
75 | int defIndex = 0; | 74 | int defIndex = 0; |
76 | int i; | 75 | int i; |
77 | for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) | 76 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); |
77 | for ( i = 0; dit.current(); ++dit, ++i ) | ||
78 | { | 78 | { |
79 | destination->insertItem( dit->getDestinationName() ); | 79 | destination->insertItem( dit.current()->getDestinationName() ); |
80 | if ( dit->getDestinationName() == defaultDest ) | 80 | if ( dit.current()->getDestinationName() == defaultDest ) |
81 | defIndex = i; | 81 | defIndex = i; |
82 | } | 82 | } |
83 | 83 | ||
84 | destination->setCurrentItem( defIndex ); | 84 | destination->setCurrentItem( defIndex ); |
85 | 85 | ||
86 | vector<InstallData>::iterator it; | 86 | QListIterator<InstallData> it( packageList ); |
87 | // setup package data | 87 | // setup package data |
88 | QString remove = tr( "Remove\n" ); | 88 | QString remove = tr( "Remove\n" ); |
89 | QString install = tr( "Install\n" ); | 89 | QString install = tr( "Install\n" ); |
90 | QString upgrade = tr( "Upgrade\n" ); | 90 | QString upgrade = tr( "Upgrade\n" ); |
91 | for ( it = packageList.begin() ; it != packageList.end() ; ++it ) | 91 | for ( ; it.current(); ++it ) |
92 | { | 92 | { |
93 | InstallData item = *it; | 93 | InstallData *item = it.current(); |
94 | if ( item.option == "I" ) | 94 | InstallData *newitem = new InstallData(); |
95 | |||
96 | newitem->option = item->option; | ||
97 | newitem->packageName = item->packageName; | ||
98 | newitem->destination = item->destination; | ||
99 | newitem->recreateLinks = item->recreateLinks; | ||
100 | |||
101 | if ( item->option == "I" ) | ||
95 | { | 102 | { |
96 | installList.push_back( item ); | 103 | installList.append( newitem ); |
97 | install.append( QString( " %1\n" ).arg( item.packageName ) ); | 104 | install.append( QString( " %1\n" ).arg( item->packageName ) ); |
98 | } | 105 | } |
99 | else if ( item.option == "D" ) | 106 | else if ( item->option == "D" ) |
100 | { | 107 | { |
101 | removeList.push_back( item ); | 108 | removeList.append( newitem ); |
102 | remove.append( QString( " %1\n" ).arg( item.packageName ) ); | 109 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); |
103 | } | 110 | } |
104 | else if ( item.option == "U" || item.option == "R" ) | 111 | else if ( item->option == "U" || item->option == "R" ) |
105 | { | 112 | { |
106 | updateList.push_back( item ); | 113 | updateList.append( newitem ); |
107 | QString type; | 114 | QString type; |
108 | if ( item.option == "R" ) | 115 | if ( item->option == "R" ) |
109 | type = tr( "(ReInstall)" ); | 116 | type = tr( "(ReInstall)" ); |
110 | else | 117 | else |
111 | type = tr( "(Upgrade)" ); | 118 | type = tr( "(Upgrade)" ); |
112 | upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) ); | 119 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); |
113 | } | 120 | } |
114 | } | 121 | } |
115 | |||
116 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); | 122 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); |
117 | 123 | ||
118 | displayAvailableSpace( destination->currentText() ); | 124 | displayAvailableSpace( destination->currentText() ); |
119 | } | 125 | } |
120 | 126 | ||
121 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) | 127 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) |
122 | : QWidget( 0, 0, 0 ) | 128 | : QWidget( 0, 0, 0 ) |
123 | { | 129 | { |
124 | setCaption( title ); | 130 | setCaption( title ); |
125 | init( FALSE ); | 131 | init( FALSE ); |
126 | pIpkg = ipkg; | 132 | pIpkg = ipkg; |
127 | output->setText( initialText ); | 133 | output->setText( initialText ); |
128 | } | 134 | } |
129 | 135 | ||
130 | 136 | ||
131 | InstallDlgImpl::~InstallDlgImpl() | 137 | InstallDlgImpl::~InstallDlgImpl() |
132 | { | 138 | { |
133 | if ( pIpkg ) | 139 | if ( pIpkg ) |
134 | delete pIpkg; | 140 | delete pIpkg; |
135 | } | 141 | } |
136 | 142 | ||
137 | void InstallDlgImpl :: init( bool displayextrainfo ) | 143 | void InstallDlgImpl :: init( bool displayextrainfo ) |
138 | { | 144 | { |
139 | QGridLayout *layout = new QGridLayout( this ); | 145 | QGridLayout *layout = new QGridLayout( this ); |
140 | layout->setSpacing( 4 ); | 146 | layout->setSpacing( 4 ); |
141 | layout->setMargin( 4 ); | 147 | layout->setMargin( 4 ); |
142 | 148 | ||
143 | if ( displayextrainfo ) | 149 | if ( displayextrainfo ) |
144 | { | 150 | { |
145 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 151 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
146 | layout->addWidget( label, 0, 0 ); | 152 | layout->addWidget( label, 0, 0 ); |
147 | destination = new QComboBox( FALSE, this ); | 153 | destination = new QComboBox( FALSE, this ); |
148 | layout->addWidget( destination, 0, 1 ); | 154 | layout->addWidget( destination, 0, 1 ); |
149 | connect( destination, SIGNAL( highlighted( const QString & ) ), | 155 | connect( destination, SIGNAL( highlighted( const QString & ) ), |
150 | this, SLOT( displayAvailableSpace( const QString & ) ) ); | 156 | this, SLOT( displayAvailableSpace( const QString & ) ) ); |
151 | 157 | ||
152 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); | 158 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); |
153 | layout->addWidget( label2, 1, 0 ); | 159 | layout->addWidget( label2, 1, 0 ); |
154 | txtAvailableSpace = new QLabel( "", this ); | 160 | txtAvailableSpace = new QLabel( "", this ); |
155 | layout->addWidget( txtAvailableSpace, 1, 1 ); | 161 | layout->addWidget( txtAvailableSpace, 1, 1 ); |
156 | } | 162 | } |
157 | else | 163 | else |
158 | { | 164 | { |
159 | destination = 0x0; | 165 | destination = 0x0; |
160 | txtAvailableSpace = 0x0; | 166 | txtAvailableSpace = 0x0; |
161 | } | 167 | } |
162 | 168 | ||
163 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 169 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
164 | GroupBox2->layout()->setSpacing( 0 ); | 170 | GroupBox2->layout()->setSpacing( 0 ); |
165 | GroupBox2->layout()->setMargin( 4 ); | 171 | GroupBox2->layout()->setMargin( 4 ); |
166 | 172 | ||
167 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); | 173 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); |
168 | output = new QMultiLineEdit( GroupBox2 ); | 174 | output = new QMultiLineEdit( GroupBox2 ); |
169 | GroupBox2Layout->addWidget( output ); | 175 | GroupBox2Layout->addWidget( output ); |
170 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); | 176 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); |
171 | 177 | ||
172 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); | 178 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); |
173 | layout->addWidget( btnInstall, 3, 0 ); | 179 | layout->addWidget( btnInstall, 3, 0 ); |
174 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); | 180 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); |
175 | 181 | ||
176 | btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this ); | 182 | btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this ); |
177 | layout->addWidget( btnOptions, 3, 1 ); | 183 | layout->addWidget( btnOptions, 3, 1 ); |
178 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); | 184 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); |
179 | } | 185 | } |
180 | 186 | ||
181 | void InstallDlgImpl :: optionsSelected() | 187 | void InstallDlgImpl :: optionsSelected() |
182 | { | 188 | { |
183 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); | 189 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); |
184 | opt.exec(); | 190 | opt.exec(); |
185 | 191 | ||
186 | // set options selected from dialog | 192 | // set options selected from dialog |
187 | flags = opt.getFlags(); | 193 | flags = opt.getFlags(); |
188 | 194 | ||
189 | #ifdef QWS | 195 | #ifdef QWS |
190 | Config cfg( "aqpkg" ); | 196 | Config cfg( "aqpkg" ); |
191 | cfg.setGroup( "settings" ); | 197 | cfg.setGroup( "settings" ); |
192 | cfg.writeEntry( "installFlags", flags ); | 198 | cfg.writeEntry( "installFlags", flags ); |
193 | #endif | 199 | #endif |
194 | } | 200 | } |
195 | 201 | ||
196 | void InstallDlgImpl :: installSelected() | 202 | void InstallDlgImpl :: installSelected() |
197 | { | 203 | { |
198 | if ( btnInstall->text() == tr( "Abort" ) ) | 204 | if ( btnInstall->text() == tr( "Abort" ) ) |
199 | { | 205 | { |
200 | if ( pIpkg ) | 206 | if ( pIpkg ) |
201 | { | 207 | { |
202 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); | 208 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); |
203 | pIpkg->abort(); | 209 | pIpkg->abort(); |
204 | displayText( tr( "**** Process Aborted ****" ) ); | 210 | displayText( tr( "**** Process Aborted ****" ) ); |
205 | } | 211 | } |
206 | 212 | ||
207 | btnInstall->setText( tr( "Close" ) ); | 213 | btnInstall->setText( tr( "Close" ) ); |
208 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 214 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
209 | return; | 215 | return; |
210 | } | 216 | } |
211 | else if ( btnInstall->text() == tr( "Close" ) ) | 217 | else if ( btnInstall->text() == tr( "Close" ) ) |
212 | { | 218 | { |
213 | emit reloadData( this ); | 219 | emit reloadData( this ); |
214 | return; | 220 | return; |
215 | } | 221 | } |
216 | 222 | ||
217 | // Disable buttons | 223 | // Disable buttons |
218 | btnOptions->setEnabled( false ); | 224 | btnOptions->setEnabled( false ); |
219 | // btnInstall->setEnabled( false ); | 225 | // btnInstall->setEnabled( false ); |
220 | 226 | ||
221 | btnInstall->setText( tr( "Abort" ) ); | 227 | btnInstall->setText( tr( "Abort" ) ); |
222 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); | 228 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); |
223 | if ( pIpkg ) | 229 | if ( pIpkg ) |
224 | { | 230 | { |
225 | output->setText( "" ); | 231 | output->setText( "" ); |
226 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 232 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
227 | pIpkg->runIpkg(); | 233 | pIpkg->runIpkg(); |
228 | } | 234 | } |
229 | else | 235 | else |
230 | { | 236 | { |
231 | output->setText( "" ); | 237 | output->setText( "" ); |
232 | vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() ); | 238 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
233 | QString dest = d->getDestinationName(); | 239 | QString dest = d->getDestinationName(); |
234 | QString destDir = d->getDestinationPath(); | 240 | QString destDir = d->getDestinationPath(); |
235 | int instFlags = flags; | 241 | int instFlags = flags; |
236 | if ( d->linkToRoot() ) | 242 | if ( d->linkToRoot() ) |
237 | instFlags |= MAKE_LINKS; | 243 | instFlags |= MAKE_LINKS; |
238 | 244 | ||
239 | #ifdef QWS | 245 | #ifdef QWS |
240 | // Save settings | 246 | // Save settings |
241 | Config cfg( "aqpkg" ); | 247 | Config cfg( "aqpkg" ); |
242 | cfg.setGroup( "settings" ); | 248 | cfg.setGroup( "settings" ); |
243 | cfg.writeEntry( "dest", dest ); | 249 | cfg.writeEntry( "dest", dest ); |
244 | #endif | 250 | #endif |
245 | 251 | ||
246 | pIpkg = new Ipkg; | 252 | pIpkg = new Ipkg; |
247 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 253 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
248 | 254 | ||
249 | // First run through the remove list, then the install list then the upgrade list | 255 | // First run through the remove list, then the install list then the upgrade list |
250 | vector<InstallData>::iterator it; | ||
251 | pIpkg->setOption( "remove" ); | 256 | pIpkg->setOption( "remove" ); |
252 | for ( it = removeList.begin() ; it != removeList.end() ; ++it ) | 257 | QListIterator<InstallData> it( removeList ); |
258 | InstallData *idata; | ||
259 | for ( ; it.current(); ++it ) | ||
253 | { | 260 | { |
254 | pIpkg->setDestination( it->destination->getDestinationName() ); | 261 | idata = it.current(); |
255 | pIpkg->setDestinationDir( it->destination->getDestinationPath() ); | 262 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
256 | pIpkg->setPackage( it->packageName ); | 263 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
264 | pIpkg->setPackage( idata->packageName ); | ||
257 | 265 | ||
258 | int tmpFlags = flags; | 266 | int tmpFlags = flags; |
259 | if ( it->destination->linkToRoot() ) | 267 | if ( idata->destination->linkToRoot() ) |
260 | tmpFlags |= MAKE_LINKS; | 268 | tmpFlags |= MAKE_LINKS; |
261 | 269 | ||
262 | pIpkg->setFlags( tmpFlags ); | 270 | pIpkg->setFlags( tmpFlags ); |
263 | pIpkg->runIpkg(); | 271 | pIpkg->runIpkg(); |
264 | } | 272 | } |
265 | 273 | ||
266 | pIpkg->setOption( "install" ); | 274 | pIpkg->setOption( "install" ); |
267 | pIpkg->setDestination( dest ); | 275 | pIpkg->setDestination( dest ); |
268 | pIpkg->setDestinationDir( destDir ); | 276 | pIpkg->setDestinationDir( destDir ); |
269 | pIpkg->setFlags( instFlags ); | 277 | pIpkg->setFlags( instFlags ); |
270 | for ( it = installList.begin() ; it != installList.end() ; ++it ) | 278 | QListIterator<InstallData> it2( installList ); |
279 | for ( ; it2.current(); ++it2 ) | ||
271 | { | 280 | { |
272 | pIpkg->setPackage( it->packageName ); | 281 | pIpkg->setPackage( it2.current()->packageName ); |
273 | pIpkg->runIpkg(); | 282 | pIpkg->runIpkg(); |
274 | } | 283 | } |
275 | 284 | ||
276 | flags |= FORCE_REINSTALL; | 285 | flags |= FORCE_REINSTALL; |
277 | for ( it = updateList.begin() ; it != updateList.end() ; ++it ) | 286 | QListIterator<InstallData> it3( updateList ); |
287 | for ( ; it3.current() ; ++it3 ) | ||
278 | { | 288 | { |
279 | if ( it->option == "R" ) | 289 | idata = it3.current(); |
290 | if ( idata->option == "R" ) | ||
280 | pIpkg->setOption( "reinstall" ); | 291 | pIpkg->setOption( "reinstall" ); |
281 | else | 292 | else |
282 | pIpkg->setOption( "upgrade" ); | 293 | pIpkg->setOption( "upgrade" ); |
283 | pIpkg->setDestination( it->destination->getDestinationName() ); | 294 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
284 | pIpkg->setDestinationDir( it->destination->getDestinationPath() ); | 295 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
285 | pIpkg->setPackage( it->packageName ); | 296 | pIpkg->setPackage( idata->packageName ); |
286 | 297 | ||
287 | int tmpFlags = flags; | 298 | int tmpFlags = flags; |
288 | if ( it->destination->linkToRoot() && it->recreateLinks ) | 299 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) |
289 | tmpFlags |= MAKE_LINKS; | 300 | tmpFlags |= MAKE_LINKS; |
290 | pIpkg->setFlags( tmpFlags ); | 301 | pIpkg->setFlags( tmpFlags ); |
291 | pIpkg->runIpkg(); | 302 | pIpkg->runIpkg(); |
292 | } | 303 | } |
293 | 304 | ||
294 | delete pIpkg; | 305 | delete pIpkg; |
295 | pIpkg = 0; | 306 | pIpkg = 0; |
296 | } | 307 | } |
297 | 308 | ||
298 | btnOptions->setEnabled( true ); | 309 | btnOptions->setEnabled( true ); |
299 | // btnInstall->setEnabled( true ); | 310 | // btnInstall->setEnabled( true ); |
300 | btnInstall->setText( tr( "Close" ) ); | 311 | btnInstall->setText( tr( "Close" ) ); |
301 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 312 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
302 | 313 | ||
303 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) | 314 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) |
304 | displayAvailableSpace( destination->currentText() ); | 315 | displayAvailableSpace( destination->currentText() ); |
305 | } | 316 | } |
306 | 317 | ||
307 | 318 | ||
308 | void InstallDlgImpl :: displayText(const QString &text ) | 319 | void InstallDlgImpl :: displayText(const QString &text ) |
309 | { | 320 | { |
310 | //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) ); | ||
311 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); | 321 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); |
312 | output->setText( newtext ); | 322 | output->setText( newtext ); |
313 | output->setCursorPosition( output->numLines(), 0 ); | 323 | output->setCursorPosition( output->numLines(), 0 ); |
314 | } | 324 | } |
315 | 325 | ||
316 | 326 | ||
317 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | 327 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) |
318 | { | 328 | { |
319 | vector<Destination>::iterator d = dataMgr->getDestination( text ); | 329 | Destination *d = dataMgr->getDestination( text ); |
320 | QString destDir = d->getDestinationPath(); | 330 | QString destDir = d->getDestinationPath(); |
321 | 331 | ||
322 | long blockSize = 0; | 332 | long blockSize = 0; |
323 | long totalBlocks = 0; | 333 | long totalBlocks = 0; |
324 | long availBlocks = 0; | 334 | long availBlocks = 0; |
325 | QString space; | 335 | QString space; |
326 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) | 336 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) |
327 | { | 337 | { |
328 | long mult = blockSize / 1024; | 338 | long mult = blockSize / 1024; |
329 | long div = 1024 / blockSize; | 339 | long div = 1024 / blockSize; |
330 | 340 | ||
331 | if ( !mult ) mult = 1; | 341 | if ( !mult ) mult = 1; |
332 | if ( !div ) div = 1; | 342 | if ( !div ) div = 1; |
333 | // long total = totalBlocks * mult / div; | 343 | // long total = totalBlocks * mult / div; |
334 | long avail = availBlocks * mult / div; | 344 | long avail = availBlocks * mult / div; |
335 | // long used = total - avail; | 345 | // long used = total - avail; |
336 | 346 | ||
337 | space.sprintf( "%ld Kb", avail ); | 347 | space.sprintf( "%ld Kb", avail ); |
338 | } | 348 | } |
339 | else | 349 | else |
340 | space = tr( "Unknown" ); | 350 | space = tr( "Unknown" ); |
341 | 351 | ||
342 | if ( txtAvailableSpace ) | 352 | if ( txtAvailableSpace ) |
343 | txtAvailableSpace->setText( space ); | 353 | txtAvailableSpace->setText( space ); |
344 | } | 354 | } |
345 | 355 | ||
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h index 4c9f087..d7509bb 100644 --- a/noncore/settings/aqpkg/installdlgimpl.h +++ b/noncore/settings/aqpkg/installdlgimpl.h | |||
@@ -1,85 +1,85 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | installdlgimpl.h - description | 2 | installdlgimpl.h - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 2002 | 4 | begin : Mon Aug 26 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 | #ifndef INSTALLDLGIMPL_H | 17 | #ifndef INSTALLDLGIMPL_H |
18 | #define INSTALLDLGIMPL_H | 18 | #define INSTALLDLGIMPL_H |
19 | 19 | ||
20 | #include <vector> | ||
21 | using namespace std; | 20 | using namespace std; |
22 | 21 | ||
23 | #include <qwidget.h> | 22 | #include <qlist.h> |
24 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qwidget.h> | ||
25 | 25 | ||
26 | class QComboBox; | 26 | class QComboBox; |
27 | class QLabel; | 27 | class QLabel; |
28 | class QMultiLineEdit; | 28 | class QMultiLineEdit; |
29 | class QPushButton; | 29 | class QPushButton; |
30 | 30 | ||
31 | class DataManager; | 31 | class DataManager; |
32 | class Destination; | 32 | class Destination; |
33 | class Ipkg; | 33 | class Ipkg; |
34 | 34 | ||
35 | class InstallData | 35 | class InstallData |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | QString option; // I - install, D - delete, R- reinstall U - upgrade | 38 | QString option; // I - install, D - delete, R- reinstall U - upgrade |
39 | QString packageName; | 39 | QString packageName; |
40 | Destination *destination; | 40 | Destination *destination; |
41 | bool recreateLinks; | 41 | bool recreateLinks; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | class InstallDlgImpl : public QWidget | 44 | class InstallDlgImpl : public QWidget |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ); | 48 | InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ); |
49 | InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); | 49 | InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); |
50 | ~InstallDlgImpl(); | 50 | ~InstallDlgImpl(); |
51 | 51 | ||
52 | bool upgradeServer( QString &server ); | 52 | bool upgradeServer( QString &server ); |
53 | 53 | ||
54 | protected: | 54 | protected: |
55 | 55 | ||
56 | private: | 56 | private: |
57 | DataManager *dataMgr; | 57 | DataManager *dataMgr; |
58 | vector<InstallData> installList; | 58 | QList<InstallData> installList; |
59 | vector<InstallData> removeList; | 59 | QList<InstallData> removeList; |
60 | vector<InstallData> updateList; | 60 | QList<InstallData> updateList; |
61 | int flags; | 61 | int flags; |
62 | Ipkg *pIpkg; | 62 | Ipkg *pIpkg; |
63 | bool upgradePackages; | 63 | bool upgradePackages; |
64 | 64 | ||
65 | QComboBox *destination; | 65 | QComboBox *destination; |
66 | QPushButton *btnInstall; | 66 | QPushButton *btnInstall; |
67 | QPushButton *btnOptions; | 67 | QPushButton *btnOptions; |
68 | QMultiLineEdit *output; | 68 | QMultiLineEdit *output; |
69 | QLabel *txtAvailableSpace; | 69 | QLabel *txtAvailableSpace; |
70 | 70 | ||
71 | void init( bool ); | 71 | void init( bool ); |
72 | 72 | ||
73 | bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); | 73 | bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); |
74 | 74 | ||
75 | signals: | 75 | signals: |
76 | void reloadData( InstallDlgImpl * ); | 76 | void reloadData( InstallDlgImpl * ); |
77 | 77 | ||
78 | public slots: | 78 | public slots: |
79 | void optionsSelected(); | 79 | void optionsSelected(); |
80 | void installSelected(); | 80 | void installSelected(); |
81 | void displayText(const QString &text ); | 81 | void displayText(const QString &text ); |
82 | void displayAvailableSpace( const QString &text); | 82 | void displayAvailableSpace( const QString &text); |
83 | }; | 83 | }; |
84 | 84 | ||
85 | #endif | 85 | #endif |
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 361946c..8ae5815 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -450,405 +450,413 @@ bool MainWindow :: setFilterCategory() | |||
450 | 450 | ||
451 | if ( categoryFilter == "" ) | 451 | if ( categoryFilter == "" ) |
452 | return false; | 452 | return false; |
453 | 453 | ||
454 | categoryFilterEnabled = true; | 454 | categoryFilterEnabled = true; |
455 | serverSelected( -1 ); | 455 | serverSelected( -1 ); |
456 | actionFilter->setOn( TRUE ); | 456 | actionFilter->setOn( TRUE ); |
457 | return true; | 457 | return true; |
458 | } | 458 | } |
459 | 459 | ||
460 | return false; | 460 | return false; |
461 | } | 461 | } |
462 | 462 | ||
463 | void MainWindow :: filterCategory() | 463 | void MainWindow :: filterCategory() |
464 | { | 464 | { |
465 | if ( !actionFilter->isOn() ) | 465 | if ( !actionFilter->isOn() ) |
466 | { | 466 | { |
467 | filterByCategory( FALSE ); | 467 | filterByCategory( FALSE ); |
468 | } | 468 | } |
469 | else | 469 | else |
470 | { | 470 | { |
471 | actionFilter->setOn( filterByCategory( TRUE ) ); | 471 | actionFilter->setOn( filterByCategory( TRUE ) ); |
472 | } | 472 | } |
473 | } | 473 | } |
474 | 474 | ||
475 | bool MainWindow :: filterByCategory( bool val ) | 475 | bool MainWindow :: filterByCategory( bool val ) |
476 | { | 476 | { |
477 | if ( val ) | 477 | if ( val ) |
478 | { | 478 | { |
479 | if ( categoryFilter == "" ) | 479 | if ( categoryFilter == "" ) |
480 | { | 480 | { |
481 | if ( !setFilterCategory() ) | 481 | if ( !setFilterCategory() ) |
482 | return false; | 482 | return false; |
483 | } | 483 | } |
484 | 484 | ||
485 | categoryFilterEnabled = true; | 485 | categoryFilterEnabled = true; |
486 | serverSelected( -1 ); | 486 | serverSelected( -1 ); |
487 | return true; | 487 | return true; |
488 | } | 488 | } |
489 | else | 489 | else |
490 | { | 490 | { |
491 | // Turn off filter | 491 | // Turn off filter |
492 | categoryFilterEnabled = false; | 492 | categoryFilterEnabled = false; |
493 | serverSelected( -1 ); | 493 | serverSelected( -1 ); |
494 | return false; | 494 | return false; |
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | void MainWindow :: raiseMainWidget() | 498 | void MainWindow :: raiseMainWidget() |
499 | { | 499 | { |
500 | stack->raiseWidget( networkPkgWindow ); | 500 | stack->raiseWidget( networkPkgWindow ); |
501 | } | 501 | } |
502 | 502 | ||
503 | void MainWindow :: raiseProgressWidget() | 503 | void MainWindow :: raiseProgressWidget() |
504 | { | 504 | { |
505 | stack->raiseWidget( progressWindow ); | 505 | stack->raiseWidget( progressWindow ); |
506 | } | 506 | } |
507 | 507 | ||
508 | void MainWindow :: enableUpgrade( bool enabled ) | 508 | void MainWindow :: enableUpgrade( bool enabled ) |
509 | { | 509 | { |
510 | actionUpgrade->setEnabled( enabled ); | 510 | actionUpgrade->setEnabled( enabled ); |
511 | } | 511 | } |
512 | 512 | ||
513 | void MainWindow :: enableDownload( bool enabled ) | 513 | void MainWindow :: enableDownload( bool enabled ) |
514 | { | 514 | { |
515 | if ( enabled ) | 515 | if ( enabled ) |
516 | { | 516 | { |
517 | actionDownload->setIconSet( iconDownload ); | 517 | actionDownload->setIconSet( iconDownload ); |
518 | actionDownload->setText( tr( "Download" ) ); | 518 | actionDownload->setText( tr( "Download" ) ); |
519 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 519 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
520 | } | 520 | } |
521 | else | 521 | else |
522 | { | 522 | { |
523 | actionDownload->setIconSet( iconRemove ); | 523 | actionDownload->setIconSet( iconRemove ); |
524 | actionDownload->setText( tr( "Remove" ) ); | 524 | actionDownload->setText( tr( "Remove" ) ); |
525 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 525 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | 528 | ||
529 | void MainWindow :: setProgressSteps( int numsteps ) | 529 | void MainWindow :: setProgressSteps( int numsteps ) |
530 | { | 530 | { |
531 | m_progress->setTotalSteps( numsteps ); | 531 | m_progress->setTotalSteps( numsteps ); |
532 | } | 532 | } |
533 | 533 | ||
534 | void MainWindow :: setProgressMessage( const QString &msg ) | 534 | void MainWindow :: setProgressMessage( const QString &msg ) |
535 | { | 535 | { |
536 | m_status->setText( msg ); | 536 | m_status->setText( msg ); |
537 | } | 537 | } |
538 | 538 | ||
539 | void MainWindow :: updateProgress( int progress ) | 539 | void MainWindow :: updateProgress( int progress ) |
540 | { | 540 | { |
541 | m_progress->setProgress( progress ); | 541 | m_progress->setProgress( progress ); |
542 | } | 542 | } |
543 | 543 | ||
544 | void MainWindow :: updateData() | 544 | void MainWindow :: updateData() |
545 | { | 545 | { |
546 | m_progress->setTotalSteps( mgr->getServerList().size() ); | 546 | m_progress->setTotalSteps( mgr->getServerList().count() ); |
547 | 547 | ||
548 | serversList->clear(); | 548 | serversList->clear(); |
549 | packagesList->clear(); | 549 | packagesList->clear(); |
550 | 550 | ||
551 | vector<Server>::iterator it; | ||
552 | int activeItem = -1; | 551 | int activeItem = -1; |
553 | int i; | 552 | int i = 0; |
554 | QString serverName; | 553 | QString serverName; |
555 | for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i ) | 554 | |
555 | QListIterator<Server> it( mgr->getServerList() ); | ||
556 | Server *server; | ||
557 | |||
558 | for ( ; it.current(); ++it, ++i ) | ||
556 | { | 559 | { |
557 | serverName = it->getServerName(); | 560 | server = it.current(); |
561 | serverName = server->getServerName(); | ||
558 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 562 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
559 | m_progress->setProgress( i ); | 563 | m_progress->setProgress( i ); |
560 | qApp->processEvents(); | 564 | qApp->processEvents(); |
561 | 565 | ||
562 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; | 566 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; |
563 | if ( !it->isServerActive() ) | 567 | if ( !server->isServerActive() ) |
564 | { | 568 | { |
565 | // cout << serverName << " is not active" << endl; | 569 | // cout << serverName << " is not active" << endl; |
566 | i--; | 570 | i--; |
567 | continue; | 571 | continue; |
568 | } | 572 | } |
569 | 573 | ||
570 | serversList->insertItem( serverName ); | 574 | serversList->insertItem( serverName ); |
571 | if ( serverName == currentlySelectedServer ) | 575 | if ( serverName == currentlySelectedServer ) |
572 | activeItem = i; | 576 | activeItem = i; |
573 | } | 577 | } |
574 | 578 | ||
575 | // set selected server to be active server | 579 | // set selected server to be active server |
576 | if ( activeItem != -1 ) | 580 | if ( activeItem != -1 ) |
577 | serversList->setCurrentItem( activeItem ); | 581 | serversList->setCurrentItem( activeItem ); |
578 | serverSelected( 0, FALSE ); | 582 | serverSelected( 0, FALSE ); |
579 | } | 583 | } |
580 | 584 | ||
581 | void MainWindow :: serverSelected( int index ) | 585 | void MainWindow :: serverSelected( int index ) |
582 | { | 586 | { |
583 | serverSelected( index, TRUE ); | 587 | serverSelected( index, TRUE ); |
584 | } | 588 | } |
585 | 589 | ||
586 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 590 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
587 | { | 591 | { |
588 | QPixmap nullIcon( installedIcon.size() ); | 592 | QPixmap nullIcon( installedIcon.size() ); |
589 | nullIcon.fill( colorGroup().base() ); | 593 | nullIcon.fill( colorGroup().base() ); |
590 | 594 | ||
591 | // display packages | 595 | // display packages |
592 | QString serverName = serversList->currentText(); | 596 | QString serverName = serversList->currentText(); |
593 | currentlySelectedServer = serverName; | 597 | currentlySelectedServer = serverName; |
594 | 598 | ||
595 | vector<Server>::iterator s = mgr->getServer( serverName ); | 599 | Server *s = mgr->getServer( serverName ); |
596 | 600 | ||
597 | vector<Package> &list = s->getPackageList(); | 601 | QList<Package> &list = s->getPackageList(); |
598 | vector<Package>::iterator it; | 602 | QListIterator<Package> it( list ); |
599 | 603 | ||
600 | // Display progress widget while loading list | 604 | // Display progress widget while loading list |
601 | bool doProgress = ( list.size() > 200 ); | 605 | bool doProgress = ( list.count() > 200 ); |
602 | if ( doProgress ) | 606 | if ( doProgress ) |
603 | { | 607 | { |
604 | if ( raiseProgress ) | 608 | if ( raiseProgress ) |
605 | { | 609 | { |
606 | stack->raiseWidget( progressWindow ); | 610 | stack->raiseWidget( progressWindow ); |
607 | } | 611 | } |
608 | m_progress->setTotalSteps( list.size() ); | 612 | m_progress->setTotalSteps( list.count() ); |
609 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 613 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
610 | } | 614 | } |
611 | 615 | ||
612 | packagesList->clear(); | 616 | packagesList->clear(); |
613 | 617 | ||
614 | #ifdef QWS | 618 | #ifdef QWS |
615 | // read download directory from config file | 619 | // read download directory from config file |
616 | Config cfg( "aqpkg" ); | 620 | Config cfg( "aqpkg" ); |
617 | cfg.setGroup( "settings" ); | 621 | cfg.setGroup( "settings" ); |
618 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 622 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
619 | #endif | 623 | #endif |
620 | 624 | ||
621 | int i = 0; | 625 | int i = 0; |
622 | for ( it = list.begin() ; it != list.end() ; ++it ) | 626 | Package *package; |
627 | for ( ; it.current(); ++it ) | ||
623 | { | 628 | { |
624 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 629 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
625 | i++; | 630 | i++; |
626 | if ( ( i % 100 ) == 0 ) | 631 | if ( ( i % 100 ) == 0 ) |
627 | { | 632 | { |
628 | if ( doProgress ) | 633 | if ( doProgress ) |
629 | { | 634 | { |
630 | m_progress->setProgress( i ); | 635 | m_progress->setProgress( i ); |
631 | } | 636 | } |
632 | qApp->processEvents(); | 637 | qApp->processEvents(); |
633 | } | 638 | } |
634 | 639 | ||
635 | QString text = ""; | 640 | QString text = ""; |
641 | |||
642 | package = it.current(); | ||
636 | 643 | ||
637 | // Apply show only uninstalled packages filter | 644 | // Apply show only uninstalled packages filter |
638 | if ( showUninstalledPkgs && it->isInstalled() ) | 645 | if ( showUninstalledPkgs && package->isInstalled() ) |
639 | continue; | 646 | continue; |
640 | 647 | ||
641 | // Apply show only installed packages filter | 648 | // Apply show only installed packages filter |
642 | if ( showInstalledPkgs && !it->isInstalled() ) | 649 | if ( showInstalledPkgs && !package->isInstalled() ) |
643 | continue; | 650 | continue; |
644 | 651 | ||
645 | // Apply show only new installed packages filter | 652 | // Apply show only new installed packages filter |
646 | if ( showUpgradedPkgs ) | 653 | if ( showUpgradedPkgs ) |
647 | { | 654 | { |
648 | if ( !it->isInstalled() || | 655 | if ( !package->isInstalled() || |
649 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) | 656 | compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 ) |
650 | continue; | 657 | continue; |
651 | } | 658 | } |
652 | 659 | ||
653 | // Apply the section filter | 660 | // Apply the section filter |
654 | if ( categoryFilterEnabled && categoryFilter != "" ) | 661 | if ( categoryFilterEnabled && categoryFilter != "" ) |
655 | { | 662 | { |
656 | if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) | 663 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) |
657 | continue; | 664 | continue; |
658 | } | 665 | } |
659 | 666 | ||
660 | // If the local server, only display installed packages | 667 | // If the local server, only display installed packages |
661 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 668 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
662 | continue; | 669 | continue; |
663 | 670 | ||
664 | 671 | ||
665 | QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); | 672 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
673 | QCheckListItem::CheckBox ); | ||
666 | 674 | ||
667 | if ( it->isInstalled() ) | 675 | if ( package->isInstalled() ) |
668 | { | 676 | { |
669 | // If a different version of package is available, show update available icon | 677 | // If a different version of package is available, show update available icon |
670 | // Otherwise, show installed icon | 678 | // Otherwise, show installed icon |
671 | if ( it->getVersion() != it->getInstalledVersion() && | 679 | if ( package->getVersion() != package->getInstalledVersion() && |
672 | compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) | 680 | compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1) |
673 | { | 681 | { |
674 | 682 | ||
675 | item->setPixmap( 0, updatedIcon ); | 683 | item->setPixmap( 0, updatedIcon ); |
676 | } | 684 | } |
677 | else | 685 | else |
678 | { | 686 | { |
679 | item->setPixmap( 0, installedIcon ); | 687 | item->setPixmap( 0, installedIcon ); |
680 | } | 688 | } |
681 | 689 | ||
682 | QString destName = ""; | 690 | QString destName = ""; |
683 | if ( it->getLocalPackage() ) | 691 | if ( package->getLocalPackage() ) |
684 | { | 692 | { |
685 | if ( it->getLocalPackage()->getInstalledTo() ) | 693 | if ( package->getLocalPackage()->getInstalledTo() ) |
686 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 694 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); |
687 | } | 695 | } |
688 | else | 696 | else |
689 | { | 697 | { |
690 | if ( it->getInstalledTo() ) | 698 | if ( package->getInstalledTo() ) |
691 | destName = it->getInstalledTo()->getDestinationName(); | 699 | destName = package->getInstalledTo()->getDestinationName(); |
692 | } | 700 | } |
693 | if ( destName != "" ) | 701 | if ( destName != "" ) |
694 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); | 702 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); |
695 | } | 703 | } |
696 | else | 704 | else |
697 | { | 705 | { |
698 | item->setPixmap( 0, nullIcon ); | 706 | item->setPixmap( 0, nullIcon ); |
699 | } | 707 | } |
700 | 708 | ||
701 | if ( !it->isPackageStoredLocally() ) | 709 | if ( !package->isPackageStoredLocally() ) |
702 | { | 710 | { |
703 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); | 711 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) ); |
704 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); | 712 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) ); |
705 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); | 713 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) ); |
706 | } | 714 | } |
707 | else | 715 | else |
708 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); | 716 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) ); |
709 | 717 | ||
710 | if ( serverName == LOCAL_SERVER ) | 718 | if ( serverName == LOCAL_SERVER ) |
711 | { | 719 | { |
712 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); | 720 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) ); |
713 | } | 721 | } |
714 | else | 722 | else |
715 | { | 723 | { |
716 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); | 724 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) ); |
717 | if ( it->getLocalPackage() ) | 725 | if ( package->getLocalPackage() ) |
718 | { | 726 | { |
719 | if ( it->isInstalled() ) | 727 | if ( package->isInstalled() ) |
720 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); | 728 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) ); |
721 | } | 729 | } |
722 | } | 730 | } |
723 | 731 | ||
724 | packagesList->insertItem( item ); | 732 | packagesList->insertItem( item ); |
725 | } | 733 | } |
726 | 734 | ||
727 | // If the local server or the local ipkgs server disable the download button | 735 | // If the local server or the local ipkgs server disable the download button |
728 | if ( serverName == LOCAL_SERVER ) | 736 | if ( serverName == LOCAL_SERVER ) |
729 | { | 737 | { |
730 | downloadEnabled = TRUE; | 738 | downloadEnabled = TRUE; |
731 | actionUpgrade->setEnabled( FALSE ); | 739 | actionUpgrade->setEnabled( FALSE ); |
732 | } | 740 | } |
733 | else if ( serverName == LOCAL_IPKGS ) | 741 | else if ( serverName == LOCAL_IPKGS ) |
734 | { | 742 | { |
735 | downloadEnabled = FALSE; | 743 | downloadEnabled = FALSE; |
736 | actionUpgrade->setEnabled( FALSE ); | 744 | actionUpgrade->setEnabled( FALSE ); |
737 | } | 745 | } |
738 | else | 746 | else |
739 | { | 747 | { |
740 | downloadEnabled = TRUE; | 748 | downloadEnabled = TRUE; |
741 | actionUpgrade->setEnabled( TRUE ); | 749 | actionUpgrade->setEnabled( TRUE ); |
742 | } | 750 | } |
743 | enableDownload( downloadEnabled ); | 751 | enableDownload( downloadEnabled ); |
744 | 752 | ||
745 | // Display this widget once everything is done | 753 | // Display this widget once everything is done |
746 | if ( doProgress && raiseProgress ) | 754 | if ( doProgress && raiseProgress ) |
747 | { | 755 | { |
748 | stack->raiseWidget( networkPkgWindow ); | 756 | stack->raiseWidget( networkPkgWindow ); |
749 | } | 757 | } |
750 | } | 758 | } |
751 | 759 | ||
752 | void MainWindow :: searchForPackage( const QString &text ) | 760 | void MainWindow :: searchForPackage( const QString &text ) |
753 | { | 761 | { |
754 | if ( !text.isEmpty() ) | 762 | if ( !text.isEmpty() ) |
755 | { | 763 | { |
756 | // cout << "searching for " << text << endl; | 764 | // cout << "searching for " << text << endl; |
757 | // look through package list for text startng at current position | 765 | // look through package list for text startng at current position |
758 | vector<InstallData> workingPackages; | 766 | // vector<InstallData> workingPackages; |
759 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 767 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
760 | // if ( start != 0 ) | 768 | // if ( start != 0 ) |
761 | // start = (QCheckListItem *)start->nextSibling(); | 769 | // start = (QCheckListItem *)start->nextSibling(); |
762 | 770 | ||
763 | if ( start == 0 ) | 771 | if ( start == 0 ) |
764 | start = (QCheckListItem *)packagesList->firstChild(); | 772 | start = (QCheckListItem *)packagesList->firstChild(); |
765 | 773 | ||
766 | for ( QCheckListItem *item = start; item != 0 ; | 774 | for ( QCheckListItem *item = start; item != 0 ; |
767 | item = (QCheckListItem *)item->nextSibling() ) | 775 | item = (QCheckListItem *)item->nextSibling() ) |
768 | { | 776 | { |
769 | // cout << "checking " << item->text().lower() << endl; | 777 | // cout << "checking " << item->text().lower() << endl; |
770 | if ( item->text().lower().find( text ) != -1 ) | 778 | if ( item->text().lower().find( text ) != -1 ) |
771 | { | 779 | { |
772 | // cout << "matched " << item->text() << endl; | 780 | // cout << "matched " << item->text() << endl; |
773 | packagesList->ensureItemVisible( item ); | 781 | packagesList->ensureItemVisible( item ); |
774 | packagesList->setCurrentItem( item ); | 782 | packagesList->setCurrentItem( item ); |
775 | break; | 783 | break; |
776 | } | 784 | } |
777 | } | 785 | } |
778 | } | 786 | } |
779 | } | 787 | } |
780 | 788 | ||
781 | void MainWindow :: updateServer() | 789 | void MainWindow :: updateServer() |
782 | { | 790 | { |
783 | QString serverName = serversList->currentText(); | 791 | QString serverName = serversList->currentText(); |
784 | 792 | ||
785 | // Update the current server | 793 | // Update the current server |
786 | // Display dialog | 794 | // Display dialog |
787 | 795 | ||
788 | // Disable buttons to stop silly people clicking lots on them :) | 796 | // Disable buttons to stop silly people clicking lots on them :) |
789 | 797 | ||
790 | // First, write out ipkg_conf file so that ipkg can use it | 798 | // First, write out ipkg_conf file so that ipkg can use it |
791 | mgr->writeOutIpkgConf(); | 799 | mgr->writeOutIpkgConf(); |
792 | 800 | ||
793 | Ipkg *ipkg = new Ipkg; | 801 | Ipkg *ipkg = new Ipkg; |
794 | ipkg->setOption( "update" ); | 802 | ipkg->setOption( "update" ); |
795 | 803 | ||
796 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), | 804 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), |
797 | tr( "Update lists" ) ); | 805 | tr( "Update lists" ) ); |
798 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 806 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
799 | dlg->showMaximized(); | 807 | dlg->showMaximized(); |
800 | 808 | ||
801 | // delete progDlg; | 809 | // delete progDlg; |
802 | } | 810 | } |
803 | 811 | ||
804 | void MainWindow :: upgradePackages() | 812 | void MainWindow :: upgradePackages() |
805 | { | 813 | { |
806 | // We're gonna do an upgrade of all packages | 814 | // We're gonna do an upgrade of all packages |
807 | // First warn user that this isn't recommended | 815 | // First warn user that this isn't recommended |
808 | // TODO - ODevice???? | 816 | // TODO - ODevice???? |
809 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | 817 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); |
810 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 818 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |
811 | QMessageBox::Yes, | 819 | QMessageBox::Yes, |
812 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 820 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
813 | 0, this ); | 821 | 0, this ); |
814 | warn.adjustSize(); | 822 | warn.adjustSize(); |
815 | 823 | ||
816 | if ( warn.exec() == QMessageBox::Yes ) | 824 | if ( warn.exec() == QMessageBox::Yes ) |
817 | { | 825 | { |
818 | // First, write out ipkg_conf file so that ipkg can use it | 826 | // First, write out ipkg_conf file so that ipkg can use it |
819 | mgr->writeOutIpkgConf(); | 827 | mgr->writeOutIpkgConf(); |
820 | 828 | ||
821 | // Now run upgrade | 829 | // Now run upgrade |
822 | Ipkg *ipkg = new Ipkg; | 830 | Ipkg *ipkg = new Ipkg; |
823 | ipkg->setOption( "upgrade" ); | 831 | ipkg->setOption( "upgrade" ); |
824 | 832 | ||
825 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), | 833 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), |
826 | tr ( "Upgrade" ) ); | 834 | tr ( "Upgrade" ) ); |
827 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 835 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
828 | dlg->showMaximized(); | 836 | dlg->showMaximized(); |
829 | } | 837 | } |
830 | } | 838 | } |
831 | 839 | ||
832 | void MainWindow :: downloadPackage() | 840 | void MainWindow :: downloadPackage() |
833 | { | 841 | { |
834 | bool doUpdate = true; | 842 | bool doUpdate = true; |
835 | if ( downloadEnabled ) | 843 | if ( downloadEnabled ) |
836 | { | 844 | { |
837 | // See if any packages are selected | 845 | // See if any packages are selected |
838 | bool found = false; | 846 | bool found = false; |
839 | if ( serversList->currentText() != LOCAL_SERVER ) | 847 | if ( serversList->currentText() != LOCAL_SERVER ) |
840 | { | 848 | { |
841 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 849 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
842 | item != 0 && !found; | 850 | item != 0 && !found; |
843 | item = (QCheckListItem *)item->nextSibling() ) | 851 | item = (QCheckListItem *)item->nextSibling() ) |
844 | { | 852 | { |
845 | if ( item->isOn() ) | 853 | if ( item->isOn() ) |
846 | found = true; | 854 | found = true; |
847 | } | 855 | } |
848 | } | 856 | } |
849 | 857 | ||
850 | // If user selected some packages then download the and store the locally | 858 | // If user selected some packages then download the and store the locally |
851 | // otherwise, display dialog asking user what package to download from an http server | 859 | // otherwise, display dialog asking user what package to download from an http server |
852 | // and whether to install it | 860 | // and whether to install it |
853 | if ( found ) | 861 | if ( found ) |
854 | downloadSelectedPackages(); | 862 | downloadSelectedPackages(); |
@@ -864,323 +872,324 @@ void MainWindow :: downloadPackage() | |||
864 | item = (QCheckListItem *)item->nextSibling() ) | 872 | item = (QCheckListItem *)item->nextSibling() ) |
865 | { | 873 | { |
866 | if ( item->isOn() ) | 874 | if ( item->isOn() ) |
867 | { | 875 | { |
868 | QString name = item->text(); | 876 | QString name = item->text(); |
869 | int pos = name.find( "*" ); | 877 | int pos = name.find( "*" ); |
870 | name.truncate( pos ); | 878 | name.truncate( pos ); |
871 | 879 | ||
872 | // if (there is a (installed), remove it | 880 | // if (there is a (installed), remove it |
873 | pos = name.find( "(installed)" ); | 881 | pos = name.find( "(installed)" ); |
874 | if ( pos > 0 ) | 882 | if ( pos > 0 ) |
875 | name.truncate( pos - 1 ); | 883 | name.truncate( pos - 1 ); |
876 | 884 | ||
877 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 885 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
878 | 886 | ||
879 | QString msgtext; | 887 | QString msgtext; |
880 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | 888 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); |
881 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 889 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
882 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 890 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
883 | { | 891 | { |
884 | doUpdate = true; | 892 | doUpdate = true; |
885 | QFile f( p->getFilename() ); | 893 | QFile f( p->getFilename() ); |
886 | f.remove(); | 894 | f.remove(); |
887 | } | 895 | } |
888 | } | 896 | } |
889 | } | 897 | } |
890 | } | 898 | } |
891 | 899 | ||
892 | if ( doUpdate ) | 900 | if ( doUpdate ) |
893 | { | 901 | { |
894 | reloadData( 0x0 ); | 902 | reloadData( 0x0 ); |
895 | } | 903 | } |
896 | } | 904 | } |
897 | 905 | ||
898 | void MainWindow :: downloadSelectedPackages() | 906 | void MainWindow :: downloadSelectedPackages() |
899 | { | 907 | { |
900 | // First, write out ipkg_conf file so that ipkg can use it | 908 | // First, write out ipkg_conf file so that ipkg can use it |
901 | mgr->writeOutIpkgConf(); | 909 | mgr->writeOutIpkgConf(); |
902 | 910 | ||
903 | // Display dialog to user asking where to download the files to | 911 | // Display dialog to user asking where to download the files to |
904 | bool ok = FALSE; | 912 | bool ok = FALSE; |
905 | QString dir = ""; | 913 | QString dir = ""; |
906 | #ifdef QWS | 914 | #ifdef QWS |
907 | // read download directory from config file | 915 | // read download directory from config file |
908 | Config cfg( "aqpkg" ); | 916 | Config cfg( "aqpkg" ); |
909 | cfg.setGroup( "settings" ); | 917 | cfg.setGroup( "settings" ); |
910 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 918 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
911 | #endif | 919 | #endif |
912 | 920 | ||
913 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 921 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
914 | if ( ok && !text.isEmpty() ) | 922 | if ( ok && !text.isEmpty() ) |
915 | dir = text; // user entered something and pressed ok | 923 | dir = text; // user entered something and pressed ok |
916 | else | 924 | else |
917 | return; // user entered nothing or pressed cancel | 925 | return; // user entered nothing or pressed cancel |
918 | 926 | ||
919 | #ifdef QWS | 927 | #ifdef QWS |
920 | // Store download directory in config file | 928 | // Store download directory in config file |
921 | cfg.writeEntry( "downloadDir", dir ); | 929 | cfg.writeEntry( "downloadDir", dir ); |
922 | #endif | 930 | #endif |
923 | 931 | ||
924 | // Get starting directory | 932 | // Get starting directory |
925 | char initDir[PATH_MAX]; | 933 | char initDir[PATH_MAX]; |
926 | getcwd( initDir, PATH_MAX ); | 934 | getcwd( initDir, PATH_MAX ); |
927 | 935 | ||
928 | // Download each package | 936 | // Download each package |
929 | Ipkg ipkg; | 937 | Ipkg ipkg; |
930 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 938 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
931 | 939 | ||
932 | ipkg.setOption( "download" ); | 940 | ipkg.setOption( "download" ); |
933 | ipkg.setRuntimeDirectory( dir ); | 941 | ipkg.setRuntimeDirectory( dir ); |
934 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 942 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
935 | item != 0 ; | 943 | item != 0 ; |
936 | item = (QCheckListItem *)item->nextSibling() ) | 944 | item = (QCheckListItem *)item->nextSibling() ) |
937 | { | 945 | { |
938 | if ( item->isOn() ) | 946 | if ( item->isOn() ) |
939 | { | 947 | { |
940 | ipkg.setPackage( item->text() ); | 948 | ipkg.setPackage( item->text() ); |
941 | ipkg.runIpkg( ); | 949 | ipkg.runIpkg( ); |
942 | } | 950 | } |
943 | } | 951 | } |
944 | } | 952 | } |
945 | 953 | ||
946 | void MainWindow :: downloadRemotePackage() | 954 | void MainWindow :: downloadRemotePackage() |
947 | { | 955 | { |
948 | // Display dialog | 956 | // Display dialog |
949 | bool ok; | 957 | bool ok; |
950 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 958 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
951 | if ( !ok || package.isEmpty() ) | 959 | if ( !ok || package.isEmpty() ) |
952 | return; | 960 | return; |
953 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 961 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
954 | // if ( dlg.exec() == QDialog::Rejected ) | 962 | // if ( dlg.exec() == QDialog::Rejected ) |
955 | // return; | 963 | // return; |
956 | 964 | ||
957 | // grab details from dialog | 965 | // grab details from dialog |
958 | // QString package = dlg.getPackageLocation(); | 966 | // QString package = dlg.getPackageLocation(); |
959 | 967 | ||
960 | InstallData item; | 968 | InstallData *item = new InstallData(); |
961 | item.option = "I"; | 969 | item->option = "I"; |
962 | item.packageName = package; | 970 | item->packageName = package; |
963 | vector<InstallData> workingPackages; | 971 | QList<InstallData> workingPackages; |
964 | workingPackages.push_back( item ); | 972 | workingPackages.setAutoDelete( TRUE ); |
973 | workingPackages.append( item ); | ||
965 | 974 | ||
966 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 975 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
967 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 976 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
968 | dlg->showMaximized(); | 977 | dlg->showMaximized(); |
969 | } | 978 | } |
970 | 979 | ||
971 | 980 | ||
972 | void MainWindow :: applyChanges() | 981 | void MainWindow :: applyChanges() |
973 | { | 982 | { |
974 | stickyOption = ""; | 983 | stickyOption = ""; |
975 | 984 | ||
976 | // First, write out ipkg_conf file so that ipkg can use it | 985 | // First, write out ipkg_conf file so that ipkg can use it |
977 | mgr->writeOutIpkgConf(); | 986 | mgr->writeOutIpkgConf(); |
978 | 987 | ||
979 | // Now for each selected item | 988 | // Now for each selected item |
980 | // deal with it | 989 | // deal with it |
981 | 990 | ||
982 | vector<InstallData> workingPackages; | 991 | QList<InstallData> workingPackages; |
992 | workingPackages.setAutoDelete( TRUE ); | ||
983 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 993 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
984 | item != 0 ; | 994 | item != 0 ; |
985 | item = (QCheckListItem *)item->nextSibling() ) | 995 | item = (QCheckListItem *)item->nextSibling() ) |
986 | { | 996 | { |
987 | if ( item->isOn() ) | 997 | if ( item->isOn() ) |
988 | { | 998 | { |
989 | InstallData data = dealWithItem( item ); | 999 | workingPackages.append( dealWithItem( item ) ); |
990 | workingPackages.push_back( data ); | ||
991 | } | 1000 | } |
992 | } | 1001 | } |
993 | 1002 | ||
994 | if ( workingPackages.size() == 0 ) | 1003 | if ( workingPackages.count() == 0 ) |
995 | { | 1004 | { |
996 | // Nothing to do | 1005 | // Nothing to do |
997 | QMessageBox::information( this, tr( "Nothing to do" ), | 1006 | QMessageBox::information( this, tr( "Nothing to do" ), |
998 | tr( "No packages selected" ), tr( "OK" ) ); | 1007 | tr( "No packages selected" ), tr( "OK" ) ); |
999 | 1008 | ||
1000 | return; | 1009 | return; |
1001 | } | 1010 | } |
1002 | 1011 | ||
1003 | // do the stuff | 1012 | // do the stuff |
1004 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 1013 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
1005 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 1014 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
1006 | dlg->showMaximized(); | 1015 | dlg->showMaximized(); |
1007 | } | 1016 | } |
1008 | 1017 | ||
1009 | // decide what to do - either remove, upgrade or install | 1018 | // decide what to do - either remove, upgrade or install |
1010 | // Current rules: | 1019 | // Current rules: |
1011 | // If not installed - install | 1020 | // If not installed - install |
1012 | // If installed and different version available - upgrade | 1021 | // If installed and different version available - upgrade |
1013 | // If installed and version up to date - remove | 1022 | // If installed and version up to date - remove |
1014 | InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | 1023 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
1015 | { | 1024 | { |
1016 | QString name = item->text(); | 1025 | QString name = item->text(); |
1017 | 1026 | ||
1018 | // Get package | 1027 | // Get package |
1019 | vector<Server>::iterator s = mgr->getServer( serversList->currentText() ); | 1028 | Server *s = mgr->getServer( serversList->currentText() ); |
1020 | Package *p = s->getPackage( name ); | 1029 | Package *p = s->getPackage( name ); |
1021 | 1030 | ||
1022 | // If the package has a filename then it is a local file | 1031 | // If the package has a filename then it is a local file |
1023 | if ( p->isPackageStoredLocally() ) | 1032 | if ( p->isPackageStoredLocally() ) |
1024 | name = p->getFilename(); | 1033 | name = p->getFilename(); |
1025 | 1034 | ||
1026 | QString option; | 1035 | QString option; |
1027 | QString dest = "root"; | 1036 | QString dest = "root"; |
1028 | if ( !p->isInstalled() ) | 1037 | if ( !p->isInstalled() ) |
1029 | { | 1038 | { |
1030 | InstallData item; | 1039 | InstallData *newitem = new InstallData();; |
1031 | item.option = "I"; | 1040 | newitem->option = "I"; |
1032 | item.packageName = name; | 1041 | newitem->packageName = name; |
1033 | return item; | 1042 | return newitem; |
1034 | } | 1043 | } |
1035 | else | 1044 | else |
1036 | { | 1045 | { |
1037 | InstallData item; | 1046 | InstallData *newitem = new InstallData();; |
1038 | item.option = "D"; | 1047 | newitem->option = "D"; |
1039 | if ( !p->isPackageStoredLocally() ) | 1048 | if ( !p->isPackageStoredLocally() ) |
1040 | item.packageName = p->getInstalledPackageName(); | 1049 | newitem->packageName = p->getInstalledPackageName(); |
1041 | else | 1050 | else |
1042 | item.packageName = name; | 1051 | newitem->packageName = name; |
1043 | 1052 | ||
1044 | if ( p->getInstalledTo() ) | 1053 | if ( p->getInstalledTo() ) |
1045 | { | 1054 | { |
1046 | item.destination = p->getInstalledTo(); | 1055 | newitem->destination = p->getInstalledTo(); |
1047 | // cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | 1056 | // cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; |
1048 | // cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | 1057 | // cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; |
1049 | } | 1058 | } |
1050 | else | 1059 | else |
1051 | { | 1060 | { |
1052 | item.destination = p->getLocalPackage()->getInstalledTo(); | 1061 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1053 | } | 1062 | } |
1054 | 1063 | ||
1055 | // Now see if version is newer or not | 1064 | // Now see if version is newer or not |
1056 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1065 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1057 | 1066 | ||
1058 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1067 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1059 | if ( p->isPackageStoredLocally() && val == -1 ) | 1068 | if ( p->isPackageStoredLocally() && val == -1 ) |
1060 | val = 0; | 1069 | val = 0; |
1061 | 1070 | ||
1062 | if ( val == -2 ) | 1071 | if ( val == -2 ) |
1063 | { | 1072 | { |
1064 | // Error - should handle | 1073 | // Error - should handle |
1065 | } | 1074 | } |
1066 | else if ( val == -1 ) | 1075 | else if ( val == -1 ) |
1067 | { | 1076 | { |
1068 | // Version available is older - remove only | 1077 | // Version available is older - remove only |
1069 | item.option = "D"; | 1078 | newitem->option = "D"; |
1070 | } | 1079 | } |
1071 | else | 1080 | else |
1072 | { | 1081 | { |
1073 | QString caption; | 1082 | QString caption; |
1074 | QString text; | 1083 | QString text; |
1075 | QString secondButton; | 1084 | QString secondButton; |
1076 | QString secondOption; | 1085 | QString secondOption; |
1077 | if ( val == 0 ) | 1086 | if ( val == 0 ) |
1078 | { | 1087 | { |
1079 | // Version available is the same - option to remove or reinstall | 1088 | // Version available is the same - option to remove or reinstall |
1080 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1089 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1081 | text = tr( "Remove or ReInstall" ); | 1090 | text = tr( "Remove or ReInstall" ); |
1082 | secondButton = tr( "ReInstall" ); | 1091 | secondButton = tr( "ReInstall" ); |
1083 | secondOption = tr( "R" ); | 1092 | secondOption = tr( "R" ); |
1084 | } | 1093 | } |
1085 | else if ( val == 1 ) | 1094 | else if ( val == 1 ) |
1086 | { | 1095 | { |
1087 | // Version available is newer - option to remove or upgrade | 1096 | // Version available is newer - option to remove or upgrade |
1088 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1097 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1089 | text = tr( "Remove or Upgrade" ); | 1098 | text = tr( "Remove or Upgrade" ); |
1090 | secondButton = tr( "Upgrade" ); | 1099 | secondButton = tr( "Upgrade" ); |
1091 | secondOption = tr( "U" ); | 1100 | secondOption = tr( "U" ); |
1092 | } | 1101 | } |
1093 | 1102 | ||
1094 | // Sticky option not implemented yet, but will eventually allow | 1103 | // Sticky option not implemented yet, but will eventually allow |
1095 | // the user to say something like 'remove all' | 1104 | // the user to say something like 'remove all' |
1096 | if ( stickyOption == "" ) | 1105 | if ( stickyOption == "" ) |
1097 | { | 1106 | { |
1098 | QString msgtext; | 1107 | QString msgtext; |
1099 | msgtext = caption.arg( ( const char * )name ); | 1108 | msgtext = caption.arg( ( const char * )name ); |
1100 | switch( QMessageBox::information( this, text, | 1109 | switch( QMessageBox::information( this, text, |
1101 | msgtext, tr( "Remove" ), secondButton ) ) | 1110 | msgtext, tr( "Remove" ), secondButton ) ) |
1102 | { | 1111 | { |
1103 | case 0: // Try again or Enter | 1112 | case 0: // Try again or Enter |
1104 | // option 0 = Remove | 1113 | // option 0 = Remove |
1105 | item.option = "D"; | 1114 | newitem->option = "D"; |
1106 | break; | 1115 | break; |
1107 | case 1: // Quit or Escape | 1116 | case 1: // Quit or Escape |
1108 | item.option = secondOption; | 1117 | newitem->option = secondOption; |
1109 | break; | 1118 | break; |
1110 | } | 1119 | } |
1111 | } | 1120 | } |
1112 | else | 1121 | else |
1113 | { | 1122 | { |
1114 | // item.option = stickyOption; | 1123 | // newitem->option = stickyOption; |
1115 | } | 1124 | } |
1116 | } | 1125 | } |
1117 | 1126 | ||
1118 | 1127 | ||
1119 | // Check if we are reinstalling the same version | 1128 | // Check if we are reinstalling the same version |
1120 | if ( item.option != "R" ) | 1129 | if ( newitem->option != "R" ) |
1121 | item.recreateLinks = true; | 1130 | newitem->recreateLinks = true; |
1122 | else | 1131 | else |
1123 | item.recreateLinks = false; | 1132 | newitem->recreateLinks = false; |
1124 | 1133 | ||
1125 | // User hit cancel (on dlg - assume remove) | 1134 | // User hit cancel (on dlg - assume remove) |
1126 | return item; | 1135 | return newitem; |
1127 | } | 1136 | } |
1128 | } | 1137 | } |
1129 | 1138 | ||
1130 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) | 1139 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) |
1131 | { | 1140 | { |
1132 | stack->raiseWidget( progressWindow ); | 1141 | stack->raiseWidget( progressWindow ); |
1133 | 1142 | ||
1134 | if ( dlg ) | 1143 | if ( dlg ) |
1135 | { | 1144 | { |
1136 | dlg->close(); | 1145 | dlg->close(); |
1137 | delete dlg; | 1146 | delete dlg; |
1138 | } | 1147 | } |
1139 | 1148 | ||
1140 | mgr->reloadServerData(); | 1149 | mgr->reloadServerData(); |
1141 | serverSelected( -1, FALSE ); | 1150 | serverSelected( -1, FALSE ); |
1142 | 1151 | ||
1143 | #ifdef QWS | 1152 | #ifdef QWS |
1144 | m_status->setText( tr( "Updating Launcher..." ) ); | 1153 | m_status->setText( tr( "Updating Launcher..." ) ); |
1145 | 1154 | ||
1146 | // Finally let the main system update itself | 1155 | // Finally let the main system update itself |
1147 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1156 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
1148 | QString lf = QString::null; | 1157 | QString lf = QString::null; |
1149 | e << lf; | 1158 | e << lf; |
1150 | #endif | 1159 | #endif |
1151 | 1160 | ||
1152 | stack->raiseWidget( networkPkgWindow ); | 1161 | stack->raiseWidget( networkPkgWindow ); |
1153 | } | 1162 | } |
1154 | 1163 | ||
1155 | void MainWindow :: letterPushed( QString t ) | 1164 | void MainWindow :: letterPushed( QString t ) |
1156 | { | 1165 | { |
1157 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 1166 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
1158 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 1167 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
1159 | if ( packagesList->firstChild() == 0 ) | 1168 | if ( packagesList->firstChild() == 0 ) |
1160 | return; | 1169 | return; |
1161 | 1170 | ||
1162 | QCheckListItem *item; | 1171 | QCheckListItem *item; |
1163 | if ( start == 0 ) | 1172 | if ( start == 0 ) |
1164 | { | 1173 | { |
1165 | item = (QCheckListItem *)packagesList->firstChild(); | 1174 | item = (QCheckListItem *)packagesList->firstChild(); |
1166 | start = top; | 1175 | start = top; |
1167 | } | 1176 | } |
1168 | else | 1177 | else |
1169 | item = (QCheckListItem *)start->nextSibling(); | 1178 | item = (QCheckListItem *)start->nextSibling(); |
1170 | 1179 | ||
1171 | if ( item == 0 ) | 1180 | if ( item == 0 ) |
1172 | item = (QCheckListItem *)packagesList->firstChild(); | 1181 | item = (QCheckListItem *)packagesList->firstChild(); |
1173 | do | 1182 | do |
1174 | { | 1183 | { |
1175 | if ( item->text().lower().startsWith( t.lower() ) ) | 1184 | if ( item->text().lower().startsWith( t.lower() ) ) |
1176 | { | 1185 | { |
1177 | packagesList->setSelected( item, true ); | 1186 | packagesList->setSelected( item, true ); |
1178 | packagesList->ensureItemVisible( item ); | 1187 | packagesList->ensureItemVisible( item ); |
1179 | break; | 1188 | break; |
1180 | } | 1189 | } |
1181 | 1190 | ||
1182 | item = (QCheckListItem *)item->nextSibling(); | 1191 | item = (QCheckListItem *)item->nextSibling(); |
1183 | if ( !item ) | 1192 | if ( !item ) |
1184 | item = (QCheckListItem *)packagesList->firstChild(); | 1193 | item = (QCheckListItem *)packagesList->firstChild(); |
1185 | } while ( item != start); | 1194 | } while ( item != start); |
1186 | } | 1195 | } |
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index d0777fb..db06e16 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h | |||
@@ -1,138 +1,138 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | mainwin.h - description | 2 | mainwin.h - 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 | #ifndef MAINWIN_H | 18 | #ifndef MAINWIN_H |
19 | #define MAINWIN_H | 19 | #define MAINWIN_H |
20 | 20 | ||
21 | #include <qmainwindow.h> | 21 | #include <qmainwindow.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | 23 | ||
24 | class DataManager; | 24 | class DataManager; |
25 | class InstallData; | 25 | class InstallData; |
26 | class InstallDlgImpl; | 26 | class InstallDlgImpl; |
27 | 27 | ||
28 | class QAction; | 28 | class QAction; |
29 | class QCheckListItem; | 29 | class QCheckListItem; |
30 | class QComboBox; | 30 | class QComboBox; |
31 | class QLabel; | 31 | class QLabel; |
32 | class QLineEdit; | 32 | class QLineEdit; |
33 | class QListView; | 33 | class QListView; |
34 | class QPEToolBar; | 34 | class QPEToolBar; |
35 | class QProgressBar; | 35 | class QProgressBar; |
36 | class QWidgetStack; | 36 | class QWidgetStack; |
37 | 37 | ||
38 | class MainWindow :public QMainWindow | 38 | class MainWindow :public QMainWindow |
39 | { | 39 | { |
40 | Q_OBJECT | 40 | Q_OBJECT |
41 | public: | 41 | public: |
42 | 42 | ||
43 | MainWindow(); | 43 | MainWindow(); |
44 | ~MainWindow(); | 44 | ~MainWindow(); |
45 | 45 | ||
46 | private: | 46 | private: |
47 | DataManager *mgr; | 47 | DataManager *mgr; |
48 | 48 | ||
49 | QWidgetStack *stack; | 49 | QWidgetStack *stack; |
50 | 50 | ||
51 | QPEToolBar *findBar; | 51 | QPEToolBar *findBar; |
52 | QPEToolBar *jumpBar; | 52 | QPEToolBar *jumpBar; |
53 | QLineEdit *findEdit; | 53 | QLineEdit *findEdit; |
54 | QAction *actionFindNext; | 54 | QAction *actionFindNext; |
55 | QAction *actionFilter; | 55 | QAction *actionFilter; |
56 | QAction *actionUpgrade; | 56 | QAction *actionUpgrade; |
57 | QAction *actionDownload; | 57 | QAction *actionDownload; |
58 | QAction *actionUninstalled; | 58 | QAction *actionUninstalled; |
59 | QAction *actionInstalled; | 59 | QAction *actionInstalled; |
60 | QAction *actionUpdated; | 60 | QAction *actionUpdated; |
61 | 61 | ||
62 | QPixmap iconDownload; | 62 | QPixmap iconDownload; |
63 | QPixmap iconRemove; | 63 | QPixmap iconRemove; |
64 | 64 | ||
65 | int mnuShowUninstalledPkgsId; | 65 | int mnuShowUninstalledPkgsId; |
66 | int mnuShowInstalledPkgsId; | 66 | int mnuShowInstalledPkgsId; |
67 | int mnuShowUpgradedPkgsId; | 67 | int mnuShowUpgradedPkgsId; |
68 | int mnuFilterByCategory; | 68 | int mnuFilterByCategory; |
69 | int mnuSetFilterCategory; | 69 | int mnuSetFilterCategory; |
70 | 70 | ||
71 | // Main package list widget | 71 | // Main package list widget |
72 | QWidget *networkPkgWindow; | 72 | QWidget *networkPkgWindow; |
73 | QComboBox *serversList; | 73 | QComboBox *serversList; |
74 | QListView *packagesList; | 74 | QListView *packagesList; |
75 | QPixmap installedIcon; | 75 | QPixmap installedIcon; |
76 | QPixmap updatedIcon; | 76 | QPixmap updatedIcon; |
77 | QString currentlySelectedServer; | 77 | QString currentlySelectedServer; |
78 | QString categoryFilter; | 78 | QString categoryFilter; |
79 | QString stickyOption; | 79 | QString stickyOption; |
80 | 80 | ||
81 | bool categoryFilterEnabled; | 81 | bool categoryFilterEnabled; |
82 | bool showJumpTo; | 82 | bool showJumpTo; |
83 | bool showUninstalledPkgs; | 83 | bool showUninstalledPkgs; |
84 | bool showInstalledPkgs; | 84 | bool showInstalledPkgs; |
85 | bool showUpgradedPkgs; | 85 | bool showUpgradedPkgs; |
86 | bool downloadEnabled; | 86 | bool downloadEnabled; |
87 | 87 | ||
88 | void initMainWidget(); | 88 | void initMainWidget(); |
89 | void updateData(); | 89 | void updateData(); |
90 | void serverSelected( int index, bool showProgress ); | 90 | void serverSelected( int index, bool showProgress ); |
91 | void searchForPackage( const QString & ); | 91 | void searchForPackage( const QString & ); |
92 | bool filterByCategory( bool val ); | 92 | bool filterByCategory( bool val ); |
93 | void downloadSelectedPackages(); | 93 | void downloadSelectedPackages(); |
94 | void downloadRemotePackage(); | 94 | void downloadRemotePackage(); |
95 | InstallData dealWithItem( QCheckListItem *item ); | 95 | InstallData *dealWithItem( QCheckListItem *item ); |
96 | 96 | ||
97 | // Progress widget | 97 | // Progress widget |
98 | QWidget *progressWindow; | 98 | QWidget *progressWindow; |
99 | QLabel *m_status; | 99 | QLabel *m_status; |
100 | QProgressBar *m_progress; | 100 | QProgressBar *m_progress; |
101 | 101 | ||
102 | void initProgressWidget(); | 102 | void initProgressWidget(); |
103 | 103 | ||
104 | public slots: | 104 | public slots: |
105 | // void setDocument( const QString &doc ); | 105 | // void setDocument( const QString &doc ); |
106 | void displayHelp(); | 106 | void displayHelp(); |
107 | void displayFindBar(); | 107 | void displayFindBar(); |
108 | void displayJumpBar(); | 108 | void displayJumpBar(); |
109 | void repeatFind(); | 109 | void repeatFind(); |
110 | void findPackage( const QString & ); | 110 | void findPackage( const QString & ); |
111 | void hideFindBar(); | 111 | void hideFindBar(); |
112 | void hideJumpBar(); | 112 | void hideJumpBar(); |
113 | void displayAbout(); | 113 | void displayAbout(); |
114 | void displaySettings(); | 114 | void displaySettings(); |
115 | void filterUninstalledPackages(); | 115 | void filterUninstalledPackages(); |
116 | void filterInstalledPackages(); | 116 | void filterInstalledPackages(); |
117 | void filterUpgradedPackages(); | 117 | void filterUpgradedPackages(); |
118 | void filterCategory(); | 118 | void filterCategory(); |
119 | bool setFilterCategory(); | 119 | bool setFilterCategory(); |
120 | void raiseMainWidget(); | 120 | void raiseMainWidget(); |
121 | void raiseProgressWidget(); | 121 | void raiseProgressWidget(); |
122 | void enableUpgrade( bool ); | 122 | void enableUpgrade( bool ); |
123 | void enableDownload( bool ); | 123 | void enableDownload( bool ); |
124 | void reloadData( InstallDlgImpl * ); | 124 | void reloadData( InstallDlgImpl * ); |
125 | 125 | ||
126 | private slots: | 126 | private slots: |
127 | void init(); | 127 | void init(); |
128 | void setProgressSteps( int ); | 128 | void setProgressSteps( int ); |
129 | void setProgressMessage( const QString & ); | 129 | void setProgressMessage( const QString & ); |
130 | void updateProgress( int ); | 130 | void updateProgress( int ); |
131 | void serverSelected( int index ); | 131 | void serverSelected( int index ); |
132 | void updateServer(); | 132 | void updateServer(); |
133 | void upgradePackages(); | 133 | void upgradePackages(); |
134 | void downloadPackage(); | 134 | void downloadPackage(); |
135 | void applyChanges(); | 135 | void applyChanges(); |
136 | void letterPushed( QString t ); | 136 | void letterPushed( QString t ); |
137 | }; | 137 | }; |
138 | #endif | 138 | #endif |
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index fc5ed12..04f5ab7 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp | |||
@@ -1,307 +1,314 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | server.cpp - description | 2 | server.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 2002 | 4 | begin : Mon Aug 26 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 | description : This class holds details about a server | 7 | description : This class holds details about a server |
8 | : e.g. all the packages that contained on the server | 8 | : e.g. all the packages that contained on the server |
9 | : the installation status | 9 | : the installation status |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * * | 13 | * * |
14 | * This program is free software; you can redistribute it and/or modify * | 14 | * This program is free software; you can redistribute it and/or modify * |
15 | * it under the terms of the GNU General Public License as published by * | 15 | * it under the terms of the GNU General Public License as published by * |
16 | * the Free Software Foundation; either version 2 of the License, or * | 16 | * the Free Software Foundation; either version 2 of the License, or * |
17 | * (at your option) any later version. * | 17 | * (at your option) any later version. * |
18 | * * | 18 | * * |
19 | ***************************************************************************/ | 19 | ***************************************************************************/ |
20 | 20 | ||
21 | 21 | ||
22 | #include <stdio.h> | 22 | #include <stdio.h> |
23 | #include <string.h> | 23 | #include <string.h> |
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | 25 | ||
26 | #include <iostream> | 26 | #include <iostream> |
27 | #include <fstream> | 27 | #include <fstream> |
28 | using namespace std; | 28 | using namespace std; |
29 | 29 | ||
30 | #include "server.h" | 30 | #include "server.h" |
31 | #include "datamgr.h" | 31 | #include "datamgr.h" |
32 | 32 | ||
33 | #ifdef QWS | 33 | #ifdef QWS |
34 | #include <qpe/global.h> | 34 | #include <qpe/global.h> |
35 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
36 | #include <qlist.h> | 36 | #include <qlist.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #include "utils.h" | 39 | #include "utils.h" |
40 | 40 | ||
41 | #include "global.h" | 41 | #include "global.h" |
42 | 42 | ||
43 | Server :: Server( const char *name, const char *url ) | 43 | Server :: Server( const char *name, const char *url ) |
44 | { | 44 | { |
45 | serverName = name; | 45 | serverName = name; |
46 | serverUrl = url; | 46 | serverUrl = url; |
47 | packageFile = IPKG_DIR; | 47 | packageFile = IPKG_DIR; |
48 | active = true; | 48 | active = true; |
49 | packageFile += "lists/" + serverName; | 49 | packageFile += "lists/" + serverName; |
50 | } | 50 | } |
51 | 51 | ||
52 | Server :: ~Server() | 52 | Server :: ~Server() |
53 | { | 53 | { |
54 | cleanUp(); | 54 | cleanUp(); |
55 | } | 55 | } |
56 | 56 | ||
57 | void Server :: cleanUp() | 57 | void Server :: cleanUp() |
58 | { | 58 | { |
59 | packageList.clear(); | 59 | packageList.clear(); |
60 | } | 60 | } |
61 | 61 | ||
62 | void Server :: readStatusFile( vector<Destination> &destList ) | 62 | void Server :: readStatusFile( QList<Destination> &destList ) |
63 | { | 63 | { |
64 | cleanUp(); | 64 | cleanUp(); |
65 | 65 | ||
66 | vector<Destination>::iterator dit; | 66 | Destination *dest; |
67 | QListIterator<Destination> dit( destList ); | ||
67 | bool rootRead = false; | 68 | bool rootRead = false; |
68 | for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) | 69 | for ( ; dit.current(); ++dit ) |
69 | { | 70 | { |
71 | dest = dit.current(); | ||
70 | bool installingToRoot = false; | 72 | bool installingToRoot = false; |
71 | 73 | ||
72 | QString path = dit->getDestinationPath(); | 74 | QString path = dest->getDestinationPath(); |
73 | if ( path.right( 1 ) != "/" ) | 75 | if ( path.right( 1 ) != "/" ) |
74 | path += "/"; | 76 | path += "/"; |
75 | 77 | ||
76 | if ( path == "/" ) | 78 | if ( path == "/" ) |
77 | { | 79 | { |
78 | rootRead = true; | 80 | rootRead = true; |
79 | installingToRoot = true; | 81 | installingToRoot = true; |
80 | } | 82 | } |
81 | 83 | ||
82 | packageFile = path + "usr/lib/ipkg/status"; | 84 | packageFile = path + "usr/lib/ipkg/status"; |
83 | readPackageFile( 0, false, installingToRoot, &( *dit ) ); | 85 | readPackageFile( 0, false, installingToRoot, &( *dest ) ); |
84 | } | 86 | } |
85 | 87 | ||
86 | // Ensure that the root status file is read | 88 | // Ensure that the root status file is read |
87 | if ( !rootRead ) | 89 | if ( !rootRead ) |
88 | { | 90 | { |
89 | cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; | 91 | cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; |
90 | packageFile = "/usr/lib/ipkg/status"; | 92 | packageFile = "/usr/lib/ipkg/status"; |
91 | readPackageFile( 0, false, true ); | 93 | readPackageFile( 0, false, true ); |
92 | } | 94 | } |
93 | } | 95 | } |
94 | 96 | ||
95 | void Server :: readLocalIpks( Server *local ) | 97 | void Server :: readLocalIpks( Server *local ) |
96 | { | 98 | { |
97 | cleanUp(); | 99 | cleanUp(); |
98 | 100 | ||
99 | #ifdef QWS | 101 | #ifdef QWS |
100 | // First, get any local IPKGs in the documents area | 102 | // First, get any local IPKGs in the documents area |
101 | // Only applicable to Qtopie/Opie | 103 | // Only applicable to Qtopie/Opie |
102 | 104 | ||
103 | DocLnkSet files; | 105 | DocLnkSet files; |
104 | Global::findDocuments( &files, "application/ipkg" ); | 106 | Global::findDocuments( &files, "application/ipkg" ); |
105 | 107 | ||
106 | // Now add the items to the list | 108 | // Now add the items to the list |
107 | QListIterator<DocLnk> it( files.children() ); | 109 | QListIterator<DocLnk> it( files.children() ); |
108 | 110 | ||
109 | for ( ; it.current() ; ++it ) | 111 | for ( ; it.current() ; ++it ) |
110 | { | 112 | { |
111 | // OK, we have a local IPK file, I think the standard naming conventions | 113 | // OK, we have a local IPK file, I think the standard naming conventions |
112 | // for these are packagename_version_arm.ipk | 114 | // for these are packagename_version_arm.ipk |
113 | QString file = (*it)->file(); | 115 | QString file = (*it)->file(); |
114 | 116 | ||
115 | // Changed to display the filename (excluding the path) | 117 | // Changed to display the filename (excluding the path) |
116 | QString packageName = Utils::getFilenameFromIpkFilename( file ); | 118 | QString packageName = Utils::getFilenameFromIpkFilename( file ); |
117 | QString ver = Utils::getPackageVersionFromIpkFilename( file ); | 119 | QString ver = Utils::getPackageVersionFromIpkFilename( file ); |
118 | packageList.push_back( Package( packageName ) ); | 120 | Package *package = new Package( packageName ); |
119 | packageList.back().setVersion( ver ); | 121 | package->setVersion( ver ); |
120 | packageList.back().setFilename( file ); | 122 | package->setFilename( file ); |
121 | packageList.back().setPackageStoredLocally( true ); | 123 | package->setPackageStoredLocally( true ); |
122 | 124 | packageList.append( package ); | |
123 | } | 125 | } |
124 | #else | 126 | #else |
125 | QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; | 127 | QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; |
126 | for ( int i = 0 ; i < 4 ; ++i ) | 128 | for ( int i = 0 ; i < 4 ; ++i ) |
127 | { | 129 | { |
128 | // OK, we have a local IPK file, I think the standard naming conventions | 130 | // OK, we have a local IPK file, I think the standard naming conventions |
129 | // for these are packagename_version_arm.ipk | 131 | // for these are packagename_version_arm.ipk |
130 | QString file = names[i]; | 132 | QString file = names[i]; |
131 | int p = file.find( "_" ); | 133 | int p = file.find( "_" ); |
132 | QString tmp = file.mid( 0, p ); | 134 | QString tmp = file.mid( 0, p ); |
133 | packageList.push_back( Package( tmp ) ); | 135 | packageList.push_back( Package( tmp ) ); |
134 | int p2 = file.find( "_", p+1 ); | 136 | int p2 = file.find( "_", p+1 ); |
135 | tmp = file.mid( p+1, p2-(p+1) ); | 137 | tmp = file.mid( p+1, p2-(p+1) ); |
136 | packageList.back().setVersion( tmp ); | 138 | packageList.back().setVersion( tmp ); |
137 | packageList.back().setPackageStoredLocally( true ); | 139 | packageList.back().setPackageStoredLocally( true ); |
138 | } | 140 | } |
139 | #endif | 141 | #endif |
140 | 142 | ||
141 | // build local packages | 143 | // build local packages |
142 | buildLocalPackages( local ); | 144 | buildLocalPackages( local ); |
143 | } | 145 | } |
144 | 146 | ||
145 | void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) | 147 | void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) |
146 | { | 148 | { |
147 | ifstream in( packageFile ); | 149 | ifstream in( packageFile ); |
148 | if ( !in.is_open() ) | 150 | if ( !in.is_open() ) |
149 | return; | 151 | return; |
150 | 152 | ||
151 | char line[1001]; | 153 | char line[1001]; |
152 | char k[21]; | 154 | char k[21]; |
153 | char v[1001]; | 155 | char v[1001]; |
154 | QString key; | 156 | QString key; |
155 | QString value; | 157 | QString value; |
156 | 158 | ||
157 | if ( clearAll ) | 159 | if ( clearAll ) |
158 | cleanUp(); | 160 | cleanUp(); |
159 | Package *currPackage = 0; | 161 | Package *currPackage = 0; |
160 | 162 | ||
161 | bool newPackage = true; | 163 | bool newPackage = true; |
162 | do | 164 | do |
163 | { | 165 | { |
164 | in.getline( line, 1000 ); | 166 | in.getline( line, 1000 ); |
165 | if ( in.eof() ) | 167 | if ( in.eof() ) |
166 | continue; | 168 | continue; |
167 | 169 | ||
168 | k[0] = '\0'; | 170 | k[0] = '\0'; |
169 | v[0] = '\0'; | 171 | v[0] = '\0'; |
170 | 172 | ||
171 | sscanf( line, "%[^:]: %[^\n]", k, v ); | 173 | sscanf( line, "%[^:]: %[^\n]", k, v ); |
172 | key = k; | 174 | key = k; |
173 | value = v; | 175 | value = v; |
174 | key = key.stripWhiteSpace(); | 176 | key = key.stripWhiteSpace(); |
175 | value = value.stripWhiteSpace(); | 177 | value = value.stripWhiteSpace(); |
176 | if ( key == "Package" && newPackage ) | 178 | if ( key == "Package" && newPackage ) |
177 | { | 179 | { |
178 | newPackage = false; | 180 | newPackage = false; |
179 | 181 | ||
180 | currPackage = getPackage( value ); | 182 | currPackage = getPackage( value ); |
181 | if ( !currPackage ) | 183 | if ( !currPackage ) |
182 | { | 184 | { |
183 | packageList.push_back( Package( value ) ); | 185 | Package *package = new Package( value ); |
184 | currPackage = &(packageList.back()); | 186 | packageList.append( package ); |
187 | currPackage = package; | ||
185 | currPackage->setInstalledTo( dest ); | 188 | currPackage->setInstalledTo( dest ); |
186 | |||
187 | if ( installingToRoot ) | 189 | if ( installingToRoot ) |
188 | currPackage->setInstalledToRoot( true ); | 190 | currPackage->setInstalledToRoot( true ); |
189 | } | 191 | } |
190 | else | 192 | else |
191 | { | 193 | { |
192 | if (currPackage->getStatus().find( "deinstall" ) != -1 ) | 194 | if (currPackage->getStatus().find( "deinstall" ) != -1 ) |
193 | currPackage->setInstalledTo( dest ); | 195 | currPackage->setInstalledTo( dest ); |
194 | } | 196 | } |
195 | } | 197 | } |
196 | else if ( key == "Version" ) | 198 | else if ( key == "Version" ) |
197 | { | 199 | { |
198 | if ( currPackage ) | 200 | if ( currPackage ) |
199 | currPackage->setVersion( value ); | 201 | currPackage->setVersion( value ); |
200 | } | 202 | } |
201 | else if ( key == "Status" ) | 203 | else if ( key == "Status" ) |
202 | { | 204 | { |
203 | if ( currPackage ) | 205 | if ( currPackage ) |
204 | currPackage->setStatus( value ); | 206 | currPackage->setStatus( value ); |
205 | } | 207 | } |
206 | else if ( key == "Description" ) | 208 | else if ( key == "Description" ) |
207 | { | 209 | { |
208 | if ( currPackage ) | 210 | if ( currPackage ) |
209 | currPackage->setDescription( value ); | 211 | currPackage->setDescription( value ); |
210 | } | 212 | } |
211 | else if ( key == "Filename" ) | 213 | else if ( key == "Filename" ) |
212 | { | 214 | { |
213 | if ( currPackage ) | 215 | if ( currPackage ) |
214 | currPackage->setFilename( value ); | 216 | currPackage->setFilename( value ); |
215 | } | 217 | } |
216 | else if ( key == "Size" ) | 218 | else if ( key == "Size" ) |
217 | { | 219 | { |
218 | if ( currPackage ) | 220 | if ( currPackage ) |
219 | currPackage->setPackageSize( value ); | 221 | currPackage->setPackageSize( value ); |
220 | } | 222 | } |
221 | else if ( key == "Section" ) | 223 | else if ( key == "Section" ) |
222 | { | 224 | { |
223 | if ( currPackage ) | 225 | if ( currPackage ) |
224 | currPackage->setSection( value ); | 226 | currPackage->setSection( value ); |
225 | 227 | ||
226 | DataManager::setAvailableCategories( value ); | 228 | DataManager::setAvailableCategories( value ); |
227 | } | 229 | } |
228 | else if ( key == "" ) | 230 | else if ( key == "" ) |
229 | { | 231 | { |
230 | newPackage = true; | 232 | newPackage = true; |
231 | } | 233 | } |
232 | } while ( !in.eof() ); | 234 | } while ( !in.eof() ); |
233 | 235 | ||
234 | in.close(); | 236 | in.close(); |
235 | 237 | ||
236 | // build local packages | 238 | // build local packages |
237 | buildLocalPackages( local ); | 239 | buildLocalPackages( local ); |
238 | } | 240 | } |
239 | 241 | ||
240 | void Server :: buildLocalPackages( Server *local ) | 242 | void Server :: buildLocalPackages( Server *local ) |
241 | { | 243 | { |
242 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) | 244 | Package *curr; |
245 | QListIterator<Package> it( packageList ); | ||
246 | for ( ; it.current(); ++it ) | ||
243 | { | 247 | { |
244 | QString name = packageList[i].getPackageName(); | 248 | curr = it.current(); |
249 | QString name = curr->getPackageName(); | ||
245 | 250 | ||
246 | // If the package name is an ipk name, then convert the filename to a package name | 251 | // If the package name is an ipk name, then convert the filename to a package name |
247 | if ( name.find( ".ipk" ) != -1 ) | 252 | if ( name.find( ".ipk" ) != -1 ) |
248 | name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); | 253 | name = Utils::getPackageNameFromIpkFilename( curr->getFilename() ); |
249 | 254 | ||
250 | if ( local ) | 255 | if ( local ) |
251 | { | 256 | { |
252 | Package *p = local->getPackage( name ); | 257 | Package *p = local->getPackage( name ); |
253 | packageList[i].setLocalPackage( p ); | 258 | curr->setLocalPackage( p ); |
254 | if ( p ) | 259 | if ( p ) |
255 | { | 260 | { |
256 | // Set some default stuff like size and things | 261 | // Set some default stuff like size and things |
257 | if ( p->getInstalledVersion() == packageList[i].getVersion() ) | 262 | if ( p->getInstalledVersion() == curr->getVersion() ) |
258 | { | 263 | { |
259 | p->setPackageSize( packageList[i].getPackageSize() ); | 264 | p->setPackageSize( curr->getPackageSize() ); |
260 | p->setSection( packageList[i].getSection() ); | 265 | p->setSection( curr->getSection() ); |
261 | p->setDescription( packageList[i].getDescription() ); | 266 | p->setDescription( curr->getDescription() ); |
262 | } | 267 | } |
263 | } | 268 | } |
264 | 269 | ||
265 | } | 270 | } |
266 | else | 271 | else |
267 | packageList[i].setLocalPackage( 0 ); | 272 | curr->setLocalPackage( 0 ); |
268 | } | 273 | } |
269 | 274 | ||
270 | } | 275 | } |
271 | 276 | ||
272 | Package *Server :: getPackage( QString &name ) | 277 | Package *Server :: getPackage( QString &name ) |
273 | { | 278 | { |
274 | return getPackage( (const char *)name ); | 279 | return getPackage( (const char *)name ); |
275 | } | 280 | } |
276 | 281 | ||
277 | Package *Server :: getPackage( const char *name ) | 282 | Package *Server :: getPackage( const char *name ) |
278 | { | 283 | { |
279 | Package *ret = 0; | 284 | Package *ret = 0; |
280 | 285 | ||
281 | for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) | 286 | QListIterator<Package> it( packageList ); |
287 | for ( ; it.current(); ++it ) | ||
282 | { | 288 | { |
283 | if ( packageList[i].getPackageName() == name ) | 289 | if ( it.current()->getPackageName() == name ) |
284 | ret = &packageList[i]; | 290 | ret = it.current(); |
285 | } | 291 | } |
286 | 292 | ||
287 | return ret; | 293 | return ret; |
288 | } | 294 | } |
289 | 295 | ||
290 | QString Server :: toString() | 296 | QString Server :: toString() |
291 | { | 297 | { |
292 | QString ret = "Server\n name - " + serverName + | 298 | QString ret = QString( "Server\n name - %1\n url - %2\n" ).arg( serverName ).arg( serverUrl ); |
293 | "\n url - " + serverUrl + | 299 | |
294 | "\n"; | 300 | QListIterator<Package> it( packageList ); |
295 | 301 | for ( ; it.current(); ++it ) | |
296 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) | 302 | { |
297 | ret += "\n " + packageList[i].toString(); | 303 | ret.append( QString( "\n %1" ).arg( it.current()->toString() ) ); |
304 | } | ||
298 | 305 | ||
299 | 306 | ||
300 | return ret; | 307 | return ret; |
301 | } | 308 | } |
302 | 309 | ||
303 | vector<Package> &Server::getPackageList() | 310 | QList<Package> &Server::getPackageList() |
304 | { | 311 | { |
305 | return packageList; | 312 | return packageList; |
306 | } | 313 | } |
307 | 314 | ||
diff --git a/noncore/settings/aqpkg/server.h b/noncore/settings/aqpkg/server.h index f585b8f..02746e0 100644 --- a/noncore/settings/aqpkg/server.h +++ b/noncore/settings/aqpkg/server.h | |||
@@ -1,66 +1,66 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | server.h - description | 2 | server.h - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 2002 | 4 | begin : Mon Aug 26 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 | #ifndef SERVER_H | 17 | #ifndef SERVER_H |
18 | #define SERVER_H | 18 | #define SERVER_H |
19 | 19 | ||
20 | #include <qlist.h> | ||
20 | #include <qstring.h> | 21 | #include <qstring.h> |
21 | 22 | ||
22 | #include <vector> | ||
23 | using namespace std; | 23 | using namespace std; |
24 | 24 | ||
25 | #include "package.h" | 25 | #include "package.h" |
26 | #include "destination.h" | 26 | #include "destination.h" |
27 | 27 | ||
28 | class Server | 28 | class Server |
29 | { | 29 | { |
30 | public: | 30 | public: |
31 | Server() {} | 31 | Server() {} |
32 | Server( const char *name, const char *url ); | 32 | Server( const char *name, const char *url ); |
33 | Server( const char *name, const char *url, const char *file ); | 33 | Server( const char *name, const char *url, const char *file ); |
34 | ~Server(); | 34 | ~Server(); |
35 | 35 | ||
36 | void cleanUp(); | 36 | void cleanUp(); |
37 | 37 | ||
38 | void readStatusFile( vector<Destination> &v ); | 38 | void readStatusFile( QList<Destination> &v ); |
39 | void readLocalIpks( Server *local ); | 39 | void readLocalIpks( Server *local ); |
40 | void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 ); | 40 | void readPackageFile( Server *local = 0, bool clearAll = true, bool installedToRoot= false, Destination *dest = 0 ); |
41 | void buildLocalPackages( Server *local ); | 41 | void buildLocalPackages( Server *local ); |
42 | Package *getPackage( const char *name ); | 42 | Package *getPackage( const char *name ); |
43 | Package *getPackage( QString &name ); | 43 | Package *getPackage( QString &name ); |
44 | QString toString(); | 44 | QString toString(); |
45 | vector<Package> &getPackageList(); | 45 | QList<Package> &getPackageList(); |
46 | bool isServerActive() { return active; } | 46 | bool isServerActive() { return active; } |
47 | 47 | ||
48 | void setServerName( const QString &name ) { serverName = name; } | 48 | void setServerName( const QString &name ) { serverName = name; } |
49 | void setServerUrl( const QString &url ) { serverUrl = url; } | 49 | void setServerUrl( const QString &url ) { serverUrl = url; } |
50 | void setActive( bool val ) { active = val; } | 50 | void setActive( bool val ) { active = val; } |
51 | QString &getServerName() { return serverName; } | 51 | QString &getServerName() { return serverName; } |
52 | QString &getServerUrl() { return serverUrl; } | 52 | QString &getServerUrl() { return serverUrl; } |
53 | 53 | ||
54 | protected: | 54 | protected: |
55 | 55 | ||
56 | private: | 56 | private: |
57 | QString serverName; | 57 | QString serverName; |
58 | QString serverUrl; | 58 | QString serverUrl; |
59 | QString packageFile; | 59 | QString packageFile; |
60 | bool active; | 60 | bool active; |
61 | 61 | ||
62 | 62 | ||
63 | vector<Package> packageList; | 63 | QList<Package> packageList; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | #endif | 66 | #endif |
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index c5a55d2..7541f0b 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -161,278 +161,280 @@ QWidget *SettingsImpl :: initDestinationTab() | |||
161 | connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); | 161 | connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); |
162 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); | 162 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); |
163 | 163 | ||
164 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 164 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
165 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); | 165 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); |
166 | layout->addWidget( btn, 1, 0 ); | 166 | layout->addWidget( btn, 1, 0 ); |
167 | 167 | ||
168 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 168 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
169 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); | 169 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); |
170 | layout->addWidget( btn, 1, 1 ); | 170 | layout->addWidget( btn, 1, 1 ); |
171 | 171 | ||
172 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); | 172 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); |
173 | grpbox->layout()->setSpacing( 2 ); | 173 | grpbox->layout()->setSpacing( 2 ); |
174 | grpbox->layout()->setMargin( 4 ); | 174 | grpbox->layout()->setMargin( 4 ); |
175 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 175 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
176 | 176 | ||
177 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 177 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
178 | 178 | ||
179 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 179 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
180 | grplayout->addWidget( label, 0, 0 ); | 180 | grplayout->addWidget( label, 0, 0 ); |
181 | destinationname = new QLineEdit( grpbox ); | 181 | destinationname = new QLineEdit( grpbox ); |
182 | grplayout->addWidget( destinationname, 0, 1 ); | 182 | grplayout->addWidget( destinationname, 0, 1 ); |
183 | 183 | ||
184 | label = new QLabel( tr( "Location:" ), grpbox ); | 184 | label = new QLabel( tr( "Location:" ), grpbox ); |
185 | grplayout->addWidget( label, 1, 0 ); | 185 | grplayout->addWidget( label, 1, 0 ); |
186 | destinationurl = new QLineEdit( grpbox ); | 186 | destinationurl = new QLineEdit( grpbox ); |
187 | grplayout->addWidget( destinationurl, 1, 1 ); | 187 | grplayout->addWidget( destinationurl, 1, 1 ); |
188 | 188 | ||
189 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); | 189 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); |
190 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); | 190 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); |
191 | 191 | ||
192 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 192 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
193 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); | 193 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); |
194 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 194 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
195 | 195 | ||
196 | return control; | 196 | return control; |
197 | } | 197 | } |
198 | 198 | ||
199 | QWidget *SettingsImpl :: initProxyTab() | 199 | QWidget *SettingsImpl :: initProxyTab() |
200 | { | 200 | { |
201 | QWidget *control = new QWidget( this ); | 201 | QWidget *control = new QWidget( this ); |
202 | 202 | ||
203 | QVBoxLayout *vb = new QVBoxLayout( control ); | 203 | QVBoxLayout *vb = new QVBoxLayout( control ); |
204 | 204 | ||
205 | QScrollView *sv = new QScrollView( control ); | 205 | QScrollView *sv = new QScrollView( control ); |
206 | vb->addWidget( sv, 0, 0 ); | 206 | vb->addWidget( sv, 0, 0 ); |
207 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 207 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
208 | sv->setFrameStyle( QFrame::NoFrame ); | 208 | sv->setFrameStyle( QFrame::NoFrame ); |
209 | 209 | ||
210 | QWidget *container = new QWidget( sv->viewport() ); | 210 | QWidget *container = new QWidget( sv->viewport() ); |
211 | sv->addChild( container ); | 211 | sv->addChild( container ); |
212 | 212 | ||
213 | QGridLayout *layout = new QGridLayout( container ); | 213 | QGridLayout *layout = new QGridLayout( container ); |
214 | layout->setSpacing( 2 ); | 214 | layout->setSpacing( 2 ); |
215 | layout->setMargin( 4 ); | 215 | layout->setMargin( 4 ); |
216 | 216 | ||
217 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 217 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
218 | grpbox->layout()->setSpacing( 2 ); | 218 | grpbox->layout()->setSpacing( 2 ); |
219 | grpbox->layout()->setMargin( 4 ); | 219 | grpbox->layout()->setMargin( 4 ); |
220 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 220 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
221 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 221 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
222 | txtHttpProxy = new QLineEdit( grpbox ); | 222 | txtHttpProxy = new QLineEdit( grpbox ); |
223 | grplayout->addWidget( txtHttpProxy ); | 223 | grplayout->addWidget( txtHttpProxy ); |
224 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 224 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
225 | grplayout->addWidget( chkHttpProxyEnabled ); | 225 | grplayout->addWidget( chkHttpProxyEnabled ); |
226 | 226 | ||
227 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 227 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
228 | grpbox->layout()->setSpacing( 2 ); | 228 | grpbox->layout()->setSpacing( 2 ); |
229 | grpbox->layout()->setMargin( 4 ); | 229 | grpbox->layout()->setMargin( 4 ); |
230 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 230 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
231 | grplayout = new QVBoxLayout( grpbox->layout() ); | 231 | grplayout = new QVBoxLayout( grpbox->layout() ); |
232 | txtFtpProxy = new QLineEdit( grpbox ); | 232 | txtFtpProxy = new QLineEdit( grpbox ); |
233 | grplayout->addWidget( txtFtpProxy ); | 233 | grplayout->addWidget( txtFtpProxy ); |
234 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 234 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
235 | grplayout->addWidget( chkFtpProxyEnabled ); | 235 | grplayout->addWidget( chkFtpProxyEnabled ); |
236 | 236 | ||
237 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 237 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
238 | layout->addWidget( label, 2, 0 ); | 238 | layout->addWidget( label, 2, 0 ); |
239 | txtUsername = new QLineEdit( container ); | 239 | txtUsername = new QLineEdit( container ); |
240 | layout->addWidget( txtUsername, 2, 1 ); | 240 | layout->addWidget( txtUsername, 2, 1 ); |
241 | 241 | ||
242 | label = new QLabel( tr( "Password:" ), container ); | 242 | label = new QLabel( tr( "Password:" ), container ); |
243 | layout->addWidget( label, 3, 0 ); | 243 | layout->addWidget( label, 3, 0 ); |
244 | txtPassword = new QLineEdit( container ); | 244 | txtPassword = new QLineEdit( container ); |
245 | layout->addWidget( txtPassword, 3, 1 ); | 245 | layout->addWidget( txtPassword, 3, 1 ); |
246 | 246 | ||
247 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); | 247 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); |
248 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); | 248 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); |
249 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); | 249 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); |
250 | 250 | ||
251 | return control; | 251 | return control; |
252 | } | 252 | } |
253 | 253 | ||
254 | void SettingsImpl :: setupData() | 254 | void SettingsImpl :: setupData() |
255 | { | 255 | { |
256 | // add servers | 256 | // add servers |
257 | vector<Server>::iterator it; | 257 | QString serverName; |
258 | for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it ) | 258 | QListIterator<Server> it( dataMgr->getServerList() ); |
259 | for ( ; it.current(); ++it ) | ||
259 | { | 260 | { |
260 | if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS ) | 261 | serverName = it.current()->getServerName(); |
262 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) | ||
261 | continue; | 263 | continue; |
262 | 264 | ||
263 | servers->insertItem( it->getServerName() ); | 265 | servers->insertItem( serverName ); |
264 | } | 266 | } |
265 | 267 | ||
266 | 268 | ||
267 | // add destinations | 269 | // add destinations |
268 | vector<Destination>::iterator it2; | 270 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); |
269 | for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 ) | 271 | for ( ; it2.current(); ++it2 ) |
270 | destinations->insertItem( it2->getDestinationName() ); | 272 | destinations->insertItem( it2.current()->getDestinationName() ); |
271 | 273 | ||
272 | // setup proxy tab | 274 | // setup proxy tab |
273 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); | 275 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); |
274 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); | 276 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); |
275 | txtUsername->setText( dataMgr->getProxyUsername() ); | 277 | txtUsername->setText( dataMgr->getProxyUsername() ); |
276 | txtPassword->setText( dataMgr->getProxyPassword() ); | 278 | txtPassword->setText( dataMgr->getProxyPassword() ); |
277 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); | 279 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); |
278 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); | 280 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); |
279 | } | 281 | } |
280 | 282 | ||
281 | //------------------ Servers tab ---------------------- | 283 | //------------------ Servers tab ---------------------- |
282 | 284 | ||
283 | void SettingsImpl :: editServer( int sel ) | 285 | void SettingsImpl :: editServer( int sel ) |
284 | { | 286 | { |
285 | currentSelectedServer = sel; | 287 | currentSelectedServer = sel; |
286 | vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); | 288 | Server *s = dataMgr->getServer( servers->currentText() ); |
287 | serverName = s->getServerName(); | 289 | serverName = s->getServerName(); |
288 | servername->setText( s->getServerName() ); | 290 | servername->setText( s->getServerName() ); |
289 | serverurl->setText( s->getServerUrl() ); | 291 | serverurl->setText( s->getServerUrl() ); |
290 | active->setChecked( s->isServerActive() ); | 292 | active->setChecked( s->isServerActive() ); |
291 | } | 293 | } |
292 | 294 | ||
293 | void SettingsImpl :: newServer() | 295 | void SettingsImpl :: newServer() |
294 | { | 296 | { |
295 | newserver = true; | 297 | newserver = true; |
296 | servername->setText( "" ); | 298 | servername->setText( "" ); |
297 | serverurl->setText( "" ); | 299 | serverurl->setText( "" ); |
298 | servername->setFocus(); | 300 | servername->setFocus(); |
299 | active->setChecked( true ); | 301 | active->setChecked( true ); |
300 | } | 302 | } |
301 | 303 | ||
302 | void SettingsImpl :: removeServer() | 304 | void SettingsImpl :: removeServer() |
303 | { | 305 | { |
304 | changed = true; | 306 | changed = true; |
305 | vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); | 307 | Server *s = dataMgr->getServer( servers->currentText() ); |
306 | dataMgr->getServerList().erase( s ); | 308 | dataMgr->getServerList().removeRef( s ); |
307 | servers->removeItem( currentSelectedServer ); | 309 | servers->removeItem( currentSelectedServer ); |
308 | } | 310 | } |
309 | 311 | ||
310 | void SettingsImpl :: changeServerDetails() | 312 | void SettingsImpl :: changeServerDetails() |
311 | { | 313 | { |
312 | changed = true; | 314 | changed = true; |
313 | 315 | ||
314 | QString newName = servername->text(); | 316 | QString newName = servername->text(); |
315 | if ( !newserver ) | 317 | if ( !newserver ) |
316 | { | 318 | { |
317 | vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); | 319 | Server *s = dataMgr->getServer( servers->currentText() ); |
318 | 320 | ||
319 | // Update url | 321 | // Update url |
320 | s->setServerUrl( serverurl->text() ); | 322 | s->setServerUrl( serverurl->text() ); |
321 | s->setActive( active->isChecked() ); | 323 | s->setActive( active->isChecked() ); |
322 | 324 | ||
323 | 325 | ||
324 | // Check if server name has changed, if it has then we need to replace the key in the map | 326 | // Check if server name has changed, if it has then we need to replace the key in the map |
325 | if ( serverName != newName ) | 327 | if ( serverName != newName ) |
326 | { | 328 | { |
327 | // Update server name | 329 | // Update server name |
328 | s->setServerName( newName ); | 330 | s->setServerName( newName ); |
329 | 331 | ||
330 | // See if this server is the active server | 332 | // See if this server is the active server |
331 | // if ( dataMgr->getActiveServer() == serverName ) | 333 | // if ( dataMgr->getActiveServer() == serverName ) |
332 | // dataMgr->setActiveServer( newName ); | 334 | // dataMgr->setActiveServer( newName ); |
333 | 335 | ||
334 | // Update list box | 336 | // Update list box |
335 | servers->changeItem( newName, currentSelectedServer ); | 337 | servers->changeItem( newName, currentSelectedServer ); |
336 | } | 338 | } |
337 | } | 339 | } |
338 | else | 340 | else |
339 | { | 341 | { |
340 | Server s( newName, serverurl->text() ); | 342 | Server s( newName, serverurl->text() ); |
341 | dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) ); | 343 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); |
342 | dataMgr->getServerList().end()->setActive( active->isChecked() ); | 344 | dataMgr->getServerList().last()->setActive( active->isChecked() ); |
343 | servers->insertItem( newName ); | 345 | servers->insertItem( newName ); |
344 | servers->setCurrentItem( servers->count() ); | 346 | servers->setCurrentItem( servers->count() ); |
345 | newserver = false; | 347 | newserver = false; |
346 | } | 348 | } |
347 | } | 349 | } |
348 | 350 | ||
349 | //------------------ Destinations tab ---------------------- | 351 | //------------------ Destinations tab ---------------------- |
350 | 352 | ||
351 | void SettingsImpl :: editDestination( int sel ) | 353 | void SettingsImpl :: editDestination( int sel ) |
352 | { | 354 | { |
353 | currentSelectedDestination = sel; | 355 | currentSelectedDestination = sel; |
354 | vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); | 356 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
355 | destinationName = d->getDestinationName(); | 357 | destinationName = d->getDestinationName(); |
356 | destinationname->setText( d->getDestinationName() ); | 358 | destinationname->setText( d->getDestinationName() ); |
357 | destinationurl->setText( d->getDestinationPath() ); | 359 | destinationurl->setText( d->getDestinationPath() ); |
358 | linkToRoot->setChecked( d->linkToRoot() ); | 360 | linkToRoot->setChecked( d->linkToRoot() ); |
359 | } | 361 | } |
360 | 362 | ||
361 | void SettingsImpl :: newDestination() | 363 | void SettingsImpl :: newDestination() |
362 | { | 364 | { |
363 | newdestination = true; | 365 | newdestination = true; |
364 | destinationname->setText( "" ); | 366 | destinationname->setText( "" ); |
365 | destinationurl->setText( "" ); | 367 | destinationurl->setText( "" ); |
366 | destinationname->setFocus(); | 368 | destinationname->setFocus(); |
367 | linkToRoot->setChecked( true ); | 369 | linkToRoot->setChecked( true ); |
368 | } | 370 | } |
369 | 371 | ||
370 | void SettingsImpl :: removeDestination() | 372 | void SettingsImpl :: removeDestination() |
371 | { | 373 | { |
372 | changed = true; | 374 | changed = true; |
373 | vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); | 375 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
374 | dataMgr->getDestinationList().erase( d ); | 376 | dataMgr->getDestinationList().removeRef( d ); |
375 | destinations->removeItem( currentSelectedDestination ); | 377 | destinations->removeItem( currentSelectedDestination ); |
376 | } | 378 | } |
377 | 379 | ||
378 | void SettingsImpl :: changeDestinationDetails() | 380 | void SettingsImpl :: changeDestinationDetails() |
379 | { | 381 | { |
380 | changed = true; | 382 | changed = true; |
381 | 383 | ||
382 | #ifdef QWS | 384 | #ifdef QWS |
383 | Config cfg( "aqpkg" ); | 385 | Config cfg( "aqpkg" ); |
384 | cfg.setGroup( "destinations" ); | 386 | cfg.setGroup( "destinations" ); |
385 | #endif | 387 | #endif |
386 | 388 | ||
387 | QString newName = destinationname->text(); | 389 | QString newName = destinationname->text(); |
388 | if ( !newdestination ) | 390 | if ( !newdestination ) |
389 | { | 391 | { |
390 | vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); | 392 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
391 | 393 | ||
392 | // Update url | 394 | // Update url |
393 | d->setDestinationPath( destinationurl->text() ); | 395 | d->setDestinationPath( destinationurl->text() ); |
394 | d->linkToRoot( linkToRoot->isChecked() ); | 396 | d->linkToRoot( linkToRoot->isChecked() ); |
395 | 397 | ||
396 | // Check if server name has changed, if it has then we need to replace the key in the map | 398 | // Check if server name has changed, if it has then we need to replace the key in the map |
397 | if ( destinationName != newName ) | 399 | if ( destinationName != newName ) |
398 | { | 400 | { |
399 | // Update server name | 401 | // Update server name |
400 | d->setDestinationName( newName ); | 402 | d->setDestinationName( newName ); |
401 | 403 | ||
402 | // Update list box | 404 | // Update list box |
403 | destinations->changeItem( newName, currentSelectedDestination ); | 405 | destinations->changeItem( newName, currentSelectedDestination ); |
404 | } | 406 | } |
405 | #ifdef QWS | 407 | #ifdef QWS |
406 | QString key = newName; | 408 | QString key = newName; |
407 | key += "_linkToRoot"; | 409 | key += "_linkToRoot"; |
408 | int val = d->linkToRoot(); | 410 | int val = d->linkToRoot(); |
409 | cfg.writeEntry( key, val ); | 411 | cfg.writeEntry( key, val ); |
410 | #endif | 412 | #endif |
411 | } | 413 | } |
412 | else | 414 | else |
413 | { | 415 | { |
414 | dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) ); | 416 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); |
415 | destinations->insertItem( newName ); | 417 | destinations->insertItem( newName ); |
416 | destinations->setCurrentItem( destinations->count() ); | 418 | destinations->setCurrentItem( destinations->count() ); |
417 | newdestination = false; | 419 | newdestination = false; |
418 | 420 | ||
419 | #ifdef QWS | 421 | #ifdef QWS |
420 | QString key = newName; | 422 | QString key = newName; |
421 | key += "_linkToRoot"; | 423 | key += "_linkToRoot"; |
422 | cfg.writeEntry( key, true ); | 424 | cfg.writeEntry( key, true ); |
423 | #endif | 425 | #endif |
424 | } | 426 | } |
425 | } | 427 | } |
426 | 428 | ||
427 | //------------------ Proxy tab ---------------------- | 429 | //------------------ Proxy tab ---------------------- |
428 | void SettingsImpl :: proxyApplyChanges() | 430 | void SettingsImpl :: proxyApplyChanges() |
429 | { | 431 | { |
430 | changed = true; | 432 | changed = true; |
431 | dataMgr->setHttpProxy( txtHttpProxy->text() ); | 433 | dataMgr->setHttpProxy( txtHttpProxy->text() ); |
432 | dataMgr->setFtpProxy( txtFtpProxy->text() ); | 434 | dataMgr->setFtpProxy( txtFtpProxy->text() ); |
433 | dataMgr->setProxyUsername( txtUsername->text() ); | 435 | dataMgr->setProxyUsername( txtUsername->text() ); |
434 | dataMgr->setProxyPassword( txtPassword->text() ); | 436 | dataMgr->setProxyPassword( txtPassword->text() ); |
435 | 437 | ||
436 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); | 438 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); |
437 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); | 439 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); |
438 | } | 440 | } |