}
void MainWindow::start(){
flush();
+ QString t("begin");
+ getButtons(t);
+
- //qDebug()<<"select * from ui; : "<<exec(QString("select * from ui;"));//SQLite doesn't support this ?
- exec(QString("select * from ui;"));
- r=q->record();
- qDebug()<<"nmb of col : "<<r.count();
- int labCol = r.indexOf("label");
- int sqlCol = r.indexOf("action");
- while(q->next()){
- addWidget(q->value(sqlCol).toString(), new CLabel(q->value(labCol).toString()));
- }
}
MainWindow::~MainWindow()
else if (a=="database")choosedb();
else if (a=="password")choosepass();
else if (a=="file")choosefile();
- /*for (int i=0; i<b; i++){
- QString c=get(i, 0);
- qDebug()<<"c="<<c;
- addWidget(c, new CLabel(c));
- }*/
+ else getButtons(a);
+
+
qDebug()<<"action() end";
- start();
+ //start();
}
void MainWindow::createMenuBar(){
return tmp;
}
int MainWindow::exec(const QString & a){
-
+ qDebug()<<"exec("<<a<<")";
q->prepare(a);// make it
q->exec();// do it
QSqlError b=q->lastError();
QTextStream flux(&fichier);
flux << a << endl;
fichier.close();
- qDebug()<<a<<" content added into file";
+ qDebug()<<"content added into file : "<<a;
q->prepare("INSERT INTO raw (date, texte) VALUES (:date, :txt);");
q->bindValue(":date", v.currentDateTime().toString(QString("yyyy-MM-dd hh:mm:ss")));
q->bindValue(":txt", texte->text());
int MainWindow::createdb(){
exec(QString("create table ui(keyword text, label text, action text);"));
exec(QString("create table raw(date timestamp, texte text);"));
- exec(QString("insert into ui (keyword, label, action) values ('begin', 'chat', 'select texte from raw');"));
+ exec(QString("insert into ui (keyword, label, action) values ('begin', 'chat', 'chien');"));
}
void MainWindow::addButton(){
QString cmd="insert into ui (keyword, label, action) values ('";
QString action=QInputDialog::getText(this, QString("action"), QString("Entrez l'action"));
QString a=cmd+key+"', '"+label+"', '"+action+"');";
- qDebug()<<"a="<<a;
+ qDebug()<<"exec("<<a<<")";
exec(a);
};
-
+void MainWindow::getButtons(const QString &a){
+ QString tmp("select keyword,label,action from ui where keyword like '%"+a+"%';");
+ exec(tmp);
+ //r=q->record();
+ //qDebug()<<"nmb of col : "<<r.count();
+ int labCol = 1;//r.indexOf("label");
+ int sqlCol = 2;//r.indexOf("action");
+ while(q->next()){
+ addWidget(q->value(sqlCol).toString(), new CLabel(q->value(labCol).toString()));
+ }
+}