Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewhelpers.h
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries | ||
---|---|---|---|---|---|
2 | Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org> | 2 | Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org> | ||
3 | Copyright (C) 2001 Anders Lund <anders@alweb.dk> | 3 | Copyright (C) 2001 Anders Lund <anders@alweb.dk> | ||
4 | Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> | 4 | Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> | ||
5 | Copyright 2017-2018 Friedrich W. H. Kossebau <kossebau@kde.org> | ||||
5 | 6 | | |||
6 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or | ||
7 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public | ||
8 | License version 2 as published by the Free Software Foundation. | 9 | License version 2 as published by the Free Software Foundation. | ||
9 | 10 | | |||
10 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Show All 26 Lines | |||||
39 | #include <ktexteditor/message.h> | 40 | #include <ktexteditor/message.h> | ||
40 | #include <ktexteditor/cursor.h> | 41 | #include <ktexteditor/cursor.h> | ||
41 | #include <ktexteditor_export.h> | 42 | #include <ktexteditor_export.h> | ||
42 | #include "katetextline.h" | 43 | #include "katetextline.h" | ||
43 | 44 | | |||
44 | namespace KTextEditor { class DocumentPrivate; } | 45 | namespace KTextEditor { class DocumentPrivate; } | ||
45 | namespace KTextEditor { class ViewPrivate; } | 46 | namespace KTextEditor { class ViewPrivate; } | ||
46 | class KateViewInternal; | 47 | class KateViewInternal; | ||
48 | class KateTextLayout; | ||||
47 | 49 | | |||
48 | #define MAXFOLDINGCOLORS 16 | 50 | #define MAXFOLDINGCOLORS 16 | ||
49 | 51 | | |||
50 | class KateLineInfo; | 52 | class KateLineInfo; | ||
51 | class KateTextPreview; | 53 | class KateTextPreview; | ||
52 | 54 | | |||
53 | namespace KTextEditor | 55 | namespace KTextEditor | ||
54 | { | 56 | { | ||
55 | class Command; | 57 | class Command; | ||
56 | class AnnotationModel; | 58 | class AnnotationModel; | ||
57 | class MovingRange; | 59 | class MovingRange; | ||
60 | class AbstractAnnotationItemDelegate; | ||||
61 | class StyleOptionAnnotationItem; | ||||
58 | } | 62 | } | ||
59 | 63 | | |||
60 | class QTimer; | 64 | class QTimer; | ||
61 | class QVBoxLayout; | 65 | class QVBoxLayout; | ||
62 | 66 | | |||
63 | /** | 67 | /** | ||
64 | * Class to layout KTextEditor::Message%s in KateView. Only the floating | 68 | * Class to layout KTextEditor::Message%s in KateView. Only the floating | ||
65 | * positions TopInView, CenterInView, and BottomInView are supported. | 69 | * positions TopInView, CenterInView, and BottomInView are supported. | ||
▲ Show 20 Lines • Show All 218 Lines • ▼ Show 20 Line(s) | 287 | { | |||
284 | return m_annotationBorderOn; | 288 | return m_annotationBorderOn; | ||
285 | } | 289 | } | ||
286 | 290 | | |||
287 | void updateForCursorLineChange(); | 291 | void updateForCursorLineChange(); | ||
288 | 292 | | |||
289 | enum BorderArea { None, LineNumbers, IconBorder, FoldingMarkers, AnnotationBorder, ModificationBorder }; | 293 | enum BorderArea { None, LineNumbers, IconBorder, FoldingMarkers, AnnotationBorder, ModificationBorder }; | ||
290 | BorderArea positionToArea(const QPoint &) const; | 294 | BorderArea positionToArea(const QPoint &) const; | ||
291 | 295 | | |||
296 | KTextEditor::AbstractAnnotationItemDelegate* annotationItemDelegate() const; | ||||
297 | void setAnnotationItemDelegate(KTextEditor::AbstractAnnotationItemDelegate *delegate); | ||||
298 | inline bool uniformAnnotationItemSizes() const | ||||
299 | { | ||||
300 | return m_hasUniformAnnotationItemSizes; | ||||
301 | } | ||||
302 | inline void setAnnotationUniformItemSizes(bool enable) | ||||
303 | { | ||||
304 | m_hasUniformAnnotationItemSizes = enable; | ||||
305 | } | ||||
306 | | ||||
292 | public Q_SLOTS: | 307 | public Q_SLOTS: | ||
293 | void updateAnnotationBorderWidth(); | 308 | void updateAnnotationBorderWidth(); | ||
294 | void updateAnnotationLine(int line); | 309 | void updateAnnotationLine(int line); | ||
295 | void annotationModelChanged(KTextEditor::AnnotationModel *oldmodel, KTextEditor::AnnotationModel *newmodel); | 310 | void annotationModelChanged(KTextEditor::AnnotationModel *oldmodel, KTextEditor::AnnotationModel *newmodel); | ||
296 | void displayRangeChanged(); | 311 | void displayRangeChanged(); | ||
297 | 312 | | |||
298 | private: | 313 | private: | ||
299 | void paintEvent(QPaintEvent *) override; | 314 | void paintEvent(QPaintEvent *) override; | ||
300 | void paintBorder(int x, int y, int width, int height); | 315 | void paintBorder(int x, int y, int width, int height); | ||
301 | 316 | | |||
302 | void mousePressEvent(QMouseEvent *) override; | 317 | void mousePressEvent(QMouseEvent *) override; | ||
303 | void mouseMoveEvent(QMouseEvent *) override; | 318 | void mouseMoveEvent(QMouseEvent *) override; | ||
304 | void mouseReleaseEvent(QMouseEvent *) override; | 319 | void mouseReleaseEvent(QMouseEvent *) override; | ||
305 | void mouseDoubleClickEvent(QMouseEvent *) override; | 320 | void mouseDoubleClickEvent(QMouseEvent *) override; | ||
306 | void leaveEvent(QEvent *event) override; | 321 | void leaveEvent(QEvent *event) override; | ||
307 | void wheelEvent(QWheelEvent *e) override; | 322 | void wheelEvent(QWheelEvent *e) override; | ||
308 | 323 | | |||
309 | void showMarkMenu(uint line, const QPoint &pos); | 324 | void showMarkMenu(uint line, const QPoint &pos); | ||
310 | 325 | | |||
311 | void showAnnotationTooltip(int line, const QPoint &pos); | | |||
312 | void hideAnnotationTooltip(); | 326 | void hideAnnotationTooltip(); | ||
313 | void removeAnnotationHovering(); | 327 | void removeAnnotationHovering(); | ||
314 | void showAnnotationMenu(int line, const QPoint &pos); | 328 | void showAnnotationMenu(int line, const QPoint &pos); | ||
315 | int annotationLineWidth(int line); | 329 | void calcAnnotationBorderWidth(); | ||
330 | | ||||
331 | void initStyleOption(KTextEditor::StyleOptionAnnotationItem *styleOption) const; | ||||
332 | void setStyleOptionLineData(KTextEditor::StyleOptionAnnotationItem *styleOption, | ||||
333 | int y, | ||||
334 | int realLine, | ||||
335 | const KTextEditor::AnnotationModel *model, | ||||
336 | const QString &annotationGroupIdentifier) const; | ||||
337 | QRect annotationLineRectInView(int line) const; | ||||
316 | 338 | | |||
339 | private: | ||||
317 | KTextEditor::ViewPrivate *m_view; | 340 | KTextEditor::ViewPrivate *m_view; | ||
318 | KTextEditor::DocumentPrivate *m_doc; | 341 | KTextEditor::DocumentPrivate *m_doc; | ||
319 | KateViewInternal *m_viewInternal; | 342 | KateViewInternal *m_viewInternal; | ||
320 | 343 | | |||
321 | bool m_iconBorderOn: 1; | 344 | bool m_iconBorderOn: 1; | ||
322 | bool m_lineNumbersOn: 1; | 345 | bool m_lineNumbersOn: 1; | ||
323 | bool m_relLineNumbersOn:1; | 346 | bool m_relLineNumbersOn:1; | ||
324 | bool m_updateRelLineNumbers:1; | 347 | bool m_updateRelLineNumbers:1; | ||
325 | bool m_foldingMarkersOn: 1; | 348 | bool m_foldingMarkersOn: 1; | ||
326 | bool m_dynWrapIndicatorsOn: 1; | 349 | bool m_dynWrapIndicatorsOn: 1; | ||
327 | bool m_annotationBorderOn: 1; | 350 | bool m_annotationBorderOn: 1; | ||
328 | int m_dynWrapIndicators; | 351 | int m_dynWrapIndicators; | ||
329 | 352 | | |||
330 | int m_lastClickedLine; | 353 | int m_lastClickedLine; | ||
331 | 354 | | |||
332 | int m_cachedLNWidth; | 355 | int m_cachedLNWidth; | ||
333 | 356 | | |||
334 | qreal m_maxCharWidth; | 357 | qreal m_maxCharWidth; | ||
335 | int iconPaneWidth; | 358 | int iconPaneWidth; | ||
336 | int m_annotationBorderWidth; | 359 | int m_annotationBorderWidth; | ||
337 | 360 | | |||
361 | KTextEditor::AbstractAnnotationItemDelegate *m_annotationItemDelegate; | ||||
362 | bool m_hasUniformAnnotationItemSizes = false; | ||||
363 | bool m_isDefaultAnnotationItemDelegate = true; | ||||
dhaumann: I would prefer in-class member initialization here for the bools. | |||||
364 | | ||||
338 | mutable QPixmap m_arrow; | 365 | mutable QPixmap m_arrow; | ||
339 | mutable QColor m_oldBackgroundColor; | 366 | mutable QColor m_oldBackgroundColor; | ||
340 | 367 | | |||
341 | QPointer<KateTextPreview> m_foldingPreview; | 368 | QPointer<KateTextPreview> m_foldingPreview; | ||
342 | KTextEditor::MovingRange *m_foldingRange; | 369 | KTextEditor::MovingRange *m_foldingRange; | ||
343 | int m_nextHighlightBlock; | 370 | int m_nextHighlightBlock; | ||
344 | int m_currentBlockLine; | 371 | int m_currentBlockLine; | ||
345 | QTimer m_delayFoldingHlTimer; | 372 | QTimer m_delayFoldingHlTimer; | ||
346 | void showDelayedBlock(int line); | 373 | void showDelayedBlock(int line); | ||
347 | void hideBlock(); | 374 | void hideBlock(); | ||
348 | 375 | | |||
349 | private Q_SLOTS: | 376 | private Q_SLOTS: | ||
350 | void showBlock(); | 377 | void showBlock(); | ||
378 | void handleDestroyedAnnotationItemDelegate(); | ||||
351 | 379 | | |||
352 | private: | 380 | private: | ||
353 | QString m_hoveredAnnotationGroupIdentifier; | 381 | QString m_hoveredAnnotationGroupIdentifier; | ||
354 | 382 | | |||
355 | void initializeFoldingColors(); | 383 | void initializeFoldingColors(); | ||
356 | }; | 384 | }; | ||
357 | 385 | | |||
358 | class KateViewEncodingAction: public KSelectAction | 386 | class KateViewEncodingAction: public KSelectAction | ||
▲ Show 20 Lines • Show All 276 Lines • Show Last 20 Lines |
I would prefer in-class member initialization here for the bools.