MythTV  master
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MythSortHelper Class Reference

A class to consolidate all the soring functions. More...

#include <mythsorthelper.h>

Public Member Functions

 MythSortHelper ()
 Create a MythSortHelper object. More...
 
 MythSortHelper (MythSortHelper *other)
 Copy a MythSortHelper object. More...
 
 MythSortHelper (Qt::CaseSensitivity case_sensitive, SortPrefixMode prefix_mode, QString exclusions)
 Fully specify the creation of a MythSortHelper object. More...
 
QString doTitle (const QString &title) const
 Create the sortable form of an title string. More...
 
QString doPathname (const QString &pathname) const
 Create the sortable form of an item. More...
 
bool hasPrefixes (void)
 Does the language translation specify any prefixes. More...
 

Private Member Functions

void MythSortHelperCommon (void)
 Common code for creating a MythSortHelper object. More...
 

Private Attributes

Qt::CaseSensitivity m_case_sensitive {Qt::CaseInsensitive}
 Whether sorting two strings should ignore upper/lower case. More...
 
SortPrefixMode m_prefix_mode {SortPrefixRemove}
 Whether or not to ignore prefix words (like A, An, and The) when sorting two strings. More...
 
QString m_prefixes {QString()}
 A string containing the regular expression of prefixes to ignore when sorting. More...
 
QRegularExpression m_prefixes_regex {QRegularExpression()}
 A regular expression used for removing a leading prefix. More...
 
QRegularExpression m_prefixes_regex2 {QRegularExpression()}
 A regular expression used for moving leading prefix to the end of a string. More...
 
QString m_exclusions {"A to Z"}
 A string containing names that should be ignored when greating the sortable form of a title. More...
 
QStringList m_excl_list {QStringList()}
 The m_exclusion string converted into a string list. More...
 
SortExclusionMode m_excl_mode {SortExclusionMatch}
 

Detailed Description

A class to consolidate all the soring functions.

Definition at line 28 of file mythsorthelper.h.

Constructor & Destructor Documentation

◆ MythSortHelper() [1/3]

MythSortHelper::MythSortHelper ( )

Create a MythSortHelper object.

Create the object and read settings from the core context.

Note
This handles the case where the gCoreContext object doesn't exists (i.e. running under the Qt test harness) which allows this code and the objects using it to be tested.

Definition at line 48 of file mythsorthelper.cpp.

◆ MythSortHelper() [2/3]

MythSortHelper::MythSortHelper ( MythSortHelper other)
explicit

Copy a MythSortHelper object.

This function is required for the shared pointer code to work.

Warning
This function should never be called directly.
Returns
A new MythSortHelper object.

Definition at line 100 of file mythsorthelper.cpp.

◆ MythSortHelper() [3/3]

MythSortHelper::MythSortHelper ( Qt::CaseSensitivity  case_sensitive,
SortPrefixMode  prefix_mode,
QString  exclusions 
)

Fully specify the creation of a MythSortHelper object.

This function creates a MythSortHelper object based on the parameters provided. It does not attempt to retrieve the user's preferred preferences from the database.

Warning
This function should never be called directly. It exists solely for use in test code.
Returns
A pointer to the MythSortHelper singleton.

Definition at line 80 of file mythsorthelper.cpp.

Member Function Documentation

◆ doTitle()

QString MythSortHelper::doTitle ( const QString &  title) const

Create the sortable form of an title string.

This function converts a title string to a version that can be used for sorting. Depending upon user settings, it may ignore the case of the string (by forcing all strings to lower case) and may strip the common prefix words "A", "An" and "The" from the beginning of the string.

Parameters
titleThe title of an item.
Returns
The conversion of the title to use when sorting.

Definition at line 155 of file mythsorthelper.cpp.

◆ doPathname()

QString MythSortHelper::doPathname ( const QString &  pathname) const

Create the sortable form of an item.

This function converts a pathname to a version that can be used for sorting. Depending upon user settings, it may ignore the case of the string (by forcing all strings to lower case) and may strip the common prefix words "A", "An" and "The" from the beginning of each component in the pathname.

Parameters
pathnameThe pathname of an item.
Returns
The conversion of the pathname to use when sorting.

Definition at line 188 of file mythsorthelper.cpp.

◆ hasPrefixes()

bool MythSortHelper::hasPrefixes ( void  )
inline

Does the language translation specify any prefixes.

Returns true if there are prefixes defined. False if there are no prefixes specified.

Definition at line 47 of file mythsorthelper.h.

Referenced by MythSortHelperCommon().

◆ MythSortHelperCommon()

void MythSortHelper::MythSortHelperCommon ( void  )
private

Common code for creating a MythSortHelper object.

Given an object with the three user specified parameters initialized, this function initializes the rest of the object.

Definition at line 14 of file mythsorthelper.cpp.

Referenced by MythSortHelper().

Member Data Documentation

◆ m_case_sensitive

Qt::CaseSensitivity MythSortHelper::m_case_sensitive {Qt::CaseInsensitive}
private

Whether sorting two strings should ignore upper/lower case.

Definition at line 53 of file mythsorthelper.h.

Referenced by doPathname(), doTitle(), MythSortHelper(), and MythSortHelperCommon().

◆ m_prefix_mode

SortPrefixMode MythSortHelper::m_prefix_mode {SortPrefixRemove}
private

Whether or not to ignore prefix words (like A, An, and The) when sorting two strings.

Definition at line 57 of file mythsorthelper.h.

Referenced by doPathname(), doTitle(), MythSortHelper(), and MythSortHelperCommon().

◆ m_prefixes

QString MythSortHelper::m_prefixes {QString()}
private

A string containing the regular expression of prefixes to ignore when sorting.

The code will ensure that this is anchored to the start of the string.

Definition at line 62 of file mythsorthelper.h.

Referenced by MythSortHelper(), and MythSortHelperCommon().

◆ m_prefixes_regex

QRegularExpression MythSortHelper::m_prefixes_regex {QRegularExpression()}
private

A regular expression used for removing a leading prefix.

It is created from m_prefixes.

Definition at line 65 of file mythsorthelper.h.

Referenced by doPathname(), doTitle(), MythSortHelper(), and MythSortHelperCommon().

◆ m_prefixes_regex2

QRegularExpression MythSortHelper::m_prefixes_regex2 {QRegularExpression()}
private

A regular expression used for moving leading prefix to the end of a string.

It is created from m_prefixes.

Definition at line 68 of file mythsorthelper.h.

Referenced by doPathname(), doTitle(), MythSortHelper(), and MythSortHelperCommon().

◆ m_exclusions

QString MythSortHelper::m_exclusions {"A to Z"}
private

A string containing names that should be ignored when greating the sortable form of a title.

Multiple titles should be separated by a semicolon. This provides a place to specify things like the show named "A to Z" should not have the prefix "A " sorted to the end of the name.

Definition at line 75 of file mythsorthelper.h.

Referenced by MythSortHelper(), and MythSortHelperCommon().

◆ m_excl_list

QStringList MythSortHelper::m_excl_list {QStringList()}
private

The m_exclusion string converted into a string list.

Definition at line 77 of file mythsorthelper.h.

Referenced by doPathname(), doTitle(), MythSortHelper(), and MythSortHelperCommon().

◆ m_excl_mode

SortExclusionMode MythSortHelper::m_excl_mode {SortExclusionMatch}
private

Definition at line 78 of file mythsorthelper.h.

Referenced by doTitle(), and MythSortHelper().


The documentation for this class was generated from the following files: