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

Method deleteButtonPressed

kdevplatform/shell/sessionchooserdialog.cpp:179–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void SessionChooserDialog::deleteButtonPressed()
180{
181 if(m_deleteCandidateRow == -1)
182 return;
183
184 QModelIndex uuidIndex = m_model->index(m_deleteCandidateRow, 0);
185 QModelIndex sessionNameIndex = m_model->index(m_deleteCandidateRow, 3);
186 const QString uuid = m_model->data(uuidIndex, Qt::DisplayRole).toString();
187 const QString sessionName = m_model->data(sessionNameIndex, Qt::DisplayRole).toString();
188
189 TryLockSessionResult result = SessionController::tryLockSession( uuid );
190 if( !result.lock ) {
191 const QString errCaption = i18nc("@title:window", "Cannot Delete Session");
192 QString errText = i18nc("@info", "<p>Cannot delete a locked session.");
193
194 if( result.runInfo.holderPid != -1 ) {
195 errText += i18nc("@info", "<p>The session <b>%1</b> is locked by %2 on %3 (PID %4).",
196 sessionName, result.runInfo.holderApp, result.runInfo.holderHostname, result.runInfo.holderPid);
197 }
198
199 KMessageBox::error( this, errText, errCaption );
200 return;
201 }
202
203 const QString text = i18nc("@info", "The session <b>%1</b> and all contained settings will be deleted. The projects will stay unaffected. Do you really want to continue?", sessionName);
204 const QString caption = i18nc("@title:window", "Delete Session");
205 const KGuiItem deleteItem = KStandardGuiItem::del();
206 const KGuiItem cancelItem = KStandardGuiItem::cancel();
207
208 if (KMessageBox::warningTwoActions(this, text, caption, deleteItem, cancelItem) == KMessageBox::PrimaryAction) {
209 SessionController::deleteSessionFromDisk(result.lock);
210
211 m_model->removeRows( m_deleteCandidateRow, 1 );
212 m_deleteCandidateRow = -1;
213 }
214}
215
216#include "moc_sessionchooserdialog.cpp"

Callers

nothing calls this directly

Calls 4

indexMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
removeRowsMethod · 0.45

Tested by

no test coverage detected