From ac44b9afb2b47bdae11b6626fde668c27a205dce Mon Sep 17 00:00:00 2001 From: Norbert Moutarde Date: Tue, 10 Dec 2013 15:09:45 +0100 Subject: [PATCH] prepare to get config into SQL !!! (and some SQL mistake) --- mainwindow.cpp | 18 ++++++++++++++++-- mainwindow.h | 1 + ui.sql | 6 +++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 4a328ce..b08e731 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -10,7 +10,7 @@ #include #include #include -#define MAXCOLUMN 4 +#define MAXCOLUMN 4 // put this setting in conf #define MAXLINE 5 // !!! @@ -143,6 +143,15 @@ void MainWindow::choosefile(){ if (ok)conf->setValue(QString("file"), file); } +void MainWindow::choosemaxc(){ + bool ok; + int maxc=QInputDialog::getInt(this, QString("colonne"), QString("colonne max ?"), conf->value(QString("maxcolumn")).toInt(), 1, 65535, 1, &ok); + if((ok==1)){ + conf->setValue(QString("maxcolumn"), maxc); + }else{ + conf->setValue(QString("maxcolumn"), conf->value(QString("maxcolumn")).toInt()); + } +} void MainWindow::lsconfig(){ flush(); QStringList tmp=conf->allKeys(); @@ -164,7 +173,8 @@ void MainWindow::quit(){ CLabel* MainWindow::addWidget(const QString &key, CLabel * a){ widget.insert(key, a); - grid->addWidget(a, grid->count()/MAXCOLUMN, grid->count()%MAXCOLUMN, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter); + int maxc=conf->value(QString("maxcolumn")).toInt(); + grid->addWidget(a, grid->count()/maxc, grid->count()%maxc, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter); QObject::connect(a, SIGNAL(released()), signalmap, SLOT(map())); signalmap->setMapping(a, key); return a; @@ -184,6 +194,8 @@ void MainWindow::action(const QString & a){ else if (a=="database")choosedb(); else if (a=="password")choosepass(); else if (a=="file")choosefile(); + else if (a=="maxcolumn")choosemaxc(); + else getButtons(a); } void MainWindow::createMenuBar(){ @@ -299,6 +311,7 @@ void MainWindow::firstrun(){ conf->setValue(QString("database"), QVariant("db")); conf->setValue(QString("password"), QVariant("pass")); conf->setValue(QString("file"), QVariant("diary.txt")); + conf->setValue(QString("maxcolumn"), QVariant(4)); createDB(); } QString &MainWindow::get(int row, int column){ @@ -374,6 +387,7 @@ void MainWindow::getButtons(const QString &a){ //qDebug()<<"nmb of col : "<first(); while(q->next()){ addWidget(q->value(actCol).toString(), new CLabel(q->value(labCol).toString())); } diff --git a/mainwindow.h b/mainwindow.h index 36b0579..3b8f5f0 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -65,6 +65,7 @@ private slots: void choosepass(); void choosedb(); void choosefile(); + void choosemaxc(); //void disconnect(); void quit(); void lsconfig(); diff --git a/ui.sql b/ui.sql index f2f1719..4296cc0 100644 --- a/ui.sql +++ b/ui.sql @@ -7,7 +7,7 @@ INSERT INTO ui ('keyword', 'label', 'action') VALUES('begin','fille','fille'); INSERT INTO ui ('keyword', 'label', 'action') VALUES('begin', 'lieu', 'lieu'); INSERT INTO ui ('keyword', 'label', 'action') VALUES('lieu', 'odysseum', 'l-odysseum'); INSERT INTO ui ('keyword', 'label', 'action') VALUES('l-odysseum', 'subway', 'l-o-subway'); - INSERT INTO ui ('keyword', 'label', 'action') VALUES('l-o-subway', 'julie', 'l-o-s-juli'); + INSERT INTO ui ('keyword', 'label', 'action') VALUES('l-o-subway', 'julie', 'l-o-s-julie'); 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-olive-val'); - INSERT INTO ui ('keyword', 'label', 'action') VALUES('l-o-olive-val', 's''enerve quand je lui demande ce qu''elle veut', 'begin'); + 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'); -- 2.45.1