]> cloud.milkyroute.net Git - dolphin.git/commitdiff
BUG: 175658
authorRahman Duran <a.rahman.duran@gmail.com>
Wed, 25 Mar 2009 22:00:50 +0000 (22:00 +0000)
committerRahman Duran <a.rahman.duran@gmail.com>
Wed, 25 Mar 2009 22:00:50 +0000 (22:00 +0000)
GUI:

The remote encoding code adapted from Konqueror to Dolphin. Now user can change
encoding for remote urls like ftp. Konqueror doesn't use
KRemoteEncodingPlugin anymore. Instead, this feature is supplied to
Konqueror via DolphinPart.

svn path=/trunk/KDE/kdebase/apps/; revision=944659

src/CMakeLists.txt
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinpart.cpp
src/dolphinpart.h
src/dolphinpart.rc
src/dolphinremoteencoding.cpp
src/dolphinremoteencoding.h
src/dolphinui.rc
src/dolphinviewactionhandler.cpp
src/dolphinviewactionhandler.h

index ed8fbe562f3b8a1c1ceef9bff570caab78cfd498..629adea88b987406c8577b5f2d1988b326c56af0 100644 (file)
@@ -29,7 +29,7 @@ set(dolphinprivate_LIB_SRCS
     dolphincategorydrawer.cpp
     dolphinview.cpp
     dolphinviewactionhandler.cpp
-    dolphinviewautoscroller.cpp
+    dolphinviewautoscroller.cpp    
     draganddrophelper.cpp
     folderexpander.cpp
     renamedialog.cpp
@@ -74,6 +74,7 @@ install(TARGETS dolphinprivate  ${INSTALL_TARGETS_DEFAULT_ARGS})
 
 set(dolphinpart_SRCS
    dolphinpart.cpp
+   dolphinremoteencoding.cpp
 )
 
 
@@ -89,6 +90,7 @@ install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
 ##########################################
 
 set(dolphin_SRCS
+    dolphinremoteencoding.cpp
     dolphinapplication.cpp
     dolphinmainwindow.cpp
     dolphinnewmenu.cpp
index 6e6d4cc1286e96cb1c56b24a05e087b476bb89ce..c2939e59ae074de1587132dc6c97e8a4ffd21900 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "dolphinmainwindow.h"
 #include "dolphinviewactionhandler.h"
+#include "dolphinremoteencoding.h"
 
 #include <config-nepomuk.h>
 
@@ -113,6 +114,7 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_tabIndex(0),
     m_viewTab(),
     m_actionHandler(0),
+    m_remoteEncoding(0),
     m_settingsDialog(0)
 {
     setObjectName("Dolphin#");
@@ -985,6 +987,10 @@ void DolphinMainWindow::init()
     view->reload();
     m_activeViewContainer->show();
     m_actionHandler->setCurrentView(view);
+    
+    m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
+    connect(this, SIGNAL(urlChanged(const KUrl&)), 
+            m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
 
     m_tabBar = new KTabBar(this);
     m_tabBar->setMovable(true);
index 35fc57db4ce48423627b8fb910e692eaa10fe438..77fc36b58e5840648edc1642e291e93f9445f967 100644 (file)
@@ -43,6 +43,7 @@ class DolphinApplication;
 class DolphinSearchBox;
 class DolphinSettingsDialog;
 class DolphinViewContainer;
+class DolphinRemoteEncoding;
 class KNewMenu;
 class KTabBar;
 class KUrl;
@@ -461,6 +462,7 @@ private:
     QList<ViewTab> m_viewTab;
 
     DolphinViewActionHandler* m_actionHandler;
+    DolphinRemoteEncoding* m_remoteEncoding;
     QPointer<DolphinSettingsDialog> m_settingsDialog;
 };
 
index c6076cc371c032015b4c79386c1f7e34a013edb4..dd590efd53071d6ab6ba8ae8a84ea9372bd8d417 100644 (file)
@@ -23,6 +23,7 @@
 #include "dolphinview.h"
 #include "dolphinmodel.h"
 #include "dolphinnewmenuobserver.h"
+#include "dolphinremoteencoding.h"
 
 #include <konq_fileitemcapabilities.h>
 #include <konq_operations.h>
@@ -125,6 +126,10 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
     m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
     m_actionHandler->setCurrentView(m_view);
 
+    m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
+    connect(this, SIGNAL(aboutToOpenURL()),
+            m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
+
     QClipboard* clipboard = QApplication::clipboard();
     connect(clipboard, SIGNAL(dataChanged()),
             this, SLOT(updatePasteAction()));
@@ -137,6 +142,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
     // (sort of spacial navigation)
 
     loadPlugins(this, this, componentData());
+
 }
 
 DolphinPart::~DolphinPart()
index a25bc72f3d55556d128ece02bc57432d7990f321..e7198d45ebc03f653e1d3bab3c2592012247687a 100644 (file)
@@ -30,6 +30,7 @@ class KFileItemList;
 class KFileItem;
 class DolphinPartBrowserExtension;
 class DolphinSortFilterProxyModel;
+class DolphinRemoteEncoding;
 class DolphinModel;
 class KDirLister;
 class DolphinView;
@@ -206,6 +207,7 @@ private:
 private:
     DolphinView* m_view;
     DolphinViewActionHandler* m_actionHandler;
+    DolphinRemoteEncoding* m_remoteEncoding;
     KDirLister* m_dirLister;
     DolphinModel* m_dolphinModel;
     DolphinSortFilterProxyModel* m_proxyModel;
index 19b606dd1ff1c7d6ca83544318ec67df11a3aa5e..2ed6ea7648922b859a49546e3c9c93dc83638fe1 100644 (file)
@@ -56,6 +56,7 @@
     <Action name="find_file" />
     <Action name="show_filter_bar" />
     <Action name="compare_files" />
+    <Action name="change_remote_encoding" />
   </Menu>
 </MenuBar>
 <ToolBar name="mainToolBar"><text context="@title:menu">Dolphin Toolbar</text>
index dc804a05aba501e01b29333a0b8a3b85dd65565b..397eaccc098babbe5819ca3b81c78ce345b93af0 100644 (file)
@@ -1,30 +1,30 @@
-/*
-    Copyright (c) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License (LGPL) as published by the Free Software Foundation;
-    either version 2 of the License, or (at your option) any later
-    version.
-
-    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 Library 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.
-*/
-
-/*
- * This code is largely based on the UserAgent changer plugin (uachanger)
- * Copyright © 2001 Dawit Alemayehu <adawit@kde.org>
+/***************************************************************************
+ *   Copyright (C) 2009 by Rahman Duran <rahman.duran@gmail.com>           *
+ *                                                                         *
+ *   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            *
+ ***************************************************************************/
+ /*
+ * This code is largely based on the kremoteencodingplugin
+ * Copyright (c) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
  * Distributed under the same terms.
  */
-
-#include "kremoteencodingplugin.h"
+#include "dolphinremoteencoding.h"
+#include "dolphinviewactionhandler.h"
 
 #include <kdebug.h>
 #include <kactionmenu.h>
 #include <kconfig.h>
 #include <kcharsets.h>
 #include <kmenu.h>
-#include <kgenericfactory.h>
 #include <kprotocolinfo.h>
 #include <kprotocolmanager.h>
 #include <kio/slaveconfig.h>
 #include <kio/scheduler.h>
-#include <kparts/browserextension.h>
 #include <kconfiggroup.h>
 
-#define DATA_KEY       QLatin1String("Charset")
+#define DATA_KEY        QLatin1String("Charset")
 
-KRemoteEncodingPlugin::KRemoteEncodingPlugin(QObject * parent,
-                                            const QStringList &)
-  : KParts::Plugin(parent), m_loaded(false), m_idDefault(0)
+DolphinRemoteEncoding::DolphinRemoteEncoding(QObject* parent, DolphinViewActionHandler* actionHandler)
+   :QObject(parent),
+    m_actionHandler(actionHandler),
+    m_loaded(false),
+    m_idDefault(0)    
 {
-  m_menu = new KActionMenu(KIcon("character-set"), i18n("Select Remote Charset"), this);
-  actionCollection()->addAction("changeremoteencoding", m_menu);
-  connect(m_menu->menu(), SIGNAL(aboutToShow()),
-         this, SLOT(slotAboutToShow()));
-  m_menu->setEnabled(false);
-  m_menu->setDelayed(false);
+    m_menu = new KActionMenu(KIcon("character-set"), i18n("Select Remote Charset"), this);
+    m_actionHandler->actionCollection()->addAction("change_remote_encoding", m_menu);
+    connect(m_menu->menu(), SIGNAL(aboutToShow()),
+          this, SLOT(slotAboutToShow()));
 
-  m_part = qobject_cast<KParts::ReadOnlyPart*>(parent);
-  if (m_part) {
-    // if parent is not a part, our menu will never show
-    connect(m_part, SIGNAL(aboutToOpenURL()),
-            this, SLOT(slotAboutToOpenURL()));
-    m_part->installEventFilter(this);
-  }
+    m_menu->setEnabled(false);
+    m_menu->setDelayed(false);
 }
 
-KRemoteEncodingPlugin::~KRemoteEncodingPlugin()
+DolphinRemoteEncoding::~DolphinRemoteEncoding()
 {
 }
 
-void
-KRemoteEncodingPlugin::slotReload()
+void DolphinRemoteEncoding::slotReload()
 {
-  loadSettings();
+    loadSettings();
 }
 
-void
-KRemoteEncodingPlugin::loadSettings()
+void DolphinRemoteEncoding::loadSettings()
 {
-  m_loaded = true;
-
-  m_encodingDescriptions = KGlobal::charsets()->descriptiveEncodingNames();
+    m_loaded = true;
+    m_encodingDescriptions = KGlobal::charsets()->descriptiveEncodingNames();
 
-  fillMenu();
+    fillMenu();
 }
 
-void
-KRemoteEncodingPlugin::slotAboutToOpenURL()
+void DolphinRemoteEncoding::slotAboutToOpenUrl()
 {
-  KUrl oldURL = m_currentURL;
-  m_currentURL = m_part->url();
-
-  if (m_currentURL.protocol() != oldURL.protocol())
-    {
-      // This plugin works on ftp, fish, etc.
-      // 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
-       m_menu->setEnabled(false);
-
-      return;
+    KUrl oldURL = m_currentURL;
+    m_currentURL = m_actionHandler->currentView()->url();
+
+    if (m_currentURL.protocol() != oldURL.protocol()) {
+        // This plugin works on ftp, fish, etc.
+        // 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 {
+            m_menu->setEnabled(false);
+        }
+        return;
     }
 
-  if (m_currentURL.host() != oldURL.host())
-    updateMenu();
+    if (m_currentURL.host() != oldURL.host()) {
+        updateMenu();
+    }
 }
 
-void
-KRemoteEncodingPlugin::fillMenu()
+void DolphinRemoteEncoding::fillMenu()
 {
-  KMenu *menu = m_menu->menu();
-  menu->clear();
-
-  QStringList::ConstIterator it;
-  int count = 0;
-  for (it = m_encodingDescriptions.constBegin(); it != m_encodingDescriptions.constEnd(); ++it)
-    menu->insertItem(*it, this, SLOT(slotItemSelected(int)), 0, ++count);
-  menu->addSeparator();
+    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);
+        action->setData(i);
+        menu->addAction(action);
+    }
+    menu->addSeparator();
 
-  menu->insertItem(i18n("Reload"), this, SLOT(slotReload()), 0, ++count);
-  menu->insertItem(i18n("Default"), this, SLOT(slotDefault()), 0, ++count);
-  m_idDefault = count;
+    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*)));
 }
 
