]> cloud.milkyroute.net Git - dolphin.git/commitdiff
some cleanups for the sidebar pages (move protected members to private section etc.)
authorPeter Penz <peter.penz19@gmail.com>
Sun, 6 May 2007 17:25:50 +0000 (17:25 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 6 May 2007 17:25:50 +0000 (17:25 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=661815

src/infosidebarpage.cpp
src/infosidebarpage.h
src/sidebarpage.cpp
src/sidebarpage.h
src/treeviewsidebarpage.cpp
src/treeviewsidebarpage.h

index 7de4d882e531fad74ae462058ab94b34cc445073..530d1fb307c4210616466fc7d854b390d75861f5 100644 (file)
@@ -54,7 +54,6 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
     m_multipleSelection(false), //TODO: check if I'm needed
     m_pendingPreview(false),
     m_timer(0),
-    m_currentSelection(KFileItemList()),
     m_preview(0),
     m_name(0),
     m_infos(0),
@@ -126,8 +125,8 @@ void InfoSidebarPage::setUrl(const KUrl& url)
 void InfoSidebarPage::setSelection(const KFileItemList& selection)
 {
     cancelRequest();
-    m_currentSelection = selection;
-    m_multipleSelection = (m_currentSelection.size() > 1);
+    SidebarPage::setSelection(selection);
+    m_multipleSelection = (selection.size() > 1);
     showItemInfo();
 }
 
@@ -146,7 +145,8 @@ void InfoSidebarPage::showItemInfo()
 {
     cancelRequest();
 
-    KFileItemList selectedItems = m_currentSelection;
+    const KFileItemList& selectedItems = selection();
+
     KUrl file;
     if (selectedItems.count() == 0) {
         file = m_shownUrl;
@@ -246,7 +246,8 @@ void InfoSidebarPage::cancelRequest()
 void InfoSidebarPage::createMetaInfo()
 {
     beginInfoLines();
-    if (m_currentSelection.size() == 0) {
+    const KFileItemList& selectedItems = selection();
+    if (selectedItems.size() == 0) {
         KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
         fileItem.refresh();
 
@@ -256,8 +257,8 @@ void InfoSidebarPage::createMetaInfo()
         if (MetaDataWidget::metaDataAvailable()) {
             m_metadataWidget->setFile(fileItem.url());
         }
-    } else if (m_currentSelection.count() == 1) {
-        KFileItem* fileItem = m_currentSelection.at(0);
+    } else if (selectedItems.count() == 1) {
+        KFileItem* fileItem = selectedItems.at(0);
         addInfoLine(i18n("Type:"), fileItem->mimeComment());
 
         QString sizeText(KIO::convertSize(fileItem->size()));
@@ -279,11 +280,11 @@ void InfoSidebarPage::createMetaInfo()
         }
     } else {
         if (MetaDataWidget::metaDataAvailable()) {
-            m_metadataWidget->setFiles(m_currentSelection.urlList());
+            m_metadataWidget->setFiles(selectedItems.urlList());
         }
 
         unsigned long int totSize = 0;
-        foreach(KFileItem* item, m_currentSelection) {
+        foreach(KFileItem* item, selectedItems) {
             totSize += item->size(); //FIXME what to do with directories ? (same with the one-item-selected-code), item->size() does not return the size of the content : not very instinctive for users
         }
         addInfoLine(i18n("Total size:"), KIO::convertSize(totSize));
index 8d84512e992d139ac0efded5c0f871a9d0c2d71e..ffa18d497164455aa1f1242e736f7d9281f0ade2 100644 (file)
@@ -49,9 +49,7 @@ class PixmapViewer;
 class MetaDataWidget;
 
 /**
- * @brief Prototype for a information sidebar.
- *
- * Will be exchanged in future releases by pluggable sidebar pages...
+ * @brief Sidebar for showing meta information of one ore more selected items.
  */
 class InfoSidebarPage : public SidebarPage
 {
@@ -62,8 +60,8 @@ public:
     virtual ~InfoSidebarPage();
 
 public slots:
-    void setUrl(const KUrl& url);
-    void setSelection(const KFileItemList& selection);
+    virtual void setUrl(const KUrl& url);
+    virtual void setSelection(const KFileItemList& selection);
 
 private slots:
     /**
@@ -130,7 +128,6 @@ private:
     QTimer* m_timer;
     KUrl m_shownUrl;
     KUrl m_urlCandidate;
-    KFileItemList m_currentSelection;
 
     PixmapViewer* m_preview;
     QLabel* m_name;
index c6c120f0e1af54b475d712399c55f06f4643878e..479bfcad0e9164f0b3a5f2fa286c3b450217fa5e 100644 (file)
@@ -1,5 +1,6 @@
 /***************************************************************************
  *   Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com>       *
+ *   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  *
 #include <kurl.h>
 
 SidebarPage::SidebarPage(QWidget* parent) :
-        QWidget(parent),
-        m_url(KUrl()),
-        m_currentSelection(KFileItemList())
-{}
+    QWidget(parent),
+    m_url(KUrl()),
+    m_currentSelection(KFileItemList())
+{
+}
 
 SidebarPage::~SidebarPage()
-{}
+{
+}
+
+const KUrl& SidebarPage::url() const
+{
+    return m_url;
+}
+
+const KFileItemList& SidebarPage::selection() const
+{
+    return m_currentSelection;
+}
 
 void SidebarPage::setUrl(const KUrl& url)
 {
index 587e435c14bfddca9260bbb7b116e684a280971a..cf9704bca3c5e8897738eab5978b359e779a2146 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 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  *
@@ -27,7 +27,6 @@
 
 /**
  * @brief Base widget for all pages that can be embedded into the Sidebar.
- *
  */
 class SidebarPage : public QWidget
 {
@@ -36,16 +35,22 @@ public:
     explicit SidebarPage(QWidget* parent = 0);
     virtual ~SidebarPage();
 
+    /** Returns the current set URL of the active Dolphin view. */
+    const KUrl& url() const;
+
+    /** Returns the current selected items of the active Dolphin view. */
+    const KFileItemList& selection() const;
+
 public slots:
     /**
      * This is invoked every time the folder being displayed in the
-     * file-management views changes.
+     * active Dolphin view changes.
      */
     virtual void setUrl(const KUrl& url);
 
     /**
      * This is invoked to inform the sidebar that the user has selected a new
-     * set of files.
+     * set of items.
      */
     virtual void setSelection(const KFileItemList& selection);
 
@@ -73,7 +78,7 @@ signals:
      */
     void urlsDropped(const KUrl::List& urls, const KUrl& destination);
 
-protected:
+private:
     KUrl m_url;
     KFileItemList m_currentSelection;
 };
index ef75baf952749aee02bc1573075fc4c01b001e53..28fc93397eef52def2128a20d48b589696b6d313 100644 (file)
@@ -81,11 +81,11 @@ TreeViewSidebarPage::~TreeViewSidebarPage()
 
 void TreeViewSidebarPage::setUrl(const KUrl& url)
 {
-    if (!url.isValid() || (url == m_url)) {
+    if (!url.isValid() || (url == SidebarPage::url())) {
         return;
     }
 
-    m_url = url;
+    SidebarPage::setUrl(url);
 
     // adjust the root of the tree to the base bookmark
     KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
@@ -156,7 +156,7 @@ void TreeViewSidebarPage::expandSelectionParent()
                this, SLOT(expandSelectionParent()));
 
     // expand the parent folder of the selected item
-    KUrl parentUrl = m_url.upUrl();
+    KUrl parentUrl = url().upUrl();
     if (!m_dirLister->url().isParentOf(parentUrl)) {
         return;
     }
@@ -167,7 +167,7 @@ void TreeViewSidebarPage::expandSelectionParent()
         m_treeView->setExpanded(proxyIndex, true);
 
         // select the item and assure that the item is visible
-        index = m_dirModel->indexForUrl(m_url);
+        index = m_dirModel->indexForUrl(url());
         if (index.isValid()) {
             proxyIndex = m_proxyModel->mapFromSource(index);
             m_treeView->scrollTo(proxyIndex);
index badc94484142decedfe4e21596ee1764da85ed0c..b7c5e25ff74c895ffb1392775c927245c99a1fde 100644 (file)
@@ -49,7 +49,7 @@ public slots:
     /**
      * Changes the current selection inside the tree to \a url.
      */
-    void setUrl(const KUrl& url);
+    virtual void setUrl(const KUrl& url);
 
 protected:
     /** @see QWidget::showEvent() */