Logo Search packages:      
Sourcecode: kbruch version File versions  Download package

MainQtWidget::MainQtWidget (  )

constructor

Definition at line 74 of file mainqtwidget.cpp.

References m_exerciseCompare, m_exerciseConvert, m_exerciseFactorize, m_exerciseMixedNumbers, m_exercisePercentage, m_statview, m_taskview, readOptions(), ReducedFormCheckSlot(), and SelectArithmetic().

{
#ifdef DEBUG
    kDebug() << "constructor MainQtWidget";
#endif

    // get the settings
    readOptions();

    // creating KActions, used by the kbruchui.rc file
    setupActions();

    setCaption (i18n ("Exercise"));

    // Create layout
    QGridLayout * layoutExercises = new QGridLayout();
    layoutExercises->setObjectName ("layoutExercises");
    layoutExercises->setRowStretch (2, 1);
    QGridLayout * layoutOptions = new QGridLayout();
    layoutOptions->setObjectName ("layoutOptions");
    layoutOptions->setRowStretch (0, 1);
    layoutOptions->setRowStretch (6, 1);
    QGridLayout * layoutQuestion = new QGridLayout();
    layoutQuestion->setObjectName ("layoutQuestion");
    layoutQuestion->setColumnMinimumWidth (0, 110);
    layoutQuestion->setColumnStretch (1, 1);
    QGridLayout * layoutAnswer = new QGridLayout();
    layoutAnswer->setObjectName ("layoutAnswer");
    layoutAnswer->setColumnMinimumWidth (0, 110);
    layoutAnswer->setColumnStretch (1, 1);
    QGridLayout * layoutOperations = new QGridLayout();
    layoutOperations->setObjectName ("layoutOperations");
    layoutOperations->setColumnMinimumWidth (0, 110);
    layoutOperations->setColumnStretch (1, 1);

    QSplitter* splitter = new QSplitter (Qt::Horizontal, this);
    splitter->setObjectName ("QSplitter");
    setCentralWidget (splitter);

    QWidget * pageExercises = new QWidget();
    QWidget * pageOptions = new QWidget();

    // Create visible components
    m_QuestionGroup = new QGroupBox (i18n ("Question:"), pageOptions);
    m_AnswerGroup = new QGroupBox (i18n ("Answer:"), pageOptions);
    m_OperationsGroup = new QGroupBox (i18n ("Operations:"), pageOptions);

    defaultFont = SettingsClass::taskFont();
    defaultFont.setBold (true);
    defaultFont.setPointSize (14);

    m_TitleLabel = new QLabel (i18n ("Arithmetic"), pageExercises);
    m_TitleLabel->setAlignment (Qt::AlignLeft);
    m_TitleLabel->setFont (defaultFont);
    m_TitleLabel->setFixedHeight (35);
    m_TitleLabel->setAlignment (Qt::AlignVCenter);

    m_statview = new StatisticsView;
    m_statview->setObjectName ("StatisticsView");
    m_statview->setFixedHeight (120);

    m_footerline = new QFrame (pageExercises);
    m_footerline->setGeometry (QRect (pageExercises->width(), 100, 20, 20));
    m_footerline->setFrameStyle (QFrame::HLine | QFrame::Sunken);

    m_headerline = new QFrame (pageExercises);
    m_headerline->setGeometry (QRect (pageExercises->width(), 100, 20, 20));
    m_headerline->setFrameStyle (QFrame::HLine | QFrame::Sunken);

    m_taskview = new TaskView (pageExercises, m_addAdd, m_addDiv, m_addMult, m_addSub, m_nrRatios, m_maxMainDenominator);
    m_taskview->setObjectName ("TaskView");
    m_taskview->hide();

    m_exerciseCompare = new ExerciseCompare (pageExercises);
    m_exerciseCompare->setObjectName ("ExerciseCompare");
    m_exerciseCompare->hide();

    m_exerciseConvert = new ExerciseConvert (pageExercises);
    m_exerciseConvert->setObjectName ("ExerciseConvert");
    m_exerciseConvert->hide();

    m_exerciseMixedNumbers = new ExerciseMixedNumbers (pageExercises);
    m_exerciseMixedNumbers->setObjectName ("ExerciseMixedNumbers");
    m_exerciseMixedNumbers->hide();

    m_exerciseFactorize = new ExerciseFactorize (pageExercises);
    m_exerciseFactorize->setObjectName ("ExerciseFactorize");
    m_exerciseFactorize->hide();

    m_exercisePercentage = new ExercisePercentage (pageExercises);
    m_exercisePercentage->setObjectName ("ExercisePercentage");
    m_exercisePercentage->hide();

    m_OptionsLabel = new QLabel (i18n ("Options:"), pageOptions);
    m_OptionsLabel->setToolTip (i18n ("Set the options to solve the exercises."));
    m_OptionsLabel->setWhatsThis (i18n ("This part of the window shows the options to solve the exercises. Use the handle between the options and main window to change the size of this window part or to hide it by moving the handle to the left border of the main window."));
    m_OptionsLabel->setObjectName ("OptionsLabel");
    m_OptionsLabel->setFont (defaultFont);

    m_QuestionMixedLabel = new QLabel (i18n ("Mixed number:"), pageOptions);
    m_QuestionMixedLabel->setToolTip (i18n ("Set if the fractions will appear as mixed numbers or not in the question expression (mixed number example: 1 4/5 = 9/5 )."));
    m_QuestionMixedLabel->setObjectName ("QuestionMixedLabel");
    m_QuestionMixedLabel->setAlignment (Qt::AlignRight);

    m_QuestionMixedCheck = new QCheckBox (pageOptions);
    m_QuestionMixedCheck->setObjectName ("QuestionMixedCheck");
    m_QuestionMixedCheck->setChecked (m_questionMixed);
    m_taskview->setQuestionMixed (m_questionMixed);
    QObject::connect (m_QuestionMixedCheck, SIGNAL (stateChanged (int)), this, SLOT (QuestionMixedCheckSlot()));

    m_AnswerMixedLabel = new QLabel (i18n ("Mixed number:"), pageOptions);
    m_AnswerMixedLabel->setToolTip (i18n ("Set if the fractions will appear as mixed numbers or not in the answer (mixed number example: 1 4/5 = 9/5 )."));
    m_AnswerMixedLabel->setObjectName ("AnswerMixedLabel");
    m_AnswerMixedLabel->setAlignment (Qt::AlignRight);

    m_AnswerMixedCheck = new QCheckBox (pageOptions);
    m_AnswerMixedCheck->setObjectName ("AnswerMixedCheck");
    m_AnswerMixedCheck->setChecked (m_answerMixed);
    m_taskview->setAnswerMixed (m_answerMixed);
    QObject::connect (m_AnswerMixedCheck, SIGNAL (stateChanged (int)), this, SLOT (AnswerMixedCheckSlot()));

    m_AdditionLabel = new QLabel (i18n ("Addition:"), pageOptions);
    m_AdditionLabel->setToolTip (i18n ("Check this to use addition operator."));
    m_AdditionLabel->setObjectName ("AdditionLabel");
    m_AdditionLabel->setAlignment (Qt::AlignRight);

    m_AdditionCheck = new QCheckBox (pageOptions);
    m_AdditionCheck->setObjectName ("AdditionCheck");
    m_AdditionCheck->setChecked (m_addAdd);
    QObject::connect (m_AdditionCheck, SIGNAL (stateChanged (int)), this, SLOT (AdditionCheckSlot()));

    m_SubtractionLabel = new QLabel (i18n ("Subtraction:"), pageOptions);
    m_SubtractionLabel->setToolTip (i18n ("Check this to use subtraction operator."));
    m_SubtractionLabel->setObjectName ("SubtractionLabel");
    m_SubtractionLabel->setAlignment (Qt::AlignRight);

    m_SubtractionCheck = new QCheckBox (pageOptions);
    m_SubtractionCheck->setObjectName ("SubtractionCheck");
    m_SubtractionCheck->setChecked (m_addSub);
    QObject::connect (m_SubtractionCheck, SIGNAL (stateChanged (int)), this, SLOT (SubtractionCheckSlot()));

    m_MultiplicationLabel = new QLabel (i18n ("Multiplication:"), pageOptions);
    m_MultiplicationLabel->setToolTip (i18n ("Check this to use multiplication operator."));
    m_MultiplicationLabel->setObjectName ("MultiplicationLabel");
    m_MultiplicationLabel->setAlignment (Qt::AlignRight);

    m_MultiplicationCheck = new QCheckBox (pageOptions);
    m_MultiplicationCheck->setObjectName ("MultiplicationCheck");
    m_MultiplicationCheck->setChecked (m_addMult);
    QObject::connect (m_MultiplicationCheck, SIGNAL (stateChanged (int)), this, SLOT (MultiplicationCheckSlot()));

    m_DivisionLabel = new QLabel (i18n ("Division:"), pageOptions);
    m_DivisionLabel->setToolTip (i18n ("Check this to use division operator."));
    m_DivisionLabel->setObjectName ("DivisionLabel");
    m_DivisionLabel->setAlignment (Qt::AlignRight);

    m_DivisionCheck = new QCheckBox (pageOptions);
    m_DivisionCheck->setObjectName ("DivisionCheck");
    m_DivisionCheck->setChecked (m_addDiv);
    QObject::connect (m_DivisionCheck, SIGNAL (stateChanged (int)), this, SLOT (DivisionCheckSlot()));

    m_ReducedLabel = new QLabel (i18n ("Reduced form:"), pageOptions);
    m_ReducedLabel->setToolTip (i18n ("Check this to force the use of the reduced form."));
    m_ReducedLabel->setObjectName ("ReducedLabel");
    m_ReducedLabel->setAlignment (Qt::AlignRight);

    m_ReducedCheck = new QCheckBox (pageOptions);
    m_ReducedCheck->setObjectName ("ReducedCheck");
    m_ReducedCheck->setChecked (m_reducedForm);
    m_taskview->setReducedForm (m_reducedForm);
    QObject::connect (m_ReducedCheck, SIGNAL (stateChanged (int)), this, SLOT (ReducedFormCheckSlot()));

    m_NrOfTermsLabel = new QLabel (i18n ("Number of terms:"), pageOptions);
    m_NrOfTermsLabel->setToolTip (i18n ("The number of \nterms you want"));
    m_NrOfTermsLabel->setObjectName ("NrOfTermsLabel");
    m_NrOfTermsLabel->setAlignment (Qt::AlignRight);

    m_NrOfTermsBox = new KComboBox (pageOptions);
    m_NrOfTermsBox->addItem ("2");
    m_NrOfTermsBox->addItem ("3");
    m_NrOfTermsBox->addItem ("4");
    m_NrOfTermsBox->addItem ("5");
    m_NrOfTermsBox->setCurrentIndex (m_nrRatios - 2);
    m_NrOfTermsBox->setToolTip (i18n ("The number of \nterms you want"));
    m_NrOfTermsBox->setWhatsThis (i18n ("Choose the number of terms (2, 3, 4 or 5) you \nwant for calculating fractions."));
    QObject::connect (m_NrOfTermsBox, SIGNAL (activated (int)), this, SLOT (NrOfTermsBoxSlot()));

    m_MaxMainDenominatorLabel = new QLabel (i18n ("Maximum denominator:"), pageOptions);
    m_MaxMainDenominatorLabel->setObjectName ("MaxMainDenominatorLabel");
    m_MaxMainDenominatorLabel->setAlignment (Qt::AlignRight);
    m_MaxMainDenominatorLabel->setWordWrap (true);

    m_MaxMainDenominatorBox = new KComboBox (pageOptions);
    m_MaxMainDenominatorBox->addItem ("10");
    m_MaxMainDenominatorBox->addItem ("20");
    m_MaxMainDenominatorBox->addItem ("30");
    m_MaxMainDenominatorBox->addItem ("50");
    m_MaxMainDenominatorBox->setToolTip (i18n ("The maximum number you can have as main denominator"));
    m_MaxMainDenominatorBox->setWhatsThis (i18n ("Choose the number which will be the maximum for the main denominator: 10, 20, 30, 40 or 50."));
    switch (m_maxMainDenominator) {
    case 10 :
        m_MaxMainDenominatorBox->setCurrentIndex (0);
        break;
    case 20 :
        m_MaxMainDenominatorBox->setCurrentIndex (1);
        break;
    case 30 :
        m_MaxMainDenominatorBox->setCurrentIndex (2);
        break;
    case 50 :
        m_MaxMainDenominatorBox->setCurrentIndex (3);
        break;
    }
    QObject::connect (m_MaxMainDenominatorBox, SIGNAL (activated (int)), this, SLOT (MaxMainDenominatorBoxSlot()));


    layoutExercises->addWidget (m_TitleLabel, 0, 0);
    layoutExercises->addWidget (m_headerline, 1, 0);
    layoutExercises->addWidget (m_taskview, 2, 0);
    layoutExercises->addWidget (m_exerciseCompare, 2, 0);
    layoutExercises->addWidget (m_exerciseConvert, 2, 0);
    layoutExercises->addWidget (m_exerciseMixedNumbers, 2, 0);
    layoutExercises->addWidget (m_exerciseFactorize, 2, 0);
    layoutExercises->addWidget (m_exercisePercentage, 2, 0);
    layoutExercises->addWidget (m_footerline, 3, 0);
    layoutExercises->addWidget (m_statview, 4, 0);

    layoutOptions->addWidget (m_OptionsLabel, 1, 0);
    layoutOptions->addWidget (m_QuestionGroup, 2, 0);
    layoutOptions->addWidget (m_AnswerGroup, 3, 0);
    layoutOptions->addWidget (m_OperationsGroup, 5, 0);

    layoutQuestion->addWidget (m_QuestionMixedLabel, 0, 0);
    layoutQuestion->addWidget (m_QuestionMixedCheck, 0, 1);
    layoutQuestion->addWidget (m_NrOfTermsLabel, 1, 0);
    layoutQuestion->addWidget (m_NrOfTermsBox, 1, 1);
    layoutQuestion->addWidget (m_MaxMainDenominatorLabel, 2, 0);
    layoutQuestion->addWidget (m_MaxMainDenominatorBox, 2, 1);

    layoutAnswer->addWidget (m_AnswerMixedLabel, 0, 0);
    layoutAnswer->addWidget (m_AnswerMixedCheck, 0, 1);
    layoutAnswer->addWidget (m_ReducedLabel, 1, 0);
    layoutAnswer->addWidget (m_ReducedCheck, 1, 1);

    layoutOperations->addWidget (m_AdditionLabel, 0, 0);
    layoutOperations->addWidget (m_AdditionCheck, 0, 1);
    layoutOperations->addWidget (m_SubtractionLabel, 1, 0);
    layoutOperations->addWidget (m_SubtractionCheck, 1, 1);
    layoutOperations->addWidget (m_MultiplicationLabel, 2, 0);
    layoutOperations->addWidget (m_MultiplicationCheck, 2, 1);
    layoutOperations->addWidget (m_DivisionLabel, 3, 0);
    layoutOperations->addWidget (m_DivisionCheck, 3, 1);

    m_QuestionGroup->setLayout (layoutQuestion);
    m_AnswerGroup->setLayout (layoutAnswer);
    m_OperationsGroup->setLayout (layoutOperations);

    // set layouts to both parts
    pageOptions->setLayout (layoutOptions);
    pageExercises->setLayout (layoutExercises);

    // preventing resizing of left sidebar
    pageOptions->setFixedWidth (pageOptions->sizeHint().width());

    // add left and right part to the splitter
    splitter->addWidget (pageOptions);
    splitter->addWidget (pageExercises);

    // connect signals of the exercises and StatisticView, so that StatisticView
    // gets informed about how the user solved a given task (wrong or correct)
    QObject::connect (m_taskview, SIGNAL (signalTaskSolvedCorrect()), m_statview, SLOT (addCorrect()));
    QObject::connect (m_taskview, SIGNAL (signalTaskSkipped()), m_statview, SLOT (addSkipped()));
    QObject::connect (m_taskview, SIGNAL (signalTaskSolvedWrong()), m_statview, SLOT (addWrong()));
    QObject::connect (m_exerciseCompare, SIGNAL (signalExerciseSolvedCorrect()), m_statview, SLOT (addCorrect()));
    QObject::connect (m_exerciseCompare, SIGNAL (signalExerciseSkipped()), m_statview, SLOT (addSkipped()));
    QObject::connect (m_exerciseCompare, SIGNAL (signalExerciseSolvedWrong()), m_statview, SLOT (addWrong()));
    QObject::connect (m_exerciseConvert, SIGNAL (signalExerciseSolvedCorrect()), m_statview, SLOT (addCorrect()));
    QObject::connect (m_exerciseConvert, SIGNAL (signalExerciseSkipped()), m_statview, SLOT (addSkipped()));
    QObject::connect (m_exerciseConvert, SIGNAL (signalExerciseSolvedWrong()), m_statview, SLOT (addWrong()));
    QObject::connect (m_exerciseMixedNumbers, SIGNAL (signalExerciseSolvedCorrect()), m_statview, SLOT (addCorrect()));
    QObject::connect (m_exerciseMixedNumbers, SIGNAL (signalExerciseSkipped()), m_statview, SLOT (addSkipped()));
    QObject::connect (m_exerciseMixedNumbers, SIGNAL (signalExerciseSolvedWrong()), m_statview, SLOT (addWrong()));
    QObject::connect (m_exerciseFactorize, SIGNAL (signalExerciseSolvedCorrect()), m_statview, SLOT (addCorrect()));
    QObject::connect (m_exerciseFactorize, SIGNAL (signalExerciseSkipped()), m_statview, SLOT (addSkipped()));
    QObject::connect (m_exerciseFactorize, SIGNAL (signalExerciseSolvedWrong()), m_statview, SLOT (addWrong()));
    QObject::connect (m_exercisePercentage, SIGNAL (signalExerciseSolvedCorrect()), m_statview, SLOT (addCorrect()));
    QObject::connect (m_exercisePercentage, SIGNAL (signalExerciseSkipped()), m_statview, SLOT (addSkipped()));
    QObject::connect (m_exercisePercentage, SIGNAL (signalExerciseSolvedWrong()), m_statview, SLOT (addWrong()));

    // Get and set the page of last exercise
    selectedTask = (ExerciseType) SettingsClass::activeExercise();
    switch (selectedTask) {
    case Arithmetic:
        SelectArithmetic();
        break;
    case Comparison:
        SelectComparison();
        break;
    case Conversion:
        SelectConversion();
        break;
    case Factorization:
        SelectFactorization();
        break;
    case Percentage:
        SelectPercentage();
        break;
    default:
        SelectArithmetic();
        break;
    }
    move (50, 50);
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index