File indexing completed on 2024-04-21 15:55:46
0001 /************************************************************************************** 0002 Copyright (C) 2003 by Jeroen Wijnhout (wijnhout@science.uva.nl) 0003 2008-2012 by Michel Ludwig (michel.ludwig@kdemail.net) 0004 **************************************************************************************/ 0005 0006 /*************************************************************************** 0007 * * 0008 * This program is free software; you can redistribute it and/or modify * 0009 * it under the terms of the GNU General Public License as published by * 0010 * the Free Software Foundation; either version 2 of the License, or * 0011 * (at your option) any later version. * 0012 * * 0013 ***************************************************************************/ 0014 0015 #ifndef OUTPUTINFO_H 0016 #define OUTPUTINFO_H 0017 0018 #include <QList> 0019 #include <QMetaType> 0020 #include <QString> 0021 0022 #include <KConfigGroup> 0023 0024 #include "tool_utils.h" 0025 0026 /** 0027 * Class for output-information of third program (e.g. Latex-Output, C-Compiler output) 0028 * 0029 * @author Thorsten Lck 0030 * @author Jeroen Wijnhout 0031 **/ 0032 0033 class OutputInfo 0034 { 0035 public: 0036 /** 0037 * Constructs an invalid output information object. 0038 **/ 0039 OutputInfo(); 0040 0041 OutputInfo(const QString& mainSourceFile, const QString& strSrcFile, int nSrcLine, int nOutputLine, const QString& strError = QString(), int nErrorID = -1); 0042 0043 public: 0044 /** 0045 * Returns true if and only if this object contains valid output 0046 * information. 0047 **/ 0048 bool isValid() const; 0049 0050 /** File that was compiled. */ 0051 QString mainSourceFile() const { 0052 return m_mainSourceFile; 0053 } 0054 void setMainSourceFile(const QString& src) { 0055 m_mainSourceFile = src; 0056 } 0057 0058 /** Source file where error occurred. */ 0059 QString source() const { 0060 return m_strSrcFile; 0061 } 0062 /** Source file where error occurred. */ 0063 void setSource(const QString& src) { 0064 m_strSrcFile = src; 0065 } 0066 0067 /** Line number in source file of the current message */ 0068 int sourceLine() const { 0069 return m_nSrcLine; 0070 } 0071 /** Line number in source file of the current message */ 0072 void setSourceLine(int line) { 0073 m_nSrcLine = line; 0074 } 0075 0076 /** Error message */ 0077 QString message() const { 0078 return m_strError; 0079 } 0080 /** Error message */ 0081 void setMessage(const QString& message) { 0082 m_strError = message; 0083 } 0084 0085 /** Error code */ 0086 int type() const { 0087 return m_nErrorID; 0088 } 0089 /** Error code */ 0090 void setType(int type) { 0091 m_nErrorID = type; 0092 } 0093 0094 /** Line number in the output, where error was reported. */ 0095 int outputLine() const { 0096 return m_nOutputLine; 0097 } 0098 /** Line number in the output, where error was reported. */ 0099 void setOutputLine(int line) { 0100 m_nOutputLine = line; 0101 } 0102 0103 /** 0104 * Clears the information stored in this object, turning it 0105 * into an invalid output information object. 0106 **/ 0107 void clear(); 0108 0109 /** 0110 * Comparison operator 0111 **/ 0112 bool operator==(const OutputInfo& info) const; 0113 0114 private: 0115 QString m_mainSourceFile; 0116 QString m_strSrcFile; 0117 int m_nSrcLine; 0118 QString m_strError; 0119 int m_nOutputLine; 0120 int m_nErrorID; 0121 }; 0122 0123 Q_DECLARE_METATYPE(OutputInfo) 0124 0125 /** 0126 * Array of OutputInfo 0127 * @author Thorsten Lck 0128 **/ 0129 typedef QList<OutputInfo> OutputInfoArray; 0130 0131 class LatexOutputInfo : public OutputInfo 0132 { 0133 public: 0134 LatexOutputInfo(); 0135 LatexOutputInfo(const QString& mainSourceFile, const QString& strSrcFile, int nSrcLine, int nOutputLine, const QString& strError = QString(), int nErrorID = -1); 0136 0137 public: 0138 /** 0139 * These constants are describing, which item types is currently 0140 * parsed. (to be set as error code) 0141 **/ 0142 enum tagCookies 0143 { 0144 itmNone = 0, 0145 itmError, 0146 itmWarning, 0147 itmBadBox 0148 }; 0149 }; 0150 0151 /** 0152 * Array of LatexOutputInfo 0153 * @author Thorsten Lck 0154 **/ 0155 typedef QList<LatexOutputInfo> LatexOutputInfoArray; 0156 0157 0158 class LaTeXOutputHandler 0159 { 0160 public: 0161 LaTeXOutputHandler(); 0162 virtual ~LaTeXOutputHandler(); 0163 0164 void storeLaTeXOutputParserResult(int nErrors, int nWarnings, int nBadBoxes, 0165 const LatexOutputInfoArray& outputList, 0166 const QString& logFile); 0167 0168 int numberOfWarnings() const; 0169 int numberOfErrors() const; 0170 int numberOfBadBoxes() const; 0171 LatexOutputInfoArray outputList() const; 0172 QString logFile() const; 0173 int currentError() const; 0174 void setCurrentError(int i); 0175 0176 void setBibliographyBackendToolUserOverride(const KileTool::ToolConfigPair& p); 0177 const KileTool::ToolConfigPair& bibliographyBackendToolUserOverride() const; 0178 0179 void setBibliographyBackendToolAutoDetected(const KileTool::ToolConfigPair& p); 0180 const KileTool::ToolConfigPair& bibliographyBackendToolAutoDetected() const; 0181 0182 void readBibliographyBackendSettings(const KConfigGroup& group); 0183 void writeBibliographyBackendSettings(KConfigGroup& group); 0184 0185 protected: 0186 int m_nErrors, m_nWarnings, m_nBadBoxes, m_currentError; 0187 LatexOutputInfoArray m_latexOutputInfoList; 0188 QString m_logFile; 0189 KileTool::ToolConfigPair m_userOverrideBibBackendToolConfigPair, m_autodetectBibBackendToolConfigPair; 0190 }; 0191 0192 #endif