/*
 * This file is part of DesktopBSD, see the README file.
 *
 * Author: Peter Hofer <ph@desktopbsd.net>
 *			(C) 2004, 2005
 *
 * Copyright: BSD, see the COPYING file included in this distribution
 *
 */

#include <dbsdglobal.h>

void  frmSelIf::addIf(NetInterface  *netif) {
	if(netif != NULL) {
		lstInterfaces->insertItem(DBSDGlobal::getIconLoader()->loadIcon("kcmpci",
																							 DBSDIconLoader::LargeListItem),
										  netif->getDesc());
		ifList.append(netif);
	}
}

void  frmSelIf::setIfList(QPtrList<NetInterface>  ifList) {
	this->ifList.clear();

	QPtrList<NetInterface>::ConstIterator  it = ifList.begin();
	while(it != ifList.end())
		addIf(*it++);
}

NetInterface  *frmSelIf::getSelIf() {
	return  ifList.at(lstInterfaces->index(lstInterfaces->selectedItem()));
}

/* All items should be inserted before the dialog
 * is shown so the first item can be selected.
 */
void  frmSelIf::polish() {
	lstInterfaces->setSelected(lstInterfaces->firstItem(), true);

	QDialog::polish();
}

void  frmSelIf::init() {
	lstInterfaces->clear();
}
