#ifndef SANALYZER
#define SANALYZER


#include <QThread>
#include <QWidget>
#include "widget.h"
#include <QDebug>
#include <QMutex>
#include "mecab.h"
#include <QLibrary>


class SAnaly1;
class AnalyzerThread : public QThread
{

    Q_OBJECT
public:

    AnalyzerThread(QObject *parent = NULL);
    AnalyzerThread(int number);
    AnalyzerThread(QMutex &_mutex, int number, int &_nCount);

private:

    enum {
        MONDAY = 1,
        TUESDAY,
        WEDNESDAY,
        THURSDAY,
        FRIDAY,
        SATURDAY,
        SUNDAY
    };

    enum
    {
        WEEK = 7
    };
    int num;
    QWidget *m_pQWidget;
    int m_nThread;
    QStringList m_slMorphereList;
    int m_nSource;
    bool m_bPeriod;
    bool m_bDateAll;
    int m_nPeriod; // 0 none, 1 1day, 2 1week, 3 1month;
    unsigned int m_nDateStart;
    unsigned int m_nDateEnd;
    int m_nTitleBody;
    Widget *m_pWidget;
    int m_nPosDate;
    int m_nPosBody;
    int m_nPosTitle;
    int m_nPosPlatformTitle;
    QMutex *mutex;
    SAnaly1 *pWidget;
    QTabWidget *m_pTabWidget;
    int *nCount;

protected:
    void run();

public:
    void setThreadNumber(int _nThread = 1);
    int getThreadNumber();
    void setWidget(QWidget *_pWidget);
    QWidget* getWidget();
    void setMorphereList(const QStringList morpherelist);
    void setMorphereList(const QString morphere);
    QStringList getMorphereList();
    void resetMorphereList();
    void setParametersfromWidget(QWidget *_pWidget, int _nSource);
    void setPeriod(const int _nPeriod);
    int getPeriod();
    void setDate(const QString _strStart, const QString _strEnd);
    void setDate(const QDateTime _dtStart, const QDateTime _dtEnd);
    void setDateStart(const QString _strStart);
    void setDateStart(const QDateTime _dtStart);
    void setDateEnd(const QString _strEnd);
    void setDateEnd(const QDateTime _dtStart);
    unsigned int getDateStart();
    unsigned int getDateEnd();
    void setTitleBody(const int _n);
    void setSource(QWidget* _qwidget);
    void setPosDate(const int _nPos);
    void setPosBody(const int _nPos);
    void setPosTitle(const int _nPos);
    void setPosPlatformTitle(const int _nPos);
    QString getWeeksInMonth(unsigned int _nDate);
    void setAnalyzerThread(QMutex &_mutex, int number, int &_nCount);
};
#endif // SANALYZER
