Eeschema find bug fixes. (fixes lp:1199689)

* Force search when wrap past end of list option changes state.
* Fix SCH_FIELD::Matches() for bug in user defined fields which have an ID
  of -1.
* Minor improvements to the find data names to improve source code readability.
This commit is contained in:
Wayne Stambaugh 2013-07-14 14:08:20 -04:00
parent 34e6314a3e
commit ba16d9e763
4 changed files with 15 additions and 12 deletions

View File

@ -81,11 +81,11 @@ enum SchematicFindReplaceFlags
/**
* Definition FR_MASK_NON_SEARCH_FLAGS
* Definition FR_MASK_NON_COMPARE_FLAGS
* is used to mask find/replace flag bits that do not effect the search results.
*/
#define FR_MASK_NON_SEARCH_FLAGS ~( wxFR_DOWN | FR_SEARCH_WRAP | FR_NO_WARP_CURSOR | \
FR_REPLACE_ITEM_FOUND )
#define FR_MASK_NON_COMPARE_FLAGS ~( wxFR_DOWN | FR_SEARCH_WRAP | FR_NO_WARP_CURSOR | \
FR_REPLACE_ITEM_FOUND )
/**
@ -122,29 +122,30 @@ public:
/**
* Function ChangesSearch
* tests \a aFindReplaceData to see if it would result in a change in the search
* results.
* Function ChangesCompare
* tests \a aFindReplaceData to see if it would result in a change in the search string
* comparison results.
*
* @param aFindReplaceData A reference to a #SCH_FIND_REPLACE_DATA object to compare
* against.
* @return True if \a aFindReplaceData would result in a search and/or replace change,
* otherwise false.
*/
bool ChangesSearch( SCH_FIND_REPLACE_DATA& aFindReplaceData )
bool ChangesCompare( SCH_FIND_REPLACE_DATA& aFindReplaceData )
{
return ( (GetFindString() != aFindReplaceData.GetFindString())
|| (GetSearchFlags() != aFindReplaceData.GetSearchFlags()) );
|| (GetCompareFlags() != aFindReplaceData.GetCompareFlags()) );
}
bool IsReplacing() const { return (GetFlags() & FR_SEARCH_REPLACE) != 0; }
bool IsWrapping() const { return (GetFlags() & FR_SEARCH_WRAP) != 0; }
private:
/**
* Function GetSearchFlags
* @return The flags that only effect the search result.
*/
wxUint32 GetSearchFlags() const { return GetFlags() & FR_MASK_NON_SEARCH_FLAGS; }
wxUint32 GetCompareFlags() const { return GetFlags() & FR_MASK_NON_COMPARE_FLAGS; }
};

View File

@ -516,7 +516,7 @@ SEARCH_RESULT SCH_FIND_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestDat
void SCH_FIND_COLLECTOR::Collect( SCH_FIND_REPLACE_DATA& aFindReplaceData,
SCH_SHEET_PATH* aSheetPath )
{
if( !m_findReplaceData.ChangesSearch( aFindReplaceData ) && !m_List.empty() && !m_forceSearch )
if( !IsSearchRequired( aFindReplaceData ) && !m_List.empty() && !m_forceSearch )
return;
m_findReplaceData = aFindReplaceData;

View File

@ -296,7 +296,8 @@ public:
*/
bool IsSearchRequired( SCH_FIND_REPLACE_DATA& aFindReplaceData )
{
return m_findReplaceData.ChangesSearch( aFindReplaceData ) || m_forceSearch;
return m_findReplaceData.ChangesCompare( aFindReplaceData ) || m_forceSearch ||
(m_findReplaceData.IsWrapping() != aFindReplaceData.IsWrapping());
}
/**

View File

@ -390,7 +390,8 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint
bool match;
wxString text = GetFullyQualifiedText();
if( ((m_id > VALUE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS))
// User defined fields have an ID of -1.
if( ((m_id > VALUE || m_id < REFERENCE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS))
|| ((m_id == REFERENCE) && !(aSearchData.GetFlags() & FR_REPLACE_REFERENCES)) )
return false;