diff --git a/src/portlist.cpp b/src/portlist.cpp --- a/src/portlist.cpp +++ b/src/portlist.cpp @@ -1,5 +1,5 @@ /* - Copyright © 2015 Hasan Yavuz Özderya + Copyright © 2016 Hasan Yavuz Özderya This file is part of serialplot. @@ -112,6 +112,18 @@ int PortList::indexOf(QString portText) return -1; // not found } +int PortList::indexOfName(QString portName) +{ + for (int i = 0; i < rowCount(); i++) + { + if (item(i)->data(PortNameRole) == portName) + { + return i; + } + } + return -1; // not found +} + void PortList::onRowsInserted(QModelIndex parent, int start, int end) { PortListItem* newItem = static_cast(item(start));