]> Git trees. - qtvoc.git/commitdiff
use combo-boxes instead of radio version-0.0.2-combo
authorReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 27 Mar 2010 12:49:25 +0000 (14:49 +0200)
committerReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 27 Mar 2010 12:49:25 +0000 (14:49 +0200)
TinyVocTrainer/TinyVocTrainer.pro
TinyVocTrainer/tinyvoctrainer.cpp
TinyVocTrainer/tinyvoctrainer.h

index 16cf80c3993d26206a95fe3ef427ab4fe0164a06..407a95ef5e952327ab6390a19bec141ce1a8148c 100644 (file)
@@ -12,5 +12,7 @@ INCLUDEPATH += . \
 QMAKE_LFLAGS += -Wl,-rpath,../lib
 SOURCES += main.cpp \
     tinyvoctrainer.cpp
+#    tinyvoctrainersettings.cpp
 HEADERS += tinyvoctrainer.h
+#    tinyvoctrainersettings.h
 FORMS += 
index c17e7563e7233ad538f5b8cbf8058070bceb264f..b9fcc29ad62971ed3ba387bec38346979f1f05f5 100644 (file)
@@ -9,6 +9,7 @@
 #include <QList>
 #include <QRadioButton>
 #include <QPushButton>
+#include <QComboBox>
 
 TinyVocTrainer::TinyVocTrainer(QWidget *parent)
     : QWidget(parent)
@@ -26,9 +27,10 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent)
     hbox_buttons->addWidget(button);
     connect(button, SIGNAL(clicked(bool)), this, SLOT(slotInit(bool)));
 
-    bgroup_lesson = new QButtonGroup();
-    bgroup_question_lang = new QButtonGroup();
-    bgroup_answer_lang =  new QButtonGroup();
+
+    QComboBox *combox_lesson = new QComboBox();
+    QComboBox *combox_question = new QComboBox();
+    QComboBox *combox_answer = new QComboBox();
     bgroup_choice =  new QButtonGroup();
 
     QuestionLabel = new QLabel();
@@ -79,24 +81,16 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent)
 
     for (int i = 0; i < docRead->identifierCount(); ++i)
     {
-        QRadioButton *radio_question_lang = new QRadioButton(docRead->identifier(i).name());
-        QRadioButton *radio_answer_lang = new QRadioButton(docRead->identifier(i).name());
-
-        bgroup_question_lang->addButton(radio_question_lang);
-        bgroup_answer_lang->addButton(radio_answer_lang);
-
-        bgroup_question_lang->setId(radio_question_lang, i);
-        bgroup_answer_lang->setId(radio_answer_lang, i);
-
-        hbox_question_lang->addWidget(radio_question_lang);
-        hbox_answer_lang->addWidget(radio_answer_lang);
-
-        connect(radio_question_lang, SIGNAL(toggled(bool)), this, SLOT(reactToToggleQuestionLang(bool)));
-        connect(radio_answer_lang, SIGNAL(toggled(bool)), this, SLOT(reactToToggleAnswerLang(bool)));
+        combox_question->insertItem(i, docRead->identifier(i).name(), NULL);
+        combox_answer->insertItem(i, docRead->identifier(i).name(), NULL);
     }
 
-    bgroup_question_lang->button(0)->click();;
-    bgroup_answer_lang->button(1)->click();
+    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) {
@@ -105,21 +99,15 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent)
                 KEduVocLesson *m_lesson;
                 m_lesson = lessonsList.last() ;
                 qDebug () << "Lesson: " << m_lesson->name();
-                QRadioButton *radio_less = new QRadioButton(m_lesson->name());
-
-                bgroup_lesson->addButton(radio_less);
-                bgroup_lesson->setId(radio_less, lessonId);
 
-                hbox_less->addWidget(radio_less);
-
-                connect(radio_less, SIGNAL(toggled(bool)), this, SLOT(reactToToggleLesson(bool)));
-
-// qDebug() << "Return rand Entry: " << getAnyEntryFromLesson(m_lesson,1);
+                combox_lesson->insertItem(lessonId, m_lesson->name(), NULL);
         }
         ++lessonId;
     }
 
-    bgroup_lesson->button(0)->click();
+    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);
@@ -146,33 +134,24 @@ KEduVocExpression * TinyVocTrainer::getAnyEntryFromLesson(KEduVocLesson *lesson,
 
 
 
-void TinyVocTrainer::reactToToggleQuestionLang(bool checked)
-{
-    if(checked){   
-        qDebug() << "bgroup_question_lang: " << bgroup_question_lang->checkedId();
-        questionID = bgroup_question_lang->checkedId();
-        // slotInit();
-    }
+void TinyVocTrainer::reactToToggleQuestion(int id)
+{ 
+    qDebug() << "Toggle Question: " << id;
+    questionID = id;
 }
 
 
-void TinyVocTrainer::reactToToggleAnswerLang(bool checked)
+void TinyVocTrainer::reactToToggleAnswer(int id)
 {
-    if(checked){
-        qDebug() << "bgroup_answer_lang: " << bgroup_answer_lang->checkedId();
-        answerID = bgroup_answer_lang->checkedId();
-        // slotInit();
-    }
+    qDebug() << "Toggle Answer: " << id;
+    answerID = id;
 }
 
 
-void TinyVocTrainer::reactToToggleLesson(bool checked)
+void TinyVocTrainer::reactToToggleLesson(int id)
 {
-    if(checked){
-        qDebug() << "bgroup_lesson: " << bgroup_lesson->checkedId();
-        lessonID = bgroup_lesson->checkedId();
-        // slotInit();
-    }
+    qDebug() << "Toggle Lesson: " << id;
+    lessonID = id;
 }
 
 void TinyVocTrainer::slotAnswer1(bool clicked){
index cdec9509359269893c2154f244fc43e7aea3be37..b5835198a330061c5936c1ad3edcfd14647456ef 100644 (file)
@@ -42,9 +42,9 @@ public:
     int CorrectID;
 
 private slots:
-    void reactToToggleQuestionLang(bool checked = 0);
-    void reactToToggleAnswerLang(bool checked = 0);
-    void reactToToggleLesson(bool checked = 0);
+    void reactToToggleQuestion(int id = 0);
+    void reactToToggleAnswer(int id = 0);
+    void reactToToggleLesson(int id = 0);
     void slotCheck(int buttonID = 0);
     void slotAnswer1(bool clicked = 0);
     void slotAnswer2(bool clicked = 0);