diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-01-22 04:29:44 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-04 03:33:22 -0500 |
| commit | 7c98635edc33d74ab24352e971bb6a127e7272e8 (patch) | |
| tree | cdb6594f379a1b4c4a29bc48ca15a04cbe469e73 /src/filetreemodel.cpp | |
| parent | a55a69e6ac56dfb6851b5538e4252e9d8dab402b (diff) | |
filetype and last modified columns
Diffstat (limited to 'src/filetreemodel.cpp')
| -rw-r--r-- | src/filetreemodel.cpp | 71 |
1 files changed, 43 insertions, 28 deletions
diff --git a/src/filetreemodel.cpp b/src/filetreemodel.cpp index 351e0d2f..5424d14b 100644 --- a/src/filetreemodel.cpp +++ b/src/filetreemodel.cpp @@ -246,32 +246,7 @@ QVariant FileTreeModel::data(const QModelIndex& index, int role) const case Qt::DisplayRole: { if (auto* item=itemFromIndex(index)) { - switch (index.column()) - { - case Filename: - { - return item->filename(); - } - - case ModName: - { - return item->mod(); - } - - case FileSize: - { - if (item->isDirectory()) { - return {}; - } else { - return localizedByteSize(item->meta().size); - } - } - - default: - { - break; - } - } + return displayData(item, index.column()); } break; @@ -326,11 +301,11 @@ QVariant FileTreeModel::data(const QModelIndex& index, int role) const QVariant FileTreeModel::headerData(int i, Qt::Orientation ori, int role) const { static const std::array<QString, ColumnCount> names = { - tr("File"), tr("Mod"), tr("Size") + tr("Name"), tr("Mod"), tr("Type"), tr("Size"), tr("Date modified") }; if (role == Qt::DisplayRole) { - if (i > 0 && i < static_cast<int>(names.size())) { + if (i >= 0 && i < static_cast<int>(names.size())) { return names[static_cast<std::size_t>(i)]; } } @@ -671,6 +646,46 @@ std::unique_ptr<FileTreeItem> FileTreeModel::createFileItem( return item; } +QVariant FileTreeModel::displayData(const FileTreeItem* item, int column) const +{ + switch (column) + { + case Filename: + { + return item->filename(); + } + + case ModName: + { + return item->mod(); + } + + case FileType: + { + return item->meta().type; + } + + case FileSize: + { + if (item->isDirectory()) { + return {}; + } else { + return localizedByteSize(item->meta().size); + } + } + + case LastModified: + { + return item->meta().lastModified.toString(Qt::SystemLocaleDate); + } + + default: + { + break; + } + } +} + std::wstring FileTreeModel::makeModName( const MOShared::FileEntry& file, int originID) const { |
