Commit cd90ddad authored by hjk's avatar hjk

TextEditor: Move some enums to namespace scope

In preparation for the final s/BaseTextEditor/TextEditor.

Change-Id: Ie18db9817ec9eec53d805443605ca55423c64c93
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 392b3f65
......@@ -849,9 +849,9 @@ void BookmarkManager::loadBookmarks()
}
void BookmarkManager::handleBookmarkRequest(TextEditorWidget *widget, int line,
BaseTextEditor::MarkRequestKind kind)
TextMarkRequestKind kind)
{
if (kind == BaseTextEditor::BookmarkRequest && widget->textDocument())
if (kind == BookmarkRequest && widget->textDocument())
toggleBookmark(widget->textDocument()->filePath(), line);
}
......
......@@ -94,7 +94,7 @@ public:
};
void handleBookmarkRequest(TextEditor::TextEditorWidget *widget, int line,
TextEditor::BaseTextEditor::MarkRequestKind kind);
TextEditor::TextMarkRequestKind kind);
void handleBookmarkTooltipRequest(TextEditor::TextEditorWidget *widget,
const QPoint &pos, int line);
......
......@@ -235,12 +235,11 @@ AssistInterface *ClangCompletionAssistProvider::createAssistInterface(
// ------------------------
// ClangAssistProposalModel
// ------------------------
class ClangAssistProposalModel : public TextEditor::GenericProposalModel
class ClangAssistProposalModel : public GenericProposalModel
{
public:
ClangAssistProposalModel()
: TextEditor::GenericProposalModel()
, m_sortable(false)
: m_sortable(false)
, m_completionOperator(T_EOF_SYMBOL)
, m_replaceDotForArrow(false)
{}
......@@ -254,11 +253,11 @@ public:
// -------------------
// ClangAssistProposal
// -------------------
class ClangAssistProposal : public TextEditor::GenericProposal
class ClangAssistProposal : public GenericProposal
{
public:
ClangAssistProposal(int cursorPos, TextEditor::GenericProposalModel *model)
: TextEditor::GenericProposal(cursorPos, model)
ClangAssistProposal(int cursorPos, GenericProposalModel *model)
: GenericProposal(cursorPos, model)
, m_replaceDotForArrow(static_cast<ClangAssistProposalModel *>(model)->m_replaceDotForArrow)
{}
......@@ -277,7 +276,7 @@ private:
// ----------------------
// ClangFunctionHintModel
// ----------------------
class ClangFunctionHintModel : public TextEditor::IFunctionHintProposalModel
class ClangFunctionHintModel : public IFunctionHintProposalModel
{
public:
ClangFunctionHintModel(const QList<CodeCompletionResult> functionSymbols)
......@@ -345,13 +344,13 @@ int ClangFunctionHintModel::activeArgument(const QString &prefix) const
return argnr;
}
class ClangAssistProposalItem : public TextEditor::AssistProposalItem
class ClangAssistProposalItem : public AssistProposalItem
{
public:
ClangAssistProposalItem() {}
virtual bool prematurelyApplies(const QChar &c) const;
virtual void applyContextualContent(TextEditor::TextEditorWidget *editorWidget,
virtual void applyContextualContent(TextEditorWidget *editorWidget,
int basePosition) const;
void keepCompletionOperator(unsigned compOp) { m_completionOperator = compOp; }
......@@ -508,7 +507,7 @@ void ClangAssistProposalItem::applyContextualContent(TextEditorWidget *editorWid
}
// Avoid inserting characters that are already there
const int endsPosition = editorWidget->position(TextEditor::BaseTextEditor::EndOfLine);
const int endsPosition = editorWidget->position(EndOfLinePosition);
const QString existingText = editorWidget->textAt(editorWidget->position(), endsPosition - editorWidget->position());
int existLength = 0;
if (!existingText.isEmpty()) {
......
......@@ -301,7 +301,7 @@ void CppAssistProposalItem::applyContextualContent(TextEditorWidget *editorWidge
// Determine the length of characters that should just be kept on the editor, but do
// not consider content that ends as an identifier (which could be undesired).
const int lineEnd = editorWidget->position(BaseTextEditor::EndOfLine);
const int lineEnd = editorWidget->position(EndOfLinePosition);
const QString inEditor = editorWidget->textAt(editorWidget->position(), lineEnd - editorWidget->position());
int preserveLength = 0;
if (!inEditor.isEmpty()) {
......
......@@ -836,7 +836,7 @@ public slots:
void updateBreakMenuItem(Core::IEditor *editor);
void setBusyCursor(bool busy);
void requestMark(TextEditor::TextEditorWidget *widget, int lineNumber,
TextEditor::BaseTextEditor::MarkRequestKind kind);
TextEditor::TextMarkRequestKind kind);
void requestContextMenu(TextEditor::TextEditorWidget *widget,
int lineNumber, QMenu *menu);
......@@ -2039,9 +2039,9 @@ void DebuggerPluginPrivate::toggleBreakpointByAddress(quint64 address,
}
void DebuggerPluginPrivate::requestMark(TextEditorWidget *widget, int lineNumber,
BaseTextEditor::MarkRequestKind kind)
TextMarkRequestKind kind)
{
if (kind != BaseTextEditor::BreakpointRequest)
if (kind != BreakpointRequest)
return;
TextDocument *document = widget->textDocument();
......
......@@ -155,7 +155,7 @@ void QmakeManager::addLibrary(const QString &fileName, BaseTextEditor *editor)
if (!editor)
return;
const int endOfDoc = editor->position(BaseTextEditor::EndOfDoc);
const int endOfDoc = editor->position(EndOfDocPosition);
editor->setCursorPosition(endOfDoc);
QString snippet = wizard.snippet();
......
......@@ -2448,28 +2448,28 @@ void TextEditorWidget::gotoLine(int line, int column, bool centerLine)
d->saveCurrentCursorPositionForNavigation();
}
int TextEditorWidget::position(BaseTextEditor::PositionOperation posOp, int at) const
int TextEditorWidget::position(TextPositionOperation posOp, int at) const
{
QTextCursor tc = textCursor();
if (at != -1)
tc.setPosition(at);
if (posOp == BaseTextEditor::Current)
if (posOp == CurrentPosition)
return tc.position();
switch (posOp) {
case BaseTextEditor::EndOfLine:
case EndOfLinePosition:
tc.movePosition(QTextCursor::EndOfLine);
return tc.position();
case BaseTextEditor::StartOfLine:
case StartOfLinePosition:
tc.movePosition(QTextCursor::StartOfLine);
return tc.position();
case BaseTextEditor::Anchor:
case AnchorPosition:
if (tc.hasSelection())
return tc.anchor();
break;
case BaseTextEditor::EndOfDoc:
case EndOfDocPosition:
tc.movePosition(QTextCursor::End);
return tc.position();
default:
......@@ -5087,11 +5087,11 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
}
}
int line = n + 1;
BaseTextEditor::MarkRequestKind kind;
TextMarkRequestKind kind;
if (QApplication::keyboardModifiers() & Qt::ShiftModifier)
kind = BaseTextEditor::BookmarkRequest;
kind = BookmarkRequest;
else
kind = BaseTextEditor::BreakpointRequest;
kind = BreakpointRequest;
emit markRequested(this, line, kind);
}
......@@ -5224,8 +5224,8 @@ void TextEditorWidgetPrivate::handleBackspaceKey()
cursorWithinSnippet = snippetCheckCursor(snippetCursor);
}
const TextEditor::TabSettings &tabSettings = m_document->tabSettings();
const TextEditor::TypingSettings &typingSettings = m_document->typingSettings();
const TabSettings &tabSettings = m_document->tabSettings();
const TypingSettings &typingSettings = m_document->typingSettings();
if (typingSettings.m_autoIndent && m_autoCompleter->autoBackspace(cursor))
return;
......@@ -6154,7 +6154,7 @@ void TextEditorWidget::setMarginSettings(const MarginSettings &ms)
extraArea()->update();
}
void TextEditorWidget::setBehaviorSettings(const TextEditor::BehaviorSettings &bs)
void TextEditorWidget::setBehaviorSettings(const BehaviorSettings &bs)
{
d->m_behaviorSettings = bs;
}
......@@ -6169,7 +6169,7 @@ void TextEditorWidget::setStorageSettings(const StorageSettings &storageSettings
d->m_document->setStorageSettings(storageSettings);
}
void TextEditorWidget::setCompletionSettings(const TextEditor::CompletionSettings &completionSettings)
void TextEditorWidget::setCompletionSettings(const CompletionSettings &completionSettings)
{
d->m_autoCompleter->setAutoParenthesesEnabled(completionSettings.m_autoInsertBrackets);
d->m_autoCompleter->setSurroundWithEnabled(completionSettings.m_autoInsertBrackets
......@@ -6588,7 +6588,7 @@ void TextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
BaseTextEditor::BaseTextEditor()
: d(new BaseTextEditorPrivate)
{
addContext(TextEditor::Constants::C_TEXTEDITOR);
addContext(Constants::C_TEXTEDITOR);
}
BaseTextEditor::~BaseTextEditor()
......@@ -6660,7 +6660,7 @@ int BaseTextEditor::rowCount() const
return editorWidget()->rowCount();
}
int BaseTextEditor::position(BaseTextEditor::PositionOperation posOp, int at) const
int BaseTextEditor::position(TextPositionOperation posOp, int at) const
{
return editorWidget()->position(posOp, at);
}
......@@ -7067,7 +7067,7 @@ bool BaseTextEditor::open(QString *errorString, const QString &fileName, const Q
{
if (!editorWidget()->open(errorString, fileName, realFileName))
return false;
textDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
textDocument()->setMimeType(MimeDatabase::findByFile(QFileInfo(fileName)).type());
return true;
}
......@@ -7187,7 +7187,7 @@ void TextEditorWidget::setupAsPlainEditor()
setMarksVisible(true);
setLineSeparatorsAllowed(true);
textDocument()->setMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
textDocument()->setMimeType(QLatin1String(Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
connect(textDocument(), &IDocument::filePathChanged,
d, &TextEditorWidgetPrivate::reconfigure);
......@@ -7258,8 +7258,8 @@ void TextEditorFactory::setSyntaxHighlighterCreator(const SyntaxHighLighterCreat
void TextEditorFactory::setGenericSyntaxHighlighter(const QString &mimeType)
{
m_syntaxHighlighterCreator = [this, mimeType]() -> SyntaxHighlighter * {
Highlighter *highlighter = new TextEditor::Highlighter();
setMimeTypeForHighlighter(highlighter, Core::MimeDatabase::findByType(mimeType));
Highlighter *highlighter = new Highlighter;
setMimeTypeForHighlighter(highlighter, MimeDatabase::findByType(mimeType));
return highlighter;
};
}
......
......@@ -112,30 +112,32 @@ private:
int _last;
};
enum TextPositionOperation
{
CurrentPosition = 1,
EndOfLinePosition = 2,
StartOfLinePosition = 3,
AnchorPosition = 4,
EndOfDocPosition = 5
};
enum TextMarkRequestKind
{
BreakpointRequest,
BookmarkRequest,
TaskMarkRequest
};
class TEXTEDITOR_EXPORT BaseTextEditor : public Core::IEditor
{
Q_OBJECT
public:
enum PositionOperation {
Current = 1,
EndOfLine = 2,
StartOfLine = 3,
Anchor = 4,
EndOfDoc = 5
};
BaseTextEditor();
~BaseTextEditor();
virtual void finalizeInitialization() {}
enum MarkRequestKind {
BreakpointRequest,
BookmarkRequest,
TaskMarkRequest
};
static BaseTextEditor *currentTextEditor();
TextEditorWidget *editorWidget() const;
......@@ -174,7 +176,7 @@ public:
int rowCount() const;
/*! Returns the position at \a posOp in characters from the beginning of the document */
virtual int position(PositionOperation posOp = Current, int at = -1) const;
virtual int position(TextPositionOperation posOp = CurrentPosition, int at = -1) const;
/*! Converts the \a pos in characters from beginning of document to \a line and \a column */
virtual void convertPosition(int pos, int *line, int *column) const;
......@@ -220,7 +222,7 @@ public:
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
void gotoLine(int line, int column = 0, bool centerLine = true);
int position(BaseTextEditor::PositionOperation posOp = BaseTextEditor::Current,
int position(TextPositionOperation posOp = CurrentPosition,
int at = -1) const;
void convertPosition(int pos, int *line, int *column) const;
using QPlainTextEdit::cursorRect;
......@@ -592,7 +594,7 @@ protected:
signals:
void markRequested(TextEditor::TextEditorWidget *widget,
int line, TextEditor::BaseTextEditor::MarkRequestKind kind);
int line, TextEditor::TextMarkRequestKind kind);
void markContextMenuRequested(TextEditor::TextEditorWidget *widget,
int line, QMenu *menu);
void tooltipOverrideRequested(TextEditor::TextEditorWidget *widget,
......
......@@ -211,18 +211,18 @@ void TextEditorPlugin::updateSearchResultsFont(const FontSettings &settings)
{
if (auto window = SearchResultWindow::instance()) {
window->setTextEditorFont(QFont(settings.family(), settings.fontSize() * settings.fontZoom() / 100),
settings.formatFor(TextEditor::C_TEXT).foreground(),
settings.formatFor(TextEditor::C_TEXT).background(),
settings.formatFor(TextEditor::C_SEARCH_RESULT).foreground(),
settings.formatFor(TextEditor::C_SEARCH_RESULT).background());
settings.formatFor(C_TEXT).foreground(),
settings.formatFor(C_TEXT).background(),
settings.formatFor(C_SEARCH_RESULT).foreground(),
settings.formatFor(C_SEARCH_RESULT).background());
}
}
void TextEditorPlugin::updateCurrentSelection(const QString &text)
{
if (BaseTextEditor *editor = qobject_cast<BaseTextEditor *>(EditorManager::currentEditor())) {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) {
const int pos = editor->position();
int anchor = editor->position(BaseTextEditor::Anchor);
int anchor = editor->position(AnchorPosition);
if (anchor < 0) // no selection
anchor = pos;
int selectionLength = pos - anchor;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment