Simpler version of [ 1604590 ] wxListCtrl::FindItem & wxString
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43719 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -253,7 +253,9 @@ Ensures this item is visible.
|
|||||||
\func{long}{FindItem}{\param{long }{start}, \param{const wxString\& }{str}, \param{const bool }{partial = false}}
|
\func{long}{FindItem}{\param{long }{start}, \param{const wxString\& }{str}, \param{const bool }{partial = false}}
|
||||||
|
|
||||||
Find an item whose label matches this string, starting from {\it start} or
|
Find an item whose label matches this string, starting from {\it start} or
|
||||||
the beginning if {\it start} is -1.
|
the beginning if {\it start} is -1. The string comparison is case
|
||||||
|
insensitive. If {\it partial} is true then this method will look for
|
||||||
|
items which begin with {\it str}.
|
||||||
|
|
||||||
\func{long}{FindItem}{\param{long }{start}, \param{long }{data}}
|
\func{long}{FindItem}{\param{long }{start}, \param{long }{data}}
|
||||||
|
|
||||||
|
@@ -4501,10 +4501,13 @@ void wxListMainWindow::EnsureVisible( long index )
|
|||||||
MoveToItem((size_t)index);
|
MoveToItem((size_t)index);
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxListMainWindow::FindItem(long start, const wxString& str, bool WXUNUSED(partial) )
|
long wxListMainWindow::FindItem(long start, const wxString& str, bool partial )
|
||||||
{
|
{
|
||||||
|
if (str.empty())
|
||||||
|
return wxNOT_FOUND;
|
||||||
|
|
||||||
long pos = start;
|
long pos = start;
|
||||||
wxString tmp = str;
|
wxString str_upper = str.Upper();
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
|
||||||
@@ -4512,8 +4515,17 @@ long wxListMainWindow::FindItem(long start, const wxString& str, bool WXUNUSED(p
|
|||||||
for ( size_t i = (size_t)pos; i < count; i++ )
|
for ( size_t i = (size_t)pos; i < count; i++ )
|
||||||
{
|
{
|
||||||
wxListLineData *line = GetLine(i);
|
wxListLineData *line = GetLine(i);
|
||||||
if ( line->GetText(0) == tmp )
|
wxString line_upper = line->GetText(0).Upper();
|
||||||
return i;
|
if (!partial)
|
||||||
|
{
|
||||||
|
if (line_upper == str_upper )
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (line_upper.find(str_upper) == 0)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxNOT_FOUND;
|
return wxNOT_FOUND;
|
||||||
|
Reference in New Issue
Block a user