| 160 | } |
| 161 | |
| 162 | void LocalTreeModel::appendItem(LocalTreeItem *parent, const IVariables &vars) |
| 163 | { |
| 164 | QWriteLocker locker(&mutex); |
| 165 | if (!items.contains(parent) && parent != rootItem) |
| 166 | return; |
| 167 | locker.unlock(); |
| 168 | |
| 169 | if (parent) { |
| 170 | QList<LocalTreeItem *> newItems; |
| 171 | |
| 172 | // when fetchChild do not highlight variables. |
| 173 | // append item to a parent which has child, highLight new item |
| 174 | bool fetchChild = parent->childCount() == 0; |
| 175 | |
| 176 | for (auto var : vars) { |
| 177 | auto item = parent->updateVariable(var.var); |
| 178 | //item = nullptr : parent has no child equal this var |
| 179 | if (!item) { |
| 180 | beginInsertColumns(parent->index(), parent->childCount(), 1); |
| 181 | item = new LocalTreeItem(this, parent); |
| 182 | item->setUpdated(!fetchChild); |
| 183 | item->setVariable(var.var); |
| 184 | parent->appendChild(item); |
| 185 | |
| 186 | locker.relock(); |
| 187 | items.append(item); |
| 188 | locker.unlock(); |
| 189 | |
| 190 | endInsertRows(); |
| 191 | } |
| 192 | |
| 193 | newItems.append(item); |
| 194 | } |
| 195 | parent->removeRedundantItems(newItems); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | void LocalTreeModel::setDatas(IVariables &datas) |
| 200 | { |
no test coverage detected