From 5e10d0b4db1be51bf1c2c2b8ff0b5a36bd0cb837 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 24 Mar 2024 09:39:31 +0800 Subject: [PATCH] clean up --- libs/qsynedit/qsynedit/qsynedit.cpp | 48 +++++------------------------ libs/qsynedit/qsynedit/qsynedit.h | 5 +-- 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index d9446001..4e7f58c7 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; - mPainting = false; mFontDummy = QFont("monospace",14); mFontDummy.setStyleStrategy(QFont::PreferAntialias); mDocument = std::make_shared(mFontDummy, this); @@ -593,12 +592,7 @@ bool QSynEdit::pointToLine(const QPoint &point, int &line) void QSynEdit::invalidateGutter() { - if (mPaintLock>0) { - mStateFlags.setFlag(StateFlag::sfGutterRedrawNeeded); - } else { - mStateFlags.setFlag(StateFlag::sfGutterRedrawNeeded, false); - invalidateGutterLines(-1, -1); - } + invalidateGutterLines(-1, -1); } void QSynEdit::invalidateGutterLine(int aLine) @@ -979,25 +973,12 @@ void QSynEdit::invalidateSelection() void QSynEdit::invalidateRect(const QRect &rect) { - if (mPaintLock>0) { - mStateFlags.setFlag(StateFlag::sfRedrawNeeded); - mInvalidateRect = mInvalidateRect.united(rect); - } else { - // if (rect != calculateCaretRect()) - // qDebug()<<"invalid rect"<update(rect); - } + viewport()->update(rect); } void QSynEdit::invalidate() { - if (mPaintLock>0) { - mStateFlags.setFlag(StateFlag::sfRedrawNeeded); - mInvalidateRect = clientRect(); - } else { - // qDebug()<<"invalidate"<update(); - } + viewport()->update(); } bool QSynEdit::selAvail() const @@ -2864,23 +2845,12 @@ void QSynEdit::doPasteFromClipboard() void QSynEdit::incPaintLock() { - if (mPaintLock == 0) { - mInvalidateRect={0,0,0,0}; - } mPaintLock ++ ; } void QSynEdit::decPaintLock() { Q_ASSERT(mPaintLock > 0); - if (mPaintLock == 1 ) { - if (mStatusChanges!=0) - doOnStatusChange(mStatusChanges); - if (mStateFlags.testFlag(StateFlag::sfCaretChanged)) - updateCaret(); - if (mStateFlags.testFlag(StateFlag::sfGutterRedrawNeeded)) - invalidateGutter(); - } mPaintLock--; if (mPaintLock == 0 ) { if (mStateFlags.testFlag(StateFlag::sfHScrollbarChanged)) { @@ -2889,11 +2859,10 @@ void QSynEdit::decPaintLock() if (mStateFlags.testFlag(StateFlag::sfVScrollbarChanged)) { updateVScrollbar(); } - if (mStateFlags.testFlag(StateFlag::sfRedrawNeeded)) { - invalidateRect(mInvalidateRect); - mStateFlags.setFlag(StateFlag::sfRedrawNeeded, false); - mInvalidateRect = {0,0,0,0}; - } + if (mStateFlags.testFlag(StateFlag::sfCaretChanged)) + updateCaret(); + if (mStatusChanges!=0) + doOnStatusChange(mStatusChanges); } } @@ -5894,7 +5863,7 @@ void QSynEdit::paintEvent(QPaintEvent *event) cacheRC.setHeight(rcClip.height()*dpr); painter.drawImage(rcCaret,*mContentImage,cacheRC); } else { - //qDebug()<<"paint event:"<