]> git.nothing2do.fr Git - diary-mobile.git/commitdiff
added sendRAW() who send raw data on a server (linked by QSetting :
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Wed, 2 Apr 2014 18:29:00 +0000 (20:29 +0200)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Wed, 2 Apr 2014 18:29:00 +0000 (20:29 +0200)
"uploadRAW" and a little "new entry" in help submenu (few tweaks to)

mainwindow.cpp
mainwindow.h

index 347d08c72d0efd0a00d10511d5b83be73e8fee71..218c4937c5e1ad5c205430ffdb35b2cb7c44b64b 100644 (file)
@@ -145,7 +145,7 @@ 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("&DownloadUi"), this, SLOT(downloadUi()),QKeySequence(trUtf8("Ctrl+W", "File|Downlad")));
-    FileMenu->addAction(trUtf8("sendDB"), this, SLOT(sendDB()),QKeySequence(trUtf8("Ctrl+L", "File|Upload")));
+    FileMenu->addAction(trUtf8("sendRAW"), this, SLOT(sendRAW()),QKeySequence(trUtf8("Ctrl+L", "File|Upload")));
     //FileMenu->addAction(trUtf8("Rest&ore"), this, SLOT(restoreDB()),QKeySequence(trUtf8("Ctrl+O", "File|Restore")));
     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")));
@@ -158,7 +158,8 @@ void MainWindow::createMenuBar(){
     EditMenu->addAction(trUtf8("&View/Hide menu"), this, SLOT(toggleMenu()), QKeySequence(trUtf8("Ctrl+T", "Buttons|View menu")));
     menuBar()->addMenu(EditMenu);
     HelpMenu=new QMenu(QString("&Help"));
-    HelpMenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt()), QKeySequence(tr("ctrl+H", "Help|About Qt")));
+    HelpMenu->addAction(trUtf8("nouvelle entré"), this, SLOT(entry()), QKeySequence());
+    HelpMenu->addAction(trUtf8("About Qt"), qApp, SLOT(aboutQt()), QKeySequence(tr("ctrl+H", "Help|About Qt")));
     EditMenu->addAction(trUtf8("C&reate Database"), this, SLOT(createDB()), QKeySequence(trUtf8("Ctrl+R", "Help|CreateDB")));
     menuBar()->addMenu(HelpMenu);
 }
@@ -241,13 +242,13 @@ void MainWindow::firstrun(){
     conf->setValue(QString("button"), QVariant("background-color: red;border-style: outset;border-width: 7px;border-radius: 10px;border-color: beige;font: bold 15px;padding: 6px;"));
     conf->setValue(QString("menu"), QVariant(1));
     conf->setValue(QString("download"), QVariant("https://raw.github.com/Nothing2Do/diary-mobile-android/master/ui.sql"));
-    conf->setValue(QString("uploadDB"), QVariant("ftp://<user>:<pass>@<hostname>/db"));
-    conf->setValue(QString("uploadUi"), QVariant("ftp://<user>:<pass>@<hostname>/ui.sql"));
-
+    conf->setValue(QString("uploadRAW"), QVariant("ftp://<user>:<pass>@<server>/raw"));
+    conf->setValue(QString("uploadUi"), QVariant("ftp://<user>:<pass>@<server>/ui.sql"));
     conf->setValue(QString("restore"), QVariant("http://www.abc.de/db"));
     conf->setValue(QString("start"), QVariant("begin"));
     conf->setValue(QString("db"), QVariant("/data/data/eu.nothing2do.diarymobile/files/db"));
     conf->setValue(QString("selectbuttons"), QVariant("select keyword,label,action from ui;"));
+    conf->setValue(QString("selectraw"), QVariant("select date,texte from raw;"));
 }
 QString &MainWindow::get(int row, int column){
     q->seek(row);
@@ -298,6 +299,10 @@ void MainWindow::entry(const QString &a){
     QSqlError b=q->lastError();
     if (b.isValid())qDebug()<<"q->lastError():"<<b.text();
 }
+void MainWindow::entry(){
+    entry(QString(""));
+}
+
 void MainWindow::createDB(){
     qDebug()<<"createDB()";
     exec(QList<QString>({"create table ui(keyword text, label text, action text);"}));
@@ -369,20 +374,33 @@ void MainWindow::writeUi(){
     readButtons(m->downloadedData());
     m->deleteLater();
 }
-void MainWindow::sendDB(){
-    system("su");
-    qDebug()<<"sendDB() : "<<conf->value(QString("uploadDB")).toString();
-    QUrl upload(conf->value(QString("uploadDB")).toString());
+void MainWindow::sendRAW(){
+    exec(QList<QString> ({conf->value(QString("selectraw"), QVariant("select date,texte from raw;")).toString()}));
+    QFile a(conf->value(QString("rawfile"), QVariant("raw")).toString());
+    a.open(QIODevice::WriteOnly|QIODevice::Text);
+    QTextStream b(&a);
+    while (q->next()) {
+        for (int i=0; i<1; i++){
+            b<<q->value(i).toString()<<" ";
+        }
+        b<<q->value(1).toString()<<"\n";
+    }
+    a.close();
+    QMessageBox::information(this, QString("end"), conf->value(QString("rawfile")).toString());
+    qDebug()<<"a.open()="<<a.open(QIODevice::ReadOnly | QIODevice::Text);
+
+    QUrl upload(conf->value(QString("uploadRAW"), QVariant("ftp://<user>:<pass>@<server>/raw")).toString());
     net=new QNetworkAccessManager(this);
-    QFile b(conf->value(QString("db"), QVariant("/data/data/eu.nothing2do.diarymobile/files/db")).toString());
-    b.open(QIODevice::ReadOnly);
-    QByteArray c(b.readAll());
-    rep=net->put(QNetworkRequest(upload), c);
+    //a.open(QIODevice::ReadOnly | QIODevice::Text);
+    rep=net->put(QNetworkRequest(upload), a.readAll());
     qDebug()<<"net->put : "<<rep<< " upload : "<<upload.url();
-    //rep=net->put(QNetworkRequest(upload),data);
-    connect(rep, SIGNAL(finished()), this, SLOT(datasent()));
-    system("exit");
+    connect(rep, SIGNAL(finished()), this, SLOT(RAWsent()));
+}
+void MainWindow::RAWsent(){
+    qDebug()<<"RAWsent";
+    QMessageBox::information(this, "RAWsent", "sendRAW finish");
 }
+
 void MainWindow::back(){
     if(way.size()-1>0){
         flush();
@@ -480,9 +498,10 @@ void MainWindow::downloadDB(){
 }
 void MainWindow::writeDB(){
     system("su");
+    disconnect(m, SIGNAL(downloaded()));
     QFile a(conf->value(QString("db"), QVariant("/data/data/eu.nothing2do.diarymobile/files/db")).toString());
     a.open(QIODevice::WriteOnly | QIODevice::Text);
-    QTextStream b(&a);
+    QDataStream b(&a);
     b<<m->downloadedData();
     system("exit");
 }
@@ -506,7 +525,7 @@ void MainWindow::savButtons(){
     a.close();
     QMessageBox::information(this, QString("end"), conf->value(QString("buttonfile"), QVariant("ui.sql")).toString());
     qDebug()<<"a.open()="<<a.open(QIODevice::ReadOnly | QIODevice::Text);
-    QUrl upload(conf->value(QString("uploadUi"), QVariant("ftp://<user>:<pass>@ftp.abc.de/ui.sql")).toString());
+    QUrl upload(conf->value(QString("uploadUi"), QVariant("ftp://<user>:<pass>@<server>/ui.sql")).toString());
     net=new QNetworkAccessManager(this);
     rep=net->put(QNetworkRequest(upload), a.readAll());
     qDebug()<<"net->put : "<<rep<< " upload : "<<upload.url();
index 3b3ddc178b2f7d32e3abadf50324fa564350e89b..a3986b72225db8cc649bb51456cef10c8a2cd784 100644 (file)
@@ -111,6 +111,7 @@ private slots:
     QString &get(int, int);
     int exec(const QList<QString> &);
     void entry(const QString &);
+    void entry();
     void createDB();
     void addButtonDB();
     void writeDB();
@@ -118,7 +119,8 @@ private slots:
     void getButtons(const QString &);
     void downloadUi();
     void writeUi();
-    void sendDB();
+    void sendRAW();
+    void RAWsent();
     void Uisent();
     void savButtons();
     void readButtons(const QByteArray &);