Repackaged to reduce size
[easylist] / src / mycheckboxcontainer.cpp
index edcab32..130cd0a 100755 (executable)
@@ -30,10 +30,35 @@ MyCheckBoxContainer * MyCheckBoxContainer::getInstance()
 void MyCheckBoxContainer::add(QString item)\r
 {\r
     QStringList list = item.split("\n");\r
+    QStringList list2;\r
     if(sortAlphabetically)\r
     {\r
-        list.sort();\r
+        list2.append(list.takeFirst());\r
+        int listSize = list.size();\r
+        int pos = 0;\r
+        bool inserted = false;\r
+        for(int i = 0; i < listSize; ++i)\r
+        {\r
+            inserted = false;\r
+            int list2Size = list2.size();\r
+            for(int j = 0; j < list2Size; ++j)\r
+            {\r
+                pos = j;\r
+                if(list[i].toUpper() < list2[j].toUpper())\r
+                {\r
+                    list2.insert(pos, list[i]);\r
+                    inserted = true;\r
+                    break;\r
+                }\r
+            }\r
+            if(inserted == false)\r
+            {\r
+                list2.append(list[i]);\r
+            }\r
+        }\r
+        list = list2;\r
     }\r
+    qDebug() << "list" << list;\r
     foreach(QString item, list)\r
     {\r
         if(item.length() > 0)\r
@@ -57,7 +82,6 @@ void MyCheckBoxContainer::add(QString item)
 \r
 void MyCheckBoxContainer::set(QString item)\r
 {\r
-    qDebug() << item;\r
     clear();\r
     add(item);\r
 }\r
@@ -89,7 +113,7 @@ void MyCheckBoxContainer::sortCheckedToBottom()
                     int pos = 0;\r
                     for(pos = 0; pos < size; ++pos)\r
                     {\r
-                        if(tempListChecked[pos]->text() > item->text())\r
+                        if(tempListChecked[pos]->text().toUpper() > item->text().toUpper())\r
                         {\r
                             break;\r
                         }\r
@@ -109,7 +133,7 @@ void MyCheckBoxContainer::sortCheckedToBottom()
                     int pos = 0;\r
                     for(pos = 0; pos < size; ++pos)\r
                     {\r
-                        if(tempList[pos]->text() > item->text())\r
+                        if(tempList[pos]->text().toUpper() > item->text().toUpper())\r
                         {\r
                             break;\r
                         }\r
@@ -125,8 +149,8 @@ void MyCheckBoxContainer::sortCheckedToBottom()
         checkBoxes.clear();\r
         checkBoxes.append(tempList);\r
         checkBoxes.append(tempListChecked);\r
-        emit signalSorted();\r
     }\r
+    emit signalSorted();\r
 }\r
 \r
 QList<MyCheckBox * > const & MyCheckBoxContainer::getCheckBoxes()\r