Bayeux  3.4.1
Core Foundation library for SuperNEMO
variant_repository_viewer.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2014-10-19
4  * Last modified : 2014-10-19
5  *
6  * Copyright (C) 2014 Francois Mauger <mauger@lpccaen.in2p3.fr>
7  *
8  * This program 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 (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * A viewer/editor widget for configuration variant registry.
26  *
27  */
28 
29 #ifndef DATATOOLS_CONFIGURATION_UI_VARIANT_REPOSITORY_VIEWER_H
30 #define DATATOOLS_CONFIGURATION_UI_VARIANT_REPOSITORY_VIEWER_H
31 
32 // Standard library:
33 #include <string>
34 #include <map>
35 #include <memory>
36 
37 // Third party:
38 // - Boost:
39 #include <boost/cstdint.hpp>
40 // - Qt:
41 #include <QWidget>
42 #include <QObject>
43 
44 // Forward declarations:
45 class QLabel;
46 class QCheckBox;
47 class QPushButton;
48 class QComboBox;
49 class QTabWidget;
50 class QIcon;
51 
52 // This project:
53 #include <datatools/logger.h>
54 
55 namespace datatools {
56 
57  namespace qt {
58  class led;
59  }
60 
61  namespace configuration {
62 
63  // Forward declaration:
64  class variant_registry;
65  class variant_repository;
66 
67  namespace ui {
68 
69  // Forward declaration:
70  class variant_registry_tree_model;
71  class variant_registry_viewer;
72 
75  {
76  public:
77 
79  registry_model_wrapper(QWidget * parent_ = 0);
80 
83 
85  void reset();
86 
88  bool has_model() const;
89 
91  const variant_registry_tree_model & get_model() const;
92 
95 
97  bool has_viewer() const;
98 
100  const variant_registry_viewer & get_viewer() const;
101 
104 
107 
108  private:
109 
110  uint32_t _flags_;
111  QWidget * _parent_;
112  variant_registry_tree_model * _model_;
113  variant_registry_viewer * _viewer_;
114 
115  };
116 
118  class variant_repository_viewer : public QWidget
119  {
120  Q_OBJECT
121 
122  public:
123 
125  typedef std::map<std::string, registry_model_wrapper> model_dict_type;
126 
128  variant_repository_viewer(QWidget * parent_ = 0);
129 
131  virtual ~variant_repository_viewer();
132 
135 
137  bool has_repository() const;
138 
140  void set_repository(variant_repository & var_rep_);
141 
144 
146  const variant_repository & get_repository() const;
147 
149  bool is_read_only() const;
150 
152  void set_read_only(bool);
153 
155  bool has_restore_buffer() const;
156 
158  void reset_restore_buffer();
159 
160  public slots:
161 
163  void slot_update_read_only_from_check_state(int check_state_);
164 
166  void slot_update_read_only_cb(bool read_only_);
167 
169  void slot_at_registry_changed(std::string changed_registry_);
170 
172  void slot_at_registry_data_changed(std::string changed_registry_, std::string changed_data_path_);
173 
175  void slot_update_tabs();
176 
178  void slot_at_set_read_only(bool);
179 
181  void slot_update_leds();
182 
184  void slot_update();
185 
187  void slot_dump() const;
188 
190  void slot_update_logging(const QString &);
191 
193  void slot_restore(std::string * buffer_ = 0);
194 
196  void slot_snapshot(std::string * buffer_ = 0);
197 
199  void slot_load_from_file();
200 
202  void slot_store_to_file();
203 
204  signals:
205 
206  void sig_read_only_changed(bool);
207 
208  void sig_repository_changed();
209 
210  protected:
211 
213  void _construct();
214 
216  void _construct_devel();
217 
220 
221  private:
222 
223  bool _devel_mode_;
224  datatools::logger::priority _logging_;
225  variant_repository * _repository_;
226  bool _read_only_;
227  model_dict_type _models_;
228  QLabel * _repository_name_title_label_;
229  QLabel * _repository_name_display_label_;
230  QLabel * _repository_org_title_label_;
231  QLabel * _repository_org_display_label_;
232  QLabel * _repository_app_title_label_;
233  QLabel * _repository_app_display_label_;
234  QLabel * _accomplished_label_;
235  datatools::qt::led * _accomplished_led_;
236  QCheckBox * _read_only_cb_;
237  QTabWidget * _registry_tabs_;
238  std::map<std::string, int> _tab_indexes_;
239  QPushButton * _dump_button_;
240  QLabel * _logging_label_;
241  QComboBox * _logging_combo_;
242  QIcon * _unaccomplished_icon_;
243  QIcon * _null_icon_;
244  std::unique_ptr<std::string> _restore_buffer_;
245 
246  };
247 
248  } // end of namespace ui
249 
250  } // end of namespace configuration
251 
252 } // end of namespace datatools
253 
254 #endif // DATATOOLS_CONFIGURATION_UI_VARIANT_REPOSITORY_VIEWER_H
255 
256 // Local Variables: --
257 // mode: c++ --
258 // c-file-style: "gnu" --
259 // tab-width: 2 --
260 // End: --
void slot_update_logging(const QString &)
Slot: set the logging priority.
void set_read_only(bool)
Set the read-only flag.
void slot_update_read_only_from_check_state(int check_state_)
Slot: update the Read-only flag from the check box state.
Registry of configuration variant parameters and associated variants.
Definition: variant_registry.h:53
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
bool has_restore_buffer() const
Check if a restore buffer is available.
Qt tree model for configuration variant registry.
Definition: variant_registry_tree_model.h:158
const variant_registry_tree_model & get_model() const
Return a non mutable reference to the model.
A wrapper that handles a registry tree model and its associated viewer object.
Definition: variant_repository_viewer.h:74
void reset_restore_buffer()
Reset the restore buffer is available.
void _compute_active_registries()
Compute the registries activation.
registry_model_wrapper(QWidget *parent_=0)
Default constructor.
void set_logging(datatools::logger::priority p_)
Set the logging priority.
void set_repository(variant_repository &var_rep_)
Set the variant repository.
void slot_load_from_file()
Slot: load the repository from a file.
A widget to browse/edit a configuration variant registry.
Definition: variant_registry_viewer.h:71
variant_repository_viewer(QWidget *parent_=0)
Default constructor.
void slot_at_set_read_only(bool)
Slot: set read-only flag.
void slot_store_to_file()
Slot: store the repository in a file.
variant_registry_tree_model & grab_model()
Return a mutable reference to the model.
variant_registry_viewer & grab_viewer()
Return a mutable reference to the viewer.
variant_registry_viewer * construct_registry_viewer(variant_registry &registry_)
Construct.
void _construct_devel()
Construct the development part of the GUI.
bool has_repository() const
Check if the viewer has a repository.
A LED widget with ON/OFF(/INDETERMINATE) status.
Definition: led.h:59
const variant_registry_viewer & get_viewer() const
Return a non mutable reference to the viewer.
bool is_read_only() const
Check if the read-only flag.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Utilities for logging information.
void slot_restore(std::string *buffer_=0)
Slot: store the current status to a buffer.
std::map< std::string, registry_model_wrapper > model_dict_type
Dictionary of registry UI models.
Definition: variant_repository_viewer.h:125
const variant_repository & get_repository() const
Return the non mutable reference to the repository.
void slot_update_read_only_cb(bool read_only_)
Slot: update the Read-only check box state.
variant_repository & grab_repository()
Return the mutable reference to the repository.
void slot_at_registry_changed(std::string changed_registry_)
Slot: action at registry changed.
void slot_snapshot(std::string *buffer_=0)
Slot: load the current status from a buffer.
void slot_at_registry_data_changed(std::string changed_registry_, std::string changed_data_path_)
Slot: action at registry data changed.
Variant repository.
Definition: variant_repository.h:57
void slot_update_tabs()
Slot: update registry tabs.
A widget to browse/edit a configuration variant registry.
Definition: variant_repository_viewer.h:118