diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2013-12-26 22:40:26 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2013-12-26 22:40:26 +0100 |
commit | f8d835cd22de89bc130ff0413228cfea0ebfd8ac (patch) | |
tree | f3691813189bd438ee88e92eab3578d888c73a98 | |
parent | 53db8edb851917809209e4473eef2a66651d6047 (diff) | |
download | MultiMC-f8d835cd22de89bc130ff0413228cfea0ebfd8ac.tar MultiMC-f8d835cd22de89bc130ff0413228cfea0ebfd8ac.tar.gz MultiMC-f8d835cd22de89bc130ff0413228cfea0ebfd8ac.tar.lz MultiMC-f8d835cd22de89bc130ff0413228cfea0ebfd8ac.tar.xz MultiMC-f8d835cd22de89bc130ff0413228cfea0ebfd8ac.zip |
Fix scrolling
-rw-r--r-- | CategorizedView.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/CategorizedView.cpp b/CategorizedView.cpp index 1860f095..6164cde6 100644 --- a/CategorizedView.cpp +++ b/CategorizedView.cpp @@ -9,6 +9,7 @@ #include <QPersistentModelIndex> #include <QDrag> #include <QMimeData> +#include <QScrollBar> template<typename T> bool listsIntersect(const QList<T> &l1, const QList<T> t2) @@ -182,6 +183,22 @@ void CategorizedView::updateGeometries() qDeleteAll(m_categories); 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(); } @@ -513,6 +530,8 @@ void CategorizedView::mouseDoubleClickEvent(QMouseEvent *event) void CategorizedView::paintEvent(QPaintEvent *event) { QPainter painter(this->viewport()); + QPoint offset(horizontalOffset(), verticalOffset()); + painter.translate(-offset); int y = 0; for (int i = 0; i < m_categories.size(); ++i) |