summaryrefslogtreecommitdiffstats
path: root/kexi/widget/relations/kexirelationviewtable.h
blob: 25faf8968f6339c30c25c85708b71b8ddadaa8b1 (plain)
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
/* This file is part of the KDE project
   Copyright (C) 2002, 2003 Lucijan Busch <[email protected]>
   Copyright (C) 2003-2007 Jaroslaw Staniek <[email protected]>

   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 KEXIRELATIONVIEWTABLE_H
#define KEXIRELATIONVIEWTABLE_H

#include <tqframe.h>
#include <tqstringlist.h>
#include <tqlabel.h>
#include <tdelistview.h>

#include <widget/kexifieldlistview.h>

class KexiRelationView;
class KexiRelationViewTable;
class KexiRelationViewTableContainerHeader;

namespace KexiDB
{
	class TableOrQuerySchema;
}

class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTableContainer : public TQFrame
{
	Q_OBJECT
  

	public:
//		KexiRelationViewTableContainer(KexiRelationView *parent, KexiDB::TableSchema *t);
		KexiRelationViewTableContainer(
			KexiRelationView *parent, KexiDB::TableOrQuerySchema *schema);

		virtual ~KexiRelationViewTableContainer();

		int globalY(const TQString &field);
//		KexiDB::TableSchema *table();

		KexiRelationViewTable* tableView() const { return m_tableView; }
		KexiDB::TableOrQuerySchema* schema() const;
		
		int right() { return x() + width() - 1; }
		int bottom() { return y() + height() - 1; }

	signals:
		void moved(KexiRelationViewTableContainer *);
		void endDrag();
		void gotFocus();
		void contextMenuRequest(const TQPoint& pos);

	public slots:
		virtual void setFocus();
		virtual void unsetFocus();

	protected slots:
		void moved();
		void slotContextMenu(TDEListView *lv, TQListViewItem *i, const TQPoint& p);

	protected:
//		KexiDB::TableSchema *m_table;
		KexiRelationViewTableContainerHeader *m_tableHeader;
		KexiRelationViewTable *m_tableView;
		KexiRelationView *m_parent;

		friend class KexiRelationViewTableContainerHeader;
};

/*
class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTableItem : public TDEListViewItem
{
	public:
		KexiRelationViewTableItem(TQListView *parent, TQListViewItem *after,
			TQString key, TQString field);
		virtual void paintFocus ( TQPainter * p, const TQColorGroup & cg, const TQRect & r );
};*/


class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTable : public KexiFieldListView
{
	Q_OBJECT
  

	public:
		KexiRelationViewTable(KexiDB::TableOrQuerySchema* tableOrQuerySchema, 
			KexiRelationView *view, TQWidget *parent, const char *name = 0);
//		KexiRelationViewTable(TQWidget *parent, KexiRelationView *view, KexiDB::TableSchema *t, const char *name=0);
		virtual ~KexiRelationViewTable();

//		KexiDB::TableSchema *table() const { return m_table; };
		int globalY(const TQString &item);
//		void setReadOnly(bool);
		virtual TQSize sizeHint() const;

	signals:
		void tableScrolling();

	protected slots:
		void slotDropped(TQDropEvent *e);
		void slotContentsMoving(int, int);
//		void slotItemDoubleClicked( TQListViewItem *i, const TQPoint &, int );

	protected:
		virtual void contentsMousePressEvent( TQMouseEvent * e );
		virtual bool acceptDrag(TQDropEvent *e) const;
//moved		virtual TQDragObject *dragObject();
		virtual TQRect drawItemHighlighter(TQPainter *painter, TQListViewItem *item); 

	private:
//		TQStringList m_fieldList;
//		KexiDB::TableSchema *m_table;
		KexiRelationView *m_view;
//		TQPixmap m_keyIcon, m_noIcon;
};

class KEXIRELATIONSVIEW_EXPORT KexiRelationViewTableContainerHeader : public TQLabel
{
	Q_OBJECT
  
	public:
		KexiRelationViewTableContainerHeader(const TQString& text,TQWidget *parent);
		virtual ~KexiRelationViewTableContainerHeader();

		virtual void setFocus();
		virtual void unsetFocus();

	signals:
		void moved();
		void endDrag();

	protected:
		bool eventFilter(TQObject *obj, TQEvent *ev);
		void mousePressEvent(TQMouseEvent *ev);
		void mouseReleaseEvent(TQMouseEvent *ev);

		bool m_dragging;
		int m_grabX;
		int m_grabY;
		int m_offsetX;
		int m_offsetY;

		TQColor m_activeBG, m_activeFG, m_inactiveBG, m_inactiveFG;
};

#endif