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();
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();
void MainWindow::lsconfig(){
flush();
QStringList tmp=conf->allKeys();
- qDebug()<<"conf.size(in lsconfig())="<<tmp.size();
for(int a=0; a<tmp.size();a++){
CLabel * b=new CLabel(tmp[a]);
addWidget(tmp[a], b);
qDebug()<<"action("<<a<<")";
label->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);
}
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() ? "<<db.open()<< ". database : "<<db.databaseName();
q=new QSqlQuery(db);
conf->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);
return tmp;
}
int MainWindow::exec(const QString & a){
- //qDebug()<<"exec("<<a<<")";
+ qDebug()<<"exec("<<a<<")";
q->prepare(a);
q->exec();
QSqlError b=q->lastError();
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');