Diff of /src/hugin1/hugin/CPListFrame.cpp [d2b853] .. [3f9ab6] Maximize Restore

  Switch to side-by-side view

--- a/src/hugin1/hugin/CPListFrame.cpp
+++ b/src/hugin1/hugin/CPListFrame.cpp
@@ -144,9 +144,9 @@
 {
     const ControlPoint &p1 = g_pano->getCtrlPoint(item1);
     const ControlPoint &p2 = g_pano->getCtrlPoint(item2);
-    if (p1.image1Nr < p2.image1Nr)
-        return -1;
-    else if (p1.image1Nr > p2.image1Nr)
+    if (p1.image2Nr < p2.image2Nr)
+        return -1;
+    else if (p1.image2Nr > p2.image2Nr)
         return 1;
     else
         return 0;
@@ -365,6 +365,7 @@
     unsigned int nrItems = m_list->GetItemCount();
     DEBUG_TRACE("nr CP:" << nrCP << " nr listentries:" << nrItems);
 
+    m_list->Freeze();
 //    m_list->Hide();
     // remove items for nonexisting CP's
     for (int i=nrItems-1; i>=(int)nrCP; i--)
@@ -395,6 +396,7 @@
             m_list->SetColumnWidth(col, width);
     }
     */
+    m_list->Thaw();
 }
 
 void CPListFrame::SetCPItem(int i, const ControlPoint & p)
@@ -498,6 +500,8 @@
     int colMode = 7;
     int colError = 8;
 
+    int colPairCP = 3;
+
     if (!m_verbose) {
         colRightImg = 2;
         colMode = 4;
@@ -545,6 +549,8 @@
             m_list->SortItems(&compareErrorGreater, 0);
 //            sort(cpv.begin(),cpv.end(), compareErrorGreater());
         }
+    } else if (m_sortCol == colPairCP) {
+        DEBUG_DEBUG("Skip sort of pair control points");
     } else {
         DEBUG_ERROR("Unknown sorting column: " << m_sortCol);
     }
@@ -634,39 +640,26 @@
     int sortCol = m_sortCol;
     bool sortAscend = m_sortAscend;
 
-    // sort by number, else the selection won't work..
-    // it seems that the list is traversed in a different order
-    // than the items can be set with SetItemState.. really strange
-
-    m_sortCol = 0;
-    m_sortAscend = true;
-    SortList();
-
-    long item = -1;
+    long row = -1;
     for(;;) {
-        item = m_list->GetNextItem(item,
+        row = m_list->GetNextItem(row,
                                    wxLIST_NEXT_ALL);
-        if (item < 0) {
+        if (row < 0) {
             break;
         }
-
-        unsigned int cpNr = (unsigned int) item;
+        unsigned int cpNr = (unsigned int) m_list->GetItemData(row);
         if (    ((cps[cpNr].error > threshold ) && (!invert)) 
              || ((cps[cpNr].error < threshold ) && (invert))  )
         {
             // select control point
-            DEBUG_DEBUG("selecting item: " << item << " cpNr: " << cpNr);
-            m_list->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+            DEBUG_DEBUG("selecting row: " << row << " cpNr: " << cpNr);
+
+            m_list->SetItemState(row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
         } else {
-            m_list->SetItemState(item, 0, wxLIST_STATE_SELECTED);
-        }
-    } while (item != -1);
-
-    // restore old sort order.
-    m_sortCol = sortCol;
-    m_sortAscend = sortAscend;
-
-    SortList();
+            m_list->SetItemState(row, 0, wxLIST_STATE_SELECTED);
+        }
+    } while (row != -1);
+
     m_list->Thaw();
 
     m_freeze = false;