QFile fichier(conf->value(QString("file")).toString());
fichier.open(QIODevice::Append | QIODevice::Text);
QTextStream flux(&fichier);
- flux << time << c << endl;
+ flux << time << " " << c << endl;
fichier.close();
QList<QString> d({"INSERT INTO raw (date, texte) VALUES (:date, :txt);", time, c});
exec(d);
}*/
}
void MainWindow::updateUi(){
+ //download(conf->value(QString("download")).toString());
qDebug()<<"updateUi() : "<<conf->value(QString("download")).toString();
- QUrl update(conf->value(QString("download")).toString());
- m = new FileDownloader(update, this);
- connect(m, SIGNAL(downloaded()), SLOT(writeUpdate()));
+ readButtons(download(conf->value(QString("download")).toString()));
+ //connect(m, SIGNAL(downloaded()), SLOT(writeUpdate()));
}
void MainWindow::sendDB(){
system("su");
}
void MainWindow::keyReleaseEvent(QKeyEvent *event)
{
- //static bool accepted=true;
- //event->setAccepted(accepted); // don't close my Top Level Widget !
+ static bool accepted=true;
+ event->setAccepted(accepted); // don't close my Top Level Widget !
int k=event->key();
qDebug()<<"key pressed="<<k;
if (k==Qt::Key_Back)
{
back();
- //accepted=false;// close the app next time when the user press back button
+ accepted=false;// close the app next time when the user press back button
}
}
void FileDownloader::fileDownloaded(QNetworkReply* pReply)
{
m_DownloadedData = pReply->readAll();
+ qDebug()<<"downloaded : "<<m_DownloadedData.size()<<" byte";
//emit a signal
pReply->deleteLater();
emit downloaded();
return m_DownloadedData;
}
void MainWindow::writeUpdate(){
- qDebug()<<"downloaded : "<<m->downloadedData().size()<<" byte";
flush();
// put newly downloaded sql file into database
q->exec("PRAGMA foreign_keys=OFF;");
b.write(rep->readAll());
system("exit");
}
+QByteArray MainWindow::download(QString a){
+ qDebug()<<"download() : "<<a;
+ QUrl url(a);
+ m = new FileDownloader(url, this);
+ connect(m, SIGNAL(downloaded()), SLOT(writeUpdate()));
+ return m->downloadedData();
+}