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

Method SampleValuesDialog

src/frontend/spreadsheet/SampleValuesDialog.cpp:38–83  ·  view source on GitHub ↗

! \class SampleValuesDialog \brief Dialog for generating values from a mathematical function. \ingroup frontend */

Source from the content-addressed store, hash-verified

36 \ingroup frontend
37 */
38SampleValuesDialog::SampleValuesDialog(Spreadsheet* s, QWidget* parent)
39 : QDialog(parent)
40 , m_spreadsheet(s) {
41 ui.setupUi(this);
42 setAttribute(Qt::WA_DeleteOnClose);
43
44 ui.cbMethod->addItem(i18n("Periodic"));
45 ui.cbMethod->addItem(i18n("Random"));
46
47 QString info = i18n(
48 "Sampling method:"
49 "<ul>"
50 "<li>Periodic - samples are created according to the specified interval.</li>"
51 "<li>Random - samples are created randomly based on the uniform distribution. </li>"
52 "</ul>");
53 ui.lMethod->setToolTip(info);
54 ui.cbMethod->setToolTip(info);
55
56 auto* btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
57 ui.gridLayout->addWidget(btnBox, 2, 1, 1, 2);
58 m_okButton = btnBox->button(QDialogButtonBox::Ok);
59
60 connect(btnBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &SampleValuesDialog::close);
61
62 m_okButton->setText(i18n("&Sample"));
63 m_okButton->setToolTip(i18n("Sample values in the selected spreadsheet columns"));
64 setWindowTitle(i18nc("@title:window", "Sample Values"));
65
66 connect(ui.cbMethod, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SampleValuesDialog::methodChanged);
67 connect(m_okButton, &QPushButton::clicked, this, &SampleValuesDialog::sampleValues);
68 connect(btnBox, &QDialogButtonBox::accepted, this, &SampleValuesDialog::accept);
69 connect(btnBox, &QDialogButtonBox::rejected, this, &SampleValuesDialog::reject);
70
71 // restore saved settings if available
72 KConfigGroup conf = Settings::group(QLatin1String("SampleValuesDialog"));
73 ui.cbMethod->setCurrentIndex(conf.readEntry("Method", 0));
74 ui.sbValue->setValue(conf.readEntry("Value", 1));
75 methodChanged(ui.cbMethod->currentIndex());
76
77 create(); // ensure there's a window created
78 if (conf.exists()) {
79 KWindowConfig::restoreWindowSize(windowHandle(), conf);
80 resize(windowHandle()->size()); // workaround for QTBUG-40584
81 } else
82 resize(QSize(400, 0).expandedTo(minimumSize()));
83}
84
85SampleValuesDialog::~SampleValuesDialog() {
86 // save the current settings

Callers

nothing calls this directly

Calls 9

groupFunction · 0.85
setToolTipMethod · 0.80
buttonMethod · 0.80
existsMethod · 0.80
setTextMethod · 0.45
setCurrentIndexMethod · 0.45
setValueMethod · 0.45
currentIndexMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected