/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename slots use Qt Designer which will
** update this file, preserving your code. Create an init() slot in place of
** a constructor, and a destroy() slot in place of a destructor.
*****************************************************************************/


void ChannelImportDlg::enableImport()
{
    _ok->setEnabled(true);
}

void ChannelImportDlg::init()
{
    KGlobal::dirs()->addResourceType("qtvision", "share/apps/qtvision");
}

void ChannelImportDlg::populateWithDefaults()
{
    QStringList qsl = KGlobal::dirs()->resourceDirs("qtvision");
    
    _channelList->clear();
    for (QStringList::Iterator p = qsl.begin(); p != qsl.end(); ++p) {
	QString path = *p + "/channels-dist/";
	QDir dir(path);
    
	if (dir.exists()) {
	    kdDebug() << "Loading default channels from directory: " << path << endl;
	    dir.setNameFilter("*");
	    const QFileInfoList *list = dir.entryInfoList();
	    QFileInfoListIterator it( *list );
	    QFileInfo *fi;

	    while ( (fi = it.current()) != 0 ) {
		if (fi->isFile()) {
		    kdDebug() << "\tFound channel file: " << fi->fileName() << endl;
		    ChannelFileMetaInfo x = ChannelIO::getMetaInfo(_qtv, fi->absFilePath());
		    new ChannelImportItem(_channelList, x, fi->absFilePath());
		}
		++it;
	    }
	}
    }   
}

QString ChannelImportDlg::selectedFile()
{
    ChannelImportItem *x = static_cast<ChannelImportItem*>(_channelList->selectedItem());
    
    if (!x)
	return QString();
    
    return x->_f;
}

QtVision* ChannelImportDlg::driver()
{
    return _qtv;
}

void ChannelImportDlg::setDriver(QtVision* driver)
{
    _qtv = driver;
}
