RB.RhythmDBQueryModel

g GObject.GInterface GObject.GInterface Gtk.TreeModel Gtk.TreeModel GObject.GInterface->Gtk.TreeModel RB.RhythmDBQueryResults RB.RhythmDBQueryResults GObject.GInterface->RB.RhythmDBQueryResults GObject.Object GObject.Object RB.RhythmDBQueryModel RB.RhythmDBQueryModel GObject.Object->RB.RhythmDBQueryModel Gtk.TreeModel->RB.RhythmDBQueryModel RB.RhythmDBQueryResults->RB.RhythmDBQueryModel

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gtk.TreeModel (28), RB.RhythmDBQueryResults (2)

Structs:

GObject.ObjectClass (5)

class

album_sort_func (a, b, data)

class

artist_sort_func (a, b, data)

class

bitrate_sort_func (a, b, data)

class

composer_sort_func (a, b, data)

class

date_sort_func (a, b, data)

class

double_ceiling_sort_func (a, b, data)

class

genre_sort_func (a, b, data)

class

location_sort_func (a, b, data)

class

new_empty (db)

class

new_for_entry_type (db, entry_type, show_hidden)

class

string_sort_func (a, b, data)

class

title_sort_func (a, b, data)

class

track_sort_func (a, b, data)

class

ulong_sort_func (a, b, data)

add_entry (entry, index)

chain (base, import_entries)

compute_status_normal (singular, plural)

copy_contents (src)

entry_to_iter (entry, iter)

get_duration ()

get_next_from_entry (entry)

get_previous_from_entry (entry)

get_size ()

has_pending_changes ()

iter_to_entry (entry_iter)

move_entry (entry, index)

reapply_query (filter)

remove_entry (entry)

set_sort_order (sort_func, sort_data, sort_reverse)

shuffle_entries ()

tree_path_to_entry (path)

Virtual Methods

Inherited:

GObject.Object (7), Gtk.TreeModel (19), RB.RhythmDBQueryResults (2)

do_complete ()

do_entry_prop_changed (entry, prop, old, new_value)

do_entry_removed (entry)

do_filter_entry_drop (entry)

do_non_entry_dropped (uri, position)

do_post_entry_delete (entry)

Properties

Name

Type

Flags

Short Description

base-model

RB.RhythmDBQueryModel

r/w/c

base RB.RhythmDBQueryModel

db

RB.RhythmDB

r/w/co

RB.RhythmDB object

limit-type

RB.RhythmDBQueryModelLimitType

r/w/co

type of limit

limit-value

GLib.Variant

r/w/co

value of limit

query

int

r/w

RhythmDBQuery

show-hidden

bool

r/w/c

if True, include entries that are ordinarily hidden

sort-data

int

r/w

Sort data

sort-data-destroy

int

r/w

Sort data destroy function

sort-func

int

r/w

Sort function

sort-reverse

bool

r/w

Reverse sort order flag

Signals

Inherited:

GObject.Object (1), Gtk.TreeModel (5)

Name

Short Description

complete

Emitted when the database query populating the model is complete.

entry-prop-changed

Emitted when an entry in the query model is changed.

entry-removed

Emitted when an entry is removed from the model.

filter-entry-drop

Emitted when an entry is being added to a model by drag-and-drop.

non-entry-dropped

Emitted when a URI that does not match an existing RB.RhythmDBEntry is dropped into the query model.

post-entry-delete

Emitted after an entry has been removed from the model.

Fields

Inherited:

GObject.Object (1), Gtk.TreeModel (5)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class RB.RhythmDBQueryModel(**kwargs)
Bases:

GObject.Object, Gtk.TreeModel, RB.RhythmDBQueryResults

Abstract:

No

Structure:

RB.RhythmDBQueryModelClass

classmethod album_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by album. Sorts by album, then disc number, then track number, then title.

classmethod artist_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by artist. Sorts by artist, then album, then disc number, then track number, then title.

classmethod bitrate_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by bitrate. Lossless encodings (as identified by media type) are considered to have the highest possible bitrate. Falls back to sorting by location for equal bitrates.

classmethod composer_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by composer. Sorts by composer, then album, then disc number, then track number, then title.

classmethod date_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by release date. Falls back to album sort order for equal dates.

classmethod double_ceiling_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by a rounded floating point value. The property value is rounded up to an integer value for sorting. If the values are the same, falls back to sorting by location.

classmethod genre_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by genre. Sorts by genre, then artist, then album, then disc number, then track number, then title.

