#[repr(C)]pub struct QCollator { /* private fields */ }
Expand description
The QCollator class compares strings according to a localized collation algorithm.
C++ class: QCollator
.
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
impl QCollator
sourcepub unsafe fn call_2_q_string(
&self,
s1: impl CastInto<Ref<QString>>,
s2: impl CastInto<Ref<QString>>
) -> bool
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
.
sourcepub 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.
pub unsafe fn call_2_q_string_view( &self, s1: impl CastInto<Ref<QStringView>>, s2: impl CastInto<Ref<QStringView>> ) -> bool
cpp_lib_version="5.14.0"
only.Calls C++ function: bool QCollator::operator()(QStringView s1, QStringView s2) const
.
sourcepub unsafe fn case_sensitivity(&self) -> CaseSensitivity
pub unsafe fn case_sensitivity(&self) -> CaseSensitivity
Returns case sensitivity of the collator.
Calls C++ function: Qt::CaseSensitivity QCollator::caseSensitivity() const
.
Returns case sensitivity of the collator.
See also setCaseSensitivity().
sourcepub unsafe fn compare_2_q_string(
&self,
s1: impl CastInto<Ref<QString>>,
s2: impl CastInto<Ref<QString>>
) -> c_int
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
.
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.
sourcepub unsafe fn compare_2_q_string_ref(
&self,
s1: impl CastInto<Ref<QStringRef>>,
s2: impl CastInto<Ref<QStringRef>>
) -> c_int
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
.
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.
sourcepub 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
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
.
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.
sourcepub 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.
pub unsafe fn compare_2_q_string_view( &self, s1: impl CastInto<Ref<QStringView>>, s2: impl CastInto<Ref<QStringView>> ) -> c_int
cpp_lib_version="5.14.0"
only.Compares s1 with s2.
Calls C++ function: int QCollator::compare(QStringView s1, QStringView s2) const
.
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.
sourcepub unsafe fn copy_from(
&self,
arg1: impl CastInto<Ref<QCollator>>
) -> Ref<QCollator>
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)
.
Assigns other to this collator.
sourcepub unsafe fn ignore_punctuation(&self) -> bool
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
.
Returns true
if punctuation characters and symbols are ignored when determining sort order.
See also setIgnorePunctuation().
sourcepub unsafe fn locale(&self) -> CppBox<QLocale>
pub unsafe fn locale(&self) -> CppBox<QLocale>
Returns the locale of the collator.
Calls C++ function: QLocale QCollator::locale() const
.
Returns the locale of the collator.
See also setLocale().
sourcepub unsafe fn new_1a(locale: impl CastInto<Ref<QLocale>>) -> CppBox<QCollator>
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 = …)
.
sourcepub unsafe fn new_0a() -> CppBox<QCollator>
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()
.
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.
sourcepub unsafe fn new_copy(arg1: impl CastInto<Ref<QCollator>>) -> CppBox<QCollator>
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)
.
Creates a copy of other.
sourcepub unsafe fn numeric_mode(&self) -> bool
pub unsafe fn numeric_mode(&self) -> bool
Returns true
if numeric sorting is enabled, false otherwise.
Calls C++ function: bool QCollator::numericMode() const
.
Returns true
if numeric sorting is enabled, false otherwise.
See also setNumericMode().
sourcepub unsafe fn set_case_sensitivity(&self, cs: CaseSensitivity)
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)
.
Sets the case sensitivity of the collator.
See also caseSensitivity().
sourcepub unsafe fn set_ignore_punctuation(&self, on: bool)
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)
.
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().
sourcepub unsafe fn set_locale(&self, locale: impl CastInto<Ref<QLocale>>)
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)
.
Sets the locale of the collator to locale.
See also locale().
sourcepub unsafe fn set_numeric_mode(&self, on: bool)
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)
.
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().
sourcepub unsafe fn sort_key(
&self,
string: impl CastInto<Ref<QString>>
) -> CppBox<QCollatorSortKey>
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
.
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.