/* 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 <gtk/gtk.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 flattens a list of lists.
 *
 * %Gtk::FlattenListModel is a list model that takes a list model containing
 * list models and flattens it into a single model.
 *
 * Another term for this is concatenation: %Gtk::FlattenListModel takes a
 * list of lists and concatenates them into a single list.
 *
 * @see Gio::ListModel
 * @ingroup ListView
 * @newin{3,98}
 */
class GTKMM_API FlattenListModel : public Glib::Object, public Gio::ListModel
{
  _CLASS_GOBJECT(FlattenListModel, GtkFlattenListModel, GTK_FLATTEN_LIST_MODEL, Glib::Object, GObject, , , GTKMM_API)
  _IMPLEMENTS_INTERFACE(Gio::ListModel)
  _DO_NOT_DERIVE_GTYPE dnl// GtkFlattenListModel is a final type
  _ABI_AS_WITH_DERIVED_GTYPE dnl// Remove when we can break ABI
  _STRUCT_NOT_HIDDEN

protected:
  _WRAP_CTOR(FlattenListModel(const Glib::RefPtr<Gio::ListModel>& model), gtk_flatten_list_model_new)

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

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

  _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model_for_item(guint position), gtk_flatten_list_model_get_model_for_item, refreturn)

  _WRAP_PROPERTY("item-type", GType)
  _WRAP_PROPERTY("model", Glib::RefPtr<Gio::ListModel>)
  _WRAP_PROPERTY("n-items", unsigned int)
};

} // namespace Gtk
