#pragma once

#include <QString>
#include <QRegularExpression>
#include <QFileInfo>

// Cleans track filenames like:
// "01 - Speak_To_Me.flac" → "Speak To Me"
// "03.Breathe.mp3"        → "Breathe"
// "7 Time.m4a"            → "Time"
static inline QString cleanTrackTitle(const QString& fileName)
{
    QString title = fileName;

    // Strip extension
    int dotIndex = title.lastIndexOf('.');
    if (dotIndex > 0)
        title = title.left(dotIndex);

    // Remove leading digits + junk like "-", "_", ".", spaces
    title.remove(QRegularExpression(R"(^\s*\d+\s*[-_\.]*\s*)"));

    // Replace underscores with spaces
    title.replace("_", " ");

    // Trim whitespace
    title = title.trimmed();

    return title;
}
