]> git.nothing2do.fr Git - diary-mobile.git/commitdiff
I've added send(QString) to remplace savbuttons and sendRAW
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Tue, 10 Jun 2014 06:22:06 +0000 (08:22 +0200)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Tue, 10 Jun 2014 06:22:06 +0000 (08:22 +0200)
mainwindow.cpp

index 60708df34a8a5e7d65d710be417696c003b1ed20..bf223ce2c375cdfae462c2f3de3fab247026b363 100644 (file)
@@ -197,7 +197,7 @@ void MainWindow::action(const QString &a){
             if(!ok)return;
         }else if(bs==2){
             d=b[1];
-            e=QInputDialog::getInt(this, "setInt", b[1] , conf->value(QString(d)).toInt(), 0, 100, 1, &ok);
+            e=QInputDialog::getInt(this, "setInt", b[1] , conf->value(QString(d)).toInt(), -100, 100, 1, &ok);
             if(!ok)return;
         }else if(bs==3){
             d=b[1];
@@ -616,6 +616,7 @@ void MainWindow::writeData(){
     conf->setValue(QString("lastdownload"), QDateTime::currentDateTime().toString(Qt::ISODate));
 }
 void MainWindow::sendRAW(){
+    //send(QString("raw"))
     exec(QList<QString> ({conf->value(QString("selectraw")).toString()}));
     QFile a(conf->value(QString("rawfile")).toString());
     a.open(QIODevice::WriteOnly|QIODevice::Text);
@@ -630,7 +631,7 @@ void MainWindow::sendRAW(){
     a.close();
     qDebug()<<"a.open()="<<a.open(QIODevice::ReadOnly | QIODevice::Text);
     //QUrl upload(conf->value(QString("uploadRAW")).toString());
-    QUrl upload(QString("ftp://")+conf->value(QString("userftp")).toString()+QString(":")+conf->value(QString("passftp")).toString()+QString("@")+conf->value(QString("hostftp")).toString()+QString("/")+conf->value(QString("file")).toString());
+    QUrl upload(QString("ftp://")+conf->value(QString("userftp")).toString()+QString(":")+conf->value(QString("passftp")).toString()+QString("@")+conf->value(QString("hostftp")).toString()+QString("/")+conf->value(QString("rawfile")).toString());
     net=new QNetworkAccessManager(this);
     //a.open(QIODevice::ReadOnly | QIODevice::Text);
     rep=net->put(QNetworkRequest(upload), a.readAll());
@@ -834,10 +835,10 @@ void MainWindow::removeButton(const QString & keyword, const QString & label, co
 void MainWindow::writeTr(){
     QString a="diary-mobile_" + QLocale::system().name()+".qm";
     qDebug()<<"writeTr->a="<<a;
-    QFile file(a);
-    file.open(QIODevice::WriteOnly);
-    file.write(m->downloadedData());
-    file.close();
+    QFile tmp(a);
+    tmp.open(QIODevice::WriteOnly);
+    tmp.write(m->downloadedData());
+    tmp.close();
 }
 void MainWindow::writeFile(){
     QFile tmp(file);
@@ -891,7 +892,7 @@ void MainWindow::resizeEvent(QResizeEvent *event)
  }
 void MainWindow::tmpdown(){
     bool ok;
-    QString url=QInputDialog::getText(this, trUtf8("tmp URL", "Title of box where ask for button tmp's URL"), trUtf8("Enter URL", "Label of box where ask for button tmp's URL"), QLineEdit::Normal, QString(""), &ok), tmp="tmp";
+    QString url=QInputDialog::getText(this, trUtf8("tmp URL", "Title of box where ask for button file's URL"), trUtf8("Enter URL", "Label of box where ask for button file's URL"), QLineEdit::Normal, QString(""), &ok), file="file";
     download(url);
 
     connect(m, SIGNAL(downloaded()), this, SLOT(readData()));
@@ -900,3 +901,29 @@ void MainWindow::readData(){
     readData(m->downloadedData());
     m->disconnect(m, SIGNAL(downloaded()),this, SLOT(readData()));
 }
+void MainWindows::send(const QString & a){
+    QString t="select"+a;
+    exec(QList<QString> ({conf->value(t).toString()}));
+    t=a+"file";
+    QFile tmp(conf->value(t).toString());
+    tmp.open(QIODevice::WriteOnly|QIODevice::Text);
+    QTextStream b(&tmp);
+    t="column"+a;
+    int c=conf->value(t).toInt()-1;
+
+    while (q->next()) {
+        for (int i=0; i<c; i++){
+            b<<q->value(i).toString()<<" ";
+        }
+        b<<q->value(1).toString()<<"\n";
+    }
+    tmp.close();
+    qDebug()<<"a.open()="<<tmp.open(QIODevice::ReadOnly | QIODevice::Text);
+    //QUrl upload(conf->value(QString("uploadRAW")).toString());
+    QUrl upload(QString("ftp://")+conf->value(QString("userftp")).toString()+QString(":")+conf->value(QString("passftp")).toString()+QString("@")+conf->value(QString("hostftp")).toString()+QString("/")+conf->value(t).toString());
+    net=new QNetworkAccessManager(this);
+    //a.open(QIODevice::ReadOnly | QIODevice::Text);
+    rep=net->put(QNetworkRequest(upload), tmp.readAll());
+    qDebug()<<"net->put : "<<rep<< " upload : "<<upload.url();
+    connect(rep, SIGNAL(finished()), this, SLOT(RAWsent()));
+}