kexirelationview.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 Lucijan Busch <lucijan@gmx.at>
3 Copyright (C) 2003-2004, 2006 Jaroslaw Staniek <js@iidea.pl>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KEXIRELATIONVIEW_H
22#define KEXIRELATIONVIEW_H
23
24#include <tqguardedptr.h>
25#include <tqscrollview.h>
26#include <tqptrlist.h>
27#include <tqdict.h>
28
29#include <kexidb/tableschema.h>
30
31#include "kexirelationviewconnection.h"
32
33class TQFrame;
34
35class KexiRelationViewTable;
36class KexiRelationViewTableContainer;
37class TDEAction;
38class TDEPopupMenu;
39
40namespace KexiDB
41{
42 class Reference;
43 class Connection;
44}
45
46typedef TQDict<KexiRelationViewTableContainer> TablesDict;
47typedef TQDictIterator<KexiRelationViewTableContainer> TablesDictIterator;
48typedef TQPtrList<KexiRelationViewConnection> ConnectionList;
49typedef TQPtrListIterator<KexiRelationViewConnection> ConnectionListIterator;
50
51struct SourceConnection
52{
53 TQString masterTable;
54 TQString detailsTable;
55 TQString masterField;
56 TQString detailsField;
57};
58
68class KEXIRELATIONSVIEW_EXPORT KexiRelationView : public TQScrollView
69{
70 TQ_OBJECT
71
72
73 public:
74 KexiRelationView(TQWidget *parent, const char *name=0);
75 virtual ~KexiRelationView();
76
78 TablesDict* tables() { return &m_tables; }
79
84 KexiRelationViewTableContainer* addTableContainer(KexiDB::TableSchema *t,
85 const TQRect &rect = TQRect());
86
88 KexiRelationViewTableContainer * tableContainer(KexiDB::TableSchema *t) const;
89
91 void addConnection(const SourceConnection& _conn /*, bool interactive=true*/);
92
93 void setReadOnly(bool);
94
95 inline KexiRelationViewConnection* selectedConnection() const { return m_selectedConnection; }
96
97 inline KexiRelationViewTableContainer* focusedTableView() const { return m_focusedTableView; }
98
99 virtual TQSize sizeHint() const;
100
101 const ConnectionList* connections() const { return &m_connectionViews; }
102
103// KexiRelationViewTableContainer* containerForTable(KexiDB::TableSchema* tableSchema);
104
105 signals:
106 void tableContextMenuRequest( const TQPoint& pos );
107 void connectionContextMenuRequest( const TQPoint& pos );
108 void emptyAreaContextMenuRequest( const TQPoint& pos );
109 void tableViewGotFocus();
110 void connectionViewGotFocus();
111 void emptyAreaGotFocus();
112 void tableHidden(KexiDB::TableSchema& t);
113 void tablePositionChanged(KexiRelationViewTableContainer*);
114 void aboutConnectionRemove(KexiRelationViewConnection*);
115
116 public slots:
118 void clearSelection();
119
122 void clear();
123
125 void removeAllConnections();
126
128 void hideAllTablesExcept( KexiDB::TableSchema::List* tables );
129
130 void slotTableScrolling(const TQString&);
131
133 void removeSelectedObject();
134
135
136 protected slots:
137 void containerMoved(KexiRelationViewTableContainer *c);
138 void slotListUpdate(TQObject *s);
139 void slotTableViewEndDrag();
140 void slotTableViewGotFocus();
141
142 protected:
143// /*! executes popup menu at \a pos, or,
144// if \a pos not specified: at center of selected table view (if any selected),
145// or at center point of the relations view. */
146// void executePopup( TQPoint pos = TQPoint(-1,-1) );
147
148 void drawContents(TQPainter *p, int cx, int cy, int cw, int ch);
149 void contentsMousePressEvent(TQMouseEvent *ev);
150 virtual void keyPressEvent(TQKeyEvent *ev);
151
152 void recalculateSize(int width, int height);
153 void stretchExpandSize();
154// void invalidateActions();
155// void clearTableSelection();
156// void clearConnSelection();
157
158 void hideTable(KexiRelationViewTableContainer* tableView);
159 void removeConnection(KexiRelationViewConnection *conn);
160
161 TablesDict m_tables;
162 bool m_readOnly;
163 ConnectionList m_connectionViews;
164 KexiRelationViewConnection* m_selectedConnection;
165 TQGuardedPtr<KexiRelationViewTableContainer> m_focusedTableView;
166};
167
168#endif
TQPtrList< TableSchema > List
Type of tables list.
Definition tableschema.h:45
provides a view for displaying relations between database tables.
TablesDict * tables()
High-level database connectivity library with database backend drivers.