KFilePlacesModel/View question

Dan Meltzer parallelgrapefruit at gmail.com
Sun Oct 18 22:56:25 BST 2009


On Sun, Oct 18, 2009 at 7:24 AM, nf2 <nf2.email at gmail.com> wrote:
> I'm wondering whether the device related code in KFilePlacesModel
> could be internalized a bit. So that the classes using it don't have
> to deal with devices directly (like kfilplacesview.cpp,
> systemmodel.cpp, placesengine.cpp, placesrunner.cpp). That way we
> could more easily plug a different model, for instance when running
> KDE apps outside KDE.
>
> My question is about the code at line 152 in kfileplacesview.cpp:
>
>

I got bored and broke the code into something less than a monster
line, I'm fairly sure it does the same thing (or at least the intended
thing... )
const bool deviceIsAccessibleStorage =
device.is<Solid::StorageAccess>() &&
device.as<Solid::StorageAccess>()->isAccessible();
const bool devicesParentIsAccessibleStorage =
device.parent().is<Solid::StorageAccess>() &&
device.parent().as<Solid::StorageAccess>()->isAccessible();

const bool deviceIsRemovableDrive = false;
const bool parentIsRemovableDrive = false;

Solid::DeviceInterface *storageInterface = device.as<Solid::StorageDrive>();
if( storageInterface ) {
    deviceIsRemovableDrive = storageInterface->isRemovable() &&
(storageInterface->driveType() != Solid::StorageDrive::CdromDrive );
}

Solid::DeviceInterface *parentInterface =
device.parent().as<Solid::StorageDrive>();
if( parentInterface ) {
    parentIsRemovableDrive = parentInterface->isRemovable() &&
(parentInterface->driveType() != Solid::StorageDrive::CdromDrive );
}

if ( deviceIsAccessibleStorage || devicesParentIsAccessibleStorage )
&& ( deviceIsRemovableDrive || parentIsRemovableDrive ) {
    isRemovableDevice = true;
}

Dan,
>
> It hardly ever sets isRemovableDevice = true (which would show the
> capacity bar), or perhaps i just don't have devices where it would.
>
> Regards,
> Norbert
>




More information about the kde-core-devel mailing list