MCPcopy Create free account
hub / github.com/KDE/labplot / AddValueLabelDialog

Method AddValueLabelDialog

src/frontend/spreadsheet/AddValueLabelDialog.cpp:35–104  ·  view source on GitHub ↗

! \class AddValueLabelDialog \brief Dialog to add a new the value label \ingroup frontend */

Source from the content-addressed store, hash-verified

33 \ingroup frontend
34 */
35AddValueLabelDialog::AddValueLabelDialog(QWidget* parent, const Column* column)
36 : QDialog(parent) {
37 setWindowTitle(i18nc("@title:window", "Add Value Label"));
38
39 auto mode = column->columnMode();
40 auto* layout = new QGridLayout(this);
41
42 // value
43 auto* l = new QLabel(i18n("Value:"));
44 layout->addWidget(l, 0, 0);
45
46 if (mode == AbstractColumn::ColumnMode::Double || mode == AbstractColumn::ColumnMode::Integer || mode == AbstractColumn::ColumnMode::BigInt) {
47 leValue = new QLineEdit(this);
48 leValue->setFocus();
49 layout->addWidget(leValue, 0, 1);
50
51 if (mode == AbstractColumn::ColumnMode::Double) {
52 leValue->setLocale(QLocale());
53 auto* validator = new QDoubleValidator(leValue);
54 validator->setLocale(QLocale());
55 leValue->setValidator(validator);
56 } else if (mode == AbstractColumn::ColumnMode::Integer || mode == AbstractColumn::ColumnMode::BigInt)
57 leValue->setValidator(new QIntValidator(leValue));
58 } else if (mode == AbstractColumn::ColumnMode::Text) {
59 cbValue = new QComboBox(this);
60
61 // show all unique text values in the combobox
62 QStringList items;
63 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
64 const auto& frequencies = column->frequencies();
65 auto i = frequencies.constBegin();
66 while (i != frequencies.constEnd()) {
67 items << i.key();
68 ++i;
69 }
70
71 cbValue->addItems(items);
72 QApplication::restoreOverrideCursor();
73
74 cbValue->setFocus();
75 layout->addWidget(cbValue, 0, 1);
76
77 } else {
78 dateTimeEdit = new QDateTimeEdit(this);
79 dateTimeEdit->setFocus();
80 layout->addWidget(dateTimeEdit, 0, 1);
81 }
82
83 // label
84 l = new QLabel(i18n("Label:"));
85 layout->addWidget(l, 1, 0);
86
87 leLabel = new QLineEdit(this);
88 layout->addWidget(leLabel, 1, 1);
89
90 auto* btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
91 connect(btnBox, &QDialogButtonBox::accepted, this, &AddValueLabelDialog::accept);
92 connect(btnBox, &QDialogButtonBox::rejected, this, &AddValueLabelDialog::reject);

Callers

nothing calls this directly

Calls 6

groupFunction · 0.85
setLocaleMethod · 0.80
existsMethod · 0.80
columnModeMethod · 0.45
setFocusMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected