mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-16 17:11:37 +08:00
添加API调用接口,添加读取分类,添加SpkUtils实用函数
使用了SpkSidebarTree子类实现对TreeWidget的特殊要求:不能取消选择,不能拖拽选择。 API调用接口暂时写死。API会获取 配置文件已添加但暂不使用。
This commit is contained in:
31
gui/spksidebartree.cpp
Normal file
31
gui/spksidebartree.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user