kexirelationviewtable.h
1/* This file is part of the KDE project
2 Copyright (C) 2002, 2003 Lucijan Busch <lucijan@gmx.at>
3 Copyright (C) 2003-2007 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 KEXIRELATIONVIEWTABLE_H
22#define KEXIRELATIONVIEWTABLE_H
23
24#include <tqframe.h>
25#include <tqstringlist.h>
26#include <tqlabel.h>
27#include <tdelistview.h>
28
29#include <widget/kexifieldlistview.h>
30
32class KexiRelationViewTable;
33class KexiRelationViewTableContainerHeader;
34
35namespace KexiDB
36{
37 class TableOrQuerySchema;
38}
39
40class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTableContainer : public TQFrame
41{
42 TQ_OBJECT
43
44
45 public:
46// KexiRelationViewTableContainer(KexiRelationView *parent, KexiDB::TableSchema *t);
47 KexiRelationViewTableContainer(
49
50 virtual ~KexiRelationViewTableContainer();
51
52 int globalY(const TQString &field);
53// KexiDB::TableSchema *table();
54
55 KexiRelationViewTable* tableView() const { return m_tableView; }
56 KexiDB::TableOrQuerySchema* schema() const;
57
58 int right() { return x() + width() - 1; }
59 int bottom() { return y() + height() - 1; }
60
61 signals:
62 void moved(KexiRelationViewTableContainer *);
63 void endDrag();
64 void gotFocus();
65 void contextMenuRequest(const TQPoint& pos);
66
67 public slots:
68 virtual void setFocus();
69 virtual void unsetFocus();
70
71 protected slots:
72 void moved();
73 void slotContextMenu(TDEListView *lv, TQListViewItem *i, const TQPoint& p);
74
75 protected:
76// KexiDB::TableSchema *m_table;
77 KexiRelationViewTableContainerHeader *m_tableHeader;
78 KexiRelationViewTable *m_tableView;
79 KexiRelationView *m_parent;
80
81 friend class KexiRelationViewTableContainerHeader;
82};
83
84/*
85class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTableItem : public TDEListViewItem
86{
87 public:
88 KexiRelationViewTableItem(TQListView *parent, TQListViewItem *after,
89 TQString key, TQString field);
90 virtual void paintFocus ( TQPainter * p, const TQColorGroup & cg, const TQRect & r );
91};*/
92
93
94class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTable : public KexiFieldListView
95{
96 TQ_OBJECT
97
98
99 public:
100 KexiRelationViewTable(KexiDB::TableOrQuerySchema* tableOrQuerySchema,
101 KexiRelationView *view, TQWidget *parent, const char *name = 0);
102// KexiRelationViewTable(TQWidget *parent, KexiRelationView *view, KexiDB::TableSchema *t, const char *name=0);
103 virtual ~KexiRelationViewTable();
104
105// KexiDB::TableSchema *table() const { return m_table; };
106 int globalY(const TQString &item);
107// void setReadOnly(bool);
108 virtual TQSize sizeHint() const;
109
110 signals:
111 void tableScrolling();
112
113 protected slots:
114 void slotDropped(TQDropEvent *e);
115 void slotContentsMoving(int, int);
116// void slotItemDoubleClicked( TQListViewItem *i, const TQPoint &, int );
117
118 protected:
119 virtual void contentsMousePressEvent( TQMouseEvent * e );
120 virtual bool acceptDrag(TQDropEvent *e) const;
121//moved virtual TQDragObject *dragObject();
122 virtual TQRect drawItemHighlighter(TQPainter *painter, TQListViewItem *item);
123
124 private:
125// TQStringList m_fieldList;
126// KexiDB::TableSchema *m_table;
127 KexiRelationView *m_view;
128// TQPixmap m_keyIcon, m_noIcon;
129};
130
131class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTableContainerHeader : public TQLabel
132{
133 TQ_OBJECT
134
135 public:
136 KexiRelationViewTableContainerHeader(const TQString& text,TQWidget *parent);
137 virtual ~KexiRelationViewTableContainerHeader();
138
139 virtual void setFocus();
140 virtual void unsetFocus();
141
142 signals:
143 void moved();
144 void endDrag();
145
146 protected:
147 bool eventFilter(TQObject *obj, TQEvent *ev);
148 void mousePressEvent(TQMouseEvent *ev);
149 void mouseReleaseEvent(TQMouseEvent *ev);
150
151 bool m_dragging;
152 int m_grabX;
153 int m_grabY;
154 int m_offsetX;
155 int m_offsetY;
156
157 TQColor m_activeBG, m_activeFG, m_inactiveBG, m_inactiveFG;
158};
159
160#endif
provides a view for displaying relations between database tables.
High-level database connectivity library with database backend drivers.