From df06a8198f8daf0cc8d39ec6958e86b06361bfa2 Mon Sep 17 00:00:00 2001 From: Norbert Moutarde Date: Tue, 25 Mar 2014 13:18:28 +0100 Subject: [PATCH] added download() --- mainwindow.cpp | 23 +++++++++++++++-------- mainwindow.h | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index a86abc1..efe435f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -287,7 +287,7 @@ void MainWindow::entry(const QString &a){ 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 d({"INSERT INTO raw (date, texte) VALUES (:date, :txt);", time, c}); exec(d); @@ -355,10 +355,10 @@ void MainWindow::editButtonDB(){ }*/ } void MainWindow::updateUi(){ + //download(conf->value(QString("download")).toString()); qDebug()<<"updateUi() : "<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"); @@ -390,14 +390,14 @@ void MainWindow::back(){ } 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="<readAll(); + qDebug()<<"downloaded : "<deleteLater(); emit downloaded(); @@ -432,7 +433,6 @@ QByteArray FileDownloader::downloadedData() const return m_DownloadedData; } void MainWindow::writeUpdate(){ - qDebug()<<"downloaded : "<downloadedData().size()<<" byte"; flush(); // put newly downloaded sql file into database q->exec("PRAGMA foreign_keys=OFF;"); @@ -481,3 +481,10 @@ void MainWindow::restoreDB(){ b.write(rep->readAll()); system("exit"); } +QByteArray MainWindow::download(QString a){ + qDebug()<<"download() : "<downloadedData(); +} diff --git a/mainwindow.h b/mainwindow.h index 132c058..4e67059 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -122,6 +122,7 @@ private slots: void readButtons(const QByteArray &); void resetUi(); void restoreDB(); + QByteArray download(QString); public slots: signals: -- 2.45.1