From: Norbert Moutarde Date: Wed, 28 May 2014 13:28:18 +0000 (+0200) Subject: removeButton now delete given sentence from entry (from "keyword") X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=573733ab20f715d6297cae14d7210effe2a294bc;p=diary-mobile.git removeButton now delete given sentence from entry (from "keyword") --- diff --git a/mainwindow.cpp b/mainwindow.cpp index 3e7515c..2b7b32b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -642,7 +642,9 @@ void MainWindow::download(const QString & a){ } void MainWindow::savButtons(){ exec(QList ({conf->value(QString("selectbuttons")).toString()})); - QTextStream b; + QFile a(conf->value(QString("buttonfile")).toString()); + a.open(QIODevice::WriteOnly|QIODevice::Text); + QTextStream b(&a); b<value("firstline").toString()<<"\n"; while (q->next()) { for (int i=0; i<2; i++){ @@ -650,9 +652,11 @@ void MainWindow::savButtons(){ } b<value(2).toString()<<"\n"; } + a.close(); QUrl upload(conf->value(QString("uploadUi")).toString()); net=new QNetworkAccessManager(this); - rep=net->put(QNetworkRequest(upload), b.device()); + a.open(QIODevice::ReadOnly | QIODevice::Text); + rep=net->put(QNetworkRequest(upload), a.readAll()); qDebug()<<"net->put : "<first(); - int count=0; - QString key=keyword, id=q->value(0).toString(), cur; - while(q->isValid()){ + int count=1; + QString key=q->value(1).toString(), id=q->value(0).toString(), cur; + while(q->next()){//la boucle ne sert que si il y a plusieurs entré avec les même label et action or insertButton nous l'interdit ! count++; cur=q->value(1).toString(); - if(cur!=keyword)key=key+" "+cur; - q->next(); + key=key+" "+cur; } - if(count==1)exec(QList({conf->value(QString("deletebutton")).toString(), id})); - else{exec(QList({conf->value(QString("updatebuttons")).toString(), key, label, action, id})); - + if(key==keyword)exec(QList({conf->value(QString("deletebutton")).toString(), id})); + else{ + key.replace(keyword, QString("")); + exec(QList({conf->value(QString("updatebuttons")).toString(), key, label, action, id})); } }