]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Cleanup of the URL navigator, so that the DolphinMainWindow and the DolphinView are...
authorPeter Penz <peter.penz19@gmail.com>
Sat, 17 Feb 2007 10:31:52 +0000 (10:31 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 17 Feb 2007 10:31:52 +0000 (10:31 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=634432

src/bookmarkselector.cpp
src/bookmarkselector.h
src/dolphinmainwindow.cpp
src/dolphinview.cpp
src/dolphinview.h
src/urlbutton.cpp
src/urlbutton.h
src/urlnavigator.cpp
src/urlnavigator.h
src/urlnavigatorbutton.cpp
src/urlnavigatorbutton.h

index 59f30e30a32c687d19664309dc37947d23ae8864..44b7055945d1a917d21144a16a8eae192ea0e33a 100644 (file)
@@ -1,6 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz                                      *
- *   peter.penz@gmx.at                                                     *
+ *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
  *                                                                         *
  *   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  *
@@ -18,6 +17,7 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
+#include "bookmarkselector.h"
 
 #include <assert.h>
 #include <q3popupmenu.h>
 #include <kglobalsettings.h>
 #include <kbookmarkmanager.h>
 
-#include "bookmarkselector.h"
 #include "dolphinsettings.h"
-#include "dolphinview.h"
-#include "dolphinmainwindow.h"
 #include "urlnavigator.h"
 
 BookmarkSelector::BookmarkSelector(UrlNavigator* parent) :
     UrlButton(parent),
-    m_selectedIndex(0)
+    m_selectedIndex(0),
+    m_urlNavigator(parent)
 {
     setFocusPolicy(Qt::NoFocus);
 
@@ -113,7 +111,7 @@ QSize BookmarkSelector::sizeHint() const
     return QSize(height, height);
 }
 
-void BookmarkSelector::paintEvent(QPaintEvent* event)
+void BookmarkSelector::paintEvent(QPaintEvent* /*event*/)
 {
     QPainter painter(this);
 
@@ -134,10 +132,7 @@ void BookmarkSelector::paintEvent(QPaintEvent* event)
     }
 
     // dimm the colors if the parent view does not have the focus
-    const DolphinView* parentView = urlNavigator()->dolphinView();
-    const DolphinMainWindow* dolphin = parentView->mainWindow();
-
-    const bool isActive = (dolphin->activeView() == parentView);
+    const bool isActive = m_urlNavigator->isActive();
     if (!isActive) {
         QColor dimmColor(palette().brush(QPalette::Background).color());
         foregroundColor = mixColors(foregroundColor, dimmColor);
@@ -168,10 +163,9 @@ void BookmarkSelector::slotBookmarkActivated(int index)
 {
     m_selectedIndex = index;
 
-    KBookmark bookmark = selectedBookmark();
+    const KBookmark bookmark = selectedBookmark();
     setPixmap(SmallIcon(bookmark.icon()));
-
-    emit bookmarkActivated(index);
+    emit bookmarkActivated(bookmark.url());
 }
 
 #include "bookmarkselector.moc"
index c662618ec5a32d8fe42c0f87b47c4463f89af081..50fc2e3e5799b76b5f0ae6feaad5a414ac66824f 100644 (file)
@@ -1,6 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz                                      *
- *   peter.penz@gmx.at                                                     *
+ *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
  *                                                                         *
  *   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  *
@@ -35,7 +34,6 @@ class KUrl;
  * inside the bookmark selector.
  *
  * @see UrlNavigator
- * @author Peter Penz <peter.penz@gmx.at>
  */
 class BookmarkSelector : public UrlButton
 {
@@ -74,9 +72,9 @@ public:
 signals:
     /**
      * Is send when a bookmark has been activated by the user.
-     * @param index Index of the selected bookmark.
+     * @param url URL of the selected bookmark.
      */
-    void bookmarkActivated(int index);
+    void bookmarkActivated(const KUrl& url);
 
 protected:
     /**
@@ -94,6 +92,7 @@ private slots:
 
 private:
     int m_selectedIndex;
+    UrlNavigator* m_urlNavigator;
     Q3PopupMenu* m_bookmarksMenu;
 
 };
index 262bc8558f9f8891a0fa33d5f92d8b3ef47d8a5e..e8071ac443ffddb621e82fc0cc653e09a7f6f0fa 100644 (file)
@@ -702,6 +702,7 @@ void DolphinMainWindow::toggleSplitView()
             setActiveView(m_view[PrimaryIdx]);\r
         }\r
     }\r
+    emit activeViewChanged();\r
 }\r
 \r
 void DolphinMainWindow::reloadView()\r
index 58c33b250027e3c0e9ee46b24a252885a4de8a59..86b864583dd7c41c6e80b8f76ab55e24b963c443 100644 (file)
@@ -79,9 +79,18 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow,
     m_topLayout->setSpacing(0);
     m_topLayout->setMargin(0);
 
+    connect(m_mainWindow, SIGNAL(activeViewChanged()),
+            this, SLOT(updateActivationState()));
+
     m_urlNavigator = new UrlNavigator(url, this);
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
             this, SLOT(loadDirectory(const KUrl&)));
+    connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&)),
+            this, SLOT(dropUrls(const KUrl::List&, const KUrl&)));
+    connect(m_urlNavigator, SIGNAL(activated()),
+            this, SLOT(requestActivation()));
+    connect(this, SIGNAL(contentsMoved(int, int)),
+            m_urlNavigator, SLOT(storeContentsPosition(int, int)));
 
     m_statusBar = new DolphinStatusBar(this);
 
@@ -165,7 +174,7 @@ const KUrl& DolphinView::url() const
 
 bool DolphinView::isActive() const
 {
-    return (mainWindow()->activeView() == this);
+    return m_mainWindow->activeView() == this;
 }
 
 void DolphinView::setMode(Mode mode)
@@ -554,11 +563,6 @@ void DolphinView::reload()
     startDirLister(m_urlNavigator->url(), true);
 }
 
-void DolphinView::declareViewActive()
-{
-    mainWindow()->setActiveView( this );
-}
-
 void DolphinView::mouseReleaseEvent(QMouseEvent* event)
 {
     QWidget::mouseReleaseEvent(event);
@@ -886,9 +890,16 @@ void DolphinView::dropUrls(const KUrl::List& urls,
 
     const KUrl& destination = (directory == 0) ? url() :
                                                  directory->url();
+    dropUrls(urls, destination);
+}
+
+void DolphinView::dropUrls(const KUrl::List& urls,
+                           const KUrl& destination)
+{
     m_mainWindow->dropUrls(urls, destination);
 }
 
+
 void DolphinView::updateSorting(DolphinView::Sorting sorting)
 {
     ViewProperties props(url());
@@ -914,6 +925,11 @@ void DolphinView::emitContentsMoved()
     emit contentsMoved(contentsX(), contentsY());
 }
 
+void DolphinView::updateActivationState()
+{
+    m_urlNavigator->setActive(isActive());
+}
+
 void DolphinView::createView()
 {
     // delete current view
index 4bb254f42fd5515757af1ec1517a2282e5830b61..cffa52880d5722095c716f6fac543bca5a0c9d78 100644 (file)
@@ -327,11 +327,6 @@ public:
     /** Reloads the current directory. */
     void reload();
 
-    /**
-     * Declare this View as the activeview of the mainWindow()
-     */
-    void declareViewActive();
-
 public slots:
     /**
      * Popups the filter bar above the status bar if \a show is true.
@@ -445,6 +440,12 @@ private slots:
     void dropUrls(const KUrl::List& urls,
                   const QPoint& pos);
 
+    /**
+     * Drops the URLs \a urls at the
+     * destination \a destination.
+     */
+    void dropUrls(const KUrl::List& urls,
+                  const KUrl& destination);
     /**
      * Updates the view properties of the current URL to the
      * sorting given by \a sorting.
@@ -463,6 +464,12 @@ private slots:
      */
     void emitContentsMoved();
 
+    /**
+     * Updates the activation state of the view by checking whether
+     * the currently active view is this view.
+     */
+    void updateActivationState();
+
 private:
     void startDirLister(const KUrl& url, bool reload = false);
 
index f2bf8ccdac643b43c0d1b8cd2ec12044b1dbe852..b1faae393915e1949bafecc047f824de15f65ca2 100644 (file)
 #include "dolphinmainwindow.h"
 
 
-UrlButton::UrlButton(UrlNavigator* parent)
-: QPushButton(parent),
-  m_displayHint(0),
-  m_urlNavigator(parent)
+UrlButton::UrlButton(UrlNavigator* 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(slotRequestActivation()));
-    connect(parent->dolphinView()->mainWindow(), SIGNAL(activeViewChanged()),
-            this, SLOT(update()));
+    connect(this, SIGNAL(clicked()), parent, SLOT(requestActivation()));
 }
 
 UrlButton::~UrlButton()
 {
 }
 
-UrlNavigator* UrlButton::urlNavigator() const
-{
-    return m_urlNavigator;
-}
-
 void UrlButton::setDisplayHintEnabled(DisplayHint hint,
                                       bool enable)
 {
index 4c88a7d3a7986b9dd7fc29fad0e0c623b63199df..06da18aba4c665d05219dd8418045409c92dab05 100644 (file)
@@ -44,7 +44,7 @@ public:
     explicit UrlButton(UrlNavigator* parent);
     virtual ~UrlButton();
 
-    UrlNavigator* urlNavigator() const;
+    UrlNavigator* urlNavigator() const { return m_urlNavigator; }
 
 protected:
     enum DisplayHint {
index d7c586961c632c72c510e61af5f5eee110426b24..93de43e67817e186c654bfe057ec9d51c5f1ce5a 100644 (file)
@@ -34,6 +34,7 @@
 #include <qsizepolicy.h>
 #include <qtooltip.h>
 //Added by qt3to4:
+#include <QDir>
 #include <Q3ValueList>
 #include <QKeyEvent>
 #include <QCheckBox>
@@ -42,6 +43,7 @@
 #include <kactioncollection.h>
 #include <kiconloader.h>
 #include <kio/job.h>
+#include <kfileitem.h>
 #include <klocale.h>
 #include <kprotocolinfo.h>
 #include <kurl.h>
 #include <kvbox.h>
 
 #include "bookmarkselector.h"
-#include "dolphinmainwindow.h"
 #include "dolphinsettings.h"
-#include "dolphinstatusbar.h"
-#include "dolphinview.h"
 #include "generalsettings.h"
 #include "protocolcombo.h"
 #include "urlnavigatorbutton.h"
 
-UrlNavigator::HistoryElem::HistoryElem()
:  m_url(),
+UrlNavigator::HistoryElem::HistoryElem() :
   m_url(),
     m_currentFileName(),
     m_contentsX(0),
     m_contentsY(0)
 {
 }
 
-UrlNavigator::HistoryElem::HistoryElem(const KUrl& url)
:  m_url(url),
+UrlNavigator::HistoryElem::HistoryElem(const KUrl& url) :
   m_url(url),
     m_currentFileName(),
     m_contentsX(0),
     m_contentsY(0)
@@ -80,10 +79,10 @@ UrlNavigator::HistoryElem::~HistoryElem()
 }
 
 UrlNavigator::UrlNavigator(const KUrl& url,
-                           DolphinView* dolphinView) :
-    KHBox(dolphinView),
+                           QWidget* parent) :
+    KHBox(parent),
+    m_active(true),
     m_historyIndex(0),
-    m_dolphinView(dolphinView),
     m_protocols(0),
     m_protocolSeparator(0),
     m_host(0)
@@ -105,8 +104,8 @@ UrlNavigator::UrlNavigator(const KUrl& url,
     }
 
     m_bookmarkSelector = new BookmarkSelector(this);
-    connect(m_bookmarkSelector, SIGNAL(bookmarkActivated(int)),
-            this, SLOT(slotBookmarkActivated(int)));
+    connect(m_bookmarkSelector, SIGNAL(bookmarkActivated(const KUrl&)),
+            this, SLOT(setUrl(const KUrl&)));
 
     m_pathBox = new KUrlComboBox(KUrlComboBox::Directories, true, this);
 
@@ -119,12 +118,8 @@ UrlNavigator::UrlNavigator(const KUrl& url,
     connect(m_pathBox, SIGNAL(urlActivated(const KUrl&)),
             this, SLOT(slotUrlActivated(const KUrl&)));
 
-    connect(dolphinView, SIGNAL(contentsMoved(int, int)),
-            this, SLOT(slotContentsMoved(int, int)));
-    connect(dolphinView, SIGNAL(redirection(const KUrl&, const KUrl&)),
-            this, SLOT(slotRedirection(const KUrl&, const KUrl&)));
-/*    connect(dolphinView, SIGNAL(redirection(const KUrl&)),
-            this, SLOT(slotRedirection(const KUrl&)));*/
+    //connect(dolphinView, SIGNAL(redirection(const KUrl&, const KUrl&)),
+    //        this, SLOT(slotRedirection(const KUrl&, const KUrl&)));
     updateContent();
 }
 
@@ -132,65 +127,6 @@ UrlNavigator::~UrlNavigator()
 {
 }
 
-void UrlNavigator::setUrl(const KUrl& url)
-{
-    QString urlStr(url.pathOrUrl());
-    //kDebug() << "setUrl(" << url << ")" << endl;
-    if ( urlStr.length() > 0 && urlStr.at(0) == '~') {
-        // replace '~' by the home directory
-        urlStr.remove(0, 1);
-        urlStr.insert(0, QDir::home().path());
-    }
-
-    const KUrl transformedUrl(urlStr);
-
-    if (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.
-        const KUrl& nextUrl = m_history[m_historyIndex - 1].url();
-        if (transformedUrl == nextUrl) {
-            goForward();
-//             kDebug() << "goin' forward in history" << endl;
-            return;
-        }
-    }
-
-    const KUrl& currUrl = m_history[m_historyIndex].url();
-    if (currUrl == transformedUrl) {
-        // don't insert duplicate history elements
-//         kDebug() << "currUrl == transformedUrl" << endl;
-        return;
-    }
-
-    updateHistoryElem();
-
-    const Q3ValueListIterator<UrlNavigator::HistoryElem> it = m_history.at(m_historyIndex);
-    m_history.insert(it, HistoryElem(transformedUrl));
-
-    updateContent();
-
-    emit urlChanged(transformedUrl);
-    emit historyChanged();
-
-    // Prevent an endless growing of the history: remembering
-    // the last 100 Urls should be enough...
-    if (m_historyIndex > 100) {
-        m_history.erase(m_history.begin());
-        --m_historyIndex;
-    }
-
-/*    kDebug() << "history starting ====================" << endl;
-    int i = 0;
-    for (QValueListIterator<UrlNavigator::HistoryElem> it = m_history.begin();
-         it != m_history.end();
-         ++it, ++i)
-    {
-        kDebug() << i << ": " << (*it).url() << endl;
-    }
-    kDebug() << "history done ========================" << endl;*/
-}
-
 const KUrl& UrlNavigator::url() const
 {
     assert(!m_history.empty());
@@ -273,9 +209,95 @@ void UrlNavigator::editUrl(bool editOrBrowse)
     }
 }
 
-DolphinView* UrlNavigator::dolphinView() const
+void UrlNavigator::setActive(bool active)
+{
+    if (active != m_active) {
+        m_active = active;
+        update();
+        if (active) {
+            emit activated();
+        }
+    }
+}
+
+void UrlNavigator::dropUrls(const KUrl::List& urls,
+                            const KUrl& destination)
+{
+    kDebug() << "------------------- URLS dropped" << endl;
+    emit urlsDropped(urls, destination);
+}
+
+void UrlNavigator::setUrl(const KUrl& url)
+{
+    QString urlStr(url.pathOrUrl());
+    //kDebug() << "setUrl(" << url << ")" << endl;
+    if ( urlStr.length() > 0 && urlStr.at(0) == '~') {
+        // replace '~' by the home directory
+        urlStr.remove(0, 1);
+        urlStr.insert(0, QDir::home().path());
+    }
+
+    const KUrl transformedUrl(urlStr);
+
+    if (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.
+        const KUrl& nextUrl = m_history[m_historyIndex - 1].url();
+        if (transformedUrl == nextUrl) {
+            goForward();
+//             kDebug() << "goin' forward in history" << endl;
+            return;
+        }
+    }
+
+    const KUrl& currUrl = m_history[m_historyIndex].url();
+    if (currUrl == transformedUrl) {
+        // don't insert duplicate history elements
+//         kDebug() << "currUrl == transformedUrl" << endl;
+        return;
+    }
+
+    updateHistoryElem();
+
+    const Q3ValueListIterator<UrlNavigator::HistoryElem> it = m_history.at(m_historyIndex);
+    m_history.insert(it, HistoryElem(transformedUrl));
+
+    updateContent();
+
+    emit urlChanged(transformedUrl);
+    emit historyChanged();
+
+    // Prevent an endless growing of the history: remembering
+    // the last 100 Urls should be enough...
+    if (m_historyIndex > 100) {
+        m_history.erase(m_history.begin());
+        --m_historyIndex;
+    }
+
+/*    kDebug() << "history starting ====================" << endl;
+    int i = 0;
+    for (QValueListIterator<UrlNavigator::HistoryElem> it = m_history.begin();
+         it != m_history.end();
+         ++it, ++i)
+    {
+        kDebug() << i << ": " << (*it).url() << endl;
+    }
+    kDebug() << "history done ========================" << endl;*/
+
+    requestActivation();
+}
+
+void UrlNavigator::requestActivation()
+{
+    kDebug() << "--------------------------- request activation" << endl;
+    setActive(true);
+}
+
+void UrlNavigator::storeContentsPosition(int x, int y)
 {
-    return m_dolphinView;
+    m_history[m_historyIndex].setContentsX(x);
+    m_history[m_historyIndex].setContentsY(y);
 }
 
 void UrlNavigator::keyReleaseEvent(QKeyEvent* event)
@@ -399,20 +421,6 @@ void UrlNavigator::slotProtocolChanged(const QString& protocol)
     }
 }
 
-void UrlNavigator::slotRequestActivation()
-{
-    m_dolphinView->requestActivation();
-}
-
-void UrlNavigator::slotBookmarkActivated(int index)
-{
-    m_dolphinView->statusBar()->clear();
-    m_dolphinView->requestActivation();
-
-    KBookmark bookmark = DolphinSettings::instance().bookmark(index);
-    m_dolphinView->setUrl(bookmark.url());
-}
-
 void UrlNavigator::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
 {
 // kDebug() << "received redirection to " << newUrl << endl;
@@ -426,12 +434,6 @@ kDebug() << "received redirection from " << oldUrl << " to " << newUrl << endl;
     m_urls.append(newUrl);*/
 }
 
-void UrlNavigator::slotContentsMoved(int x, int y)
-{
-    m_history[m_historyIndex].setContentsX(x);
-    m_history[m_historyIndex].setContentsY(y);
-}
-
 void UrlNavigator::slotClicked()
 {
     if (isUrlEditable()) {
@@ -440,7 +442,7 @@ void UrlNavigator::slotClicked()
     }
     else {
         setUrl(m_pathBox->currentText());
-        m_dolphinView->setFocus();
+        emit requestActivation();
     }
 }
 
@@ -451,8 +453,6 @@ void UrlNavigator::updateHistoryElem()
     if (item != 0) {
         m_history[m_historyIndex].setCurrentFileName(item->name());
     }
-    m_history[m_historyIndex].setContentsX(m_dolphinView->contentsX());
-    m_history[m_historyIndex].setContentsY(m_dolphinView->contentsY());
 }
 
 void UrlNavigator::updateContent()
@@ -470,22 +470,26 @@ void UrlNavigator::updateContent()
 
     m_toggleButton->setToolTip(QString());
     QString path(url().pathOrUrl());
-    const QAction* action = dolphinView()->mainWindow()->actionCollection()->action("editable_location");
+
+    // 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";
+    //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;
 
-        m_toggleButton->setToolTip(i18n("Browse (%1, Escape)",shortcut));
+        m_toggleButton->setToolTip(i18n("Browse (%1, Escape)", shortcut));
 
         setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
         m_pathBox->show();
         m_pathBox->setUrl(url());
     }
     else {
-        m_toggleButton->setToolTip(i18n("Edit location (%1)",shortcut));
+        m_toggleButton->setToolTip(i18n("Edit location (%1)", shortcut));
 
         setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
         m_pathBox->hide();
index 5e7477a1c9cac43547371d75b0a52b2d8cdd82d1..bafece2ea98e179ac4909e257ecd1add8eb33630 100644 (file)
@@ -42,7 +42,6 @@ class KFileItem;
 class KUrlComboBox;
 
 class BookmarkSelector;
-class DolphinView;
 class ProtocolCombo;
 
 /**
@@ -103,16 +102,9 @@ public:
         int m_contentsY;
     };
 
-    UrlNavigator(const KUrl& url, DolphinView* dolphinView);
+    UrlNavigator(const KUrl& url, QWidget* parent);
     virtual ~UrlNavigator();
 
-    /**
-     * Sets the current active Url.
-     * The signals UrlNavigator::urlChanged and UrlNavigator::historyChanged
-     * are submitted.
-     */
-    void setUrl(const KUrl& url);
-
     /** Returns the current active Url. */
     const KUrl& url() const;
 
@@ -167,12 +159,75 @@ public:
      */
     void editUrl(bool editOrBrowse); //TODO: switch to an enum
 
-    DolphinView* dolphinView() const;
+    /**
+     * 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 a 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 { return m_active; }
+
+    /**
+     * 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 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);
 
 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. */
@@ -183,19 +238,8 @@ private slots:
     void slotUrlActivated(const KUrl& url);
     void slotRemoteHostActivated();
     void slotProtocolChanged(const QString& protocol);
-
-    void slotRequestActivation();
-    void slotBookmarkActivated(int index);
-
     void slotRedirection(const KUrl&, const KUrl&);
 
-    /**
-     * Stores the coordinates of the moved content into
-     * the current history element. Is usually triggered
-     * by the signal 'contentsMoved' emitted by DolphinView.
-     */
-    void slotContentsMoved(int x, int y);
-
     /**
      * Switches the navigation bar between the editable and noneditable
      * state (see setUrlEditable()) and is connected to the clicked signal
@@ -204,8 +248,8 @@ private slots:
     void slotClicked();
 
 private:
+    bool m_active;
     int m_historyIndex;
-    DolphinView* m_dolphinView;
     Q3ValueList<HistoryElem> m_history;
     QCheckBox* m_toggleButton;
     BookmarkSelector* m_bookmarkSelector;
index 9fe2186dab1dec9ed9c8e355467a6a832bd9d907..9616558a56564f25ef5d0f00b9496136bb8f8676 100644 (file)
  ***************************************************************************/
 
 #include "urlnavigatorbutton.h"
-#include <qcursor.h>
-#include <qfontmetrics.h>
-#include <qpainter.h>
-#include <qtimer.h>
-#include <qtooltip.h>
-//Added by qt3to4:
-#include <QDropEvent>
-#include <QDragLeaveEvent>
-#include <Q3PopupMenu>
-#include <QEvent>
-#include <QDragEnterEvent>
+
+#include <assert.h>
+
+#include "urlnavigator.h"
 
 #include <kglobalsettings.h>
 #include <kiconloader.h>
+#include <kio/job.h>
 #include <kio/jobclasses.h>
 #include <klocale.h>
 #include <kurl.h>
-#include <assert.h>
 
-#include "urlnavigator.h"
-#include "dolphinview.h"
-#include "dolphinmainwindow.h"
+#include <Q3PopupMenu>
+#include <QPainter>
+#include <QTimer>
 
 UrlNavigatorButton::UrlNavigatorButton(int index, UrlNavigator* parent) :
     UrlButton(parent),
     m_index(-1),
+    m_popupDelay(0),
     m_listJob(0)
 {
     setAcceptDrops(true);
@@ -117,10 +111,7 @@ void UrlNavigatorButton::paintEvent(QPaintEvent* event)
     }
 
     // dimm the colors if the parent view does not have the focus
-    const DolphinView* parentView = urlNavigator()->dolphinView();
-    const DolphinMainWindow* dolphin = parentView->mainWindow();
-
-    const bool isActive = (dolphin->activeView() == parentView);
+    const bool isActive = urlNavigator()->isActive();
     if (!isActive) {
         QColor dimmColor(palette().brush(QPalette::Background).color());
         foregroundColor = mixColors(foregroundColor, dimmColor);
@@ -218,8 +209,7 @@ void UrlNavigatorButton::dropEvent(QDropEvent* event)
         QString path(urlNavigator()->url().prettyUrl());
         path = path.section('/', 0, m_index + 2);
 
-        DolphinMainWindow* win = urlNavigator()->dolphinView()->mainWindow();
-        win->dropUrls(urls, KUrl(path));
+        urlNavigator()->dropUrls(urls, KUrl(path));
 
         setDisplayHintEnabled(DraggedHint, false);
         update();
@@ -251,9 +241,7 @@ void UrlNavigatorButton::updateNavigatorUrl()
         return;
     }
 
-    UrlNavigator* navigator = urlNavigator();
-    assert(navigator != 0);
-    navigator->setUrl(navigator->url(m_index));
+    urlNavigator()->setUrl(urlNavigator()->url(m_index));
 }
 
 void UrlNavigatorButton::startPopupDelay()
@@ -300,7 +288,7 @@ void UrlNavigatorButton::entriesList(KIO::Job* job, const KIO::UDSEntryList& ent
     KIO::UDSEntryList::const_iterator itEnd = entries.constEnd();
     while (it != itEnd) {
         QString name;
-        bool isDir = false;
+        //bool isDir = false;
         KIO::UDSEntry entry = *it;
 
         /* KDE3 reference:
index 0ddaf66a3d100eaec6a41d82b60949dda65f3b32..9234f0b104972f834ccba1d001342abe8c651ebe 100644 (file)
 #ifndef UrlNAVIGATORBUTTON_H
 #define UrlNAVIGATORBUTTON_H
 
-#include <qstringlist.h>
-#include <QEvent>
-#include <QDragLeaveEvent>
-#include <QDropEvent>
-#include <QDragEnterEvent>
-
 #include <kio/global.h>
-
 #include <urlbutton.h>
 
+class KJob;
 class KUrl;
 class UrlNavigator;
 class QPainter;
@@ -52,7 +46,7 @@ class UrlNavigatorButton : public UrlButton
     Q_OBJECT
 
 public:
-    explicit UrlNavigatorButton(int index, UrlNavigator* parent = 0);
+    explicit UrlNavigatorButton(int index, UrlNavigator* parent);
     virtual ~UrlNavigatorButton();
     void setIndex(int index);
     int index() const { return m_index; }
@@ -80,6 +74,7 @@ private:
     int arrowWidth() const;
     bool isTextClipped() const;
 
+private:
     int m_index;
     QTimer* m_popupDelay;
     KIO::Job* m_listJob;