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

Method removeUrl

kdevplatform/project/helper.cpp:36–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34using namespace KDevelop;
35
36bool KDevelop::removeUrl(const KDevelop::IProject* project, const QUrl& url, const bool isFolder)
37{
38 qCDebug(PROJECT) << "Removing url:" << url << "from project" << project;
39
40 QWidget* window = QApplication::activeWindow();
41
42 auto job = KIO::stat(url, KIO::StatJob::DestinationSide, KIO::StatNoDetails);
43 KJobWidgets::setWindow(job, window);
44 if (!job->exec()) {
45 qCWarning(PROJECT) << "tried to remove non-existing url:" << url << project << isFolder;
46 return true;
47 }
48
49 IPlugin* vcsplugin=project->versionControlPlugin();
50 if(vcsplugin) {
51 auto* vcs=vcsplugin->extension<IBasicVersionControl>();
52
53 // We have a vcs and the file/folder is controller, need to make the rename through vcs
54 if(vcs->isVersionControlled(url)) {
55 VcsJob* job=vcs->remove(QList<QUrl>() << url);
56 if(job) {
57 return job->exec();
58 }
59 }
60 }
61
62 //if we didn't find a VCS, we remove using KIO (if the file still exists, the vcs plugin might have simply deleted the url without returning a job
63 auto deleteJob = KIO::del(url);
64 KJobWidgets::setWindow(deleteJob, window);
65 if (!deleteJob->exec() && url.isLocalFile() && (QFileInfo::exists(url.toLocalFile()))) {
66 const QString messageText =
67 isFolder ? i18n( "Cannot remove folder <i>%1</i>.", url.toDisplayString(QUrl::PreferLocalFile) )
68 : i18n( "Cannot remove file <i>%1</i>.", url.toDisplayString(QUrl::PreferLocalFile) );
69 auto* message = new Sublime::Message(messageText, Sublime::Message::Error);
70 ICore::self()->uiController()->postMessage(message);
71 return false;
72 }
73 return true;
74}
75
76bool KDevelop::removePath(const KDevelop::IProject* project, const KDevelop::Path& path, const bool isFolder)
77{

Callers

nothing calls this directly

Calls 9

statClass · 0.85
execMethod · 0.80
versionControlPluginMethod · 0.80
isLocalFileMethod · 0.80
toLocalFileMethod · 0.80
uiControllerMethod · 0.80
isVersionControlledMethod · 0.45
removeMethod · 0.45
postMessageMethod · 0.45

Tested by

no test coverage detected