| 171 | } |
| 172 | |
| 173 | void Scratchpad::removeScratch(const QModelIndex& index) |
| 174 | { |
| 175 | const QString path = index.data(FullPathRole).toString(); |
| 176 | if (auto* document = core()->documentController()->documentForUrl(QUrl::fromLocalFile(path))) { |
| 177 | if (!document->close()) { |
| 178 | return; // canceled by the user |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | if (QFile::remove(path)) { |
| 183 | qCDebug(PLUGIN_SCRATCHPAD) << "removed" << index.data(FullPathRole); |
| 184 | scratchCommands().deleteEntry(index.data().toString()); |
| 185 | m_model->removeRow(index.row()); |
| 186 | } else { |
| 187 | emit actionFailed(i18n("Failed to remove scratch: %1", index.data().toString())); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | void Scratchpad::createScratch(const QString& name) |
| 192 | { |
no test coverage detected