Differential D8512 Diff 21414 kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp
Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | 93 | { | |||
---|---|---|---|---|---|
95 | int pos = 0; | 95 | int pos = 0; | ||
96 | QString fileMark = QStringLiteral("KDEV_FILE_LINK{"); | 96 | QString fileMark = QStringLiteral("KDEV_FILE_LINK{"); | ||
97 | while( pos < text.length() && (pos = text.indexOf( fileMark, pos)) != -1 ) { | 97 | while( pos < text.length() && (pos = text.indexOf( fileMark, pos)) != -1 ) { | ||
98 | modifyHtml() += text.mid(lastPos, pos-lastPos); | 98 | modifyHtml() += text.mid(lastPos, pos-lastPos); | ||
99 | 99 | | |||
100 | pos += fileMark.length(); | 100 | pos += fileMark.length(); | ||
101 | 101 | | |||
102 | if( pos != text.length() ) { | 102 | if( pos != text.length() ) { | ||
103 | int fileEnd = text.indexOf('}', pos); | 103 | int fileEnd = text.indexOf(QLatin1Char('}'), pos); | ||
104 | if( fileEnd != -1 ) { | 104 | if( fileEnd != -1 ) { | ||
105 | QString file = text.mid( pos, fileEnd - pos ); | 105 | QString file = text.mid( pos, fileEnd - pos ); | ||
106 | pos = fileEnd + 1; | 106 | pos = fileEnd + 1; | ||
107 | const QUrl url = QUrl::fromUserInput(file); | 107 | const QUrl url = QUrl::fromUserInput(file); | ||
108 | makeLink( url.fileName(), file, NavigationAction( url, KTextEditor::Cursor() ) ); | 108 | makeLink( url.fileName(), file, NavigationAction( url, KTextEditor::Cursor() ) ); | ||
109 | } | 109 | } | ||
110 | } | 110 | } | ||
111 | 111 | | |||
Show All 27 Lines | 125 | { | |||
139 | d->m_linkLines[ d->m_linkCount ] = d->m_currentLine; | 139 | d->m_linkLines[ d->m_linkCount ] = d->m_currentLine; | ||
140 | if(d->m_currentPositionLine == d->m_currentLine) { | 140 | if(d->m_currentPositionLine == d->m_currentLine) { | ||
141 | d->m_currentPositionLine = -1; | 141 | d->m_currentPositionLine = -1; | ||
142 | d->m_selectedLink = d->m_linkCount; | 142 | d->m_selectedLink = d->m_linkCount; | ||
143 | } | 143 | } | ||
144 | 144 | | |||
145 | QString str = name.toHtmlEscaped(); | 145 | QString str = name.toHtmlEscaped(); | ||
146 | if( d->m_linkCount == d->m_selectedLink ) | 146 | if( d->m_linkCount == d->m_selectedLink ) | ||
147 | str = "<font style=\"background-color:#f1f1f1;\" color=\"#880088\">" + str + "</font>"; | 147 | str = QLatin1String("<font style=\"background-color:#f1f1f1;\" color=\"#880088\">") + str + QLatin1String("</font>"); | ||
148 | 148 | | |||
149 | QString ret = "<a href=\"" + hrefId + "\"" + ((d->m_linkCount == d->m_selectedLink && d->m_currentPositionLine == -1) ? QStringLiteral(" name = \"currentPosition\"") : QString()) + ">" + str + "</a>"; | 149 | QString ret = QLatin1String("<a href=\"") + hrefId + QLatin1Char('\"') + ((d->m_linkCount == d->m_selectedLink && d->m_currentPositionLine == -1) ? QStringLiteral(" name = \"currentPosition\"") : QString()) + QLatin1Char('>') + str + QLatin1String("</a>"); | ||
150 | 150 | | |||
151 | if( d->m_selectedLink == d->m_linkCount ) | 151 | if( d->m_selectedLink == d->m_linkCount ) | ||
152 | d->m_selectedLinkAction = action; | 152 | d->m_selectedLinkAction = action; | ||
153 | 153 | | |||
154 | ++d->m_linkCount; | 154 | ++d->m_linkCount; | ||
155 | return ret; | 155 | return ret; | ||
156 | } | 156 | } | ||
157 | 157 | | |||
▲ Show 20 Lines • Show All 345 Lines • ▼ Show 20 Line(s) | 501 | while(place != -1) { | |||
503 | str = str.mid(place + regExp.matchedLength()); | 503 | str = str.mid(place + regExp.matchedLength()); | ||
504 | place = regExp.indexIn(str); | 504 | place = regExp.indexIn(str); | ||
505 | } | 505 | } | ||
506 | ret << str; | 506 | ret << str; | ||
507 | return ret; | 507 | return ret; | ||
508 | } | 508 | } | ||
509 | 509 | | |||
510 | void AbstractNavigationContext::addHtml(const QString& html) { | 510 | void AbstractNavigationContext::addHtml(const QString& html) { | ||
511 | QRegExp newLineRegExp("<br>|<br */>"); | 511 | QRegExp newLineRegExp(QStringLiteral("<br>|<br */>")); | ||
512 | foreach(const QString& line, splitAndKeep(html, newLineRegExp)) { | 512 | foreach(const QString& line, splitAndKeep(html, newLineRegExp)) { | ||
513 | d->m_currentText += line; | 513 | d->m_currentText += line; | ||
514 | if(line.indexOf(newLineRegExp) != -1) { | 514 | if(line.indexOf(newLineRegExp) != -1) { | ||
515 | ++d->m_currentLine; | 515 | ++d->m_currentLine; | ||
516 | if(d->m_currentLine == d->m_currentPositionLine) { | 516 | if(d->m_currentLine == d->m_currentPositionLine) { | ||
517 | d->m_currentText += QStringLiteral("<font color=\"#880088\"> <a name = \"currentPosition\" ><-></a> </font>"); // ><-> is <-> | 517 | d->m_currentText += QStringLiteral("<font color=\"#880088\"> <a name = \"currentPosition\" ><-></a> </font>"); // ><-> is <-> | ||
518 | } | 518 | } | ||
519 | } | 519 | } | ||
Show All 11 Lines | |||||
531 | 531 | | |||
532 | QString AbstractNavigationContext::fontSizeSuffix(bool /*shorten*/) const | 532 | QString AbstractNavigationContext::fontSizeSuffix(bool /*shorten*/) const | ||
533 | { | 533 | { | ||
534 | return QString(); | 534 | return QString(); | ||
535 | } | 535 | } | ||
536 | 536 | | |||
537 | QString Colorizer::operator() ( const QString& str ) const | 537 | QString Colorizer::operator() ( const QString& str ) const | ||
538 | { | 538 | { | ||
539 | QString ret = "<font color=\"#" + m_color + "\">" + str + "</font>"; | 539 | QString ret = QLatin1String("<font color=\"#") + m_color + QLatin1String("\">") + str + QLatin1String("</font>"); | ||
540 | 540 | | |||
541 | if( m_formatting & Fixed ) | 541 | if( m_formatting & Fixed ) | ||
542 | ret = "<tt>"+ret+"</tt>"; | 542 | ret = QLatin1String("<tt>") + ret + QLatin1String("</tt>"); | ||
543 | if ( m_formatting & Bold ) | 543 | if ( m_formatting & Bold ) | ||
544 | ret = "<b>"+ret+"</b>"; | 544 | ret = QLatin1String("<b>") + ret + QLatin1String("</b>"); | ||
545 | if ( m_formatting & Italic ) | 545 | if ( m_formatting & Italic ) | ||
546 | ret = "<i>"+ret+"</i>"; | 546 | ret = QLatin1String("<i>") + ret + QLatin1String("</i>"); | ||
547 | 547 | | |||
548 | return ret; | 548 | return ret; | ||
549 | } | 549 | } | ||
550 | 550 | | |||
551 | const Colorizer AbstractNavigationContext::typeHighlight(QStringLiteral("006000")); | 551 | const Colorizer AbstractNavigationContext::typeHighlight(QStringLiteral("006000")); | ||
552 | const Colorizer AbstractNavigationContext::errorHighlight(QStringLiteral("990000")); | 552 | const Colorizer AbstractNavigationContext::errorHighlight(QStringLiteral("990000")); | ||
553 | const Colorizer AbstractNavigationContext::labelHighlight(QStringLiteral("000000")); | 553 | const Colorizer AbstractNavigationContext::labelHighlight(QStringLiteral("000000")); | ||
554 | const Colorizer AbstractNavigationContext::codeHighlight(QStringLiteral("005000")); | 554 | const Colorizer AbstractNavigationContext::codeHighlight(QStringLiteral("005000")); | ||
555 | const Colorizer AbstractNavigationContext::propertyHighlight(QStringLiteral("009900")); | 555 | const Colorizer AbstractNavigationContext::propertyHighlight(QStringLiteral("009900")); | ||
556 | const Colorizer AbstractNavigationContext::navigationHighlight(QStringLiteral("000099")); | 556 | const Colorizer AbstractNavigationContext::navigationHighlight(QStringLiteral("000099")); | ||
557 | const Colorizer AbstractNavigationContext::importantHighlight(QStringLiteral("000000"), Colorizer::Bold | Colorizer::Italic); | 557 | const Colorizer AbstractNavigationContext::importantHighlight(QStringLiteral("000000"), Colorizer::Bold | Colorizer::Italic); | ||
558 | const Colorizer AbstractNavigationContext::commentHighlight(QStringLiteral("303030")); | 558 | const Colorizer AbstractNavigationContext::commentHighlight(QStringLiteral("303030")); | ||
559 | const Colorizer AbstractNavigationContext::nameHighlight(QStringLiteral("000000"), Colorizer::Bold); | 559 | const Colorizer AbstractNavigationContext::nameHighlight(QStringLiteral("000000"), Colorizer::Bold); | ||
560 | 560 | | |||
561 | } | 561 | } |