X-Git-Url: http://git.maemo.org/git/?p=mverbiste;a=blobdiff_plain;f=mainwindow.cpp;h=8786183a3a6e247769635995cac1ea06c9f180c1;hp=dbba68b724028be67c36b71a7d69fa7561b4a954;hb=0f544c4b78f242a3ac985c69874c6e41493cb8f0;hpb=6b71b328a4ed0cc4e8236fc27f4dd0dc392e1c34 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); +}