• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/vcs

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • vcs
  • widgets
vcsannotationitemdelegate.h
Go to the documentation of this file.
1 /* This file is part of KDevelop
2  *
3  * Copyright 2017-2018 Friedrich W. H. Kossebau <[email protected]>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA.
19  */
20 
21 #ifndef KDEVPLATFORM_VCSANNOTATIONITEMDELEGATE_H
22 #define KDEVPLATFORM_VCSANNOTATIONITEMDELEGATE_H
23 
24 // KDev
25 #include <vcsrevision.h>
26 // KF
27 #include <KTextEditor/AbstractAnnotationItemDelegate>
28 // Qt
29 #include <QHash>
30 #include <QBrush>
31 
32 namespace KDevelop
33 {
34 class VcsAnnotationLine;
35 
36 class VcsAnnotationItemDelegate : public KTextEditor::AbstractAnnotationItemDelegate
37 {
38  Q_OBJECT
39 
40 public:
41  VcsAnnotationItemDelegate(KTextEditor::View* view, KTextEditor::AnnotationModel* model, QObject* parent);
42  ~VcsAnnotationItemDelegate() override;
43 
44 public: // AbstractAnnotationItemDelegate APO
45  void paint(QPainter* painter, const KTextEditor::StyleOptionAnnotationItem& option,
46  KTextEditor::AnnotationModel* model, int line) const override;
47  QSize sizeHint(const KTextEditor::StyleOptionAnnotationItem& option,
48  KTextEditor::AnnotationModel* model, int line) const override;
49  bool helpEvent(QHelpEvent* event, KTextEditor::View* view,
50  const KTextEditor::StyleOptionAnnotationItem& option,
51  KTextEditor::AnnotationModel *model, int line) override;
52  void hideTooltip(KTextEditor::View *view) override;
53 
54 private:
55  void renderBackground(QPainter* painter,
56  const KTextEditor::StyleOptionAnnotationItem& option,
57  const VcsAnnotationLine& annotationLine) const;
58  void renderMessageAndAge(QPainter* painter,
59  const KTextEditor::StyleOptionAnnotationItem& option,
60  const QRect& messageRect, const QString& messageText,
61  const QRect& ageRect, const QString& ageText) const;
62  void renderAuthor(QPainter* painter,
63  const KTextEditor::StyleOptionAnnotationItem& option,
64  const QRect& authorRect, const QString& authorText) const;
65  void renderHighlight(QPainter* painter,
66  const KTextEditor::StyleOptionAnnotationItem& option) const;
67  void doMessageLineLayout(const KTextEditor::StyleOptionAnnotationItem& option,
68  QRect* messageRect, QRect* ageRect) const;
69  void doAuthorLineLayout(const KTextEditor::StyleOptionAnnotationItem& option,
70  QRect* authorRect) const;
71 
72 protected: // QObject API
73  bool eventFilter(QObject* object, QEvent* event) override;
74 
75 private Q_SLOTS:
76  void resetBackgrounds();
77 
78 private:
79  int widthHintFromViewWidth(int viewWidth) const;
80 
81 private:
82  KTextEditor::AnnotationModel* const m_model;
83 
84  // TODO: make this configurable
85  const int m_maxWidthViewPercent = 25;
86 
87  mutable QHash<VcsRevision, QBrush> m_backgrounds;
88 
89  mutable int m_lastCharBasedWidthHint = 0;
90  mutable int m_lastViewBasedWidthHint = 0;
91 };
92 
93 }
94 
95 #endif
QRect
KDevelop::VcsAnnotationItemDelegate::eventFilter
bool eventFilter(QObject *object, QEvent *event) override
Definition: vcsannotationitemdelegate.cpp:379
QSize
QPainter
KDevelop::VcsAnnotationItemDelegate::~VcsAnnotationItemDelegate
~VcsAnnotationItemDelegate() override
KDevelop::VcsAnnotationItemDelegate::VcsAnnotationItemDelegate
VcsAnnotationItemDelegate(KTextEditor::View *view, KTextEditor::AnnotationModel *model, QObject *parent)
Definition: vcsannotationitemdelegate.cpp:47
QObject
QString
KDevelop::VcsAnnotationItemDelegate::paint
void paint(QPainter *painter, const KTextEditor::StyleOptionAnnotationItem &option, KTextEditor::AnnotationModel *model, int line) const override
Definition: vcsannotationitemdelegate.cpp:249
KDevelop::VcsAnnotationLine
Annotation information for a line of a version controlled file.
Definition: vcsannotation.h:40
KDevelop::VcsAnnotationItemDelegate::sizeHint
QSize sizeHint(const KTextEditor::StyleOptionAnnotationItem &option, KTextEditor::AnnotationModel *model, int line) const override
Definition: vcsannotationitemdelegate.cpp:358
KDevelop::VcsAnnotationItemDelegate::helpEvent
bool helpEvent(QHelpEvent *event, KTextEditor::View *view, const KTextEditor::StyleOptionAnnotationItem &option, KTextEditor::AnnotationModel *model, int line) override
Definition: vcsannotationitemdelegate.cpp:328
QEvent
KDevelop::VcsAnnotationItemDelegate::hideTooltip
void hideTooltip(KTextEditor::View *view) override
Definition: vcsannotationitemdelegate.cpp:352
KDevelop
Definition: dvcsevent.h:33
QHelpEvent
KDevelop::VcsAnnotationItemDelegate
Definition: vcsannotationitemdelegate.h:36
QHash
vcsrevision.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Jan 17 2021 23:36:31 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/vcs

Skip menu "kdevplatform/vcs"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal