Commit 6b2d00ee authored by Michael Reeves's avatar Michael Reeves

Let QWidget handle disabling updates.

Drop uneeded internal flag QWidgets can diaable paint events for us.
parent c18537da
......@@ -49,7 +49,6 @@ class DiffTextWindowData
explicit DiffTextWindowData(DiffTextWindow* p)
{
m_pDiffTextWindow = p;
m_bPaintingAllowed = false;
m_pLineData = nullptr;
m_size = 0;
m_bWordWrap = false;
......@@ -83,7 +82,6 @@ class DiffTextWindowData
QTextCodec* m_pTextCodec;
e_LineEndStyle m_eLineEndStyle;
bool m_bPaintingAllowed;
const LineData* m_pLineData;
int m_size;
QString m_filename;
......@@ -168,6 +166,7 @@ DiffTextWindow::DiffTextWindow(
setObjectName(QString("DiffTextWindow%1").arg(winIdx));
setAttribute(Qt::WA_OpaquePaintEvent);
//setAttribute( Qt::WA_PaintOnScreen );
setUpdatesEnabled(false);
d = new DiffTextWindowData(this);
d->m_pDiffTextWindowFrame = pParent;
......@@ -180,7 +179,7 @@ DiffTextWindow::DiffTextWindow(
setMinimumSize(QSize(20, 20));
d->m_pStatusBar = pStatusBar;
d->m_bPaintingAllowed = true;
setUpdatesEnabled(true);
d->m_bWordWrap = false;
d->m_winIdx = winIdx;
......@@ -239,10 +238,10 @@ void DiffTextWindow::reset()
void DiffTextWindow::setPaintingAllowed(bool bAllowPainting)
{
if(d->m_bPaintingAllowed != bAllowPainting)
if(updatesEnabled() != bAllowPainting)
{
d->m_bPaintingAllowed = bAllowPainting;
if(d->m_bPaintingAllowed)
setUpdatesEnabled(bAllowPainting);
if(bAllowPainting)
update();
else
reset();
......@@ -1010,7 +1009,7 @@ void DiffTextWindowData::writeLine(
void DiffTextWindow::paintEvent(QPaintEvent* e)
{
QRect invalidRect = e->rect();
if(invalidRect.isEmpty() || !d->m_bPaintingAllowed)
if(invalidRect.isEmpty())
return;
if(d->m_pDiff3LineVector == nullptr || (d->m_diff3WrapLineVector.empty() && d->m_bWordWrap))
......@@ -1042,7 +1041,7 @@ void DiffTextWindow::paintEvent(QPaintEvent* e)
void DiffTextWindow::print(MyPainter& p, const QRect&, int firstLine, int nofLinesPerPage)
{
if(d->m_pDiff3LineVector == nullptr || !d->m_bPaintingAllowed ||
if(d->m_pDiff3LineVector == nullptr || !updatesEnabled() ||
(d->m_diff3WrapLineVector.empty() && d->m_bWordWrap))
return;
resetSelection();
......@@ -1459,7 +1458,7 @@ void DiffTextWindow::getSelectionRange(int* pFirstLine, int* pLastLine, e_CoordT
void DiffTextWindow::convertSelectionToD3LCoords()
{
if(d->m_pDiff3LineVector == nullptr || !d->m_bPaintingAllowed || !isVisible() || d->m_selection.isEmpty())
if(d->m_pDiff3LineVector == nullptr || !updatesEnabled() || !isVisible() || d->m_selection.isEmpty())
{
return;
}
......@@ -1565,7 +1564,7 @@ void DiffTextWindow::recalcWordWrap(bool bWordWrap, int wrapLineVectorSize, int
if(wrapLineVectorSize == 0)
{
d->m_wrapLineCacheList.clear();
d->m_bPaintingAllowed = false;
setUpdatesEnabled(false);
for(int i = 0, j = 0; i < d->m_pDiff3LineVector->size(); i += s_linesPerRunnable, ++j)
//int i=0;
{
......@@ -1576,7 +1575,7 @@ void DiffTextWindow::recalcWordWrap(bool bWordWrap, int wrapLineVectorSize, int
else
{
recalcWordWrapHelper(wrapLineVectorSize, visibleTextWidth, 0);
d->m_bPaintingAllowed = true;
setUpdatesEnabled(true);
}
}
else
......@@ -1585,7 +1584,7 @@ void DiffTextWindow::recalcWordWrap(bool bWordWrap, int wrapLineVectorSize, int
{
d->m_diff3WrapLineVector.resize(0);
d->m_wrapLineCacheList.clear();
d->m_bPaintingAllowed = false;
setUpdatesEnabled(false);
for(int i = 0, j = 0; i < d->m_pDiff3LineVector->size(); i += s_linesPerRunnable, ++j)
{
s_runnables.push_back(new RecalcWordWrapRunnable(this, d, visibleTextWidth, j));
......@@ -1593,7 +1592,7 @@ void DiffTextWindow::recalcWordWrap(bool bWordWrap, int wrapLineVectorSize, int
}
else
{
d->m_bPaintingAllowed = true;
setUpdatesEnabled(true);
}
}
}
......
......@@ -90,7 +90,7 @@ MergeResultWindow::MergeResultWindow(
connect(m_pStatusBar, &QStatusBar::messageChanged, this, &MergeResultWindow::slotStatusMessageChanged);
m_pOptions = pOptions;
m_bPaintingAllowed = false;
setUpdatesEnabled(false);
m_delayedDrawTimer = 0;
m_cursorXPos = 0;
......@@ -1888,18 +1888,19 @@ void MergeResultWindow::writeLine(
void MergeResultWindow::setPaintingAllowed(bool bPaintingAllowed)
{
m_bPaintingAllowed = bPaintingAllowed;
if(!m_bPaintingAllowed)
setUpdatesEnabled(bPaintingAllowed);
if(!bPaintingAllowed)
{
m_currentMergeLineIt = m_mergeLineList.end();
reset();
}
update();
else
update();
}
void MergeResultWindow::paintEvent(QPaintEvent*)
{
if(m_pDiff3LineList == nullptr || !m_bPaintingAllowed)
if(m_pDiff3LineList == nullptr)
return;
bool bOldSelectionContainsData = m_selection.selectionContainsData();
......@@ -1997,7 +1998,7 @@ void MergeResultWindow::updateSourceMask()
{
int srcMask = 0;
int enabledMask = 0;
if(!hasFocus() || m_pDiff3LineList == nullptr || !m_bPaintingAllowed || m_currentMergeLineIt == m_mergeLineList.end())
if(!hasFocus() || m_pDiff3LineList == nullptr || !updatesEnabled() || m_currentMergeLineIt == m_mergeLineList.end())
{
srcMask = 0;
enabledMask = 0;
......@@ -3069,7 +3070,7 @@ Overview::Overview(Options* pOptions)
m_bTripleDiff = false;
m_eOverviewMode = eOMNormal;
m_nofLines = 1;
m_bPaintingAllowed = false;
setUpdatesEnabled(false);
m_firstLine = 0;
m_pageHeight = 0;
......@@ -3133,10 +3134,11 @@ void Overview::mouseMoveEvent(QMouseEvent* e)
void Overview::setPaintingAllowed(bool bAllowPainting)
{
if(m_bPaintingAllowed != bAllowPainting)
if(updatesEnabled() != bAllowPainting)
{
m_bPaintingAllowed = bAllowPainting;
if(m_bPaintingAllowed)
setUpdatesEnabled(bAllowPainting);
if(bAllowPainting)
update();
else
reset();
......@@ -3308,7 +3310,7 @@ void Overview::drawColumn(QPainter& p, e_OverviewMode eOverviewMode, int x, int
void Overview::paintEvent(QPaintEvent*)
{
if(m_pDiff3LineList == nullptr || !m_bPaintingAllowed) return;
if(m_pDiff3LineList == nullptr) return;
int h = height() - 1;
int w = width();
......
......@@ -56,7 +56,6 @@ private:
int m_firstLine;
int m_pageHeight;
QPixmap m_pixmap;
bool m_bPaintingAllowed;
e_OverviewMode m_eOverviewMode;
int m_nofLines;
......@@ -187,7 +186,6 @@ private:
const Diff3LineList* m_pDiff3LineList;
TotalDiffStatus* m_pTotalDiffStatus;
bool m_bPaintingAllowed;
int m_delayedDrawTimer;
Overview::e_OverviewMode m_eOverviewMode;
QString m_persistentStatusMessage;
......
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