From: Norbert Moutarde Date: Tue, 27 Oct 2015 20:20:25 +0000 (+0100) Subject: i've added the switch ('#') as last character to not go through replace X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=344607e34f97699d8342d99b402770458fdb9ee7;p=diary-mobile.git i've added the switch ('#') as last character to not go through replace --- diff --git a/mainwindow.cpp b/mainwindow.cpp index 748ca56..09399ee 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -181,12 +181,15 @@ void MainWindow::action(const QString &a){ if(deb)QMessageBox::information(this, trUtf8("action", "box title to debug action"), a); QString aa=a; bool ok=1; + if(aa.right(1)!=QString("#")){ for(QMap::iterator b=valeur->begin();b!=valeur->end();b++){ if(aa.contains(b.key())){//key.replace(b.key(), b.value()); QString abefore=aa; aa.replace(b.key(), b.value()); - if(deb)QMessageBox::information(this, trUtf8("valeur replace", "box title to debug valeur replace"), QString(abefore+"=a>"+aa)); + if(deb)QMessageBox::information(this, trUtf8("valeur replace", "box title to debug valeur replace"), QString(abefore+"=>"+aa)); } + }}else{ + aa.chop(1); } QString c=aa; QStringList b=aa.split(QString(" ")); @@ -438,27 +441,47 @@ void MainWindow::action(const QString &a){ system(d.toStdString().c_str()); } else if(b[0]==QString("val")){ + bool ok; + QList tmpkeys=valeur->keys(); + QList tmpvalues=valeur->values(); if(bs!=1){ if(b[1]==QString("list")){ - flush(); - QList tmpkeys=valeur->keys(); - QList tmpvalues=valeur->values(); + flush(); for(int a=0;asize();a++){ addWidget(QString("box "+tmpvalues[a]), new CLabel(tmpkeys[a], *conf)); if(deb)QMessageBox::information(this, QString("val"), QString(tmpkeys[a]+"=="+tmpvalues[a])); } - }else if(bs==2){ - QMessageBox::information(this, QString("val)"), QString(b[1]+"=="+valeur->value(b[1], QString("don't exist")))); + }else if(b[1]==QString("edit")){ + flush(); + for(int a=0;asize();a++){ + addWidget(QString("val "+tmpvalues[a]+"#"), new CLabel(tmpkeys[a], *conf)); + if(deb)QMessageBox::information(this, QString("val"), QString(tmpkeys[a]+"=="+tmpvalues[a])); + } + } + else if(bs==2){ + //QMessageBox::information(this, QString("val)"), QString(b[1]+"=="+valeur->value(b[1], QString("don't exist")))); + QString old; + if(valeur->size())old=tmpvalues[0]; + else old=""; + for(int t=1;tsize();t++){ + old=old+" "+tmpvalues[t]; + } + QString tmp=QInputDialog::getText(this, QString("val"), b[1], QLineEdit::Normal, old, &ok); + if((ok)&&(tmp!=valeur->value(b[1]))){ + valeur->remove(b[1]); + valeur->insert(b[1], tmp); + } }else if((bs==3)&&(b[2]==QString("?"))){ - QString val,tmp="Enter value for "+QString(b[1]); + QString val,tmp="Enter value for "+b[1]; val=QInputDialog::getText(this, "val", tmp, QLineEdit::Normal, QString(""), &ok); - if(ok)action(QString("val "+b[1]+" "+val)); + //if(ok)action(QString("val "+b[1]+" "+val));// ERROR + if(ok)valeur->insertMulti(b[1],val);//good if((deb)&&(ok))QMessageBox::information(this, QString("val"), QString("val("+b[1]+")=="+val)); }else{//if (bs=>3)&&(b[2]!="?") int t=aa.size()-(b[1].size())-5;//5==val+2 space qDebug()<<"aa.size()=="<insert(b[1], tmp); + valeur->insertMulti(b[1], tmp); if(deb)QMessageBox::information(this, QString("val"), QString("val("+b[1]+")=="+tmp)); } }else{ @@ -786,7 +809,7 @@ void MainWindow::editDB(const QString & a, const QString & b){ else tmpaction=QInputDialog::getText(this, trUtf8("action", "Title of box where ask for button's action"), trUtf8("new action", "question to get new button's action"), QLineEdit::Normal, action, &ok); if(!ok)return; - if((tmpkeyword=="del")||(tmplabel=="del")||(tmpaction=="del")){ + if((tmpkeyword=="")||(tmplabel=="")||(tmpaction=="")){ remove(a, keyword, label, action); if(deb)QMessageBox::information(this, trUtf8("EditDB", "title of box to say a button was deleted"), trUtf8("button was deleted", "text to say button was deleted")); return;