MCPcopy Create free account
hub / github.com/KDE/kdevelop / setData

Method setData

kdevplatform/vcs/models/brancheslistmodel.cpp:55–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
87static QVariant runSynchronously(KDevelop::VcsJob* job)

Callers 2

addItemEventsMethod · 0.45

Calls 7

modelFunction · 0.85
execMethod · 0.80
toStringMethod · 0.45
isEmptyMethod · 0.45
renameBranchMethod · 0.45
interfaceMethod · 0.45
repositoryMethod · 0.45

Tested by

no test coverage detected