summaryrefslogtreecommitdiffstats
path: root/kexi/widget/tableview/kexicomboboxpopup.h
blob: 876be9bce2c5e26af4226ef2f8742281824aa368 (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
/* This file is part of the KDE project
   Copyright (C) 2004-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 KEXICOMBOBOXPOPUP_H
#define KEXICOMBOBOXPOPUP_H

#include <tqframe.h>

class KexiComboBoxPopupPrivate;
class KexiTableView;
class KexiTableViewData;
class KexiTableViewColumn;
class KexiTableItem;
namespace KexiDB {
	class Field;
}

//! Internal class for displaying popup table view 
class KexiComboBoxPopup : public TQFrame
{
	Q_OBJECT
  TQ_OBJECT
	public:
//js TODO: more ctors!
		/*! Constructor for creating a popup using definition from \a column. 
		 If the column is lookup column, it's definition is used to display
		 one or more column within the popup. Otherwise column.field() is used
		 to display single-column data. */
		KexiComboBoxPopup(TQWidget* parent, KexiTableViewColumn &column);

		/*! Alternative constructor supporting lookup fields and enum hints. */
		KexiComboBoxPopup(TQWidget* parent, KexiDB::Field &field);

		virtual ~KexiComboBoxPopup();

		KexiTableView* tableView();

		/*! Sets maximum number of rows for this popup. */
		void setMaxRows(int r);

		/*! \return maximum number of rows for this popup. */
		int maxRows() const;

		/*! Default maximum number of rows for KexiComboBoxPopup objects. */
		static const int defaultMaxRows;

		virtual bool eventFilter( TQObject *o, TQEvent *e );

	signals:
		void rowAccepted(KexiTableItem *item, int row);
		void cancelled();
		void hidden();

	public slots:
		virtual void resize( int w, int h );
		void updateSize(int minWidth = 0);

	protected slots:
		void slotTVItemAccepted(KexiTableItem *item, int row, int col);
		void slotDataReloadRequested();

	protected:
		void init();
		//! The main function for setting data; data can be set either by passing \a column or \a field.
		//! The second case is used for lookup
		void setData(KexiTableViewColumn *column, KexiDB::Field *field);

		//! used by setData()
		void setDataInternal( KexiTableViewData *data, bool owner = true ); //!< helper

		KexiComboBoxPopupPrivate *d;

		friend class KexiComboBoxTableEdit;
};

#endif