Code review

This commit is contained in:
Atlante45 2014-04-08 11:06:48 -07:00
parent ee5ebae89e
commit 22cab29d25
2 changed files with 7 additions and 1 deletions

View file

@ -51,6 +51,8 @@ void VoxelsScriptingInterface::setVoxelNonDestructive(float x, float y, float z,
AddVoxelCommand* command = new AddVoxelCommand(_tree, AddVoxelCommand* command = new AddVoxelCommand(_tree,
addVoxelDetail, addVoxelDetail,
getVoxelPacketSender()); getVoxelPacketSender());
// As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves.
_undoStack->push(command); _undoStack->push(command);
} else { } else {
// queue the add packet // queue the add packet
@ -89,11 +91,12 @@ void VoxelsScriptingInterface::setVoxel(float x, float y, float z, float scale,
deleteVoxelDetail, deleteVoxelDetail,
getVoxelPacketSender()); getVoxelPacketSender());
_undoStack->beginMacro(addCommand->text()); _undoStack->beginMacro(addCommand->text());
qDebug() << "Macro"; // As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves.
_undoStack->push(delCommand); _undoStack->push(delCommand);
_undoStack->push(addCommand); _undoStack->push(addCommand);
_undoStack->endMacro(); _undoStack->endMacro();
} else { } else {
// As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves.
_undoStack->push(addCommand); _undoStack->push(addCommand);
} }
} else { } else {
@ -123,6 +126,7 @@ void VoxelsScriptingInterface::eraseVoxel(float x, float y, float z, float scale
DeleteVoxelCommand* command = new DeleteVoxelCommand(_tree, DeleteVoxelCommand* command = new DeleteVoxelCommand(_tree,
deleteVoxelDetail, deleteVoxelDetail,
getVoxelPacketSender()); getVoxelPacketSender());
// As QUndoStack automatically executes redo() on push, we don't need to execute the command ourselves.
_undoStack->push(command); _undoStack->push(command);
} else { } else {
getVoxelPacketSender()->queueVoxelEditMessages(PacketTypeVoxelErase, 1, &deleteVoxelDetail); getVoxelPacketSender()->queueVoxelEditMessages(PacketTypeVoxelErase, 1, &deleteVoxelDetail);

View file

@ -18,6 +18,8 @@
#include "VoxelEditPacketSender.h" #include "VoxelEditPacketSender.h"
#include "VoxelTree.h" #include "VoxelTree.h"
class QUndoStack;
/// handles scripting of voxel commands from JS passed to assigned clients /// handles scripting of voxel commands from JS passed to assigned clients
class VoxelsScriptingInterface : public OctreeScriptingInterface { class VoxelsScriptingInterface : public OctreeScriptingInterface {
Q_OBJECT Q_OBJECT