Warning, file /education/cantor/src/backends/kalgebra/kalgebracompletionobject.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2009 Aleix Pol <aleixpol@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "kalgebracompletionobject.h"
0008 
0009 #include <QStringList>
0010 
0011 #include "kalgebrasession.h"
0012 #include <analitzagui/operatorsmodel.h>
0013 
0014 KAlgebraCompletionObject::KAlgebraCompletionObject(const QString& command, int index, KAlgebraSession* session)
0015     : Cantor::CompletionObject(session)
0016 {
0017     setLine(command, index);
0018 }
0019 
0020 void KAlgebraCompletionObject::fetchCompletions()
0021 {
0022     OperatorsModel* opm=static_cast<KAlgebraSession*>(session())->operatorsModel();
0023 
0024     QModelIndexList idxs=opm->match(opm->index(0,0), Qt::DisplayRole, command(), 5, Qt::MatchStartsWith);
0025     QStringList comp;
0026     foreach(const QModelIndex& idx, idxs)
0027         comp << idx.data().toString();
0028 
0029     setCompletions(comp);
0030     emit fetchingDone();
0031 }
0032 
0033 bool KAlgebraCompletionObject::mayIdentifierBeginWith(QChar c) const
0034 {
0035     return c.isLetter();
0036 }