#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QHBoxLayout>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QFileDialog>
#include <QProcess>
#include <QTimer>
#include <QDateTime>
#include <QCheckBox>
#include <QSql>
#include <QSqlQuery>
#include <QSqlDatabase>
#include <QTextStream>
#include <QFile>
#include <QListWidget>
#include <QMutex>
namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();
    bool SendIpList(QStringList _str);
    bool Debug(QString _strFilename,QString _strData);
    void InsertLog(QString str);
    void InsertCrawlingLog(QString str);
    void skipSite();
    QStringList getProxyList();

    QStringList readList(QString strPath);
private:
    Ui::Widget *ui;

    QHBoxLayout *hlayoutParam[4];
    QHBoxLayout *hlayoutDefault;
    QVBoxLayout *vlayoutButton;
    QVBoxLayout *vlayoutParam;
    QGridLayout *glayout;
    QLineEdit *p_lineUrl;
    QLineEdit *p_lineTime;
    QLineEdit *p_lineProxyFile;
    QMutex mutex;

    QLabel *p_labelUrl;
    QLabel *p_labelTime;
    QLabel *p_labelProxyFile;
    QLabel *p_labelRecentTime;
    QLabel *p_labelNextTime;
    QLabel *p_labelTimerOnOff;
    QLabel *p_labelRecent;
    QLabel *p_labelNext;

    QCheckBox *p_chkDb;
    QCheckBox *p_chkLocal;

    QFileDialog *p_FileDialog;
    QListWidget *m_pResultList;
    QListWidget *m_pCrawlingResultList;
    QPushButton *p_btnStart;
    QPushButton *p_btnStop;
    QPushButton *p_btnChoose;
    QProcess v_pro;
    QTimer *p_timer;
    QTimer *p_checkTimer;
    QTimer *p_crawlingTimer;
    QStringList m_slIpPortList;
    QStringList m_slIpPortListTemp;
    QStringList m_slIpUrl;
    int m_index;
public slots:
    void btnStart();
    void btnStop();
    void btnChoose();
    void update();
    //void processFinished();
    void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
    void chkDb();
    void chkLocal();
    void checkProxy();
    void crawlingProxy();
    void updateDB();
};

#endif // WIDGET_H
