From: Norbert Moutarde Date: Fri, 3 Jan 2014 18:31:46 +0000 (+0100) Subject: i've tweaked ui.sql (and mainwindows.cpp) to update with less data to X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=de7a4c56cf6e3f2e21ffb9e6651dac86216fb9f7;p=diary-mobile.git i've tweaked ui.sql (and mainwindows.cpp) to update with less data to transfer) --- diff --git a/mainwindow.cpp b/mainwindow.cpp index d199c41..5448e37 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -249,6 +249,7 @@ void MainWindow::firstrun(){ conf->setValue(QString("database"), QVariant("db")); conf->setValue(QString("password"), QVariant("pass")); conf->setValue(QString("file"), QVariant("diary.txt")); + conf->setValue(QString("buttonfile"), QVariant("bfile.xml")); conf->setValue(QString("maxcolumn"), QVariant(2)); conf->setValue(QString("maxline"), QVariant(5)); conf->setValue(QString("SQLsettings"), QVariant("requiressl=1 connect_timeout=10000")); @@ -266,15 +267,18 @@ QString &MainWindow::get(int row, int column){ } int MainWindow::exec(const QList & a){ qDebug()<<"exec("<prepare(a[0]); for (int j=1; jbindValue(j-1, a[j]); qDebug()<<"bind "<exec(); + QSqlError b=q->lastError(); db.commit(); qDebug()<<"exec finish"; + if (b.isValid())qDebug()<<"SQL error->exec() :"<isSelect())return q->size(); else return 0; @@ -313,6 +317,7 @@ void MainWindow::entry(const QString &a){ d.append(time); d.append(entry); exec(d); + //sql.unlock(); QSqlError b=q->lastError(); if (b.isValid())qDebug()<<"q->lastError():"< cmd; bool ok=0; cmd.append("insert into ui (label, keyword, action) values (:label, :keyword, :action)"); @@ -440,10 +446,11 @@ void MainWindow::writeUpdate(){ qDebug()<<"downloaded : "<downloadedData().size()<<" byte"; /* put newly downloaded sql file into database */ int a=m->downloadedData().count('\n'); - for(int i=0; iprepare(m->downloadedData().split('\n').at(i)); - q->exec(); + q->prepare(m->downloadedData().split('\n').at(0)); + for(int i=1; idownloadedData().split('\n').at(i).count('§'); + for(int j=0; jbindValue(j, m->downloadedData().split('\n').at(i).split('§').at(j)); } - start(); + q->exec(); } diff --git a/mainwindow.h b/mainwindow.h index a40fe09..50d208f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -106,9 +106,6 @@ private slots: void toggleMenu(); void flush(); void debug(int); - //void connected(); - //void TCPerrors(QAbstractSocket::SocketError); - //QString getText(const QString &); void connectDB(); void firstrun(); QString &get(int, int); @@ -119,7 +116,6 @@ private slots: void addButtonDB(); void editButtonDB(); void getButtons(const QString &); - //void getButtons(); void updateUi(); void writeUpdate(); void sendUi(); @@ -128,7 +124,7 @@ public slots: signals: private: - //bool first; + //QMutex sql; QWidget *screen; QGridLayout *grid; QLabel *label; diff --git a/ui.sql b/ui.sql index 4267e8a..a98147c 100644 --- a/ui.sql +++ b/ui.sql @@ -1,25 +1,23 @@ -PRAGMA foreign_keys=OFF; -BEGIN TRANSACTION; -delete from ui; -INSERT INTO "ui" (keyword, label, action) VALUES('begin','new', 'new'); -INSERT INTO "ui" (keyword, label, action) VALUES('begin','fille', 'fille'); -INSERT INTO "ui" (keyword, label, action) VALUES('begin','config', 'config'); -INSERT INTO "ui" (keyword, label, action) VALUES('begin','lieu','lieu'); -INSERT INTO "ui" (keyword, label, action) VALUES('lieu', 'oliver''s pub', 'oliver''s pub'); -INSERT INTO "ui" (keyword, label, action) VALUES('oliver''s pub fille','audrey','audrey zanella'); -INSERT INTO "ui" (keyword, label, action) VALUES('oliver''s pub fille audrey zanella','Pourquoi vous me prenez pour un perver ?','begi-olive-audre-perver'); -INSERT INTO "ui" (keyword, label, action) VALUES('begi-lie-olive-audre-perver','"On ne te prends pas pour un perver."','begi-olive-audre-perve-non'); -INSERT INTO "ui" (keyword, label, action) VALUES('begi-lie-olive-audre-perve-non','Pourquoi vous refusez qu''on se voit hors d''ici alors ?','begi-olive-audre-perve-non-hors'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','max column','setint maxcolumn'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','host','settext host '); -INSERT INTO "ui" (keyword, label, action) VALUES('config','port','setint port'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','user','settext user'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','password','settext pass'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','database','settext database'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','filesave','settext file'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','SQLsettings', 'settext SQLsettings'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','button', 'settext button'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','download', 'settext download'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','upload', 'settext upload'); -INSERT INTO "ui" (keyword, label, action) VALUES('config','start', 'settext start'); -COMMIT; +INSERT INTO "ui" (keyword, label, action) VALUES(?, ?, ?); +begin§new§new +begin§fille§fille +begin§config§config +begin§lieu§lieu +lieu§oliver''s pub§oliver''s pub +oliver''s pub fille§audrey§audrey zanella +audrey zanella§Pourquoi vous me prenez pour un perver ?§begi-olive-audre-perver +begi-lie-olive-audre-perver§"On ne te prends pas pour un perver."§begi-olive-audre-perve-non +begi-lie-olive-audre-perve-non§Pourquoi vous refusez qu''on se voit hors d''ici alors ?§begi-olive-audre-perve-non-hors +config§max column§setint maxcolumn +config§host§settext host +config§port§setint port +config§user§settext user +config§password§settext pass +config§database§settext database +config§filesave§settext file +config§SQLsettings§settext SQLsettings +config§button§settext button +config§download§settext download +config§upload§settext upload +config§start§settext start +