From 1f13c91c7c78c49d137ad406ed86d1640c762198 Mon Sep 17 00:00:00 2001 From: Norbert Moutarde Date: Wed, 7 May 2014 10:25:02 +0200 Subject: [PATCH] i've added "sql" to action() --- mainwindow.cpp | 37 ++++++++++++++++++++++++++----------- mainwindow.h | 2 +- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 2ad6232..5e1f14b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -171,6 +171,10 @@ void MainWindow::action(const QString &a){ else if(b[0]==QString("clear")){ way.clear(); } + else if(b[0]==QString("sql")){ + exec(QList ({c})); + } + else if(b[0]==QString("edit")){ const QString a=QInputDialog::getText(this, QString("ID"), QString("Entrez l'ID du bouton à éditez"), QLineEdit::Normal, b[1]); editButtonDB(a); @@ -433,8 +437,6 @@ void MainWindow::downloadUi(){ connect(m, SIGNAL(downloaded()), SLOT(writeUi())); } void MainWindow::writeUi(){ - q->exec("PRAGMA foreign_keys=OFF;"); - q->exec("BEGIN TRANSACTION;"); readButtons(m->downloadedData()); m->deleteLater(); conf->setValue(QString("lastdownload"), QDateTime::currentDateTime().toString(Qt::ISODate)); @@ -525,6 +527,8 @@ QByteArray FileDownloader::downloadedData() const } void MainWindow::readButtons(const QByteArray &in){ qDebug()<<"readButtons"; + q->exec("PRAGMA foreign_keys=OFF;"); + q->exec("BEGIN TRANSACTION;"); int a=in.count('\n'); QString d=in.split('\n').at(0); conf->setValue(QString("firstline"), d); @@ -540,8 +544,6 @@ void MainWindow::readButtons(const QByteArray &in){ qDebug()<<"q->exec() : "<exec()<<" lastError()="<lastError(); }; - db.commit(); - flush(); /*QDomDocument a("buttons"); if (!a.setContent(in)){ @@ -549,21 +551,34 @@ void MainWindow::readButtons(const QByteArray &in){ return; } QDomElement root = a.documentElement(); - QDomNode n = root.firstChildElement(); + QDomNode n = root.firstChild(); QList cmd; while(!n.isNull()) { - QDomNode e = n.firstChildElement(); - if((cmd.size()<1)&&(n.isText()))e.toText().nodeValue(); - qDebug()<<"n.nodeName()="<