Changeset View
Changeset View
Standalone View
Standalone View
app/fileoperations.cpp
Show All 33 Lines | |||||
34 | #include <KIO/Job> | 34 | #include <KIO/Job> | ||
35 | #include <KIO/JobUiDelegate> | 35 | #include <KIO/JobUiDelegate> | ||
36 | #include <KLocalizedString> | 36 | #include <KLocalizedString> | ||
37 | #include <KJobWidgets> | 37 | #include <KJobWidgets> | ||
38 | 38 | | |||
39 | // Local | 39 | // Local | ||
40 | #include <lib/document/documentfactory.h> | 40 | #include <lib/document/documentfactory.h> | ||
41 | #include <lib/thumbnailprovider/thumbnailprovider.h> | 41 | #include <lib/thumbnailprovider/thumbnailprovider.h> | ||
42 | #include <lib/contextmanager.h> | ||||
cfeck: Not sure if the Diff is messed up, but here it looks like you are duplicating the include. | |||||
42 | 43 | | |||
cfeck: Please add empty line after include section. | |||||
43 | namespace Gwenview | 44 | namespace Gwenview | ||
44 | { | 45 | { | ||
45 | 46 | | |||
46 | namespace FileOperations | 47 | namespace FileOperations | ||
47 | { | 48 | { | ||
48 | 49 | | |||
49 | static void copyMoveOrLink(Operation operation, const QList<QUrl>& urlList, QWidget* parent) | 50 | static void copyMoveOrLink(Operation operation, const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager) | ||
50 | { | 51 | { | ||
51 | Q_ASSERT(!urlList.isEmpty()); | 52 | Q_ASSERT(!urlList.isEmpty()); | ||
52 | 53 | | |||
53 | QFileDialog dialog(parent, QString(), "kfiledialog:///<copyMoveOrLink>"); | 54 | QFileDialog dialog(parent->nativeParentWidget(), QString()); | ||
cfeck: Please only use single empty lines. | |||||
54 | dialog.setAcceptMode(QFileDialog::AcceptSave); | 55 | dialog.setAcceptMode(QFileDialog::AcceptSave); | ||
55 | 56 | | |||
56 | switch (operation) { | 57 | switch (operation) { | ||
57 | case COPY: | 58 | case COPY: | ||
58 | dialog.setWindowTitle(i18nc("@title:window", "Copy To")); | 59 | dialog.setWindowTitle(i18nc("@title:window", "Copy To")); | ||
59 | dialog.setLabelText(QFileDialog::DialogLabel::Accept, i18nc("@action:button", "Copy")); | 60 | dialog.setLabelText(QFileDialog::DialogLabel::Accept, i18nc("@action:button", "Copy")); | ||
60 | break; | 61 | break; | ||
61 | case MOVE: | 62 | case MOVE: | ||
Show All 9 Lines | |||||
71 | } | 72 | } | ||
72 | 73 | | |||
73 | if (urlList.count() == 1) { | 74 | if (urlList.count() == 1) { | ||
74 | dialog.setFileMode(QFileDialog::AnyFile); | 75 | dialog.setFileMode(QFileDialog::AnyFile); | ||
75 | dialog.selectUrl(urlList.first()); | 76 | dialog.selectUrl(urlList.first()); | ||
76 | } else { | 77 | } else { | ||
77 | dialog.setFileMode(QFileDialog::Directory); | 78 | dialog.setFileMode(QFileDialog::Directory); | ||
78 | dialog.setOption(QFileDialog::ShowDirsOnly, true); | 79 | dialog.setOption(QFileDialog::ShowDirsOnly, true); | ||
79 | dialog.setDirectoryUrl(urlList.first().adjusted(QUrl::RemoveFilename)); | | |||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | dialog.setDirectoryUrl(contextManager->targetUrl().adjusted(QUrl::RemoveFilename)); | ||||
82 | if (!dialog.exec()) { | 83 | if (!dialog.exec()) { | ||
83 | return; | 84 | return; | ||
84 | } | 85 | } | ||
85 | 86 | | |||
86 | QUrl destUrl = dialog.selectedUrls().first(); | 87 | QUrl destUrl = dialog.selectedUrls().first(); | ||
88 | contextManager->setTargetUrl(destUrl); | ||||
89 | | ||||
87 | KIO::CopyJob* job = 0; | 90 | KIO::CopyJob* job = 0; | ||
88 | switch (operation) { | 91 | switch (operation) { | ||
89 | case COPY: | 92 | case COPY: | ||
90 | job = KIO::copy(urlList, destUrl); | 93 | job = KIO::copy(urlList, destUrl); | ||
91 | break; | 94 | break; | ||
92 | case MOVE: | 95 | case MOVE: | ||
93 | job = KIO::move(urlList, destUrl); | 96 | job = KIO::move(urlList, destUrl); | ||
94 | break; | 97 | break; | ||
Show All 30 Lines | 109 | { | |||
125 | Q_ASSERT(job); | 128 | Q_ASSERT(job); | ||
126 | KJobWidgets::setWindow(job,parent); | 129 | KJobWidgets::setWindow(job,parent); | ||
127 | 130 | | |||
128 | Q_FOREACH(const QUrl &url, urlList) { | 131 | Q_FOREACH(const QUrl &url, urlList) { | ||
129 | DocumentFactory::instance()->forget(url); | 132 | DocumentFactory::instance()->forget(url); | ||
130 | } | 133 | } | ||
131 | } | 134 | } | ||
132 | 135 | | |||
133 | void copyTo(const QList<QUrl>& urlList, QWidget* parent) | 136 | void copyTo(const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager) | ||
134 | { | 137 | { | ||
135 | copyMoveOrLink(COPY, urlList, parent); | 138 | copyMoveOrLink(COPY, urlList, parent, contextManager); | ||
136 | } | 139 | } | ||
137 | 140 | | |||
138 | void moveTo(const QList<QUrl>& urlList, QWidget* parent) | 141 | void moveTo(const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager) | ||
139 | { | 142 | { | ||
140 | copyMoveOrLink(MOVE, urlList, parent); | 143 | copyMoveOrLink(MOVE, urlList, parent, contextManager); | ||
141 | } | 144 | } | ||
142 | 145 | | |||
143 | void linkTo(const QList<QUrl>& urlList, QWidget* parent) | 146 | void linkTo(const QList<QUrl>& urlList, QWidget* parent, ContextManager* contextManager) | ||
144 | { | 147 | { | ||
145 | copyMoveOrLink(LINK, urlList, parent); | 148 | copyMoveOrLink(LINK, urlList, parent, contextManager); | ||
146 | } | 149 | } | ||
147 | 150 | | |||
148 | void trash(const QList<QUrl>& urlList, QWidget* parent) | 151 | void trash(const QList<QUrl>& urlList, QWidget* parent) | ||
149 | { | 152 | { | ||
150 | delOrTrash(KIO::JobUiDelegate::Trash, urlList, parent); | 153 | delOrTrash(KIO::JobUiDelegate::Trash, urlList, parent); | ||
151 | } | 154 | } | ||
152 | 155 | | |||
153 | void del(const QList<QUrl>& urlList, QWidget* parent) | 156 | void del(const QList<QUrl>& urlList, QWidget* parent) | ||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |
Not sure if the Diff is messed up, but here it looks like you are duplicating the include.