qdesigner_internal::WidgetDataBase Class Reference

#include <widgetdatabase_p.h>

Inheritance diagram for qdesigner_internal::WidgetDataBase:

Inheritance graph
[legend]
Collaboration diagram for qdesigner_internal::WidgetDataBase:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 114 of file widgetdatabase_p.h.

Public Slots

void loadPlugins ()

Public Member Functions

 WidgetDataBase (QDesignerFormEditorInterface *core, QObject *parent=0)
virtual ~WidgetDataBase ()
virtual QDesignerFormEditorInterfacecore () const
virtual QDesignerWidgetDataBaseItemInterfaceitem (int index) const
virtual int indexOfObject (QObject *o, bool resolveName=true) const
void grabDefaultPropertyValues ()

Private Member Functions

QList< QVariantdefaultPropertyValues (const QString &name)
WidgetDataBaseItemcreateCustomWidgetItem (QDesignerCustomWidgetInterface *customWidget) const

Private Attributes

QDesignerFormEditorInterfacem_core


Constructor & Destructor Documentation

qdesigner_internal::WidgetDataBase::WidgetDataBase ( QDesignerFormEditorInterface core,
QObject parent = 0 
)

Definition at line 183 of file widgetdatabase.cpp.

References QDesignerWidgetDataBaseInterface::append(), QString::fromUtf8(), QDesignerWidgetDataBaseInterface::indexOfClassName(), and item().

00184     : QDesignerWidgetDataBaseInterface(parent),
00185       m_core(core)
00186 {
00187 #define DECLARE_LAYOUT(L, C)
00188 #define DECLARE_COMPAT_WIDGET(W, C) DECLARE_WIDGET(W, C)
00189 #define DECLARE_WIDGET(W, C) append(new WidgetDataBaseItem(QString::fromUtf8(#W)));
00190 
00191 #include "widgets.table"
00192 
00193 #undef DECLARE_COMPAT_WIDGET
00194 #undef DECLARE_LAYOUT
00195 #undef DECLARE_WIDGET
00196 #undef DECLARE_WIDGET_1
00197 
00198     append(new WidgetDataBaseItem(QString::fromUtf8("Line")));
00199     append(new WidgetDataBaseItem(QString::fromUtf8("Spacer")));
00200     append(new WidgetDataBaseItem(QString::fromUtf8("QSplitter")));
00201     append(new WidgetDataBaseItem(QString::fromUtf8("QLayoutWidget")));
00202     append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerWidget")));
00203     append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerDialog")));
00204     append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerToolBar")));
00205     append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerMenu")));
00206     append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerMenuBar")));
00207     append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerDockWidget")));
00208     append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerQ3WidgetStack")));
00209     append(new WidgetDataBaseItem(QString::fromUtf8("QAction")));
00210 
00211     // ### remove me
00212     // ### check the casts
00213 
00214 #if 0 // ### enable me after 4.1
00215     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QToolBar"))))->setContainer(true);
00216     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QDesignerToolBar"))))->setContainer(true);
00217 #endif
00218 
00219     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QTabWidget"))))->setContainer(true);
00220     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QGroupBox"))))->setContainer(true);
00221     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QStackedWidget"))))->setContainer(true);
00222     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QToolBox"))))->setContainer(true);
00223     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QFrame"))))->setContainer(true);
00224     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QLayoutWidget"))))->setContainer(true);
00225     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QDesignerWidget"))))->setContainer(true);
00226     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QDesignerDialog"))))->setContainer(true);
00227     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QSplitter"))))->setContainer(true);
00228     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QMainWindow"))))->setContainer(true);
00229     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QDockWidget"))))->setContainer(true);
00230     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QDesignerDockWidget"))))->setContainer(true);
00231     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QDesignerQ3WidgetStack"))))->setContainer(true);
00232 
00233     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QWidget"))))->setContainer(true);
00234     static_cast<WidgetDataBaseItem *>(item(indexOfClassName(QLatin1String("QDialog"))))->setContainer(true);
00235 }

Here is the call graph for this function:

qdesigner_internal::WidgetDataBase::~WidgetDataBase (  )  [virtual]

Definition at line 237 of file widgetdatabase.cpp.

00238 {
00239 }


Member Function Documentation

QDesignerFormEditorInterface * qdesigner_internal::WidgetDataBase::core (  )  const [virtual]

Reimplemented from QDesignerWidgetDataBaseInterface.

Definition at line 241 of file widgetdatabase.cpp.

References m_core.

00242 {
00243     return m_core;
00244 }

QDesignerWidgetDataBaseItemInterface * qdesigner_internal::WidgetDataBase::item ( int  index  )  const [virtual]

Reimplemented from QDesignerWidgetDataBaseInterface.

Definition at line 262 of file widgetdatabase.cpp.

References QDesignerWidgetDataBaseInterface::item().

Referenced by createCustomWidgetItem(), grabDefaultPropertyValues(), loadPlugins(), and WidgetDataBase().

00263 {
00264     return QDesignerWidgetDataBaseInterface::item(index);
00265 }

Here is the call graph for this function:

int qdesigner_internal::WidgetDataBase::indexOfObject ( QObject o,
bool  resolveName = true 
) const [virtual]

Reimplemented from QDesignerWidgetDataBaseInterface.

Definition at line 246 of file widgetdatabase.cpp.

References QDesignerLanguageExtension::classNameOf(), qdesigner_internal::WidgetFactory::classNameOf(), QDesignerFormEditorInterface::extensionManager(), QString::fromUtf8(), id, QDesignerWidgetDataBaseInterface::indexOfClassName(), isEmpty(), m_core, and object.

00247 {
00248     QExtensionManager *mgr = m_core->extensionManager();
00249     QDesignerLanguageExtension *lang = qt_extension<QDesignerLanguageExtension*> (mgr, m_core);
00250 
00251     QString id;
00252 
00253     if (lang)
00254         id = lang->classNameOf(object);
00255 
00256     if (id.isEmpty())
00257         id = QString::fromUtf8 (WidgetFactory::classNameOf(object));
00258 
00259     return QDesignerWidgetDataBaseInterface::indexOfClassName(id);
00260 }

Here is the call graph for this function:

void qdesigner_internal::WidgetDataBase::grabDefaultPropertyValues (  ) 

Definition at line 342 of file widgetdatabase.cpp.

References QDesignerWidgetDataBaseInterface::count(), defaultPropertyValues(), i, item(), QDesignerWidgetDataBaseItemInterface::name(), and QDesignerWidgetDataBaseItemInterface::setDefaultPropertyValues().

00343 {
00344     for (int i = 0; i < count(); ++i) {
00345         QDesignerWidgetDataBaseItemInterface *item = this->item(i);
00346         QList<QVariant> default_prop_values = defaultPropertyValues(item->name());
00347         item->setDefaultPropertyValues(default_prop_values);
00348 
00349     }
00350 }

Here is the call graph for this function:

void qdesigner_internal::WidgetDataBase::loadPlugins (  )  [slot]

Definition at line 267 of file widgetdatabase.cpp.

References QDesignerWidgetDataBaseInterface::append(), c, createCustomWidgetItem(), QDesignerPluginManager::ensureInitialized(), QDesignerPluginManager::instance(), QDesignerWidgetDataBaseItemInterface::isCustom(), item(), m_core, QDesignerWidgetDataBaseInterface::m_items, o, QDesignerFormEditorInterface::pluginManager(), QDesignerPluginManager::registeredPlugins(), and QDesignerWidgetDataBaseItemInterface::setPluginPath().

00268 {
00269     QDesignerPluginManager *pluginManager = m_core->pluginManager();
00270 
00271     QStringList plugins = pluginManager->registeredPlugins();
00272 
00273     QMutableListIterator<QDesignerWidgetDataBaseItemInterface *> it(m_items);
00274     while (it.hasNext()) {
00275         QDesignerWidgetDataBaseItemInterface *item = it.next();
00276 
00277         if (item->isCustom()) {
00278             it.remove();
00279             delete item;
00280         }
00281     }
00282 
00283     pluginManager->ensureInitialized();
00284 
00285     foreach (QString plugin, plugins) {
00286         QObject *o = pluginManager->instance(plugin);
00287 
00288         if (QDesignerCustomWidgetInterface *c = qobject_cast<QDesignerCustomWidgetInterface*>(o)) {
00289             WidgetDataBaseItem *item = createCustomWidgetItem(c);
00290             item->setPluginPath(plugin);
00291             append(item);
00292         } else if (QDesignerCustomWidgetCollectionInterface *coll = qobject_cast<QDesignerCustomWidgetCollectionInterface*>(o)) {
00293             foreach (QDesignerCustomWidgetInterface *c, coll->customWidgets()) {
00294                 WidgetDataBaseItem *item = createCustomWidgetItem(c);
00295                 item->setPluginPath(plugin);
00296                 append(item);
00297             }
00298         }
00299     }
00300 }

QList< QVariant > qdesigner_internal::WidgetDataBase::defaultPropertyValues ( const QString name  )  [private]

Definition at line 317 of file widgetdatabase.cpp.

References QList< T >::append(), QDesignerPropertySheetExtension::count(), qdesigner_internal::WidgetFactory::createWidget(), QDesignerFormEditorInterface::extensionManager(), i, m_core, name, QDesignerPropertySheetExtension::property(), and w.

Referenced by grabDefaultPropertyValues().

00318 {
00319     QList<QVariant> result;
00320 
00321     WidgetFactory factory(m_core);
00322     QWidget *w = factory.createWidget(name, 0);
00323     if (w == 0) {
00324         return result;
00325     }
00326 
00327     QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_core->extensionManager(), w);
00328     if (sheet == 0) {
00329         delete w;
00330         return result;
00331     }
00332 
00333     for (int i = 0; i < sheet->count(); ++i) {
00334         result.append(sheet->property(i));
00335     }
00336 
00337     delete w;
00338 
00339     return result;
00340 }

Here is the call graph for this function:

WidgetDataBaseItem * qdesigner_internal::WidgetDataBase::createCustomWidgetItem ( QDesignerCustomWidgetInterface customWidget  )  const [private]

Definition at line 302 of file widgetdatabase.cpp.

References c, item(), QDesignerWidgetDataBaseItemInterface::setContainer(), QDesignerWidgetDataBaseItemInterface::setCustom(), QDesignerWidgetDataBaseItemInterface::setGroup(), QDesignerWidgetDataBaseItemInterface::setIcon(), QDesignerWidgetDataBaseItemInterface::setIncludeFile(), QDesignerWidgetDataBaseItemInterface::setName(), QDesignerWidgetDataBaseItemInterface::setToolTip(), and QDesignerWidgetDataBaseItemInterface::setWhatsThis().

Referenced by loadPlugins().

00303 {
00304     WidgetDataBaseItem *item = new WidgetDataBaseItem();
00305     item->setContainer(c->isContainer());
00306     item->setCustom(true);
00307     item->setGroup(c->group());
00308     item->setIcon(c->icon());
00309     item->setIncludeFile(c->includeFile());
00310     item->setName(c->name());
00311     item->setToolTip(c->toolTip());
00312     item->setWhatsThis(c->whatsThis());
00313 
00314     return item;
00315 }

Here is the call graph for this function:


Member Data Documentation

QDesignerFormEditorInterface* qdesigner_internal::WidgetDataBase::m_core [private]

Definition at line 135 of file widgetdatabase_p.h.

Referenced by core(), defaultPropertyValues(), indexOfObject(), and loadPlugins().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 20:50:08 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1