[multimedia/haruna] src/models: tracksmodel: add findTrackRow method
George Florea Bănuș <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit ba9a79076c30da6693b45908e9cc2eb0b7df7187 by George Florea Bănuș, on behalf of M. Sadık Uğursoy.
Committed on 13/08/2026 at 20:57.
Pushed by georgefb into branch 'master'.
tracksmodel: add findTrackRow method
M +11 -0 src/models/tracksmodel.cpp
M +1 -0 src/models/tracksmodel.h
https://invent.kde.org/multimedia/haruna/-/commit/ba9a79076c30da6693b45908e9cc2eb0b7df7187
diff --git a/src/models/tracksmodel.cpp b/src/models/tracksmodel.cpp
index 9dce3715..98c1fbda 100644
--- a/src/models/tracksmodel.cpp
+++ b/src/models/tracksmodel.cpp
@@ -136,4 +136,15 @@ void TracksModel::setActiveRow(int newActiveTrack)
m_activeRow = newActiveTrack;
}
+int TracksModel::findTrackRow(int trackId) const
+{
+ for (int row = 0; row < m_data.size(); ++row) {
+ if (m_data.at(row).trackid == trackId) {
+ return row;
+ }
+ }
+
+ return -1;
+}
+
#include "moc_tracksmodel.cpp"
diff --git a/src/models/tracksmodel.h b/src/models/tracksmodel.h
index ce30d4b0..90dc9232 100644
--- a/src/models/tracksmodel.h
+++ b/src/models/tracksmodel.h
@@ -73,6 +73,7 @@ public:
void setActiveRow(int newActiveTrack);
int nextRow();
int previousRow();
+ Q_INVOKABLE int findTrackRow(int trackId) const;
public Q_SLOTS:
void setTracks(QList<Track> tracks);