Forráskód Böngészése

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.
Andreas Kling 5 éve
szülő
commit
169a38113e
1 módosított fájl, 27 hozzáadás és 4 törlés
  1. 27 4
      Applications/FileManager/DirectoryView.cpp

+ 27 - 4
Applications/FileManager/DirectoryView.cpp

@@ -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());
 }