digiKam Developer Documentation
Professional Photo Management with the Power of Open Source
Loading...
Searching...
No Matches
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 , SortByPickLabel , SortByColorLabel ,
  SortByFormat
}

Public Member Functions

int compare (const CamItemInfo &left, const CamItemInfo &right) const
 Compares the camItemInfos left and right.
int compare (const CamItemInfo &left, const CamItemInfo &right, SortRole sortRole) const
int compareCategories (const CamItemInfo &left, const CamItemInfo &right) const
 Compares the categories of left and right camItemInfos.
bool isCategorized () const
bool lessThan (const CamItemInfo &left, const CamItemInfo &right) const
 Returns true if left is less than right.
bool lessThan (const QVariant &left, const QVariant &right) const
 Returns true if left QVariant is less than right.
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)

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)
 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.
template<typename T>
static int compareValue (const T &a, const T &b)
 Returns the usual compare result of -1, 0, or 1 for lessThan, equals and greaterThan.
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)
 Returns a < b if sortOrder is Ascending, or b < a if order is descending.
static int naturalCompare (const QString &a, const QString &b, Qt::SortOrder sortOrder, Qt::CaseSensitivity caseSensitive=Qt::CaseSensitive, bool natural=true)
 Compares the two string by natural comparison and adheres to given sort order.

Public Attributes

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

Member Enumeration Documentation

◆ SortOrder

Enumerator
DefaultOrder 

sort order depends on the chosen sort role

Member Function Documentation

◆ compare()

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

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.

◆ compareCategories()

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

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.

◆ lessThan() [1/2]

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

Adheres to current sort role and sort order.

◆ lessThan() [2/2]

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

Adheres to current sort role and sort order.