1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 00:48:11 +00:00

FileManager: Show symlink targets in status bar message

When a single item is selected and it happens to be a symlink pointing
somewhere, we now show where it points to in the status bar. :^)

There is a big ugly FIXME here about how DirectoryView has to work
around the fact that there's a GSortingProxyModel attached to the table
view widget.
This commit is contained in:
Andreas Kling 2020-01-27 22:36:06 +01:00
parent f7b394af7d
commit 169a38113e

View file

@ -26,6 +26,7 @@
#include "DirectoryView.h"
#include <AK/FileSystemPath.h>
#include <AK/StringBuilder.h>
#include <LibGUI/GSortingProxyModel.h>
#include <stdio.h>
#include <unistd.h>
@ -295,8 +296,30 @@ void DirectoryView::update_statusbar()
selected_byte_count += file_size;
});
set_status_message(String::format("%d item%s selected (%s)",
selected_item_count,
selected_item_count != 1 ? "s" : "",
human_readable_size(selected_byte_count).characters()));
StringBuilder builder;
builder.append(String::number(selected_item_count));
builder.append(" item");
if (selected_item_count != 1)
builder.append('s');
builder.append(" selected (");
builder.append(human_readable_size(selected_byte_count).characters());
builder.append(')');
if (selected_item_count == 1) {
auto index = current_view().selection().first();
// FIXME: This is disgusting. This code should not even be aware that there is a GSortingProxyModel in the table view.
if (m_view_mode == ViewMode::List) {
auto& filter_model = (GSortingProxyModel&)*m_table_view->model();
index = filter_model.map_to_target(index);
}
auto& node = model().node(index);
if (!node.symlink_target.is_empty()) {
builder.append(" -> ");
builder.append(node.symlink_target);
}
}
set_status_message(builder.to_string());
}