/* Copyright (C) 2020 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(gtkmmconfig.h)

#include <giomm/listmodel.h>
#include <gtkmm/filter.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gtk
{

//TODO: Derive from (and implement) SectionModel when we can break ABI.
/** A list model that filters its items.
 *
 * %Gtk::FilterListModel is a list model that filters a given other
 * listmodel.
 * It hides some elements from the other model according to
 * criteria given by a Gtk::Filter.
 *
 * The model can be set up to do incremental searching, so that
 * filtering long lists doesn't block the UI. See set_incremental()
 * for details.
 *
 * @see Gio::ListModel, Gtk::Filter
 * @ingroup ListView
 * @newin{3,98}
 */
class GTKMM_API FilterListModel : public Glib::Object, public Gio::ListModel
{
  _CLASS_GOBJECT(FilterListModel, GtkFilterListModel, GTK_FILTER_LIST_MODEL, Glib::Object, GObject, , , GTKMM_API)
  _IMPLEMENTS_INTERFACE(Gio::ListModel)
  _DO_NOT_DERIVE_GTYPE dnl// GtkFilterListModel is a final type
  _ABI_AS_WITH_DERIVED_GTYPE dnl// Remove when we can break ABI
  _STRUCT_NOT_HIDDEN

protected:
  _WRAP_CTOR(FilterListModel(const Glib::RefPtr<Gio::ListModel>& model, const Glib::RefPtr<Filter>& filter), gtk_filter_list_model_new)

public:
  _WRAP_CREATE(const Glib::RefPtr<Gio::ListModel>& model, const Glib::RefPtr<Filter>& filter)

  _WRAP_METHOD(void set_filter(const Glib::RefPtr<Filter>& filter), gtk_filter_list_model_set_filter)
  _WRAP_METHOD(Glib::RefPtr<Filter> get_filter(), gtk_filter_list_model_get_filter, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Filter> get_filter() const, gtk_filter_list_model_get_filter, refreturn, constversion)

  _WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_filter_list_model_set_model)
  _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_filter_list_model_get_model, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_model() const, gtk_filter_list_model_get_model, refreturn, constversion)

  _WRAP_METHOD(void set_incremental(bool incremental = true), gtk_filter_list_model_set_incremental)
  _WRAP_METHOD(bool get_incremental() const, gtk_filter_list_model_get_incremental)

  _WRAP_METHOD(guint get_pending() const, gtk_filter_list_model_get_pending)

  _WRAP_PROPERTY("filter", Glib::RefPtr<Filter>)
  _WRAP_PROPERTY("incremental", bool)
  _WRAP_PROPERTY("item-type", GType)
  _WRAP_PROPERTY("model", Glib::RefPtr<Gio::ListModel>)
  _WRAP_PROPERTY("n-items", unsigned int)
  _WRAP_PROPERTY("pending", guint)
};

} // namespace Gtk
