#ifndef BLASTRECORD_H
#define BLASTRECORD_H

#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QStandardItemModel>
#include <QUrl>
#include <QWidget>

#include "../PageWidget.h"
#include "../global.h"
#include "../httpclient.h"
#include "hblastrecorddao.h"
namespace Ui {
class BlastRecord;
}

class BlastRecord : public QWidget {
    Q_OBJECT

   public:
    explicit BlastRecord(QWidget *parent = nullptr);
    ~BlastRecord();

   private:
    void dataTable(const QJsonDocument &jsonDoc);
    void drawTable(QList<QSharedPointer<HBlastRecord>> blastRecordsList);
    void loadAndRefreshData();
    void PageChanged(int page);
    void onComboBoxIndexChanged(int index);
    QList<QStandardItem *> jsonToItem(const QJsonObject &jsonObj);

   private:
    Ui::BlastRecord *ui;
    PageWidget *m_pPageWidget;
    int m_pageSize;     // 每页显示的记录数量
    int m_currentPage;  // 当前页面
    int m_totalCount;
    HBlastRecordDao dao;
    QStandardItemModel *model;
    QJsonArray dataArray;
};

#endif  // BLASTRECORD_H
