Beispiel #1
0
SnakePart* SnakeList::take(int pos){
    SnakePart* sp = 0;
    goToFirst();

    for(int i = 1; i < pos; i++)
        goToNext();

    if(pos != 1 && pos != conteo){
        current->prev->next = current->next;
        current->next->prev = current->prev;
    }else if(pos == conteo){
        first = current->next;
        if(current->next != 0)
            current->next->prev = 0;
    }else if(pos == conteo){
        last = current->prev;
        current->prev->next = 0;
    }

    if(pos > 0 && pos <= conteo){
        conteo--;
        sp = current->content;
        delete current;
    }
    return sp;
}
Beispiel #2
0
void SnakeList::advanceItems(){
    goToFirst();
    SnakePart* head = get();

    switch(head->direction()){
    case head->UP:
        head->setY( head->y() - head->partSize );
        break;
    case head->DOWN:
        head->setY( head->y() + head->partSize );
        break;
    case head->RIGHT:
        head->setX( head->x() + head->partSize );
        break;
    case head->LEFT:
        head->setX( head->x() - head->partSize );
        break;
    }

    goToLast();
    for(int i = count()-1; i > 1; i--){
        SnakePart* act = get();
        SnakePart* previ = 0;
        if(current->prev != 0)
            previ = current->prev->content;
        if(previ != 0 && act != 0){
            act->setDirection(previ->direction());
            act->setX(previ->x());
            act->setY(previ->y());
            act->setZ(previ->getZ());
            act->advance();
        }
        goToPrevious();
    }
}
Beispiel #3
0
void SnakeList::goTo(int pos){
    if(pos <= 1){
        goToNext(); return;
    }
    if(pos == conteo - 1){
        goToLast(); return;
    }
    goToFirst();
    for(int i = 1; i < pos; i++){
        if(current->next != 0)
            goToNext();
    }
}
Beispiel #4
0
SnakePart* SnakeList::at(int pos){
    qDebug() << "in the at() method";
    if(isEmpty()){
        qDebug() << "it was empty";
        return 0;
    }
    qDebug() << "it was NOT empty";
    if( (pos > count()) || (pos <= 0))

        return 0;
    else{
        goToFirst();
        for(int i = 1; i < pos; i++)
            goToNext();
        return current->content;
    }
}
/*!

*/
void
LogPlayerToolBar::createControls( LogPlayer * log_player,
                                  QMainWindow * main_win )
{
    // visible actions
    {
        QAction * act
            = new QAction( QIcon( QPixmap( rew_xpm ) ),
                           tr( "Rewind" ), this );
#ifdef Q_WS_MAC
        act->setShortcut( Qt::META + Qt::Key_Down );
#else
        act->setShortcut( Qt::CTRL + Qt::Key_Down );
#endif
        act->setStatusTip( tr( "Rewind the log player.(" )
                           + act->shortcut().toString() + tr( ")" ) );
        connect( act, SIGNAL( triggered() ),
                 log_player, SLOT( accelerateBack() ) );
        this->addAction( act );
        main_win->addAction( act );
    }
    {
        QAction * act
            = new QAction( QIcon( QPixmap( rev_xpm ) ),
                           tr( "Play Backward" ), this );
        act->setShortcut( Qt::Key_Down );
        act->setStatusTip( tr( "Play backward the log player.(" )
                           + act->shortcut().toString() + tr( ")" ) );
        connect( act, SIGNAL( triggered() ),
                 log_player, SLOT( playBack() ) );
        this->addAction( act );
        main_win->addAction( act );
    }
    {
        QAction * act
            = new QAction( QIcon( QPixmap( minus_xpm ) ),
                           tr( "Step Back" ), this );
        act->setShortcut( Qt::Key_Left );
        act->setStatusTip( tr( "One step back the log player.(" )
                           + act->shortcut().toString() + tr( ")" ) );
        connect( act, SIGNAL( triggered() ),
                 log_player, SLOT( stepBack() ) );
        this->addAction( act );
        main_win->addAction( act );
    }
    {
        QAction * act
            = new QAction( QIcon( QPixmap( stop_xpm ) ),
                           tr( "Play/Stop" ), this );
        act->setShortcut( Qt::Key_Space );
        act->setStatusTip( tr( "Play/Stop the log player. (" )
                           + act->shortcut().toString() + tr( ")" ) );
        connect( act, SIGNAL( triggered() ),
                 log_player, SLOT( playOrStop() ) );
        this->addAction( act );
        main_win->addAction( act );
    }
    {
        QAction * act
            = new QAction( QIcon( QPixmap( plus_xpm ) ),
                           tr( "Step Forward" ), this );
        act->setShortcut( Qt::Key_Right );
        act->setStatusTip( tr( "One step forward the log player. (" )
                           + act->shortcut().toString() + tr( ")" ) );
        connect( act, SIGNAL( triggered() ),
                 log_player, SLOT( stepForward() ) );
        this->addAction( act );
        main_win->addAction( act );
    }
    {
        QAction * act
            = new QAction( QIcon( QPixmap( play_xpm ) ),
                           tr( "Play Forward" ), this );
        act->setShortcut( Qt::Key_Up );
        act->setStatusTip( tr( "Play forward the log player.(" )
                           + act->shortcut().toString() + tr( ")" ) );
        connect( act, SIGNAL( triggered() ),
                 log_player, SLOT( playForward() ) );
        this->addAction( act );
        main_win->addAction( act );
    }
    {
        QAction * act
            = new QAction( QIcon( QPixmap( ff_xpm ) ),
                           tr( "Fast Forward" ), this );
#ifdef Q_WS_MAC
        act->setShortcut( Qt::META + Qt::Key_Up );
#else
        act->setShortcut( Qt::CTRL + Qt::Key_Up );
#endif
        act->setStatusTip( tr( "Fast forward the log player.(" )
                           + act->shortcut().toString() + tr( ")" ) );
        connect( act, SIGNAL( triggered() ),
                 log_player, SLOT( accelerateForward() ) );
        this->addAction( act );
        main_win->addAction( act );
    }

    this->addSeparator();


    // invisible actions
    {
        QAction * act
            = new QAction( //QIcon( QPixmap( go_first_xpm ) ),
                           tr( "Go first" ), this );
        act->setShortcut( Qt::Key_Home );
        act->setStatusTip( tr( "Go to the first.(" )
                           + act->shortcut().toString() + tr( ")" ) );
        connect( act, SIGNAL( triggered() ),
                 log_player, SLOT( goToFirst() ) );
        //this->addAction( act );
        main_win->addAction( act );
    }
    {
        QAction * act
            = new QAction( //QIcon( QPixmap( go_last_xpm ) ),
                           tr( "Go last" ), this );
        act->setShortcut( Qt::Key_End );
        act->setStatusTip( tr( "Go to the last.(" )
                           + act->shortcut().toString() + tr( ")" ) );
        connect( act, SIGNAL( triggered() ),
                 log_player, SLOT( goToLast() ) );
        //this->addAction( act );
        main_win->addAction( act );
    }
}