Commit 7be60997 authored by Simon Thiel's avatar Simon Thiel Committed by Christoph Feck
Browse files

Remember paths for Copy-To and Move-To

BUG: 362474
FIXED-IN: 17.08.1

Differential Revision: https://phabricator.kde.org/D6379
parent fd658695
......@@ -39,6 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
// Local
#include <lib/document/documentfactory.h>
#include <lib/thumbnailprovider/thumbnailprovider.h>
#include <lib/contextmanager.h>
namespace Gwenview
{
......@@ -46,11 +47,11 @@ namespace Gwenview
namespace FileOperations
{
static void copyMoveOrLink(Operation operation, const QList<QUrl>& urlList, QWidget* parent)
static void copyMoveOrLink(Operation operation, const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager)
{
Q_ASSERT(!urlList.isEmpty());
QFileDialog dialog(parent, QString(), "kfiledialog:///<copyMoveOrLink>");
QFileDialog dialog(parent->nativeParentWidget(), QString());
dialog.setAcceptMode(QFileDialog::AcceptSave);
switch (operation) {
......@@ -76,14 +77,16 @@ static void copyMoveOrLink(Operation operation, const QList<QUrl>& urlList, QWid
} else {
dialog.setFileMode(QFileDialog::Directory);
dialog.setOption(QFileDialog::ShowDirsOnly, true);
dialog.setDirectoryUrl(urlList.first().adjusted(QUrl::RemoveFilename));
}
dialog.setDirectoryUrl(contextManager->targetUrl().adjusted(QUrl::RemoveFilename));
if (!dialog.exec()) {
return;
}
QUrl destUrl = dialog.selectedUrls().first();
contextManager->setTargetUrl(destUrl);
KIO::CopyJob* job = 0;
switch (operation) {
case COPY:
......@@ -130,19 +133,19 @@ static void delOrTrash(KIO::JobUiDelegate::DeletionType deletionType, const QLis
}
}
void copyTo(const QList<QUrl>& urlList, QWidget* parent)
void copyTo(const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager)
{
copyMoveOrLink(COPY, urlList, parent);
copyMoveOrLink(COPY, urlList, parent, contextManager);
}
void moveTo(const QList<QUrl>& urlList, QWidget* parent)
void moveTo(const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager)
{
copyMoveOrLink(MOVE, urlList, parent);
copyMoveOrLink(MOVE, urlList, parent, contextManager);
}
void linkTo(const QList<QUrl>& urlList, QWidget* parent)
void linkTo(const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager)
{
copyMoveOrLink(LINK, urlList, parent);
copyMoveOrLink(LINK, urlList, parent, contextManager);
}
void trash(const QList<QUrl>& urlList, QWidget* parent)
......
......@@ -22,8 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#define FILEOPERATIONS_H
#include <QUrl>
#include <QWidget>
class QWidget;
class ContextManager;
namespace Gwenview
{
......@@ -33,9 +35,9 @@ namespace FileOperations
enum Operation { TRASH, COPY, MOVE, LINK, UNKNOWN, PUT };
void copyTo(const QList<QUrl>& urlList, QWidget* parent);
void moveTo(const QList<QUrl>& urlList, QWidget* parent);
void linkTo(const QList<QUrl>& urlList, QWidget* parent);
void copyTo(const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager);
void moveTo(const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager);
void linkTo(const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager);
void trash(const QList<QUrl>& urlList, QWidget* parent);
void del(const QList<QUrl>& urlList, QWidget* parent);
void rename(const QUrl &url, QWidget* parent);
......
......@@ -329,17 +329,17 @@ void FileOpsContextManagerItem::restore()
void FileOpsContextManagerItem::copyTo()
{
FileOperations::copyTo(urlList(), mGroup);
FileOperations::copyTo(urlList(), widget(), contextManager());
}
void FileOpsContextManagerItem::moveTo()
{
FileOperations::moveTo(urlList(), mGroup);
FileOperations::moveTo(urlList(), widget(), contextManager());
}
void FileOpsContextManagerItem::linkTo()
{
FileOperations::linkTo(urlList(), mGroup);
FileOperations::linkTo(urlList(), widget(), contextManager());
}
void FileOpsContextManagerItem::rename()
......
......@@ -46,6 +46,7 @@ struct ContextManagerPrivate
QUrl mCurrentUrl;
QUrl mUrlToSelect;
QUrl mTargetUrl;
bool mSelectedFileItemListNeedsUpdate;
QSet<QByteArray> mQueuedSignals;
......@@ -279,6 +280,17 @@ void ContextManager::setUrlToSelect(const QUrl &url)
selectUrlToSelect();
}
QUrl ContextManager::targetUrl() const
{
return d->mTargetUrl;
}
void ContextManager::setTargetUrl(const QUrl &url)
{
GV_RETURN_IF_FAIL(url.isValid());
d->mTargetUrl = url;
}
void ContextManager::slotRowsInserted()
{
// We reach this method when rows have been inserted in the model, but views
......
......@@ -71,6 +71,10 @@ public:
void setUrlToSelect(const QUrl&);
QUrl targetUrl() const;
void setTargetUrl(const QUrl&);
Q_SIGNALS:
void currentDirUrlChanged(const QUrl&);
void currentUrlChanged(const QUrl&);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment