File indexing completed on 2024-04-28 07:28:50
0001 /************************************************************************************* 0002 * Copyright (C) 2007 by Aleix Pol <aleixpol@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License * 0006 * as published by the Free Software Foundation; either version 2 * 0007 * of the License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the Free Software * 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 0017 *************************************************************************************/ 0018 0019 #ifndef VAREDIT_H 0020 #define VAREDIT_H 0021 0022 #include <QDialog> 0023 #include <QLabel> 0024 0025 class QDialogButtonBox; 0026 namespace Analitza 0027 { 0028 class Analyzer; 0029 class Variables; 0030 class Expression; 0031 class ExpressionEdit; 0032 } 0033 0034 /** 0035 * The VarEdit provides a dialog to allow users to edit/create a variable. 0036 * @author Aleix Pol i Gonzalez 0037 */ 0038 0039 class VarEdit : public QDialog 0040 { 0041 Q_OBJECT 0042 public: 0043 /** Constructor. Creates a variable editing dialog. */ 0044 explicit VarEdit(QWidget *parent = nullptr, bool modal = false); 0045 0046 /** Sets the editing variable name */ 0047 void setName(const QString &newVar); 0048 0049 /** Sets an Analitza which will evaluate it. It may be interesting because variables can change. */ 0050 void setAnalitza(Analitza::Analyzer *na); 0051 0052 /** Returns the resulting variable expression */ 0053 Analitza::Expression val(); 0054 0055 private: 0056 bool canRemove(const QString &name) const; 0057 0058 Analitza::ExpressionEdit *m_exp; 0059 0060 QLabel *m_valid; 0061 QSharedPointer<Analitza::Variables> vars; 0062 bool m_correct; 0063 QString m_var; 0064 QDialogButtonBox *m_buttonBox; 0065 QPushButton *m_removeBtn; 0066 0067 private Q_SLOTS: 0068 void edit(); 0069 void ok(); 0070 void removeVariable(); 0071 }; 0072 0073 #endif