RKVarSlot::RKVarSlot (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
	RK_TRACE (PLUGIN);

	XMLHelper *xml = XMLHelper::getStaticHelper ();

	// basic layout
	QGridLayout *g_layout = new QGridLayout (this, 4, 3, RKGlobals::spacingHint ());

	QLabel *label = new QLabel (xml->getStringAttribute (element, "label", i18n ("Variable:"), DL_INFO), this);
	g_layout->addWidget (label, 0, 2);

	select = new QPushButton (QString::null, this);
	setSelectButton (false);
	connect (select, SIGNAL (clicked ()), this, SLOT (selectPressed ()));
	g_layout->addWidget (select, 1, 0);
	g_layout->addColSpacing (1, 5);

	list = new QListView (this);
	list->setSelectionMode (QListView::Extended);
	list->addColumn (" ");		// for counter
	list->addColumn (i18n ("Name"));
	list->setSorting (2);
	g_layout->addWidget (list, 1, 2);

	// initialize properties
	addChild ("source", source = new RKComponentPropertyRObjects (this, false));
	addChild ("available", available = new RKComponentPropertyRObjects (this, true));
	addChild ("selected", selected = new RKComponentPropertyRObjects (this, false));

	// find out about options
	if (multi = xml->getBoolAttribute (element, "multi", false, DL_INFO)) {
		available->setListLength (xml->getIntAttribute (element, "min_vars", 1, DL_INFO), xml->getIntAttribute (element, "min_vars_if_any", 1, DL_INFO), xml->getIntAttribute (element, "max_vars", 0, DL_INFO));
		connect (list, SIGNAL (selectionChanged ()), this, SLOT (listSelectionChanged ()));
	} else {
		available->setListLength (1, 1, 1);

		// make it look like a line-edit
		list->header ()->hide ();
		list->setFixedHeight (list->fontMetrics ().height () + 2*list->itemMargin () + 4);	// the height of a single line including margins
		list->setColumnWidthMode (0, QListView::Manual);
		list->setColumnWidth (0, 0);
		list->setHScrollBarMode (QScrollView::AlwaysOff);
		list->setVScrollBarMode (QScrollView::AlwaysOff);
		g_layout->setRowStretch (3, 1);		// so the label does not get separated from the view
	}

	// initialize filters
	available->setClassFilter (QStringList::split (" ", xml->getStringAttribute (element, "classes", QString::null, DL_INFO)));
	setRequired (xml->getBoolAttribute (element, "required", false, DL_INFO));
	available->setTypeFilter (QStringList::split (" ", xml->getStringAttribute (element, "types", QString::null, DL_INFO)));
	available->setDimensionFilter (xml->getIntAttribute (element, "num_dimensions", 0, DL_INFO), xml->getIntAttribute (element, "min_length", 0, DL_INFO), xml->getIntAttribute (element, "max_length", INT_MAX, DL_INFO));

	connect (available, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (availablePropertyChanged (RKComponentPropertyBase *)));
	availablePropertyChanged (available);		// initialize
}
QBT_NAMESPACE_BEGIN

// ----------------------------------------------------------------------------
// QBtSingleDeviceSelectorUIPrivate::::QBtSingleDeviceSelectorUIPrivate(QWidget* parent) :
//		QFrame(parent), prnt(parent)
//
// constuctor
// ----------------------------------------------------------------------------
QBtSingleDeviceSelectorUIPrivate::QBtSingleDeviceSelectorUIPrivate (QWidget* parent, QBtSingleDeviceSelectorUI* publicClass) :
    QDialog(parent), _parent(parent), _selectedDevice(0), _discoverer(0),
    _devList(0), _menu(0), _select(0), _exit(0), _publicClass (publicClass)
{
    //setup UI
    setObjectName(QString::fromUtf8("btDeviceSelectorUIWidget"));
    setAutoFillBackground(true);
    //setFrameShape(QFrame::WinPanel);
    //setFrameShadow(QFrame::Sunken);
    this->setFocus();
    
    
    QDesktopWidget* dw = QApplication::desktop();
    int width = dw->screenGeometry().width();
    int height = dw->screenGeometry().height() /4;
        
    setGeometry(QRect(0, 148 , width, height));

    _verticalLayout = new QVBoxLayout(this);
    _verticalLayout->setSpacing(6);
    _verticalLayout->setMargin(11);
    _verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));

    _label = new QLabel(this);
    _label->setText("Devices:");
    _verticalLayout->addWidget(_label);

    _devList = new QListWidget(this);

    /*QAction* clear = new QAction(tr("&Exit"), this);
    clear->setSoftKeyRole(QAction::NegativeSoftKey);
    connect(clear, SIGNAL(triggered()), this, SLOT(closeWidget()));

    devList->addAction(clear);
    addAction(clear);*/

    _devList->setFocusPolicy(Qt::WheelFocus);
    _devList->setFrameShape(QFrame::WinPanel);
    _devList->setFrameShadow(QFrame::Sunken);
    _devList->setFocus();
    _verticalLayout->addWidget(_devList);

    _select = new QAction(QString("Select"), this);
    _select->setSoftKeyRole(QAction::PositiveSoftKey);
    connect(_select, SIGNAL(triggered()), this, SLOT(selectPressed()));
    addAction(_select);


    _exit = new QAction(QString("Cancel"), this);
    _exit->setSoftKeyRole(QAction::NegativeSoftKey);
    connect(_exit, SIGNAL(triggered()), this, SLOT(exitPressed()));
    addAction(_exit);

    /*menu = new QMenuBar(this);
    menu->addAction(select);
    menu->addAction(exit);

    menu->setNativeMenuBar(true);
    verticalLayout->setMenuBar(menu);*/

    ////////////////

    _discoverer = new QBtDeviceDiscoverer(parent);

    connect(_discoverer, SIGNAL(newDeviceFound(const QBtDevice&)),
            this, SLOT(populateDeviceList(const QBtDevice&)));

    connect(_devList, SIGNAL(itemActivated(QListWidgetItem *)),
                    this, SLOT(devSelected(QListWidgetItem *)));
    this->hide();

}