ATLAS Offline Software
Loading...
Searching...
No Matches
VP1GeoDBSelection Class Reference

#include <VP1GeoDBSelection.h>

Inheritance diagram for VP1GeoDBSelection:
Collaboration diagram for VP1GeoDBSelection:

Public Member Functions

 VP1GeoDBSelection (QWidget *parent=0)

Private Slots

void on_browseButton_clicked ()
void loadDatabase ()

Private Member Functions

void animateFindClick ()
QComboBox * createComboBox (const QString &text=QString())

Private Attributes

QString m_fileName
QComboBox * m_directoryComboBox
QPushButton * m_browseButton
QPushButton * m_openButton
QPushButton * m_cancelButton
QDialogButtonBox * m_buttonBox

Detailed Description

Definition at line 24 of file VP1GeoDBSelection.h.

Constructor & Destructor Documentation

◆ VP1GeoDBSelection()

VP1GeoDBSelection::VP1GeoDBSelection ( QWidget * parent = 0)
explicit

Definition at line 34 of file VP1GeoDBSelection.cxx.

34 : QDialog(parent)
35{
36 //Set default dialog size
37 int nWidth = 800;
38 int nHeight = 220;
39 if (parent != NULL)
40 setGeometry(parent->x() + parent->width()/2 - nWidth/2,
41 parent->y() + parent->height()/2 - nHeight/2,
42 nWidth, nHeight);
43 else
44 resize(nWidth, nHeight);
45
46 //Browse button to select database
47 m_browseButton = new QPushButton(tr("&Browse..."), this);
48 connect(m_browseButton, &QAbstractButton::clicked, this, &VP1GeoDBSelection::on_browseButton_clicked);
49
50 //Buttonbox to set Open, Cancel buttons
51 m_buttonBox = new QDialogButtonBox(this);
52 m_openButton = m_buttonBox->addButton(tr("&Open"), QDialogButtonBox::AcceptRole);
53 m_cancelButton = m_buttonBox->addButton(tr("&Cancel"),QDialogButtonBox::RejectRole);
54 connect(m_openButton, &QPushButton::clicked, this, &VP1GeoDBSelection::loadDatabase);
55 connect(m_cancelButton, &QPushButton::clicked, this, &VP1GeoDBSelection::reject);
56
57 //Open QSettings to store path do database
58 QSettings settings("ATLAS", "VP1Light");
59 QString text;
60
61 //If no db file has been provided via command line argument, the "db/path" value is ""
62 if(settings.value("db/path").toString()==""){
63 m_openButton->setEnabled(false);
64 text = "(*.db)";
65 } else { //If a db file has been provided show it in the combobox
66 text = settings.value("db/path").toString();
67 }
68 //Create the combobox
70
71 //Create the main layout
72 QGridLayout *mainLayout = new QGridLayout(this);
73 mainLayout->addWidget(new QLabel(tr("Select Geometry Database:")), 0, 0);
74 mainLayout->addWidget(m_directoryComboBox, 1, 0, 1, 2);
75 mainLayout->addWidget(m_browseButton, 1, 4);
76 mainLayout->addWidget(m_buttonBox, 3, 4);
77
78 m_browseButton->setMinimumWidth(200);
79 m_buttonBox->setMinimumWidth(200);
80 m_browseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
81 m_buttonBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
82}
QComboBox * m_directoryComboBox
QPushButton * m_openButton
QPushButton * m_cancelButton
QComboBox * createComboBox(const QString &text=QString())
QPushButton * m_browseButton
QDialogButtonBox * m_buttonBox

Member Function Documentation

◆ animateFindClick()

void VP1GeoDBSelection::animateFindClick ( )
private

Definition at line 96 of file VP1GeoDBSelection.cxx.

97{
98 m_openButton->animateClick();
99}

◆ createComboBox()

QComboBox * VP1GeoDBSelection::createComboBox ( const QString & text = QString())
private

Definition at line 85 of file VP1GeoDBSelection.cxx.

86{
87 QComboBox *comboBox = new QComboBox;
88 comboBox->setMinimumWidth(600);
89 comboBox->setEditable(false);
90 comboBox->addItem(text);
91 comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
92 return comboBox;
93}

◆ loadDatabase

void VP1GeoDBSelection::loadDatabase ( )
privateslot

Definition at line 121 of file VP1GeoDBSelection.cxx.

121 {
122
123 //Save DB path to settings
124 QSettings settings("ATLAS", "VP1Light");
125 settings.setValue("db/path", m_directoryComboBox->itemText(m_directoryComboBox->currentIndex()));
126
127 //If the selected DB does not exists, go back
128 if (!QFileInfo::exists(m_directoryComboBox->itemText(m_directoryComboBox->currentIndex()))){
129 QMessageBox msgBox;
130 msgBox.setWindowTitle("Virtual Point 1");
131 msgBox.setText("Database does not exist. Please choose another database file.");
132 msgBox.exec();
133 return;
134 }
135 VP1GeoDBSelection::setResult(1);
136 VP1GeoDBSelection::accept();
137}

◆ on_browseButton_clicked

void VP1GeoDBSelection::on_browseButton_clicked ( )
privateslot

Definition at line 102 of file VP1GeoDBSelection.cxx.

103{
104 m_fileName = QFileDialog::getOpenFileName(this,
105 tr("Select Database"), QDir::currentPath(),
106 tr("DB Files (*.db)"));
107
108 // Add the selected file to the combobox
109 if (!m_fileName.isEmpty()) {
110 if (m_directoryComboBox->findText(m_fileName) == -1)
112 m_directoryComboBox->setCurrentIndex(m_directoryComboBox->findText(m_fileName));
113
114 //When valid a database is selected, enable the Open button to confirm
115 m_openButton->setEnabled(true);
116 }
117
118}

Member Data Documentation

◆ m_browseButton

QPushButton* VP1GeoDBSelection::m_browseButton
private

Definition at line 42 of file VP1GeoDBSelection.h.

◆ m_buttonBox

QDialogButtonBox* VP1GeoDBSelection::m_buttonBox
private

Definition at line 45 of file VP1GeoDBSelection.h.

◆ m_cancelButton

QPushButton* VP1GeoDBSelection::m_cancelButton
private

Definition at line 44 of file VP1GeoDBSelection.h.

◆ m_directoryComboBox

QComboBox* VP1GeoDBSelection::m_directoryComboBox
private

Definition at line 41 of file VP1GeoDBSelection.h.

◆ m_fileName

QString VP1GeoDBSelection::m_fileName
private

Definition at line 40 of file VP1GeoDBSelection.h.

◆ m_openButton

QPushButton* VP1GeoDBSelection::m_openButton
private

Definition at line 43 of file VP1GeoDBSelection.h.


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