Warning, file /office/kile/src/parser/parserthread.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) 2011-2019 by Michel Ludwig (michel.ludwig@kdemail.net) * 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published by * 0009 * the Free Software Foundation; either version 2 of the License, or * 0010 * (at your option) any later version. * 0011 * * 0012 ***************************************************************************/ 0013 0014 #ifndef PARSERTHREAD_H 0015 #define PARSERTHREAD_H 0016 0017 #include <QMutex> 0018 #include <QPair> 0019 #include <QThread> 0020 #include <QQueue> 0021 #include <QWaitCondition> 0022 0023 #include <QUrl> 0024 0025 #include "documentinfo.h" 0026 0027 #include "parser.h" 0028 0029 class KileInfo; 0030 0031 namespace KileDocument { 0032 class Info; 0033 class TextInfo; 0034 } 0035 0036 namespace KileParser { 0037 0038 class Parser; 0039 class ParserInput; 0040 class ParserOutput; 0041 0042 enum ParserType { LaTeX = 0, BibTeX }; 0043 0044 class ParserThread : public QThread 0045 { 0046 Q_OBJECT 0047 0048 public: 0049 explicit ParserThread(KileInfo *info, QObject *parent = 0); 0050 virtual ~ParserThread(); 0051 0052 void stopParsing(); 0053 0054 bool shouldContinueDocumentParsing(); 0055 0056 bool isParsingComplete(); 0057 0058 Q_SIGNALS: 0059 /** 0060 * The ownership of the 'output' object is transferred to the slot(s) 0061 * connected to this signal. 0062 **/ 0063 void parsingComplete(const QUrl &url, KileParser::ParserOutput* output); 0064 0065 void parsingQueueEmpty(); 0066 void parsingStarted(); 0067 0068 protected: 0069 KileInfo *m_ki; 0070 0071 void addParserInput(ParserInput *input); 0072 void removeParserInput(const QUrl &url); 0073 0074 void run() override; 0075 0076 virtual Parser* createParser(ParserInput *input) = 0; 0077 0078 private: 0079 bool m_keepParserThreadAlive; 0080 bool m_keepParsingDocument; 0081 QQueue<ParserInput*> m_parserQueue; 0082 QUrl m_currentlyParsedUrl; 0083 QMutex m_parserMutex; 0084 QWaitCondition m_queueEmptyWaitCondition; 0085 }; 0086 0087 0088 class DocumentParserThread : public ParserThread 0089 { 0090 Q_OBJECT 0091 0092 public: 0093 explicit DocumentParserThread(KileInfo *info, QObject *parent = Q_NULLPTR); 0094 virtual ~DocumentParserThread(); 0095 0096 public Q_SLOTS: 0097 void addDocument(KileDocument::TextInfo *textInfo); 0098 void removeDocument(KileDocument::TextInfo *textInfo); 0099 void removeDocument(const QUrl &url); 0100 0101 protected: 0102 virtual Parser* createParser(ParserInput *input) override; 0103 0104 }; 0105 0106 0107 class OutputParserThread: public ParserThread 0108 { 0109 Q_OBJECT 0110 0111 public: 0112 explicit OutputParserThread(KileInfo *info, QObject *parent = Q_NULLPTR); 0113 virtual ~OutputParserThread(); 0114 0115 public Q_SLOTS: 0116 void addLaTeXLogFile(const QString& logFile, const QString& sourceFile, 0117 // for QuickPreview 0118 const QString& texFileName = "", int selrow = -1, int docrow = -1); 0119 void removeFile(const QString& fileName); 0120 0121 protected: 0122 virtual Parser* createParser(ParserInput *input) override; 0123 }; 0124 0125 } 0126 0127 #endif