void CDownloadWithSearch::RunSearch(DWORD tNow) { if ( ! CanSearch() ) { StopSearch(); return; } if ( tNow > m_tSearchTime && tNow - m_tSearchTime < Settings.Downloads.SearchPeriod ) { StartManualSearch(); } else if ( tNow > m_tSearchCheck && tNow - m_tSearchCheck >= 1000 ) { BOOL bFewSources = GetSourceCount( FALSE, TRUE ) < Settings.Downloads.MinSources; BOOL bDataStarve = ( tNow > m_tReceived ? tNow - m_tReceived : 0 ) > Settings.Downloads.StarveTimeout * 1000; m_tSearchCheck = tNow; if ( IsPaused() == FALSE && ( bFewSources || bDataStarve ) ) { StartAutomaticSearch(); } else { StopSearch(); } } }
NS_IMETHODIMP nsAutoCompleteController::HandleEnter(bool aIsPopupSelection, bool *_retval) { *_retval = false; if (!mInput) return NS_OK; // allow the event through unless there is something selected in the popup mInput->GetPopupOpen(_retval); if (*_retval) { nsCOMPtr<nsIAutoCompletePopup> popup; mInput->GetPopup(getter_AddRefs(popup)); if (popup) { PRInt32 selectedIndex; popup->GetSelectedIndex(&selectedIndex); *_retval = selectedIndex >= 0; } } // Stop the search, and handle the enter. StopSearch(); EnterMatch(aIsPopupSelection); return NS_OK; }
VSCSearch::~VSCSearch() { if (m_bStarted == TRUE) { StopSearch(); } }
NS_IMETHODIMP nsAutoCompleteController::SetInput(nsIAutoCompleteInput *aInput) { // Don't do anything if the input isn't changing. if (mInput == aInput) return NS_OK; // Clear out the current search context if (mInput) { // Stop all searches in case they are async. StopSearch(); ClearResults(); ClosePopup(); mSearches.Clear(); } mInput = aInput; // Nothing more to do if the input was just being set to null. if (!aInput) return NS_OK; nsAutoString newValue; aInput->GetTextValue(newValue); // Clear out this reference in case the new input's popup has no tree mTree = nsnull; // Reset all search state members to default values mSearchString = newValue; mDefaultIndexCompleted = false; mBackspaced = false; mSearchStatus = nsIAutoCompleteController::STATUS_NONE; mRowCount = 0; mSearchesOngoing = 0; // Initialize our list of search objects PRUint32 searchCount; aInput->GetSearchCount(&searchCount); mResults.SetCapacity(searchCount); mSearches.SetCapacity(searchCount); mMatchCounts.SetLength(searchCount); const char *searchCID = kAutoCompleteSearchCID; for (PRUint32 i = 0; i < searchCount; ++i) { // Use the search name to create the contract id string for the search service nsCAutoString searchName; aInput->GetSearchAt(i, searchName); nsCAutoString cid(searchCID); cid.Append(searchName); // Use the created cid to get a pointer to the search service and store it for later nsCOMPtr<nsIAutoCompleteSearch> search = do_GetService(cid.get()); if (search) mSearches.AppendObject(search); } return NS_OK; }
void CDownload::OnDownloaded() { ASSERT( m_bComplete == false ); theApp.Message( MSG_NOTICE, IDS_DOWNLOAD_COMPLETED, GetDisplayName() ); m_tCompleted = GetTickCount(); m_bDownloading = false; StopSearch(); CloseTransfers(); //AppendMetadata(); if ( GetTaskType() == dtaskMergeFile || GetTaskType() == dtaskPreviewRequest ) AbortTask(); // LibraryBuilder.m_bBusy = true; // ? m_pTask.Copy(); Statistics.Current.Downloads.Files++; SetModified(); }
NS_IMETHODIMP nsAutoCompleteController::HandleStartComposition() { NS_ENSURE_TRUE(!mIsIMEComposing, NS_OK); mPopupClosedByCompositionStart = false; mIsIMEComposing = true; if (!mInput) return NS_OK; nsCOMPtr<nsIAutoCompleteInput> input(mInput); bool disabled; input->GetDisableAutoComplete(&disabled); if (disabled) return NS_OK; // Stop all searches in case they are async. StopSearch(); bool isOpen = false; input->GetPopupOpen(&isOpen); if (isOpen) { ClosePopup(); bool stillOpen = false; input->GetPopupOpen(&stillOpen); mPopupClosedByCompositionStart = !stillOpen; } return NS_OK; }
WidgetSearchTemplate::~WidgetSearchTemplate() { if(m_pSearch != 0) { StopSearch(); } delete m_ui; }
void VSCSearch::SetupConnections() { connect( this->ui.pushButtonStart, SIGNAL( clicked() ), this, SLOT(StartSearch())); connect( this->ui.pushButtonStop, SIGNAL( clicked() ), this, SLOT(StopSearch())); connect( this->ui.pushButtonAdd, SIGNAL( clicked() ), this, SLOT(AddAll())); connect( this->ui.pushButtonSelect, SIGNAL( clicked() ), this, SLOT(SelectAll())); connect( this, SIGNAL(NewSearchedItem(astring, astring, astring, astring, astring, astring) ), this, SLOT(AddItem(astring, astring, astring, astring, astring, astring)), Qt::QueuedConnection); //Qt::QueuedConnection }
// Start a new background search. The start and end parameters say what part of // the file does not need to be searched (if any). void CHexEditDoc::StartSearch(FILE_ADDRESS start /*=-1*/, FILE_ADDRESS end /*=-1*/) { StopSearch(); // -1 for end means EOF (unless both start and end are -1) if (start != -1 && end == -1) end = length_; // This is not done until we know the bg thread has stopped searching // else the bg thread may add more entries to found that apply to the old // search string which would be wrongly displayed. CBGSearchHint bgsh(FALSE); UpdateAllViews(NULL, 0, &bgsh); // Setup up the info for the new search docdata_.Lock(); to_search_.clear(); to_adjust_.clear(); find_total_ = 0; find_done_ = 0.0; if (start == -1) { // Search whole file ASSERT(end == -1); to_search_.push_back(pair<FILE_ADDRESS, FILE_ADDRESS>(0,-1)); find_total_ += length_; TRACE("+++ StartSearch: 0 to -1\n"); } else { // Only search the part of the file not already searched ASSERT(start <= end); // Search end of file first if (end < length_) { to_search_.push_back(pair<FILE_ADDRESS, FILE_ADDRESS>(end, -1)); find_total_ += length_ - end; } if (start > 0) { to_search_.push_back(pair<FILE_ADDRESS, FILE_ADDRESS>(0, start)); find_total_ += start; } } found_.clear(); // Clear set of found addresses // Restart the search search_command_ = NONE; search_fin_ = false; docdata_.Unlock(); TRACE("+++ Pulsing search event for %p\n", this); start_search_event_.SetEvent(); }
void SearchThread::DoSearchFiles(ThreadRequest *req) { SearchData *data = static_cast<SearchData*>(req); // Get all files if ( data->GetRootDirs().IsEmpty() ) return; if ( data->GetFindString().IsEmpty() ) return; StopSearch(false); wxArrayString fileList; GetFiles(data, fileList); wxStopWatch sw; // Send startup message to main thread if ( m_notifiedWindow || data->GetOwner() ) { wxCommandEvent event(wxEVT_SEARCH_THREAD_SEARCHSTARTED, GetId()); event.SetClientData(new SearchData(*data)); //set the rquested output tab event.SetInt(data->UseNewTab() ? 1 : 0); if (data->GetOwner()) { ::wxPostEvent(data->GetOwner(), event); } else { // since we are in if ( m_notifiedWindow || data->GetOwner() ) block... ::wxPostEvent(m_notifiedWindow, event); } } for (size_t i=0; i<fileList.Count(); i++) { m_summary.SetNumFileScanned((int)i+1); // give user chance to cancel the search ... if ( TestStopSearch() ) { // Send cancel event SendEvent(wxEVT_SEARCH_THREAD_SEARCHCANCELED, data->GetOwner()); StopSearch(false); break; } DoSearchFile(fileList.Item(i), data); } }
CWidgetSearchTemplate::~CWidgetSearchTemplate() { if(m_pSearch != 0) { StopSearch(); } delete m_pSearchModel; delete ui; }
HWND CFindPanel::Activate(bool bActivate) { if (bActivate) { if (!IsAvailable(false)) return NULL; SetFocus(mh_Edit); } else { StopSearch(); } return mh_Edit; }
HWND CFindPanel::Activate(bool bActivate) { if (bActivate) { if (!IsAvailable(false)) return NULL; if (!IsWindowVisible(mh_Pane)) ::ShowWindow(mh_Pane, SW_SHOWNORMAL); SetFocus(mh_Edit); } else { StopSearch(); } return mh_Edit; }
void CDownload::StopTrying() { if ( ! IsTrying() || ( IsCompleted() && ! IsSeeding() ) ) return; m_tBegan = 0; m_bDownloading = false; // If m_bTorrentRequested = TRUE, sends Stop // CloseTorrent() additionally closes uploads if ( IsTorrent() ) CloseTorrent(); CloseTransfers(); CloseFile(); StopSearch(); SetModified(); }
NS_IMETHODIMP nsAutoCompleteController::HandleEscape(bool *_retval) { *_retval = false; if (!mInput) return NS_OK; // allow the event through if the popup is closed mInput->GetPopupOpen(_retval); // Stop all searches in case they are async. StopSearch(); ClearResults(); RevertTextValue(); ClosePopup(); return NS_OK; }
void DatabaseDlg::OnAddDB(wxCommandEvent &event) { StopSearch(); wxProgressDialog *prg_diag = new wxProgressDialog( "FluoRender: Loading catalog data...", "Loading selected catalog data. Please wait.", 100, 0, wxPD_APP_MODAL | wxPD_SMOOTH); prg_diag->Update(95); m_dbtree->LoadDatabase(m_db_text->GetValue()); m_db_text->Clear(); prg_diag->Destroy(); SaveDefault(); }
NS_IMETHODIMP nsAutoCompleteController::HandleText() { // Note: the events occur in the following order when IME is used. // 1. a compositionstart event(HandleStartComposition) // 2. some input events (HandleText), eCompositionState_Composing // 3. a compositionend event(HandleEndComposition) // 4. an input event(HandleText), eCompositionState_Committing // We should do nothing during composition. if (mCompositionState == eCompositionState_Composing) { return NS_OK; } bool handlingCompositionCommit = (mCompositionState == eCompositionState_Committing); bool popupClosedByCompositionStart = mPopupClosedByCompositionStart; if (handlingCompositionCommit) { mCompositionState = eCompositionState_None; mPopupClosedByCompositionStart = false; } if (!mInput) { // Stop all searches in case they are async. StopSearch(); // Note: if now is after blur and IME end composition, // check mInput before calling. // See https://bugzilla.mozilla.org/show_bug.cgi?id=193544#c31 NS_ERROR("Called before attaching to the control or after detaching from the control"); return NS_OK; } nsAutoString newValue; nsCOMPtr<nsIAutoCompleteInput> input(mInput); input->GetTextValue(newValue); // Stop all searches in case they are async. StopSearch(); if (!mInput) { // StopSearch() can call PostSearchCleanup() which might result // in a blur event, which could null out mInput, so we need to check it // again. See bug #395344 for more details return NS_OK; } bool disabled; input->GetDisableAutoComplete(&disabled); NS_ENSURE_TRUE(!disabled, NS_OK); // Don't search again if the new string is the same as the last search // However, if this is called immediately after compositionend event, // we need to search the same value again since the search was canceled // at compositionstart event handler. if (!handlingCompositionCommit && newValue.Length() > 0 && newValue.Equals(mSearchString)) { return NS_OK; } // Determine if the user has removed text from the end (probably by backspacing) if (newValue.Length() < mSearchString.Length() && Substring(mSearchString, 0, newValue.Length()).Equals(newValue)) { // We need to throw away previous results so we don't try to search through them again ClearResults(); mBackspaced = true; } else mBackspaced = false; mSearchString = newValue; // Don't search if the value is empty if (newValue.Length() == 0) { // If autocomplete popup was closed by compositionstart event handler, // we should reopen it forcibly even if the value is empty. if (popupClosedByCompositionStart && handlingCompositionCommit) { bool cancel; HandleKeyNavigation(nsIDOMKeyEvent::DOM_VK_DOWN, &cancel); return NS_OK; } ClosePopup(); return NS_OK; } StartSearches(); return NS_OK; }
NS_IMETHODIMP nsAutoCompleteController::HandleKeyNavigation(PRUint32 aKey, bool *_retval) { // By default, don't cancel the event *_retval = false; if (!mInput) { // Stop all searches in case they are async. StopSearch(); // Note: if now is after blur and IME end composition, // check mInput before calling. // See https://bugzilla.mozilla.org/show_bug.cgi?id=193544#c31 NS_ERROR("Called before attaching to the control or after detaching from the control"); return NS_OK; } nsCOMPtr<nsIAutoCompleteInput> input(mInput); nsCOMPtr<nsIAutoCompletePopup> popup; input->GetPopup(getter_AddRefs(popup)); NS_ENSURE_TRUE(popup != nsnull, NS_ERROR_FAILURE); bool disabled; input->GetDisableAutoComplete(&disabled); NS_ENSURE_TRUE(!disabled, NS_OK); if (aKey == nsIDOMKeyEvent::DOM_VK_UP || aKey == nsIDOMKeyEvent::DOM_VK_DOWN || aKey == nsIDOMKeyEvent::DOM_VK_PAGE_UP || aKey == nsIDOMKeyEvent::DOM_VK_PAGE_DOWN) { // Prevent the input from handling up/down events, as it may move // the cursor to home/end on some systems *_retval = true; bool isOpen = false; input->GetPopupOpen(&isOpen); if (isOpen) { bool reverse = aKey == nsIDOMKeyEvent::DOM_VK_UP || aKey == nsIDOMKeyEvent::DOM_VK_PAGE_UP ? true : false; bool page = aKey == nsIDOMKeyEvent::DOM_VK_PAGE_UP || aKey == nsIDOMKeyEvent::DOM_VK_PAGE_DOWN ? true : false; // Fill in the value of the textbox with whatever is selected in the popup // if the completeSelectedIndex attribute is set. We check this before // calling SelectBy of an earlier attempt to avoid crashing. bool completeSelection; input->GetCompleteSelectedIndex(&completeSelection); // Instruct the result view to scroll by the given amount and direction popup->SelectBy(reverse, page); if (completeSelection) { PRInt32 selectedIndex; popup->GetSelectedIndex(&selectedIndex); if (selectedIndex >= 0) { // A result is selected, so fill in its value nsAutoString value; if (NS_SUCCEEDED(GetResultValueAt(selectedIndex, true, value))) { input->SetTextValue(value); input->SelectTextRange(value.Length(), value.Length()); } } else { // Nothing is selected, so fill in the last typed value input->SetTextValue(mSearchString); input->SelectTextRange(mSearchString.Length(), mSearchString.Length()); } } } else { #ifdef XP_MACOSX // on Mac, only show the popup if the caret is at the start or end of // the input and there is no selection, so that the default defined key // shortcuts for up and down move to the beginning and end of the field // otherwise. PRInt32 start, end; if (aKey == nsIDOMKeyEvent::DOM_VK_UP) { input->GetSelectionStart(&start); input->GetSelectionEnd(&end); if (start > 0 || start != end) *_retval = false; } else if (aKey == nsIDOMKeyEvent::DOM_VK_DOWN) { nsAutoString text; input->GetTextValue(text); input->GetSelectionStart(&start); input->GetSelectionEnd(&end); if (start != end || end < (PRInt32)text.Length()) *_retval = false; } #endif if (*_retval) { // Open the popup if there has been a previous search, or else kick off a new search if (mResults.Count() > 0) { if (mRowCount) { OpenPopup(); } } else { // Stop all searches in case they are async. StopSearch(); if (!mInput) { // StopSearch() can call PostSearchCleanup() which might result // in a blur event, which could null out mInput, so we need to check it // again. See bug #395344 for more details return NS_OK; } StartSearchTimer(); } } } } else if ( aKey == nsIDOMKeyEvent::DOM_VK_LEFT || aKey == nsIDOMKeyEvent::DOM_VK_RIGHT #ifndef XP_MACOSX || aKey == nsIDOMKeyEvent::DOM_VK_HOME #endif ) { // The user hit a text-navigation key. bool isOpen = false; input->GetPopupOpen(&isOpen); if (isOpen) { PRInt32 selectedIndex; popup->GetSelectedIndex(&selectedIndex); bool shouldComplete; input->GetCompleteDefaultIndex(&shouldComplete); if (selectedIndex >= 0) { // The pop-up is open and has a selection, take its value nsAutoString value; if (NS_SUCCEEDED(GetResultValueAt(selectedIndex, true, value))) { input->SetTextValue(value); input->SelectTextRange(value.Length(), value.Length()); } } else if (shouldComplete) { // We usually try to preserve the casing of what user has typed, but // if he wants to autocomplete, we will replace the value with the // actual autocomplete result. // The user wants explicitely to use that result, so this ensures // association of the result with the autocompleted text. nsAutoString value; nsAutoString inputValue; input->GetTextValue(inputValue); if (NS_SUCCEEDED(GetDefaultCompleteValue(-1, false, value)) && value.Equals(inputValue, nsCaseInsensitiveStringComparator())) { input->SetTextValue(value); input->SelectTextRange(value.Length(), value.Length()); } } // Close the pop-up even if nothing was selected ClearSearchTimer(); ClosePopup(); } // Update last-searched string to the current input, since the input may // have changed. Without this, subsequent backspaces look like text // additions, not text deletions. nsAutoString value; input->GetTextValue(value); mSearchString = value; } return NS_OK; }
void DatabaseDlg::OnSearchText(wxCommandEvent &event) { StopSearch(); }
NS_IMETHODIMP nsAutoCompleteController::HandleText() { // We should do nothing during composition. if (mIsIMEComposing) { return NS_OK; } if (!mInput) { // Stop all searches in case they are async. StopSearch(); // Note: if now is after blur and IME end composition, // check mInput before calling. // See https://bugzilla.mozilla.org/show_bug.cgi?id=193544#c31 NS_ERROR("Called before attaching to the control or after detaching from the control"); return NS_OK; } nsAutoString newValue; nsCOMPtr<nsIAutoCompleteInput> input(mInput); input->GetTextValue(newValue); // Note: the events occur in the following order when IME is used. // 1. composition start event(HandleStartComposition) // 2. composition end event(HandleEndComposition) // 3. input event(HandleText) // Note that the input event occurs if IME composition is cancelled, as well. // In HandleEndComposition, we are processing the popup properly. // Therefore, the input event after composition end event should do nothing. // (E.g., calling StopSearch() and ClosePopup().) // If it is not, popup is always closed after composition end. if (mIgnoreHandleText) { mIgnoreHandleText = false; if (newValue.Equals(mSearchString)) return NS_OK; NS_ERROR("Now is after composition end event. But the value was changed."); } // Stop all searches in case they are async. StopSearch(); if (!mInput) { // StopSearch() can call PostSearchCleanup() which might result // in a blur event, which could null out mInput, so we need to check it // again. See bug #395344 for more details return NS_OK; } bool disabled; input->GetDisableAutoComplete(&disabled); NS_ENSURE_TRUE(!disabled, NS_OK); // Don't search again if the new string is the same as the last search if (newValue.Length() > 0 && newValue.Equals(mSearchString)) return NS_OK; // Determine if the user has removed text from the end (probably by backspacing) if (newValue.Length() < mSearchString.Length() && Substring(mSearchString, 0, newValue.Length()).Equals(newValue)) { // We need to throw away previous results so we don't try to search through them again ClearResults(); mBackspaced = true; } else mBackspaced = false; mSearchString = newValue; // Don't search if the value is empty if (newValue.Length() == 0) { ClosePopup(); return NS_OK; } StartSearchTimer(); return NS_OK; }
NS_IMETHODIMP nsAbLDAPDirectory::StartSearch () { if (!mIsQueryURI || mQueryString.IsEmpty()) return NS_OK; nsresult rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); rv = StopSearch(); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIAbDirectoryQueryArguments> arguments = do_CreateInstance(NS_ABDIRECTORYQUERYARGUMENTS_CONTRACTID,&rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIAbBooleanExpression> expression; rv = nsAbQueryStringToExpression::Convert(mQueryString.get(), getter_AddRefs(expression)); NS_ENSURE_SUCCESS(rv, rv); rv = arguments->SetExpression(expression); NS_ENSURE_SUCCESS(rv, rv); rv = arguments->SetQuerySubDirectories(PR_TRUE); NS_ENSURE_SUCCESS(rv, rv); // Get the max hits to return PRInt32 maxHits; rv = GetMaxHits(&maxHits); if (NS_FAILED(rv)) maxHits = kDefaultMaxHits; // get the appropriate ldap attribute map, and pass it in via the // TypeSpecificArgument nsCOMPtr<nsIAbLDAPAttributeMap> attrMap; rv = GetAttributeMap(getter_AddRefs(attrMap)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsISupports> typeSpecificArg = do_QueryInterface(attrMap, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = arguments->SetTypeSpecificArg(attrMap); NS_ENSURE_SUCCESS(rv, rv); if (!mDirectoryQuery) { mDirectoryQuery = do_CreateInstance(NS_ABLDAPDIRECTORYQUERY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); } // Perform the query rv = mDirectoryQuery->DoQuery(this, arguments, this, maxHits, 0, &mContext); NS_ENSURE_SUCCESS(rv, rv); // Enter lock nsAutoLock lock(mLock); mPerformingQuery = PR_TRUE; mCache.Clear(); return rv; }
bool CFindPanel::OnKeyboard(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lRc) { bool bSkip = false; switch (uMsg) { case WM_CHAR: switch (LOWORD(wParam)) { case VK_RETURN: case VK_ESCAPE: bSkip = true; } break; case WM_SYSCHAR: // Чтобы не пищало lRc = bSkip = true; break; case WM_KEYDOWN: case WM_KEYUP: switch (LOWORD(wParam)) { case VK_ESCAPE: case VK_F10: if (uMsg == WM_KEYDOWN) mn_KeyDown = LOWORD(wParam); else if (mn_KeyDown == LOWORD(wParam)) StopSearch(); bSkip = true; break; case VK_RETURN: case VK_F3: if (uMsg == WM_KEYDOWN) gpConEmu->DoFindText(isPressed(VK_SHIFT) ? -1 : 1); bSkip = true; break; case VK_APPS: if (uMsg == WM_KEYDOWN) mn_KeyDown = VK_APPS; else if (mn_KeyDown == VK_APPS) ShowMenu(); bSkip = true; break; } break; case WM_SYSKEYDOWN: bSkip = true; lRc = TRUE; switch (LOWORD(wParam)) { case 'C': gpSet->FindOptions.bMatchCase = !gpSet->FindOptions.bMatchCase; break; case 'W': gpSet->FindOptions.bMatchWholeWords = !gpSet->FindOptions.bMatchWholeWords; break; case 'F': gpSet->FindOptions.bFreezeConsole = !gpSet->FindOptions.bFreezeConsole; break; case 'A': gpSet->FindOptions.bHighlightAll = !gpSet->FindOptions.bHighlightAll; break; case VK_F10: mn_KeyDown = LOWORD(wParam); bSkip = true; goto wrap; default: goto wrap; } gpConEmu->DoFindText(isPressed(VK_SHIFT) ? -1 : 1); break; case WM_SYSKEYUP: if (mn_KeyDown == LOWORD(wParam)) StopSearch(); bSkip = true; lRc = TRUE; goto wrap; } wrap: return bSkip; }