void WorkspaceEdit::setChanges(const Changes &changes) { QJsonObject changesObject; const auto end = changes.end(); for (auto it = changes.begin(); it != end; ++it) { QJsonArray edits; for (const TextEdit &edit : it.value()) edits.append(QJsonValue(edit)); changesObject.insert(it.key().toFileName().toString(), edits); } insert(changesKey, changesObject); }
static void couchChangeSetOneShot(PrintTextA &a) { CouchDB db(getTestCouch()); db.use(DATABASENAME); ChangesSink chsink (db.createChangesSink()); Changes chngs = chsink.exec(); natural count = 0; while (chngs.hasItems()) { ChangedDoc doc(chngs.getNext()); count++; } a("%1") << (count > 10); }
ChangeTileTerrain::ChangeTileTerrain(MapEditor *editor, Changes &changes) : mMapEditor(editor), mTileset(changes.begin().key()->tileset()), mChanges(changes), mMergeable(true) { initText(); }
void FileSystemWatcher::notifyReadyRead() { Changes changes; { std::lock_guard<std::mutex> lock(mMutex); int s = 0; ioctl(mFd, FIONREAD, &s); if (!s) return; enum { StaticBufSize = 4096 }; char staticBuf[StaticBufSize]; char *buf = s > StaticBufSize ? new char[s] : staticBuf; const int read = ::read(mFd, buf, s); int idx = 0; while (idx < read) { inotify_event *event = reinterpret_cast<inotify_event*>(buf + idx); idx += sizeof(inotify_event) + event->len; Path path = mWatchedById.value(event->wd); // printf("%s [%s]", path.constData(), event->name); // dump(event->mask); // printf("\n"); const bool isDir = path.isDir(); if (event->mask & (IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT)) { changes.add(Changes::Remove, path); } else if (event->mask & (IN_CREATE|IN_MOVED_TO)) { if (isDir) path.append(event->name); changes.add(Changes::Add, path); } else if (event->mask & (IN_DELETE|IN_MOVED_FROM)) { if (isDir) path.append(event->name); changes.add(Changes::Remove, path); } else if (event->mask & (IN_ATTRIB|IN_CLOSE_WRITE)) { if (isDir) path.append(event->name); changes.add(Changes::Modified, path); } } if (buf != staticBuf) delete []buf; } processChanges(changes); }
ChangeTileTerrain::ChangeTileTerrain(TilesetDocument *tilesetDocument, const Changes &changes, QUndoCommand *parent) : QUndoCommand(parent) , mTilesetDocument(tilesetDocument) , mTileset(changes.begin().key()->tileset()) , mChanges(changes) , mMergeable(true) { initText(); }