summaryrefslogtreecommitdiffstats
path: root/gui/groupview/GroupView.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-02-08 21:46:29 +0100
committerPetr Mrázek <peterix@gmail.com>2014-02-08 21:46:29 +0100
commitaa41b891f06a629099d108ab1f4df94d1bbc828c (patch)
treecc98e0a6d2c34a48325c1fc7a0fa66770a2d0fbb /gui/groupview/GroupView.cpp
parent573d4c8050fa6548e4680fd74c1a0872e9a62c34 (diff)
downloadMultiMC-aa41b891f06a629099d108ab1f4df94d1bbc828c.tar
MultiMC-aa41b891f06a629099d108ab1f4df94d1bbc828c.tar.gz
MultiMC-aa41b891f06a629099d108ab1f4df94d1bbc828c.tar.lz
MultiMC-aa41b891f06a629099d108ab1f4df94d1bbc828c.tar.xz
MultiMC-aa41b891f06a629099d108ab1f4df94d1bbc828c.zip
Group View: Use painting code from the previous group headers, small optimizations
Diffstat (limited to 'gui/groupview/GroupView.cpp')
-rw-r--r--gui/groupview/GroupView.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/gui/groupview/GroupView.cpp b/gui/groupview/GroupView.cpp
index 9e186854..9954d743 100644
--- a/gui/groupview/GroupView.cpp
+++ b/gui/groupview/GroupView.cpp
@@ -114,12 +114,19 @@ void GroupView::updateGeometries()
else
{
int totalHeight = 0;
+ // top margin
+ totalHeight += m_categoryMargin;
for (auto category : m_groups)
{
+ category->m_verticalPosition = totalHeight;
totalHeight += category->totalHeight() + m_categoryMargin;
}
+ /*
// remove the last margin (we don't want it)
totalHeight -= m_categoryMargin;
+ // add a margin on top...
+ totalHeight += m_categoryMargin;
+ */
totalHeight += m_bottomMargin;
verticalScrollBar()->setRange(0, totalHeight - height());
}
@@ -426,12 +433,22 @@ void GroupView::paintEvent(QPaintEvent *event)
QStyleOptionViewItemV4 option(viewOptions());
option.widget = this;
- int y = -verticalOffset();
+ int wpWidth = viewport()->width();
+ option.rect.setWidth(wpWidth);
for (int i = 0; i < m_groups.size(); ++i)
{
Group *category = m_groups.at(i);
- category->drawHeader(&painter, option, y);
+ int y = category->verticalPosition();
+ y -= verticalOffset();
+ QRect backup = option.rect;
+ int height = category->totalHeight();
+ option.rect.setTop(y);
+ option.rect.setHeight(height);
+ option.rect.setLeft(m_leftMargin);
+ option.rect.setRight(wpWidth - m_rightMargin);
+ category->drawHeader(&painter, option);
y += category->totalHeight() + m_categoryMargin;
+ option.rect = backup;
}
for (int i = 0; i < model()->rowCount(); ++i)
@@ -587,7 +604,6 @@ void GroupView::startDrag(Qt::DropActions supportedActions)
QDrag *drag = new QDrag(this);
drag->setPixmap(pixmap);
drag->setMimeData(data);
- drag->setHotSpot(m_pressedPosition - rect.topLeft());
Qt::DropAction defaultDropAction = Qt::IgnoreAction;
if (this->defaultDropAction() != Qt::IgnoreAction &&
(supportedActions & this->defaultDropAction()))