Начал добавлять функции работы с таблицей

pull/24/head
Igor Belitskiy 2 years ago
parent d2e0afef67
commit f3d083c1f8

@ -1,5 +1,5 @@
#include "util.h"
#define yon_gtk_builder_get_widget(builder, widget_name) GTK_WIDGET(gtk_builder_get_object(builder, widget_name))
namespace Utils {
string format_str_size(int num, int index) {

@ -63,7 +63,6 @@ void MainWindow::settings() {
ubl_make_plugs(boxSave, boxButton, (*socket_ext_id_I), (*socket_trd_id_I));
this->add_CSS();
this->flag_block_gui();
this->init_tree_view();
this->init_spin_all();
if (geteuid() == 0) {
this->wrapper_load_system();
@ -139,62 +138,7 @@ void MainWindow::init_spin_all() {
generalUsersFilesMinutesSpin->set_value(0);
}
void MainWindow::init_tree_view() {
//this->view_add_columns(*usersQuotasTree);
//this->view_add_columns(*groupsQuotasTree);
//this->view_add_columns(*ProjectQuotasTree);
//this->init_tree_view_general();
}
void MainWindow::init_tree_view_general() {
GeneralQuotasTree->append_column_editable(str_status, m_columnsGeneral.status);
GeneralQuotasTree->append_column(str_quota, m_columnsGeneral.type_quotas);
GeneralQuotasTree->append_column(str_device_project, m_columnsGeneral.device);
GeneralQuotasTree->append_column(str_user, m_columnsGeneral.user);
GeneralQuotasTree->append_column(str_group, m_columnsGeneral.group);
GeneralQuotasTree->append_column(str_projects, m_columnsGeneral.projects);
GeneralQuotasTree->append_column(str_tw_soft_limit, m_columnsGeneral.soft_limit_size);
GeneralQuotasTree->append_column(str_tw_severe_limitation, m_columnsGeneral.hard_limit_size);
GeneralQuotasTree->append_column(str_tw_soft_limit_files, m_columnsGeneral.soft_limit_files);
GeneralQuotasTree->append_column(str_tw_severe_limitation_files, m_columnsGeneral.hard_limit_files);
GeneralQuotasTree->append_column(str_tw_general_deferring_size, m_columnsGeneral.deferring_size);
GeneralQuotasTree->append_column(str_tw_general_deferring_files, m_columnsGeneral.deferring_files);
}
void MainWindow::view_add_columns(Gtk::TreeView &treeView) {
treeView.append_column_editable(str_name, m_columns.name);
treeView.append_column_editable(str_quotas, m_columns.quotas);
treeView.append_column(str_size, m_columns.size);
treeView.append_column(str_tw_soft_limit, m_columns.soft_limit_size);
treeView.append_column(str_tw_severe_limitation, m_columns.hard_limit_size);
treeView.append_column(str_tw_deferring_size, m_columns.deferring_size);
treeView.append_column(str_files, m_columns.files);
treeView.append_column(str_tw_soft_limit_files, m_columns.soft_limit_files);
treeView.append_column(str_tw_severe_limitation_files, m_columns.hard_limit_delay);
treeView.append_column(str_tw_deferring_files, m_columns.deferring_files);
}
void MainWindow::lacalization() {
GroupsTabLabel->set_text(str_groups);
headerTopic->set_label(name_app);
UsersTabLabel->set_text(str_users);
generalGroupsFilesLabel->set_text(str_excess_files_delay);
generalUsersSizeLabel->set_text(str_excess_size_delay);
generalUsersFilesLabel->set_text(str_excess_files_delay);
lblLoad->set_text(str_load_local);
lblSave->set_text(str_save_local);
groupsDeviceLabel->set_label(str_device);
usersDeviceLabel->set_label(str_device);
headLabel->set_label(str_lb_head);
btnLoadGlob->set_label(load_global);
btnLoadLocal->set_label(load_local);
btnAbout->set_label(str_about_1);
btnSynopsis->set_label(str_help);
btnSaveLocalGlob->set_label(save_all);
btnSaveGlob->set_label(save_global);
btnSaveLocal->set_label(save_local);
ProjectTabLabel->set_label(str_projects);
usersProjectLabel->set_text(str_device);
chbMangSystemFile->set_label(str_quotas_mode);
}
@ -412,8 +356,99 @@ void MainWindow::get_builder() {
builder->get_widget("boxProjectDays", boxProjectDays);
builder->get_widget("boxProjectHours", boxProjectHours);
builder->get_widget("boxProjectMinutes", boxProjectMinutes);
GtkBuilder *builder = gtk_builder_new_from_file(path_glade);
gtk_list_project = GTK_LIST_STORE(gtk_builder_get_object(builder, "ListProject"));
gtk_list_groups = GTK_LIST_STORE(gtk_builder_get_object(builder, "ListGroups"));
gtk_list_user = GTK_LIST_STORE(gtk_builder_get_object(builder, "ListUser"));
gtk_list_general = GTK_LIST_STORE(gtk_builder_get_object(builder, "ListGeneral"));
}
/*
void tree_view_del_line() {
int index = 0;
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->treeViewMain));
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
char* str_iter = yon_char_new(gtk_tree_model_get_string_from_iter(model, &iter));
index = atoi(str_iter);
g_object_ref(main_config.list);
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), NULL);
gtk_list_store_clear(main_config.list);
main_fill_tree_view_after_remove();
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model);
free(str_iter);
}
}
void MainWindow::tree_view_select() {
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(gtk_list_user);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(usersQuotasTree->gobj()));
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_widget_set_sensitive(GTK_WIDGET(btnAddUsers->gobj()),1);
gtk_widget_set_sensitive(GTK_WIDGET(btnEditUsers->gobj()),1);
gtk_widget_set_sensitive(GTK_WIDGET(btnDelUsers->gobj()),1);
}
else {
gtk_widget_set_sensitive(GTK_WIDGET(btnAddUsers->gobj()),1);
gtk_widget_set_sensitive(GTK_WIDGET(btnEditUsers->gobj()),1);
gtk_widget_set_sensitive(GTK_WIDGET(btnDelUsers->gobj()),0);
}
}
void fill_tree_view(int start, int size, int flag_gui_add) {
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
if (flag_gui_add == 0) {
g_object_ref(main_config.list);
gtk_list_store_clear(main_config.list);
}
for (int index = start; index < size; index++) {
GtkTreeIter iter;
gtk_list_store_append(main_config.list,&iter);
char* str_io_read = format_io_limit_in_tree_view(main_config.disk, main_config.i_o_limit_read, main_config.i_o_limit_read_size, index);
char* str_io_write = format_io_limit_in_tree_view(main_config.disk, main_config.i_o_limit_write, main_config.i_o_limit_write_size, index);
gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index],
1,main_config.quota_volume[index],
2,main_config.soft_raw_limit[index],
3,main_config.hard_raw_limit[index],
4,main_config.swap[index],
5,main_config.cpu_limit[index],
6,str_io_read,
7,str_io_write,-1);
free(str_io_read);
free(str_io_write);
}
if (flag_gui_add != 0) {
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model);
}
}
int tree_view_edit() {
int index = 0;
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->treeViewMain));
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
char* str_iter = gtk_tree_model_get_string_from_iter(model, &iter);
index = atoi(str_iter);
gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index],
1,main_config.quota_volume[index],
2,main_config.soft_raw_limit[index],
3,main_config.hard_raw_limit[index],
4,main_config.swap[index],
5,main_config.cpu_limit[index],
6,str_io_read,
7,str_io_write,-1);
return 1;
}
else {
return 0;
}
}
*/
void MainWindow::open_browser() {
obj_open_browser->open_help();
}
@ -488,6 +523,7 @@ void MainWindow::event() {
btnAddGroups->signal_clicked().connect(
sigc::bind<string,Gtk::TreeView*, Gtk::TreeModel::Row&, Glib::RefPtr<Gtk::ListStore>&, struct tv_g_u_p> (sigc::mem_fun( *this,
&MainWindow::set_add_tv_g_u_p), str_groups, groupsQuotasTree, row, list_store_groups, obj_tv_g_u_p));
usersQuotasTree->signal_cursor_changed().connect([&]() {this->obj_view_add_project->show();});
}
void MainWindow::resize_widget() {
@ -598,9 +634,6 @@ void MainWindow::init_work_tv_g_u_p() {
Glib::RefPtr<Gtk::TreeModel> usersQuotasTreeModel = usersQuotasTree->get_model();
usersQuotasTreeModel->signal_row_changed().connect(sigc::bind<Gtk::TreeModel::iterator&, bool&>
(sigc::mem_fun(*this, &MainWindow::remove_line_template),iter_users, flag_validate_del_users));
//this->view_add_columns(*groupsQuotasTree);
//this->view_add_columns(*ProjectQuotasTree);
//this->view_add_columns(*usersQuotasTree);
}
void MainWindow::remove_line_template(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter, Gtk::TreeModel::iterator& iter_del, bool& flag_del) {

@ -16,6 +16,7 @@
using namespace std;
#define yon_gtk_builder_get_widget(builder, widget_name) GTK_WIDGET(gtk_builder_get_object(builder, widget_name))
extern bool flag_save;
@ -179,6 +180,10 @@ class MainWindow {
Gtk::Box* boxProjectDays;
Gtk::Box* boxProjectHours;
Gtk::Box* boxProjectMinutes;
GtkListStore* gtk_list_project;
GtkListStore* gtk_list_groups;
GtkListStore* gtk_list_user;
GtkListStore* gtk_list_general;
public:
map_str_str* map_gui_cfg = NULL;
@ -220,6 +225,7 @@ class MainWindow {
~MainWindow();
void settings();
void flag_block_gui();
void tree_view_select();
void lacalization();
void add_CSS();
void resize_widget();

@ -8,6 +8,108 @@
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="ListGeneral">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
<!-- column-name gchararray2 -->
<column type="gchararray"/>
<!-- column-name gchararray3 -->
<column type="gchararray"/>
<!-- column-name gchararray4 -->
<column type="gchararray"/>
<!-- column-name gchararray5 -->
<column type="gchararray"/>
<!-- column-name gchararray6 -->
<column type="gchararray"/>
<!-- column-name gchararray7 -->
<column type="gchararray"/>
<!-- column-name gchararray8 -->
<column type="gchararray"/>
<!-- column-name gchararray9 -->
<column type="gchararray"/>
<!-- column-name gchararray10 -->
<column type="gchararray"/>
<!-- column-name gchararray11 -->
<column type="gchararray"/>
<!-- column-name gchararray12 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="ListGroups">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
<!-- column-name gchararray2 -->
<column type="gchararray"/>
<!-- column-name gchararray3 -->
<column type="gchararray"/>
<!-- column-name gchararray4 -->
<column type="gchararray"/>
<!-- column-name gchararray5 -->
<column type="gchararray"/>
<!-- column-name gchararray6 -->
<column type="gchararray"/>
<!-- column-name gchararray7 -->
<column type="gchararray"/>
<!-- column-name gchararray8 -->
<column type="gchararray"/>
<!-- column-name gchararray9 -->
<column type="gchararray"/>
<!-- column-name gchararray10 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="ListProject">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
<!-- column-name gchararray2 -->
<column type="gchararray"/>
<!-- column-name gchararray3 -->
<column type="gchararray"/>
<!-- column-name gchararray4 -->
<column type="gchararray"/>
<!-- column-name gchararray5 -->
<column type="gchararray"/>
<!-- column-name gchararray6 -->
<column type="gchararray"/>
<!-- column-name gchararray7 -->
<column type="gchararray"/>
<!-- column-name gchararray8 -->
<column type="gchararray"/>
<!-- column-name gchararray9 -->
<column type="gchararray"/>
<!-- column-name gchararray10 -->
<column type="gchararray"/>
<!-- column-name gchararray11 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="ListUser">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
<!-- column-name gchararray2 -->
<column type="gchararray"/>
<!-- column-name gchararray3 -->
<column type="gchararray"/>
<!-- column-name gchararray4 -->
<column type="gchararray"/>
<!-- column-name gchararray5 -->
<column type="gchararray"/>
<!-- column-name gchararray6 -->
<column type="gchararray"/>
<!-- column-name gchararray7 -->
<column type="gchararray"/>
<!-- column-name gchararray8 -->
<column type="gchararray"/>
<!-- column-name gchararray9 -->
<column type="gchararray"/>
<!-- column-name gchararray10 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="SizeStore">
<columns>
<!-- column-name gchararray1 -->
@ -325,7 +427,6 @@
</object>
</child>
</object>
<object class="GtkListStore" id="liststore1"/>
<object class="GtkMenu" id="menuLoad">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -528,7 +629,7 @@
<object class="GtkTreeView" id="GeneralQuotasTree">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="model">liststore1</property>
<property name="model">ListGeneral</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
@ -1248,7 +1349,7 @@ limitation
<object class="GtkTreeView" id="usersQuotasTree">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="model">liststore1</property>
<property name="model">ListUser</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
@ -2120,7 +2221,7 @@ limitation
<object class="GtkTreeView" id="groupsQuotasTree">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="model">liststore1</property>
<property name="model">ListGroups</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
@ -2992,7 +3093,7 @@ limitation
<object class="GtkTreeView" id="ProjectQuotasTree">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="model">liststore1</property>
<property name="model">ListProject</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>

Loading…
Cancel
Save