#include "connexion.h"
#include "copyMyChoices.h"

#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QTextStream>
#include <QString>
#include <QMessageBox>
#include <iostream> 

int main (int argc, char * argv[])
{
	QApplication a(argc,argv);
	QString arg;
	QString file;
	QStringList args;
	args = a.arguments();
	if (args.size()>1)
	{
		  file = a.arguments()[1];
	    }
        QFile returnFile(a.applicationDirPath()+"/../../../../tmp/returnFile.txt");
	if (!returnFile.open(QIODevice::ReadWrite|QIODevice::Text))
	{
		QMessageBox::warning(0,"Warning","Exchange file cannot open",QMessageBox::Ok);
	    }
	QTextStream stream(&returnFile);
	Common::Connexion * c = new Common::Connexion;
	if (!c->connect())
	{
		  qWarning() << __FILE__ << QString::number(__LINE__) << "cannot connect to database" ;
	    }
	CopyMyChoices * copy = new CopyMyChoices(0);
	copy->run(arg);
	stream << copy->returnString();
	int r = a.exec();
	//QMessageBox::information(0,"Warning",copy->returnString(),QMessageBox::Ok);
	

	return r;
}
