Warning, file /education/kmplot/kmplot/initialconditionseditor.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 KmPlot - a math. function plotter for the KDE-Desktop 0003 0004 SPDX-FileCopyrightText: 2006 David Saxton <david@bluehaze.org> 0005 0006 This file is part of the KDE Project. 0007 KmPlot is part of the KDE-EDU Project. 0008 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 0011 */ 0012 0013 #ifndef INITIALCONDITIONSEDITOR_H 0014 #define INITIALCONDITIONSEDITOR_H 0015 0016 #include "function.h" 0017 0018 #include <QAbstractTableModel> 0019 #include <QItemDelegate> 0020 #include <QTableView> 0021 0022 class DifferentialStates; 0023 class EquationEdit; 0024 class Function; 0025 class InitialConditionsEditor; 0026 0027 class InitialConditionsModel : public QAbstractTableModel 0028 { 0029 public: 0030 explicit InitialConditionsModel(InitialConditionsEditor *parent); 0031 0032 int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; 0033 int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; 0034 QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; 0035 QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE; 0036 bool setData(const QModelIndex &index, const QVariant &value, int role) Q_DECL_OVERRIDE; 0037 Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; 0038 bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex()) Q_DECL_OVERRIDE; 0039 bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex()) Q_DECL_OVERRIDE; 0040 0041 protected: 0042 InitialConditionsEditor *m_parent; 0043 0044 friend class InitialConditionsEditor; 0045 }; 0046 0047 class InitialConditionsView : public QTableView 0048 { 0049 public: 0050 explicit InitialConditionsView(QWidget *parent); 0051 }; 0052 0053 class InitialConditionsDelegate : public QItemDelegate 0054 { 0055 Q_OBJECT 0056 0057 public: 0058 explicit InitialConditionsDelegate(InitialConditionsEditor *parent); 0059 0060 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; 0061 void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE; 0062 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE; 0063 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; 0064 0065 protected slots: 0066 void equationEditDone(); 0067 0068 protected: 0069 InitialConditionsEditor *m_parent; 0070 mutable EquationEdit *m_lastEditor; 0071 }; 0072 0073 #include "ui_initialconditionswidget.h" 0074 0075 class InitialConditionsEditor : public QWidget, public Ui::InitialConditionsWidget 0076 { 0077 Q_OBJECT 0078 0079 public: 0080 explicit InitialConditionsEditor(QWidget *parent); 0081 0082 /** 0083 * Initializes the list from the given states in \p function 0084 */ 0085 void init(Function *function); 0086 /** 0087 * Changes the order of the differential equation. 0088 */ 0089 void setOrder(int order); 0090 /** 0091 * \return the current function. 0092 */ 0093 DifferentialStates *differentialStates() 0094 { 0095 return &m_states; 0096 } 0097 /** 0098 * \return the equation currently in use. Use differentialStates 0099 * for accessing the DifferentialStates instead of through equation, 0100 * however, since the DifferentialStates in equation will be 0101 * overwritten after saving via function editor. 0102 */ 0103 Equation *equation() const 0104 { 0105 return m_equation; 0106 } 0107 0108 signals: 0109 void dataChanged(); 0110 0111 public slots: 0112 /** 0113 * For differential equations, add an initial condition. 0114 */ 0115 void add(); 0116 /** 0117 * For differential equations, remove the selected initial condition. 0118 */ 0119 void remove(); 0120 0121 protected: 0122 InitialConditionsModel *m_model; 0123 Equation *m_equation; 0124 DifferentialStates m_states; 0125 }; 0126 0127 #endif // INITIALCONDITIONSEDITOR_H