summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukáš Lalinský <lalinsky@gmail.com>2008-11-27 20:44:47 +0100
committerLukáš Lalinský <lalinsky@gmail.com>2008-11-27 20:44:47 +0100
commit38c64d01f173989e3bc2172f6989e587480bd83e (patch)
tree021a8be7a81d7c7a73024d595c37331c5cc4d2cb
parent94cb727e66cae3d3be4a1ab592a0ca5e30edc993 (diff)
downloaddbmodel-38c64d01f173989e3bc2172f6989e587480bd83e.tar.xz
Merge multiple EditTableNameCommands on the same table into one
-rw-r--r--commands.cpp17
-rw-r--r--commands.h12
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;
+}
diff --git a/commands.h b/commands.h
index da67779..a554f3e 100644
--- a/commands.h
+++ b/commands.h
@@ -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;