Kitlist
A list manager for maintaining kit lists
Loading...
Searching...
No Matches
kitlist_ftxui.hpp
Go to the documentation of this file.
1/*
2
3 This file is part of Kitlist, a program to maintain a simple list
4 of items and assign items to one or more categories.
5
6 Copyright (C) 2008-2025 Frank Dean
7
8 Kitlist is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 Kitlist is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Kitlist. If not, see <http://www.gnu.org/licenses/>.
20
21*/
22#ifndef FTXUI_HPP
23#define FTXUI_HPP
24
25#include "kitlist_base_app.hpp"
26#include <ftxui/component/component.hpp>
27#include <ftxui/dom/elements.hpp>
28#include <memory>
29#include <string>
30#include <vector>
31
36namespace fdsd
37{
38namespace ftxui
39{
40
48 std::shared_ptr<Category> category;
49};
50
58public:
59
62 selected_categories(std::vector<SelectCategory>()),
64 category_menu_entries(std::vector<std::string>()) {}
65
67 int run(const std::string filename);
68
69protected:
70
80 virtual void category_entry_changed(const std::shared_ptr<Category> category) override {
81 (void) category;
82 }
83
92 virtual void item_entry_changed(const std::shared_ptr<Item> item) override {
93 (void) item;
94 }
95
96private:
97
109
111 ::ftxui::Component copy_category_container = ::ftxui::Container::Vertical({});
112
113 std::vector<SelectCategory> selected_categories;
114
116 ::ftxui::Component item_action_container = ::ftxui::Container::Horizontal({});
117
124
126 ::ftxui::Component select_category_list();
127
129 ::ftxui::Component copy_items_dialog();
130
132 ::ftxui::Component item_action_dialog();
133
135 ::ftxui::Component new_category_component(std::function<void()> cancel,
136 std::function<void()> create_item);
137
139 ::ftxui::Component new_item_component(std::function<void()> cancel,
140 std::function<void()> create_item);
141
151 std::vector<std::shared_ptr<Category>>current_categories;
152
162
168 int layer = static_cast<int>(Layer::default_layer);
169
171 bool show_save = false;
172
175
177 std::string category_name;
178
180 std::string item_name;
181
183 bool item_checked = false;
184
187
190
193
195 std::vector<std::string> category_menu_entries;
196};
197
198} // namespace ftxui
199} // namespace fdsd
200
201#endif // FTXUI_HPP
KitListBaseApp()
Default constructor.
std::string filename
The current filename the Model was loaded from.
std::vector< std::string > category_menu_entries
The menu entries for the catalog list.
::ftxui::Component copy_category_container
Component for modal dialog for copying items to categories.
::ftxui::Component item_action_dialog()
Component to display options for removing or deleting checked items.
KitListFtxui()
Default constructor.
std::vector< std::shared_ptr< Category > > current_categories
The current list of Category instances.
bool refresh_category_container
When true, the category container needs to be refreshed.
void do_refresh_select_category_list()
refreshes the select category list.
std::string item_name
Updated by new_item_component.
bool refresh_select_category_list
When true, the select category list needs to be refreshed.
int selected_filter
Maintained by dropdown giving choices of Model::state_filter.
::ftxui::Component new_item_component(std::function< void()> cancel, std::function< void()> create_item)
Component for modal dialog for the user to create a new Item.
::ftxui::Component item_action_container
Component for modal dialog for delete or removing items.
std::string category_name
Updated by new_category_component.
::ftxui::Component copy_items_dialog()
Modal dialog for selecting target categories.
bool refresh_copy_item_category_container
When true, the copy items to category container needs to be refreshed.
bool show_save
Whether the Save button is shown.
virtual void category_entry_changed(const std::shared_ptr< Category > category) override
Called when a Category name has changed.
bool item_checked
Updated by new_item_component.
::ftxui::Component select_category_list()
Component displaying a list of all categories with a checkbox.
::ftxui::Component new_category_component(std::function< void()> cancel, std::function< void()> create_item)
Component for modal dialog for the user to create a new Category.
int run(const std::string filename)
The main run loop.
Layer
Indicates the different layers of the application.
std::vector< SelectCategory > selected_categories
int menu_selected_category
The index position in the list of category menu items.
virtual void item_entry_changed(const std::shared_ptr< Item > item) override
Called when a Item instance's state has changed.
A namespace for the FTXUI user interface.
An element used in lists for selecting categories.
std::shared_ptr< Category > category
Copyright 2008-2025 Frank Dean