DBParamsGroupBox.cpp
Go to the documentation of this file.
1 #include <DatabaseUtils/GUI/DBParamsGroupBox.h>
2 #include <NovaDAQUtilities/EnvVarCache.h>
3 #include <QtGui/QGridLayout>
4 #include <QtGui/QHBoxLayout>
5 
6 namespace dbutils {
7 namespace gui {
8 
11  QGroupBox(tr("Current Database Parameters"), parent)
12 {
13  QGridLayout* gridLayout = new QGridLayout;
14  NameValueLabelPair* nameValWidget;
15 
16  nameValWidget = new NameValueLabelPair("DB Host");
17  std::string dbHost =
19  nameValWidget->setValue(dbHost);
20  gridLayout->addWidget(nameValWidget, 0, 0);
21 
22 
23  QHBoxLayout* hboxLayout = new QHBoxLayout;
24  hboxLayout->setContentsMargins(0,0,0,0);
25 
26  nameValWidget = new NameValueLabelPair("DB Name");
27  std::string dbName =
29  nameValWidget->setValue(dbName);
30  hboxLayout->addWidget(nameValWidget);
31  hboxLayout->addSpacing(10);
32 
33  nameValWidget = new NameValueLabelPair("DB User");
34  std::string dbUser =
36  std::string cfgMgrDBUser =
37  novadaq::EnvVarCache::getInstance().getEnvVar("CFGMGR_DB_USER");
38  std::string simpleUser =
40  if (dbUser == "" && cfgMgrDBUser == "") {
41  nameValWidget->setValue(simpleUser.c_str());
42  }
43  else if (dbUser == cfgMgrDBUser) {
44  nameValWidget->setValue(dbUser.c_str());
45  }
46  else {
47  std::string tmpString = dbUser;
48  tmpString.append("/");
49  tmpString.append(cfgMgrDBUser);
50  nameValWidget->setValue(tmpString.c_str());
51  }
52  hboxLayout->addWidget(nameValWidget);
53  hboxLayout->addStretch();
54 
55  QWidget* tmpWidget = new QWidget();
56  tmpWidget->setLayout(hboxLayout);
57  gridLayout->addWidget(tmpWidget, 1, 0, Qt::AlignLeft);
58 
59  this->setLayout(gridLayout);
60 }
61 
62 } // end of namespace gui
63 } // end of namespace dbutils
static EnvVarCache & getInstance()
Definition: EnvVarCache.cpp:12
std::string getEnvVar(std::string name)
Definition: EnvVarCache.cpp:33
void setValue(const std::string &value)
enum BeamMode string