]> git.nothing2do.fr Git - diary-mobile.git/commitdiff
added the possibility to get multiple SQL call (2 yet)
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Fri, 8 Jan 2016 11:42:32 +0000 (12:42 +0100)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Fri, 8 Jan 2016 11:42:32 +0000 (12:42 +0100)
mainwindow.cpp
mainwindow.h

index 10b9ca9da7714277c38c8ec663f49d4e870dff46..b5a3f2288189889122c089272cc9502805a4cebe 100644 (file)
@@ -289,13 +289,13 @@ void MainWindow::action(const QString &a){
         if(!page)tmp=q->seek(0);
         else tmp=q->seek(-t-max-1,true);
         if(deb)QMessageBox::information(this, trUtf8("result", "box title to debug prevpage"), int(tmp));
-        printItem();
+        printItem(*q);
 
     }
     else if(b[0]==QString("nextpage")){
         page++;
         flush();
-        printItem();
+        printItem(*q);
     }
     else if(b[0]==QString("setfile")){
         bool ok=0;
@@ -768,7 +768,7 @@ void MainWindow::get(const QString & d, const QString &b){
     exec(tmp);
     page=0;
     //while(q->next()){
-         printItem();
+         printItem(*q);
     //}
 }
 void MainWindow::chooseDB(){
@@ -1232,7 +1232,7 @@ void MainWindow::reset(){
     QList<QString> b({"delete from buttons;"});
     exec(b);
 }
-bool MainWindow::printItem(){
+bool MainWindow::printItem(const QSqlQuery & a){
     int labCol = 0;//r.indexOf("label");
     int actCol = 1;//r.indexOf("action");
     int i=0;
@@ -1241,8 +1241,8 @@ bool MainWindow::printItem(){
         addWidget(QString("prevpage"), new CLabel(trUtf8("Prev"), *conf));
 
     };
-    while(q->next()){
-        int tmp=addWidget(q->value(actCol).toString(), new CLabel(q->value(labCol).toString(), *conf));
+    while(a.next()){
+        int tmp=addWidget(a.value(actCol).toString(), new CLabel(a.value(labCol).toString(), *conf));
         if(tmp==1){
             addWidget(QString("nextpage"), new CLabel(trUtf8("Next"), *conf));
             return 1;
@@ -1256,3 +1256,23 @@ bool MainWindow::printItem(){
     qDebug()<<"end printItem : "<<i<<" button(s) way.size()"<<way.size()<<" page : "<<page;
     return 0;
 }
+void MainWindow::get2(const QString & d, const QString &b){
+    if(deb)QMessageBox::information(this, trUtf8("action", "box title to debug get"), "type:"+d+" keyword:"+b);
+    QString a=b;lastprint=b;
+    if((b[0]!='-')&&(b[0]!='+'))way.append(a);
+    else a.remove(0, 1);
+    qDebug()<<"get"<<d<<"("<<a<<") way.size()"<<way.size();
+    if(b[0]!='+')flush();
+    if(updatelocker.tryLock(60000))updatelocker.unlock();
+    else{qDebug()<<"updatelocker is locked more than 1mn";}
+    QString t=QString("get"+d);
+    QString c="%"+a+"%", x=conf->value(t).toString();
+    qDebug()<<"l691 x="<<x<<" c="<<c<<" t="<<t;
+    QList<QString> tmp({x, c});
+    label->setText(c);
+    exec2(tmp);
+    page=0;
+    //while(q->next()){
+         printItem(*qq);
+    //}
+}
index 27cecdd8d1238f35bc474d795b5bca0fb468f9ff..a1a16e0197d642e02e018c281182ccbe15f9cdc3 100644 (file)
@@ -173,6 +173,7 @@ private slots:
     void addMedia(const QString &);
     void editDB(const QString &, const QString &);
     void get(const QString &, const QString &);
+    void get2(const QString &, const QString &);
     void get(const QString &);
     void downloadData();
     void writeData();
@@ -188,7 +189,7 @@ private slots:
     void download(const QString &);
     void download(const QString &,const QString &);
     void use(const QString &);
-    bool printItem();
+    bool printItem(const QSqlQuery &);
 public slots:
 
 signals: