#ifndef SBATCHRUN
#define SBATCHRUN

#include <QDialog>
#include "scolumn.h"
#include "./../common.h"
#include <QString>
#include <QMap>

class QGroupBox;
class QListWidget;
class QLineEdit;
class QDateEdit;
class QVBoxLayout;

class SBatchRun : public QDialog
{
    Q_OBJECT
public:
    enum E_COLUMN
    {
        E_COLUMN_DATABASE=0,
        E_COLUMN_NAME,
        E_COLUMN_DATE,
        E_COLUMN_COUNT,
    };

    enum E_ARTICLE
    {
        E_ARTICLE_BODY = 0,
        E_ARTICLE_REPLY,
        E_ARTICLE_MAX,
    };

    enum E_DATA
    {
        E_DATA_platform_title = 0,
        E_DATA_article_form,
        E_DATA_article_parent,
        E_DATA_article_id,
        E_DATA_article_nickname,
        E_DATA_article_title,
        E_DATA_article_data,
        E_DATA_article_url,
        E_DATA_article_hit,
        E_DATA_article_date,
        E_DATA_article_order,
        E_DATA_platform_id,
        E_DATA_platform_name,
        E_DATA_platform_form,
        E_DATA_reply_url,
        E_DATA_keyword_id,
        E_DATA_article_profileurl,
        E_DATA_article_profile,
        E_DATA_etc,
        E_DATA_MAX,
    };


private slots:
    void clickedFromTo(bool clicked);
    void clickedCutDays(bool clicked);
    void run();
    void Refresh();

private:
    void setMainWidgets();
    QVBoxLayout* setLoadWidgets();
    QVBoxLayout* setDaysWidgets();
    QVBoxLayout* setFilterWidgets();
    QGroupBox* setCutDaysWidgets();
    QGroupBox* setFromToWidgets();
    void RefreshFilter(int nGroupID);
    void ViewResult();
    void ViewRawResult();
    bool execFilter();
    bool loadData();
    void clearData();
    void Message(QString strMessage);

    // functions from FilterProcess
    bool ReloadColumn();
    void DataFilter();
    void FilterDate(QString strJson);
    void FilterSerach(QString strJson);
    void FilterLength(QString strJson);
    void FilterReplace(QString strJson);
    void FilterCounter(QString _strJson);


public:
    SBatchRun();
    ~SBatchRun();
    void showBatchRun(int nGroupID);


private:
    QVector<QStringList> m_vecData[E_ARTICLE_MAX];
    QVector<QStringList> m_data[E_ARTICLE_MAX];
    QListWidget *m_plwData, *m_plwFilter;
    QGroupBox *m_pgbCutDays, *m_pgbFromTo;
    QLineEdit *m_pleCutDays, *m_pleFilter;
    QDateEdit *m_pdeFrom, *m_pdeTo;

    QVector <SKeyword> m_vecKeyword;

    //variables from FilterProcess
    QStringList m_listDataBaseColumn;
    int m_nUrlColumn, m_nDateColumn, m_nOrderColumn;
    int m_anData[E_DATA_MAX];
    bool m_bDataFlag[E_DATA_MAX];
};



#endif // SBATCHRUN

