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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
/* This file is part of the KDE project
Copyright (C) 2003 Lucijan Busch <lucijan@gmx.at>
Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
Copyright (C) 2004-2007 Jaroslaw Staniek <js@iidea.pl>
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 KFORMDESIGNERWIDGETLIBRARY_H
#define KFORMDESIGNERWIDGETLIBRARY_H
#include <tqobject.h>
#include <tqmap.h>
#include <tqdict.h>
#include "widgetfactory.h"
template<class type> class TQPtrList;
template<class type> class TQValueVector;
class KActionCollection;
class KAction;
class TQWidget;
class TQPopupMenu;
class TQVariant;
class TQDomDocument;
class TQDomElement;
namespace KFormDesigner {
class Container;
class ObjectTreeItem;
class WidgetLibraryPrivate;
class WidgetPropertySet;
typedef TQPtrList<KAction> ActionList;
/**
* This class searches for factories and provides KActions for widget creation.
* Every widget can be located using this library.
* You call WidgetLibrary functions instead of calling directly factories.
* See WidgetFactory for a description of the functions.
*/
class KFORMEDITOR_EXPORT WidgetLibrary : public TQObject
{
Q_OBJECT
TQ_OBJECT
public:
/*! Constructs WidgetLibrary object.
In \a supportedFactoryGroups you can provide
factory group list to be supported. Factory groups are defined by
"X-KFormDesigner-FactoryGroup" field in every factory serviece's .desktop file.
By default (when supportedFactoryGroups is empty) only factories having empty
"X-KFormDesigner-FactoryGroup" field will be loaded.
Factory group names are case-insensitive. */
WidgetLibrary(TQObject *tqparent=0, const TQStringList& supportedFactoryGroups = TQStringList());
virtual ~WidgetLibrary();
/**
* creates actions for widget creating
*/
ActionList createWidgetActions(KXMLGUIClient* client, KActionCollection *tqparent,
TQObject *receiver, const char *slot);
void addCustomWidgetActions(KActionCollection *col);
//old /**
//old * creates the XML for widget actions
//old */
//old TQString createXML();
/**
* searches the right factory and creates a widget.
* \return the widget or 0 if something falid
*/
TQWidget *createWidget(const TQCString &classname, TQWidget *tqparent, const char *name, Container *c,
int options = WidgetFactory::DefaultOptions);
bool createMenuActions(const TQCString &c, TQWidget *w, TQPopupMenu *menu,
KFormDesigner::Container *container);
/**
* Shows orientation selection popup.
* \return one of the following values:
* - WidgetFactory::AnyQt::Orientation (means no selection has been made, i.e. it was cancelled)
* - WidgetFactory::HorizontalQt::Orientation
* - WidgetFactory::VerticalQt::Orientation
*/
WidgetFactory::CreateWidgetOptions showOrientationSelectionPopup(
const TQCString &classname, TQWidget* tqparent, const TQPoint& pos);
TQString internalProperty(const TQCString& classname, const TQCString& property);
TQString displayName(const TQCString &classname);
TQString namePrefix(const TQCString &classname);
TQString textForWidgetName(const TQCString &name, const TQCString &className);
/*! Checks if the \a classname is an alternate classname,
and returns the good classname.
If \a classname is not alternate, \a classname is returned. */
TQCString classNameForAlternate(const TQCString &classname);
TQString iconName(const TQCString &classname);
TQString includeFileName(const TQCString &classname);
TQString savingName(const TQCString &classname);
bool startEditing(const TQCString &classname, TQWidget *w, Container *container);
bool previewWidget(const TQCString &classname, TQWidget *widget, Container *container);
bool clearWidgetContent(const TQCString &classname, TQWidget *w);
bool saveSpecialProperty(const TQCString &classname, const TQString &name,
const TQVariant &value, TQWidget *w, TQDomElement &tqparentNode, TQDomDocument &tqparent);
bool readSpecialProperty(const TQCString &classname, TQDomElement &node, TQWidget *w,
ObjectTreeItem *item);
bool isPropertyVisible(const TQCString &classname, TQWidget *w,
const TQCString &property, bool multiple = false, bool isTopLevel = false);
TQValueList<TQCString> autoSaveProperties(const TQCString &classname);
WidgetInfo* widgetInfoForClassName(const char* classname);
WidgetFactory* factoryForClassName(const char* className);
WidgetFactory* factory(const char* factoryName) const;
/*! \return true if advanced properties like "mouseTracking" should
be user-visible. True by default (in KFD), but Kexi set's this to false.
See WidgetLibraryPrivate class implementation for complete list
of advanced properties. */
bool advancedPropertiesVisible() const;
/*! Sets advanced properties to be visible or not. */
void setAdvancedPropertiesVisible(bool set);
/*! \return The i18n'ed name of the property \a propertyName
for a class described by \a winfo. The name can be displayed in
PropertyEditor. The name is retrieved from class' widget library.
If this library doesn't define description for such property,
and there is a tqparent library for \a winfo defined, tqparent library
is asked for returning description string.
Eventually, if even this failed, empty string is returned.
@see WidgetFactory::propertyDescForName() */
TQString propertyDescForName(WidgetInfo *winfo, const TQCString& propertyName);
/*! \return The i18n'ed name of the property's value whose name is \a name.
Works in the same way as propertyDescForName(): if actual library
does not define a description we are looking for, tqparent factory is asked
to return such description.
Eventually, if even this failed, empty string is returned.
@see WidgetFactory::propertyDescForValue() */
TQString propertyDescForValue(WidgetInfo *winfo, const TQCString& name);
/*! Used by WidgetPropertySet::setWidget() after creating properties. */
void setPropertyOptions( WidgetPropertySet &list, const WidgetInfo& winfo, TQWidget* w );
/*! \return true if property sets should be reloaded for \a property property,
\a classname class and widget \a w when a given property value changed. */
bool propertySetShouldBeReloadedAfterPropertyChange(const TQCString& classname, TQWidget *w,
const TQCString& property);
signals:
void prepareInsert(const TQCString &c);
//! Received by KexiFormPart::slotWidgetCreatedByFormsLibrary() so we can add drag/drop
//! connection for the new widget
void widgetCreated(TQWidget *widget);
protected:
/**
* Adds a factory to the library, creates actions for widgets in the added factory.
* This function is not called directly but by the factory locater.
*/
void loadFactoryWidgets(WidgetFactory *f);
#if 0 //UNIMPLEMENTED
/**
* you can restrict the loaded factories by setting the filter to a pattern
* like 'kexi|containers' in that case only factory containing 'kexi' or containers will be loaded.
* this is useful if you want to embedd formeditor and provide e.g. a LineEdit with special features
* but don't want to confuse the user... are you confused now?
* NB: not implemented yet
*/
void setFilter(const TQRegExp &expr);
#endif
/**
* Lookups widget factories list (note that this function get called once in ctor)
*/
void lookupFactories();
/**
* Loads widget factories found in lookupFactories(). This is called once.
*/
void loadFactories();
WidgetLibraryPrivate *d;
};
}
#endif
|