Revision: 7453
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7453&view=rev
Author:   vadz
Date:     2008-05-02 17:03:37 -0700 (Fri, 02 May 2008)

Log Message:
-----------
exclude other entries using the same address as the ones which were explicitly 
deleted by user from the ADB expansion dialog

Modified Paths:
--------------
    trunk/M/src/adb/AdbManager.cpp

Modified: trunk/M/src/adb/AdbManager.cpp
===================================================================
--- trunk/M/src/adb/AdbManager.cpp      2008-05-02 23:35:01 UTC (rev 7452)
+++ trunk/M/src/adb/AdbManager.cpp      2008-05-03 00:03:37 UTC (rev 7453)
@@ -71,7 +71,8 @@
                         const String& what,
                         int where,
                         int how,
-                        ArrayAdbGroups *aGroups = NULL
+                        ArrayAdbGroups *aGroups = NULL,
+                        wxSortedArrayString *entriesToIgnore = NULL
                        );
 
 // search in the books specified or in all loaded books otherwise
@@ -110,7 +111,8 @@
                         const String& what,
                         int where,
                         int how,
-                        ArrayAdbGroups *aGroups)
+                        ArrayAdbGroups *aGroups,
+                        wxSortedArrayString *entriesToIgnore)
 {
   // check if this book doesn't match itself: the other groups are checked in
   // the parent one but the books don't have a parent
@@ -131,12 +133,17 @@
      }
   }
 
+  wxSortedArrayString entriesToIgnoreLocal;
+  if ( !entriesToIgnore )
+    entriesToIgnore = &entriesToIgnoreLocal;
+
   wxArrayString aNames;
   size_t nGroupCount = pGroup->GetGroupNames(aNames);
   for ( size_t nGroup = 0; nGroup < nGroupCount; nGroup++ ) {
     AdbEntryGroup *pSubGroup = pGroup->GetGroup(aNames[nGroup]);
 
-    GroupLookup(aEntries, aMoreEntries, pSubGroup, what, where, how);
+    GroupLookup(aEntries, aMoreEntries, pSubGroup, what, where, how,
+                aGroups, entriesToIgnore);
 
     // groups are matched by name only (case-insensitive)
     if ( aGroups && aNames[nGroup].Lower().Matches(nameMatch) ) {
@@ -147,18 +154,35 @@
     }
   }
 
+  bool checkExclusions = false;
+
   aNames.Empty();
   size_t nEntryCount = pGroup->GetEntryNames(aNames);
   for ( size_t nEntry = 0; nEntry < nEntryCount; nEntry++ ) {
     AdbEntry *pEntry = pGroup->GetEntry(aNames[nEntry]);
 
+    const String desc = pEntry->GetDescription();
     if ( pEntry->GetField(AdbField_ExpandPriority) == _T("-1") )
     {
-      // never use this one for expansion
+      // never use this one for expansion and also remember its email so that
+      // another entry, with the same email, wouldn't be used neither
+      entriesToIgnore->Add(desc);
+
+      // it is still possible that we had other entries with the same address
+      // before so set a flag telling us to check whether this was the case at
+      // the end
+      checkExclusions = true;
+
       pEntry->DecRef();
       continue;
     }
 
+    if ( entriesToIgnore->Index(desc) != wxNOT_FOUND )
+    {
+      pEntry->DecRef();
+      continue;
+    }
+
     // we put the entries which match with their nick name in one array and
     // the entries which match anywhere else in the other one: see AdbExpand()
     // to see why
@@ -179,6 +203,18 @@
         break;
     }
   }
+
+  if ( checkExclusions ) {
+    for ( size_t nEntry = aEntries.size(); nEntry > 0; ) {
+      nEntry--;
+
+      if ( entriesToIgnore->Index(aEntries[nEntry]->GetDescription())
+            != wxNOT_FOUND )
+      {
+        entriesToIgnore->RemoveAt(nEntry);
+      }
+    }
+  }
 }
 
 static bool
@@ -195,10 +231,11 @@
   if ( paBooks == NULL || paBooks->IsEmpty() )
     paBooks = &gs_booksCache;
 
+  wxSortedArrayString entriesToIgnore;
   size_t nBookCount = paBooks->Count();
   for ( size_t nBook = 0; nBook < nBookCount; nBook++ ) {
     GroupLookup(aEntries, aMoreEntries,
-                (*paBooks)[nBook], what, where, how, aGroups);
+                (*paBooks)[nBook], what, where, how, aGroups, 
&entriesToIgnore);
   }
 
   // return true if something found


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to