Filter tracks by length with tokens similar to lastplayed etc.#7413
Filter tracks by length with tokens similar to lastplayed etc.#7413hatstand merged 3 commits intoclementine-player:masterfrom residuum:track-length-filter
Conversation
hatstand
left a comment
There was a problem hiding this comment.
Just some style fixes while you're there.
src/library/libraryquery.cpp
Outdated
| } else if (columntoken == "length") { | ||
| double seconds = GetSecondsFromToken(val); | ||
| if (seconds > 0) { | ||
| double nanoseconds = seconds * 1000000000; |
There was a problem hiding this comment.
I have changed to type of seconds and nanoseconds to qint64, as that seems more appropriate.
src/library/libraryquery.cpp
Outdated
| int LibraryQuery::GetSecondsFromToken(QString val) { | ||
| int seconds = 0; | ||
| QString tmp = ""; | ||
| QString allowedChars = "smhd"; |
There was a problem hiding this comment.
static const QString kAllowedChars
src/library/libraryquery.cpp
Outdated
| if (c.isDigit()) { | ||
| tmp.append(c); | ||
| } else if (allowedChars.contains(c)) { | ||
| bool ok; |
src/library/libraryquery.cpp
Outdated
| } | ||
| } | ||
|
|
||
| int LibraryQuery::GetSecondsFromToken(QString val) { |
There was a problem hiding this comment.
int LibraryQuery::GetSecondsFromToken(const QString& val) const
There was a problem hiding this comment.
I am not well versed in C++, so I am unsure about the semantics, and if this is also needed in the corresponding .h file, but I have added it there as well.
src/library/libraryquery.cpp
Outdated
| } else if (c == 'h') { | ||
| seconds += intVal * 60 * 60; | ||
| } else if (c == 'd') { | ||
| seconds += intVal * 60 * 60 * 24; |
src/library/libraryquery.cpp
Outdated
| {"stream", Song::Type_Stream}, | ||
| {"unknown", Song::Type_Unknown}}); | ||
|
|
||
| const int kNsecsPerSec = 1e9; |
There was a problem hiding this comment.
These constants already exist somewhere in Clementine
There was a problem hiding this comment.
Thanks for the info, I did not find it, because it is kNsecPerSec, but could not find kAllowedChars or anything else that defines a value of smhd.
Implements #7370