BaseTextEditor: Style fixes

Whitespace, s/e/m_editorWidget/, remove unneeded struct, remove 'inline'
when not needed...

Change-Id: I1ce76f5c4b1febe45c4a3b6404107fed7d9c6868
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
hjk
2013-05-24 14:23:07 +02:00
committed by David Schulz
parent cfc8ce8c1b
commit 2b93fea580
2 changed files with 77 additions and 84 deletions

View File

@@ -104,26 +104,25 @@
\internal
*/
using namespace TextEditor;
using namespace TextEditor::Internal;
using namespace Utils;
namespace TextEditor {
namespace Internal {
class TextEditExtraArea : public QWidget {
BaseTextEditorWidget *textEdit;
class TextEditExtraArea : public QWidget
{
public:
TextEditExtraArea(BaseTextEditorWidget *edit):QWidget(edit) {
TextEditExtraArea(BaseTextEditorWidget *edit)
: QWidget(edit)
{
textEdit = edit;
setAutoFillBackground(true);
}
public:
protected:
QSize sizeHint() const {
return QSize(textEdit->extraAreaWidth(), 0);
}
protected:
void paintEvent(QPaintEvent *event) {
textEdit->extraAreaPaintEvent(event);
}
@@ -146,13 +145,17 @@ protected:
void wheelEvent(QWheelEvent *event) {
QCoreApplication::sendEvent(textEdit->viewport(), event);
}
private:
BaseTextEditorWidget *textEdit;
};
} // namespace Internal
} // namespace TextEditor
using namespace Internal;
Core::IEditor *BaseTextEditorWidget::openEditorAt(const QString &fileName, int line, int column,
const Core::Id &editorKind,
Core::Id editorKind,
Core::EditorManager::OpenEditorFlags flags,
bool *newEditor)
{
@@ -631,8 +634,6 @@ const Utils::ChangeSet &BaseTextEditorWidget::changeSet() const
void BaseTextEditorWidget::setChangeSet(const Utils::ChangeSet &changeSet)
{
using namespace Utils;
d->m_changeSet = changeSet;
foreach (const ChangeSet::EditOp &op, changeSet.operationList()) {
@@ -1057,7 +1058,6 @@ void BaseTextEditorWidget::uppercaseSelection()
transformSelection(&QString::toUpper);
}
void BaseTextEditorWidget::lowercaseSelection()
{
transformSelection(&QString::toLower);
@@ -1173,7 +1173,7 @@ void BaseTextEditorWidget::moveLineUpDown(bool up)
d->m_refactorOverlay->setMarkers(nonAffectedMarkers + affectedMarkers);
bool shouldReindent = true;
const Utils::CommentDefinition* commentDefinition(editor()->commentDefinition());
const CommentDefinition *commentDefinition(editor()->commentDefinition());
if (commentDefinition) {
QString trimmedText(text.trimmed());
@@ -2825,19 +2825,6 @@ void BaseTextEditorWidgetPrivate::highlightSearchResults(const QTextBlock &block
}
}
namespace TextEditor {
namespace Internal {
struct BlockSelectionData {
int selectionIndex;
int selectionStart;
int selectionEnd;
int firstColumn;
int lastColumn;
};
}
}
void BaseTextEditorWidgetPrivate::clearBlockSelection()
{
if (m_inBlockSelectionMode) {
@@ -6281,9 +6268,9 @@ void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
BaseTextEditor::BaseTextEditor(BaseTextEditorWidget *editor)
: e(editor)
: m_editorWidget(editor)
{
setWidget(e);
setWidget(m_editorWidget);
using namespace Find;
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
BaseTextFind *baseTextFind = new BaseTextFind(editor);
@@ -6318,7 +6305,7 @@ BaseTextEditor::BaseTextEditor(BaseTextEditorWidget *editor)
BaseTextEditor::~BaseTextEditor()
{
delete m_toolBar;
delete e;
delete m_editorWidget;
}
QWidget *BaseTextEditor::toolBar()
@@ -6343,74 +6330,74 @@ void BaseTextEditor::insertExtraToolBarWidget(BaseTextEditor::Side side,
int BaseTextEditor::currentLine() const
{
return e->textCursor().blockNumber() + 1;
return m_editorWidget->textCursor().blockNumber() + 1;
}
int BaseTextEditor::currentColumn() const
{
QTextCursor cursor = e->textCursor();
QTextCursor cursor = m_editorWidget->textCursor();
return cursor.position() - cursor.block().position() + 1;
}
int BaseTextEditor::columnCount() const
{
return e->columnCount();
return m_editorWidget->columnCount();
}
int BaseTextEditor::rowCount() const
{
return e->rowCount();
return m_editorWidget->rowCount();
}
QRect BaseTextEditor::cursorRect(int pos) const
{
QTextCursor tc = e->textCursor();
QTextCursor tc = m_editorWidget->textCursor();
if (pos >= 0)
tc.setPosition(pos);
QRect result = e->cursorRect(tc);
result.moveTo(e->viewport()->mapToGlobal(result.topLeft()));
QRect result = m_editorWidget->cursorRect(tc);
result.moveTo(m_editorWidget->viewport()->mapToGlobal(result.topLeft()));
return result;
}
QString BaseTextEditor::selectedText() const
{
if (e->textCursor().hasSelection())
return e->textCursor().selectedText();
if (m_editorWidget->textCursor().hasSelection())
return m_editorWidget->textCursor().selectedText();
return QString();
}
void BaseTextEditor::remove(int length)
{
QTextCursor tc = e->textCursor();
QTextCursor tc = m_editorWidget->textCursor();
tc.setPosition(tc.position() + length, QTextCursor::KeepAnchor);
tc.removeSelectedText();
}
void BaseTextEditor::insert(const QString &string)
{
QTextCursor tc = e->textCursor();
QTextCursor tc = m_editorWidget->textCursor();
tc.insertText(string);
}
void BaseTextEditor::replace(int length, const QString &string)
{
QTextCursor tc = e->textCursor();
QTextCursor tc = m_editorWidget->textCursor();
tc.setPosition(tc.position() + length, QTextCursor::KeepAnchor);
tc.insertText(string);
}
void BaseTextEditor::setCursorPosition(int pos)
{
QTextCursor tc = e->textCursor();
QTextCursor tc = m_editorWidget->textCursor();
tc.setPosition(pos);
e->setTextCursor(tc);
m_editorWidget->setTextCursor(tc);
}
void BaseTextEditor::select(int toPos)
{
QTextCursor tc = e->textCursor();
QTextCursor tc = m_editorWidget->textCursor();
tc.setPosition(toPos, QTextCursor::KeepAnchor);
e->setTextCursor(tc);
m_editorWidget->setTextCursor(tc);
}
const CommentDefinition *BaseTextEditor::commentDefinition() const
@@ -6420,16 +6407,16 @@ const CommentDefinition *BaseTextEditor::commentDefinition() const
void BaseTextEditor::updateCursorPosition()
{
const QTextCursor cursor = e->textCursor();
const QTextCursor cursor = m_editorWidget->textCursor();
const QTextBlock block = cursor.block();
const int line = block.blockNumber() + 1;
const int column = cursor.position() - block.position();
m_cursorPositionLabel->setText(tr("Line: %1, Col: %2").arg(line).arg(e->tabSettings().columnAt(block.text(), column)+1),
m_cursorPositionLabel->setText(tr("Line: %1, Col: %2").arg(line).arg(m_editorWidget->tabSettings().columnAt(block.text(), column)+1),
tr("Line: 9999, Col: 999"));
m_contextHelpId.clear();
if (!block.isVisible())
e->ensureCursorVisible();
m_editorWidget->ensureCursorVisible();
}
@@ -6456,8 +6443,8 @@ void BaseTextEditor::setFileEncodingLabelText(const QString &text)
QString BaseTextEditor::contextHelpId() const
{
if (m_contextHelpId.isEmpty())
emit const_cast<BaseTextEditor*>(this)->contextHelpIdRequested(e->editor(),
e->textCursor().position());
emit const_cast<BaseTextEditor*>(this)->contextHelpIdRequested(m_editorWidget->editor(),
m_editorWidget->textCursor().position());
return m_contextHelpId;
}
@@ -6754,3 +6741,10 @@ QString TextEditor::BaseTextEditorWidget::foldReplacementText(const QTextBlock &
{
return QLatin1String("...");
}
bool BaseTextEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
return m_editorWidget->open(errorString, fileName, realFileName);
}
} // namespace TextEditor

View File

@@ -126,12 +126,13 @@ class TEXTEDITOR_EXPORT BaseTextEditorWidget : public QPlainTextEdit
Q_OBJECT
Q_PROPERTY(int verticalBlockSelectionFirstColumn READ verticalBlockSelectionFirstColumn)
Q_PROPERTY(int verticalBlockSelectionLastColumn READ verticalBlockSelectionLastColumn)
public:
BaseTextEditorWidget(QWidget *parent);
~BaseTextEditorWidget();
static Core::IEditor *openEditorAt(const QString &fileName, int line, int column = 0,
const Core::Id &editorId = Core::Id(),
Core::Id editorId = Core::Id(),
Core::EditorManager::OpenEditorFlags flags = Core::EditorManager::IgnoreNavigationHistory,
bool *newEditor = 0);
@@ -146,13 +147,10 @@ public:
bool restoreState(const QByteArray &state);
QString displayName() const;
// ITextEditor
void gotoLine(int line, int column = 0);
int position(
ITextEditor::PositionOperation posOp = ITextEditor::Current
, int at = -1) const;
int position(ITextEditor::PositionOperation posOp = ITextEditor::Current,
int at = -1) const;
void convertPosition(int pos, int *line, int *column) const;
BaseTextEditor *editor() const;
@@ -164,7 +162,7 @@ public:
QString mimeType() const;
virtual void setMimeType(const QString &mt);
void appendMenuActionsFromContext(QMenu *menu, const Core::Id menuContextId);
void appendMenuActionsFromContext(QMenu *menu, Core::Id menuContextId);
void appendStandardContextMenuActions(QMenu *menu);
// Works only in conjunction with a syntax highlighter that puts
@@ -217,7 +215,7 @@ public:
int columnCount() const;
int rowCount() const;
void setActionHack(QObject *);
void setActionHack(QObject *hack);
QObject *actionHack() const;
void setTextCodec(QTextCodec *codec);
@@ -617,17 +615,17 @@ public:
~BaseTextEditor();
friend class BaseTextEditorWidget;
BaseTextEditorWidget *editorWidget() const { return e; }
BaseTextEditorWidget *editorWidget() const { return m_editorWidget; }
// IEditor
Core::IDocument * document() { return e->editorDocument(); }
bool createNew(const QString &contents) { return e->createNew(contents); }
bool open(QString *errorString, const QString &fileName, const QString &realFileName) { return e->open(errorString, fileName, realFileName); }
QString displayName() const { return e->displayName(); }
void setDisplayName(const QString &title) { e->setDisplayName(title); emit changed(); }
Core::IDocument *document() { return m_editorWidget->editorDocument(); }
bool createNew(const QString &contents) { return m_editorWidget->createNew(contents); }
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
QString displayName() const { return m_editorWidget->displayName(); }
void setDisplayName(const QString &title) { m_editorWidget->setDisplayName(title); emit changed(); }
QByteArray saveState() const { return e->saveState(); }
bool restoreState(const QByteArray &state) { return e->restoreState(state); }
QByteArray saveState() const { return m_editorWidget->saveState(); }
bool restoreState(const QByteArray &state) { return m_editorWidget->restoreState(state); }
QWidget *toolBar();
enum Side { Left, Right };
@@ -636,25 +634,24 @@ public:
// ITextEditor
int currentLine() const;
int currentColumn() const;
void gotoLine(int line, int column = 0) { e->gotoLine(line, column); }
void gotoLine(int line, int column = 0) { m_editorWidget->gotoLine(line, column); }
int columnCount() const;
int rowCount() const;
int position(PositionOperation posOp = Current, int at = -1) const
{ return e->position(posOp, at); }
{ return m_editorWidget->position(posOp, at); }
void convertPosition(int pos, int *line, int *column) const
{ e->convertPosition(pos, line, column); }
{ m_editorWidget->convertPosition(pos, line, column); }
QRect cursorRect(int pos = -1) const;
QString selectedText() const;
inline ITextMarkable *markableInterface() { return e->markableInterface(); }
ITextMarkable *markableInterface() { return m_editorWidget->markableInterface(); }
QString contextHelpId() const; // from IContext
inline void setTextCodec(QTextCodec *codec, TextCodecReason = TextCodecOtherReason) { e->setTextCodec(codec); }
inline QTextCodec *textCodec() const { return e->textCodec(); }
void setTextCodec(QTextCodec *codec, TextCodecReason = TextCodecOtherReason) { m_editorWidget->setTextCodec(codec); }
QTextCodec *textCodec() const { return m_editorWidget->textCodec(); }
// ITextEditor
void remove(int length);
@@ -671,7 +668,9 @@ private slots:
void setFileEncodingLabelText(const QString &text);
private:
BaseTextEditorWidget *e;
// Note: This is always a copy of IContext::m_widget.
BaseTextEditorWidget *m_editorWidget;
QToolBar *m_toolBar;
QWidget *m_stretchWidget;
QAction *m_cursorPositionLabelAction;