Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
nsAutoCompleteController Class Reference

#include <nsAutoCompleteController.h>

Inheritance diagram for nsAutoCompleteController:
Inheritance graph
[legend]
Collaboration diagram for nsAutoCompleteController:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIAUTOCOMPLETECONTROLLER
NS_DECL_NSIAUTOCOMPLETECONTROLLER_MOZILLA_1_8_BRANCH
NS_DECL_NSIAUTOCOMPLETEOBSERVER
NS_DECL_NSIROLLUPLISTENER
NS_DECL_NSITREEVIEW
NS_DECL_NSITIMERCALLBACK 
nsAutoCompleteController ()
virtual ~nsAutoCompleteController ()
void attachRollupListener ()
void detachRollupListener ()
void startSearch (in AString searchString)
void handleText (in boolean aIgnoreSelection)
boolean handleEnter ()
boolean handleEscape ()
void handleStartComposition ()
void handleEndComposition ()
void handleTab ()
boolean handleKeyNavigation (in unsigned short key)
boolean handleDelete ()
AString getValueAt (in long index)
AString getCommentAt (in long index)
AString getStyleAt (in long index)
void setSearchString (in AString aSearchString)
void onSearchResult (in nsIAutoCompleteSearch search, in nsIAutoCompleteResult result)
void Rollup ()
 Notifies the object to rollup.
void ShouldRollupOnMouseWheelEvent (out PRBool aShould)
 Asks the RollupListener if it should rollup on mousevents.
void ShouldRollupOnMouseActivate (out PRBool aShould)
 Asks the RollupListener if it should rollup on mouse activate, eg.
void notify (in nsITimer timer)
void getRowProperties (in long index, in nsISupportsArray properties)
 An atomized list of properties for a given row.
void getCellProperties (in long row, in nsITreeColumn col, in nsISupportsArray properties)
 An atomized list of properties for a given cell.
void getColumnProperties (in nsITreeColumn col, in nsISupportsArray properties)
 Called to get properties to paint a column background.
boolean isContainer (in long index)
 Methods that can be used to test whether or not a twisty should be drawn, and if so, whether an open or closed twisty should be used.
boolean isContainerOpen (in long index)
boolean isContainerEmpty (in long index)
boolean isSeparator (in long index)
 isSeparator is used to determine if the row at index is a separator.
boolean isSorted ()
 Specifies if there is currently a sort on any column.
boolean canDrop (in long index, in long orientation)
 Methods used by the drag feedback code to determine if a drag is allowable at the current location.
void drop (in long row, in long orientation)
 Called when the user drops something on this view.
long getParentIndex (in long rowIndex)
 Methods used by the tree to draw thread lines in the tree.
boolean hasNextSibling (in long rowIndex, in long afterIndex)
 hasNextSibling is used to determine if the row at rowIndex has a nextSibling that occurs after the index specified by afterIndex.
long getLevel (in long index)
 The level is an integer value that represents the level of indentation.
AString getImageSrc (in long row, in nsITreeColumn col)
 The image path for a given cell.
long getProgressMode (in long row, in nsITreeColumn col)
AString getCellValue (in long row, in nsITreeColumn col)
 The value for a given cell.
AString getCellText (in long row, in nsITreeColumn col)
 The text for a given cell.
void setTree (in nsITreeBoxObject tree)
 Called during initialization to link the view to the front end box object.
void toggleOpenState (in long index)
 Called on the view when an item is opened or closed.
void cycleHeader (in nsITreeColumn col)
 Called on the view when a header is clicked.
void selectionChanged ()
 Should be called from a XUL onselect handler whenever the selection changes.
void cycleCell (in long row, in nsITreeColumn col)
 Called on the view when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.
boolean isEditable (in long row, in nsITreeColumn col)
 isEditable is called to ask the view if the cell contents are editable.
void setCellValue (in long row, in nsITreeColumn col, in AString value)
 setCellValue is called when the value of the cell has been set by the user.
void setCellText (in long row, in nsITreeColumn col, in AString value)
 setCellText is called when the contents of the cell have been edited by the user.
void performAction (in wstring action)
 A command API that can be used to invoke commands on the selection.
void performActionOnRow (in wstring action, in long row)
 A command API that can be used to invoke commands on a specific row.
void performActionOnCell (in wstring action, in long row, in nsITreeColumn col)
 A command API that can be used to invoke commands on a specific cell.

Public Attributes

const unsigned short STATUS_NONE = 1
const unsigned short STATUS_SEARCHING = 2
const unsigned short STATUS_COMPLETE_NO_MATCH = 3
const unsigned short STATUS_COMPLETE_MATCH = 4
const unsigned short KEY_UP = 1
const unsigned short KEY_DOWN = 2
const unsigned short KEY_LEFT = 3
const unsigned short KEY_RIGHT = 4
const unsigned short KEY_PAGE_UP = 5
const unsigned short KEY_PAGE_DOWN = 6
const unsigned short KEY_HOME = 7
const unsigned short KEY_END = 8
attribute nsIAutoCompleteInput input
readonly attribute unsigned short searchStatus
readonly attribute unsigned long matchCount
readonly attribute long rowCount
 The total number of rows in the tree (including the offscreen rows).
attribute nsITreeSelection selection
 The selection for this view.
const short DROP_BEFORE = -1
const short DROP_ON = 0
const short DROP_AFTER = 1
const short PROGRESS_NORMAL = 1
 The progress mode for a given cell.
const short PROGRESS_UNDETERMINED = 2
const short PROGRESS_NONE = 3

Protected Member Functions

nsresult OpenPopup ()
nsresult ClosePopup ()
nsresult StartSearch ()
nsresult StopSearch ()
nsresult StartSearchTimer ()
nsresult ClearSearchTimer ()
nsresult ProcessResult (PRInt32 aSearchIndex, nsIAutoCompleteResult *aResult)
nsresult PostSearchCleanup ()
nsresult EnterMatch ()
nsresult RevertTextValue ()
nsresult CompleteDefaultIndex (PRInt32 aSearchIndex)
nsresult CompleteValue (nsString &aValue, PRBool selectDifference)
nsresult GetResultValueAt (PRInt32 aIndex, PRBool aValueOnly, nsAString &_retval)
nsresult ClearResults ()
nsresult RowIndexToSearch (PRInt32 aRowIndex, PRInt32 *aSearchIndex, PRInt32 *aItemIndex)
nsIWidgetGetPopupWidget ()

Protected Attributes

nsCOMPtr< nsIAutoCompleteInputmInput
nsCOMPtr< nsISupportsArraymSearches
nsCOMPtr< nsISupportsArraymResults
nsCOMPtr< nsITimermTimer
nsCOMPtr< nsITreeSelectionmSelection
nsCOMPtr< nsITreeBoxObjectmTree
nsString mSearchString
PRPackedBool mEnterAfterSearch
PRPackedBool mDefaultIndexCompleted
PRPackedBool mBackspaced
PRPackedBool mPopupClosedByCompositionStart
PRPackedBool mIsIMEComposing
PRPackedBool mIgnoreHandleText
PRBool mIsOpen
PRUint16 mSearchStatus
PRUint32 mRowCount
PRUint32 mSearchesOngoing

Detailed Description

Definition at line 56 of file nsAutoCompleteController.h.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_NSIAUTOCOMPLETECONTROLLER NS_DECL_NSIAUTOCOMPLETECONTROLLER_MOZILLA_1_8_BRANCH NS_DECL_NSIAUTOCOMPLETEOBSERVER NS_DECL_NSIROLLUPLISTENER NS_DECL_NSITREEVIEW NS_DECL_NSITIMERCALLBACK nsAutoCompleteController::nsAutoCompleteController ( )

Definition at line 86 of file nsAutoCompleteController.cpp.

{
  SetInput(nsnull);
}

Member Function Documentation

boolean nsITreeView::canDrop ( in long  index,
in long  orientation 
) [inherited]

Methods used by the drag feedback code to determine if a drag is allowable at the current location.

To get the behavior where drops are only allowed on items, such as the mailNews folder pane, always return false when the orientation is not DROP_ON.

Definition at line 1226 of file nsAutoCompleteController.cpp.

{
  PRInt32 oldRowCount = mRowCount;
  mRowCount = 0;
  mResults->Clear();
  if (oldRowCount != 0 && mTree)
    mTree->RowCountChanged(0, -oldRowCount);
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 1044 of file nsAutoCompleteController.cpp.

{
  if (mTimer) {
    mTimer->Cancel();
    mTimer = nsnull;
  }
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 948 of file nsAutoCompleteController.cpp.

{
  if (!mInput) {
    return NS_OK;
  }
  nsCOMPtr<nsIAutoCompletePopup> popup;
  mInput->GetPopup(getter_AddRefs(popup));
  NS_ENSURE_TRUE(popup != nsnull, NS_ERROR_FAILURE);
  popup->SetSelectedIndex(-1);
  mIsOpen = PR_FALSE;
  return mInput->SetPopupOpen(PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1237 of file nsAutoCompleteController.cpp.

{
  if (mDefaultIndexCompleted || mEnterAfterSearch || mBackspaced || mRowCount == 0 || mSearchString.Length() == 0)
    return NS_OK;

  PRBool shouldComplete;
  mInput->GetCompleteDefaultIndex(&shouldComplete);
  if (!shouldComplete)
    return NS_OK;

  nsCOMPtr<nsIAutoCompleteSearch> search;
  mSearches->GetElementAt(aSearchIndex, getter_AddRefs(search));
  nsCOMPtr<nsIAutoCompleteResult> result;
  mResults->GetElementAt(aSearchIndex, getter_AddRefs(result));
  NS_ENSURE_TRUE(result != nsnull, NS_ERROR_FAILURE);
  
  // The search must explicitly provide a default index in order
  // for us to be able to complete 
  PRInt32 defaultIndex;
  result->GetDefaultIndex(&defaultIndex);
  NS_ENSURE_TRUE(defaultIndex >= 0, NS_OK);

  nsAutoString resultValue;
  result->GetValueAt(defaultIndex, resultValue);
  CompleteValue(resultValue, PR_TRUE);
  
  mDefaultIndexCompleted = PR_TRUE;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsAutoCompleteController::CompleteValue ( nsString aValue,
PRBool  selectDifference 
) [protected]

Definition at line 1269 of file nsAutoCompleteController.cpp.

{
  const PRInt32 mSearchStringLength = mSearchString.Length();
  PRInt32 endSelect = aValue.Length();  // By default, select all of aValue.

  if (aValue.IsEmpty() || 
      StringBeginsWith(aValue, mSearchString,
                       nsCaseInsensitiveStringComparator())) {
    // aValue is empty (we were asked to clear mInput), or mSearchString 
    // matches the beginning of aValue.  In either case we can simply 
    // autocomplete to aValue.
    mInput->SetTextValue(aValue);
  } else {
    PRInt32 findIndex;  // Offset of mSearchString within aValue.

    nsresult rv;
    nsCOMPtr<nsIIOService> ios = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
    NS_ENSURE_SUCCESS(rv, rv);
    nsCAutoString scheme;
    if (NS_SUCCEEDED(ios->ExtractScheme(NS_ConvertUTF16toUTF8(aValue), scheme))) {
      // Trying to autocomplete a URI from somewhere other than the beginning.
      // Only succeed if the missing portion is "http://"; otherwise do not
      // autocomplete.  This prevents us from "helpfully" autocompleting to a
      // URI that isn't equivalent to what the user expected.
      findIndex = 7; // length of "http://"

      if ((endSelect < findIndex + mSearchStringLength) ||
          !scheme.LowerCaseEqualsLiteral("http") ||
          !Substring(aValue, findIndex, mSearchStringLength).Equals(
            mSearchString, nsCaseInsensitiveStringComparator())) {
        return NS_OK;
      }
    } else {
      // Autocompleting something other than a URI from the middle.  Assume we
      // can just go ahead and autocomplete the missing final portion; this
      // seems like a problematic assumption...
      nsString::const_iterator iter, end;
      aValue.BeginReading(iter);
      aValue.EndReading(end);
      const nsString::const_iterator::pointer start = iter.get();
      ++iter;  // Skip past beginning since we know that doesn't match

      FindInReadable(mSearchString, iter, end, 
                     nsCaseInsensitiveStringComparator());

      findIndex = iter.get() - start;
    }

    mInput->SetTextValue(mSearchString + 
                         Substring(aValue, mSearchStringLength + findIndex,
                                   endSelect));

    endSelect -= findIndex; // We're skipping this many characters of aValue.
  }

  mInput->SelectTextRange(selectDifference ? 
                          mSearchStringLength : endSelect, endSelect);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsITreeView::cycleCell ( in long  row,
in nsITreeColumn  col 
) [inherited]

Called on the view when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.

Called on the view when a header is clicked.

void nsITreeView::drop ( in long  row,
in long  orientation 
) [inherited]

Called when the user drops something on this view.

The |orientation| param specifies before/on/after the given |row|.

Definition at line 1054 of file nsAutoCompleteController.cpp.

{
  // If a search is still ongoing, bail out of this function
  // and let the search finish, and tell it to come back here when it's done
  if (mSearchStatus == nsIAutoCompleteController::STATUS_SEARCHING) {
    mEnterAfterSearch = PR_TRUE;
    return NS_OK;
  }
  mEnterAfterSearch = PR_FALSE;
  
  nsCOMPtr<nsIAutoCompletePopup> popup;
  mInput->GetPopup(getter_AddRefs(popup));
  NS_ENSURE_TRUE(popup != nsnull, NS_ERROR_FAILURE);
  
  PRBool forceComplete;
  mInput->GetForceComplete(&forceComplete);
  
  // Ask the popup if it wants to enter a special value into the textbox
  nsAutoString value;
  popup->GetOverrideValue(value);
  if (value.IsEmpty()) {
    // If a row is selected in the popup, enter it into the textbox
    PRInt32 selectedIndex;
    popup->GetSelectedIndex(&selectedIndex);
    if (selectedIndex >= 0)
      GetResultValueAt(selectedIndex, PR_TRUE, value);
    
    if (forceComplete && value.IsEmpty()) {
      // Since nothing was selected, and forceComplete is specified, that means
      // we have to find find the first default match and enter it instead
      PRUint32 count;
      mResults->Count(&count);
      for (PRUint32 i = 0; i < count; ++i) {
        nsCOMPtr<nsIAutoCompleteResult> result;
        mResults->GetElementAt(i, getter_AddRefs(result));

        if (result) {
          PRInt32 defaultIndex;
          result->GetDefaultIndex(&defaultIndex);
          if (defaultIndex >= 0) {
            result->GetValueAt(defaultIndex, value);
            break;
          }
        }
      }
    }
  }
  
  nsCOMPtr<nsIObserverService> obsSvc =
    do_GetService("@mozilla.org/observer-service;1");
  NS_ENSURE_STATE(obsSvc);
  obsSvc->NotifyObservers(mInput, "autocomplete-will-enter-text", nsnull);

  if (!value.IsEmpty()) {
    mInput->SetTextValue(value);
    mInput->SelectTextRange(value.Length(), value.Length());
    mSearchString = value;
  }
  
  obsSvc->NotifyObservers(mInput, "autocomplete-did-enter-text", nsnull);
  ClosePopup();
  
  PRBool cancel;
  mInput->OnTextEntered(&cancel);
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsITreeView::getCellProperties ( in long  row,
in nsITreeColumn  col,
in nsISupportsArray  properties 
) [inherited]

An atomized list of properties for a given cell.

Each property, x, that the view gives back will cause the pseudoclass :moz-tree-cell-x to be matched on the ::moz-tree-cell pseudoelement.

AString nsITreeView::getCellText ( in long  row,
in nsITreeColumn  col 
) [inherited]

The text for a given cell.

If a column consists only of an image, then the empty string is returned.

AString nsITreeView::getCellValue ( in long  row,
in nsITreeColumn  col 
) [inherited]

The value for a given cell.

This method is only called for columns of type other than |text|.

Called to get properties to paint a column background.

For shading the sort column, etc.

AString nsIAutoCompleteController::getCommentAt ( in long  index) [inherited]
AString nsITreeView::getImageSrc ( in long  row,
in nsITreeColumn  col 
) [inherited]

The image path for a given cell.

For defining an icon for a cell. If the empty string is returned, the :moz-tree-image pseudoelement will be used.

long nsITreeView::getLevel ( in long  index) [inherited]

The level is an integer value that represents the level of indentation.

It is multiplied by the width specified in the :moz-tree-indentation pseudoelement to compute the exact indendation.

long nsITreeView::getParentIndex ( in long  rowIndex) [inherited]

Methods used by the tree to draw thread lines in the tree.

getParentIndex is used to obtain the index of a parent row. If there is no parent row, getParentIndex returns -1.

Definition at line 1398 of file nsAutoCompleteController.cpp.

{
  NS_ENSURE_TRUE(mInput, nsnull);

  nsCOMPtr<nsIAutoCompletePopup> autoCompletePopup;
  mInput->GetPopup(getter_AddRefs(autoCompletePopup));
  NS_ENSURE_TRUE(autoCompletePopup, nsnull);

  nsCOMPtr<nsIDOMNode> popup = do_QueryInterface(autoCompletePopup);
  NS_ENSURE_TRUE(popup, nsnull);

  nsCOMPtr<nsIDOMDocument> domDoc;
  popup->GetOwnerDocument(getter_AddRefs(domDoc));

  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
  nsIPresShell* presShell = doc->GetShellAt(0);
  nsCOMPtr<nsIContent> content = do_QueryInterface(popup);
  nsIFrame* frame;
  presShell->GetPrimaryFrameFor(content, &frame);
  while (frame) {
    nsIView* view = frame->GetViewExternal();
    if (view && view->HasWidget())
      return view->GetWidget();
    frame = frame->GetParent();
  }

  NS_ERROR("widget wasn't found!");

  return nsnull;
}

Here is the call graph for this function:

long nsITreeView::getProgressMode ( in long  row,
in nsITreeColumn  col 
) [inherited]
nsresult nsAutoCompleteController::GetResultValueAt ( PRInt32  aIndex,
PRBool  aValueOnly,
nsAString &  _retval 
) [protected]

Definition at line 1335 of file nsAutoCompleteController.cpp.

{
  NS_ENSURE_TRUE(aIndex >= 0 && (PRUint32) aIndex < mRowCount, NS_ERROR_ILLEGAL_VALUE);

  PRInt32 searchIndex;
  PRInt32 rowIndex;
  RowIndexToSearch(aIndex, &searchIndex, &rowIndex);
  NS_ENSURE_TRUE(searchIndex >= 0 && rowIndex >= 0, NS_ERROR_FAILURE);
  
  nsCOMPtr<nsIAutoCompleteResult> result;
  mResults->GetElementAt(searchIndex, getter_AddRefs(result));
  NS_ENSURE_TRUE(result != nsnull, NS_ERROR_FAILURE);
  
  PRUint16 searchResult;
  result->GetSearchResult(&searchResult);
  
  if (searchResult == nsIAutoCompleteResult::RESULT_FAILURE) {
    if (aValueOnly)
      return NS_ERROR_FAILURE;
    result->GetErrorDescription(_retval);
  } else if (searchResult == nsIAutoCompleteResult::RESULT_SUCCESS) {
    result->GetValueAt(rowIndex, _retval);
  }
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsITreeView::getRowProperties ( in long  index,
in nsISupportsArray  properties 
) [inherited]

An atomized list of properties for a given row.

Each property, x, that the view gives back will cause the pseudoclass :moz-tree-row-x to be matched on the pseudoelement ::moz-tree-row.

AString nsIAutoCompleteController::getStyleAt ( in long  index) [inherited]
AString nsIAutoCompleteController::getValueAt ( in long  index) [inherited]
boolean nsIAutoCompleteController::handleKeyNavigation ( in unsigned short  key) [inherited]
void nsIAutoCompleteController::handleText ( in boolean  aIgnoreSelection) [inherited]
boolean nsITreeView::hasNextSibling ( in long  rowIndex,
in long  afterIndex 
) [inherited]

hasNextSibling is used to determine if the row at rowIndex has a nextSibling that occurs after the index specified by afterIndex.

Code that is forced to march down the view looking at levels can optimize the march by starting at afterIndex+1.

boolean nsITreeView::isContainer ( in long  index) [inherited]

Methods that can be used to test whether or not a twisty should be drawn, and if so, whether an open or closed twisty should be used.

Here is the caller graph for this function:

boolean nsITreeView::isContainerEmpty ( in long  index) [inherited]
boolean nsITreeView::isContainerOpen ( in long  index) [inherited]
boolean nsITreeView::isEditable ( in long  row,
in nsITreeColumn  col 
) [inherited]

isEditable is called to ask the view if the cell contents are editable.

A value of true will result in the tree popping up a text field when the user tries to inline edit the cell.

boolean nsITreeView::isSeparator ( in long  index) [inherited]

isSeparator is used to determine if the row at index is a separator.

A value of true will result in the tree drawing a horizontal separator. The tree uses the ::moz-tree-separator pseudoclass to draw the separator.

boolean nsITreeView::isSorted ( ) [inherited]

Specifies if there is currently a sort on any column.

Used mostly by dragdrop to affect drop feedback.

void nsITimerCallback::notify ( in nsITimer  timer) [inherited]
Parameters:
aTimerthe timer which has expired

Definition at line 934 of file nsAutoCompleteController.cpp.

{
  PRUint32 minResults;
  mInput->GetMinResultsForPopup(&minResults);

  if (mRowCount >= minResults) {
    mIsOpen = PR_TRUE;
    return mInput->SetPopupOpen(PR_TRUE);
  }
  
  return NS_OK;
}

Here is the caller graph for this function:

void nsITreeView::performAction ( in wstring  action) [inherited]

A command API that can be used to invoke commands on the selection.

The tree will automatically invoke this method when certain keys are pressed. For example, when the DEL key is pressed, performAction will be called with the "delete" string.

void nsITreeView::performActionOnCell ( in wstring  action,
in long  row,
in nsITreeColumn  col 
) [inherited]

A command API that can be used to invoke commands on a specific cell.

void nsITreeView::performActionOnRow ( in wstring  action,
in long  row 
) [inherited]

A command API that can be used to invoke commands on a specific row.

Definition at line 1204 of file nsAutoCompleteController.cpp.

{  
  if (mRowCount) {
    OpenPopup();
    mSearchStatus = nsIAutoCompleteController::STATUS_COMPLETE_MATCH;
  } else {
    mSearchStatus = nsIAutoCompleteController::STATUS_COMPLETE_NO_MATCH;
    ClosePopup();
  }
  
  // notify the input that the search is complete
  mInput->OnSearchComplete();
  
  // if mEnterAfterSearch was set, then the user hit enter while the search was ongoing,
  // so we need to enter a match now that the search is done
  if (mEnterAfterSearch)
    EnterMatch();

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsAutoCompleteController::ProcessResult ( PRInt32  aSearchIndex,
nsIAutoCompleteResult aResult 
) [protected]

Definition at line 1145 of file nsAutoCompleteController.cpp.

{
  NS_ENSURE_STATE(mInput);
  // If this is the first search to return, we should clear out the previous cached results
  PRUint32 searchCount;
  mSearches->Count(&searchCount);
  if (mSearchesOngoing == searchCount)
    ClearResults();

  --mSearchesOngoing;
  
  // Cache the result
  mResults->AppendElement(aResult);

  // If the search failed, increase the match count to include the error description
  PRUint16 result = 0;
  PRUint32 oldRowCount = mRowCount;

  if (aResult)
    aResult->GetSearchResult(&result);
  if (result == nsIAutoCompleteResult::RESULT_FAILURE) {
    nsAutoString error;
    aResult->GetErrorDescription(error);
    if (!error.IsEmpty())
      ++mRowCount;
  } else if (result == nsIAutoCompleteResult::RESULT_SUCCESS) {
    // Increase the match count for all matches in this result
    PRUint32 matchCount = 0;
    aResult->GetMatchCount(&matchCount);
    mRowCount += matchCount;

    // Try to autocomplete the default index for this search
    CompleteDefaultIndex(aSearchIndex);
  }

  if (oldRowCount != mRowCount && mTree)
    mTree->RowCountChanged(oldRowCount, mRowCount - oldRowCount);

  // Refresh the popup view to display the new search results
  nsCOMPtr<nsIAutoCompletePopup> popup;
  mInput->GetPopup(getter_AddRefs(popup));
  NS_ENSURE_TRUE(popup != nsnull, NS_ERROR_FAILURE);
  popup->Invalidate();
  
  // Make sure the popup is open, if necessary, since we now
  // have at least one search result ready to display
  if (mRowCount)
    OpenPopup();
  else
    ClosePopup();

  // If this is the last search to return, cleanup
  if (mSearchesOngoing == 0)
    PostSearchCleanup();

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 1123 of file nsAutoCompleteController.cpp.

{
  nsAutoString oldValue(mSearchString);
  
  PRBool cancel = PR_FALSE;
  mInput->OnTextReverted(&cancel);  

  if (!cancel) {
    nsCOMPtr<nsIObserverService> obsSvc =
      do_GetService("@mozilla.org/observer-service;1");
    NS_ENSURE_STATE(obsSvc);
    obsSvc->NotifyObservers(mInput, "autocomplete-will-revert-text", nsnull);

    mInput->SetTextValue(oldValue);

    obsSvc->NotifyObservers(mInput, "autocomplete-did-revert-text", nsnull);
  }

  return NS_OK;
}

Here is the call graph for this function:

Notifies the object to rollup.

Returns:
NS_Ok if no errors

Implemented in nsComboboxControlFrame.

Here is the caller graph for this function:

nsresult nsAutoCompleteController::RowIndexToSearch ( PRInt32  aRowIndex,
PRInt32 aSearchIndex,
PRInt32 aItemIndex 
) [protected]

Definition at line 1363 of file nsAutoCompleteController.cpp.

{
  *aSearchIndex = -1;
  *aItemIndex = -1;
  
  PRUint32 count;
  mSearches->Count(&count);
  PRUint32 index = 0;
  for (PRUint32 i = 0; i < count; ++i) {
    nsCOMPtr<nsIAutoCompleteResult> result;
    mResults->GetElementAt(i, getter_AddRefs(result));
    if (!result)
      continue;
      
    PRUint16 searchResult;
    result->GetSearchResult(&searchResult);
    
    PRUint32 rowCount = 1;
    if (searchResult == nsIAutoCompleteResult::RESULT_SUCCESS) {
      result->GetMatchCount(&rowCount);
    }
    
    if (index + rowCount-1 >= (PRUint32) aRowIndex) {
      *aSearchIndex = i;
      *aItemIndex = aRowIndex - index;
      return NS_OK;
    }

    index += rowCount;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Should be called from a XUL onselect handler whenever the selection changes.

void nsITreeView::setCellText ( in long  row,
in nsITreeColumn  col,
in AString  value 
) [inherited]

setCellText is called when the contents of the cell have been edited by the user.

void nsITreeView::setCellValue ( in long  row,
in nsITreeColumn  col,
in AString  value 
) [inherited]

setCellValue is called when the value of the cell has been set by the user.

This method is only called for columns of type other than |text|.

void nsIAutoCompleteController::setSearchString ( in AString  aSearchString) [inherited]

Called during initialization to link the view to the front end box object.

Asks the RollupListener if it should rollup on mouse activate, eg.

X-Mouse

Returns:
NS_Ok if no errors

Here is the caller graph for this function:

Asks the RollupListener if it should rollup on mousevents.

Returns:
NS_Ok if no errors

Here is the caller graph for this function:

Definition at line 176 of file nsAutoCompleteController.cpp.

{ 
  mSearchString = aSearchString;
  StartSearchTimer();

  return NS_OK;
}

Here is the call graph for this function:

void nsIAutoCompleteController::startSearch ( in AString  searchString) [inherited]

Definition at line 1027 of file nsAutoCompleteController.cpp.

{
  // Don't create a new search timer if we're already waiting for one to fire.
  // If we don't check for this, we won't be able to cancel the original timer
  // and may crash when it fires (bug 236659).
  if (mTimer || !mInput)
    return NS_OK;

  PRUint32 timeout;
  mInput->GetTimeout(&timeout);

  mTimer = do_CreateInstance("@mozilla.org/timer;1");
  mTimer->InitWithCallback(this, timeout, nsITimer::TYPE_ONE_SHOT);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1007 of file nsAutoCompleteController.cpp.

{
  // Stop the timer if there is one
  ClearSearchTimer();

  // Stop any ongoing asynchronous searches
  if (mSearchStatus == nsIAutoCompleteController::STATUS_SEARCHING) {
    PRUint32 count;
    mSearches->Count(&count);
  
    for (PRUint32 i = 0; i < count; ++i) {
      nsCOMPtr<nsIAutoCompleteSearch> search;
      mSearches->GetElementAt(i, getter_AddRefs(search));
      search->StopSearch();
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

void nsITreeView::toggleOpenState ( in long  index) [inherited]

Called on the view when an item is opened or closed.


Member Data Documentation

const short nsITreeView::DROP_AFTER = 1 [inherited]

Definition at line 103 of file nsITreeView.idl.

const short nsITreeView::DROP_BEFORE = -1 [inherited]

Definition at line 101 of file nsITreeView.idl.

const short nsITreeView::DROP_ON = 0 [inherited]

Definition at line 102 of file nsITreeView.idl.

Definition at line 70 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::KEY_DOWN = 2 [inherited]

Definition at line 59 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::KEY_END = 8 [inherited]

Definition at line 65 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::KEY_HOME = 7 [inherited]

Definition at line 64 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::KEY_LEFT = 3 [inherited]

Definition at line 60 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::KEY_PAGE_DOWN = 6 [inherited]

Definition at line 63 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::KEY_PAGE_UP = 5 [inherited]

Definition at line 62 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::KEY_RIGHT = 4 [inherited]

Definition at line 61 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::KEY_UP = 1 [inherited]

Definition at line 58 of file nsIAutoCompleteController.idl.

readonly attribute unsigned long nsIAutoCompleteController::matchCount [inherited]

Definition at line 80 of file nsIAutoCompleteController.idl.

Definition at line 114 of file nsAutoCompleteController.h.

Definition at line 113 of file nsAutoCompleteController.h.

Definition at line 112 of file nsAutoCompleteController.h.

Definition at line 117 of file nsAutoCompleteController.h.

Definition at line 102 of file nsAutoCompleteController.h.

Definition at line 116 of file nsAutoCompleteController.h.

Definition at line 118 of file nsAutoCompleteController.h.

Definition at line 115 of file nsAutoCompleteController.h.

Definition at line 105 of file nsAutoCompleteController.h.

Definition at line 120 of file nsAutoCompleteController.h.

Definition at line 104 of file nsAutoCompleteController.h.

Definition at line 121 of file nsAutoCompleteController.h.

Definition at line 119 of file nsAutoCompleteController.h.

Definition at line 111 of file nsAutoCompleteController.h.

Definition at line 108 of file nsAutoCompleteController.h.

Definition at line 107 of file nsAutoCompleteController.h.

Definition at line 109 of file nsAutoCompleteController.h.

const short nsITreeView::PROGRESS_NONE = 3 [inherited]

Definition at line 153 of file nsITreeView.idl.

const short nsITreeView::PROGRESS_NORMAL = 1 [inherited]

The progress mode for a given cell.

This method is only called for columns of type |progressmeter|.

Definition at line 151 of file nsITreeView.idl.

Definition at line 152 of file nsITreeView.idl.

readonly attribute long nsITreeView::rowCount [inherited]

The total number of rows in the tree (including the offscreen rows).

Definition at line 53 of file nsITreeView.idl.

readonly attribute unsigned short nsIAutoCompleteController::searchStatus [inherited]

Definition at line 75 of file nsIAutoCompleteController.idl.

The selection for this view.

Definition at line 58 of file nsITreeView.idl.

Definition at line 53 of file nsIAutoCompleteController.idl.

Definition at line 52 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::STATUS_NONE = 1 [inherited]

Definition at line 50 of file nsIAutoCompleteController.idl.

const unsigned short nsIAutoCompleteController::STATUS_SEARCHING = 2 [inherited]

Definition at line 51 of file nsIAutoCompleteController.idl.


The documentation for this class was generated from the following files: