]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Internal cleanup for panels: Let the panel-implementations decide whether they accept...
authorPeter Penz <peter.penz19@gmail.com>
Thu, 7 Oct 2010 14:09:30 +0000 (14:09 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 7 Oct 2010 14:09:30 +0000 (14:09 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1183480

src/panels/folders/folderspanel.cpp
src/panels/folders/folderspanel.h
src/panels/information/informationpanel.cpp
src/panels/information/informationpanel.h
src/panels/information/informationpanelcontent.cpp
src/panels/information/informationpanelcontent.h
src/panels/panel.cpp
src/panels/panel.h
src/panels/terminal/terminalpanel.cpp
src/panels/terminal/terminalpanel.h

index 134d8ba7e32b57413a55f2c210e5f3939777aa60..fae7ca6a17003cc6841a893b24d9fb2cbad917d8 100644 (file)
@@ -103,23 +103,20 @@ void FoldersPanel::rename(const KFileItem& item)
     }
 }
 
-void FoldersPanel::setUrl(const KUrl& url)
+bool FoldersPanel::urlChanged()
 {
-    if (!url.isValid() || (url == Panel::url())) {
-        return;
-    }
-
-    if (url.protocol().contains("search")) {
+    if (!url().isValid() || url().protocol().contains("search")) {
         // Skip results shown by a search, as possible identical
         // directory names are useless without parent-path information.
-        return;
+        return false;
     }
 
-    Panel::setUrl(url);
     if (m_dirLister != 0) {
         m_setLeafVisible = true;
-        loadTree(url);
+        loadTree(url());
     }
+
+    return true;
 }
 
 void FoldersPanel::showEvent(QShowEvent* event)
index 438a9ee686c382ee5c7d242dd92598c591620502..972dc13a767ef6fa22c93673330586cf3f0172d6 100644 (file)
@@ -59,13 +59,10 @@ signals:
      */
     void changeUrl(const KUrl& url, Qt::MouseButtons buttons);
 
-public slots:
-    /**
-     * Changes the current selection inside the tree to \a url.
-     */
-    virtual void setUrl(const KUrl& url);
-
 protected:
+    /** @see Panel::urlChanged() */
+    virtual bool urlChanged();
+
     /** @see QWidget::showEvent() */
     virtual void showEvent(QShowEvent* event);
 
index c18cc7fdb96f69bc3e835f6e3811f48f7dc23df2..d45974a48a0c5b0c0fda0d63c90aa9457ea496ff 100644 (file)
@@ -52,24 +52,6 @@ QSize InformationPanel::sizeHint() const
     return size;
 }
 
-void InformationPanel::setUrl(const KUrl& url)
-{
-    Panel::setUrl(url);
-    if (!url.isValid() || isEqualToShownUrl(url)) {
-        return;
-    }
-
-    m_shownUrl = url;
-    if (isVisible()) {
-        cancelRequest();
-        // Update the content with a delay. This gives
-        // the directory lister the chance to show the content
-        // before expensive operations are done to show
-        // meta information.
-        m_urlChangedTimer->start();
-    }
-}
-
 void InformationPanel::setSelection(const KFileItemList& selection)
 {
     if (!isVisible()) {
@@ -126,6 +108,25 @@ void InformationPanel::requestDelayedItemInfo(const KFileItem& item)
     }
 }
 
+bool InformationPanel::urlChanged()
+{
+    if (!url().isValid() || isEqualToShownUrl(url())) {
+        return false;
+    }
+
+    m_shownUrl = url();
+    if (isVisible()) {
+        cancelRequest();
+        // Update the content with a delay. This gives
+        // the directory lister the chance to show the content
+        // before expensive operations are done to show
+        // meta information.
+        m_urlChangedTimer->start();
+    }
+
+    return true;
+}
+
 void InformationPanel::showEvent(QShowEvent* event)
 {
     Panel::showEvent(event);
index e0768bc1b3efe1142fb698d66f7479ec959ef714..abd7ed811ee93847cf08960b548a4d191bf15460 100644 (file)
@@ -42,9 +42,6 @@ signals:
     void urlActivated(const KUrl& url);
 
 public slots:
-    /** @see Panel::setUrl() */
-    virtual void setUrl(const KUrl& url);
-
     /**
      * This is invoked to inform the panel that the user has selected a new
      * set of items.
@@ -60,6 +57,9 @@ public slots:
     void requestDelayedItemInfo(const KFileItem& item);
 
 protected:
+    /** @see Panel::urlChanged() */
+    virtual bool urlChanged();
+
     /** @see QWidget::showEvent() */
     virtual void showEvent(QShowEvent* event);
 
index 3b9a179605a125b94d1cf28083c4f2364b140d60..b6a41ca3d211c12d13b4f36b1e9854e2c347d946 100644 (file)
@@ -55,7 +55,7 @@
 #include "pixmapviewer.h"
 
 InformationPanelContent::InformationPanelContent(QWidget* parent) :
-    Panel(parent),
+    QWidget(parent),
     m_item(),
     m_pendingPreview(false),
     m_outdatedPreviewTimer(0),
@@ -262,7 +262,7 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
         break;
     }
 
-    return Panel::eventFilter(obj, event);
+    return QWidget::eventFilter(obj, event);
 }
 
 void InformationPanelContent::configureSettings()
index cb712627df6777218dbcc01b067b69a5a037635f..f918b8582a8233ec54ad1f72c5d4809fd37bd612 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2009-2010 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  *
 #ifndef INFORMATIONPANELCONTENT_H
 #define INFORMATIONPANELCONTENT_H
 
-#include <panels/panel.h>
-
 #include <kconfig.h>
+#include <kfileitem.h>
 #include <kurl.h>
 #include <kvbox.h>
 
-class KFileItem;
+class KFileItemList;
 class KFileMetaDataWidget;
 class PhononWidget;
 class PixmapViewer;
@@ -39,7 +38,7 @@ class QScrollArea;
  * @brief Manages the widgets that display the meta information
 *         for file items of the Information Panel.
  */
-class InformationPanelContent : public Panel
+class InformationPanelContent : public QWidget
 {
     Q_OBJECT
 
index 9e7ff4ff3afdd10f624bad47d230e34414c375d5..6d11422d8a6cbea1a1dc45cd29f46abc2408d0ed 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  *   Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com>       *
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2006-2010 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  *
@@ -31,14 +31,23 @@ Panel::~Panel()
 {
 }
 
-const KUrl& Panel::url() const
+KUrl Panel::url() const
 {
     return m_url;
 }
 
 void Panel::setUrl(const KUrl& url)
 {
+    if (url.equals(m_url, KUrl::CompareWithoutTrailingSlash)) {
+        return;
+    }
+
+    const KUrl oldUrl = m_url;
     m_url = url;
+    const bool accepted = urlChanged();
+    if (!accepted) {
+        m_url = oldUrl;
+    }
 }
 
 #include "panel.moc"
index b056ca1cb08e1e19df8d87ec0e7d0f96175bb53e..11558e2defc5fa1d70a38004ba9032322f47c7ff 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  *   Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com>       *
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2006-2010 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  *
@@ -37,14 +37,24 @@ public:
     virtual ~Panel();
 
     /** Returns the current set URL of the active Dolphin view. */
-    const KUrl& url() const;
+    KUrl url() const;
 
 public slots:
     /**
      * This is invoked every time the folder being displayed in the
      * active Dolphin view changes.
      */
-    virtual void setUrl(const KUrl& url);
+    void setUrl(const KUrl& url);
+
+protected:
+    /**
+     * Must be implemented by derived classes and is invoked when
+     * the URL has been changed (see Panel::setUrl()).
+     * @return True, if the new URL will get accepted by the derived
+     *         class. If false is returned,
+     *         the URL will be reset to the previous URL.
+     */
+    virtual bool urlChanged() = 0;
 
 private:
     KUrl m_url;
index d6b3703293b5fb328edde02766d1e51bbbc133a7..12b319f3c6da0a270d2296af65116ef1f1580ed6 100644 (file)
@@ -52,26 +52,26 @@ QSize TerminalPanel::sizeHint() const
     return size;
 }
 
-void TerminalPanel::setUrl(const KUrl& url)
+void TerminalPanel::terminalExited()
 {
-    if (!url.isValid() || (url == Panel::url())) {
-        return;
-    }
+    emit hideTerminalPanel();
+    m_terminal = 0;
+}
 
-    Panel::setUrl(url);
+bool TerminalPanel::urlChanged()
+{
+    if (!url().isValid()) {
+        return false;
+    }
 
     const bool sendInput = (m_terminal != 0)
                            && (m_terminal->foregroundProcessId() == -1)
                            && isVisible();
     if (sendInput) {
-        changeDir(url);
+        changeDir(url());
     }
-}
 
-void TerminalPanel::terminalExited()
-{
-    emit hideTerminalPanel();
-    m_terminal = 0;
+    return true;
 }
 
 void TerminalPanel::showEvent(QShowEvent* event)
index 91a75a989cc76b232e3b567ce8ee8ba3db4a7431..b9508279ec94f58825b333ed27920b60158b0afe 100644 (file)
@@ -46,14 +46,15 @@ public:
     virtual QSize sizeHint() const;
 
 public slots:
-    /** @see Panel::setUrl(). */
-    virtual void setUrl(const KUrl& url);
     void terminalExited();
 
 signals:
     void hideTerminalPanel();
 
 protected:
+    /** @see Panel::urlChanged() */
+    virtual bool urlChanged();
+
     /** @see QWidget::showEvent() */
     virtual void showEvent(QShowEvent* event);