1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef PROJECTTREE_H |
6 | #define PROJECTTREE_H |
7 | |
8 | #include "services/project/projectservice.h" |
9 | |
10 | #include <QTreeView> |
11 | |
12 | class QStandardItem; |
13 | class ProjectTreePrivate; |
14 | class ProjectTree : public QTreeView |
15 | { |
16 | Q_OBJECT |
17 | ProjectTreePrivate *const d; |
18 | |
19 | public: |
20 | explicit ProjectTree(QWidget *parent = nullptr); |
21 | ~ProjectTree() override; |
22 | void appendProjectInfo(const dpfservice::ProjectInfo &info); |
23 | void activeProjectInfo(const dpfservice::ProjectInfo &info); |
24 | void activeProjectInfo(const QString &kitName, const QString &language, |
25 | const QString &workspace); |
26 | void appendRootItem(QStandardItem *root); |
27 | void removeRootItem(QStandardItem *root); |
28 | void takeRootItem(QStandardItem *root); |
29 | void expandedProjectDepth(const QStandardItem *root, int depth); |
30 | void expandedProjectAll(const QStandardItem *root); |
31 | QList<dpfservice::ProjectInfo> getAllProjectInfo(); |
32 | dpfservice::ProjectInfo getProjectInfo(const QString &kitName, const QString &workspace); |
33 | dpfservice::ProjectInfo getActiveProjectInfo() const; |
34 | |
35 | Q_SIGNALS: |
36 | void (const QModelIndex &index, QContextMenuEvent *event); |
37 | void itemMenuRequest(QStandardItem *item, QContextMenuEvent *event); |
38 | |
39 | protected: |
40 | void (QContextMenuEvent *event) override; |
41 | void mousePressEvent(QMouseEvent *event) override; |
42 | void mouseMoveEvent(QMouseEvent *event) override; |
43 | |
44 | private: |
45 | QMenu *childMenu(const QStandardItem *root, const QStandardItem *child); |
46 | QMenu *rootMenu(QStandardItem *root); |
47 | void performDrag(); |
48 | |
49 | public slots: |
50 | void itemModified(QStandardItem *item, const QList<QStandardItem *> &childs); |
51 | |
52 | private slots: |
53 | void doItemMenuRequest(QStandardItem *item, QContextMenuEvent *event); |
54 | void doDoubleClieked(const QModelIndex &index); |
55 | void doCloseProject(QStandardItem *root); |
56 | void doShowProjectInfo(QStandardItem *root); |
57 | void doActiveProject(QStandardItem *root); |
58 | void actionNewDocument(const QStandardItem *item); |
59 | void actionDeleteDocument(const QStandardItem *item); |
60 | void creatNewDocument(const QStandardItem *item, const QString &fileName); |
61 | }; |
62 | |
63 | #endif // PROJECTTREE_H |
64 | |