digiKam
Digikam::CamItemSortSettings Class Reference

Public Types

enum  CategorizationMode { NoCategories , CategoryByFolder , CategoryByFormat , CategoryByDate }
 
enum  SortOrder { AscendingOrder = Qt::AscendingOrder , DescendingOrder = Qt::DescendingOrder , DefaultOrder }
 
enum  SortRole {
  SortByFileName , SortByFilePath , SortByCreationDate , SortByFileSize ,
  SortByDownloadState , SortByRating
}
 

Public Member Functions

 CamItemSortSettings ()
 
int compare (const CamItemInfo &left, const CamItemInfo &right) const
 
int compare (const CamItemInfo &left, const CamItemInfo &right, SortRole sortRole) const
 
int compareCategories (const CamItemInfo &left, const CamItemInfo &right) const
 
bool isCategorized () const
 
bool lessThan (const CamItemInfo &left, const CamItemInfo &right) const
 
bool lessThan (const QVariant &left, const QVariant &right) const
 
bool operator== (const CamItemSortSettings &other) const
 
void setCategorizationMode (CategorizationMode mode)
 
void setCategorizationSortOrder (SortOrder order)
 
void setSortOrder (SortOrder order)
 
void setSortRole (SortRole role)
 
void setStringTypeNatural (bool natural)
 
 ~CamItemSortSettings ()
 

Static Public Member Functions

template<typename T >
static int compareByOrder (const T &a, const T &b, Qt::SortOrder sortOrder)
 
static int compareByOrder (int compareResult, Qt::SortOrder sortOrder)
 
template<typename T >
static int compareValue (const T &a, const T &b)
 
static Qt::SortOrder defaultSortOrderForCategorizationMode (CategorizationMode mode)
 
static Qt::SortOrder defaultSortOrderForSortRole (SortRole role)
 
template<typename T >
static bool lessThanByOrder (const T &a, const T &b, Qt::SortOrder sortOrder)
 
static int naturalCompare (const QString &a, const QString &b, Qt::SortOrder sortOrder, Qt::CaseSensitivity caseSensitive=Qt::CaseSensitive, bool natural=true)
 

Public Attributes

Qt::CaseSensitivity categorizationCaseSensitivity
 
CategorizationMode categorizationMode
 
SortOrder categorizationSortOrder
 
Qt::SortOrder currentCategorizationSortOrder
 Only Ascending or Descending, never be DefaultOrder. More...
 
Qt::SortOrder currentSortOrder
 
Qt::CaseSensitivity sortCaseSensitivity
 
SortOrder sortOrder
 Camera Items Sorting. More...
 
SortRole sortRole
 
bool strTypeNatural
 

Member Enumeration Documentation

◆ CategorizationMode

Enumerator
NoCategories 
CategoryByFolder 
CategoryByFormat 
CategoryByDate 

◆ SortOrder

Enumerator
AscendingOrder 
DescendingOrder 
DefaultOrder 

sort order depends on the chosen sort role

◆ SortRole

Enumerator
SortByFileName 
SortByFilePath 
SortByCreationDate 
SortByFileSize 
SortByDownloadState 
SortByRating 

Constructor & Destructor Documentation

◆ CamItemSortSettings()

Digikam::CamItemSortSettings::CamItemSortSettings ( )

◆ ~CamItemSortSettings()

Digikam::CamItemSortSettings::~CamItemSortSettings ( )

Member Function Documentation

◆ compare() [1/2]

int Digikam::CamItemSortSettings::compare ( const CamItemInfo left,
const CamItemInfo right 
) const

Compares the camItemInfos left and right. Return -1 if left is less than right, 1 if left is greater than right, and 0 if left equals right comparing the current sort role's value. Adheres to set sort role and sort order.

References sortRole.

Referenced by lessThan().

◆ compare() [2/2]

◆ compareByOrder() [1/2]

template<typename T >
static int Digikam::CamItemSortSettings::compareByOrder ( const T a,
const T b,
Qt::SortOrder  sortOrder 
)
inlinestatic

◆ compareByOrder() [2/2]

static int Digikam::CamItemSortSettings::compareByOrder ( int  compareResult,
Qt::SortOrder  sortOrder 
)
inlinestatic

Takes a typical result from a compare method (0 is equal, -1 is less than, 1 is greater than) and applies the given sort order to it.

References sortOrder.

Referenced by compare(), compareByOrder(), compareCategories(), lessThan(), and naturalCompare().

◆ compareCategories()

int Digikam::CamItemSortSettings::compareCategories ( const CamItemInfo left,
const CamItemInfo right 
) const

Compares the categories of left and right camItemInfos. It returns -1 if the left camItemInfo is less than right, and 0 if both fall in the same category, and 1 if the left camItemInfo is greater than right. Adheres to set categorization mode and current category sort order.

References categorizationCaseSensitivity, categorizationMode, CategoryByDate, CategoryByFolder, CategoryByFormat, compareByOrder(), Digikam::CamItemInfo::ctime, currentCategorizationSortOrder, Digikam::CamItemInfo::folder, Digikam::CamItemInfo::mime, naturalCompare(), NoCategories, and strTypeNatural.

◆ compareValue()

template<typename T >
static int Digikam::CamItemSortSettings::compareValue ( const T a,
const T b 
)
inlinestatic

Returns the usual compare result of -1, 0, or 1 for lessThan, equals and greaterThan.

Referenced by compareByOrder().

◆ defaultSortOrderForCategorizationMode()

Qt::SortOrder Digikam::CamItemSortSettings::defaultSortOrderForCategorizationMode ( CategorizationMode  mode)
static

◆ defaultSortOrderForSortRole()

Qt::SortOrder Digikam::CamItemSortSettings::defaultSortOrderForSortRole ( SortRole  role)
static

◆ isCategorized()

bool Digikam::CamItemSortSettings::isCategorized ( ) const
inline

◆ lessThan() [1/2]

bool Digikam::CamItemSortSettings::lessThan ( const CamItemInfo left,
const CamItemInfo right 
) const

Returns true if left is less than right. Adheres to current sort role and sort order.

References compare(), SortByCreationDate, SortByDownloadState, SortByFileName, SortByFilePath, SortByFileSize, SortByRating, and sortRole.

◆ lessThan() [2/2]

bool Digikam::CamItemSortSettings::lessThan ( const QVariant &  left,
const QVariant &  right 
) const

Returns true if left QVariant is less than right. Adheres to current sort role and sort order.

References compareByOrder(), currentSortOrder, naturalCompare(), sortCaseSensitivity, and strTypeNatural.

◆ lessThanByOrder()

template<typename T >
static bool Digikam::CamItemSortSettings::lessThanByOrder ( const T a,
const T b,
Qt::SortOrder  sortOrder 
)
inlinestatic

Returns a < b if sortOrder is Ascending, or b < a if order is descending

References sortOrder.

◆ naturalCompare()

static int Digikam::CamItemSortSettings::naturalCompare ( const QString &  a,
const QString &  b,
Qt::SortOrder  sortOrder,
Qt::CaseSensitivity  caseSensitive = Qt::CaseSensitive,
bool  natural = true 
)
inlinestatic

Compares the two string by natural comparison and adheres to given sort order

References compareByOrder(), Digikam::ItemSortCollator::instance(), Digikam::ItemSortCollator::itemCompare(), and sortOrder.

Referenced by compare(), compareCategories(), and lessThan().

◆ operator==()

bool Digikam::CamItemSortSettings::operator== ( const CamItemSortSettings other) const

◆ setCategorizationMode()

void Digikam::CamItemSortSettings::setCategorizationMode ( CategorizationMode  mode)

◆ setCategorizationSortOrder()

void Digikam::CamItemSortSettings::setCategorizationSortOrder ( SortOrder  order)

◆ setSortOrder()

void Digikam::CamItemSortSettings::setSortOrder ( SortOrder  order)

◆ setSortRole()

void Digikam::CamItemSortSettings::setSortRole ( SortRole  role)

◆ setStringTypeNatural()

void Digikam::CamItemSortSettings::setStringTypeNatural ( bool  natural)

References strTypeNatural.

Member Data Documentation

◆ categorizationCaseSensitivity

Qt::CaseSensitivity Digikam::CamItemSortSettings::categorizationCaseSensitivity

Referenced by compareCategories(), and operator==().

◆ categorizationMode

CategorizationMode Digikam::CamItemSortSettings::categorizationMode

◆ categorizationSortOrder

SortOrder Digikam::CamItemSortSettings::categorizationSortOrder

◆ currentCategorizationSortOrder

Qt::SortOrder Digikam::CamItemSortSettings::currentCategorizationSortOrder

Only Ascending or Descending, never be DefaultOrder.

Referenced by compareCategories(), setCategorizationMode(), and setCategorizationSortOrder().

◆ currentSortOrder

Qt::SortOrder Digikam::CamItemSortSettings::currentSortOrder

◆ sortCaseSensitivity

Qt::CaseSensitivity Digikam::CamItemSortSettings::sortCaseSensitivity

Referenced by compare(), lessThan(), and operator==().

◆ sortOrder

SortOrder Digikam::CamItemSortSettings::sortOrder

◆ sortRole

SortRole Digikam::CamItemSortSettings::sortRole

◆ strTypeNatural

bool Digikam::CamItemSortSettings::strTypeNatural

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