From 0b1df764041ecb1643a24ab00a7a6fe9dfd3b529 Mon Sep 17 00:00:00 2001 From: "huheng@kylinos.cn" Date: Fri, 25 Nov 2022 11:33:22 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(UI=E6=A8=A1=E5=9D=97):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E5=93=8D=E5=BA=94=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/filemanageview/fileview.cpp | 7 ++++++- ui/filemanageview/fileview.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/filemanageview/fileview.cpp b/ui/filemanageview/fileview.cpp index 617a5fa..4d3d1e7 100644 --- a/ui/filemanageview/fileview.cpp +++ b/ui/filemanageview/fileview.cpp @@ -142,6 +142,11 @@ FileView::ItemSelectMode FileView::getItemMode() const return m_itemMode; } +void FileView::setAllowDrag(bool isAllowDrag) +{ + m_isAllowDrag = isAllowDrag; +} + void FileView::mousePressEvent(QMouseEvent *event) { if (!indexAt(event->pos()).isValid()) { @@ -181,7 +186,7 @@ void FileView::keyPressEvent(QKeyEvent *event) void FileView::dragEnterEvent(QDragEnterEvent *event) { - if (event->mimeData()->hasUrls() && m_itemMode == ItemSelectMode::Default) { + if (m_isAllowDrag && m_itemMode == ItemSelectMode::Default && event->mimeData()->hasUrls()) { event->accept(); } else { event->ignore(); diff --git a/ui/filemanageview/fileview.h b/ui/filemanageview/fileview.h index db11fd1..99177ef 100644 --- a/ui/filemanageview/fileview.h +++ b/ui/filemanageview/fileview.h @@ -34,6 +34,7 @@ public: PublicAttributes::Theme getTheme() const; void setItemMode(FileView::ItemSelectMode mode); FileView::ItemSelectMode getItemMode() const; + void setAllowDrag(bool isAllowDrag); protected: void mousePressEvent(QMouseEvent *event) override; @@ -72,6 +73,7 @@ private: QListView::ViewMode m_viewModel = QListView::IconMode; // 当前视图模式 PublicAttributes::Theme m_theme = PublicAttributes::Theme::Light; // 当前主题 FileView::ItemSelectMode m_itemMode = FileView::ItemSelectMode::Default; // 当前item视图模式 + bool m_isAllowDrag = true; }; #endif // FILEVIEW_H