Exit applicazione
[qmemory] / testThread.cpp
index 7c6ba3c..e8d0477 100644 (file)
@@ -6,9 +6,8 @@
 TestThread::TestThread(QObject *parent):QThread(parent){
     colore=0;
     attendiInputUtente=false;
 TestThread::TestThread(QObject *parent):QThread(parent){
     colore=0;
     attendiInputUtente=false;
-
-    _score=0;
     index=0;
     index=0;
+    _score=0;
 
     qsrand(QDateTime::currentDateTime().toTime_t());
 
 
     qsrand(QDateTime::currentDateTime().toTime_t());
 
@@ -16,53 +15,48 @@ TestThread::TestThread(QObject *parent):QThread(parent){
 TestThread::~TestThread(){
 
 }
 TestThread::~TestThread(){
 
 }
-void TestThread::run()
-{
+void TestThread::run(){
     while(true){
     while(true){
-        //msleep(200);
-        qsrand(QDateTime::currentDateTime().toTime_t());
-        sequenza.append(qrand()%9);
-        int i=0;
 
 
-        qDebug()<<"Init Emission";
-        emit disableInterface();
-        while(i<sequenza.size())
-        {
-          qDebug()<<"Init Generate";
-          emit generate(sequenza.at(i));
-          qDebug()<<sequenza.at(i);
-          msleep(500 - (_score*5));
-          emit generate(sequenza.at(i));
-          msleep(500 - (_score*5));
-          i++;
-        }
-        i=0;
-        attendiInputUtente=true;
-        emit enableInterface();
+    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));
+      qDebug()<<sequenza.at(i);
+      msleep(500 - (_score*5));
+      emit generate(sequenza.at(i));
+      msleep(500 - (_score*5));
+      i++;
+    }
+    i=0;
+    attendiInputUtente=true;
+    emit enableInterface();
 
 
-        while(attendiInputUtente){
-            msleep(1);
-        } ;
+    while(attendiInputUtente){
+        msleep(1);
+    }
     }
 
 
 }
 
     }
 
 
 }
 
-void TestThread::updateCaption(int inputUser)
-{
-     qDebug()<<"Entro in update Caption ="<< inputUser<< " valore aspettato" << sequenza.at(index);
-     if (attendiInputUtente){
+void TestThread::updateCaption(int inputUser){
+
+    if(attendiInputUtente){
 
 
-        if(sequenza.at(index) == inputUser)
+        if(sequenza.at(index)==inputUser)
         {
         {
-            if(index == sequenza.size() - 1){
-                qDebug()<<"Entro in if if ="<< inputUser<< " valore aspettato" << sequenza.at(index);
+            index++;
+            _score++;
+
+            if(index==sequenza.size()){
                 attendiInputUtente=false;
                 index=0;
                 attendiInputUtente=false;
                 index=0;
-            }else
-            {
-                index++;
-                _score++;
             }
         }
         else{
             }
         }
         else{
@@ -77,6 +71,7 @@ void TestThread::updateCaption(int inputUser)
 
 void TestThread::genera()
 {
 
 void TestThread::genera()
 {
+        qDebug()<<"Init Emission";
     attendiInputUtente=false;
 
 }
     attendiInputUtente=false;
 
 }