### Class

# RB RhythmDBQueryModel

#### Description [src]

    class RB.RhythmDBQueryModel : GObject.Object
      implements Gtk.TreeModel, RB.RhythmDBQueryResults {
      RhythmDBQueryModelPrivate* priv
    }

A RhythmDBQueryModel contains an ordered set of `RhythmDBEntry` items, either generated by running a query against the database, or populated by adding individual entries.

All sources use a `RhythmDBQueryModel` to provide their track listing. Since most sources provide a search or filtering capacity, there is usually a distinction between the source’s base query model, which contains all entries for the source, and its current query model, which reflects the current search terms and filter selections.

A RhythmDBQueryModel can be populated directly from the `RhythmDB`, or it can be chained to another query model. Chained query models inherit the set of entries from the query model they chain to and then restrict the set using a query.

The query model consists of a `GSequence`, which provides ordering of entries, and a `GHashTable`, which allows efficient checks to see if a given entry is in the model. A side effect of this is that an entry can only be placed into a query model in one location.

In addition to the query, a `RhythmDBQueryModel` can have a sort order and a limit, specified in terms of file size, duration, or number of entries. A query model can only have a limit if it also has a sort order, as the sort order is required to determine which entries fall inside the limit. When a limit is applied, entries that match the query but fall outside the limit are maintained in a separate `GSequence` and `GHashTable` inside the query model.

#### Ancestors

- GObject

#### Implements

- GtkTreeModel
- RhythmDBQueryResults

#### Constructors

###### rhythmdb_query_model_new

Constructs a new `RhythmDBQueryModel` with the specified query and sorting parameters.

###### rhythmdb_query_model_new_empty

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.

###### rhythmdb_query_model_new_for_entry_type

No description available.

#### Functions

###### rhythmdb_query_model_album_sort_func

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

###### rhythmdb_query_model_artist_sort_func

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

###### rhythmdb_query_model_bitrate_sort_func

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.

###### rhythmdb_query_model_composer_sort_func

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

###### rhythmdb_query_model_date_sort_func

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

###### rhythmdb_query_model_double_ceiling_sort_func

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.

###### rhythmdb_query_model_genre_sort_func

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

###### rhythmdb_query_model_location_sort_func

Sort function for sorting by location.

###### rhythmdb_query_model_string_sort_func

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

###### rhythmdb_query_model_title_sort_func

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

###### rhythmdb_query_model_track_sort_func

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

###### rhythmdb_query_model_ulong_sort_func

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

#### Instance methods

###### rhythmdb_query_model_add_entry

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

###### rhythmdb_query_model_chain

Chains `model` 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.

###### rhythmdb_query_model_compute_status_normal

Constructs a status string describing the contents of the model.

###### rhythmdb_query_model_copy_contents

Copies all entries from `src` to `dest`.

###### rhythmdb_query_model_entry_to_iter

Creates a `GtkTreeIter` pointing to the specified entry in the model.

###### rhythmdb_query_model_get_duration

Returns the total duration of all entries in the model.

###### rhythmdb_query_model_get_next_from_entry

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

###### rhythmdb_query_model_get_previous_from_entry

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

###### rhythmdb_query_model_get_size

Returns the total size of all entries in the model.

###### rhythmdb_query_model_has_pending_changes

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

###### rhythmdb_query_model_iter_to_entry

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

###### rhythmdb_query_model_move_entry

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.

###### rhythmdb_query_model_reapply_query

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.

###### rhythmdb_query_model_remove_entry

Removes an entry from the query model.

###### rhythmdb_query_model_set_sort_order

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

###### rhythmdb_query_model_shuffle_entries

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

###### rhythmdb_query_model_tree_path_to_entry

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

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

##### Methods inherited from GtkTreeModel (28)

Please see GtkTreeModel for a full list of methods.

##### Methods inherited from RhythmDBQueryResults (3)

###### rhythmdb_query_results_add_results

Provides a new set of query results. References must be taken on the entries.

###### rhythmdb_query_results_query_complete

Called when the query is complete and all entries that match the query have been supplied to rhythmdb_query_results_add_results. If the object implementing this interface needs to identify newly added or changed entries that match the query, it needs to use the entry-added, entry-deleted and entry-changed signals from `RhythmDB`.

###### rhythmdb_query_results_set_query

When a new query is run, this method is invoked to give the object implementing this interface a chance to take a copy of the query criteria, so that it can evaluate the query for newly added or changed entries once the query is complete.

#### Properties

###### RB.RhythmDBQueryModel:base-model

No description available.

###### RB.RhythmDBQueryModel:db

No description available.

###### RB.RhythmDBQueryModel:limit-type

No description available.

###### RB.RhythmDBQueryModel:limit-value

No description available.

###### RB.RhythmDBQueryModel:query

No description available.

###### RB.RhythmDBQueryModel:show-hidden

No description available.

###### RB.RhythmDBQueryModel:sort-data

No description available.

###### RB.RhythmDBQueryModel:sort-data-destroy

No description available.

###### RB.RhythmDBQueryModel:sort-func

No description available.

###### RB.RhythmDBQueryModel:sort-reverse

No description available.

#### Signals

###### RB.RhythmDBQueryModel::complete

Emitted when the database query populating the model is complete.

###### RB.RhythmDBQueryModel::entry-prop-changed

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 `RhythmDBEntry`.

###### RB.RhythmDBQueryModel::entry-removed

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

###### RB.RhythmDBQueryModel::filter-entry-drop

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::non-entry-dropped

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

###### RB.RhythmDBQueryModel::post-entry-delete

Emitted after an entry has been removed from the model.

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

##### Signals inherited from GtkTreeModel (5)

###### GtkTreeModel::row-changed

This signal is emitted when a row in the model has changed.

###### GtkTreeModel::row-deleted

This signal is emitted when a row has been deleted.

###### GtkTreeModel::row-has-child-toggled

This signal is emitted when a row has gotten the first child row or lost its last child row.

###### GtkTreeModel::row-inserted

This signal is emitted when a new row has been inserted in the model.

###### GtkTreeModel::rows-reordered

This signal is emitted when the children of a node in the `GtkTreeModel` have been reordered.

#### Class structure

    struct RBRhythmDBQueryModelClass {
      GObjectClass parent;
      void (* complete) (
        RhythmDBQueryModel* model
      );
      void (* entry_prop_changed) (
        RhythmDBQueryModel* model,
        RhythmDBEntry* entry,
        RhythmDBPropType prop,
        const GValue* old,
        const GValue* new_value
      );
      void (* non_entry_dropped) (
        RhythmDBQueryModel* model,
        const char* uri,
        int position
      );
      void (* entry_removed) (
        RhythmDBQueryModel* model,
        RhythmDBEntry* entry
      );
      void (* post_entry_delete) (
        RhythmDBQueryModel* model,
        RhythmDBEntry* entry
      );
      gboolean (* filter_entry_drop) (
        RhythmDBQueryModel* model,
        RhythmDBEntry* entry
      );

    }

No description available.

###### Class members

`parent: GObjectClass`

  No description available.

`complete: void (* complete) ( RhythmDBQueryModel* model )`

  No description available.

`entry_prop_changed: void (* entry_prop_changed) ( RhythmDBQueryModel* model, RhythmDBEntry* entry, RhythmDBPropType prop, const GValue* old, const GValue* new_value )`

  No description available.

`non_entry_dropped: void (* non_entry_dropped) ( RhythmDBQueryModel* model, const char* uri, int position )`

  No description available.

`entry_removed: void (* entry_removed) ( RhythmDBQueryModel* model, RhythmDBEntry* entry )`

  No description available.

`post_entry_delete: void (* post_entry_delete) ( RhythmDBQueryModel* model, RhythmDBEntry* entry )`

  No description available.

`filter_entry_drop: gboolean (* filter_entry_drop) ( RhythmDBQueryModel* model, RhythmDBEntry* entry )`

  No description available.

#### Virtual methods

###### RB.RhythmDBQueryModelClass.complete

No description available.

###### RB.RhythmDBQueryModelClass.entry_prop_changed

No description available.

###### RB.RhythmDBQueryModelClass.entry_removed

No description available.

###### RB.RhythmDBQueryModelClass.filter_entry_drop

No description available.

###### RB.RhythmDBQueryModelClass.non_entry_dropped

No description available.

###### RB.RhythmDBQueryModelClass.post_entry_delete

No description available.