diff --git a/portlist.cpp b/portlist.cpp --- a/portlist.cpp +++ b/portlist.cpp @@ -58,7 +58,7 @@ void PortListItem::construct(QString nam setData(name, PortNameRole); } -QString PortListItem::name() +QString PortListItem::portName() { return data(PortNameRole).toString(); } @@ -78,3 +78,15 @@ void PortList::loadPortList() appendRow(new PortListItem(&portInfo)); } } + +int PortList::indexOf(QString portName) +{ + for (int i = 0; i < rowCount(); i++) + { + if (static_cast(item(i))->portName() == portName) + { + return i; + } + } + return -1; // not found +}