forked from qt-creator/qt-creator
TextEditor: Re-work comment definition handling
No need for most of the machinery. Change-Id: I9078174582d83da94c6c7f20282fd3a5f1742911 Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -34,12 +34,30 @@
|
||||
using namespace Utils;
|
||||
|
||||
CommentDefinition::CommentDefinition() :
|
||||
isAfterWhiteSpaces(false),
|
||||
singleLine(QLatin1String("//")),
|
||||
multiLineStart(QLatin1String("/*")),
|
||||
multiLineEnd(QLatin1String("*/"))
|
||||
isAfterWhiteSpaces(false)
|
||||
{}
|
||||
|
||||
void CommentDefinition::setStyle(Style style)
|
||||
{
|
||||
switch (style) {
|
||||
case CppStyle:
|
||||
singleLine = QLatin1String("//");
|
||||
multiLineStart = QLatin1String("/*");
|
||||
multiLineEnd = QLatin1String("*/");
|
||||
break;
|
||||
case HashStyle:
|
||||
singleLine = QLatin1String("#");
|
||||
multiLineStart.clear();
|
||||
multiLineEnd.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool CommentDefinition::isValid() const
|
||||
{
|
||||
return hasSingleLineStyle() || hasMultiLineStyle();
|
||||
}
|
||||
|
||||
bool CommentDefinition::hasSingleLineStyle() const
|
||||
{
|
||||
return !singleLine.isEmpty();
|
||||
@@ -50,13 +68,6 @@ bool CommentDefinition::hasMultiLineStyle() const
|
||||
return !multiLineStart.isEmpty() && !multiLineEnd.isEmpty();
|
||||
}
|
||||
|
||||
void CommentDefinition::clearCommentStyles()
|
||||
{
|
||||
singleLine.clear();
|
||||
multiLineStart.clear();
|
||||
multiLineEnd.clear();
|
||||
}
|
||||
|
||||
static bool isComment(const QString &text, int index,
|
||||
const QString &commentType)
|
||||
{
|
||||
@@ -76,7 +87,7 @@ static bool isComment(const QString &text, int index,
|
||||
|
||||
void Utils::unCommentSelection(QPlainTextEdit *edit, const CommentDefinition &definition)
|
||||
{
|
||||
if (!definition.hasSingleLineStyle() && !definition.hasMultiLineStyle())
|
||||
if (!definition.isValid())
|
||||
return;
|
||||
|
||||
QTextCursor cursor = edit->textCursor();
|
||||
|
||||
Reference in New Issue
Block a user