-
#include "mainwindow.h"
//#include "ui_mainwindow.h"
#include "mainwindow.h"
}
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")));
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()){
}
//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);
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();
}
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();
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();
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)
}
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;"}));