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; | ||
Context not available. | |||||
144 | 144 | | |||
145 | qint64 _cursorPos; | 145 | qint64 _cursorPos; | ||
146 | bool _cursorAtFirstColumn; | 146 | bool _cursorAtFirstColumn; | ||
147 | bool _skipCursorChangedListener = false; | ||||
147 | 148 | | |||
148 | qint64 _cursorAnchorPos; | 149 | qint64 _cursorAnchorPos; | ||
149 | 150 | | |||
150 | int _skippedLines; | 151 | int _skippedLines; | ||
151 | 152 | | |||
152 | bool _inSliderOp; | 153 | bool _inSliderOp; | ||
153 | bool _inCursorUpdate; | | |||
154 | bool _hexMode; | 154 | bool _hexMode; | ||
155 | 155 | | |||
156 | bool _cursorState = false; | 156 | QMutex _cursorBlinkMutex; | ||
157 | QTimer *_blinkTimer = 0; | ||||
157 | }; | 158 | }; | ||
158 | 159 | | |||
159 | class ListerBrowserExtension : public KParts::BrowserExtension | 160 | class ListerBrowserExtension : public KParts::BrowserExtension | ||
Context not available. | |||||
194 | 195 | | |||
195 | public: | 196 | public: | ||
196 | explicit Lister(QWidget *parent); | 197 | explicit Lister(QWidget *parent); | ||
197 | ~Lister(); | | |||
198 | 198 | | |||
199 | QScrollBar *scrollBar() { | 199 | QScrollBar *scrollBar() { | ||
200 | return _scrollBar; | 200 | return _scrollBar; | ||
Context not available. | |||||
206 | inline qint64 fileSize() { | 206 | inline qint64 fileSize() { | ||
207 | return _fileSize; | 207 | return _fileSize; | ||
208 | } | 208 | } | ||
209 | char * cacheRef(qint64 filePos, int &size); | 209 | QByteArray cacheChunk(const qint64 filePos, int &size); | ||
210 | 210 | | |||
211 | bool isSearchEnabled(); | 211 | bool isSearchEnabled(); | ||
212 | void enableSearch(bool); | 212 | void enableSearch(const bool); | ||
213 | void enableActions(bool); | 213 | void enableActions(const bool); | ||
214 | 214 | | |||
215 | QString characterSet() { | 215 | QString characterSet() { return _characterSet; } | ||
216 | return _characterSet; | 216 | QTextCodec *codec() { return _codec; } | ||
217 | } | 217 | void setCharacterSet(const QString set); | ||
218 | void setCharacterSet(QString set); | 218 | void setHexMode(const bool); | ||
219 | void setHexMode(bool); | | |||
220 | 219 | | |||
221 | QStringList readHexLines(qint64 &filePos, qint64 endPos, int columns, int lines); | 220 | QStringList readHexLines(qint64 &filePos, const qint64 endPos, const int columns, const int lines); | ||
222 | int hexBytesPerLine(int columns); | 221 | int hexBytesPerLine(const int columns); | ||
223 | int hexPositionDigits(); | 222 | int hexPositionDigits(); | ||
224 | int hexIndexToPosition(int columns, int index); | 223 | int hexIndexToPosition(const int columns, const int index); | ||
225 | int hexPositionToIndex(int columns, int position); | 224 | int hexPositionToIndex(const int columns, const int position); | ||
226 | 225 | | |||
227 | 226 | | |||
228 | public slots: | 227 | public slots: | ||
Context not available. | |||||
237 | void saveSelected(); | 236 | void saveSelected(); | ||
238 | void print(); | 237 | void print(); | ||
239 | void toggleHexMode(); | 238 | void toggleHexMode(); | ||
239 | void slotUpdate(); | ||||
240 | 240 | | |||
241 | protected slots: | 241 | protected slots: | ||
242 | void slotUpdate(); | | |||
243 | void slotSearchMore(); | 242 | void slotSearchMore(); | ||
244 | 243 | | |||
245 | void searchSucceeded(); | 244 | void searchSucceeded(); | ||
246 | void searchFailed(); | 245 | void searchFailed(); | ||
247 | void searchTextChanged(); | 246 | void searchTextChanged(); | ||
248 | 247 | | |||
249 | void slotFileDataReceived(KIO::Job *, const QByteArray &); | | |||
250 | void slotFileFinished(KJob *); | | |||
251 | | ||||
252 | void slotDataSend(KIO::Job *, QByteArray &); | 248 | void slotDataSend(KIO::Job *, QByteArray &); | ||
253 | void slotSendFinished(KJob *); | 249 | void slotSendFinished(KJob *); | ||
254 | 250 | | |||
Context not available. | |||||
261 | return true; | 257 | return true; | ||
262 | } | 258 | } | ||
263 | virtual void guiActivateEvent(KParts::GUIActivateEvent * event) Q_DECL_OVERRIDE; | 259 | virtual void guiActivateEvent(KParts::GUIActivateEvent * event) Q_DECL_OVERRIDE; | ||
264 | void setColor(bool match, bool restore); | 260 | void setColor(const bool match, const bool restore); | ||
265 | void hideProgressBar(); | 261 | void hideProgressBar(); | ||
266 | void updateProgressBar(); | 262 | void updateProgressBar(); | ||
267 | void resetSearchPosition(); | 263 | void resetSearchPosition(); | ||
268 | 264 | | |||
269 | qint64 getFileSize(); | 265 | qint64 getFileSize(); | ||
270 | void search(bool forward, bool restart = false); | 266 | void search(const bool forward, const bool restart = false); | ||
271 | QStringList readLines(qint64 &filePos, qint64 endPos, int columns, int lines); | 267 | QStringList readLines(qint64 &filePos, const qint64 endPos, const int columns, const int lines); | ||
272 | 268 | | |||
273 | QTimer _updateTimer; | 269 | QTimer _searchUpdateTimer; | ||
274 | ListerTextArea *_textArea; | 270 | ListerTextArea *_textArea; | ||
275 | QScrollBar *_scrollBar; | 271 | QScrollBar *_scrollBar; | ||
276 | QLabel *_listerLabel; | 272 | QLabel *_listerLabel; | ||
Context not available. | |||||
303 | QString _filePath; | 299 | QString _filePath; | ||
304 | qint64 _fileSize; | 300 | qint64 _fileSize; | ||
305 | 301 | | |||
306 | char *_cache; | 302 | QByteArray _cache; | ||
307 | int _cacheSize; | | |||
308 | qint64 _cachePos; | 303 | qint64 _cachePos; | ||
309 | 304 | | |||
310 | bool _active; | | |||
311 | | ||||
312 | KRQuery _searchQuery; | 305 | KRQuery _searchQuery; | ||
313 | QByteArray _searchHexQuery; | 306 | QByteArray _searchHexQuery; | ||
314 | qint64 _searchPosition; | 307 | qint64 _searchPosition; | ||
Context not available. | |||||
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; | ||
325 | 319 | | |||
Context not available. |