]> 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:29:07 +0000 (08:29 +0200)
mainwindow.cpp
mainwindow.h

index 60708df34a8a5e7d65d710be417696c003b1ed20..d854af36a607f93677c104a132c8b8e023371f93 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];
@@ -221,6 +221,9 @@ void MainWindow::action(const QString &a){
         QString e=QInputDialog::getItem(this, trUtf8("choice", "title of box who ask multiple choice"), trUtf8("Please choose an action.", "text to ask multiple choice"), c.split(conf->value(QString("sepchc")).toString()), 0, 0, &ok);
         if(ok)action(e);
     }
+    else if(b[0]==QString("send")){
+        if(bs==2)send(b[1]);
+    }
     else if(b[0]==QString("back")){
         if(way.size()>=2){
             way.removeLast();
@@ -616,6 +619,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 +634,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 +838,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 +895,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 +904,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()));
+}
index c1670d145a22093c7a6a76006ddb0264f141081e..1dedf98a341338a33d04c20eca23ac70fac3dece 100644 (file)
@@ -132,6 +132,7 @@ public:
     void showExpanded();
     const CLabel* addWidget(const QString &, const CLabel *);
     void resizeEvent(QResizeEvent *);
+    void send(const QString &);
 private slots:
     void tmpdown();
     void readData();