From: Norbert Moutarde Date: Tue, 10 Dec 2013 16:14:15 +0000 (+0100) Subject: all buttons is SQL'ed (config's too !) X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=2cc44689152fc5ab78e06ceaeb06a28eb4adc346;p=diary-mobile.git all buttons is SQL'ed (config's too !) --- diff --git a/mainwindow.cpp b/mainwindow.cpp index b08e731..73699c0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -16,6 +16,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { + qDebug()<<"0"; conf=new QSettings(QString("FwF"), QString("diary-mobile"), this); if (conf->allKeys().size()==0)firstrun(); texte=new QLineEdit(); @@ -31,16 +32,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) vbox->addLayout(hbox); vbox->addLayout(grid); signalmap=new QSignalMapper(this); - host=conf->value(QString("host"), QVariant("host")).toString(); - port=conf->value(QString("port"), QVariant(5432)).toInt(); - user=conf->value(QString("user"), QVariant("user")).toString(); - servercert=conf->value(QString("server-cert"), QVariant("a.pem")).toString(); - database=conf->value(QString("database"), QVariant("db")).toString(); - password=conf->value(QString("password"), QVariant("pass")).toString(); - file=conf->value(QString("file"), QVariant("diary.txt")).toString(); connect(signalmap, SIGNAL(mapped(const QString &)), this, SLOT(action(const QString &))); - label=new QLabel("page name"); + label=new QLabel("begin"); setCentralWidget(screen); createMenuBar(); connectDB(); @@ -155,7 +149,6 @@ void MainWindow::choosemaxc(){ void MainWindow::lsconfig(){ flush(); QStringList tmp=conf->allKeys(); - qDebug()<<"conf.size(in lsconfig())="<setText(a); flush(); - if (a=="host")choosehost(); - else if (a=="port")chooseport(); - else if (a=="user")chooseuser(); + /*if (a=="host")choosehost(); done + else if (a=="port")chooseport(); done + else if (a=="user")chooseuser(); done else if (a=="database")choosedb(); else if (a=="password")choosepass(); else if (a=="file")choosefile(); - else if (a=="maxcolumn")choosemaxc(); + else if (a=="maxcolumn")choosemaxc();*/ + if (a.split(QString(" "))[0]==QString("set")){ + conf->setValue(QString(a.split(QString(" "))[1]), a.split(QString(" "))[2]); +} else getButtons(a); } @@ -292,11 +288,12 @@ QString MainWindow::getText(const QString &a){ void MainWindow::connectDB(){ db = QSqlDatabase::addDatabase("QSQLITE"); //db = QSqlDatabase::addDatabase("QPSQL"); - db.setHostName(host); - db.setDatabaseName(database); - db.setUserName(user); - db.setPassword(password); - db.setConnectOptions(QString("requiressl=1 connect_timeout=10000"));//10sec, + db.setHostName(conf->value(QString("host")).toString()); + db.setDatabaseName(conf->value(QString("database")).toString()); + db.setUserName(conf->value(QString("user")).toString()); + db.setPassword(conf->value(QString("password")).toString()); + db.setConnectOptions(conf->value(QString("SQLsettings")).toString());//10sec, + //bool ok=db.open(); qDebug()<<"db.open() ? "<setValue(QString("password"), QVariant("pass")); conf->setValue(QString("file"), QVariant("diary.txt")); conf->setValue(QString("maxcolumn"), QVariant(4)); - createDB(); + conf->setValue(QString("SQLsettings"), QVariant("requiressl=1 connect_timeout=10000)")); } QString &MainWindow::get(int row, int column){ q->seek(row); @@ -320,7 +317,7 @@ QString &MainWindow::get(int row, int column){ return tmp; } int MainWindow::exec(const QString & a){ - //qDebug()<<"exec("<prepare(a); q->exec(); QSqlError b=q->lastError(); diff --git a/ui.sql b/ui.sql index 4296cc0..7c70980 100644 --- a/ui.sql +++ b/ui.sql @@ -11,3 +11,20 @@ INSERT INTO ui ('keyword', 'label', 'action') VALUES('begin', 'lieu', 'lieu'); INSERT INTO ui ('keyword', 'label', 'action') VALUES('l-odysseum', 'oliver''s pub', 'l-o-op'); INSERT INTO ui ('keyword', 'label', 'action') VALUES('l-o-op', 'valentine', 'l-o-opub-val'); INSERT INTO ui ('keyword', 'label', 'action') VALUES('l-o-opub-val', 's''enerve quand je lui demande ce qu''elle veut', 'begin'); +--config buttons +INSERT INTO ui ('keyword', 'label', 'action') VALUES('begin', 'config', 'config'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('config', 'max column', 'c-maxc'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('c-maxc', '3', 'set maxcolumn 3'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('c-maxc', '4', 'set maxcolumn 4'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('c-maxc', '5', 'set maxcolumn 5'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('config', 'host', 'c-host'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('c-host', '127.0.0.1', 'set host 127.0.0.1'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('c-host', 'ssh.alwaysdata.com', 'set host ssh.alwaysdata.com'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('config', 'port', 'c-port'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('c-port', '5432', 'set port 5432'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('config', 'user', 'c-user'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('c-user', 'android', 'set user android'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('config', 'password', 'c-pass'); -- I highly discourage to set pass in a public zone ! + INSERT INTO ui ('keyword', 'label', 'action') VALUES('c-pass', '123', 'set pass 123'); -- " + INSERT INTO ui ('keyword', 'label', 'action') VALUES('config', 'db', 'c-db'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('c-db', 'chat', 'set db chat');