OGS
SetNameDialog Class Reference

Detailed Description

Small dialog for setting a name for an object.

Definition at line 17 of file SetNameDialog.h.

#include <SetNameDialog.h>

Inheritance diagram for SetNameDialog:
[legend]
Collaboration diagram for SetNameDialog:
[legend]

Public Member Functions

 SetNameDialog (const std::string &geo_object_type, std::size_t id, const std::string &old_name, QDialog *parent=nullptr)
 Constructor.
 ~SetNameDialog () override
std::string getNewName ()

Private Slots

void accept () override
 Instructions if the OK-Button has been pressed.
void reject () override
 Instructions if the Cancel-Button has been pressed.

Private Member Functions

void setupDialog (const QString &label, const std::string &old_name)
 Constructs a dialog window.

Private Attributes

QLabel * _txt_label
QLineEdit * _new_name
QVBoxLayout * _layout
QDialogButtonBox * _buttonBox

Constructor & Destructor Documentation

◆ SetNameDialog()

SetNameDialog::SetNameDialog ( const std::string & geo_object_type,
std::size_t id,
const std::string & old_name = "",
QDialog * parent = nullptr )

Constructor.

Definition at line 11 of file SetNameDialog.cpp.

13 : QDialog(parent)
14{
15 QString const& label =
16 QString::fromStdString(geo_object_type) + "#" + QString::number(id);
17 setupDialog(label, old_name);
18 show();
19}
void setupDialog(const QString &label, const std::string &old_name)
Constructs a dialog window.

References setupDialog().

◆ ~SetNameDialog()

SetNameDialog::~SetNameDialog ( )
override

Definition at line 21 of file SetNameDialog.cpp.

22{
23 delete _buttonBox;
24 delete _layout;
25 delete _new_name;
26 delete _txt_label;
27}
QDialogButtonBox * _buttonBox
QLineEdit * _new_name
QLabel * _txt_label
QVBoxLayout * _layout

References _buttonBox, _layout, _new_name, and _txt_label.

Member Function Documentation

◆ accept

void SetNameDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 54 of file SetNameDialog.cpp.

55{
56 this->done(QDialog::Accepted);
57}

Referenced by setupDialog().

◆ getNewName()

std::string SetNameDialog::getNewName ( )

Definition at line 49 of file SetNameDialog.cpp.

50{
51 return _new_name->text().toStdString();
52}

References _new_name.

Referenced by MainWindow::showGeoNameDialog(), and MainWindow::showStationNameDialog().

◆ reject

void SetNameDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 59 of file SetNameDialog.cpp.

60{
61 this->done(QDialog::Rejected);
62}

Referenced by setupDialog().

◆ setupDialog()

void SetNameDialog::setupDialog ( const QString & label,
const std::string & old_name )
private

Constructs a dialog window.

Definition at line 29 of file SetNameDialog.cpp.

31{
32 _layout = new QVBoxLayout(this);
33 QString dialog_text("Please enter a name for " + label);
34 _txt_label = new QLabel(dialog_text, this);
35 _new_name = new QLineEdit(QString::fromStdString(old_name));
36
37 setWindowTitle("Set name...");
38 _layout->addWidget(_txt_label);
39 _layout->addWidget(_new_name);
41 new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
42 connect(_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
43 connect(_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
44 _layout->addWidget(_buttonBox);
45
46 setLayout(_layout);
47}
void reject() override
Instructions if the Cancel-Button has been pressed.
void accept() override
Instructions if the OK-Button has been pressed.

References _buttonBox, _layout, _new_name, _txt_label, accept(), and reject().

Referenced by SetNameDialog().

Member Data Documentation

◆ _buttonBox

QDialogButtonBox* SetNameDialog::_buttonBox
private

Definition at line 36 of file SetNameDialog.h.

Referenced by ~SetNameDialog(), and setupDialog().

◆ _layout

QVBoxLayout* SetNameDialog::_layout
private

Definition at line 35 of file SetNameDialog.h.

Referenced by ~SetNameDialog(), and setupDialog().

◆ _new_name

QLineEdit* SetNameDialog::_new_name
private

Definition at line 34 of file SetNameDialog.h.

Referenced by ~SetNameDialog(), getNewName(), and setupDialog().

◆ _txt_label

QLabel* SetNameDialog::_txt_label
private

Definition at line 33 of file SetNameDialog.h.

Referenced by ~SetNameDialog(), and setupDialog().


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