summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/forms/kexidatasourcepage.h
blob: 748d5d3db70aaaeceaaefba353712fd6440cbe27 (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
/* This file is part of the KDE project
   Copyright (C) 2005 Jaroslaw Staniek <[email protected]>

   This library 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 library 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 library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/
#ifndef KEXIDATASOURCEPAGE_H
#define KEXIDATASOURCEPAGE_H

#include <tqwidget.h>
#include <kexidb/field.h>
#include <kexidb/utils.h>
#include <koproperty/set.h>

class KCommand;
class KexiObjectInfoLabel;
class KexiDataSourceComboBox;
class KexiFieldComboBox;
class KexiFieldListView;
class KexiProject;
class TQToolButton;
class TQLabel;
class TQFrame;

//! A page within form designer's property tabbed pane, providing data source editor
class KEXIFORMUTILS_EXPORT KexiDataSourcePage : public TQWidget
{
	Q_OBJECT
  TQ_OBJECT

	public:
		KexiDataSourcePage(TQWidget *parent, const char *name = 0);
		virtual ~KexiDataSourcePage();

		KexiDataSourceComboBox* dataSourceCombo() const { return m_dataSourceCombo; }
		KexiObjectInfoLabel* objectInfoLabel() const { return m_objectInfoLabel; }

	public slots:
		void setProject(KexiProject *prj);
		void clearDataSourceSelection(bool alsoClearComboBox = true);
		void clearWidgetDataSourceSelection();

		//! Sets data source of a currently selected form. 
		//! This is performed on form initialization and on activating.
		void setDataSource(const TQCString& mimeType, const TQCString& name);

		//! Receives a pointer to a new property \a set (from KexiFormView::managerPropertyChanged())
		void assignPropertySet(KoProperty::Set* propertySet);

	signals:
		//! Signal emitted when helper button 'go to selected data source' is clicked.
		void jumpToObjectRequested(const TQCString& mime, const TQCString& name);

		//! Signal emitted when form's data source has been changed. It's connected to the Form Manager.
		void formDataSourceChanged(const TQCString& mime, const TQCString& name);

		/*! Signal emitted when current widget's data source (field/expression)
		 has been changed. It's connected to the Form Manager. 
		 \a caption for this field is also provided (e.g. AutoField form widget use it) */
		void dataSourceFieldOrExpressionChanged(const TQString& string, const TQString& caption,
			KexiDB::Field::Type type);

		/*! Signal emitted when 'insert fields' button has been clicked */
		void insertAutoFields(const TQString& sourceMimeType, const TQString& sourceName,
			const TQStringList& fields);

	protected slots:
		void slotDataSourceTextChanged(const TQString & string);
		void slotDataSourceChanged();
		void slotFieldSelected();
		void slotGotoSelected();
		void slotInsertSelectedFields();
		void slotFieldListViewSelectionChanged();
		void slotFieldDoubleClicked(const TQString& sourceMimeType, const TQString& sourceName,
			const TQString& fieldName);

	protected:
		void updateSourceFieldWidgetsAvailability();

		KexiFieldComboBox *m_sourceFieldCombo;
		KexiObjectInfoLabel *m_objectInfoLabel;
		KexiDataSourceComboBox* m_dataSourceCombo;
		TQLabel *m_dataSourceLabel, *m_noDataSourceAvailableLabel, 
			*m_widgetDSLabel, *m_availableFieldsLabel,
			*m_mousePointerLabel, *m_availableFieldsDescriptionLabel;
		TQToolButton *m_clearWidgetDSButton, *m_clearDSButton, *m_gotoButton, *m_addField;
		TQFrame *m_dataSourceSeparator;
		TQString m_noDataSourceAvailableSingleText, m_noDataSourceAvailableMultiText;
		bool m_insideClearDataSourceSelection : 1;
#ifdef KEXI_NO_AUTOFIELD_WIDGET
		KexiDB::TableOrQuerySchema *m_tableOrQuerySchema; //!< temp.
#else
		KexiFieldListView* m_fieldListView;
#endif

		//! Used only in assignPropertySet() to check whether we already have the set assigned
		TQCString m_currentObjectName;
		//TQGuardedPtr<KoProperty::Set> m_propertySet;
};

#endif