#include "diskdetailswidget.h"

DiskDetailsWidget::DiskDetailsWidget(QWidget *parent): BaseDetailViewWidget(parent)
{
    this->setAttribute(Qt::WA_TranslucentBackground);
    initUI();
}

DiskDetailsWidget::~DiskDetailsWidget()
{

}

void DiskDetailsWidget::initUI()
{
    setTitle(tr("Disk"));

    m_pDiskGraphScrollArea =  new DiskViewScrollArea();

    // 详情列表
    m_pDetailModel = new DiskDetailsModel();
    m_pDetailList =  new DetailListTable(m_pDetailModel);
    m_pDetailList->setFixedHeight(108);
    mCurrentDiskName = m_pDiskGraphScrollArea->getCurrentDiskName();
    m_pDetailModel->refreshDiskInfo(mCurrentDiskName);

    QHBoxLayout *listHLayout = new QHBoxLayout(this);
    listHLayout->addWidget(m_pDetailList);

    mMainLayout->addWidget(m_pDiskGraphScrollArea);
    mMainLayout->addSpacing(8);
    mMainLayout->addLayout(listHLayout);

    connect(m_pDiskGraphScrollArea, &DiskViewScrollArea::changeInfo, this, [=](const QString &diskName){
//        m_pDetailModel->refreshDiskInfo(diskName);
        mCurrentDiskName = diskName;
    });
}

void DiskDetailsWidget::onUpdateData()
{
    m_pDiskGraphScrollArea->onUpdateData();
    m_pDetailModel->refreshDiskInfo(mCurrentDiskName);
    // 刷新数据列表
    m_pDetailModel->onModelUpdated();
}

