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

Method created

kdevplatform/project/abstractfilemanagerplugin.cpp:241–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241void AbstractFileManagerPluginPrivate::created(const QString& path_)
242{
243 qCDebug(FILEMANAGER) << "created:" << path_;
244 QFileInfo info(path_);
245 if (!info.exists()) {
246 // we delay handling of the signal, so maybe the path actually got removed again
247 return;
248 }
249
250 ///FIXME: share memory with parent
251 const Path path(path_);
252 const IndexedString indexedPath(path.pathOrUrl());
253 const IndexedString indexedParent(path.parent().pathOrUrl());
254
255 QHashIterator<IProject*, KDirWatch*> it(m_watchers);
256 while (it.hasNext()) {
257 const auto p = it.next().key();
258 if ( !p->projectItem()->model() ) {
259 // not yet finished with loading
260 // FIXME: how should this be handled? see unit test
261 continue;
262 }
263 if ( !q->isValid(path, info.isDir(), p) ) {
264 continue;
265 }
266 if ( info.isDir() ) {
267 bool found = false;
268 const auto folderItems = p->foldersForPath(indexedPath);
269 for (ProjectFolderItem* folder : folderItems) {
270 // exists already in this project, happens e.g. when we restart the dirwatcher
271 // or if we delete and remove folders consecutively https://bugs.kde.org/show_bug.cgi?id=260741
272 qCDebug(FILEMANAGER) << "force reload of" << path << folder;
273 auto job = eventuallyReadFolder( folder );
274 job->start();
275 found = true;
276 }
277 if ( found ) {
278 continue;
279 }
280 } else if (!p->filesForPath(indexedPath).isEmpty()) {
281 // also gets triggered for kate's backup files
282 continue;
283 }
284 const auto parentItems = p->foldersForPath(indexedParent);
285 for (ProjectFolderItem* parentItem : parentItems) {
286 if ( info.isDir() ) {
287 ProjectFolderItem* folder = q->createFolderItem( p, path, parentItem );
288 if (folder) {
289 emit q->folderAdded( folder );
290 auto job = eventuallyReadFolder( folder );
291 job->start();
292 }
293 } else {
294 ProjectFileItem* file = q->createFileItem( p, path, parentItem );
295 if (file) {
296 emit q->fileAdded( file );
297 }
298 }

Callers 1

importMethod · 0.80

Calls 15

existsMethod · 0.80
pathOrUrlMethod · 0.80
foldersForPathMethod · 0.80
parentMethod · 0.45
hasNextMethod · 0.45
keyMethod · 0.45
nextMethod · 0.45
modelMethod · 0.45
projectItemMethod · 0.45
isValidMethod · 0.45
startMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected