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("testbuttons"), QVariant("select id,keyword from ui where label=? and action=?;"));
conf->setValue(QString("volumdown"), QVariant("config"));
conf->setValue(QString("volumup"), QVariant("config"));
qDebug()<<"firstrun() finished";
}
void MainWindow::addButtonDB(){
qDebug()<<"addButtonDB()";
- //QMutexLocker locker(&addblock);
- QList<QString> cmd;
bool ok=0;
- cmd.append(conf->value(QString("addbuttons")).toString());
- QString cur=way.last();
+ QString cur=label->text();
QString a, b, c=QInputDialog::getText(this, QString("label"), QString("Entrez son label"),QLineEdit::Normal, QString(""), &ok);
if ((c=="")||(ok==0))return;
- cmd.append(c);
b=QInputDialog::getText(this, QString("keyword"), QString("Entrez ses mots clé (no limit !)"), QLineEdit::Normal, cur, &ok);
if ((b=="")||(ok==0))return;
- cmd.append(b);
a=QInputDialog::getText(this, QString("action"), QString("Entrez son action"), QLineEdit::Normal, c, &ok);
if ((a=="")||(ok==0))return;
- cmd.append(a);
- exec(cmd);
+ insertbutton(b, c, a);
return;
}
void MainWindow::getButtons(const QString &b){
exec(QList<QString>({conf->value(QString("updatebuttons")).toString(), keyword, label, action, a}));
}
-/*void MainWindow::editButtonById(){
- const QString a=QInputDialog::getText(this, QString("editButtonById"), QString("Entrez l'ID : "));
- editButtonDB(a);
-}*/
void MainWindow::downloadUi(){
qDebug()<<"updateUi() : "<<conf->value(QString("download")).toString();
download(conf->value(QString("download")).toString());
const QString a=QInputDialog::getText(this, QString("getButtons"), QString("Entrez le mots-clé : "));
getButtons(a);
}
+void MainWindow::insertbutton(const QString & keyword, const QString & label, const QString & action){
+ QList<QString> 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();
+ while(q->isValid()){
+ count++;
+ key=key+" "+q->value(1).toString();
+ q->next();
+ }
+ if(count==0)exec(QList<QString>({conf->value(QString("addbuttons")).toString(), label, keyword, action}));
+ else{exec(QList<QString>({conf->value(QString("updatebuttons")).toString(), key, label, action, id}));
+
+ }
+}