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

fix: [workspace] select issue #1892

Merged
merged 3 commits into from
Mar 27, 2024
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
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
dde-file-manager (6.0.42) unstable; urgency=medium

* update file manager baseline version to V6.0.42

-- liuyangming <[email protected]> Wed, 27 Mar 2024 16:56:00 +0800

dde-file-manager (6.0.41) unstable; urgency=medium

* update file manager baseline version to V6.0.41
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ void WorkspaceEventReceiver::handlePasteFileResult(const QList<QUrl> &srcUrls, c
Q_UNUSED(ok)
Q_UNUSED(errMsg)

if (!destUrls.isEmpty())
// if paste files from revocation operate, these files should not be selected.
QList<QUrl> filterUrls = WorkspaceHelper::instance()->filterUndoFiles(destUrls);

if (!filterUrls.isEmpty())
WorkspaceHelper::instance()->laterRequestSelectFiles(destUrls);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void FileOperatorHelper::undoFiles(const FileView *view)
auto windowId = WorkspaceHelper::instance()->windowId(view);

dpfSignalDispatcher->publish(GlobalEventType::kRevocation,
windowId, nullptr);
windowId, undoCallBack);
}

void FileOperatorHelper::moveToTrash(const FileView *view)
Expand Down Expand Up @@ -415,6 +415,7 @@ FileOperatorHelper::FileOperatorHelper(QObject *parent)
: QObject(parent)
{
callBack = std::bind(&FileOperatorHelper::callBackFunction, this, std::placeholders::_1);
undoCallBack = std::bind(&FileOperatorHelper::undoCallBackFunction, this, std::placeholders::_1);
}

void FileOperatorHelper::callBackFunction(const AbstractJobHandler::CallbackArgus args)
Expand Down Expand Up @@ -457,3 +458,18 @@ void FileOperatorHelper::callBackFunction(const AbstractJobHandler::CallbackArgu
break;
}
}

