22 "Regular Expression for what to ignore when sorting");
63 ? Qt::CaseSensitive : Qt::CaseInsensitive;
87 Qt::CaseSensitivity case_sensitive,
90 m_caseSensitive(case_sensitive),
91 m_prefixMode(prefix_mode),
92 m_exclusions(std::move(exclusions))
108 if (other ==
nullptr)
110 LOG(VB_GENERAL, LOG_ERR,
111 QString(
"MythSortHelper created from null pointer."));
124static std::shared_ptr<MythSortHelper>
singleton =
nullptr;
137 singleton = std::make_shared<MythSortHelper>();
169 QString ltitle = title;
171 ltitle = ltitle.toLower();
179 for (
const auto& str : std::as_const(
m_exclList))
180 if (ltitle.startsWith(str))
202 QString lpathname = pathname;
204 lpathname = lpathname.toLower();
207 QStringList parts = lpathname.split(
"/");
209 for (
int i = 0; i < parts.size(); ++i) {
210 if (std::ranges::any_of(std::as_const(
m_exclList),
211 [&parts,i](
const QString& excl)
212 {
return parts[i].startsWith(excl); } ))
219 return parts.join(
"/");
QString GetSetting(const QString &key, const QString &defaultval="")
bool GetBoolSetting(const QString &key, bool defaultval=false)
A class to consolidate all the soring functions.
Qt::CaseSensitivity m_caseSensitive
Whether sorting two strings should ignore upper/lower case.
SortPrefixMode m_prefixMode
Whether or not to ignore prefix words (like A, An, and The) when sorting two strings.
bool hasPrefixes(void)
Does the language translation specify any prefixes.
QStringList m_exclList
The m_exclusion string converted into a string list.
QRegularExpression m_prefixesRegex2
A regular expression used for moving leading prefix to the end of a string.
QString doPathname(const QString &pathname) const
Create the sortable form of an item.
QRegularExpression m_prefixesRegex
A regular expression used for removing a leading prefix.
QString m_exclusions
A string containing names that should be ignored when greating the sortable form of a title.
QString doTitle(const QString &title) const
Create the sortable form of an title string.
QString m_prefixes
A string containing the regular expression of prefixes to ignore when sorting.
void MythSortHelperCommon(void)
Common code for creating a MythSortHelper object.
MythSortHelper()
Create a MythSortHelper object.
SortExclusionMode m_exclMode
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static std::shared_ptr< MythSortHelper > singleton
std::shared_ptr< MythSortHelper > getMythSortHelper(void)
Get a pointer to the MythSortHelper singleton.
void resetMythSortHelper(void)
Delete the MythSortHelper singleton.