beautypg.com

Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 583

background image

C H A P T E R 1 5

Filing

Using the Filing Service

15-17

perform any other actions that are appropriate, such as redrawing views affected by
the change in filing filter.

The symbol passed as the sole argument to your

NewFilingFilter

method

specifies which of the

storesFilter

or

labelsFilter

slots changed in value.

This argument does not specify the slot’s new value, however. Your

NewFilingFilter

method must use the current value of the specified slot to

retrieve those soup entries that fall into the new filing category.

The following code example shows the implementation of a typical

NewFilingFilter

method, which queries the application soup for the entries

that match the current filing category and then redraws views affected by the
change in filing category.

NewFilingFilter: func(newFilterPath)

begin

// first figure out if query should be done on

// a union soup or on a specific store soup

// this is to make filter by store more efficient

local querySoup := GetUnionSoupAlways(kSoupName) ;

if storesFilter and storesFilter:IsValid() then

querySoup := querySoup:GetMember(storesFilter) ;

// now construct the query based on the labelsFilter

// and set my application cursor (called myCursor)

// to the new query

// the default is to show all items, i.e.,

// labelsFilter is '_all

local theQuery := nil ;

if NOT labelsFilter then

// labelsFilter is NIL, so show only those entries

// that do not have a valid tag in the labels

// slot

theQuery := {none: GetFolderList(appSymbol, nil)};

else if labelsFilter <> '_all then

// labelsFilter is some specific folder

theQuery := {all: labelsFilter} ;

myCursor := querySoup:Query(theQuery) ;