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; }
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&))); }
_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); }
void Devices::execDevExistanceMenuResult(Device_Action ret) { if ( ret==ADD ) { addDevice(); } else if ( ret==DEL ) { delDevice(); }; }
void Devices::execDevExistanceMenuResult(Device_Action ret) { if ( ret==ADD ) { stackWdg->setCurrentWidget(deviceStack); } else if ( ret==DEL ) { delDevice(); }; }
void UDiskProvider::dbusDeviceRemoved(const QDBusObjectPath &path) { UDiskMountDevice *device = getDevice(path); if (device) { emit deviceRemoved(device); delDevice(device); } }
void DeviceSerial::deviceDeinitialise( void ) { DeviceSerial *DevSer; while( !mDeviceList.isEmpty() ) { DevSer = mDeviceList.takeFirst(); delDevice( DevSer ); } }
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(); }