From: Peter Penz Date: Fri, 26 Feb 2010 14:42:47 +0000 (+0000) Subject: The number of fixed meta-info items may vary dependent on whether Nepomuk is enabled... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/5dee68a0615db33b4607567e28e3638a9e085786 The number of fixed meta-info items may vary dependent on whether Nepomuk is enabled or not. Avoid the nasty hack to hardcode the value within the slotLoadingFinished() method. BUG: 228540 svn path=/trunk/KDE/kdebase/apps/; revision=1096347 --- diff --git a/src/panels/information/kmetadatawidget.cpp b/src/panels/information/kmetadatawidget.cpp index 80d8062a6..d5920ecb7 100644 --- a/src/panels/information/kmetadatawidget.cpp +++ b/src/panels/information/kmetadatawidget.cpp @@ -116,6 +116,7 @@ public: bool m_sizeVisible; bool m_readOnly; bool m_nepomukActivated; + int m_fixedRowCount; MetaDataTypes m_visibleDataTypes; QList m_fileItems; QList m_rows; @@ -147,6 +148,7 @@ KMetaDataWidget::Private::Private(KMetaDataWidget* parent) : m_sizeVisible(true), m_readOnly(false), m_nepomukActivated(false), + m_fixedRowCount(0), m_visibleDataTypes(TypeData | SizeData | ModifiedData | OwnerData | PermissionsData | RatingData | TagsData | CommentData), m_fileItems(), @@ -370,10 +372,7 @@ void KMetaDataWidget::Private::slotLoadingFinished() // Show the remaining meta information as text. The number // of required rows may very. Existing rows are reused to // prevent flickering. - int usedRowCnt = 8; // TODO: don't hardcode this value here - const int rowCount = m_rows.count(); - Q_ASSERT(rowCount >= usedRowCnt); - + int rowIndex = m_fixedRowCount; const QList items = mergedItems(m_loadMetaDataThread->items()); foreach (const KLoadMetaDataThread::Item& item, items) { const QString itemLabel = item.label; @@ -391,10 +390,10 @@ void KMetaDataWidget::Private::slotLoadingFinished() .arg(decoration); itemValue.insert(3 /* after "setText(itemLabel); - QLabel* infoValueLabel = qobject_cast(m_rows[usedRowCnt].infoWidget); + m_rows[rowIndex].label->setText(itemLabel); + QLabel* infoValueLabel = qobject_cast(m_rows[rowIndex].infoWidget); Q_ASSERT(infoValueLabel != 0); infoValueLabel->setText(itemValue); } else { @@ -405,11 +404,11 @@ void KMetaDataWidget::Private::slotLoadingFinished() q, SLOT(slotLinkActivated(QString))); addRow(infoLabel, infoValue); } - ++usedRowCnt; + ++rowIndex; } // remove rows that are not needed anymore - for (int i = m_rows.count() - 1; i >= usedRowCnt; --i) { + for (int i = m_rows.count() - 1; i >= rowIndex; --i) { delete m_rows[i].label; delete m_rows[i].infoWidget; m_rows.pop_back(); @@ -694,6 +693,11 @@ bool KMetaDataWidget::event(QEvent* event) } #endif + // The current number of rows represents meta data, that will be shown for + // all files. Dynamic meta data will be appended after those rows (see + // slotLoadingFinished()). + d->m_fixedRowCount = d->m_rows.count(); + d->updateRowsVisibility(); }