fix issue that filebox incorrectly loads folder tree on Linux

This commit is contained in:
cnjinhao 2017-09-11 14:42:20 +08:00
parent c348ec4009
commit 8cb29a1617
2 changed files with 13 additions and 18 deletions

View File

@ -435,20 +435,20 @@ namespace nana
nodes_.filesystem = tree_.insert("FS.ROOT", "Filesystem"); nodes_.filesystem = tree_.insert("FS.ROOT", "Filesystem");
nodes_.filesystem.value(kind::filesystem); nodes_.filesystem.value(kind::filesystem);
std::vector<std::string> paths; std::vector<std::pair<std::string, treebox::item_proxy>> paths;
paths.emplace_back(fs_ext::path_user().native()); paths.emplace_back(fs_ext::path_user().native(), nodes_.home);
paths.emplace_back("/"); paths.emplace_back("/", nodes_.filesystem);
fs::directory_iterator end; fs::directory_iterator end;
for (auto & p : paths) for (auto & p : paths)
{ {
for (fs::directory_iterator i(p); i != end; ++i) for (fs::directory_iterator i{p.first}; i != end; ++i)
{ {
auto name = i->path().filename().native(); auto name = i->path().filename().native();
if (!is_directory(i->status()) || (name.size() && name[0] == '.')) if (!is_directory(i->status()) || (name.size() && name[0] == '.'))
continue; continue;
item_proxy node = tree_.insert(nodes_.filesystem, name, name); item_proxy node = tree_.insert(p.second, name, name);
if (false == node.empty()) if (false == node.empty())
{ {
node.value(kind::filesystem); node.value(kind::filesystem);
@ -831,8 +831,8 @@ namespace nana
{ {
for(fs::directory_iterator u(i->path()); u != end; ++u) for(fs::directory_iterator u(i->path()); u != end; ++u)
{ {
auto uname = i->path().filename().native(); auto uname = u->path().filename().native();
if ((!is_directory(*i)) || (uname.size() && uname[0] == '.')) if ((!is_directory(*u)) || (uname.size() && uname[0] == '.'))
continue; continue;
child.append(uname, uname, kind::filesystem); child.append(uname, uname, kind::filesystem);

View File

@ -1825,7 +1825,6 @@ namespace nana
item_locator nl(impl_, xpos, arg.pos.x, arg.pos.y); item_locator nl(impl_, xpos, arg.pos.x, arg.pos.y);
impl_->attr.tree_cont.for_each<item_locator&>(shape.first, nl); impl_->attr.tree_cont.for_each<item_locator&>(shape.first, nl);
bool has_redraw = false;
auto & node_state = impl_->node_state; auto & node_state = impl_->node_state;
node_state.pressed_node = nl.node(); node_state.pressed_node = nl.node();
@ -1834,21 +1833,17 @@ namespace nana
{ {
if(impl_->set_expanded(node_state.pressed_node, !node_state.pressed_node->value.second.expanded)) if(impl_->set_expanded(node_state.pressed_node, !node_state.pressed_node->value.second.expanded))
impl_->make_adjust(node_state.pressed_node, 0); impl_->make_adjust(node_state.pressed_node, 0);
has_redraw = true; //btw, don't select the node
} }
else if (node_state.selected != node_state.pressed_node)
if ((!has_redraw) && (node_state.selected != node_state.pressed_node))
{ {
impl_->set_selected(node_state.pressed_node); impl_->set_selected(node_state.pressed_node);
has_redraw = true;
} }
else
return;
if(has_redraw)
{ impl_->draw(true);
impl_->draw(true); API::dev::lazy_refresh();
API::dev::lazy_refresh();
}
} }
void trigger::mouse_up(graph_reference, const arg_mouse& arg) void trigger::mouse_up(graph_reference, const arg_mouse& arg)