[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/textshape-stylesWidget-PierreSt] plugins/textshape/dialogs: Fix sorting of style names.
From:       Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date:       2012-12-30 10:35:45
Message-ID: 20121230103545.87928A6091 () git ! kde ! org
[Download RAW message or body]

Git commit 7ea974af2415e3c4aa4ed6f4f2ce1c02f1e20b38 by Pierre Stirnweiss.
Committed on 30/12/2012 at 10:28.
Pushed by pstirnweiss into branch 'textshape-stylesWidget-PierreSt'.

Fix sorting of style names.

The style names were not sorted in natural order.
Use KStringHandler::naturalCompare to fix the problem.

The sorting of styles per category (ie. list styles,...) belongs to
a wish item, and needs debating first.
BUG: 288651
REVIEW: 108020

M  +7    -6    plugins/textshape/dialogs/DockerStylesComboModel.cpp
M  +7    -6    plugins/textshape/dialogs/StylesModel.cpp

http://commits.kde.org/calligra/7ea974af2415e3c4aa4ed6f4f2ce1c02f1e20b38

diff --git a/plugins/textshape/dialogs/DockerStylesComboModel.cpp \
b/plugins/textshape/dialogs/DockerStylesComboModel.cpp index c1ffaa1..a669b77 100644
--- a/plugins/textshape/dialogs/DockerStylesComboModel.cpp
+++ b/plugins/textshape/dialogs/DockerStylesComboModel.cpp
@@ -24,6 +24,7 @@
 #include <KoStyleManager.h>
 
 #include <KLocale>
+#include <KStringHandler>
 
 #include <KDebug>
 
@@ -118,7 +119,7 @@ void DockerStylesComboModel::setStyleManager(KoStyleManager *sm)
                 for ( ; begin != m_usedStyles.end(); ++begin) {
                     if (m_sourceModel->index(*begin, 0, QModelIndex()).internalId() \
!= -1) { //styleNone (internalId=-1) is a virtual style provided only for the UI. it \
                does not exist in KoStyleManager
                         KoCharacterStyle *s = \
m_styleManager->characterStyle(m_sourceModel->index(*begin, 0, \
                QModelIndex()).internalId());
-                        if (QString::localeAwareCompare(compareStyle->name(), \
s->name()) < 0) { +                        if \
(KStringHandler::naturalCompare(compareStyle->name(), s->name()) < 0) {  break;
                         }
                     }
@@ -137,7 +138,7 @@ void DockerStylesComboModel::setStyleManager(KoStyleManager *sm)
                 for ( ; begin != m_usedStyles.end(); ++begin) {
                     if (m_sourceModel->index(*begin, 0, QModelIndex()).internalId() \
!= -1) { //styleNone (internalId=-1) is a virtual style provided only for the UI. it \
                does not exist in KoStyleManager
                         KoParagraphStyle *s = \
m_styleManager->paragraphStyle(m_sourceModel->index(*begin, 0, \
                QModelIndex()).internalId());
-                        if (QString::localeAwareCompare(compareStyle->name(), \
s->name()) < 0) { +                        if \
(KStringHandler::naturalCompare(compareStyle->name(), s->name()) < 0) {  break;
                         }
                     }
@@ -159,7 +160,7 @@ void DockerStylesComboModel::styleApplied(const KoCharacterStyle \
*style)  for ( ; begin != m_usedStyles.end(); ++begin) {
                 if (m_sourceModel->index(*begin, 0, QModelIndex()).internalId() != \
-1) { //styleNone (internalId=-1) is a virtual style provided only for the UI. it \
                does not exist in KoStyleManager
                     KoCharacterStyle *s = \
m_styleManager->characterStyle(m_sourceModel->index(*begin, 0, \
                QModelIndex()).internalId());
-                    if (QString::localeAwareCompare(style->name(), s->name()) < 0) {
+                    if (KStringHandler::naturalCompare(style->name(), s->name()) < \
0) {  break;
                     }
                 }
@@ -170,7 +171,7 @@ void DockerStylesComboModel::styleApplied(const KoCharacterStyle \
*style)  QVector<int>::iterator begin = m_usedStyles.begin();
             for ( ; begin != m_usedStyles.end(); ++begin) {
                 KoParagraphStyle *s = \
m_styleManager->paragraphStyle(m_sourceModel->index(*begin, 0, \
                QModelIndex()).internalId());
-                if (QString::localeAwareCompare(style->name(), s->name()) < 0) {
+                if (KStringHandler::naturalCompare(style->name(), s->name()) < 0) {
                     break;
                 }
             }
@@ -214,7 +215,7 @@ void DockerStylesComboModel::createMapping()
                         QVector<int>::iterator begin = m_unusedStyles.begin();
                         for ( ; begin != m_unusedStyles.end(); ++begin) {
                             KoParagraphStyle *style = \
m_styleManager->paragraphStyle(m_sourceModel->index(*begin, 0, \
                QModelIndex()).internalId());
-                            if (QString::localeAwareCompare(paragStyle->name(), \
style->name()) < 0) { +                            if \
(KStringHandler::naturalCompare(paragStyle->name(), style->name()) < 0) {  break;
                             }
                         }
@@ -232,7 +233,7 @@ void DockerStylesComboModel::createMapping()
                         QVector<int>::iterator begin = m_unusedStyles.begin();
                         for ( ; begin != m_unusedStyles.end(); ++begin) {
                             KoCharacterStyle *style = \
m_styleManager->characterStyle(m_sourceModel->index(*begin, 0, \
                QModelIndex()).internalId());
-                            if (QString::localeAwareCompare(charStyle->name(), \
style->name()) < 0) { +                            if \
(KStringHandler::naturalCompare(charStyle->name(), style->name()) < 0) {  break;
                             }
                         }
diff --git a/plugins/textshape/dialogs/StylesModel.cpp \
b/plugins/textshape/dialogs/StylesModel.cpp index 4b1b9f6..0e33084 100644
--- a/plugins/textshape/dialogs/StylesModel.cpp
+++ b/plugins/textshape/dialogs/StylesModel.cpp
@@ -30,6 +30,7 @@
 #include <QSharedPointer>
 #include <QSignalMapper>
 
+#include <KStringHandler>
 #include <KLocale>
 #include <KDebug>
 
@@ -322,7 +323,7 @@ void StylesModel::addParagraphStyle(KoParagraphStyle *style)
             s = m_draftParStyleList[*begin];
         // s should be found as the manager and the m_styleList should be in sync
         Q_ASSERT(s);
-        if (QString::localeAwareCompare(style->name(), s->name()) < 0) {
+        if (KStringHandler::naturalCompare(style->name(),s->name()) < 0) {
             break;
         }
         ++index;
@@ -338,7 +339,7 @@ bool sortParagraphStyleByName(KoParagraphStyle *style1, \
KoParagraphStyle *style2  {
     Q_ASSERT(style1);
     Q_ASSERT(style2);
-    return QString::localeAwareCompare(style1->name(), style2->name()) < 0;
+    return KStringHandler::naturalCompare(style1->name(), style2->name()) < 0;
 }
 
 void StylesModel::updateParagraphStyles()
@@ -378,7 +379,7 @@ void StylesModel::addCharacterStyle(KoCharacterStyle *style)
             s = m_draftCharStyleList[*begin];
         // s should be found as the manager and the m_styleList should be in sync
         Q_ASSERT(s);
-        if (QString::localeAwareCompare(style->name(), s->name()) < 0) {
+        if (KStringHandler::naturalCompare(style->name(),s->name()) < 0) {
             break;
         }
         ++index;
@@ -394,7 +395,7 @@ bool sortCharacterStyleByName(KoCharacterStyle *style1, \
KoCharacterStyle *style2  {
     Q_ASSERT(style1);
     Q_ASSERT(style2);
-    return QString::localeAwareCompare(style1->name(), style2->name()) < 0;
+    return KStringHandler::naturalCompare(style1->name(), style2->name()) < 0;
 }
 
 void StylesModel::updateCharacterStyles()
@@ -468,7 +469,7 @@ void StylesModel::updateName(int styleId)
                         s = m_draftParStyleList[*begin];
                     // s should be found as the manager and the m_styleList should \
be in sync  Q_ASSERT(s);
-                    if (QString::localeAwareCompare(paragStyle->name(), s->name()) < \
0) { +                    if (KStringHandler::naturalCompare(paragStyle->name(), \
s->name()) < 0) {  break;
                     }
                     ++newIndex;
@@ -505,7 +506,7 @@ void StylesModel::updateName(int styleId)
                         s = m_draftCharStyleList[*begin];
                     // s should be found as the manager and the m_styleList should \
be in sync  Q_ASSERT(s);
-                    if (QString::localeAwareCompare(characterStyle->name(), \
s->name()) < 0) { +                    if \
(KStringHandler::naturalCompare(characterStyle->name(), s->name()) < 0) {  break;
                     }
                     ++newIndex;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic