Public Slots | Signals | Public Member Functions | Private Attributes | List of all members
dbutils::gui::TabbedSetOfTableEditors Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-02/DatabaseUtils/cxx/include/GUI/TabbedSetOfTableEditors.h"

Inheritance diagram for dbutils::gui::TabbedSetOfTableEditors:
dbutils::gui::Changeable dbutils::gui::Storeable

Public Slots

void reactToEditorDataChange ()
 
void reactToDataSave ()
 

Signals

void aChangeWasMade ()
 
void dataWasSaved ()
 

Public Member Functions

 TabbedSetOfTableEditors (const std::string &subsystemName, const std::string &configType, const std::vector< std::string > &tableDefinitionList, QWidget *parent=0)
 
bool loadData (const dbutils::daqconfig::IDSpec &idSpec)
 
bool hasChanges () const
 
bool saveChanges (const dbutils::daqconfig::IDSpec &oldGlobalIdSpec, const dbutils::daqconfig::IDSpec &newGlobalIdSpec, const dbutils::daqconfig::GlobalNameSpec &newGlobalNameSpec)
 
bool addInitialRow ()
 
void isTopLevel (bool setting=true)
 

Private Attributes

std::string _subsystemName
 
std::string _configType
 
std::vector< std::string_tableDefinitionList
 
bool _isTopLevel
 

Detailed Description

Class for displaying tabs for table-style editors of configuration data.

Author
Kurt Biery
Version
Revision
1.6.14.1
Date
2019/09/27 00:07:04

Definition at line 19 of file TabbedSetOfTableEditors.h.

Constructor & Destructor Documentation

dbutils::gui::TabbedSetOfTableEditors::TabbedSetOfTableEditors ( const std::string subsystemName,
const std::string configType,
const std::vector< std::string > &  tableDefinitionList,
QWidget *  parent = 0 
)

Definition at line 13 of file TabbedSetOfTableEditors.cpp.

References _configType, _subsystemName, _tableDefinitionList, aChangeWasMade(), g4zmq::connect(), dataWasSaved(), shutoffs::filename, dbutils::gui::ConfigDataTableEditor::getTableName(), compare_h5_caf::idx, loadData(), reactToDataSave(), reactToEditorDataChange(), and string.

16  : QTabWidget(parent),
17  _isTopLevel(false)
18 {
19  _subsystemName = subsystemName;
20  _configType = configType;
21  _tableDefinitionList = tableDefinitionList;
22 
23  for (uint32_t idx = 0; idx < _tableDefinitionList.size(); ++idx) {
25  ConfigDataTableEditor* editor =
26  new ConfigDataTableEditor(filename, this);
27  this->addTab(editor, editor->getTableName().c_str());
28 
29  connect(editor, SIGNAL(aChangeWasMade()),
30  this, SLOT(reactToEditorDataChange()));
31  connect(editor, SIGNAL(dataWasSaved()),
32  this, SLOT(reactToDataSave()));
33  }
34 }
string filename
Definition: shutoffs.py:106
def connect(endpoint="tcp://127.0.0.1:5555")
Definition: g4zmq.py:15
std::vector< std::string > _tableDefinitionList
enum BeamMode string

Member Function Documentation

void dbutils::gui::TabbedSetOfTableEditors::aChangeWasMade ( )
signal
bool dbutils::gui::TabbedSetOfTableEditors::addInitialRow ( )
virtual

Requests that an initial row be added to the currently displayed table or tree.

Implements dbutils::gui::Changeable.

Definition at line 187 of file TabbedSetOfTableEditors.cpp.

References dbutils::gui::ConfigDataTableEditor::addInitialRow(), confusionMatrixTree::count, compare_h5_caf::idx, and fabricate::status.

188 {
189  bool status = true;
190  for (int idx = 0; idx < this->count(); ++idx) {
191  QWidget* theWidget = widget(idx);
192  ConfigDataTableEditor* editor =
193  static_cast<ConfigDataTableEditor*>(theWidget);
194  if (! editor->addInitialRow()) {status = false;}
195  }
196  return status;
197 }
int status
Definition: fabricate.py:1613
void dbutils::gui::TabbedSetOfTableEditors::dataWasSaved ( )
signal
bool dbutils::gui::TabbedSetOfTableEditors::hasChanges ( ) const
virtual

Tests whether there are any local changes that have not yet been stored in the database.

Implements dbutils::gui::Changeable.

Definition at line 72 of file TabbedSetOfTableEditors.cpp.

References confusionMatrixTree::count, dbutils::gui::ConfigDataTableEditor::hasChanges(), compare_h5_caf::idx, and saveChanges().

Referenced by saveChanges().

73 {
74  for (int idx = 0; idx < this->count(); ++idx) {
75  QWidget* theWidget = widget(idx);
76  ConfigDataTableEditor* editor =
77  static_cast<ConfigDataTableEditor*>(theWidget);
78  if (editor->hasChanges()) {return true;}
79  }
80  return false;
81 }
void dbutils::gui::TabbedSetOfTableEditors::isTopLevel ( bool  setting = true)
inline
bool dbutils::gui::TabbedSetOfTableEditors::loadData ( const dbutils::daqconfig::IDSpec idSpec)
virtual

