Exemplo n.º 1
0
Devices::~Devices()
{
    if ( deviceStack!=NULL ) {
        delete deviceStack;
        deviceStack = NULL;
    };
    disconnect(usedDeviceList,
               SIGNAL(customContextMenuRequested(const QPoint&)),
               this,
               SLOT(showContextMenu(const QPoint&)));
    disconnect(addNewDevice, SIGNAL(clicked()), this, SLOT(addDevice()));
    disconnect(delSelDevice, SIGNAL(clicked()), this, SLOT(delDevice()));
    delete usedDeviceList;
    usedDeviceList = NULL;
    delete addNewDevice;
    addNewDevice = NULL;
    delete delSelDevice;
    delSelDevice = NULL;

    delete buttonlayout;
    buttonlayout = NULL;
    delete buttons;
    buttons = NULL;

    delete listLayout;
    listLayout = NULL;
    delete listWidget;
    listWidget = NULL;

    delete infoWidget;
    infoWidget = NULL;
    delete commonLayout;
    commonLayout = NULL;
}
Exemplo n.º 2
0
Devices::Devices(
        QWidget *parent, virConnectPtr *connPtrPtr, QString _xmlDesc) :
    _QWidget(parent, connPtrPtr), xmlDesc(_xmlDesc)
{
    setObjectName("Computer:Device");
    usedDeviceList = new QListWidget(this);
    usedDeviceList->setSelectionMode(QAbstractItemView::SingleSelection);
    usedDeviceList->setContextMenuPolicy(Qt::CustomContextMenu);
    usedDeviceList->setSortingEnabled(false);
    connect(usedDeviceList, SIGNAL(customContextMenuRequested(const QPoint&)),
            this, SLOT(showContextMenu(const QPoint&)));
    addNewDevice = new QPushButton(QIcon::fromTheme("list-add"), "", this);
    addNewDevice->setToolTip("Add Device");
    connect(addNewDevice, SIGNAL(clicked()), this, SLOT(showDeviceStack()));
    delSelDevice = new QPushButton(QIcon::fromTheme("list-remove"), "", this);
    delSelDevice->setToolTip("Del Device");
    connect(delSelDevice, SIGNAL(clicked()), this, SLOT(delDevice()));

    buttonlayout = new QHBoxLayout(this);
    buttonlayout->addWidget(addNewDevice);
    buttonlayout->addWidget(delSelDevice);
    buttons = new QWidget(this);
    buttons->setLayout(buttonlayout);

    listLayout = new QVBoxLayout(this);
    listLayout->addWidget(usedDeviceList);
    listLayout->addWidget(buttons);
    listWidget = new QWidget(this);
    listWidget->setLayout(listLayout);

    infoWidget = new DeviceData(this, ptr_ConnPtr);
    baseLayout = new QHBoxLayout(this);
    baseLayout->addWidget(listWidget, 3);
    baseLayout->addWidget(infoWidget, 8);
    baseWdg = new QWidget(this);
    baseWdg->setLayout(baseLayout);

    deviceStack = new DeviceStack(this, ptr_ConnPtr);
    stackWdg = new QStackedWidget(this);
    stackWdg->addWidget(baseWdg);
    stackWdg->addWidget(deviceStack);

    commonLayout = new QHBoxLayout(this);
    commonLayout->addWidget(stackWdg);
    setLayout(commonLayout);

    detectAttachedDevicesFromXMLDesc();
    //connect(usedDeviceList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
    //        this, SLOT(showDevice(QListWidgetItem*,QListWidgetItem*)));
    connect(usedDeviceList, SIGNAL(itemSelectionChanged()),
            this, SLOT(showDevice()));
    connect(infoWidget, SIGNAL(saveDeviceXMLDesc(int, QString&)),
            this, SLOT(saveDeviceXMLDescription(int, QString&)));
    connect(infoWidget, SIGNAL(errorMsg(QString&)),
            this, SIGNAL(errorMsg(QString&)));
    connect(deviceStack, SIGNAL(finished(int)),
            this, SLOT(addDevice()));
    connect(deviceStack, SIGNAL(errorMsg(QString&)),
            this, SIGNAL(errorMsg(QString&)));
}
Exemplo n.º 3
0
_BlockDevices::_BlockDevices(QWidget *parent) :
    QWidget(parent)
{
    devices = new QListWidget(this);
    add = new QPushButton(QIcon::fromTheme("list-add"), "", this);
    browse = new QPushButton(QIcon::fromTheme("edit-find"), "", this);
    del = new QPushButton(QIcon::fromTheme("list-remove"), "", this);
    name = new QLineEdit(this);
    name->setPlaceholderText("Block device name");
    panelLayout = new QHBoxLayout(this);
    panel = new QWidget(this);
    panelLayout->addWidget(add, 1);
    panelLayout->addWidget(browse, 1);
    panelLayout->addWidget(name, 20);
    panelLayout->addWidget(del, 1);
    panel->setLayout(panelLayout);
    commonLayout = new QVBoxLayout(this);
    commonLayout->addWidget(devices);
    commonLayout->addWidget(panel);
    commonLayout->addStretch(-1);
    setLayout(commonLayout);
    connect(add, SIGNAL(clicked()),
            this, SLOT(addDevice()));
    connect(del, SIGNAL(clicked()),
            this, SLOT(delDevice()));
    connect(browse, SIGNAL(clicked()),
            this, SLOT(setBlockDevPath()));
    setOneDeviceMode(false);
}
Exemplo n.º 4
0
void Devices::execDevExistanceMenuResult(Device_Action ret)
{
    if ( ret==ADD ) {
        addDevice();
    } else if ( ret==DEL ) {
        delDevice();
    };
}
Exemplo n.º 5
0
void Devices::execDevExistanceMenuResult(Device_Action ret)
{
    if ( ret==ADD ) {
        stackWdg->setCurrentWidget(deviceStack);
    } else if ( ret==DEL ) {
        delDevice();
    };
}
Exemplo n.º 6
0
void UDiskProvider::dbusDeviceRemoved(const QDBusObjectPath &path)
{
    UDiskMountDevice *device = getDevice(path);
    if (device)
    {
        emit deviceRemoved(device);
        delDevice(device);
    }
}
Exemplo n.º 7
0
void DeviceSerial::deviceDeinitialise( void )
{
	DeviceSerial		*DevSer;

	while( !mDeviceList.isEmpty() )
	{
		DevSer = mDeviceList.takeFirst();

		delDevice( DevSer );
	}
}
Exemplo n.º 8
0
void DeviceSerial::deviceCfgLoad( QSettings &pDataStream )
{
	DeviceSerial		*DevCur;

	while( !mDeviceList.isEmpty() )
	{
		DevCur = mDeviceList.takeFirst();

		delDevice( DevCur );
	}

	pDataStream.beginGroup( "serial" );

	int		DevCnt = pDataStream.beginReadArray( "devices" );

	for( int i = 0 ; i < DevCnt ; i++ )
	{
		pDataStream.setArrayIndex( i );

		if( ( DevCur = newDevice() ) == 0 )
		{
			continue;
		}

		DevCur->setName( pDataStream.value( "name", DevCur->name() ).toString() );

		DevCur->setUuid( pDataStream.value( "uuid", DevCur->uuid() ).value<QUuid>() );

		DevCur->cfgLoad( pDataStream );

		if( pDataStream.value( "enabled", false ).toBool() )
		{
			DevCur->setEnabled( true );
		}
	}

	pDataStream.endArray();

	pDataStream.endGroup();
}