]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Properly KIO::stat instead of simply using the KFileItem constructor when
authorSebastian Trueg <sebastian@trueg.de>
Thu, 22 Jul 2010 08:26:07 +0000 (08:26 +0000)
committerSebastian Trueg <sebastian@trueg.de>
Thu, 22 Jul 2010 08:26:07 +0000 (08:26 +0000)
showing metadata for the currently selected folder. This way we can even get rid of the
special handling of nepomuksearch:/ URLs since the KIO slave provides a nice name and
all you need to show to the user.
Even nicer: When clicking an entry in the metadata view the resulting query will be related
to the one clicked resource. This resource will then be represented by the query folder.
So all in all this patch makes Dolphin more generic while additionally activating a new feature.

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

src/dolphinviewcontainer.cpp
src/panels/information/informationpanel.cpp
src/panels/information/informationpanel.h
src/panels/information/informationpanelcontent.cpp

index 28ffc23e45dd4c5d2eaee8a8d5e526470b15c109..9d33329e5c53f20964e5cc0465bfffffaebd9434 100644 (file)
@@ -279,7 +279,7 @@ void DolphinViewContainer::updateStatusBar()
 void DolphinViewContainer::initializeProgress()
 {
     if (url().protocol() == "nepomuksearch") {
-        // The Nepomuk IO-slave does not provide any progress information. Give
+        // The Nepomuk IO-slave does not provide progress information right away. Give
         // an immediate hint to the user that a searching is done:
         m_statusBar->setProgressText(i18nc("@info", "Searching..."));
         m_statusBar->setProgress(-1);
@@ -433,13 +433,13 @@ void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
     Q_UNUSED(oldUrl);
     const bool block = m_urlNavigator->signalsBlocked();
     m_urlNavigator->blockSignals(true);
-    
+
     // Assure that the location state is reset for redirection URLs. This
     // allows to skip redirection URLs when going back or forward in the
     // URL history.
     m_urlNavigator->saveLocationState(QByteArray());
     m_urlNavigator->setLocationUrl(newUrl);
-    
+
     m_urlNavigator->blockSignals(block);
 }
 
index f15cf05d51cd8fc149d6d84ac86e26626fdbbbe3..2d6810c88acd80f456f7ad2526d56c66c3f11779 100644 (file)
@@ -23,6 +23,8 @@
 #include <QVBoxLayout>
 #include "informationpanelcontent.h"
 
+#include <kio/job.h>
+
 InformationPanel::InformationPanel(QWidget* parent) :
     Panel(parent),
     m_initialized(false),
@@ -34,6 +36,7 @@ InformationPanel::InformationPanel(QWidget* parent) :
     m_invalidUrlCandidate(),
     m_fileItem(),
     m_selection(),
+    m_folderStatJob(0),
     m_content(0)
 {
 }
@@ -170,17 +173,28 @@ void InformationPanel::showItemInfo()
         } else if (!m_selection.isEmpty()) {
             Q_ASSERT(m_selection.count() == 1);
             item = m_selection.first();
-        } else {
+        }
+
+        if ( item.isNull() ) {
             // no item is hovered and no selection has been done: provide
             // an item for the directory represented by m_shownUrl
-            item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
-            item.refresh();
+            m_folderStatJob = KIO::stat(m_shownUrl, KIO::HideProgressInfo);
+            connect(m_folderStatJob, SIGNAL(result(KJob*)),
+                    this, SLOT(slotFolderStatFinished(KJob*)));
+        }
+        else {
+            m_content->showItem(item);
         }
-
-        m_content->showItem(item);
     }
 }
 
+void InformationPanel::slotFolderStatFinished(KJob* job)
+{
+    m_folderStatJob = 0;
+    const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
+    m_content->showItem(KFileItem(entry, m_shownUrl));
+}
+
 void InformationPanel::slotInfoTimeout()
 {
     m_shownUrl = m_urlCandidate;
@@ -272,6 +286,8 @@ void InformationPanel::slotLeftDirectory(const QString& directory)
 
 void InformationPanel::cancelRequest()
 {
+    delete m_folderStatJob;
+    m_folderStatJob = 0;
     m_infoTimer->stop();
 }
 
@@ -324,7 +340,7 @@ void InformationPanel::init()
 
     m_content = new InformationPanelContent(this);
     connect(m_content, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl)));
-    
+
     QVBoxLayout* layout = new QVBoxLayout(this);
     layout->addWidget(m_content);
 
index 0622a79a2b6f41608dcef10a49dcf6c2207cfe26..e0768bc1b3efe1142fb698d66f7479ec959ef714 100644 (file)
@@ -76,6 +76,12 @@ private slots:
      */
     void showItemInfo();
 
+    /**
+     * Shows the information for the currently displayed folder as a result from
+     * a stat job issued in showItemInfo().
+     */
+    void slotFolderStatFinished(KJob* job);
+
     /**
      * Triggered if the request for item information has timed out.
      * @see InformationPanel::requestDelayedItemInfo()
@@ -154,6 +160,8 @@ private:
     KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
     KFileItemList m_selection;
 
+    KJob* m_folderStatJob;
+
     InformationPanelContent* m_content;
 };
 
index 5254eb2eb417286d18a3950b9d813bfb93ff2786..b18e6b26e53a1f1eb25cc4b829c89dba7557f0e0 100644 (file)
@@ -150,6 +150,7 @@ void InformationPanelContent::showItem(const KFileItem& item)
     const KUrl itemUrl = item.url();
     const bool isNepomukSearchUrl = itemUrl.protocol().startsWith("nepomuk") && item.nepomukUri().isEmpty();
     if (!applyPlace(itemUrl)) {
+        setNameLabelText(item.text());
         if (isNepomukSearchUrl) {
             // in the case of a Nepomuk query-URL the URL is not readable for humans
             // (at least not useful to show in the Information Panel)
@@ -158,7 +159,6 @@ void InformationPanelContent::showItem(const KFileItem& item)
                                                KIconLoader::NoGroup,
                                                KIconLoader::SizeEnormous);
             m_preview->setPixmap(icon);
-            setNameLabelText(QString());
         } else {
             // try to get a preview pixmap from the item...
             m_pendingPreview = true;
@@ -184,18 +184,12 @@ void InformationPanelContent::showItem(const KFileItem& item)
                     this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
             connect(job, SIGNAL(failed(const KFileItem&)),
                     this, SLOT(showIcon(const KFileItem&)));
-
-            setNameLabelText(item.text());
         }
     }
 
     if (m_metaDataWidget != 0) {
-        if (isNepomukSearchUrl) {
-            m_metaDataWidget->hide();
-        } else {
-            m_metaDataWidget->show();
-            m_metaDataWidget->setItems(KFileItemList() << item);
-        }
+        m_metaDataWidget->show();
+        m_metaDataWidget->setItems(KFileItemList() << item);
     }
 
     if (InformationPanelSettings::showPreview()) {
@@ -377,7 +371,7 @@ void InformationPanelContent::setNameLabelText(const QString& text)
     textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
 
     const QString processedText = Qt::mightBeRichText(text) ? text : KStringHandler::preProcessWrap(text);
-    
+
     QTextLayout textLayout(processedText);
     textLayout.setFont(m_nameLabel->font());
     textLayout.setTextOption(textOption);