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
189
190
191
192
|
/* This file is part of the KDE project
Copyright (C) 2004-2006 Jaroslaw Staniek <js@iidea.pl>
This program 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 program 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 program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KEXIALTERTABLEDIALOG_P_H
#define KEXIALTERTABLEDIALOG_P_H
#include "kexitabledesignerview.h"
#include <kcommand.h>
class KexiDataAwarePropertySet;
//! @internal indices for table columns
#define COLUMN_ID_ICON 0
#define COLUMN_ID_CAPTION 1
#define COLUMN_ID_TYPE 2
#define COLUMN_ID_DESC 3
/*! @internal
Command group, reimplemented to get access to commands().
We need it to iterate through commands so we can perform a set of ALTER TABLE atomic actions. */
class CommandGroup : public KMacroCommand
{
public:
CommandGroup( const TQString & name )
: KMacroCommand(name)
{}
virtual ~CommandGroup() {}
const TQPtrList<KCommand>& commands() const { return m_commands; }
};
/*! @internal
Command history, reimplemented to get access to commands().
We need it to iterate through commands so we can perform a set of ALTER TABLE atomic actions. */
class CommandHistory : public KCommandHistory
{
Q_OBJECT
TQ_OBJECT
public:
CommandHistory(KActionCollection *actionCollection, bool withMenus = true);
const TQPtrList<KCommand>& commands() const { return m_commandsToUndo; }
void addCommand(KCommand *command, bool execute = true);
void clear();
public slots:
virtual void undo();
virtual void redo();
protected:
TQPtrList<KCommand> m_commandsToUndo, m_commandsToRedo;
};
//----------------------------------------------
//! @internal
class KexiTableDesignerViewPrivate
{
public:
KexiTableDesignerViewPrivate(KexiTableDesignerView* aDesignerView);
~KexiTableDesignerViewPrivate();
int generateUniqueId();
/*! @internal
Sets property \a propertyName in property set \a set to \a newValue.
If \a commandGroup is not 0, a new ChangeFieldPropertyCommand object is added there as well.
While setting the new value, addHistoryCommand_in_slotPropertyChanged_enabled is set to false,
so addHistoryCommand() wont be executed in slotPropertyChanged() as an answer to setting
the property.
If \a forceAddCommand is false (the default) and \a newValue does not differ from curent property value
(set[propertyName].value()), ChangeFieldPropertyCommand command is not added to the \a commandGroup.
Otherwise, command is always added.
\a rememberOldValue argument is passed to Property::setValue()
If \a slist and \a nlist if not NULL and not empty, these are passed to Property::setListData().
If \a slist and \a nlist if not NULL but empty, Property::setListData(0) is called.
addHistoryCommand_in_slotPropertyChanged_enabled is then set back to the original state.
*/
void setPropertyValueIfNeeded( const KoProperty::Set& set, const TQCString& propertyName,
const TQVariant& newValue, CommandGroup* commandGroup,
bool forceAddCommand = false, bool rememberOldValue = true,
TQStringList* const slist = 0, TQStringList* const nlist = 0);
/*! Like above but allows to specify \a oldValue. */
void setPropertyValueIfNeeded(
const KoProperty::Set& set, const TQCString& propertyName,
const TQVariant& newValue, const TQVariant& oldValue, CommandGroup* commandGroup,
bool forceAddCommand = false, bool rememberOldValue = true,
TQStringList* const slist = 0, TQStringList* const nlist = 0);
/*! @internal
Used in updatePropertiesVisibility().
Does nothing if visibility should not be changed, i.e. when prop->isVisible()==visible,
otherwise sets changed to true and sets visibility of property \a prop to \a visible.
*/
void setVisibilityIfNeeded( const KoProperty::Set& set, KoProperty::Property* prop,
bool visible, bool &changed, CommandGroup *commandGroup );
bool updatePropertiesVisibility(KexiDB::Field::Type fieldType, KoProperty::Set &set,
CommandGroup *commandGroup = 0);
/*! \return message used to ask user for accepting saving the design.
\a emptyTable is set to true if the table designed contains no rows.
If \a skipWarning is true, no warning about data loss is appended (useful when
only non-physical altering actions will be performed). */
TQString messageForSavingChanges(bool &emptyTable, bool skipWarning = false);
/*! Updates icon in the first column, depending on property set \a set.
For example, when "rowSource" and "rowSourceType" propertiesa are not empty,
"combo" icon appears. */
void updateIconForItem(KexiTableItem &item, KoProperty::Set& set);
KexiTableDesignerView* designerView;
KexiTableView *view; //!< helper
KexiTableViewData *data;
KexiDataAwarePropertySet *sets;
int row; //!< used to know if a new row is selected in slotCellSelected()
KToggleAction *action_toggle_pkey;
KPopupTitle *contextMenuTitle;
int uniqueIdCounter;
//! internal
int maxTypeNameTextWidth;
//! Set to true in beforeSwitchTo() to avoid asking again in storeData()
bool dontAskOnStoreData : 1;
bool slotTogglePrimaryKeyCalled : 1;
bool primaryKeyExists : 1;
//! Used in slotPropertyChanged() to avoid infinite recursion
bool slotPropertyChanged_primaryKey_enabled : 1;
//! Used in slotPropertyChanged() to avoid infinite recursion
bool slotPropertyChanged_subType_enabled : 1;
//! used in slotPropertyChanged() to disable addHistoryCommand()
bool addHistoryCommand_in_slotPropertyChanged_enabled : 1;
//! used in slotRowUpdated() to disable addHistoryCommand()
bool addHistoryCommand_in_slotRowUpdated_enabled : 1;
//! used in slotAboutToDeleteRow() to disable addHistoryCommand()
bool addHistoryCommand_in_slotAboutToDeleteRow_enabled : 1;
//! used in slotRowInserted() to disable addHistoryCommand()
bool addHistoryCommand_in_slotRowInserted_enabled : 1;
//! used to disable slotBeforeCellChanged()
bool slotBeforeCellChanged_enabled : 1;
//! @tood temp; remove this:
//! Temporary flag, used for testingu the Alter Table machinery. Affects storeData()
//! Used in slotExecuteRealAlterTable() to switch on real alter table for a while.
bool tempStoreDataUsingRealAlterTable : 1;
/*! Set to a recent result of calling \ref tristate KexiTableDesignerView::storeData(bool dontAsk).
Then, it is used in \ref void KexiTableDesignerView::executeRealAlterTable()
to know what return value should be. */
tristate recentResultOfStoreData;
KActionCollection* historyActionCollection;
CommandHistory* history;
//! A cache used in KexiTableDesignerView::buildField() to quickly identify
//! properties internal to the designer
TQAsciiDict<char> internalPropertyNames;
};
#endif
|