]> Git trees. - qtvoc.git/commitdiff
4th button
authorReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 27 Mar 2010 14:58:59 +0000 (16:58 +0200)
committerReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 27 Mar 2010 14:58:59 +0000 (16:58 +0200)
TinyVocTrainer/tinyvoctrainer.cpp
TinyVocTrainer/tinyvoctrainer.h

index 09433b981e530df6d2e9b95ebc055f3319ae7748..145b3921fed4f0cc2e3a01d78ea26dff4a692f0e 100644 (file)
@@ -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() );
     }
index e6c25c476595537deaaeef00c7586a9cca8ac323..1a91012ab5175c4a3687fca74ea29f14e61c65f9 100644 (file)
@@ -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<KEduVocContainer *>  lessons;
     QList<KEduVocLesson *> lessonsList;
@@ -34,6 +34,7 @@ public:
     QPushButton *answer1;
     QPushButton *answer2;
     QPushButton *answer3;
+    QPushButton *answer4;
     QList<KEduVocExpression *> choiceList;
     QList<QPushButton *> 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);