]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Places and url navigator are now provided by kfile. Port Dolphin to this
authorKevin Ottens <ervin@kde.org>
Mon, 2 Apr 2007 20:08:14 +0000 (20:08 +0000)
committerKevin Ottens <ervin@kde.org>
Mon, 2 Apr 2007 20:08:14 +0000 (20:08 +0000)
change.

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

17 files changed:
src/CMakeLists.txt
src/kfileplacesitem.cpp [deleted file]
src/kfileplacesitem_p.h [deleted file]
src/kfileplacesmodel.cpp [deleted file]
src/kfileplacesmodel.h [deleted file]
src/kfileplacesselector.cpp [deleted file]
src/kfileplacesselector_p.h [deleted file]
src/kfileplacesview.cpp [deleted file]
src/kfileplacesview.h [deleted file]
src/kprotocolcombo.cpp [deleted file]
src/kprotocolcombo_p.h [deleted file]
src/kurlbutton.cpp [deleted file]
src/kurlbutton_p.h [deleted file]
src/kurlnavigator.cpp [deleted file]
src/kurlnavigator.h [deleted file]
src/kurlnavigatorbutton.cpp [deleted file]
src/kurlnavigatorbutton_p.h [deleted file]

index 988572925e4328b6234cf4adc2dac986ac38e7c3..34006f3f4def80685c76c93e3e034fb9e2d1b9d4 100644 (file)
@@ -37,10 +37,6 @@ install(TARGETS dolphinprivate  DESTINATION ${LIB_INSTALL_DIR} )
 
 set(dolphin_SRCS
    applyviewpropsjob.cpp
-   kfileplacesmodel.cpp
-   kfileplacesitem.cpp
-   kfileplacesview.cpp
-   kfileplacesselector.cpp
    bookmarkssettingspage.cpp
    bookmarkssidebarpage.cpp
    columnviewsettingspage.cpp
@@ -63,7 +59,6 @@ set(dolphin_SRCS
    infosidebarpage.cpp
    main.cpp
    metadatawidget.cpp
-   kprotocolcombo.cpp
    pixmapviewer.cpp
    renamedialog.cpp
    settingspagebase.cpp
@@ -73,9 +68,6 @@ set(dolphin_SRCS
    treeviewcontextmenu.cpp
    treeviewsidebarpage.cpp
    sidebartreeview.cpp
-   kurlbutton.cpp
-   kurlnavigator.cpp
-   kurlnavigatorbutton.cpp
    viewpropertiesdialog.cpp
    viewsettingspage.cpp
    viewpropsprogressinfo.cpp )
@@ -100,7 +92,7 @@ else(KMETADATA_INCLUDE_DIR AND KMETADATA_LIBRARY)
 set(KDE4_KMETADATA "")
 endif(KMETADATA_INCLUDE_DIR AND KMETADATA_LIBRARY AND KMETADATA_TOOLS_LIBRARY)
 configure_file(config-kmetadata.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kmetadata.h )
-target_link_libraries(dolphin  ${KDE4_KDECORE_LIBS} ${KDE4_KDEPRINT_LIBS} ${KDE4_KMETADATA} konq dolphinprivate)
+target_link_libraries(dolphin  ${KDE4_KDECORE_LIBS} ${KDE4_KDEPRINT_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KMETADATA} konq dolphinprivate)
 
 install(TARGETS dolphin DESTINATION ${BIN_INSTALL_DIR})
 
diff --git a/src/kfileplacesitem.cpp b/src/kfileplacesitem.cpp
deleted file mode 100644 (file)
index bbef32b..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*  This file is part of the KDE project
-    Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License 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 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.
-
-*/
-
-#include "kfileplacesitem_p.h"
-
-KFilePlacesItem::KFilePlacesItem()
-    : m_isDevice(false)
-{
-}
-
-KFilePlacesItem::~KFilePlacesItem()
-{
-}
-
-bool KFilePlacesItem::isDevice() const
-{
-    return m_isDevice;
-}
-
-QString KFilePlacesItem::bookmarkAddress() const
-{
-    return m_bookmarkAddress;
-}
-
-void KFilePlacesItem::setBookmarkAddress(const QString &address)
-{
-    m_bookmarkAddress = address;
-}
-
-QPersistentModelIndex KFilePlacesItem::deviceIndex() const
-{
-    return m_deviceIndex;
-}
-
-void KFilePlacesItem::setDeviceIndex(const QPersistentModelIndex &index)
-{
-    m_deviceIndex = index;
-    m_isDevice = index.isValid();
-}
-
diff --git a/src/kfileplacesitem_p.h b/src/kfileplacesitem_p.h
deleted file mode 100644 (file)
index e3aed78..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*  This file is part of the KDE project
-    Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License 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 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 KFILEPLACESITEM_P_H
-#define KFILEPLACESITEM_P_H
-
-#include <QString>
-#include <QPersistentModelIndex>
-
-class KFilePlacesItem
-{
-public:
-    KFilePlacesItem();
-    ~KFilePlacesItem();
-
-    bool isDevice() const;
-
-    QString bookmarkAddress() const;
-    void setBookmarkAddress(const QString &address);
-
-    QPersistentModelIndex deviceIndex() const;
-    void setDeviceIndex(const QPersistentModelIndex &index);
-
-private:
-    bool m_isDevice;
-    QString m_bookmarkAddress;
-    QPersistentModelIndex m_deviceIndex;
-};
-
-#endif
diff --git a/src/kfileplacesmodel.cpp b/src/kfileplacesmodel.cpp
deleted file mode 100644 (file)
index 273830b..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-/*  This file is part of the KDE project
-    Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
-    Copyright (C) 2007 David Faure <faure@kde.org>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License 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 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.
-
-*/
-#include "kfileplacesmodel.h"
-#include "kfileplacesitem_p.h"
-
-#include <kglobal.h>
-#include <kstandarddirs.h>
-#include <kcomponentdata.h>
-#include <kicon.h>
-
-#include <kdevicelistmodel.h>
-#include <kbookmarkmanager.h>
-#include <kbookmark.h>
-
-#include <solid/volume.h>
-
-class KFilePlacesModel::Private
-{
-public:
-    Private(KFilePlacesModel *self) : q(self), deviceModel(0), bookmarkManager(0) {}
-
-
-    KFilePlacesModel *q;
-
-    QList<KFilePlacesItem*> items;
-    QMap<QString, QPersistentModelIndex> availableDevices;
-
-    KDeviceListModel *deviceModel;
-    KBookmarkManager *bookmarkManager;
-
-    QVariant bookmarkData(const QString &address, int role) const;
-    QVariant deviceData(const QPersistentModelIndex &index, int role) const;
-
-    void _k_devicesInserted(const QModelIndex &parent, int start, int end);
-    void _k_devicesRemoved(const QModelIndex &parent, int start, int end);
-    void _k_reloadBookmarks();
-};
-
-KFilePlacesModel::KFilePlacesModel(QObject *parent)
-    : QAbstractItemModel(parent), d(new Private(this))
-{
-    QString basePath = KGlobal::mainComponent().componentName();
-    basePath.append("/bookmarks.xml");
-    const QString file = KStandardDirs::locateLocal("data", basePath);
-
-    d->bookmarkManager = KBookmarkManager::managerForFile(file, "dolphin", false);
-
-    d->deviceModel = new KDeviceListModel("IS Volume", this);
-
-    connect(d->deviceModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
-            this, SLOT(_k_devicesInserted(const QModelIndex&, int, int)));
-    connect(d->deviceModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)),
-            this, SLOT(_k_devicesRemoved(const QModelIndex&, int, int)));
-    connect(d->bookmarkManager, SIGNAL(changed(const QString&, const QString&)),
-            this, SLOT(_k_reloadBookmarks()));
-
-    d->_k_reloadBookmarks();
-}
-
-KFilePlacesModel::~KFilePlacesModel()
-{
-    delete d;
-}
-
-KUrl KFilePlacesModel::url(const QModelIndex &index) const
-{
-    return KUrl(data(index, UrlRole).toUrl());
-}
-
-bool KFilePlacesModel::mountNeeded(const QModelIndex &index) const
-{
-    return data(index, MountNeededRole).toBool();
-}
-
-KIcon KFilePlacesModel::icon(const QModelIndex &index) const
-{
-    return KIcon(data(index, Qt::DecorationRole).value<QIcon>());
-}
-
-QString KFilePlacesModel::text(const QModelIndex &index) const
-{
-    return data(index, Qt::DisplayRole).toString();
-}
-
-QVariant KFilePlacesModel::data(const QModelIndex &index, int role) const
-{
-    if (!index.isValid())
-        return QVariant();
-
-    QVariant returnData;
-
-    KFilePlacesItem *item = static_cast<KFilePlacesItem*>(index.internalPointer());
-
-    if (item->isDevice()) {
-        returnData = d->deviceData(item->deviceIndex(), role);
-    } else {
-        returnData = d->bookmarkData(item->bookmarkAddress(), role);
-    }
-
-    return returnData;
-}
-
-QModelIndex KFilePlacesModel::index(int row, int column, const QModelIndex &parent) const
-{
-    if (row<0 || column!=0 || row>=d->items.size())
-        return QModelIndex();
-
-    if (parent.isValid())
-        return QModelIndex();
-
-    return createIndex(row, column, d->items[row]);
-}
-
-QModelIndex KFilePlacesModel::parent(const QModelIndex &child) const
-{
-    return QModelIndex();
-}
-
-int KFilePlacesModel::rowCount(const QModelIndex &parent) const
-{
-    if (parent.isValid())
-        return 0;
-    else
-        return d->items.size();
-}
-
-int KFilePlacesModel::columnCount(const QModelIndex &parent) const
-{
-    Q_UNUSED(parent)
-    // We only know 1 piece of information for a particular entry
-    return 1;
-}
-
-QModelIndex KFilePlacesModel::closestItem(const KUrl &url) const
-{
-    int foundRow = -1;
-    int maxLength = 0;
-
-    // Search the item which is equal to the URL or at least is a parent URL.
-    // If there are more than one possible item URL candidates, choose the item
-    // which covers the bigger range of the URL.
-    for (int row = 0; row<d->items.size(); ++row) {
-        KFilePlacesItem *item = d->items[row];
-        KUrl itemUrl;
-
-        if (item->isDevice()) {
-            itemUrl = KUrl(d->deviceData(item->deviceIndex(), UrlRole).toUrl());
-        } else {
-            itemUrl = KUrl(d->bookmarkData(item->bookmarkAddress(), UrlRole).toUrl());
-        }
-
-        if (itemUrl.isParentOf(url)) {
-            const int length = itemUrl.prettyUrl().length();
-            if (length > maxLength) {
-                foundRow = row;
-                maxLength = length;
-            }
-        }
-    }
-
-    if (foundRow==-1)
-        return QModelIndex();
-    else
-        return createIndex(foundRow, 0, d->items[foundRow]);
-}
-
-QVariant KFilePlacesModel::Private::bookmarkData(const QString &address, int role) const
-{
-    KBookmark bookmark = bookmarkManager->findByAddress(address);
-
-    if (bookmark.isNull()) return QVariant();
-
-    switch (role)
-    {
-    case Qt::DisplayRole:
-        return bookmark.text();
-    case Qt::DecorationRole:
-        return KIcon(bookmark.icon());
-    case UrlRole:
-        return QUrl(bookmark.url());
-    case MountNeededRole:
-        return false;
-    default:
-        return QVariant();
-    }
-}
-
-QVariant KFilePlacesModel::Private::deviceData(const QPersistentModelIndex &index, int role) const
-{
-    if (index.isValid()) {
-        switch (role)
-        {
-        case UrlRole:
-            return QUrl(KUrl(deviceModel->deviceForIndex(index).as<Solid::Volume>()->mountPoint()));
-        case MountNeededRole:
-            return !deviceModel->deviceForIndex(index).as<Solid::Volume>()->isMounted();
-        default:
-            return deviceModel->data(index, role);
-        }
-    } else {
-        return QVariant();
-    }
-}
-
-void KFilePlacesModel::Private::_k_devicesInserted(const QModelIndex &parent, int start, int end)
-{
-    for (int i = start; i<=end; ++i) {
-        QModelIndex index = parent.child(i, 0);
-        QString udi = deviceModel->deviceForIndex(index).udi();
-
-        availableDevices[udi] = index;
-    }
-
-    _k_reloadBookmarks();
-}
-
-void KFilePlacesModel::Private::_k_devicesRemoved(const QModelIndex &parent, int start, int end)
-{
-    for (int i = start; i<=end; ++i) {
-        QModelIndex index = parent.child(i, 0);
-        // Can't find by UDI since the device is already invalid.
-        availableDevices.remove(availableDevices.key(index));
-    }
-
-    _k_reloadBookmarks();
-}
-
-void KFilePlacesModel::Private::_k_reloadBookmarks()
-{
-    qDeleteAll(items);
-    items.clear();
-    q->reset();
-
-    KBookmarkGroup root = bookmarkManager->root();
-    KBookmark bookmark = root.first();
-    QMap<QString, QPersistentModelIndex> devices = availableDevices;
-
-    while (!bookmark.isNull()) {
-        QString udi = bookmark.metaDataItem("UDI");
-        QPersistentModelIndex index = devices.take(udi);
-
-        if (udi.isEmpty() || index.isValid()) {
-            q->beginInsertRows(QModelIndex(), items.size(), items.size());
-
-            KFilePlacesItem *item = new KFilePlacesItem();
-            item->setBookmarkAddress(bookmark.address());
-            if (index.isValid()) {
-                item->setDeviceIndex(index);
-                // TODO: Update bookmark internal element
-            }
-            items << item;
-
-            q->endInsertRows();
-        }
-
-        bookmark = root.next(bookmark);
-    }
-
-    // Add bookmarks for the remaining devices, they were previously unknown
-    foreach (QString udi, devices.keys()) {
-        bookmark = root.createNewSeparator();
-        bookmark.setMetaDataItem("UDI", udi);
-
-        q->beginInsertRows(QModelIndex(), items.size(), items.size());
-
-        KFilePlacesItem *item = new KFilePlacesItem();
-        item->setBookmarkAddress(bookmark.address());
-        item->setDeviceIndex(devices[udi]);
-        // TODO: Update bookmark internal element
-        items << item;
-
-        q->endInsertRows();
-    }
-}
-
-#include "kfileplacesmodel.moc"
diff --git a/src/kfileplacesmodel.h b/src/kfileplacesmodel.h
deleted file mode 100644 (file)
index fb3803b..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*  This file is part of the KDE project
-    Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
-    Copyright (C) 2007 David Faure <faure@kde.org>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License 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 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 KFILEPLACESMODEL_H
-#define KFILEPLACESMODEL_H
-
-
-#include <QAbstractItemModel>
-#include <kurl.h>
-#include <kicon.h>
-
-/**
- * This class is a list view model. Each entry represents a "place"
- * where user can access files. Only revelant when
- * used with QListView or QTableView.
- */
-class /*KIO_EXPORT*/ KFilePlacesModel : public QAbstractItemModel
-{
-    Q_OBJECT
-public:
-    enum AdditionalRoles {
-        UrlRole = 0x069CD12B,
-        HiddenRole = 0x0741CAAC,
-        MountNeededRole = 0x059A935D
-    };
-
-    KFilePlacesModel(QObject *parent=0);
-    ~KFilePlacesModel();
-
-    KUrl url(const QModelIndex &index) const;
-    bool mountNeeded(const QModelIndex &index) const;
-    KIcon icon(const QModelIndex &index) const;
-    QString text(const QModelIndex &index) const;
-
-    /**
-     * @brief Get a visible data based on Qt role for the given index.
-     * Return the device information for the give index.
-     *
-     * @param index The QModelIndex which contains the row, column to fetch the data.
-     * @param role The Interview data role(ex: Qt::DisplayRole).
-     *
-     * @return the data for the given index and role.
-     */
-    QVariant data(const QModelIndex &index, int role) const;
-
-    /**
-     * @brief Get the children model index for the given row and column.
-     */
-    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
-
-    /**
-     * @brief Get the parent QModelIndex for the given model child.
-     */
-    QModelIndex parent(const QModelIndex &child) const;
-
-    /**
-     * @brief Get the number of rows for a model index.
-     */
-    int rowCount(const QModelIndex &parent = QModelIndex()) const;
-
-    /**
-     * @brief Get the number of columns for a model index.
-     */
-    int columnCount(const QModelIndex &parent = QModelIndex()) const;
-
-    /**
-     * Returns the closest item for the URL \a url.
-     * The closest item is defined as item which is equal to
-     * the URL or at least is a parent URL. If there are more than
-     * one possible parent URL candidates, the item which covers
-     * the bigger range of the URL is returned.
-     *
-     * Example: the url is '/home/peter/Documents/Music'.
-     * Available items are:
-     * - /home/peter
-     * - /home/peter/Documents
-     *
-     * The returned item will the one for '/home/peter/Documents'.
-     */
-    QModelIndex closestItem(const KUrl &url) const;
-
-private:
-    Q_PRIVATE_SLOT(d, void _k_devicesInserted(const QModelIndex&, int, int))
-    Q_PRIVATE_SLOT(d, void _k_devicesRemoved(const QModelIndex&, int, int))
-    Q_PRIVATE_SLOT(d, void _k_reloadBookmarks())
-
-    class Private;
-    Private * const d;
-    friend class Private;
-};
-
-#endif
diff --git a/src/kfileplacesselector.cpp b/src/kfileplacesselector.cpp
deleted file mode 100644 (file)
index a12d70b..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
- *   Copyright (C) 2007 by Kevin Ottens (ervin@kde.org)                    *
- *                                                                         *
- *   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 "kfileplacesselector_p.h"
-
-#include "kurlnavigator.h"
-
-#include <assert.h>
-
-#include <kiconloader.h>
-#include <kglobalsettings.h>
-#include <kfileplacesmodel.h>
-#include <kmenu.h>
-#include <kdebug.h>
-
-#include <QPainter>
-#include <QPixmap>
-#include <kicon.h>
-
-KFilePlacesSelector::KFilePlacesSelector(KUrlNavigator* parent, KFilePlacesModel* placesModel) :
-    KUrlButton(parent),
-    m_selectedItem(-1),
-    m_urlNavigator(parent),
-    m_placesModel(placesModel)
-{
-    setFocusPolicy(Qt::NoFocus);
-
-    m_placesMenu = new KMenu(this);
-
-    updateMenu();
-
-    connect(m_placesModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
-            this, SLOT(updateMenu()));
-    connect(m_placesModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
-            this, SLOT(updateMenu()));
-    connect(m_placesMenu, SIGNAL(triggered(QAction*)),
-            this, SLOT(activatePlace(QAction*)));
-
-    setMenu(m_placesMenu);
-}
-
-KFilePlacesSelector::~KFilePlacesSelector()
-{
-}
-
-void KFilePlacesSelector::updateMenu()
-{
-    m_placesMenu->clear();
-
-    const int rowCount = m_placesModel->rowCount();
-    for (int i=0; i<rowCount; ++i) {
-        QModelIndex index = m_placesModel->index(i, 0);
-        QAction* action = new QAction(m_placesModel->icon(index),
-                                      m_placesModel->text(index),
-                                      m_placesMenu);
-        m_placesMenu->addAction(action);
-
-        action->setData(i);
-
-        if (i == m_selectedItem) {
-            //QPixmap pixmap = SmallIcon(bookmark.icon());
-            setIcon(m_placesModel->icon(index));
-            //setIconSize(pixmap.size());
-            //setMinimumWidth(pixmap.width() + 2);
-        }
-    }
-}
-
-void KFilePlacesSelector::updateSelection(const KUrl& url)
-{
-    QModelIndex index = m_placesModel->closestItem(url);
-
-    if (index.isValid()) {
-        m_selectedItem = index.row();
-        setIcon(m_placesModel->icon(index));
-    }
-    else {
-        m_selectedItem = -1;
-        // No bookmark has been found which matches to the given Url. Show
-        // a generic folder icon as pixmap for indication:
-        setIcon(KIcon("folder"));
-    }
-}
-
-KUrl KFilePlacesSelector::selectedPlaceUrl() const
-{
-    QModelIndex index = m_placesModel->index(m_selectedItem, 0);
-
-    if (index.isValid())
-        return m_placesModel->url(index);
-    else
-        return KUrl();
-}
-
-QString KFilePlacesSelector::selectedPlaceText() const
-{
-    QModelIndex index = m_placesModel->index(m_selectedItem, 0);
-
-    if (index.isValid())
-        return m_placesModel->text(index);
-    else
-        return QString();
-}
-
-QSize KFilePlacesSelector::sizeHint() const
-{
-    const int height = KUrlButton::sizeHint().height();
-    return QSize(height, height);
-}
-
-void KFilePlacesSelector::paintEvent(QPaintEvent* /*event*/)
-{
-    QPainter painter(this);
-
-    const int buttonWidth  = width();
-    const int buttonHeight = height();
-
-    QColor backgroundColor;
-    QColor foregroundColor;
-    const bool isHighlighted = isDisplayHintEnabled(EnteredHint) ||
-                               isDisplayHintEnabled(DraggedHint);
-    if (isHighlighted) {
-        backgroundColor = KGlobalSettings::highlightColor();
-        foregroundColor = KGlobalSettings::highlightedTextColor();
-    }
-    else {
-        backgroundColor = palette().brush(QPalette::Background).color();
-        foregroundColor = KGlobalSettings::buttonTextColor();
-    }
-
-    // dimm the colors if the parent view does not have the focus
-    const bool isActive = m_urlNavigator->isActive();
-    if (!isActive) {
-        QColor dimmColor(palette().brush(QPalette::Background).color());
-        foregroundColor = mixColors(foregroundColor, dimmColor);
-        if (isHighlighted) {
-            backgroundColor = mixColors(backgroundColor, dimmColor);
-        }
-    }
-
-    if (!(isDisplayHintEnabled(ActivatedHint) && isActive) && !isHighlighted) {
-        // dimm the foreground color by mixing it with the background
-        foregroundColor = mixColors(foregroundColor, backgroundColor);
-        painter.setPen(foregroundColor);
-    }
-
-    // draw button backround
-    painter.setPen(Qt::NoPen);
-    painter.setBrush(backgroundColor);
-    painter.drawRect(0, 0, buttonWidth, buttonHeight);
-
-    // draw icon
-    const QPixmap pixmap = icon().pixmap();
-    const int x = (buttonWidth -  pixmap.width()) / 2;
-    const int y = (buttonHeight - pixmap.height()) / 2;
-    painter.drawPixmap(x, y, pixmap);
-}
-
-void KFilePlacesSelector::activatePlace(QAction* action)
-{
-    assert(action != 0);
-    m_selectedItem = action->data().toInt();
-
-    QModelIndex index = m_placesModel->index(m_selectedItem, 0);
-
-    if (index.isValid()) {
-        setIcon(m_placesModel->icon(index));
-        emit placeActivated(m_placesModel->url(index));
-    }
-}
-
-#include "kfileplacesselector_p.moc"
-
diff --git a/src/kfileplacesselector_p.h b/src/kfileplacesselector_p.h
deleted file mode 100644 (file)
index f5c60ba..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
- *   Copyright (C) 2007 by Kevin Ottens (ervin@kde.org)                    *
- *                                                                         *
- *   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            *
- ***************************************************************************/
-
-#ifndef KFILEPLACESSELECTOR_P_H
-#define KFILEPLACESSELECTOR_P_H
-
-#include "kurlbutton_p.h"
-#include <kurl.h>
-
-class KFilePlacesModel;
-class KUrlNavigator;
-class KMenu;
-
-/**
- * @brief Allows to select a bookmark from a popup menu.
- *
- * The icon from the current selected bookmark is shown
- * inside the bookmark selector.
- *
- * @see UrlNavigator
- */
-class KFilePlacesSelector : public KUrlButton
-{
-    Q_OBJECT
-
-public:
-    /**
-     * @param parent Parent widget where the bookmark selector
-     *               is embedded into.
-     */
-    KFilePlacesSelector(KUrlNavigator* parent, KFilePlacesModel* placesModel);
-
-    virtual ~KFilePlacesSelector();
-
-    /**
-     * Updates the selection dependent from the given URL \a url. The
-     * URL must not match exactly to one of the available bookmarks:
-     * The bookmark which is equal to the URL or at least is a parent URL
-     * is selected. If there are more than one possible parent URL candidates,
-     * the bookmark which covers the bigger range of the URL is selected.
-     */
-    void updateSelection(const KUrl& url);
-
-    /** Returns the selected bookmark. */
-    KUrl selectedPlaceUrl() const;
-    /** Returns the selected bookmark. */
-    QString selectedPlaceText() const;
-
-    /** @see QWidget::sizeHint() */
-    virtual QSize sizeHint() const;
-
-Q_SIGNALS:
-    /**
-     * Is send when a bookmark has been activated by the user.
-     * @param url URL of the selected place.
-     */
-    void placeActivated(const KUrl& url);
-
-protected:
-    /**
-     * Draws the icon of the selected Url as content of the Url
-     * selector.
-     */
-    virtual void paintEvent(QPaintEvent* event);
-
-private Q_SLOTS:
-    /**
-     * Updates the selected index and the icon to the bookmark
-     * which is indicated by the triggered action \a action.
-     */
-    void activatePlace(QAction* action);
-
-    void updateMenu();
-
-private:
-    int m_selectedItem;
-    KUrlNavigator* m_urlNavigator;
-    KMenu* m_placesMenu;
-    KFilePlacesModel* m_placesModel;
-};
-
-#endif
diff --git a/src/kfileplacesview.cpp b/src/kfileplacesview.cpp
deleted file mode 100644 (file)
index 91cbd6d..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*  This file is part of the KDE project
-    Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License 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 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.
-
-*/
-
-#include "kfileplacesview.h"
-
-#include <kdebug.h>
-
-#include "kfileplacesmodel.h"
-
-class KFilePlacesView::Private
-{
-public:
-    Private(KFilePlacesView *parent) : q(parent) { }
-
-    KFilePlacesView * const q;
-
-    void _k_placeClicked(const QModelIndex &index);
-};
-
-KFilePlacesView::KFilePlacesView(QWidget *parent)
-    : QListView(parent), d(new Private(this))
-{
-    connect(this, SIGNAL(clicked(const QModelIndex&)),
-            this, SLOT(_k_placeClicked(const QModelIndex&)));
-}
-
-KFilePlacesView::~KFilePlacesView()
-{
-    delete d;
-}
-
-void KFilePlacesView::setUrl(const KUrl &url)
-{
-    kDebug() << k_funcinfo << endl;
-    KFilePlacesModel *placesModel = qobject_cast<KFilePlacesModel*>(model());
-
-    if (placesModel==0) return;
-
-    QModelIndex index = placesModel->closestItem(url);
-
-    if (index.isValid()) {
-        selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
-    } else {
-        selectionModel()->clear();
-    }
-}
-
-void KFilePlacesView::Private::_k_placeClicked(const QModelIndex &index)
-{
-    kDebug() << k_funcinfo << endl;
-    KFilePlacesModel *placesModel = qobject_cast<KFilePlacesModel*>(q->model());
-
-    if (placesModel==0) return;
-
-    emit q->urlChanged(placesModel->url(index));
-}
-
-#include "kfileplacesview.moc"
diff --git a/src/kfileplacesview.h b/src/kfileplacesview.h
deleted file mode 100644 (file)
index 84c9c05..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*  This file is part of the KDE project
-    Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License 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 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 KFILEPLACESVIEW_H
-#define KFILEPLACESVIEW_H
-
-#include <QListView>
-
-#include <kurl.h>
-
-class QAbstractItemModel;
-
-/**
- * This class allows to display a KFilePlacesModel.
- */
-class /*KIO_EXPORT*/ KFilePlacesView : public QListView
-{
-    Q_OBJECT
-public:
-    KFilePlacesView(QWidget *parent = 0);
-    ~KFilePlacesView();
-
-public Q_SLOTS:
-    void setUrl(const KUrl &url);
-
-Q_SIGNALS:
-    void urlChanged(const KUrl &url);
-
-private:
-    Q_PRIVATE_SLOT(d, void _k_placeClicked(const QModelIndex &))
-
-    class Private;
-    Private * const d;
-    friend class Private;
-};
-
-#endif
diff --git a/src/kprotocolcombo.cpp b/src/kprotocolcombo.cpp
deleted file mode 100644 (file)
index abe8825..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
- *                                                                         *
- *   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 <QMenu>
-
-#include <kdebug.h>
-#include <kprotocolinfo.h>
-#include <kprotocolmanager.h>
-
-#include "kprotocolcombo_p.h"
-
-const static int customProtocolIndex = 0;
-
-KProtocolCombo::KProtocolCombo(const QString& protocol, KUrlNavigator* parent)
-    : KUrlNavigatorButton(-1, parent),
-      m_protocols(KProtocolInfo::protocols())
-{
-    qSort(m_protocols);
-    QStringList::iterator it = m_protocols.begin();
-    QStringList::iterator itEnd = m_protocols.end();
-    QMenu* menu = new QMenu(this);
-    while (it != itEnd)
-    {
-        //kDebug() << "info for " << *it << " "
-        //          << KProtocolInfo::protocolClass(*it) << endl;
-        //TODO: wow this is ugly. or .. is it? ;) we need a way to determine
-        //      if a protocol is appropriate for use in a file manager. hum!
-        //if (KProtocolInfo::capabilities(*it).findIndex("filemanager") == -1)
-
-        // DF: why not just supportsListing?
-
-        if (KProtocolInfo::protocolClass(*it) == ":" ||
-            !KProtocolManager::supportsWriting(*it))
-        {
-        //kDebug() << "!!! removing " << *it << endl;
-            QStringList::iterator tempIt = it;
-            ++tempIt;
-            m_protocols.erase(it);
-            it = tempIt;
-        }
-        else
-        {
-            ++it;
-        }
-    }
-
-//    setEditable(true);
-//    menu->insertItem("", customProtocolIndex);
-//    menu->insertStringList(m_protocols);
-    int i = 0;
-    for (QStringList::const_iterator it = m_protocols.constBegin();
-         it != m_protocols.constEnd();
-         ++it, ++i)
-    {
-        menu->insertItem(*it, i);
-    }
-    //menu->insertItems(m_protocols);
-    connect(menu, SIGNAL(activated(int)), this, SLOT(setProtocol(int)));
-    setText(protocol);
-    setMenu(menu);
-    setFlat(true);
-}
-
-
-// #include <kurl.h>
-// #include "urlnavigator.h"
-void KProtocolCombo::setProtocol(const QString& protocol)
-{
-    setText(protocol);
-//    if (KProtocolInfo::isKnownProtocol(protocol))
-//     int index = m_protocols.findIndex(protocol);
-//     if (index == -1)
-//     {
-//         changeItem(protocol, customProtocolIndex);
-//         setCurrentItem(customProtocolIndex);
-//     }
-//     else
-//     {
-//         setCurrentItem(index + 1);
-//     }
-}
-
-void KProtocolCombo::setProtocol(int index)
-{
-    if (index < 0 || index > m_protocols.count())
-    {
-        return;
-    }
-
-    QString protocol = m_protocols[index];
-kDebug() << "setProtocol " << index << " " << protocol << endl;
-    setText(protocol);
-    emit activated(protocol);
-/*    */
-}
-
-QString KProtocolCombo::currentProtocol() const
-{
-    return text(); //currentText();
-}
-
-#include "kprotocolcombo_p.moc"
diff --git a/src/kprotocolcombo_p.h b/src/kprotocolcombo_p.h
deleted file mode 100644 (file)
index 8a58f5b..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
- *                                                                         *
- *   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          *
- ***************************************************************************/
-#ifndef KPROTOCOLCOMBO_P_H
-#define KPROTOCOLCOMBO_P_H
-
-#include "kurlnavigatorbutton_p.h"
-
-class KUrlNavigator;
-
-/**
- * A combobox listing available protocols
- */
-class KProtocolCombo : public KUrlNavigatorButton
-{
-    Q_OBJECT
-
-public:
-    explicit KProtocolCombo(const QString& protocol, KUrlNavigator* parent = 0);
-
-    QString currentProtocol() const;
-
-public Q_SLOTS:
-    void setProtocol(const QString& protocol);
-    void setProtocol(int index);
-
-Q_SIGNALS:
-    void activated(const QString& protocol);
-
-private:
-    QStringList m_protocols;
-};
-
-#endif
diff --git a/src/kurlbutton.cpp b/src/kurlbutton.cpp
deleted file mode 100644 (file)
index af2d563..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
- *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
- *                                                                         *
- *   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 "kurlbutton_p.h"
-
-#include "kurlnavigator.h"
-
-KUrlButton::KUrlButton(KUrlNavigator* parent) :
-    QPushButton(parent),
-    m_displayHint(0),
-    m_urlNavigator(parent)
-{
-    setFocusPolicy(Qt::NoFocus);
-    setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
-    setMinimumHeight(parent->minimumHeight());
-
-    connect(this, SIGNAL(clicked()), parent, SLOT(requestActivation()));
-}
-
-KUrlButton::~KUrlButton()
-{
-}
-
-void KUrlButton::setDisplayHintEnabled(DisplayHint hint,
-                                      bool enable)
-{
-    if (enable) {
-        m_displayHint = m_displayHint | hint;
-    }
-    else {
-        m_displayHint = m_displayHint & ~hint;
-    }
-    update();
-}
-
-bool KUrlButton::isDisplayHintEnabled(DisplayHint hint) const
-{
-    return (m_displayHint & hint) > 0;
-}
-
-void KUrlButton::enterEvent(QEvent* event)
-{
-    QPushButton::enterEvent(event);
-    setDisplayHintEnabled(EnteredHint, true);
-    update();
-}
-
-void KUrlButton::leaveEvent(QEvent* event)
-{
-    QPushButton::leaveEvent(event);
-    setDisplayHintEnabled(EnteredHint, false);
-    update();
-}
-
-QColor KUrlButton::mixColors(const QColor& c1,
-                            const QColor& c2) const
-{
-    const int red   = (c1.red()   + c2.red())   / 2;
-    const int green = (c1.green() + c2.green()) / 2;
-    const int blue  = (c1.blue()  + c2.blue())  / 2;
-    return QColor(red, green, blue);
-}
-
-#include "kurlbutton_p.moc"
diff --git a/src/kurlbutton_p.h b/src/kurlbutton_p.h
deleted file mode 100644 (file)
index ed0e314..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
- *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
- *                                                                         *
- *   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          *
- ***************************************************************************/
-
-#ifndef KURLBUTTON_P_H
-#define KURLBUTTON_P_H
-
-#include <QPushButton>
-
-class KUrl;
-class QEvent;
-class KUrlNavigator;
-
-/**
- * @brief Base class for buttons of the URL navigator.
- *
- * Each button of the URL navigator contains an URL, which
- * is set as soon as the button has been clicked.
- */
-class KUrlButton : public QPushButton
-{
-    Q_OBJECT
-
-public:
-    explicit KUrlButton(KUrlNavigator* parent);
-    virtual ~KUrlButton();
-
-    KUrlNavigator* urlNavigator() const { return m_urlNavigator; }
-
-protected:
-    enum DisplayHint {
-        ActivatedHint = 1,
-        EnteredHint = 2,
-        DraggedHint = 4,
-        PopupActiveHint = 8
-    };
-
-    void setDisplayHintEnabled(DisplayHint hint, bool enable);
-    bool isDisplayHintEnabled(DisplayHint hint) const;
-
-    virtual void enterEvent(QEvent* event);
-    virtual void leaveEvent(QEvent* event);
-
-    QColor mixColors(const QColor& c1, const QColor& c2) const;
-
-private:
-    int m_displayHint;
-    KUrlNavigator* m_urlNavigator;
-};
-
-#endif
diff --git a/src/kurlnavigator.cpp b/src/kurlnavigator.cpp
deleted file mode 100644 (file)
index 2d2cd8c..0000000
+++ /dev/null
@@ -1,823 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (<peter.penz@gmx.at>)                *
- *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
- *   Copyright (C) 2006 by Patrice Tremblay                                *
- *   Copyright (C) 2007 by Kevin Ottens (ervin@kde.org)                    *
- *                                                                         *
- *   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 "kurlnavigator.h"
-
-#include "kfileplacesselector_p.h"
-#include "kprotocolcombo_p.h"
-#include "kurlnavigatorbutton_p.h"
-
-#include <assert.h>
-
-#include <kfileitem.h>
-#include <kicon.h>
-#include <klocale.h>
-#include <kprotocolinfo.h>
-#include <kurlcombobox.h>
-#include <kurlcompletion.h>
-
-#include <QApplication>
-#include <QClipboard>
-#include <QDir>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QLineEdit>
-#include <QLinkedList>
-#include <QMouseEvent>
-#include <QToolButton>
-
-/**
- * @brief Represents the history element of an URL.
- *
- * A history element contains the URL, the name of the current file
- * (the 'current file' is the file where the cursor is located) and
- * the x- and y-position of the content.
- */
-class HistoryElem {
-public:
-    HistoryElem();
-    HistoryElem(const KUrl& url);
-    ~HistoryElem(); // non virtual
-
-    const KUrl& url() const { return m_url; }
-
-    void setCurrentFileName(const QString& name) { m_currentFileName = name; }
-    const QString& currentFileName() const { return m_currentFileName; }
-
-    void setContentsX(int x) { m_contentsX = x; }
-    int contentsX() const { return m_contentsX; }
-
-    void setContentsY(int y) { m_contentsY = y; }
-    int contentsY() const { return m_contentsY; }
-
-private:
-    KUrl m_url;
-    QString m_currentFileName;
-    int m_contentsX;
-    int m_contentsY;
-};
-
-HistoryElem::HistoryElem() :
-    m_url(),
-    m_currentFileName(),
-    m_contentsX(0),
-    m_contentsY(0)
-{
-}
-
-HistoryElem::HistoryElem(const KUrl& url) :
-    m_url(url),
-    m_currentFileName(),
-    m_contentsX(0),
-    m_contentsY(0)
-{
-}
-
-HistoryElem::~HistoryElem()
-{
-}
-
-class KUrlNavigator::Private
-{
-public:
-    Private(KUrlNavigator* q, KFilePlacesModel* placesModel);
-
-    void slotReturnPressed(const QString&);
-    void slotRemoteHostActivated();
-    void slotProtocolChanged(const QString&);
-
-    /**
-     * Appends the widget at the end of the URL navigator. It is assured
-     * that the filler widget remains as last widget to fill the remaining
-     * width.
-     */
-    void appendWidget(QWidget* widget);
-
-    /**
-     * Switches the navigation bar between the breadcrumb view and the
-     * traditional view (see setUrlEditable()) and is connected to the clicked signal
-     * of the navigation bar button.
-     */
-    void switchView();
-
-    /**
-     * Updates the history element with the current file item
-     * and the contents position.
-     */
-    void updateHistoryElem();
-    void updateContent();
-
-    /**
-     * Updates all buttons to have one button for each part of the
-     * path \a path. Existing buttons, which are available by m_navButtons,
-     * are reused if possible. If the path is longer, new buttons will be
-     * created, if the path is shorter, the remaining buttons will be deleted.
-     * @param startIndex    Start index of path part (/), where the buttons
-     *                      should be created for each following part.
-     */
-    void updateButtons(const QString& path, int startIndex);
-
-    /**
-     * Deletes all URL navigator buttons. m_navButtons is
-     * empty after this operation.
-     */
-    void deleteButtons();
-
-
-    bool m_active;
-    bool m_showHiddenFiles;
-    int m_historyIndex;
-
-    QHBoxLayout* m_layout;
-
-    QList<HistoryElem> m_history;
-    QToolButton* m_toggleButton;
-    KFilePlacesSelector* m_placesSelector;
-    KUrlComboBox* m_pathBox;
-    KProtocolCombo* m_protocols;
-    QLabel* m_protocolSeparator;
-    QLineEdit* m_host;
-    QLinkedList<KUrlNavigatorButton*> m_navButtons;
-    QWidget* m_filler;
-    QString m_homeUrl;
-    KUrlNavigator* q;
-};
-
-
-KUrlNavigator::Private::Private(KUrlNavigator* q, KFilePlacesModel* placesModel)
-    :
-    m_active(true),
-    m_showHiddenFiles(false),
-    m_historyIndex(0),
-    m_layout(new QHBoxLayout),
-    m_protocols(0),
-    m_protocolSeparator(0),
-    m_host(0),
-    m_filler(0),
-    q(q)
-{
-    m_layout->setSpacing(0);
-    m_layout->setMargin(0);
-
-    // initialize toggle button which switches between the breadcrumb view
-    // and the traditional view
-    m_toggleButton = new QToolButton();
-    m_toggleButton->setCheckable(true);
-    m_toggleButton->setAutoRaise(true);
-    m_toggleButton->setIcon(KIcon("editinput")); // TODO: is just a placeholder icon (?)
-    m_toggleButton->setFocusPolicy(Qt::NoFocus);
-    m_toggleButton->setMinimumHeight(q->minimumHeight());
-    connect(m_toggleButton, SIGNAL(clicked()),
-            q, SLOT(switchView()));
-
-    // initialize the places selector
-    m_placesSelector = new KFilePlacesSelector(q, placesModel);
-    connect(m_placesSelector, SIGNAL(placeActivated(const KUrl&)),
-            q, SLOT(setUrl(const KUrl&)));
-
-    // initialize the path box of the traditional view
-    m_pathBox = new KUrlComboBox(KUrlComboBox::Directories, true, q);
-
-    KUrlCompletion* kurlCompletion = new KUrlCompletion(KUrlCompletion::DirCompletion);
-    m_pathBox->setCompletionObject(kurlCompletion);
-    m_pathBox->setAutoDeleteCompletionObject(true);
-
-    connect(m_pathBox, SIGNAL(returnPressed(QString)),
-            q, SLOT(slotReturnPressed(QString)));
-    connect(m_pathBox, SIGNAL(urlActivated(KUrl)),
-            q, SLOT(setUrl(KUrl)));
-
-    // Append a filler widget at the end, which automatically resizes to the
-    // maximum available width. This assures that the URL navigator uses the
-    // whole width, so that the clipboard content can be dropped.
-    m_filler = new QWidget();
-    m_filler->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
-
-    m_layout->addWidget(m_toggleButton);
-    m_layout->addWidget(m_placesSelector);
-    m_layout->addWidget(m_pathBox);
-    m_layout->addWidget(m_filler);
-}
-
-void KUrlNavigator::Private::appendWidget(QWidget* widget)
-{
-    m_layout->insertWidget(m_layout->count() - 1, widget);
-}
-
-void KUrlNavigator::Private::slotReturnPressed(const QString& text)
-{
-    // Parts of the following code have been taken
-    // from the class KateFileSelector located in
-    // kate/app/katefileselector.hpp of Kate.
-    // Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
-    // Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
-    // Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
-
-    KUrl typedUrl(text);
-    if (typedUrl.hasPass()) {
-        typedUrl.setPass(QString());
-    }
-
-    QStringList urls = m_pathBox->urls();
-    urls.removeAll(typedUrl.url());
-    urls.prepend(typedUrl.url());
-    m_pathBox->setUrls(urls, KUrlComboBox::RemoveBottom);
-
-    q->setUrl(typedUrl);
-    // The URL might have been adjusted by KUrlNavigator::setUrl(), hence
-    // synchronize the result in the path box.
-    m_pathBox->setUrl(q->url());
-}
-
-void KUrlNavigator::Private::slotRemoteHostActivated()
-{
-    KUrl u = q->url();
-
-    QString host = m_host->text();
-    QString user;
-
-    int marker = host.indexOf("@");
-    if (marker != -1)
-    {
-        user = host.left(marker);
-        u.setUser(user);
-        host = host.right(host.length() - marker - 1);
-    }
-
-    marker = host.indexOf("/");
-    if (marker != -1)
-    {
-        u.setPath(host.right(host.length() - marker));
-        host.truncate(marker);
-    }
-    else
-    {
-        u.setPath("");
-    }
-
-    if (m_protocols->currentProtocol() != u.protocol() ||
-        host != u.host() ||
-        user != u.user())
-    {
-        u.setProtocol(m_protocols->currentProtocol());
-        u.setHost(m_host->text());
-
-        //TODO: get rid of this HACK for file:///!
-        if (u.protocol() == "file")
-        {
-            u.setHost("");
-            if (u.path().isEmpty())
-            {
-                u.setPath("/");
-            }
-        }
-
-        q->setUrl(u);
-    }
-}
-
-void KUrlNavigator::Private::slotProtocolChanged(const QString& protocol)
-{
-    KUrl url;
-    url.setProtocol(protocol);
-    //url.setPath(KProtocolInfo::protocolClass(protocol) == ":local" ? "/" : "");
-    url.setPath("/");
-    QLinkedList<KUrlNavigatorButton*>::const_iterator it = m_navButtons.begin();
-    const QLinkedList<KUrlNavigatorButton*>::const_iterator itEnd = m_navButtons.end();
-    while (it != itEnd) {
-        (*it)->close();
-        (*it)->deleteLater();
-        ++it;
-    }
-    m_navButtons.clear();
-
-    if (KProtocolInfo::protocolClass(protocol) == ":local") {
-        q->setUrl(url);
-    }
-    else {
-        if (!m_host) {
-            m_protocolSeparator = new QLabel("://", q);
-            appendWidget(m_protocolSeparator);
-            m_host = new QLineEdit(q);
-            appendWidget(m_host);
-
-            connect(m_host, SIGNAL(lostFocus()),
-                    q, SLOT(slotRemoteHostActivated()));
-            connect(m_host, SIGNAL(returnPressed()),
-                    q, SLOT(slotRemoteHostActivated()));
-        }
-        else {
-            m_host->setText("");
-        }
-        m_protocolSeparator->show();
-        m_host->show();
-        m_host->setFocus();
-    }
-}
-
-#if 0
-void KUrlNavigator::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
-{
-// kDebug() << "received redirection to " << newUrl << endl;
-kDebug() << "received redirection from " << oldUrl << " to " << newUrl << endl;
-/*    UrlStack::iterator it = m_urls.find(oldUrl);
-    if (it != m_urls.end())
-    {
-        m_urls.erase(++it, m_urls.end());
-    }
-
-    m_urls.append(newUrl);*/
-}
-#endif
-
-void KUrlNavigator::Private::switchView()
-{
-    updateContent();
-    if (q->isUrlEditable()) {
-        m_pathBox->setFocus();
-    } else {
-        q->setUrl(m_pathBox->currentText());
-    }
-    emit q->requestActivation();
-}
-
-void KUrlNavigator::Private::updateHistoryElem()
-{
-    assert(m_historyIndex >= 0);
-    const KFileItem* item = 0; // TODO: m_dolphinView->currentFileItem();
-    if (item != 0) {
-        HistoryElem& hist = m_history[m_historyIndex];
-        hist.setCurrentFileName(item->name());
-    }
-}
-
-void KUrlNavigator::Private::updateContent()
-{
-    m_placesSelector->updateSelection(q->url());
-
-    m_toggleButton->setToolTip(QString());
-    QString path(q->url().pathOrUrl());
-
-    // TODO: prevent accessing the DolphinMainWindow out from this scope
-    //const QAction* action = dolphinView()->mainWindow()->actionCollection()->action("editable_location");
-    // TODO: registry of default shortcuts
-    //QString shortcut = action? action->shortcut().toString() : "Ctrl+L";
-    const QString shortcut = "Ctrl+L";
-
-    if (m_toggleButton->isChecked()) {
-        delete m_protocols; m_protocols = 0;
-        delete m_protocolSeparator; m_protocolSeparator = 0;
-        delete m_host; m_host = 0;
-        deleteButtons();
-        m_filler->hide();
-
-        m_toggleButton->setToolTip(i18n("Browse (%1, Escape)", shortcut));
-
-        q->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
-        m_pathBox->show();
-        m_pathBox->setUrl(q->url());
-    }
-    else {
-        m_toggleButton->setToolTip(i18n("Edit location (%1)", shortcut));
-
-        q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-        m_pathBox->hide();
-        m_filler->show();
-
-        // get the data from the currently selected place
-        KUrl placeUrl = m_placesSelector->selectedPlaceUrl();
-
-        QString placePath;
-        if (!placeUrl.isValid()) {
-            // No place is a part of the current Url.
-            // The following code tries to guess the place
-            // path. E. g. "fish://root@192.168.0.2/var/lib" writes
-            // "fish://root@192.168.0.2" to 'placePath', which leads to the
-            // navigation indication 'Custom Path > var > lib".
-            int idx = path.indexOf(QString("//"));
-            idx = path.indexOf("/", (idx < 0) ? 0 : idx + 2);
-            placePath = (idx < 0) ? path : path.left(idx);
-        }
-        else {
-            placePath = placeUrl.pathOrUrl();
-        }
-        const uint len = placePath.length();
-
-        // calculate the start point for the URL navigator buttons by counting
-        // the slashs inside the place URL
-        int slashCount = 0;
-        for (uint i = 0; i < len; ++i) {
-            if (placePath.at(i) == QChar('/')) {
-                ++slashCount;
-            }
-        }
-        if ((len > 0) && placePath.at(len - 1) == QChar('/')) {
-            assert(slashCount > 0);
-            --slashCount;
-        }
-
-        const KUrl currentUrl = q->url();
-        if (!currentUrl.isLocalFile() && !placeUrl.isValid()) {
-            QString protocol = currentUrl.protocol();
-            if (!m_protocols) {
-                deleteButtons();
-                m_protocols = new KProtocolCombo(protocol, q);
-                appendWidget(m_protocols);
-                connect(m_protocols, SIGNAL(activated(QString)),
-                        q, SLOT(slotProtocolChanged(QString)));
-            }
-            else {
-                m_protocols->setProtocol(protocol);
-            }
-            m_protocols->show();
-
-            if (KProtocolInfo::protocolClass(protocol) != ":local") {
-                QString hostText = currentUrl.host();
-
-                if (!currentUrl.user().isEmpty()) {
-                    hostText = currentUrl.user() + '@' + hostText;
-                }
-
-                if (!m_host) {
-                    // ######### TODO: this code is duplicated from slotProtocolChanged!
-                    m_protocolSeparator = new QLabel("://", q);
-                    appendWidget(m_protocolSeparator);
-                    m_host = new QLineEdit(hostText, q);
-                    appendWidget(m_host);
-
-                    connect(m_host, SIGNAL(lostFocus()),
-                            q, SLOT(slotRemoteHostActivated()));
-                    connect(m_host, SIGNAL(returnPressed()),
-                            q, SLOT(slotRemoteHostActivated()));
-                }
-                else {
-                    m_host->setText(hostText);
-                }
-                m_protocolSeparator->show();
-                m_host->show();
-            }
-            else {
-                delete m_protocolSeparator; m_protocolSeparator = 0;
-                delete m_host; m_host = 0;
-            }
-        }
-        else if (m_protocols) {
-            m_protocols->hide();
-
-            if (m_host) {
-                m_protocolSeparator->hide();
-                m_host->hide();
-            }
-        }
-
-        updateButtons(path, slashCount);
-    }
-}
-
-void KUrlNavigator::Private::updateButtons(const QString& path, int startIndex)
-{
-    QLinkedList<KUrlNavigatorButton*>::iterator it = m_navButtons.begin();
-    const QLinkedList<KUrlNavigatorButton*>::const_iterator itEnd = m_navButtons.end();
-    bool createButton = false;
-    const KUrl currentUrl = q->url();
-
-    int idx = startIndex;
-    bool hasNext = true;
-    do {
-        createButton = (it == itEnd);
-
-        const QString dirName = path.section('/', idx, idx);
-        const bool isFirstButton = (idx == startIndex);
-        hasNext = isFirstButton || !dirName.isEmpty();
-        if (hasNext) {
-            QString text;
-            if (isFirstButton) {
-                // the first URL navigator button should get the name of the
-                // place instead of the directory name
-                const KUrl placeUrl = m_placesSelector->selectedPlaceUrl();
-                text = m_placesSelector->selectedPlaceText();
-                if (text.isEmpty()) {
-                    if (currentUrl.isLocalFile()) {
-                        text = i18n("Custom Path");
-                    }
-                    else {
-                        ++idx;
-                        continue;
-                    }
-                }
-            }
-
-            KUrlNavigatorButton* button = 0;
-            if (createButton) {
-                button = new KUrlNavigatorButton(idx, q);
-                appendWidget(button);
-            }
-            else {
-                button = *it;
-                button->setIndex(idx);
-            }
-
-            if (isFirstButton) {
-                button->setText(text);
-            }
-
-            if (createButton) {
-                button->show();
-                m_navButtons.append(button);
-            }
-            else {
-                ++it;
-            }
-            ++idx;
-        }
-    } while (hasNext);
-
-    // delete buttons which are not used anymore
-    QLinkedList<KUrlNavigatorButton*>::iterator itBegin = it;
-    while (it != itEnd) {
-        (*it)->close();
-        (*it)->deleteLater();
-        ++it;
-    }
-    m_navButtons.erase(itBegin, m_navButtons.end());
-}
-
-void KUrlNavigator::Private::deleteButtons()
-{
-    QLinkedList<KUrlNavigatorButton*>::iterator itBegin = m_navButtons.begin();
-    QLinkedList<KUrlNavigatorButton*>::iterator itEnd = m_navButtons.end();
-    QLinkedList<KUrlNavigatorButton*>::iterator it = itBegin;
-    while (it != itEnd) {
-        (*it)->close();
-        (*it)->deleteLater();
-        ++it;
-    }
-    m_navButtons.erase(itBegin, itEnd);
-}
-
-////
-
-
-KUrlNavigator::KUrlNavigator(KFilePlacesModel* placesModel,
-                           const KUrl& url,
-                           QWidget* parent) :
-    QWidget(parent),
-    d( new Private(this, placesModel) )
-{
-    d->m_history.prepend(HistoryElem(url));
-
-    QFontMetrics fontMetrics(font());
-    setMinimumHeight(fontMetrics.height() + 10);
-
-    setLayout(d->m_layout);
-
-    d->updateContent();
-}
-
-KUrlNavigator::~KUrlNavigator()
-{
-    delete d;
-}
-
-const KUrl& KUrlNavigator::url() const
-{
-    assert(!d->m_history.empty());
-    return d->m_history[d->m_historyIndex].url();
-}
-
-KUrl KUrlNavigator::url(int index) const
-{
-    assert(index >= 0);
-    // keep scheme, hostname etc. maybe we will need this in the future
-    // for e.g. browsing ftp repositories.
-    KUrl newurl(url());
-    newurl.setPath(QString());
-    QString path(url().path());
-
-    if (!path.isEmpty()) {
-        if (index == 0) //prevent the last "/" from being stripped
-            path = "/"; //or we end up with an empty path
-        else
-            path = path.section('/', 0, index);
-    }
-
-    newurl.setPath(path);
-    return newurl;
-}
-
-QPoint KUrlNavigator::savedPosition() const
-{
-    const HistoryElem& histElem = d->m_history[d->m_historyIndex];
-    return QPoint( histElem.contentsX(), histElem.contentsY() );
-}
-
-int KUrlNavigator::historySize() const
-{
-    return d->m_history.count();
-}
-
-void KUrlNavigator::goBack()
-{
-    d->updateHistoryElem();
-
-    const int count = d->m_history.count();
-    if (d->m_historyIndex < count - 1) {
-        ++d->m_historyIndex;
-        d->updateContent();
-        emit urlChanged(url());
-        emit historyChanged();
-    }
-}
-
-void KUrlNavigator::goForward()
-{
-    if (d->m_historyIndex > 0) {
-        --d->m_historyIndex;
-        d->updateContent();
-        emit urlChanged(url());
-        emit historyChanged();
-    }
-}
-
-void KUrlNavigator::goUp()
-{
-    setUrl(url().upUrl());
-}
-
-void KUrlNavigator::goHome()
-{
-    if (d->m_homeUrl.isEmpty())
-        setUrl(QDir::homePath());
-    else
-        setUrl(d->m_homeUrl);
-}
-
-bool KUrlNavigator::isUrlEditable() const
-{
-    return d->m_toggleButton->isChecked();
-}
-
-void KUrlNavigator::setUrlEditable(bool editable)
-{
-    if (isUrlEditable() != editable) {
-        d->m_toggleButton->toggle();
-        d->switchView();
-    }
-}
-
-void KUrlNavigator::setActive(bool active)
-{
-    if (active != d->m_active) {
-        d->m_active = active;
-        update();
-        if (active) {
-            emit activated();
-        }
-    }
-}
-
-void KUrlNavigator::setShowHiddenFiles( bool show )
-{
-    d->m_showHiddenFiles = show;
-}
-
-void KUrlNavigator::dropUrls(const KUrl::List& urls,
-                            const KUrl& destination)
-{
-    emit urlsDropped(urls, destination);
-}
-
-void KUrlNavigator::setUrl(const KUrl& url)
-{
-    QString urlStr(url.pathOrUrl());
-
-    // TODO: a patch has been submitted by Filip Brcic which adjusts
-    // the URL for tar and zip files. See https://bugs.kde.org/show_bug.cgi?id=142781
-    // for details. The URL navigator part of the patch has not been committed yet,
-    // as the URL navigator will be subject of change and
-    // we might think of a more generic approach to check the protocol + MIME type for
-    // this use case.
-
-    //kDebug() << "setUrl(" << url << ")" << endl;
-    if ( urlStr.length() > 0 && urlStr.at(0) == '~') {
-        // replace '~' by the home directory
-        urlStr.remove(0, 1);
-        urlStr.insert(0, QDir::homePath());
-    }
-
-    const KUrl transformedUrl(urlStr);
-
-    if (d->m_historyIndex > 0) {
-        // Check whether the previous element of the history has the same Url.
-        // If yes, just go forward instead of inserting a duplicate history
-        // element.
-        HistoryElem& prevHistoryElem = d->m_history[d->m_historyIndex - 1];
-        if (transformedUrl == prevHistoryElem.url()) {
-            goForward();
-//             kDebug() << "goin' forward in history" << endl;
-            return;
-        }
-    }
-
-    if (this->url() == transformedUrl) {
-        // don't insert duplicate history elements
-//         kDebug() << "current url == transformedUrl" << endl;
-        return;
-    }
-
-    d->updateHistoryElem();
-    d->m_history.insert(d->m_historyIndex, HistoryElem(transformedUrl));
-
-    d->updateContent();
-
-    emit urlChanged(transformedUrl);
-    emit historyChanged();
-
-    // Prevent an endless growing of the history: remembering
-    // the last 100 Urls should be enough...
-    if (d->m_historyIndex > 100) {
-        d->m_history.removeFirst();
-        --d->m_historyIndex;
-    }
-
-/*    kDebug() << "history starting ====================" << endl;
-    int i = 0;
-    for (QValueListIterator<KUrlNavigator::HistoryElem> it = d->m_history.begin();
-         it != d->m_history.end();
-         ++it, ++i)
-    {
-        kDebug() << i << ": " << (*it).url() << endl;
-    }
-    kDebug() << "history done ========================" << endl;*/
-
-    requestActivation();
-}
-
-void KUrlNavigator::requestActivation()
-{
-    setActive(true);
-}
-
-void KUrlNavigator::storeContentsPosition(int x, int y)
-{
-    HistoryElem& hist = d->m_history[d->m_historyIndex];
-    hist.setContentsX(x);
-    hist.setContentsY(y);
-}
-
-void KUrlNavigator::keyReleaseEvent(QKeyEvent* event)
-{
-    QWidget::keyReleaseEvent(event);
-    if (isUrlEditable() && (event->key() == Qt::Key_Escape)) {
-        setUrlEditable(false);
-    }
-}
-
-void KUrlNavigator::mouseReleaseEvent(QMouseEvent* event)
-{
-    if (event->button() == Qt::MidButton) {
-        QClipboard* clipboard = QApplication::clipboard();
-        const QMimeData* mimeData = clipboard->mimeData();
-        if (mimeData->hasText()) {
-            const QString text = mimeData->text();
-            setUrl(KUrl(text));
-        }
-    }
-    QWidget::mouseReleaseEvent(event);
-}
-
-bool KUrlNavigator::isActive() const
-{
-    return d->m_active;
-}
-
-bool KUrlNavigator::showHiddenFiles() const
-{
-    return d->m_showHiddenFiles;
-}
-
-void KUrlNavigator::setHomeUrl(const QString& homeUrl)
-{
-    d->m_homeUrl = homeUrl;
-}
-
-#include "kurlnavigator.moc"
diff --git a/src/kurlnavigator.h b/src/kurlnavigator.h
deleted file mode 100644 (file)
index 56e9761..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (<peter.penz@gmx.at>)                *
- *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
- *   Copyright (C) 2006 by Patrice Tremblay                                *
- *   Copyright (C) 2007 by Kevin Ottens (ervin@kde.org)                    *
- *                                                                         *
- *   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          *
- ***************************************************************************/
-
-#ifndef KURLNAVIGATOR_H
-#define KURLNAVIGATOR_H
-
-#include <kurl.h>
-#include <QWidget>
-
-class KFilePlacesModel;
-class QMouseEvent;
-
-/**
- * @brief Navigation bar which contains the current shown URL.
- *
- * The URL navigator offers two modes:
- * - Editable:     Represents the 'classic' mode, where the current URL
- *                 is editable inside a line editor.
- * - Non editable: The URL is represented by a number of buttons, where
- *                 clicking on a button results in activating the URL
- *                 the button represents. This mode also supports drag
- *                 and drop of items.
- *
- * The mode can be changed by a toggle button located on the left side of
- * the navigator.
- *
- * The URL navigator also remembers the URL history and allows to go
- * back and forward within this history.
- */
-class KUrlNavigator : public QWidget
-{
-    Q_OBJECT
-
-public:
-    KUrlNavigator(KFilePlacesModel* placesModel, const KUrl& url, QWidget* parent);
-    virtual ~KUrlNavigator();
-
-    /** Returns the current active URL. */
-    const KUrl& url() const;
-
-    /** Returns the portion of the current active URL up to the button at index. */
-    KUrl url(int index) const;
-
-    /** Returns the amount of items in the history */
-    int historySize() const;
-
-    /** Returns the saved position from the history */
-    QPoint savedPosition() const;
-
-    /**
-     * Goes back one step in the URL history. The signals
-     * UrlNavigator::urlChanged and UrlNavigator::historyChanged
-     * are submitted.
-     */
-    void goBack();
-
-    /**
-     * Goes forward one step in the URL history. The signals
-     * UrlNavigator::urlChanged and UrlNavigator::historyChanged
-     * are submitted.
-     */
-    void goForward();
-
-    /**
-     * Goes up one step of the URL path. The signals
-     * UrlNavigator::urlChanged and UrlNavigator::historyChanged
-     * are submitted.
-     */
-    void goUp();
-
-    /**
-     * Goes to the home URL. The signals UrlNavigator::urlChanged
-     * and UrlNavigator::historyChanged are submitted.
-     */
-    void goHome();
-
-    /**
-     * Sets the home URL used by goHome().
-     */
-    void setHomeUrl(const QString& homeUrl);
-
-    /**
-     * @return True, if the URL is editable by the user within a line editor.
-     *         If false is returned, each part of the URL is presented by a button
-     *         for fast navigation.
-     */
-    bool isUrlEditable() const;
-
-    /**
-     * Allows to edit the URL of the navigation bar if \a editable
-     * is true, and sets the focus accordingly.
-     * If \a editable is false, each part of
-     * the URL is presented by a button for a fast navigation.
-     */
-    void setUrlEditable(bool editable);
-
-    /**
-     * Set the URL navigator to the active mode, if \a active
-     * is true. The active mode is default. Using the URL navigator
-     * in the inactive mode is useful when having split views,
-     * where the inactive view is indicated by an inactive URL
-     * navigator visually.
-     */
-    void setActive(bool active);
-
-    /**
-     * Returns true, if the URL navigator is in the active mode.
-     * @see UrlNavigator::setActive()
-     */
-    bool isActive() const;
-
-    /**
-     * Sets whether or not to show hidden files in lists
-     */
-    void setShowHiddenFiles( bool show );
-
-    /**
-     * Returns true if the URL navigator is set to show hidden files
-     */
-    bool showHiddenFiles() const; // TODO rename, looks like a verb
-
-    /**
-     * Handles the dropping of the URLs \a urls to the given
-     * destination \a destination and emits the signal urlsDropped.
-     */
-    void dropUrls(const KUrl::List& urls,
-                  const KUrl& destination);
-
-public Q_SLOTS:
-    /**
-     * Sets the current active URL.
-     * The signals UrlNavigator::urlChanged and UrlNavigator::historyChanged
-     * are submitted.
-     */
-    void setUrl(const KUrl& url);
-
-    /**
-     * Activates the URL navigator (UrlNavigator::isActive() will return true)
-     * and emits the signal 'activationChanged()'.
-     */
-    void requestActivation();
-
-    /**
-     * Stores the coordinates of the contents into
-     * the current history element.
-     */
-    void storeContentsPosition(int x, int y);
-
-Q_SIGNALS:
-    /**
-     * Is emitted, if the URL navigator has been activated by
-     * a user interaction.
-     */
-    void activated();
-
-    /**
-     * Is emitted, if the URL has been changed e. g. by
-     * the user.
-     * @see setUrl()
-     */
-    void urlChanged(const KUrl& url);
-
-    /**
-     * Is emitted, if the history has been changed. Usually
-     * the history is changed if a new URL has been selected.
-     */
-    void historyChanged();
-
-    /**
-     * Is emitted if the URLs \a urls have been dropped
-     * to the destination \a destination.
-     */
-    void urlsDropped(const KUrl::List& urls,
-                     const KUrl& destination);
-
-protected:
-    /**
-     * If the Escape key is pressed, the navigation bar should switch
-     * to the browse mode.
-     */
-    virtual void keyReleaseEvent(QKeyEvent* event);
-
-    /**
-     * Paste the clipboard content as URL, if the middle mouse
-     * button has been clicked.
-     */
-    virtual void mouseReleaseEvent(QMouseEvent* event);
-
-private:
-    Q_PRIVATE_SLOT(d, void slotReturnPressed(const QString& text))
-    Q_PRIVATE_SLOT(d, void slotRemoteHostActivated())
-    Q_PRIVATE_SLOT(d, void slotProtocolChanged(const QString& protocol))
-    Q_PRIVATE_SLOT(d, void switchView())
-    //Q_PRIVATE_SLOT(d, void slotRedirection(const KUrl&, const KUrl&))
-
-private:
-    class Private;
-    Private* const d;
-
-    Q_DISABLE_COPY( KUrlNavigator )
-};
-
-#endif
diff --git a/src/kurlnavigatorbutton.cpp b/src/kurlnavigatorbutton.cpp
deleted file mode 100644 (file)
index 2e8f5fe..0000000
+++ /dev/null
@@ -1,361 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
- *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
- *                                                                         *
- *   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 "kurlnavigatorbutton_p.h"
-
-#include <assert.h>
-
-#include "kurlnavigator.h"
-
-#include <kio/job.h>
-#include <kio/jobclasses.h>
-#include <kglobalsettings.h>
-#include <kmenu.h>
-
-#include <QPainter>
-#include <QPaintEvent>
-#include <QTimer>
-
-KUrlNavigatorButton::KUrlNavigatorButton(int index, KUrlNavigator* parent) :
-    KUrlButton(parent),
-    m_index(-1),
-    m_popupDelay(0),
-    m_listJob(0)
-{
-    setAcceptDrops(true);
-    setMinimumWidth(arrowWidth());
-    setIndex(index);
-    connect(this, SIGNAL(clicked()), this, SLOT(updateNavigatorUrl()));
-
-    m_popupDelay = new QTimer(this);
-    m_popupDelay->setSingleShot(true);
-    connect(m_popupDelay, SIGNAL(timeout()), this, SLOT(startListJob()));
-    connect(this, SIGNAL(pressed()), this, SLOT(startPopupDelay()));
-}
-
-KUrlNavigatorButton::~KUrlNavigatorButton()
-{
-}
-
-void KUrlNavigatorButton::setIndex(int index)
-{
-    m_index = index;
-
-    if (m_index < 0) {
-        return;
-    }
-
-    QString path(urlNavigator()->url().pathOrUrl());
-    setText(path.section('/', index, index));
-
-    // Check whether the button indicates the full path of the Url. If
-    // this is the case, the button is marked as 'active'.
-    ++index;
-    QFont adjustedFont(font());
-    if (path.section('/', index, index).isEmpty()) {
-        setDisplayHintEnabled(ActivatedHint, true);
-        adjustedFont.setBold(true);
-    }
-    else {
-        setDisplayHintEnabled(ActivatedHint, false);
-        adjustedFont.setBold(false);
-    }
-
-    setFont(adjustedFont);
-    update();
-}
-
-QSize KUrlNavigatorButton::sizeHint() const
-{
-    const int width = fontMetrics().width(text()) + (arrowWidth() * 4);
-    return QSize(width, KUrlButton::sizeHint().height());
-}
-
-void KUrlNavigatorButton::paintEvent(QPaintEvent* event)
-{
-    QPainter painter(this);
-    painter.setClipRect(event->rect());
-    const int buttonWidth  = width();
-    const int buttonHeight = height();
-
-    QColor backgroundColor;
-    QColor foregroundColor;
-    const bool isHighlighted = isDisplayHintEnabled(EnteredHint) ||
-                               isDisplayHintEnabled(DraggedHint) ||
-                               isDisplayHintEnabled(PopupActiveHint);
-    if (isHighlighted) {
-        backgroundColor = KGlobalSettings::highlightColor();
-        foregroundColor = KGlobalSettings::highlightedTextColor();
-    }
-    else {
-        backgroundColor = palette().brush(QPalette::Background).color();
-        foregroundColor = KGlobalSettings::buttonTextColor();
-    }
-
-    // dimm the colors if the parent view does not have the focus
-    const bool isActive = urlNavigator()->isActive();
-    if (!isActive) {
-        QColor dimmColor(palette().brush(QPalette::Background).color());
-        foregroundColor = mixColors(foregroundColor, dimmColor);
-        if (isHighlighted) {
-            backgroundColor = mixColors(backgroundColor, dimmColor);
-        }
-    }
-
-    // draw button background
-    painter.setPen(Qt::NoPen);
-    painter.setBrush(backgroundColor);
-    painter.drawRect(0, 0, buttonWidth, buttonHeight);
-
-    int textWidth = buttonWidth;
-    if (isDisplayHintEnabled(ActivatedHint) && isActive || isHighlighted) {
-        painter.setPen(foregroundColor);
-    }
-    else {
-        // dimm the foreground color by mixing it with the background
-        foregroundColor = mixColors(foregroundColor, backgroundColor);
-        painter.setPen(foregroundColor);
-    }
-
-    if (!isDisplayHintEnabled(ActivatedHint)) {
-        // draw arrow
-        const int border = 2;  // horizontal border
-        const int middleY = height() / 2;
-        const int width = arrowWidth();
-        const int startX = (buttonWidth - width) - (2 * border);
-        const int startTopY = middleY - (width - 1);
-        const int startBottomY = middleY + (width - 1);
-        for (int i = 0; i < width; ++i) {
-            painter.drawLine(startX, startTopY + i, startX + i, startTopY + i);
-            painter.drawLine(startX, startBottomY - i, startX + i, startBottomY - i);
-        }
-
-        textWidth = startX - border;
-    }
-
-    const bool clipped = isTextClipped();
-    const int align = clipped ? Qt::AlignVCenter : Qt::AlignCenter;
-    const QRect textRect(0, 0, textWidth, buttonHeight);
-    if (clipped) {
-        QLinearGradient gradient(textRect.topLeft(), textRect.topRight());
-        gradient.setColorAt(0.8, foregroundColor);
-        gradient.setColorAt(1.0, backgroundColor);
-
-        QPen pen;
-        pen.setBrush(QBrush(gradient));
-        painter.setPen(pen);
-        painter.drawText(textRect, align, text());
-    }
-    else {
-        painter.drawText(textRect, align, text());
-    }
-}
-
-void KUrlNavigatorButton::enterEvent(QEvent* event)
-{
-    KUrlButton::enterEvent(event);
-
-    // if the text is clipped due to a small window width, the text should
-    // be shown as tooltip
-    if (isTextClipped()) {
-        setToolTip(text());
-    }
-}
-
-void KUrlNavigatorButton::leaveEvent(QEvent* event)
-{
-    KUrlButton::leaveEvent(event);
-    setToolTip(QString());
-}
-
-void KUrlNavigatorButton::dropEvent(QDropEvent* event)
-{
-    if (m_index < 0) {
-        return;
-    }
-
-    const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
-    if (!urls.isEmpty()) {
-        event->acceptProposedAction();
-
-        setDisplayHintEnabled(DraggedHint, true);
-
-        QString path(urlNavigator()->url().prettyUrl());
-        path = path.section('/', 0, m_index + 2);
-
-        urlNavigator()->dropUrls(urls, KUrl(path));
-
-        setDisplayHintEnabled(DraggedHint, false);
-        update();
-    }
-}
-
-void KUrlNavigatorButton::dragEnterEvent(QDragEnterEvent* event)
-{
-    if (event->mimeData()->hasUrls()) {
-        setDisplayHintEnabled(DraggedHint, true);
-        event->acceptProposedAction();
-
-        update();
-    }
-}
-
-void KUrlNavigatorButton::dragLeaveEvent(QDragLeaveEvent* event)
-{
-    KUrlButton::dragLeaveEvent(event);
-
-    setDisplayHintEnabled(DraggedHint, false);
-    update();
-}
-
-
-void KUrlNavigatorButton::updateNavigatorUrl()
-{
-    stopPopupDelay();
-
-    if (m_index < 0) {
-        return;
-    }
-
-    urlNavigator()->setUrl(urlNavigator()->url(m_index));
-}
-
-void KUrlNavigatorButton::startPopupDelay()
-{
-    if (m_popupDelay->isActive() || (m_listJob != 0) || (m_index < 0)) {
-        return;
-    }
-
-    m_popupDelay->start(300);
-}
-
-void KUrlNavigatorButton::stopPopupDelay()
-{
-    m_popupDelay->stop();
-    if (m_listJob != 0) {
-        m_listJob->kill();
-        m_listJob = 0;
-    }
-}
-
-void KUrlNavigatorButton::startListJob()
-{
-    if (m_listJob != 0) {
-        return;
-    }
-
-    const KUrl& url = urlNavigator()->url(m_index);
-    m_listJob = KIO::listDir(url, false, urlNavigator()->showHiddenFiles());
-    m_subdirs.clear(); // just to be ++safe
-
-    connect(m_listJob, SIGNAL(entries(KIO::Job*, const KIO::UDSEntryList &)),
-            this, SLOT(entriesList(KIO::Job*, const KIO::UDSEntryList&)));
-    connect(m_listJob, SIGNAL(result(KJob*)), this, SLOT(listJobFinished(KJob*)));
-}
-
-void KUrlNavigatorButton::entriesList(KIO::Job* job, const KIO::UDSEntryList& entries)
-{
-    if (job != m_listJob) {
-        return;
-    }
-
-    KIO::UDSEntryList::const_iterator it = entries.constBegin();
-    KIO::UDSEntryList::const_iterator itEnd = entries.constEnd();
-
-    bool showHidden = urlNavigator()->showHiddenFiles();
-    while (it != itEnd) {
-        const KIO::UDSEntry entry = *it;
-        if (entry.isDir()) {
-            QString name = entry.stringValue(KIO::UDS_NAME);
-
-            if (!showHidden || (name != "." && name != "..")) {
-                m_subdirs.append(name);
-            }
-        }
-
-        ++it;
-    }
-
-    m_subdirs.sort();
-}
-
-void KUrlNavigatorButton::listJobFinished(KJob* job)
-{
-    if (job != m_listJob) {
-        return;
-    }
-
-    if (job->error() || m_subdirs.isEmpty()) {
-        // clear listing
-        return;
-    }
-
-    setDisplayHintEnabled(PopupActiveHint, true);
-    update(); // ensure the button is drawn highlighted
-
-    KMenu* dirsMenu = new KMenu(this);
-    QStringList::const_iterator it = m_subdirs.constBegin();
-    QStringList::const_iterator itEnd = m_subdirs.constEnd();
-    int i = 0;
-    while (it != itEnd) {
-        QAction* action = new QAction(*it, this);
-        action->setData(i);
-        dirsMenu->addAction(action);
-        ++it;
-        ++i;
-    }
-
-    const QAction* action = dirsMenu->exec(urlNavigator()->mapToGlobal(geometry().bottomLeft()));
-    if (action != 0) {
-        const int result = action->data().toInt();
-        KUrl url = urlNavigator()->url(m_index);
-        url.addPath(m_subdirs[result]);
-        urlNavigator()->setUrl(url);
-    }
-
-    m_listJob = 0;
-    m_subdirs.clear();
-    delete dirsMenu;
-    dirsMenu = 0;
-
-    setDisplayHintEnabled(PopupActiveHint, false);
-}
-
-int KUrlNavigatorButton::arrowWidth() const
-{
-    int width = (height() / 2) - 7;
-    if (width < 4) {
-        width = 4;
-    }
-    return width;
-}
-
-bool KUrlNavigatorButton::isTextClipped() const
-{
-    int availableWidth = width();
-    if (!isDisplayHintEnabled(ActivatedHint)) {
-        availableWidth -= arrowWidth() + 1;
-    }
-
-    QFontMetrics fontMetrics(font());
-    return fontMetrics.width(text()) >= availableWidth;
-}
-
-#include "kurlnavigatorbutton_p.moc"
diff --git a/src/kurlnavigatorbutton_p.h b/src/kurlnavigatorbutton_p.h
deleted file mode 100644 (file)
index 606ccb1..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
- *   Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>)               *
- *                                                                         *
- *   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          *
- ***************************************************************************/
-
-#ifndef KURLNAVIGATORBUTTON_P_H
-#define KURLNAVIGATORBUTTON_P_H
-
-#include <kio/global.h>
-#include "kurlbutton_p.h"
-
-class KJob;
-class KUrl;
-class KUrlNavigator;
-class QPainter;
-class QPaintEvent;
-
-namespace KIO
-{
-    class Job;
-}
-
-/**
- * @brief Button of the URL navigator which contains one part of an URL.
- *
- * It is possible to drop a various number of items to an UrlNavigatorButton. In this case
- * a context menu is opened where the user must select whether he wants
- * to copy, move or link the dropped items to the URL part indicated by
- * the button.
- */
-class KUrlNavigatorButton : public KUrlButton
-{
-    Q_OBJECT
-
-public:
-    explicit KUrlNavigatorButton(int index, KUrlNavigator* parent);
-    virtual ~KUrlNavigatorButton();
-    void setIndex(int index);
-    int index() const { return m_index; }
-
-    /** @see QWidget::sizeHint() */
-    virtual QSize sizeHint() const;
-
-protected:
-    virtual void paintEvent(QPaintEvent* event);
-    virtual void enterEvent(QEvent* event);
-    virtual void leaveEvent(QEvent* event);
-    virtual void dropEvent(QDropEvent* event);
-    virtual void dragEnterEvent(QDragEnterEvent* event);
-    virtual void dragLeaveEvent(QDragLeaveEvent* event);
-
-private Q_SLOTS:
-    void updateNavigatorUrl();
-    void startPopupDelay();
-    void stopPopupDelay();
-    void startListJob();
-    void entriesList(KIO::Job* job, const KIO::UDSEntryList& entries);
-    void listJobFinished(KJob* job);
-
-private:
-    int arrowWidth() const;
-    bool isTextClipped() const;
-
-private:
-    int m_index;
-    QTimer* m_popupDelay;
-    KIO::Job* m_listJob;
-    QStringList m_subdirs;
-};
-
-#endif