1 2 /* 3 * CodeQuery 4 * Copyright (C) 2013-2017 ruben2020 https://github.com/ruben2020/ 5 * 6 * This Source Code Form is subject to the terms of the Mozilla Public 7 * License, v. 2.0. If a copy of the MPL was not distributed with this 8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 * 10 */ 11 12 13 #ifndef FILEVIEWER_H_CQ 14 #define FILEVIEWER_H_CQ 15 16 #ifdef USE_QT5 17 #include <QtWidgets> 18 #else 19 #include <QtGui> 20 #endif 21 22 #include "sqlquery.h" 23 Q_DECLARE_METATYPE(sqlqueryresultlist*) 24 25 26 class mainwindow; 27 class ScintillaEdit; 28 29 30 class filedata 31 { 32 public: 33 QString filename; 34 QString linenum; 35 int fileid; 36 37 filedata(); 38 filedata(const QString& fn, const QString& ln, const int& fi); 39 filedata(const filedata& fd); 40 bool compare(const filedata& fd); 41 bool compareFilePathOnly(const filedata& fd); 42 bool compareFileNameOnly(const filedata& fd); 43 filedata& operator=(const filedata& fd); 44 }; 45 46 47 enum langtypes 48 { 49 enHighlightNone = 0, 50 enHighlightCPP, 51 enHighlightPython, 52 enHighlightJava, 53 enHighlightRuby, 54 enHighlightGo, 55 enHighlightJavascript 56 }; 57 58 class fileviewer : public QObject 59 { 60 Q_OBJECT 61 62 public: 63 QPushButton *m_pushButtonPrev; 64 QPushButton *m_pushButtonNext; 65 QPushButton *m_pushButtonOpenInEditor; 66 QPushButton *m_pushButtonPaste; 67 QPushButton *m_pushButtonGoToLine; 68 QPushButton *m_pushButtonTextShrink; 69 QPushButton *m_pushButtonTextEnlarge; 70 QCheckBox *m_checkBoxSymbolOnly; 71 QLabel *m_labelFilePath; 72 ScintillaEdit *m_textEditSource; 73 QListWidget *m_listWidgetFunc; 74 QComboBox *m_comboBoxFuncListSort; 75 QString m_externalEditorPath; 76 QFont m_textEditSourceFont; 77 int m_lexer; 78 int m_fontsize; 79 QString m_theme; 80 81 fileviewer(mainwindow* pmw); 82 ~fileviewer(); 83 void init(void); 84 void updateTextEdit(void); 85 void updateFilePathLabel(void); 86 void handleFileCannotBeOpenedCase(void); 87 QString checkFontFamily(QString fontname); 88 89 public slots: 90 void fileToBeOpened(QString filename, QString linenum, int fileid); 91 void AbleToCopy(bool copy); 92 void GoToLine_ButtonClick(bool checked); 93 void Paste_ButtonClick(bool checked); 94 void Prev_ButtonClick(bool checked); 95 void Next_ButtonClick(bool checked); 96 void OpenInEditor_ButtonClick(bool checked); 97 void TextShrink_ButtonClick(bool checked); 98 void TextEnlarge_ButtonClick(bool checked); 99 void OptionsExtEditor_Triggered(bool checked); 100 void fileViewSettings_Triggered(bool checked); 101 void clearList(); 102 void recvDBtimestamp(QDateTime dt); 103 void fontSelectionTemporary(const QString &fonttxt); 104 void themeSelectionTemporary(const QString &themetxt); 105 void tabWidthSelectionTemporary(const QString &width); 106 void annotate(QStringList annotstrLst); 107 void recvFuncList(sqlqueryresultlist* reslist); 108 void funcItemSelected(QListWidgetItem * curitem); 109 void FuncListSort_indexChanged(const int& idx); 110 111 signals: 112 void searchCopiedText(); 113 void searchCopiedTextSymbolOnly(); 114 void requestAnnotation(QString searchstr); 115 void requestFuncList_filename(QString filename); 116 void requestFuncList_fileid(int fileid); 117 118 private: 119 mainwindow *mw; 120 QVector<filedata> m_fileDataList; 121 QVector<filedata>::iterator m_iter; 122 QDateTime m_DBtimestamp; 123 bool m_timestampMismatchWarned; 124 QStringList m_fontlist; 125 QString m_fonttemp; 126 QString m_themetemp; 127 QString m_themelast; 128 int m_currentlang; 129 int m_fontwidthtemp; 130 int m_markerhandle; 131 int m_markerhandle2; 132 long m_currentline; 133 long m_annotline; 134 sqlqueryresultlist m_funclist; 135 136 void createFontList(void); 137 void textSizeChange(int n); 138 void highlightLine(unsigned int num = 0); 139 void setLexer(int lang = -1); 140 void replaceLexer(int sclang, int lang); 141 void clearTextEdit(void); 142 void braceMatchCheck(void); 143 void updateFuncList(void); 144 145 }; 146 147 148 #endif 149