| 53 | } |
| 54 | |
| 55 | void setData(const QVariant& value, int role = Qt::UserRole + 1) override |
| 56 | { |
| 57 | if(role==Qt::EditRole && value.toString()!=text()) { |
| 58 | QString newBranch = value.toString(); |
| 59 | |
| 60 | auto* bmodel = qobject_cast<BranchesListModel*>(model()); |
| 61 | if(!bmodel->findItems(newBranch).isEmpty()) |
| 62 | { |
| 63 | KMessageBox::error(nullptr, i18n("Branch \"%1\" already exists.", newBranch)); |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | int ret = KMessageBox::warningTwoActions( |
| 68 | nullptr, i18n("Are you sure you want to rename \"%1\" to \"%2\"?", text(), newBranch), {}, |
| 69 | KGuiItem(i18nc("@action:button", "Rename"), QStringLiteral("edit-rename")), |
| 70 | KStandardGuiItem::cancel()); |
| 71 | if (ret == KMessageBox::SecondaryAction) { |
| 72 | return; // ignore event |
| 73 | } |
| 74 | |
| 75 | KDevelop::VcsJob *branchJob = bmodel->interface()->renameBranch(bmodel->repository(), newBranch, text()); |
| 76 | ret = branchJob->exec(); |
| 77 | qCDebug(VCS) << "Renaming " << text() << " to " << newBranch << ':' << ret; |
| 78 | if (!ret) { |
| 79 | return; // ignore event |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | QStandardItem::setData(value, role); |
| 84 | } |
| 85 | }; |
| 86 | |
| 87 | static QVariant runSynchronously(KDevelop::VcsJob* job) |
no test coverage detected