summaryrefslogtreecommitdiff
path: root/commands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'commands.cpp')
-rw-r--r--commands.cpp57
1 files changed, 28 insertions, 29 deletions
diff --git a/commands.cpp b/commands.cpp
index 70b1487..57a8b6e 100644
--- a/commands.cpp
+++ b/commands.cpp
@@ -19,77 +19,76 @@
#include "databasetable.h"
#include "column.h"
-EditTableNameCommand::EditTableNameCommand(DatabaseTable *table, const QString &name, QUndoCommand *parent)
+ChangeColumnPropertyCommand::ChangeColumnPropertyCommand(Column *column, Column::Property property, const QVariant &value, QUndoCommand *parent)
: QUndoCommand(parent)
{
- m_table = table;
- m_oldName = table->name();
- m_newName = name;
+ m_column = column;
+ m_property = property;
+ m_oldValue = column->property(property);
+ m_newValue = value;
}
void
-EditTableNameCommand::redo()
+ChangeColumnPropertyCommand::redo()
{
- m_table->setName(m_newName);
+ m_column->setProperty(m_property, m_newValue);
}
void
-EditTableNameCommand::undo()
+ChangeColumnPropertyCommand::undo()
{
- m_table->setName(m_oldName);
+ m_column->setProperty(m_property, m_oldValue);
}
int
-EditTableNameCommand::id() const
+ChangeColumnPropertyCommand::id() const
{
- return COMMAND_EDIT_TABLE_NAME;
+ return COMMAND_CHANGE_COLUMN_PROPERTY;
}
bool
-EditTableNameCommand::mergeWith(const QUndoCommand *o)
+ChangeColumnPropertyCommand::mergeWith(const QUndoCommand *o)
{
+ return false;
Q_ASSERT(id() == o->id());
- const EditTableNameCommand *other = static_cast<const EditTableNameCommand *>(o);
- if (m_table != other->m_table)
+ const ChangeColumnPropertyCommand *other = static_cast<const ChangeColumnPropertyCommand *>(o);
+ if (m_column != other->m_column || m_property != other->m_property)
return false;
- m_newName = other->m_newName;
+ m_newValue = other->m_newValue;
return true;
}
-ChangeColumnPropertyCommand::ChangeColumnPropertyCommand(Column *column, Column::Property property, const QVariant &value, QUndoCommand *parent)
- : QUndoCommand(parent)
+SetObjectPropertyCommand::SetObjectPropertyCommand(QObject *object, const char *name, const QVariant &value, QUndoCommand *parent)
+ : QUndoCommand(parent), m_object(object), m_name(name), m_newValue(value)
{
- m_column = column;
- m_property = property;
- m_oldValue = column->property(property);
- m_newValue = value;
+ m_oldValue = object->property(name);
}
void
-ChangeColumnPropertyCommand::redo()
+SetObjectPropertyCommand::redo()
{
- m_column->setProperty(m_property, m_newValue);
+ m_object->setProperty(m_name.latin1(), m_newValue);
}
void
-ChangeColumnPropertyCommand::undo()
+SetObjectPropertyCommand::undo()
{
- m_column->setProperty(m_property, m_oldValue);
+ m_object->setProperty(m_name.latin1(), m_oldValue);
}
int
-ChangeColumnPropertyCommand::id() const
+SetObjectPropertyCommand::id() const
{
- return COMMAND_CHANGE_COLUMN_PROPERTY;
+ return COMMAND_SET_OBJECT_PROPERTY;
}
bool
-ChangeColumnPropertyCommand::mergeWith(const QUndoCommand *o)
+SetObjectPropertyCommand::mergeWith(const QUndoCommand *o)
{
return false;
Q_ASSERT(id() == o->id());
- const ChangeColumnPropertyCommand *other = static_cast<const ChangeColumnPropertyCommand *>(o);
- if (m_column != other->m_column || m_property != other->m_property)
+ const SetObjectPropertyCommand *other = static_cast<const SetObjectPropertyCommand *>(o);
+ if (m_object != other->m_object || m_name != other->m_name)
return false;
m_newValue = other->m_newValue;
return true;