Webdar 1.0.0
Web user interface to libdar
html_dir_tree.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef HTML_DIR_TREE_HPP
25#define HTML_DIR_TREE_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <vector>
36
37 // webdar headers
38#include "html_div.hpp"
39#include "events.hpp"
40#include "chemin.hpp"
41#include "archive_init_list.hpp"
42#include "html_button.hpp"
43#include "html_focus.hpp"
44#include "html_table.hpp"
45
47
54
75class html_dir_tree: public html_div, public actor
76{
77public:
78 html_dir_tree(const std::string & chemin); // minimal constructeur, must use set_source() ASAP
79 html_dir_tree(const archive_init_list * ref, const std::string & chemin);
80 html_dir_tree(const html_dir_tree & ref) = delete;
81 html_dir_tree(html_dir_tree && ref) noexcept = delete;
82 html_dir_tree & operator = (const html_dir_tree & ref) = delete;
83 html_dir_tree & operator = (html_dir_tree && ref) noexcept = delete;
84 ~html_dir_tree() { clear(); };
85
87 void clear();
88
90 void set_source(const archive_init_list *ref);
91
93 void set_drop_content(html_focus *ref) { focus_place = ref; };
94
96 void set_drop_path(html_div *ref) { focus_title = ref; };
97
99 void go_shrink();
100
102 void go_expand();
103
105 void go_show() { on_event(event_click); };
106
108 virtual void on_event(const std::string & event_name) override;
109
110protected:
111
113 virtual std::string inherited_get_body_part(const chemin & path,
114 const request & req) override;
115
116 // inherited from body_builder
117 virtual void new_css_library_available() override;
118
119
120private:
121 static const std::string event_shrink;
122 static const std::string event_expand;
123 static const std::string event_click;
124
125
126 chemin my_path;
127 const archive_init_list *src;
128 bool info_read;
129 bool has_sub;
130 bool visibility_has_changed; //< whether we need to rebuild the body_builder answer
131 std::vector<html_dir_tree *> subdirs; //< subdirectories of the tree
132
133 // HTML controls
134 html_div line; //< contains shrink/expand/nosubdir buttons + name for alignment
135 html_button shrink; //< alternatively visible button
136 html_button expand; //< alternatively visible button
137 html_button nosubdir; //< "shown" when no subdir exist
138 html_button name; //< name of the directory
139 html_div for_subdirs; //< where take place subdirs
140 html_focus *focus_place; //< where to send contents upon focus
141 html_table contents; //< directory contents
142 html_div *focus_title; //< where to write title of the contents when are under focus
143
144 void init(const std::string & chemin);
145 void go_init_indent();
146 void go_hide();
147 void clear_contents();
148};
149
150#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
this objects is a thread object that provide access to the content of an existing archive
Definition: archive_init_list.hpp:55
class chemin definition
Definition: chemin.hpp:51
simple html component providing the usual button feature of GUIs, better using html_double_button ins...
Definition: html_button.hpp:48
class html_dir_tree show a directory content read from an existing dar archive
Definition: html_dir_tree.hpp:76
void set_drop_path(html_div *ref)
where to write the path when under focus
Definition: html_dir_tree.hpp:96
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherite from html_div
Definition: html_dir_tree.cpp:231
void go_expand()
expand the directory exposing all its subdirectories
Definition: html_dir_tree.cpp:186
void set_source(const archive_init_list *ref)
where to fetch from archive content
Definition: html_dir_tree.cpp:160
void clear()
clear information learnt from a previously opened archive
Definition: html_dir_tree.cpp:139
void go_show()
show contents in the focus place
Definition: html_dir_tree.hpp:105
void set_drop_content(html_focus *ref)
where to attach to the archive contents when "this" is selected
Definition: html_dir_tree.hpp:93
void go_shrink()
shrink the directory
Definition: html_dir_tree.cpp:175
virtual void new_css_library_available() override
inherited from body_builder
Definition: html_dir_tree.cpp:336
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: html_dir_tree.cpp:209
class html_div is the implementation of
Definition: html_div.hpp:46
html_focus class provides a mean to temporarily have an object show at a particular place in a page
Definition: html_focus.hpp:50
html component implementing the html table structure
Definition: html_table.hpp:52
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines the event class