GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4UserCommandsDialog.cpp
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4UserCommandsDialog.h"
15 
16 #include "TGo4QSettings.h"
17 #include "TGo4UserCommands.h"
18 
19 #include <QPushButton>
20 
22  : QDialog( parent )
23 {
24  setObjectName("Go4UserCommandsDialog");
25  setupUi(this);
26 
27  // here we fill table directly from go4 settings:
28  for (int id = 0; id < GO4GUI_MAXMACRONUM; ++id) {
29  QString com= go4sett->getAnalysisMacroCommand(id);
30  QString tip=go4sett->getAnalysisMacroTip(id).split(":").first();
31  bool monitor=go4sett->getAnalysisMacroAutomode(id);
32  QTableWidgetItem* comitem= CommandsTable->item(id,0);
33  if(comitem) comitem->setText(com);
34  QTableWidgetItem* tipitem= CommandsTable->item(id,1);
35  if(tipitem) tipitem->setText(tip);
36 
37  QTableWidgetItem* autoitem= CommandsTable->item(id,2);
38  if(autoitem) {
39  autoitem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
40  autoitem->setCheckState( monitor ? Qt::Checked : Qt::Unchecked);
41  }
42  }
43 
44  QObject::connect (DialogButtonBox, &QDialogButtonBox::clicked, this, &TGo4UserCommandsDialog::ButtonPressed);
45 }
46 
48 {
49  QString rev;
50  QTableWidgetItem *item = CommandsTable->item(id, 0);
51  if (item)
52  rev = item->text();
53  return rev;
54 }
55 
57 {
58  QString rev;
59  QTableWidgetItem *item = CommandsTable->item(id, 1);
60  if (item)
61  rev = item->text();
62  return rev;
63 }
64 
66 {
67  bool rev = false;
68  QTableWidgetItem *item = CommandsTable->item(id, 2);
69  if (item)
70  rev = item->checkState() == Qt::Checked;
71  return rev;
72 }
73 
74 void TGo4UserCommandsDialog::ButtonPressed(QAbstractButton* but)
75 {
76  QPushButton* pbut = dynamic_cast<QPushButton*>(but);
77  if (pbut == DialogButtonBox->button(QDialogButtonBox::Reset)) {
78  for (int id = 0; id < GO4GUI_MAXMACRONUM; ++id) {
79  QTableWidgetItem *comitem = CommandsTable->item(id, 0);
80  if (comitem)
81  comitem->setText(QString(""));
82  QTableWidgetItem *tipitem = CommandsTable->item(id, 1);
83  if (tipitem)
84  tipitem->setText(QString(""));
85  QTableWidgetItem *autoitem = CommandsTable->item(id, 2);
86  if (autoitem)
87  autoitem->setCheckState(Qt::Unchecked);
88  }
89  } // if Reset
90 }
virtual void ButtonPressed(QAbstractButton *)
#define GO4GUI_MAXMACRONUM
TGo4UserCommandsDialog(QWidget *parent=nullptr)
bool getAnalysisMacroAutomode(int id)
QString getAnalysisMacroCommand(int id)
TGo4QSettings * go4sett
QString getAnalysisMacroTip(int id)