MCPcopy Create free account
hub / github.com/bumptop/BumpTop / updateDirectory

Method updateDirectory

trunk/win/Source/BT_LocalPhotoFrameSource.cpp:34–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32{}
33
34void LocalPhotoFrameSource::updateDirectory(QDir dir, vector<PhotoFrameSourceItem>& items)
35{
36 // assume dir exists
37 if (!empty(dir))
38 {
39 StrList dirListing = fsManager->getDirectoryContents(native(dir));
40 for (int i = 0; i < dirListing.size(); ++i)
41 {
42 QFileInfo file(dirListing[i]);
43
44 if (file.isSymLink()) {
45 file = QFile(file.symLinkTarget());
46 }
47
48 if (file.isDir())
49 // recurse into that directory
50 updateDirectory(file.absoluteFilePath(), items);
51 else
52 {
53 // XXX: we can do this smarter with watched directories?!
54
55 // check if this is a valid image file
56 QString filename = file.fileName();
57 if (filename.size() > 4)
58 {
59 QString ext = fsManager->getFileExtension(filename);
60 bool isValidImage = !ext.isEmpty() && GLOBAL(supportedExtensions).contains(ext + ".");
61 if (isValidImage)
62 {
63 // check if we already have that item in the list
64 vector<PhotoFrameSourceItem>::const_iterator itemIter = items.begin();
65 vector<PhotoFrameSourceItem>::const_iterator endIter = items.end();
66 bool exists = false;
67 while (itemIter != endIter)
68 {
69 if ((*itemIter).getResourceId() == dirListing[i])
70 exists = true;
71 ++itemIter;
72 }
73
74 // if not, add it to the list
75 if (!exists)
76 {
77 PhotoFrameSourceItem item(dirListing[i]);
78 item.setTexturePath(dirListing[i]);
79 items.push_back(item);
80 }
81 }
82 }
83 }
84 }
85 }
86}
87
88void LocalPhotoFrameSource::requestSourceUpdate()
89{

Callers

nothing calls this directly

Calls 15

QFileClass · 0.85
getDirectoryContentsMethod · 0.80
isSymLinkMethod · 0.80
isDirMethod · 0.80
fileNameMethod · 0.80
getFileExtensionMethod · 0.80
getResourceIdMethod · 0.80
setTexturePathMethod · 0.80
emptyFunction · 0.70
nativeFunction · 0.70
sizeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected