]> git.nothing2do.fr Git - diary-mobile.git/commitdiff
i've tweaked ui.sql (and mainwindows.cpp) to update with less data to
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Fri, 3 Jan 2014 18:31:46 +0000 (19:31 +0100)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Fri, 3 Jan 2014 18:31:46 +0000 (19:31 +0100)
transfer)

mainwindow.cpp
mainwindow.h
ui.sql

index d199c41dd68220fa89293278d99353758a2a24d8..5448e3793b52db4ebea3eb67b70909eea2be8e4a 100644 (file)
@@ -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<QString> & a){
     qDebug()<<"exec("<<a[0]<<")";
+    //QMutexLocker locker(&sql);
     q->prepare(a[0]);
     for (int j=1; j<a.size(); j++){
         q->bindValue(j-1, a[j]);
         qDebug()<<"bind "<<j-1<<" and"<<a[j];
     }
     q->exec();
+
     QSqlError b=q->lastError();
     db.commit();
     qDebug()<<"exec finish";
+
     if (b.isValid())qDebug()<<"SQL error->exec() :"<<b.text();
     if(q->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():"<<b.text();
 }
@@ -323,6 +328,7 @@ void MainWindow::createDB(){
 }
 void MainWindow::addButtonDB(){
     qDebug()<<"addButtonDB()";
+    //QMutexLocker locker(&addblock);
     QList<QString> 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 : "<<m->downloadedData().size()<<" byte";
     /* put newly downloaded sql file into database */
     int a=m->downloadedData().count('\n');
-    for(int i=0; i<a; i++){
-        q->prepare(m->downloadedData().split('\n').at(i));
-        q->exec();
+    q->prepare(m->downloadedData().split('\n').at(0));
+    for(int i=1; i<a; i++){
+        int b=m->downloadedData().split('\n').at(i).count('§');
+        for(int j=0; j<b; j++)q->bindValue(j, m->downloadedData().split('\n').at(i).split('§').at(j));
     }
-    start();
+    q->exec();
 }
 
index a40fe0965b7cf465e00bd4b9b7a08bcbe4cdbb8a..50d208f265ec3800980bcf9928099760fe0f2ac4 100644 (file)
@@ -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 4267e8a05ae1958907af6175a869cd22152709d4..a98147c33180e24a1403dcd7a62b4be171f8de27 100644 (file)
--- 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
+