/* * Copyright (C) 2012 - Juan Ferrer Toribio * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DB_ITERATOR_H #define DB_ITERATOR_H #include "db-model.h" #define DB_TYPE_ITERATOR (db_iterator_get_type ()) #define DB_ITERATOR(self) (G_TYPE_CHECK_INSTANCE_CAST (self, DB_TYPE_ITERATOR, DbIterator)) #define DB_IS_ITERATOR(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, DB_TYPE_ITERATOR)) #define DB_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, DB_TYPE_ITERATOR, DbIteratorClass)) #define DB_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, DB_TYPE_ITERATOR)) #define DB_ITERATOR_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, DB_TYPE_ITERATOR, DbIteratorClass)) #define DB_TYPE_ITERATOR_MODE (db_iterator_mode_get_type ()) typedef struct _DbIterator DbIterator; typedef struct _DbIteratorClass DbIteratorClass; #include "db-param.h" /** * DbIteratorMode: * @DB_ITERATOR_MODE_ON_CHANGE: every change made in a cell will be sent to the * database instantly. * @DB_ITERATOR_MODE_ON_ITER: every change made in a row will be sent to the * database when iter changes. * @DB_ITERATOR_MODE_ON_DEMAND: nothing will be sent to the database since it's * demanded. * * The working mode of a Iterator. **/ typedef enum { DB_ITERATOR_MODE_ON_CHANGE ,DB_ITERATOR_MODE_ON_ITER ,DB_ITERATOR_MODE_ON_DEMAND } DbIteratorMode; /** * DbIteratorMove: * @DB_ITERATOR_MOVE_FIRST: Moves to the first position. * @DB_ITERATOR_MOVE_PREVIOUS: Moves previous. * @DB_ITERATOR_MOVE_NEXT: Moves next. * @DB_ITERATOR_MOVE_LAST: Moves to the last position. * * Indicates the movement. **/ typedef enum { DB_ITERATOR_MOVE_FIRST ,DB_ITERATOR_MOVE_PREVIOUS ,DB_ITERATOR_MOVE_NEXT ,DB_ITERATOR_MOVE_LAST } DbIteratorMove; struct _DbIterator { GObject parent; DbModel * model; GList * params; DbIteratorMode mode; DbIter iter; GHashTable * selected; gint row; gboolean row_selected; gboolean remember_selection; }; struct _DbIteratorClass { /* */ GObjectClass parent; }; GType db_iterator_get_type (); GType db_iterator_mode_get_type () G_GNUC_CONST; DbIterator * db_iterator_new (DbModel * model); gboolean db_iterator_is_ready (DbIterator * self); DbIteratorMode db_iterator_get_mode (DbIterator * self); void db_iterator_set_mode (DbIterator * self, DbIteratorMode mode); gint db_iterator_get_row (DbIterator * self); gboolean db_iterator_get_iter (DbIterator * self, DbIter * iter); void db_iterator_select_iter (DbIterator * self, DbIter * iter); void db_iterator_move_iter (DbIterator * self, DbIter * iter); void db_iterator_move_first (DbIterator * self); void db_iterator_move_last (DbIterator * self); void db_iterator_move_previous (DbIterator * self); void db_iterator_move_next (DbIterator * self); void db_iterator_move_to (DbIterator * self, DbIteratorMove move); void db_iterator_refresh (DbIterator * self); const GvnParamSpec * db_iterator_get_spec (DbIterator * self, gint column); const GValue * db_iterator_get_value (DbIterator * self, gint column); gint db_iterator_get_column_index (DbIterator * self, const gchar * name); gboolean db_iterator_set_value (DbIterator * self, gint column, const GValue * value, GError ** err); void db_iterator_delete (DbIterator * self); void db_iterator_insert (DbIterator * self); void db_iterator_add_param (DbIterator * self, DbParam * param); GvnParam * db_iterator_get_param (DbIterator * self, const gchar * column); GList * db_iterator_get_params (DbIterator * self); void db_iterator_bind_param (DbIterator * self, const gchar * column, GvnParam * param); void db_iterator_link (DbIterator * self, const gchar * field, DbIterator * src, const gchar * column); void db_iterator_link_with_param (DbIterator * self, const gchar * field, GvnParam * param); gint db_iterator_get_nrows (DbIterator * self); DbModelUpdateFlags db_iterator_get_update_flags (DbIterator * self); void db_iterator_reverse_operations (DbIterator * self); void db_iterator_perform_operations (DbIterator * self); DbModelRowOp db_iterator_get_pending_operations (DbIterator * self); gboolean db_iterator_has_pending_operations (DbIterator * self); #endif