#include "tablewidget.h"

#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QTableWidget>

TableWidget::TableWidget(QWidget *parent)
    : FancyWindow(parent)
{
    mCentralWidget = new QWidget;

    mMainVLayout = new QVBoxLayout;
    mTableWidget = new QTableWidget;
    mTableWidget->setObjectName("TableWidget");
    mTableWidget->setRowCount(50);
    mTableWidget->setColumnCount(10);
    mTableWidget->setHorizontalHeaderLabels(QStringList() << "功能1" << "功能2" << "功能3" << "功能4" << "功能5" << "功能6" << "功能6" << "功能8"  << "功能9" << "功能10");
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 50; j++)
        {
            QTableWidgetItem* item = new QTableWidgetItem;
            item->setText(QString("%1, %2").arg(i).arg(j));
            mTableWidget->setItem(i, j, item);
        }
    }

    mButtonHLayout = new QHBoxLayout;
    mSaveButton = new QPushButton;
    mSaveButton->setText("保存");
    mCoseButton = new QPushButton;
    mCoseButton->setText("关闭");
    mButtonHLayout->addStretch();
    mButtonHLayout->addWidget(mSaveButton);
    mButtonHLayout->addWidget(mCoseButton);

    mMainVLayout->addWidget(mTableWidget);
    mMainVLayout->addLayout(mButtonHLayout);
    mCentralWidget->setLayout(mMainVLayout);

    this->setCentralWidget(mCentralWidget);
    this->setObjectName("TableWidget");

    QObject::connect(mCoseButton, &QPushButton::clicked, this, &FancyWindow::hide);
}

TableWidget::~TableWidget()
{

}
