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

ExerciseConvert::ExerciseConvert ( QWidget *  parent = 0 )


Definition at line 50 of file exerciseconvert.cpp.

    ExerciseBase (parent)
#ifdef DEBUG
    kDebug() << "constructor ExerciseConvert()";

    /* create a new task */
    QApplication::setOverrideCursor (Qt::WaitCursor); /* show the sand clock */
    QApplication::restoreOverrideCursor(); /* show the normal cursor */

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

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

    m_currentState = _CHECK_TASK;

    // Create layout
    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 (3, 1);

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

    // first left is the rational widget
    m_rationalWidget = new RationalWidget (taskWidget, m_number, m_periodStart, m_periodLength);
    m_rationalWidget->setObjectName ("m_rationalWidget");
    taskLayout->addWidget (m_rationalWidget, 1, 1, 3, 1);

    /* 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->setFixedSize (85, 42);
    numer_edit->setAlignment (Qt::AlignHCenter);
    numer_edit->setFont (defaultFont);
    QObject::connect (numer_edit, SIGNAL (returnPressed (const QString &)), this,
                      SLOT (numeratorReturnPressed (const QString &)));
    taskLayout->addWidget (numer_edit, 1, 2);

    /* 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, 2);

    /* 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->setFixedSize (85, 42);
    deno_edit->setAlignment (Qt::AlignHCenter);
    deno_edit->setFont (defaultFont);
    QObject::connect (deno_edit, SIGNAL (returnPressed (const QString &)), this,
                      SLOT (denominatorReturnPressed (const QString &)));
    taskLayout->addWidget (deno_edit, 3, 2);

    // next is the result widget
    m_resultWidget = new ResultWidget (checkWidget, m_result);
    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 on 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 on 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);

    setLayout (baseGrid);
    taskWidget->setLayout (taskLayout);
    checkWidget->setLayout (checkLayout);

    // add tooltip and qwhatsthis help to the widget
    setToolTip (i18n ("In this exercise you have to convert a number into a fraction."));
    setWhatsThis (i18n ("In this exercise you have to convert a given number into a fraction by entering a numerator and denominator. Do not forget to reduce the result."));

Generated by  Doxygen 1.6.0   Back to index