#ifndef WIDGET_H
#define WIDGET_H

#include <QListWidget>
#include <QWidget>
#include <QProgressBar>
#include <QTimer>
#include <QSqlDatabase>
#include <QLineEdit>
#include <QDateTime>
#include <QProcess>

class Widget : public QWidget
{
    Q_OBJECT
public:
    Widget(QWidget *parent = 0);
    ~Widget();
    enum E_LIST
    {
        E_LIST_DATA = 0,
        E_LIST_FILTER,
        E_LIST_COMPANY,
        E_LIST_CATALOG,
        E_LIST_MAX
    };
    enum E_SERVICE
    {
        E_SERVICE_INFLUENCER = 0,
        E_SERVICE_CONSUMER,
        E_SERVICE_SPAMMER,
        E_SERVICE_POWERCAFE,
        E_SERVICE_MAX
    };

    void FilterProcssRefresh(QString _strGroupID);
    void Refresh();
    bool ReloadSetup();

private:
    QListWidget *m_plw;
    QListWidget *m_plwLog;
    QListWidget *m_plwFilterProcess;    
    QListWidget *m_plwFilterProcessGroup;    
    QListWidget *m_plwProcess;
    QTimer m_statusTimer;
    QTimer m_executionTimer;
    QLineEdit *m_pleFilterProcessGroup;        
    QLineEdit *m_pleExcutionTime;

    QString m_strWebDataBaseHost;
    QString m_strWebDataBaseUser;
    QString m_strWebDataBasePass;
    QString m_strWebDataBaseName;

    QSqlDatabase m_db;
    void InsertLog(QString str);
    void InsertFilterProcess(int _nProcessType);
    void Kill(int _nProcess);

#define D_PROCESS_MAX  1024
    QProcess m_aProcess[D_PROCESS_MAX];
private slots:
    void CompanyItemChanged(QListWidgetItem*,QListWidgetItem* _prev = 0);
    void FilterProcessGroupClicked(QListWidgetItem*);
    void on_load();
    void on_refresh();
    void on_category();
    void on_send();
    void on_delete();
    void on_influence_count();
    void on_power_cafe_count();
    void on_consumer_supervison_count();
    void on_spammers_count();

    void on_process_insert();
    void on_process_delete();

    void on_filter_process_group_insert();
    void on_filter_process_group_delete();
    void on_filter_process_group_modify();
    void time_update();
    void time_execute();
    void process_refresh();
    void process_output();    
    void on_process_start();
    void on_process_stop();
};

#endif // WIDGET_H
