]> git.nothing2do.fr Git - diary-mobile.git/commitdiff
I've added "multiline" and "onlylast" switch
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Sat, 22 Nov 2014 13:21:22 +0000 (14:21 +0100)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Sat, 22 Nov 2014 13:21:22 +0000 (14:21 +0100)
mainwindow.cpp

index e1f36e8bb5d5170d9ebb093b2ab24f94eb86ac46..6624435f72e82fb35dec65a9d92821a5e71d2bdc 100644 (file)
@@ -396,10 +396,10 @@ void MainWindow::action(const QString &a){
         }
     }
     else if(b[0]==QString("wri")){
-        QFile tmp(conf->value(QString("file")).toString());
+        QFile tmp(c);
         tmp.open(QIODevice::WriteOnly);
         QTextStream stream(&tmp);
-        stream<<c;
+        stream<<m->downloadedData();
         tmp.close();
 
     }
@@ -574,6 +574,8 @@ void MainWindow::firstrun(){
     conf->setValue(QString("sqlval"), QVariant("?"));
     conf->setValue(QString("always"), QVariant("+always"));
     conf->setValue(QString("currenttype"), QVariant("buttons"));
+    conf->setValue(QString("multiline"), QVariant(0));
+
     qDebug()<<"firstrun() finished";
 }
 QString MainWindow::get(int column){
@@ -615,16 +617,22 @@ int MainWindow::exec2(const QList<QString> & a){
 void MainWindow::entry(const QString &a){
     QString label, time=QDateTime::currentDateTime().toString(QString("yyyy-MM-dd hh:mm:ss")), entry, context;
     bool ok=0;
-    for(int b=0; b<way.size()-1;b++){
-        qDebug()<<"way["<<b<<"]="<<way[b];
-        context.append(way[b]);
-        context.append("<br>");
-    }
+    //if(!conf->value(QString("onlylast")).toBool()){
+        for(int b=0; b<way.size()-1;b++){
+            qDebug()<<"way["<<b<<"]="<<way[b];
+            context.append(way[b]);
+            context.append(" ");
+        };
+    //};
     context.append(way.last());
-    if(a=="")label=context+" : ";
-    else label=context+", "+a+" : ";
-    //entry=QInputDialog::getText(this, trUtf8("New entry"), label, QLineEdit::Normal, "", &ok);
-    entry=QInputDialog::getMultiLineText(this, trUtf8("New entry"), label, QString(""), &ok);
+
+    if((a=="")&&(!conf->value(QString("onlylast")).toBool()))label=context+" : ";
+    else if((a=="")&&(conf->value(QString("onlylast")).toBool()))label=way.last()+" : ";
+    else if((a!="")&&(!conf->value(QString("onlylast")).toBool()))label=context+", "+ a +" : ";
+    else label=way.last()+", "+a+" : ";
+    if(conf->value(QString("multiline")).toBool())entry=QInputDialog::getMultiLineText(this, trUtf8("New entry"), label, QString(""), &ok);
+    else entry=QInputDialog::getText(this, trUtf8("New entry"), label, QLineEdit::Normal, "", &ok);
+
     if(!ok)return;
     QString c;
     if(a=="")c=context+" : "+entry;
@@ -705,12 +713,19 @@ void MainWindow::editDB(const QString & a, const QString & b){
     QString keyword=q->value(1).toString();
     QString label=q->value(2).toString();
     QString action=q->value(3).toString();
-    const QString tmpkeyword=QInputDialog::getText(this, trUtf8("keyword", "Title of box where ask for button's keyword"), trUtf8("new keyword", "question to get new button's keyword"), QLineEdit::Normal, keyword, &ok);
+    QString tmpkeyword, tmplabel, tmpaction;
+    if(conf->value(QString("multiline")).toBool())tmpkeyword=QInputDialog::getMultiLineText(this, trUtf8("keyword", "Title of box where ask for button's keyword"), trUtf8("new keyword", "question to get new button's keyword"), keyword, &ok);
+    else tmpkeyword=QInputDialog::getText(this, trUtf8("keyword", "Title of box where ask for button's keyword"), trUtf8("new keyword", "question to get new button's keyword"), QLineEdit::Normal, keyword, &ok);
     if(!ok)return;
-    const QString tmplabel=QInputDialog::getText(this, trUtf8("label", "Title of box where ask for button's label"), trUtf8("new label", "question to get new button's label"), QLineEdit::Normal, label, &ok);
+
+    if(conf->value(QString("multiline")).toBool())tmplabel=QInputDialog::getMultiLineText(this, trUtf8("label", "Title of box where ask for button's label"), trUtf8("new label", "question to get new button's label"), label, &ok);
+    else tmplabel=QInputDialog::getText(this, trUtf8("label", "Title of box where ask for button's label"), trUtf8("new label", "question to get new button's label"), QLineEdit::Normal, label, &ok);
     if(!ok)return;
-    const QString 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(conf->value(QString("multiline")).toBool())const QString tmpaction=QInputDialog::getMultiLineText(this, trUtf8("action", "Title of box where ask for button's action"), trUtf8("new action", "question to get new button's action"), action, &ok);
+    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=="")||(tmplabel=="")||(tmpaction=="")){
         remove(a, keyword, label, action);
         return;