forked from qt-creator/qt-creator
Merge ITextMark and BaseTextMark
Turns out we don't even need two-phase initialization, by transparently postponing registration until we get a non-empty file name, either at constuction, or at file name change times. Change-Id: I3e87e47c820066e6707e946fc474ab9c1993e61f Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -37,10 +37,10 @@
|
|||||||
using namespace Bookmarks::Internal;
|
using namespace Bookmarks::Internal;
|
||||||
|
|
||||||
Bookmark::Bookmark(const QString& fileName, int lineNumber, BookmarkManager *manager) :
|
Bookmark::Bookmark(const QString& fileName, int lineNumber, BookmarkManager *manager) :
|
||||||
BaseTextMark(fileName, lineNumber),
|
TextMark(fileName, lineNumber),
|
||||||
m_manager(manager)
|
m_manager(manager)
|
||||||
{
|
{
|
||||||
setPriority(TextEditor::ITextMark::NormalPriority);
|
setPriority(TextEditor::TextMark::NormalPriority);
|
||||||
setIcon(m_manager->bookmarkIcon());
|
setIcon(m_manager->bookmarkIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ void Bookmark::removedFromEditor()
|
|||||||
void Bookmark::updateLineNumber(int line)
|
void Bookmark::updateLineNumber(int line)
|
||||||
{
|
{
|
||||||
if (line != lineNumber()) {
|
if (line != lineNumber()) {
|
||||||
BaseTextMark::updateLineNumber(line);
|
TextMark::updateLineNumber(line);
|
||||||
m_manager->updateBookmark(this);
|
m_manager->updateBookmark(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ void Bookmark::updateLineNumber(int line)
|
|||||||
void Bookmark::move(int line)
|
void Bookmark::move(int line)
|
||||||
{
|
{
|
||||||
if (line != lineNumber()) {
|
if (line != lineNumber()) {
|
||||||
BaseTextMark::move(line);
|
TextMark::move(line);
|
||||||
m_manager->updateBookmark(this);
|
m_manager->updateBookmark(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ void Bookmark::updateBlock(const QTextBlock &block)
|
|||||||
|
|
||||||
void Bookmark::updateFileName(const QString &fileName)
|
void Bookmark::updateFileName(const QString &fileName)
|
||||||
{
|
{
|
||||||
BaseTextMark::updateFileName(fileName);
|
TextMark::updateFileName(fileName);
|
||||||
m_manager->updateBookmark(this);
|
m_manager->updateBookmark(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,15 +30,14 @@
|
|||||||
#ifndef BOOKMARK_H
|
#ifndef BOOKMARK_H
|
||||||
#define BOOKMARK_H
|
#define BOOKMARK_H
|
||||||
|
|
||||||
#include <texteditor/itexteditor.h>
|
#include <texteditor/textmark.h>
|
||||||
#include <texteditor/basetextmark.h>
|
|
||||||
|
|
||||||
namespace Bookmarks {
|
namespace Bookmarks {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class BookmarkManager;
|
class BookmarkManager;
|
||||||
|
|
||||||
class Bookmark : public TextEditor::BaseTextMark
|
class Bookmark : public TextEditor::TextMark
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Bookmark(const QString &fileName, int lineNumber, BookmarkManager *manager);
|
Bookmark(const QString &fileName, int lineNumber, BookmarkManager *manager);
|
||||||
|
@@ -429,9 +429,7 @@ void BookmarkManager::toggleBookmark(const QString &fileName, int lineNumber)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a new bookmark if no bookmark existed on this line
|
// Add a new bookmark if no bookmark existed on this line
|
||||||
Bookmark *bookmark = new Bookmark(fileName, editorLine, this);
|
addBookmark(new Bookmark(fileName, editorLine, this));
|
||||||
bookmark->init();
|
|
||||||
addBookmark(bookmark);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkManager::updateBookmark(Bookmark *bookmark)
|
void BookmarkManager::updateBookmark(Bookmark *bookmark)
|
||||||
@@ -769,7 +767,6 @@ void BookmarkManager::addBookmark(const QString &s)
|
|||||||
if (!filePath.isEmpty() && !findBookmark(filePath, lineNumber)) {
|
if (!filePath.isEmpty() && !findBookmark(filePath, lineNumber)) {
|
||||||
Bookmark *b = new Bookmark(filePath, lineNumber, this);
|
Bookmark *b = new Bookmark(filePath, lineNumber, this);
|
||||||
b->setNote(note);
|
b->setNote(note);
|
||||||
b->init();
|
|
||||||
addBookmark(b, false);
|
addBookmark(b, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -51,7 +51,7 @@ class DeclarationAST;
|
|||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
class BaseTextEditor;
|
class BaseTextEditor;
|
||||||
class ITextMark;
|
class TextMark;
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
@@ -1468,10 +1468,8 @@ void BreakHandler::BreakpointItem::updateMarker(BreakpointModelId id)
|
|||||||
if (marker && (file != marker->fileName() || line != marker->lineNumber()))
|
if (marker && (file != marker->fileName() || line != marker->lineNumber()))
|
||||||
destroyMarker();
|
destroyMarker();
|
||||||
|
|
||||||
if (!marker && !file.isEmpty() && line > 0) {
|
if (!marker && !file.isEmpty() && line > 0)
|
||||||
marker = new BreakpointMarker(id, file, line);
|
marker = new BreakpointMarker(id, file, line);
|
||||||
marker->init();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon BreakHandler::BreakpointItem::icon() const
|
QIcon BreakHandler::BreakpointItem::icon() const
|
||||||
|
@@ -43,10 +43,10 @@ namespace Internal {
|
|||||||
|
|
||||||
BreakpointMarker::BreakpointMarker(BreakpointModelId id,
|
BreakpointMarker::BreakpointMarker(BreakpointModelId id,
|
||||||
const QString &fileName, int lineNumber)
|
const QString &fileName, int lineNumber)
|
||||||
: BaseTextMark(fileName, lineNumber), m_id(id)
|
: TextMark(fileName, lineNumber), m_id(id)
|
||||||
{
|
{
|
||||||
setIcon(breakHandler()->icon(m_id));
|
setIcon(breakHandler()->icon(m_id));
|
||||||
setPriority(TextEditor::ITextMark::NormalPriority);
|
setPriority(TextEditor::TextMark::NormalPriority);
|
||||||
//qDebug() << "CREATE MARKER " << fileName << lineNumber;
|
//qDebug() << "CREATE MARKER " << fileName << lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ void BreakpointMarker::removedFromEditor()
|
|||||||
|
|
||||||
void BreakpointMarker::updateLineNumber(int lineNumber)
|
void BreakpointMarker::updateLineNumber(int lineNumber)
|
||||||
{
|
{
|
||||||
BaseTextMark::updateLineNumber(lineNumber);
|
TextMark::updateLineNumber(lineNumber);
|
||||||
breakHandler()->updateLineNumberFromMarker(m_id, lineNumber);
|
breakHandler()->updateLineNumberFromMarker(m_id, lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ void BreakpointMarker::clicked()
|
|||||||
|
|
||||||
void BreakpointMarker::updateFileName(const QString &fileName)
|
void BreakpointMarker::updateFileName(const QString &fileName)
|
||||||
{
|
{
|
||||||
BaseTextMark::updateFileName(fileName);
|
TextMark::updateFileName(fileName);
|
||||||
breakHandler()->updateFileNameFromMarker(m_id, fileName);
|
breakHandler()->updateFileNameFromMarker(m_id, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,13 +32,13 @@
|
|||||||
|
|
||||||
#include "breakpoint.h"
|
#include "breakpoint.h"
|
||||||
|
|
||||||
#include <texteditor/basetextmark.h>
|
#include <texteditor/textmark.h>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// The red blob on the left side in the cpp editor.
|
// The red blob on the left side in the cpp editor.
|
||||||
class BreakpointMarker : public TextEditor::BaseTextMark
|
class BreakpointMarker : public TextEditor::TextMark
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BreakpointMarker(BreakpointModelId id, const QString &fileName, int lineNumber);
|
BreakpointMarker(BreakpointModelId id, const QString &fileName, int lineNumber);
|
||||||
|
@@ -307,7 +307,7 @@ public:
|
|||||||
|
|
||||||
DisassemblerAgent m_disassemblerAgent;
|
DisassemblerAgent m_disassemblerAgent;
|
||||||
MemoryAgent m_memoryAgent;
|
MemoryAgent m_memoryAgent;
|
||||||
QScopedPointer<TextEditor::BaseTextMark> m_locationMark;
|
QScopedPointer<TextEditor::TextMark> m_locationMark;
|
||||||
QTimer m_locationTimer;
|
QTimer m_locationTimer;
|
||||||
|
|
||||||
bool m_isStateDebugging;
|
bool m_isStateDebugging;
|
||||||
@@ -565,10 +565,9 @@ void DebuggerEngine::gotoLocation(const Location &loc)
|
|||||||
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
||||||
|
|
||||||
if (loc.needsMarker()) {
|
if (loc.needsMarker()) {
|
||||||
d->m_locationMark.reset(new TextEditor::BaseTextMark(file, line));
|
d->m_locationMark.reset(new TextEditor::TextMark(file, line));
|
||||||
d->m_locationMark->setIcon(debuggerCore()->locationMarkIcon());
|
d->m_locationMark->setIcon(debuggerCore()->locationMarkIcon());
|
||||||
d->m_locationMark->setPriority(TextEditor::ITextMark::HighPriority);
|
d->m_locationMark->setPriority(TextEditor::TextMark::HighPriority);
|
||||||
d->m_locationMark->init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << "MEMORY: " << d->m_memoryAgent.hasVisibleEditor();
|
//qDebug() << "MEMORY: " << d->m_memoryAgent.hasVisibleEditor();
|
||||||
|
@@ -103,8 +103,8 @@ public:
|
|||||||
QPointer<BaseTextDocument> document;
|
QPointer<BaseTextDocument> document;
|
||||||
Location location;
|
Location location;
|
||||||
QPointer<DebuggerEngine> engine;
|
QPointer<DebuggerEngine> engine;
|
||||||
ITextMark locationMark;
|
TextMark locationMark;
|
||||||
QList<ITextMark *> breakpointMarks;
|
QList<TextMark *> breakpointMarks;
|
||||||
QList<CacheEntry> cache;
|
QList<CacheEntry> cache;
|
||||||
QString mimeType;
|
QString mimeType;
|
||||||
bool tryMixedInitialized;
|
bool tryMixedInitialized;
|
||||||
@@ -114,14 +114,14 @@ public:
|
|||||||
|
|
||||||
DisassemblerAgentPrivate::DisassemblerAgentPrivate()
|
DisassemblerAgentPrivate::DisassemblerAgentPrivate()
|
||||||
: document(0),
|
: document(0),
|
||||||
locationMark(0),
|
locationMark(QString(), 0),
|
||||||
mimeType(_("text/x-qtcreator-generic-asm")),
|
mimeType(_("text/x-qtcreator-generic-asm")),
|
||||||
tryMixedInitialized(false),
|
tryMixedInitialized(false),
|
||||||
tryMixed(true),
|
tryMixed(true),
|
||||||
resetLocationScheduled(false)
|
resetLocationScheduled(false)
|
||||||
{
|
{
|
||||||
locationMark.setIcon(debuggerCore()->locationMarkIcon());
|
locationMark.setIcon(debuggerCore()->locationMarkIcon());
|
||||||
locationMark.setPriority(TextEditor::ITextMark::HighPriority);
|
locationMark.setPriority(TextEditor::TextMark::HighPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisassemblerAgentPrivate::~DisassemblerAgentPrivate()
|
DisassemblerAgentPrivate::~DisassemblerAgentPrivate()
|
||||||
@@ -353,7 +353,7 @@ void DisassemblerAgent::updateBreakpointMarkers()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const DisassemblerLines contents = d->contentsAtCurrentLocation();
|
const DisassemblerLines contents = d->contentsAtCurrentLocation();
|
||||||
foreach (TextEditor::ITextMark *marker, d->breakpointMarks)
|
foreach (TextEditor::TextMark *marker, d->breakpointMarks)
|
||||||
d->document->removeMark(marker);
|
d->document->removeMark(marker);
|
||||||
qDeleteAll(d->breakpointMarks);
|
qDeleteAll(d->breakpointMarks);
|
||||||
d->breakpointMarks.clear();
|
d->breakpointMarks.clear();
|
||||||
@@ -364,9 +364,9 @@ void DisassemblerAgent::updateBreakpointMarkers()
|
|||||||
const int lineNumber = contents.lineForAddress(address);
|
const int lineNumber = contents.lineForAddress(address);
|
||||||
if (!lineNumber)
|
if (!lineNumber)
|
||||||
continue;
|
continue;
|
||||||
ITextMark *marker = new ITextMark(lineNumber);
|
TextMark *marker = new TextMark(QString(), lineNumber);
|
||||||
marker->setIcon(handler->icon(id));
|
marker->setIcon(handler->icon(id));
|
||||||
marker->setPriority(ITextMark::NormalPriority);
|
marker->setPriority(TextMark::NormalPriority);
|
||||||
d->breakpointMarks.append(marker);
|
d->breakpointMarks.append(marker);
|
||||||
d->document->addMark(marker);
|
d->document->addMark(marker);
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include "stackhandler.h"
|
#include "stackhandler.h"
|
||||||
|
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
#include <texteditor/textmark.h>
|
||||||
|
|
||||||
#include <cppeditor/cppeditorconstants.h>
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
QPointer<TextEditor::BaseTextEditor> editor;
|
QPointer<TextEditor::BaseTextEditor> editor;
|
||||||
QPointer<DebuggerEngine> engine;
|
QPointer<DebuggerEngine> engine;
|
||||||
TextEditor::ITextMark *locationMark;
|
TextEditor::TextMark *locationMark;
|
||||||
QString path;
|
QString path;
|
||||||
QString producer;
|
QString producer;
|
||||||
};
|
};
|
||||||
@@ -140,9 +141,9 @@ void SourceAgent::updateLocationMarker()
|
|||||||
d->locationMark = 0;
|
d->locationMark = 0;
|
||||||
if (d->engine->stackHandler()->currentFrame().file == d->path) {
|
if (d->engine->stackHandler()->currentFrame().file == d->path) {
|
||||||
int lineNumber = d->engine->stackHandler()->currentFrame().line;
|
int lineNumber = d->engine->stackHandler()->currentFrame().line;
|
||||||
d->locationMark = new TextEditor::ITextMark(lineNumber);
|
d->locationMark = new TextEditor::TextMark(QString(), lineNumber);
|
||||||
d->locationMark->setIcon(debuggerCore()->locationMarkIcon());
|
d->locationMark->setIcon(debuggerCore()->locationMarkIcon());
|
||||||
d->locationMark->setPriority(TextEditor::ITextMark::HighPriority);
|
d->locationMark->setPriority(TextEditor::TextMark::HighPriority);
|
||||||
d->editor->baseTextDocument()->addMark(d->locationMark);
|
d->editor->baseTextDocument()->addMark(d->locationMark);
|
||||||
QPlainTextEdit *plainTextEdit = d->editor->editorWidget();
|
QPlainTextEdit *plainTextEdit = d->editor->editorWidget();
|
||||||
QTC_ASSERT(plainTextEdit, return);
|
QTC_ASSERT(plainTextEdit, return);
|
||||||
|
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#include <texteditor/basetextdocumentlayout.h>
|
#include <texteditor/basetextdocumentlayout.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
#include <texteditor/basetextmark.h>
|
#include <texteditor/textmark.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
#include <texteditor/typingsettings.h>
|
#include <texteditor/typingsettings.h>
|
||||||
#include <texteditor/tabsettings.h>
|
#include <texteditor/tabsettings.h>
|
||||||
|
@@ -91,11 +91,11 @@ Task Task::buildConfigurationMissingTask()
|
|||||||
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::addMark(TextEditor::BaseTextMark *mark)
|
void Task::addMark(TextEditor::TextMark *mark)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_mark.isNull(), return);
|
QTC_ASSERT(m_mark.isNull(), return);
|
||||||
|
|
||||||
m_mark = QSharedPointer<TextEditor::BaseTextMark>(mark);
|
m_mark = QSharedPointer<TextEditor::TextMark>(mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Task::isNull() const
|
bool Task::isNull() const
|
||||||
|
@@ -33,11 +33,11 @@
|
|||||||
#include "projectexplorer_export.h"
|
#include "projectexplorer_export.h"
|
||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
#include <texteditor/basetextmark.h>
|
#include <texteditor/textmark.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
|
#include <QIcon>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
|
||||||
#include <QTextLayout>
|
#include <QTextLayout>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
int movedLine; // contains a line number if the line was moved in the editor
|
int movedLine; // contains a line number if the line was moved in the editor
|
||||||
Core::Id category;
|
Core::Id category;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
void addMark(TextEditor::BaseTextMark *mark);
|
void addMark(TextEditor::TextMark *mark);
|
||||||
|
|
||||||
// Having a QList<QTextLayout::FormatRange> in Task isn't that great
|
// Having a QList<QTextLayout::FormatRange> in Task isn't that great
|
||||||
// It would be cleaner to split up the text into
|
// It would be cleaner to split up the text into
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
QList<QTextLayout::FormatRange> formats;
|
QList<QTextLayout::FormatRange> formats;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<TextEditor::BaseTextMark> m_mark;
|
QSharedPointer<TextEditor::TextMark> m_mark;
|
||||||
static unsigned int s_nextId;
|
static unsigned int s_nextId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -38,11 +38,11 @@ using namespace ProjectExplorer;
|
|||||||
TaskHub *m_instance = 0;
|
TaskHub *m_instance = 0;
|
||||||
QSet<Core::Id> TaskHub::m_registeredCategories;
|
QSet<Core::Id> TaskHub::m_registeredCategories;
|
||||||
|
|
||||||
class TaskMark : public TextEditor::BaseTextMark
|
class TaskMark : public TextEditor::TextMark
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TaskMark(unsigned int id, const QString &fileName, int lineNumber, bool visible)
|
TaskMark(unsigned int id, const QString &fileName, int lineNumber, bool visible)
|
||||||
: BaseTextMark(fileName, lineNumber), m_id(id)
|
: TextMark(fileName, lineNumber), m_id(id)
|
||||||
{
|
{
|
||||||
setVisible(visible);
|
setVisible(visible);
|
||||||
}
|
}
|
||||||
@@ -60,13 +60,13 @@ private:
|
|||||||
void TaskMark::updateLineNumber(int lineNumber)
|
void TaskMark::updateLineNumber(int lineNumber)
|
||||||
{
|
{
|
||||||
TaskHub::updateTaskLineNumber(m_id, lineNumber);
|
TaskHub::updateTaskLineNumber(m_id, lineNumber);
|
||||||
BaseTextMark::updateLineNumber(lineNumber);
|
TextMark::updateLineNumber(lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMark::updateFileName(const QString &fileName)
|
void TaskMark::updateFileName(const QString &fileName)
|
||||||
{
|
{
|
||||||
TaskHub::updateTaskFileName(m_id, fileName);
|
TaskHub::updateTaskFileName(m_id, fileName);
|
||||||
BaseTextMark::updateFileName(fileName);
|
TextMark::updateFileName(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMark::removedFromEditor()
|
void TaskMark::removedFromEditor()
|
||||||
@@ -131,13 +131,10 @@ void TaskHub::addTask(Task task)
|
|||||||
if (task.line != -1 && !task.file.isEmpty()) {
|
if (task.line != -1 && !task.file.isEmpty()) {
|
||||||
TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, !task.icon.isNull());
|
TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, !task.icon.isNull());
|
||||||
mark->setIcon(task.icon);
|
mark->setIcon(task.icon);
|
||||||
mark->setPriority(TextEditor::ITextMark::LowPriority);
|
mark->setPriority(TextEditor::TextMark::LowPriority);
|
||||||
task.addMark(mark);
|
task.addMark(mark);
|
||||||
emit m_instance->taskAdded(task);
|
|
||||||
mark->init();
|
|
||||||
} else {
|
|
||||||
emit m_instance->taskAdded(task);
|
|
||||||
}
|
}
|
||||||
|
emit m_instance->taskAdded(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskHub::clearTasks(Core::Id categoryId)
|
void TaskHub::clearTasks(Core::Id categoryId)
|
||||||
|
@@ -683,7 +683,7 @@ TextMarks BaseTextDocument::marks() const
|
|||||||
return d->m_marksCache;
|
return d->m_marksCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::addMark(ITextMark *mark)
|
bool BaseTextDocument::addMark(TextMark *mark)
|
||||||
{
|
{
|
||||||
if (mark->baseTextDocument())
|
if (mark->baseTextDocument())
|
||||||
return false;
|
return false;
|
||||||
@@ -730,7 +730,7 @@ TextMarks BaseTextDocument::marksAt(int line) const
|
|||||||
return TextMarks();
|
return TextMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::removeMarkFromMarksCache(ITextMark *mark)
|
void BaseTextDocument::removeMarkFromMarksCache(TextMark *mark)
|
||||||
{
|
{
|
||||||
auto documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document->documentLayout());
|
auto documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document->documentLayout());
|
||||||
QTC_ASSERT(documentLayout, return);
|
QTC_ASSERT(documentLayout, return);
|
||||||
@@ -753,7 +753,7 @@ void BaseTextDocument::removeMarkFromMarksCache(ITextMark *mark)
|
|||||||
documentLayout->requestExtraAreaUpdate();
|
documentLayout->requestExtraAreaUpdate();
|
||||||
} else {
|
} else {
|
||||||
double maxWidthFactor = 1.0;
|
double maxWidthFactor = 1.0;
|
||||||
foreach (const ITextMark *mark, marks()) {
|
foreach (const TextMark *mark, marks()) {
|
||||||
if (!mark->isVisible())
|
if (!mark->isVisible())
|
||||||
continue;
|
continue;
|
||||||
maxWidthFactor = qMax(mark->widthFactor(), maxWidthFactor);
|
maxWidthFactor = qMax(mark->widthFactor(), maxWidthFactor);
|
||||||
@@ -770,7 +770,7 @@ void BaseTextDocument::removeMarkFromMarksCache(ITextMark *mark)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::removeMark(ITextMark *mark)
|
void BaseTextDocument::removeMark(TextMark *mark)
|
||||||
{
|
{
|
||||||
QTextBlock block = d->m_document->findBlockByNumber(mark->lineNumber() - 1);
|
QTextBlock block = d->m_document->findBlockByNumber(mark->lineNumber() - 1);
|
||||||
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
|
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
|
||||||
@@ -782,7 +782,7 @@ void BaseTextDocument::removeMark(ITextMark *mark)
|
|||||||
mark->setBaseTextDocument(0);
|
mark->setBaseTextDocument(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::updateMark(ITextMark *mark)
|
void BaseTextDocument::updateMark(TextMark *mark)
|
||||||
{
|
{
|
||||||
Q_UNUSED(mark)
|
Q_UNUSED(mark)
|
||||||
auto documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document->documentLayout());
|
auto documentLayout = qobject_cast<BaseTextDocumentLayout*>(d->m_document->documentLayout());
|
||||||
@@ -790,7 +790,7 @@ void BaseTextDocument::updateMark(ITextMark *mark)
|
|||||||
documentLayout->requestUpdate();
|
documentLayout->requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextDocument::moveMark(ITextMark *mark, int previousLine)
|
void BaseTextDocument::moveMark(TextMark *mark, int previousLine)
|
||||||
{
|
{
|
||||||
QTextBlock block = d->m_document->findBlockByNumber(previousLine - 1);
|
QTextBlock block = d->m_document->findBlockByNumber(previousLine - 1);
|
||||||
if (TextBlockUserData *data = BaseTextDocumentLayout::testUserData(block)) {
|
if (TextBlockUserData *data = BaseTextDocumentLayout::testUserData(block)) {
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "texteditor_global.h"
|
#include "texteditor_global.h"
|
||||||
|
|
||||||
|
#include "itexteditor.h"
|
||||||
#include "itexteditor.h"
|
#include "itexteditor.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@@ -50,9 +51,10 @@ class Indenter;
|
|||||||
class StorageSettings;
|
class StorageSettings;
|
||||||
class SyntaxHighlighter;
|
class SyntaxHighlighter;
|
||||||
class TabSettings;
|
class TabSettings;
|
||||||
|
class TextMark;
|
||||||
class TypingSettings;
|
class TypingSettings;
|
||||||
|
|
||||||
typedef QList<ITextMark *> TextMarks;
|
typedef QList<TextMark *> TextMarks;
|
||||||
|
|
||||||
class TEXTEDITOR_EXPORT BaseTextDocument : public ITextEditorDocument
|
class TEXTEDITOR_EXPORT BaseTextDocument : public ITextEditorDocument
|
||||||
{
|
{
|
||||||
@@ -85,12 +87,12 @@ public:
|
|||||||
QTextCursor unindent(const QTextCursor &cursor);
|
QTextCursor unindent(const QTextCursor &cursor);
|
||||||
|
|
||||||
TextMarks marks() const;
|
TextMarks marks() const;
|
||||||
bool addMark(ITextMark *mark);
|
bool addMark(TextMark *mark);
|
||||||
TextMarks marksAt(int line) const;
|
TextMarks marksAt(int line) const;
|
||||||
void removeMark(ITextMark *mark);
|
void removeMark(TextMark *mark);
|
||||||
void updateMark(ITextMark *mark);
|
void updateMark(TextMark *mark);
|
||||||
void moveMark(ITextMark *mark, int previousLine);
|
void moveMark(TextMark *mark, int previousLine);
|
||||||
void removeMarkFromMarksCache(TextEditor::ITextMark *mark);
|
void removeMarkFromMarksCache(TextEditor::TextMark *mark);
|
||||||
|
|
||||||
// IDocument implementation.
|
// IDocument implementation.
|
||||||
bool save(QString *errorString, const QString &fileName, bool autoSave);
|
bool save(QString *errorString, const QString &fileName, bool autoSave);
|
||||||
|
@@ -40,7 +40,7 @@ CodeFormatterData::~CodeFormatterData()
|
|||||||
|
|
||||||
TextBlockUserData::~TextBlockUserData()
|
TextBlockUserData::~TextBlockUserData()
|
||||||
{
|
{
|
||||||
foreach (ITextMark *mrk, m_marks) {
|
foreach (TextMark *mrk, m_marks) {
|
||||||
mrk->baseTextDocument()->removeMarkFromMarksCache(mrk);
|
mrk->baseTextDocument()->removeMarkFromMarksCache(mrk);
|
||||||
mrk->setBaseTextDocument(0);
|
mrk->setBaseTextDocument(0);
|
||||||
mrk->removedFromEditor();
|
mrk->removedFromEditor();
|
||||||
@@ -376,7 +376,7 @@ void TextBlockUserData::setCodeFormatterData(CodeFormatterData *data)
|
|||||||
m_codeFormatterData = data;
|
m_codeFormatterData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBlockUserData::addMark(ITextMark *mark)
|
void TextBlockUserData::addMark(TextMark *mark)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for ( ; i < m_marks.size(); ++i) {
|
for ( ; i < m_marks.size(); ++i) {
|
||||||
@@ -593,7 +593,7 @@ TextMarks BaseTextDocumentLayout::documentClosing()
|
|||||||
|
|
||||||
void BaseTextDocumentLayout::documentReloaded(TextMarks marks, BaseTextDocument *baseTextDocument)
|
void BaseTextDocumentLayout::documentReloaded(TextMarks marks, BaseTextDocument *baseTextDocument)
|
||||||
{
|
{
|
||||||
foreach (ITextMark *mark, marks) {
|
foreach (TextMark *mark, marks) {
|
||||||
int blockNumber = mark->lineNumber() - 1;
|
int blockNumber = mark->lineNumber() - 1;
|
||||||
QTextBlock block = document()->findBlockByNumber(blockNumber);
|
QTextBlock block = document()->findBlockByNumber(blockNumber);
|
||||||
if (block.isValid()) {
|
if (block.isValid()) {
|
||||||
@@ -618,7 +618,7 @@ void BaseTextDocumentLayout::updateMarksLineNumber()
|
|||||||
int blockNumber = 0;
|
int blockNumber = 0;
|
||||||
while (block.isValid()) {
|
while (block.isValid()) {
|
||||||
if (const TextBlockUserData *userData = testUserData(block))
|
if (const TextBlockUserData *userData = testUserData(block))
|
||||||
foreach (ITextMark *mrk, userData->marks())
|
foreach (TextMark *mrk, userData->marks())
|
||||||
mrk->updateLineNumber(blockNumber + 1);
|
mrk->updateLineNumber(blockNumber + 1);
|
||||||
block = block.next();
|
block = block.next();
|
||||||
++blockNumber;
|
++blockNumber;
|
||||||
@@ -628,7 +628,7 @@ void BaseTextDocumentLayout::updateMarksLineNumber()
|
|||||||
void BaseTextDocumentLayout::updateMarksBlock(const QTextBlock &block)
|
void BaseTextDocumentLayout::updateMarksBlock(const QTextBlock &block)
|
||||||
{
|
{
|
||||||
if (const TextBlockUserData *userData = testUserData(block))
|
if (const TextBlockUserData *userData = testUserData(block))
|
||||||
foreach (ITextMark *mrk, userData->marks())
|
foreach (TextMark *mrk, userData->marks())
|
||||||
mrk->updateBlock(block);
|
mrk->updateBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "texteditor_global.h"
|
#include "texteditor_global.h"
|
||||||
|
|
||||||
#include "basetexteditor.h"
|
#include "basetexteditor.h"
|
||||||
|
#include "textmark.h"
|
||||||
|
|
||||||
#include <QTextBlockUserData>
|
#include <QTextBlockUserData>
|
||||||
#include <QPlainTextDocumentLayout>
|
#include <QPlainTextDocumentLayout>
|
||||||
@@ -75,12 +76,12 @@ public:
|
|||||||
~TextBlockUserData();
|
~TextBlockUserData();
|
||||||
|
|
||||||
inline TextMarks marks() const { return m_marks; }
|
inline TextMarks marks() const { return m_marks; }
|
||||||
void addMark(ITextMark *mark);
|
void addMark(TextMark *mark);
|
||||||
inline bool removeMark(ITextMark *mark) { return m_marks.removeAll(mark); }
|
inline bool removeMark(TextMark *mark) { return m_marks.removeAll(mark); }
|
||||||
|
|
||||||
inline TextMarks documentClosing() {
|
inline TextMarks documentClosing() {
|
||||||
TextMarks marks = m_marks;
|
TextMarks marks = m_marks;
|
||||||
foreach (ITextMark *mrk, m_marks)
|
foreach (TextMark *mrk, m_marks)
|
||||||
mrk->setBaseTextDocument(0);
|
mrk->setBaseTextDocument(0);
|
||||||
m_marks.clear();
|
m_marks.clear();
|
||||||
return marks;
|
return marks;
|
||||||
|
@@ -3933,7 +3933,7 @@ void BaseTextEditorWidget::extraAreaPaintEvent(QPaintEvent *e)
|
|||||||
}
|
}
|
||||||
TextMarks::const_iterator end = marks.constEnd();
|
TextMarks::const_iterator end = marks.constEnd();
|
||||||
for ( ; it != end; ++it) {
|
for ( ; it != end; ++it) {
|
||||||
ITextMark *mark = *it;
|
TextMark *mark = *it;
|
||||||
if (!mark->isVisible())
|
if (!mark->isVisible())
|
||||||
continue;
|
continue;
|
||||||
const int height = fmLineSpacing - 1;
|
const int height = fmLineSpacing - 1;
|
||||||
@@ -4605,7 +4605,7 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
|||||||
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
|
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
|
||||||
TextMarks marks = data->marks();
|
TextMarks marks = data->marks();
|
||||||
for (int i = marks.size(); --i >= 0; ) {
|
for (int i = marks.size(); --i >= 0; ) {
|
||||||
ITextMark *mark = marks.at(i);
|
TextMark *mark = marks.at(i);
|
||||||
if (mark->isDraggable()) {
|
if (mark->isDraggable()) {
|
||||||
d->m_markDragStart = e->pos();
|
d->m_markDragStart = e->pos();
|
||||||
break;
|
break;
|
||||||
@@ -4653,7 +4653,7 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
|||||||
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
|
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
|
||||||
TextMarks marks = data->marks();
|
TextMarks marks = data->marks();
|
||||||
for (int i = marks.size(); --i >= 0; ) {
|
for (int i = marks.size(); --i >= 0; ) {
|
||||||
ITextMark *mark = marks.at(i);
|
TextMark *mark = marks.at(i);
|
||||||
if (sameLine) {
|
if (sameLine) {
|
||||||
if (mark->isClickable()) {
|
if (mark->isClickable()) {
|
||||||
mark->clicked();
|
mark->clicked();
|
||||||
|
@@ -1,60 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
||||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef BASETEXTMARK_H
|
|
||||||
#define BASETEXTMARK_H
|
|
||||||
|
|
||||||
#include "texteditor_global.h"
|
|
||||||
#include "itextmark.h"
|
|
||||||
|
|
||||||
namespace TextEditor {
|
|
||||||
namespace Internal { class BaseTextMarkRegistry; }
|
|
||||||
|
|
||||||
class TEXTEDITOR_EXPORT BaseTextMark : public TextEditor::ITextMark
|
|
||||||
{
|
|
||||||
friend class Internal::BaseTextMarkRegistry;
|
|
||||||
|
|
||||||
public:
|
|
||||||
BaseTextMark(const QString &fileName, int lineNumber);
|
|
||||||
void init();
|
|
||||||
virtual ~BaseTextMark();
|
|
||||||
|
|
||||||
/// called if the filename of the document changed
|
|
||||||
virtual void updateFileName(const QString &fileName);
|
|
||||||
|
|
||||||
// access to internal data
|
|
||||||
QString fileName() const { return m_fileName; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_fileName;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace TextEditor
|
|
||||||
|
|
||||||
#endif // BASETEXTMARK_H
|
|
@@ -32,17 +32,13 @@
|
|||||||
|
|
||||||
#include "texteditor_global.h"
|
#include "texteditor_global.h"
|
||||||
|
|
||||||
#include "itextmark.h"
|
|
||||||
|
|
||||||
#include <coreplugin/textdocument.h>
|
#include <coreplugin/textdocument.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QIcon>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QIcon;
|
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class QPoint;
|
class QPoint;
|
||||||
|
@@ -1,143 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
||||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "itextmark.h"
|
|
||||||
#include "basetextdocument.h"
|
|
||||||
|
|
||||||
using namespace TextEditor;
|
|
||||||
|
|
||||||
ITextMark::~ITextMark()
|
|
||||||
{
|
|
||||||
if (m_baseTextDocument)
|
|
||||||
m_baseTextDocument->removeMark(this);
|
|
||||||
m_baseTextDocument = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ITextMark::lineNumber() const
|
|
||||||
{
|
|
||||||
return m_lineNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::paint(QPainter *painter, const QRect &rect) const
|
|
||||||
{
|
|
||||||
m_icon.paint(painter, rect, Qt::AlignCenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::updateLineNumber(int lineNumber)
|
|
||||||
{
|
|
||||||
m_lineNumber = lineNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::move(int line)
|
|
||||||
{
|
|
||||||
if (line == m_lineNumber)
|
|
||||||
return;
|
|
||||||
const int previousLine = m_lineNumber;
|
|
||||||
m_lineNumber = line;
|
|
||||||
if (m_baseTextDocument)
|
|
||||||
m_baseTextDocument->moveMark(this, previousLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::updateBlock(const QTextBlock &)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void ITextMark::removedFromEditor()
|
|
||||||
{}
|
|
||||||
|
|
||||||
void ITextMark::setIcon(const QIcon &icon)
|
|
||||||
{
|
|
||||||
m_icon = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::updateMarker()
|
|
||||||
{
|
|
||||||
if (m_baseTextDocument)
|
|
||||||
m_baseTextDocument->updateMark(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::setPriority(Priority priority)
|
|
||||||
{
|
|
||||||
m_priority = priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
ITextMark::Priority ITextMark::priority() const
|
|
||||||
{
|
|
||||||
return m_priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ITextMark::isVisible() const
|
|
||||||
{
|
|
||||||
return m_visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::setVisible(bool visible)
|
|
||||||
{
|
|
||||||
m_visible = visible;
|
|
||||||
if (m_baseTextDocument)
|
|
||||||
m_baseTextDocument->updateMark(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
double ITextMark::widthFactor() const
|
|
||||||
{
|
|
||||||
return m_widthFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::setWidthFactor(double factor)
|
|
||||||
{
|
|
||||||
m_widthFactor = factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ITextMark::isClickable() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::clicked()
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool ITextMark::isDraggable() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::dragToLine(int lineNumber)
|
|
||||||
{
|
|
||||||
Q_UNUSED(lineNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseTextDocument *ITextMark::baseTextDocument() const
|
|
||||||
{
|
|
||||||
return m_baseTextDocument;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITextMark::setBaseTextDocument(BaseTextDocument *baseTextDocument)
|
|
||||||
{
|
|
||||||
m_baseTextDocument = baseTextDocument;
|
|
||||||
}
|
|
||||||
|
|
@@ -21,7 +21,6 @@ SOURCES += texteditorplugin.cpp \
|
|||||||
displaysettingspage.cpp \
|
displaysettingspage.cpp \
|
||||||
fontsettings.cpp \
|
fontsettings.cpp \
|
||||||
linenumberfilter.cpp \
|
linenumberfilter.cpp \
|
||||||
basetextmark.cpp \
|
|
||||||
findinfiles.cpp \
|
findinfiles.cpp \
|
||||||
basefilefind.cpp \
|
basefilefind.cpp \
|
||||||
texteditorsettings.cpp \
|
texteditorsettings.cpp \
|
||||||
@@ -106,7 +105,7 @@ SOURCES += texteditorplugin.cpp \
|
|||||||
codestyleeditor.cpp \
|
codestyleeditor.cpp \
|
||||||
circularclipboard.cpp \
|
circularclipboard.cpp \
|
||||||
circularclipboardassist.cpp \
|
circularclipboardassist.cpp \
|
||||||
itextmark.cpp \
|
textmark.cpp \
|
||||||
codeassist/keywordscompletionassist.cpp \
|
codeassist/keywordscompletionassist.cpp \
|
||||||
marginsettings.cpp
|
marginsettings.cpp
|
||||||
|
|
||||||
@@ -130,7 +129,6 @@ HEADERS += texteditorplugin.h \
|
|||||||
itexteditor.h \
|
itexteditor.h \
|
||||||
linenumberfilter.h \
|
linenumberfilter.h \
|
||||||
texteditor_global.h \
|
texteditor_global.h \
|
||||||
basetextmark.h \
|
|
||||||
findinfiles.h \
|
findinfiles.h \
|
||||||
basefilefind.h \
|
basefilefind.h \
|
||||||
texteditorsettings.h \
|
texteditorsettings.h \
|
||||||
@@ -223,9 +221,9 @@ HEADERS += texteditorplugin.h \
|
|||||||
basefilefind_p.h \
|
basefilefind_p.h \
|
||||||
circularclipboard.h \
|
circularclipboard.h \
|
||||||
circularclipboardassist.h \
|
circularclipboardassist.h \
|
||||||
itextmark.h \
|
textmark.h \
|
||||||
codeassist/keywordscompletionassist.h \
|
codeassist/keywordscompletionassist.h \
|
||||||
basetextmarkregistry.h \
|
textmarkregistry.h \
|
||||||
marginsettings.h
|
marginsettings.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
@@ -28,9 +28,6 @@ QtcPlugin {
|
|||||||
"basetexteditor.cpp",
|
"basetexteditor.cpp",
|
||||||
"basetexteditor.h",
|
"basetexteditor.h",
|
||||||
"basetexteditor_p.h",
|
"basetexteditor_p.h",
|
||||||
"basetextmark.cpp",
|
|
||||||
"basetextmark.h",
|
|
||||||
"basetextmarkregistry.h",
|
|
||||||
"behaviorsettings.cpp",
|
"behaviorsettings.cpp",
|
||||||
"behaviorsettings.h",
|
"behaviorsettings.h",
|
||||||
"behaviorsettingspage.cpp",
|
"behaviorsettingspage.cpp",
|
||||||
@@ -93,8 +90,6 @@ QtcPlugin {
|
|||||||
"ioutlinewidget.h",
|
"ioutlinewidget.h",
|
||||||
"itexteditor.cpp",
|
"itexteditor.cpp",
|
||||||
"itexteditor.h",
|
"itexteditor.h",
|
||||||
"itextmark.cpp",
|
|
||||||
"itextmark.h",
|
|
||||||
"linenumberfilter.cpp",
|
"linenumberfilter.cpp",
|
||||||
"linenumberfilter.h",
|
"linenumberfilter.h",
|
||||||
"marginsettings.cpp",
|
"marginsettings.cpp",
|
||||||
@@ -144,6 +139,9 @@ QtcPlugin {
|
|||||||
"texteditorsettings.h",
|
"texteditorsettings.h",
|
||||||
"textfilewizard.cpp",
|
"textfilewizard.cpp",
|
||||||
"textfilewizard.h",
|
"textfilewizard.h",
|
||||||
|
"textmark.cpp",
|
||||||
|
"textmark.h",
|
||||||
|
"textmarkregistry.h",
|
||||||
"typingsettings.cpp",
|
"typingsettings.cpp",
|
||||||
"typingsettings.h",
|
"typingsettings.h",
|
||||||
]
|
]
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
#include "plaintexteditor.h"
|
#include "plaintexteditor.h"
|
||||||
#include "outlinefactory.h"
|
#include "outlinefactory.h"
|
||||||
#include "snippets/plaintextsnippetprovider.h"
|
#include "snippets/plaintextsnippetprovider.h"
|
||||||
#include "basetextmarkregistry.h"
|
#include "textmarkregistry.h"
|
||||||
#include <texteditor/generichighlighter/manager.h>
|
#include <texteditor/generichighlighter/manager.h>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -190,7 +190,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
|||||||
m_outlineFactory = new OutlineFactory;
|
m_outlineFactory = new OutlineFactory;
|
||||||
addAutoReleasedObject(m_outlineFactory);
|
addAutoReleasedObject(m_outlineFactory);
|
||||||
|
|
||||||
m_baseTextMarkRegistry = new BaseTextMarkRegistry(this);
|
m_baseTextMarkRegistry = new TextMarkRegistry(this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ LineNumberFilter *TextEditorPlugin::lineNumberFilter()
|
|||||||
return m_instance->m_lineNumberFilter;
|
return m_instance->m_lineNumberFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextMarkRegistry *TextEditorPlugin::baseTextMarkRegistry()
|
TextMarkRegistry *TextEditorPlugin::baseTextMarkRegistry()
|
||||||
{
|
{
|
||||||
return m_instance->m_baseTextMarkRegistry;
|
return m_instance->m_baseTextMarkRegistry;
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ namespace Internal {
|
|||||||
class LineNumberFilter;
|
class LineNumberFilter;
|
||||||
class PlainTextEditorFactory;
|
class PlainTextEditorFactory;
|
||||||
class OutlineFactory;
|
class OutlineFactory;
|
||||||
class BaseTextMarkRegistry;
|
class TextMarkRegistry;
|
||||||
|
|
||||||
class TextEditorPlugin : public ExtensionSystem::IPlugin
|
class TextEditorPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
|
|
||||||
static PlainTextEditorFactory *editorFactory();
|
static PlainTextEditorFactory *editorFactory();
|
||||||
static LineNumberFilter *lineNumberFilter();
|
static LineNumberFilter *lineNumberFilter();
|
||||||
static BaseTextMarkRegistry *baseTextMarkRegistry();
|
static TextMarkRegistry *baseTextMarkRegistry();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void invokeCompletion();
|
void invokeCompletion();
|
||||||
@@ -76,7 +76,7 @@ private:
|
|||||||
LineNumberFilter *m_lineNumberFilter;
|
LineNumberFilter *m_lineNumberFilter;
|
||||||
Core::SearchResultWindow *m_searchResultWindow;
|
Core::SearchResultWindow *m_searchResultWindow;
|
||||||
OutlineFactory *m_outlineFactory;
|
OutlineFactory *m_outlineFactory;
|
||||||
BaseTextMarkRegistry *m_baseTextMarkRegistry;
|
TextMarkRegistry *m_baseTextMarkRegistry;
|
||||||
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
|
@@ -27,24 +27,163 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "basetextmarkregistry.h"
|
#include "textmark.h"
|
||||||
#include "basetextmark.h"
|
#include "basetextdocument.h"
|
||||||
|
#include "textmarkregistry.h"
|
||||||
#include "itexteditor.h"
|
#include "itexteditor.h"
|
||||||
#include "basetextdocument.h"
|
#include "basetextdocument.h"
|
||||||
#include "texteditorplugin.h"
|
#include "texteditorplugin.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
using namespace TextEditor::Internal;
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
BaseTextMarkRegistry::BaseTextMarkRegistry(QObject *parent)
|
TextMark::TextMark(const QString &fileName, int lineNumber)
|
||||||
|
: m_baseTextDocument(0),
|
||||||
|
m_fileName(fileName),
|
||||||
|
m_lineNumber(lineNumber),
|
||||||
|
m_priority(NormalPriority),
|
||||||
|
m_visible(true),
|
||||||
|
m_widthFactor(1.0)
|
||||||
|
{
|
||||||
|
if (!m_fileName.isEmpty())
|
||||||
|
TextEditorPlugin::baseTextMarkRegistry()->add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextMark::~TextMark()
|
||||||
|
{
|
||||||
|
TextEditorPlugin::baseTextMarkRegistry()->remove(this);
|
||||||
|
if (m_baseTextDocument)
|
||||||
|
m_baseTextDocument->removeMark(this);
|
||||||
|
m_baseTextDocument = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TextMark::fileName() const
|
||||||
|
{
|
||||||
|
return m_fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::updateFileName(const QString &fileName)
|
||||||
|
{
|
||||||
|
if (fileName == m_fileName)
|
||||||
|
return;
|
||||||
|
if (!m_fileName.isEmpty())
|
||||||
|
TextEditorPlugin::baseTextMarkRegistry()->remove(this);
|
||||||
|
m_fileName = fileName;
|
||||||
|
if (!m_fileName.isEmpty())
|
||||||
|
TextEditorPlugin::baseTextMarkRegistry()->add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TextMark::lineNumber() const
|
||||||
|
{
|
||||||
|
return m_lineNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::paint(QPainter *painter, const QRect &rect) const
|
||||||
|
{
|
||||||
|
m_icon.paint(painter, rect, Qt::AlignCenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::updateLineNumber(int lineNumber)
|
||||||
|
{
|
||||||
|
m_lineNumber = lineNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::move(int line)
|
||||||
|
{
|
||||||
|
if (line == m_lineNumber)
|
||||||
|
return;
|
||||||
|
const int previousLine = m_lineNumber;
|
||||||
|
m_lineNumber = line;
|
||||||
|
if (m_baseTextDocument)
|
||||||
|
m_baseTextDocument->moveMark(this, previousLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::updateBlock(const QTextBlock &)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void TextMark::removedFromEditor()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void TextMark::setIcon(const QIcon &icon)
|
||||||
|
{
|
||||||
|
m_icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::updateMarker()
|
||||||
|
{
|
||||||
|
if (m_baseTextDocument)
|
||||||
|
m_baseTextDocument->updateMark(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::setPriority(Priority priority)
|
||||||
|
{
|
||||||
|
m_priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextMark::Priority TextMark::priority() const
|
||||||
|
{
|
||||||
|
return m_priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TextMark::isVisible() const
|
||||||
|
{
|
||||||
|
return m_visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::setVisible(bool visible)
|
||||||
|
{
|
||||||
|
m_visible = visible;
|
||||||
|
if (m_baseTextDocument)
|
||||||
|
m_baseTextDocument->updateMark(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
double TextMark::widthFactor() const
|
||||||
|
{
|
||||||
|
return m_widthFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::setWidthFactor(double factor)
|
||||||
|
{
|
||||||
|
m_widthFactor = factor;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TextMark::isClickable() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::clicked()
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool TextMark::isDraggable() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::dragToLine(int lineNumber)
|
||||||
|
{
|
||||||
|
Q_UNUSED(lineNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseTextDocument *TextMark::baseTextDocument() const
|
||||||
|
{
|
||||||
|
return m_baseTextDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextMark::setBaseTextDocument(BaseTextDocument *baseTextDocument)
|
||||||
|
{
|
||||||
|
m_baseTextDocument = baseTextDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TextMarkRegistry::TextMarkRegistry(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)),
|
connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)),
|
||||||
@@ -56,7 +195,7 @@ BaseTextMarkRegistry::BaseTextMarkRegistry(QObject *parent)
|
|||||||
this, SLOT(documentRenamed(Core::IDocument*,QString,QString)));
|
this, SLOT(documentRenamed(Core::IDocument*,QString,QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextMarkRegistry::add(BaseTextMark *mark)
|
void TextMarkRegistry::add(TextMark *mark)
|
||||||
{
|
{
|
||||||
m_marks[FileName::fromString(mark->fileName())].insert(mark);
|
m_marks[FileName::fromString(mark->fileName())].insert(mark);
|
||||||
auto document = qobject_cast<BaseTextDocument*>(DocumentModel::documentForFilePath(mark->fileName()));
|
auto document = qobject_cast<BaseTextDocument*>(DocumentModel::documentForFilePath(mark->fileName()));
|
||||||
@@ -65,12 +204,12 @@ void BaseTextMarkRegistry::add(BaseTextMark *mark)
|
|||||||
document->addMark(mark);
|
document->addMark(mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextMarkRegistry::remove(BaseTextMark *mark)
|
bool TextMarkRegistry::remove(TextMark *mark)
|
||||||
{
|
{
|
||||||
return m_marks[FileName::fromString(mark->fileName())].remove(mark);
|
return m_marks[FileName::fromString(mark->fileName())].remove(mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor)
|
void TextMarkRegistry::editorOpened(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
auto document = qobject_cast<BaseTextDocument *>(editor ? editor->document() : 0);
|
auto document = qobject_cast<BaseTextDocument *>(editor ? editor->document() : 0);
|
||||||
if (!document)
|
if (!document)
|
||||||
@@ -78,15 +217,14 @@ void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor)
|
|||||||
if (!m_marks.contains(FileName::fromString(document->filePath())))
|
if (!m_marks.contains(FileName::fromString(document->filePath())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (BaseTextMark *mark, m_marks.value(FileName::fromString(document->filePath())))
|
foreach (TextMark *mark, m_marks.value(FileName::fromString(document->filePath())))
|
||||||
document->addMark(mark);
|
document->addMark(mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextMarkRegistry::documentRenamed(IDocument *document, const
|
void TextMarkRegistry::documentRenamed(IDocument *document, const
|
||||||
QString &oldName, const QString &newName)
|
QString &oldName, const QString &newName)
|
||||||
{
|
{
|
||||||
TextEditor::BaseTextDocument *baseTextDocument
|
BaseTextDocument *baseTextDocument = qobject_cast<BaseTextDocument *>(document);
|
||||||
= qobject_cast<TextEditor::BaseTextDocument *>(document);
|
|
||||||
if (!document)
|
if (!document)
|
||||||
return;
|
return;
|
||||||
FileName oldFileName = FileName::fromString(oldName);
|
FileName oldFileName = FileName::fromString(oldName);
|
||||||
@@ -94,60 +232,31 @@ void BaseTextMarkRegistry::documentRenamed(IDocument *document, const
|
|||||||
if (!m_marks.contains(oldFileName))
|
if (!m_marks.contains(oldFileName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QSet<BaseTextMark *> toBeMoved;
|
QSet<TextMark *> toBeMoved;
|
||||||
foreach (ITextMark *mark, baseTextDocument->marks())
|
foreach (TextMark *mark, baseTextDocument->marks())
|
||||||
if (BaseTextMark *baseTextMark = dynamic_cast<BaseTextMark *>(mark))
|
toBeMoved.insert(mark);
|
||||||
toBeMoved.insert(baseTextMark);
|
|
||||||
|
|
||||||
m_marks[oldFileName].subtract(toBeMoved);
|
m_marks[oldFileName].subtract(toBeMoved);
|
||||||
m_marks[newFileName].unite(toBeMoved);
|
m_marks[newFileName].unite(toBeMoved);
|
||||||
|
|
||||||
foreach (BaseTextMark *mark, toBeMoved)
|
foreach (TextMark *mark, toBeMoved)
|
||||||
mark->updateFileName(newName);
|
mark->updateFileName(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QString &newName)
|
void TextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QString &newName)
|
||||||
{
|
{
|
||||||
FileName oldFileName = FileName::fromString(oldName);
|
FileName oldFileName = FileName::fromString(oldName);
|
||||||
FileName newFileName = FileName::fromString(newName);
|
FileName newFileName = FileName::fromString(newName);
|
||||||
if (!m_marks.contains(oldFileName))
|
if (!m_marks.contains(oldFileName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QSet<BaseTextMark *> oldFileNameMarks = m_marks.value(oldFileName);
|
QSet<TextMark *> oldFileNameMarks = m_marks.value(oldFileName);
|
||||||
|
|
||||||
m_marks[newFileName].unite(oldFileNameMarks);
|
m_marks[newFileName].unite(oldFileNameMarks);
|
||||||
m_marks[oldFileName].clear();
|
m_marks[oldFileName].clear();
|
||||||
|
|
||||||
foreach (BaseTextMark *mark, oldFileNameMarks)
|
foreach (TextMark *mark, oldFileNameMarks)
|
||||||
mark->updateFileName(newName);
|
mark->updateFileName(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
|
|
||||||
BaseTextMark::BaseTextMark(const QString &fileName, int lineNumber)
|
|
||||||
: ITextMark(lineNumber), m_fileName(fileName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// we need two phase initialization, since we are calling virtual functions
|
|
||||||
// of BaseTextMark in add() and also accessing widthFactor
|
|
||||||
// which might be set in the derived constructor
|
|
||||||
void BaseTextMark::init()
|
|
||||||
{
|
|
||||||
Internal::TextEditorPlugin::baseTextMarkRegistry()->add(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseTextMark::~BaseTextMark()
|
|
||||||
{
|
|
||||||
// oha we are deleted
|
|
||||||
bool b = Internal::TextEditorPlugin::baseTextMarkRegistry()->remove(this);
|
|
||||||
// If you get a assertion in this line, init() was never called
|
|
||||||
QTC_CHECK(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseTextMark::updateFileName(const QString &fileName)
|
|
||||||
{
|
|
||||||
m_fileName = fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
@@ -27,8 +27,8 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef ITEXTMARK_H
|
#ifndef TextMark_H
|
||||||
#define ITEXTMARK_H
|
#define TextMark_H
|
||||||
|
|
||||||
#include "texteditor_global.h"
|
#include "texteditor_global.h"
|
||||||
|
|
||||||
@@ -46,17 +46,13 @@ namespace TextEditor {
|
|||||||
class ITextEditor;
|
class ITextEditor;
|
||||||
class BaseTextDocument;
|
class BaseTextDocument;
|
||||||
|
|
||||||
class TEXTEDITOR_EXPORT ITextMark
|
namespace Internal { class TextMarkRegistry; }
|
||||||
|
|
||||||
|
class TEXTEDITOR_EXPORT TextMark
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ITextMark(int line)
|
TextMark(const QString &fileName, int lineNumber);
|
||||||
: m_baseTextDocument(0),
|
virtual ~TextMark();
|
||||||
m_lineNumber(line),
|
|
||||||
m_priority(NormalPriority),
|
|
||||||
m_visible(true),
|
|
||||||
m_widthFactor(1.0)
|
|
||||||
{}
|
|
||||||
virtual ~ITextMark();
|
|
||||||
|
|
||||||
// determine order on markers on the same line.
|
// determine order on markers on the same line.
|
||||||
enum Priority
|
enum Priority
|
||||||
@@ -66,8 +62,12 @@ public:
|
|||||||
HighPriority // shown on top.
|
HighPriority // shown on top.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString fileName() const;
|
||||||
int lineNumber() const;
|
int lineNumber() const;
|
||||||
|
|
||||||
virtual void paint(QPainter *painter, const QRect &rect) const;
|
virtual void paint(QPainter *painter, const QRect &rect) const;
|
||||||
|
/// called if the filename of the document changed
|
||||||
|
virtual void updateFileName(const QString &fileName);
|
||||||
virtual void updateLineNumber(int lineNumber);
|
virtual void updateLineNumber(int lineNumber);
|
||||||
virtual void updateBlock(const QTextBlock &block);
|
virtual void updateBlock(const QTextBlock &block);
|
||||||
virtual void move(int line);
|
virtual void move(int line);
|
||||||
@@ -91,8 +91,11 @@ public:
|
|||||||
void setBaseTextDocument(BaseTextDocument *baseTextDocument);
|
void setBaseTextDocument(BaseTextDocument *baseTextDocument);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(ITextMark)
|
Q_DISABLE_COPY(TextMark)
|
||||||
|
friend class Internal::TextMarkRegistry;
|
||||||
|
|
||||||
BaseTextDocument *m_baseTextDocument;
|
BaseTextDocument *m_baseTextDocument;
|
||||||
|
QString m_fileName;
|
||||||
int m_lineNumber;
|
int m_lineNumber;
|
||||||
Priority m_priority;
|
Priority m_priority;
|
||||||
bool m_visible;
|
bool m_visible;
|
||||||
@@ -102,4 +105,4 @@ private:
|
|||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|
||||||
#endif // ITEXTMARK_H
|
#endif // TextMark_H
|
@@ -42,23 +42,23 @@ class IDocument;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
class BaseTextMark;
|
class TextMark;
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class BaseTextMarkRegistry : public QObject
|
class TextMarkRegistry : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
BaseTextMarkRegistry(QObject *parent);
|
TextMarkRegistry(QObject *parent);
|
||||||
|
|
||||||
void add(BaseTextMark *mark);
|
void add(TextMark *mark);
|
||||||
bool remove(BaseTextMark *mark);
|
bool remove(TextMark *mark);
|
||||||
private slots:
|
private slots:
|
||||||
void editorOpened(Core::IEditor *editor);
|
void editorOpened(Core::IEditor *editor);
|
||||||
void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName);
|
void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName);
|
||||||
void allDocumentsRenamed(const QString &oldName, const QString &newName);
|
void allDocumentsRenamed(const QString &oldName, const QString &newName);
|
||||||
private:
|
private:
|
||||||
QHash<Utils::FileName, QSet<BaseTextMark *> > m_marks;
|
QHash<Utils::FileName, QSet<TextMark *> > m_marks;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
@@ -44,9 +44,9 @@ using namespace Valgrind::Callgrind;
|
|||||||
|
|
||||||
CallgrindTextMark::CallgrindTextMark(const QPersistentModelIndex &index,
|
CallgrindTextMark::CallgrindTextMark(const QPersistentModelIndex &index,
|
||||||
const QString &fileName, int lineNumber)
|
const QString &fileName, int lineNumber)
|
||||||
: TextEditor::BaseTextMark(fileName, lineNumber), m_modelIndex(index)
|
: TextEditor::TextMark(fileName, lineNumber), m_modelIndex(index)
|
||||||
{
|
{
|
||||||
setPriority(TextEditor::ITextMark::HighPriority);
|
setPriority(TextEditor::TextMark::HighPriority);
|
||||||
setWidthFactor(4.0);
|
setWidthFactor(4.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#ifndef CALLGRINDTEXTMARK_H
|
#ifndef CALLGRINDTEXTMARK_H
|
||||||
#define CALLGRINDTEXTMARK_H
|
#define CALLGRINDTEXTMARK_H
|
||||||
|
|
||||||
#include <texteditor/basetextmark.h>
|
#include <texteditor/textmark.h>
|
||||||
|
|
||||||
#include <QPersistentModelIndex>
|
#include <QPersistentModelIndex>
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace Callgrind { class Function; }
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class CallgrindTextMark : public TextEditor::BaseTextMark
|
class CallgrindTextMark : public TextEditor::TextMark
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@@ -1014,9 +1014,7 @@ void CallgrindToolPrivate::createTextMarks()
|
|||||||
continue;
|
continue;
|
||||||
locations << location;
|
locations << location;
|
||||||
|
|
||||||
CallgrindTextMark *mark = new CallgrindTextMark(index, fileName, lineNumber);
|
m_textMarks.append(new CallgrindTextMark(index, fileName, lineNumber));
|
||||||
mark->init();
|
|
||||||
m_textMarks.append(mark);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user