Diffstat (limited to 'noncore/unsupported/oipkg/pksettings.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pksettings.cpp | 45 |
1 files changed, 38 insertions, 7 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 | |||
@@ -31,6 +31,7 @@ | |||
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 ) |
@@ -56,6 +57,7 @@ PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* na | |||
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() |
@@ -76,8 +78,10 @@ void PackageManagerSettings::newServer() | |||
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() |
@@ -97,6 +101,7 @@ void PackageManagerSettings::newDestination() | |||
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 | ||
@@ -117,6 +122,7 @@ void PackageManagerSettings::editServer(int 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 | ||
@@ -137,6 +143,7 @@ void PackageManagerSettings::editDestination(int 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() |
@@ -151,6 +158,7 @@ void PackageManagerSettings::removeServer() | |||
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() |
@@ -166,6 +174,7 @@ void PackageManagerSettings::removeDestination() | |||
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) |
@@ -173,7 +182,9 @@ void PackageManagerSettings::serverNameChanged(const QString& t) | |||
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) |
@@ -183,16 +194,19 @@ void PackageManagerSettings::destNameChanged(const QString& t) | |||
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) |
@@ -265,11 +279,11 @@ void PackageManagerSettings::installationSettingChange(int cs) | |||
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" ); |
@@ -285,12 +299,11 @@ void PackageManagerSettings::readInstallationSetting(int setting) | |||
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 ) |
@@ -303,7 +316,6 @@ void PackageManagerSettings::readInstallationSetting(int setting) | |||
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() ); |
@@ -332,6 +344,7 @@ void PackageManagerSettings::installationSettingSetName(const QString &name) | |||
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(); |
@@ -424,7 +437,7 @@ void PackageManagerSettings::readSettings() | |||
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 */ |
@@ -435,7 +448,7 @@ bool PackageManagerSettings::showDialog( int i ) | |||
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() |
@@ -469,6 +482,15 @@ QStringList PackageManagerSettings::getActiveServers() | |||
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() |
@@ -506,6 +528,15 @@ QStringList PackageManagerSettings::getDestinationNames() | |||
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 | } | ||