From 01ccba50f56bb2d9bb06efb3bcca04484a94ab79 Mon Sep 17 00:00:00 2001 From: Reto Zingg Date: Sat, 27 Mar 2010 16:58:59 +0200 Subject: [PATCH] 4th button --- TinyVocTrainer/tinyvoctrainer.cpp | 81 ++++++++++++++++++------------- TinyVocTrainer/tinyvoctrainer.h | 8 +-- 2 files changed, 53 insertions(+), 36 deletions(-) diff --git a/TinyVocTrainer/tinyvoctrainer.cpp b/TinyVocTrainer/tinyvoctrainer.cpp index 09433b9..145b392 100644 --- a/TinyVocTrainer/tinyvoctrainer.cpp +++ b/TinyVocTrainer/tinyvoctrainer.cpp @@ -17,9 +17,9 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent) srand(time(NULL)); QVBoxLayout *vbox = new QVBoxLayout(); - QHBoxLayout *hbox_less = new QHBoxLayout(); - QHBoxLayout *hbox_question_lang = new QHBoxLayout(); - QHBoxLayout *hbox_answer_lang = new QHBoxLayout(); +// QHBoxLayout *hbox_less = new QHBoxLayout(); +// QHBoxLayout *hbox_question_lang = new QHBoxLayout(); +// QHBoxLayout *hbox_answer_lang = new QHBoxLayout(); QVBoxLayout *vbox_label = new QVBoxLayout(); QHBoxLayout *hbox_buttons = new QHBoxLayout(); @@ -27,10 +27,10 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent) hbox_buttons->addWidget(button); connect(button, SIGNAL(clicked(bool)), this, SLOT(slotSettings(bool))); - - QComboBox *combox_lesson = new QComboBox(); - QComboBox *combox_question = new QComboBox(); - QComboBox *combox_answer = new QComboBox(); +// +// QComboBox *combox_lesson = new QComboBox(); +// QComboBox *combox_question = new QComboBox(); +// QComboBox *combox_answer = new QComboBox(); bgroup_choice = new QButtonGroup(); QuestionLabel = new QLabel(); @@ -40,36 +40,46 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent) answer1 = new QPushButton; answer2 = new QPushButton; answer3 = new QPushButton; + answer4 = new QPushButton; + vbox_label->addWidget(answer1); vbox_label->addWidget(answer2); vbox_label->addWidget(answer3); + vbox_label->addWidget(answer4); + answerButtonsList.append(answer1); answerButtonsList.append(answer2); answerButtonsList.append(answer3); + answerButtonsList.append(answer4); + bgroup_choice->addButton(answer1); - bgroup_choice->setId(answer1, 0); bgroup_choice->addButton(answer2); - bgroup_choice->setId(answer2, 1); bgroup_choice->addButton(answer3); + bgroup_choice->addButton(answer4); + + bgroup_choice->setId(answer1, 0); + bgroup_choice->setId(answer2, 1); bgroup_choice->setId(answer3, 2); + bgroup_choice->setId(answer4, 3); connect(answer1,SIGNAL(clicked(bool)),this,SLOT(slotAnswer1(bool))); connect(answer2,SIGNAL(clicked(bool)),this,SLOT(slotAnswer2(bool))); connect(answer3,SIGNAL(clicked(bool)),this,SLOT(slotAnswer3(bool))); + connect(answer4,SIGNAL(clicked(bool)),this,SLOT(slotAnswer4(bool))); questionID = 0; answerID = 0; lessonID = 0; CorrectID = 0; - QLabel *label_question = new QLabel("Question:"); - hbox_question_lang->addWidget(label_question); - - QLabel *label_answer = new QLabel("Answer:"); - hbox_answer_lang->addWidget(label_answer); - - QLabel *label_lesson = new QLabel("Lesson:"); - hbox_less->addWidget(label_lesson); +// QLabel *label_question = new QLabel("Question:"); +// hbox_question_lang->addWidget(label_question); +// +// QLabel *label_answer = new QLabel("Answer:"); +// hbox_answer_lang->addWidget(label_answer); +// +// QLabel *label_lesson = new QLabel("Lesson:"); +// hbox_less->addWidget(label_lesson); QStringList args = QApplication::arguments(); args.removeFirst(); @@ -79,18 +89,18 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent) lessons = docRead->lesson()->childContainers(); - for (int i = 0; i < docRead->identifierCount(); ++i) - { - combox_question->insertItem(i, docRead->identifier(i).name(), NULL); - combox_answer->insertItem(i, docRead->identifier(i).name(), NULL); - } +// for (int i = 0; i < docRead->identifierCount(); ++i) +// { +// combox_question->insertItem(i, docRead->identifier(i).name(), NULL); +// combox_answer->insertItem(i, docRead->identifier(i).name(), NULL); +// } - connect(combox_question,SIGNAL(currentIndexChanged(int)),this,SLOT(reactToToggleQuestion(int))); - connect(combox_answer,SIGNAL(currentIndexChanged(int)),this,SLOT(reactToToggleAnswer(int))); - combox_question->setCurrentIndex(0); - combox_answer->setCurrentIndex(1); - hbox_question_lang->addWidget(combox_question); - hbox_answer_lang->addWidget(combox_answer); +// connect(combox_question,SIGNAL(currentIndexChanged(int)),this,SLOT(reactToToggleQuestion(int))); +// connect(combox_answer,SIGNAL(currentIndexChanged(int)),this,SLOT(reactToToggleAnswer(int))); +// combox_question->setCurrentIndex(0); +// combox_answer->setCurrentIndex(1); +// hbox_question_lang->addWidget(combox_question); +// hbox_answer_lang->addWidget(combox_answer); int lessonId = 0; foreach(KEduVocContainer * c, lessons) { @@ -100,14 +110,14 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent) m_lesson = lessonsList.last() ; qDebug () << "Lesson: " << m_lesson->name(); - combox_lesson->insertItem(lessonId, m_lesson->name(), NULL); +// combox_lesson->insertItem(lessonId, m_lesson->name(), NULL); } ++lessonId; } - connect(combox_lesson,SIGNAL(currentIndexChanged(int)),this,SLOT(reactToToggleLesson(int))); - combox_lesson->setCurrentIndex(0); - hbox_less->addWidget(combox_lesson); +// connect(combox_lesson,SIGNAL(currentIndexChanged(int)),this,SLOT(reactToToggleLesson(int))); +// combox_lesson->setCurrentIndex(0); +// hbox_less->addWidget(combox_lesson); // vbox->addLayout(hbox_less); // vbox->addLayout(hbox_question_lang); @@ -175,6 +185,11 @@ void TinyVocTrainer::slotAnswer3(bool clicked){ slotCheck(2); } +void TinyVocTrainer::slotAnswer4(bool clicked){ + Q_UNUSED(clicked); + slotCheck(3); +} + void TinyVocTrainer::slotCheck(int buttonID){ qDebug() << "slotCheck(): buton id: " << buttonID << "Correct Id: " << CorrectID; @@ -194,7 +209,7 @@ void TinyVocTrainer::slotInit(bool clicked){ Q_UNUSED(clicked); choiceList.clear(); - for (int i=0; i < 3; ++i){ + for (int i=0; i < 4; ++i){ choiceList.append( getAnyEntryFromLesson(lessonsList.at(lessonID), questionID) ); answerButtonsList.at(i)->setText( choiceList.at(i)->translation(questionID)->text() ); } diff --git a/TinyVocTrainer/tinyvoctrainer.h b/TinyVocTrainer/tinyvoctrainer.h index e6c25c4..1a91012 100644 --- a/TinyVocTrainer/tinyvoctrainer.h +++ b/TinyVocTrainer/tinyvoctrainer.h @@ -23,9 +23,9 @@ public: ~TinyVocTrainer(); KEduVocExpression * getAnyEntryFromLesson(KEduVocLesson *lesson = 0, int language = 0); - QButtonGroup *bgroup_lesson; - QButtonGroup *bgroup_question_lang; - QButtonGroup *bgroup_answer_lang; +// QButtonGroup *bgroup_lesson; +// QButtonGroup *bgroup_question_lang; +// QButtonGroup *bgroup_answer_lang; QButtonGroup *bgroup_choice; QList lessons; QList lessonsList; @@ -34,6 +34,7 @@ public: QPushButton *answer1; QPushButton *answer2; QPushButton *answer3; + QPushButton *answer4; QList choiceList; QList answerButtonsList; @@ -53,6 +54,7 @@ private slots: void slotAnswer1(bool clicked = 0); void slotAnswer2(bool clicked = 0); void slotAnswer3(bool clicked = 0); + void slotAnswer4(bool clicked = 0); void slotInit(bool clicked = 0); void slotSettings(bool clicked = 0); -- 2.47.3