summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp
diff options
context:
space:
mode:
authorspycrab <spycrab@users.noreply.github.com>2018-06-02 18:14:42 +0200
committerspycrab <spycrab@users.noreply.github.com>2018-06-02 18:59:56 +0200
commitf6865117e47fb48c58ab53af1297a79b850a345a (patch)
tree3bbd307e4b852a40f166b7a9b4279e070f321621 /Source/Core/DolphinQt2/Config/FilesystemWidget.cpp
parentf09f83c309e2c4a0e80648dc698cecd4ecba3f8f (diff)
Qt/FilesystemWidget: Add size column
Diffstat (limited to 'Source/Core/DolphinQt2/Config/FilesystemWidget.cpp')
-rw-r--r--Source/Core/DolphinQt2/Config/FilesystemWidget.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp
index bfae5b78df..165ef0fd09 100644
--- a/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp
+++ b/Source/Core/DolphinQt2/Config/FilesystemWidget.cpp
@@ -25,6 +25,8 @@
#include "DolphinQt2/QtUtils/ActionHelper.h"
#include "DolphinQt2/Resources.h"
+#include "UICommon/UICommon.h"
+
constexpr int ENTRY_PARTITION = Qt::UserRole;
constexpr int ENTRY_NAME = Qt::UserRole + 1;
constexpr int ENTRY_TYPE = Qt::UserRole + 2;
@@ -52,11 +54,18 @@ void FilesystemWidget::CreateWidgets()
{
auto* layout = new QVBoxLayout;
- m_tree_model = new QStandardItemModel(0, 1);
+ m_tree_model = new QStandardItemModel(0, 2);
+ m_tree_model->setHorizontalHeaderLabels({tr("Name"), tr("Size")});
+
m_tree_view = new QTreeView(this);
m_tree_view->setModel(m_tree_model);
m_tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
- m_tree_view->header()->hide();
+
+ auto* header = m_tree_view->header();
+
+ header->setSectionResizeMode(0, QHeaderView::Stretch);
+ header->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+ header->setStretchLastSection(false);
// Windows: Set style to (old) windows, which draws branch lines
#ifdef _WIN32
@@ -132,7 +141,14 @@ void FilesystemWidget::PopulateDirectory(int partition_id, QStandardItem* root,
item->setData(QString::fromStdString(info.GetPath()), ENTRY_NAME);
item->setData(QVariant::fromValue(info.IsDirectory() ? EntryType::Dir : EntryType::File),
ENTRY_TYPE);
- root->appendRow(item);
+
+ const auto size = info.GetTotalSize();
+
+ auto* size_item = new QStandardItem(QString::fromStdString(UICommon::FormatSize(size)));
+ size_item->setTextAlignment(Qt::AlignRight);
+ size_item->setEditable(false);
+
+ root->appendRow({item, size_item});
}
}