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
|
/* This file is part of the KDE project
Copyright (C) 2004-2005 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 KEXIDATAAWAREPROPERTYSET_H
#define KEXIDATAAWAREPROPERTYSET_H
#include <tqguardedptr.h>
#include <tqptrvector.h>
#include <koproperty/set.h>
typedef TQPtrVector<KoProperty::Set> SetVector;
class KexiViewBase;
class KexiTableItem;
class KexiTableViewData;
class KexiDataAwareObjectInterface;
/*! This helper class handles data changes of a single
object implementing KexiDataAwareObjectInterface (e.g. KexiTableView) inside
a KexiViewBase container.
It is currently used in KexiAlterTableDialog and KexiQueryDesignerGuiEditor,
and may be used for similar purposes, when each KexiDataAwareObjectInterface's
row can be associated with single KoProperty::Set object, and given
KexiDataAwareObjectInterface object has to inform the world about currently
selected row/property set.
Following functionality is built-in:
- auto-initializing after resetting of table view's data
- destroying single property set that is associated with deleted row
- inserting single property set that and associating it with new row
- all property sets are cleared when view's data is cleared (using clear())
- setting view's 'dirty' flag when needed
- signalling via KexiViewBase::propertySetSwitched() that current property
set has changed (e.g. on moving to other row)
*/
class KEXIDATATABLE_EXPORT KexiDataAwarePropertySet : public TQObject
{
Q_OBJECT
TQ_OBJECT
public:
/*! You can instantiate KexiDataAwarePropertySet object
for existing \a tableView and \a view. \a tableView can have data assigned
(KexiDataAwareObjectInterface::setData()) now but it can be done later as well
(but assigning data is needed for proper functionality).
Any changed reassignments of table view's data will be handled automatically. */
KexiDataAwarePropertySet(KexiViewBase *view, KexiDataAwareObjectInterface* dataObject);
virtual ~KexiDataAwarePropertySet();
uint size() const;
KoProperty::Set* currentPropertySet() const;
uint currentRow() const;
inline KoProperty::Set* at(uint row) const { return m_sets[row]; }
/*! \return a pointer to property set assigned for \a item or null if \a item has no
property set assigned or it's not owned by assigned table view or
if assigned table view has no data set. */
KoProperty::Set* findPropertySetForItem(KexiTableItem& item);
/*! \return number of the first row containing \a propertyName property equal to \a value.
This is used e.g. in the Table Designer to find a row by field name.
If no such row has been found, -1 is returned. */
int findRowForPropertyValue(const TQCString& propertyName, const TQVariant& value);
signals:
/*! Emmited when row is deleted.
KexiDataAwareObjectInterface::rowDeleted() signal is usually used but when you're using
KexiDataAwarePropertySet, you never know if currentPropertySet() is updated.
So use this signal instead. */
void rowDeleted();
/*! Emmited when row is inserted.
Purpose of this signal is similar to rowDeleted() signal. */
void rowInserted();
public slots:
void removeCurrentPropertySet();
void clear(uint tqminimumSize = 0);
/*! Inserts \a set property set at \a row position.
If there was a buffer at this position before, it will be destroyed.
If \a newOne is true, the property set will be marked as newly created,
simply by adding "newrow" property.
The property set \a set will be owned by this object, so you should not
delete this property set by hand but call removeCurrentPropertySet()
or remove(uint) instead.
Note that property set's tqparent (TQObject::tqparent()) must be null
or qual to this KexiDataAwarePropertySet object, otherwise this method
will fail with a warning.
*/
void insert(uint row, KoProperty::Set* set, bool newOne = false);
/*! Removes a property set at \a row position. */
void remove(uint row);
protected slots:
/*! Handles table view's data source changes. */
void slotDataSet( KexiTableViewData *data );
//! Called on row delete in a tableview.
void slotRowDeleted();
//! Called on multiple rows delete in a tableview.
void slotRowsDeleted( const TQValueList<int> &rows );
//! Called on \a row insertion in a tableview.
void slotRowInserted(KexiTableItem* item, uint row, bool tqrepaint);
//! Called on selecting another cell in a tableview.
void slotCellSelected(int, int row);
//! Called on clearing tableview's data: just clears all property sets.
void slotReloadRequested();
protected:
SetVector m_sets; //!< prop. sets vector
TQGuardedPtr<KexiViewBase> m_view;
KexiDataAwareObjectInterface* m_dataObject;
// TQGuardedPtr<KexiTableView> m_tableView;
TQGuardedPtr<KexiTableViewData> m_currentTVData;
int m_row; //!< used to know if a new row is selected in slotCellSelected()
};
#endif
|