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_caseSensitive {Qt::CaseInsensitive}
 Whether sorting two strings should ignore upper/lower case. More...
 
SortPrefixMode m_prefixMode {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_prefixesRegex {QRegularExpression()}
 A regular expression used for removing a leading prefix. More...
 
QRegularExpression m_prefixesRegex2 {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_exclList {QStringList()}
 The m_exclusion string converted into a string list. More...
 
SortExclusionMode m_exclMode {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 49 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 101 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 81 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 163 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 196 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_caseSensitive

Qt::CaseSensitivity MythSortHelper::m_caseSensitive {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_prefixMode

SortPrefixMode MythSortHelper::m_prefixMode {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_prefixesRegex

QRegularExpression MythSortHelper::m_prefixesRegex {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_prefixesRegex2

QRegularExpression MythSortHelper::m_prefixesRegex2 {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_exclList

QStringList MythSortHelper::m_exclList {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_exclMode

SortExclusionMode MythSortHelper::m_exclMode {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: