1 #include <DatabaseUtils/GUI/ConfigDataTreeEditor.h> 2 #include <DatabaseUtils/GUI/ConfigDataTreeModel.h> 3 #include <DatabaseUtils/GUI/BitmapEditor.h> 4 #include <DatabaseUtils/DAQConfig/DBColumnParams.h> 5 #include <QtGui/QInputDialog> 16 ConfigDataTreeEditor::
17 ConfigDataTreeEditor(QWidget *
parent) : QTreeView(parent)
19 this->setAlternatingRowColors(
true);
20 this->setSelectionBehavior(QAbstractItemView::SelectItems);
21 this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
22 this->setAnimated(
false);
23 this->setAllColumnsShowFocus(
true);
29 QTreeView::mousePressEvent(event);
32 if (event->type() == QEvent::MouseButtonPress &&
33 event->button() == Qt::RightButton) {
42 loadData(boost::shared_ptr<daqconfig::ConfigDataTree> dataTree)
49 if (! model->
loadData(dataTree)) {
return false;}
55 connect(model, SIGNAL(dataChanged(
const QModelIndex&,
58 const QModelIndex&)));
60 this->setModel(model);
64 SIGNAL(currentChanged(
const QModelIndex &,
65 const QModelIndex &)),
69 if (! model->
loadData(dataTree)) {
return false;}
73 for (
int column = 0; column < model->
columnCount(); ++column) {
74 this->resizeColumnToContents(column);
77 this->expandToDepth(0);
86 if (model == 0) {
return false;}
92 const int64_t& subsystemConfigId)
97 if (model == 0) {
return false;}
105 if (! currentIndex.isValid()) {
return;}
109 if (model == 0) {
return;}
113 bool dcnLookupWorked =
115 if (dcnLookupWorked && dataColumnName ==
"mask") {
116 QAction* obeAction =
_popupMenu->addAction(
tr(
"Open bitmap editor"));
127 if (selectorColumn == DBColumnParams::DCMNAME_COLUMN_NAME) {
130 if (selectorColumn == DBColumnParams::FEBID_COLUMN_NAME) {
133 if (selectorColumn == DBColumnParams::PIXELID_COLUMN_NAME) {
136 if (selectorColumn == DBColumnParams::HOSTNAME_COLUMN_NAME) {
141 if (selectorColumn == DBColumnParams::DCMNAME_COLUMN_NAME) {
144 if (selectorColumn == DBColumnParams::FEBID_COLUMN_NAME) {
147 if (selectorColumn == DBColumnParams::PIXELID_COLUMN_NAME) {
150 if (selectorColumn == DBColumnParams::HOSTNAME_COLUMN_NAME) {
179 text =
"Add " + peerType +
" after this";
198 if (model == 0) {
return true;}
217 const QModelIndex& bottomRight)
223 this->collapse(topLeft);
224 this->expand(topLeft);
232 if (model == 0) {
return;}
234 QModelIndex currentIndex = this->selectionModel()->currentIndex();
237 if (peerType == DBColumnParams::FEBID_COLUMN_NAME) {
238 QString responseText =
239 QInputDialog::getItem(
this,
tr(
"Add FEB"),
tr(
"FEB ID:"),
246 else if (peerType == DBColumnParams::PIXELID_COLUMN_NAME) {
247 QString responseText =
248 QInputDialog::getItem(
this,
tr(
"Add Pixel"),
tr(
"Pixel ID:"),
260 this->resizeColumnToContents(0);
268 if (model == 0) {
return;}
270 QModelIndex currentIndex = this->selectionModel()->currentIndex();
273 if (peerType == DBColumnParams::DCMNAME_COLUMN_NAME) {
274 QString responseText =
275 QInputDialog::getText(
this,
tr(
"Add DCM"),
tr(
"New DCM name:"),
282 else if (peerType == DBColumnParams::FEBID_COLUMN_NAME) {
283 QString responseText =
284 QInputDialog::getItem(
this,
tr(
"Add FEB"),
tr(
"FEB ID:"),
291 else if (peerType == DBColumnParams::PIXELID_COLUMN_NAME) {
292 QString responseText =
293 QInputDialog::getItem(
this,
tr(
"Add Pixel"),
tr(
"Pixel ID:"),
300 else if (peerType == DBColumnParams::HOSTNAME_COLUMN_NAME) {
301 QString responseText =
302 QInputDialog::getText(
this,
tr(
"Add Host"),
tr(
"New Host Name:"),
314 this->resizeColumnToContents(0);
322 if (model == 0) {
return;}
324 QModelIndex currentIndex = this->selectionModel()->currentIndex();
327 if (childType == DBColumnParams::DCMNAME_COLUMN_NAME) {
328 QString responseText =
329 QInputDialog::getText(
this,
tr(
"Add DCM"),
tr(
"New DCM name:"),
334 this->expand(currentIndex);
337 else if (childType == DBColumnParams::FEBID_COLUMN_NAME) {
338 QString responseText =
339 QInputDialog::getItem(
this,
tr(
"Add FEB"),
tr(
"FEB ID:"),
344 this->expand(currentIndex);
347 else if (childType == DBColumnParams::PIXELID_COLUMN_NAME) {
348 QString responseText =
349 QInputDialog::getItem(
this,
tr(
"Add Pixel"),
tr(
"Pixel ID:"),
354 this->expand(currentIndex);
357 else if (childType == DBColumnParams::HOSTNAME_COLUMN_NAME) {
358 QString responseText =
359 QInputDialog::getText(
this,
tr(
"Add Host"),
tr(
"New Host Name:"),
364 this->expand(currentIndex);
372 this->resizeColumnToContents(0);
379 if (model == 0) {
return;}
381 QModelIndex currentIndex = this->selectionModel()->currentIndex();
382 QVariant
value = model->
data(currentIndex);
386 bool dctLookupWorked =
388 if (dctLookupWorked && dataColumnType ==
"bigint") {
392 BitmapEditor editor(value.toString().toStdString(), bitCount,
this);
393 int result = editor.exec();
395 if (result == QDialog::Accepted) {
396 model->
setData(currentIndex, editor.getResult().c_str());
bool addChildRow(QModelIndex index, QString selectorColumnText, int position=0)
QList< QString > allowsInsertBefore(const QModelIndex &index) const
bool dataColumnTypeForIndex(const QModelIndex &index, std::string &dataColumnType) const
bool loadData(boost::shared_ptr< daqconfig::ConfigDataTree > dataTree)
bool addRowBefore(const QModelIndex &index, QString selectorColumnText)
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
QList< QString > allowsChildInsert(const QModelIndex &index) const
bool dataColumnNameForIndex(const QModelIndex &index, std::string &dataColumnName) const
QList< QString > _candidatesForInsertAfter
QList< QString > allowsInsertAfter(const QModelIndex &index) const
def connect(endpoint="tcp://127.0.0.1:5555")
const XML_Char int const XML_Char * value
QAction * _addRowBeforeAction
virtual bool saveChanges(const int64_t &subsystemConfigId)
void updatePopupMenu(const QModelIndex ¤tIndex)
bool addRowAfter(const QModelIndex &index, QString selectorColumnText)
bool saveChanges(const int64_t &oldSubsystemConfigId, const int64_t &subsystemConfigId)
void refreshDisplayOfChildren(const QModelIndex &, const QModelIndex &)
virtual bool loadData(boost::shared_ptr< daqconfig::ConfigDataTree > dataTree)
QAction * _addRowAfterAction
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QList< QString > _candidatesForChildInsert
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
QAction * _addChildRowAction
void mousePressEvent(QMouseEvent *event)
const XML_Char XML_Content * model
virtual bool hasChanges() const
bool selectorColumnNameForChild(const QModelIndex &index, std::string &selectorColumnName) const
bool selectorColumnNameForIndex(const QModelIndex &index, std::string &selectorColumnName) const
void reactToDataModelChange()
QList< QString > _candidatesForInsertBefore