Piccole modifiche al codice
authorEmmanuel Granatello <emmanuelgranatello@gmail.com>
Mon, 1 Mar 2010 14:42:47 +0000 (15:42 +0100)
committerEmmanuel Granatello <emmanuelgranatello@gmail.com>
Mon, 1 Mar 2010 14:42:47 +0000 (15:42 +0100)
mainwindow.cpp
testThread.cpp
testThread.h

index 3bdfb6d..6bdd621 100644 (file)
@@ -9,9 +9,10 @@ MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent),
     ui(new Ui::MainWindow)
 {
-            bestScore=0;
-            readSettings();
     ui->setupUi(this);
+
+    bestScore=0;
+    readSettings();
     statusLed = new QLed(ui->verticalLayoutWidget);
     ui->horizontalLayout_4->insertWidget(0,statusLed);
 
@@ -25,7 +26,7 @@ MainWindow::MainWindow(QWidget *parent) :
     connect(&tread,SIGNAL(exit(int)),this,SLOT(sbagliato(int)));
     connect(&tread,SIGNAL(disableInterface()),this,SLOT(disableAll()));
     connect(&tread,SIGNAL(enableInterface()),this,SLOT(enableAll()));
-    connect(this,SIGNAL(cliccatoIlBottone(int)),&tread,SLOT(updateCaption(int)));
+    connect(this,SIGNAL(cliccatoIlBottone(int)),&tread,SLOT(addUserInput(int)));
     connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(clickA()));
     connect(ui->pushButton_2,SIGNAL(clicked()),this,SLOT(clickB()));
     connect(ui->pushButton_3,SIGNAL(clicked()),this,SLOT(clickC()));
@@ -58,6 +59,7 @@ MainWindow::MainWindow(QWidget *parent) :
                  "padding-top: 15px;"
                  "}");
     //showMaximized();
+     setWindowTitle(tr("QMemory"));
 }
 void MainWindow::sbagliato(int score){
 
index e3087e1..b41a56e 100644 (file)
@@ -3,52 +3,51 @@
 #include <qdebug.h>
 #include <QMessageBox>
 #include <QDateTime>
-TestThread::TestThread(QObject *parent):QThread(parent){
-    colore=0;
 
+TestThread::TestThread(QObject *parent):QThread(parent)
+{
+    colore=0;
     index=0;
     _score=0;
-
     qsrand(QDateTime::currentDateTime().toTime_t());
 
 }
-TestThread::~TestThread(){
+
+TestThread::~TestThread()
+{
 
 }
 void TestThread::run(){
     sleep(1);
-    while(true){
-    mutex.lock();
-    qsrand(QDateTime::currentDateTime().toTime_t());
-    sequenza.append(qrand()%9);
-    int i=0;
-    index=0;
+    forever{
+        mutex.lock();
 
-    emit disableInterface();
-    while(i<sequenza.size())
-    {
-      emit generate(sequenza.at(i));
-      qDebug()<<sequenza.at(i);
-      msleep(500 - (_score*2));
-      emit generate(sequenza.at(i));
-      msleep(500 - (_score*2));
-      i++;
-    }
-    i=0;
-    emit enableInterface();
-    attendiInputUtente.wait(&mutex);
+        qsrand(QDateTime::currentDateTime().toTime_t());
+        sequenza.append(qrand()%9);
+        int i=0;
+        index=0;
+
+        emit disableInterface();
+        while(i<sequenza.size())
+        {
+          emit generate(sequenza.at(i));
+          msleep(500 - (_score*2));
+          emit generate(sequenza.at(i));
+          msleep(500 - (_score*2));
+          i++;
+        }
+        i=0;
+        emit enableInterface();
+        attendiInputUtente.wait(&mutex);
 
-    mutex.unlock();
+        mutex.unlock();
 
     }
 
 
 }
 
-void TestThread::updateCaption(int inputUser){
-
-
-
+void TestThread::addUserInput(int inputUser){
         if(sequenza.at(index)==inputUser)
         {
             index++;
index b5ad416..7c8a421 100644 (file)
@@ -23,7 +23,7 @@ protected:
     void run();
 
 public slots:
-    void updateCaption(int inputUser);
+    void addUserInput(int inputUser);
     void genera(void);