General Purpose Geodetic Library
NsSessionNameDialog.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of nuSolve. nuSolve is a part of CALC/SOLVE system
4  * and is designed to perform data analyis of a geodetic VLBI session.
5  * Copyright (C) 2010-2020 Sergei Bolotin.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #include "nuSolve.h"
23 #include "NsSessionNameDialog.h"
24 
25 
26 #include <SgLogger.h>
27 
28 #if QT_VERSION >= 0x050000
29 # include <QtWidgets/QBoxLayout>
30 # include <QtWidgets/QCheckBox>
31 # include <QtWidgets/QGroupBox>
32 # include <QtWidgets/QLabel>
33 # include <QtWidgets/QLineEdit>
34 # include <QtWidgets/QPushButton>
35 #else
36 # include <QtGui/QBoxLayout>
37 # include <QtGui/QCheckBox>
38 # include <QtGui/QGroupBox>
39 # include <QtGui/QLabel>
40 # include <QtGui/QLineEdit>
41 # include <QtGui/QPushButton>
42 #endif
43 
44 
45 
46 
47 
48 
49 /*=======================================================================================================
50 *
51 * METHODS:
52 *
53 *======================================================================================================*/
54 NsSessionNameDialog::NsSessionNameDialog(QWidget *parent, QString *fileName, QString *auxFileName,
55  Qt::WindowFlags flags) : QDialog(parent, flags)
56 {
57  QGroupBox *gbox;
58  QGridLayout *grid;
59  QLabel *label;
60  bool isVdb = auxFileName==NULL; // a vgosDb session
61 
62  fileName_ = fileName;
63  auxFileName_ = auxFileName;
64 
65  if (isVdb)
66  {
67  setWindowTitle("Open a session");
68  gbox = new QGroupBox("Session name", this);
69  grid = new QGridLayout(gbox);
70 
71  label= new QLabel("<h5>Loading default wrapper file for the specified session.</h5>"
72  "<p>"
73  "Enter a name of the session to open."
74  "</p>"
75  "<p>"
76  "The format of the name is: <b>YYMMMDDBC</b>[_V<b>xxx</b>]<br>"
77  "Where"
78  "<ul>"
79  "<li><b>YY</b> </t> - two digits of year of observation</li>"
80  "<li><b>MMM</b> - three chars of month</li>"
81  "<li><b>DD</b> - day of observation</li>"
82  "<li><b>B</b> - band, usually, it is <b>X</b></li>"
83  "<li><b>C</b> - network code</li>"
84  "<li><b>xxx</b> - version number of the session (optional)</li>"
85  "</ul>"
86  "</p>"
87  "<p></p>",
88  gbox);
89  }
90  else
91  {
92  setWindowTitle("Open a database");
93  gbox = new QGroupBox("Database file name", this);
94  grid = new QGridLayout(gbox);
95 
96  label= new QLabel("<h5>Working through CALC/SOLVE catalog sysem.</h5>"
97  "<p>"
98  "Enter a name of the database to open. You can specify one file, "
99  "X- or S-band, &nu;Solve will pick the second one automatically (if it exists). "
100  "Or, you can provide both file names, but be sure that they belongs to one VLBI session."
101  "</p>"
102  "<p>"
103  "The format of the name is: [$]<b>YYMMMDDBC</b>[_V<b>xxx</b>]<br>"
104  "Where"
105  "<ul>"
106  "<li><b>YY</b> </t> - two digits of year of observation</li>"
107  "<li><b>MMM</b> - three chars of month</li>"
108  "<li><b>DD</b> - day of observation</li>"
109  "<li><b>B</b> - band, usually, it is <b>X</b> or <b>S</b></li>"
110  "<li><b>C</b> - network code</li>"
111  "<li><b>xxx</b> - version number of the database (optional)</li>"
112  "</ul>"
113  "</p>"
114  "<p></p>",
115  gbox);
116  };
117 
118  label->setWordWrap(true);
119 //label->setMinimumSize(label->sizeHint());
120  label->setMinimumWidth(1.5*label->sizeHint().width());
121  label->setMinimumHeight(label->sizeHint().height());
122  grid ->addWidget(label, 0, 0, 1, 2);
123  grid ->setRowStretch(1, 2);
124 
125  label= new QLabel("Session name to open: ", gbox);
126  label->setMinimumSize(label->sizeHint());
127  grid ->addWidget(label, 2, 0, Qt::AlignLeft | Qt::AlignVCenter);
128 
129  leDbName_ = new QLineEdit("YYMMMDDBC_Vxxx", gbox);
130  leDbName_->setFixedWidth(leDbName_->fontMetrics().width("YYMMMDDBC_VxxxQQQQ") + 10);
131  leDbName_->selectAll();
132  grid ->addWidget(leDbName_, 2, 1);
133 
134  //
135  if (!isVdb)
136  {
137  cbAutoLoad2band_ = new QCheckBox("Load 2nd file (empty==AUTO):", gbox);
138  cbAutoLoad2band_->setMinimumSize(cbAutoLoad2band_->sizeHint());
139  grid->addWidget(cbAutoLoad2band_, 3, 0, Qt::AlignLeft | Qt::AlignVCenter);
140  cbAutoLoad2band_->setCheckState(setup.getHave2AutoloadAllBands()?Qt::Checked:Qt::Unchecked);
141  connect(cbAutoLoad2band_, SIGNAL(stateChanged(int)), SLOT(changeAutoload(int)));
142  //
143  leDbName2_ = new QLineEdit("", gbox);
144  leDbName2_->setFixedWidth(leDbName_->fontMetrics().width("YYMMMDDBC_VxxxQQQQ") + 10);
145  grid->addWidget(leDbName2_, 3, 1);
146 
148  leDbName2_->setEnabled(false);
149  };
150  //---
151  QVBoxLayout *layout;
152  QHBoxLayout *subLayout;
153  layout = new QVBoxLayout(this);
154  layout -> addWidget(gbox);
155  subLayout = new QHBoxLayout();
156  layout->addLayout(subLayout);
157  subLayout->addStretch(1);
158 
159  QPushButton *bOk=new QPushButton("OK", this);
160  QPushButton *bCancel=new QPushButton("Cancel", this);
161  bOk->setDefault(true);
162  QSize btnSize;
163 
164  bCancel->setMinimumSize((btnSize=bCancel->sizeHint()));
165  bOk->setMinimumSize(btnSize);
166  subLayout->addWidget(bOk);
167  subLayout->addWidget(bCancel);
168  connect(bOk, SIGNAL(clicked()), SLOT(accept()));
169  connect(bCancel, SIGNAL(clicked()), SLOT(reject()));
170 };
171 
172 
173 
174 //
176 {
177 };
178 
179 
180 
181 //
183 {
184  leDbName2_->setEnabled(chkState==Qt::Checked);
185 };
186 
187 
188 
189 //
191 {
192  *fileName_ = leDbName_->text();
193 
194  if (auxFileName_)
195  {
196  if (leDbName2_->isEnabled())
197  *auxFileName_ = leDbName2_->text();
198  else
199  *auxFileName_ = "/dev/null";
200  };
201 
202  QDialog::accept();
204  ": accept selected");
205  deleteLater();
206 };
207 
208 
209 
210 //
212 {
213  QDialog::reject();
215  ": reject selected");
216  deleteLater();
217 };
218 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
QString className() const
NsSessionNameDialog(QWidget *parent, QString *fileName, QString *auxFileName=NULL, Qt::WindowFlags flags=0)
bool getHave2AutoloadAllBands() const
Definition: NsSetup.h:638
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
NsSetup setup
Definition: nuSolve.cpp:61