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

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-04-12/DatabaseUtils/cxx/include/GUI/ConfigDataTableEditor.h"

Inheritance diagram for dbutils::gui::ConfigDataTableEditor:
dbutils::gui::Changeable

Public Slots

void updatePopupMenu (const QModelIndex &currentIndex)
 
void reactToDataModelChange ()
 
void reactToDataSave ()
 
void addRow ()
 
void deleteRow ()
 

Signals

void aChangeWasMade ()
 
void dataWasSaved ()
 

Public Member Functions

 ConfigDataTableEditor (const std::string &tableDefinitionFileName, QWidget *parent=0)
 
void mousePressEvent (QMouseEvent *event)
 
bool loadData (const std::vector< int64_t > &subsystemConfigIdList)
 
bool hasChanges () const
 
bool saveChanges (const int64_t &oldSubsystemConfigId, const int64_t &subsystemConfigId)
 
bool addInitialRow ()
 
std::string getTableName () const
 

Private Attributes

std::string _tableDefinitionFileName
 
QMenu * _popupMenu
 
QAction * _addRowAction
 

Detailed Description

Class for displaying a table of configuration data from a single database table.

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

Definition at line 21 of file ConfigDataTableEditor.h.

Constructor & Destructor Documentation

dbutils::gui::ConfigDataTableEditor::ConfigDataTableEditor ( const std::string tableDefinitionFileName,
QWidget *  parent = 0 
)

Creates the table display for editing configuration data from a single database table.

Definition at line 13 of file ConfigDataTableEditor.cpp.

References _tableDefinitionFileName.

14  : QTableView(parent)
15 {
16  _tableDefinitionFileName = tableDefinitionFileName;
17 
18  this->setAlternatingRowColors(true);
19  this->setSelectionBehavior(QAbstractItemView::SelectItems);
20  this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
21 }

Member Function Documentation

void dbutils::gui::ConfigDataTableEditor::aChangeWasMade ( )
signal

Referenced by loadData(), and reactToDataModelChange().

bool dbutils::gui::ConfigDataTableEditor::addInitialRow ( )
virtual

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

Implements dbutils::gui::Changeable.

Definition at line 88 of file ConfigDataTableEditor.cpp.

References dbutils::gui::ConfigDataTableModel::addInitialRow(), and dbutils::gui::ConfigDataTableModel::rowCount().

Referenced by dbutils::gui::TabbedSetOfTableEditors::addInitialRow().

89 {
90  ConfigDataTableModel *model =
91  static_cast<ConfigDataTableModel *>(this->model());
92 
93  if (model == 0) {return true;}
94  if (! isVisible()) {return true;}
95  if (model->rowCount() > 0) {return true;}
96 
97  return model->addInitialRow();
98 }
const XML_Char XML_Content * model
Definition: expat.h:151
void dbutils::gui::ConfigDataTableEditor::addRow ( )
slot

Definition at line 137 of file ConfigDataTableEditor.cpp.

References dbutils::gui::ConfigDataTableModel::addInitialRow(), and dbutils::gui::ConfigDataTableModel::addRowAfter().

Referenced by updatePopupMenu().

138 {
139  ConfigDataTableModel *model =
140  static_cast<ConfigDataTableModel *>(this->model());
141  if (model == 0) {return;}
142 
143  QModelIndex currentIndex = this->selectionModel()->currentIndex();
144  if (currentIndex.isValid()) {
145  model->addRowAfter(currentIndex);
146  }
147  else {
148  model->addInitialRow();
149  }
150 }
const XML_Char XML_Content * model
Definition: expat.h:151
void dbutils::gui::ConfigDataTableEditor::dataWasSaved ( )
signal

Referenced by loadData(), and reactToDataSave().

void dbutils::gui::ConfigDataTableEditor::deleteRow ( )
slot

Definition at line 152 of file ConfigDataTableEditor.cpp.

References dbutils::gui::ConfigDataTableModel::deleteRow().

Referenced by updatePopupMenu().

153 {
154  ConfigDataTableModel *model =
155  static_cast<ConfigDataTableModel *>(this->model());
156  if (model == 0) {return;}
157 
158  QModelIndex currentIndex = this->selectionModel()->currentIndex();
159  if (currentIndex.isValid()) {
160  model->deleteRow(currentIndex);
161  }
162 }
const XML_Char XML_Content * model
Definition: expat.h:151
std::string dbutils::gui::ConfigDataTableEditor::getTableName ( ) const

Definition at line 100 of file ConfigDataTableEditor.cpp.

References dbutils::gui::ConfigDataTableModel::getTableName().

Referenced by dbutils::gui::TabbedSetOfTableEditors::loadData(), and dbutils::gui::TabbedSetOfTableEditors::TabbedSetOfTableEditors().

101 {
102  ConfigDataTableModel *model =
103  static_cast<ConfigDataTableModel *>(this->model());
104 
105  if (model == 0) {return "unknown table";}
106 
107  return model->getTableName();
108 }
const XML_Char XML_Content * model
Definition: expat.h:151
bool dbutils::gui::ConfigDataTableEditor::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 67 of file ConfigDataTableEditor.cpp.

References dbutils::gui::ConfigDataTableModel::hasChanges().

Referenced by dbutils::gui::TabbedSetOfTableEditors::hasChanges().

68 {
69  ConfigDataTableModel *model =
70  static_cast<ConfigDataTableModel *>(this->model());
71 
72  if (model == 0) {return false;}
73 
74  return model->hasChanges();
75 }
const XML_Char XML_Content * model
Definition: expat.h:151
bool dbutils::gui::ConfigDataTableEditor::loadData ( const std::vector< int64_t > &  subsystemConfigIdList)

Definition at line 36 of file ConfigDataTableEditor.cpp.

References _popupMenu, _tableDefinitionFileName, aChangeWasMade(), g4zmq::connect(), dataWasSaved(), dbutils::gui::ConfigDataTableModel::loadData(), reactToDataModelChange(), reactToDataSave(), and updatePopupMenu().

Referenced by dbutils::gui::TabbedSetOfTableEditors::loadData(), and mousePressEvent().

37 {
38  ConfigDataTableModel *model =
39  static_cast<ConfigDataTableModel *>(this->model());
40 
41  if (model == 0) {
42  model = new ConfigDataTableModel(_tableDefinitionFileName);
43  if (! model->loadData(subsystemConfigIdList)) {return false;}
44 
45  connect(model, SIGNAL(aChangeWasMade()),
46  this, SLOT(reactToDataModelChange()));
47  connect(model, SIGNAL(dataWasSaved()),
48  this, SLOT(reactToDataSave()));
49 
50  this->setModel(model);
51 
52  _popupMenu = new QMenu(this);
53  connect(this->selectionModel(),
54  SIGNAL(currentChanged(const QModelIndex &,
55  const QModelIndex &)),
56  this, SLOT(updatePopupMenu(const QModelIndex &)));
57  }
58  else {
59  if (! model->loadData(subsystemConfigIdList)) {return false;}
60  }
61 
62  this->resizeColumnsToContents();
63  this->resizeRowsToContents();
64  return true;
65 }
void updatePopupMenu(const QModelIndex &currentIndex)
def connect(endpoint="tcp://127.0.0.1:5555")
Definition: g4zmq.py:15
const XML_Char XML_Content * model
Definition: expat.h:151
void dbutils::gui::ConfigDataTableEditor::mousePressEvent ( QMouseEvent *  event)

Definition at line 23 of file ConfigDataTableEditor.cpp.

References _popupMenu, and loadData().

24 {
25  // first, do the standard processing for the mouse event
26  QTableView::mousePressEvent(event);
27 
28  // next, check if we should show the popup menu (right-mouse)
29  if (event->type() == QEvent::MouseButtonPress &&
30  event->button() == Qt::RightButton) {
31  _popupMenu->popup(event->globalPos());
32  }
33 }
void dbutils::gui::ConfigDataTableEditor::reactToDataModelChange ( )
slot

Definition at line 127 of file ConfigDataTableEditor.cpp.

References aChangeWasMade().

Referenced by loadData().

128 {
129  emit aChangeWasMade();
130 }
void dbutils::gui::ConfigDataTableEditor::reactToDataSave ( )
slot

Definition at line 132 of file ConfigDataTableEditor.cpp.

References dataWasSaved().

Referenced by loadData().

133 {
134  emit dataWasSaved();
135 }
bool dbutils::gui::ConfigDataTableEditor::saveChanges ( const int64_t &  oldSubsystemConfigId,
const int64_t &  subsystemConfigId 
)

Definition at line 77 of file ConfigDataTableEditor.cpp.

References dbutils::gui::ConfigDataTableModel::saveChanges().

Referenced by dbutils::gui::TabbedSetOfTableEditors::saveChanges().

79 {
80  ConfigDataTableModel *model =
81  static_cast<ConfigDataTableModel *>(this->model());
82 
83  if (model == 0) {return false;}
84 
85  return model->saveChanges(subsystemConfigId);
86 }
const XML_Char XML_Content * model
Definition: expat.h:151
void dbutils::gui::ConfigDataTableEditor::updatePopupMenu ( const QModelIndex &  currentIndex)
slot

Definition at line 110 of file ConfigDataTableEditor.cpp.

References _addRowAction, _popupMenu, addRow(), g4zmq::connect(), deleteRow(), and make_root_from_grid_output::tr.

Referenced by loadData().

111 {
112  _popupMenu->clear();
113 
114  // always allow a row to be added
115  _addRowAction = _popupMenu->addAction(tr("Add Row"));
116  QObject::connect(_addRowAction, SIGNAL(triggered()),
117  this, SLOT(addRow()));
118 
119  // only allow a valid row to be deleted
120  if (currentIndex.isValid()) {
121  _addRowAction = _popupMenu->addAction(tr("Delete Row"));
122  QObject::connect(_addRowAction, SIGNAL(triggered()),
123  this, SLOT(deleteRow()));
124  }
125 }
def connect(endpoint="tcp://127.0.0.1:5555")
Definition: g4zmq.py:15

Member Data Documentation

QAction* dbutils::gui::ConfigDataTableEditor::_addRowAction
private

Definition at line 58 of file ConfigDataTableEditor.h.

Referenced by updatePopupMenu().

QMenu* dbutils::gui::ConfigDataTableEditor::_popupMenu
private

Definition at line 57 of file ConfigDataTableEditor.h.

Referenced by loadData(), mousePressEvent(), and updatePopupMenu().

std::string dbutils::gui::ConfigDataTableEditor::_tableDefinitionFileName
private

Definition at line 56 of file ConfigDataTableEditor.h.

Referenced by ConfigDataTableEditor(), and loadData().


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