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

TaskView::TaskView ( QWidget *  parent = 0,
bool  padd_add = true,
bool  padd_div = false,
bool  padd_mult = false,
bool  padd_sub = false,
unsigned int  pnr_ratios = 2,
unsigned int  pmax_md = 10 
) [explicit]

constructor

Definition at line 48 of file taskview.cpp.

References task::create_task().

                                                                   :
    ExerciseBase (parent), m_addAdd (padd_add), m_addDiv (padd_div),
    m_addMult (padd_mult), m_addSub (padd_sub),
    nr_ratios (pnr_ratios), max_md (pmax_md)
{
#ifdef DEBUG
    kDebug() << "constructor TaskView()";
#endif
    curr_nr_ratios = nr_ratios;

    /* create a new task */
    QApplication::setOverrideCursor (Qt::WaitCursor); /* show the sand clock */
    current_task.create_task (max_md, nr_ratios, m_addAdd, m_addDiv, m_addMult, m_addSub);
    QApplication::restoreOverrideCursor(); /* show the normal cursor */

    // to validate, that the input is an int
    KIntValidator *valnum = new KIntValidator (this);

    // the next thing to do on a button click would be to check the entered
    // result
    m_currentState = _CHECK_TASK;

    // Create the base of Widget
    taskWidget = new QWidget (this);
    taskWidget->setObjectName ("taskWidget");
    checkWidget = new QWidget (this);
    checkWidget->setObjectName ("checkWidget");

    baseGrid = new QGridLayout (this);
    baseGrid->setObjectName ("baseGrid");
    baseGrid->setColumnStretch (0, 1);

    baseGrid->addWidget (taskWidget, 0, 0);
    baseGrid->addWidget (checkWidget, 0, 1);

    taskLayout = new QGridLayout (taskWidget);
    taskLayout->setObjectName ("taskLayout");
    taskLayout->setRowStretch (0, 1);
    taskLayout->setRowStretch (4, 1);
    taskLayout->setColumnStretch (0, 1);
    taskLayout->setColumnStretch (5, 1);

    checkLayout = new QGridLayout (checkWidget);
    checkLayout->setObjectName ("checkLayout");

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

    // first left is the task widget
    m_taskWidget = new TaskWidget (taskWidget, current_task);
    m_taskWidget->setObjectName ("m_taskWidget");
    taskLayout->addWidget (m_taskWidget, 1, 1, 3, 1);

    /* add input box so the user can enter the integer par of the fraction */
    integer_edit = new KLineEdit (taskWidget);
    integer_edit->setObjectName ("integer_edit");
    integer_edit->setValidator (valnum);  // use the int validator
    integer_edit->setToolTip (i18n ("Enter the integer part of the fraction"));
    integer_edit->setFont (defaultFont);
    integer_edit->setFixedSize (85, 42);
    integer_edit->setAlignment (Qt::AlignHCenter);
    QObject::connect (integer_edit, SIGNAL (returnPressed (const QString &)), this, SLOT (integerReturnPressed (const QString &)));
    taskLayout->addWidget (integer_edit, 1, 3, 3, 1, Qt::AlignVCenter | Qt::AlignRight);


    /* add input box so the user can enter numerator */
    numer_edit = new KLineEdit (taskWidget);
    numer_edit->setObjectName ("numer_edit");
    numer_edit->setValidator (valnum);  // use the int validator
    numer_edit->setToolTip (i18n ("Enter the numerator of your result"));
    numer_edit->setFont (defaultFont);
    numer_edit->setFixedSize (85, 42);
    numer_edit->setAlignment (Qt::AlignHCenter);
    QObject::connect (numer_edit, SIGNAL (returnPressed (const QString &)), this,
                      SLOT (numeratorReturnPressed (const QString &)));
    taskLayout->addWidget (numer_edit, 1, 4);

    /* add a line between the edit boxes */
    edit_line = new QFrame (taskWidget);
    edit_line->setGeometry (QRect (100, 100, 20, 20));
    edit_line->setFrameStyle (QFrame::HLine | QFrame::Sunken);
    taskLayout->addWidget (edit_line, 2, 4);

    /* add input box so the user can enter denominator */
    deno_edit = new KLineEdit (taskWidget);
    deno_edit->setObjectName ("deno_edit");
    deno_edit->setValidator (valnum);  // use the int validator
    deno_edit->setToolTip (i18n ("Enter the denominator of your result"));
    deno_edit->setFont (defaultFont);
    deno_edit->setFixedSize (85, 42);
    deno_edit->setAlignment (Qt::AlignHCenter);
    QObject::connect (deno_edit, SIGNAL (returnPressed (const QString &)), this,
                      SLOT (denominatorReturnPressed (const QString &)));
    taskLayout->addWidget (deno_edit, 3, 4);

    // next is the result widget
    m_resultWidget = new ResultWidget (checkWidget, ratio());
    m_resultWidget->setObjectName ("m_resultWidget");
    checkLayout->addWidget (m_resultWidget, 0, 0, 1, 2);

    defaultFont.setPointSize (10);

    // the right aligned button
    m_checkButton = new QPushButton (checkWidget);
    m_checkButton->setObjectName ("m_checkButton");
    m_checkButton->setText (i18n ("&Check"));
    m_checkButton->setDefault (true); // is the default button of the dialog
    m_checkButton->setToolTip (i18n ("Click this button to check your result. The button will not work if you have not entered a result yet."));
    m_checkButton->setFont (defaultFont);
    QObject::connect (m_checkButton, SIGNAL (clicked()), this, SLOT (slotCheckButtonClicked()));
    checkLayout->addWidget (m_checkButton, 1, 0);

    // the right aligned button
    m_skipButton = new QPushButton (checkWidget);
    m_skipButton->setObjectName ("m_skipButton");
    m_skipButton->setText (i18n ("&Skip"));
    m_skipButton->setToolTip (i18n ("Click this button to skip this question."));
    m_skipButton->setFont (defaultFont);
    QObject::connect (m_skipButton, SIGNAL (clicked()), this, SLOT (slotSkipButtonClicked()));
    checkLayout->addWidget (m_skipButton, 1, 1);

    // show the whole layout
    m_taskWidget->show();

    // add tooltip and qwhatsthis help to the widget
    setToolTip (i18n ("In this exercise you have to solve a given question with fractions."));
    setWhatsThis (i18n ("In this exercise you have to solve the generated question. You have to enter the integer part of the fraction and the numerator and the denominator. You can adjust the difficulty of the question in the options window part. Do not forget to reduce the result, if the use of the reduced form is forced."));
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index