/********************************* CMDI_Ident.cpp ********************************
 *                                                                                *
 *   #include "CMDI_Ident.h"                                                      *
 *   Project: MedinTux                                                            *
 *   Copyright (C) 2003 2004 2005 by Sevin Roland  and Data Medical Design        *
 *   E-Mail: data.medical.design@club-internet.fr                                 *
 *                                                                                *
 *   This program is free software; you can redistribute it and/or modify         *
 *   it under the terms of the CeCILL Version 1 du 21/06/2004                     *
 *   License (GPL compatible)                                                     *
 *                              http://www.cecill.info/                           *
 *   as published by :                                                            *
 *                                                                                *
 *   Commissariat à l'Energie Atomique                                            *
 *   - CEA,                                                                       *
 *                            31-33 rue de la Fédération, 75752 PARIS cedex 15.   *
 *                            FRANCE                                              *
 *   Centre National de la Recherche Scientifique                                 *
 *   - CNRS,                                                                      *
 *                            3 rue Michel-Ange, 75794 Paris cedex 16.            *
 *                            FRANCE                                              *
 *   Institut National de Recherche en Informatique et en Automatique             *
 *   - INRIA,                                                                     *
 *                            Domaine de Voluceau, Rocquencourt, BP 105, 78153    *
 *                            FRANCE                                              *
 *                                                                                *
 *         This program 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.                   *
 *         CeCILL  License (GPL compatible) for more details.                     *
 *                                                                                *
 **********************************************************************************/
#include <qvbox.h>
#include "CMDI_Ident.h"
#include "CApp.h"
#include "drtux.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//====================================== CMDI_Ident ============================================================================



//---------------------------------- CMDI_Ident --------------------------------------------------------------------------------
CMDI_Ident::CMDI_Ident( QWidget* parent, const char* name, int wflags,  
			CMoteurBase *pCMoteurBase, RUBREC_LIST  *pRubList,
                        const char* num_GUID, const char* id_doss, 
			const char* dossNom, const char* dossPrenom, const char* user)
   :CMDI_Generic( parent, name, wflags , pCMoteurBase, pRubList) // : QMainWindow( parent, name, wflags )
{   SetType(TYP_IDENTITE);
    SetPrintableState(FALSE);
    QVBox *pQVCentral = new QVBox( this );
    m_pFormRubIdent = new FormRubIdent(pQVCentral, QString("Form") + name );
    if (m_pFormRubIdent)
       {m_pFormRubIdent->m_pCMoteurBase = pCMoteurBase;
         if (num_GUID)   m_pFormRubIdent->m_NumGUID    = num_GUID;
         else            m_pFormRubIdent->m_NumGUID    = "";
         if (id_doss)    m_pFormRubIdent->m_ID_Doss    = id_doss;
         else            m_pFormRubIdent->m_ID_Doss    = "";
         if (dossNom)    m_pFormRubIdent->m_DossNom    = dossNom;
         else            m_pFormRubIdent->m_DossNom    = "";
         if (dossPrenom) m_pFormRubIdent->m_DossPrenom = dossPrenom;
         else            m_pFormRubIdent->m_DossPrenom = "";
         if (dossPrenom) m_pFormRubIdent->m_User       = user;
         else            m_pFormRubIdent->m_User       = "";

         m_pFormRubIdent->SetData();
        }
    setIcon(Theme::getIcon("16x16/type_ident.png"));
    setFocusProxy( m_pFormRubIdent );
    setCentralWidget( pQVCentral );
}

//---------------------------------- ~CMDI_Ident -------------------------------------------------------------------------------
CMDI_Ident::~CMDI_Ident()
{emit Sign_RubIsDeleted(CMDI_Ident::S_GetRubName());
 if (G_pCApp->m_pDrTux) G_pCApp->m_pDrTux->m_pCMDI_Ident = 0;
}

//---------------------------------- RubOnUserChange -----------------------------------------------------------------------------
void CMDI_Ident::RubOnUserChange(const char*user, const char*/*sign_user*/)
{ m_pFormRubIdent->m_User       = user;
}

//---------------------------------- OnIdentChange -----------------------------------------------------------------------------
/*! \brief Ce slot est appelé par qui veut, pour signaler un changement d'identité à cette fenetre MDI qui doit donc adapter son contenu à un nouveau malade.*/
void CMDI_Ident::OnIdentChange(const char* num_GUID,  const char* id_doss,
                               const char* dossNom ,  const char* dossPrenom )
{ m_pFormRubIdent->m_NumGUID    = num_GUID;
  m_pFormRubIdent->m_ID_Doss    = id_doss;
  m_pFormRubIdent->m_DossNom    = dossNom;
  m_pFormRubIdent->m_DossPrenom = dossPrenom;
  m_pFormRubIdent->SetData();
}

//---------------------------------- SetModifiableState -----------------------------------------------------------------------------
void CMDI_Ident::SetModifiableState(int state)
{ if (m_pFormRubIdent) m_pFormRubIdent->SetModifiableState(state);
}
