MCPcopy Create free account
hub / github.com/LMMS/lmms / addItems

Method addItems

src/gui/FileBrowser.cpp:227–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225
226
227void FileBrowser::addItems(const QString & path )
228{
229 if( m_dirsAsItems )
230 {
231 m_l->addTopLevelItem( new Directory( path, QString::null, m_filter ) );
232 return;
233 }
234
235 // try to add all directories from file system alphabetically into the tree
236 QDir cdir( path );
237 QStringList files = cdir.entryList( QDir::Dirs, QDir::Name );
238 for( QStringList::const_iterator it = files.constBegin();
239 it != files.constEnd(); ++it )
240 {
241 QString cur_file = *it;
242 if( cur_file[0] != '.' )
243 {
244 bool orphan = true;
245 for( int i = 0; i < m_l->topLevelItemCount(); ++i )
246 {
247 Directory * d = dynamic_cast<Directory *>(
248 m_l->topLevelItem( i ) );
249 if( d == NULL || cur_file < d->text( 0 ) )
250 {
251 // insert before item, we're done
252 Directory *dd = new Directory( cur_file, path,
253 m_filter );
254 m_l->insertTopLevelItem( i,dd );
255 dd->update();
256 orphan = false;
257 break;
258 }
259 else if( cur_file == d->text( 0 ) )
260 {
261 // imagine we have subdirs named "TripleOscillator/xyz" in
262 // two directories from m_directories
263 // then only add one tree widget for both
264 // so we don't add a new Directory - we just
265 // add the path to the current directory
266 d->addDirectory( path );
267 d->update();
268 orphan = false;
269 break;
270 }
271 }
272 if( orphan )
273 {
274 // it has not yet been added yet, so it's (lexically)
275 // larger than all other dirs => append it at the bottom
276 Directory *d = new Directory( cur_file,
277 path, m_filter );
278 d->update();
279 m_l->addTopLevelItem( d );
280 }
281 }
282 }
283
284 files = cdir.entryList( QDir::Files, QDir::Name );

Callers 2

setupActionsMethod · 0.80
ladspaDescriptionMethod · 0.80

Calls 3

addDirectoryMethod · 0.80
updateMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected