Link to: header | other data directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
DB_AccountNameArrayOwner
owner of an array of account names and status, used for clairvoyant fields,
and to fill in icon order for the chart of accounts.
We use this class to increase performance. With an array owner we can fill
in a list of accounts in a small fraction of a second, while it might take
several seconds to retrieve a thousand names from separate account records.
The tradeoff is memory use (this class adds 58 bytes of storage for each
account) and potential database fragility (if changes are not stored properly,
the menu display can mismatch the actual accounts).
This class manages account names for the Goldenseal job cost accounting software,
project management software and construction project
estimating software.
SUPERCLASS = DB_PersistentObject
Constructor
/*********************************************************************************
Constructor
*********************************************************************************/
DB_AccountNameArrayOwner::DB_AccountNameArrayOwner()
{
mEndSafetyTag = tag_endsafetytag; // TCS 9/8/02
// we used to set array sorting and comparator here. Now that's done
// in AddObject TCS 9/20/00
}
Source Code
DB_AccountNameArrayOwner::SortIconArray(const PaneIDT colID, TArray<LPane*> &iconArray,
const UInt8 sortMethod, const Boolean reverseSort)
{
// create a master name array
TAccountNameArray *nameArray = NEW TAccountNameArray;
TCS_FailNILMsg(nameArray, TCS_GetErrString(errID_BadArray));
TCS_TRY
{
// fill in the array for all accounts in the column
FillMasterNameArray(colID, nameArray, sortMethod, reverseSort);
if (sortMethod == sort_Custom)
{
}
else
{
// move the current icons to a new temporary array
TIconSortArray tempArray;
SIconSortInfo sortInfo;
sortInfo.filler = 0;
LPane *pane = nil;
CAFWIcon *icon = nil;
TArrayIterator<LPane*> iconIterator(iconArray);
while (iconIterator.Next(pane))
{
icon = TCS_SAFE_CAST(pane, CAFWIcon); // TCS tidy 12/13/03
if (icon)
{
sortInfo.classID = icon->GetAccountClassID();
sortInfo.accountID = icon->GetAccountID();
sortInfo.icon = icon;
tempArray.Append(sortInfo);
}
}
iconArray.RemoveItemsAt(iconArray.GetCount(), 1);
CIconSortComparator *comparator = NEW CIconSortComparator();
TCS_FailNILMsg(comparator, TCS_GetErrString(errID_BadComparator));
tempArray.SetComparator(comparator, cWillDeleteComparator);
tempArray.SetKeepSorted(true);
TAccountNameArrayIterator iterator(*nameArray);
SAccountNameInfo info;
SInt32 index;
while (iterator.Next(info))
{
sortInfo.accountID = info.id;
sortInfo.classID = info.status;
index = tempArray.FetchIndexOf(sortInfo);
if (index != LArray::index_Bad)
{
tempArray.FetchItemAt(index, sortInfo);
iconArray.InsertItemsAt(1, LArray::index_Last, sortInfo.icon);
}
}
}
}
TCS_CATCH {}
TCS_Forget(nameArray);
}
|