- quint64 totalSize = 0;
- foreach (const KFileItem& item, m_selection) {
- // Only count the size of files, not dirs to match what
- // DolphinViewContainer::selectionStatusBarText() does.
- if (!item.isDir() && !item.isLink()) {
- totalSize += item.size();
- }
- }
- m_metaTextLabel->add(i18nc("@label", "Total size:"), KIO::convertSize(totalSize));
- } else {
- const KFileItem item = fileItem();
- if (item.isDir()) {
- m_metaTextLabel->add(i18nc("@label", "Type:"), i18nc("@label", "Folder"));
- m_metaTextLabel->add(i18nc("@label", "Modified:"), item.timeString());
- } else {
- m_metaTextLabel->add(i18nc("@label", "Type:"), item.mimeComment());
-
- m_metaTextLabel->add(i18nc("@label", "Size:"), KIO::convertSize(item.size()));
- m_metaTextLabel->add(i18nc("@label", "Modified:"), item.timeString());
-
-#ifdef HAVE_NEPOMUK
- KConfig config("kmetainformationrc", KConfig::NoGlobals);
- KConfigGroup settings = config.group("Show");
- initMetaInfoSettings(settings);
-
- Nepomuk::Resource res(item.url());
-
- QHash<QUrl, Nepomuk::Variant> properties = res.properties();
- QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
- while (it != properties.constEnd()) {
- Nepomuk::Types::Property prop(it.key());
- const QString label = prop.label();
- if (settings.readEntry(label, true)) {
- // TODO: use Nepomuk::formatValue(res, prop) if available
- // instead of it.value().toString()
- m_metaTextLabel->add(label, it.value().toString());
- }
- ++it;
- }
-#endif
- }
-
- if (m_metaDataWidget != 0) {
- m_metaDataWidget->setFile(item.targetUrl());
- }
- }
-
- updatePhononWidget();
-}
-
-KFileItem InformationPanel::fileItem() const
-{
- if (!m_fileItem.isNull()) {
- return m_fileItem;
- }
-
- if (!m_selection.isEmpty()) {
- Q_ASSERT(m_selection.count() == 1);
- return m_selection.first();
- }
-
- // no item is hovered and no selection has been done: provide
- // an item for the directory represented by m_shownUrl
- KFileItem item(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
- item.refresh();
- return item;
-}
-
-bool InformationPanel::showMultipleSelectionInfo() const
-{
- return m_fileItem.isNull() && (m_selection.count() > 1);
-}
-
-bool InformationPanel::isEqualToShownUrl(const KUrl& url) const
-{
- return m_shownUrl.equals(url, KUrl::CompareWithoutTrailingSlash);
-}
-
-void InformationPanel::setNameLabelText(const QString& text)
-{
- QTextOption textOption;
- textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
-
- QTextLayout textLayout(text);
- textLayout.setFont(m_nameLabel->font());
- textLayout.setTextOption(textOption);
-
- QString wrappedText;
- wrappedText.reserve(text.length());
-
- // wrap the text to fit into the width of m_nameLabel
- textLayout.beginLayout();
- QTextLine line = textLayout.createLine();
- while (line.isValid()) {
- line.setLineWidth(m_nameLabel->width());
- wrappedText += text.mid(line.textStart(), line.textLength());
-
- line = textLayout.createLine();
- if (line.isValid()) {
- wrappedText += QChar::LineSeparator;
- }
- }
- textLayout.endLayout();