//
// C++ Implementation: blinkable
//
// Description: 
//
//
// Author: Predrag Viceic <viceic@net2000.ch>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "blinkable.h"

Blinkable::Blinkable(QObject *parent, const char *name)
 : QObject(parent, name)
{
}


Blinkable::~Blinkable()
{
}




/*!
    \fn Blinkable::blink()
 */
void Blinkable::blink()
{
    int next=nextStep();
    executeBlink(next);
    if(next==-1){
        Blinkable::timer->stop();
        killTimer(Blinkable::timer->timerId());
        cout<<"Timer stopped\n";
    }

}

/*!
    \fn Blinkable::startBlink(Blinkable* obj, int nbSteps, int stepInterval, int totalDuration)
 */
void Blinkable::startBlink(Blinkable* blinkable, int nbSteps, int stepInterval, int totalDuration)
{
    
    blinkable->nbSteps=nbSteps;
    blinkable->stepInterval=stepInterval;
    blinkable->totalDuration=totalDuration;
    blinkable->timer=new QTimer(blinkable);
    blinkable->init();
    connect(blinkable->timer,SIGNAL(timeout()),blinkable,SLOT(blink()));
    blinkable->timer->start(stepInterval);
}
