I find the following code very suspicious
QString localFile = directory.path();
Also, when you use a non-folder icon the thumbnail overlays will look bad but at least you can have colored folders now. Dunno about remote locations (does it even create folder thumbnails there?).