]> git.nothing2do.fr Git - diary-mobile.git/commitdiff
val now work (with unlimited number of caracter replaced :-)
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Tue, 29 Sep 2015 19:26:06 +0000 (21:26 +0200)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Tue, 29 Sep 2015 20:01:30 +0000 (22:01 +0200)
mainwindow.cpp

index 4ba962a7d442ab547a9cb86d56b47ed1b034ef7b..0bf5ba50979e2ad3226ee178e099b7be082a7e24 100644 (file)
@@ -179,18 +179,19 @@ int unsigned MainWindow::addWidget(const QString &key, const CLabel *a){
 void MainWindow::action(const QString &a){
     qDebug()<<"action("<<a<<")";
     if(deb)QMessageBox::information(this, trUtf8("action", "box title to debug action"), a);
-    QStringList b=a.split(QString(" "));
     QString c=a, aa=a;
     bool ok=1;
-    c.remove(0,4);
     for(QMap<QString, QString>::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<QString> tmpkeys=valeur->keys();
                 QList<QString> tmpvalues=valeur->values();
                 for(int a=0;a<valeur->size();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="";
     }
 }