diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /kioslave/cgi/kcmcgi/kcmcgi.cpp | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kioslave/cgi/kcmcgi/kcmcgi.cpp')
-rw-r--r-- | kioslave/cgi/kcmcgi/kcmcgi.cpp | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/kioslave/cgi/kcmcgi/kcmcgi.cpp b/kioslave/cgi/kcmcgi/kcmcgi.cpp new file mode 100644 index 000000000..18436e8d9 --- /dev/null +++ b/kioslave/cgi/kcmcgi/kcmcgi.cpp @@ -0,0 +1,151 @@ +/* + Copyright (C) 2002 Cornelius Schumacher <[email protected]> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include <kconfig.h> +#include <klocale.h> +#include <kglobal.h> +#include <kaboutdata.h> +#include <kfiledialog.h> + +#include <qlayout.h> +#include <qlistbox.h> +#include <qpushbutton.h> +#include <qgroupbox.h> +#include <qhbox.h> + +#include "kcmcgi.h" +#include "kcmcgi.moc" + +extern "C" +{ + KDE_EXPORT KCModule *create_cgi( QWidget *parent, const char * ) + { + KGlobal::locale()->insertCatalogue("kcmcgi"); + return new KCMCgi( parent, "kcmcgi" ); + } +} + + +KCMCgi::KCMCgi(QWidget *parent, const char *name) + : KCModule(parent, name) +{ + setButtons(Default|Apply); + + QVBoxLayout *topLayout = new QVBoxLayout(this, 0, KDialog::spacingHint()); + + QGroupBox *topBox = new QGroupBox( 1, Horizontal, i18n("Paths to Local CGI Programs"), this ); + topLayout->addWidget( topBox ); + + mListBox = new QListBox( topBox ); + + QHBox *buttonBox = new QHBox( topBox ); + buttonBox->setSpacing( KDialog::spacingHint() ); + + mAddButton = new QPushButton( i18n("Add..."), buttonBox ); + connect( mAddButton, SIGNAL( clicked() ), SLOT( addPath() ) ); + + mRemoveButton = new QPushButton( i18n("Remove"), buttonBox ); + connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removePath() ) ); + connect( mListBox, SIGNAL( clicked ( QListBoxItem * )),this, SLOT( slotItemSelected( QListBoxItem *))); + + mConfig = new KConfig("kcmcgirc"); + + load(); + updateButton(); + KAboutData *about = + new KAboutData( I18N_NOOP("kcmcgi"), + I18N_NOOP("CGI KIO Slave Control Module"), + 0, 0, KAboutData::License_GPL, + I18N_NOOP("(c) 2002 Cornelius Schumacher") ); + + about->addAuthor( "Cornelius Schumacher", 0, "[email protected]" ); + setAboutData(about); +} + +KCMCgi::~KCMCgi() +{ + delete mConfig; +} + +void KCMCgi::slotItemSelected( QListBoxItem * ) +{ + updateButton(); +} + +void KCMCgi::updateButton() +{ + mRemoveButton->setEnabled( mListBox->selectedItem ()); +} + +void KCMCgi::defaults() +{ + mListBox->clear(); + updateButton(); +} + +void KCMCgi::save() +{ + QStringList paths; + + uint i; + for( i = 0; i < mListBox->count(); ++i ) { + paths.append( mListBox->text( i ) ); + } + + mConfig->setGroup( "General" ); + mConfig->writeEntry( "Paths", paths ); + + mConfig->sync(); +} + +void KCMCgi::load() +{ + mConfig->setGroup( "General" ); + QStringList paths = mConfig->readListEntry( "Paths" ); + + mListBox->insertStringList( paths ); +} + +void KCMCgi::addPath() +{ + QString path = KFileDialog::getExistingDirectory( QString::null, this ); + + if ( !path.isEmpty() ) { + mListBox->insertItem( path ); + emit changed( true ); + } + updateButton(); +} + +void KCMCgi::removePath() +{ + int index = mListBox->currentItem(); + if ( index >= 0 ) { + mListBox->removeItem( index ); + emit changed( true ); + } + updateButton(); +} + +QString KCMCgi::quickHelp() const +{ + return i18n("<h1>CGI Scripts</h1> The CGI KIO slave lets you execute " + "local CGI programs without the need to run a web server. " + "In this control module you can configure the paths that " + "are searched for CGI scripts."); +} |