Merge PR #998: Add a find() method to SerialPorts

pull/1000/head
jenkins 2023-03-28 19:53:27 +02:00
commit 0346a7b1ca
3 changed files with 14 additions and 3 deletions

View File

@ -99,6 +99,16 @@ void SerialPorts::clear()
emit countChanged();
}
SerialPort *SerialPorts::find(const QString &systemLocation) const
{
for (int i = 0; i < m_serialPorts.count(); i++) {
if (m_serialPorts.at(i)->systemLocation() == systemLocation) {
return m_serialPorts.at(i);
}
}
return nullptr;
}
SerialPort *SerialPorts::get(int index) const
{
if (index < 0 || index >= m_serialPorts.count()) {

View File

@ -62,6 +62,7 @@ public:
void clear();
Q_INVOKABLE SerialPort *find(const QString &systemLocation) const;
Q_INVOKABLE virtual SerialPort *get(int index) const;
signals:

View File

@ -90,7 +90,7 @@ ItemDelegate {
contentItem: RowLayout {
id: innerLayout
spacing: app.margins
spacing: Style.margins
Item {
Layout.preferredHeight: root.iconSize
Layout.preferredWidth: height
@ -140,7 +140,7 @@ ItemDelegate {
Layout.fillWidth: true
Layout.fillHeight: true
text: root.subText
font.pixelSize: root.prominentSubText ? app.smallFont : app.extraSmallFont
font.pixelSize: root.prominentSubText ? Style.smallFont : app.extraSmallFont
color: root.prominentSubText ? Material.foreground : Material.color(Material.Grey)
wrapMode: root.wrapTexts ? Text.WordWrap : Text.NoWrap
maximumLineCount: root.wrapTexts ? 2 : 1
@ -159,7 +159,7 @@ ItemDelegate {
id: secondaryIconMouseArea
enabled: false
anchors.fill: parent
anchors.margins: -app.margins
anchors.margins: -Style.margins
onClicked: root.secondaryIconClicked();
}
}