OGS
SetNameDialog Class Reference

Detailed Description

Small dialog for setting a name for an object.

Definition at line 28 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 22 of file SetNameDialog.cpp.

24 : QDialog(parent)
25{
26 QString const& label =
27 QString::fromStdString(geo_object_type) + "#" + QString::number(id);
28 setupDialog(label, old_name);
29 show();
30}
void setupDialog(const QString &label, const std::string &old_name)
Constructs a dialog window.

References setupDialog().

◆ ~SetNameDialog()

SetNameDialog::~SetNameDialog ( )
override

Definition at line 32 of file SetNameDialog.cpp.

33{
34 delete _buttonBox;
35 delete _layout;
36 delete _new_name;
37 delete _txt_label;
38}
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 65 of file SetNameDialog.cpp.

66{
67 this->done(QDialog::Accepted);
68}

Referenced by setupDialog().

◆ getNewName()

std::string SetNameDialog::getNewName ( )

Definition at line 60 of file SetNameDialog.cpp.

61{
62 return _new_name->text().toStdString();
63}

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 70 of file SetNameDialog.cpp.

71{
72 this->done(QDialog::Rejected);
73}

Referenced by setupDialog().

◆ setupDialog()

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

Constructs a dialog window.

Definition at line 40 of file SetNameDialog.cpp.

42{
43 _layout = new QVBoxLayout(this);
44 QString dialog_text("Please enter a name for " + label);
45 _txt_label = new QLabel(dialog_text, this);
46 _new_name = new QLineEdit(QString::fromStdString(old_name));
47
48 setWindowTitle("Set name...");
49 _layout->addWidget(_txt_label);
50 _layout->addWidget(_new_name);
52 new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
53 connect(_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
54 connect(_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
55 _layout->addWidget(_buttonBox);
56
57 setLayout(_layout);
58}
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 47 of file SetNameDialog.h.

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

◆ _layout

QVBoxLayout* SetNameDialog::_layout
private

Definition at line 46 of file SetNameDialog.h.

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

◆ _new_name

QLineEdit* SetNameDialog::_new_name
private

Definition at line 45 of file SetNameDialog.h.

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

◆ _txt_label

QLabel* SetNameDialog::_txt_label
private

Definition at line 44 of file SetNameDialog.h.

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


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