#ifndef SFILTEROBJECT_H
#define SFILTEROBJECT_H

#include <QDialog>
#include <QTabWidget>
#include <QDateEdit>
#include <QComboBox>
#include <QLineEdit>
#include <QCheckBox>

#include "./../common.h"

class SFilterObject : public QDialog
{
    Q_OBJECT    
public:
    SFilterObject();
    ~SFilterObject();
    void setWidgets();
    QWidget *setDateWidgets();
    QWidget *setSearchWidgets();
    QWidget *setReplaceWidgets();
    QWidget *setLengthWidgets();
    QWidget *setCounterWidgets();

    void lockTabs(int _nExcept);
    void unlockTabs(); 

    void JsonToWidget(int _nSelect,QString _strJson);
    QString JsonToString(int _nSelect,QString _strJson);

    void DataBaseFilter(int _nType,QString _strJson,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
    void DataBaseTimeFilter(int _nArticle ,QDate _dateStart ,QDate _dateEnd ,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
    void DataBaseSearchFilter(int _nArticle,int _nCategory,int _nMethod,int _nKeyword ,bool _nLast , QString _str,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
    void DataBaseLengthFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
    void DataBaseCounterFilter(int _nArticle,int _nCategory,int _nComp,int _nInsDel,QString _str,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
    void DataBaseReplaceFilter(int _nArticle,int _nCategory,int _nFind,QString _strFind,QString _strReplace,int _nGroup,int _nCommand,int _nFilterID = D_NOT_SELECT);
private:
    enum E_DATABASE_COMMAND
    {
        E_DATABASE_COMMAND_INSERT = 0,
        E_DATABASE_COMMAND_UPDATE,
    };
    QTabWidget m_tab;

    QDateEdit *m_pdeStart;
    QDateEdit *m_pdeEnd;

    QComboBox *m_pcbCatalog;
    QComboBox *m_pcbKeyword;
    QComboBox *m_pcbMethod;
    QCheckBox *m_pchbLast;
    QLineEdit *m_pleString;

    QComboBox *m_pcbLengthCatalog;
    QComboBox *m_pcbLengthComp;
    QComboBox *m_pcbLengthInsDel;
    QLineEdit *m_pleLength;

    QComboBox *m_pcbCounterCatalog;
    QComboBox *m_pcbCounterComp;
    QComboBox *m_pcbCounterInsDel;
    QComboBox *m_pcbCounterCntApl;
    QLineEdit *m_pleCounter;

    QComboBox *m_pcbReplaceCatalog;
    QComboBox *m_pcbReplaceFind;
    QComboBox *m_pcbReplace;
    QLineEdit *m_pleReplaceFind;
    QLineEdit *m_pleReplace;    

    QVector <SKeyword> m_vecKeyword;
private slots:
    void SearchDate();
    void SearchDateUpdate();
    void SearchCounter();
    void SearchCounterUpdate();
    void SearchLength();
    void SearchLengthUpdate();
    void SearchReplace();
    void SearchReplaceUpdate();
    void SearchKeyword();
    void SearchKeywordUpdate();
};

#endif // SFILTEROBJECT_H