void FileOperatorHelper::undoCallBackFunction(QSharedPointer<AbstractJobHandler> handler)
{
connect(handler.data(), &AbstractJobHandler::finishedNotify, this, [ = ](const JobInfoPointer jobInfo){
AbstractJobHandler::JobType type = static_cast<AbstractJobHandler::JobType>(jobInfo->value(AbstractJobHandler::kJobtypeKey).toInt());
if (type == AbstractJobHandler::JobType::kCutType) {
QList<QUrl> targetUrls(jobInfo->value(AbstractJobHandler::kCompleteTargetFilesKey).value<QList<QUrl>>());
WorkspaceHelper::instance()->setUndoFiles(targetUrls);
}
});

connect(handler.data(), &AbstractJobHandler::workerFinish, this, [ = ](){
WorkspaceHelper::instance()->setUndoFiles({});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ class FileOperatorHelper : public QObject
private:
explicit FileOperatorHelper(QObject *parent = nullptr);
void callBackFunction(const DFMBASE_NAMESPACE::AbstractJobHandler::CallbackArgus args);
void undoCallBackFunction(QSharedPointer<DFMBASE_NAMESPACE::AbstractJobHandler> handler);

DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callBack;
DFMBASE_NAMESPACE::AbstractJobHandler::OperatorHandleCallback undoCallBack;
};

#define FileOperatorHelperIns \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,27 @@
return !notSupportTreeView.contains(scheme);
}

void WorkspaceHelper::setUndoFiles(const QList<QUrl> &files)
{
undoFiles = files;
}

QList<QUrl> WorkspaceHelper::filterUndoFiles(const QList<QUrl> &urlList) const
{
QList<QUrl> urls(urlList);
for (auto url : urlList) {
for (auto undoFile : undoFiles) {
if (UniversalUtils::urlEquals(url, undoFile)) {
urls.removeAll(url);
break;
}
}
}

return urls;
}

void WorkspaceHelper::installWorkspaceWidgetToWindow(const quint64 windowID)

Check warning on line 425 in src/plugins/filemanager/core/dfmplugin-workspace/utils/workspacehelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'installWorkspaceWidgetToWindow' is never used.
{
WorkspaceWidget *widget = nullptr;
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ class WorkspaceHelper : public QObject
void setNotSupportTreeView(const QString &scheme);
bool supportTreeView(const QString &scheme) const;

void setUndoFiles(const QList<QUrl> &files);
QList<QUrl> filterUndoFiles(const QList<QUrl> &urlList) const;

static QMap<quint64, QPair<QUrl, QUrl>> kSelectionAndRenameFile; //###: for creating new file.
static QMap<quint64, QPair<QUrl, QUrl>> kSelectionFile; //###: rename a file which must be existance.

Expand Down Expand Up @@ -125,6 +128,8 @@ public Q_SLOTS:
QList<QString> registeredFileViewScheme {};
QList<QString> notSupportTreeView{};

QList<QUrl> undoFiles {};

Q_DISABLE_COPY(WorkspaceHelper)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ QRect BaseItemDelegate::getRectOfItem(RectOfItemType type, const QModelIndex &in
return QRect();
}

bool BaseItemDelegate::itemExpanded()
{
return false;
}

QRect BaseItemDelegate::expandItemRect()
{
return QRect();
}

QModelIndex BaseItemDelegate::expandedIndex()
{
return QModelIndex();
}

FileViewHelper *BaseItemDelegate::parent() const
{
return dynamic_cast<FileViewHelper *>(QStyledItemDelegate::parent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ class BaseItemDelegate : public QStyledItemDelegate

virtual QRect getRectOfItem(RectOfItemType type, const QModelIndex &index) const;

virtual bool itemExpanded();
virtual QRect expandItemRect();
virtual QModelIndex expandedIndex();

QModelIndex editingIndex() const;

QWidget *editingIndexWidget() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,10 @@ QModelIndex FileView::iconIndexAt(const QPoint &pos, const QSize &itemSize) cons
iconVerticalTopMargin = DSizeModeHelper::element(kCompactIconVerticalTopMargin, kIconVerticalTopMargin);
#endif

if (itemDelegate()->itemExpanded() && itemDelegate()->expandItemRect().contains(pos)) {
return itemDelegate()->expandedIndex();
}

QPoint actualPos = QPoint(pos.x() + horizontalOffset(), pos.y() + verticalOffset() - iconVerticalTopMargin);
auto index = FileViewHelper::caculateIconItemIndex(this, itemSize, actualPos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,34 @@ QList<QRect> IconItemDelegate::itemGeomertys(const QStyleOptionViewItem &opt, co
return geometries;
}

bool IconItemDelegate::itemExpanded()
{
Q_D(IconItemDelegate);

return d->expandedIndex.isValid() && d->expandedItem->isVisible();
}

QRect IconItemDelegate::expandItemRect()
{
Q_D(IconItemDelegate);

if (d->expandedIndex.isValid() && d->expandedItem->isVisible()) {
QRect itemRect = d->expandedItem->getOption().rect;
QRect textRect = d->expandedItem->textGeometry().toRect();
textRect.moveTopLeft(itemRect.topLeft() + textRect.topLeft());
return textRect;
}

return QRect();
}

QModelIndex IconItemDelegate::expandedIndex()
{
Q_D(IconItemDelegate);

return d->expandedIndex;
}

QString IconItemDelegate::displayFileName(const QModelIndex &index) const
{
bool showSuffix { Application::instance()->genericAttribute(Application::kShowedFileSuffix).toBool() };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class IconItemDelegate : public BaseItemDelegate
QRectF itemIconRect(const QRectF &itemRect) const override;
QList<QRect> itemGeomertys(const QStyleOptionViewItem &opt, const QModelIndex &index) const override;

bool itemExpanded() override;
QRect expandItemRect() override;
QModelIndex expandedIndex() override;

QString displayFileName(const QModelIndex &index) const;
QList<QRectF> calFileNameRect(const QString &name, const QRectF &rect, Qt::TextElideMode elideMode) const;

Expand Down
Loading