Hi,
I've already tried to write model you need
My model didn't used modelProxy(i didn't know something like this exists) so i've subclassed QDirModel with own setWinFilePath etc. methods(those original aren't virtual).
I actually left it behind because of some strange behavior i couldn't debug(it wasn't as important as time consuming).
I had also custom iconProvider(that's in use and generates thumbnails for images for standard QDirModel) so i had to refresh model after thumbnails changes(because QDirModel have internally cached data). Model crashes on refreshing after entering/leaving my documents (i think the fact that same modelIndex can be retrieved via 2 different paths causes some recursion in QDirModels internal cache). Maybe you could figure it out - i would be glad to get it back in use.
Maybe you can even use it as is, if you don't need refreshes.
Attached model returns same values as QDirModel
change theRefreshing = true to false in CWinDirModelPrivate constructor to get behavior with my computer & myDocuments. It's because i blocked added feature instead of removing whole class hoping i'll fix it later, but there's still lots of other things to do so its pending.
Oh, almost forgot - im getting myDocuments path by
QString CWinDirModel
::getMyDocsPath()const {
WCHAR docs[1024];
LPITEMIDLIST doc = new ITEMIDLIST;
SHGetSpecialFolderLocation(qApp->activeWindow()->winId(), CSIDL_PERSONAL ,&doc);
SHGetPathFromIDList(doc, docs);
char cast[1024];
for(int i=0; i < 1024;i++)
cast[i] = docs[i];
}
QString CWinDirModel::getMyDocsPath()const
{
WCHAR docs[1024];
LPITEMIDLIST doc = new ITEMIDLIST;
SHGetSpecialFolderLocation(qApp->activeWindow()->winId(), CSIDL_PERSONAL ,&doc);
SHGetPathFromIDList(doc, docs);
char cast[1024];
for(int i=0; i < 1024;i++)
cast[i] = docs[i];
return QString(cast);
}
To copy to clipboard, switch view to plain text mode
Bookmarks