1 #ifndef Header_Latex_Completer_P 2 #define Header_Latex_Completer_P 3 4 #include "mostQtHeaders.h" 5 6 #include "codesnippet.h" 7 #include "latexcompleter_config.h" 8 #include <set> 9 10 typedef CodeSnippet CompletionWord; 11 12 //class CompleterInputBinding; 13 class CompletionListModel : public QAbstractListModel 14 { 15 Q_OBJECT 16 17 public: QAbstractListModel(parent)18 CompletionListModel(QObject *parent = 0): QAbstractListModel(parent), mostUsedUpdated(false), mCanFetchMore(false), mLastMU(0), mLastType(CodeSnippet::none), mEnvMode(false), mWordCount(0), mCitCount(-1) {} 19 20 int rowCount(const QModelIndex &parent = QModelIndex()) const; 21 QVariant data(const QModelIndex &index, int role)const; 22 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 23 getWords()24 const QList<CompletionWord> &getWords() { return words; } 25 bool isNextCharPossible(const QChar &c); //does this character lead to a new possible word 26 void filterList(const QString &word, int mostUsed = -1, bool fetchMore = false, CodeSnippet::Type type = CodeSnippet::none); 27 void setEnvironMode(bool mode); 28 void setBaseWords(const QSet<QString> &newwords, CompletionType completionType); 29 void setBaseWords(const std::set<QString> &newwords, CompletionType completionType); 30 void setBaseWords(const QList<CompletionWord> &newwords, CompletionType completionType); 31 void setBaseWords(const CodeSnippetList &baseCommands, const CodeSnippetList &newwords, CompletionType completionType); 32 void setAbbrevWords(const QList<CompletionWord> &newwords); 33 void incUsage(const QModelIndex &index); 34 void setConfig(LatexCompleterConfig *newConfig); 35 virtual bool canFetchMore(const QModelIndex &parent) const; 36 void fetchMore(const QModelIndex &parent); 37 CompletionWord getLastWord(); 38 void setContextWords(const QSet<QString> &newwords, const QString &context); 39 void setKeyValWords(const QString &name, const QSet<QString> &newwords); 40 41 private: 42 friend class LatexCompleter; //TODO: make this unnecessary 43 QList<CompletionWord> words; 44 QString curWord; 45 46 QList<CompletionWord> baselist; 47 QList<CompletionWord> wordsText, wordsCommands, wordsAbbrev, wordsLabels, wordsCitations; 48 49 int mostUsedUpdated; 50 51 QMap<QString, QList<CompletionWord> > keyValLists; 52 QMap<QString, QList<CompletionWord> > contextLists; 53 54 bool mCanFetchMore; 55 QString mLastWord; 56 int mLastMU; 57 CodeSnippet::Type mLastType; 58 CompletionWord mLastWordInList; 59 60 bool mEnvMode; 61 62 int mWordCount, mCitCount; 63 64 QList<CompletionWord>::iterator it; 65 66 static LatexCompleterConfig *config; 67 }; 68 69 #endif // LATEXCOMPLETER_P_H 70