#include <QApplication>
#include "scrawler.h"
#include <QSqlDatabase>
#include <QWebSettings>
#include <iostream>
#include <QFile>
#include <time.h>
#include <QTextStream>

using namespace std;

void Debug(QString _strFilename,QString _strData)
{
    QFile file(_strFilename);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
        return;
    QTextStream out(&file);
    out << _strData;
    file.close();
}

int main(int argc, char *argv[])
{
    srand(time(0));
    QApplication a(argc, argv);
    a.setApplicationName(QString("Chrome"));
    a.setApplicationVersion(QString("39.0.2171.95"));

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("bigbird.iptime.org");
    db.setUserName("admin");
    db.setPassword("admin123");
    db.setDatabaseName("concepters");

    if (db.open() == false)
    {
        cout << "error : db open fail...";
        return 0;
    }
    QWebSettings::setObjectCacheCapacities(0,0,0);
    QWebSettings::clearMemoryCaches();
    QStringList strArgv;
    for (int i = 1; i < argc ; i++)
        strArgv.push_back(argv[i]);

    SCrawler *process = new SCrawler;
    QObject::connect(process, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
    process->load(strArgv);

    return a.exec();

}