classmethod location_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by location.

classmethod new_empty(db)
Parameters:

db (RB.RhythmDB) – the RB.RhythmDB

Returns:

the newly constructed query model

Return type:

RB.RhythmDBQueryModel

Constructs a new empty query model with no query or sorting parameters. This should only be used when the query model will be populated by explicitly adding entries.

classmethod new_for_entry_type(db, entry_type, show_hidden)
Parameters:
Returns:

the newly constructed query model

Return type:

RB.RhythmDBQueryModel

classmethod string_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by a single string property Falls back to location sort order if the strings are equal.

classmethod title_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by title. Falls back to sorting by location if the titles are the same.

classmethod track_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by track. Sorts by artist, then album, then disc number, then track number, then title.

classmethod ulong_sort_func(a, b, data)
Parameters:
Returns:

result of sort comparison between a and b.

Return type:

int

Sort function for sorting by an unsigned integer property value. If the values are the same, falls back to sorting by location.

add_entry(entry, index)
Parameters:

Adds an entry to the query model at the specified position. Does not check if the entry matches the query (if any).

chain(base, import_entries)
Parameters:

Chains self to base. All changes made to the base model will be reflected in the child model, and all changes made to the child model will be passed on to the base model.

compute_status_normal(singular, plural)
Parameters:
  • singular (str) – singular form of the pattern describing the number of entries (“%d song”)

  • plural (str) – plural form of the pattern describing the number of entries (“%d songs”)

Returns:

allocated status string, to be freed by the caller.

Return type:

str

Constructs a status string describing the contents of the model.

copy_contents(src)
Parameters:

src (RB.RhythmDBQueryModel) – source RB.RhythmDBQueryModel

Copies all entries from src to self.

entry_to_iter(entry, iter)
Parameters:
Returns:

True if the iterator now points to the entry

Return type:

bool

Creates a Gtk.TreeIter pointing to the specified entry in the model.

get_duration()
Returns:

the total duration (in seconds) of all entries in the model

Return type:

int

Returns the total duration of all entries in the model.

get_next_from_entry(entry)
Parameters:

entry (RB.RhythmDBEntry) – a RB.RhythmDBEntry

Returns:

the next RB.RhythmDBEntry in the model, if any

Return type:

RB.RhythmDBEntry

Locates and returns the next RB.RhythmDBEntry in the model after the specified entry. The caller owns a reference to the returned entry.

get_previous_from_entry(entry)
Parameters:

entry (RB.RhythmDBEntry) – a RB.RhythmDBEntry

Returns:

the previous RB.RhythmDBEntry in the model, if any

Return type:

RB.RhythmDBEntry

Locates and returns the RB.RhythmDBEntry in the model before the specified entry. The caller owns a reference to the returned entry.

get_size()
Returns:

the total size (in bytes) of all entries in the model

Return type:

int

Returns the total size of all entries in the model.

has_pending_changes()
Returns:

True if there are outstanding changes to the model

Return type:

bool

Checks if a RB.RhythmDBQueryModel has any outstanding changes that are yet to be processed. This is not very useful.

iter_to_entry(entry_iter)
Parameters:

entry_iter (Gtk.TreeIter) – a Gtk.TreeIter to dereference

Returns:

the RB.RhythmDBEntry, if any

Return type:

RB.RhythmDBEntry

Locates and returns the RB.RhythmDBEntry pointed to by the specified iterator in the model. The caller owns a reference to the returned entry.

move_entry(entry, index)
Parameters:

Moves an entry to a new position in the query model. The position must be a between 0 and the number of entries in the model. Specifying -1 does not move the entry to the end of the model.

reapply_query(filter)
Parameters:

filter (bool) – if False, emit entry-removed signals

Reapplies the existing query to the entries in the model. This is mostly useful when the query contains relative time criteria (such as ‘not played in the last hour’). This will only remove entries that are already in the model, it will not find entries that previously did not match the query.

The ‘filter’ parameter should be set to True when the query is being used as a filter, rather than to define a base set of entries.

remove_entry(entry)
Parameters:

entry (RB.RhythmDBEntry) – the RB.RhythmDBEntry to remove

Returns:

True if the entry was removed

Return type:

bool

Removes an entry from the query model.

set_sort_order(sort_func, sort_data, sort_reverse)
Parameters:

Sets a new sort order on the model. This reorders the entries in the model to match the new sort order.

shuffle_entries()

Shuffles the entries in the model into a new random order.

tree_path_to_entry(path)
Parameters:

path (Gtk.TreePath) – a Gtk.TreePath

Returns:

the RB.RhythmDBEntry, if any

Return type:

RB.RhythmDBEntry

Locates the RB.RhythmDBEntry identified by the specified path in the model. The caller owns a reference to the returned entry.

do_complete() virtual
do_entry_prop_changed(entry, prop, old, new_value) virtual
Parameters:
do_entry_removed(entry) virtual
Parameters:

entry (RB.RhythmDBEntry) –

do_filter_entry_drop(entry) virtual
Parameters:

entry (RB.RhythmDBEntry) –

Return type:

bool

do_non_entry_dropped(uri, position) virtual
Parameters:
  • uri (str) –

  • position (int) –

do_post_entry_delete(entry) virtual
Parameters:

entry (RB.RhythmDBEntry) –

Signal Details

RB.RhythmDBQueryModel.signals.complete(rhythm_d_b_query_model)
Signal Name:

complete

Flags:

RUN_LAST

Parameters:

rhythm_d_b_query_model (RB.RhythmDBQueryModel) – The object which received the signal

Emitted when the database query populating the model is complete.

RB.RhythmDBQueryModel.signals.entry_prop_changed(rhythm_d_b_query_model, entry, prop, old, new_value)
Signal Name:

entry-prop-changed

Flags:

RUN_LAST

Parameters:

Emitted when an entry in the query model is changed. When multiple properties are changed, the entry-prop-changed signals will be emitted in the order that the changes were made. At the point that the signal is emitted, all changes have already been applied to the RB.RhythmDBEntry.

RB.RhythmDBQueryModel.signals.entry_removed(rhythm_d_b_query_model, entry)
Signal Name:

entry-removed

Flags:

RUN_LAST

Parameters:

Emitted when an entry is removed from the model. There is some difference between this and the Gtk.TreeModel row-removed signal but I don’t know what it is right now.

RB.RhythmDBQueryModel.signals.filter_entry_drop(rhythm_d_b_query_model, entry)
Signal Name:

filter-entry-drop

Flags:

RUN_LAST

Parameters:
Return type:

bool

Emitted when an entry is being added to a model by drag-and-drop. This allows the owner of the model to filter out entries that should not be added to the model (based on entry type, for instance). If the signal handler returns False, the entry will not be added.

RB.RhythmDBQueryModel.signals.non_entry_dropped(rhythm_d_b_query_model, uri, position)
Signal Name:

non-entry-dropped

Flags:

RUN_LAST

Parameters:
  • rhythm_d_b_query_model (RB.RhythmDBQueryModel) – The object which received the signal

  • uri (str) – the URI that was dropped

  • position (int) – the position in the query model at which it was dropped

Emitted when a URI that does not match an existing RB.RhythmDBEntry is dropped into the query model.

RB.RhythmDBQueryModel.signals.post_entry_delete(rhythm_d_b_query_model, entry)
Signal Name:

post-entry-delete

Flags:

RUN_LAST

Parameters:

Emitted after an entry has been removed from the model.

Property Details

RB.RhythmDBQueryModel.props.base_model
Name:

base-model

Type:

RB.RhythmDBQueryModel

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

base RB.RhythmDBQueryModel

RB.RhythmDBQueryModel.props.db
Name:

db

Type:

RB.RhythmDB

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

RB.RhythmDB object

RB.RhythmDBQueryModel.props.limit_type
Name:

limit-type

Type:

RB.RhythmDBQueryModelLimitType

Default Value:

RB.RhythmDBQueryModelLimitType.NO_LIMIT

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

type of limit

RB.RhythmDBQueryModel.props.limit_value
Name:

limit-value

Type:

GLib.Variant

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

value of limit

RB.RhythmDBQueryModel.props.query
Name:

query

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE

RhythmDBQuery

RB.RhythmDBQueryModel.props.show_hidden
Name:

show-hidden

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT

if True, include entries that are ordinarily hidden

RB.RhythmDBQueryModel.props.sort_data
Name:

sort-data

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE

Sort data

RB.RhythmDBQueryModel.props.sort_data_destroy
Name:

sort-data-destroy

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE

Sort data destroy function

RB.RhythmDBQueryModel.props.sort_func
Name:

sort-func

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE

Sort function

RB.RhythmDBQueryModel.props.sort_reverse
Name:

sort-reverse

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Reverse sort order flag