Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Abnormal background color selected in symbol plugin #105

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/plugins/symbol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
36 changes: 0 additions & 36 deletions src/plugins/symbol/mainframe/symboldelegate.cpp

This file was deleted.

24 changes: 0 additions & 24 deletions src/plugins/symbol/mainframe/symboldelegate.h

This file was deleted.

9 changes: 3 additions & 6 deletions src/plugins/symbol/mainframe/symboltreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#include "services/project/projectservice.h"

#include "symboldelegate.h"

#include <DMenu>
#include <DTreeView>
#include <DWidget>
Expand All @@ -25,9 +23,8 @@
SymbolTreeView *const q;
QModelIndex selIndex;
QFileSystemModel *model {nullptr};
SymbolDelegate *delegate = {nullptr};
DMenu *getFileLineMenu(const QString &filePath);
SymbolTreeViewPrivate(SymbolTreeView *qq): q(qq){}

Check warning on line 27 in src/plugins/symbol/mainframe/symboltreeview.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Class 'SymbolTreeViewPrivate' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.
};

SymbolTreeView::SymbolTreeView(DWidget *parent)
Expand All @@ -35,22 +32,22 @@
, d (new SymbolTreeViewPrivate(this))
{
d->model = new SymbolModel();
d->delegate = new SymbolDelegate;
DTreeView::setModel(d->model);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确认下:这个symboldelegate是不是没用了,是否可以删除该类

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之所以这么修改是因为,如果使用了这个的话,会导致选中后的蓝色背景没有圆角,试了下应该是可以删除这个类的

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

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()
Expand Down