]> git.nothing2do.fr Git - diary-mobile.git/commitdiff
back() at begining now refresh the page
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Sat, 1 Feb 2014 12:18:09 +0000 (13:18 +0100)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Sat, 1 Feb 2014 12:18:09 +0000 (13:18 +0100)
mainwindow.cpp
mainwindow.h

index 4bdb868d823f9f705ef2489995fa40c4c12af191..1f11598ee08875a13853a0fa6379e31e6cad257a 100644 (file)
@@ -1,4 +1,3 @@
-
 #include "mainwindow.h"
 //#include "ui_mainwindow.h"
 #include "mainwindow.h"
@@ -149,11 +148,12 @@ void MainWindow::action(const QString &a){
 }
 void MainWindow::createMenuBar(){
     FileMenu=new QMenu(QString("&File"), this);
-    FileMenu->addAction(trUtf8("&Start..."), this, SLOT(start()),QKeySequence(trUtf8("Ctrl+S", "Start")));
-    FileMenu->addAction(trUtf8("&Back"), this, SLOT(back()),QKeySequence(trUtf8("Ctrl+B", "Back")));
-    FileMenu->addAction(trUtf8("&Download"), this, SLOT(updateUi()),QKeySequence(trUtf8("Ctrl+W", "Downlad")));
-    FileMenu->addAction(trUtf8("Up&load"), this, SLOT(sendUi()),QKeySequence(trUtf8("Ctrl+L", "Upload")));
-    FileMenu->addAction(trUtf8("&Quit..."), this, SLOT(quit()),QKeySequence(trUtf8("Ctrl+Q", "Quit")));
+    FileMenu->addAction(trUtf8("&Start..."), this, SLOT(start()),QKeySequence(trUtf8("Ctrl+S", "File|Start")));
+    FileMenu->addAction(trUtf8("&Back"), this, SLOT(back()),QKeySequence(trUtf8("Ctrl+B", "File|Back")));
+    FileMenu->addAction(trUtf8("&Download"), this, SLOT(updateUi()),QKeySequence(trUtf8("Ctrl+W", "File|Downlad")));
+    FileMenu->addAction(trUtf8("Up&load"), this, SLOT(sendUi()),QKeySequence(trUtf8("Ctrl+L", "File|Upload")));
+    FileMenu->addAction(trUtf8("Reset Ui"), this, SLOT(resetUi()), QKeySequence(trUtf8("Ctrl+Z", "File|ResetUi")));
+    FileMenu->addAction(trUtf8("&Quit..."), this, SLOT(quit()),QKeySequence(trUtf8("Ctrl+Q", "File|Quit")));
     menuBar()->addMenu(FileMenu);
     EditMenu=new QMenu(QString("&Buttons"));
     EditMenu->addAction(trUtf8("C&reate Database"), this, SLOT(createDB()), QKeySequence(trUtf8("Ctrl+R", "Buttons|CreateDB")));
@@ -161,14 +161,10 @@ void MainWindow::createMenuBar(){
     EditMenu->addAction(trUtf8("Sa&v buttons"), this, SLOT(savButtons()), QKeySequence(trUtf8("Ctrl+V", "Buttons|Save")));
     EditMenu->addAction(trUtf8("&Edit buttons"), this, SLOT(editButtonDB()), QKeySequence(trUtf8("Ctrl+E", "Buttons|&Edit")));
     EditMenu->addAction(trUtf8("&View/Hide menu"), this, SLOT(toggleMenu()), QKeySequence(trUtf8("Ctrl+T", "Buttons|View menu")));
-    EditMenu->addAction(trUtf8("Reset database"), this, SLOT(resetUi()), QKeySequence(trUtf8("Ctrl+Z", "Buttons|ResetDB")));
     menuBar()->addMenu(EditMenu);
     HelpMenu=new QMenu(QString("&Help"));
     HelpMenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt()), QKeySequence(tr("ctrl+H", "About Qt")));
     menuBar()->addMenu(HelpMenu);
-
-
-    //menuBar()->show();
 }
 void MainWindow::toggleMenu(){
     if (menuBar()->isVisible()){
@@ -186,7 +182,7 @@ void MainWindow::flush(){
     }
     //widget.clear();
 }
-CLabel::CLabel( const QString& text, const QRect & dim, const QString & style, QWidget * parent ) : QLabel(parent)
+CLabel::CLabel( const QString& text, const QString & style, QWidget * parent ) : QLabel(parent)
 {
     m_style=style;
     setText(text);
@@ -281,27 +277,23 @@ void MainWindow::entry(const QString &a){
         context.append(" ");
     }
     context.append(way[way.size()-1]);
-    qDebug()<<"context="<<context;
+    //qDebug()<<"context="<<context;
     if(a=="")label=time+" "+context+" : ";
     else label=time+" "+context+", "+a+" : ";
     entry=QInputDialog::getText(this, QString("nouvelle entrée"), label, QLineEdit::Normal, "", &ok);
     if(ok==0)return;
     QString c;
-    qDebug()<<"c="<<c<<" context="<<context<<" entry="<<entry<<" a="<<a;
+    //qDebug()<<"c="<<c<<" context="<<context<<" entry="<<entry<<" a="<<a;
     if(a=="")c=context+" : "+entry;
     else c=context+", "+a+" : "+entry;
-    qDebug()<<"c="<<c;
+    //qDebug()<<"c="<<c;
     QFile fichier(conf->value(QString("file")).toString());
     fichier.open(QIODevice::Append | QIODevice::Text);
     QTextStream flux(&fichier);
-    flux << label << c << endl;
+    flux << label << entry << endl;
     fichier.close();
-    QList<QString> d({"INSERT INTO raw (date, texte) VALUES (:date, :txt);"});
-    qDebug()<<"c="<<c;
-    d.append(time);
-    d.append(c);
+    QList<QString> d({"INSERT INTO raw (date, texte) VALUES (:date, :txt);", time, entry});
     exec(d);
-    //sql.unlock();
     QSqlError b=q->lastError();
     if (b.isValid())qDebug()<<"q->lastError():"<<b.text();
 }
@@ -332,6 +324,7 @@ void MainWindow::addButtonDB(){
     return;
 }
 void MainWindow::getButtons(const QString &a){
+    if(a==conf->value(QString("start")).toString())way.clear();
     qDebug()<<"getButtons("<<a<<") way.size()"<<way.size();
     flush();
     if(updatelocker.tryLock(60000))updatelocker.unlock();
@@ -344,10 +337,9 @@ void MainWindow::getButtons(const QString &a){
     int labCol = 0;//r.indexOf("label");
     int actCol = 1;//r.indexOf("action");
     int i=0;
-    QRect rect;
     qDebug()<<"bcl to add buttons";
     while(q->next()){
-        addWidget(q->value(actCol).toString(), new CLabel(q->value(labCol).toString(), rect, conf->value(QString("button")).toString()));
+        addWidget(q->value(actCol).toString(), new CLabel(q->value(labCol).toString(), conf->value(QString("button")).toString()));
         i++;
     };
     qDebug()<<"end getButtons : "<<i<<" button(s) way.size()"<<way.size();
@@ -387,7 +379,11 @@ void MainWindow::back(){
             addWidget(QString(way[i]), new CLabel(QString(way[i])));
         }
     }
-    else QMessageBox::information(this, QString("Erreur"), QString("Vous êtes déja au départ."));
+    else {
+        flush();
+        getButtons(conf->value(QString("start")).toString());
+        //QMessageBox::information(this, QString("Erreur"), QString("Vous êtes déja au départ."));
+    }
 
 }
 void MainWindow::keyReleaseEvent(QKeyEvent *event)
@@ -468,11 +464,11 @@ void MainWindow::readButtons(const QByteArray &in){
 }
 void MainWindow::datasend(){
     qDebug()<<"datasend";
-    QString texte="Update finish"/*, s=m->downloadedData().size()*/;
+    QString texte="Upload finish"/*, s=m->downloadedData().size()*/;
     //texte=texte+s.toInt()+" byte)";
     qDebug()<<"texte : "<<texte;
 
-    QMessageBox::information(this, "update", texte);
+    QMessageBox::information(this, "upload", texte);
 }
 void MainWindow::resetUi(){
     exec(QList<QString>({"delete from ui;"}));
index 110c41cee39464350c16a97b7b79c067b6aa468f..4099296a338b422b67c34d92eae6fafcc382c21e 100644 (file)
@@ -63,7 +63,7 @@ Q_OBJECT
     QString m_style;
 
 public:
-    explicit CLabel(const QString& text ="default",const QRect & =QRect(0,0,1,1), const QString &style="background-color: red;border-style: outset;border-width: 7px;border-radius: 10px;border-color: beige;font: bold 15px;padding: 6px;",QWidget * parent = 0 );
+    explicit CLabel(const QString& text ="default",const QString &style="background-color: red;border-style: outset;border-width: 7px;border-radius: 10px;border-color: beige;font: bold 15px;padding: 6px;",QWidget * parent = 0 );
     ~CLabel();
     void SetTextToLabel(const QString &);
 signals: