]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/information/informationpanelcontent.cpp
[InformationPanel] Remove obsolete intermediate wrapper widget/layout
[dolphin.git] / src / panels / information / informationpanelcontent.cpp
index e2b90dcc894da300810b0b6c250e3afe61c4765f..6e718f961dc74f0e7f366f06e1b26d0e0128f920 100644 (file)
@@ -107,18 +107,8 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
     m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
     m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
 
-    // Encapsulate the MetaDataWidget inside a container that has a dummy widget
-    // at the bottom. This prevents that the meta data widget gets vertically stretched
-    // in the case where the height of m_metaDataArea > m_metaDataWidget.
-    QWidget* metaDataWidgetContainer = new QWidget(parent);
-    QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer);
-    containerLayout->setContentsMargins(0, 0, 0, 0);
-    containerLayout->setSpacing(0);
-    containerLayout->addWidget(m_metaDataWidget);
-    containerLayout->addStretch();
-
     m_metaDataArea = new QScrollArea(parent);
-    m_metaDataArea->setWidget(metaDataWidgetContainer);
+    m_metaDataArea->setWidget(m_metaDataWidget);
     m_metaDataArea->setWidgetResizable(true);
     m_metaDataArea->setFrameShape(QFrame::NoFrame);
 
@@ -147,19 +137,20 @@ void InformationPanelContent::showItem(const KFileItem& item)
     refreshMetaData();
 }
 
-void InformationPanelContent::refreshPreview() {
+void InformationPanelContent::refreshPreview()
+{
     // If there is a preview job, kill it to prevent that we have jobs for
     // multiple items running, and thus a race condition (bug 250787).
     if (m_previewJob) {
         m_previewJob->kill();
     }
 
+    setNameLabelText(m_item.text());
     if (InformationPanelSettings::previewsShown()) {
         m_preview->show();
 
         const QUrl itemUrl = m_item.url();
         const bool isSearchUrl = itemUrl.scheme().contains(QStringLiteral("search")) && m_item.localPath().isEmpty();
-        setNameLabelText(m_item.text());
         if (isSearchUrl) {
             // in the case of a search-URL the URL is not readable for humans
             // (at least not useful to show in the Information Panel)
@@ -209,12 +200,11 @@ void InformationPanelContent::refreshPreview() {
     }
 }
 
-void InformationPanelContent::refreshMetaData() {
-    if (m_metaDataWidget) {
-        m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat()));
-        m_metaDataWidget->show();
-        m_metaDataWidget->setItems(KFileItemList() << m_item);
-    }
+void InformationPanelContent::refreshMetaData()
+{
+    m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat()));
+    m_metaDataWidget->show();
+    m_metaDataWidget->setItems(KFileItemList() << m_item);
 }
 
 void InformationPanelContent::showItems(const KFileItemList& items)
@@ -230,9 +220,7 @@ void InformationPanelContent::showItems(const KFileItemList& items)
     );
     setNameLabelText(i18ncp("@label", "%1 item selected", "%1 items selected", items.count()));
 
-    if (m_metaDataWidget) {
-        m_metaDataWidget->setItems(items);
-    }
+    m_metaDataWidget->setItems(items);
 
     m_phononWidget->hide();
 
@@ -297,7 +285,8 @@ void InformationPanelContent::markOutdatedPreview()
     m_preview->setPixmap(disabledPixmap);
 }
 
-KFileItemList InformationPanelContent::items() {
+KFileItemList InformationPanelContent::items()
+{
     return m_metaDataWidget->items();
 }
 
@@ -349,9 +338,7 @@ void InformationPanelContent::adjustWidgetSizes(int width)
 
     // The metadata widget also contains a text widget which may return
     // a large preferred width.
-    if (m_metaDataWidget) {
-        m_metaDataWidget->setMaximumWidth(maxWidth);
-    }
+    m_metaDataWidget->setMaximumWidth(maxWidth);
 
     // try to increase the preview as large as possible
     m_preview->setSizeHint(QSize(maxWidth, maxWidth));