Changed parts search to be just a simple substring search.

This commit is contained in:
leo 2015-01-06 15:17:29 +00:00
parent 7d30c9bc88
commit b1ed33ac3f
4 changed files with 37 additions and 11 deletions

View file

@ -1887,13 +1887,10 @@ bool lcPiecesLibrary::PieceInCategory(PieceInfo* Info, const String& CategoryKey
void lcPiecesLibrary::GetCategoryEntries(int CategoryIndex, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& GroupedPieces)
{
if (gCategories[CategoryIndex].Name == "Search Results")
GroupPieces = false;
SearchPieces(gCategories[CategoryIndex].Keywords, GroupPieces, SinglePieces, GroupedPieces);
GetCategoryEntries(gCategories[CategoryIndex].Keywords, GroupPieces, SinglePieces, GroupedPieces);
}
void lcPiecesLibrary::SearchPieces(const String& CategoryKeywords, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& GroupedPieces)
void lcPiecesLibrary::GetCategoryEntries(const String& CategoryKeywords, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& GroupedPieces)
{
SinglePieces.RemoveAll();
GroupedPieces.RemoveAll();
@ -1953,6 +1950,36 @@ void lcPiecesLibrary::SearchPieces(const String& CategoryKeywords, bool GroupPie
}
}
void lcPiecesLibrary::SearchPieces(const char* Keyword, lcArray<PieceInfo*>& Pieces) const
{
Pieces.RemoveAll();
String LowerKeyword = Keyword;
LowerKeyword.MakeLower();
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
{
PieceInfo* Info = mPieces[PieceIdx];
char LowerName[sizeof(Info->m_strName)];
strcpy(LowerName, Info->m_strName);
strlwr(LowerName);
if (strstr(LowerName, LowerKeyword))
{
Pieces.Add(Info);
continue;
}
char LowerDescription[sizeof(Info->m_strDescription)];
strcpy(LowerDescription, Info->m_strDescription);
strlwr(LowerDescription);
if (strstr(LowerDescription, LowerKeyword))
Pieces.Add(Info);
}
}
void lcPiecesLibrary::GetPatternedPieces(PieceInfo* Parent, lcArray<PieceInfo*>& Pieces) const
{
char Name[LC_PIECE_NAME_LEN];

View file

@ -130,8 +130,9 @@ public:
void CloseCache();
bool PieceInCategory(PieceInfo* Info, const String& CategoryKeywords) const;
void SearchPieces(const String& CategoryKeywords, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& GroupedPieces);
void SearchPieces(const char* Keyword, lcArray<PieceInfo*>& Pieces) const;
void GetCategoryEntries(int CategoryIndex, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& GroupedPieces);
void GetCategoryEntries(const String& CategoryKeywords, bool GroupPieces, lcArray<PieceInfo*>& SinglePieces, lcArray<PieceInfo*>& GroupedPieces);
void GetPatternedPieces(PieceInfo* Parent, lcArray<PieceInfo*>& Pieces) const;
void SetOfficialPieces()

View file

@ -117,10 +117,8 @@ void lcQPartsTree::searchParts(const QString& searchString)
while (QTreeWidgetItem* Item = mSearchResultsItem->child(0))
delete Item;
lcPiecesLibrary* library = lcGetPiecesLibrary();
lcArray<PieceInfo*> singleParts, groupedParts;
library->SearchPieces(searchString.toLocal8Bit().data(), false, singleParts, groupedParts);
lcArray<PieceInfo*> singleParts;
lcGetPiecesLibrary()->SearchPieces(searchString.toLocal8Bit().data(), singleParts);
singleParts.Sort(lcQPartsTreeSortFunc);
for (int partIndex = 0; partIndex < singleParts.GetSize(); partIndex++)

View file

@ -244,7 +244,7 @@ void lcQPreferencesDialog::updateParts()
{
lcArray<PieceInfo*> singleParts, groupedParts;
library->SearchPieces(options->Categories[categoryIndex].Keywords, false, singleParts, groupedParts);
library->GetCategoryEntries(options->Categories[categoryIndex].Keywords, false, singleParts, groupedParts);
for (int partIndex = 0; partIndex < singleParts.GetSize(); partIndex++)
{