/*******************************************************************************
*                                                                              *
* Société de Transports de Montréal.                                    	   *
* 2012                                                                         *
*                                                                              *
* Projet Zones Tests                                                           *
*                                                                              *
*                                                                              *
*                                                                              *
*******************************************************************************/
/*
    Description:
    Description du fichier si nécessaire.

*/

/* ************************************************************************** */
/* Revision:
### 20131024 JFM
    Verision d'origine.

### YYYMMDD Description du besoin ou du bug
    Description du changement.
 */

/* ************************************************************************** */


#ifndef LOGSLISTPAGE_H
#define LOGSLISTPAGE_H

#include "GlobalDefine.h"
#include <QGraphicsWidget>
#include "Guipage.h"
#include <QString>
#include "PushButton.h"
#include "TextButtonWidget.h"
#include "LogMgr.h"
#include <QTableWidget>
#include <QCheckBox>
#include <QComboBox>
#include <QTreeWidget>

#define MAX_DETECTION_LIST_NBR 6
//#define NETWORK_LOGS_BASE_PATH "S:\\EEF\\TCPE\\72410\\72410\\BD ZT\\Logs_Reseau\\"
#define NETWORK_LOGS_BASE_PATH "D:\\Main\\Fichiers\\JOB\\OutilZT_Direct\\trains\\"


class COutilZT;

enum eTreeItemType
{
    TREE_ITEM_STATION_TYPE,
    TREE_ITEM_DIR_TYPE,
    TREE_ITEM_LOGFILE_TYPE
};

class CTreeItemInfo
{
public:
    int TreeItemType;
    QString TreeItemPath;
};

class CLogsListPage : public CGuiPage
{
Q_OBJECT
public:
    virtual ~CLogsListPage();
	CLogsListPage(QGraphicsWidget *Parent = 0);


    COutilZT *mProgramHandle;
	CLogMgr *mLogMgrHandle;

	unsigned int RefreshList();
    void EnableEngineeringMode();

	virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
	virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
	virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

private:

	QTableWidget *mLogsTable;
    QTreeWidget *mLogFilesTree;
    QGraphicsTextItem *mSummaryText;
	CTextButtonWidget *mViewLogDataButton;
    CTextButtonWidget *mExportCSVLogButton;
    QGraphicsProxyWidget *mLogListTableProxy, *mLogsTreeProxy;

    QCheckBox *mShowZT1ItemsChkBx, *mShowZT2ItemsChkBx, *mShowNoDetectionsChkBx;
    QCheckBox *mShowFNChkBx, *mShowCountChkBx, *mShowPGChkBx, *mShowPPChkBx,*mShowMPM10ChkBx, *mShowMRChkBx, *mShowProblematicTrainsChkbx;//, *mShowAllChkBx;
    QCheckBox *mLoadTreeLogDetails;
    QGraphicsTextItem *mTreeLoadingStatusLabel;

    QTimer *mListParsingTimer;
    QComboBox *mStationsFilterComboBox;

    QString mStationFilter;

    CPushButton *mViewZTLogBtn, *mSaveCSVLogBtn,*mDeleteFileButton, *mLogsTreeMode, *mLogsTableMode;
    QCheckBox *mProtectLogChkBx;
    QString mNetworkBasePath;

    //bool mShowZT1Items,mShowZT2Items,mShowNoDetections,mUSBDetected;

	void ClearTable();

    int PopulateDirectoriesTreeBranch(QTreeWidgetItem *parent, QString Path);
    int PopulateLogFilesTreeBranch(QTreeWidgetItem *parent, QString Path);

    int UpdateSummaryText(CLogElement* Element);


public slots:
	void ButtonClicked(CTextButtonWidget *);
	void LogsTableCellClicked(int, int);
    void LogsTableCellSelected(int,int,int,int);
    void CheckBoxClicked(int);
    void TableDoubleClicked(int,int);
    void StationFilterSelected(int);
    void ViewZTLogBtnClicked(CPushButton *);
    void SaveCSVLogBtnClicked(CPushButton *);
    void DeleteSelectedLog(CPushButton*);
    void ProtectLogCheckBoxClicked();
    void TreeLogsViewModeSelected(CPushButton*);
    void TableLogsViewModeSelected(CPushButton*);

    void LogsTreeItemExpanded(QTreeWidgetItem *item);
    void LogsTreeItemDoubleClicked(QTreeWidgetItem *item);
    void LogsTreeItemCollapsed(QTreeWidgetItem *item);
    void LogsTreeItemSelected();
//    void ParsingTimerExipred();

};



#endif // LOGSLISTPAGE_H
