From: Norbert Moutarde Date: Wed, 26 Mar 2014 16:24:04 +0000 (+0100) Subject: updateUi() is clearly a downloader (and writeUpdate use downloaded data) X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=e351a10c4f71d660018bc719fd4063574cf7110d;p=diary-mobile.git updateUi() is clearly a downloader (and writeUpdate use downloaded data) --- diff --git a/mainwindow.cpp b/mainwindow.cpp index efe435f..72f48f5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -144,7 +144,7 @@ void MainWindow::createMenuBar(){ FileMenu=new QMenu(QString("&File"), this); FileMenu->addAction(trUtf8("&Start..."), this, SLOT(start()),QKeySequence(trUtf8("Ctrl+S", "File|Start"))); FileMenu->addAction(trUtf8("&Back"), this, SLOT(back()),QKeySequence(trUtf8("Ctrl+B", "File|Back"))); - FileMenu->addAction(trUtf8("&Download"), this, SLOT(updateUi()),QKeySequence(trUtf8("Ctrl+W", "File|Downlad"))); + FileMenu->addAction(trUtf8("&DownloadUi"), this, SLOT(updateUi()),QKeySequence(trUtf8("Ctrl+W", "File|Downlad"))); FileMenu->addAction(trUtf8("BackUp"), this, SLOT(sendDB()),QKeySequence(trUtf8("Ctrl+L", "File|Upload"))); FileMenu->addAction(trUtf8("Rest&ore"), this, SLOT(restoreDB()),QKeySequence(trUtf8("Ctrl+O", "File|Restore"))); FileMenu->addAction(trUtf8("Reset Ui"), this, SLOT(resetUi()), QKeySequence(trUtf8("Ctrl+Z", "File|ResetUi"))); @@ -357,8 +357,17 @@ void MainWindow::editButtonDB(){ void MainWindow::updateUi(){ //download(conf->value(QString("download")).toString()); qDebug()<<"updateUi() : "<value(QString("download")).toString(); - readButtons(download(conf->value(QString("download")).toString())); - //connect(m, SIGNAL(downloaded()), SLOT(writeUpdate())); + download(conf->value(QString("download")).toString()); + //readButtons(); + connect(m, SIGNAL(downloaded()), SLOT(writeUpdate())); +} +void MainWindow::writeUpdate(){ + //flush(); now in readButtons() + // put newly downloaded sql file into database + q->exec("PRAGMA foreign_keys=OFF;"); + q->exec("BEGIN TRANSACTION;"); + readButtons(m->downloadedData()); + m->deleteLater(); } void MainWindow::sendDB(){ system("su"); @@ -404,7 +413,7 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event) void CLabel::SetTextToLabel(const QString& text) { qDebug()<<"setTextToLabel"; - QFontMetrics metrix(font()); + //QFontMetrics metrix(font()); //font().setPointSize(width); setText(text); } @@ -432,13 +441,6 @@ QByteArray FileDownloader::downloadedData() const { return m_DownloadedData; } -void MainWindow::writeUpdate(){ - flush(); - // put newly downloaded sql file into database - q->exec("PRAGMA foreign_keys=OFF;"); - q->exec("BEGIN TRANSACTION;"); - readButtons(m->downloadedData()); -} void MainWindow::readButtons(const QByteArray &in){ int a=in.count('\n'); QString d=in.split('\n').at(0); @@ -455,6 +457,7 @@ void MainWindow::readButtons(const QByteArray &in){ }; db.commit(); + flush(); emit datafilled(); } void MainWindow::datasend(){ @@ -481,10 +484,10 @@ void MainWindow::restoreDB(){ b.write(rep->readAll()); system("exit"); } -QByteArray MainWindow::download(QString a){ +void MainWindow::download(const QString a){ qDebug()<<"download() : "<downloadedData(); + //connect(m, SIGNAL(downloaded()), SLOT(writeUpdate())); + //return m->downloadedData(); } diff --git a/mainwindow.h b/mainwindow.h index 4e67059..2dfe263 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -122,7 +122,7 @@ private slots: void readButtons(const QByteArray &); void resetUi(); void restoreDB(); - QByteArray download(QString); + void download(const QString &); public slots: signals: