From b1f627e875c2ca6a44cead3e22f5b4fb8ebe951f Mon Sep 17 00:00:00 2001 From: tsl115 Date: Fri, 24 Nov 2023 09:59:00 +0800 Subject: [PATCH] feat: Selected effects in the rune plugin were replaced Selected effects in the rune plugin were replaced --- src/plugins/symbol/CMakeLists.txt | 2 -- .../symbol/mainframe/symboldelegate.cpp | 36 ------------------- src/plugins/symbol/mainframe/symboldelegate.h | 24 ------------- .../symbol/mainframe/symboltreeview.cpp | 9 ++--- 4 files changed, 3 insertions(+), 68 deletions(-) delete mode 100644 src/plugins/symbol/mainframe/symboldelegate.cpp delete mode 100644 src/plugins/symbol/mainframe/symboldelegate.h diff --git a/src/plugins/symbol/CMakeLists.txt b/src/plugins/symbol/CMakeLists.txt index 16a241acc..3cee9e641 100644 --- a/src/plugins/symbol/CMakeLists.txt +++ b/src/plugins/symbol/CMakeLists.txt @@ -6,7 +6,6 @@ find_package(Clang REQUIRED) include_directories(${CLANG_INCLUDE_DIRS}) set(CXX_CPP - mainframe/symboldelegate.cpp mainframe/symbolmodel.cpp mainframe/symboltreeview.cpp mainframe/symbolkeeper.cpp @@ -20,7 +19,6 @@ set(CXX_CPP set(CXX_H mainframe/definitions.h - mainframe/symboldelegate.h mainframe/symbolmodel.h mainframe/symboltreeview.h mainframe/symbolkeeper.h diff --git a/src/plugins/symbol/mainframe/symboldelegate.cpp b/src/plugins/symbol/mainframe/symboldelegate.cpp deleted file mode 100644 index 1317f8cbb..000000000 --- a/src/plugins/symbol/mainframe/symboldelegate.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "symboldelegate.h" - -#include - -class SymbolDelegatePrivate -{ - friend class SymbolDelegate; - QModelIndex index; -}; - -SymbolDelegate::SymbolDelegate(QObject *parent) - : QStyledItemDelegate (parent) - , d (new SymbolDelegatePrivate) -{ - -} - -void SymbolDelegate::setActiveProject(const QModelIndex &root) -{ - d->index = root; -} - -void SymbolDelegate::paint(QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - QStyleOptionViewItem iOption = option; - if (d->index.isValid() && d->index == index) { - iOption.font.setBold(true); - } - QStyledItemDelegate::paint(painter, iOption, index); -} diff --git a/src/plugins/symbol/mainframe/symboldelegate.h b/src/plugins/symbol/mainframe/symboldelegate.h deleted file mode 100644 index 7f559726d..000000000 --- a/src/plugins/symbol/mainframe/symboldelegate.h +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef PROJECTDELEGATE_H -#define PROJECTDELEGATE_H - -#include - -class SymbolDelegatePrivate; -class SymbolDelegate : public QStyledItemDelegate -{ - Q_OBJECT - SymbolDelegatePrivate *const d; -public: - explicit SymbolDelegate(QObject *parent = nullptr); - void setActiveProject(const QModelIndex &root); -protected: - void paint(QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const override; -}; - -#endif // PROJECTDELEGATE_H diff --git a/src/plugins/symbol/mainframe/symboltreeview.cpp b/src/plugins/symbol/mainframe/symboltreeview.cpp index ce1084ae4..12a8919b9 100644 --- a/src/plugins/symbol/mainframe/symboltreeview.cpp +++ b/src/plugins/symbol/mainframe/symboltreeview.cpp @@ -8,8 +8,6 @@ #include "services/project/projectservice.h" -#include "symboldelegate.h" - #include #include #include @@ -25,7 +23,6 @@ class SymbolTreeViewPrivate SymbolTreeView *const q; QModelIndex selIndex; QFileSystemModel *model {nullptr}; - SymbolDelegate *delegate = {nullptr}; DMenu *getFileLineMenu(const QString &filePath); SymbolTreeViewPrivate(SymbolTreeView *qq): q(qq){} }; @@ -35,22 +32,22 @@ SymbolTreeView::SymbolTreeView(DWidget *parent) , d (new SymbolTreeViewPrivate(this)) { d->model = new SymbolModel(); - d->delegate = new SymbolDelegate; DTreeView::setModel(d->model); - DTreeView::setItemDelegate(d->delegate); setContextMenuPolicy(Qt::CustomContextMenu); setEditTriggers(DTreeView::NoEditTriggers); //节点不能编辑 setSelectionBehavior(DTreeView::SelectRows); //一次选中整行 setSelectionMode(DTreeView::SingleSelection); //单选,配合上面的整行就是一次选单行 - setFocusPolicy(Qt::NoFocus); //去掉鼠标移到节点上时的虚线框 header()->setVisible(false); + QObject::connect(this, &DTreeView::doubleClicked, this, &SymbolTreeView::doDoubleClieked, Qt::UniqueConnection); QObject::connect(this, &DTreeView::customContextMenuRequested, this, &SymbolTreeView::doContextMenu, Qt::UniqueConnection); + + } SymbolTreeView::~SymbolTreeView()