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
|
/* This file is part of the KDE project
Copyright (C) 2002 Lucijan Busch <lucijan@gmx.at>
Copyright (C) 2003-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 KEXIRELATIONVIEW_H
#define KEXIRELATIONVIEW_H
#include <tqguardedptr.h>
#include <tqscrollview.h>
#include <tqptrlist.h>
#include <tqdict.h>
#include <kexidb/tableschema.h>
#include "kexirelationviewconnection.h"
class TQFrame;
class KexiRelationViewTable;
class KexiRelationViewTableContainer;
class KAction;
class KPopupMenu;
namespace KexiDB
{
class Reference;
class Connection;
}
typedef TQDict<KexiRelationViewTableContainer> TablesDict;
typedef TQDictIterator<KexiRelationViewTableContainer> TablesDictIterator;
typedef TQPtrList<KexiRelationViewConnection> ConnectionList;
typedef TQPtrListIterator<KexiRelationViewConnection> ConnectionListIterator;
struct SourceConnection
{
TQString masterTable;
TQString detailsTable;
TQString masterField;
TQString detailsField;
};
/*! @short provides a view for displaying relations between database tables.
It is currently used for two purposes:
- displaying global database relations
- displaying relations defined for a database query
The class is for displaying only - retrieving data and updating data on the backend side is implemented
in KexiRelationWidget, and more specifically in: Kexi Relation Part and Kexi Query Part.
*/
class KEXIRELATIONSVIEW_EXPORT KexiRelationView : public TQScrollView
{
Q_OBJECT
public:
KexiRelationView(TQWidget *parent, const char *name=0);
virtual ~KexiRelationView();
//! \return a dictionary of added tables
TablesDict* tables() { return &m_tables; }
/*! Adds a table \a t to the area. This changes only visual representation.
If \a rect is valid, table widget geometry will be initialized.
\return added table container or 0 on failure.
*/
KexiRelationViewTableContainer* addTableContainer(KexiDB::TableSchema *t,
const TQRect &rect = TQRect());
/*! \return table container for table \a t. */
KexiRelationViewTableContainer * tableContainer(KexiDB::TableSchema *t) const;
//! Adds a connection \a con to the area. This changes only visual representation.
void addConnection(const SourceConnection& _conn /*, bool interactive=true*/);
void setReadOnly(bool);
inline KexiRelationViewConnection* selectedConnection() const { return m_selectedConnection; }
inline KexiRelationViewTableContainer* focusedTableView() const { return m_focusedTableView; }
virtual TQSize sizeHint() const;
const ConnectionList* connections() const { return &m_connectionViews; }
// KexiRelationViewTableContainer* containerForTable(KexiDB::TableSchema* tableSchema);
signals:
void tableContextMenuRequest( const TQPoint& pos );
void connectionContextMenuRequest( const TQPoint& pos );
void emptyAreaContextMenuRequest( const TQPoint& pos );
void tableViewGotFocus();
void connectionViewGotFocus();
void emptyAreaGotFocus();
void tableHidden(KexiDB::TableSchema& t);
void tablePositionChanged(KexiRelationViewTableContainer*);
void aboutConnectionRemove(KexiRelationViewConnection*);
public slots:
//! Clears current selection - table/query or connection
void clearSelection();
/*! Removes all tables and connections from the view.
Does not emit signals like tableHidden(). */
void clear();
/*! Removes all coonections from the view. */
void removeAllConnections();
/*! Hides all tables except \a tables. */
void hideAllTablesExcept( KexiDB::TableSchema::List* tables );
void slotTableScrolling(const TQString&);
//! removes selected table or connection
void removeSelectedObject();
protected slots:
void containerMoved(KexiRelationViewTableContainer *c);
void slotListUpdate(TQObject *s);
void slotTableViewEndDrag();
void slotTableViewGotFocus();
protected:
// /*! executes popup menu at \a pos, or,
// if \a pos not specified: at center of selected table view (if any selected),
// or at center point of the relations view. */
// void executePopup( TQPoint pos = TQPoint(-1,-1) );
void drawContents(TQPainter *p, int cx, int cy, int cw, int ch);
void contentsMousePressEvent(TQMouseEvent *ev);
virtual void keyPressEvent(TQKeyEvent *ev);
void recalculateSize(int width, int height);
void stretchExpandSize();
// void invalidateActions();
// void clearTableSelection();
// void clearConnSelection();
void hideTable(KexiRelationViewTableContainer* tableView);
void removeConnection(KexiRelationViewConnection *conn);
TablesDict m_tables;
bool m_readOnly;
ConnectionList m_connectionViews;
KexiRelationViewConnection* m_selectedConnection;
TQGuardedPtr<KexiRelationViewTableContainer> m_focusedTableView;
};
#endif
|