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"));
}
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;
d.append(time);
d.append(entry);
exec(d);
+ //sql.unlock();
QSqlError b=q->lastError();
if (b.isValid())qDebug()<<"q->lastError():"<<b.text();
}
}
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)");
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();
}
-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
+