Reorganize things a bit so that we no longer need the 'valid' flag on

each item.
Small comments update.
This commit is contained in:
Dimitrie O. Paun 2002-10-19 00:16:37 +00:00 committed by Alexandre Julliard
parent c07f4cbd42
commit f8f559fa3c
1 changed files with 14 additions and 16 deletions

View File

@ -97,7 +97,6 @@ typedef struct tagLISTVIEW_ITEM
UINT state; UINT state;
LPARAM lParam; LPARAM lParam;
INT iIndent; INT iIndent;
BOOL valid;
} LISTVIEW_ITEM; } LISTVIEW_ITEM;
typedef struct tagRANGE typedef struct tagRANGE
@ -2878,6 +2877,7 @@ static inline BOOL is_assignable_item(LPLVITEMW lpLVItem, LONG lStyle)
* PARAMETER(S): * PARAMETER(S):
* [I] infoPtr : valid pointer to the listview structure * [I] infoPtr : valid pointer to the listview structure
* [I] lpLVItem : valid pointer to new item atttributes * [I] lpLVItem : valid pointer to new item atttributes
* [I] isNew : the item being set is being inserted
* [I] isW : TRUE if lpLVItem is Unicode, FALSE if it's ANSI * [I] isW : TRUE if lpLVItem is Unicode, FALSE if it's ANSI
* [O] bChanged : will be set to TRUE if the item really changed * [O] bChanged : will be set to TRUE if the item really changed
* *
@ -2885,7 +2885,7 @@ static inline BOOL is_assignable_item(LPLVITEMW lpLVItem, LONG lStyle)
* SUCCESS : TRUE * SUCCESS : TRUE
* FAILURE : FALSE * FAILURE : FALSE
*/ */
static BOOL set_main_item(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL isW, BOOL *bChanged) static BOOL set_main_item(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL isNew, BOOL isW, BOOL *bChanged)
{ {
LISTVIEW_ITEM *lpItem; LISTVIEW_ITEM *lpItem;
NMLISTVIEW nmlv; NMLISTVIEW nmlv;
@ -2894,6 +2894,8 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL isW,
TRACE("()\n"); TRACE("()\n");
if (lpLVItem->mask == 0) return TRUE;
if (infoPtr->dwStyle & LVS_OWNERDATA) if (infoPtr->dwStyle & LVS_OWNERDATA)
{ {
/* a virtual listview we stores only selection and focus */ /* a virtual listview we stores only selection and focus */
@ -2945,7 +2947,7 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL isW,
/* send LVN_ITEMCHANGING notification, if the item is not being inserted */ /* send LVN_ITEMCHANGING notification, if the item is not being inserted */
/* and we are _NOT_ virtual (LVS_OWERNDATA) */ /* and we are _NOT_ virtual (LVS_OWERNDATA) */
if(lpItem && lpItem->valid && notify_listview(infoPtr, LVN_ITEMCHANGING, &nmlv)) if(lpItem && !isNew && notify_listview(infoPtr, LVN_ITEMCHANGING, &nmlv))
return FALSE; return FALSE;
/* copy information */ /* copy information */
@ -2991,7 +2993,7 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL isW,
} }
/* if we're inserting the item, we're done */ /* if we're inserting the item, we're done */
if (lpItem && !lpItem->valid) return TRUE; if (isNew) return TRUE;
/* send LVN_ITEMCHANGED notification */ /* send LVN_ITEMCHANGED notification */
if (lpLVItem->mask & LVIF_PARAM) nmlv.lParam = lpLVItem->lParam; if (lpLVItem->mask & LVIF_PARAM) nmlv.lParam = lpLVItem->lParam;
@ -3002,7 +3004,7 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL isW,
/*** /***
* DESCRIPTION: * DESCRIPTION:
* Helper for LISTVIEW_SetItemT *only*: sets subitem attributes. * Helper for LISTVIEW_{Set,Insert}ItemT *only*: sets subitem attributes.
* *
* PARAMETER(S): * PARAMETER(S):
* [I] infoPtr : valid pointer to the listview structure * [I] infoPtr : valid pointer to the listview structure
@ -3098,8 +3100,6 @@ static BOOL LISTVIEW_SetItemT(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL i
if (!lpLVItem || lpLVItem->iItem < 0 || lpLVItem->iItem >= infoPtr->nItemCount) if (!lpLVItem || lpLVItem->iItem < 0 || lpLVItem->iItem >= infoPtr->nItemCount)
return FALSE; return FALSE;
if (lpLVItem->mask == 0) return TRUE;
/* For efficiency, we transform the lpLVItem->pszText to Unicode here */ /* For efficiency, we transform the lpLVItem->pszText to Unicode here */
if ((lpLVItem->mask & LVIF_TEXT) && is_textW(lpLVItem->pszText)) if ((lpLVItem->mask & LVIF_TEXT) && is_textW(lpLVItem->pszText))
{ {
@ -3113,7 +3113,7 @@ static BOOL LISTVIEW_SetItemT(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL i
if (lpLVItem->iSubItem) if (lpLVItem->iSubItem)
bResult = set_sub_item(infoPtr, lpLVItem, TRUE, &bChanged); bResult = set_sub_item(infoPtr, lpLVItem, TRUE, &bChanged);
else else
bResult = set_main_item(infoPtr, lpLVItem, TRUE, &bChanged); bResult = set_main_item(infoPtr, lpLVItem, FALSE, TRUE, &bChanged);
/* redraw item, if necessary */ /* redraw item, if necessary */
if (bChanged && !infoPtr->bIsDrawing) if (bChanged && !infoPtr->bIsDrawing)
@ -4741,7 +4741,7 @@ static BOOL LISTVIEW_GetItemT(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL i
if ((lpLVItem->mask & LVIF_IMAGE) && pItemHdr->iImage == I_IMAGECALLBACK) if ((lpLVItem->mask & LVIF_IMAGE) && pItemHdr->iImage == I_IMAGECALLBACK)
dispInfo.item.mask |= LVIF_IMAGE; dispInfo.item.mask |= LVIF_IMAGE;
/* Do we need to enquire about the text? */ /* Apps depend on calling back for text if it is NULL or LPSTR_TEXTCALLBACKW */
if ((lpLVItem->mask & LVIF_TEXT) && !is_textW(pItemHdr->pszText)) if ((lpLVItem->mask & LVIF_TEXT) && !is_textW(pItemHdr->pszText))
{ {
dispInfo.item.mask |= LVIF_TEXT; dispInfo.item.mask |= LVIF_TEXT;
@ -4765,7 +4765,7 @@ static BOOL LISTVIEW_GetItemT(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL i
if (dispInfo.item.mask & LVIF_IMAGE) if (dispInfo.item.mask & LVIF_IMAGE)
{ {
lpLVItem->iImage = dispInfo.item.iImage; lpLVItem->iImage = dispInfo.item.iImage;
if ((dispInfo.item.mask & LVIF_DI_SETITEM) && (pItemHdr->iImage==I_IMAGECALLBACK)) if ((dispInfo.item.mask & LVIF_DI_SETITEM) && pItemHdr->iImage == I_IMAGECALLBACK)
pItemHdr->iImage = dispInfo.item.iImage; pItemHdr->iImage = dispInfo.item.iImage;
} }
else if (lpLVItem->mask & LVIF_IMAGE) else if (lpLVItem->mask & LVIF_IMAGE)
@ -5792,7 +5792,7 @@ static LRESULT LISTVIEW_InsertItemT(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem,
HDPA hdpaSubItems; HDPA hdpaSubItems;
NMLISTVIEW nmlv; NMLISTVIEW nmlv;
LISTVIEW_ITEM *lpItem; LISTVIEW_ITEM *lpItem;
BOOL is_sorted; BOOL is_sorted, has_changed;
TRACE("(lpLVItem=%s, isW=%d)\n", debuglvitem_t(lpLVItem, isW), isW); TRACE("(lpLVItem=%s, isW=%d)\n", debuglvitem_t(lpLVItem, isW), isW);
@ -5827,8 +5827,8 @@ static LRESULT LISTVIEW_InsertItemT(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem,
/* the array may be sparsly populated, we can't just increment the count here */ /* the array may be sparsly populated, we can't just increment the count here */
infoPtr->nItemCount = infoPtr->hdpaItems->nItemCount; infoPtr->nItemCount = infoPtr->hdpaItems->nItemCount;
if (!LISTVIEW_SetItemT(infoPtr, lpLVItem, isW)) /* set the item attributes */
goto undo; if (!set_main_item(infoPtr, lpLVItem, TRUE, isW, &has_changed)) goto undo;
/* if we're sorted, sort the list, and update the index */ /* if we're sorted, sort the list, and update the index */
if (is_sorted) if (is_sorted)
@ -5855,8 +5855,6 @@ static LRESULT LISTVIEW_InsertItemT(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem,
*/ */
LISTVIEW_ShiftIndices(infoPtr, nItem, 1); LISTVIEW_ShiftIndices(infoPtr, nItem, 1);
lpItem->valid = TRUE;
/* send LVN_INSERTITEM notification */ /* send LVN_INSERTITEM notification */
ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
nmlv.iItem = nItem; nmlv.iItem = nItem;