#ifndef SANALY2
#define SANALY2

#include <QWidget>
#include <QCalendarWidget>
#include <QDateEdit>
#include <QPushButton>
#include <QHBoxLayout>
#include <QComboBox>
#include <QLineEdit>
#include <QGroupBox>
#include <QListWidget>
#include <QTabWidget>
#include <QRadioButton>
#include <QButtonGroup>
#include <QTableWidget>
#include <QProgressBar>
#include <QMenuBar>
#include <QSqlDatabase>
#include <QListWidgetItem>
#include "stable.h"
#include "widget.h"
#include "keywordthread.h"
#include <QMutex>
class SAnaly2 : public QWidget
{
    enum E_COLUMN
    {
        E_COLUMN_DATABASE=0,
        E_COLUMN_NAME,
        E_COLUMN_DATE,
        E_COLUMN_COUNT,
    };

    enum E_LENGTH_COMP
    {
        E_LENGTH_COMP_GREATER = 0,
        E_LENGTH_COMP_LESS,
        E_LENGTH_COMP_EQUAL,
    };
    Q_OBJECT
public:
    SAnaly2(QWidget *parent = 0);
    ~SAnaly2();
    int getThread();
    unsigned int getDateStart();
    unsigned int getDateEnd();
    int getPeriod();
    QStringList getMorphereList();
    bool getDateAll();
    QString getUserDictList();
    void Exec(int setBodyTitle);

private:
    // Data
    QListWidget *m_plwData;
    // Date
    QCalendarWidget *m_pcw;
    QDateEdit *m_pdeStart;
    QDateEdit *m_pdeEnd;
    //QPushButton *m_ppbInsertCalc;
    //QComboBox *m_pcbDateCatalog;
    //
    QTabWidget *m_ptwData;
    //
    QProgressBar *m_pProgress;
    // Column
    QVector <QStringList> m_vecColumn;
    KeywordThread **m_pThread;
    // MorphereList
    QListWidget *m_plwMorphereList;
    QListWidget *m_plwMorphereAdd;

    QComboBox *m_pcbDate;
    QComboBox *m_pcbPeriod;

    QLineEdit *m_pleTop;
    QLineEdit *m_pleKeyword;

    QComboBox *m_pcbThread;
    QComboBox *m_pcbSort;

    QListWidgetItem **m_plwiMorphere;
    QStringList m_strlistMorphere;
    QStringList m_strlistMorphereko;
    Widget *m_pwidget;
    QRadioButton *m_rbDateMorphere;
    QRadioButton *m_rbMorphereDate;
    QButtonGroup *m_bgRadioGroup;

    QLineEdit *m_pleCKeyword;

    QComboBox *m_pcbDictionary;
    QList<STable*> m_lTable;
    QList<QTabWidget*> m_lTabWidget;
    QTabWidget* m_ptwTable;
    QMutex mutex;
    QString m_strCKeyword;
public:
    struct m_mapKey
    {
        QString strDate;
        QString strMorphere;
        QString strKeyword;
    };

    //QHash<m_mapKey, int> m_HashResult[16];
    QHash<QString, int> m_HashResult[16];
    QMap<QString, int> m_TotalResult;
    QMap<QString, QMap<QString, QMap<int, QString> > > m_mapViewResult;

private:
    QGroupBox *setMorphereList();
    QGroupBox *setDate();
    QGroupBox *setFilter();
    QGroupBox *setOther();
    QGroupBox *setSort();
    QGroupBox *setDictionary();
    QGroupBox *setCenterKeyword();


    void ExecThread(int _setBodyTitle);
    void EmergeThreadResult();
    void SortViewResult();
    void ViewResult();

    QTableWidget *AddTable(QString _str);
public slots:
    void CloseTab(int index);
    void DoubleClickTab(int index);
    void FileImport();
    void FileExport();
    void RawFileExport();
    void MemClear();
    void MorphereListAdd();
    void MorphereListDel();
    void AddDictionary();
    void DelDictionary();
    bool setListMorphere(QStringList& MorphereEN, QStringList& MorphereKO);
    QTabWidget* getQTabWidget();
    void setWidget(Widget *widget);
    bool isSortMorphereDateChecked();
    bool isSortDateMorphereChecked();
};


#endif // SANALY2

