Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch treeview-list-detached Excluding Merge-Ins
This is equivalent to a diff from acdfd0eb to bcf2edd9
2023-11-14
| ||
19:59 | TIP #678: Better API for Detached Treeview Items check-in: e416d422 user: dkf tags: trunk, main | |
2023-11-13
| ||
18:35 | merge trunk Closed-Leaf check-in: bcf2edd9 user: dkf tags: treeview-list-detached | |
17:25 | Using the application's TkMainInfo struct for sharing the nbTabsStickBit in a thread-safe manner. Thanks Christian W.! check-in: acdfd0eb user: csaba tags: trunk, main | |
09:11 | Merge 8.7 (this should fix the Windows "symbols" build) check-in: 5f3cf3c4 user: jan.nijtmans tags: trunk, main | |
2023-11-11
| ||
09:21 | Unbreak the build. check-in: 23af7721 user: fvogel tags: treeview-list-detached | |
Changes to doc/ttk_treeview.n.
︙ | ︙ | |||
228 229 230 231 232 233 234 235 236 237 238 239 240 241 | Unlinks all of the specified items in \fIitemList\fR from the tree. The items and all of their descendants are still present and may be reinserted at another point in the tree with the \fBmove\fR operation, but will not be displayed until that is done. The root item may not be detached. See also: \fBdelete\fR. .TP \fIpathname \fBexists \fIitem\fR Returns 1 if the specified \fIitem\fR is present in the tree, 0 otherwise. .TP \fIpathname \fBfocus \fR?\fIitem\fR? If \fIitem\fR is specified, sets the focus item to \fIitem\fR. | > > > > > > > | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | Unlinks all of the specified items in \fIitemList\fR from the tree. The items and all of their descendants are still present and may be reinserted at another point in the tree with the \fBmove\fR operation, but will not be displayed until that is done. The root item may not be detached. See also: \fBdelete\fR. .TP \fIpathname \fBdetached \fR?\fIitem\fR? . If \fIitem\fR is provided, returns a boolean value indicating whether it is the name of a detached item (see \fBdetach\fR). Otherwise, returns a list of all the detached items (in an arbitrary order). The root item is never detached. .TP \fIpathname \fBexists \fIitem\fR Returns 1 if the specified \fIitem\fR is present in the tree, 0 otherwise. .TP \fIpathname \fBfocus \fR?\fIitem\fR? If \fIitem\fR is specified, sets the focus item to \fIitem\fR. |
︙ | ︙ |
Changes to generic/ttk/ttkTreeview.c.
︙ | ︙ | |||
3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 | tv->tree.rowPosNeedsUpdate = 1; TtkRedisplayWidget(&tv->core); ckfree(items); return TCL_OK; } /* + $tv delete $items -- * Delete each item in $items. * * Do this in two passes: * First detach the item and all its descendants and remove them * from the hash table. Free the items themselves in a second pass. * | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 | tv->tree.rowPosNeedsUpdate = 1; TtkRedisplayWidget(&tv->core); ckfree(items); return TCL_OK; } /* Is an item detached? The root is never detached. */ static int IsDetached(Treeview *tv, TreeItem *item) { return item->next == NULL && item->prev == NULL && item->parent == NULL && item != tv->tree.root; } /* + $tv detached ?$item? -- * List detached items (in arbitrary order) or query the detached state of * $item. */ static int TreeviewDetachedCommand( void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeItem *item; if (objc == 2) { /* List detached items */ Tcl_HashSearch search; Tcl_HashEntry *entryPtr = Tcl_FirstHashEntry(&tv->tree.items, &search); Tcl_Obj *objPtr = Tcl_NewObj(); while (entryPtr != NULL) { item = Tcl_GetHashValue(entryPtr); entryPtr = Tcl_NextHashEntry(&search); if (IsDetached(tv, item)) { Tcl_ListObjAppendElement(NULL, objPtr, ItemID(tv, item)); } } Tcl_SetObjResult(interp, objPtr); return TCL_OK; } else if (objc == 3) { /* Query; the root is never reported as detached */ if (!(item = FindItem(interp, tv, objv[2]))) { return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(IsDetached(tv, item))); return TCL_OK; } else { Tcl_WrongNumArgs(interp, 2, objv, "?item?"); return TCL_ERROR; } } /* + $tv delete $items -- * Delete each item in $items. * * Do this in two passes: * First detach the item and all its descendants and remove them * from the hash table. Free the items themselves in a second pass. * |
︙ | ︙ | |||
4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 | { "cellselection" , TreeviewCellSelectionCommand,0 }, { "children", TreeviewChildrenCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, { "column", TreeviewColumnCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "delete", TreeviewDeleteCommand,0 }, { "detach", TreeviewDetachCommand,0 }, { "drag", TreeviewDragCommand,0 }, { "drop", TreeviewDropCommand,0 }, { "exists", TreeviewExistsCommand,0 }, { "focus", TreeviewFocusCommand,0 }, { "heading", TreeviewHeadingCommand,0 }, { "identify", TreeviewIdentifyCommand,0 }, { "index", TreeviewIndexCommand,0 }, | > | 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 | { "cellselection" , TreeviewCellSelectionCommand,0 }, { "children", TreeviewChildrenCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, { "column", TreeviewColumnCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "delete", TreeviewDeleteCommand,0 }, { "detach", TreeviewDetachCommand,0 }, { "detached", TreeviewDetachedCommand,0 }, { "drag", TreeviewDragCommand,0 }, { "drop", TreeviewDropCommand,0 }, { "exists", TreeviewExistsCommand,0 }, { "focus", TreeviewFocusCommand,0 }, { "heading", TreeviewHeadingCommand,0 }, { "identify", TreeviewIdentifyCommand,0 }, { "index", TreeviewIndexCommand,0 }, |
︙ | ︙ |
Changes to tests/ttk/treeview.test.
︙ | ︙ | |||
187 188 189 190 191 192 193 194 195 | foreach item [.tv children {}] { lappend result [.tv index $item] } set result } -result [list 0 1 2 3 4 5 6] test treeview-3.6 "detach" -body { .tv detach newnode consistencyCheck .tv | > | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | foreach item [.tv children {}] { lappend result [.tv index $item] } set result } -result [list 0 1 2 3 4 5 6] test treeview-3.6 "detach" -body { set before [.tv detached newnode] .tv detach newnode consistencyCheck .tv list [.tv children {}] [.tv detached] $before [.tv detached newnode] } -result {{newfirstone firstnode anotherone onemore lastnode newlastone} newnode 0 1} # XREF: treeview-2.13 test treeview-3.7 "detach didn't screw up internal links" -body { consistencyCheck .tv set result [list] foreach item [.tv children {}] { lappend result [.tv index $item] |
︙ | ︙ | |||
225 226 227 228 229 230 231 232 233 | .tv detach [list {}] } -cleanup { update consistencyCheck .tv } -returnCodes error -result "Cannot detach root item" test treeview-3.12 "Reattach" -body { .tv move newnode {} end consistencyCheck .tv | > | | > | | | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | .tv detach [list {}] } -cleanup { update consistencyCheck .tv } -returnCodes error -result "Cannot detach root item" test treeview-3.12 "Reattach" -body { set before [.tv detached newnode] .tv move newnode {} end consistencyCheck .tv list [.tv children {}] $before [.tv detached newnode] [.tv detached] } -result {{newfirstone firstnode anotherone onemore lastnode newlastone newnode} 1 0 {}} # Bug # ????? test treeview-3.13 "Re-reattach" -body { set before [.tv detached newnode] .tv move newnode {} end consistencyCheck .tv list [.tv children {}] $before [.tv detached newnode] } -result {{newfirstone firstnode anotherone onemore lastnode newlastone newnode} 0 0} catch { .tv insert newfirstone end -id x1 .tv insert newfirstone end -id x2 .tv insert newfirstone end -id x3 } |
︙ | ︙ |