#include "medicalrecordwidget.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QFontMetrics>
#include <QDebug>
#include <QGroupBox>
MedicalRecordWidget::MedicalRecordWidget(QWidget * parent   ):QWidget(parent)
{
    init();
    initLay();
    initConnect();
}
MedicalRecordWidget::~MedicalRecordWidget()
{

}
void  MedicalRecordWidget::init()
{
    setObjectName("MedicalRecordWidget");
    this->setStyleSheet("QWidget \
   {\
       background-color:white;\
        border-radius:10px;\
    }"\
   );

   // setFixedSize(600,600);
    m_labStar.setText(tr("*"));
    m_labStar2.setText(tr("*"));
    m_labStar.setStyleSheet("color:red");
    m_labStar2.setStyleSheet("color:red");
#if 0
    //检查号
    m_labCheckNum.setText(tr("CheckNum"));

    //住院 hospitalized
    m_labType.setText(tr("type"));
    m_chHospitalized.setText(tr("hospitalized"));
    //门诊
    m_chOutpatient.setText(tr("Outpatient"));

    //姓名
    m_labName.setText(tr("Name"));
    //性别
     m_labSex.setText(tr("Sex"));;
    //左右利
    m_labLaterality.setText(tr("Laterality"));
    //检查日期
    m_labDate_Of_inspection.setText(tr("DateInspection"));
    m_labAge.setText(tr("Age"));
    m_labBirthDay.setText(tr("birthDay"));
    //诊断病历
    m_labDiagnosticRecord.setText(tr("Record"));

    m_btnOk.setText(tr("ok"));
    m_btnCancel.setText(tr("Cancel"));

   int iwidth =  QFontMetrics(this->font()).width("Laterality");
   //m_labCheckNum.setFixedWidth(iwidth);
  // m_labName.setFixedWidth(iwidth);
  // m_labLaterality.setFixedWidth(iwidth);
   //m_labDiagnosticRecord.setFixedWidth(iwidth);

#else
     m_gbx.setTitle("病历资料");
    //检查号
    m_labCheckNum.setText(tr("检查号"));

    //住院 hospitalized
    m_labType.setText(tr("类型"));
    m_chHospitalized.setText(tr("住院"));
    //门诊
    m_chOutpatient.setText(tr("门诊"));

    //姓名
    m_labName.setText(tr("姓  名"));
    //性别
     m_labSex.setText(tr("性别"));;
     m_chMan.setText(tr("男"));;
     m_chWan.setText(tr("女"));;
    //左右利
    m_labLaterality.setText(tr("  左右利"));
    m_chLeft.setText(tr("左"));;
    m_chRfight.setText(tr("右"));;
    //检查日期
    m_labDate_Of_inspection.setText(tr("检查日期"));
    m_labAge.setText(tr("年龄"));
    m_labBirthDay.setText(tr("出生日期"));
    //诊断病历
    m_labDiagnosticRecord.setText(tr("其  他:"));
    m_labDiagnosticRecord.setFixedHeight(30);
    m_btnOk.setText(tr("保存"));
    m_btnCancel.setText(tr("取消"));

   int iwidth =  QFontMetrics(this->font()).width("Laterality");
   //m_labCheckNum.setFixedWidth(iwidth);
  // m_labName.setFixedWidth(iwidth);
  // m_labLaterality.setFixedWidth(iwidth);
   //m_labDiagnosticRecord.setFixedWidth(iwidth);

#endif
}
void  MedicalRecordWidget::initLay()
{
#if 1
    QHBoxLayout * hlayStart1  = new QHBoxLayout;
    hlayStart1->addWidget(&m_labStar);
    hlayStart1->addWidget(&m_labCheckNum);
    hlayStart1->addWidget(&m_editCheckNum);


    hlayStart1->addWidget(&m_labType);
    hlayStart1->addWidget(&m_chHospitalized);
    hlayStart1->addWidget(&m_chOutpatient);
    hlayStart1->addStretch();

    QHBoxLayout * hlayStart2  = new QHBoxLayout;
    hlayStart2->addWidget(&m_labStar2);
    hlayStart2->addWidget(&m_labName);
    hlayStart2->addWidget(&m_editName);


    hlayStart2->addWidget(&m_labSex);
    hlayStart2->addWidget(&m_chMan);
    hlayStart2->addWidget(&m_chWan);
    hlayStart2->addStretch();

    QHBoxLayout  * hlay3 = new QHBoxLayout;
    hlay3->addWidget(&m_labBirthDay);
    hlay3->addWidget(&m_dateBirthDay);


    hlay3->addWidget(&m_labAge);
    hlay3->addWidget(&m_editAge);
     hlay3->addStretch();

    QHBoxLayout  * hlay4 = new QHBoxLayout;
    hlay4->addWidget(&m_labLaterality);
    hlay4->addWidget(&m_chLeft);
    hlay4->addWidget(&m_chRfight);
    hlay4->addWidget(&m_labDate_Of_inspection);
    hlay4->addWidget(&m_dateInspection);
    hlay4->addStretch();

    QHBoxLayout  * hlay5 = new QHBoxLayout;
    hlay5->addWidget(&m_labDiagnosticRecord);
    hlay5->addWidget(&m_textDiagnosticRecord);

    QHBoxLayout  * hlay6 = new QHBoxLayout;
    hlay6->addStretch();
    hlay6->addWidget(&m_btnCancel);
    hlay6->addWidget(&m_btnOk);
     hlay6->addStretch();


    QVBoxLayout *vlay = new QVBoxLayout;
    vlay->addLayout(hlayStart1);
    vlay->addLayout(hlayStart2);
    vlay->addLayout(hlay3);
    vlay->addLayout(hlay4);
    vlay->addLayout(hlay5);
    vlay->addLayout(hlay6);

    //vlay->addStretch();



    m_gbx.setLayout(vlay);
    QHBoxLayout * vlayall = new QHBoxLayout;

    vlayall->addWidget(&m_gbx);
    int widthi =50;
    vlay->setContentsMargins(widthi,widthi,widthi,widthi);
    setLayout(vlayall);

    int iwidth = 200;
   m_editCheckNum.setFixedWidth(iwidth);
   m_editName.setFixedWidth(iwidth);
   m_dateBirthDay.setFixedWidth(iwidth);
   m_chLeft.setFixedWidth(iwidth);
   m_editAge.setFixedWidth(iwidth);
   m_chLeft.setFixedWidth(iwidth/2);
   m_chRfight.setFixedWidth(iwidth/2);

#else

    QVBoxLayout * vlay1 = new QVBoxLayout;
    QHBoxLayout * hlayStart1  = new QHBoxLayout;
    hlayStart1->addWidget(&m_labStar);
    hlayStart1->addWidget(&m_labCheckNum);
    vlay1->addLayout(hlayStart1);

    QHBoxLayout * hlayStart2  = new QHBoxLayout;
    hlayStart2->addWidget(&m_labStar2);
    hlayStart2->addWidget(&m_labName);
    vlay1->addLayout(hlayStart2);
    vlay1->addWidget(&m_labBirthDay);
    vlay1->addWidget(&m_labLaterality);
    vlay1->addWidget(&m_labDiagnosticRecord);

    QVBoxLayout * vlay2 = new QVBoxLayout;
    vlay2->addWidget(&m_editCheckNum);
    vlay2->addWidget(&m_editName);
    vlay2->addWidget(&m_dateBirthDay);
    QHBoxLayout  * hlay3 = new QHBoxLayout;
    hlay3->addWidget(&m_chLeft);
    hlay3->addWidget(&m_chRfight);
    vlay2->addLayout(hlay3);
#endif


}
bool  MedicalRecordWidget::initConnect()
{

}
