23#include <tqsplitter.h>
24#include <tqmetaobject.h>
28#include <tdepopupmenu.h>
29#include <tdemessagebox.h>
30#include <tdeaccelmanager.h>
32#include <koproperty/property.h>
34#include "kexitabledesignercommands.h"
36using namespace KexiTableDesignerCommands;
52 const KoProperty::Set& set,
const TQCString& propertyName,
const TQVariant& oldValue,
const TQVariant& newValue,
53 KoProperty::Property::ListData*
const oldListData, KoProperty::Property::ListData*
const newListData)
56 propertyName==
"name" ? oldValue.toString() : set.property(
"name").value().toString(),
57 propertyName, newValue, set[
"uid"].value().toInt())
58 , m_oldValue(oldValue)
60 , m_oldListData( oldListData ? new KoProperty::Property::ListData(*oldListData) : 0 )
61 , m_listData( newListData ? new KoProperty::Property::ListData(*newListData) : 0 )
63 kexipluginsdbg <<
"ChangeFieldPropertyCommand: " << debugString() << endl;
66ChangeFieldPropertyCommand::~ChangeFieldPropertyCommand()
72TQString ChangeFieldPropertyCommand::name()
const
74 return i18n(
"Change \"%1\" property for table field from \"%2\" to \"%3\"")
75 .arg(m_alterTableAction.propertyName()).arg(m_oldValue.toString())
76 .arg(m_alterTableAction.newValue().toString());
79TQString ChangeFieldPropertyCommand::debugString()
82 if (m_oldListData || m_listData)
83 s += TQString(
"\nAnd list data from [%1]\n to [%2]")
86 .arg(m_oldListData->keysAsStringList().join(
",")).arg(m_oldListData->names.join(
","))
90 .arg(m_listData->keysAsStringList().join(
",")).arg(m_listData->names.join(
","))
91 : TQString(
"<NONE>"));
92 return s + TQString(
" (UID=%1)").arg(m_alterTableAction.uid());
95void ChangeFieldPropertyCommand::execute()
97 m_view->changeFieldProperty(
98 m_alterTableAction.uid(),
99 m_alterTableAction.propertyName().latin1(),
100 m_alterTableAction.newValue(), m_listData );
103void ChangeFieldPropertyCommand::unexecute()
105 m_view->changeFieldProperty(
106 m_alterTableAction.uid(),
107 m_alterTableAction.propertyName().latin1(),
108 m_oldValue, m_oldListData );
113 if (m_alterTableAction.propertyName()==
"subType") {
122 const KoProperty::Set* set)
124 , m_alterTableAction( set ? (*set)[
"name"].value().toString() : TQString(),
125 set ? (*set)[
"uid"].value().toInt() : -1 )
126 , m_set( set ? new KoProperty::Set(*set ) : 0 )
127 , m_fieldIndex(fieldIndex)
131RemoveFieldCommand::~RemoveFieldCommand()
136TQString RemoveFieldCommand::name()
const
139 return i18n(
"Remove table field \"%1\"").arg(m_alterTableAction.
fieldName());
141 return TQString(
"Remove empty row at position %1").arg(m_fieldIndex);
144void RemoveFieldCommand::execute()
147 m_view->deleteRow( m_fieldIndex );
150void RemoveFieldCommand::unexecute()
152 m_view->insertEmptyRow(m_fieldIndex);
154 m_view->insertField( m_fieldIndex, *m_set );
157TQString RemoveFieldCommand::debugString()
162 return name() +
"\nAT ROW " + TQString::number(m_fieldIndex)
163 +
", FIELD: " + (*m_set)[
"caption"].value().toString()
164 + TQString(
" (UID=%1)").arg(m_alterTableAction.uid());
175 int fieldIndex,
const KoProperty::Set& set )
177 , m_alterTableAction(0)
183 fieldIndex, f, set[
"uid"].value().toInt());
188InsertFieldCommand::~InsertFieldCommand()
190 delete m_alterTableAction;
193TQString InsertFieldCommand::name()
const
195 return i18n(
"Insert table field \"%1\"").arg(m_set[
"caption"].value().toString());
198void InsertFieldCommand::execute()
200 m_view->insertField( m_alterTableAction->index(), m_set );
203void InsertFieldCommand::unexecute()
205 m_view->clearRow( m_alterTableAction->index() );
216 const KoProperty::Set& set,
const TQCString& propertyName,
bool visible)
218 , m_alterTableAction(set.property(
"name").value().toString(), propertyName, visible, set[
"uid"].value().toInt())
220 , m_oldVisibility( set.property(propertyName).isVisible() )
222 kexipluginsdbg <<
"ChangePropertyVisibilityCommand: " << debugString() << endl;
225ChangePropertyVisibilityCommand::~ChangePropertyVisibilityCommand()
229TQString ChangePropertyVisibilityCommand::name()
const
231 return TQString(
"[internal] Change \"%1\" visibility from \"%2\" to \"%3\"")
232 .arg(m_alterTableAction.propertyName())
233 .arg(m_oldVisibility ?
"true" :
"false")
234 .arg(m_alterTableAction.newValue().toBool() ?
"true" :
"false");
237void ChangePropertyVisibilityCommand::execute()
239 m_view->changePropertyVisibility(
240 m_alterTableAction.uid(),
241 m_alterTableAction.propertyName().latin1(),
242 m_alterTableAction.newValue().toBool() );
245void ChangePropertyVisibilityCommand::unexecute()
247 m_view->changePropertyVisibility(
248 m_alterTableAction.uid(),
249 m_alterTableAction.propertyName().latin1(),
257 , m_alterTableAction(true)
262InsertEmptyRowCommand::~InsertEmptyRowCommand()
266TQString InsertEmptyRowCommand::name()
const
268 return TQString(
"Insert empty row at position %1").arg(m_row);
271void InsertEmptyRowCommand::execute()
273 m_view->insertEmptyRow( m_row );
276void InsertEmptyRowCommand::unexecute()
279 m_view->deleteRow( m_row );
Abstract base class used for implementing all the AlterTable actions.
TQString fieldName() const
Defines an action for inserting a single table field.
Defines an action for removing a single table field.
ChangeFieldPropertyCommand(KexiTableDesignerView *view, const KoProperty::Set &set, const TQCString &propertyName, const TQVariant &oldValue, const TQVariant &newValue, KoProperty::Property::ListData *const oldListData=0, KoProperty::Property::ListData *const newListData=0)
virtual KexiDB::AlterTableHandler::ActionBase * createAction()
ChangePropertyVisibilityCommand(KexiTableDesignerView *view, const KoProperty::Set &set, const TQCString &propertyName, bool visible)
Base class for all Table Designer's commands.
InsertEmptyRowCommand(KexiTableDesignerView *view, int row)
virtual KexiDB::AlterTableHandler::ActionBase * createAction()
RemoveFieldCommand(KexiTableDesignerView *view, int fieldIndex, const KoProperty::Set *set)
virtual KexiDB::AlterTableHandler::ActionBase * createAction()
Design view of the Table Designer.
KexiDB::Field * buildField(const KoProperty::Set &set) const