summaryrefslogtreecommitdiffstats
path: root/kexi/formeditor/widgetwithsubpropertiesinterface.h
blob: dd6b0ddcbb7d80966d7353cfa915560352504d56 (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
/* This file is part of the KDE project
   Copyright (C) 2006 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 WIDGETWITHSUBPROPERTIESINTERFACE_H
#define WIDGETWITHSUBPROPERTIESINTERFACE_H

#include <tqcstring.h>
#include <tqvaluelist.h>
#include <tqwidget.h>
#include <tqguardedptr.h>
#include <tqvariant.h>

namespace KFormDesigner {

//! An interface for declaring form widgets to have subproperties.
/*! Currently used in KexiDBAutoField to allow editing specific properties 
 of its internal editor. For example, if the autofield is of type Image Box,
 the Image Box widget has some specific properties like "lineWidth". 
 Such properties are provided by the parent KexiDBAutoField object as subproperties. */
class KFORMEDITOR_EXPORT WidgetWithSubpropertiesInterface
{
	public:
		WidgetWithSubpropertiesInterface();
		virtual ~WidgetWithSubpropertiesInterface();

		//! Sets \a widget subwidget handling subproperties. Setting 0 clears subwidget.
//! @todo maybe someone wants to add more than one widget here?
		void setSubwidget(TQWidget *widget);

		//! \return the assigned subwidget.
		TQWidget* subwidget() const;

		//! \return a list of subproperties available for this widget.
		//! This is achieved by only listing those properties that are available in the 
		TQValueList<TQCString> subproperies() const;

		//! \return a meta property for a widget's subproperty or 0 if there 
		//! is no such subproperty.
		const TQMetaProperty *findMetaSubproperty(const char * name) const;

		//! \return a value of widget's subproperty. \a ok is set to true on success
		//! and to false on failure.
		TQVariant subproperty( const char * name, bool &ok  ) const;

		//! Sets a subproperty value \a value for a subproperty \a name
		//! \return true on successful setting and false when there 
		//! is no such a subproperty in the subwidget or TQObject::setProperty() failed.
		bool setSubproperty( const char * name, const TQVariant & value );

	protected:
		TQGuardedPtr<TQWidget> m_subwidget;
		TQValueList<TQCString> m_subproperies;
};
}

#endif