Loads the data associated with the specified config ID.

Implements dbutils::gui::Storeable.

Definition at line 37 of file TabbedSetOfTableEditors.cpp.

References _configType, _isTopLevel, _subsystemName, confusionMatrixTree::count, dbutils::daqconfig::IDSpec::getConfigId(), dbutils::gui::ConfigDataTableEditor::getTableName(), compare_h5_caf::idx, dbutils::gui::ConfigDataTableEditor::loadData(), bp_utils::progressBar(), and fabricate::status.

Referenced by TabbedSetOfTableEditors().

38 {
39  if (idSpec.getConfigId() == -1) {return false;}
40 
41  boost::shared_ptr<QProgressDialog> progressBar;
42  if (_isTopLevel) {
43  progressBar.reset(new QProgressDialog("Loading data...", "Close", 0,
44  this->count(), this));
45  progressBar->setWindowModality(Qt::WindowModal);
46  progressBar->setMinimumDuration(250);
47  }
48 
49  std::vector<int64_t> subsystemConfigIdList;
50  if (! NamedConfigUtils::
51  getSubsystemConfigIdAncestryFromGlobalId(idSpec,
54  subsystemConfigIdList)) {
55  return false;
56  }
57 
58  bool status = true;
59  for (int idx = 0; idx < this->count(); ++idx) {
60  if (_isTopLevel) {progressBar->setValue(idx);}
61  QWidget* theWidget = widget(idx);
62  ConfigDataTableEditor* editor =
63  static_cast<ConfigDataTableEditor*>(theWidget);
64  if (! editor->loadData(subsystemConfigIdList)) {status = false;}
65  this->setTabText(idx, editor->getTableName().c_str());
66  }
67  if (_isTopLevel) {progressBar->setValue(this->count());}
68 
69  return status;
70 }
def progressBar(value, endvalue, docdb_id, bar_length=40)
Definition: bp_utils.py:6
int status
Definition: fabricate.py:1613
int64_t getConfigId() const
Definition: IDSpec.h:36
void dbutils::gui::TabbedSetOfTableEditors::reactToDataSave ( )
slot

Definition at line 205 of file TabbedSetOfTableEditors.cpp.

References dataWasSaved(), and dbutils::gui::CustomTabBehaviors::updateTabTextColors().

Referenced by isTopLevel(), and TabbedSetOfTableEditors().

206 {
207  CustomTabBehaviors::updateTabTextColors(this, this->tabBar());
208  emit dataWasSaved();
209 }
void updateTabTextColors(QTabWidget *tabWidget, QTabBar *tabBar)
void dbutils::gui::TabbedSetOfTableEditors::reactToEditorDataChange ( )
slot

Definition at line 199 of file TabbedSetOfTableEditors.cpp.

References aChangeWasMade(), and dbutils::gui::CustomTabBehaviors::updateTabTextColors().

Referenced by isTopLevel(), and TabbedSetOfTableEditors().

200 {
201  CustomTabBehaviors::updateTabTextColors(this, this->tabBar());
202  emit aChangeWasMade();
203 }
void updateTabTextColors(QTabWidget *tabWidget, QTabBar *tabBar)
bool dbutils::gui::TabbedSetOfTableEditors::saveChanges ( const dbutils::daqconfig::IDSpec oldIdSpec,
const dbutils::daqconfig::IDSpec newIdSpec,
const dbutils::daqconfig::GlobalNameSpec newNameSpec 
)
virtual

Saves all local changes to the database.

Implements dbutils::gui::Storeable.

Definition at line 84 of file TabbedSetOfTableEditors.cpp.

References _configType, _isTopLevel, _subsystemName, om::cerr, novadaq::Status::code, confusionMatrixTree::count, allTimeWatchdog::endl, dbutils::daqconfig::IDSpec::getConfigId(), dbutils::daqconfig::GlobalNameSpec::getConfigName(), dbutils::daqconfig::GlobalNameSpec::getDCMOpMode(), hasChanges(), compare_h5_caf::idx, dbutils::daqconfig::IDSpec::isDAQConfiguration(), novadaq::Status::message, bp_utils::progressBar(), dbutils::SimpleParameterSet::put(), dbutils::gui::ConfigDataTableEditor::saveChanges(), fabricate::status, and string.

Referenced by hasChanges().

87 {
88  if (! this->hasChanges()) {return true;}
89 
90  boost::shared_ptr<QProgressDialog> progressBar;
91  if (_isTopLevel) {
92  progressBar.reset(new QProgressDialog("Loading data...", "Close", 0,
93  this->count(), this));
94  progressBar->setWindowModality(Qt::WindowModal);
95  progressBar->setMinimumDuration(250);
96  }
97 
98  // ** create the new subsystem named configuration ***
99  std::vector<int64_t> existingSubystemConfigIdList;
100  if (! NamedConfigUtils::
101  getSubsystemConfigIdAncestryFromGlobalId(oldGlobalIdSpec,
103  existingSubystemConfigIdList)) {
104  std::cerr << "ERROR: unable to fetch the existing named subsystem "
105  << "configurations." << std::endl;
106  return false;
107  }
108  int64_t oldSubsystemConfigId = existingSubystemConfigIdList[0];
109  IDSpec oldSubsystemIdSpec(oldSubsystemConfigId, IDSpec::SUBSYSTEM,
110  (oldGlobalIdSpec.isDAQConfiguration() ?
111  IDSpec::DAQ : IDSpec::SLOWCONTROLS));
112 
114  if (newGlobalNameSpec.getConfigName() != "InitialGlobalConfig" &&
115  newGlobalNameSpec.getConfigName() != "ColdDetectorSettings") {
116  std::string newName = newGlobalNameSpec.getConfigName() + "_" +
117  _subsystemName + "_" + _configType;
118  paramSet.put(NamedConfigUtils::NAME_COLUMN_NAME, newName);
119  }
120  paramSet.put(NamedConfigUtils::DCMOPMODE_COLUMN_NAME,
121  newGlobalNameSpec.getDCMOpMode());
122  paramSet.put(NamedConfigUtils::DESCRIPTION_COLUMN_NAME,
123  "New values from the Configuration Editor GUI.");
124  paramSet.put(NamedConfigUtils::GLOBALCFGID_COLUMN_NAME,
125  boost::lexical_cast<std::string>
126  (newGlobalIdSpec.getConfigId()));
127  int64_t subsystemConfigId;
128  novadaq::Status resultStatus =
129  NamedConfigUtils::copySubsystemConfig(oldSubsystemIdSpec, true,
130  paramSet, "", true,
131  subsystemConfigId);
132  if (resultStatus.code ==
133  NamedConfigUtils::COPY_FOUND_UPDATE_IN_PROGRESS) {
134  std::cerr << "Unable to create a copy of the named "
135  << "subsystem configuration with ID = "
136  << oldSubsystemConfigId
137  << ": the creation of a new configuration is "
138  << "already in progress ("
139  << resultStatus.message << ")"
140  << std::endl;
141  return false;
142  }
143  else if (resultStatus.code ==
144  NamedConfigUtils::COPY_FOUND_INTERMEDIATE_UPDATE) {
145  std::cerr << "Unable to create a copy of the named "
146  << "subsystem configuration with ID = "
147  << oldSubsystemConfigId
148  << ": intermediate changes would be overwritten by "
149  << "this change (" << resultStatus.message << ")"
150  << std::endl;
151  return false;
152  }
153  else if (resultStatus.code != NamedConfigUtils::COPY_SUCCEEDED) {
154  std::cerr << "Unable to create a copy of the named "
155  << "subsystem configuration with ID = "
156  << oldSubsystemConfigId
157  << ": " << resultStatus.message
158  << std::endl;
159  return false;
160  }
161 
162  bool status = true;
163  for (int idx = 0; idx < this->count(); ++idx) {
164  if (_isTopLevel) {progressBar->setValue(idx);}
165  QWidget* theWidget = widget(idx);
166  ConfigDataTableEditor* editor =
167  static_cast<ConfigDataTableEditor*>(theWidget);
168  if (! editor->saveChanges(oldSubsystemConfigId, subsystemConfigId)) {
169  status = false;
170  }
171  }
172 
173  IDSpec subsystemIdSpec(subsystemConfigId, IDSpec::SUBSYSTEM,
174  (oldGlobalIdSpec.isDAQConfiguration() ?
175  IDSpec::DAQ : IDSpec::SLOWCONTROLS));
176  if (status) {
177  NamedConfigUtils::markConfigDone(subsystemIdSpec, true);
178  }
179  else {
180  NamedConfigUtils::markConfigDone(subsystemIdSpec, false);
181  }
182  if (_isTopLevel) {progressBar->setValue(this->count());}
183 
184  return status;
185 }
def progressBar(value, endvalue, docdb_id, bar_length=40)
Definition: bp_utils.py:6
int status
Definition: fabricate.py:1613
void put(const std::string &key, const std::string &value)
int32_t code
Definition: Status.h:22
OStream cerr
Definition: OStream.cxx:7
std::string message
Definition: Status.h:24
enum BeamMode string

Member Data Documentation

std::string dbutils::gui::TabbedSetOfTableEditors::_configType
private

Definition at line 54 of file TabbedSetOfTableEditors.h.

Referenced by loadData(), saveChanges(), and TabbedSetOfTableEditors().

bool dbutils::gui::TabbedSetOfTableEditors::_isTopLevel
private

Definition at line 56 of file TabbedSetOfTableEditors.h.

Referenced by isTopLevel(), loadData(), and saveChanges().

std::string dbutils::gui::TabbedSetOfTableEditors::_subsystemName
private

Definition at line 53 of file TabbedSetOfTableEditors.h.

Referenced by loadData(), saveChanges(), and TabbedSetOfTableEditors().

std::vector<std::string> dbutils::gui::TabbedSetOfTableEditors::_tableDefinitionList
private

Definition at line 55 of file TabbedSetOfTableEditors.h.

Referenced by TabbedSetOfTableEditors().


The documentation for this class was generated from the following files: