From ceb08bf3da34dd842a844993c3924556c7ca4adb Mon Sep 17 00:00:00 2001 From: Norbert Moutarde Date: Tue, 3 Dec 2013 09:21:02 +0100 Subject: [PATCH] It save entry into a text file and into sqlite database ... (and android added by 5.2 rc1) --- android/AndroidManifest.xml | 43 +++++++++++++++++++------------------ diary-mobile-android.pro | 28 +++++++++++++++++++++++- mainwindow.cpp | 24 +++++++++++---------- mainwindow.h | 4 +++- 4 files changed, 65 insertions(+), 34 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 7e4ac63..324fdf4 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,38 +1,39 @@ - + - + - - - - - + + + + + - - - + + + - - - - - + + + + + - - - + + + - + - - + + + diff --git a/diary-mobile-android.pro b/diary-mobile-android.pro index 419b418..f535fa8 100644 --- a/diary-mobile-android.pro +++ b/diary-mobile-android.pro @@ -27,4 +27,30 @@ ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android OTHER_FILES += \ android/AndroidManifest.xml \ - ui.sql + ui.sql \ + android/src/org/qtproject/qt5/android/bindings/QtActivity.java \ + android/src/org/qtproject/qt5/android/bindings/QtApplication.java \ + android/src/org/kde/necessitas/ministro/IMinistro.aidl \ + android/src/org/kde/necessitas/ministro/IMinistroCallback.aidl \ + android/res/values-zh-rTW/strings.xml \ + android/res/layout/splash.xml \ + android/res/values-pt-rBR/strings.xml \ + android/res/values-de/strings.xml \ + android/res/values-ru/strings.xml \ + android/res/values-ms/strings.xml \ + android/res/values-et/strings.xml \ + android/res/values-rs/strings.xml \ + android/res/values-fa/strings.xml \ + android/res/values/strings.xml \ + android/res/values-nl/strings.xml \ + android/res/values-id/strings.xml \ + android/res/values-nb/strings.xml \ + android/res/values-ja/strings.xml \ + android/res/values-pl/strings.xml \ + android/res/values-ro/strings.xml \ + android/res/values-zh-rCN/strings.xml \ + android/res/values-it/strings.xml \ + android/res/values-es/strings.xml \ + android/res/values-fr/strings.xml \ + android/res/values-el/strings.xml \ + android/version.xml diff --git a/mainwindow.cpp b/mainwindow.cpp index 95a2984..8d5a8a5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -49,7 +49,7 @@ MainWindow::MainWindow(QWidget *parent) } void MainWindow::start(){ flush(); - //connectdb(); + connectdb(); //exec(QString("select * from ui;")); @@ -172,7 +172,8 @@ void MainWindow::lsconfig(){ } void MainWindow::quit(){ conf->sync(); - //debug(0); + db.commit(); + db.close(); qApp->quit(); } CLabel* MainWindow::addWidget(const QString &key, CLabel * a){ @@ -302,17 +303,18 @@ QString MainWindow::getText(const QString &a){ return widget.value(a)->text(); } void MainWindow::connectdb(){ - //db = QSqlDatabase::addDatabase("QSQLITE"); - db = QSqlDatabase::addDatabase("QPSQL"); + db = QSqlDatabase::addDatabase("QSQLITE"); + //db = QSqlDatabase::addDatabase("QPSQL"); db.setHostName(host); db.setDatabaseName(database); db.setUserName(user); db.setPassword(password); - db.setConnectOptions(QString("requiressl=1 connect_timeout=10000"));//10sec*/ - bool ok=db.open(); - qDebug()<<"db.open() ? "<setValue(QString("host"), QVariant("127.0.0.1")); @@ -364,12 +366,12 @@ int MainWindow::entry(){ fichier.open(QIODevice::Append | QIODevice::Text); QTextStream flux(&fichier); flux << a << endl; - texte->clear(); fichier.close(); - qDebug()<prepare("INSERT INTO "+database+"raw (date, texte) VALUES (:date, :texte);"); + qDebug()<prepare("INSERT INTO raw (date, texte) VALUES (:date :texte);"); q->bindValue(":date", v.currentDateTime().toString(QString("yyyy-MM-dd hh:mm:ss"))); q->bindValue(":texte", texte->text()); - q->exec();*/ + q->exec(); + texte->clear(); } diff --git a/mainwindow.h b/mainwindow.h index 7825970..5a75440 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -4,7 +4,7 @@ #include //#include don't work since 5.1 (or 5.2) #include -#include + #include #include #include @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include //#include #include -- 2.45.1