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

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

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

Public Slots

void reactToEditorDataChange ()
 
void reactToDataSave ()
 

Signals

void aChangeWasMade ()
 
void dataWasSaved ()
 

Public Member Functions

 TabbedSetOfTreeEditors (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 the tabs that make up the graphical configuration editor.

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

Definition at line 19 of file TabbedSetOfTreeEditors.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file TabbedSetOfTreeEditors.cpp.

References _configType, _subsystemName, _tableDefinitionList, aChangeWasMade(), g4zmq::connect(), dataWasSaved(), compare_h5_caf::idx, loadData(), reactToDataSave(), and reactToEditorDataChange().

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

Member Function Documentation

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

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

Implements dbutils::gui::Changeable.

Definition at line 200 of file TabbedSetOfTreeEditors.cpp.

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

201 {
202  bool status = true;
203  for (int idx = 0; idx < this->count(); ++idx) {
204  QWidget* theWidget = widget(idx);
205  ConfigDataTreeEditor* editor =
206  static_cast<ConfigDataTreeEditor*>(theWidget);
207  if (! editor->addInitialRow()) {status = false;}
208  }
209  return status;
210 }
int status
Definition: fabricate.py:1613
void dbutils::gui::TabbedSetOfTreeEditors::dataWasSaved ( )
signal
bool dbutils::gui::TabbedSetOfTreeEditors::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 85 of file TabbedSetOfTreeEditors.cpp.

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

Referenced by dbutils::gui::DCSConfigEditorDisplay::hasChanges(), and saveChanges().

86 {
87  for (int idx = 0; idx < this->count(); ++idx) {
88  QWidget* theWidget = widget(idx);
89  ConfigDataTreeEditor* editor =
90  static_cast<ConfigDataTreeEditor*>(theWidget);
91  if (editor->hasChanges()) {return true;}
92  }
93  return false;
94 }
void dbutils::gui::TabbedSetOfTreeEditors::isTopLevel ( bool  setting = true)
inline
bool dbutils::gui::TabbedSetOfTreeEditors::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 TabbedSetOfTreeEditors.cpp.

References _configType, _isTopLevel, _subsystemName, _tableDefinitionList, confusionMatrixTree::count, shutoffs::filename, dbutils::daqconfig::IDSpec::getConfigId(), compare_h5_caf::idx, dbutils::gui::ConfigDataTreeEditor::loadData(), bp_utils::progressBar(), fabricate::status, and string.

Referenced by dbutils::gui::DCSConfigEditorDisplay::_doLoadNewDataset(), dbutils::gui::DCSConfigEditorDisplay::_doReloadCurrentDataset(), dbutils::gui::DCSConfigEditorDisplay::DCSConfigEditorDisplay(), and TabbedSetOfTreeEditors().

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  boost::shared_ptr<DataTreeCreatorThread> treeThreadPtr;
59  std::vector<boost::shared_ptr<DataTreeCreatorThread> > treeThreadList;
60  for (uint32_t idx = 0; idx < _tableDefinitionList.size(); ++idx) {
62  treeThreadPtr.reset(new DataTreeCreatorThread(filename,
63  subsystemConfigIdList,this));
64  treeThreadList.push_back(treeThreadPtr);
65  }
66 
67  bool status = true;
68  for (uint32_t idx = 0; idx < treeThreadList.size(); ++idx) {
69  if (_isTopLevel) {progressBar->setValue(idx);}
70  treeThreadPtr = treeThreadList[idx];
71  treeThreadPtr->wait();
72  boost::shared_ptr<ConfigDataTree> dataTreePtr=treeThreadPtr->getTree();
73 
74  QWidget* theWidget = widget(idx);
75  ConfigDataTreeEditor* editor =
76  static_cast<ConfigDataTreeEditor*>(theWidget);
77  if (! editor->loadData(dataTreePtr)) {status = false;}
78  this->setTabText(idx, dataTreePtr->getTableName().c_str());
79  }
80  if (_isTopLevel) {progressBar->setValue(this->count());}
81 
82  return status;
83 }
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
string filename
Definition: shutoffs.py:106
std::vector< std::string > _tableDefinitionList
enum BeamMode string
void dbutils::gui::TabbedSetOfTreeEditors::reactToDataSave ( )
slot

Definition at line 218 of file TabbedSetOfTreeEditors.cpp.

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

Referenced by isTopLevel(), and TabbedSetOfTreeEditors().

219 {
220  CustomTabBehaviors::updateTabTextColors(this, this->tabBar());
221  emit dataWasSaved();
222 }
void updateTabTextColors(QTabWidget *tabWidget, QTabBar *tabBar)
void dbutils::gui::TabbedSetOfTreeEditors::reactToEditorDataChange ( )
slot

Definition at line 212 of file TabbedSetOfTreeEditors.cpp.

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

Referenced by isTopLevel(), and TabbedSetOfTreeEditors().

213 {
214  CustomTabBehaviors::updateTabTextColors(this, this->tabBar());
215  emit aChangeWasMade();
216 }
void updateTabTextColors(QTabWidget *tabWidget, QTabBar *tabBar)
bool dbutils::gui::TabbedSetOfTreeEditors::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 97 of file TabbedSetOfTreeEditors.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::ConfigDataTreeEditor::saveChanges(), fabricate::status, and string.

Referenced by dbutils::gui::DCSConfigEditorDisplay::_doSaveChanges(), and hasChanges().

100 {
101  if (! this->hasChanges()) {return true;}
102 
103  boost::shared_ptr<QProgressDialog> progressBar;
104  if (_isTopLevel) {
105  progressBar.reset(new QProgressDialog("Loading data...", "Close", 0,
106  this->count(), this));
107  progressBar->setWindowModality(Qt::WindowModal);
108  progressBar->setMinimumDuration(250);
109  }
110 
111  // ** create the new subsystem named configuration ***
112  std::vector<int64_t> existingSubystemConfigIdList;
113  if (! NamedConfigUtils::
114  getSubsystemConfigIdAncestryFromGlobalId(oldGlobalIdSpec,
116  existingSubystemConfigIdList)) {
117  std::cerr << "ERROR: unable to fetch the existing named subsystem "
118  << "configurations." << std::endl;
119  return false;
120  }
121  int64_t oldSubsystemConfigId = existingSubystemConfigIdList[0];
122  IDSpec oldSubsystemIdSpec(oldSubsystemConfigId, IDSpec::SUBSYSTEM,
123  (oldGlobalIdSpec.isDAQConfiguration() ?
124  IDSpec::DAQ : IDSpec::SLOWCONTROLS));
125 
127  if (newGlobalNameSpec.getConfigName() != "InitialGlobalConfig" &&
128  newGlobalNameSpec.getConfigName() != "ColdDetectorSettings") {
129  std::string newName = newGlobalNameSpec.getConfigName() + "_" +
130  _subsystemName + "_" + _configType;
131  paramSet.put(NamedConfigUtils::NAME_COLUMN_NAME, newName);
132  }
133  paramSet.put(NamedConfigUtils::DCMOPMODE_COLUMN_NAME,
134  newGlobalNameSpec.getDCMOpMode());
135  paramSet.put(NamedConfigUtils::DESCRIPTION_COLUMN_NAME,
136  "New values from the Configuration Editor GUI.");
137  paramSet.put(NamedConfigUtils::GLOBALCFGID_COLUMN_NAME,
138  boost::lexical_cast<std::string>
139  (newGlobalIdSpec.getConfigId()));
140  int64_t subsystemConfigId;
141  novadaq::Status resultStatus =
142  NamedConfigUtils::copySubsystemConfig(oldSubsystemIdSpec, true,
143  paramSet, "", true,
144  subsystemConfigId);
145  if (resultStatus.code ==
146  NamedConfigUtils::COPY_FOUND_UPDATE_IN_PROGRESS) {
147  std::cerr << "Unable to create a copy of the named "
148  << "subsystem configuration with ID = "
149  << oldSubsystemConfigId
150  << ": the creation of a new configuration is "
151  << "already in progress ("
152  << resultStatus.message << ")"
153  << std::endl;
154  return false;
155  }
156  else if (resultStatus.code ==
157  NamedConfigUtils::COPY_FOUND_INTERMEDIATE_UPDATE) {
158  std::cerr << "Unable to create a copy of the named "
159  << "subsystem configuration with ID = "
160  << oldSubsystemConfigId
161  << ": intermediate changes would be overwritten by "
162  << "this change (" << resultStatus.message << ")"
163  << std::endl;
164  return false;
165  }
166  else if (resultStatus.code != NamedConfigUtils::COPY_SUCCEEDED) {
167  std::cerr << "Unable to create a copy of the named "
168  << "subsystem configuration with ID = "
169  << oldSubsystemConfigId
170  << ": " << resultStatus.message
171  << std::endl;
172  return false;
173  }
174 
175  bool status = true;
176  for (int idx = 0; idx < this->count(); ++idx) {
177  if (_isTopLevel) {progressBar->setValue(idx);}
178  QWidget* theWidget = widget(idx);
179  ConfigDataTreeEditor* editor =
180  static_cast<ConfigDataTreeEditor*>(theWidget);
181  if (! editor->saveChanges(oldSubsystemConfigId, subsystemConfigId)) {
182  status = false;
183  }
184  }
185 
186  IDSpec subsystemIdSpec(subsystemConfigId, IDSpec::SUBSYSTEM,
187  (oldGlobalIdSpec.isDAQConfiguration() ?
188  IDSpec::DAQ : IDSpec::SLOWCONTROLS));
189  if (status) {
190  NamedConfigUtils::markConfigDone(subsystemIdSpec, true);
191  }
192  else {
193  NamedConfigUtils::markConfigDone(subsystemIdSpec, false);
194  }
195  if (_isTopLevel) {progressBar->setValue(this->count());}
196 
197  return status;
198 }
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::TabbedSetOfTreeEditors::_configType
private

Definition at line 54 of file TabbedSetOfTreeEditors.h.

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

bool dbutils::gui::TabbedSetOfTreeEditors::_isTopLevel
private

Definition at line 56 of file TabbedSetOfTreeEditors.h.

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

std::string dbutils::gui::TabbedSetOfTreeEditors::_subsystemName
private

Definition at line 53 of file TabbedSetOfTreeEditors.h.

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

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

Definition at line 55 of file TabbedSetOfTreeEditors.h.

Referenced by loadData(), and TabbedSetOfTreeEditors().


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