diff options
author | Lukáš Lalinský <lalinsky@gmail.com> | 2008-11-27 20:44:47 +0100 |
---|---|---|
committer | Lukáš Lalinský <lalinsky@gmail.com> | 2008-11-27 20:44:47 +0100 |
commit | 38c64d01f173989e3bc2172f6989e587480bd83e (patch) | |
tree | 021a8be7a81d7c7a73024d595c37331c5cc4d2cb | |
parent | 94cb727e66cae3d3be4a1ab592a0ca5e30edc993 (diff) | |
download | dbmodel-38c64d01f173989e3bc2172f6989e587480bd83e.tar.xz |
Merge multiple EditTableNameCommands on the same table into one
-rw-r--r-- | commands.cpp | 17 | ||||
-rw-r--r-- | commands.h | 12 |
2 files changed, 26 insertions, 3 deletions
diff --git a/commands.cpp b/commands.cpp index 1c2c1e0..0f9fe64 100644 --- a/commands.cpp +++ b/commands.cpp @@ -36,3 +36,20 @@ EditTableNameCommand::undo() { m_table->setName(m_oldName); } + +int +EditTableNameCommand::id() const +{ + return COMMAND_EDIT_TABLE_NAME; +} + +bool +EditTableNameCommand::mergeWith(const QUndoCommand *o) +{ + Q_ASSERT(id() == o->id()); + const EditTableNameCommand *other = static_cast<const EditTableNameCommand *>(o); + if (m_table != other->m_table) + return false; + m_newName = other->m_newName; + return true; +} @@ -21,12 +21,18 @@ class DatabaseTable; +enum { + COMMAND_EDIT_TABLE_NAME = 1, +}; + class EditTableNameCommand : public QUndoCommand { public: - EditTableNameCommand(DatabaseTable *table, const QString &name, QUndoCommand *parent = 0); - void undo(); - void redo(); + EditTableNameCommand(DatabaseTable *table, const QString &name, QUndoCommand *parent = 0); + void undo(); + void redo(); + int id() const; + bool mergeWith(const QUndoCommand *command); private: DatabaseTable *m_table; |