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 @@ -28,12 +28,13 @@ #include <qtoolbutton.h> #include <qtabwidget.h> #include <stdlib.h> #include <unistd.h> #include "debug.h" +//#include "utils.h" PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) : PackageManagerSettingsBase( parent, name, fl ) { connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); @@ -53,12 +54,13 @@ PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* na serverurl->setEnabled(FALSE); serverurlDic.setAutoDelete(TRUE); destinationname->setEnabled(FALSE); destinationurl->setEnabled(FALSE); destinationurlDic.setAutoDelete(TRUE); readSettings(); + activeLinkDestination->hide(); } PackageManagerSettings::~PackageManagerSettings() { } @@ -73,14 +75,16 @@ void PackageManagerSettings::newServer() } else { // allows one-level undo serverurlDic.insert(i,new QString(serverurl->text())); servers->insertItem(servername->text()); activeServers->insertItem(servername->text()); } + changed = true; servers->setSelected(i,TRUE); editServer(i); + changed = true; } void PackageManagerSettings::newDestination() { int i = destinations->count(); if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { @@ -94,12 +98,13 @@ void PackageManagerSettings::newDestination() destinations->insertItem(destinationname->text()); activeDestination->insertItem(destinationname->text()); activeLinkDestination->insertItem(destinationname->text()); } destinations->setSelected(i,TRUE); editDestination(i); + changed = true; } void PackageManagerSettings::editServer(int i) { if ( servername->isEnabled() ) { @@ -114,12 +119,13 @@ void PackageManagerSettings::editServer(int i) serverurl->setText( *serverurlDic[i] ); editedserver = i; connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); + changed = true; } void PackageManagerSettings::editDestination(int i) { if ( destinationname->isEnabled() ) { @@ -134,12 +140,13 @@ void PackageManagerSettings::editDestination(int i) destinationurl->setText( *destinationurlDic[i] ); editeddestination = i; connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); + changed = true; } void PackageManagerSettings::removeServer() { disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); @@ -148,12 +155,13 @@ void PackageManagerSettings::removeServer() disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); servers->removeItem(editedserver); activeServers->removeItem(editedserver); connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); servername->setEnabled(FALSE); serverurl->setEnabled(FALSE); + changed = true; } void PackageManagerSettings::removeDestination() { disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); @@ -163,39 +171,45 @@ void PackageManagerSettings::removeDestination() destinations->removeItem(editeddestination); activeDestination->removeItem(editeddestination); activeLinkDestination->removeItem(editeddestination); connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); destinationname->setEnabled(FALSE); destinationurl->setEnabled(FALSE); + changed = true; } void PackageManagerSettings::serverNameChanged(const QString& t) { disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); servers->changeItem( t, editedserver ); activeServers->changeItem( t, editedserver ); + changed = true; connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); + changed = true; } void PackageManagerSettings::destNameChanged(const QString& t) { disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); destinations->changeItem( t, editeddestination ); activeDestination->changeItem( t, editeddestination ); activeLinkDestination->changeItem( t, editeddestination ); connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); + changed = true; } void PackageManagerSettings::serverUrlChanged(const QString& t) { serverurlDic.replace(editedserver, new QString(t)); + changed = true; } void PackageManagerSettings::destUrlChanged(const QString& t) { destinationurlDic.replace(editeddestination, new QString(t)); + changed = true; } void PackageManagerSettings::writeIpkgConfig(const QString& conffile) { QFile conf(conffile); if ( ! conf.open(IO_WriteOnly) ) return; @@ -262,17 +276,17 @@ void PackageManagerSettings::newInstallationSetting() void PackageManagerSettings::installationSettingChange(int cs) { writeCurrentInstallationSetting(); currentSetting = cs; readInstallationSetting( cs ); + changed = true; } void PackageManagerSettings::writeInstallationSettings() { - if ( ! changed ) return ; { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Settings" ); cfg.writeEntry( "count", installationSettingsCount ); cfg.writeEntry( "current", currentSetting ); } @@ -282,31 +296,29 @@ void PackageManagerSettings::writeInstallationSettings() void PackageManagerSettings::readInstallationSetting(int setting) { if ( setting < 0 ) return; Config cfg( "oipkg", Config::User ); cfg.setGroup( "Setting_" + QString::number( setting ) ); - CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) ); + CheckBoxLink->setChecked( cfg.readBoolEntry( "link", true ) ); QString dest = cfg.readEntry( "dest" ); QString linkdest = cfg.readEntry( "linkdest" ); pvDebug(3, "dest="+dest); pvDebug(3, "linkdest="+linkdest); - for ( int i = 0; i < activeDestination->count(); i++) { if ( activeDestination->text( i ) == dest ) activeDestination->setCurrentItem( i ); if ( activeLinkDestination->text( i ) == linkdest ) activeLinkDestination->setCurrentItem( i ); } } void PackageManagerSettings::writeCurrentInstallationSetting() { Config cfg( "oipkg", Config::User ); - changed = false; cfg.setGroup( "Setting_" + QString::number(currentSetting) ); cfg.writeEntry( "link", CheckBoxLink->isChecked() ); cfg.writeEntry( "dest", getDestinationName() ); cfg.writeEntry( "linkdest" , getLinkDestinationName() ); QStringList sers = getActiveServers(); int srvc = 0; @@ -329,12 +341,13 @@ void PackageManagerSettings::installationSettingSetName(const QString &name) } bool PackageManagerSettings::readIpkgConfig(const QString& conffile) { QFile conf(conffile); + changed = false; if ( conf.open(IO_ReadOnly) ) { QTextStream s(&conf); servers->clear(); activeServers->clear(); activeDestination->clear(); activeLinkDestination->clear(); @@ -421,24 +434,24 @@ void PackageManagerSettings::readSettings() readIpkgConfig("/etc/ipkg.conf"); readInstallationSettings(); } void PackageManagerSettings::writeSettings() { - writeIpkgConfig("/etc/ipkg.conf"); + if ( changed ) writeIpkgConfig("/etc/ipkg.conf"); writeInstallationSettings(); } /** shows the setting dialog */ bool PackageManagerSettings::showDialog( int i ) { TabWidget->setCurrentPage( i ); showMaximized(); bool ret = exec(); if ( ret ) writeSettings(); else readSettings(); - return ret; + return (changed && ret); } /** Returns the installation destination */ QString PackageManagerSettings::getDestinationName() { return activeDestination->currentText(); } @@ -466,12 +479,21 @@ QStringList PackageManagerSettings::getActiveServers() { if ( activeServers->isSelected(i) ) sl += activeServers->text(i); } return sl; } + QStringList PackageManagerSettings::getServers() +{ + QStringList sl; + for (int i=0; i<(int)activeServers->count(); i++) + { + sl += activeServers->text(i); + } + return sl; +} /** returns the destination listed in ipkg.conf */ QStringList PackageManagerSettings::getDestinationUrls() { QStringList sl; for (int i=0; i<(int)destinations->count(); i++) @@ -503,9 +525,18 @@ QStringList PackageManagerSettings::getDestinationNames() return sl; } void PackageManagerSettings::linkEnabled( bool b ) { - changed = true; activeLinkDestination->setEnabled( b ); } + +void PackageManagerSettings::activeServerChanged() +{ + changed = true; +} + +QComboBox* PackageManagerSettings::getDestCombo() +{ + return new QComboBox(activeDestination); +} |