From 9a231d8cecde1eebd02133dce95b1ef45f86d5f6 Mon Sep 17 00:00:00 2001 From: Norbert Moutarde Date: Fri, 14 Mar 2014 13:26:59 +0100 Subject: [PATCH] now, I send the database entirely (the ui table + the raw) --- android/AndroidManifest.xml | 43 +++++++++++++++++++------------------ mainwindow.cpp | 36 ++++++++++++++----------------- mainwindow.h | 4 ++-- 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 0e2a9be..04e6a32 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,39 +1,40 @@ - - - + + + - - - - - + + + + + - - - + + + - - - - - + + + + + - - - + + + - + - + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 1f11598..631e436 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -109,7 +109,7 @@ void MainWindow::showExpanded() void MainWindow::quit(){ qDebug()<<"quit()"; conf->setValue(QString("menu"), menuBar()->isVisible()); - savButtons(); + //savButtons(); db.commit(); db.close(); qApp->quit(); @@ -151,14 +151,14 @@ void MainWindow::createMenuBar(){ 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("Up&load"), this, SLOT(sendUi()),QKeySequence(trUtf8("Ctrl+L", "File|Upload"))); + FileMenu->addAction(trUtf8("Up&load"), this, SLOT(sendDB()),QKeySequence(trUtf8("Ctrl+L", "File|Upload"))); FileMenu->addAction(trUtf8("Reset Ui"), this, SLOT(resetUi()), QKeySequence(trUtf8("Ctrl+Z", "File|ResetUi"))); FileMenu->addAction(trUtf8("&Quit..."), this, SLOT(quit()),QKeySequence(trUtf8("Ctrl+Q", "File|Quit"))); menuBar()->addMenu(FileMenu); EditMenu=new QMenu(QString("&Buttons")); EditMenu->addAction(trUtf8("C&reate Database"), this, SLOT(createDB()), QKeySequence(trUtf8("Ctrl+R", "Buttons|CreateDB"))); EditMenu->addAction(trUtf8("A&dd buttons"), this, SLOT(addButtonDB()), QKeySequence(trUtf8("Ctrl+D", "Buttons|Add"))); - EditMenu->addAction(trUtf8("Sa&v buttons"), this, SLOT(savButtons()), QKeySequence(trUtf8("Ctrl+V", "Buttons|Save"))); + //EditMenu->addAction(trUtf8("Sa&v buttons"), this, SLOT(savButtons()), QKeySequence(trUtf8("Ctrl+V", "Buttons|Save"))); EditMenu->addAction(trUtf8("&Edit buttons"), this, SLOT(editButtonDB()), QKeySequence(trUtf8("Ctrl+E", "Buttons|&Edit"))); EditMenu->addAction(trUtf8("&View/Hide menu"), this, SLOT(toggleMenu()), QKeySequence(trUtf8("Ctrl+T", "Buttons|View menu"))); menuBar()->addMenu(EditMenu); @@ -309,7 +309,7 @@ void MainWindow::addButtonDB(){ bool ok=0; cmd.append("insert into ui (label, keyword, action) values (:label, :keyword, :action)"); QString cur=way.last(); - QString a, b, c=QInputDialog::getText(this, QString("label"), QString("Entrez son label"),QLineEdit::Normal, QString(), &ok); + QString a, b, c=QInputDialog::getText(this, QString("label"), QString("Entrez son label"),QLineEdit::Normal, QString(""), &ok); if ((c=="")||(ok==0))return; cmd.append(c); b=QInputDialog::getText(this, QString("keyword"), QString("Entrez ses mots clé (no limit !)"), QLineEdit::Normal, cur, &ok); @@ -320,7 +320,7 @@ void MainWindow::addButtonDB(){ cmd.append(a); exec(cmd); data.append(c).append('$').append(b).append('$').append(a).append('\n'); - savButtons(); + //savButtons(); return; } void MainWindow::getButtons(const QString &a){ @@ -363,11 +363,13 @@ void MainWindow::updateUi(){ m = new FileDownloader(update, this); connect(m, SIGNAL(downloaded()), SLOT(writeUpdate())); } -void MainWindow::sendUi(){ - qDebug()<<"sendUi() : "<value(QString("upload")).toString(); +void MainWindow::sendDB(){ + qDebug()<<"sendDB() : "<value(QString("upload")).toString(); QUrl upload(conf->value(QString("upload")).toString()); net=new QNetworkAccessManager(this); - rep=net->put(QNetworkRequest(upload), data); + QFile b(conf->value(QString("database")).toString()); + b.open(QIODevice::ReadOnly); + rep=net->put(QNetworkRequest(upload), b.readAll()); qDebug()<<"net->put : "<put(QNetworkRequest(upload),data); connect(rep, SIGNAL(finished()), this, SLOT(datasend())); @@ -388,14 +390,14 @@ void MainWindow::back(){ } void MainWindow::keyReleaseEvent(QKeyEvent *event) { - static bool accepted=true; - event->setAccepted(accepted); // don't close my Top Level Widget ! + //static bool accepted=true; + //event->setAccepted(accepted); // don't close my Top Level Widget ! int k=event->key(); qDebug()<<"key pressed="<exec("BEGIN TRANSACTION;"); readButtons(m->downloadedData()); } -void MainWindow::savButtons(){ - qDebug()<<"savButtons"; - QFile b(conf->value(QString("buttonfile")).toString()); - b.open(QIODevice::WriteOnly); - b.write(data); - b.close(); -} void MainWindow::readButtons(const QByteArray &in){ int a=in.count('\n'); - qDebug()<<"first line : "<prepare(d); int b=in.split('\n').at(i).count('$'); @@ -456,7 +451,8 @@ void MainWindow::readButtons(const QByteArray &in){ q->bindValue(j, QString(in.split('\n').at(i).split('$').at(j))); qDebug()<<"bind "<exec() : "<exec(); + qDebug()<<"q->exec() : "<exec()<<" lastError()="<lastError(); + }; db.commit(); data=in; diff --git a/mainwindow.h b/mainwindow.h index 4099296..a3d08ee 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -117,8 +117,8 @@ private slots: void getButtons(const QString &); void updateUi(); void writeUpdate(); - void sendUi(); - void savButtons(); + void sendDB(); + //void savButtons(); void readButtons(const QByteArray &); void resetUi(); public slots: -- 2.45.1