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