/************************************************************************************* * Copyright (C) 2007-2008 by Aleix Pol * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * *************************************************************************************/ #include "operatorsmodel.h" #include #include #include #include #include using Analitza::Operator; OperatorsModel::OperatorsModel(QObject *parent) : QAbstractTableModel(parent), m_vars(0) { } QVariant OperatorsModel::data(const QModelIndex & index, int role) const { QVariant ret; if(role==Qt::DisplayRole) { if(index.row()keys()[var]; switch(index.column()) { case 0: ret=key; break; case 1: ret=m_vars->value(key)->toString(); break; } } } else if(role==Qt::FontRole && index.column()==1) { QFont f = KApplication::font(); f.setItalic(true); ret=f; } return ret; } QVariant OperatorsModel::headerData(int section, Qt::Orientation orientation, int role) const { QVariant ret; if(role==Qt::DisplayRole && orientation==Qt::Horizontal) { switch(section) { case 0: ret=i18nc("@title:column", "Name"); break; case 1: ret=i18nc("@title:column", "Description"); break; case 2: ret=i18nc("@title:column", "Parameters"); break; case 3: ret=i18nc("@title:column", "Example"); break; } } return ret; } int OperatorsModel::rowCount(const QModelIndex &) const { int count=Analitza::Operator::nOfOps; if(m_vars) count+=m_vars->count(); return count-2; } int OperatorsModel::columnCount(const QModelIndex &) const { return 4; } void OperatorsModel::updateInformation() { reset(); } QString OperatorsModel::sample(Operator oper) { QString funcname=oper.toString(); QString bounds; if(oper.isBounded()) { bounds=" : var=from..to"; } QString sample = i18n("%1(", funcname); if(oper.nparams()<0) { return i18n("%1... parameters, ...%2)", sample, bounds); } else { for(int i=0; ib"); break; case Operator::lt: s = i18n("Less than. lt(a,b)=adata(Qt::EditRole).toInt()==op.operatorType()) { return item(i,0)->data(Qt::EditRole).toString(); } } return QString(); }*/