From: Norbert Moutarde Date: Thu, 22 May 2014 13:28:59 +0000 (+0200) Subject: action("buttons URL") download buttons from URL, and "removebutton" X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=82a702c6d974da45dcb4c5ad34755e30bdda506e;p=diary-mobile.git action("buttons URL") download buttons from URL, and "removebutton" remove one buttons (only one keyword). --- diff --git a/mainwindow.cpp b/mainwindow.cpp index e08c376..58de54f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -182,7 +182,7 @@ void MainWindow::action(const QString &a){ else if(b[0]==QString("start")){ getButtons(conf->value(QString("start")).toString()); } - else if(b[0]=="new"){ + else if(b[0]==QString("new")){ entry(c); } else if(b[0]==QString("a/b")){ @@ -190,18 +190,18 @@ void MainWindow::action(const QString &a){ QString e=QInputDialog::getItem(this, QString("choice"), QString("On vous offre un choix."), c.split(QString("!q!")), 0, 1, &ok); if(ok)action(e); } - else if(b[0]=="back"){ + else if(b[0]==QString("back")){ if(way.size()>=2){ way.removeLast(); getButtons(way.takeLast()); } } - else if(b[0]=="run"){ + else if(b[0]==QString("run")){ for(int d=0; d<=a.count(QString("!q!")); d++){ action(c.split(QString("!q!"))[d]); } } - else if(b[0]=="setfile"){ + else if(b[0]==QString("setfile")){ bool ok; QString e=QFileDialog::getSaveFileName(this, QString("get file"), conf->value(b[1]).toString()); if(ok)conf->setValue(b[1], e); @@ -210,7 +210,7 @@ void MainWindow::action(const QString &a){ QMessageBox::information(this, QString("box"), c); } - else if(b[0]=="quit"){ + else if(b[0]==QString("quit")){ quit(); } else if(b[0]==QString("clear")){ @@ -229,6 +229,10 @@ void MainWindow::action(const QString &a){ else editButtonDB(b[1]); } + else if(b[0]==QString("buttons")){ + download(b[1]); + connect(m, SIGNAL(downloaded()), SLOT(writeUi())); + } else getButtons(a); } void MainWindow::createMenuBar(){ @@ -351,7 +355,7 @@ void MainWindow::firstrun(){ conf->setValue(QString("getbuttons"), QVariant("select label,action from ui where keyword like ? order by label;")); conf->setValue(QString("editbuttons"), QVariant("select id,keyword,label,action from ui where id=?;")); conf->setValue(QString("updatebuttons"), QVariant("update ui set keyword=?, label=?, action=? where id=?;")); - conf->setValue(QString("deletebuttons"), QVariant("delete from ui where id=?")); + conf->setValue(QString("deletebutton"), QVariant("delete from ui where id=?")); conf->setValue(QString("testbuttons"), QVariant("select id,keyword from ui where label=? and action=?;")); conf->setValue(QString("volumdown"), QVariant("back")); conf->setValue(QString("volumup"), QVariant("begin")); @@ -471,7 +475,8 @@ void MainWindow::editButtonDB(const QString & a){ const QString action=QInputDialog::getText(this, "action", "new action", QLineEdit::Normal, q->value(3).toString(), &ok); if(!ok)return; if((keyword=="")||(label=="")||(action=="")){ - exec(QList({conf->value(QString("deletebuttons")).toString(), a})); + //exec(QList({conf->value(QString("deletebuttons")).toString(), a})); + removebutton(keyword, label, action); return; } exec(QList({conf->value(QString("updatebuttons")).toString(), keyword, label, action, a})); @@ -703,3 +708,23 @@ void MainWindow::insertbutton(const QString & keyword, const QString & label, co } } +void MainWindow::removebutton(const QString & keyword, const QString &label, const QString &action){ + QList tmp; + tmp.append(conf->value(QString("testbuttons")).toString()); + tmp.append(label); + tmp.append(action); + exec(tmp); + q->first(); + int count=0; + QString key=keyword, id=q->value(0).toString(), cur; + while(q->isValid()){ + count++; + cur=q->value(1).toString(); + if(cur!=keyword)key=key+" "+cur; + q->next(); + } + if(count==1)exec(QList({conf->value(QString("deletebutton")).toString(), id})); + else{exec(QList({conf->value(QString("updatebuttons")).toString(), key, label, action, id})); + + } +} diff --git a/mainwindow.h b/mainwindow.h index 2e6fffc..46d3a28 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -119,6 +119,7 @@ public: explicit MainWindow(QWidget *parent = 0); virtual ~MainWindow(); void insertbutton(const QString &, const QString &, const QString &); + void removebutton(const QString &, const QString &, const QString &); // Note that this will only have an effect on Symbian and Fremantle. void setOrientation(ScreenOrientation orientation);