------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2009-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) $
------------------------------------------------------------------------------
with Qt_Ada.Internals.Objects.Object_Utilities;

package body Qt4.List_Of_Q_Integers is

   function initialize_QListOfint
    (Storage : System.Address)
       return Internals.QListOfint_Access;
   pragma Import
           (C, initialize_QListOfint, "__QtAda_initialize_QListOfint");

   function adjust_QListOfint
    (Storage : System.Address;
     From    : Internals.QListOfint_Access)
       return Internals.QListOfint_Access;
   pragma Import (C, adjust_QListOfint, "__QtAda_adjust_QListOfint");

   procedure finalize_QListOfint
    (Object : Internals.QListOfint_Access);
   pragma Import
           (C, finalize_QListOfint, "__QtAda_finalize_QListOfint");

   procedure QListOfint_append_int
    (Self  : not null Internals.QListOfint_Access;
     Value : Qt4.Q_Integer);
   pragma Import (C, QListOfint_append_int, "__QtAda_QListOfint_append_int");

   function QListOfint_size
    (Self : not null Internals.QListOfint_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QListOfint_size, "__QtAda_QListOfint_size");

   function QListOfint_value_int
    (Self  : not null Internals.QListOfint_Access;
     Index : Qt4.Q_Integer)
       return Qt4.Q_Integer;
   pragma Import
           (C, QListOfint_value_int, "__QtAda_QListOfint_value_int");

   ------------
   -- Adjust --
   ------------

   overriding
   procedure Adjust (Self : in out Q_List_Of_Q_Integer) is
   begin
      Self.Object := adjust_QListOfint (Self.Storage'Address, Self.Object);
      Self.Wrapper := False;
   end Adjust;

   --------------
   -- Finalize --
   --------------

   overriding
   procedure Finalize (Self : in out Q_List_Of_Q_Integer) is
   begin
      if not Self.Wrapper then
         finalize_QListOfint (Self.Object);
      end if;
   end Finalize;

   ----------------
   -- Initialize --
   ----------------

   overriding
   procedure Initialize (Self : in out Q_List_Of_Q_Integer) is
      use type Internals.QListOfint_Access;

   begin
      if Self.Object = null then
         Self.Object := initialize_QListOfint (Self.Storage'Address);
      end if;
   end Initialize;

   ------------
   -- Append --
   ------------

   procedure Append
    (Self  : Q_List_Of_Q_Integer'Class;
     Value : Qt4.Q_Integer) is
   begin
      QListOfint_append_int (Self.Object, Value);
   end Append;

   ----------
   -- Size --
   ----------

   function Size (Self : Q_List_Of_Q_Integer'Class) return Qt4.Q_Integer is
   begin
      return QListOfint_size (Self.Object);
   end Size;

   -----------
   -- Value --
   -----------

   function Value
    (Self  : Q_List_Of_Q_Integer'Class;
     Index : Qt4.Q_Integer) return Qt4.Q_Integer is
   begin
      return QListOfint_value_int (Self.Object, Index);
   end Value;

   ---------------
   -- Internals --
   ---------------

   package body Internals is

      ---------------------
      -- QListOfint_View --
      ---------------------

      function QListOfint_View
       (Item : Q_List_Of_Q_Integer'Class) return QListOfint_Access is
      begin
         return Item.Object;
      end QListOfint_View;

   end Internals;

end Qt4.List_Of_Q_Integers;
