KFilePlacesModel/View question

nf2 nf2.email at gmail.com
Sun Oct 18 23:29:15 BST 2009


On Sun, Oct 18, 2009 at 11:56 PM, Dan Meltzer
<parallelgrapefruit at gmail.com> wrote:
> 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;
> }
>
>

Yeah - that looks easier to understand. Although i'm still wondering
about the intention. Shouldn't it just be

accessible  && !Cdrom  ?

Norbert




More information about the kde-core-devel mailing list