[Development] QStorageInfo

André Somers andre at familiesomers.nl
Fri Aug 29 13:42:44 CEST 2014


Bo Thorsen schreef op 29-8-2014 13:29:
> Den 29-08-2014 12:46, André Somers skrev:
>> Thiago Macieira schreef op 29-8-2014 06:32:
>>> Could be, but I want to be really clear that it should only be local,
>>> remote and unknown. I don't want other types like "removable
>>> magnetic", "removable optical", "removable solid state", "virtual
>>> regular filesystem", "virtual special", etc.
>> Just wondering, but what exactly is the problem with providing more
>> details if such details are available? A combination of flags "local",
>> "removable" and "optical" would be quite informative.
> The problem with flags like this that if they are there, then a return
> value with the absence of the "optical" flag set means that it's not an
> optical disk. Flags are bools, they don't mean yes, no or unknown. The
> flag shows the presence of something or the absence of something.
>
Good point.

So, perhaps not a QFlags, but something like an enum with attributes and 
an enum with values, and a method to check those?

Along these lines I mean:

enum StorageAttribute {
     Local, Remote,  // stick to these for now
     Removable, Optical, Virtual // some possible future extensions
}
enum StorageAttributeValue {
     Yes, No, Unknown
}

StorageAttributeValue QStorageInfo::hasAttribute(StorageAttribute 
attribute) const;

That is, unless you want to use QOptional type for something like this, 
because that effectively can make a bool into a tri-state :-)

André





More information about the Development mailing list