#include <widgetfactory_p.h>
Inheritance diagram for qdesigner_internal::WidgetFactory:


Definition at line 57 of file widgetfactory_p.h.
| qdesigner_internal::WidgetFactory::WidgetFactory | ( | QDesignerFormEditorInterface * | core, | |
| QObject * | parent = 0 | |||
| ) |
Definition at line 59 of file widgetfactory.cpp.
00060 : QDesignerWidgetFactoryInterface(parent), 00061 m_core(core), 00062 m_formWindow(0) 00063 { 00064 }
| qdesigner_internal::WidgetFactory::~WidgetFactory | ( | ) |
Returns the widget into which children should be inserted when w is a container known to the designer.
Usually that is w itself, sometimes it is different (e.g. a tabwidget is known to the designer as a container but the child widgets should be inserted into the current page of the tabwidget. So in this case this function returns the current page of the tabwidget.)
Implements QDesignerWidgetFactoryInterface.
Definition at line 290 of file widgetfactory.cpp.
00291 { 00292 if (QDesignerPromotedWidget *promoted = qobject_cast<QDesignerPromotedWidget*>(w)) 00293 return containerOfWidget(promoted->child()); 00294 else if (QDesignerContainerExtension *container = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), w)) 00295 return container->widget(container->currentIndex()); 00296 00297 return w; 00298 }
Here is the call graph for this function:

Returns the actual designer widget of the container w. This is normally w itself, but might be a parent or grand parent of w (e.g. when working with a tabwidget and w is the container which contains and layouts childs, but the actual widget known to the designer is the tabwidget which is the parent of w. So this function returns the tabwidget then.)
Implements QDesignerWidgetFactoryInterface.
Definition at line 308 of file widgetfactory.cpp.
References core(), QWidget::parentWidget(), and w.
00309 { 00310 // ### cleanup 00311 if (!w) 00312 return 0; 00313 00314 if (QDesignerPromotedWidget *promoted = qobject_cast<QDesignerPromotedWidget*>(w)) 00315 return widgetOfContainer(promoted->child()); 00316 00317 if (w->parentWidget() && w->parentWidget()->parentWidget() && 00318 w->parentWidget()->parentWidget()->parentWidget() && 00319 qobject_cast<QToolBox*>(w->parentWidget()->parentWidget()->parentWidget())) 00320 return w->parentWidget()->parentWidget()->parentWidget(); 00321 00322 while (w != 0) { 00323 if (core()->widgetDataBase()->isContainer(w) || 00324 w && qobject_cast<QDesignerFormWindowInterface*>(w->parentWidget())) 00325 return w; 00326 00327 w = w->parentWidget(); 00328 } 00329 00330 return w; 00331 }
Here is the call graph for this function:

| QWidget * qdesigner_internal::WidgetFactory::createWidget | ( | const QString & | className, | |
| QWidget * | parentWidget | |||
| ) | const [virtual] |
Returns a new widget with the given name and parent widget. If no parent is specified, the widget created will be a top-level widget.
Implements QDesignerWidgetFactoryInterface.
Definition at line 89 of file widgetfactory.cpp.
References QDesignerWidgetDataBaseInterface::append(), core(), QDesignerWidgetDataBaseItemInterface::extends(), QDesignerFormEditorInterface::extensionManager(), QDesignerFormWindowInterface::findFormWindow(), QDesignerWidgetDataBaseInterface::indexOfClassName(), initialize(), QString::isEmpty(), QDesignerWidgetDataBaseInterface::item(), m_core, m_customFactory, m_formWindow, QObject::QWidget, qdesigner_internal::QDesignerPromotedWidget::setChildWidget(), QDesignerWidgetDataBaseItemInterface::setContainer(), QDesignerWidgetDataBaseItemInterface::setCustom(), QDesignerWidgetDataBaseItemInterface::setExtends(), QDesignerWidgetDataBaseItemInterface::setIncludeFile(), QDesignerWidgetDataBaseItemInterface::setPromoted(), QString::toLower(), QMap< Key, T >::value(), w, and QDesignerFormEditorInterface::widgetDataBase().
Referenced by qdesigner_internal::WidgetDataBase::defaultPropertyValues().
00090 { 00091 if (QDesignerPromotedWidget *promoted = qobject_cast<QDesignerPromotedWidget*>(parentWidget)) 00092 parentWidget = promoted->child(); 00093 00094 QDesignerFormWindowInterface *fw = m_formWindow; 00095 if (! fw) 00096 fw = QDesignerFormWindowInterface::findFormWindow(parentWidget); 00097 00098 QWidget *w = 0; 00099 00100 // ### cleanup 00101 if (QDesignerCustomWidgetInterface *f = m_customFactory.value(widgetName)) { 00102 w = f->createWidget(parentWidget); 00103 } else if (widgetName == QLatin1String("Line")) { 00104 w = new Line(parentWidget); 00105 } else if (widgetName == QLatin1String("QLabel")) { 00106 w = new QDesignerLabel(parentWidget); 00107 } else if (widgetName == QLatin1String("QDockWidget")) { 00108 w = new QDesignerDockWidget(parentWidget); 00109 } else if (widgetName == QLatin1String("QTabWidget")) { 00110 w = new QDesignerTabWidget(parentWidget); 00111 } else if (widgetName == QLatin1String("QStackedWidget")) { 00112 w = new QDesignerStackedWidget(parentWidget); 00113 } else if (widgetName == QLatin1String("QToolBox")) { 00114 w = new QDesignerToolBox(parentWidget); 00115 } else if (widgetName == QLatin1String("QToolBar")) { 00116 w = new QDesignerToolBar(parentWidget); 00117 } else if (widgetName == QLatin1String("QMenuBar")) { 00118 w = new QDesignerMenuBar(parentWidget); 00119 } else if (widgetName == QLatin1String("QMenu")) { 00120 w = new QDesignerMenu(parentWidget); 00121 } else if (widgetName == QLatin1String("Spacer")) { 00122 w = new Spacer(parentWidget); 00123 } else if (widgetName == QLatin1String("QDockWidget")) { 00124 w = new QDesignerDockWidget(parentWidget); 00125 } else if (widgetName == QLatin1String("QLayoutWidget")) { 00126 w = fw ? new QLayoutWidget(fw, parentWidget) : new QWidget(parentWidget); 00127 } else if (widgetName == QLatin1String("QDialog")) { 00128 if (fw) { 00129 w = new QDesignerDialog(fw, parentWidget); 00130 } else { 00131 w = new QDialog(parentWidget); 00132 } 00133 } else if (widgetName == QLatin1String("QWidget")) { 00134 if (fw && parentWidget && 00135 (qobject_cast<QDesignerFormWindowInterface*>(parentWidget) || qt_extension<QDesignerContainerExtension*>(m_core->extensionManager(), parentWidget))) { 00136 w = new QDesignerWidget(fw, qobject_cast<QDesignerFormWindowInterface*>(parentWidget) ? parentWidget : 0); 00137 } else { 00138 w = new QWidget(parentWidget); 00139 } 00140 } 00141 00142 #define DECLARE_LAYOUT(L, C) 00143 #define DECLARE_COMPAT_WIDGET(W, C) /*DECLARE_WIDGET(W, C)*/ 00144 #define DECLARE_WIDGET(W, C) else if (widgetName == QLatin1String(#W)) { Q_ASSERT(w == 0); w = new W(parentWidget); } 00145 #define DECLARE_WIDGET_1(W, C) else if (widgetName == QLatin1String(#W)) { Q_ASSERT(w == 0); w = new W(0, parentWidget); } 00146 00147 #include "widgets.table" 00148 00149 #undef DECLARE_COMPAT_WIDGET 00150 #undef DECLARE_LAYOUT 00151 #undef DECLARE_WIDGET 00152 #undef DECLARE_WIDGET_1 00153 00154 if (w == 0) { 00155 QDesignerWidgetDataBaseInterface *db = core()->widgetDataBase(); 00156 QDesignerWidgetDataBaseItemInterface *item = db->item(db->indexOfClassName(widgetName)); 00157 00158 if (item == 0) { 00159 item = new WidgetDataBaseItem(widgetName, tr("%1 Widget").arg(widgetName)); 00160 item->setCustom(true); 00161 item->setPromoted(true); 00162 item->setExtends(QLatin1String("QWidget")); 00163 item->setContainer(true); 00164 item->setIncludeFile(widgetName.toLower() + QLatin1String(".h")); 00165 db->append(item); 00166 } 00167 00168 QString baseClass = item->extends(); 00169 if (baseClass.isEmpty()) 00170 baseClass = QLatin1String("QWidget"); 00171 00172 QDesignerPromotedWidget *promoted = new QDesignerPromotedWidget(item, parentWidget); 00173 QWidget *child = createWidget(baseClass, promoted); 00174 promoted->setChildWidget(child); 00175 00176 w = promoted; 00177 } 00178 00179 Q_ASSERT(w != 0); 00180 00181 if (fw != 0) 00182 initialize(w); 00183 00184 return w; 00185 }
Here is the call graph for this function:

| QLayout * qdesigner_internal::WidgetFactory::createLayout | ( | QWidget * | widget, | |
| QLayout * | parentLayout, | |||
| int | type | |||
| ) | const [virtual] |
Creates a layout on the widget widget of the type type which can be HBox, VBox or Grid.
Implements QDesignerWidgetFactoryInterface.
Definition at line 224 of file widgetfactory.cpp.
References QDesignerMetaDataBaseInterface::add(), qdesigner_internal::LayoutInfo::Grid, qdesigner_internal::LayoutInfo::HBox, QDesignerMetaDataBaseInterface::item(), layout, qdesigner_internal::LayoutInfo::Stacked, type, and qdesigner_internal::LayoutInfo::VBox.
00225 { 00226 QDesignerMetaDataBaseInterface *metaDataBase = core()->metaDataBase(); 00227 00228 if (parentLayout == 0) { 00229 widget = containerOfWidget(widget); 00230 } 00231 00232 Q_ASSERT(metaDataBase->item(widget) != 0); // ensure the widget is managed 00233 00234 if (parentLayout == 0 && metaDataBase->item(widget->layout()) == 0) { 00235 parentLayout = widget->layout(); 00236 } 00237 00238 QWidget *parentWidget = parentLayout != 0 ? 0 : widget; 00239 00240 QLayout *layout = 0; 00241 switch (type) { 00242 case LayoutInfo::HBox: 00243 layout = new QHBoxLayout(parentWidget); 00244 break; 00245 case LayoutInfo::VBox: 00246 layout = new QVBoxLayout(parentWidget); 00247 break; 00248 case LayoutInfo::Grid: 00249 layout = new QGridLayout(parentWidget); 00250 break; 00251 case LayoutInfo::Stacked: 00252 layout = new QStackedLayout(parentWidget); 00253 break; 00254 default: 00255 Q_ASSERT(0); 00256 return 0; 00257 } // end switch 00258 00259 metaDataBase->add(layout); // add the layout in the MetaDataBase 00260 00261 if (QLayoutWidget *layoutWidget = qobject_cast<QLayoutWidget*>(widget)) { 00262 layoutWidget->setLayoutMargin(0); 00263 } 00264 00265 if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), layout)) { 00266 sheet->setChanged(sheet->indexOf(QLatin1String("margin")), true); 00267 sheet->setChanged(sheet->indexOf(QLatin1String("spacing")), true); 00268 sheet->setChanged(sheet->indexOf(QLatin1String("alignment")), true); 00269 } 00270 00271 if (widget && metaDataBase->item(widget->layout()) == 0) { 00272 Q_ASSERT(layout->parent() == 0); 00273 QBoxLayout *box = qobject_cast<QBoxLayout*>(widget->layout()); 00274 Q_ASSERT(box != 0); // we support only unmanaged box layouts 00275 box->addLayout(layout); 00276 } 00277 00278 return layout; 00279 }
Here is the call graph for this function:

| bool qdesigner_internal::WidgetFactory::isPassiveInteractor | ( | QWidget * | widget | ) | [virtual] |
Implements QDesignerWidgetFactoryInterface.
Definition at line 392 of file widgetfactory.cpp.
References QApplication::activePopupWidget(), m_lastPassiveInteractor, m_lastWasAPassiveInteractor, and qstrcmp().
00393 { 00394 if (m_lastPassiveInteractor != 0 && (QWidget*)(*m_lastPassiveInteractor) == widget) 00395 return m_lastWasAPassiveInteractor; 00396 00397 m_lastWasAPassiveInteractor = false; 00398 (*m_lastPassiveInteractor) = widget; 00399 00400 if (QApplication::activePopupWidget()) // if a popup is open, we have to make sure that this one is closed, else X might do funny things 00401 return (m_lastWasAPassiveInteractor = true); 00402 else if (widget == 0) 00403 return m_lastWasAPassiveInteractor; 00404 00405 if (qobject_cast<QTabBar*>(widget)) 00406 return (m_lastWasAPassiveInteractor = true); 00407 else if (qobject_cast<QSizeGrip*>(widget)) 00408 return (m_lastWasAPassiveInteractor = true); 00409 else if (qobject_cast<QAbstractButton*>(widget) && (qobject_cast<QTabBar*>(widget->parent()) || qobject_cast<QToolBox*>(widget->parent()))) 00410 return (m_lastWasAPassiveInteractor = true); 00411 else if (qobject_cast<QMenuBar*>(widget)) 00412 return (m_lastWasAPassiveInteractor = true); 00413 else if (qstrcmp(widget->metaObject()->className(), "QDockWidgetTitle") == 0) 00414 return (m_lastWasAPassiveInteractor = true); 00415 else if (qstrcmp(widget->metaObject()->className(), "QToolBarHandle") == 0) 00416 return (m_lastWasAPassiveInteractor = true); 00417 else if (widget->objectName().startsWith(QLatin1String("__qt__passive_"))) 00418 return (m_lastWasAPassiveInteractor = true); 00419 00420 return m_lastWasAPassiveInteractor; 00421 }
Here is the call graph for this function:

| void qdesigner_internal::WidgetFactory::initialize | ( | QObject * | object | ) | const [virtual] |
Implements QDesignerWidgetFactoryInterface.
Definition at line 338 of file widgetfactory.cpp.
References QDesignerFormEditorInterface::extensionManager(), QSize::height(), QDesignerPropertySheetExtension::indexOf(), m_core, Qt::NoFocus, o, object, qobject_cast< QWidget * >(), QDesignerPropertySheetExtension::setChanged(), QDesignerPropertySheetExtension::setVisible(), Qt::StrongFocus, Qt::WA_TintedBackground, Qt::WA_TransparentForMouseEvents, and QSize::width().
Referenced by createWidget().
00339 { 00340 QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_core->extensionManager(), object); 00341 00342 if (object->metaObject()->indexOfProperty("focusPolicy") != -1) 00343 object->setProperty("focusPolicy", Qt::NoFocus); 00344 00345 if (!sheet) 00346 return; 00347 00348 sheet->setChanged(sheet->indexOf(QLatin1String("objectName")), true); 00349 sheet->setChanged(sheet->indexOf(QLatin1String("geometry")), true); 00350 00351 if (qobject_cast<Spacer*>(object)) 00352 sheet->setChanged(sheet->indexOf(QLatin1String("sizeHint")), true); 00353 00354 int o = sheet->indexOf(QLatin1String("orientation")); 00355 if (o != -1) 00356 sheet->setChanged(o, true); 00357 00358 if (QWidget *widget = qobject_cast<QWidget*>(object)) { 00359 QSize sz = widget->sizeHint(); 00360 00361 if (qobject_cast<QFrame*>(object) && sz.width() <= 0 && sz.height() <= 0) 00362 widget->setMinimumSize(QSize(16, 16)); 00363 00364 widget->setAttribute(Qt::WA_TransparentForMouseEvents, false); 00365 00366 if (!(qobject_cast<QDesignerWidget*>(widget) || qobject_cast<QDesignerDialog*>(widget))) 00367 widget->setAttribute(Qt::WA_TintedBackground); 00368 } 00369 00370 if (qobject_cast<QDockWidget*>(object) || qobject_cast<QToolBar*>(object)) { 00371 sheet->setVisible(sheet->indexOf(QLatin1String("windowTitle")), true); 00372 00373 if (qobject_cast<QDockWidget*>(object)) { 00374 sheet->setVisible(sheet->indexOf(QLatin1String("windowIcon")), true); 00375 } 00376 } 00377 00378 if (qobject_cast<QAction*>(object)) { 00379 sheet->setChanged(sheet->indexOf(QLatin1String("text")), true); 00380 } 00381 00382 if (qobject_cast<QMenu*>(object)) { 00383 sheet->setChanged(sheet->indexOf(QLatin1String("geometry")), false); 00384 sheet->setChanged(sheet->indexOf(QLatin1String("title")), true); 00385 } 00386 00387 if (qobject_cast<QMenu*>(object) || qobject_cast<QMenuBar*>(object)) { 00388 qobject_cast<QWidget*>(object)->setFocusPolicy(Qt::StrongFocus); 00389 } 00390 }
Here is the call graph for this function:

| QDesignerFormEditorInterface * qdesigner_internal::WidgetFactory::core | ( | ) | const [virtual] |
Returns the core form editor interface associated with this interface.
Implements QDesignerWidgetFactoryInterface.
Definition at line 333 of file widgetfactory.cpp.
References m_core.
Referenced by containerOfWidget(), createWidget(), and widgetOfContainer().
00334 { 00335 return m_core; 00336 }
| const char * qdesigner_internal::WidgetFactory::classNameOf | ( | QObject * | o | ) | [static] |
Definition at line 187 of file widgetfactory.cpp.
Referenced by qdesigner_internal::WidgetDataBase::indexOfObject(), and qdesigner_internal::QDesignerTaskMenu::promoteToCustomWidget().
00188 { 00189 if (o == 0) 00190 return 0; 00191 00192 if (qobject_cast<QDesignerTabWidget*>(o)) 00193 return "QTabWidget"; 00194 else if (qobject_cast<QDesignerStackedWidget*>(o)) 00195 return "QStackedWidget"; 00196 else if (qobject_cast<QDesignerMenuBar*>(o)) 00197 return "QMenuBar"; 00198 else if (qobject_cast<QDesignerToolBar*>(o)) 00199 return "QToolBar"; 00200 else if (qobject_cast<QDesignerDockWidget*>(o)) 00201 return "QDockWidget"; 00202 else if (qobject_cast<QDesignerToolBox*>(o)) 00203 return "QToolBox"; 00204 else if (qobject_cast<QDesignerDialog*>(o)) 00205 return "QDialog"; 00206 else if (qobject_cast<QDesignerWidget*>(o)) 00207 return "QWidget"; 00208 else if (qobject_cast<QDesignerLabel*>(o)) 00209 return "QLabel"; 00210 else if (qstrcmp(o->metaObject()->className(), "QAxBase") == 0) 00211 return "QAxWidget"; 00212 else if (qstrcmp(o->metaObject()->className(), "QDesignerQ3WidgetStack") == 0) 00213 return "Q3WidgetStack"; 00214 else if (QDesignerPromotedWidget *promoted = qobject_cast<QDesignerPromotedWidget*>(o)) 00215 return promoted->customClassName(); 00216 00217 return o->metaObject()->className(); 00218 }
Here is the call graph for this function:

| QDesignerFormWindowInterface * qdesigner_internal::WidgetFactory::currentFormWindow | ( | QDesignerFormWindowInterface * | fw | ) |
Definition at line 70 of file widgetfactory.cpp.
References m_formWindow.
Referenced by qdesigner_internal::QDesignerResource::create().
00071 { 00072 QDesignerFormWindowInterface *was = m_formWindow; 00073 m_formWindow = fw; 00074 return was; 00075 }
| void qdesigner_internal::WidgetFactory::loadPlugins | ( | ) | [slot] |
Definition at line 77 of file widgetfactory.cpp.
References c, QMap< Key, T >::clear(), QMap< Key, T >::insert(), m_core, m_customFactory, QDesignerFormEditorInterface::pluginManager(), and QDesignerPluginManager::registeredCustomWidgets().
00078 { 00079 m_customFactory.clear(); 00080 00081 QDesignerPluginManager *pluginManager = m_core->pluginManager(); 00082 00083 QList<QDesignerCustomWidgetInterface*> lst = pluginManager->registeredCustomWidgets(); 00084 foreach (QDesignerCustomWidgetInterface *c, lst) { 00085 m_customFactory.insert(c->name(), c); 00086 } 00087 }
Definition at line 83 of file widgetfactory_p.h.
Referenced by core(), createWidget(), initialize(), and loadPlugins().
Definition at line 85 of file widgetfactory_p.h.
Referenced by createWidget(), and currentFormWindow().
QPointer< QWidget > * qdesigner_internal::WidgetFactory::m_lastPassiveInteractor [static, private] |
bool qdesigner_internal::WidgetFactory::m_lastWasAPassiveInteractor [static, private] |
1.5.1