forked from organicmaps/organicmaps
[search] Remove "query" logic from all platforms. Now it's invalid because of search query filtering.
This commit is contained in:
parent
327d99e9da
commit
a39dab692b
5 changed files with 49 additions and 68 deletions
|
@ -245,6 +245,8 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
{
|
||||
super.onResume();
|
||||
|
||||
// reset current location flag
|
||||
m_mode = 0;
|
||||
m_location.startUpdate(this);
|
||||
|
||||
// do the search immediately after resume
|
||||
|
@ -277,9 +279,8 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
}
|
||||
else
|
||||
{
|
||||
// set suggestion string and run search
|
||||
// set suggestion string and run search (this call invokes runSearch)
|
||||
getSearchBox().setText(suggestion);
|
||||
runSearch();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,17 +325,13 @@ public class SearchActivity extends ListActivity implements LocationService.List
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
// emit only last query
|
||||
if (resultID >= m_queryID && resultID < m_queryID + QUERY_STEP)
|
||||
{
|
||||
Log.d(TAG, "Show " + count + " results for id = " + resultID);
|
||||
Log.d(TAG, "Show " + count + " results for id = " + resultID);
|
||||
|
||||
// update list view content
|
||||
getSA().updateData(count, resultID);
|
||||
// update list view content
|
||||
getSA().updateData(count, resultID);
|
||||
|
||||
// scroll list view to the top
|
||||
setSelection(0);
|
||||
}
|
||||
// scroll list view to the top
|
||||
setSelection(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,39 +14,37 @@
|
|||
#include "../../indexer/mercator.hpp"
|
||||
#include "../../search/result.hpp"
|
||||
|
||||
|
||||
#define MAPSWITHME_PREMIUM_APPSTORE_URL @"itms://itunes.com/apps/mapswithmepro"
|
||||
|
||||
/// When to display compass instead of country flags
|
||||
#define MIN_COMPASS_DISTANCE 25000.0
|
||||
|
||||
|
||||
SearchVC * g_searchVC = nil;
|
||||
volatile int g_queryId = 0;
|
||||
|
||||
@interface ResultsWrapper : NSObject
|
||||
{
|
||||
vector<search::Result> m_results;
|
||||
NSString * m_searchString;
|
||||
int m_queryId;
|
||||
}
|
||||
|
||||
// Stores search string which corresponds to these results.
|
||||
@property(nonatomic,retain) NSString * m_searchString;
|
||||
// Used to double-checking and discarding old results in GUI thread
|
||||
@property(nonatomic,assign) int m_queryId;
|
||||
- (id)initWithResults:(search::Results const &) res andQueryId:(int)qId;
|
||||
@property(nonatomic, retain) NSString * m_searchString;
|
||||
|
||||
- (id)initWithResults:(search::Results const &)res;
|
||||
- (vector<search::Result> const &)get;
|
||||
@end
|
||||
|
||||
@implementation ResultsWrapper
|
||||
|
||||
@synthesize m_searchString;
|
||||
@synthesize m_queryId;
|
||||
|
||||
- (id)initWithResults:(search::Results const &)res andQueryId:(int)qId
|
||||
- (id)initWithResults:(search::Results const &)res
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
m_results.assign(res.Begin(), res.End());
|
||||
m_queryId = qId;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -57,19 +55,18 @@ volatile int g_queryId = 0;
|
|||
}
|
||||
@end
|
||||
|
||||
|
||||
// Last search results are stored betweel SearchVC sessions
|
||||
// to appear instantly for the user, they also store last search text query
|
||||
ResultsWrapper * g_lastSearchResults = nil;
|
||||
|
||||
static void OnSearchResultCallback(search::Results const & res, int queryId)
|
||||
static void OnSearchResultCallback(search::Results const & res)
|
||||
{
|
||||
int currQueryId = g_queryId;
|
||||
if (g_searchVC && queryId == currQueryId)
|
||||
if (g_searchVC)
|
||||
{
|
||||
ResultsWrapper * w = [[ResultsWrapper alloc] initWithResults:res andQueryId:currQueryId];
|
||||
ResultsWrapper * w = [[ResultsWrapper alloc] initWithResults:res];
|
||||
[g_searchVC performSelectorOnMainThread:@selector(addResult:)
|
||||
withObject:w
|
||||
waitUntilDone:NO];
|
||||
withObject:w waitUntilDone:NO];
|
||||
[w release];
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +105,7 @@ static void OnSearchResultCallback(search::Results const & res, int queryId)
|
|||
- (void)fillSearchParams:(search::SearchParams &)params withText:(NSString *)queryString
|
||||
{
|
||||
params.m_query = [[queryString precomposedStringWithCompatibilityMapping] UTF8String];
|
||||
params.m_callback = bind(&OnSearchResultCallback, _1, g_queryId);
|
||||
params.m_callback = bind(&OnSearchResultCallback, _1);
|
||||
|
||||
// Set current keyboard input mode
|
||||
string lang;
|
||||
|
@ -123,8 +120,6 @@ static void OnSearchResultCallback(search::Results const & res, int queryId)
|
|||
double lat, lon;
|
||||
if ([m_locationManager getLat:lat Lon:lon])
|
||||
params.SetPosition(lat, lon);
|
||||
|
||||
params.SetNearMeMode(false);
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
|
@ -264,8 +259,6 @@ static void OnSearchResultCallback(search::Results const & res, int queryId)
|
|||
//*********** SearchBar handlers *******************************************
|
||||
- (void)searchBar:(UISearchBar *)sender textDidChange:(NSString *)searchText
|
||||
{
|
||||
++g_queryId;
|
||||
|
||||
// Search even with empty string.
|
||||
//if (searchText.length)
|
||||
{
|
||||
|
@ -460,15 +453,14 @@ static void OnSearchResultCallback(search::Results const & res, int queryId)
|
|||
- (void)addResult:(id)res
|
||||
{
|
||||
ResultsWrapper * w = (ResultsWrapper *)res;
|
||||
// Additional check to discard old results when user entered new text query
|
||||
if (g_queryId == w.m_queryId)
|
||||
{
|
||||
[g_lastSearchResults release];
|
||||
g_lastSearchResults = [w retain];
|
||||
w.m_searchString = m_searchBar.text;
|
||||
[self hideIndicator];
|
||||
[m_table reloadData];
|
||||
}
|
||||
|
||||
[g_lastSearchResults release];
|
||||
g_lastSearchResults = [w retain];
|
||||
|
||||
w.m_searchString = m_searchBar.text;
|
||||
|
||||
[self hideIndicator];
|
||||
[m_table reloadData];
|
||||
}
|
||||
|
||||
//******************************************************************
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace qt
|
|||
{
|
||||
|
||||
SearchPanel::SearchPanel(DrawWidget * drawWidget, QWidget * parent)
|
||||
: QWidget(parent), m_pDrawWidget(drawWidget), m_busyIcon(":/ui/busy.png"), m_queryId(0)
|
||||
: QWidget(parent), m_pDrawWidget(drawWidget), m_busyIcon(":/ui/busy.png")
|
||||
{
|
||||
m_pEditor = new QLineEdit(this);
|
||||
connect(m_pEditor, SIGNAL(textChanged(QString const &)),
|
||||
|
@ -52,21 +52,16 @@ SearchPanel::SearchPanel(DrawWidget * drawWidget, QWidget * parent)
|
|||
setLayout(verticalLayout);
|
||||
|
||||
// for multithreading support
|
||||
CHECK(connect(this, SIGNAL(SearchResultSignal(ResultsT *, int)),
|
||||
this, SLOT(OnSearchResult(ResultsT *, int)), Qt::QueuedConnection), ());
|
||||
CHECK(connect(this, SIGNAL(SearchResultSignal(ResultsT *)),
|
||||
this, SLOT(OnSearchResult(ResultsT *)), Qt::QueuedConnection), ());
|
||||
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setFocusProxy(m_pEditor);
|
||||
}
|
||||
|
||||
SearchPanel::~SearchPanel()
|
||||
void SearchPanel::SearchResultThreadFunc(ResultsT const & result)
|
||||
{
|
||||
}
|
||||
|
||||
void SearchPanel::SearchResultThreadFunc(ResultsT const & result, int queryId)
|
||||
{
|
||||
if (queryId == m_queryId)
|
||||
emit SearchResultSignal(new ResultsT(result), queryId);
|
||||
emit SearchResultSignal(new ResultsT(result));
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -113,11 +108,8 @@ namespace
|
|||
*/
|
||||
}
|
||||
|
||||
void SearchPanel::OnSearchResult(ResultsT * res, int queryId)
|
||||
void SearchPanel::OnSearchResult(ResultsT * res)
|
||||
{
|
||||
if (queryId != m_queryId)
|
||||
return;
|
||||
|
||||
// clear old results
|
||||
m_pTable->clear();
|
||||
m_pTable->setRowCount(0);
|
||||
|
@ -170,15 +162,13 @@ void SearchPanel::OnSearchResult(ResultsT * res, int queryId)
|
|||
|
||||
void SearchPanel::OnSearchTextChanged(QString const & str)
|
||||
{
|
||||
++m_queryId;
|
||||
|
||||
QString const normalized = str.normalized(QString::NormalizationForm_KC);
|
||||
|
||||
// search even with empty query
|
||||
//if (!normalized.isEmpty())
|
||||
{
|
||||
m_params.m_query = normalized.toUtf8().constData();
|
||||
m_params.m_callback = bind(&SearchPanel::SearchResultThreadFunc, this, _1, m_queryId);
|
||||
m_params.m_callback = bind(&SearchPanel::SearchResultThreadFunc, this, _1);
|
||||
|
||||
m_pDrawWidget->Search(m_params);
|
||||
|
||||
|
|
|
@ -32,29 +32,30 @@ class SearchPanel : public QWidget
|
|||
typedef search::Results ResultsT;
|
||||
typedef search::Result ResultT;
|
||||
vector<ResultT> m_results;
|
||||
int volatile m_queryId;
|
||||
|
||||
search::SearchParams m_params;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void SearchResultSignal(ResultsT * result, int queryId);
|
||||
public:
|
||||
SearchPanel(DrawWidget * drawWidget, QWidget * parent);
|
||||
|
||||
private:
|
||||
void SearchResultThreadFunc(ResultsT const & result, int queryId);
|
||||
virtual void showEvent(QShowEvent *);
|
||||
virtual void hideEvent(QHideEvent *);
|
||||
|
||||
public:
|
||||
explicit SearchPanel(DrawWidget * drawWidget, QWidget * parent);
|
||||
~SearchPanel();
|
||||
void SearchResultThreadFunc(ResultsT const & result);
|
||||
|
||||
signals:
|
||||
void SearchResultSignal(ResultsT * result);
|
||||
|
||||
private slots:
|
||||
void OnSearchPanelItemClicked(int row, int column);
|
||||
void OnSearchTextChanged(QString const &);
|
||||
|
||||
/// Called via signal to support multithreading
|
||||
void OnSearchResult(ResultsT * result, int queryId);
|
||||
void OnSearchResult(ResultsT * result);
|
||||
|
||||
void OnViewportChanged();
|
||||
void OnAnimationTimer();
|
||||
void OnClearButton();
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
namespace search
|
||||
{
|
||||
|
||||
SearchParams::SearchParams() : m_mode(All),
|
||||
m_inputLanguageCode(StringUtf8Multilang::UNSUPPORTED_LANGUAGE_CODE),
|
||||
m_validPos(false)
|
||||
SearchParams::SearchParams()
|
||||
: m_mode(All),
|
||||
m_inputLanguageCode(StringUtf8Multilang::UNSUPPORTED_LANGUAGE_CODE),
|
||||
m_validPos(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue