Changeset View
Changeset View
Standalone View
Standalone View
krusader/Panel/krfiletreeview.cpp
Show All 17 Lines | |||||
18 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | 18 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||
19 | *****************************************************************************/ | 19 | *****************************************************************************/ | ||
20 | #include "krfiletreeview.h" | 20 | #include "krfiletreeview.h" | ||
21 | 21 | | |||
22 | #include "panelfunc.h" | 22 | #include "panelfunc.h" | ||
23 | 23 | | |||
24 | #include "../defaults.h" | 24 | #include "../defaults.h" | ||
25 | #include "../krglobal.h" | 25 | #include "../krglobal.h" | ||
26 | #include "../icon.h" | ||||
26 | #include "../FileSystem/filesystemprovider.h" | 27 | #include "../FileSystem/filesystemprovider.h" | ||
27 | 28 | | |||
28 | #include <QAction> | 29 | #include <QAction> | ||
29 | #include <QApplication> | 30 | #include <QApplication> | ||
30 | #include <QCursor> | 31 | #include <QCursor> | ||
31 | #include <QDir> | 32 | #include <QDir> | ||
32 | #include <QDropEvent> | 33 | #include <QDropEvent> | ||
33 | #include <QHeaderView> | 34 | #include <QHeaderView> | ||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Line(s) | 236 | { | |||
240 | const KFileItem fileItem = mSourceModel->itemForIndex(mProxyModel->mapToSource(index)); | 241 | const KFileItem fileItem = mSourceModel->itemForIndex(mProxyModel->mapToSource(index)); | ||
241 | const KFileItemListProperties capabilities(KFileItemList() << fileItem); | 242 | const KFileItemListProperties capabilities(KFileItemList() << fileItem); | ||
242 | 243 | | |||
243 | QMenu* popup = new QMenu(this); | 244 | QMenu* popup = new QMenu(this); | ||
244 | 245 | | |||
245 | // TODO nice to have: "open with" | 246 | // TODO nice to have: "open with" | ||
246 | 247 | | |||
247 | // cut/copy/paste | 248 | // cut/copy/paste | ||
248 | QAction* cutAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-cut")), i18nc("@action:inmenu", "Cut"), this); | 249 | QAction* cutAction = new QAction(Icon(QStringLiteral("edit-cut")), i18nc("@action:inmenu", "Cut"), this); | ||
249 | cutAction->setEnabled(capabilities.supportsMoving()); | 250 | cutAction->setEnabled(capabilities.supportsMoving()); | ||
250 | connect(cutAction, &QAction::triggered, this, [=]() { copyToClipBoard(fileItem, true); }); | 251 | connect(cutAction, &QAction::triggered, this, [=]() { copyToClipBoard(fileItem, true); }); | ||
251 | popup->addAction(cutAction); | 252 | popup->addAction(cutAction); | ||
252 | 253 | | |||
253 | QAction* copyAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18nc("@action:inmenu", "Copy"), this); | 254 | QAction* copyAction = new QAction(Icon(QStringLiteral("edit-copy")), i18nc("@action:inmenu", "Copy"), this); | ||
254 | connect(copyAction, &QAction::triggered, this, [=]() { copyToClipBoard(fileItem, false); }); | 255 | connect(copyAction, &QAction::triggered, this, [=]() { copyToClipBoard(fileItem, false); }); | ||
255 | popup->addAction(copyAction); | 256 | popup->addAction(copyAction); | ||
256 | 257 | | |||
257 | const QMimeData *mimeData = QApplication::clipboard()->mimeData(); | 258 | const QMimeData *mimeData = QApplication::clipboard()->mimeData(); | ||
258 | bool canPaste; | 259 | bool canPaste; | ||
259 | const QString text = KIO::pasteActionText(mimeData, &canPaste, fileItem); | 260 | const QString text = KIO::pasteActionText(mimeData, &canPaste, fileItem); | ||
260 | QAction* pasteAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), text, this); | 261 | QAction* pasteAction = new QAction(Icon(QStringLiteral("edit-paste")), text, this); | ||
261 | connect(pasteAction, &QAction::triggered, this, [=]() { | 262 | connect(pasteAction, &QAction::triggered, this, [=]() { | ||
262 | KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), fileItem.url()); | 263 | KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), fileItem.url()); | ||
263 | KJobWidgets::setWindow(job, this); | 264 | KJobWidgets::setWindow(job, this); | ||
264 | }); | 265 | }); | ||
265 | pasteAction->setEnabled(canPaste); | 266 | pasteAction->setEnabled(canPaste); | ||
266 | popup->addAction(pasteAction); | 267 | popup->addAction(pasteAction); | ||
267 | 268 | | |||
268 | popup->addSeparator(); | 269 | popup->addSeparator(); | ||
269 | 270 | | |||
270 | // TODO nice to have: rename | 271 | // TODO nice to have: rename | ||
271 | 272 | | |||
272 | // trash | 273 | // trash | ||
273 | if (KConfigGroup(krConfig, "General").readEntry("Move To Trash", _MoveToTrash)) { | 274 | if (KConfigGroup(krConfig, "General").readEntry("Move To Trash", _MoveToTrash)) { | ||
274 | QAction* moveToTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("user-trash")), | 275 | QAction* moveToTrashAction = new QAction(Icon(QStringLiteral("user-trash")), | ||
275 | i18nc("@action:inmenu", "Move to Trash"), this); | 276 | i18nc("@action:inmenu", "Move to Trash"), this); | ||
276 | const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); | 277 | const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); | ||
277 | moveToTrashAction->setEnabled(enableMoveToTrash); | 278 | moveToTrashAction->setEnabled(enableMoveToTrash); | ||
278 | connect(moveToTrashAction, &QAction::triggered, this, [=]() { | 279 | connect(moveToTrashAction, &QAction::triggered, this, [=]() { | ||
279 | deleteFile(fileItem, true); | 280 | deleteFile(fileItem, true); | ||
280 | }); | 281 | }); | ||
281 | popup->addAction(moveToTrashAction); | 282 | popup->addAction(moveToTrashAction); | ||
282 | } | 283 | } | ||
283 | 284 | | |||
284 | // delete | 285 | // delete | ||
285 | QAction *deleteAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-delete")), | 286 | QAction *deleteAction = new QAction(Icon(QStringLiteral("edit-delete")), | ||
286 | i18nc("@action:inmenu", "Delete"), this); | 287 | i18nc("@action:inmenu", "Delete"), this); | ||
287 | deleteAction->setEnabled(capabilities.supportsDeleting()); | 288 | deleteAction->setEnabled(capabilities.supportsDeleting()); | ||
288 | connect(deleteAction, &QAction::triggered, this, [=]() { | 289 | connect(deleteAction, &QAction::triggered, this, [=]() { | ||
289 | deleteFile(fileItem, false); | 290 | deleteFile(fileItem, false); | ||
290 | }); | 291 | }); | ||
291 | popup->addAction(deleteAction); | 292 | popup->addAction(deleteAction); | ||
292 | 293 | | |||
293 | popup->addSeparator(); | 294 | popup->addSeparator(); | ||
294 | 295 | | |||
295 | // properties | 296 | // properties | ||
296 | if (!fileItem.isNull()) { | 297 | if (!fileItem.isNull()) { | ||
297 | QAction* propertiesAction = new QAction(i18nc("@action:inmenu", "Properties"), this); | 298 | QAction* propertiesAction = new QAction(i18nc("@action:inmenu", "Properties"), this); | ||
298 | propertiesAction->setIcon(QIcon::fromTheme(QStringLiteral("document-properties"))); | 299 | propertiesAction->setIcon(Icon(QStringLiteral("document-properties"))); | ||
299 | connect(propertiesAction, &QAction::triggered, this, [=]() { | 300 | connect(propertiesAction, &QAction::triggered, this, [=]() { | ||
300 | KPropertiesDialog* dialog = new KPropertiesDialog(fileItem.url(), this); | 301 | KPropertiesDialog* dialog = new KPropertiesDialog(fileItem.url(), this); | ||
301 | dialog->setAttribute(Qt::WA_DeleteOnClose); | 302 | dialog->setAttribute(Qt::WA_DeleteOnClose); | ||
302 | dialog->show(); | 303 | dialog->show(); | ||
303 | }); | 304 | }); | ||
304 | popup->addAction(propertiesAction); | 305 | popup->addAction(propertiesAction); | ||
305 | } | 306 | } | ||
306 | 307 | | |||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |