From e249da82ffbae0d611848dc0ce19b3269a6c5481 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 23 Mar 2024 18:14:52 +0800 Subject: [PATCH] code cleanup --- libs/qsynedit/qsynedit/qsynedit.cpp | 45 ++++++++--------------------- libs/qsynedit/qsynedit/qsynedit.h | 3 -- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index d349dd14..be71c48f 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -55,7 +55,6 @@ QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent), mLastKeyModifiers = Qt::NoModifier; mModified = false; mPaintLock = 0; - mPainterLock = 0; mPainting = false; mFontDummy = QFont("monospace",14); mFontDummy.setStyleStrategy(QFont::PreferAntialias); @@ -918,8 +917,6 @@ void QSynEdit::setExtraKeystrokes() void QSynEdit::invalidateLine(int line) { QRect rcInval; - if (mPainterLock >0) - return; if (line<1 || (line>mDocument->count() && line!=1) || !isVisible()) return; @@ -941,9 +938,6 @@ void QSynEdit::invalidateLine(int line) void QSynEdit::invalidateLines(int firstLine, int lastLine) { - if (mPainterLock>0) - return; - if (!isVisible()) return; //qDebug()<<"invalidate lines:"<0) - return; invalidateLines(blockBegin().line, blockEnd().line); } void QSynEdit::invalidateRect(const QRect &rect) { - if (mPainterLock>0) - return; - // if (rect.height()>mTextHeight) - // qDebug()<<"invalidate rect"<update(rect); + if (mPaintLock>0) { + mStateFlags.setFlag(StateFlag::sfRedrawNeeded); + } else { + viewport()->update(rect); + } } void QSynEdit::invalidate() { - if (mPainterLock>0) { + if (mPaintLock>0) { mStateFlags.setFlag(StateFlag::sfRedrawNeeded); } else { mStateFlags.setFlag(StateFlag::sfRedrawNeeded, false); @@ -1017,17 +1009,6 @@ void QSynEdit::invalidate() } } -void QSynEdit::lockPainter() -{ - mPainterLock++; -} - -void QSynEdit::unlockPainter() -{ - Q_ASSERT(mPainterLock>0); - mPainterLock--; -} - bool QSynEdit::selAvail() const { if (mBlockBegin.ch == mBlockEnd.ch && mBlockBegin.line == mBlockEnd.line) @@ -1510,15 +1491,15 @@ int QSynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent void QSynEdit::doSelectAll() { - BufferCoord LastPt; - LastPt.ch = 1; + BufferCoord lastPt; + lastPt.ch = 1; if (mDocument->empty()) { - LastPt.line = 1; + lastPt.line = 1; } else { - LastPt.line = mDocument->count(); - LastPt.ch = mDocument->getLine(LastPt.line-1).length()+1; + lastPt.line = mDocument->count(); + lastPt.ch = mDocument->getLine(lastPt.line-1).length()+1; } - setCaretAndSelection(caretXY(), BufferCoord{1, 1}, LastPt); + setCaretAndSelection(caretXY(), BufferCoord{1, 1}, lastPt); // Selection should have changed... emit statusChanged(StatusChange::scSelection); } @@ -5896,8 +5877,6 @@ bool QSynEdit::isCaretVisible() void QSynEdit::paintEvent(QPaintEvent *event) { - if (mPainterLock>0) - return; if (mPainting) return; mPainting = true; diff --git a/libs/qsynedit/qsynedit/qsynedit.h b/libs/qsynedit/qsynedit/qsynedit.h index 2ce358f7..f6a05525 100644 --- a/libs/qsynedit/qsynedit/qsynedit.h +++ b/libs/qsynedit/qsynedit/qsynedit.h @@ -213,8 +213,6 @@ public: void invalidateSelection(); void invalidateRect(const QRect& rect); void invalidate(); - void lockPainter(); - void unlockPainter(); bool selAvail() const; bool colSelAvail() const; QString wordAtCursor(); @@ -747,7 +745,6 @@ private: int mPaintTransientLock; bool mIsScrolling; - int mPainterLock; // lock counter to prevent repaint while painting int mOptionLock; // lock counter to prevent recalculate glyph widths while change settings; bool mUndoing; // event handlers