#include "awidget.h"

#include <QVBoxLayout>
#include <QGridLayout>
#include <QLineEdit>
#include <QLabel>

AWidget::AWidget(QWidget *parent)
    : QWidget(parent)
{
    mMainHLayout = new QHBoxLayout;
    mLabel1 = new QLabel;
    mLabel1->setText("I am A");
    mLabel1->setAlignment(Qt::AlignCenter);
    mHorizontalLine = new QFrame;
    mHorizontalLine->setFrameShape(QFrame::VLine);

    mParamWidget = new QWidget;
    mParamGLayout = new QGridLayout;
    mParam1Label = new QLabel;
    mParam1Label->setText("参数1:");
    mParam1LineEdit = new QLineEdit;
    mParam2Label = new QLabel;
    mParam2Label->setText("参数2:");
    mParam2LineEdit = new QLineEdit;
    mParam3Label = new QLabel;
    mParam3Label->setText("参数3:");
    mParam3LineEdit = new QLineEdit;
    mParam4Label = new QLabel;
    mParam4Label->setText("参数4:");
    mParam4LineEdit = new QLineEdit;
    mParam5Label = new QLabel;
    mParam5Label->setText("参数5:");
    mParam5LineEdit = new QLineEdit;
    mParam6Label = new QLabel;
    mParam6Label->setText("参数6:");
    mParam6LineEdit = new QLineEdit;
    mParamGLayout->addWidget(mParam1Label, 0, 0);
    mParamGLayout->addWidget(mParam1LineEdit, 0, 1);
    mParamGLayout->addWidget(mParam2Label, 0, 2);
    mParamGLayout->addWidget(mParam2LineEdit, 0, 3);
    mParamGLayout->addWidget(mParam3Label, 1, 0);
    mParamGLayout->addWidget(mParam3LineEdit, 1, 1);
    mParamGLayout->addWidget(mParam4Label, 1, 2);
    mParamGLayout->addWidget(mParam4LineEdit, 1, 3);
    mParamGLayout->addWidget(mParam5Label, 2, 0);
    mParamGLayout->addWidget(mParam5LineEdit, 2, 1);
    mParamGLayout->addWidget(mParam6Label, 2, 2);
    mParamGLayout->addWidget(mParam6LineEdit, 2, 3);
    mParamWidget->setLayout(mParamGLayout);

    mMainHLayout->addWidget(mLabel1, 2);
    mMainHLayout->addWidget(mHorizontalLine);
    mMainHLayout->addWidget(mParamWidget, 1);
    this->setLayout(mMainHLayout);
}

void AWidget::showHideParam()
{
    if(mParamWidget->isVisible())
    {
        mParamWidget->hide();
        mHorizontalLine->hide();
    }
    else
    {
        mParamWidget->show();
        mHorizontalLine->show();
    }
}

