| 181 | } |
| 182 | |
| 183 | void JsonStoreSync::insert_rows_base( |
| 184 | const int row, |
| 185 | const int count, |
| 186 | const nlohmann::json &data, |
| 187 | const std::string &parent, |
| 188 | const bool local, |
| 189 | const utility::Uuid &id, |
| 190 | const bool undo_redo) { |
| 191 | |
| 192 | // try doing it.. |
| 193 | auto ptr = json::json_pointer(parent); |
| 194 | auto &p = (*(this))[ptr]; |
| 195 | |
| 196 | if (p.at(children_).is_array()) { |
| 197 | if (data.empty()) { |
| 198 | p[children_].insert(std::next(p[children_].begin(), row), count, R"({})"_json); |
| 199 | } else { |
| 200 | p[children_].insert(std::next(p[children_].begin(), row), data.begin(), data.end()); |
| 201 | } |
| 202 | |
| 203 | // if local broadcast |
| 204 | if (local or origin_) { |
| 205 | auto event = xstudio::utility::SyncEvent; |
| 206 | event["redo"] = xstudio::utility::InsertRowsEvent; |
| 207 | event["redo"]["id"] = id; |
| 208 | event["redo"]["parent"] = parent; |
| 209 | event["redo"]["row"] = row; |
| 210 | event["redo"]["count"] = count; |
| 211 | event["redo"]["data"] = data; |
| 212 | |
| 213 | event["undo"] = xstudio::utility::RemoveRowsEvent; |
| 214 | event["undo"]["id"] = id; |
| 215 | event["undo"]["parent"] = parent; |
| 216 | event["undo"]["row"] = row; |
| 217 | event["undo"]["count"] = count; |
| 218 | |
| 219 | last_event_ = event; |
| 220 | if (event_send_func_) |
| 221 | event_send_func_(event, undo_redo); |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | void JsonStoreSync::remove_rows(const int row, const int count, const std::string &parent) { |
| 227 | if (count) |