X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d3496b12310d9fec0e52e537c341e87fcaa2f8b5..2d2d55f3df09614e6b7cf267771b52a04dcb5e28:/src/views/dolphinremoteencoding.cpp diff --git a/src/views/dolphinremoteencoding.cpp b/src/views/dolphinremoteencoding.cpp index 475769e91..04b350eda 100644 --- a/src/views/dolphinremoteencoding.cpp +++ b/src/views/dolphinremoteencoding.cpp @@ -16,13 +16,13 @@ * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ - + /* * This code is largely based on the kremoteencodingplugin * Copyright (c) 2003 Thiago Macieira * Distributed under the same terms. */ - + #include "dolphinremoteencoding.h" #include "dolphinviewactionhandler.h" @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -48,7 +47,7 @@ DolphinRemoteEncoding::DolphinRemoteEncoding(QObject* parent, DolphinViewActionH :QObject(parent), m_actionHandler(actionHandler), m_loaded(false), - m_idDefault(0) + m_idDefault(0) { m_menu = new KActionMenu(KIcon("character-set"), i18n("Select Remote Charset"), this); m_actionHandler->actionCollection()->addAction("change_remote_encoding", m_menu); @@ -86,7 +85,7 @@ void DolphinRemoteEncoding::slotAboutToOpenUrl() // everything whose type is T_FILESYSTEM except for local files if (!m_currentURL.isLocalFile() && KProtocolManager::outputType(m_currentURL) == KProtocolInfo::T_FILESYSTEM) { - + m_menu->setEnabled(true); loadSettings(); } else { @@ -105,7 +104,7 @@ void DolphinRemoteEncoding::fillMenu() KMenu* menu = m_menu->menu(); menu->clear(); - + for (int i = 0; i < m_encodingDescriptions.size();i++) { QAction* action = new QAction(m_encodingDescriptions.at(i), this); action->setCheckable(true); @@ -117,7 +116,7 @@ void DolphinRemoteEncoding::fillMenu() menu->addAction(i18n("Reload"), this, SLOT(slotReload()), 0); menu->addAction(i18n("Default"), this, SLOT(slotDefault()), 0)->setCheckable(true); m_idDefault = m_encodingDescriptions.size() + 2; - + connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(slotItemSelected(QAction*))); } @@ -126,26 +125,24 @@ void DolphinRemoteEncoding::updateMenu() if (!m_loaded) { loadSettings(); } - + // uncheck everything for (int i = 0; i < m_menu->menu()->actions().count(); i++) { m_menu->menu()->actions().at(i)->setChecked(false); } - - QString charset = KIO::SlaveConfig::self()->configData(m_currentURL.protocol(), - m_currentURL.host(), DATA_KEY); + const QString charset = KGlobal::charsets()->descriptionForEncoding(KProtocolManager::charsetFor(m_currentURL)); if (!charset.isEmpty()) { int id = 0; bool isFound = false; for (int i = 0; i < m_encodingDescriptions.size(); i++) { - if (m_encodingDescriptions.at(i).contains(charset)) { + if (m_encodingDescriptions.at(i) == charset) { isFound = true; id = i; break; } } - + kDebug() << "URL=" << m_currentURL << " charset=" << charset; if (!isFound) { @@ -156,7 +153,7 @@ void DolphinRemoteEncoding::updateMenu() } else { m_menu->menu()->actions().at(m_idDefault)->setChecked(true); } - + } void DolphinRemoteEncoding::slotAboutToShow() @@ -171,7 +168,7 @@ void DolphinRemoteEncoding::slotItemSelected(QAction* action) { if (action) { int id = action->data().toInt(); - + KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1()); QString host = m_currentURL.host(); if (m_menu->menu()->actions().at(id)->isChecked()) {