Node state setting method of tree structure, related device and storage medium
By setting node states from the outside to the inside in a tree structure and using a global container to store the check status of leaf nodes, the problem of excessively long node state setting time in traditional solutions is solved, achieving faster response and improved user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-07
AI Technical Summary
Traditional solutions take too long to set the node states of a tree structure, resulting in excessively long interface response times and impacting user experience, especially when the number of variables is large.
After constructing a tree structure, the node status is set from the outside to the inside based on the global container. The leaf node only needs to synchronize its status to the parent node, saving the step of finding the parent node level by level. The global container is used to store the names of the leaf nodes with selected statuses, so as to achieve fast response.
It significantly shortens the node state setting time, improves interface response speed, and ensures the continuity and efficiency of user operations.
Smart Images

Figure CN121807281A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method for setting the node status of a tree structure, related devices, and storage media. Background Technology
[0002] Currently, when exporting from the interface, since the total number of variables changes dynamically with the changes in the simulation model (i.e., variables are volatile), it is necessary to first clear the original tree structure and rebuild a new tree structure. At the same time, it is necessary to ensure that the check status of leaf nodes with the same variable name is consistent with that before the last time the dialog box was closed, and the check status of the parent node needs to be dynamically adjusted according to the status of its child nodes.
[0003] In traditional solutions, after setting the child node states of a tree structure, the parent node needs to "listen to changes in the child node states". Whenever a child node's checked state changes, the parent node needs to re-traverse all its child nodes to count the states and finally determine its own checked state.
[0004] However, when the variables in the tree structure are greater than a certain value (such as 100,000), the traditional solution takes a long time to initialize and the pop-up interface response time is too long, which seriously affects the user experience. Summary of the Invention
[0005] In view of this, the present invention provides a method, related device and storage medium for setting the node state of a tree structure, so as to solve the problem that the traditional solution takes too long to set the node state of a tree structure, resulting in a long response time for the pop-up interface.
[0006] The first aspect of this invention provides a method for setting the node state of a tree structure, comprising:
[0007] Receive export requests from the interface;
[0008] A tree structure is constructed based on the hierarchical relationship of all variables in the current software.
[0009] From the outside to the inside of the tree structure, the node state of each level of the tree structure is set based on a global container; wherein, the global container is updated when the interface is opened and closed, and stores the names of all leaf nodes whose node state is checked.
[0010] Optionally, setting the node state of each level of the tree structure from the outside in, based on a global container, includes:
[0011] Starting from the outside to the inside of the tree structure, for each leaf node in the tree structure, the name of the leaf node is queried in the global container to obtain the query result;
[0012] Based on the query results, set the node status of the leaf node;
[0013] The state flag of the parent node of the leaf node is triggered based on the node state of the leaf node;
[0014] After all leaf nodes in the hierarchy have been traversed, the node state of the parent node of the leaf node is set according to the triggering status of the parent node's status flag, until the node state in each level of the tree structure has been set.
[0015] Optionally, setting the node status of the leaf node based on the query result includes:
[0016] If the query result indicates that the name of the leaf node exists in the global container, then the node status of the leaf node is set to the checked state;
[0017] If the query result indicates that the name of the leaf node is not found in the global container, then the node status of the leaf node is set to unchecked.
[0018] Optionally, the status flags include: a checked flag and an unchecked flag. The triggering of the parent node's status flag based on the leaf node's node status includes:
[0019] If the node status of the leaf node is checked, then the check flag of the parent node of the leaf node is triggered.
[0020] If the node status of the leaf node is unchecked, then the unchecked flag of the parent node of the leaf node is triggered.
[0021] Optionally, after all leaf nodes in the hierarchy have been traversed, the node state of the parent node of the leaf node is set according to the triggering status flag of the parent node of the leaf node, including:
[0022] After all leaf nodes in the hierarchy have been traversed, if both status flags of the parent node of the leaf node are triggered, then the node status of the parent node of the leaf node is set to a half-checked state.
[0023] If the check flag of the parent node of the leaf node is triggered, then the node state of the parent node of the leaf node is set to the check flag state.
[0024] If the unchecked flag of the parent node of the leaf node is triggered, the node state of the parent node of the leaf node is set to the unchecked state.
[0025] A second aspect of the present invention provides a node state setting device for a tree structure, comprising:
[0026] The receiving unit is used to receive export requests from the interface.
[0027] Building units are used to construct a tree structure based on the hierarchical relationship of all variables in the current software.
[0028] The setting unit is used to set the node state of each level of the tree structure from the outside to the inside, based on a global container; wherein, the global container is updated when the interface is opened and closed, and stores the names of all leaf nodes whose node state is checked.
[0029] Optionally, the setting unit includes:
[0030] The query unit is used to query the name of the leaf node in the global container from the outside to the inside of the tree structure, for each leaf node in the tree structure, and obtain the query result;
[0031] The first setting subunit is used to set the node status of the leaf node based on the query result;
[0032] A triggering unit is used to trigger the status flag bit of the parent node of the leaf node based on the node status of the leaf node;
[0033] The second setting subunit is used to set the node state of the parent node of the leaf node according to the triggering status of the parent node's status flag after all leaf nodes in the hierarchy have been traversed, until the node states in each level of the tree structure have been set.
[0034] Optionally, the first setting subunit includes:
[0035] The first node status setting subunit is used to set the node status of the leaf node to a checked state if the query result shows that the name of the leaf node exists in the global container.
[0036] The first node status setting subunit is further configured to set the node status of the leaf node to an unchecked state if the query result indicates that the name of the leaf node is not found in the global container.
[0037] Optionally, the status flags include: a checked flag and an unchecked flag; the triggering unit includes:
[0038] The first triggering subunit is used to trigger the check flag of the parent node of the leaf node if the node state of the leaf node is checked.
[0039] The second triggering subunit is used to trigger the unchecked flag of the parent node of the leaf node if the node state of the leaf node is unchecked.
[0040] Optionally, the second setting subunit includes:
[0041] The second node state setting subunit is used to set the node state of the parent node of the leaf node to a half-checked state when all leaf nodes in the hierarchy have been traversed and both state flags of the parent node of the leaf node are triggered.
[0042] The second node state setting subunit is also used to set the node state of the parent node of the leaf node to the checked state if the check flag of the parent node of the leaf node is triggered.
[0043] The second node state setting subunit is also used to set the node state of the parent node of the leaf node to an unchecked state if the unchecked flag of the parent node of the leaf node is triggered.
[0044] A third aspect of the present invention provides an electronic device, comprising:
[0045] One or more processors;
[0046] A storage device on which one or more programs are stored;
[0047] When the one or more programs are executed by the one or more processors, the one or more processors implement the node state setting method of the tree structure as described in any one of the first aspects.
[0048] A fourth aspect of the present invention provides a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the node state setting method of the tree structure as described in any one of the first aspects.
[0049] As can be seen from the above scheme, the present invention provides a method, related device, and storage medium for setting the node state of a tree structure. After receiving an export request from the interface, a tree structure is constructed according to the hierarchical relationship of all variables in the current software. Then, from the outside to the inside of the tree structure, the node state of each level of the tree structure is set based on a global container. The global container is updated when the interface is opened and closed, storing the names of all leaf nodes whose node state is checked. During the node state setting process, leaf nodes only need to synchronize their own state to their parent nodes, rather than searching for parent nodes level by level, achieving a fast response. Furthermore, through the global container, the checked state of existing nodes must be consistent with the setting state when the interface was last opened, ensuring the continuity of user operation. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0051] Figure 1 A detailed flowchart of a method for setting the node state of a tree structure provided in an embodiment of the present invention;
[0052] Figure 2 This is a schematic diagram of an export variable configuration interface provided in an embodiment of the present invention;
[0053] Figure 3 A flowchart illustrating a method for setting the node state of a tree structure, as provided in an embodiment of the present invention;
[0054] Figure 4 This is a schematic diagram illustrating the relationship between nodes according to an embodiment of the present invention;
[0055] Figure 5 A schematic diagram of a tree-structured node state setting device provided in an embodiment of the present invention;
[0056] Figure 6 This is a schematic diagram of an electronic device that implements a method for setting the node state of a tree structure, as provided in an embodiment of the present invention. Detailed Implementation
[0057] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0058] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0059] It should be noted that the information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this invention are all information and data authorized by the user or fully authorized by all parties.
[0060] It should be noted that the concepts of "first" and "second" mentioned in this invention are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0061] It should be noted that the terms "a" and "a plurality of" used in this invention are illustrative rather than restrictive. Those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0062] This invention provides a method for setting the node state of a tree structure, such as... Figure 1 As shown, the specific steps include:
[0063] S101, Receive the export request from the interface.
[0064] In practical applications of this invention, an export request can be generated after the user clicks a button on the interface, such as... Figure 2 As shown, taking the "Export Variable Configuration Interface" as an example, when the user clicks the "Settings" button in the "Export Variable Configuration Interface", an export request for the interface is generated, and the dialog box on the right should pop up quickly, while also supporting the user to select and set variables.
[0065] It should be noted that since the total number of variables will change dynamically with the changes in the simulation model (i.e., variables are volatile), the original tree structure must be cleared and a new tree structure must be rebuilt each time the dialog box is opened. At the same time, it is necessary to ensure that the check status of leaf nodes with the same variable name is consistent with that before the last time the dialog box was closed, and the check status of the parent node needs to be dynamically adjusted according to the status of its child nodes.
[0066] In existing technologies, when the number of variables reaches 100,000, the dialog box takes about 10 minutes to pop up after the user clicks the "Settings" button, which seriously affects the user's operating efficiency and user experience.
[0067] Therefore, the present invention uses step S103 to achieve a fast response of the dialog box, thus solving the problem of excessive time consumption in the prior art.
[0068] S102. Based on the hierarchical relationship of all variables in the current software, construct a tree structure.
[0069] The tree-structured data comes from all the variables in the current software. These variables are distributed in different levels. For example, subsystem A includes functional block B, and functional block B includes variables a1, a2, and a3.
[0070] In the practical application of this invention, a tree structure can be automatically created by scanning all current variables in the software and based on their hierarchical relationship; this is not limited here.
[0071] S103. Starting from the outside and working inside of the tree structure, set the node state of each node in each level of the tree structure based on the global container.
[0072] The global container updates when the interface is opened and closed, storing the names of all leaf nodes whose status is checked.
[0073] It should be noted that the names used in this invention are processed to ensure they are not duplicated.
[0074] Specifically, the update logic for the global container is to iterate through all leaf nodes, and store the selected nodes in the container. The next time the interface is opened, all selected leaf nodes can be retrieved from this container.
[0075] Optionally, in another embodiment of the present invention, one implementation of step S103 is as follows: Figure 3 As shown, it includes:
[0076] S301. Starting from the outside to the inside of the tree structure, for each leaf node in the tree structure, query the name of the leaf node in the global container to obtain the query result.
[0077] If the name of the leaf node can be found in the global container, it means that the leaf node was selected when the interface was closed last time; otherwise, it was not selected or is a newly added node.
[0078] S302. Based on the query results, set the node status of the leaf nodes.
[0079] In the practical application of the present invention, one embodiment of step S302 can be: if the query result shows that there is a leaf node name in the global container, then the node status of the leaf node is set to the checked state; if the query result shows that there is no leaf node name in the global container, then the node status of the leaf node is set to the unchecked state.
[0080] S303. Trigger the status flag of the parent node of the leaf node based on the node status of the leaf node.
[0081] The status flags include: a checked flag and an unchecked flag.
[0082] Continuing with the above example, one implementation of step S303 can be: if the node state of the leaf node is checked, then the checked flag of the parent node of the leaf node is triggered; if the node state of the leaf node is unchecked, then the unchecked flag of the parent node of the leaf node is triggered.
[0083] S304. After all leaf nodes in the hierarchy have been traversed, the node state of the parent node of the leaf node is set according to the triggering of the status flag of the parent node of the leaf node, until the node state of each level of the tree structure has been set.
[0084] Continuing with the above example, one implementation of step S304 can be as follows: after all leaf nodes in the hierarchy have been traversed, if both status flags of the parent node of a leaf node are triggered, then the node status of the parent node of the leaf node is set to a half-checked state; if the checked flag of the parent node of a leaf node is triggered, then the node status of the parent node of the leaf node is set to a checked state; if the unchecked flag of the parent node of a leaf node is triggered, then the node status of the parent node of the leaf node is set to an unchecked state.
[0085] It is understandable that a node in a tree structure can be either a leaf node or a parent node, such as... Figure 4 As shown, taking the "Parameter" node as an example, it is both a leaf node of the "WingController" node and the parent node of the three leaf nodes "MaxAngle", "MinAngle" and "AngleStep".
[0086] In the practical application of this invention, after the leaf nodes are traversed, a key-value pair data structure, QMap, can be generated.<QTreeWidgetItem*,int> QTreeWidgetItem represents the parent node, and int (a 32-bit variable) is used to record the flag bits (only 2 bits are used, corresponding to the two status flag bits mentioned above: checked flag bit and unchecked flag bit).
[0087] It should be emphasized that, through the above examples, the present invention can indicate three states using only two flag bits, further saving resources and thus further improving response speed.
[0088] In this invention, the checked and unchecked flags are represented as high and low bits. When the state of each node is set, it only informs itself of its own state from the directly parent node.
[0089] If the node status is "checked", the low flag bit record of the parent node at the next higher level is valid;
[0090] If the node status is "not checked", the high flag bit record of the parent node at the next higher level is valid;
[0091] If the node status is "partially checked", both the high and low flags of the parent node at the next higher level are recorded as valid.
[0092] It is understandable that, using the method in this invention, once all leaf nodes have been traversed, the state of the child nodes has been accurately set, and the flag bits of all parent nodes have been recorded.
[0093] At this point, we begin traversing the parent nodes: treating the current parent node as a "child node" and its parent node as a "new parent node," and determining and setting the state of the "new parent node" based on the two flags of the current parent node:
[0094] If both flags are triggered (i.e., some child nodes are checked and some are unchecked), then the "new parent node" is set to the "partially checked" state.
[0095] If only the "check flag" is triggered (i.e. all child nodes are checked), then the "new parent node" is set to the "checked" state;
[0096] If only the "Unchecked flag" is triggered (i.e. all child nodes are unchecked), then the "new parent node" is set to the "unchecked" state.
[0097] This solution achieves rapid dialog box response and solves the problem of excessive time consumption in the old solution by using the core method of "setting the check status layer by layer from leaf node to root node, completing the operation in a single traversal, and setting only the leaf node status in each round while simultaneously recording the parent node status". Compared with the traditional solution, after setting the child node status, the parent node needs to "listen to changes in the child node status". Whenever the child node's check status changes, the parent node needs to traverse all its own child nodes again to count the status and finally determine its own check status. This solution eliminates the step of the parent node repeatedly traversing the child nodes by "pre-recording the parent node status", replacing the "repeated traversal" of the traditional solution with "single traversal", simplifying the operation process and improving efficiency (reducing the time consumption from n^2 in the traditional solution to n (where n is the total number of variables)).
[0098] In practical applications of this invention, the code for implementing the above solution can be as follows, without limitation:
[0099] / / The following code sets the checkmark status for all nodes in the tree.
[0100] / / itemSet is a global container that stores all selected leaf nodes. It is used to query whether each leaf node was previously selected after the tree structure is built.
[0101] QSet <qstring>itemSets(itemList.begin(), itemList.end());
[0102] / / The itemCheckMap container is used to store the state of the next level. The value is in the form of a key-value pair (node, flag); the flag is divided into high and low.
[0103] QMap<QTreeWidgetItem*, int> itemCheckMap;
[0104] / / Initialize the iterator for traversing the current tree structure
[0105] QTreeWidgetItemIterator it(this);
[0106] / / Loop structure, traversing the tree structure one by one
[0107] while (*it)
[0108] {
[0109] / / Each time the loop enters, first check if it is a leaf node, and only set the leaf node.
[0110] if ((*it)->childCount() != 0)
[0111] {
[0112] If it's not a leaf node, `it` points to the next node, and the loop continues.
[0113] ++it;
[0114] continue?
[0115] }
[0116] / / It is only after the leaf node that we enter this place.
[0117] if ((*it)->data(0, Qt::UserRole).isValid())
[0118] {
[0119] / / Get node information
[0120] FilterTreeData treeData = (*it)->data(0, Qt::UserRole).value <filtertreedata>();
[0121] / / Processed, unique node names. It consists of multiple parts: path and name, and variable name.
[0122] QString str1 = treeData.referenceIdPath + "." + treeData.fmuName + "|" + treeData.fmuVar.m_name; / / User system parameter location
[0123] / / Check if the itemSets container contains the current leaf node
[0124] if (itemSets.contains(str1) )
[0125] {
[0126] (*it)->setCheckState(0, Qt::Checked);
[0127] / / Found. Get the parent node of the current node. The high-order bits of the parent node's state are valid.
[0128] itemCheckMap[(*it)->parent()] = itemCheckMap[(*it)->parent()] | 0x01;
[0129] }
[0130] else
[0131] {
[0132] / / Not found. Get the parent node of the current node. The high-order bits of the parent node's state are valid.
[0133] / / Flag bit, if it is already valid, recording it here will have no effect.
[0134] itemCheckMap[(*it)->parent()] = itemCheckMap[(*it)->parent()] | 0x10;
[0135] }
[0136] }
[0137] ++it;
[0138] }
[0139] / / Loop ends, all leaf nodes are now set.
[0140] / / Begin processing the checkmark status settings of the parent node.
[0141] while (itemCheckMap.size() > 1)
[0142] {
[0143] / / Used to record the state of nodes in the itemCheckMap container and report it to the direct parent node.
[0144] QMap<QTreeWidgetItem*, int> map;
[0145] / / Traverse the container map, storing the current node and its flag record.
[0146] for (auto it = itemCheckMap.begin(); it != itemCheckMap.end();++it)
[0147] {
[0148] QTreeWidgetItem* item = it.key();
[0149] if (nullptr == item)
[0150] {
[0151] continue?
[0152] }
[0153] / / Flag bit equals only the least significant bit
[0154] if (it.value() == 0x01)
[0155] {
[0156] / / Set the current node to the "checked" state and report its state to the direct parent node.
[0157] item->setCheckState(0, Qt::Checked);
[0158] map[item->parent()] = map[item->parent()] | 0x01;
[0159] }
[0160] / / Both high and low bits of the flag are valid
[0161] else if (it.value() == 0x11)
[0162] {
[0163] / / Set the current node to a "partially checked" state and report its state to its direct parent node.
[0164] item->setCheckState(0, Qt::PartiallyChecked);
[0165] map[item->parent()] = map[item->parent()] | 0x11;
[0166] }
[0167] / / Flag bit equals only the high-order bit is valid
[0168] else
[0169] {
[0170] / / Set the current node to the "unchecked" state and report its state to its direct parent node.
[0171] map[item->parent()] = map[item->parent()] | 0x10;
[0172] }
[0173] }
[0174] / / The current container has been traversed, clear the container.
[0175] itemCheckMap.clear();
[0176] / / Reassign the reported results to the container. Then begin the setup for the next layer.
[0177] itemCheckMap = map;
[0178] }
[0179] / / If only one node remains, it represents the root node. The status is read directly for setting.
[0180] if (itemCheckMap.size() == 1)
[0181] {
[0182] / / If there is only one element, get an iterator of the first element.
[0183] auto it = itemCheckMap.begin();
[0184] / / Get the key of this element, which is a pointer to the node.
[0185] QTreeWidgetItem* item = it.key();
[0186] / / it.value() is the value of the element, representing the flag. Like 0x01, it's set to checked; like 0x11, it's set to partially checked.
[0187] / / No need to check 0x10, the default is that it is unchecked.
[0188] if (it.value() == 0x01)
[0189] {
[0190] while (item!=nullptr)
[0191] {
[0192] item->setCheckState(0, Qt::Checked);
[0193] item = item->parent();
[0194] }
[0195] }
[0196] else if (it.value() == 0x11)
[0197] {
[0198] while (item != nullptr)
[0199] {
[0200] item->setCheckState(0, Qt::PartiallyChecked);
[0201] item = item->parent();
[0202] }
[0203] }
[0204] }
[0205] As can be seen from the above scheme, the present invention provides a method for setting the node state of a tree structure. After receiving the export request from the interface, a tree structure is constructed according to the hierarchical relationship of all variables in the current software. Then, from the outside to the inside of the tree structure, the node state of each level of the tree structure is set based on a global container. The global container is updated when the interface is opened and closed, storing the names of all leaf nodes whose node state is checked. During the node state setting process, leaf nodes only need to synchronize their own state to their parent nodes, instead of searching for parent nodes level by level, achieving a fast response. Furthermore, through the global container, the checked state of existing nodes must be consistent with the setting state when the interface was last opened, ensuring the continuity of user operation.
[0206] Another embodiment of the present invention provides a node state setting device for a tree structure, such as... Figure 5 As shown, it specifically includes:
[0207] The receiving unit 501 is used to receive the export request from the interface.
[0208] Building unit 502 is used to construct a tree structure based on the hierarchical relationship of all variables in the current software.
[0209] Setting unit 503 is used to set the node state of each level of the tree structure from the outside to the inside, based on the global container.
[0210] The global container updates when the interface is opened and closed, storing the names of all leaf nodes whose status is checked.
[0211] For details on the specific operation of the units disclosed in the above embodiments of the present invention, please refer to the corresponding method embodiments, such as... Figure 1 As shown, it will not be elaborated further here.
[0212] Optionally, in another embodiment of the present invention, one implementation of the setting unit 503 includes:
[0213] The query unit is used to search for the name of the leaf node in the global container from the outside to the inside of the tree structure, and obtain the query result.
[0214] The first setting sub-unit is used to set the node status of the leaf nodes based on the query results.
[0215] The triggering unit is used to trigger the status flag of the parent node of the leaf node based on the node status of the leaf node.
[0216] The second setting subunit is used to set the node state of the parent node of the leaf node according to the triggering of the status flag of the parent node of the leaf node after all leaf nodes in the hierarchy have been traversed, until the node state in each level of the tree structure has been set.
[0217] For details on the specific operation of the units disclosed in the above embodiments of the present invention, please refer to the corresponding method embodiments, such as... Figure 3 As shown, it will not be elaborated further here.
[0218] Optionally, in another embodiment of the present invention, one implementation of the first setting subunit includes:
[0219] The first node status setting sub-unit is used to set the node status of the leaf node to the checked state if the query result shows that there is a leaf node name in the global container.
[0220] The first node status setting sub-unit is also used to set the node status of the leaf node to unchecked if the query result shows that there is no leaf node name in the global container.
[0221] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0222] Optionally, in another embodiment of the present invention, the status flags include: a checked flag and an unchecked flag; one implementation of the triggering unit includes:
[0223] The first trigger sub-unit is used to trigger the check flag of the parent node of the leaf node if the node state of the leaf node is checked.
[0224] The second trigger subunit is used to trigger the unchecked flag of the parent node of the leaf node if the node state of the leaf node is unchecked.
[0225] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0226] Optionally, in another embodiment of the present invention, one implementation of the second setting subunit includes:
[0227] The second node state setting sub-unit is used to set the node state of the parent node of the leaf node to a half-checked state after all leaf nodes in the hierarchy have been traversed and both state flags of the parent node of the leaf node have been triggered.
[0228] The second node state setting sub-unit is also used to set the node state of the parent node of the leaf node to the checked state if the check flag of the parent node of the leaf node is triggered.
[0229] The second node state setting sub-unit is also used to set the node state of the parent node of the leaf node to the unchecked state if the unchecked flag of the parent node of the leaf node is triggered.
[0230] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0231] As can be seen from the above scheme, the present invention provides a tree-structured node state setting device. After the receiving unit 501 receives the export request from the interface, the construction unit 502 constructs a tree structure according to the hierarchical relationship of all variables in the current software. Then, the setting unit 503 sets the node state of each level of the tree structure from the outside to the inside, based on a global container. The global container is updated when the interface is opened and closed, storing the names of all leaf nodes whose node state is checked. During the node state setting process, leaf nodes only need to synchronize their own state to their parent nodes, instead of searching for parent nodes level by level, achieving a fast response. Furthermore, through the global container, the checked state of existing nodes must be consistent with the setting state when the interface was last opened, ensuring the continuity of user operation.
[0232] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
[0233] Another embodiment of the present invention provides an electronic device, such as... Figure 6 As shown, it includes:
[0234] One or more processors 601.
[0235] Storage device 602, on which one or more programs are stored.
[0236] When the one or more programs are executed by the one or more processors 601, the one or more processors 601 implement the node state setting method of the tree structure as described in the above embodiments.
[0237] Another embodiment of the present invention provides a storage medium on which a computer program is stored, wherein when the computer program is executed by a processor, it implements the node state setting method of the tree structure as described in the above embodiment.
[0238] In the context of this invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0239] It should be noted that the computer-readable medium described above in this invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0240] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0241] Another embodiment of the present invention provides a computer program product, which, when executed, is used to perform the above-described method for setting the node state of a tree structure.
[0242] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, it performs the functions defined in the methods of the embodiments of the present invention.
[0243] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in this invention is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely exemplary forms for implementing the invention.
[0244] While several specific implementation details are included in the foregoing discussion, these should not be construed as limiting the scope of the invention. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0245] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention is not limited to the specific combination of the above-described technical features, but also includes other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with technical features of the present invention (but not limited to) that have similar functions.< / filtertreedata> < / qstring>
Claims
1. A method for setting the node state of a tree structure, characterized in that, include: Receive export requests from the interface; A tree structure is constructed based on the hierarchical relationship of all variables in the current software. From the outside to the inside of the tree structure, the node state of each level of the tree structure is set based on a global container; wherein, the global container is updated when the interface is opened and closed, and stores the names of all leaf nodes whose node state is checked.
2. The method for setting the node state of a tree structure according to claim 1, characterized in that, The step of setting the node state of each level of the tree structure from the outside to the inside, based on a global container, includes: Starting from the outside to the inside of the tree structure, for each leaf node in the tree structure, the name of the leaf node is queried in the global container to obtain the query result; Based on the query results, set the node status of the leaf node; The state flag of the parent node of the leaf node is triggered based on the node state of the leaf node; After all leaf nodes in the hierarchy have been traversed, the node state of the parent node of the leaf node is set according to the triggering status of the parent node's status flag, until the node state in each level of the tree structure has been set.
3. The method for setting the node state of a tree structure according to claim 2, characterized in that, Setting the node status of the leaf node based on the query result includes: If the query result indicates that the name of the leaf node exists in the global container, then the node status of the leaf node is set to the checked state; If the query result indicates that the name of the leaf node is not found in the global container, then the node status of the leaf node is set to unchecked.
4. The method for setting the node state of a tree structure according to claim 3, characterized in that, The status flags include: a checked flag and an unchecked flag. The triggering of the parent node's status flag based on the leaf node's node status includes: If the node status of the leaf node is checked, then the check flag of the parent node of the leaf node is triggered. If the node status of the leaf node is unchecked, then the unchecked flag of the parent node of the leaf node is triggered.
5. The method for setting the node state of a tree structure according to claim 4, characterized in that, After all leaf nodes in the hierarchy have been traversed, the node state of the parent node of the leaf node is set according to the triggering status flag of the parent node, including: After all leaf nodes in the hierarchy have been traversed, if both status flags of the parent node of the leaf node are triggered, then the node status of the parent node of the leaf node is set to a half-checked state. If the check flag of the parent node of the leaf node is triggered, then the node state of the parent node of the leaf node is set to the check flag state. If the unchecked flag of the parent node of the leaf node is triggered, the node state of the parent node of the leaf node is set to the unchecked state.
6. A node state setting device for a tree structure, characterized in that, include: The receiving unit is used to receive export requests from the interface. Building units are used to construct a tree structure based on the hierarchical relationship of all variables in the current software. The setting unit is used to set the node state of each level of the tree structure from the outside to the inside, based on a global container; wherein, the global container is updated when the interface is opened and closed, and stores the names of all leaf nodes whose node state is checked.
7. The node state setting device for a tree structure according to claim 6, characterized in that, The setting unit includes: The query unit is used to query the name of the leaf node in the global container from the outside to the inside of the tree structure, for each leaf node in the tree structure, and obtain the query result; The first setting subunit is used to set the node status of the leaf node based on the query result; A triggering unit is used to trigger the status flag bit of the parent node of the leaf node based on the node status of the leaf node; The second setting subunit is used to set the node state of the parent node of the leaf node according to the triggering status of the parent node's status flag after all leaf nodes in the hierarchy have been traversed, until the node states in each level of the tree structure have been set.
8. The node state setting device for a tree structure according to claim 7, characterized in that, The first setting subunit includes: The first node status setting subunit is used to set the node status of the leaf node to a checked state if the query result shows that the name of the leaf node exists in the global container. The first node status setting subunit is further configured to set the node status of the leaf node to an unchecked state if the query result indicates that the name of the leaf node is not found in the global container.
9. An electronic device, characterized in that, include: One or more processors; A storage device on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors implement the node state setting method of the tree structure as described in any one of claims 1 to 5.
10. A storage medium, characterized in that, It stores a computer program, wherein the computer program, when executed by a processor, implements the node state setting method of the tree structure as described in any one of claims 1 to 5.