Changeset View
Changeset View
Standalone View
Standalone View
src/lib/defaulthighlighter.cpp
Show All 15 Lines | 1 | /* | |||
---|---|---|---|---|---|
16 | 16 | | |||
17 | --- | 17 | --- | ||
18 | Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com> | 18 | Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com> | ||
19 | Copyright (C) 2006 David Saxton <david@bluehaze.org> | 19 | Copyright (C) 2006 David Saxton <david@bluehaze.org> | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "defaulthighlighter.h" | 22 | #include "defaulthighlighter.h" | ||
23 | 23 | | |||
24 | #include "defaultvariablemodel.h" | ||||
25 | #include "session.h" | ||||
26 | | ||||
24 | #include <QApplication> | 27 | #include <QApplication> | ||
25 | #include <QLocale> | 28 | #include <QLocale> | ||
26 | #include <QTextDocument> | 29 | #include <QTextDocument> | ||
27 | #include <QTextCursor> | 30 | #include <QTextCursor> | ||
28 | #include <QGraphicsTextItem> | 31 | #include <QGraphicsTextItem> | ||
29 | #include <KColorScheme> | 32 | #include <KColorScheme> | ||
30 | #include <QDebug> | 33 | #include <QDebug> | ||
31 | #include <QStack> | 34 | #include <QStack> | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 89 | { | |||
93 | addPair(QLatin1Char('['), QLatin1Char(']')); | 96 | addPair(QLatin1Char('['), QLatin1Char(']')); | ||
94 | addPair(QLatin1Char('{'), QLatin1Char('}')); | 97 | addPair(QLatin1Char('{'), QLatin1Char('}')); | ||
95 | 98 | | |||
96 | updateFormats(); | 99 | updateFormats(); | ||
97 | connect(qApp, &QGuiApplication::paletteChanged, | 100 | connect(qApp, &QGuiApplication::paletteChanged, | ||
98 | this, &DefaultHighlighter::updateFormats); | 101 | this, &DefaultHighlighter::updateFormats); | ||
99 | } | 102 | } | ||
100 | 103 | | |||
104 | DefaultHighlighter::DefaultHighlighter(QObject* parent, Session* session) | ||||
105 | :DefaultHighlighter(parent) | ||||
106 | { | ||||
107 | if (session) | ||||
108 | { | ||||
109 | DefaultVariableModel* model = session->variableModel(); | ||||
110 | if (model) | ||||
111 | { | ||||
112 | connect(model, &DefaultVariableModel::variablesAdded, this, &DefaultHighlighter::addVariables); | ||||
113 | connect(model, &DefaultVariableModel::variablesRemoved, this, &DefaultHighlighter::removeRules); | ||||
114 | connect(model, &DefaultVariableModel::functionsAdded, this, &DefaultHighlighter::addFunctions); | ||||
115 | connect(model, &DefaultVariableModel::functionsRemoved, this, &DefaultHighlighter::removeRules); | ||||
116 | | ||||
117 | addVariables(model->variableNames()); | ||||
118 | addFunctions(model->functions()); | ||||
119 | } | ||||
120 | } | ||||
121 | } | ||||
122 | | ||||
101 | DefaultHighlighter::~DefaultHighlighter() | 123 | DefaultHighlighter::~DefaultHighlighter() | ||
102 | { | 124 | { | ||
103 | delete d; | 125 | delete d; | ||
104 | } | 126 | } | ||
105 | 127 | | |||
106 | void DefaultHighlighter::setTextItem(QGraphicsTextItem* item) | 128 | void DefaultHighlighter::setTextItem(QGraphicsTextItem* item) | ||
107 | { | 129 | { | ||
108 | d->cursor = item->textCursor(); | 130 | d->cursor = item->textCursor(); | ||
▲ Show 20 Lines • Show All 352 Lines • Show Last 20 Lines |