Diffstat (limited to 'noncore/unsupported/oipkg/pksettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pksettings.cpp | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/noncore/unsupported/oipkg/pksettings.cpp b/noncore/unsupported/oipkg/pksettings.cpp index be01837..6c8dc2a 100644 --- a/noncore/unsupported/oipkg/pksettings.cpp +++ b/noncore/unsupported/oipkg/pksettings.cpp | |||
@@ -22,24 +22,25 @@ | |||
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | #include <qregexp.h> | 23 | #include <qregexp.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | #include <qtextview.h> | 27 | #include <qtextview.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include "debug.h" | 33 | #include "debug.h" |
34 | //#include "utils.h" | ||
34 | 35 | ||
35 | PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) | 36 | PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) |
36 | : PackageManagerSettingsBase( parent, name, fl ) | 37 | : PackageManagerSettingsBase( parent, name, fl ) |
37 | { | 38 | { |
38 | connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); | 39 | connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); |
39 | connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); | 40 | connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); |
40 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 41 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
41 | connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) ); | 42 | connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) ); |
42 | connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) ); | 43 | connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) ); |
43 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 44 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
44 | // connect( CheckBoxLink, SIGNAL(toggled(bool)), | 45 | // connect( CheckBoxLink, SIGNAL(toggled(bool)), |
45 | // activeLinkDestination, SLOT(setEnabled(bool)) ); | 46 | // activeLinkDestination, SLOT(setEnabled(bool)) ); |
@@ -47,161 +48,174 @@ PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* na | |||
47 | connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); | 48 | connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); |
48 | connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) ); | 49 | connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) ); |
49 | connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); | 50 | connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); |
50 | connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); | 51 | connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); |
51 | connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); | 52 | connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); |
52 | servername->setEnabled(FALSE); | 53 | servername->setEnabled(FALSE); |
53 | serverurl->setEnabled(FALSE); | 54 | serverurl->setEnabled(FALSE); |
54 | serverurlDic.setAutoDelete(TRUE); | 55 | serverurlDic.setAutoDelete(TRUE); |
55 | destinationname->setEnabled(FALSE); | 56 | destinationname->setEnabled(FALSE); |
56 | destinationurl->setEnabled(FALSE); | 57 | destinationurl->setEnabled(FALSE); |
57 | destinationurlDic.setAutoDelete(TRUE); | 58 | destinationurlDic.setAutoDelete(TRUE); |
58 | readSettings(); | 59 | readSettings(); |
60 | activeLinkDestination->hide(); | ||
59 | } | 61 | } |
60 | 62 | ||
61 | PackageManagerSettings::~PackageManagerSettings() | 63 | PackageManagerSettings::~PackageManagerSettings() |
62 | { | 64 | { |
63 | } | 65 | } |
64 | 66 | ||
65 | 67 | ||
66 | void PackageManagerSettings::newServer() | 68 | void PackageManagerSettings::newServer() |
67 | { | 69 | { |
68 | int i = servers->count(); | 70 | int i = servers->count(); |
69 | if ( servername->isEnabled() || serverurl->text().isEmpty() ) { | 71 | if ( servername->isEnabled() || serverurl->text().isEmpty() ) { |
70 | serverurlDic.insert(i,new QString("http://")); | 72 | serverurlDic.insert(i,new QString("http://")); |
71 | servers->insertItem(tr("New")); | 73 | servers->insertItem(tr("New")); |
72 | activeServers->insertItem(tr("New")); | 74 | activeServers->insertItem(tr("New")); |
73 | } else { | 75 | } else { |
74 | // allows one-level undo | 76 | // allows one-level undo |
75 | serverurlDic.insert(i,new QString(serverurl->text())); | 77 | serverurlDic.insert(i,new QString(serverurl->text())); |
76 | servers->insertItem(servername->text()); | 78 | servers->insertItem(servername->text()); |
77 | activeServers->insertItem(servername->text()); | 79 | activeServers->insertItem(servername->text()); |
78 | } | 80 | } |
81 | changed = true; | ||
79 | servers->setSelected(i,TRUE); | 82 | servers->setSelected(i,TRUE); |
80 | editServer(i); | 83 | editServer(i); |
84 | changed = true; | ||
81 | } | 85 | } |
82 | 86 | ||
83 | void PackageManagerSettings::newDestination() | 87 | void PackageManagerSettings::newDestination() |
84 | { | 88 | { |
85 | int i = destinations->count(); | 89 | int i = destinations->count(); |
86 | if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { | 90 | if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { |
87 | destinationurlDic.insert(i,new QString("/")); | 91 | destinationurlDic.insert(i,new QString("/")); |
88 | destinations->insertItem(tr("New")); | 92 | destinations->insertItem(tr("New")); |
89 | activeDestination->insertItem(tr("New")); | 93 | activeDestination->insertItem(tr("New")); |
90 | activeLinkDestination->insertItem(tr("New")); | 94 | activeLinkDestination->insertItem(tr("New")); |
91 | } else { | 95 | } else { |
92 | // allows one-level undo | 96 | // allows one-level undo |
93 | destinationurlDic.insert(i,new QString(destinationurl->text())); | 97 | destinationurlDic.insert(i,new QString(destinationurl->text())); |
94 | destinations->insertItem(destinationname->text()); | 98 | destinations->insertItem(destinationname->text()); |
95 | activeDestination->insertItem(destinationname->text()); | 99 | activeDestination->insertItem(destinationname->text()); |
96 | activeLinkDestination->insertItem(destinationname->text()); | 100 | activeLinkDestination->insertItem(destinationname->text()); |
97 | } | 101 | } |
98 | destinations->setSelected(i,TRUE); | 102 | destinations->setSelected(i,TRUE); |
99 | editDestination(i); | 103 | editDestination(i); |
104 | changed = true; | ||
100 | } | 105 | } |
101 | 106 | ||
102 | 107 | ||
103 | void PackageManagerSettings::editServer(int i) | 108 | void PackageManagerSettings::editServer(int i) |
104 | { | 109 | { |
105 | if ( servername->isEnabled() ) { | 110 | if ( servername->isEnabled() ) { |
106 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 111 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
107 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 112 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
108 | } else { | 113 | } else { |
109 | servername->setEnabled(TRUE); | 114 | servername->setEnabled(TRUE); |
110 | serverurl->setEnabled(TRUE); | 115 | serverurl->setEnabled(TRUE); |
111 | } | 116 | } |
112 | 117 | ||
113 | servername->setText( servers->text(i) ); | 118 | servername->setText( servers->text(i) ); |
114 | serverurl->setText( *serverurlDic[i] ); | 119 | serverurl->setText( *serverurlDic[i] ); |
115 | 120 | ||
116 | editedserver = i; | 121 | editedserver = i; |
117 | 122 | ||
118 | connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 123 | connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
119 | connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 124 | connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
125 | changed = true; | ||
120 | } | 126 | } |
121 | 127 | ||
122 | 128 | ||
123 | void PackageManagerSettings::editDestination(int i) | 129 | void PackageManagerSettings::editDestination(int i) |
124 | { | 130 | { |
125 | if ( destinationname->isEnabled() ) { | 131 | if ( destinationname->isEnabled() ) { |
126 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 132 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
127 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 133 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
128 | } else { | 134 | } else { |
129 | destinationname->setEnabled(TRUE); | 135 | destinationname->setEnabled(TRUE); |
130 | destinationurl->setEnabled(TRUE); | 136 | destinationurl->setEnabled(TRUE); |
131 | } | 137 | } |
132 | 138 | ||
133 | destinationname->setText( destinations->text(i) ); | 139 | destinationname->setText( destinations->text(i) ); |
134 | destinationurl->setText( *destinationurlDic[i] ); | 140 | destinationurl->setText( *destinationurlDic[i] ); |
135 | 141 | ||
136 | editeddestination = i; | 142 | editeddestination = i; |
137 | 143 | ||
138 | connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 144 | connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
139 | connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 145 | connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
146 | changed = true; | ||
140 | } | 147 | } |
141 | 148 | ||
142 | void PackageManagerSettings::removeServer() | 149 | void PackageManagerSettings::removeServer() |
143 | { | 150 | { |
144 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 151 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
145 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 152 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
146 | servername->setText(servers->text(editedserver)); | 153 | servername->setText(servers->text(editedserver)); |
147 | serverurl->setText(*serverurlDic[editedserver]); | 154 | serverurl->setText(*serverurlDic[editedserver]); |
148 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 155 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
149 | servers->removeItem(editedserver); | 156 | servers->removeItem(editedserver); |
150 | activeServers->removeItem(editedserver); | 157 | activeServers->removeItem(editedserver); |
151 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 158 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
152 | servername->setEnabled(FALSE); | 159 | servername->setEnabled(FALSE); |
153 | serverurl->setEnabled(FALSE); | 160 | serverurl->setEnabled(FALSE); |
161 | changed = true; | ||
154 | } | 162 | } |
155 | 163 | ||
156 | void PackageManagerSettings::removeDestination() | 164 | void PackageManagerSettings::removeDestination() |
157 | { | 165 | { |
158 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 166 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
159 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 167 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
160 | destinationname->setText(destinations->text(editedserver)); | 168 | destinationname->setText(destinations->text(editedserver)); |
161 | destinationurl->setText(*destinationurlDic[editedserver]); | 169 | destinationurl->setText(*destinationurlDic[editedserver]); |
162 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 170 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
163 | destinations->removeItem(editeddestination); | 171 | destinations->removeItem(editeddestination); |
164 | activeDestination->removeItem(editeddestination); | 172 | activeDestination->removeItem(editeddestination); |
165 | activeLinkDestination->removeItem(editeddestination); | 173 | activeLinkDestination->removeItem(editeddestination); |
166 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 174 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
167 | destinationname->setEnabled(FALSE); | 175 | destinationname->setEnabled(FALSE); |
168 | destinationurl->setEnabled(FALSE); | 176 | destinationurl->setEnabled(FALSE); |
177 | changed = true; | ||
169 | } | 178 | } |
170 | 179 | ||
171 | void PackageManagerSettings::serverNameChanged(const QString& t) | 180 | void PackageManagerSettings::serverNameChanged(const QString& t) |
172 | { | 181 | { |
173 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 182 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
174 | servers->changeItem( t, editedserver ); | 183 | servers->changeItem( t, editedserver ); |
175 | activeServers->changeItem( t, editedserver ); | 184 | activeServers->changeItem( t, editedserver ); |
185 | changed = true; | ||
176 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 186 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
187 | changed = true; | ||
177 | } | 188 | } |
178 | 189 | ||
179 | void PackageManagerSettings::destNameChanged(const QString& t) | 190 | void PackageManagerSettings::destNameChanged(const QString& t) |
180 | { | 191 | { |
181 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 192 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
182 | destinations->changeItem( t, editeddestination ); | 193 | destinations->changeItem( t, editeddestination ); |
183 | activeDestination->changeItem( t, editeddestination ); | 194 | activeDestination->changeItem( t, editeddestination ); |
184 | activeLinkDestination->changeItem( t, editeddestination ); | 195 | activeLinkDestination->changeItem( t, editeddestination ); |
185 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 196 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
197 | changed = true; | ||
186 | } | 198 | } |
187 | 199 | ||
188 | void PackageManagerSettings::serverUrlChanged(const QString& t) | 200 | void PackageManagerSettings::serverUrlChanged(const QString& t) |
189 | { | 201 | { |
190 | serverurlDic.replace(editedserver, new QString(t)); | 202 | serverurlDic.replace(editedserver, new QString(t)); |
203 | changed = true; | ||
191 | } | 204 | } |
192 | 205 | ||
193 | void PackageManagerSettings::destUrlChanged(const QString& t) | 206 | void PackageManagerSettings::destUrlChanged(const QString& t) |
194 | { | 207 | { |
195 | destinationurlDic.replace(editeddestination, new QString(t)); | 208 | destinationurlDic.replace(editeddestination, new QString(t)); |
209 | changed = true; | ||
196 | } | 210 | } |
197 | 211 | ||
198 | void PackageManagerSettings::writeIpkgConfig(const QString& conffile) | 212 | void PackageManagerSettings::writeIpkgConfig(const QString& conffile) |
199 | { | 213 | { |
200 | QFile conf(conffile); | 214 | QFile conf(conffile); |
201 | if ( ! conf.open(IO_WriteOnly) ) return; | 215 | if ( ! conf.open(IO_WriteOnly) ) return; |
202 | QTextStream s(&conf); | 216 | QTextStream s(&conf); |
203 | s << "# Written by qpie Package Manager\n"; | 217 | s << "# Written by qpie Package Manager\n"; |
204 | for (int i=0; i<(int)activeServers->count(); i++) | 218 | for (int i=0; i<(int)activeServers->count(); i++) |
205 | { | 219 | { |
206 | QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???"); | 220 | QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???"); |
207 | if ( !activeServers->isSelected(i) ) | 221 | if ( !activeServers->isSelected(i) ) |
@@ -256,63 +270,61 @@ void PackageManagerSettings::newInstallationSetting() | |||
256 | installationSettingsCount++; | 270 | installationSettingsCount++; |
257 | settingName->insertItem( "New", installationSettingsCount ); | 271 | settingName->insertItem( "New", installationSettingsCount ); |
258 | settingName->setCurrentItem( installationSettingsCount ); | 272 | settingName->setCurrentItem( installationSettingsCount ); |
259 | settingName->setEditable( true ); | 273 | settingName->setEditable( true ); |
260 | changed = true; | 274 | changed = true; |
261 | } | 275 | } |
262 | 276 | ||
263 | void PackageManagerSettings::installationSettingChange(int cs) | 277 | void PackageManagerSettings::installationSettingChange(int cs) |
264 | { | 278 | { |
265 | writeCurrentInstallationSetting(); | 279 | writeCurrentInstallationSetting(); |
266 | currentSetting = cs; | 280 | currentSetting = cs; |
267 | readInstallationSetting( cs ); | 281 | readInstallationSetting( cs ); |
282 | changed = true; | ||
268 | } | 283 | } |
269 | 284 | ||
270 | void PackageManagerSettings::writeInstallationSettings() | 285 | void PackageManagerSettings::writeInstallationSettings() |
271 | { | 286 | { |
272 | if ( ! changed ) return ; | ||
273 | { | 287 | { |
274 | Config cfg( "oipkg", Config::User ); | 288 | Config cfg( "oipkg", Config::User ); |
275 | cfg.setGroup( "Settings" ); | 289 | cfg.setGroup( "Settings" ); |
276 | cfg.writeEntry( "count", installationSettingsCount ); | 290 | cfg.writeEntry( "count", installationSettingsCount ); |
277 | cfg.writeEntry( "current", currentSetting ); | 291 | cfg.writeEntry( "current", currentSetting ); |
278 | } | 292 | } |
279 | writeCurrentInstallationSetting(); | 293 | writeCurrentInstallationSetting(); |
280 | } | 294 | } |
281 | 295 | ||
282 | 296 | ||
283 | void PackageManagerSettings::readInstallationSetting(int setting) | 297 | void PackageManagerSettings::readInstallationSetting(int setting) |
284 | { | 298 | { |
285 | if ( setting < 0 ) return; | 299 | if ( setting < 0 ) return; |
286 | Config cfg( "oipkg", Config::User ); | 300 | Config cfg( "oipkg", Config::User ); |
287 | cfg.setGroup( "Setting_" + QString::number( setting ) ); | 301 | cfg.setGroup( "Setting_" + QString::number( setting ) ); |
288 | CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) ); | 302 | CheckBoxLink->setChecked( cfg.readBoolEntry( "link", true ) ); |
289 | QString dest = cfg.readEntry( "dest" ); | 303 | QString dest = cfg.readEntry( "dest" ); |
290 | QString linkdest = cfg.readEntry( "linkdest" ); | 304 | QString linkdest = cfg.readEntry( "linkdest" ); |
291 | pvDebug(3, "dest="+dest); | 305 | pvDebug(3, "dest="+dest); |
292 | pvDebug(3, "linkdest="+linkdest); | 306 | pvDebug(3, "linkdest="+linkdest); |
293 | |||
294 | for ( int i = 0; i < activeDestination->count(); i++) | 307 | for ( int i = 0; i < activeDestination->count(); i++) |
295 | { | 308 | { |
296 | if ( activeDestination->text( i ) == dest ) | 309 | if ( activeDestination->text( i ) == dest ) |
297 | activeDestination->setCurrentItem( i ); | 310 | activeDestination->setCurrentItem( i ); |
298 | if ( activeLinkDestination->text( i ) == linkdest ) | 311 | if ( activeLinkDestination->text( i ) == linkdest ) |
299 | activeLinkDestination->setCurrentItem( i ); | 312 | activeLinkDestination->setCurrentItem( i ); |
300 | } | 313 | } |
301 | } | 314 | } |
302 | 315 | ||
303 | void PackageManagerSettings::writeCurrentInstallationSetting() | 316 | void PackageManagerSettings::writeCurrentInstallationSetting() |
304 | { | 317 | { |
305 | Config cfg( "oipkg", Config::User ); | 318 | Config cfg( "oipkg", Config::User ); |
306 | changed = false; | ||
307 | cfg.setGroup( "Setting_" + QString::number(currentSetting) ); | 319 | cfg.setGroup( "Setting_" + QString::number(currentSetting) ); |
308 | cfg.writeEntry( "link", CheckBoxLink->isChecked() ); | 320 | cfg.writeEntry( "link", CheckBoxLink->isChecked() ); |
309 | cfg.writeEntry( "dest", getDestinationName() ); | 321 | cfg.writeEntry( "dest", getDestinationName() ); |
310 | cfg.writeEntry( "linkdest" , getLinkDestinationName() ); | 322 | cfg.writeEntry( "linkdest" , getLinkDestinationName() ); |
311 | QStringList sers = getActiveServers(); | 323 | QStringList sers = getActiveServers(); |
312 | int srvc = 0; | 324 | int srvc = 0; |
313 | for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) { | 325 | for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) { |
314 | cfg.writeEntry( "server_" + QString::number(srvc++), *it ); | 326 | cfg.writeEntry( "server_" + QString::number(srvc++), *it ); |
315 | } | 327 | } |
316 | cfg.writeEntry( "server_count", srvc ); | 328 | cfg.writeEntry( "server_count", srvc ); |
317 | } | 329 | } |
318 | 330 | ||
@@ -323,24 +335,25 @@ void PackageManagerSettings::renameInstallationSetting() | |||
323 | } | 335 | } |
324 | 336 | ||
325 | void PackageManagerSettings::installationSettingSetName(const QString &name) | 337 | void PackageManagerSettings::installationSettingSetName(const QString &name) |
326 | { | 338 | { |
327 | settingName->changeItem( name, settingName->currentItem() ); | 339 | settingName->changeItem( name, settingName->currentItem() ); |
328 | changed = true; | 340 | changed = true; |
329 | } | 341 | } |
330 | 342 | ||
331 | 343 | ||
332 | bool PackageManagerSettings::readIpkgConfig(const QString& conffile) | 344 | bool PackageManagerSettings::readIpkgConfig(const QString& conffile) |
333 | { | 345 | { |
334 | QFile conf(conffile); | 346 | QFile conf(conffile); |
347 | changed = false; | ||
335 | if ( conf.open(IO_ReadOnly) ) { | 348 | if ( conf.open(IO_ReadOnly) ) { |
336 | QTextStream s(&conf); | 349 | QTextStream s(&conf); |
337 | servers->clear(); | 350 | servers->clear(); |
338 | activeServers->clear(); | 351 | activeServers->clear(); |
339 | activeDestination->clear(); | 352 | activeDestination->clear(); |
340 | activeLinkDestination->clear(); | 353 | activeLinkDestination->clear(); |
341 | serverurlDic.clear(); | 354 | serverurlDic.clear(); |
342 | destinationurlDic.clear(); | 355 | destinationurlDic.clear(); |
343 | ipkg_old=0; | 356 | ipkg_old=0; |
344 | int currentserver=0; | 357 | int currentserver=0; |
345 | while ( !s.atEnd() ) { | 358 | while ( !s.atEnd() ) { |
346 | QString l = s.readLine(); | 359 | QString l = s.readLine(); |
@@ -415,36 +428,36 @@ bool PackageManagerSettings::readIpkgConfig(const QString& conffile) | |||
415 | 428 | ||
416 | /** | 429 | /** |
417 | * read from config file(s) | 430 | * read from config file(s) |
418 | */ | 431 | */ |
419 | void PackageManagerSettings::readSettings() | 432 | void PackageManagerSettings::readSettings() |
420 | { | 433 | { |
421 | readIpkgConfig("/etc/ipkg.conf"); | 434 | readIpkgConfig("/etc/ipkg.conf"); |
422 | readInstallationSettings(); | 435 | readInstallationSettings(); |
423 | } | 436 | } |
424 | 437 | ||
425 | void PackageManagerSettings::writeSettings() | 438 | void PackageManagerSettings::writeSettings() |
426 | { | 439 | { |
427 | writeIpkgConfig("/etc/ipkg.conf"); | 440 | if ( changed ) writeIpkgConfig("/etc/ipkg.conf"); |
428 | writeInstallationSettings(); | 441 | writeInstallationSettings(); |
429 | } | 442 | } |
430 | /** shows the setting dialog */ | 443 | /** shows the setting dialog */ |
431 | bool PackageManagerSettings::showDialog( int i ) | 444 | bool PackageManagerSettings::showDialog( int i ) |
432 | { | 445 | { |
433 | TabWidget->setCurrentPage( i ); | 446 | TabWidget->setCurrentPage( i ); |
434 | showMaximized(); | 447 | showMaximized(); |
435 | bool ret = exec(); | 448 | bool ret = exec(); |
436 | if ( ret ) writeSettings(); | 449 | if ( ret ) writeSettings(); |
437 | else readSettings(); | 450 | else readSettings(); |
438 | return ret; | 451 | return (changed && ret); |
439 | } | 452 | } |
440 | /** Returns the installation destination */ | 453 | /** Returns the installation destination */ |
441 | QString PackageManagerSettings::getDestinationName() | 454 | QString PackageManagerSettings::getDestinationName() |
442 | { | 455 | { |
443 | return activeDestination->currentText(); | 456 | return activeDestination->currentText(); |
444 | } | 457 | } |
445 | /** Returns the link destination */ | 458 | /** Returns the link destination */ |
446 | QString PackageManagerSettings::getLinkDestinationName() | 459 | QString PackageManagerSettings::getLinkDestinationName() |
447 | { | 460 | { |
448 | return activeLinkDestination->currentText(); | 461 | return activeLinkDestination->currentText(); |
449 | } | 462 | } |
450 | /** Returns the URL of the active destination */ | 463 | /** Returns the URL of the active destination */ |
@@ -460,24 +473,33 @@ bool PackageManagerSettings::createLinks() | |||
460 | } | 473 | } |
461 | /** get the servers that are active */ | 474 | /** get the servers that are active */ |
462 | QStringList PackageManagerSettings::getActiveServers() | 475 | QStringList PackageManagerSettings::getActiveServers() |
463 | { | 476 | { |
464 | QStringList sl; | 477 | QStringList sl; |
465 | for (int i=0; i<(int)activeServers->count(); i++) | 478 | for (int i=0; i<(int)activeServers->count(); i++) |
466 | { | 479 | { |
467 | if ( activeServers->isSelected(i) ) | 480 | if ( activeServers->isSelected(i) ) |
468 | sl += activeServers->text(i); | 481 | sl += activeServers->text(i); |
469 | } | 482 | } |
470 | return sl; | 483 | return sl; |
471 | } | 484 | } |
485 | QStringList PackageManagerSettings::getServers() | ||
486 | { | ||
487 | QStringList sl; | ||
488 | for (int i=0; i<(int)activeServers->count(); i++) | ||
489 | { | ||
490 | sl += activeServers->text(i); | ||
491 | } | ||
492 | return sl; | ||
493 | } | ||
472 | 494 | ||
473 | /** returns the destination listed in ipkg.conf */ | 495 | /** returns the destination listed in ipkg.conf */ |
474 | QStringList PackageManagerSettings::getDestinationUrls() | 496 | QStringList PackageManagerSettings::getDestinationUrls() |
475 | { | 497 | { |
476 | QStringList sl; | 498 | QStringList sl; |
477 | for (int i=0; i<(int)destinations->count(); i++) | 499 | for (int i=0; i<(int)destinations->count(); i++) |
478 | { | 500 | { |
479 | sl += *destinationurlDic[i]; | 501 | sl += *destinationurlDic[i]; |
480 | } | 502 | } |
481 | return sl; | 503 | return sl; |
482 | } | 504 | } |
483 | 505 | ||
@@ -497,15 +519,24 @@ QStringList PackageManagerSettings::getDestinationNames() | |||
497 | { | 519 | { |
498 | QStringList sl; | 520 | QStringList sl; |
499 | for (int i=0; i<(int)destinations->count(); i++) | 521 | for (int i=0; i<(int)destinations->count(); i++) |
500 | { | 522 | { |
501 | sl += destinations->text(i); | 523 | sl += destinations->text(i); |
502 | } | 524 | } |
503 | return sl; | 525 | return sl; |
504 | } | 526 | } |
505 | 527 | ||
506 | 528 | ||
507 | void PackageManagerSettings::linkEnabled( bool b ) | 529 | void PackageManagerSettings::linkEnabled( bool b ) |
508 | { | 530 | { |
509 | changed = true; | ||
510 | activeLinkDestination->setEnabled( b ); | 531 | activeLinkDestination->setEnabled( b ); |
511 | } | 532 | } |
533 | |||
534 | void PackageManagerSettings::activeServerChanged() | ||
535 | { | ||
536 | changed = true; | ||
537 | } | ||
538 | |||
539 | QComboBox* PackageManagerSettings::getDestCombo() | ||
540 | { | ||
541 | return new QComboBox(activeDestination); | ||
542 | } | ||