/********************************* CMDI_Generic.cpp *******************************
 *                                                                                *
 *   #include "CMDI_Terrain.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 "CMDI_Generic.h"
#include "../../MedinTuxTools/CPrtQListBoxItem.h"


/*! \class CMDI_Generic
 *  Classe dont hériteront toutes les autres CMDI.
*/

//---------------------------------- CMDI_Generic ----------------------------------------------------------------------------------
CMDI_Generic::CMDI_Generic(QWidget* parent, const char* name, int wflags, CMoteurBase *pCMoteurBase, RUBREC_LIST  *pRubList)
        :QMainWindow( parent, name, wflags ), m_pCMoteurBase(pCMoteurBase) , m_RubName(name), m_pRubList(pRubList)
        {
        }

//---------------------------------- DoActionWithThisDocument ----------------------------------------------------------------------------------
void CMDI_Generic::DoActionWithThisDocument(const QString &/*action*/, int /*typ*/, const char */*path =0*/, const QDateTime */*pQDateTime=0*/, const QString */*libelle=0*/, const QString */*subType=0*/)
{return ;
}

//---------------------------------- ChangeCurrentComboBoxItemName ----------------------------------------------------------------------------------
void CMDI_Generic::ChangeCurrentComboBoxItemName(const QString &name)
{if (name.length()==0)               return;
 CPrtQListBoxItem* pCPrtQListBoxItem  = GetRubListComboBox();
 if (!pCPrtQListBoxItem)             return;
 pCPrtQListBoxItem->setText ( name );
}

//---------------------------------- GetRubListComboBox ----------------------------------------------------------------------------------
CPrtQListBoxItem    *CMDI_Generic::GetRubListComboBox()
{return 0;
}

//---------------------------------- AddNewDocument ----------------------------------------------------------------------------------
void   CMDI_Generic::AddNewDocument(const QString &/*strData*/, int /*typ*/, const char */*path =0*/, const QDateTime */*pQDateTime=0*/, const QString */*libelle=0*/,  const QString */*subType=0*/)
{return ;
}

//---------------------------------- GetType ----------------------------------------------------------------------------------
int CMDI_Generic::GetType()
               {return m_Type;
               }
//---------------------------------- SetType ----------------------------------------------------------------------------------
void CMDI_Generic::SetType(int type)
               {m_Type = type;
               }

//---------------------------------- GetDefaultMaskDirectory ----------------------------------------------------------------------------------
QString CMDI_Generic::GetDefaultMaskDirectory()
{return (G_pCApp->m_PathGlossaire + m_RubName);
}
//---------------------------------- GetDefaultMaskFile ----------------------------------------------------------------------------------
QString CMDI_Generic::GetDefaultMaskFile()
{return (GetDefaultMaskDirectory()+"/default.html");
}
//---------------------------------- setGeometry ----------------------------------------------------------------------------------
void CMDI_Generic::setGeometry(QRect rect, int flag)
               {setCaption(m_RubName);
                //................................. un peu de geometrie ........................................
               QString val1, val2, val3, val4;
               if (flag) QMainWindow::setGeometry (rect);
                //if (m_pCMoteurBase->Param_ReadParam( m_RubName, "Montrer", &val1)==0)  // zero = pas d'erreur
                   {if ( /*val1=="Normal" && */
                        m_pCMoteurBase->Param_ReadParam( m_RubName, "Position", &val1, &val2, &val3, &val4)==0
                       )
 	             // zero = pas d'erreur 
 	             {QPoint p(atoi(val1),atoi(val2));        // store position
                        QSize  s(atoi(val3),atoi(val4));        // store size
                        resize( s );        // restore size
                        move( p );          // restore position
 	             }   	       
 	          }
               }
//---------------------------------- saveGeometry ----------------------------------------------------------------------------------
void CMDI_Generic::saveGeometry()
               {QPoint p ;   // store position
                QSize  s ;   // store size
                QPoint p_ofs = pos() ;         // permet de relever hauteur et largeur decorations 
                p = parentWidget ()->pos() ;   // store position
                s = parentWidget ()->size();   // store size
                m_pCMoteurBase->Param_WriteParam( m_RubName, "Montrer", "Normal");
                m_pCMoteurBase->Param_WriteParam( m_RubName, "Position", 
                                                 QString::number(p.x()),     QString::number(p.y()), 
                                                 QString::number(s.width()-p_ofs.x()), QString::number(s.height()-p_ofs.y()));
               }
    
//---------------------------------- ActiverRubrique ----------------------------------------------------------------------------------
void    CMDI_Generic::ActiverRubrique(const char *rubName)
{   if (rubName != m_RubName) return;
    showNormal();
    //setActiveWindow();
    //hide();
    //show();

    //update();
    //updateGeometry ();
    //setActiveWindow ();
    //raise ();
    //show();
}
