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

Method createLibraryFromKnownFolders

trunk/win/Source/BT_LibraryManager.cpp:186–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186QSharedPointer<Library> LibraryManager::createLibraryFromKnownFolders(QList<KNOWNFOLDERID>& kfList)
187{
188 QSharedPointer<LibraryImpl> library(NULL);
189 if (!_comInitialized || !_pSHGetKnownFolderIDList || !_pSHCreateItemFromIDList)
190 return library;
191
192 QString libraryName;
193 QString iconPath;
194 QList<QString> directories;
195 QListIterator<KNOWNFOLDERID> iter(kfList);
196 while (iter.hasNext())
197 {
198 const KNOWNFOLDERID& id = iter.next();
199 PIDLIST_ABSOLUTE pidl;
200 if (SUCCEEDED(_pSHGetKnownFolderIDList(id, KF_FLAG_DEFAULT_PATH, NULL, &pidl)))
201 {
202 IShellItem* item;
203 if (SUCCEEDED(_pSHCreateItemFromIDList(pidl, IID_PPV_ARGS(&item))))
204 {
205 LPWSTR path;
206 if (SUCCEEDED(item->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &path)))
207 {
208 directories.append(QString::fromUtf16((const ushort*) path));
209 CoTaskMemFree(path);
210
211 if (id == kfList.front())
212 {
213 // This is the first directory, so use it's folder name as the name of the Library
214 LPWSTR name;
215 if (SUCCEEDED(item->GetDisplayName(SIGDN_NORMALDISPLAY, &name)))
216 {
217 libraryName = QString::fromUtf16((const ushort*) name);
218 CoTaskMemFree(name);
219 }
220 }
221 }
222 item->Release();
223 }
224 CoTaskMemFree(pidl);
225 }
226 }
227
228 if (directories.isEmpty())
229 return library;
230
231 library = QSharedPointer<LibraryImpl>(new LibraryImpl(libraryName));
232 library->setTextureKey(QString_NT("library_default.folder.icon"));
233 library->setFolderPaths(directories);
234 library->setHashKey(QString_NT("lib_%1").arg(directories.front()));
235 library->setValid(true);
236 return library;
237}
238
239QSharedPointer<Library> LibraryManager::createDesktopLibrary()
240{

Callers

nothing calls this directly

Calls 11

hasNextMethod · 0.80
setTextureKeyMethod · 0.80
setFolderPathsMethod · 0.80
setHashKeyMethod · 0.80
setValidMethod · 0.80
nextMethod · 0.45
appendMethod · 0.45
frontMethod · 0.45
ReleaseMethod · 0.45
isEmptyMethod · 0.45
argMethod · 0.45

Tested by

no test coverage detected