/*
    knetd, KDE Network Daemon

    Copyright (c) 2005 by Engin AYDOGAN		<engin @ bzzzt.biz>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include "popupmanager.h"
#include "popupdispatch.h"

#include <kdebug.h>

class PopupManager::Private
{
public:
	QValueList<PopupInternal> popupQueue;
	PopupDispatch *last;
};

PopupManager::PopupManager()
 : d( new Private )
{
}

PopupManager::~PopupManager()
{
	delete d;
}

void
PopupManager::enqueue( QWidget* w, int t, int to )
{
	d->popupQueue.push_back( PopupInternal( w, t, to ) );
	startTimer( 500 );
}

void
PopupManager::timerEvent( QTimerEvent* )
{
	if( !d->popupQueue.isEmpty() )
	{
		kdWarning() << k_funcinfo << "Popping from popup queue" << endl;
		d->last = new PopupDispatch( d->popupQueue.first(), d->last, this );
		d->popupQueue.pop_front();
	}
}

void
PopupManager::setLast( PopupDispatch* dp )
{
	d->last = dp;
}
