Commit 8095c11d authored by Thomas Lübking's avatar Thomas Lübking
Browse files

Fix KCategorizedView race - better :p

BUG: 213068
BUG: 287847
REVIEW: 103335
parent e5348a49
......@@ -1352,6 +1352,7 @@ void KCategorizedView::rowsAboutToBeRemoved(const QModelIndex &parent,
void KCategorizedView::updateGeometries()
{
const int oldVerticalOffset = verticalOffset();
const Qt::ScrollBarPolicy verticalP = verticalScrollBarPolicy(), horizontalP = horizontalScrollBarPolicy();
//BEGIN bugs 213068, 287847 ------------------------------------------------------------
/*
......@@ -1362,20 +1363,21 @@ void KCategorizedView::updateGeometries()
*
* As a result QListView and KCategorizedView occasionally started a race on the scrollbar visibility, effectively blocking the UI
* So we prevent QListView from having an own opinion on the scrollbar visibility by
* fixing it before calling the baseclass QListView::updateGeometries() and restoring the policy afterwards
* fixing it before calling the baseclass QListView::updateGeometries()
*
* Since the implicit show/hide by the followin range setting will cause further resizes if the policy is Qt::ScrollBarAsNeeded
* we keep it static until we're done, then restore the original value and ultimately change the scrollbar visibility ourself.
*/
const Qt::ScrollBarPolicy verticalP = verticalScrollBarPolicy(), horizontalP = horizontalScrollBarPolicy();
setVerticalScrollBarPolicy(verticalScrollBar()->isVisibleTo(this) ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(horizontalScrollBar()->isVisibleTo(this) ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
if (d->isCategorized()) { // important! - otherwise we'd pollute the setting if the view is initially not categorized
setVerticalScrollBarPolicy((verticalP == Qt::ScrollBarAlwaysOn || verticalScrollBar()->isVisibleTo(this)) ?
Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy((horizontalP == Qt::ScrollBarAlwaysOn || horizontalScrollBar()->isVisibleTo(this)) ?
Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff);
}
//END bugs 213068, 287847 --------------------------------------------------------------
QListView::updateGeometries();
//BEGIN bugs 213068, 287847 ------------------------------------------------------------
setVerticalScrollBarPolicy(verticalP);
setHorizontalScrollBarPolicy(horizontalP);
//END bugs 213068, 287847 --------------------------------------------------------------
if (!d->isCategorized()) {
return;
}
......@@ -1423,6 +1425,19 @@ void KCategorizedView::updateGeometries()
// (think how to draw categories), we would have to take care of the horizontal scroll bar too.
// In theory, as KCategorizedView has been designed, there is no need of horizontal scroll bar.
horizontalScrollBar()->setRange(0, 0);
//BEGIN bugs 213068, 287847 ------------------------------------------------------------
// restoring values from above ...
setVerticalScrollBarPolicy(verticalP);
setHorizontalScrollBarPolicy(horizontalP);
// ... and correct the visibility
bool validRange = verticalScrollBar()->maximum() != verticalScrollBar()->minimum();
if (verticalP == Qt::ScrollBarAsNeeded && (verticalScrollBar()->isVisibleTo(this) != validRange))
verticalScrollBar()->setVisible(validRange);
validRange = horizontalScrollBar()->maximum() > horizontalScrollBar()->minimum();
if (horizontalP == Qt::ScrollBarAsNeeded && (horizontalScrollBar()->isVisibleTo(this) != validRange))
horizontalScrollBar()->setVisible(validRange);
//END bugs 213068, 287847 --------------------------------------------------------------
}
void KCategorizedView::currentChanged(const QModelIndex &current,
......
Supports Markdown
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