------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2008-2010 Vadim Godunko <vgodunko@gmail.com>                 --
--                                                                          --
-- QtAda is free software;  you can  redistribute it and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion. QtAda is distributed in the hope that it will be useful, but WITH- --
-- OUT 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 distributed with QtAda;  see file COPYING.  If not, write --
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
-- Boston, MA 02110-1301, USA.                                              --
--                                                                          --
-- As a special exception,  if other files  instantiate  generics from this --
-- unit, or you link  this unit with other files  to produce an executable, --
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
-- covered  by the  GNU  General  Public  License.  This exception does not --
-- however invalidate  any other reasons why  the executable file  might be --
-- covered by the  GNU Public License.                                      --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 3769 $ $Date: 2010-10-24 03:16:28 +0400 (Sun, 24 Oct 2010) $
------------------------------------------------------------------------------

package body Qt4.Model_Index_Lists is

   function new_QModelIndexList return not null access Qt4_Entities.Cpp_Class;
   pragma Import (C, new_QModelIndexList, "__Qt4Ada_new_QModelIndexList");

   procedure delete_QModelIndexList
    (Cpp_Object : not null access Qt4_Entities.Cpp_Class);
   pragma Import
    (C, delete_QModelIndexList, "__Qt4Ada_delete_QModelIndexList");

   procedure assign_QModelIndexList
   (S_1 : not null access          Thin.QModelIndexList;
    S_2 : not null access constant Thin.QModelIndexList);
   pragma Import
    (C, assign_QModelIndexList, "__Qt4Ada_assign_QModelIndexList");

   function comparison_QModelIndexList_wrapper
   (Left  : not null access Thin.QModelIndexList;
    Right : not null access Thin.QModelIndexList)
      return bool;
   pragma Import (C,
                  comparison_QModelIndexList_wrapper,
                  "__Qt4Ada_comparison_QModelIndexList_wrapper");

   procedure value_wrapper
    (Self : not null access Thin.QModelIndexList;
     I    : Interfaces.C.int;
     M_I  : not null access Qt4.Model_Indices.Internals.QModelIndex);
   pragma Import (C, value_wrapper, "__Qt4Ada_QModelIndexList_value_wrapper");

   procedure at_wrapper
   (Self : not null access Thin.QModelIndexList;
    I    : Interfaces.C.int;
    M_I  : not null access Qt4.Model_Indices.Internals.QModelIndex);
   pragma Import (C, at_wrapper, "__Qt4Ada_QModelIndexList_at_wrapper");

   procedure append_wrapper
    (Self  : not null access Thin.QModelIndexList;
     Value : not null access Qt4.Model_Indices.Internals.QModelIndex);
   pragma Import
      (C, append_wrapper, "__Qt4Ada_QModelIndexList_append_wrapper");

   function size_wrapper (Self  : not null access Thin.QModelIndexList)
     return Interfaces.C.int;
   pragma Import
      (C, size_wrapper, "__Qt4Ada_QModelIndexList_size_wrapper");

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> =
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding function "="
    (Left  : Q_Model_Index_List;
     Right : Q_Model_Index_List) return Boolean is
   begin
      return To_Boolean (comparison_QModelIndexList_wrapper
                           (Internals.QModelIndexList_View (Left),
                            Internals.QModelIndexList_View (Right)));
   end "=";

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Append
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   procedure Append (Self  : Q_Model_Index_List;
                     Value : Model_Indices.Q_Model_Index) is
   begin
      append_wrapper (Internals.QModelIndexList_View (Self),
                      Model_Indices.Internals.QModelIndex_View (Value));
   end Append;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Copy_Cpp_Object
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding function Copy_Cpp_Object
    (Self : not null access Q_Model_Index_List)
       return not null access Qt4_Entities.Cpp_Class is
   begin
      return Thin.copy_QModelIndexList (Self.Cpp_Object);
   end Copy_Cpp_Object;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Default_Cpp_Object
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding function Default_Cpp_Object
    (Self : not null access Q_Model_Index_List)
      return access Qt4_Entities.Cpp_Class
   is
      pragma Unreferenced (Self);
      --  Параметр необходим для диспетчеризации надклассового вызова.

   begin
      return new_QModelIndexList;
   end Default_Cpp_Object;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Delete_Cpp_Object
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   overriding
   procedure Delete_Cpp_Object (Self : not null access Q_Model_Index_List) is
   begin
      delete_QModelIndexList (Self.Cpp_Object);
   end Delete_Cpp_Object;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Item_At
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   function Item_At (Self : Q_Model_Index_List;
                     I    : Q_Integer)
      return Model_Indices.Q_Model_Index is
   begin
      return Result : Model_Indices.Q_Model_Index do
         at_wrapper (Internals.QModelIndexList_View (Self),
                     Interfaces.C.int (I),
                     Model_Indices.Internals.QModelIndex_View (Result));
      end return;
   end Item_At;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Size
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   function Size (Self  : Q_Model_Index_List) return Q_Integer is
   begin
      return Q_Integer (size_wrapper (Internals.QModelIndexList_View (Self)));
   end Size;

   ---------------------------------------------------------------------------
   --! <Subprogram>
   --!    <Unit> Value
   --!    <ImplementationNotes>
   ---------------------------------------------------------------------------
   function Value (Self : Q_Model_Index_List;
                   I    : Q_Integer)
      return Model_Indices.Q_Model_Index is
   begin
      return Result : Model_Indices.Q_Model_Index do
         value_wrapper (Internals.QModelIndexList_View (Self),
                        Interfaces.C.int (I),
                        Model_Indices.Internals.QModelIndex_View (Result));
      end return;
   end Value;

   package body Internals is

      ---------------------------------------------------------------------
      --! <Subprogram>
      --!    <Unit> QModelIndexList_View
      --!    <ImplementationNotes>
      ---------------------------------------------------------------------
      function QModelIndexList_View (Self : Q_Model_Index_List)
        return not null access Thin.QModelIndexList
      is
      begin
         return Qt4_Entities.Cpp_Object (Self);
      end QModelIndexList_View;

      ---------------------------------------------------------------------
      --! <Subprogram>
      --!    <Unit> To_Q_Model_Index_List
      --!    <ImplementationNotes>
      ---------------------------------------------------------------------
      function To_Q_Model_Index_List
       (Item : not null access constant Thin.QModelIndexList)
         return Q_Model_Index_List is
      begin
         return Result : Q_Model_Index_List do
            assign_QModelIndexList
             (Internals.QModelIndexList_View (Result), Item);
         end return;
      end To_Q_Model_Index_List;

   end Internals;

end Qt4.Model_Index_Lists;
