Skip to content

Comments

Filter tracks by length with tokens similar to lastplayed etc.#7413

Merged
hatstand merged 3 commits intoclementine-player:masterfrom
residuum:track-length-filter
Oct 3, 2025
Merged

Filter tracks by length with tokens similar to lastplayed etc.#7413
hatstand merged 3 commits intoclementine-player:masterfrom
residuum:track-length-filter

Conversation

@residuum
Copy link
Contributor

@residuum residuum commented Sep 7, 2025

Implements #7370

@residuum residuum changed the title Filter tracks by length with tokens similar to lasplayed etc. Filter tracks by length with tokens similar to lastplayed etc. Sep 9, 2025
Copy link
Contributor

@hatstand hatstand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some style fixes while you're there.

} else if (columntoken == "length") {
double seconds = GetSecondsFromToken(val);
if (seconds > 0) {
double nanoseconds = seconds * 1000000000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seconds * kNsecsPerSec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed to type of seconds and nanoseconds to qint64, as that seems more appropriate.

int LibraryQuery::GetSecondsFromToken(QString val) {
int seconds = 0;
QString tmp = "";
QString allowedChars = "smhd";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static const QString kAllowedChars

if (c.isDigit()) {
tmp.append(c);
} else if (allowedChars.contains(c)) {
bool ok;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool ok = false;

}
}

int LibraryQuery::GetSecondsFromToken(QString val) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int LibraryQuery::GetSecondsFromToken(const QString& val) const

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

} else if (c == 'h') {
seconds += intVal * 60 * 60;
} else if (c == 'd') {
seconds += intVal * 60 * 60 * 24;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kSecsPerDay

{"stream", Song::Type_Stream},
{"unknown", Song::Type_Unknown}});

const int kNsecsPerSec = 1e9;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These constants already exist somewhere in Clementine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hatstand hatstand merged commit bae968a into clementine-player:master Oct 3, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants