┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-06-27 20:01:04 +0000
committerPeter Penz <[email protected]>2008-06-27 20:01:04 +0000
commitd96712f50ea5ab3fd0998d5118fcc5c0d6e804e9 (patch)
treeb2f08c35345999502f69cf6177f2e5084000efb2 /src
parent3a6ee0eee85b4f2af32cc1aeacd0add377ebeb7f (diff)
tried to simplify the logic to decide whether the information panel should show the information for one file or for a multiple selection
CCMAIL: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=825317
Diffstat (limited to 'src')
-rw-r--r--src/infosidebarpage.cpp57
-rw-r--r--src/infosidebarpage.h17
2 files changed, 49 insertions, 25 deletions
diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp
index 2cfe56bf7..7a11994af 100644
--- a/src/infosidebarpage.cpp
+++ b/src/infosidebarpage.cpp
@@ -181,19 +181,18 @@ void InfoSidebarPage::showItemInfo()
cancelRequest();
- const KUrl file = (!m_fileItem.isNull() || m_selection.isEmpty()) ? m_shownUrl : m_selection[0].url();
+ const KUrl file = fileUrl();
if (!file.isValid()) {
return;
}
- const int selectionCount = m_selection.count();
- if (m_fileItem.isNull() && (selectionCount > 1)) {
+ if (showMultipleSelectionInfo()) {
KIconLoader iconLoader;
QPixmap icon = iconLoader.loadIcon("dialog-information",
KIconLoader::NoGroup,
KIconLoader::SizeEnormous);
m_preview->setPixmap(icon);
- m_nameLabel->setText(i18ncp("@info", "%1 item selected", "%1 items selected", selectionCount));
+ m_nameLabel->setText(i18ncp("@info", "%1 item selected", "%1 items selected", m_selection.count()));
} else if (!applyPlace(file)) {
// try to get a preview pixmap from the item...
KUrl::List list;
@@ -339,10 +338,26 @@ void InfoSidebarPage::showMetaInfo()
{
m_metaTextLabel->clear();
- const KUrl file = (!m_fileItem.isNull() || m_selection.isEmpty()) ? m_shownUrl : m_selection[0].url();
+ if (showMultipleSelectionInfo()) {
+ if (m_metaDataWidget != 0) {
+ KUrl::List urls;
+ foreach (const KFileItem& item, m_selection) {
+ urls.append(item.targetUrl());
+ }
+ m_metaDataWidget->setFiles(urls);
+ }
- if ((m_selection.size() <= 1) || !m_fileItem.isNull()) {
- KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, file);
+ 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 {
+ KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, fileUrl());
fileItem.refresh();
if (fileItem.isDir()) {
@@ -382,24 +397,6 @@ void InfoSidebarPage::showMetaInfo()
if (m_metaDataWidget != 0) {
m_metaDataWidget->setFile(fileItem.targetUrl());
}
- } else {
- if (m_metaDataWidget != 0) {
- KUrl::List urls;
- foreach (const KFileItem& item, m_selection) {
- urls.append(item.targetUrl());
- }
- m_metaDataWidget->setFiles(urls);
- }
-
- 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));
}
}
@@ -441,6 +438,16 @@ bool InfoSidebarPage::convertMetaInfo(const QString& key, QString& text) const
return false;
}
+KUrl InfoSidebarPage::fileUrl() const
+{
+ return (!m_fileItem.isNull() || m_selection.isEmpty()) ? m_shownUrl : m_selection[0].url();
+}
+
+bool InfoSidebarPage::showMultipleSelectionInfo() const
+{
+ return m_fileItem.isNull() && (m_selection.count() > 1);
+}
+
void InfoSidebarPage::init()
{
const int spacing = KDialog::spacingHint();
diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h
index b15a01814..5663c119c 100644
--- a/src/infosidebarpage.h
+++ b/src/infosidebarpage.h
@@ -139,6 +139,23 @@ private:
*/
bool convertMetaInfo(const QString& key, QString& text) const;
+ /**
+ * Returns the URL of the file where the preview and meta information
+ * should be received, if InfoSidebarPage::showMultipleSelectionInfo()
+ * returns false.
+ */
+ KUrl fileUrl() const;
+
+ /**
+ * Returns true, if the meta information should be shown for
+ * the items multiple selected items that are stored in
+ * m_selection. If true is returned, it is assured that
+ * m_selection.count() > 1. If false is returned, the meta
+ * information should be shown for the file
+ * InfosidebarPage::fileUrl();
+ */
+ bool showMultipleSelectionInfo() const;
+
void init();
private: