]> git.nothing2do.fr Git - diary-mobile.git/commitdiff
prepare to get config into SQL !!! (and some SQL mistake)
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Tue, 10 Dec 2013 14:09:45 +0000 (15:09 +0100)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Tue, 10 Dec 2013 14:09:45 +0000 (15:09 +0100)
mainwindow.cpp
mainwindow.h
ui.sql

index 4a328cee9028866e5984eea8f9ed5a51a4f43ead..b08e731d9194479a1d0d68a5f25bef735b001cb0 100644 (file)
@@ -10,7 +10,7 @@
 #include <QKeySequence>
 #include <QDateTime>
 #include <QFileDialog>
-#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 : "<<r.count();
     int labCol = 0;//r.indexOf("label");
     int actCol = 1;//r.indexOf("action");
+    //q->first();
     while(q->next()){
         addWidget(q->value(actCol).toString(), new CLabel(q->value(labCol).toString()));
     }
index 36b05795ed917a86037d5642f3de88be5c76f02b..3b8f5f01c57f9a287877e9f5170bcdec986083cc 100644 (file)
@@ -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 f2f171930c1c5452310b1f5bb36d022b8140a5cf..4296cc0ee572b6b7ea2c4cf73f47d17a202f07e0 100644 (file)
--- 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');