void KDirSelectDialog::Private::slotMoveToTrash() { const KUrl url = m_treeView->selectedUrl(); KIO::JobUiDelegate job; if (job.askDeleteConfirmation(KUrl::List() << url, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) { KIO::CopyJob* copyJob = KIO::trash(url); copyJob->ui()->setWindow(m_parent); copyJob->ui()->setAutoErrorHandlingEnabled(true); } }
void TreeLog::onSaveLog() { const QUrl url = QFileDialog::getSaveFileUrl(); if (!url.isEmpty()) { QTemporaryFile tempFile; if (!tempFile.open()) { KMessageBox::error(this, xi18nc("@info", "Could not create temporary output file to save <filename>%1</filename>.", url.fileName()), i18nc("@title:window", "Error Saving Log File")); return; } QTextStream stream(&tempFile); for (qint32 idx = 0; idx < treeLog().topLevelItemCount(); idx++) { QTreeWidgetItem* item = treeLog().topLevelItem(idx); stream << item->text(1) << ": " << item->text(2) << "\n"; } tempFile.close(); KIO::CopyJob* job = KIO::move(QUrl::fromLocalFile(tempFile.fileName()), url, KIO::HideProgressInfo); job->exec(); if ( job->error() ) job->ui()->showErrorMessage(); } }