Struct qt_core::QCollator

source ·
#[repr(C)]
pub struct QCollator { /* private fields */ }
Expand description

The QCollator class compares strings according to a localized collation algorithm.

C++ class: QCollator.

C++ documentation:

The QCollator class compares strings according to a localized collation algorithm.

QCollator is initialized with a QLocale and an optional collation strategy. It tries to initialize the collator with the specified values. The collator can then be used to compare and sort strings in a locale dependent fashion.

A QCollator object can be used together with template based sorting algorithms such as std::sort to sort a list of QStrings.

In addition to the locale and collation strategy, several optional flags can be set that influence the result of the collation.

Implementations§

source§

impl QCollator

source

pub unsafe fn call_2_q_string( &self, s1: impl CastInto<Ref<QString>>, s2: impl CastInto<Ref<QString>> ) -> bool

Calls C++ function: bool QCollator::operator()(const QString& s1, const QString& s2) const.

source

pub unsafe fn call_2_q_string_view( &self, s1: impl CastInto<Ref<QStringView>>, s2: impl CastInto<Ref<QStringView>> ) -> bool

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: bool QCollator::operator()(QStringView s1, QStringView s2) const.

source

pub unsafe fn case_sensitivity(&self) -> CaseSensitivity

Returns case sensitivity of the collator.

Calls C++ function: Qt::CaseSensitivity QCollator::caseSensitivity() const.

C++ documentation:

Returns case sensitivity of the collator.

See also setCaseSensitivity().

source

pub unsafe fn compare_2_q_string( &self, s1: impl CastInto<Ref<QString>>, s2: impl CastInto<Ref<QString>> ) -> c_int

Compares s1 with s2. Returns an integer less than, equal to, or greater than zero depending on whether s1 is smaller, equal or larger than s2.

Calls C++ function: int QCollator::compare(const QString& s1, const QString& s2) const.

C++ documentation:

Compares s1 with s2. Returns an integer less than, equal to, or greater than zero depending on whether s1 is smaller, equal or larger than s2.

source

pub unsafe fn compare_2_q_string_ref( &self, s1: impl CastInto<Ref<QStringRef>>, s2: impl CastInto<Ref<QStringRef>> ) -> c_int

This is an overloaded function.

Calls C++ function: int QCollator::compare(const QStringRef& s1, const QStringRef& s2) const.

C++ documentation:

This is an overloaded function.

Compares s1 with s2. Returns an integer less than, equal to, or greater than zero depending on whether s1 is smaller, equal or larger than s2.

source

pub unsafe fn compare_q_char_int_q_char_int( &self, s1: impl CastInto<Ptr<QChar>>, len1: c_int, s2: impl CastInto<Ptr<QChar>>, len2: c_int ) -> c_int

This is an overloaded function.

Calls C++ function: int QCollator::compare(const QChar* s1, int len1, const QChar* s2, int len2) const.

C++ documentation:

This is an overloaded function.

Compares s1 with s2. len1 and len2 specify the length of the QChar arrays pointer to by s1 and s2.

Returns an integer less than, equal to, or greater than zero depending on whether s1 is smaller, equal or larger than s2.

source

pub unsafe fn compare_2_q_string_view( &self, s1: impl CastInto<Ref<QStringView>>, s2: impl CastInto<Ref<QStringView>> ) -> c_int

Available on cpp_lib_version="5.14.0" only.

Compares s1 with s2.

Calls C++ function: int QCollator::compare(QStringView s1, QStringView s2) const.

C++ documentation:

Compares s1 with s2.

Returns an integer less than, equal to, or greater than zero depending on whether s1 sorts before, with or after s2.

This function was introduced in Qt 5.13.

source

pub unsafe fn copy_from( &self, arg1: impl CastInto<Ref<QCollator>> ) -> Ref<QCollator>

Assigns other to this collator.

Calls C++ function: QCollator& QCollator::operator=(const QCollator& arg1).

C++ documentation:

Assigns other to this collator.

source

pub unsafe fn ignore_punctuation(&self) -> bool

Returns true if punctuation characters and symbols are ignored when determining sort order.

Calls C++ function: bool QCollator::ignorePunctuation() const.

C++ documentation:

Returns true if punctuation characters and symbols are ignored when determining sort order.

See also setIgnorePunctuation().

source

pub unsafe fn locale(&self) -> CppBox<QLocale>

Returns the locale of the collator.

Calls C++ function: QLocale QCollator::locale() const.

C++ documentation:

Returns the locale of the collator.

See also setLocale().

source

pub unsafe fn new_1a(locale: impl CastInto<Ref<QLocale>>) -> CppBox<QCollator>

Constructs a QCollator from locale. If locale is not specified the system's default locale is used.

Calls C++ function: [constructor] void QCollator::QCollator(const QLocale& locale = …).

C++ documentation:

Constructs a QCollator from locale. If locale is not specified the system’s default locale is used.

See also setLocale().

source

pub unsafe fn new_0a() -> CppBox<QCollator>

The QCollator class compares strings according to a localized collation algorithm.

Calls C++ function: [constructor] void QCollator::QCollator().

C++ documentation:

The QCollator class compares strings according to a localized collation algorithm.

QCollator is initialized with a QLocale and an optional collation strategy. It tries to initialize the collator with the specified values. The collator can then be used to compare and sort strings in a locale dependent fashion.

A QCollator object can be used together with template based sorting algorithms such as std::sort to sort a list of QStrings.

In addition to the locale and collation strategy, several optional flags can be set that influence the result of the collation.

source

pub unsafe fn new_copy(arg1: impl CastInto<Ref<QCollator>>) -> CppBox<QCollator>

Creates a copy of other.

Calls C++ function: [constructor] void QCollator::QCollator(const QCollator& arg1).

C++ documentation:

Creates a copy of other.

source

pub unsafe fn numeric_mode(&self) -> bool

Returns true if numeric sorting is enabled, false otherwise.

Calls C++ function: bool QCollator::numericMode() const.

C++ documentation:

Returns true if numeric sorting is enabled, false otherwise.

See also setNumericMode().

source

pub unsafe fn set_case_sensitivity(&self, cs: CaseSensitivity)

Sets the case sensitivity of the collator.

Calls C++ function: void QCollator::setCaseSensitivity(Qt::CaseSensitivity cs).

C++ documentation:

Sets the case sensitivity of the collator.

See also caseSensitivity().

source

pub unsafe fn set_ignore_punctuation(&self, on: bool)

If on is set to true, punctuation characters and symbols are ignored when determining sort order.

Calls C++ function: void QCollator::setIgnorePunctuation(bool on).

C++ documentation:

If on is set to true, punctuation characters and symbols are ignored when determining sort order.

The default is locale dependent.

Note: This method is not currently supported if Qt is configured to not use ICU on Linux.

See also ignorePunctuation().

source

pub unsafe fn set_locale(&self, locale: impl CastInto<Ref<QLocale>>)

Sets the locale of the collator to locale.

Calls C++ function: void QCollator::setLocale(const QLocale& locale).

C++ documentation:

Sets the locale of the collator to locale.

See also locale().

source

pub unsafe fn set_numeric_mode(&self, on: bool)

Enables numeric sorting mode when on is set to true.

Calls C++ function: void QCollator::setNumericMode(bool on).

C++ documentation:

Enables numeric sorting mode when on is set to true.

This will enable proper sorting of numeric digits, so that e.g. 100 sorts after 99.

By default this mode is off.

Note: On Windows, this functionality makes use of the ICU library. If Qt was compiled without ICU support, it falls back to code using native Windows API, which only works from Windows 7 onwards. On older versions of Windows, it will not work and a warning will be emitted at runtime.

See also numericMode().

source

pub unsafe fn sort_key( &self, string: impl CastInto<Ref<QString>> ) -> CppBox<QCollatorSortKey>

Returns a sortKey for string.

Calls C++ function: QCollatorSortKey QCollator::sortKey(const QString& string) const.

C++ documentation:

Returns a sortKey for string.

Creating the sort key is usually somewhat slower, than using the compare() methods directly. But if the string is compared repeatedly (e.g. when sorting a whole list of strings), it's usually faster to create the sort keys for each string and then sort using the keys.

source

pub unsafe fn swap(&self, other: impl CastInto<Ref<QCollator>>)

Swaps this collator with other. This function is very fast and never fails.

Calls C++ function: void QCollator::swap(QCollator& other).

C++ documentation:

Swaps this collator with other. This function is very fast and never fails.

Trait Implementations§

source§

impl CppDeletable for QCollator

source§

unsafe fn delete(&self)

Destroys the collator.

Calls C++ function: [destructor] void QCollator::~QCollator().

C++ documentation:

Destroys the collator.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.