#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QLineEdit>
#include <QTimer>
#include <QDateEdit>
#include <QListWidget>
#include <QSqlDatabase>
#include <QComboBox>
#include <QCheckBox>
#include <QGroupBox>

class SNaverCafeManage;
class SNaverBlogManage;
class SDaumCafeManage;
class SNaverNewsManage;
class SNaverCafeListManage;
class SManage;
class SDaumCafeListManage;
class SKakaoChannelManage;
class SKakaoTagManage;
class SKakaoUserManage;
class SInstaTagManage;
class SInstaUserManage;
class SFacebookTagManage;
class SFacebookUserManage;
class SNaverBlogAccuracyManage;

#define SAFE_DELETE(p) {if(p) delete (p); (p) = NULL; }

class Widget : public QWidget
{
    Q_OBJECT
public:
    Widget(QWidget *parent = 0);
    ~Widget();        
public:
    void    InsertLog(QString str);
    bool    SetCrawlingState(QString _str);
    bool    LockTable();
    void    UnLockTables();
    void    Debug(QString _strMsg);
    QString StartDay();
    QString UntilPage();

    enum E_MODE
    {
        E_MODE_WAIT = 0,
        E_MODE_RUN,
    };

private:        
    QLineEdit *m_pedUntilPage;
    QLineEdit *m_pedStartDay;
    QTimer m_timer,m_timerAlive;
    QSqlDatabase m_db;    
    static const int C_PLATFORM_MAX = 14;
    SManage *m_pManage[C_PLATFORM_MAX];
    QListWidget	*m_pResultList;
    QString m_strFileName;
    QComboBox   *m_pcb;
    QVector <QString> m_vecSelect;
    SNaverCafeManage *m_pNaverCafe;
    SNaverBlogManage *m_pNaverBlog;
    SDaumCafeManage *m_pDaumCafe;
    SNaverNewsManage *m_pNaverNews;
    SNaverCafeListManage *m_pNaverCafeList;
    SDaumCafeListManage *m_pDaumCafeList;
    SKakaoChannelManage *m_pKakaoChannel;
    SKakaoTagManage *m_pKakaoTag;
    SKakaoUserManage *m_pKakaoUser;
    SInstaTagManage *m_pInstaTag;
    SInstaUserManage *m_pInstaUser;
    SFacebookTagManage *m_pFacebookTag;
    SFacebookUserManage *m_pFacebookUser;
    SNaverBlogAccuracyManage *m_pNaverBlogAccuracy;
    int m_nStartTime,m_nRangeTime,m_nPlatform;    
    //QGroupBox *m_pgbManual;
    QCheckBox *m_pcheckboxReal;
    int m_nMode;
    QString m_strCrawlingID;
private:                
    void    Start();
    QString makeCafeGetListQuery(QString _str,QDate _date,int _nPage);    
    QGroupBox *setRealGroupWidgets();
private slots:    
    void RefreshButton();
    void StartButton();
    void StopButton();
    void Update();
    void Alive();
};

#endif // WIDGET_H
