Can get inflections of verb.
authorNguyễn Hồng Quân <ng.hong.quan@gmail.com>
Sat, 27 Oct 2012 15:44:41 +0000 (22:44 +0700)
committerNguyễn Hồng Quân <ng.hong.quan@gmail.com>
Sat, 27 Oct 2012 15:44:41 +0000 (22:44 +0700)
mainwindow.cpp
mainwindow.h
mverbiste.pro

index dbba68b..8786183 100644 (file)
@@ -3,7 +3,9 @@
 #include "gui/conjugation.h"
 
 #include <QtCore/QCoreApplication>
+#ifdef DEBUG
 #include <QDebug>
+#endif
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent), ui(new Ui::MainWindow)
@@ -52,6 +54,7 @@ void MainWindow::setupcodedUI()
 MainWindow::~MainWindow()
 {
     delete ui;
+    delete freVerbDic;
 }
 
 void MainWindow::setOrientation(ScreenOrientation orientation)
@@ -179,15 +182,21 @@ void MainWindow::startLookup()
 
             int row = i / 4;
             int col = i % 4;
-            qDebug() << row << col;
 
             std::string utf8TenseName = getTenseNameForTableCell(row, col, isItalian);
             if (utf8TenseName.empty())
                 continue;
 
+#ifdef DEBUG
             qDebug() << utf8TenseName.c_str();
+#endif
+            QVBoxLayout *cell = makeResultCell(*t, utf8TenseName, word, freVerbDic);
+            rsp->grid->addLayout(cell, row, col);
+#ifdef DEBUG
+            qDebug() << "Add cell to " << row << col;
+#endif
         }
-
+        rsp->packContent();
         prevUTF8Infinitive = utf8Infinitive;
         prevTemplateName = d.templateName;
     }
@@ -214,11 +223,38 @@ void MainWindow::clearResults()
     wordinput->setFocus();
 }
 
+QVBoxLayout* MainWindow::makeResultCell(const VVS &tenseIterator,
+                                        const std::string &tenseName,
+                                        const std::string &inputWord,
+                                        FrenchVerbDictionary *verbDict)
+{
+    QLabel *tenseLabel = new QLabel();
+    tenseLabel->setText(QString::fromUtf8(tenseName.c_str()));
+    QVBoxLayout *vbox = new QVBoxLayout();
+    vbox->addWidget(tenseLabel);
+    std::string conjugated = createTableCellText(
+                                    *verbDict,
+                                    tenseIterator,
+                                    inputWord,
+                                    "",
+                                    "");
+    QLabel *conjResult = new QLabel();
+    conjResult->setText(QString::fromUtf8(conjugated.c_str()));
+    vbox->addWidget(conjResult);
+    return vbox;
+}
+
 /**** For ResultPage class ****/
 ResultPage::ResultPage()
     : page(new QScrollArea),
-      table(new QTableWidget)
+      grid(new QGridLayout)
 {
 }
 
+void ResultPage::packContent()
+{
+    QWidget *immediate = new QWidget();
+    immediate->setLayout(grid);
+    page->setWidget(immediate);
+}
 
index e3d5502..d09491d 100644 (file)
@@ -27,10 +27,14 @@ class ResultPage
 {
 public:
     QScrollArea *page;
-    QTableWidget *table;
+    QGridLayout *grid;
 
     ResultPage();
     // No destructor because this object does not own the two widgets.
+    void packContent();
+
+private:
+    QWidget *immediate;
 };
 
 class MainWindow : public QMainWindow
@@ -54,6 +58,10 @@ public:
 
     void showExpanded();
     void initverbiste();
+    QVBoxLayout* makeResultCell(const VVS &tenseIterator,
+                                     const std::string &tenseName,
+                                     const std::string &inputWord,
+                                     FrenchVerbDictionary *verbDict);
 
 public slots:
     void startLookup();
index 24554c8..bd51e44 100644 (file)
@@ -68,3 +68,7 @@ unix: PKGCONFIG += libxml-2.0
 DEFINES += ICONV_CONST=
 # installPrefix must be explicitly exported from deployment.pri first
 DEFINES += LIBDATADIR=\\\"$${installPrefix}/data\\\"
+
+CONFIG(debug) {
+    DEFINES += DEBUG
+}