From: Norbert Moutarde Date: Tue, 29 Sep 2015 19:26:06 +0000 (+0200) Subject: val now work (with unlimited number of caracter replaced :-) X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=3326113fb85f6c2413c36c92ea0f007eb132947b;p=diary-mobile.git val now work (with unlimited number of caracter replaced :-) --- diff --git a/mainwindow.cpp b/mainwindow.cpp index 4ba962a..0bf5ba5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -179,18 +179,19 @@ int unsigned MainWindow::addWidget(const QString &key, const CLabel *a){ void MainWindow::action(const QString &a){ qDebug()<<"action("<::iterator b=valeur->begin();b!=valeur->end();b++){ - if(a.contains(b.key())){//key.replace(b.key(), b.value()); - QString abefore=a; - aa=a.replace(b.key(), b.value()); - c=c.replace(b.key(), b.value()); - if(deb)QMessageBox::information(this, trUtf8("valeur replace", "box title to debug valeur replace"), QString(abefore+"->"+aa)); + if(aa.contains(b.key())){//key.replace(b.key(), b.value()); + QString abefore=aa, cbefore=c; + aa.replace(b.key(), b.value()); + c.replace(b.key(), b.value()); + if(deb)QMessageBox::information(this, trUtf8("valeur replace", "box title to debug valeur replace"), QString(abefore+"=a>"+aa+"\n"+cbefore+"=c>"+c)); } } + QStringList b=aa.split(QString(" ")); + c.remove(0,4); + if(deb)QMessageBox::information(this, trUtf8("action after replace", "box title to debug action"), aa); int bs=b.size(), part=aa.count(conf->value(QString("sepcmd")).toString()); if(part){ for(int d=0; d<=part; d++){ @@ -443,25 +444,27 @@ void MainWindow::action(const QString &a){ QList tmpkeys=valeur->keys(); QList tmpvalues=valeur->values(); for(int a=0;asize();a++){ - addWidget(QString("box "+tmpkeys[a]), new CLabel(tmpvalues[a], *conf)); + addWidget(QString("box "+tmpvalues[a]), new CLabel(tmpkeys[a], *conf)); if(deb)QMessageBox::information(this, QString("val"), QString(tmpkeys[a]+"=="+tmpvalues[a])); } }else if(b[2]==QString("?")){ QString val,tmp="Enter value for "+QString(b[1]); - val=QInputDialog::getText(this, "val", trUtf8(tmp.toLocal8Bit().constData(), "text to ask value's name before changing it (val)"), QLineEdit::Normal, QString(""), &ok); + val=QInputDialog::getText(this, "val", QString(tmp), QLineEdit::Normal, QString(""), &ok); if(ok)action(QString("val "+b[1]+" "+val)); + if((deb)&&(ok))QMessageBox::information(this, QString("val"), QString("val("+b[1]+")=="+val)); } else{ - for(int a=0;a<((bs-1)/2); a++){ - valeur->insert(b[(2*a)+1], b[(2*a)+2]); - if(deb)QMessageBox::information(this, QString("val"), QString("val("+b[(2*a)+1]+")=="+b[(2*a)+2])); - }; + int t=aa.size()-b.at(2).size()+1; + QString tmp=aa.right(t); + valeur->insert(b[1], tmp); + if(deb)QMessageBox::information(this, QString("val"), QString("val("+b[1]+")=="+tmp)); } }else{ valeur->clear(); if(deb)QMessageBox::information(this, QString("val"), QString("val cleared")); } - if(deb)QMessageBox::information(this, QString("val"), QString("val.size()=="+valeur->size())); + QString tmp=QString("val.size()==")+QString::number(valeur->size()); + if(deb)QMessageBox::information(this, QString("val"), tmp); } else if(b[0]==QString("add")){ addDB(c); @@ -471,7 +474,7 @@ void MainWindow::action(const QString &a){ else action(c); } else{ - get(conf->value(QString("currenttype")).toString(),a); + get(conf->value(QString("currenttype")).toString(),aa); //a=""; } }