forked from qt-creator/qt-creator
Editor: Renaming Link members.
Change-Id: I1ae21152ee7b8e2a9323322575de23d77c260c72 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
@@ -231,9 +231,9 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
else
|
else
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
link.fileName = fileName;
|
link.targetFileName = fileName;
|
||||||
link.begin = cursor.position() - positionInBlock + beginPos + 1;
|
link.linkTextStart = cursor.position() - positionInBlock + beginPos + 1;
|
||||||
link.end = cursor.position() - positionInBlock + endPos;
|
link.linkTextEnd = cursor.position() - positionInBlock + endPos;
|
||||||
}
|
}
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
@@ -1178,7 +1178,7 @@ void CPPEditorWidget::switchDeclarationDefinition()
|
|||||||
bool isVisible = false;
|
bool isVisible = false;
|
||||||
foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
|
foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
|
||||||
if (visEditor->document() &&
|
if (visEditor->document() &&
|
||||||
(symbolLink.fileName == visEditor->document()->fileName()) &&
|
(symbolLink.targetFileName == visEditor->document()->fileName()) &&
|
||||||
(visEditor != editor)) {
|
(visEditor != editor)) {
|
||||||
isVisible = true;
|
isVisible = true;
|
||||||
editorManager->activateEditor(visEditor);
|
editorManager->activateEditor(visEditor);
|
||||||
@@ -1199,15 +1199,15 @@ void CPPEditorWidget::switchDeclarationDefinition()
|
|||||||
if (Symbol *def = symbolFinder()->findMatchingDefinition(lastVisibleSymbol, snapshot)) {
|
if (Symbol *def = symbolFinder()->findMatchingDefinition(lastVisibleSymbol, snapshot)) {
|
||||||
Core::IEditor *editor = editorManager->currentEditor();
|
Core::IEditor *editor = editorManager->currentEditor();
|
||||||
CPPEditorWidget::Link symbolLink = linkToSymbol(def);
|
CPPEditorWidget::Link symbolLink = linkToSymbol(def);
|
||||||
if (editorManager->hasSplitter() && (editor->document()->fileName() != symbolLink.fileName)) {
|
if (editorManager->hasSplitter() && (editor->document()->fileName() != symbolLink.targetFileName)) {
|
||||||
if (forceOpenLinksInNextSplit()) {
|
if (forceOpenLinksInNextSplit()) {
|
||||||
editorManager->gotoOtherSplit();
|
editorManager->gotoOtherSplit();
|
||||||
} else if (openLinksInNextSplit()) {
|
} else if (openLinksInNextSplit()) {
|
||||||
bool isVisible = false;
|
bool isVisible = false;
|
||||||
foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
|
foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
|
||||||
if (visEditor->document() &&
|
if (visEditor->document()
|
||||||
(symbolLink.fileName == visEditor->document()->fileName()) &&
|
&& (symbolLink.targetFileName == visEditor->document()->fileName())
|
||||||
(visEditor != editor)) {
|
&& (visEditor != editor)) {
|
||||||
isVisible = true;
|
isVisible = true;
|
||||||
editorManager->activateEditor(visEditor);
|
editorManager->activateEditor(visEditor);
|
||||||
break;
|
break;
|
||||||
@@ -1333,8 +1333,10 @@ CPPEditorWidget::Link CPPEditorWidget::attemptFuncDeclDef(const QTextCursor &cur
|
|||||||
doc->translationUnit()->getTokenEndPosition(name->lastToken() - 1, &endLine, &endColumn);
|
doc->translationUnit()->getTokenEndPosition(name->lastToken() - 1, &endLine, &endColumn);
|
||||||
|
|
||||||
QTextDocument *textDocument = cursor.document();
|
QTextDocument *textDocument = cursor.document();
|
||||||
result.begin = textDocument->findBlockByNumber(startLine - 1).position() + startColumn - 1;
|
result.linkTextStart =
|
||||||
result.end = textDocument->findBlockByNumber(endLine - 1).position() + endColumn - 1;
|
textDocument->findBlockByNumber(startLine - 1).position() + startColumn - 1;
|
||||||
|
result.linkTextEnd =
|
||||||
|
textDocument->findBlockByNumber(endLine - 1).position() + endColumn - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -1364,8 +1366,8 @@ CPPEditorWidget::Link CPPEditorWidget::findMacroLink(const QByteArray &name,
|
|||||||
foreach (const Macro ¯o, doc->definedMacros()) {
|
foreach (const Macro ¯o, doc->definedMacros()) {
|
||||||
if (macro.name() == name) {
|
if (macro.name() == name) {
|
||||||
Link link;
|
Link link;
|
||||||
link.fileName = macro.fileName();
|
link.targetFileName = macro.fileName();
|
||||||
link.line = macro.line();
|
link.targetLine = macro.line();
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1374,7 +1376,7 @@ CPPEditorWidget::Link CPPEditorWidget::findMacroLink(const QByteArray &name,
|
|||||||
for (int index = includes.size() - 1; index != -1; --index) {
|
for (int index = includes.size() - 1; index != -1; --index) {
|
||||||
const Document::Include &i = includes.at(index);
|
const Document::Include &i = includes.at(index);
|
||||||
Link link = findMacroLink(name, snapshot.document(i.fileName()), snapshot, processed);
|
Link link = findMacroLink(name, snapshot.document(i.fileName()), snapshot, processed);
|
||||||
if (! link.fileName.isEmpty())
|
if (link.hasValidTarget())
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1415,7 +1417,7 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
++pos;
|
++pos;
|
||||||
if (characterAt(pos) == QLatin1Char('(')) {
|
if (characterAt(pos) == QLatin1Char('(')) {
|
||||||
link = attemptFuncDeclDef(cursor, m_lastSemanticInfo.doc, snapshot);
|
link = attemptFuncDeclDef(cursor, m_lastSemanticInfo.doc, snapshot);
|
||||||
if (link.isValid())
|
if (link.hasValidLinkText())
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1501,9 +1503,9 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
const unsigned lineno = cursor.blockNumber() + 1;
|
const unsigned lineno = cursor.blockNumber() + 1;
|
||||||
foreach (const Document::Include &incl, doc->includes()) {
|
foreach (const Document::Include &incl, doc->includes()) {
|
||||||
if (incl.line() == lineno && incl.resolved()) {
|
if (incl.line() == lineno && incl.resolved()) {
|
||||||
link.fileName = incl.fileName();
|
link.targetFileName = incl.fileName();
|
||||||
link.begin = beginOfToken + 1;
|
link.linkTextStart = beginOfToken + 1;
|
||||||
link.end = endOfToken - 1;
|
link.linkTextEnd = endOfToken - 1;
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1526,10 +1528,10 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
const Document::MacroUse *use = doc->findMacroUseAt(endOfToken - 1);
|
const Document::MacroUse *use = doc->findMacroUseAt(endOfToken - 1);
|
||||||
if (use && use->macro().fileName() != CppModelManagerInterface::configurationFileName()) {
|
if (use && use->macro().fileName() != CppModelManagerInterface::configurationFileName()) {
|
||||||
const Macro ¯o = use->macro();
|
const Macro ¯o = use->macro();
|
||||||
link.fileName = macro.fileName();
|
link.targetFileName = macro.fileName();
|
||||||
link.line = macro.line();
|
link.targetLine = macro.line();
|
||||||
link.begin = use->begin();
|
link.linkTextStart = use->begin();
|
||||||
link.end = use->end();
|
link.linkTextEnd = use->end();
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1597,8 +1599,8 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
link = linkToSymbol(def ? def : symbol);
|
link = linkToSymbol(def ? def : symbol);
|
||||||
link.begin = beginOfToken;
|
link.linkTextStart = beginOfToken;
|
||||||
link.end = endOfToken;
|
link.linkTextEnd = endOfToken;
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1607,9 +1609,9 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
QTextCursor macroCursor = cursor;
|
QTextCursor macroCursor = cursor;
|
||||||
const QByteArray name = identifierUnderCursor(¯oCursor).toLatin1();
|
const QByteArray name = identifierUnderCursor(¯oCursor).toLatin1();
|
||||||
link = findMacroLink(name);
|
link = findMacroLink(name);
|
||||||
if (! link.fileName.isEmpty()) {
|
if (link.hasValidTarget()) {
|
||||||
link.begin = macroCursor.selectionStart();
|
link.linkTextStart = macroCursor.selectionStart();
|
||||||
link.end = macroCursor.selectionEnd();
|
link.linkTextEnd = macroCursor.selectionEnd();
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1920,8 +1922,9 @@ CPPEditorWidget::Link CPPEditorWidget::linkToSymbol(CPlusPlus::Symbol *symbol)
|
|||||||
if (!symbol)
|
if (!symbol)
|
||||||
return Link();
|
return Link();
|
||||||
|
|
||||||
const QString fileName = QString::fromUtf8(symbol->fileName(),
|
const QString filename = QString::fromUtf8(symbol->fileName(),
|
||||||
symbol->fileNameLength());
|
symbol->fileNameLength());
|
||||||
|
|
||||||
unsigned line = symbol->line();
|
unsigned line = symbol->line();
|
||||||
unsigned column = symbol->column();
|
unsigned column = symbol->column();
|
||||||
|
|
||||||
@@ -1931,18 +1934,18 @@ CPPEditorWidget::Link CPPEditorWidget::linkToSymbol(CPlusPlus::Symbol *symbol)
|
|||||||
if (symbol->isGenerated())
|
if (symbol->isGenerated())
|
||||||
column = 0;
|
column = 0;
|
||||||
|
|
||||||
return Link(fileName, line, column);
|
return Link(filename, line, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPPEditorWidget::openCppEditorAt(const Link &link)
|
bool CPPEditorWidget::openCppEditorAt(const Link &link)
|
||||||
{
|
{
|
||||||
if (link.fileName.isEmpty())
|
if (link.targetFileName.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return TextEditor::BaseTextEditorWidget::openEditorAt(link.fileName,
|
return TextEditor::BaseTextEditorWidget::openEditorAt(link.targetFileName,
|
||||||
link.line,
|
link.targetLine,
|
||||||
link.column,
|
link.targetColumn,
|
||||||
Constants::CPPEDITOR_ID);
|
Constants::CPPEDITOR_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPPEditorWidget::semanticRehighlight(bool force)
|
void CPPEditorWidget::semanticRehighlight(bool force)
|
||||||
|
@@ -105,12 +105,12 @@ public:
|
|||||||
private:
|
private:
|
||||||
void mousePressEvent(QMouseEvent *)
|
void mousePressEvent(QMouseEvent *)
|
||||||
{
|
{
|
||||||
if (m_link.fileName.isEmpty())
|
if (!m_link.hasValidTarget())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TextEditor::BaseTextEditorWidget::openEditorAt(m_link.fileName,
|
TextEditor::BaseTextEditorWidget::openEditorAt(m_link.targetFileName,
|
||||||
m_link.line,
|
m_link.targetLine,
|
||||||
m_link.column,
|
m_link.targetColumn,
|
||||||
Constants::CPPEDITOR_ID);
|
Constants::CPPEDITOR_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,10 +207,10 @@ void CppTypeHierarchyWidget::onItemClicked(const QModelIndex &index)
|
|||||||
{
|
{
|
||||||
const TextEditor::BaseTextEditorWidget::Link link
|
const TextEditor::BaseTextEditorWidget::Link link
|
||||||
= index.data(LinkRole).value<TextEditor::BaseTextEditorWidget::Link>();
|
= index.data(LinkRole).value<TextEditor::BaseTextEditorWidget::Link>();
|
||||||
if (!link.fileName.isEmpty())
|
if (link.hasValidTarget())
|
||||||
TextEditor::BaseTextEditorWidget::openEditorAt(link.fileName,
|
TextEditor::BaseTextEditorWidget::openEditorAt(link.targetFileName,
|
||||||
link.line,
|
link.targetLine,
|
||||||
link.column,
|
link.targetColumn,
|
||||||
Constants::CPPEDITOR_ID);
|
Constants::CPPEDITOR_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1106,8 +1106,8 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
|
|||||||
foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) {
|
foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) {
|
||||||
if (import.ast() == importAst && import.type() == ImportInfo::FileImport) {
|
if (import.ast() == importAst && import.type() == ImportInfo::FileImport) {
|
||||||
BaseTextEditorWidget::Link link(import.path());
|
BaseTextEditorWidget::Link link(import.path());
|
||||||
link.begin = importAst->firstSourceLocation().begin();
|
link.linkTextStart = importAst->firstSourceLocation().begin();
|
||||||
link.end = importAst->lastSourceLocation().end();
|
link.linkTextEnd = importAst->lastSourceLocation().end();
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1118,17 +1118,17 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
|
|||||||
if (StringLiteral *literal = cast<StringLiteral *>(node)) {
|
if (StringLiteral *literal = cast<StringLiteral *>(node)) {
|
||||||
const QString &text = literal->value.toString();
|
const QString &text = literal->value.toString();
|
||||||
BaseTextEditorWidget::Link link;
|
BaseTextEditorWidget::Link link;
|
||||||
link.begin = literal->literalToken.begin();
|
link.linkTextStart = literal->literalToken.begin();
|
||||||
link.end = literal->literalToken.end();
|
link.linkTextEnd = literal->literalToken.end();
|
||||||
if (semanticInfo.snapshot.document(text)) {
|
if (semanticInfo.snapshot.document(text)) {
|
||||||
link.fileName = text;
|
link.targetFileName = text;
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
const QString relative = QString::fromLatin1("%1/%2").arg(
|
const QString relative = QString::fromLatin1("%1/%2").arg(
|
||||||
semanticInfo.document->path(),
|
semanticInfo.document->path(),
|
||||||
text);
|
text);
|
||||||
if (semanticInfo.snapshot.document(relative)) {
|
if (semanticInfo.snapshot.document(relative)) {
|
||||||
link.fileName = relative;
|
link.targetFileName = relative;
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1144,27 +1144,27 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
|
|||||||
return Link();
|
return Link();
|
||||||
|
|
||||||
BaseTextEditorWidget::Link link;
|
BaseTextEditorWidget::Link link;
|
||||||
link.fileName = fileName;
|
link.targetFileName = fileName;
|
||||||
link.line = line;
|
link.targetLine = line;
|
||||||
link.column = column - 1; // adjust the column
|
link.targetColumn = column - 1; // adjust the column
|
||||||
|
|
||||||
if (AST::UiQualifiedId *q = AST::cast<AST::UiQualifiedId *>(node)) {
|
if (AST::UiQualifiedId *q = AST::cast<AST::UiQualifiedId *>(node)) {
|
||||||
for (AST::UiQualifiedId *tail = q; tail; tail = tail->next) {
|
for (AST::UiQualifiedId *tail = q; tail; tail = tail->next) {
|
||||||
if (! tail->next && cursorPosition <= tail->identifierToken.end()) {
|
if (! tail->next && cursorPosition <= tail->identifierToken.end()) {
|
||||||
link.begin = tail->identifierToken.begin();
|
link.linkTextStart = tail->identifierToken.begin();
|
||||||
link.end = tail->identifierToken.end();
|
link.linkTextEnd = tail->identifierToken.end();
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (AST::IdentifierExpression *id = AST::cast<AST::IdentifierExpression *>(node)) {
|
} else if (AST::IdentifierExpression *id = AST::cast<AST::IdentifierExpression *>(node)) {
|
||||||
link.begin = id->firstSourceLocation().begin();
|
link.linkTextStart = id->firstSourceLocation().begin();
|
||||||
link.end = id->lastSourceLocation().end();
|
link.linkTextEnd = id->lastSourceLocation().end();
|
||||||
return link;
|
return link;
|
||||||
|
|
||||||
} else if (AST::FieldMemberExpression *mem = AST::cast<AST::FieldMemberExpression *>(node)) {
|
} else if (AST::FieldMemberExpression *mem = AST::cast<AST::FieldMemberExpression *>(node)) {
|
||||||
link.begin = mem->lastSourceLocation().begin();
|
link.linkTextStart = mem->lastSourceLocation().begin();
|
||||||
link.end = mem->lastSourceLocation().end();
|
link.linkTextEnd = mem->lastSourceLocation().end();
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -178,9 +178,9 @@ ProFileEditorWidget::Link ProFileEditorWidget::findLinkAt(const QTextCursor &cur
|
|||||||
else
|
else
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
link.fileName = QDir::cleanPath(fileName);
|
link.targetFileName = QDir::cleanPath(fileName);
|
||||||
link.begin = cursor.position() - positionInBlock + beginPos + 1;
|
link.linkTextStart = cursor.position() - positionInBlock + beginPos + 1;
|
||||||
link.end = cursor.position() - positionInBlock + endPos;
|
link.linkTextEnd = cursor.position() - positionInBlock + endPos;
|
||||||
}
|
}
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
@@ -1095,7 +1095,7 @@ void BaseTextEditorWidget::openLinkUnderCursor()
|
|||||||
bool isVisible = false;
|
bool isVisible = false;
|
||||||
foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
|
foreach (Core::IEditor *visEditor, editorManager->visibleEditors()) {
|
||||||
if (visEditor->document() &&
|
if (visEditor->document() &&
|
||||||
(symbolLink.fileName == visEditor->document()->fileName()) &&
|
(symbolLink.targetFileName == visEditor->document()->fileName()) &&
|
||||||
(visEditor != editor)) {
|
(visEditor != editor)) {
|
||||||
isVisible = true;
|
isVisible = true;
|
||||||
editorManager->activateEditor(visEditor);
|
editorManager->activateEditor(visEditor);
|
||||||
@@ -4289,7 +4289,7 @@ void BaseTextEditorWidget::mousePressEvent(QMouseEvent *e)
|
|||||||
} else {
|
} else {
|
||||||
updateLink(e);
|
updateLink(e);
|
||||||
|
|
||||||
if (d->m_currentLink.isValid())
|
if (d->m_currentLink.hasValidLinkText())
|
||||||
d->m_linkPressed = true;
|
d->m_linkPressed = true;
|
||||||
}
|
}
|
||||||
} else if (e->button() == Qt::RightButton) {
|
} else if (e->button() == Qt::RightButton) {
|
||||||
@@ -4328,7 +4328,7 @@ void BaseTextEditorWidget::mouseReleaseEvent(QMouseEvent *e)
|
|||||||
bool isVisible = false;
|
bool isVisible = false;
|
||||||
foreach (Core::IEditor *visEditor, editorManager->visibleEditors())
|
foreach (Core::IEditor *visEditor, editorManager->visibleEditors())
|
||||||
if (visEditor->document() &&
|
if (visEditor->document() &&
|
||||||
(symbolLink.fileName == visEditor->document()->fileName()) &&
|
(symbolLink.targetFileName == visEditor->document()->fileName()) &&
|
||||||
(editor != visEditor)) {
|
(editor != visEditor)) {
|
||||||
isVisible = true;
|
isVisible = true;
|
||||||
editorManager->activateEditor(visEditor);
|
editorManager->activateEditor(visEditor);
|
||||||
@@ -4911,18 +4911,17 @@ BaseTextEditorWidget::Link BaseTextEditorWidget::findLinkAt(const QTextCursor &,
|
|||||||
|
|
||||||
bool BaseTextEditorWidget::openLink(const Link &link)
|
bool BaseTextEditorWidget::openLink(const Link &link)
|
||||||
{
|
{
|
||||||
if (link.fileName.isEmpty())
|
if (!link.hasValidTarget())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (baseTextDocument()->fileName() == link.fileName) {
|
if (baseTextDocument()->fileName() == link.targetFileName) {
|
||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
Core::EditorManager::instance()->addCurrentPositionToNavigationHistory();
|
||||||
editorManager->addCurrentPositionToNavigationHistory();
|
gotoLine(link.targetLine, link.targetColumn);
|
||||||
gotoLine(link.line, link.column);
|
|
||||||
setFocus();
|
setFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return openEditorAt(link.fileName, link.line, link.column, Core::Id(),
|
return openEditorAt(link.targetFileName, link.targetLine, link.targetColumn, Core::Id(),
|
||||||
Core::EditorManager::IgnoreNavigationHistory
|
Core::EditorManager::IgnoreNavigationHistory
|
||||||
| Core::EditorManager::ModeSwitch);
|
| Core::EditorManager::ModeSwitch);
|
||||||
}
|
}
|
||||||
@@ -4945,7 +4944,7 @@ void BaseTextEditorWidget::updateLink(QMouseEvent *e)
|
|||||||
|
|
||||||
const Link link = findLinkAt(cursor, false);
|
const Link link = findLinkAt(cursor, false);
|
||||||
|
|
||||||
if (onText && link.isValid()) {
|
if (onText && link.hasValidLinkText()) {
|
||||||
showLink(link);
|
showLink(link);
|
||||||
linkFound = true;
|
linkFound = true;
|
||||||
}
|
}
|
||||||
@@ -4962,8 +4961,8 @@ void BaseTextEditorWidget::showLink(const Link &link)
|
|||||||
|
|
||||||
QTextEdit::ExtraSelection sel;
|
QTextEdit::ExtraSelection sel;
|
||||||
sel.cursor = textCursor();
|
sel.cursor = textCursor();
|
||||||
sel.cursor.setPosition(link.begin);
|
sel.cursor.setPosition(link.linkTextStart);
|
||||||
sel.cursor.setPosition(link.end, QTextCursor::KeepAnchor);
|
sel.cursor.setPosition(link.linkTextEnd, QTextCursor::KeepAnchor);
|
||||||
sel.format = d->m_linkFormat;
|
sel.format = d->m_linkFormat;
|
||||||
sel.format.setFontUnderline(true);
|
sel.format.setFontUnderline(true);
|
||||||
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>() << sel);
|
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>() << sel);
|
||||||
@@ -4974,7 +4973,7 @@ void BaseTextEditorWidget::showLink(const Link &link)
|
|||||||
|
|
||||||
void BaseTextEditorWidget::clearLink()
|
void BaseTextEditorWidget::clearLink()
|
||||||
{
|
{
|
||||||
if (!d->m_currentLink.isValid())
|
if (!d->m_currentLink.hasValidLinkText())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>());
|
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>());
|
||||||
|
@@ -492,28 +492,29 @@ public:
|
|||||||
|
|
||||||
struct Link
|
struct Link
|
||||||
{
|
{
|
||||||
Link(const QString &fileName = QString(),
|
Link(const QString &fileName = QString(), int line = 0, int column = 0)
|
||||||
int line = 0,
|
: linkTextStart(-1)
|
||||||
int column = 0)
|
, linkTextEnd(-1)
|
||||||
: begin(-1)
|
, targetFileName(fileName)
|
||||||
, end(-1)
|
, targetLine(line)
|
||||||
, fileName(fileName)
|
, targetColumn(column)
|
||||||
, line(line)
|
|
||||||
, column(column)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool isValid() const
|
bool hasValidTarget() const
|
||||||
{ return begin != end; }
|
{ return !targetFileName.isEmpty(); }
|
||||||
|
|
||||||
|
bool hasValidLinkText() const
|
||||||
|
{ return linkTextStart != linkTextEnd; }
|
||||||
|
|
||||||
bool operator==(const Link &other) const
|
bool operator==(const Link &other) const
|
||||||
{ return begin == other.begin && end == other.end; }
|
{ return linkTextStart == other.linkTextStart && linkTextEnd == other.linkTextEnd; }
|
||||||
|
|
||||||
int begin; // Link position
|
int linkTextStart;
|
||||||
int end; // Link end position
|
int linkTextEnd;
|
||||||
|
|
||||||
QString fileName; // Target file
|
QString targetFileName;
|
||||||
int line; // Target line
|
int targetLine;
|
||||||
int column; // Target column
|
int targetColumn;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Reference in New Issue
Block a user