]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/infosidebarpage.cpp
fix: forgot to invoke base implementation
[dolphin.git] / src / infosidebarpage.cpp
index b7490625fb861deb97574bfa17b95e14020b09ed..319582cb495e5d1773c715786388d72fa90c19c8 100644 (file)
@@ -102,6 +102,13 @@ InfoSidebarPage::~InfoSidebarPage()
 {
 }
 
+QSize InfoSidebarPage::sizeHint() const
+{
+    QSize size = SidebarPage::sizeHint();
+    size.setWidth(minimumSizeHint().width());
+    return size;
+}
+
 void InfoSidebarPage::setUrl(const KUrl& url)
 {
     if (url.isValid() && !m_shownUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
@@ -111,9 +118,15 @@ void InfoSidebarPage::setUrl(const KUrl& url)
     }
 }
 
-void InfoSidebarPage::setSelection(const KFileItemList& selection)
+void InfoSidebarPage::setSelection(const QList<KFileItem>& selection)
 {
     SidebarPage::setSelection(selection);
+    if (selection.size() == 1) {
+        const KUrl url = selection.first().url();
+        if (!url.isEmpty()) {
+            m_urlCandidate = url;
+        }
+    }
     m_timer->start(TimerDelay);
 }
 
@@ -160,13 +173,13 @@ void InfoSidebarPage::showItemInfo()
 
     cancelRequest();
 
-    const KFileItemList& selectedItems = selection();
+    const QList<KFileItem>& selectedItems = selection();
 
     KUrl file;
     if (selectedItems.isEmpty()) {
         file = m_shownUrl;
     } else {
-        file = selectedItems[0]->url();
+        file = selectedItems[0].url();
     }
     if (!file.isValid()) {
         return;
@@ -179,7 +192,7 @@ void InfoSidebarPage::showItemInfo()
                                            K3Icon::SizeEnormous);
         m_preview->setPixmap(icon);
         m_nameLabel->setText(i18ncp("@info", "%1 item selected", "%1 items selected", selectedItems.count()));
-    } else if (!applyBookmark(file)) {
+    } else if (!applyPlace(file)) {
         // try to get a preview pixmap from the item...
         KUrl::List list;
         list.append(file);
@@ -219,7 +232,7 @@ void InfoSidebarPage::slotTimeout()
 void InfoSidebarPage::showIcon(const KFileItem& item)
 {
     m_pendingPreview = false;
-    if (!applyBookmark(item.url())) {
+    if (!applyPlace(item.url())) {
         m_preview->setPixmap(item.pixmap(K3Icon::SizeEnormous));
     }
 }
@@ -234,7 +247,7 @@ void InfoSidebarPage::showPreview(const KFileItem& item,
     }
 }
 
-bool InfoSidebarPage::applyBookmark(const KUrl& url)
+bool InfoSidebarPage::applyPlace(const KUrl& url)
 {
     KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
     int count = placesModel->rowCount();
@@ -266,13 +279,13 @@ void InfoSidebarPage::showMetaInfo()
 {
     QString text;
 
-    const KFileItemList& selectedItems = selection();
+    const QList<KFileItem>& selectedItems = selection();
     if (selectedItems.size() <= 1) {
         KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
         fileItem.refresh();
 
         if (fileItem.isDir()) {
-            addInfoLine(text, i18nc("@label", "Type:"), i18nc("@info", "Folder"));
+            addInfoLine(text, i18nc("@label", "Type:"), i18nc("@label", "Folder"));
         } else {
             addInfoLine(text, i18nc("@label", "Type:"), fileItem.mimeComment());
 
@@ -304,14 +317,18 @@ void InfoSidebarPage::showMetaInfo()
         }
     } else {
         if (MetaDataWidget::metaDataAvailable()) {
-            m_metadataWidget->setFiles(selectedItems.urlList());
+            KUrl::List urls;
+            foreach (const KFileItem& item, selectedItems) {
+                urls.append(item.url());
+            }
+            m_metadataWidget->setFiles(urls);
         }
 
         unsigned long int totalSize = 0;
-        foreach (KFileItem* item, selectedItems) {
+        foreach (const KFileItem& item, selectedItems) {
             // TODO: 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
-            totalSize += item->size();
+            // item.size() does not return the size of the content : not very instinctive for users
+            totalSize += item.size();
         }
         addInfoLine(text, i18nc("@label", "Total size:"), KIO::convertSize(totalSize));
     }
@@ -322,7 +339,7 @@ void InfoSidebarPage::addInfoLine(QString& text,
                                   const QString& labelText,
                                   const QString& infoText)
 {
-    if (!infoText.isEmpty()) {
+    if (!text.isEmpty()) {
         text += "<br/>";
     }
     text += QString("<b>%1</b> %2").arg(labelText).arg(infoText);