Changeset View
Changeset View
Standalone View
Standalone View
src/panels/places/placespanel.cpp
Show All 18 Lines | |||||
19 | * along with this program; if not, write to the * | 19 | * along with this program; if not, write to the * | ||
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 "trash/dolphintrash.h" | ||||
27 | 28 | | |||
28 | #include "global.h" | 29 | #include "global.h" | ||
29 | #include <KFileItem> | 30 | #include <KFileItem> | ||
30 | #include <KDirNotify> | 31 | #include <KDirNotify> | ||
31 | #include <QIcon> | 32 | #include <QIcon> | ||
32 | #include <KIO/Job> | 33 | #include <KIO/Job> | ||
33 | #include <KIO/DropJob> | 34 | #include <KIO/DropJob> | ||
34 | #include <KIO/EmptyTrashJob> | 35 | #include <KIO/EmptyTrashJob> | ||
▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Line(s) | 164 | { | |||
220 | hideAction->setCheckable(true); | 221 | hideAction->setCheckable(true); | ||
221 | hideAction->setChecked(item->isHidden()); | 222 | hideAction->setChecked(item->isHidden()); | ||
222 | 223 | | |||
223 | buildGroupContextMenu(&menu, index); | 224 | buildGroupContextMenu(&menu, index); | ||
224 | 225 | | |||
225 | QAction* action = menu.exec(pos.toPoint()); | 226 | QAction* action = menu.exec(pos.toPoint()); | ||
226 | if (action) { | 227 | if (action) { | ||
227 | if (action == emptyTrashAction) { | 228 | if (action == emptyTrashAction) { | ||
228 | emptyTrash(); | 229 | Trash::instance().empty(this); | ||
229 | } else { | 230 | } else { | ||
230 | // The index might have changed if devices were added/removed while | 231 | // The index might have changed if devices were added/removed while | ||
231 | // the context menu was open. | 232 | // the context menu was open. | ||
232 | index = m_model->index(item); | 233 | index = m_model->index(item); | ||
233 | if (index < 0) { | 234 | if (index < 0) { | ||
234 | // The item is not in the model any more, probably because it was an | 235 | // The item is not in the model any more, probably because it was an | ||
235 | // external device that has been removed while the context menu was open. | 236 | // external device that has been removed while the context menu was open. | ||
236 | return; | 237 | return; | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | |||||
419 | void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent) | 420 | void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent) | ||
420 | { | 421 | { | ||
421 | KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent); | 422 | KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent); | ||
422 | if (job) { | 423 | if (job) { | ||
423 | connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); }); | 424 | connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); }); | ||
424 | } | 425 | } | ||
425 | } | 426 | } | ||
426 | 427 | | |||
427 | void PlacesPanel::slotTrashUpdated(KJob* job) | | |||
428 | { | | |||
429 | if (job->error()) { | | |||
430 | emit errorMessage(job->errorString()); | | |||
431 | } | | |||
432 | // 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. | |||||
433 | KNotification::event(QStringLiteral("Trash: emptied"), QString(), QPixmap(), nullptr, KNotification::DefaultEvent); | | |||
434 | } | | |||
435 | | ||||
436 | void PlacesPanel::slotStorageSetupDone(int index, bool success) | 428 | void PlacesPanel::slotStorageSetupDone(int index, bool success) | ||
437 | { | 429 | { | ||
438 | disconnect(m_model, &PlacesItemModel::storageSetupDone, | 430 | disconnect(m_model, &PlacesItemModel::storageSetupDone, | ||
439 | this, &PlacesPanel::slotStorageSetupDone); | 431 | this, &PlacesPanel::slotStorageSetupDone); | ||
440 | 432 | | |||
441 | if (m_triggerStorageSetupButton == Qt::NoButton) { | 433 | if (m_triggerStorageSetupButton == Qt::NoButton) { | ||
442 | return; | 434 | return; | ||
443 | } | 435 | } | ||
444 | 436 | | |||
445 | if (success) { | 437 | if (success) { | ||
446 | Q_ASSERT(!m_model->storageSetupNeeded(index)); | 438 | Q_ASSERT(!m_model->storageSetupNeeded(index)); | ||
447 | triggerItem(index, m_triggerStorageSetupButton); | 439 | triggerItem(index, m_triggerStorageSetupButton); | ||
448 | m_triggerStorageSetupButton = Qt::NoButton; | 440 | m_triggerStorageSetupButton = Qt::NoButton; | ||
449 | } else { | 441 | } else { | ||
450 | setUrl(m_storageSetupFailedUrl); | 442 | setUrl(m_storageSetupFailedUrl); | ||
451 | m_storageSetupFailedUrl = QUrl(); | 443 | m_storageSetupFailedUrl = QUrl(); | ||
452 | } | 444 | } | ||
453 | } | 445 | } | ||
454 | 446 | | |||
455 | void PlacesPanel::emptyTrash() | | |||
456 | { | | |||
457 | KIO::JobUiDelegate uiDelegate; | | |||
458 | uiDelegate.setWindow(window()); | | |||
459 | if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) { | | |||
460 | KIO::Job* job = KIO::emptyTrash(); | | |||
461 | KJobWidgets::setWindow(job, window()); | | |||
462 | connect(job, &KIO::Job::result, this, &PlacesPanel::slotTrashUpdated); | | |||
463 | } | | |||
464 | } | | |||
465 | | ||||
466 | void PlacesPanel::addEntry() | 447 | void PlacesPanel::addEntry() | ||
467 | { | 448 | { | ||
468 | const int index = m_controller->selectionManager()->currentItem(); | 449 | const int index = m_controller->selectionManager()->currentItem(); | ||
469 | const QUrl url = m_model->data(index).value("url").toUrl(); | 450 | const QUrl url = m_model->data(index).value("url").toUrl(); | ||
470 | 451 | | |||
471 | QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this); | 452 | QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this); | ||
472 | dialog->setWindowTitle(i18nc("@title:window", "Add Places Entry")); | 453 | dialog->setWindowTitle(i18nc("@title:window", "Add Places Entry")); | ||
473 | dialog->setAllowGlobal(true); | 454 | 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.