Warning, file /education/analitza/analitzagui/operatorsmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 OPERATORSMODEL_H 0020 #define OPERATORSMODEL_H 0021 0022 #include <QAbstractTableModel> 0023 #include <QSharedPointer> 0024 #include "analitzaguiexport.h" 0025 0026 namespace Analitza 0027 { 0028 class Variables; 0029 class Operator; 0030 } 0031 0032 //TODO: get in the namespace 0033 /** Operators model is a model class that has a relation of all operators string with their OperatorType. */ 0034 class ANALITZAGUI_EXPORT OperatorsModel : public QAbstractTableModel 0035 { 0036 Q_OBJECT 0037 public: 0038 enum Roles { 0039 IsVariableRole = Qt::UserRole + 1, 0040 DescriptionRole 0041 }; 0042 0043 /** Constructor. Creates a new Operator Model. */ 0044 explicit OperatorsModel(QObject *parent=nullptr); 0045 0046 /** Returns the description of the @p o operator. */ 0047 static QString description(const Analitza::Operator& o); 0048 0049 /** Returns the description of the @p o operator. */ 0050 static QString sample(const Analitza::Operator& o); 0051 0052 static QString example(const Analitza::Operator& o); 0053 0054 QHash<int, QByteArray> roleNames() const override; 0055 0056 /** Adds an entry to the model. */ 0057 // void addEntry(int i, const QString&, const QString&, const QString& ex=QString()); 0058 0059 /** Updates the variables information */ 0060 void updateInformation(); 0061 0062 QVariant data( const QModelIndex &index, int role=Qt::DisplayRole) const override; 0063 QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override; 0064 int rowCount(const QModelIndex &parent=QModelIndex()) const override; 0065 int columnCount(const QModelIndex &parent=QModelIndex()) const override; 0066 0067 void setVariables(const QSharedPointer<Analitza::Variables> &v) { m_vars=v; } 0068 QModelIndex indexForOperatorName(const QString& id) const; 0069 QString parameterHelp(const QModelIndex& idx, int param, bool inbounds) const; 0070 static QString standardFunctionCallHelp(const QString& funcname, int param, int paramcount, bool inbounds, bool isbounded); 0071 0072 Q_SCRIPTABLE static QString lastWord(int pos, const QString &exp); 0073 0074 private: 0075 QSharedPointer<Analitza::Variables> m_vars; 0076 }; 0077 0078 0079 #endif