-void
-KRemoteEncodingPlugin::updateMenu()
+void DolphinRemoteEncoding::updateMenu()
 {
-  if (!m_loaded)
-    loadSettings();
-
-  // uncheck everything
-  for (unsigned i =  0; i < m_menu->menu()->actions().count(); i++)
-    m_menu->menu()->setItemChecked(m_menu->menu()->idAt(i), false);
-
-  QString charset = KIO::SlaveConfig::self()->configData(m_currentURL.protocol(), m_currentURL.host(),
-                                                        DATA_KEY);
-  if (!charset.isEmpty())
-    {
-      int id = 1;
-      QStringList::const_iterator it;
-      for (it = m_encodingDescriptions.constBegin(); it != m_encodingDescriptions.constEnd(); ++it, ++id)
-       if ((*it).indexOf(charset) != -1)
-         break;
-
-      kDebug() << "URL=" << m_currentURL << " charset=" << charset;
-
-      if (it == m_encodingDescriptions.constEnd())
-       kWarning() << "could not find entry for charset=" << charset ;
-      else
-       m_menu->menu()->setItemChecked(id, true);
+    if (!m_loaded) {
+        loadSettings();
     }
-  else
-    m_menu->menu()->setItemChecked(m_idDefault, true);
+  
+    // 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);
+
+    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)) {
+                isFound = true;
+                id = i;
+                break;
+            }
+        }
+      
+        kDebug() << "URL=" << m_currentURL << " charset=" << charset;
+
+        if (!isFound) {
+            kWarning() << "could not find entry for charset=" << charset ;
+        } else {
+            m_menu->menu()->actions().at(id)->setChecked(true);
+        }
+    } else {
+        m_menu->menu()->actions().at(m_idDefault)->setChecked(true);
+    }
+    
 }
 
-void
-KRemoteEncodingPlugin::slotAboutToShow()
+void DolphinRemoteEncoding::slotAboutToShow()
 {
-  if (!m_loaded)
-    loadSettings();
-  updateMenu();
+    if (!m_loaded) {
+        loadSettings();
+    }
+    updateMenu();
 }
 
-void
-KRemoteEncodingPlugin::slotItemSelected(int id)
+void DolphinRemoteEncoding::slotItemSelected(QAction* action)
 {
-    KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1());
-    QString host = m_currentURL.host();
-    if ( m_menu->menu()->isItemChecked(id) )
-    {
-        QString charset = KGlobal::charsets()->encodingForName(m_encodingDescriptions[id - 1]);
-        KConfigGroup cg(&config, host);
-        cg.writeEntry(DATA_KEY, charset);
-        config.sync();
-        // Update the io-slaves...
-        updateBrowser();
+    if (action != 0) {
+        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()) {
+            QString charset = KGlobal::charsets()->encodingForName(m_encodingDescriptions.at(id));
+            KConfigGroup cg(&config, host);
+            cg.writeEntry(DATA_KEY, charset);
+            config.sync();
+
+            // Update the io-slaves...
+            updateView();
+        }
     }
 }
 
-void
-KRemoteEncodingPlugin::slotDefault()
+void DolphinRemoteEncoding::slotDefault()
 {
-  // We have no choice but delete all higher domain level
-  // settings here since it affects what will be matched.
-  KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1());
-
-  QStringList partList = m_currentURL.host().split('.', QString::SkipEmptyParts);
-  if (!partList.isEmpty())
-    {
-      partList.erase(partList.begin());
-
-      QStringList domains;
-      // Remove the exact name match...
-      domains << m_currentURL.host();
-
-      while (partList.count())
-       {
-         if (partList.count() == 2)
-           if (partList[0].length() <= 2 && partList[1].length() == 2)
-             break;
-
-         if (partList.count() == 1)
-           break;
-
-         domains << partList.join(".");
-         partList.erase(partList.begin());
-       }
+    // We have no choice but delete all higher domain level
+    // settings here since it affects what will be matched.
+    KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1());
 
-      for (QStringList::const_iterator it = domains.constBegin(); it != domains.constEnd();
-          ++it)
-       {
-         kDebug() << "Domain to remove: " << *it;
-         if (config.hasGroup(*it))
-           config.deleteGroup(*it);
-         else if (config.group("").hasKey(*it))
-           config.group("").deleteEntry(*it); //don't know what group name is supposed to be XXX
-       }
+    QStringList partList = m_currentURL.host().split('.', QString::SkipEmptyParts);
+    if (!partList.isEmpty()) {
+        partList.erase(partList.begin());
+
+        QStringList domains;
+        // Remove the exact name match...
+        domains << m_currentURL.host();
+
+        while (partList.count()) {
+            if (partList.count() == 2) {
+                if (partList[0].length() <= 2 && partList[1].length() == 2) {
+                    break;
+                }
+            }
+
+            if (partList.count() == 1) {
+                break;
+            }
+
+            domains << partList.join(".");
+            partList.erase(partList.begin());
+        }
+
+        for (QStringList::const_iterator it = domains.constBegin(); it != domains.constEnd();++it) {
+            kDebug() << "Domain to remove: " << *it;
+            if (config.hasGroup(*it)) {
+                config.deleteGroup(*it);
+            } else if (config.group("").hasKey(*it)) {
+                config.group("").deleteEntry(*it); //don't know what group name is supposed to be XXX
+            }
+        }
     }
-  config.sync();
-
-  // Update the io-slaves.
-  updateBrowser();
-}
+    config.sync();
 
-void
-KRemoteEncodingPlugin::updateBrowser()
-{
-  KIO::Scheduler::emitReparseSlaveConfiguration();
-  // Reload the page with the new charset
-  KParts::OpenUrlArguments args = m_part->arguments();
-  args.setReload( true );
-  m_part->setArguments( args );
-  m_part->openUrl(m_currentURL);
+    // Update the io-slaves.
+    updateView();
 }
 
-bool KRemoteEncodingPlugin::eventFilter(QObject*obj, QEvent *ev)
+void DolphinRemoteEncoding::updateView()
 {
-    if (obj == m_part && KParts::OpenUrlEvent::test(ev)) {
-        const QString mimeType = m_part->arguments().mimeType();
-        if (!mimeType.isEmpty() && KMimeType::mimeType(mimeType)->is("inode/directory"))
-            slotAboutToOpenURL();
-    }
-    return KParts::Plugin::eventFilter(obj, ev);
+    KIO::Scheduler::emitReparseSlaveConfiguration();
+    // Reload the page with the new charset
+    m_actionHandler->currentView()->setUrl(m_currentURL);
+    m_actionHandler->currentView()->reload();
 }
 
-typedef KGenericFactory < KRemoteEncodingPlugin > KRemoteEncodingPluginFactory;
-K_EXPORT_COMPONENT_FACTORY(konq_remoteencoding,
-                          KRemoteEncodingPluginFactory("kremoteencodingplugin"))
-
-#include "kremoteencodingplugin.moc"
+#include "dolphinremoteencoding.moc"
index a61d1fee13c760db0ac474a02e9ffc901905f1cd..97b6f8b60cb89a37bc4fe83c3dc4cd9b3936e7d1 100644 (file)
@@ -1,61 +1,65 @@
-/*
-    Copyright (c) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
+/***************************************************************************
+ *   Copyright (C) 2009 by Rahman Duran <rahman.duran@gmail.com>           *
+ *                                                                         *
+ *   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            *
+ ***************************************************************************/
 
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License (LGPL) as published by the Free Software Foundation;
-    either version 2 of the License, or (at your option) any later
-    version.
+#ifndef DOLPHINREMOTEENCODING_H
+#define DOLPHINREMOTEENCODING_H
 
-    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 Library 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.
-*/
-
-#ifndef REMOTEENCODING_PLUGIN_H
-#define REMOTEENCODING_PLUGIN_H
-
-#include <QtCore/QStringList>
+#include <QStringList>
+#include <QtGui/QAction>
 #include <kurl.h>
-#include <klibloader.h>
-#include <kparts/plugin.h>
+
 
 class KActionMenu;
