Top |
RhythmDBQueryModelRhythmDBQueryModel — a GtkTreeModel containing RhythmDBEntry items |
Functions
Properties
RhythmDBQueryModel * | base-model | Read / Write / Construct |
RhythmDB * | db | Read / Write / Construct Only |
RhythmDBQueryModelLimitType | limit-type | Read / Write / Construct Only |
GVariant * | limit-value | Read / Write / Construct Only |
gpointer | query | Read / Write |
gboolean | show-hidden | Read / Write / Construct |
gpointer | sort-data | Read / Write |
gpointer | sort-data-destroy | Read / Write |
gpointer | sort-func | Read / Write |
gboolean | sort-reverse | Read / Write |
Signals
void | complete | Run Last |
void | entry-prop-changed | Run Last |
void | entry-removed | Run Last |
gboolean | filter-entry-drop | Run Last |
void | non-entry-dropped | Run Last |
void | post-entry-delete | Run Last |
Types and Values
enum | RhythmDBQueryModelLimitType |
#define | RHYTHMDB_QUERY_MODEL_SUGGESTED_UPDATE_CHUNK |
struct | RhythmDBQueryModel |
struct | RhythmDBQueryModelClass |
Implemented Interfaces
RhythmDBQueryModel implements RhythmDBQueryResults, GtkTreeModel, RbTreeDragSource and RbTreeDragDest.
Description
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.
Functions
rhythmdb_query_model_new ()
RhythmDBQueryModel * rhythmdb_query_model_new (RhythmDB *db
,GPtrArray *query
,GCompareDataFunc sort_func
,gpointer sort_data
,GDestroyNotify sort_data_destroy
,gboolean sort_reverse
);
Constructs a new RhythmDBQueryModel with the specified query and sorting parameters.
[skip]
rhythmdb_query_model_new_empty ()
RhythmDBQueryModel *
rhythmdb_query_model_new_empty (RhythmDB *db
);
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_copy_contents ()
void rhythmdb_query_model_copy_contents (RhythmDBQueryModel *dest
,RhythmDBQueryModel *src
);
Copies all entries from src
to dest
.
rhythmdb_query_model_chain ()
void rhythmdb_query_model_chain (RhythmDBQueryModel *model
,RhythmDBQueryModel *base
,gboolean import_entries
);
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.
Parameters
model |
the RhythmDBQueryModel to chain |
|
base |
the RhythmDBQueryModel to chain it to |
|
import_entries |
if |
rhythmdb_query_model_add_entry ()
void rhythmdb_query_model_add_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
,gint index
);
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_remove_entry ()
gboolean rhythmdb_query_model_remove_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
);
Removes an entry from the query model.
rhythmdb_query_model_shuffle_entries ()
void
rhythmdb_query_model_shuffle_entries (RhythmDBQueryModel *model
);
Shuffles the entries in the model into a new random order.
rhythmdb_query_model_move_entry ()
void rhythmdb_query_model_move_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
,gint index
);
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_get_size ()
guint64
rhythmdb_query_model_get_size (RhythmDBQueryModel *model
);
Returns the total size of all entries in the model.
rhythmdb_query_model_get_duration ()
long
rhythmdb_query_model_get_duration (RhythmDBQueryModel *model
);
Returns the total duration of all entries in the model.
rhythmdb_query_model_entry_to_iter ()
gboolean rhythmdb_query_model_entry_to_iter (RhythmDBQueryModel *model
,RhythmDBEntry *entry
,GtkTreeIter *iter
);
Creates a GtkTreeIter pointing to the specified entry in the model.
rhythmdb_query_model_has_pending_changes ()
gboolean
rhythmdb_query_model_has_pending_changes
(RhythmDBQueryModel *model
);
Checks if a RhythmDBQueryModel has any outstanding changes that are yet to be processed. This is not very useful.
rhythmdb_query_model_tree_path_to_entry ()
RhythmDBEntry * rhythmdb_query_model_tree_path_to_entry (RhythmDBQueryModel *model
,GtkTreePath *path
);
Locates the RhythmDBEntry identified by the specified path in the model. The caller owns a reference to the returned entry.
rhythmdb_query_model_iter_to_entry ()
RhythmDBEntry * rhythmdb_query_model_iter_to_entry (RhythmDBQueryModel *model
,GtkTreeIter *entry_iter
);
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_get_next_from_entry ()
RhythmDBEntry * rhythmdb_query_model_get_next_from_entry (RhythmDBQueryModel *model
,RhythmDBEntry *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 ()
RhythmDBEntry * rhythmdb_query_model_get_previous_from_entry (RhythmDBQueryModel *model
,RhythmDBEntry *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_compute_status_normal ()
char * rhythmdb_query_model_compute_status_normal (RhythmDBQueryModel *model
,const char *singular
,const char *plural
);
Constructs a status string describing the contents of the model.
rhythmdb_query_model_set_sort_order ()
void rhythmdb_query_model_set_sort_order (RhythmDBQueryModel *model
,GCompareDataFunc sort_func
,gpointer sort_data
,GDestroyNotify sort_data_destroy
,gboolean sort_reverse
);
Sets a new sort order on the model. This reorders the entries in the model to match the new sort order.
Parameters
model |
||
sort_func |
new sort function |
|
sort_data |
data to pass to the new sort function |
|
sort_data_destroy |
function to call to free the sort data |
|
sort_reverse |
if |
rhythmdb_query_model_reapply_query ()
void rhythmdb_query_model_reapply_query (RhythmDBQueryModel *model
,gboolean filter
);
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.
rhythmdb_query_model_location_sort_func ()
gint rhythmdb_query_model_location_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by location.
rhythmdb_query_model_string_sort_func ()
gint rhythmdb_query_model_string_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
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 ()
gint rhythmdb_query_model_title_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by title. Falls back to sorting by location if the titles are the same.
rhythmdb_query_model_album_sort_func ()
gint rhythmdb_query_model_album_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by album. Sorts by album, then disc number, then track number, then title.
rhythmdb_query_model_artist_sort_func ()
gint rhythmdb_query_model_artist_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by artist. Sorts by artist, then album, then disc number, then track number, then title.
rhythmdb_query_model_genre_sort_func ()
gint rhythmdb_query_model_genre_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by genre. Sorts by genre, then artist, then album, then disc number, then track number, then title.
rhythmdb_query_model_track_sort_func ()
gint rhythmdb_query_model_track_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by track. Sorts by artist, then album, then disc number, then track number, then title.
rhythmdb_query_model_double_ceiling_sort_func ()
gint rhythmdb_query_model_double_ceiling_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
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_ulong_sort_func ()
gint rhythmdb_query_model_ulong_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by an unsigned integer property value. If the values are the same, falls back to sorting by location.
rhythmdb_query_model_bitrate_sort_func ()
gint rhythmdb_query_model_bitrate_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
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.
Types and Values
RHYTHMDB_QUERY_MODEL_SUGGESTED_UPDATE_CHUNK
#define RHYTHMDB_QUERY_MODEL_SUGGESTED_UPDATE_CHUNK 1024
struct RhythmDBQueryModelClass
struct RhythmDBQueryModelClass { GObjectClass parent; /* signals */ 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); };
Property Details
The “base-model”
property
“base-model” RhythmDBQueryModel *
base RhythmDBQueryModel.
Flags: Read / Write / Construct
The “limit-type”
property
“limit-type” RhythmDBQueryModelLimitType
type of limit.
Flags: Read / Write / Construct Only
Default value: RHYTHMDB_QUERY_MODEL_LIMIT_NONE
The “limit-value”
property
“limit-value” GVariant *
value of limit.
Flags: Read / Write / Construct Only
Allowed values: GVariant<t>
Default value: NULL
The “show-hidden”
property
“show-hidden” gboolean
if TRUE, include entries that are ordinarily hidden.
Flags: Read / Write / Construct
Default value: FALSE
The “sort-data-destroy”
property
“sort-data-destroy” gpointer
Sort data destroy function.
Flags: Read / Write
The “sort-reverse”
property
“sort-reverse” gboolean
Reverse sort order flag.
Flags: Read / Write
Default value: FALSE
Signal Details
The “complete”
signal
void user_function (RhythmDBQueryModel *model, gpointer user_data)
Emitted when the database query populating the model is complete.
Flags: Run Last
The “entry-prop-changed”
signal
void user_function (RhythmDBQueryModel *model, RhythmDBEntry *entry, gint prop, gpointer old, gpointer new_value, gpointer user_data)
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.
Parameters
model |
||
entry |
the RhythmDBEntry that changed |
|
prop |
the RhythmDBPropType that was changed |
|
old |
the previous value for the property |
|
new_value |
the new value for the property |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
The “entry-removed”
signal
void user_function (RhythmDBQueryModel *model, RhythmDBEntry *entry, gpointer user_data)
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.
Parameters
model |
||
entry |
the RhythmDBEntry that was removed |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
The “filter-entry-drop”
signal
gboolean user_function (RhythmDBQueryModel *model, RhythmDBEntry *entry, gpointer user_data)
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.
Parameters
model |
||
entry |
the RhythmDBEntry being dropped |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
The “non-entry-dropped”
signal
void user_function (RhythmDBQueryModel *model, gchar *uri, gint position, gpointer user_data)
Emitted when a URI that does not match an existing RhythmDBEntry is dropped into the query model.
Parameters
model |
||
uri |
the URI that was dropped |
|
position |
the position in the query model at which it was dropped |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
The “post-entry-delete”
signal
void user_function (RhythmDBQueryModel *model, RhythmDBEntry *entry, gpointer user_data)
Emitted after an entry has been removed from the model.
Parameters
model |
||
entry |
the RhythmDBEntry that was removed |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last