Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kfileitemlistwidget.cpp
| Show All 15 Lines | |||||
| 16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
| 18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
| 19 | 19 | | |||
| 20 | #include "kfileitemlistwidget.h" | 20 | #include "kfileitemlistwidget.h" | ||
| 21 | #include "kfileitemmodel.h" | 21 | #include "kfileitemmodel.h" | ||
| 22 | #include "kitemlistview.h" | 22 | #include "kitemlistview.h" | ||
| 23 | 23 | | |||
| 24 | #include "dolphin_detailsmodesettings.h" | ||||
| 25 | | ||||
| 24 | #include <KFormat> | 26 | #include <KFormat> | ||
| 25 | #include <KLocalizedString> | 27 | #include <KLocalizedString> | ||
| 26 | 28 | | |||
| 27 | #include <QMimeDatabase> | 29 | #include <QMimeDatabase> | ||
| 28 | 30 | | |||
| 29 | KFileItemListWidgetInformant::KFileItemListWidgetInformant() : | 31 | KFileItemListWidgetInformant::KFileItemListWidgetInformant() : | ||
| 30 | KStandardItemListWidgetInformant() | 32 | KStandardItemListWidgetInformant() | ||
| 31 | { | 33 | { | ||
| Show All 26 Lines | |||||
| 58 | { | 60 | { | ||
| 59 | QString text; | 61 | QString text; | ||
| 60 | const QVariant roleValue = values.value(role); | 62 | const QVariant roleValue = values.value(role); | ||
| 61 | 63 | | |||
| 62 | // Implementation note: In case if more roles require a custom handling | 64 | // Implementation note: In case if more roles require a custom handling | ||
| 63 | // use a hash + switch for a linear runtime. | 65 | // use a hash + switch for a linear runtime. | ||
| 64 | 66 | | |||
| 65 | if (role == "size") { | 67 | if (role == "size") { | ||
| 66 | if (values.value("isDir").toBool()) { | 68 | if (values.value("isDir").toBool()) { | ||
| 67 | // The item represents a directory. Show the number of sub directories | 69 | // The item represents a directory. | ||
elvisangelaccio: Please fix this comment (or drop it). | |||||
| 68 | // instead of the file size of the directory. | | |||
| 69 | if (!roleValue.isNull()) { | 70 | if (!roleValue.isNull()) { | ||
| 70 | const int count = roleValue.toInt(); | 71 | const int count = values.value("count").toInt(); | ||
| 71 | if (count < 0) { | 72 | if (count < 0) { | ||
| 72 | text = i18nc("@item:intable", "Unknown"); | 73 | text = i18nc("@item:intable", "Unknown"); | ||
| 73 | } else { | 74 | } else { | ||
| 75 | if (DetailsModeSettings::directorySizeCount()) { | ||||
| 76 | // Show the number of sub directories instead of the file size of the directory. | ||||
| 74 | text = i18ncp("@item:intable", "%1 item", "%1 items", count); | 77 | text = i18ncp("@item:intable", "%1 item", "%1 items", count); | ||
| 78 | } else { | ||||
| 79 | // if we have directory size available | ||||
| 80 | if (roleValue == -1) { | ||||
| 81 | text = i18nc("@item:intable", "Unknown"); | ||||
| 82 | } else { | ||||
| 83 | const KIO::filesize_t size = roleValue.value<KIO::filesize_t>(); | ||||
| 84 | text = KFormat().formatByteSize(size); | ||||
| 85 | } | ||||
| 86 | } | ||||
| 75 | } | 87 | } | ||
| 76 | } | 88 | } | ||
| 77 | } else { | 89 | } else { | ||
| 78 | const KIO::filesize_t size = roleValue.value<KIO::filesize_t>(); | 90 | const KIO::filesize_t size = roleValue.value<KIO::filesize_t>(); | ||
| 79 | text = KFormat().formatByteSize(size); | 91 | text = KFormat().formatByteSize(size); | ||
| 80 | } | 92 | } | ||
| 81 | } else if (role == "modificationtime" || role == "creationtime" || role == "accesstime") { | 93 | } else if (role == "modificationtime" || role == "creationtime" || role == "accesstime") { | ||
| 82 | bool ok; | 94 | bool ok; | ||
| ▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines | |||||
Please fix this comment (or drop it).