-namespace KParts { class ReadOnlyPart; }
+class DolphinViewActionHandler;
+
+/**
+ * @brief Allows to chnage character encoding for remote urls like ftp.
+ *
+ * When browsing remote url, its possible to change encoding from Tools Menu.
+ */
 
-class KRemoteEncodingPlugin: public KParts::Plugin
+class DolphinRemoteEncoding: public QObject
 {
   Q_OBJECT
 public:
-  KRemoteEncodingPlugin(QObject * parent, const QStringList &);
-  ~KRemoteEncodingPlugin();
+  DolphinRemoteEncoding(QObject* parent, DolphinViewActionHandler* actionHandler);
+  ~DolphinRemoteEncoding();
 
-protected Q_SLOTS:
-  void slotAboutToOpenURL();
-  void slotAboutToShow();
-  void slotItemSelected(int);
+public Q_SLOTS:
+  void slotAboutToOpenUrl();
+  void slotItemSelected(QAction* action);
   void slotReload();
   void slotDefault();
-
-protected:
-    virtual bool eventFilter(QObject*obj, QEvent *ev);
-
+  
+private Q_SLOTS:
+  void slotAboutToShow();
+  
 private:
-  void updateBrowser();
+  void updateView();
   void loadSettings();
   void fillMenu();
   void updateMenu();
 
-  KParts::ReadOnlyPart *m_part;
-  KActionMenu *m_menu;
+  KActionMenu* m_menu;
   QStringList m_encodingDescriptions;
   KUrl m_currentURL;
+  DolphinViewActionHandler* m_actionHandler;
 
   bool m_loaded;
   int m_idDefault;
index 8d89b07c8c10471612f600f2853a14898bccc96b..05dfd3abbfb4d785bcb625c53c9a8bea00d08256 100644 (file)
@@ -78,6 +78,7 @@
             <Action name="show_filter_bar" />
             <Action name="open_terminal" />
             <Action name="compare_files" />
+            <Action name="change_remote_encoding" />
         </Menu>
     </MenuBar>
     <State name="new_file" >
index 748856275990f429ceafe00da7f4078cb45d8797..404c6eae095a54c2a9d01c8d3decbb5edc8269d6 100644 (file)
@@ -22,7 +22,6 @@
 #include "settings/viewpropertiesdialog.h"
 #include "dolphinview.h"
 #include "zoomlevelinfo.h"
-
 #include <konq_operations.h>
 
 #include <kaction.h>
@@ -32,6 +31,7 @@
 #include <krun.h>
 #include <kpropertiesdialog.h>
 
+
 DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent)
     : QObject(parent),
       m_actionCollection(collection),
@@ -68,6 +68,11 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view)
             this, SLOT(slotZoomLevelChanged(int)));
 }
 
+DolphinView* DolphinViewActionHandler::currentView()
+{
+    return m_currentView;
+}
+
 void DolphinViewActionHandler::createActions()
 {
     // This action doesn't appear in the GUI, it's for the shortcut only.
@@ -340,6 +345,11 @@ QString DolphinViewActionHandler::currentViewModeActionName() const
     return QString(); // can't happen
 }
 
+KActionCollection* DolphinViewActionHandler::actionCollection()
+{
+    return m_actionCollection;
+}
+
 void DolphinViewActionHandler::updateViewActions()
 {
     QAction* viewModeAction = m_actionCollection->action(currentViewModeActionName());
index ad56518c4e0614b1d78590c93b1e941b5f5680fa..18305d19f01c9da798ae76a5034d5a50f4a1e69e 100644 (file)
@@ -55,11 +55,21 @@ public:
      * Sets the view that this action handler should work on.
      */
     void setCurrentView(DolphinView* view);
+    
+    /**
+     * Returns the view that this action handler should work on.
+     */
+    DolphinView* currentView();
 
     /**
      * Returns the name of the action for the current viewmode
      */
     QString currentViewModeActionName() const;
+    
+    /**
+     * Returns m_actionCollection
+     */
+    KActionCollection* actionCollection(); 
 
 public Q_SLOTS:
     /**