summaryrefslogtreecommitdiffstats
path: root/application/groupview/GroupView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'application/groupview/GroupView.cpp')
-rw-r--r--application/groupview/GroupView.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/application/groupview/GroupView.cpp b/application/groupview/GroupView.cpp
index ab9e71cf..aa85bec7 100644
--- a/application/groupview/GroupView.cpp
+++ b/application/groupview/GroupView.cpp
@@ -188,18 +188,31 @@ VisualGroup *GroupView::category(const QString &cat) const
return nullptr;
}
-VisualGroup *GroupView::categoryAt(const QPoint &pos) const
+VisualGroup *GroupView::categoryAt(const QPoint &pos, VisualGroup::HitResults & result) const
{
for (auto group : m_groups)
{
- if(group->hitScan(pos) & VisualGroup::CheckboxHit)
+ result = group->hitScan(pos);
+ if(result != VisualGroup::NoHit)
{
return group;
}
}
+ result = VisualGroup::NoHit;
return nullptr;
}
+QString GroupView::groupNameAt(const QPoint &point)
+{
+ VisualGroup::HitResults hitresult;
+ auto group = categoryAt(point + offset(), hitresult);
+ if(group && (hitresult & (VisualGroup::HeaderHit | VisualGroup::BodyHit)))
+ {
+ return group->text;
+ }
+ return QString();
+}
+
int GroupView::calculateItemsPerRow() const
{
return qFloor((qreal)(contentWidth()) / (qreal)(itemWidth() + m_spacing));
@@ -228,8 +241,9 @@ void GroupView::mousePressEvent(QMouseEvent *event)
m_pressedAlreadySelected = selectionModel()->isSelected(m_pressedIndex);
m_pressedPosition = geometryPos;
- m_pressedCategory = categoryAt(geometryPos);
- if (m_pressedCategory)
+ VisualGroup::HitResults hitresult;
+ m_pressedCategory = categoryAt(geometryPos, hitresult);
+ if (m_pressedCategory && hitresult & VisualGroup::CheckboxHit)
{
setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState);
event->accept();
@@ -325,8 +339,10 @@ void GroupView::mouseReleaseEvent(QMouseEvent *event)
QPoint geometryPos = event->pos() + offset();
QPersistentModelIndex index = indexAt(visualPos);
+ VisualGroup::HitResults hitresult;
+
bool click = (index == m_pressedIndex && index.isValid()) ||
- (m_pressedCategory && m_pressedCategory == categoryAt(geometryPos));
+ (m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitresult));
if (click && m_pressedCategory)
{