1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
/* This file is part of the KDE project
Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KEXITABLEDESIGNER_COMMANDS_H
#define KEXITABLEDESIGNER_COMMANDS_H
#include <tqmap.h>
#include <tqdict.h>
#include <tqptrlist.h>
#include <tqptrdict.h>
#include <tqvariant.h>
#include <tqguardedptr.h>
#include <kcommand.h>
#include <kexidb/alter.h>
#include <koproperty/set.h>
#include "kexitabledesignerview.h"
class TQWidget;
class TQRect;
class TQPoint;
class TQStringList;
class TQCString;
namespace KexiTableDesignerCommands {
//! @short Base class for all Table Designer's commands
class Command : public KCommand
{
public:
Command(KexiTableDesignerView* view);
virtual ~Command();
//! Used to collect actions data for AlterTableHandler
//! Can return 0 if the action should not be passed to AlterTableHandler
virtual KexiDB::AlterTableHandler::ActionBase* createAction() { return 0; }
virtual TQString debugString() { return name(); }
protected:
TQGuardedPtr<KexiTableDesignerView> m_view;
};
//! @short Undo/redo command used for when changing a property for a table field
class ChangeFieldPropertyCommand : public Command
{
public:
/*! Creates the ChangeFieldPropertyCommand object.
Note: we use internal "uid" property of a field (set["uid"]) to avoid problems with looking
for field by name when more than one field exists with the same name
(it's invalid but allowed in design time).
\a oldlistData and and \a newListData can be specified so Property::setListData() will be called
on execute() and unexecute().
*/
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 ~ChangeFieldPropertyCommand();
virtual TQString name() const;
virtual void execute();
virtual void unexecute();
virtual KexiDB::AlterTableHandler::ActionBase* createAction();
virtual TQString debugString();
protected:
KexiDB::AlterTableHandler::ChangeFieldPropertyAction m_alterTableAction;
TQVariant m_oldValue;
// int m_fieldUID;
KoProperty::Property::ListData* m_oldListData, *m_listData;
};
//! @short Undo/redo command used when a field is removed from a table
class RemoveFieldCommand : public Command
{
public:
/*! Constructs RemoveFieldCommand object.
If \a set is 0, the action only means removing empty row (internal). */
RemoveFieldCommand( KexiTableDesignerView* view, int fieldIndex,
const KoProperty::Set* set);
virtual ~RemoveFieldCommand();
virtual TQString name() const;
virtual void execute();
virtual void unexecute();
virtual KexiDB::AlterTableHandler::ActionBase* createAction();
virtual TQString debugString();
protected:
KexiDB::AlterTableHandler::RemoveFieldAction m_alterTableAction;
KoProperty::Set* m_set;
int m_fieldIndex;
};
//! @short Undo/redo command used when a new field is inserted into a table
class InsertFieldCommand : public Command
{
public:
InsertFieldCommand( KexiTableDesignerView* view,
int fieldIndex/*, const KexiDB::Field& field*/, const KoProperty::Set& set );
virtual ~InsertFieldCommand();
virtual TQString name() const;
virtual void execute();
virtual void unexecute();
virtual KexiDB::AlterTableHandler::ActionBase* createAction();
virtual TQString debugString() {
return name() + "\nAT ROW " + TQString::number(m_alterTableAction->index()) //m_alterTableAction.index())
+ ", FIELD: " + m_set["caption"].value().toString(); //m_alterTableAction.field().debugString();
}
protected:
KexiDB::AlterTableHandler::InsertFieldAction *m_alterTableAction;
KoProperty::Set m_set;
};
/* ---- Internal commands follow (not used for building performing ALTER TABLE ---- */
//! @short Undo/redo command used when property visibility is changed
/*! Internal, only used in addition to property change. */
class ChangePropertyVisibilityCommand : public Command
{
public:
/*! Creates the ChangePropertyVisibilityCommand object.
Note: we use internal "uid" property of a field (set["uid"]) to avoid problems with looking
for field by name when more than one field exists with the same name
(it's invalid but allowed in design time).
*/
ChangePropertyVisibilityCommand( KexiTableDesignerView* view,
const KoProperty::Set& set, const TQCString& propertyName,
bool visible);
virtual ~ChangePropertyVisibilityCommand();
virtual TQString name() const;
virtual void execute();
virtual void unexecute();
protected:
KexiDB::AlterTableHandler::ChangeFieldPropertyAction m_alterTableAction;
// int m_fieldUID;
bool m_oldVisibility;
};
//! @short Undo/redo command used when property visibility is changed
/*! Internal, only used in addition to property change. */
class InsertEmptyRowCommand : public Command
{
public:
/*! Creates the InsertEmptyRowCommand object. */
InsertEmptyRowCommand( KexiTableDesignerView* view, int row );
virtual ~InsertEmptyRowCommand();
virtual TQString name() const;
virtual void execute();
virtual void unexecute();
protected:
KexiDB::AlterTableHandler::ChangeFieldPropertyAction m_alterTableAction;
int m_row;
};
}
#endif
|