mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-06 19:32:22 +08:00
32 lines
786 B
C++
32 lines
786 B
C++
|
|
#include <QMouseEvent>
|
|
#include "spksidebartree.h"
|
|
|
|
SpkUi::SpkSidebarTree::SpkSidebarTree(QWidget *parent) :
|
|
QTreeWidget(parent)
|
|
{
|
|
|
|
}
|
|
|
|
void SpkUi::SpkSidebarTree::mouseMoveEvent(QMouseEvent *e)
|
|
{
|
|
// This is solely for forcibly disabling the view to change selection when dragging on the view
|
|
// and probably the only reason why this class began its existence
|
|
if((e->buttons() & Qt::LeftButton))
|
|
setState(NoState);
|
|
else
|
|
QTreeWidget::mouseMoveEvent(e);
|
|
}
|
|
|
|
void SpkUi::SpkSidebarTree::mousePressEvent(QMouseEvent *e)
|
|
{
|
|
// Prevent anything being deselected
|
|
if(e->modifiers().testFlag(Qt::ControlModifier) && e->buttons().testFlag(Qt::LeftButton))
|
|
{
|
|
auto i = itemAt(e->pos());
|
|
if(i && i->isSelected())
|
|
return;
|
|
}
|
|
QTreeWidget::mousePressEvent(e);
|
|
}
|