code cleanup

This commit is contained in:
Roy Qu 2024-03-23 18:14:52 +08:00
parent 67f9cbe6ee
commit e249da82ff
2 changed files with 12 additions and 36 deletions

View File

@ -55,7 +55,6 @@ QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent),
mLastKeyModifiers = Qt::NoModifier; mLastKeyModifiers = Qt::NoModifier;
mModified = false; mModified = false;
mPaintLock = 0; mPaintLock = 0;
mPainterLock = 0;
mPainting = false; mPainting = false;
mFontDummy = QFont("monospace",14); mFontDummy = QFont("monospace",14);
mFontDummy.setStyleStrategy(QFont::PreferAntialias); mFontDummy.setStyleStrategy(QFont::PreferAntialias);
@ -918,8 +917,6 @@ void QSynEdit::setExtraKeystrokes()
void QSynEdit::invalidateLine(int line) void QSynEdit::invalidateLine(int line)
{ {
QRect rcInval; QRect rcInval;
if (mPainterLock >0)
return;
if (line<1 || (line>mDocument->count() && if (line<1 || (line>mDocument->count() &&
line!=1) || !isVisible()) line!=1) || !isVisible())
return; return;
@ -941,9 +938,6 @@ void QSynEdit::invalidateLine(int line)
void QSynEdit::invalidateLines(int firstLine, int lastLine) void QSynEdit::invalidateLines(int firstLine, int lastLine)
{ {
if (mPainterLock>0)
return;
if (!isVisible()) if (!isVisible())
return; return;
//qDebug()<<"invalidate lines:"<<firstLine<<lastLine; //qDebug()<<"invalidate lines:"<<firstLine<<lastLine;
@ -993,23 +987,21 @@ void QSynEdit::invalidateLines(int firstLine, int lastLine)
void QSynEdit::invalidateSelection() void QSynEdit::invalidateSelection()
{ {
if (mPainterLock>0)
return;
invalidateLines(blockBegin().line, blockEnd().line); invalidateLines(blockBegin().line, blockEnd().line);
} }
void QSynEdit::invalidateRect(const QRect &rect) void QSynEdit::invalidateRect(const QRect &rect)
{ {
if (mPainterLock>0) if (mPaintLock>0) {
return; mStateFlags.setFlag(StateFlag::sfRedrawNeeded);
// if (rect.height()>mTextHeight) } else {
// qDebug()<<"invalidate rect"<<rect; viewport()->update(rect);
viewport()->update(rect); }
} }
void QSynEdit::invalidate() void QSynEdit::invalidate()
{ {
if (mPainterLock>0) { if (mPaintLock>0) {
mStateFlags.setFlag(StateFlag::sfRedrawNeeded); mStateFlags.setFlag(StateFlag::sfRedrawNeeded);
} else { } else {
mStateFlags.setFlag(StateFlag::sfRedrawNeeded, false); 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 bool QSynEdit::selAvail() const
{ {
if (mBlockBegin.ch == mBlockEnd.ch && mBlockBegin.line == mBlockEnd.line) 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() void QSynEdit::doSelectAll()
{ {
BufferCoord LastPt; BufferCoord lastPt;
LastPt.ch = 1; lastPt.ch = 1;
if (mDocument->empty()) { if (mDocument->empty()) {
LastPt.line = 1; lastPt.line = 1;
} else { } else {
LastPt.line = mDocument->count(); lastPt.line = mDocument->count();
LastPt.ch = mDocument->getLine(LastPt.line-1).length()+1; 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... // Selection should have changed...
emit statusChanged(StatusChange::scSelection); emit statusChanged(StatusChange::scSelection);
} }
@ -5896,8 +5877,6 @@ bool QSynEdit::isCaretVisible()
void QSynEdit::paintEvent(QPaintEvent *event) void QSynEdit::paintEvent(QPaintEvent *event)
{ {
if (mPainterLock>0)
return;
if (mPainting) if (mPainting)
return; return;
mPainting = true; mPainting = true;

View File

@ -213,8 +213,6 @@ public:
void invalidateSelection(); void invalidateSelection();
void invalidateRect(const QRect& rect); void invalidateRect(const QRect& rect);
void invalidate(); void invalidate();
void lockPainter();
void unlockPainter();
bool selAvail() const; bool selAvail() const;
bool colSelAvail() const; bool colSelAvail() const;
QString wordAtCursor(); QString wordAtCursor();
@ -747,7 +745,6 @@ private:
int mPaintTransientLock; int mPaintTransientLock;
bool mIsScrolling; bool mIsScrolling;
int mPainterLock; // lock counter to prevent repaint while painting
int mOptionLock; // lock counter to prevent recalculate glyph widths while change settings; int mOptionLock; // lock counter to prevent recalculate glyph widths while change settings;
bool mUndoing; bool mUndoing;
// event handlers // event handlers