------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2007-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.                                      --
--                                                                          --
------------------------------------------------------------------------------
--    This file has been generated automatically. Please don't edit it.     --
------------------------------------------------------------------------------
with Qt_Ada.Internals.Boolean_Conversions;
with System.Address_To_Access_Conversions;

package body Qt4.Variants is

   function initialize_QVariant
    (Storage : System.Address)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant, "__QtAda_inititialize_QVariant");

   function initialize_QVariant_unsigned_voidCP
    (Storage  : System.Address;
     the_type : Variant_Type;
     copy     : System.Address)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_unsigned_voidCP, "__QtAda_inititialize_QVariant_unsigned_voidCP");

   function initialize_QVariant_Type
    (Storage : System.Address;
     the_type : Variant_Type)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_Type, "__QtAda_inititialize_QVariant_Type");

   function initialize_QVariant_int
    (Storage : System.Address;
     I : Qt4.Q_Integer)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_int, "__QtAda_inititialize_QVariant_int");

   function initialize_QVariant_bool
    (Storage : System.Address;
     B : Interfaces.C.unsigned)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_bool, "__QtAda_inititialize_QVariant_bool");

   function initialize_QVariant_double
    (Storage : System.Address;
     D : Qt4.Q_Double)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_double, "__QtAda_inititialize_QVariant_double");

   function initialize_QVariant_QStringCR
    (Storage : System.Address;
     String : Qt4.Strings.Internals.QString_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QStringCR, "__QtAda_inititialize_QVariant_QStringCR");

   function initialize_QVariant_QCharCR
    (Storage : System.Address;
     Qchar : Qt4.Chars.Internals.QChar_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QCharCR, "__QtAda_inititialize_QVariant_QCharCR");

   function initialize_QVariant_QDateCR
    (Storage : System.Address;
     Date : Qt4.Dates.Internals.QDate_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QDateCR, "__QtAda_inititialize_QVariant_QDateCR");

   function initialize_QVariant_QTimeCR
    (Storage : System.Address;
     Time : Qt4.Times.Internals.QTime_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QTimeCR, "__QtAda_inititialize_QVariant_QTimeCR");

   function initialize_QVariant_QDateTimeCR
    (Storage : System.Address;
     Datetime : Qt4.Date_Times.Internals.QDateTime_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QDateTimeCR, "__QtAda_inititialize_QVariant_QDateTimeCR");

   function initialize_QVariant_QSizeCR
    (Storage : System.Address;
     Size : Qt4.Sizes.Internals.QSize_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QSizeCR, "__QtAda_inititialize_QVariant_QSizeCR");

   function initialize_QVariant_QSizeFCR
    (Storage : System.Address;
     Size : Qt4.Size_Fs.Internals.QSizeF_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QSizeFCR, "__QtAda_inititialize_QVariant_QSizeFCR");

   function initialize_QVariant_QPointCR
    (Storage : System.Address;
     Pt : Qt4.Points.Internals.QPoint_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QPointCR, "__QtAda_inititialize_QVariant_QPointCR");

   function initialize_QVariant_QPointFCR
    (Storage : System.Address;
     Pt : Qt4.Point_Fs.Internals.QPointF_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QPointFCR, "__QtAda_inititialize_QVariant_QPointFCR");

   function initialize_QVariant_QLineCR
    (Storage : System.Address;
     Line : Qt4.Lines.Internals.QLine_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QLineCR, "__QtAda_inititialize_QVariant_QLineCR");

   function initialize_QVariant_QLineFCR
    (Storage : System.Address;
     Line : Qt4.Line_Fs.Internals.QLineF_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QLineFCR, "__QtAda_inititialize_QVariant_QLineFCR");

   function initialize_QVariant_QRectCR
    (Storage : System.Address;
     Rect : Qt4.Rects.Internals.QRect_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QRectCR, "__QtAda_inititialize_QVariant_QRectCR");

   function initialize_QVariant_QRectFCR
    (Storage : System.Address;
     Rect : Qt4.Rect_Fs.Internals.QRectF_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QRectFCR, "__QtAda_inititialize_QVariant_QRectFCR");

   function initialize_QVariant_QRegExpCR
    (Storage : System.Address;
     Reg_Exp : Qt4.Reg_Exps.Internals.QRegExp_Access)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_QRegExpCR, "__QtAda_inititialize_QVariant_QRegExpCR");

   function initialize_QVariant_GlobalColor
    (Storage : System.Address;
     Color : Qt4.Global_Color)
      return Internals.QVariant_Access;
   pragma Import (C, initialize_QVariant_GlobalColor, "__QtAda_inititialize_QVariant_GlobalColor");

   function adjust_QVariant
    (Storage : System.Address;
     From    : Internals.QVariant_Access)
       return Internals.QVariant_Access;
   pragma Import (C, adjust_QVariant, "__QtAda_adjust_QVariant");

   procedure finalize_QVariant (Object : Internals.QVariant_Access);
   pragma Import (C, finalize_QVariant, "__QtAda_finalize_QVariant");

   function QVariant_canConvert_Type
    (Self : Internals.QVariant_Access;
     T : Variant_Type)
       return Interfaces.C.unsigned;
   pragma Import (C, QVariant_canConvert_Type, "__QtAda_QVariant_canConvert_Type_Q");

   procedure QVariant_clear
    (Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_clear, "__QtAda_QVariant_clear");

   function QVariant_isNull
    (Self : Internals.QVariant_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QVariant_isNull, "__QtAda_QVariant_isNull_Q");

   function QVariant_isValid
    (Self : Internals.QVariant_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QVariant_isValid, "__QtAda_QVariant_isValid_Q");

   function QVariant_toBool
    (Self : Internals.QVariant_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QVariant_toBool, "__QtAda_QVariant_toBool_Q");

   function QVariant_toDouble
    (Self : Internals.QVariant_Access;
     Ok   : access Interfaces.C.unsigned)
       return Qt4.Q_Double;
   pragma Import (C, QVariant_toDouble, "__QtAda_QVariant_toDouble_bool_Q");

   function QVariant_toInt
    (Self : Internals.QVariant_Access;
     Ok   : access Interfaces.C.unsigned)
       return Qt4.Q_Integer;
   pragma Import (C, QVariant_toInt, "__QtAda_QVariant_toInt_bool_Q");

   procedure QVariant_toChar
    (Returns : Qt4.Chars.Internals.QChar_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toChar, "__QtAda_QVariant_toChar_Q");

   procedure QVariant_toDate
    (Returns : Qt4.Dates.Internals.QDate_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toDate, "__QtAda_QVariant_toDate_Q");

   procedure QVariant_toTime
    (Returns : Qt4.Times.Internals.QTime_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toTime, "__QtAda_QVariant_toTime_Q");

   procedure QVariant_toDateTime
    (Returns : Qt4.Date_Times.Internals.QDateTime_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toDateTime, "__QtAda_QVariant_toDateTime_Q");

   procedure QVariant_toLine
    (Returns : Qt4.Lines.Internals.QLine_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toLine, "__QtAda_QVariant_toLine_Q");

   procedure QVariant_toLineF
    (Returns : Qt4.Line_Fs.Internals.QLineF_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toLineF, "__QtAda_QVariant_toLineF_Q");

   procedure QVariant_toPoint
    (Returns : Qt4.Points.Internals.QPoint_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toPoint, "__QtAda_QVariant_toPoint_Q");

   procedure QVariant_toPointF
    (Returns : Qt4.Point_Fs.Internals.QPointF_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toPointF, "__QtAda_QVariant_toPointF_Q");

   procedure QVariant_toRect
    (Returns : Qt4.Rects.Internals.QRect_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toRect, "__QtAda_QVariant_toRect_Q");

   procedure QVariant_toRectF
    (Returns : Qt4.Rect_Fs.Internals.QRectF_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toRectF, "__QtAda_QVariant_toRectF_Q");

   procedure QVariant_toSize
    (Returns : Qt4.Sizes.Internals.QSize_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toSize, "__QtAda_QVariant_toSize_Q");

   procedure QVariant_toSizeF
    (Returns : Qt4.Size_Fs.Internals.QSizeF_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toSizeF, "__QtAda_QVariant_toSizeF_Q");

   procedure QVariant_toString
    (Returns : Qt4.Strings.Internals.QString_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toString, "__QtAda_QVariant_toString_Q");

   procedure QVariant_toRegExp
    (Returns : Qt4.Reg_Exps.Internals.QRegExp_Access;
     Self : Internals.QVariant_Access);
   pragma Import (C, QVariant_toRegExp, "__QtAda_QVariant_toRegExp_Q");

   function QVariant_type
    (Self : Internals.QVariant_Access)
       return Variant_Type;
   pragma Import (C, QVariant_type, "__QtAda_QVariant_type");

   function QVariant_userType
    (Self : Internals.QVariant_Access)
       return Qt4.Meta_Types.Meta_Type_Type;
   pragma Import (C, QVariant_userType, "__QtAda_QVariant_userType");

   function eq_QVariantCR
    (Self : Internals.QVariant_Access;
     V : Internals.QVariant_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QVariantCR, "__QtAda_QVariant_eq_QVariantCR_Q");

   function QVariant_constData
    (Self : Internals.QVariant_Access)
       return System.Address;
   pragma Import (C, QVariant_constData, "__QtAda_QVariant_constData_Q");

   procedure registerMetaType_QVariant;
   pragma Import (C, registerMetaType_QVariant, "__QtAda_registerMetaType_QVariant");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Variant) is
      use type Internals.QVariant_Access;

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

   ------------
   -- Create --
   ------------

   function Create
     return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant (Self.Storage'Address);
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (the_type : Variant_Type)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_Type (Self.Storage'Address, the_type);
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (I : Qt4.Q_Integer)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_int (Self.Storage'Address, I);
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (B : Boolean)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_bool (Self.Storage'Address, Qt_Ada.Internals.Boolean_Conversions.To_unsigned (B));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (D : Qt4.Q_Double)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_double (Self.Storage'Address, D);
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (String : Qt4.Strings.Q_String'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QStringCR (Self.Storage'Address, Qt4.Strings.Internals.QString_View (String));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Qchar : Qt4.Chars.Q_Char'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QCharCR (Self.Storage'Address, Qt4.Chars.Internals.QChar_View (Qchar));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Date : Qt4.Dates.Q_Date'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QDateCR (Self.Storage'Address, Qt4.Dates.Internals.QDate_View (Date));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Time : Qt4.Times.Q_Time'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QTimeCR (Self.Storage'Address, Qt4.Times.Internals.QTime_View (Time));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Datetime : Qt4.Date_Times.Q_Date_Time'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QDateTimeCR (Self.Storage'Address, Qt4.Date_Times.Internals.QDateTime_View (Datetime));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Size : Qt4.Sizes.Q_Size'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QSizeCR (Self.Storage'Address, Qt4.Sizes.Internals.QSize_View (Size));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Size : Qt4.Size_Fs.Q_Size_F'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QSizeFCR (Self.Storage'Address, Qt4.Size_Fs.Internals.QSizeF_View (Size));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Pt : Qt4.Points.Q_Point'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QPointCR (Self.Storage'Address, Qt4.Points.Internals.QPoint_View (Pt));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Pt : Qt4.Point_Fs.Q_Point_F'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QPointFCR (Self.Storage'Address, Qt4.Point_Fs.Internals.QPointF_View (Pt));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Line : Qt4.Lines.Q_Line'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QLineCR (Self.Storage'Address, Qt4.Lines.Internals.QLine_View (Line));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Line : Qt4.Line_Fs.Q_Line_F'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QLineFCR (Self.Storage'Address, Qt4.Line_Fs.Internals.QLineF_View (Line));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Rect : Qt4.Rects.Q_Rect'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QRectCR (Self.Storage'Address, Qt4.Rects.Internals.QRect_View (Rect));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Rect : Qt4.Rect_Fs.Q_Rect_F'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QRectFCR (Self.Storage'Address, Qt4.Rect_Fs.Internals.QRectF_View (Rect));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Reg_Exp : Qt4.Reg_Exps.Q_Reg_Exp'Class)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_QRegExpCR (Self.Storage'Address, Qt4.Reg_Exps.Internals.QRegExp_View (Reg_Exp));
      end return;
   end Create;

   ------------
   -- Create --
   ------------

   function Create
    (Color : Qt4.Global_Color)
       return Q_Variant
   is
   begin
      return Self : Q_Variant
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QVariant_GlobalColor (Self.Storage'Address, Color);
      end return;
   end Create;

   -----------------
   -- Can_Convert --
   -----------------

   function Can_Convert
    (Self : Q_Variant'Class;
     T : Variant_Type)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QVariant_canConvert_Type (Self.Object, T), 0);
   end Can_Convert;

   -----------
   -- Clear --
   -----------

   procedure Clear
    (Self : in out Q_Variant'Class)
   is
   begin
      QVariant_clear (Self.Object);
   end Clear;

   -------------
   -- Is_Null --
   -------------

   function Is_Null
    (Self : Q_Variant'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QVariant_isNull (Self.Object), 0);
   end Is_Null;

   --------------
   -- Is_Valid --
   --------------

   function Is_Valid
    (Self : Q_Variant'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QVariant_isValid (Self.Object), 0);
   end Is_Valid;

   -------------
   -- To_Bool --
   -------------

   function To_Bool
    (Self : Q_Variant'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QVariant_toBool (Self.Object), 0);
   end To_Bool;

   ---------------
   -- To_Double --
   ---------------

   function To_Double
    (Self : Q_Variant'Class)
       return Qt4.Q_Double
   is
      Valid  : aliased Interfaces.C.unsigned;
      Result : Qt4.Q_Double := QVariant_toDouble (Self.Object, Valid'Access);

   begin
      if Interfaces.C."=" (Valid, 0) then
         raise Constraint_Error;
      end if;

      return Result;
   end To_Double;

   ----------------
   -- To_Integer --
   ----------------

   function To_Integer
    (Self : Q_Variant'Class)
       return Qt4.Q_Integer
   is
       Valid  : aliased Interfaces.C.unsigned;
       Result : Qt4.Q_Integer := QVariant_toInt (Self.Object, Valid'Access);

   begin
      if Interfaces.C."=" (Valid, 0) then
         raise Constraint_Error;
      end if;

      return Result;
   end To_Integer;

   -------------
   -- To_Char --
   -------------

   function To_Char
    (Self : Q_Variant'Class)
       return Qt4.Chars.Q_Char
   is
   begin
      return Returns : Qt4.Chars.Q_Char do
         QVariant_toChar (Qt4.Chars.Internals.QChar_View (Returns), Self.Object);
      end return;
   end To_Char;

   -------------
   -- To_Date --
   -------------

   function To_Date
    (Self : Q_Variant'Class)
       return Qt4.Dates.Q_Date
   is
   begin
      return Returns : Qt4.Dates.Q_Date do
         QVariant_toDate (Qt4.Dates.Internals.QDate_View (Returns), Self.Object);
      end return;
   end To_Date;

   -------------
   -- To_Time --
   -------------

   function To_Time
    (Self : Q_Variant'Class)
       return Qt4.Times.Q_Time
   is
   begin
      return Returns : Qt4.Times.Q_Time do
         QVariant_toTime (Qt4.Times.Internals.QTime_View (Returns), Self.Object);
      end return;
   end To_Time;

   ------------------
   -- To_Date_Time --
   ------------------

   function To_Date_Time
    (Self : Q_Variant'Class)
       return Qt4.Date_Times.Q_Date_Time
   is
   begin
      return Returns : Qt4.Date_Times.Q_Date_Time do
         QVariant_toDateTime (Qt4.Date_Times.Internals.QDateTime_View (Returns), Self.Object);
      end return;
   end To_Date_Time;

   -------------
   -- To_Line --
   -------------

   function To_Line
    (Self : Q_Variant'Class)
       return Qt4.Lines.Q_Line
   is
   begin
      return Returns : Qt4.Lines.Q_Line do
         QVariant_toLine (Qt4.Lines.Internals.QLine_View (Returns), Self.Object);
      end return;
   end To_Line;

   ---------------
   -- To_Line_F --
   ---------------

   function To_Line_F
    (Self : Q_Variant'Class)
       return Qt4.Line_Fs.Q_Line_F
   is
   begin
      return Returns : Qt4.Line_Fs.Q_Line_F do
         QVariant_toLineF (Qt4.Line_Fs.Internals.QLineF_View (Returns), Self.Object);
      end return;
   end To_Line_F;

   --------------
   -- To_Point --
   --------------

   function To_Point
    (Self : Q_Variant'Class)
       return Qt4.Points.Q_Point
   is
   begin
      return Returns : Qt4.Points.Q_Point do
         QVariant_toPoint (Qt4.Points.Internals.QPoint_View (Returns), Self.Object);
      end return;
   end To_Point;

   ----------------
   -- To_Point_F --
   ----------------

   function To_Point_F
    (Self : Q_Variant'Class)
       return Qt4.Point_Fs.Q_Point_F
   is
   begin
      return Returns : Qt4.Point_Fs.Q_Point_F do
         QVariant_toPointF (Qt4.Point_Fs.Internals.QPointF_View (Returns), Self.Object);
      end return;
   end To_Point_F;

   -------------
   -- To_Rect --
   -------------

   function To_Rect
    (Self : Q_Variant'Class)
       return Qt4.Rects.Q_Rect
   is
   begin
      return Returns : Qt4.Rects.Q_Rect do
         QVariant_toRect (Qt4.Rects.Internals.QRect_View (Returns), Self.Object);
      end return;
   end To_Rect;

   ---------------
   -- To_Rect_F --
   ---------------

   function To_Rect_F
    (Self : Q_Variant'Class)
       return Qt4.Rect_Fs.Q_Rect_F
   is
   begin
      return Returns : Qt4.Rect_Fs.Q_Rect_F do
         QVariant_toRectF (Qt4.Rect_Fs.Internals.QRectF_View (Returns), Self.Object);
      end return;
   end To_Rect_F;

   -------------
   -- To_Size --
   -------------

   function To_Size
    (Self : Q_Variant'Class)
       return Qt4.Sizes.Q_Size
   is
   begin
      return Returns : Qt4.Sizes.Q_Size do
         QVariant_toSize (Qt4.Sizes.Internals.QSize_View (Returns), Self.Object);
      end return;
   end To_Size;

   ---------------
   -- To_Size_F --
   ---------------

   function To_Size_F
    (Self : Q_Variant'Class)
       return Qt4.Size_Fs.Q_Size_F
   is
   begin
      return Returns : Qt4.Size_Fs.Q_Size_F do
         QVariant_toSizeF (Qt4.Size_Fs.Internals.QSizeF_View (Returns), Self.Object);
      end return;
   end To_Size_F;

   ---------------
   -- To_String --
   ---------------

   function To_String
    (Self : Q_Variant'Class)
       return Qt4.Strings.Q_String
   is
   begin
      return Returns : Qt4.Strings.Q_String do
         QVariant_toString (Qt4.Strings.Internals.QString_View (Returns), Self.Object);
      end return;
   end To_String;

   ----------------
   -- To_Reg_Exp --
   ----------------

   function To_Reg_Exp
    (Self : Q_Variant'Class)
       return Qt4.Reg_Exps.Q_Reg_Exp
   is
   begin
      return Returns : Qt4.Reg_Exps.Q_Reg_Exp do
         QVariant_toRegExp (Qt4.Reg_Exps.Internals.QRegExp_View (Returns), Self.Object);
      end return;
   end To_Reg_Exp;

   --------------
   -- Get_Type --
   --------------

   function Get_Type
    (Self : Q_Variant'Class)
       return Variant_Type
   is
   begin
      return QVariant_type (Self.Object);
   end Get_Type;

   -------------------
   -- Get_User_Type --
   -------------------

   function Get_User_Type
    (Self : Q_Variant'Class)
       return Qt4.Meta_Types.Meta_Type_Type
   is
   begin
      return QVariant_userType (Self.Object);
   end Get_User_Type;

   ---------
   -- "=" --
   ---------

   overriding function "="
    (Self : Q_Variant;
     V : Q_Variant)
       return Boolean is
   begin
      return Interfaces.C."/=" (eq_QVariantCR (Self.Object, V.Object), 0);
   end "=";

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

   package body Internals is

   -------------------
   -- QVariant_View --
   -------------------

      function QVariant_View
       (Item : Q_Variant'Class)
          return QVariant_Access
      is
      begin
         return Item.Object;
      end QVariant_View;

      package QVariant_Conversions is
        new System.Address_To_Access_Conversions
             (QVariant);

   ------------------------
   -- QVariantTo_Pointer --
   ------------------------

      function To_Pointer
       (Address : System.Address)
          return QVariant_Access
      is
      begin
         return
           QVariant_Access
            (QVariant_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   ------------------------
   -- QVariantTo_Address --
   ------------------------

      function To_Address
       (Pointer : QVariant_Access)
          return System.Address
      is
      begin
         return
           QVariant_Conversions.To_Address
            (QVariant_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

   --------------------
   -- Create_Wrapper --
   --------------------

      function Create_Wrapper
       (Item : Internals.QVariant_Access)
          return Q_Variant
      is
      begin
         return Q_Variant'
          (Ada.Finalization.Controlled with
             Object  => Item,
             Wrapper => True,
             others  => <>);
      end Create_Wrapper;

      ------------
      -- Create --
      ------------

      function Create
        (The_Type : Qt4.Meta_Types.Meta_Type_Type;
         Copy     : System.Address)
           return Q_Variant
      is
      begin
         return Self : Q_Variant
           := (Ada.Finalization.Controlled with others => <>)
         do
            Self.Object :=
              initialize_QVariant_unsigned_voidCP
               (Self.Storage'Address, Variant_Type (The_Type), Copy);
         end return;
      end Create;

      ----------------
      -- Const_Data --
      ----------------

      function Const_Data (Item : Q_Variant'Class) return System.Address is
      begin
         return QVariant_constData (Item.Object);
      end Const_Data;

   end Internals;

begin
   registerMetaType_QVariant;
end Qt4.Variants;
