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

Method FunctionValuesDialog

src/frontend/spreadsheet/FunctionValuesDialog.cpp:39–90  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

37 \ingroup frontend
38 */
39FunctionValuesDialog::FunctionValuesDialog(Spreadsheet* s, QWidget* parent)
40 : QDialog(parent)
41 , m_spreadsheet(s) {
42 Q_ASSERT(s);
43 setWindowTitle(i18nc("@title:window", "Function Values"));
44
45 ui.setupUi(this);
46 setAttribute(Qt::WA_DeleteOnClose);
47 ui.tbConstants->setIcon(QIcon::fromTheme(QStringLiteral("format-text-symbol")));
48 ui.tbFunctions->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-font")));
49
50 ui.teEquation->setMaximumHeight(QLineEdit().sizeHint().height() * 2);
51 ui.teEquation->setFocus();
52
53// needed for buggy compiler
54#if __cplusplus < 201103L
55 m_aspectTreeModel = std::auto_ptr<AspectTreeModel>(new AspectTreeModel(m_spreadsheet->project()));
56#else
57 m_aspectTreeModel = std::unique_ptr<AspectTreeModel>(new AspectTreeModel(m_spreadsheet->project()));
58#endif
59 m_aspectTreeModel->setSelectableAspects({AspectType::Column});
60 m_aspectTreeModel->enableNumericColumnsOnly(true);
61
62 ui.bAddVariable->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
63 ui.bAddVariable->setToolTip(i18n("Add new variable"));
64
65 ui.chkAutoUpdate->setToolTip(i18n("Automatically update the calculated values in the target column on changes in the variable columns"));
66 ui.chkAutoResize->setToolTip(i18n("Automatically resize the target column to fit the size of the variable columns"));
67
68 auto* btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
69 ui.verticalLayout->addWidget(btnBox);
70 m_okButton = btnBox->button(QDialogButtonBox::Ok);
71
72 connect(btnBox, &QDialogButtonBox::accepted, this, &FunctionValuesDialog::accept);
73 connect(btnBox, &QDialogButtonBox::rejected, this, &FunctionValuesDialog::reject);
74 m_okButton->setText(i18n("&Generate"));
75
76 connect(ui.bAddVariable, &QPushButton::pressed, this, &FunctionValuesDialog::addVariable);
77 connect(ui.teEquation, &ExpressionTextEdit::expressionChanged, this, &FunctionValuesDialog::checkValues);
78 connect(ui.tbConstants, &QToolButton::clicked, this, &FunctionValuesDialog::showConstants);
79 connect(ui.tbFunctions, &QToolButton::clicked, this, &FunctionValuesDialog::showFunctions);
80 connect(m_okButton, &QPushButton::clicked, this, &FunctionValuesDialog::generate);
81
82 // restore saved settings if available
83 create(); // ensure there's a window created
84 KConfigGroup conf = Settings::group(QStringLiteral("FunctionValuesDialog"));
85 if (conf.exists()) {
86 KWindowConfig::restoreWindowSize(windowHandle(), conf);
87 resize(windowHandle()->size()); // workaround for QTBUG-40584
88 } else
89 resize(QSize(300, 0).expandedTo(minimumSize()));
90}
91
92FunctionValuesDialog::~FunctionValuesDialog() {
93 KConfigGroup conf = Settings::group(QStringLiteral("FunctionValuesDialog"));

Callers

nothing calls this directly

Calls 14

groupFunction · 0.85
heightMethod · 0.80
setSelectableAspectsMethod · 0.80
setToolTipMethod · 0.80
buttonMethod · 0.80
existsMethod · 0.80
QLineEditClass · 0.70
setIconMethod · 0.45
sizeHintMethod · 0.45
setFocusMethod · 0.45
projectMethod · 0.45

Tested by

no test coverage detected