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

Method addJobItems

kdevplatform/project/abstractfilemanagerplugin.cpp:152–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152void AbstractFileManagerPluginPrivate::addJobItems(FileManagerListJob* job,
153 ProjectFolderItem* baseItem,
154 const KIO::UDSEntryList& entries)
155{
156 qCDebug(FILEMANAGER) << "reading entries of" << baseItem->path();
157
158 // build lists of valid files and folders with paths relative to the project folder
159 Path::List files;
160 Path::List folders;
161 for (const KIO::UDSEntry& entry : entries) {
162 QString name = entry.stringValue( KIO::UDSEntry::UDS_NAME );
163 if (name == QLatin1String(".") || name == QLatin1String("..")) {
164 continue;
165 }
166
167 Path path(baseItem->path(), name);
168
169 if ( !q->isValid( path, entry.isDir(), baseItem->project() ) ) {
170 continue;
171 } else {
172 if ( entry.isDir() ) {
173 if( entry.isLink() ) {
174 const Path linkedPath = baseItem->path().cd(entry.stringValue( KIO::UDSEntry::UDS_LINK_DEST ));
175 // make sure we don't end in an infinite loop
176 if( linkedPath.isParentOf( baseItem->project()->path() ) ||
177 baseItem->project()->path().isParentOf( linkedPath ) ||
178 linkedPath == baseItem->project()->path() )
179 {
180 continue;
181 }
182 }
183 folders << path;
184 } else {
185 files << path;
186 }
187 }
188 }
189
190 ifDebug(qCDebug(FILEMANAGER) << "valid folders:" << folders;)
191 ifDebug(qCDebug(FILEMANAGER) << "valid files:" << files;)
192
193 // remove obsolete rows
194 for ( int j = 0; j < baseItem->rowCount(); ++j ) {
195 if ( ProjectFolderItem* f = baseItem->child(j)->folder() ) {
196 // check if this is still a valid folder
197 int index = folders.indexOf( f->path() );
198 if ( index == -1 ) {
199 // folder got removed or is now invalid
200 delete f;
201 --j;
202 } else {
203 // this folder already exists in the view
204 folders.remove( index );
205 // no need to add this item, but we still want to recurse into it
206 job->addSubDir( f );
207 emit q->reloadedFolderItem( f );
208 }
209 } else if ( ProjectFileItem* f = baseItem->child(j)->file() ) {

Callers

nothing calls this directly

Calls 15

stringValueMethod · 0.80
cdMethod · 0.80
isParentOfMethod · 0.80
folderMethod · 0.80
addSubDirMethod · 0.80
pathMethod · 0.45
isValidMethod · 0.45
projectMethod · 0.45
rowCountMethod · 0.45
childMethod · 0.45
indexOfMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected