From 0f544c4b78f242a3ac985c69874c6e41493cb8f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?= Date: Sat, 27 Oct 2012 22:44:41 +0700 Subject: [PATCH] Can get inflections of verb. --- mainwindow.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- mainwindow.h | 10 +++++++++- mverbiste.pro | 4 ++++ 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index dbba68b..8786183 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -3,7 +3,9 @@ #include "gui/conjugation.h" #include +#ifdef DEBUG #include +#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); +} diff --git a/mainwindow.h b/mainwindow.h index e3d5502..d09491d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -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(); diff --git a/mverbiste.pro b/mverbiste.pro index 24554c8..bd51e44 100644 --- a/mverbiste.pro +++ b/mverbiste.pro @@ -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 +} -- 1.7.9.5