Пример #1
0
FaToDFA::FaToDFA(modes _mode, AlgorithmWidget* _algorithm_widget, FA_widget* _not_dfa_widget, FA_widget* _dfa_widget, QLabel* _var_widget, QObject* parrent)
 : Algorithm(parrent),  mode(_mode),  algorithm_widget(_algorithm_widget), not_dfa_widget(_not_dfa_widget), dfa_widget(_dfa_widget), var_widget(_var_widget)
{
    actInstruction = HEADER;
    prewInstruction = HEADER;
    instruction_count = WHILE_NEW+1;
    initInstructions();
    initBreakpoints(instruction_count);

    this->setColumnCount(1);
    this->setRowCount(instructions.count());

    var_widget->setText("");

    for(int i = 0; i < instructions.count();i++)
    {
        QModelIndex index = this->index(i,0,QModelIndex());
        setData(index,instructions[i],Qt::EditRole);
        setData(index,true,Algorithm::HasBreakpoint_Role);
        setData(index,false,Algorithm::Breakpoint_Role);
        switch(i)
        {
            case HEADER:
                setData(index,false,Algorithm::HasBreakpoint_Role);
                break;
        }
    }


    //
    // Connect algorithm buttons.
    //
    connect(this->algorithm_widget,SIGNAL(playPressed(int)),this,SLOT(runAlgorithm(int)));
    connect(this->algorithm_widget,SIGNAL(stopPressed()),this,SLOT(stop()));
    connect(this->algorithm_widget,SIGNAL(prewPressed()),this,SLOT(prevStep()));
    connect(this->algorithm_widget,SIGNAL(nextPressed()),this,SLOT(nextStep()));
    connect(this->algorithm_widget, SIGNAL(checkSolutionPressed()), this, SLOT(checkSolution()));
    connect(this->algorithm_widget, SIGNAL(showCorrectSolutionPressed()), this, SLOT(showCorrectSolution()));
    connect(this->algorithm_widget, SIGNAL(showUserSolutionPressed()), this, SLOT(showUserSolution()));
    connect(this->algorithm_widget, SIGNAL(beginPressed()), this, SLOT(toBegin()));
    connect(this->algorithm_widget, SIGNAL(endPressed()), this, SLOT(toEnd()));

    //
    // Connect timers.
    //
    connect(play_timer, SIGNAL(timeout()), this, SLOT(nextStep()));
    connect(check_step_timer, SIGNAL(timeout()), this, SLOT(checkSolution()));

    // Connect Finite Automata widgets
    connect(not_dfa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(setFA(FiniteAutomata*)));
    connect(dfa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(setDFA(FiniteAutomata*)));

    not_dfa_widget->setFA(new FiniteAutomata());

    algorithm_widget->enableShowButton();
}
Пример #2
0
CAlgorithmWidget::CAlgorithmWidget(QWidget *parent) : QWidget(parent), m_mode(AlgorithmModes::NONE),
    ui(new Ui::AlgorithmWidget)
{
    ui->setupUi(this);

    showSolution = true;

    connect(this->ui->nextButton,SIGNAL(clicked()),this,SIGNAL(nextPressed()));
    connect(this->ui->prewButton,SIGNAL(clicked()),this,SIGNAL(prewPressed()));
    connect(this->ui->playButton,SIGNAL(clicked()),this,SLOT(emitPlay()));
    connect(this->ui->stopButton,SIGNAL(clicked()),this,SIGNAL(stopPressed()));
    connect(this->ui->checkButton,SIGNAL(clicked()),this,SIGNAL(checkSolutionPressed()));
    connect(this->ui->beginButton,SIGNAL(clicked()), this, SIGNAL(beginPressed()));
    connect(this->ui->endButton,SIGNAL(clicked()),this, SIGNAL(endPressed()));
    SetMode(m_mode);
    ui->Formal->removeTab(1);
}
Пример #3
0
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// keyboard handling
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- 
void FileListView::keyPressEvent( QKeyEvent* keyEvent )
{
    // implementing our needs
    Qt::KeyboardModifiers   keyboardModifier    = keyEvent->modifiers();
    Qt::Key                 pressedKey          = static_cast<Qt::Key>( keyEvent->key() );

    if( Qt::NoModifier == keyboardModifier )
    {
        switch( pressedKey )
        {
            case Qt::Key_Escape:    emit escPressed();      break;

            case Qt::Key_Period:    emit consolePressed();  break;

            case Qt::Key_F1 :       emit f01keyPressed();   break;
            case Qt::Key_F2 :       emit f02keyPressed();   break;
            case Qt::Key_F3 :       emit f03keyPressed();   break;
            case Qt::Key_F4 :       emit f04keyPressed();   break;
            case Qt::Key_F5 :       emit f05keyPressed();   break;
            case Qt::Key_F6 :       emit f06keyPressed();   break;
            case Qt::Key_F7 :       emit f07keyPressed();   break;
            case Qt::Key_F8 :       emit f08keyPressed();   break;
            case Qt::Key_F9 :       emit f09keyPressed();   break;
            case Qt::Key_F10:       emit f10keyPressed();   break;
            case Qt::Key_F11:       emit f11keyPressed();   break;
            case Qt::Key_F12:       emit f12keyPressed();   break;

            case Qt::Key_Print:     emit printPressed();    break;
            case Qt::Key_Pause:     emit pausePressed();    break;

            case Qt::Key_Tab:       emit tabPressed();      break;
            case Qt::Key_CapsLock:  emit capsLockPressed(); break;
            case Qt::Key_Shift:     emit leftShiftPressed();break;
            case Qt::Key_Control:   emit leftCtrlPressed(); break;

            case Qt::Key_Insert:    emit insertPressed();   break;
            case Qt::Key_Delete:    emit deletePressed();   break;
            case Qt::Key_Home:      emit homePressed();     break;
            case Qt::Key_End:       emit endPressed();      break;
            case Qt::Key_PageUp:    emit pageUpPressed();   break;
            case Qt::Key_PageDown:  emit pageDownPressed(); break;

            case Qt::Key_Backspace: emit backspacePressed();break;
            case Qt::Key_Return:    emit enterPressed();    break;
            case Qt::Key_Space:     emit spacePressed();    break;

            default:                keyEvent->ignore();     break;
        }
    }

    else if( Qt::AltModifier == keyboardModifier )
    {
        switch( pressedKey )
        {
            case Qt::Key_0: emit alt0Pressed(); break;
            case Qt::Key_1: emit alt1Pressed(); break;
            case Qt::Key_2: emit alt2Pressed(); break;
            case Qt::Key_3: emit alt3Pressed(); break;
            case Qt::Key_4: emit alt4Pressed(); break;
            case Qt::Key_5: emit alt5Pressed(); break;
            case Qt::Key_6: emit alt6Pressed(); break;
            case Qt::Key_7: emit alt7Pressed(); break;
            case Qt::Key_8: emit alt8Pressed(); break;
            case Qt::Key_9: emit alt9Pressed(); break;
            default:        keyEvent->ignore(); break;
        }
    }

    else if( Qt::ControlModifier == keyboardModifier )
    {
        switch( pressedKey )
        {
            case Qt::Key_0: emit ctrl0Pressed(); break;
            case Qt::Key_1: emit ctrl1Pressed(); break;
            case Qt::Key_2: emit ctrl2Pressed(); break;
            case Qt::Key_3: emit ctrl3Pressed(); break;
            case Qt::Key_4: emit ctrl4Pressed(); break;
            case Qt::Key_5: emit ctrl5Pressed(); break;
            case Qt::Key_6: emit ctrl6Pressed(); break;
            case Qt::Key_7: emit ctrl7Pressed(); break;
            case Qt::Key_8: emit ctrl8Pressed(); break;
            case Qt::Key_9: emit ctrl9Pressed(); break;
            default:        keyEvent->ignore();  break;
        }
    }

    else if( Qt::ShiftModifier == keyboardModifier )
    {
        switch( pressedKey )
        {
            case Qt::Key_0: emit shift0Pressed(); break;
            case Qt::Key_1: emit shift1Pressed(); break;
            case Qt::Key_2: emit shift2Pressed(); break;
            case Qt::Key_3: emit shift3Pressed(); break;
            case Qt::Key_4: emit shift4Pressed(); break;
            case Qt::Key_5: emit shift5Pressed(); break;
            case Qt::Key_6: emit shift6Pressed(); break;
            case Qt::Key_7: emit shift7Pressed(); break;
            case Qt::Key_8: emit shift8Pressed(); break;
            case Qt::Key_9: emit shift9Pressed(); break;
            default:        keyEvent->ignore();   break;
        }
    }

    else if( Qt::KeypadModifier == keyboardModifier )
    {
        switch( pressedKey )
        {
            case Qt::Key_Minus:     emit numpadMinusPressed();      break;
            case Qt::Key_Plus:      emit numpadPlusPressed();       break;
            case Qt::Key_Slash:     emit numpadSlashPressed();      break;
            case Qt::Key_Asterisk:  emit numpadAsteriskPressed();   break;
            default:                keyEvent->ignore();             break;
        }
    }

    // allowing the default behaviour
    QListView::keyPressEvent( keyEvent );
}