Changeset View
Changeset View
Standalone View
Standalone View
krusader/KViewer/lister.h
Context not available. | |||||
34 | // QtCore | 34 | // QtCore | ||
---|---|---|---|---|---|
35 | #include <QList> | 35 | #include <QList> | ||
36 | #include <QTimer> | 36 | #include <QTimer> | ||
37 | #include <QTextCodec> | ||||
38 | #include <QMutex> | ||||
37 | // QtGui | 39 | // QtGui | ||
38 | #include <QColor> | 40 | #include <QColor> | ||
39 | // QtWidgets | 41 | // QtWidgets | ||
Context not available. | |||||
66 | public: | 68 | public: | ||
67 | ListerTextArea(Lister *lister, QWidget *parent); | 69 | ListerTextArea(Lister *lister, QWidget *parent); | ||
68 | void reset(); | 70 | void reset(); | ||
69 | void calculateText(bool forcedUpdate = false); | 71 | void calculateText(const bool forcedUpdate = false); | ||
70 | void redrawTextArea(bool forcedUpdate = false); | 72 | void redrawTextArea(const bool forcedUpdate = false); | ||
71 | 73 | | |||
72 | qint64 textToFilePosition(int x, int y, bool &isfirst); | 74 | qint64 textToFilePositionOnScreen(const int x, const int y, bool &isfirst); | ||
73 | void fileToTextPosition(qint64 p, bool isfirst, int &x, int &y); | 75 | void fileToTextPositionOnScreen(const qint64 p, const bool isfirst, int &x, int &y); | ||
74 | 76 | | |||
75 | QTextCodec * codec(); | | |||
76 | int tabWidth() { | 77 | int tabWidth() { | ||
77 | return _tabWidth; | 78 | return _tabWidth; | ||
78 | } | 79 | } | ||
79 | bool hexMode() { | 80 | bool hexMode() { | ||
80 | return _hexMode; | 81 | return _hexMode; | ||
81 | } | 82 | } | ||
82 | void setHexMode(bool hexMode); | 83 | void setHexMode(const bool hexMode); | ||
83 | 84 | | |||
84 | void copySelectedToClipboard(); | 85 | void copySelectedToClipboard(); | ||
85 | QString getSelectedText(); | 86 | QString getSelectedText(); | ||
Context not available. | |||||
90 | qint64 getCursorAnchor() { | 91 | qint64 getCursorAnchor() { | ||
91 | return _cursorAnchorPos; | 92 | return _cursorAnchorPos; | ||
92 | } | 93 | } | ||
93 | void setCursorPosition(qint64 p, bool isfirst); | 94 | void setCursorPositionInDocument(const qint64 p, const bool isfirst); | ||
94 | void ensureVisibleCursor(); | 95 | void ensureVisibleCursor(); | ||
95 | void deleteAnchor() { | 96 | void deleteAnchor() { | ||
96 | _cursorAnchorPos = -1; | 97 | _cursorAnchorPos = -1; | ||
97 | } | 98 | } | ||
98 | 99 | | |||
99 | void setAnchorAndCursor(qint64 anchor, qint64 cursor); | 100 | void setAnchorAndCursor(const qint64 anchor, const qint64 cursor); | ||
100 | void sizeChanged(); | 101 | void sizeChanged(); | ||
101 | 102 | | |||
102 | protected: | 103 | protected: | ||
Context not available. | |||||
107 | virtual void mouseMoveEvent(QMouseEvent * e) Q_DECL_OVERRIDE; | 108 | virtual void mouseMoveEvent(QMouseEvent * e) Q_DECL_OVERRIDE; | ||
108 | virtual void wheelEvent(QWheelEvent * event) Q_DECL_OVERRIDE; | 109 | virtual void wheelEvent(QWheelEvent * event) Q_DECL_OVERRIDE; | ||
109 | 110 | | |||
110 | QStringList readLines(qint64 filePos, qint64 &endPos, int lines, QList<qint64> * locs = 0); | 111 | QStringList readLines(const qint64 filePos, qint64 &endPos, const int lines, QList<qint64> * locs = 0); | ||
111 | QString readSection(qint64 p1, qint64 p2); | 112 | QString readSection(qint64 p1, qint64 p2); | ||
112 | void setUpScrollBar(); | 113 | void setUpScrollBar(); | ||
113 | void setCursorPosition(int x, int y, int anchorX = -1, int anchorY = -1); | 114 | void setCursorPositionOnScreen(const int x, const int y, const int anchorX = -1, const int anchorY = -1); | ||
114 | void handleAnchorChange(int oldAnchor); | 115 | void handleAnchorChange(const int oldAnchor); | ||
115 | void performAnchorChange(int anchor); | 116 | void performAnchorChange(const int anchor); | ||
116 | void getScreenPosition(int position, int &x, int &y); | 117 | void getScreenPosition(const int position, int &x, int &y); | ||
117 | 118 | | |||
118 | protected slots: | 119 | protected slots: | ||
119 | void slotActionTriggered(int action); | 120 | void slotActionTriggered(const int action); | ||
120 | void slotCursorPositionChanged(); | 121 | void slotCursorPositionChanged(); | ||
121 | void blinkCursor(); | 122 | void zoomIn(const int range = 1); | ||
122 | void zoomIn(int range = 1); | 123 | void zoomOut(const int range = 1); | ||
123 | void zoomOut(int range = 1); | | |||
124 | 124 | | |||
125 | protected: | 125 | protected: | ||
126 | Lister *_lister; | 126 | Lister *_lister; | ||
127 | 127 | | |||
128 | qint64 _screenStartPos; | 128 | qint64 _screenStartPos = 0; | ||
129 | qint64 _screenEndPos; | 129 | qint64 _screenEndPos = 0; | ||
130 | qint64 _averagePageSize; | 130 | qint64 _averagePageSize = 0; | ||
131 | 131 | | |||
132 | qint64 _lastPageStartPos; | 132 | qint64 _lastPageStartPos = 0; | ||
133 | 133 | | |||
134 | int _sizeX; | 134 | int _sizeX = -1; | ||
135 | int _sizeY; | 135 | int _sizeY = -1; | ||
136 | int _pageSize; | 136 | int _pageSize = 0; | ||
137 | 137 | | |||
138 | int _tabWidth; | 138 | int _tabWidth = 4; | ||
139 | 139 | | |||
140 | bool _sizeChanged; | 140 | bool _sizeChanged = false; | ||
141 | 141 | | |||
142 | QStringList _rowContent; | 142 | QStringList _rowContent; | ||
143 | QList<qint64> _rowStarts; | 143 | QList<qint64> _rowStarts; | ||
144 | 144 | | |||
145 | qint64 _cursorPos; | 145 | qint64 _cursorPos = -1; | ||
146 | bool _cursorAtFirstColumn; | 146 | bool _cursorAtFirstColumn = true; | ||
147 | bool _skipCursorChangedListener = false; | ||||
147 | 148 | | |||
148 | qint64 _cursorAnchorPos; | 149 | qint64 _cursorAnchorPos = -1; | ||
149 | 150 | | |||
150 | int _skippedLines; | 151 | int _skippedLines = 0; | ||
151 | 152 | | |||
152 | bool _inSliderOp; | 153 | bool _inSliderOp = false; | ||
153 | bool _inCursorUpdate; | 154 | bool _hexMode = false; | ||
154 | bool _hexMode; | 155 | bool _redrawing = false; | ||
155 | 156 | | |||
156 | bool _cursorState = false; | 157 | QMutex _cursorBlinkMutex; | ||
158 | QTimer _blinkTimer; | ||||
157 | }; | 159 | }; | ||
158 | 160 | | |||
159 | class ListerBrowserExtension : public KParts::BrowserExtension | 161 | class ListerBrowserExtension : public KParts::BrowserExtension | ||
Context not available. | |||||
194 | 196 | | |||
195 | public: | 197 | public: | ||
196 | explicit Lister(QWidget *parent); | 198 | explicit Lister(QWidget *parent); | ||
197 | ~Lister(); | | |||
198 | 199 | | |||
199 | QScrollBar *scrollBar() { | 200 | QScrollBar *scrollBar() { | ||
200 | return _scrollBar; | 201 | return _scrollBar; | ||
Context not available. | |||||
206 | inline qint64 fileSize() { | 207 | inline qint64 fileSize() { | ||
207 | return _fileSize; | 208 | return _fileSize; | ||
208 | } | 209 | } | ||
209 | char * cacheRef(qint64 filePos, int &size); | 210 | QByteArray cacheChunk(const qint64 filePos, const int maxSize); | ||
210 | 211 | | |||
211 | bool isSearchEnabled(); | 212 | bool isSearchEnabled(); | ||
212 | void enableSearch(bool); | 213 | void enableSearch(const bool); | ||
213 | void enableActions(bool); | 214 | void enableActions(const bool); | ||
214 | 215 | | |||
215 | QString characterSet() { | 216 | QString characterSet() { return _characterSet; } | ||
216 | return _characterSet; | 217 | QTextCodec *codec() { return _codec; } | ||
217 | } | 218 | void setCharacterSet(const QString set); | ||
218 | void setCharacterSet(QString set); | 219 | void setHexMode(const bool); | ||
219 | void setHexMode(bool); | | |||
220 | 220 | | |||
221 | QStringList readHexLines(qint64 &filePos, qint64 endPos, int columns, int lines); | 221 | QStringList readHexLines(qint64 &filePos, const qint64 endPos, const int columns, const int lines); | ||
222 | int hexBytesPerLine(int columns); | 222 | int hexBytesPerLine(const int columns); | ||
223 | int hexPositionDigits(); | 223 | int hexPositionDigits(); | ||
224 | int hexIndexToPosition(int columns, int index); | 224 | int hexIndexToPosition(const int columns, const int index); | ||
225 | int hexPositionToIndex(int columns, int position); | 225 | int hexPositionToIndex(const int columns, const int position); | ||
226 | 226 | | |||
227 | 227 | | |||
228 | public slots: | 228 | public slots: | ||
Context not available. | |||||
237 | void saveSelected(); | 237 | void saveSelected(); | ||
238 | void print(); | 238 | void print(); | ||
239 | void toggleHexMode(); | 239 | void toggleHexMode(); | ||
240 | void slotUpdate(); | ||||
240 | 241 | | |||
241 | protected slots: | 242 | protected slots: | ||
242 | void slotUpdate(); | | |||
243 | void slotSearchMore(); | 243 | void slotSearchMore(); | ||
244 | 244 | | |||
245 | void searchSucceeded(); | 245 | void searchSucceeded(); | ||
246 | void searchFailed(); | 246 | void searchFailed(); | ||
247 | void searchTextChanged(); | 247 | void searchTextChanged(); | ||
248 | 248 | | |||
249 | void slotFileDataReceived(KIO::Job *, const QByteArray &); | | |||
250 | void slotFileFinished(KJob *); | | |||
251 | | ||||
252 | void slotDataSend(KIO::Job *, QByteArray &); | 249 | void slotDataSend(KIO::Job *, QByteArray &); | ||
253 | void slotSendFinished(KJob *); | 250 | void slotSendFinished(KJob *); | ||
254 | 251 | | |||
Context not available. | |||||
261 | return true; | 258 | return true; | ||
262 | } | 259 | } | ||
263 | virtual void guiActivateEvent(KParts::GUIActivateEvent * event) Q_DECL_OVERRIDE; | 260 | virtual void guiActivateEvent(KParts::GUIActivateEvent * event) Q_DECL_OVERRIDE; | ||
264 | void setColor(bool match, bool restore); | 261 | void setColor(const bool match, const bool restore); | ||
265 | void hideProgressBar(); | 262 | void hideProgressBar(); | ||
266 | void updateProgressBar(); | 263 | void updateProgressBar(); | ||
267 | void resetSearchPosition(); | 264 | void resetSearchPosition(); | ||
268 | 265 | | |||
269 | qint64 getFileSize(); | 266 | qint64 getFileSize(); | ||
270 | void search(bool forward, bool restart = false); | 267 | void search(const bool forward, const bool restart = false); | ||
271 | QStringList readLines(qint64 &filePos, qint64 endPos, int columns, int lines); | 268 | QStringList readLines(qint64 &filePos, const qint64 endPos, const int columns, const int lines); | ||
272 | 269 | | |||
273 | QTimer _updateTimer; | 270 | QTimer _searchUpdateTimer; | ||
274 | ListerTextArea *_textArea; | 271 | ListerTextArea *_textArea; | ||
275 | QScrollBar *_scrollBar; | 272 | QScrollBar *_scrollBar; | ||
276 | QLabel *_listerLabel; | 273 | QLabel *_listerLabel; | ||
Context not available. | |||||
279 | QToolButton *_searchStopButton; | 276 | QToolButton *_searchStopButton; | ||
280 | QPushButton *_searchNextButton; | 277 | QPushButton *_searchNextButton; | ||
281 | QPushButton *_searchPrevButton; | 278 | QPushButton *_searchPrevButton; | ||
282 | bool _searchInProgress; | 279 | bool _searchInProgress = false; | ||
283 | bool _searchHexadecimal; | 280 | bool _searchHexadecimal = false; | ||
284 | QPushButton *_searchOptions; | 281 | QPushButton *_searchOptions; | ||
285 | QLabel *_statusLabel; | 282 | QLabel *_statusLabel; | ||
286 | 283 | | |||
Context not available. | |||||
290 | QAction *_regExpAction; | 287 | QAction *_regExpAction; | ||
291 | QAction *_hexAction; | 288 | QAction *_hexAction; | ||
292 | 289 | | |||
293 | QAction *_actionSaveSelected; | 290 | QAction *_actionSaveSelected; | ||
294 | QAction *_actionSaveAs; | 291 | QAction *_actionSaveAs; | ||
295 | QAction *_actionPrint; | 292 | QAction *_actionPrint; | ||
296 | QAction *_actionSearch; | 293 | QAction *_actionSearch; | ||
297 | QAction *_actionSearchNext; | 294 | QAction *_actionSearchNext; | ||
298 | QAction *_actionSearchPrev; | 295 | QAction *_actionSearchPrev; | ||
299 | QAction *_actionJumpToPosition; | 296 | QAction *_actionJumpToPosition; | ||
300 | QAction *_actionHexMode; | 297 | QAction *_actionHexMode; | ||
301 | ListerEncodingMenu *_actionEncoding; | | |||
302 | 298 | | |||
303 | QString _filePath; | 299 | QString _filePath; | ||
304 | qint64 _fileSize; | 300 | qint64 _fileSize = 0; | ||
305 | | ||||
306 | char *_cache; | | |||
307 | int _cacheSize; | | |||
308 | qint64 _cachePos; | | |||
309 | 301 | | |||
310 | bool _active; | 302 | QByteArray _cache; | ||
303 | qint64 _cachePos = 0; | ||||
311 | 304 | | |||
312 | KRQuery _searchQuery; | 305 | KRQuery _searchQuery; | ||
313 | QByteArray _searchHexQuery; | 306 | QByteArray _searchHexQuery; | ||
314 | qint64 _searchPosition; | 307 | qint64 _searchPosition = 0; | ||
315 | bool _searchIsForward; | 308 | bool _searchIsForward = true; | ||
316 | qint64 _searchLastFailedPosition; | 309 | qint64 _searchLastFailedPosition = -1; | ||
317 | int _searchProgressCounter; | 310 | int _searchProgressCounter = 0; | ||
318 | 311 | | |||
319 | QColor _originalBackground; | 312 | QColor _originalBackground; | ||
320 | QColor _originalForeground; | 313 | QColor _originalForeground; | ||
321 | 314 | | |||
322 | QString _characterSet; | 315 | QString _characterSet; | ||
316 | QTextCodec *_codec = QTextCodec::codecForLocale(); | ||||
323 | 317 | | |||
324 | QTemporaryFile *_tempFile; | 318 | QTemporaryFile *_tempFile = 0; | ||
325 | 319 | | |||
326 | bool _downloading; | 320 | bool _downloading = false; | ||
327 | bool _restartFromBeginning; | 321 | bool _restartFromBeginning = false; | ||
322 | QTimer _downloadUpdateTimer; | ||||
328 | 323 | | |||
329 | qint64 _savePosition; | 324 | qint64 _savePosition = 0; | ||
330 | qint64 _saveEnd; | 325 | qint64 _saveEnd = 0; | ||
331 | }; | 326 | }; | ||
332 | 327 | | |||
333 | #endif // __LISTER_H__ | 328 | #endif // __LISTER_H__ | ||
Context not available. |