2 Commits 8465a55530 ... f0f85c5a55

Autor SHA1 Mensaje Fecha
  Ivan Baidakou f0f85c5a55 fltk, refactor entries hace 1 semana
  Ivan Baidakou 54213c21d6 core, fix file_iterator + tests hace 1 semana

+ 2 - 1
src/model/misc/file_iterator.cpp

@@ -54,7 +54,8 @@ file_info_t *file_iterator_t::next_need_cloning() noexcept {
         auto &it = fi.it_clone;
         auto files_scan = size_t{0};
         auto &files_map = fi.peer_folder->get_file_infos();
-        auto local_folder = fi.peer_folder->get_folder()->get_folder_infos().by_device(*cluster.get_device());
+        auto &folder_infos = fi.peer_folder->get_folder()->get_folder_infos();
+        auto local_folder = folder_infos.by_device(*cluster.get_device());
 
         if (!local_folder->get_folder()->is_paused()) {
             while (files_scan < files_map.size()) {

+ 1 - 0
src/ui-fltk/CMakeLists.txt

@@ -34,6 +34,7 @@ add_executable(syncspirit-fltk WIN32
     table_widget/path.cpp
     tree_item/devices.cpp
     tree_item/entry.cpp
+    tree_item/file_entry.cpp
     tree_item/folder.cpp
     tree_item/folders.cpp
     tree_item/ignored_device.cpp

+ 3 - 9
src/ui-fltk/tree_item/entry.cpp

@@ -55,15 +55,9 @@ void entry_t::add_entry(model::file_info_t &file) {
     auto t = tree();
     auto node = within_tree([&]() -> entry_t * { return make_entry(&file, file.get_path().filename().string()); });
     node->update_label();
-
-    if (deleted) {
-        deleted_items.emplace(node);
-    }
-
-    if (!deleted || show_deleted) {
-        insert_node(node);
-    } else {
-        orphaned_items.emplace(node);
+    insert_node(node);
+    if (deleted && !show_deleted) {
+        remove_node(node);
     }
 }
 

+ 68 - 0
src/ui-fltk/tree_item/file_entry.cpp

@@ -0,0 +1,68 @@
+#include "file_entry.h"
+#include "../content/remote_file_table.h"
+
+using namespace syncspirit::fltk;
+using namespace syncspirit::fltk::tree_item;
+
+file_entry_t::file_entry_t(app_supervisor_t &supervisor, Fl_Tree *tree, model::file_info_t *entry_,
+                           std::string filename_)
+    : parent_t(supervisor, tree, true), entry{entry_}, filename{std::move(filename_)} {
+    if (entry) {
+        entry->set_augmentation(get_proxy());
+    }
+}
+
+void file_entry_t::update_label() {
+    if (entry) {
+        filename = get_entry()->get_path().filename().string();
+        if (entry->is_deleted()) {
+            labelfgcolor(FL_DARK1);
+        } else if (entry->is_global()) {
+            labelfgcolor(FL_GREEN);
+        } else {
+            labelfgcolor(FL_BLACK);
+        }
+    }
+    label(filename.c_str());
+    tree()->redraw();
+}
+
+bool file_entry_t::on_select() {
+    if (entry) {
+        content = supervisor.replace_content([&](content_t *content) -> content_t * {
+            auto prev = content->get_widget();
+            int x = prev->x(), y = prev->y(), w = prev->w(), h = prev->h();
+            return new content::remote_file_table_t(*this, x, y, w, h);
+        });
+    }
+    return true;
+}
+
+void file_entry_t::on_update() {
+    parent_t::on_update();
+    if (entry) {
+        if (entry->is_deleted()) {
+            auto host = static_cast<entry_t *>(parent());
+            bool show_deleted = supervisor.get_app_config().fltk_config.display_deleted;
+            if (!show_deleted) {
+                host->remove_child(this);
+            } else {
+                host->deleted_items.emplace(this);
+            }
+        }
+    }
+}
+
+auto file_entry_t::get_entry() -> model::file_info_t * { return entry; }
+
+auto file_entry_t::make_entry(model::file_info_t *file, std::string filename) -> entry_t * {
+    return new file_entry_t(supervisor, tree(), file, std::move(filename));
+}
+
+void file_entry_t::assign(entry_t &new_entry) {
+    auto &e = dynamic_cast<file_entry_t &>(new_entry);
+    entry = e.entry;
+    entry->set_augmentation(get_proxy());
+    e.get_proxy()->release_onwer();
+    on_update();
+}

+ 23 - 0
src/ui-fltk/tree_item/file_entry.h

@@ -0,0 +1,23 @@
+#pragma once
+
+#include "entry.h"
+
+namespace syncspirit::fltk::tree_item {
+
+struct file_entry_t : entry_t {
+    using parent_t = entry_t;
+    file_entry_t(app_supervisor_t &supervisor, Fl_Tree *tree, model::file_info_t *entry, std::string filename);
+
+    bool on_select() override;
+    void update_label() override;
+    void on_update() override;
+
+    model::file_info_t *get_entry() override;
+    entry_t *make_entry(model::file_info_t *file, std::string) override;
+    void assign(entry_t &) override;
+
+    model::file_info_t *entry;
+    std::string filename;
+};
+
+}; // namespace syncspirit::fltk::tree_item

+ 1 - 1
src/ui-fltk/tree_item/folder.cpp

@@ -242,5 +242,5 @@ bool folder_t::on_select() {
 auto folder_t::get_entry() -> model::file_info_t * { return nullptr; }
 
 auto folder_t::make_entry(model::file_info_t *file, std::string filename) -> entry_t * {
-    return new local_entry_t(supervisor, tree(), file, std::move(filename));
+    return new file_entry_t(supervisor, tree(), file, std::move(filename));
 }

+ 0 - 67
src/ui-fltk/tree_item/local_entry.cpp

@@ -1,68 +1 @@
 #include "local_entry.h"
-#include "../content/remote_file_table.h"
-
-using namespace syncspirit::fltk;
-using namespace syncspirit::fltk::tree_item;
-
-local_entry_t::local_entry_t(app_supervisor_t &supervisor, Fl_Tree *tree, model::file_info_t *entry_,
-                             std::string filename_)
-    : parent_t(supervisor, tree, true), entry{entry_}, filename{std::move(filename_)} {
-    if (entry) {
-        entry->set_augmentation(get_proxy());
-    }
-}
-
-void local_entry_t::update_label() {
-    if (entry) {
-        filename = get_entry()->get_path().filename().string();
-        if (entry->is_deleted()) {
-            labelfgcolor(FL_DARK1);
-        } else if (entry->is_global()) {
-            labelfgcolor(FL_GREEN);
-        } else {
-            labelfgcolor(FL_BLACK);
-        }
-    }
-    label(filename.c_str());
-    tree()->redraw();
-}
-
-bool local_entry_t::on_select() {
-    if (entry) {
-        content = supervisor.replace_content([&](content_t *content) -> content_t * {
-            auto prev = content->get_widget();
-            int x = prev->x(), y = prev->y(), w = prev->w(), h = prev->h();
-            return new content::remote_file_table_t(*this, x, y, w, h);
-        });
-    }
-    return true;
-}
-
-void local_entry_t::on_update() {
-    parent_t::on_update();
-    if (entry) {
-        if (entry->is_deleted()) {
-            auto host = static_cast<entry_t *>(parent());
-            bool show_deleted = supervisor.get_app_config().fltk_config.display_deleted;
-            if (!show_deleted) {
-                host->remove_child(this);
-            } else {
-                host->deleted_items.emplace(this);
-            }
-        }
-    }
-}
-
-auto local_entry_t::get_entry() -> model::file_info_t * { return entry; }
-
-auto local_entry_t::make_entry(model::file_info_t *file, std::string filename) -> entry_t * {
-    return new local_entry_t(supervisor, tree(), file, std::move(filename));
-}
-
-void local_entry_t::assign(entry_t &new_entry) {
-    auto &e = dynamic_cast<local_entry_t &>(new_entry);
-    entry = e.entry;
-    entry->set_augmentation(get_proxy());
-    e.get_proxy()->release_onwer();
-    on_update();
-}

+ 4 - 15
src/ui-fltk/tree_item/local_entry.h

@@ -1,23 +1,12 @@
 #pragma once
 
-#include "entry.h"
+#include "file_entry.h"
 
 namespace syncspirit::fltk::tree_item {
 
-struct local_entry_t final : entry_t {
-    using parent_t = entry_t;
-    local_entry_t(app_supervisor_t &supervisor, Fl_Tree *tree, model::file_info_t *entry, std::string filename);
-
-    bool on_select() override;
-    void update_label() override;
-    void on_update() override;
-
-    model::file_info_t *get_entry() override;
-    entry_t *make_entry(model::file_info_t *file, std::string) override;
-    void assign(entry_t &) override;
-
-    model::file_info_t *entry;
-    std::string filename;
+struct local_entry_t final : file_entry_t {
+    using parent_t = file_entry_t;
+    using parent_t::parent_t;
 };
 
 }; // namespace syncspirit::fltk::tree_item

+ 0 - 55
src/ui-fltk/tree_item/peer_entry.cpp

@@ -3,58 +3,3 @@
 
 using namespace syncspirit::fltk;
 using namespace syncspirit::fltk::tree_item;
-
-peer_entry_t::peer_entry_t(app_supervisor_t &supervisor, Fl_Tree *tree, model::file_info_t *entry_,
-                           std::string filename_)
-    : parent_t(supervisor, tree, true), entry{entry_}, filename{std::move(filename_)} {
-    if (entry) {
-        entry->set_augmentation(get_proxy());
-    }
-}
-
-void peer_entry_t::update_label() {
-    if (entry) {
-        filename = entry->get_path().filename().string();
-        if (entry->is_deleted()) {
-            labelfgcolor(FL_DARK1);
-        } else if (entry->is_global()) {
-            labelfgcolor(FL_GREEN);
-        } else {
-            labelfgcolor(FL_BLACK);
-        }
-    }
-    label(filename.c_str());
-    tree()->redraw();
-}
-
-bool peer_entry_t::on_select() {
-    if (entry) {
-        content = supervisor.replace_content([&](content_t *content) -> content_t * {
-            auto prev = content->get_widget();
-            int x = prev->x(), y = prev->y(), w = prev->w(), h = prev->h();
-            return new content::remote_file_table_t(*this, x, y, w, h);
-        });
-    }
-    return true;
-}
-
-void peer_entry_t::on_update() {
-    parent_t::on_update();
-    if (entry) {
-        if (entry->is_deleted()) {
-            auto host = static_cast<entry_t *>(parent());
-            bool show_deleted = supervisor.get_app_config().fltk_config.display_deleted;
-            if (!show_deleted) {
-                host->remove_child(this);
-            } else {
-                host->deleted_items.emplace(this);
-            }
-        }
-    }
-}
-
-auto peer_entry_t::get_entry() -> model::file_info_t * { return entry; }
-
-auto peer_entry_t::make_entry(model::file_info_t *file, std::string filename) -> entry_t * {
-    return new peer_entry_t(supervisor, tree(), file, std::move(filename));
-}

+ 0 - 0
src/ui-fltk/tree_item/peer_entry.h


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio