/*******************************************************************************
*                                                                              *
* Société de Transports de Montréal.                                    	   *
* 2012                                                                         *
*                                                                              *
* Projet Zones Tests                                                           *
*                                                                              *
*                                                                              *
*                                                                              *
*******************************************************************************/
/*
    Description:
	Page principale de la ZT.  C'est sur cette dernière que tout est affiché.

*/

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

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

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


#include "MainPage.h"
#include <QPainter>
#include "GlobalDefine.h"
#include <QDialog>
#include <QMainWindow>
#include "OutilZT.h"
#include <QDateTime>
//#include "Version.h"

CMainPage::CMainPage(QGraphicsWidget *Parent)
{
    setGeometry(0,0,SCREEN_RES_WIDTH,SCREEN_RES_HEIGHT);

	mProgramHandle = 0;

//	QGraphicsTextItem *SoftVersion = new QGraphicsTextItem(this);
//	QFont TextFont;
//	TextFont.setPointSize(15);
//	TextFont.setBold(true);
//	SoftVersion->setFont(TextFont);
//    SoftVersion->setPlainText(QString().sprintf("Version: %s",SOFT_VERSION));
//	SoftVersion->setZValue(1);
//	SoftVersion->adjustSize();
//	SoftVersion->setPos(800,2);

//	mTimeDisplayText = new QGraphicsTextItem(this);
//	mTimeDisplayText->setPos(400,2);
//	mTimeDisplayText->setFont(TextFont);
//	mTimeDisplayText->setZValue(1);

    mDatabaseModePushButton = new CPushButton(this,"./Images/Save-icon.png");
    mDatabaseModePushButton->setPos(5,5);
    mDatabaseModePushButton->resize(35,35);
    connect( mDatabaseModePushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );

    mNetworkModePushButton = new CPushButton(this,"./Images/ethernet.png");
    mNetworkModePushButton->setPos(5,150);
    mNetworkModePushButton->resize(35,35);
    connect( mNetworkModePushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );
    mNetworkModePushButton->hide();

    mZTLogsListPushButton = new CPushButton(this,"./Images/log.png");
    mZTLogsListPushButton->setPos(5,80);
    mZTLogsListPushButton->resize(35,35);
    connect( mZTLogsListPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );

	mToolsPushButton = new CPushButton(this,"./Images/tools.png");
    mToolsPushButton->setPos(5,375);
    mToolsPushButton->resize(35,35);
    connect( mToolsPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );

    mDatabaseOptionsPushButton = new CPushButton(this,"./Images/database.png");
    mDatabaseOptionsPushButton->setPos(5,300);
    mDatabaseOptionsPushButton->resize(35,35);
    connect( mDatabaseOptionsPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(ButtonPressed(CPushButton*) ) );






//	CPushButton *LogsPushButton = new CPushButton(this,"./Images/Save-icon.png");
//    LogsPushButton->setPos(70,700);
//	LogsPushButton->resize(65,65);
//	connect( LogsPushButton, SIGNAL( clicked(CPushButton*) ), this, SLOT(LogsButtonPressed()) );


//    mTimeDisplayTimer = new QTimer();
//    connect(mTimeDisplayTimer,SIGNAL(timeout()),this,SLOT(UpdateTime()));
//    mTimeDisplayTimer->setSingleShot(false);
//    mTimeDisplayTimer->start(1000);

}

void CMainPage::ButtonPressed(CPushButton *Btn)
{
    if(Btn == mToolsPushButton)
    {
        mProgramHandle->ShowOptionsRequest();
    }
    else if(Btn == mNetworkModePushButton)
    {
        mProgramHandle->EnterNetworkModeRequest();
    }
    else if(Btn == mDatabaseModePushButton)
    {
        mProgramHandle->EnterDatabaseModeRequest();
    }
    else if(Btn == mDatabaseOptionsPushButton)
    {
        mProgramHandle->ShowDatabaseMgrRequest();
    }
    else if(Btn == mZTLogsListPushButton)
    {
        mProgramHandle->EnterZTLogModeRequest();
    }
}


void CMainPage::UpdateTime()
{
//	QDateTime time = QDateTime::currentDateTime();
//	mTimeDisplayText->setPlainText(time.toString("yyyy/MM/dd   hh:mm:ss"));

}
