Commit ba16d9e7 authored by Wayne Stambaugh's avatar Wayne Stambaugh

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.
parent 34e6314a
...@@ -81,10 +81,10 @@ enum SchematicFindReplaceFlags ...@@ -81,10 +81,10 @@ 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. * 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 | \ #define FR_MASK_NON_COMPARE_FLAGS ~( wxFR_DOWN | FR_SEARCH_WRAP | FR_NO_WARP_CURSOR | \
FR_REPLACE_ITEM_FOUND ) FR_REPLACE_ITEM_FOUND )
...@@ -122,29 +122,30 @@ public: ...@@ -122,29 +122,30 @@ public:
/** /**
* Function ChangesSearch * Function ChangesCompare
* tests \a aFindReplaceData to see if it would result in a change in the search * tests \a aFindReplaceData to see if it would result in a change in the search string
* results. * comparison results.
* *
* @param aFindReplaceData A reference to a #SCH_FIND_REPLACE_DATA object to compare * @param aFindReplaceData A reference to a #SCH_FIND_REPLACE_DATA object to compare
* against. * against.
* @return True if \a aFindReplaceData would result in a search and/or replace change, * @return True if \a aFindReplaceData would result in a search and/or replace change,
* otherwise false. * otherwise false.
*/ */
bool ChangesSearch( SCH_FIND_REPLACE_DATA& aFindReplaceData ) bool ChangesCompare( SCH_FIND_REPLACE_DATA& aFindReplaceData )
{ {
return ( (GetFindString() != aFindReplaceData.GetFindString()) return ( (GetFindString() != aFindReplaceData.GetFindString())
|| (GetSearchFlags() != aFindReplaceData.GetSearchFlags()) ); || (GetCompareFlags() != aFindReplaceData.GetCompareFlags()) );
} }
bool IsReplacing() const { return (GetFlags() & FR_SEARCH_REPLACE) != 0; } bool IsReplacing() const { return (GetFlags() & FR_SEARCH_REPLACE) != 0; }
bool IsWrapping() const { return (GetFlags() & FR_SEARCH_WRAP) != 0; }
private: private:
/** /**
* Function GetSearchFlags * Function GetSearchFlags
* @return The flags that only effect the search result. * @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; }
}; };
......
...@@ -516,7 +516,7 @@ SEARCH_RESULT SCH_FIND_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestDat ...@@ -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, void SCH_FIND_COLLECTOR::Collect( SCH_FIND_REPLACE_DATA& aFindReplaceData,
SCH_SHEET_PATH* aSheetPath ) SCH_SHEET_PATH* aSheetPath )
{ {
if( !m_findReplaceData.ChangesSearch( aFindReplaceData ) && !m_List.empty() && !m_forceSearch ) if( !IsSearchRequired( aFindReplaceData ) && !m_List.empty() && !m_forceSearch )
return; return;
m_findReplaceData = aFindReplaceData; m_findReplaceData = aFindReplaceData;
......
...@@ -296,7 +296,8 @@ public: ...@@ -296,7 +296,8 @@ public:
*/ */
bool IsSearchRequired( SCH_FIND_REPLACE_DATA& aFindReplaceData ) 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());
} }
/** /**
......
...@@ -390,7 +390,8 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint ...@@ -390,7 +390,8 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint
bool match; bool match;
wxString text = GetFullyQualifiedText(); 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)) ) || ((m_id == REFERENCE) && !(aSearchData.GetFlags() & FR_REPLACE_REFERENCES)) )
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment