summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qcollator.h
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2013-09-10 03:46:06 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-13 05:47:55 +0200
commitc517a6d6ff70235ed3a3b93a87948add1de743ed (patch)
tree6cef21f4479332cea6e777bafc8a5248e8a61bd0 /src/corelib/tools/qcollator.h
parentec64d514fbf7bc6a6ccf5ee2342734a4719fc634 (diff)
Refactor QCollator to be able to use it in different platforms
Propose the API to be changed so that we can implement QCollator in the different platforms where Qt is available. Change-Id: I7b3e933d7e3d1aa26c1b78d21ef75b71c692827f Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qcollator.h')
-rw-r--r--src/corelib/tools/qcollator.h70
1 files changed, 33 insertions, 37 deletions
diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h
index 02470c331f..677092c718 100644
--- a/src/corelib/tools/qcollator.h
+++ b/src/corelib/tools/qcollator.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Aleix Pol Gonzalez <aleixpol@kde.org>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -39,36 +40,46 @@
**
****************************************************************************/
-#ifndef QCOLLATOR_P_H
-#define QCOLLATOR_P_H
+#ifndef QCOLLATOR_H
+#define QCOLLATOR_H
#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
#include <QtCore/qlocale.h>
QT_BEGIN_NAMESPACE
class QCollatorPrivate;
+class QCollatorSortKeyPrivate;
+
+class Q_CORE_EXPORT QCollatorSortKey
+{
+ friend class QCollator;
+public:
+ QCollatorSortKey(const QCollatorSortKey &other);
+ ~QCollatorSortKey();
+ QCollatorSortKey &operator=(const QCollatorSortKey &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QCollatorSortKey &operator=(QCollatorSortKey &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+
+ bool operator<(const QCollatorSortKey &key) const;
+ int compare(const QCollatorSortKey &key) const;
+
+protected:
+ QCollatorSortKey(QCollatorSortKeyPrivate*);
+
+ QSharedDataPointer<QCollatorSortKeyPrivate> d;
+
+private:
+ QCollatorSortKey();
+};
class Q_CORE_EXPORT QCollator
{
public:
- enum Collation {
- Default,
- Big5Han,
- Dictionary,
- Direct,
- GB2312Han,
- PhoneBook,
- Pinyin,
- Phonetic,
- Reformed,
- Standard,
- Stroke,
- Traditional,
- UniHan
- };
-
- QCollator(const QLocale &locale = QLocale(), QCollator::Collation collation = QCollator::Default);
+ QCollator(const QLocale &locale = QLocale());
QCollator(const QCollator &);
~QCollator();
QCollator &operator=(const QCollator &);
@@ -76,20 +87,8 @@ public:
void setLocale(const QLocale &locale);
QLocale locale() const;
- void setCollation(Collation collation);
- Collation collation() const;
-
- QString identifier() const;
- static QCollator fromIdentifier(const QString &identifier);
-
- enum CasePreference {
- CasePreferenceOff = 0x0,
- CasePreferenceUpper = 0x1,
- CasePreferenceLower = 0x2
- };
-
- CasePreference casePreference() const;
- void setCasePreference(CasePreference preference);
+ Qt::CaseSensitivity caseSensitivity() const;
+ void setCaseSensitivity(Qt::CaseSensitivity cs);
void setNumericMode(bool on);
bool numericMode() const;
@@ -104,15 +103,12 @@ public:
bool operator()(const QString &s1, const QString &s2) const
{ return compare(s1, s2) < 0; }
- QByteArray sortKey(const QString &string) const;
-
- QStringList indexCharacters() const;
+ QCollatorSortKey sortKey(const QString &string) const;
private:
QCollatorPrivate *d;
void detach();
- void init();
};
QT_END_NAMESPACE