Build with Qt 4.7. Add some debug directives.
authorNguyễn Hồng Quân <ng.hong.quan@gmail.com>
Mon, 29 Oct 2012 09:53:06 +0000 (16:53 +0700)
committerNguyễn Hồng Quân <ng.hong.quan@gmail.com>
Mon, 29 Oct 2012 10:28:46 +0000 (17:28 +0700)
gui/conjugation.cpp
gui/conjugation.h
mainwindow.cpp
mainwindow.h
mverbiste.pro

index b37ed8a..781a76a 100644 (file)
@@ -38,8 +38,14 @@ getConjugation(const FrenchVerbDictionary &fvd,
                         const string &infinitive,
                         const string &tname,
                         VVVS &dest,
+               #ifndef QT_NO_DEBUG
+               QElapsedTimer &timer,
+               #endif
                         bool includePronouns)
 {
+#ifndef QT_NO_DEBUG
+        qDebug() << " *>> Inside getConjugation " << timer.elapsed();
+#endif
     const TemplateSpec *templ = fvd.getTemplate(tname);
     if (templ == NULL)
         return;
index e9111de..411dcc9 100644 (file)
 
 #include <vector>
 #include <string>
-#include <QVector>
-#include <QString>
+#include <QtCore/QVector>
+#include <QtCore/QString>
 
 typedef std::vector<std::string> VS;
 typedef std::vector<VS> VVS;
 typedef std::vector<VVS> VVVS;
 
-
+#ifndef QT_NO_DEBUG
+#include <QtCore/QElapsedTimer>
+#include <QtCore/QDebug>
+#endif
 
 /** Obtains the conjugation of the given infinitive.
     @param  fvd             verb dictionary from which to obtain
@@ -50,6 +53,9 @@ void getConjugation(const verbiste::FrenchVerbDictionary &fvd,
                         const std::string &infinitive,
                         const std::string &tname,
                         VVVS &dest,
+                    #ifndef QT_NO_DEBUG
+                        QElapsedTimer &timer,
+                    #endif
                         bool includePronouns = false);
 
 
index f194fc1..439641c 100644 (file)
@@ -13,7 +13,6 @@ MainWindow::MainWindow(QWidget *parent)
 #endif
     ui->setupUi(this);
     setupcodedUI();
-    initverbiste();
 }
 
 void MainWindow::setupcodedUI()
@@ -104,6 +103,7 @@ void MainWindow::showExpanded()
     show();
 #endif
     wordinput->setFocus();
+    initverbiste();
 }
 
 void  MainWindow::initverbiste()
@@ -144,6 +144,10 @@ void MainWindow::startLookup()
     bool includePronouns = FALSE;    // TODO: Will get this value from external
     bool isItalian = FALSE;          // TODO: Will get this value from external
 
+#ifndef QT_NO_DEBUG
+    timer.start();
+    qDebug() << "Start " << timer.elapsed();
+#endif
     freVerbDic->deconjugate(word, infles);
 
     resultPages->setUpdatesEnabled(false);
@@ -171,7 +175,18 @@ void MainWindow::startLookup()
          */
 
         VVVS conjug;
-        getConjugation(freVerbDic, d.infinitive, d.templateName, conjug, includePronouns);
+#ifndef QT_NO_DEBUG
+        qDebug() << "   START getConjugation " << timer.elapsed();
+#endif
+        getConjugation(freVerbDic, d.infinitive, d.templateName, conjug,
+               #ifndef QT_NO_DEBUG
+                       timer,
+               #endif
+                       includePronouns);
+
+#ifndef QT_NO_DEBUG
+        qDebug() << "   getConjugation() returns: " << timer.elapsed();
+#endif
 
         if (conjug.size() == 0           // if no tenses
             || conjug[0].size() == 0     // if no infinitive tense
@@ -183,8 +198,7 @@ void MainWindow::startLookup()
 
         std::string utf8Infinitive = conjug[0][0][0];
 #ifndef QT_NO_DEBUG
-        qDebug() << "   getConjugation() returns:";
-        qDebug() << "     Infinitive " << utf8Infinitive.c_str() << " at " << timer.elapsed();
+        qDebug() << "     Infinitive " << utf8Infinitive.c_str();
         qDebug() << "     Template " << d.templateName.c_str();
 #endif
 
@@ -211,11 +225,13 @@ void MainWindow::startLookup()
             QVBoxLayout *cell = makeResultCell(*t, utf8TenseName, word, freVerbDic);
             rsp->grid->addLayout(cell, row, col);
         }
+
         /* Show the result on GUI */
         rsp->packContent();
         prevUTF8Infinitive = utf8Infinitive;
         prevTemplateName = d.templateName;
     }
+
     /* Enable the button again */
     btnLookup->setEnabled(true);
     btnLookup->setText("");
index cb38a10..c02a6cb 100644 (file)
@@ -18,8 +18,8 @@
 #include "gui/conjugation.h"
 
 #ifndef QT_NO_DEBUG
-#include <QDebug>
-#include <QElapsedTimer>
+#include <QtCore/QDebug>
+#include <QtCore/QElapsedTimer>
 #endif
 
 using namespace verbiste;
index df50c4c..0e6f13e 100644 (file)
@@ -67,8 +67,11 @@ unix: PKGCONFIG += libxml-2.0
 
 DEFINES += ICONV_CONST=
 
-CONFIG(simulator) {    # Build to run on simulator. This needs the
-    # argument CONFIG+=simulator in the config of "Qt Simulator" target.
+simulator {
+    DEFINES += LIBDATADIR=\\\"$$PWD/data\\\"
+}
+
+simulator {    # Build to run on simulator.
     DEFINES += LIBDATADIR=\\\"$$PWD/data\\\"
 }
 else {