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