1 /************************************************************************ 2 ** 3 ** Copyright (C) 2009, 2010, 2011 Strahinja Markovic <strahinja.markovic@gmail.com> 4 ** 5 ** This file is part of Sigil. 6 ** 7 ** Sigil is free software: you can redistribute it and/or modify 8 ** it under the terms of the GNU General Public License as published by 9 ** the Free Software Foundation, either version 3 of the License, or 10 ** (at your option) any later version. 11 ** 12 ** Sigil is distributed in the hope that it will be useful, 13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ** GNU General Public License for more details. 16 ** 17 ** You should have received a copy of the GNU General Public License 18 ** along with Sigil. If not, see <http://www.gnu.org/licenses/>. 19 ** 20 *************************************************************************/ 21 22 #pragma once 23 #ifndef TEXTTAB_H 24 #define TEXTTAB_H 25 26 #include "Misc/Utility.h" 27 #include "MiscEditors/ClipEditorModel.h" 28 #include "Tabs/ContentTab.h" 29 #include "ViewEditors/CodeViewEditor.h" 30 31 class TextResource; 32 class QTextDocument; 33 34 35 class TextTab : public ContentTab 36 { 37 Q_OBJECT 38 39 public: 40 41 TextTab(TextResource *resource, 42 CodeViewEditor::HighlighterType type, 43 int line_to_scroll_to = -1, 44 int position_to_scroll_to = -1, 45 QWidget *parent = 0); 46 47 ~TextTab(); 48 49 void ScrollToLine(int line); 50 51 void ScrollToPosition(int cursor_position); 52 53 // Overrides inherited from ContentTab 54 bool IsModified(); 55 56 bool CutEnabled(); 57 58 bool CopyEnabled(); 59 60 bool PasteEnabled(); 61 62 bool DeleteLineEnabled(); 63 64 bool CutCodeTagsEnabled(); 65 66 int GetCursorLine() const; 67 68 int GetCursorPosition() const; 69 70 int GetCursorColumn() const; 71 72 float GetZoomFactor() const; 73 74 void SetZoomFactor(float new_zoom_factor); 75 76 void UpdateDisplay(); 77 78 Searchable *GetSearchableContent(); 79 80 public slots: 81 82 /** 83 * Implements Undo action functionality. 84 */ 85 void Undo(); 86 87 /** 88 * Implements Redo action functionality. 89 */ 90 void Redo(); 91 92 /** 93 * Implements Cut action functionality. 94 */ 95 void Cut(); 96 97 /** 98 * void Cut(); 99 */ 100 void Copy(); 101 102 /** 103 * Implements Paste action functionality. 104 */ 105 void Paste(); 106 107 void DeleteLine(); 108 109 bool MarkSelection(); 110 bool ClearMarkedText(); 111 112 void CutCodeTags(); 113 114 /** 115 * Change casing of the selected text. 116 */ 117 void ChangeCasing(const Utility::Casing casing); 118 119 void Print(); 120 void PrintPreview(); 121 122 signals: 123 124 void SelectionChanged(); 125 126 void OpenClipEditorRequest(ClipEditorModel::clipEntry *clip); 127 128 protected slots: 129 130 void SaveTabContent(); 131 132 void SaveTabContent(QWidget *editor); 133 134 void LoadTabContent(); 135 136 void LoadTabContent(QWidget *editor); 137 138 private slots: 139 140 void EmitUpdateCursorPosition(); 141 142 void DelayedInitialization(); 143 144 private: 145 146 virtual void ConnectSignalsToSlots(); 147 148 protected: 149 150 // The plain text code editor 151 CodeViewEditor *m_wCodeView; 152 153 private: 154 155 /////////////////////////////// 156 // PRIVATE MEMBER VARIABLES 157 /////////////////////////////// 158 159 TextResource *m_TextResource; 160 161 int m_LineToScrollTo; 162 int m_PositionToScrollTo; 163 164 }; 165 166 #endif // TEXTTAB_H 167