Changeset View
Changeset View
Standalone View
Standalone View
src/panels/places/placespanel.cpp
Show All 19 Lines | |||||
20 | * Free Software Foundation, Inc., * | 20 | * Free Software Foundation, Inc., * | ||
21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
22 | ***************************************************************************/ | 22 | ***************************************************************************/ | ||
23 | 23 | | |||
24 | #include "placespanel.h" | 24 | #include "placespanel.h" | ||
25 | 25 | | |||
26 | #include "dolphin_generalsettings.h" | 26 | #include "dolphin_generalsettings.h" | ||
27 | #include "global.h" | 27 | #include "global.h" | ||
28 | #include "kitemviews/kitemlistcontainer.h" | ||||
29 | #include "kitemviews/kitemlistcontroller.h" | ||||
30 | #include "kitemviews/kitemlistselectionmanager.h" | ||||
31 | #include "kitemviews/kstandarditem.h" | ||||
28 | #include "placesitem.h" | 32 | #include "placesitem.h" | ||
29 | #include "placesitemeditdialog.h" | 33 | #include "placesitemeditdialog.h" | ||
30 | #include "placesitemlistgroupheader.h" | 34 | #include "placesitemlistgroupheader.h" | ||
31 | #include "placesitemlistwidget.h" | 35 | #include "placesitemlistwidget.h" | ||
32 | #include "placesitemmodel.h" | 36 | #include "placesitemmodel.h" | ||
33 | #include "placesview.h" | 37 | #include "placesview.h" | ||
34 | #include "kitemviews/kitemlistcontainer.h" | 38 | #include "trash/dolphintrash.h" | ||
35 | #include "kitemviews/kitemlistcontroller.h" | | |||
36 | #include "kitemviews/kitemlistselectionmanager.h" | | |||
37 | #include "kitemviews/kstandarditem.h" | | |||
38 | #include "views/draganddrophelper.h" | 39 | #include "views/draganddrophelper.h" | ||
39 | 40 | | |||
40 | #include <KDirNotify> | 41 | #include <KDirNotify> | ||
41 | #include <KFileItem> | 42 | #include <KFileItem> | ||
42 | #include <KFilePlacesModel> | 43 | #include <KFilePlacesModel> | ||
43 | #include <KIO/DropJob> | 44 | #include <KIO/DropJob> | ||
44 | #include <KIO/EmptyTrashJob> | 45 | #include <KIO/EmptyTrashJob> | ||
45 | #include <KIO/Job> | 46 | #include <KIO/Job> | ||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Line(s) | 165 | { | |||
221 | hideAction->setCheckable(true); | 222 | hideAction->setCheckable(true); | ||
222 | hideAction->setChecked(item->isHidden()); | 223 | hideAction->setChecked(item->isHidden()); | ||
223 | 224 | | |||
224 | buildGroupContextMenu(&menu, index); | 225 | buildGroupContextMenu(&menu, index); | ||
225 | 226 | | |||
226 | QAction* action = menu.exec(pos.toPoint()); | 227 | QAction* action = menu.exec(pos.toPoint()); | ||
227 | if (action) { | 228 | if (action) { | ||
228 | if (action == emptyTrashAction) { | 229 | if (action == emptyTrashAction) { | ||
229 | emptyTrash(); | 230 | Trash::instance().empty(this); | ||
230 | } else { | 231 | } else { | ||
231 | // The index might have changed if devices were added/removed while | 232 | // The index might have changed if devices were added/removed while | ||
232 | // the context menu was open. | 233 | // the context menu was open. | ||
233 | index = m_model->index(item); | 234 | index = m_model->index(item); | ||
234 | if (index < 0) { | 235 | if (index < 0) { | ||
235 | // The item is not in the model any more, probably because it was an | 236 | // The item is not in the model any more, probably because it was an | ||
236 | // external device that has been removed while the context menu was open. | 237 | // external device that has been removed while the context menu was open. | ||
237 | return; | 238 | return; | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | |||||
420 | void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent) | 421 | void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent) | ||
421 | { | 422 | { | ||
422 | KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent); | 423 | KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent); | ||
423 | if (job) { | 424 | if (job) { | ||
424 | connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); }); | 425 | connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); }); | ||
425 | } | 426 | } | ||
426 | } | 427 | } | ||
427 | 428 | | |||
428 | void PlacesPanel::slotTrashUpdated(KJob* job) | | |||
429 | { | | |||
430 | if (job->error()) { | | |||
431 | emit errorMessage(job->errorString()); | | |||
432 | } | | |||
433 | // as long as KIO doesn't do this, do it ourselves | | |||
elvisangelaccio: Please don't discard this comment, let's keep it even in the new file. | |||||
434 | KNotification::event(QStringLiteral("Trash: emptied"), QString(), QPixmap(), nullptr, KNotification::DefaultEvent); | | |||
435 | } | | |||
436 | | ||||
437 | void PlacesPanel::slotStorageSetupDone(int index, bool success) | 429 | void PlacesPanel::slotStorageSetupDone(int index, bool success) | ||
438 | { | 430 | { | ||
439 | disconnect(m_model, &PlacesItemModel::storageSetupDone, | 431 | disconnect(m_model, &PlacesItemModel::storageSetupDone, | ||
440 | this, &PlacesPanel::slotStorageSetupDone); | 432 | this, &PlacesPanel::slotStorageSetupDone); | ||
441 | 433 | | |||
442 | if (m_triggerStorageSetupButton == Qt::NoButton) { | 434 | if (m_triggerStorageSetupButton == Qt::NoButton) { | ||
443 | return; | 435 | return; | ||
444 | } | 436 | } | ||
445 | 437 | | |||
446 | if (success) { | 438 | if (success) { | ||
447 | Q_ASSERT(!m_model->storageSetupNeeded(index)); | 439 | Q_ASSERT(!m_model->storageSetupNeeded(index)); | ||
448 | triggerItem(index, m_triggerStorageSetupButton); | 440 | triggerItem(index, m_triggerStorageSetupButton); | ||
449 | m_triggerStorageSetupButton = Qt::NoButton; | 441 | m_triggerStorageSetupButton = Qt::NoButton; | ||
450 | } else { | 442 | } else { | ||
451 | setUrl(m_storageSetupFailedUrl); | 443 | setUrl(m_storageSetupFailedUrl); | ||
452 | m_storageSetupFailedUrl = QUrl(); | 444 | m_storageSetupFailedUrl = QUrl(); | ||
453 | } | 445 | } | ||
454 | } | 446 | } | ||
455 | 447 | | |||
456 | void PlacesPanel::emptyTrash() | | |||
457 | { | | |||
458 | KIO::JobUiDelegate uiDelegate; | | |||
459 | uiDelegate.setWindow(window()); | | |||
460 | if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) { | | |||
461 | KIO::Job* job = KIO::emptyTrash(); | | |||
462 | KJobWidgets::setWindow(job, window()); | | |||
463 | connect(job, &KIO::Job::result, this, &PlacesPanel::slotTrashUpdated); | | |||
464 | } | | |||
465 | } | | |||
466 | | ||||
467 | void PlacesPanel::addEntry() | 448 | void PlacesPanel::addEntry() | ||
468 | { | 449 | { | ||
469 | const int index = m_controller->selectionManager()->currentItem(); | 450 | const int index = m_controller->selectionManager()->currentItem(); | ||
470 | const QUrl url = m_model->data(index).value("url").toUrl(); | 451 | const QUrl url = m_model->data(index).value("url").toUrl(); | ||
471 | 452 | | |||
472 | QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this); | 453 | QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this); | ||
473 | dialog->setWindowTitle(i18nc("@title:window", "Add Places Entry")); | 454 | dialog->setWindowTitle(i18nc("@title:window", "Add Places Entry")); | ||
474 | dialog->setAllowGlobal(true); | 455 | dialog->setAllowGlobal(true); | ||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |
Please don't discard this comment, let's keep it even in the new file.