Skip to content

Commit f7c6bf2

Browse files
committed
Add PTZDeviceList::removeDevice()
Adds an api for removing devices without direct accsss to the PTZDevice pointer. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
1 parent 38ec850 commit f7c6bf2

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/ptz-device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ void PTZListModel::add(PTZDevice *ptz)
211211
do_reset();
212212
}
213213

214+
void PTZListModel::removeDevice(const QModelIndex &index)
215+
{
216+
PTZDevice *ptz = getDevice(index);
217+
if (ptz)
218+
delete ptz;
219+
}
220+
214221
void PTZListModel::remove(PTZDevice *ptz)
215222
{
216223
if (ptz == devices.value(ptz->id)) {

src/ptz-device.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class PTZListModel : public QAbstractListModel {
5959
QModelIndex indexFromDeviceId(uint32_t device_id);
6060
void renameDevice(QString new_name, QString prev_name);
6161
obs_data_array_t *getConfigs();
62+
void removeDevice(const QModelIndex &index);
6263
void add(PTZDevice *ptz);
6364
void remove(PTZDevice *ptz);
6465
void delete_all();

src/settings.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,7 @@ void PTZSettings::on_addPTZ_clicked()
420420

421421
void PTZSettings::on_removePTZ_clicked()
422422
{
423-
PTZDevice *ptz = ptzDeviceList.getDevice(ui->deviceList->currentIndex());
424-
if (!ptz)
425-
return;
426-
delete ptz;
423+
ptzDeviceList.removeDevice(ui->deviceList->currentIndex());
427424
}
428425

429426
void PTZSettings::on_applyButton_clicked()

0 commit comments

Comments
 (0)