summaryrefslogtreecommitdiffstats
path: root/kcontrol/kio/cache.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/kio/cache.cpp
downloadtdebase-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 'kcontrol/kio/cache.cpp')
-rw-r--r--kcontrol/kio/cache.cpp127
1 files changed, 127 insertions, 0 deletions
diff --git a/kcontrol/kio/cache.cpp b/kcontrol/kio/cache.cpp
new file mode 100644
index 000000000..8b730ae77
--- /dev/null
+++ b/kcontrol/kio/cache.cpp
@@ -0,0 +1,127 @@
+/*
+ cache.cpp - Proxy configuration dialog
+
+ Copyright (C) 2001,02,03 Dawit Alemayehu <[email protected]>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License (GPL) version 2 as published by the Free Software
+ Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qwhatsthis.h>
+#include <qpushbutton.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kprocess.h>
+#include <knuminput.h>
+
+#include "ksaveioconfig.h"
+#include <kio/http_slave_defaults.h>
+
+#include "cache.h"
+#include "cache_ui.h"
+
+KCacheConfigDialog::KCacheConfigDialog( QWidget* parent )
+ :KCModule( parent, "kcmkio" )
+{
+ QVBoxLayout* mainLayout = new QVBoxLayout(this, 0, 0);
+ m_dlg = new CacheDlgUI(this);
+ mainLayout->addWidget(m_dlg);
+ mainLayout->addStretch();
+
+ load();
+}
+
+void KCacheConfigDialog::load()
+{
+ m_dlg->cbUseCache->setChecked(KProtocolManager::useCache());
+ m_dlg->sbMaxCacheSize->setValue( KProtocolManager::maxCacheSize() );
+
+ KIO::CacheControl cc = KProtocolManager::cacheControl();
+
+ if (cc==KIO::CC_Verify)
+ m_dlg->rbVerifyCache->setChecked( true );
+ else if (cc==KIO::CC_Refresh)
+ m_dlg->rbVerifyCache->setChecked( true );
+ else if (cc==KIO::CC_CacheOnly)
+ m_dlg->rbOfflineMode->setChecked( true );
+ else if (cc==KIO::CC_Cache)
+ m_dlg->rbCacheIfPossible->setChecked( true );
+
+ // Config changed notifications...
+ connect ( m_dlg->cbUseCache, SIGNAL(toggled(bool)), SLOT(configChanged()) );
+ connect ( m_dlg->bgCachePolicy, SIGNAL(clicked (int)), SLOT(configChanged()) );
+ connect ( m_dlg->sbMaxCacheSize, SIGNAL(valueChanged(int)), SLOT(configChanged()) );
+ connect ( m_dlg->pbClearCache, SIGNAL(clicked()), SLOT(slotClearCache()) );
+ emit changed( false );
+}
+
+void KCacheConfigDialog::save()
+{
+ KSaveIOConfig::setUseCache( m_dlg->cbUseCache->isChecked() );
+ KSaveIOConfig::setMaxCacheSize( m_dlg->sbMaxCacheSize->value() );
+
+ if ( !m_dlg->cbUseCache->isChecked() )
+ KSaveIOConfig::setCacheControl(KIO::CC_Refresh);
+ else if ( m_dlg->rbVerifyCache->isChecked() )
+ KSaveIOConfig::setCacheControl(KIO::CC_Refresh);
+ else if ( m_dlg->rbOfflineMode->isChecked() )
+ KSaveIOConfig::setCacheControl(KIO::CC_CacheOnly);
+ else if ( m_dlg->rbCacheIfPossible->isChecked() )
+ KSaveIOConfig::setCacheControl(KIO::CC_Cache);
+
+ // Update running io-slaves...
+ KSaveIOConfig::updateRunningIOSlaves (this);
+
+ emit changed( false );
+}
+
+void KCacheConfigDialog::defaults()
+{
+ m_dlg->cbUseCache->setChecked( true );
+ m_dlg->rbVerifyCache->setChecked( true );
+ m_dlg->sbMaxCacheSize->setValue( DEFAULT_MAX_CACHE_SIZE );
+}
+
+QString KCacheConfigDialog::quickHelp() const
+{
+ return i18n( "<h1>Cache</h1><p>This module lets you configure your cache settings.</p>"
+ "<p>The cache is an internal memory in Konqueror where recently "
+ "read web pages are stored. If you want to retrieve a web "
+ "page again that you have recently read, it will not be "
+ "downloaded from the Internet, but rather retrieved from the "
+ "cache, which is a lot faster.</p>" );
+}
+
+void KCacheConfigDialog::configChanged()
+{
+ emit changed( true );
+}
+
+void KCacheConfigDialog::slotClearCache()
+{
+ KProcess process;
+ process << "kio_http_cache_cleaner" << "--clear-all";
+ process.start(KProcess::DontCare);
+ // Cleaning up might take a while. Better detach.
+ process.detach();
+}
+
+#include "cache.moc"