20 #include <QListWidgetItem> 23 #include "ui_ambedevicesdialog.h" 28 m_ambeEngine(ambeEngine)
42 std::vector<QString> ambeSerialDevices;
44 ui->ambeSerialDevices->clear();
45 std::vector<QString>::const_iterator it = ambeSerialDevices.begin();
47 for (; it != ambeSerialDevices.end(); ++it)
49 ui->ambeSerialDevices->addItem(QString(*it));
55 std::vector<QString> inUseDevices;
57 ui->ambeDeviceRefs->clear();
58 std::vector<QString>::const_iterator it = inUseDevices.begin();
60 for (; it != inUseDevices.end(); ++it)
62 qDebug(
"AMBEDevicesDialog::refreshInUseList: %s", qPrintable(*it));
63 ui->ambeDeviceRefs->addItem(*it);
70 QListWidgetItem *serialItem =
ui->ambeSerialDevices->currentItem();
74 ui->statusText->setText(
"No selection");
78 QString serialName = serialItem->text();
79 QList<QListWidgetItem*> foundItems =
ui->ambeDeviceRefs->findItems(serialName, Qt::MatchFixedString|Qt::MatchCaseSensitive);
81 if (foundItems.size() == 0)
85 ui->ambeDeviceRefs->addItem(serialName);
86 ui->statusText->setText(tr(
"%1 added").
arg(serialName));
90 ui->statusText->setText(tr(
"Cannot open %1").
arg(serialName));
95 ui->statusText->setText(
"Device already in use");
104 for (
int i = 0;
i <
ui->ambeSerialDevices->count();
i++)
106 const QListWidgetItem *serialItem =
ui->ambeSerialDevices->item(
i);
107 QString serialName = serialItem->text();
108 QList<QListWidgetItem*> foundItems =
ui->ambeDeviceRefs->findItems(serialName, Qt::MatchFixedString|Qt::MatchCaseSensitive);
110 if (foundItems.size() == 0)
114 ui->ambeDeviceRefs->addItem(serialName);
120 ui->statusText->setText(tr(
"%1 devices added").
arg(count));
126 QListWidgetItem *deviceItem =
ui->ambeDeviceRefs->currentItem();
130 ui->statusText->setText(
"No selection");
134 QString deviceName = deviceItem->text();
136 ui->statusText->setText(tr(
"%1 removed").
arg(deviceName));
143 ui->statusText->setText(
"In use refreshed");
148 if (
ui->ambeDeviceRefs->count() == 0)
150 ui->statusText->setText(
"No active items");
155 ui->ambeDeviceRefs->clear();
156 ui->statusText->setText(
"All items released");
161 QString addressAndPort =
ui->ambeAddressText->text();
163 QList<QListWidgetItem*> foundItems =
ui->ambeDeviceRefs->findItems(addressAndPort, Qt::MatchFixedString|Qt::MatchCaseSensitive);
165 if (foundItems.size() == 0)
169 ui->ambeDeviceRefs->addItem(addressAndPort);
170 ui->statusText->setText(tr(
"%1 added").
arg(addressAndPort));
174 ui->statusText->setText(tr(
"Cannot open %1").
arg(addressAndPort));
179 ui->statusText->setText(
"Address already in use");
void on_clearAmbeList_clicked(bool checked)
void on_refreshAmbeList_clicked(bool checked)
void on_importSerial_clicked(bool checked)
void on_importAddress_clicked(bool checked)
void getDeviceRefs(std::vector< QString > &devicesRefs)
reference of the devices used (device path or url)
void scan(std::vector< QString > &ambeDevices)
void populateSerialList()
bool registerController(const std::string &deviceRef)
create a new controller for the device in reference
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
AMBEDevicesDialog(AMBEEngine *ambeEngine, QWidget *parent=nullptr)
void on_importAllSerial_clicked(bool checked)
void on_removeAmbeDevice_clicked(bool checked)
AMBEEngine * m_ambeEngine
void releaseController(const std::string &deviceRef)
release controller resources for the device in reference
Ui::AMBEDevicesDialog * ui