File indexing completed on 2024-04-21 05:43:40
0001 /*************************************************************************** 0002 * Copyright (C) 2003-2005 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #ifndef LOGVIEW_H 0012 #define LOGVIEW_H 0013 0014 class KTechlab; 0015 // class Q3PopupMenu; 0016 0017 #include <KTextEdit> 0018 #include <QMap> 0019 0020 namespace KateMDI 0021 { 0022 class ToolView; 0023 } 0024 0025 class MessageInfo 0026 { 0027 public: 0028 MessageInfo(); 0029 MessageInfo(QString fileURL, int fileLine); 0030 0031 QString fileURL() const 0032 { 0033 return m_fileURL; 0034 } 0035 int fileLine() const 0036 { 0037 return m_fileLine; 0038 } 0039 0040 protected: 0041 QString m_fileURL; 0042 int m_fileLine; 0043 }; 0044 typedef QMap<int, MessageInfo> MessageInfoMap; 0045 0046 /** 0047 Base class for logviews (eg GpasmInterface) which output information, warnings, errors to a viewable log 0048 @short Dockable logview 0049 @author David Saxton 0050 */ 0051 class LogView : public KTextEdit 0052 { 0053 Q_OBJECT 0054 public: 0055 LogView(KateMDI::ToolView *parent); 0056 ~LogView() override; 0057 0058 enum OutputType { 0059 ot_important, // Bold 0060 ot_info, // Italic 0061 ot_message, // Plain 0062 ot_warning, // Grey 0063 ot_error // Red 0064 }; 0065 0066 signals: 0067 /** 0068 * Emitted when the user clicks on a paragraph in the log view 0069 */ 0070 void paraClicked(const QString &text, MessageInfo messageInfo); 0071 0072 public slots: 0073 virtual void clear(); 0074 void addOutput(QString text, OutputType outputType, MessageInfo messageInfo = MessageInfo()); 0075 0076 protected: 0077 virtual QMenu *createPopupMenu(const QPoint &pos); 0078 /** 0079 * Replaces "&" with &, "<" with <, etc 0080 */ 0081 void tidyText(QString &t); 0082 /** 0083 * Replaces "<" with "<", "&" with "&", etc 0084 */ 0085 void untidyText(QString &t); 0086 0087 MessageInfoMap m_messageInfoMap; 0088 0089 void mouseDoubleClickEvent(QMouseEvent *e) override; 0090 0091 private slots: 0092 void slotParaClicked(int para, int pos); 0093 }; 0094 0095 #endif