marcingu added a comment.

  Ok, so far I have implemented `Solid::Device::storageAccessFromPath` by 
talking all StorageAccess devices, going though all of them and and returning 
proper one.
    Solid::Device Solid::Device::storageAccessFromPath(const QString &path)
        // TODO check if symlinks are in the path
        QFileInfo fileInfo = QFileInfo(path);
        if (!fileInfo.exists()) {
            //TODO error handling
        QSet<QString> checked; //To avoid weird infinete loops
        while (fileInfo.isSymLink()) {
            fileInfo = QFileInfo(fileInfo.symLinkTarget());
            if (checked.contains(fileInfo.path())) {
                //TODO error handling
        QDir dir = fileInfo.dir();
        QString canonPath = dir.canonicalPath();
        QList<Device> list = 
        Device match;
        int match_length = 0;
        for (Device device: list) {
            StorageAccess *storageAccess =<StorageAccess>();
            if (canonPath.startsWith(storageAccess->filePath()) && 
storageAccess->filePath().size() > match_length) {
                match_length = storageAccess->filePath().size();
                match = device;
        return match;
  and in the thumbnail.cpp:
    Solid::Device device = Solid::Device::storageAccessFromPath(filePath);
    if (<Solid::StorageVolume>()) {
        allowCache =<Solid::StorageVolume>()->usage() != 
  It works, but it might be better to hold tree structure with all StorageAcces 
devices where position on tree would be determined by mountpoint of device, 
which would allow us to go straight to the desired StorageAccess without 
checking all of them.
  On the other hand, to do that we would have to slice path into parts and 
compare those parts with nodes on the tree and also create special structure 
for that. I'm not sure which approach is better.
  Another problem with storing StorageAccess tree is that I looked at 
DeviceManager classes and it might be too difficult for me, as I don't know 
Solid well.
  Which should it be and do we go about it?

  R320 KIO Extras


To: marcingu, ivan, broulik, #dolphin, ngraham, meven, bruns
Cc: thiago, bruns, meven, ngraham, kde-frameworks-devel, kfm-devel, 
waitquietly, azyx, nikolaik, pberestov, iasensio, aprcela, fprice, LeGast00n, 
cblack, fbampaloukas, alexde, Codezela, feverfew, michaelh, spoorun, 
navarromorales, firef, andrebarros, emmanuelp, rdieter, mikesomov

Reply via email to