blob: 27c8365e19e8180451f4eecadf76f961de9cd158 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "bookmark.h"
#include "bookmarkmanager.h"
#include "bookmarks_global.h"
#include "bookmarkstr.h"
#include <utils/utilsicons.h>
#include <QTextBlock>
using namespace Utils;
namespace Bookmarks::Internal {
Bookmark::Bookmark(int lineNumber, BookmarkManager *manager) :
TextMark(FilePath(), lineNumber, {Tr::tr("Bookmark"), Constants::BOOKMARKS_TEXT_MARK_CATEGORY}),
m_manager(manager)
{
setColor(Theme::Bookmarks_TextMarkColor);
setIcon(Icons::BOOKMARK_TEXTEDITOR.icon());
setDefaultToolTip(Tr::tr("Bookmark"));
setPriority(TextEditor::TextMark::NormalPriority);
}
void Bookmark::removedFromEditor()
{
m_manager->deleteBookmark(this);
}
bool Bookmark::isDraggable() const
{
return true;
}
void Bookmark::dragToLine(int lineNumber)
{
move(lineNumber);
}
void Bookmark::updateLineNumber(int line)
{
if (line != lineNumber()) {
TextMark::updateLineNumber(line);
m_manager->updateBookmark(this);
}
}
void Bookmark::move(int line)
{
if (line != lineNumber()) {
TextMark::move(line);
m_manager->updateBookmark(this);
updateMarker();
}
}
void Bookmark::updateBlock(const QTextBlock &block)
{
const QString &lineText = block.text().trimmed();
if (m_lineText != lineText) {
m_lineText = lineText;
m_manager->updateBookmark(this);
}
}
void Bookmark::updateFilePath(const FilePath &filePath)
{
const FilePath oldFilePath = this->filePath();
TextMark::updateFilePath(filePath);
m_manager->updateBookmarkFileName(this, oldFilePath);
}
void Bookmark::setNote(const QString ¬e)
{
setToolTip(note);
setLineAnnotation(note);
updateMarker();
}
void Bookmark::updateNote(const QString ¬e)
{
setNote(note);
m_manager->updateBookmark(this);
}
QString Bookmark::lineText() const
{
return m_lineText;
}
QString Bookmark::note() const
{
return toolTip();
}
} // Bookmarks::Internal
|