KDE 4.7 PyKDE API Reference

- KDE's Python API

# Predicate Class Reference

`from PyKDE4.solid import *`

Namespace: Solid

## Detailed Description

This class implements predicates for devices.

A predicate is a logical condition that a given device can match or not. It's a constraint about the value a property must have in a given device interface, or any combination (conjunction, disjunction) of such constraints.

FIXME: Add an example.

## Enumerations
ComparisonOperator | { Equals, Mask }
Type | { PropertyCheck, Conjunction, Disjunction, InterfaceCheck }
## Methods
| __init__ (self)
| __init__ (self, Solid.Predicate other)
| __init__ (self, QString ifaceName, QString property, QVariant value, Solid.Predicate.ComparisonOperator compOperator=Solid.Predicate.Equals)
| __init__ (self, Solid.DeviceInterface.Type ifaceType)
| __init__ (self, QString ifaceName)
Solid.Predicate.ComparisonOperator | comparisonOperator (self)
Solid.Predicate | firstOperand (self)
Solid.DeviceInterface.Type | interfaceType (self)
bool | isValid (self)
bool | matches (self, Solid.Device device)
QVariant | matchingValue (self)
Solid.Predicate | operator & (self, Solid.Predicate other)
Solid.Predicate | operator &= (self, Solid.Predicate other)
Solid.Predicate | operator | (self, Solid.Predicate other)
Solid.Predicate | operator |= (self, Solid.Predicate other)
QString | propertyName (self)
Solid.Predicate | secondOperand (self)
QString | toString (self)
Solid.Predicate.Type | type (self)
QSet | usedTypes (self)
## Static Methods
Solid.Predicate | fromString (QString predicate)

## Method Documentation

__init__ | ( |  | self ) |

Constructs an invalid predicate.

__init__ | ( | self, |
|  | Solid.Predicate | other
| ) |  |  |

Copy constructor.

Parameters:

  | other | the predicate to copy

__init__ | ( | self, |
|  | QString | ifaceName,
|  | QString | property,
|  | QVariant | value,
|  | Solid.Predicate.ComparisonOperator | compOperator=Solid.Predicate.Equals
| ) |  |  |

Constructs a predicate matching the value of a property in a given device interface.

Parameters:

  | ifaceName | the name of the device interface the device must have
  | property | the property name of the device interface
  | value | the value the property must have to make the device match
  | compOperator | the operator to apply between the property and the value when matching

__init__ | ( | self, |
|  | Solid.DeviceInterface.Type | ifaceType
| ) |  |  |

Constructs a predicate matching devices being of a particular device interface

Parameters:

  | ifaceType | the device interface the device must have

__init__ | ( | self, |
|  | QString | ifaceName
| ) |  |  |

Constructs a predicate matching devices being of a particular device interface

Parameters:

  | ifaceName | the name of the device interface the device must have

Solid.Predicate.ComparisonOperator comparisonOperator | ( |  | self ) |

Retrieves the comparison operator used to compare a property's value

Since:
  4.4

Note:
  This is only valid for Conjunction and Disjunction types

Returns:
  the comparison operator used

Solid.Predicate firstOperand | ( |  | self ) |

A smaller, inner predicate which is the first to appear and is compared with the second one

Since:
  4.4

Note:
  This is only valid for Conjunction and Disjunction types

Returns:
  The predicate used for the first operand

Solid.DeviceInterface.Type interfaceType | ( |  | self ) |

Retrieves the interface type.

Note:
  This is only valid for InterfaceCheck and PropertyCheck types

Since:
  4.4

Returns:
  a device interface type used by the predicate

bool isValid | ( |  | self ) |

Indicates if the predicate is valid.

Predicate() is the only invalid predicate.

Returns:
  true if the predicate is valid, false otherwise

bool matches | ( | self, |
|  | Solid.Device | device
| ) |  |  |

Checks if a device matches the predicate.

Parameters:

  | device | the device to match against the predicate

Returns:
  true if the given device matches the predicate, false otherwise

QVariant matchingValue | ( |  | self ) |

Retrieves the value used when comparing a devices property to see if it matches the predicate

Note:
  This is only valid for the PropertyCheck type

Since:
  4.4

Returns:
  the value used

Solid.Predicate operator & | ( | self, |
|  | Solid.Predicate | other
| ) |  |  |

'And' operator.

Parameters:

  | other | the second operand

Returns:
  a new 'and' predicate having 'this' and 'other' as operands

Solid.Predicate operator &= | ( | self, |
|  | Solid.Predicate | other
| ) |  |  |

'AndEquals' operator.

Parameters:

  | other | the second operand

Returns:
  assigns to 'this' a new 'and' predicate having 'this' and 'other' as operands

Solid.Predicate operator | | ( | self, |
|  | Solid.Predicate | other
| ) |  |  |

'Or' operator.

Parameters:

  | other | the second operand

Returns:
  a new 'or' predicate having 'this' and 'other' as operands

Solid.Predicate operator |= | ( | self, |
|  | Solid.Predicate | other
| ) |  |  |

'OrEquals' operator.

Parameters:

  | other | the second operand

Returns:
  assigns to 'this' a new 'or' predicate having 'this' and 'other' as operands

QString propertyName | ( |  | self ) |

Retrieves the property name used when retrieving the value to compare against

Note:
  This is only valid for the PropertyCheck type

Since:
  4.4

Returns:
  a property name

Solid.Predicate secondOperand | ( |  | self ) |

A smaller, inner predicate which is the second to appear and is compared with the first one

Since:
  4.4

Note:
  This is only valid for Conjunction and Disjunction types

Returns:
  The predicate used for the second operand

QString toString | ( |  | self ) |

Converts the predicate to its string form.

Returns:
  a string representation of the predicate

Solid.Predicate.Type type | ( |  | self ) |

Retrieves the predicate type, used to determine how to handle the predicate

Since:
  4.4

Returns:
  the predicate type

QSet usedTypes | ( |  | self ) |

Retrieves the device interface types used in this predicate.

Returns:
  all the device interface types used in this predicate

## Static Method Documentation

Solid.Predicate fromString | ( | QString | predicate
| ) |  |  |

Converts a string to a predicate.

Parameters:

  | predicate | the string to convert

Returns:
  a new valid predicate if the given string is syntactically correct, Predicate() otherwise

## Enumeration Documentation

ComparisonOperator

The comparison operator which can be used for matching within the predicate.

- Equals, the property and the value will match for strict equality - Mask, the property and the value will match if the bitmasking is not null

Enumerator:

  Equals |
  Mask |

Type

The predicate type which controls how the predicate is handled

- PropertyCheck, the predicate contains a comparison that needs to be matched using a ComparisonOperator - Conjunction, the two contained predicates need to be true for this predicate to be true - Disjunction, either of the two contained predicates may be true for this predicate to be true - InterfaceCheck, the device type is compared

Enumerator:

  PropertyCheck |
  Conjunction |
  Disjunction |
  InterfaceCheck |