comparison libgui/src/workspace-view.cc @ 20605:734d446560a8

possibility to hide filters in history and workspace view (bug#45428) * history_dock_widget.cc(construct): use settings file for show/hide the filter; (~history_dock_widget): save current filter state to settings file; (ctxMenu): add menu entry for showing/hiding the filter; (handle_contextmenu_filter): slot for the new menu entry * history-dock-widget.h: new slot for new menu entry, new class variables for filter and show/hide-state * workspace-view.cc(workspace_view): use settings file for show/hide the filter; (~workspace_view): save current filter state to settings file; (contextmenu_requested): add menu entry for showing/hiding the filter; (handle_contextmenu_filter): slot for the new menu entry * workspace-view.h: new slot for new menu entry, new class variables for filter and show/hide-state
author Torsten <ttl@justmail.de>
date Wed, 07 Oct 2015 21:01:25 +0200
parents 2b28f509b645
children
comparison
equal deleted inserted replaced
20603:f61c67865d9f 20605:734d446560a8
73 view_previous_row_count = 0; 73 view_previous_row_count = 0;
74 74
75 // Set an empty widget, so we can assign a layout to it. 75 // Set an empty widget, so we can assign a layout to it.
76 setWidget (new QWidget (this)); 76 setWidget (new QWidget (this));
77 77
78 // Create a new layout and add widgets to it. 78 // Create the layouts
79 QVBoxLayout *vbox_layout = new QVBoxLayout (); 79 _filter_widget = new QWidget (this);
80 QHBoxLayout *hbox_layout = new QHBoxLayout (); 80 QHBoxLayout *filter_layout = new QHBoxLayout ();
81 hbox_layout->addWidget (filter_label); 81
82 hbox_layout->addWidget (_filter_checkbox); 82 filter_layout->addWidget (filter_label);
83 hbox_layout->addWidget (_filter); 83 filter_layout->addWidget (_filter_checkbox);
84 vbox_layout->addLayout (hbox_layout); 84 filter_layout->addWidget (_filter);
85 vbox_layout->addWidget (view); 85 filter_layout->setMargin(0);
86 vbox_layout->setMargin (2); 86 _filter_widget->setLayout (filter_layout);
87
88 QVBoxLayout *ws_layout = new QVBoxLayout ();
89 ws_layout->addWidget (_filter_widget);
90 ws_layout->addWidget (view);
91
92 QSettings *settings = resource_manager::get_settings ();
93
94 _filter_shown = settings->value ("workspaceview/filter_shown",true).toBool();
95 _filter_widget->setVisible (_filter_shown);
96
97 ws_layout->setMargin (2);
87 98
88 // Set the empty widget to have our layout. 99 // Set the empty widget to have our layout.
89 widget ()->setLayout (vbox_layout); 100 widget ()->setLayout (ws_layout);
90 101
91 // Initialize collapse/expand state of the workspace subcategories. 102 // Initialize collapse/expand state of the workspace subcategories.
92
93 QSettings *settings = resource_manager::get_settings ();
94 103
95 //enable sorting (setting column and order after model was set) 104 //enable sorting (setting column and order after model was set)
96 view->setSortingEnabled (true); 105 view->setSortingEnabled (true);
97 // Initialize column order and width of the workspace 106 // Initialize column order and width of the workspace
98 view->horizontalHeader ()->restoreState ( 107 view->horizontalHeader ()->restoreState (
127 connect (view, SIGNAL (customContextMenuRequested (const QPoint&)), 136 connect (view, SIGNAL (customContextMenuRequested (const QPoint&)),
128 this, SLOT (contextmenu_requested (const QPoint&))); 137 this, SLOT (contextmenu_requested (const QPoint&)));
129 138
130 connect (this, SIGNAL (command_requested (const QString&)), 139 connect (this, SIGNAL (command_requested (const QString&)),
131 p, SLOT (execute_command_in_terminal (const QString&))); 140 p, SLOT (execute_command_in_terminal (const QString&)));
132
133 } 141 }
134 142
135 workspace_view::~workspace_view (void) 143 workspace_view::~workspace_view (void)
136 { 144 {
137 QSettings *settings = resource_manager::get_settings (); 145 QSettings *settings = resource_manager::get_settings ();
144 settings->setValue ("workspaceview/sort_by_column", sort_column); 152 settings->setValue ("workspaceview/sort_by_column", sort_column);
145 settings->setValue ("workspaceview/sort_order", sort_order); 153 settings->setValue ("workspaceview/sort_order", sort_order);
146 154
147 settings->setValue ("workspaceview/filter_active", 155 settings->setValue ("workspaceview/filter_active",
148 _filter_checkbox->isChecked ()); 156 _filter_checkbox->isChecked ());
157 settings->setValue ("workspaceview/filter_shown", _filter_shown);
149 158
150 QStringList mru; 159 QStringList mru;
151 for (int i = 0; i < _filter->count (); i++) 160 for (int i = 0; i < _filter->count (); i++)
152 mru.append (_filter->itemText (i)); 161 mru.append (_filter->itemText (i));
153 settings->setValue ("workspaceview/mru_list", mru); 162 settings->setValue ("workspaceview/mru_list", mru);
261 SLOT (handle_contextmenu_plot ())); 270 SLOT (handle_contextmenu_plot ()));
262 271
263 menu.addAction ("stem (" + var_name + ")", this, 272 menu.addAction ("stem (" + var_name + ")", this,
264 SLOT (handle_contextmenu_stem ())); 273 SLOT (handle_contextmenu_stem ()));
265 274
266 menu.exec (view->mapToGlobal (qpos)); 275 menu.addSeparator ();
267 } 276
277 }
278
279 if (_filter_shown)
280 menu.addAction (tr ("Hide filter"), this,
281 SLOT (handle_contextmenu_filter ()));
282 else
283 menu.addAction (tr ("Show filter"), this,
284 SLOT (handle_contextmenu_filter ()));
285
286 menu.exec (view->mapToGlobal (qpos));
268 } 287 }
269 288
270 void 289 void
271 workspace_view::handle_contextmenu_copy (void) 290 workspace_view::handle_contextmenu_copy (void)
272 { 291 {
354 { 373 {
355 QString var_name = get_var_name (index); 374 QString var_name = get_var_name (index);
356 375
357 emit command_requested (cmdname + " (" + var_name + ");"); 376 emit command_requested (cmdname + " (" + var_name + ");");
358 } 377 }
378 }
379
380 void
381 workspace_view::handle_contextmenu_filter (void)
382 {
383 _filter_shown = not _filter_shown;
384 _filter_widget->setVisible (_filter_shown);
359 } 385 }
360 386
361 void 387 void
362 workspace_view::handle_model_changed (void) 388 workspace_view::handle_model_changed (void)
363 { 389 {