author | andyq <andyq> | 2002-10-18 22:40:08 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-10-18 22:40:08 (UTC) |
commit | f899c1a0d216a1197c947a533d82085a02fed259 (patch) (unidiff) | |
tree | d0bf68d5fbf2021acc35973978e063cb6a8a5906 | |
parent | eea247f2664f0c70247399b2f4d969ddb00df7ba (diff) | |
download | opie-f899c1a0d216a1197c947a533d82085a02fed259.zip opie-f899c1a0d216a1197c947a533d82085a02fed259.tar.gz opie-f899c1a0d216a1197c947a533d82085a02fed259.tar.bz2 |
Added option to settings to show or hide Jump To letters
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 27 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 1 | ||||
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 23 | ||||
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.h | 2 |
4 files changed, 40 insertions, 13 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index ed5bf75..3aee7bd 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -1,558 +1,563 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | networkpkgmgr.cpp - description | 2 | networkpkgmgr.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 13:32:30 BST 2002 | 4 | begin : Mon Aug 26 13:32:30 BST 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <fstream> | 18 | #include <fstream> |
19 | #include <iostream> | 19 | #include <iostream> |
20 | using namespace std; | 20 | using namespace std; |
21 | 21 | ||
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <linux/limits.h> | 24 | #include <linux/limits.h> |
25 | 25 | ||
26 | #ifdef QWS | 26 | #ifdef QWS |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | #else | 30 | #else |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #endif | 32 | #endif |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | 36 | ||
37 | #include "datamgr.h" | 37 | #include "datamgr.h" |
38 | #include "networkpkgmgr.h" | 38 | #include "networkpkgmgr.h" |
39 | #include "installdlgimpl.h" | 39 | #include "installdlgimpl.h" |
40 | #include "ipkg.h" | 40 | #include "ipkg.h" |
41 | #include "inputdlg.h" | 41 | #include "inputdlg.h" |
42 | #include "letterpushbutton.h" | 42 | #include "letterpushbutton.h" |
43 | 43 | ||
44 | #include "global.h" | 44 | #include "global.h" |
45 | 45 | ||
46 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) | 46 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) |
47 | : QWidget(parent, name) | 47 | : QWidget(parent, name) |
48 | { | 48 | { |
49 | dataMgr = dataManager; | 49 | dataMgr = dataManager; |
50 | 50 | ||
51 | #ifdef QWS | 51 | #ifdef QWS |
52 | // read download directory from config file | 52 | // read download directory from config file |
53 | Config cfg( "aqpkg" ); | 53 | Config cfg( "aqpkg" ); |
54 | cfg.setGroup( "settings" ); | 54 | cfg.setGroup( "settings" ); |
55 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 55 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
56 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | ||
56 | #endif | 57 | #endif |
57 | 58 | ||
58 | 59 | ||
59 | initGui(); | 60 | initGui(); |
60 | setupConnections(); | 61 | setupConnections(); |
61 | 62 | ||
62 | progressDlg = 0; | 63 | progressDlg = 0; |
63 | timerId = startTimer( 100 ); | 64 | timerId = startTimer( 100 ); |
64 | } | 65 | } |
65 | 66 | ||
66 | NetworkPackageManager::~NetworkPackageManager() | 67 | NetworkPackageManager::~NetworkPackageManager() |
67 | { | 68 | { |
68 | } | 69 | } |
69 | 70 | ||
70 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) | 71 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) |
71 | { | 72 | { |
72 | killTimer( timerId ); | 73 | killTimer( timerId ); |
73 | 74 | ||
74 | // showProgressDialog(); | 75 | // showProgressDialog(); |
75 | // Add server names to listbox | 76 | // Add server names to listbox |
76 | updateData(); | 77 | updateData(); |
77 | 78 | ||
78 | // progressDlg->hide(); | 79 | // progressDlg->hide(); |
79 | } | 80 | } |
80 | 81 | ||
81 | void NetworkPackageManager :: updateData() | 82 | void NetworkPackageManager :: updateData() |
82 | { | 83 | { |
83 | serversList->clear(); | 84 | serversList->clear(); |
84 | packagesList->clear(); | 85 | packagesList->clear(); |
85 | 86 | ||
86 | 87 | ||
87 | vector<Server>::iterator it; | 88 | vector<Server>::iterator it; |
88 | int activeItem = -1; | 89 | int activeItem = -1; |
89 | int i; | 90 | int i; |
90 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) | 91 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) |
91 | { | 92 | { |
92 | if ( !it->isServerActive() ) | 93 | if ( !it->isServerActive() ) |
93 | { | 94 | { |
94 | i--; | 95 | i--; |
95 | continue; | 96 | continue; |
96 | } | 97 | } |
97 | serversList->insertItem( it->getServerName() ); | 98 | serversList->insertItem( it->getServerName() ); |
98 | if ( it->getServerName() == currentlySelectedServer ) | 99 | if ( it->getServerName() == currentlySelectedServer ) |
99 | activeItem = i; | 100 | activeItem = i; |
100 | } | 101 | } |
101 | 102 | ||
102 | // set selected server to be active server | 103 | // set selected server to be active server |
103 | if ( activeItem != -1 ) | 104 | if ( activeItem != -1 ) |
104 | serversList->setCurrentItem( activeItem ); | 105 | serversList->setCurrentItem( activeItem ); |
105 | serverSelected( 0 ); | 106 | serverSelected( 0 ); |
106 | } | 107 | } |
107 | 108 | ||
108 | 109 | ||
109 | void NetworkPackageManager :: initGui() | 110 | void NetworkPackageManager :: initGui() |
110 | { | 111 | { |
111 | QLabel *l = new QLabel( "Servers", this ); | 112 | QLabel *l = new QLabel( "Servers", this ); |
112 | serversList = new QComboBox( this ); | 113 | serversList = new QComboBox( this ); |
113 | packagesList = new QListView( this ); | 114 | packagesList = new QListView( this ); |
114 | update = new QPushButton( "Refresh List", this ); | 115 | update = new QPushButton( "Refresh List", this ); |
115 | download = new QPushButton( "Download", this ); | 116 | download = new QPushButton( "Download", this ); |
116 | upgrade = new QPushButton( "Upgrade", this ); | 117 | upgrade = new QPushButton( "Upgrade", this ); |
117 | apply = new QPushButton( "Apply", this ); | 118 | apply = new QPushButton( "Apply", this ); |
118 | 119 | ||
119 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); | 120 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); |
120 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); | 121 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); |
121 | hbox1->addWidget( l ); | 122 | hbox1->addWidget( l ); |
122 | hbox1->addWidget( serversList ); | 123 | hbox1->addWidget( serversList ); |
123 | 124 | ||
124 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); | 125 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); |
125 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); | 126 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); |
126 | 127 | ||
127 | char text[2]; | 128 | |
128 | text[1] = '\0'; | 129 | if ( showJumpTo ) |
129 | for ( int i = 0 ; i < 26 ; ++i ) | 130 | { |
130 | { | 131 | char text[2]; |
131 | text[0] = 'A' + i; | 132 | text[1] = '\0'; |
132 | LetterPushButton *b = new LetterPushButton( text, this ); | 133 | for ( int i = 0 ; i < 26 ; ++i ) |
133 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 134 | { |
134 | if ( i < 16 ) | 135 | text[0] = 'A' + i; |
135 | hbox3->addWidget( b ); | 136 | LetterPushButton *b = new LetterPushButton( text, this ); |
136 | else | 137 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
137 | hbox4->addWidget( b ); | 138 | if ( i < 16 ) |
139 | hbox3->addWidget( b ); | ||
140 | else | ||
141 | hbox4->addWidget( b ); | ||
142 | } | ||
138 | } | 143 | } |
139 | 144 | ||
140 | vbox->addWidget( packagesList ); | 145 | vbox->addWidget( packagesList ); |
141 | packagesList->addColumn( "Packages" ); | 146 | packagesList->addColumn( "Packages" ); |
142 | 147 | ||
143 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); | 148 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); |
144 | hbox2->addWidget( update ); | 149 | hbox2->addWidget( update ); |
145 | hbox2->addWidget( download ); | 150 | hbox2->addWidget( download ); |
146 | hbox2->addWidget( upgrade ); | 151 | hbox2->addWidget( upgrade ); |
147 | hbox2->addWidget( apply ); | 152 | hbox2->addWidget( apply ); |
148 | } | 153 | } |
149 | 154 | ||
150 | void NetworkPackageManager :: setupConnections() | 155 | void NetworkPackageManager :: setupConnections() |
151 | { | 156 | { |
152 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); | 157 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); |
153 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); | 158 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); |
154 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); | 159 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); |
155 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); | 160 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); |
156 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); | 161 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); |
157 | } | 162 | } |
158 | 163 | ||
159 | void NetworkPackageManager :: showProgressDialog( char *initialText ) | 164 | void NetworkPackageManager :: showProgressDialog( char *initialText ) |
160 | { | 165 | { |
161 | if ( !progressDlg ) | 166 | if ( !progressDlg ) |
162 | progressDlg = new ProgressDlg( this, "Progress", false ); | 167 | progressDlg = new ProgressDlg( this, "Progress", false ); |
163 | progressDlg->setText( initialText ); | 168 | progressDlg->setText( initialText ); |
164 | progressDlg->show(); | 169 | progressDlg->show(); |
165 | } | 170 | } |
166 | 171 | ||
167 | 172 | ||
168 | void NetworkPackageManager :: serverSelected( int ) | 173 | void NetworkPackageManager :: serverSelected( int ) |
169 | { | 174 | { |
170 | packagesList->clear(); | 175 | packagesList->clear(); |
171 | 176 | ||
172 | // display packages | 177 | // display packages |
173 | QString serverName = serversList->currentText(); | 178 | QString serverName = serversList->currentText(); |
174 | currentlySelectedServer = serverName; | 179 | currentlySelectedServer = serverName; |
175 | 180 | ||
176 | #ifdef QWS | 181 | #ifdef QWS |
177 | // read download directory from config file | 182 | // read download directory from config file |
178 | Config cfg( "aqpkg" ); | 183 | Config cfg( "aqpkg" ); |
179 | cfg.setGroup( "settings" ); | 184 | cfg.setGroup( "settings" ); |
180 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 185 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
181 | #endif | 186 | #endif |
182 | 187 | ||
183 | Server *s = dataMgr->getServer( serverName ); | 188 | Server *s = dataMgr->getServer( serverName ); |
184 | // dataMgr->setActiveServer( serverName ); | 189 | // dataMgr->setActiveServer( serverName ); |
185 | 190 | ||
186 | vector<Package> &list = s->getPackageList(); | 191 | vector<Package> &list = s->getPackageList(); |
187 | vector<Package>::iterator it; | 192 | vector<Package>::iterator it; |
188 | for ( it = list.begin() ; it != list.end() ; ++it ) | 193 | for ( it = list.begin() ; it != list.end() ; ++it ) |
189 | { | 194 | { |
190 | QString text = ""; | 195 | QString text = ""; |
191 | 196 | ||
192 | // If the local server, only display installed packages | 197 | // If the local server, only display installed packages |
193 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 198 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) |
194 | continue; | 199 | continue; |
195 | 200 | ||
196 | text += it->getPackageName(); | 201 | text += it->getPackageName(); |
197 | if ( it->isInstalled() ) | 202 | if ( it->isInstalled() ) |
198 | { | 203 | { |
199 | text += " (installed)"; | 204 | text += " (installed)"; |
200 | 205 | ||
201 | // If a different version of package is available, postfix it with an * | 206 | // If a different version of package is available, postfix it with an * |
202 | if ( it->getVersion() != it->getInstalledVersion() ) | 207 | if ( it->getVersion() != it->getInstalledVersion() ) |
203 | text += "*"; | 208 | text += "*"; |
204 | } | 209 | } |
205 | 210 | ||
206 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); | 211 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); |
207 | 212 | ||
208 | if ( it->isInstalled() ) | 213 | if ( it->isInstalled() ) |
209 | { | 214 | { |
210 | QString destName = ""; | 215 | QString destName = ""; |
211 | if ( it->getLocalPackage() ) | 216 | if ( it->getLocalPackage() ) |
212 | { | 217 | { |
213 | if ( it->getLocalPackage()->getInstalledTo() ) | 218 | if ( it->getLocalPackage()->getInstalledTo() ) |
214 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 219 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); |
215 | } | 220 | } |
216 | else | 221 | else |
217 | { | 222 | { |
218 | if ( it->getInstalledTo() ) | 223 | if ( it->getInstalledTo() ) |
219 | destName = it->getInstalledTo()->getDestinationName(); | 224 | destName = it->getInstalledTo()->getDestinationName(); |
220 | } | 225 | } |
221 | if ( destName != "" ) | 226 | if ( destName != "" ) |
222 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); | 227 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); |
223 | } | 228 | } |
224 | 229 | ||
225 | if ( !it->isPackageStoredLocally() ) | 230 | if ( !it->isPackageStoredLocally() ) |
226 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); | 231 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); |
227 | else | 232 | else |
228 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); | 233 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); |
229 | 234 | ||
230 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); | 235 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); |
231 | if ( it->getLocalPackage() ) | 236 | if ( it->getLocalPackage() ) |
232 | { | 237 | { |
233 | if ( it->isInstalled() ) | 238 | if ( it->isInstalled() ) |
234 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); | 239 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); |
235 | } | 240 | } |
236 | packagesList->insertItem( item ); | 241 | packagesList->insertItem( item ); |
237 | } | 242 | } |
238 | 243 | ||
239 | // If the local server or the local ipkgs server disable the download button | 244 | // If the local server or the local ipkgs server disable the download button |
240 | if ( serverName == LOCAL_SERVER ) | 245 | if ( serverName == LOCAL_SERVER ) |
241 | { | 246 | { |
242 | upgrade->setEnabled( false ); | 247 | upgrade->setEnabled( false ); |
243 | download->setText( "Download" ); | 248 | download->setText( "Download" ); |
244 | download->setEnabled( false ); | 249 | download->setEnabled( false ); |
245 | } | 250 | } |
246 | else if ( serverName == LOCAL_IPKGS ) | 251 | else if ( serverName == LOCAL_IPKGS ) |
247 | { | 252 | { |
248 | upgrade->setEnabled( false ); | 253 | upgrade->setEnabled( false ); |
249 | download->setEnabled( true ); | 254 | download->setEnabled( true ); |
250 | download->setText( "Remove" ); | 255 | download->setText( "Remove" ); |
251 | } | 256 | } |
252 | else | 257 | else |
253 | { | 258 | { |
254 | upgrade->setEnabled( true ); | 259 | upgrade->setEnabled( true ); |
255 | download->setEnabled( true ); | 260 | download->setEnabled( true ); |
256 | download->setText( "Download" ); | 261 | download->setText( "Download" ); |
257 | } | 262 | } |
258 | } | 263 | } |
259 | 264 | ||
260 | void NetworkPackageManager :: updateServer() | 265 | void NetworkPackageManager :: updateServer() |
261 | { | 266 | { |
262 | QString serverName = serversList->currentText(); | 267 | QString serverName = serversList->currentText(); |
263 | 268 | ||
264 | // Update the current server | 269 | // Update the current server |
265 | // Display dialog | 270 | // Display dialog |
266 | ProgressDlg *dlg = new ProgressDlg( this ); | 271 | ProgressDlg *dlg = new ProgressDlg( this ); |
267 | QString status = "Updating package lists..."; | 272 | QString status = "Updating package lists..."; |
268 | dlg->show(); | 273 | dlg->show(); |
269 | dlg->setText( status ); | 274 | dlg->setText( status ); |
270 | 275 | ||
271 | // Disable buttons to stop silly people clicking lots on them :) | 276 | // Disable buttons to stop silly people clicking lots on them :) |
272 | 277 | ||
273 | // First, write out ipkg_conf file so that ipkg can use it | 278 | // First, write out ipkg_conf file so that ipkg can use it |
274 | dataMgr->writeOutIpkgConf(); | 279 | dataMgr->writeOutIpkgConf(); |
275 | 280 | ||
276 | QString option = "update"; | 281 | QString option = "update"; |
277 | QString dummy = ""; | 282 | QString dummy = ""; |
278 | Ipkg ipkg; | 283 | Ipkg ipkg; |
279 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 284 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
280 | ipkg.setOption( option ); | 285 | ipkg.setOption( option ); |
281 | 286 | ||
282 | ipkg.runIpkg( ); | 287 | ipkg.runIpkg( ); |
283 | 288 | ||
284 | // Reload data | 289 | // Reload data |
285 | dataMgr->reloadServerData( serversList->currentText() ); | 290 | dataMgr->reloadServerData( serversList->currentText() ); |
286 | serverSelected(-1); | 291 | serverSelected(-1); |
287 | delete dlg; | 292 | delete dlg; |
288 | } | 293 | } |
289 | 294 | ||
290 | void NetworkPackageManager :: upgradePackages() | 295 | void NetworkPackageManager :: upgradePackages() |
291 | { | 296 | { |
292 | // We're gonna do an upgrade of all packages | 297 | // We're gonna do an upgrade of all packages |
293 | // First warn user that this isn't recommended | 298 | // First warn user that this isn't recommended |
294 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; | 299 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; |
295 | QMessageBox warn("Warning", text, QMessageBox::Warning, | 300 | QMessageBox warn("Warning", text, QMessageBox::Warning, |
296 | QMessageBox::Yes, | 301 | QMessageBox::Yes, |
297 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 302 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
298 | 0, this ); | 303 | 0, this ); |
299 | warn.adjustSize(); | 304 | warn.adjustSize(); |
300 | 305 | ||
301 | if ( warn.exec() == QMessageBox::Yes ) | 306 | if ( warn.exec() == QMessageBox::Yes ) |
302 | { | 307 | { |
303 | // First, write out ipkg_conf file so that ipkg can use it | 308 | // First, write out ipkg_conf file so that ipkg can use it |
304 | dataMgr->writeOutIpkgConf(); | 309 | dataMgr->writeOutIpkgConf(); |
305 | 310 | ||
306 | // Now run upgrade | 311 | // Now run upgrade |
307 | InstallDlgImpl dlg( this, "Upgrade", true ); | 312 | InstallDlgImpl dlg( this, "Upgrade", true ); |
308 | dlg.showDlg(); | 313 | dlg.showDlg(); |
309 | 314 | ||
310 | // Reload data | 315 | // Reload data |
311 | dataMgr->reloadServerData( LOCAL_SERVER ); | 316 | dataMgr->reloadServerData( LOCAL_SERVER ); |
312 | 317 | ||
313 | dataMgr->reloadServerData( serversList->currentText() ); | 318 | dataMgr->reloadServerData( serversList->currentText() ); |
314 | serverSelected(-1); | 319 | serverSelected(-1); |
315 | } | 320 | } |
316 | } | 321 | } |
317 | 322 | ||
318 | 323 | ||
319 | void NetworkPackageManager :: downloadPackage() | 324 | void NetworkPackageManager :: downloadPackage() |
320 | { | 325 | { |
321 | if ( download->text() == "Download" ) | 326 | if ( download->text() == "Download" ) |
322 | { | 327 | { |
323 | // First, write out ipkg_conf file so that ipkg can use it | 328 | // First, write out ipkg_conf file so that ipkg can use it |
324 | dataMgr->writeOutIpkgConf(); | 329 | dataMgr->writeOutIpkgConf(); |
325 | 330 | ||
326 | // Display dialog to user asking where to download the files to | 331 | // Display dialog to user asking where to download the files to |
327 | bool ok = FALSE; | 332 | bool ok = FALSE; |
328 | QString dir = ""; | 333 | QString dir = ""; |
329 | #ifdef QWS | 334 | #ifdef QWS |
330 | // read download directory from config file | 335 | // read download directory from config file |
331 | Config cfg( "aqpkg" ); | 336 | Config cfg( "aqpkg" ); |
332 | cfg.setGroup( "settings" ); | 337 | cfg.setGroup( "settings" ); |
333 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 338 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
334 | #endif | 339 | #endif |
335 | 340 | ||
336 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 341 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
337 | if ( ok && !text.isEmpty() ) | 342 | if ( ok && !text.isEmpty() ) |
338 | dir = text; // user entered something and pressed ok | 343 | dir = text; // user entered something and pressed ok |
339 | else | 344 | else |
340 | return; // user entered nothing or pressed cancel | 345 | return; // user entered nothing or pressed cancel |
341 | 346 | ||
342 | #ifdef QWS | 347 | #ifdef QWS |
343 | // Store download directory in config file | 348 | // Store download directory in config file |
344 | cfg.writeEntry( "downloadDir", dir ); | 349 | cfg.writeEntry( "downloadDir", dir ); |
345 | #endif | 350 | #endif |
346 | 351 | ||
347 | // Get starting directory | 352 | // Get starting directory |
348 | char initDir[PATH_MAX]; | 353 | char initDir[PATH_MAX]; |
349 | getcwd( initDir, PATH_MAX ); | 354 | getcwd( initDir, PATH_MAX ); |
350 | 355 | ||
351 | // Download each package | 356 | // Download each package |
352 | Ipkg ipkg; | 357 | Ipkg ipkg; |
353 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 358 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
354 | 359 | ||
355 | ipkg.setOption( "download" ); | 360 | ipkg.setOption( "download" ); |
356 | ipkg.setRuntimeDirectory( dir ); | 361 | ipkg.setRuntimeDirectory( dir ); |
357 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 362 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
358 | item != 0 ; | 363 | item != 0 ; |
359 | item = (QCheckListItem *)item->nextSibling() ) | 364 | item = (QCheckListItem *)item->nextSibling() ) |
360 | { | 365 | { |
361 | if ( item->isOn() ) | 366 | if ( item->isOn() ) |
362 | { | 367 | { |
363 | QString name = item->text(); | 368 | QString name = item->text(); |
364 | int pos = name.find( "*" ); | 369 | int pos = name.find( "*" ); |
365 | name.truncate( pos ); | 370 | name.truncate( pos ); |
366 | 371 | ||
367 | // if (there is a (installed), remove it | 372 | // if (there is a (installed), remove it |
368 | pos = name.find( "(installed)" ); | 373 | pos = name.find( "(installed)" ); |
369 | if ( pos > 0 ) | 374 | if ( pos > 0 ) |
370 | name.truncate( pos - 1 ); | 375 | name.truncate( pos - 1 ); |
371 | 376 | ||
372 | ipkg.setPackage( name ); | 377 | ipkg.setPackage( name ); |
373 | ipkg.runIpkg( ); | 378 | ipkg.runIpkg( ); |
374 | } | 379 | } |
375 | } | 380 | } |
376 | } | 381 | } |
377 | else if ( download->text() == "Remove" ) | 382 | else if ( download->text() == "Remove" ) |
378 | { | 383 | { |
379 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 384 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
380 | item != 0 ; | 385 | item != 0 ; |
381 | item = (QCheckListItem *)item->nextSibling() ) | 386 | item = (QCheckListItem *)item->nextSibling() ) |
382 | { | 387 | { |
383 | if ( item->isOn() ) | 388 | if ( item->isOn() ) |
384 | { | 389 | { |
385 | QString name = item->text(); | 390 | QString name = item->text(); |
386 | int pos = name.find( "*" ); | 391 | int pos = name.find( "*" ); |
387 | name.truncate( pos ); | 392 | name.truncate( pos ); |
388 | 393 | ||
389 | // if (there is a (installed), remove it | 394 | // if (there is a (installed), remove it |
390 | pos = name.find( "(installed)" ); | 395 | pos = name.find( "(installed)" ); |
391 | if ( pos > 0 ) | 396 | if ( pos > 0 ) |
392 | name.truncate( pos - 1 ); | 397 | name.truncate( pos - 1 ); |
393 | 398 | ||
394 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); | 399 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); |
395 | QFile f( p->getFilename() ); | 400 | QFile f( p->getFilename() ); |
396 | f.remove(); | 401 | f.remove(); |
397 | } | 402 | } |
398 | } | 403 | } |
399 | } | 404 | } |
400 | 405 | ||
401 | dataMgr->reloadServerData( LOCAL_IPKGS ); | 406 | dataMgr->reloadServerData( LOCAL_IPKGS ); |
402 | serverSelected( -1 ); | 407 | serverSelected( -1 ); |
403 | } | 408 | } |
404 | 409 | ||
405 | 410 | ||
406 | void NetworkPackageManager :: applyChanges() | 411 | void NetworkPackageManager :: applyChanges() |
407 | { | 412 | { |
408 | stickyOption = ""; | 413 | stickyOption = ""; |
409 | 414 | ||
410 | // First, write out ipkg_conf file so that ipkg can use it | 415 | // First, write out ipkg_conf file so that ipkg can use it |
411 | dataMgr->writeOutIpkgConf(); | 416 | dataMgr->writeOutIpkgConf(); |
412 | 417 | ||
413 | // Now for each selected item | 418 | // Now for each selected item |
414 | // deal with it | 419 | // deal with it |
415 | 420 | ||
416 | vector<InstallData> workingPackages; | 421 | vector<InstallData> workingPackages; |
417 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 422 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
418 | item != 0 ; | 423 | item != 0 ; |
419 | item = (QCheckListItem *)item->nextSibling() ) | 424 | item = (QCheckListItem *)item->nextSibling() ) |
420 | { | 425 | { |
421 | if ( item->isOn() ) | 426 | if ( item->isOn() ) |
422 | { | 427 | { |
423 | InstallData data = dealWithItem( item ); | 428 | InstallData data = dealWithItem( item ); |
424 | workingPackages.push_back( data ); | 429 | workingPackages.push_back( data ); |
425 | } | 430 | } |
426 | } | 431 | } |
427 | 432 | ||
428 | // do the stuff | 433 | // do the stuff |
429 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); | 434 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); |
430 | dlg.showDlg(); | 435 | dlg.showDlg(); |
431 | 436 | ||
432 | // Reload data | 437 | // Reload data |
433 | dataMgr->reloadServerData( LOCAL_SERVER ); | 438 | dataMgr->reloadServerData( LOCAL_SERVER ); |
434 | 439 | ||
435 | dataMgr->reloadServerData( serversList->currentText() ); | 440 | dataMgr->reloadServerData( serversList->currentText() ); |
436 | serverSelected(-1); | 441 | serverSelected(-1); |
437 | 442 | ||
438 | #ifdef QWS | 443 | #ifdef QWS |
439 | // Finally let the main system update itself | 444 | // Finally let the main system update itself |
440 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 445 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
441 | QString lf = QString::null; | 446 | QString lf = QString::null; |
442 | e << lf; | 447 | e << lf; |
443 | #endif | 448 | #endif |
444 | } | 449 | } |
445 | 450 | ||
446 | // decide what to do - either remove, upgrade or install | 451 | // decide what to do - either remove, upgrade or install |
447 | // Current rules: | 452 | // Current rules: |
448 | // If not installed - install | 453 | // If not installed - install |
449 | // If installed and different version available - upgrade | 454 | // If installed and different version available - upgrade |
450 | // If installed and version up to date - remove | 455 | // If installed and version up to date - remove |
451 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 456 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) |
452 | { | 457 | { |
453 | QString name = item->text(); | 458 | QString name = item->text(); |
454 | int pos = name.find( "*" ); | 459 | int pos = name.find( "*" ); |
455 | name.truncate( pos ); | 460 | name.truncate( pos ); |
456 | 461 | ||
457 | // if (there is a (installed), remove it | 462 | // if (there is a (installed), remove it |
458 | pos = name.find( "(installed)" ); | 463 | pos = name.find( "(installed)" ); |
459 | if ( pos > 0 ) | 464 | if ( pos > 0 ) |
460 | name.truncate( pos - 1 ); | 465 | name.truncate( pos - 1 ); |
461 | 466 | ||
462 | // Get package | 467 | // Get package |
463 | Server *s = dataMgr->getServer( serversList->currentText() ); | 468 | Server *s = dataMgr->getServer( serversList->currentText() ); |
464 | Package *p = s->getPackage( name ); | 469 | Package *p = s->getPackage( name ); |
465 | 470 | ||
466 | // If the package has a filename then it is a local file | 471 | // If the package has a filename then it is a local file |
467 | if ( p->isPackageStoredLocally() ) | 472 | if ( p->isPackageStoredLocally() ) |
468 | name = p->getFilename(); | 473 | name = p->getFilename(); |
469 | QString option; | 474 | QString option; |
470 | QString dest = "root"; | 475 | QString dest = "root"; |
471 | if ( !p->isInstalled() ) | 476 | if ( !p->isInstalled() ) |
472 | { | 477 | { |
473 | InstallData item; | 478 | InstallData item; |
474 | item.option = "I"; | 479 | item.option = "I"; |
475 | item.packageName = name; | 480 | item.packageName = name; |
476 | return item; | 481 | return item; |
477 | } | 482 | } |
478 | else | 483 | else |
479 | { | 484 | { |
480 | InstallData item; | 485 | InstallData item; |
481 | item.option = "D"; | 486 | item.option = "D"; |
482 | item.packageName = name; | 487 | item.packageName = name; |
483 | if ( p->getInstalledTo() ) | 488 | if ( p->getInstalledTo() ) |
484 | item.destination = p->getInstalledTo(); | 489 | item.destination = p->getInstalledTo(); |
485 | else | 490 | else |
486 | item.destination = p->getLocalPackage()->getInstalledTo(); | 491 | item.destination = p->getLocalPackage()->getInstalledTo(); |
487 | 492 | ||
488 | // Sticky option not implemented yet, but will eventually allow | 493 | // Sticky option not implemented yet, but will eventually allow |
489 | // the user to say something like 'remove all' | 494 | // the user to say something like 'remove all' |
490 | if ( stickyOption == "" ) | 495 | if ( stickyOption == "" ) |
491 | { | 496 | { |
492 | QString msgtext; | 497 | QString msgtext; |
493 | msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); | 498 | msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); |
494 | switch( QMessageBox::information( this, "Remove or ReInstall", | 499 | switch( QMessageBox::information( this, "Remove or ReInstall", |
495 | msgtext, "Remove", "ReInstall" ) ) | 500 | msgtext, "Remove", "ReInstall" ) ) |
496 | { | 501 | { |
497 | case 0: // Try again or Enter | 502 | case 0: // Try again or Enter |
498 | item.option = "D"; | 503 | item.option = "D"; |
499 | break; | 504 | break; |
500 | case 1: // Quit or Escape | 505 | case 1: // Quit or Escape |
501 | item.option = "U"; | 506 | item.option = "U"; |
502 | break; | 507 | break; |
503 | } | 508 | } |
504 | } | 509 | } |
505 | else | 510 | else |
506 | { | 511 | { |
507 | // item.option = stickyOption; | 512 | // item.option = stickyOption; |
508 | } | 513 | } |
509 | 514 | ||
510 | // Check if we are reinstalling the same version | 515 | // Check if we are reinstalling the same version |
511 | if ( p->getVersion() != p->getInstalledVersion() ) | 516 | if ( p->getVersion() != p->getInstalledVersion() ) |
512 | item.recreateLinks = true; | 517 | item.recreateLinks = true; |
513 | else | 518 | else |
514 | item.recreateLinks = false; | 519 | item.recreateLinks = false; |
515 | 520 | ||
516 | // User hit cancel (on dlg - assume remove) | 521 | // User hit cancel (on dlg - assume remove) |
517 | return item; | 522 | return item; |
518 | } | 523 | } |
519 | } | 524 | } |
520 | 525 | ||
521 | void NetworkPackageManager :: displayText( const QString &t ) | 526 | void NetworkPackageManager :: displayText( const QString &t ) |
522 | { | 527 | { |
523 | cout << t << endl; | 528 | cout << t << endl; |
524 | } | 529 | } |
525 | 530 | ||
526 | 531 | ||
527 | void NetworkPackageManager :: letterPushed( QString t ) | 532 | void NetworkPackageManager :: letterPushed( QString t ) |
528 | { | 533 | { |
529 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 534 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
530 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 535 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
531 | if ( packagesList->firstChild() == 0 ) | 536 | if ( packagesList->firstChild() == 0 ) |
532 | return; | 537 | return; |
533 | 538 | ||
534 | QCheckListItem *item; | 539 | QCheckListItem *item; |
535 | if ( start == 0 ) | 540 | if ( start == 0 ) |
536 | { | 541 | { |
537 | item = (QCheckListItem *)packagesList->firstChild(); | 542 | item = (QCheckListItem *)packagesList->firstChild(); |
538 | start = top; | 543 | start = top; |
539 | } | 544 | } |
540 | else | 545 | else |
541 | item = (QCheckListItem *)start->nextSibling(); | 546 | item = (QCheckListItem *)start->nextSibling(); |
542 | 547 | ||
543 | if ( item == 0 ) | 548 | if ( item == 0 ) |
544 | item = (QCheckListItem *)packagesList->firstChild(); | 549 | item = (QCheckListItem *)packagesList->firstChild(); |
545 | do | 550 | do |
546 | { | 551 | { |
547 | if ( item->text().lower().startsWith( t.lower() ) ) | 552 | if ( item->text().lower().startsWith( t.lower() ) ) |
548 | { | 553 | { |
549 | packagesList->setSelected( item, true ); | 554 | packagesList->setSelected( item, true ); |
550 | packagesList->ensureItemVisible( item ); | 555 | packagesList->ensureItemVisible( item ); |
551 | break; | 556 | break; |
552 | } | 557 | } |
553 | 558 | ||
554 | item = (QCheckListItem *)item->nextSibling(); | 559 | item = (QCheckListItem *)item->nextSibling(); |
555 | if ( !item ) | 560 | if ( !item ) |
556 | item = (QCheckListItem *)packagesList->firstChild(); | 561 | item = (QCheckListItem *)packagesList->firstChild(); |
557 | } while ( item != start); | 562 | } while ( item != start); |
558 | } | 563 | } |
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h index 7efa42c..fba8155 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.h +++ b/noncore/settings/aqpkg/networkpkgmgr.h | |||
@@ -1,76 +1,77 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | networkpkgmgr.h - description | 2 | networkpkgmgr.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 NETWORKPKGMGR_H | 18 | #ifndef NETWORKPKGMGR_H |
19 | #define NETWORKPKGMGR_H | 19 | #define NETWORKPKGMGR_H |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | 26 | ||
27 | #include "datamgr.h" | 27 | #include "datamgr.h" |
28 | #include "progressdlg.h" | 28 | #include "progressdlg.h" |
29 | class InstallData; | 29 | class InstallData; |
30 | 30 | ||
31 | /** NetworkPackageManager is the base class of the project */ | 31 | /** NetworkPackageManager is the base class of the project */ |
32 | class NetworkPackageManager : public QWidget | 32 | class NetworkPackageManager : public QWidget |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | /** construtor */ | 36 | /** construtor */ |
37 | NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); | 37 | NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); |
38 | /** destructor */ | 38 | /** destructor */ |
39 | ~NetworkPackageManager(); | 39 | ~NetworkPackageManager(); |
40 | 40 | ||
41 | void updateData(); | 41 | void updateData(); |
42 | 42 | ||
43 | private: | 43 | private: |
44 | DataManager *dataMgr; | 44 | DataManager *dataMgr; |
45 | 45 | ||
46 | QComboBox *serversList; | 46 | QComboBox *serversList; |
47 | QListView *packagesList; | 47 | QListView *packagesList; |
48 | QPushButton *update; | 48 | QPushButton *update; |
49 | QPushButton *upgrade; | 49 | QPushButton *upgrade; |
50 | QPushButton *download; | 50 | QPushButton *download; |
51 | QPushButton *apply; | 51 | QPushButton *apply; |
52 | 52 | ||
53 | ProgressDlg *progressDlg; | 53 | ProgressDlg *progressDlg; |
54 | QString currentlySelectedServer; | 54 | QString currentlySelectedServer; |
55 | 55 | ||
56 | bool showJumpTo; | ||
56 | int timerId; | 57 | int timerId; |
57 | 58 | ||
58 | void timerEvent ( QTimerEvent * ); | 59 | void timerEvent ( QTimerEvent * ); |
59 | 60 | ||
60 | void initGui(); | 61 | void initGui(); |
61 | void setupConnections(); | 62 | void setupConnections(); |
62 | void showProgressDialog( char *initialText ); | 63 | void showProgressDialog( char *initialText ); |
63 | InstallData dealWithItem( QCheckListItem *item ); | 64 | InstallData dealWithItem( QCheckListItem *item ); |
64 | QString stickyOption; | 65 | QString stickyOption; |
65 | 66 | ||
66 | public slots: | 67 | public slots: |
67 | void serverSelected( int index ); | 68 | void serverSelected( int index ); |
68 | void applyChanges(); | 69 | void applyChanges(); |
69 | void upgradePackages(); | 70 | void upgradePackages(); |
70 | void downloadPackage(); | 71 | void downloadPackage(); |
71 | void updateServer(); | 72 | void updateServer(); |
72 | void displayText( const QString &t ); | 73 | void displayText( const QString &t ); |
73 | void letterPushed( QString t ); | 74 | void letterPushed( QString t ); |
74 | }; | 75 | }; |
75 | 76 | ||
76 | #endif | 77 | #endif |
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index 9ee3a33..a18a178 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -1,226 +1,245 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | settingsimpl.cpp - description | 2 | settingsimpl.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 | 17 | ||
18 | #include <fstream> | 18 | #include <fstream> |
19 | using namespace std; | 19 | using namespace std; |
20 | 20 | ||
21 | #include <qlistbox.h> | 21 | #include <qlistbox.h> |
22 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
23 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qtabwidget.h> | 24 | #include <qtabwidget.h> |
25 | #include <qcheckbox.h> | 25 | #include <qcheckbox.h> |
26 | 26 | ||
27 | #ifdef QWS | 27 | #ifdef QWS |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #include "settingsimpl.h" | 31 | #include "settingsimpl.h" |
32 | 32 | ||
33 | #include "global.h" | 33 | #include "global.h" |
34 | 34 | ||
35 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 35 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) |
36 | : SettingsBase( parent, name, modal, fl ) | 36 | : SettingsBase( parent, name, modal, fl ) |
37 | { | 37 | { |
38 | dataMgr = dataManager; | 38 | dataMgr = dataManager; |
39 | 39 | ||
40 | setupData(); | 40 | setupData(); |
41 | changed = false; | 41 | changed = false; |
42 | newserver = false; | 42 | newserver = false; |
43 | newdestination = false; | 43 | newdestination = false; |
44 | } | 44 | } |
45 | 45 | ||
46 | SettingsImpl :: ~SettingsImpl() | 46 | SettingsImpl :: ~SettingsImpl() |
47 | { | 47 | { |
48 | 48 | ||
49 | } | 49 | } |
50 | 50 | ||
51 | bool SettingsImpl :: showDlg( int i ) | 51 | bool SettingsImpl :: showDlg( int i ) |
52 | { | 52 | { |
53 | TabWidget->setCurrentPage( i ); | 53 | TabWidget->setCurrentPage( i ); |
54 | showMaximized(); | 54 | showMaximized(); |
55 | exec(); | 55 | exec(); |
56 | 56 | ||
57 | if ( changed ) | 57 | if ( changed ) |
58 | dataMgr->writeOutIpkgConf(); | 58 | dataMgr->writeOutIpkgConf(); |
59 | 59 | ||
60 | return changed; | 60 | return changed; |
61 | } | 61 | } |
62 | 62 | ||
63 | void SettingsImpl :: setupData() | 63 | void SettingsImpl :: setupData() |
64 | { | 64 | { |
65 | // add servers | 65 | // add servers |
66 | vector<Server>::iterator it; | 66 | vector<Server>::iterator it; |
67 | for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it ) | 67 | for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it ) |
68 | { | 68 | { |
69 | if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS ) | 69 | if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS ) |
70 | continue; | 70 | continue; |
71 | 71 | ||
72 | servers->insertItem( it->getServerName() ); | 72 | servers->insertItem( it->getServerName() ); |
73 | } | 73 | } |
74 | 74 | ||
75 | // add destinations | 75 | // add destinations |
76 | vector<Destination>::iterator it2; | 76 | vector<Destination>::iterator it2; |
77 | for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 ) | 77 | for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 ) |
78 | destinations->insertItem( it2->getDestinationName() ); | 78 | destinations->insertItem( it2->getDestinationName() ); |
79 | 79 | ||
80 | #ifdef QWS | ||
81 | Config cfg( "aqpkg" ); | ||
82 | cfg.setGroup( "settings" ); | ||
83 | jumpTo->setChecked( cfg.readBoolEntry( "showJumpTo", "true" ) ); | ||
84 | #else | ||
85 | jumpTo->setChecked( true ); | ||
86 | #endif | ||
80 | } | 87 | } |
81 | 88 | ||
82 | //------------------ Servers tab ---------------------- | 89 | //------------------ Servers tab ---------------------- |
83 | 90 | ||
84 | void SettingsImpl :: editServer( int sel ) | 91 | void SettingsImpl :: editServer( int sel ) |
85 | { | 92 | { |
86 | currentSelectedServer = sel; | 93 | currentSelectedServer = sel; |
87 | Server *s = dataMgr->getServer( servers->currentText() ); | 94 | Server *s = dataMgr->getServer( servers->currentText() ); |
88 | serverName = s->getServerName(); | 95 | serverName = s->getServerName(); |
89 | servername->setText( s->getServerName() ); | 96 | servername->setText( s->getServerName() ); |
90 | serverurl->setText( s->getServerUrl() ); | 97 | serverurl->setText( s->getServerUrl() ); |
91 | active->setChecked( s->isServerActive() ); | 98 | active->setChecked( s->isServerActive() ); |
92 | } | 99 | } |
93 | 100 | ||
94 | void SettingsImpl :: newServer() | 101 | void SettingsImpl :: newServer() |
95 | { | 102 | { |
96 | newserver = true; | 103 | newserver = true; |
97 | servername->setText( "" ); | 104 | servername->setText( "" ); |
98 | serverurl->setText( "" ); | 105 | serverurl->setText( "" ); |
99 | servername->setFocus(); | 106 | servername->setFocus(); |
100 | active->setChecked( true ); | 107 | active->setChecked( true ); |
101 | } | 108 | } |
102 | 109 | ||
103 | void SettingsImpl :: removeServer() | 110 | void SettingsImpl :: removeServer() |
104 | { | 111 | { |
105 | changed = true; | 112 | changed = true; |
106 | Server *s = dataMgr->getServer( servers->currentText() ); | 113 | Server *s = dataMgr->getServer( servers->currentText() ); |
107 | dataMgr->getServerList().erase( s ); | 114 | dataMgr->getServerList().erase( s ); |
108 | servers->removeItem( currentSelectedServer ); | 115 | servers->removeItem( currentSelectedServer ); |
109 | } | 116 | } |
110 | 117 | ||
111 | void SettingsImpl :: changeServerDetails() | 118 | void SettingsImpl :: changeServerDetails() |
112 | { | 119 | { |
113 | changed = true; | 120 | changed = true; |
114 | 121 | ||
115 | QString newName = servername->text(); | 122 | QString newName = servername->text(); |
116 | if ( !newserver ) | 123 | if ( !newserver ) |
117 | { | 124 | { |
118 | Server *s = dataMgr->getServer( serverName ); | 125 | Server *s = dataMgr->getServer( serverName ); |
119 | 126 | ||
120 | // Update url | 127 | // Update url |
121 | s->setServerUrl( serverurl->text() ); | 128 | s->setServerUrl( serverurl->text() ); |
122 | s->setActive( active->isChecked() ); | 129 | s->setActive( active->isChecked() ); |
123 | 130 | ||
124 | 131 | ||
125 | // Check if server name has changed, if it has then we need to replace the key in the map | 132 | // Check if server name has changed, if it has then we need to replace the key in the map |
126 | if ( serverName != newName ) | 133 | if ( serverName != newName ) |
127 | { | 134 | { |
128 | // Update server name | 135 | // Update server name |
129 | s->setServerName( newName ); | 136 | s->setServerName( newName ); |
130 | 137 | ||
131 | // See if this server is the active server | 138 | // See if this server is the active server |
132 | // if ( dataMgr->getActiveServer() == serverName ) | 139 | // if ( dataMgr->getActiveServer() == serverName ) |
133 | // dataMgr->setActiveServer( newName ); | 140 | // dataMgr->setActiveServer( newName ); |
134 | 141 | ||
135 | // Update list box | 142 | // Update list box |
136 | servers->changeItem( newName, currentSelectedServer ); | 143 | servers->changeItem( newName, currentSelectedServer ); |
137 | } | 144 | } |
138 | } | 145 | } |
139 | else | 146 | else |
140 | { | 147 | { |
141 | Server s( newName, serverurl->text() ); | 148 | Server s( newName, serverurl->text() ); |
142 | dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) ); | 149 | dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) ); |
143 | dataMgr->getServerList().end()->setActive( active->isChecked() ); | 150 | dataMgr->getServerList().end()->setActive( active->isChecked() ); |
144 | servers->insertItem( newName ); | 151 | servers->insertItem( newName ); |
145 | servers->setCurrentItem( servers->count() ); | 152 | servers->setCurrentItem( servers->count() ); |
146 | newserver = false; | 153 | newserver = false; |
147 | } | 154 | } |
148 | } | 155 | } |
149 | 156 | ||
150 | //------------------ Destinations tab ---------------------- | 157 | //------------------ Destinations tab ---------------------- |
151 | 158 | ||
152 | void SettingsImpl :: editDestination( int sel ) | 159 | void SettingsImpl :: editDestination( int sel ) |
153 | { | 160 | { |
154 | currentSelectedDestination = sel; | 161 | currentSelectedDestination = sel; |
155 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 162 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
156 | destinationName = d->getDestinationName(); | 163 | destinationName = d->getDestinationName(); |
157 | destinationname->setText( d->getDestinationName() ); | 164 | destinationname->setText( d->getDestinationName() ); |
158 | destinationurl->setText( d->getDestinationPath() ); | 165 | destinationurl->setText( d->getDestinationPath() ); |
159 | linkToRoot->setChecked( d->linkToRoot() ); | 166 | linkToRoot->setChecked( d->linkToRoot() ); |
160 | } | 167 | } |
161 | 168 | ||
162 | void SettingsImpl :: newDestination() | 169 | void SettingsImpl :: newDestination() |
163 | { | 170 | { |
164 | newdestination = true; | 171 | newdestination = true; |
165 | destinationname->setText( "" ); | 172 | destinationname->setText( "" ); |
166 | destinationurl->setText( "" ); | 173 | destinationurl->setText( "" ); |
167 | destinationname->setFocus(); | 174 | destinationname->setFocus(); |
168 | linkToRoot->setChecked( true ); | 175 | linkToRoot->setChecked( true ); |
169 | } | 176 | } |
170 | 177 | ||
171 | void SettingsImpl :: removeDestination() | 178 | void SettingsImpl :: removeDestination() |
172 | { | 179 | { |
173 | changed = true; | 180 | changed = true; |
174 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 181 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
175 | dataMgr->getDestinationList().erase( d ); | 182 | dataMgr->getDestinationList().erase( d ); |
176 | destinations->removeItem( currentSelectedDestination ); | 183 | destinations->removeItem( currentSelectedDestination ); |
177 | } | 184 | } |
178 | 185 | ||
179 | void SettingsImpl :: changeDestinationDetails() | 186 | void SettingsImpl :: changeDestinationDetails() |
180 | { | 187 | { |
181 | changed = true; | 188 | changed = true; |
182 | 189 | ||
183 | #ifdef QWS | 190 | #ifdef QWS |
184 | Config cfg( "aqpkg" ); | 191 | Config cfg( "aqpkg" ); |
185 | cfg.setGroup( "destinations" ); | 192 | cfg.setGroup( "destinations" ); |
186 | #endif | 193 | #endif |
187 | 194 | ||
188 | QString newName = destinationname->text(); | 195 | QString newName = destinationname->text(); |
189 | if ( !newdestination ) | 196 | if ( !newdestination ) |
190 | { | 197 | { |
191 | Destination *d = dataMgr->getDestination( destinationName ); | 198 | Destination *d = dataMgr->getDestination( destinationName ); |
192 | 199 | ||
193 | // Update url | 200 | // Update url |
194 | d->setDestinationPath( destinationurl->text() ); | 201 | d->setDestinationPath( destinationurl->text() ); |
195 | d->linkToRoot( linkToRoot->isChecked() ); | 202 | d->linkToRoot( linkToRoot->isChecked() ); |
196 | 203 | ||
197 | // Check if server name has changed, if it has then we need to replace the key in the map | 204 | // Check if server name has changed, if it has then we need to replace the key in the map |
198 | if ( destinationName != newName ) | 205 | if ( destinationName != newName ) |
199 | { | 206 | { |
200 | // Update server name | 207 | // Update server name |
201 | d->setDestinationName( newName ); | 208 | d->setDestinationName( newName ); |
202 | 209 | ||
203 | // Update list box | 210 | // Update list box |
204 | destinations->changeItem( newName, currentSelectedDestination ); | 211 | destinations->changeItem( newName, currentSelectedDestination ); |
205 | } | 212 | } |
206 | #ifdef QWS | 213 | #ifdef QWS |
207 | QString key = newName; | 214 | QString key = newName; |
208 | key += "_linkToRoot"; | 215 | key += "_linkToRoot"; |
209 | int val = d->linkToRoot(); | 216 | int val = d->linkToRoot(); |
210 | cfg.writeEntry( key, val ); | 217 | cfg.writeEntry( key, val ); |
211 | #endif | 218 | #endif |
212 | } | 219 | } |
213 | else | 220 | else |
214 | { | 221 | { |
215 | dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) ); | 222 | dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) ); |
216 | destinations->insertItem( newName ); | 223 | destinations->insertItem( newName ); |
217 | destinations->setCurrentItem( destinations->count() ); | 224 | destinations->setCurrentItem( destinations->count() ); |
218 | newdestination = false; | 225 | newdestination = false; |
219 | 226 | ||
220 | #ifdef QWS | 227 | #ifdef QWS |
221 | QString key = newName; | 228 | QString key = newName; |
222 | key += "_linkToRoot"; | 229 | key += "_linkToRoot"; |
223 | cfg.writeEntry( key, true ); | 230 | cfg.writeEntry( key, true ); |
224 | #endif | 231 | #endif |
225 | } | 232 | } |
226 | } | 233 | } |
234 | |||
235 | //------------------ General tab ---------------------- | ||
236 | |||
237 | void SettingsImpl :: toggleJumpTo( bool val ) | ||
238 | { | ||
239 | #ifdef QWS | ||
240 | Config cfg( "aqpkg" ); | ||
241 | cfg.setGroup( "settings" ); | ||
242 | cfg.writeEntry( "showJumpTo", val ); | ||
243 | #endif | ||
244 | } | ||
245 | |||
diff --git a/noncore/settings/aqpkg/settingsimpl.h b/noncore/settings/aqpkg/settingsimpl.h index bc231a1..971516b 100644 --- a/noncore/settings/aqpkg/settingsimpl.h +++ b/noncore/settings/aqpkg/settingsimpl.h | |||
@@ -1,52 +1,54 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | settingsimpl.h - description | 2 | settingsimpl.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 | #include "settings.h" | 18 | #include "settings.h" |
19 | 19 | ||
20 | #include "datamgr.h" | 20 | #include "datamgr.h" |
21 | 21 | ||
22 | class SettingsImpl : public SettingsBase | 22 | class SettingsImpl : public SettingsBase |
23 | { | 23 | { |
24 | public: | 24 | public: |
25 | SettingsImpl( DataManager *dataManager, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 25 | SettingsImpl( DataManager *dataManager, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
26 | ~SettingsImpl(); | 26 | ~SettingsImpl(); |
27 | 27 | ||
28 | bool showDlg( int i ); | 28 | bool showDlg( int i ); |
29 | 29 | ||
30 | private: | 30 | private: |
31 | DataManager *dataMgr; | 31 | DataManager *dataMgr; |
32 | QString serverName; | 32 | QString serverName; |
33 | QString destinationName; | 33 | QString destinationName; |
34 | int currentSelectedServer; | 34 | int currentSelectedServer; |
35 | int currentSelectedDestination; | 35 | int currentSelectedDestination; |
36 | bool changed; | 36 | bool changed; |
37 | bool newserver; | 37 | bool newserver; |
38 | bool newdestination; | 38 | bool newdestination; |
39 | 39 | ||
40 | void setupConnections(); | 40 | void setupConnections(); |
41 | void setupData(); | 41 | void setupData(); |
42 | 42 | ||
43 | void editServer( int s ); | 43 | void editServer( int s ); |
44 | void changeServerDetails(); | 44 | void changeServerDetails(); |
45 | void newServer(); | 45 | void newServer(); |
46 | void removeServer(); | 46 | void removeServer(); |
47 | 47 | ||
48 | void editDestination( int s ); | 48 | void editDestination( int s ); |
49 | void changeDestinationDetails(); | 49 | void changeDestinationDetails(); |
50 | void newDestination(); | 50 | void newDestination(); |
51 | void removeDestination(); | 51 | void removeDestination(); |
52 | |||
53 | void toggleJumpTo( bool val ); | ||
52 | }; | 54 | }; |