Fix scrolling
This commit is contained in:
parent
53db8edb85
commit
f8d835cd22
@ -9,6 +9,7 @@
|
|||||||
#include <QPersistentModelIndex>
|
#include <QPersistentModelIndex>
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool listsIntersect(const QList<T> &l1, const QList<T> t2)
|
bool listsIntersect(const QList<T> &l1, const QList<T> t2)
|
||||||
@ -182,6 +183,22 @@ void CategorizedView::updateGeometries()
|
|||||||
qDeleteAll(m_categories);
|
qDeleteAll(m_categories);
|
||||||
m_categories = cats.values();
|
m_categories = cats.values();
|
||||||
|
|
||||||
|
if (m_categories.isEmpty())
|
||||||
|
{
|
||||||
|
verticalScrollBar()->setRange(0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int totalHeight = 0;
|
||||||
|
foreach (const Category *category, m_categories)
|
||||||
|
{
|
||||||
|
totalHeight += category->totalHeight() + m_categoryMargin;
|
||||||
|
}
|
||||||
|
// remove the last margin (we don't want it)
|
||||||
|
totalHeight -= m_categoryMargin;
|
||||||
|
verticalScrollBar()->setRange(0, totalHeight- height());
|
||||||
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,6 +530,8 @@ void CategorizedView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
void CategorizedView::paintEvent(QPaintEvent *event)
|
void CategorizedView::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter painter(this->viewport());
|
QPainter painter(this->viewport());
|
||||||
|
QPoint offset(horizontalOffset(), verticalOffset());
|
||||||
|
painter.translate(-offset);
|
||||||
|
|
||||||
int y = 0;
|
int y = 0;
|
||||||
for (int i = 0; i < m_categories.size(); ++i)
|
for (int i = 0; i < m_categories.size(); ++i)
|
||||||
|
Loading…
Reference in New Issue
Block a user