|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QTreeWidget>
|
|
|
|
|
#include "mModuleDefines.h"
|
|
|
|
|
#include "TreeItemBase.h"
|
|
|
|
|
|
|
|
|
|
class M_GUI_TREE_EXPORT TreeWxBase : public QTreeWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
TreeWxBase(QWidget* parent = 0);
|
|
|
|
|
~TreeWxBase();
|
|
|
|
|
|
|
|
|
|
virtual void refresh();
|
|
|
|
|
//virtual QStringList getParentsOf(TreeItemBase* p);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
// 公共Action初始化
|
|
|
|
|
virtual void initCommonActions();
|
|
|
|
|
|
|
|
|
|
// 右键菜单功能总调用
|
|
|
|
|
virtual void initContextMenu(QMenu* pMenu);
|
|
|
|
|
// 空节点通用
|
|
|
|
|
virtual void initContextMenuCommonAll(QMenu* pMenu);
|
|
|
|
|
// 节点通用
|
|
|
|
|
virtual void initContextMenuCommonNode(QMenu* pMenu);
|
|
|
|
|
|
|
|
|
|
// 填充
|
|
|
|
|
virtual void fillTree();
|
|
|
|
|
|
|
|
|
|
// 右键的部分功能重载实现
|
|
|
|
|
virtual bool showOrEditNode(QTreeWidgetItem* pItem);
|
|
|
|
|
virtual bool delCurrentNodes(QList<TreeItemBase*>& listItems);
|
|
|
|
|
virtual bool renameCurrentNode(QString sNew);
|
|
|
|
|
virtual void doubleClickItem(QTreeWidgetItem* pItem);
|
|
|
|
|
virtual void enteredItem(QTreeWidgetItem* pItem);
|
|
|
|
|
|
|
|
|
|
// 拖拽支持
|
|
|
|
|
void dragEnterEvent(QDragEnterEvent* event);
|
|
|
|
|
void dropEvent(QDropEvent* event);
|
|
|
|
|
|
|
|
|
|
// 拖拽相关的信号
|
|
|
|
|
virtual bool isDragAccepted(QDragEnterEvent* event);
|
|
|
|
|
virtual void dealwithDrop(QDropEvent* event);
|
|
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
|
|
|
|
|
// 触发项目树节点
|
|
|
|
|
void sigRunNodeCmd(TreeItemBase* , TreeNodeCmd, bool&);
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
|
|
// 具体响应函数
|
|
|
|
|
virtual void slotShowContextMenu(const QPoint &pos);
|
|
|
|
|
virtual void slotItemDoubleClicked(QTreeWidgetItem* item, int column);
|
|
|
|
|
virtual void slotItemEntered(QTreeWidgetItem* item, int column);
|
|
|
|
|
|
|
|
|
|
// 节点右键操作
|
|
|
|
|
virtual void slotDelNodes();
|
|
|
|
|
virtual void slotEditNode();
|
|
|
|
|
virtual void slotRenameNode();
|
|
|
|
|
virtual void slotItemNodeNameChanged(); //节点名称改变的槽
|
|
|
|
|
|
|
|
|
|
// 节点统一操作
|
|
|
|
|
virtual void slotExpandNode();
|
|
|
|
|
virtual void slotExpandNodeAll();
|
|
|
|
|
virtual void slotCollapseNode();
|
|
|
|
|
virtual void slotCollapseNodeAll();
|
|
|
|
|
virtual void slotRefresh();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
QMenu* m_pMenu;
|
|
|
|
|
TreeItemBase* m_pItemSel;
|
|
|
|
|
TreeItemBase* m_pRenameItem;
|
|
|
|
|
|
|
|
|
|
// 公共的Action项
|
|
|
|
|
QAction* m_pActionRename;
|
|
|
|
|
QAction* m_pActionEdit;
|
|
|
|
|
QAction* m_pActionDel;
|
|
|
|
|
|
|
|
|
|
// 临时
|
|
|
|
|
bool m_bDraging;
|
|
|
|
|
};
|