| 1 | /********************************************************************** | 
|---|
| 2 | ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved. | 
|---|
| 3 | ** | 
|---|
| 4 | ** This file is part of Qt Designer. | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file may be distributed and/or modified under the terms of the | 
|---|
| 7 | ** GNU General Public License version 2 as published by the Free Software | 
|---|
| 8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 9 | ** packaging of this file. | 
|---|
| 10 | ** | 
|---|
| 11 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 
|---|
| 12 | ** licenses may use this file in accordance with the Qt Commercial License | 
|---|
| 13 | ** Agreement provided with the Software. | 
|---|
| 14 | ** | 
|---|
| 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 
|---|
| 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 
|---|
| 17 | ** | 
|---|
| 18 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 
|---|
| 19 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 
|---|
| 20 | **   information about Qt Commercial License Agreements. | 
|---|
| 21 | ** | 
|---|
| 22 | ** Contact info@trolltech.com if any conditions of this licensing are | 
|---|
| 23 | ** not clear to you. | 
|---|
| 24 | ** | 
|---|
| 25 | **********************************************************************/ | 
|---|
| 26 |  | 
|---|
| 27 | #include "widgetdatabase.h" | 
|---|
| 28 | #include "../interfaces/widgetinterface.h" | 
|---|
| 29 |  | 
|---|
| 30 | #include <qapplication.h> | 
|---|
| 31 | #define NO_STATIC_COLORS | 
|---|
| 32 | #include <globaldefs.h> | 
|---|
| 33 | #include <qstrlist.h> | 
|---|
| 34 | #include <qdict.h> | 
|---|
| 35 | #include <qfile.h> | 
|---|
| 36 | #include <qtextstream.h> | 
|---|
| 37 | #include <qcleanuphandler.h> | 
|---|
| 38 | #include <qfeatures.h> | 
|---|
| 39 |  | 
|---|
| 40 | #include <stdlib.h> | 
|---|
| 41 |  | 
|---|
| 42 | const int dbsize = 300; | 
|---|
| 43 | const int dbcustom = 200; | 
|---|
| 44 | const int dbdictsize = 211; | 
|---|
| 45 | static WidgetDatabaseRecord* db[ dbsize ]; | 
|---|
| 46 | static QDict<int> *className2Id = 0; | 
|---|
| 47 | static int dbcount  = 0; | 
|---|
| 48 | static int dbcustomcount = 200; | 
|---|
| 49 | static QStrList *wGroups; | 
|---|
| 50 | static QStrList *invisibleGroups; | 
|---|
| 51 | static bool whatsThisLoaded = FALSE; | 
|---|
| 52 | static QPluginManager<WidgetInterface> *widgetPluginManager = 0; | 
|---|
| 53 | static bool plugins_set_up = FALSE; | 
|---|
| 54 | static bool was_in_setup = FALSE; | 
|---|
| 55 |  | 
|---|
| 56 | QCleanupHandler<QPluginManager<WidgetInterface> > cleanup_manager; | 
|---|
| 57 |  | 
|---|
| 58 | WidgetDatabaseRecord::WidgetDatabaseRecord() | 
|---|
| 59 | { | 
|---|
| 60 | isForm = FALSE; | 
|---|
| 61 | isContainer = FALSE; | 
|---|
| 62 | icon = 0; | 
|---|
| 63 | nameCounter = 0; | 
|---|
| 64 | isCommon = FALSE; | 
|---|
| 65 | isPlugin = FALSE; | 
|---|
| 66 | } | 
|---|
| 67 |  | 
|---|
| 68 | WidgetDatabaseRecord::~WidgetDatabaseRecord() | 
|---|
| 69 | { | 
|---|
| 70 | delete icon; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 |  | 
|---|
| 74 | /*! | 
|---|
| 75 | \class WidgetDatabase widgetdatabase.h | 
|---|
| 76 | \brief The WidgetDatabase class holds information about widgets | 
|---|
| 77 |  | 
|---|
| 78 | The WidgetDatabase holds information about widgets like toolTip(), | 
|---|
| 79 | iconSet(), ... It works Id-based, so all access functions take the | 
|---|
| 80 | widget id as parameter. To get the id for a widget (classname), use | 
|---|
| 81 | idFromClassName(). | 
|---|
| 82 |  | 
|---|
| 83 | All access functions are static.  Having multiple widgetdatabases in | 
|---|
| 84 | one application doesn't make sense anyway and so you don't need more | 
|---|
| 85 | than an instance of the widgetdatabase. | 
|---|
| 86 |  | 
|---|
| 87 | For creating widgets, layouts, etc. see WidgetFactory. | 
|---|
| 88 | */ | 
|---|
| 89 |  | 
|---|
| 90 | /*! | 
|---|
| 91 | Creates widget database. Does nothing. | 
|---|
| 92 | */ | 
|---|
| 93 |  | 
|---|
| 94 | WidgetDatabase::WidgetDatabase() | 
|---|
| 95 | { | 
|---|
| 96 | } | 
|---|
| 97 |  | 
|---|
| 98 | /*!  Sets up the widget database. If the static widgetdatabase already | 
|---|
| 99 | exists, the functions returns immediately. | 
|---|
| 100 | */ | 
|---|
| 101 |  | 
|---|
| 102 | void WidgetDatabase::setupDataBase( int id ) | 
|---|
| 103 | { | 
|---|
| 104 | was_in_setup = TRUE; | 
|---|
| 105 | #ifndef UIC | 
|---|
| 106 | Q_UNUSED( id ) | 
|---|
| 107 | if ( dbcount ) | 
|---|
| 108 | return; | 
|---|
| 109 | #else | 
|---|
| 110 | if ( dbcount && id != -2 ) | 
|---|
| 111 | return; | 
|---|
| 112 | if ( dbcount && !plugins_set_up ) { | 
|---|
| 113 | setupPlugins(); | 
|---|
| 114 | return; | 
|---|
| 115 | } | 
|---|
| 116 | if ( dbcount && plugins_set_up) | 
|---|
| 117 | return; | 
|---|
| 118 | #endif | 
|---|
| 119 |  | 
|---|
| 120 | wGroups = new QStrList; | 
|---|
| 121 | invisibleGroups = new QStrList; | 
|---|
| 122 | invisibleGroups->append( "Forms" ); | 
|---|
| 123 | invisibleGroups->append( "Temp" ); | 
|---|
| 124 | className2Id = new QDict<int>( dbdictsize ); | 
|---|
| 125 | className2Id->setAutoDelete( TRUE ); | 
|---|
| 126 |  | 
|---|
| 127 | WidgetDatabaseRecord *r = 0; | 
|---|
| 128 |  | 
|---|
| 129 | r = new WidgetDatabaseRecord; | 
|---|
| 130 | r->iconSet = "designer_pushbutton.png"; | 
|---|
| 131 | r->name = "QPushButton"; | 
|---|
| 132 | r->group = widgetGroup( "Buttons" ); | 
|---|
| 133 | r->toolTip = "Push Button"; | 
|---|
| 134 | r->isCommon = TRUE; | 
|---|
| 135 |  | 
|---|
| 136 | append( r ); | 
|---|
| 137 |  | 
|---|
| 138 | r = new WidgetDatabaseRecord; | 
|---|
| 139 | r->iconSet = "designer_toolbutton.png"; | 
|---|
| 140 | r->name = "QToolButton"; | 
|---|
| 141 | r->group = widgetGroup( "Buttons" ); | 
|---|
| 142 | r->toolTip = "Tool Button"; | 
|---|
| 143 |  | 
|---|
| 144 | append( r ); | 
|---|
| 145 |  | 
|---|
| 146 | r = new WidgetDatabaseRecord; | 
|---|
| 147 | r->iconSet = "designer_radiobutton.png"; | 
|---|
| 148 | r->name = "QRadioButton"; | 
|---|
| 149 | r->group = widgetGroup( "Buttons" ); | 
|---|
| 150 | r->toolTip = "Radio Button"; | 
|---|
| 151 | r->isCommon = TRUE; | 
|---|
| 152 |  | 
|---|
| 153 | append( r ); | 
|---|
| 154 |  | 
|---|
| 155 | r = new WidgetDatabaseRecord; | 
|---|
| 156 | r->iconSet = "designer_checkbox.png"; | 
|---|
| 157 | r->name = "QCheckBox"; | 
|---|
| 158 | r->group = widgetGroup( "Buttons" ); | 
|---|
| 159 | r->toolTip = "Check Box"; | 
|---|
| 160 | r->isCommon = TRUE; | 
|---|
| 161 |  | 
|---|
| 162 | append( r ); | 
|---|
| 163 |  | 
|---|
| 164 | r = new WidgetDatabaseRecord; | 
|---|
| 165 | r->iconSet = "designer_groupbox.png"; | 
|---|
| 166 | r->name = "QGroupBox"; | 
|---|
| 167 | r->group = widgetGroup( "Containers" ); | 
|---|
| 168 | r->toolTip = "Group Box"; | 
|---|
| 169 | r->isContainer = TRUE; | 
|---|
| 170 |  | 
|---|
| 171 | append( r ); | 
|---|
| 172 |  | 
|---|
| 173 | r = new WidgetDatabaseRecord; | 
|---|
| 174 | r->iconSet = "designer_buttongroup.png"; | 
|---|
| 175 | r->name = "QButtonGroup"; | 
|---|
| 176 | r->group = widgetGroup( "Containers" ); | 
|---|
| 177 | r->toolTip = "Button Group"; | 
|---|
| 178 | r->isContainer = TRUE; | 
|---|
| 179 | r->isCommon = TRUE; | 
|---|
| 180 |  | 
|---|
| 181 | append( r ); | 
|---|
| 182 |  | 
|---|
| 183 | r = new WidgetDatabaseRecord; | 
|---|
| 184 | r->iconSet = "designer_frame.png"; | 
|---|
| 185 | r->name = "QFrame"; | 
|---|
| 186 | r->group = widgetGroup( "Containers" ); | 
|---|
| 187 | r->toolTip = "Frame"; | 
|---|
| 188 | r->isContainer = TRUE; | 
|---|
| 189 |  | 
|---|
| 190 | append( r ); | 
|---|
| 191 |  | 
|---|
| 192 | r = new WidgetDatabaseRecord; | 
|---|
| 193 | r->iconSet = "designer_tabwidget.png"; | 
|---|
| 194 | r->name = "QTabWidget"; | 
|---|
| 195 | r->group = widgetGroup( "Containers" ); | 
|---|
| 196 | r->toolTip = "Tabwidget"; | 
|---|
| 197 | r->isContainer = TRUE; | 
|---|
| 198 |  | 
|---|
| 199 | append( r ); | 
|---|
| 200 |  | 
|---|
| 201 | r = new WidgetDatabaseRecord; | 
|---|
| 202 | r->iconSet = "designer_widgetstack.png"; | 
|---|
| 203 | r->name = "QWidgetStack"; | 
|---|
| 204 | r->group = widgetGroup( "Containers" ); | 
|---|
| 205 | r->toolTip = "Widget Stack"; | 
|---|
| 206 | r->isContainer = TRUE; | 
|---|
| 207 |  | 
|---|
| 208 | append( r ); | 
|---|
| 209 |  | 
|---|
| 210 | r = new WidgetDatabaseRecord; | 
|---|
| 211 | r->iconSet = "designer_toolbox.png"; | 
|---|
| 212 | r->name = "QToolBox"; | 
|---|
| 213 | r->group = widgetGroup( "Containers" ); | 
|---|
| 214 | r->toolTip = "Tool Box"; | 
|---|
| 215 | r->isContainer = TRUE; | 
|---|
| 216 |  | 
|---|
| 217 | append( r ); | 
|---|
| 218 |  | 
|---|
| 219 | r = new WidgetDatabaseRecord; | 
|---|
| 220 | r->iconSet = "designer_listbox.png"; | 
|---|
| 221 | r->name = "QListBox"; | 
|---|
| 222 | r->group = widgetGroup( "Views" ); | 
|---|
| 223 | r->toolTip = "List Box"; | 
|---|
| 224 | r->isCommon = TRUE; | 
|---|
| 225 |  | 
|---|
| 226 | append( r ); | 
|---|
| 227 |  | 
|---|
| 228 | r = new WidgetDatabaseRecord; | 
|---|
| 229 | r->iconSet = "designer_listview.png"; | 
|---|
| 230 | r->name = "QListView"; | 
|---|
| 231 | r->group = widgetGroup( "Views" ); | 
|---|
| 232 | r->toolTip = "List View"; | 
|---|
| 233 |  | 
|---|
| 234 | append( r ); | 
|---|
| 235 |  | 
|---|
| 236 | #if !defined(QT_NO_ICONVIEW) || defined(UIC) | 
|---|
| 237 | r = new WidgetDatabaseRecord; | 
|---|
| 238 | r->iconSet = "designer_iconview.png"; | 
|---|
| 239 | r->name = "QIconView"; | 
|---|
| 240 | r->group = widgetGroup( "Views" ); | 
|---|
| 241 | r->toolTip = "Icon View"; | 
|---|
| 242 |  | 
|---|
| 243 | append( r ); | 
|---|
| 244 | #endif | 
|---|
| 245 |  | 
|---|
| 246 | #if !defined(QT_NO_TABLE) | 
|---|
| 247 | r = new WidgetDatabaseRecord; | 
|---|
| 248 | r->iconSet = "designer_table.png"; | 
|---|
| 249 | r->name = "QTable"; | 
|---|
| 250 | r->group = widgetGroup( "Views" ); | 
|---|
| 251 | r->toolTip = "Table"; | 
|---|
| 252 |  | 
|---|
| 253 | append( r ); | 
|---|
| 254 | #endif | 
|---|
| 255 |  | 
|---|
| 256 | #if !defined(QT_NO_SQL) | 
|---|
| 257 | r = new WidgetDatabaseRecord; | 
|---|
| 258 | r->iconSet = "designer_datatable.png"; | 
|---|
| 259 | r->includeFile = "qdatatable.h"; | 
|---|
| 260 | r->name = "QDataTable"; | 
|---|
| 261 | r->group = widgetGroup( "Database" ); | 
|---|
| 262 | r->toolTip = "Data Table"; | 
|---|
| 263 |  | 
|---|
| 264 | append( r ); | 
|---|
| 265 | #endif | 
|---|
| 266 |  | 
|---|
| 267 | r = new WidgetDatabaseRecord; | 
|---|
| 268 | r->iconSet = "designer_lineedit.png"; | 
|---|
| 269 | r->name = "QLineEdit"; | 
|---|
| 270 | r->group = widgetGroup( "Input" ); | 
|---|
| 271 | r->toolTip = "Line Edit"; | 
|---|
| 272 | r->isCommon = TRUE; | 
|---|
| 273 |  | 
|---|
| 274 | append( r ); | 
|---|
| 275 |  | 
|---|
| 276 | r = new WidgetDatabaseRecord; | 
|---|
| 277 | r->iconSet = "designer_spinbox.png"; | 
|---|
| 278 | r->name = "QSpinBox"; | 
|---|
| 279 | r->group = widgetGroup( "Input" ); | 
|---|
| 280 | r->toolTip = "Spin Box"; | 
|---|
| 281 | r->isCommon = TRUE; | 
|---|
| 282 |  | 
|---|
| 283 | append( r ); | 
|---|
| 284 |  | 
|---|
| 285 | r = new WidgetDatabaseRecord; | 
|---|
| 286 | r->iconSet = "designer_dateedit.png"; | 
|---|
| 287 | r->name = "QDateEdit"; | 
|---|
| 288 | r->group = widgetGroup( "Input" ); | 
|---|
| 289 | r->toolTip = "Date Edit"; | 
|---|
| 290 | r->includeFile = "qdatetimeedit.h"; | 
|---|
| 291 |  | 
|---|
| 292 | append( r ); | 
|---|
| 293 |  | 
|---|
| 294 | r = new WidgetDatabaseRecord; | 
|---|
| 295 | r->iconSet = "designer_timeedit.png"; | 
|---|
| 296 | r->name = "QTimeEdit"; | 
|---|
| 297 | r->group = widgetGroup( "Input" ); | 
|---|
| 298 | r->toolTip = "Time Edit"; | 
|---|
| 299 | r->includeFile = "qdatetimeedit.h"; | 
|---|
| 300 |  | 
|---|
| 301 | append( r ); | 
|---|
| 302 |  | 
|---|
| 303 | r = new WidgetDatabaseRecord; | 
|---|
| 304 | r->iconSet = "designer_datetimeedit.png"; | 
|---|
| 305 | r->name = "QDateTimeEdit"; | 
|---|
| 306 | r->group = widgetGroup( "Input" ); | 
|---|
| 307 | r->toolTip = "Date-Time Edit"; | 
|---|
| 308 | r->includeFile = "qdatetimeedit.h"; | 
|---|
| 309 |  | 
|---|
| 310 | append( r ); | 
|---|
| 311 |  | 
|---|
| 312 | r = new WidgetDatabaseRecord; | 
|---|
| 313 | r->iconSet = "designer_multilineedit.png"; | 
|---|
| 314 | r->name = "QMultiLineEdit"; | 
|---|
| 315 | r->group = widgetGroup( "Temp" ); | 
|---|
| 316 | r->toolTip = "Multi Line Edit"; | 
|---|
| 317 |  | 
|---|
| 318 | append( r ); | 
|---|
| 319 |  | 
|---|
| 320 | r = new WidgetDatabaseRecord; | 
|---|
| 321 | r->iconSet = "designer_richtextedit.png"; | 
|---|
| 322 | r->name = "QTextEdit"; | 
|---|
| 323 | r->group = widgetGroup( "Input" ); | 
|---|
| 324 | r->toolTip = "Rich Text Edit"; | 
|---|
| 325 | r->isCommon = TRUE; | 
|---|
| 326 |  | 
|---|
| 327 | append( r ); | 
|---|
| 328 |  | 
|---|
| 329 | r = new WidgetDatabaseRecord; | 
|---|
| 330 | r->iconSet = "designer_combobox.png"; | 
|---|
| 331 | r->name = "QComboBox"; | 
|---|
| 332 | r->group = widgetGroup( "Input" ); | 
|---|
| 333 | r->toolTip = "Combo Box"; | 
|---|
| 334 | r->isCommon = TRUE; | 
|---|
| 335 |  | 
|---|
| 336 | append( r ); | 
|---|
| 337 |  | 
|---|
| 338 | r = new WidgetDatabaseRecord; | 
|---|
| 339 | r->iconSet = "designer_slider.png"; | 
|---|
| 340 | r->name = "QSlider"; | 
|---|
| 341 | r->group = widgetGroup( "Input" ); | 
|---|
| 342 | r->toolTip = "Slider"; | 
|---|
| 343 |  | 
|---|
| 344 | append( r ); | 
|---|
| 345 |  | 
|---|
| 346 | r = new WidgetDatabaseRecord; | 
|---|
| 347 | r->iconSet = "designer_scrollbar.png"; | 
|---|
| 348 | r->name = "QScrollBar"; | 
|---|
| 349 | r->group = widgetGroup( "Input" ); | 
|---|
| 350 | r->toolTip = "Scrollbar"; | 
|---|
| 351 |  | 
|---|
| 352 | append( r ); | 
|---|
| 353 |  | 
|---|
| 354 | r = new WidgetDatabaseRecord; | 
|---|
| 355 | r->iconSet = "designer_dial.png"; | 
|---|
| 356 | r->name = "QDial"; | 
|---|
| 357 | r->group = widgetGroup( "Input" ); | 
|---|
| 358 | r->toolTip = "Dial"; | 
|---|
| 359 |  | 
|---|
| 360 | append( r ); | 
|---|
| 361 |  | 
|---|
| 362 | r = new WidgetDatabaseRecord; | 
|---|
| 363 | r->iconSet = "designer_label.png"; | 
|---|
| 364 | r->name = "QLabel"; | 
|---|
| 365 | r->group = widgetGroup( "Temp" ); | 
|---|
| 366 | r->toolTip = "Label"; | 
|---|
| 367 |  | 
|---|
| 368 | append( r ); | 
|---|
| 369 |  | 
|---|
| 370 | r = new WidgetDatabaseRecord; | 
|---|
| 371 | r->iconSet = "designer_label.png"; | 
|---|
| 372 | r->name = "TextLabel"; | 
|---|
| 373 | r->group = widgetGroup( "Display" ); | 
|---|
| 374 | r->toolTip = "Text Label"; | 
|---|
| 375 | r->whatsThis = "The Text Label provides a widget to display static text."; | 
|---|
| 376 | r->isCommon = TRUE; | 
|---|
| 377 |  | 
|---|
| 378 | append( r ); | 
|---|
| 379 |  | 
|---|
| 380 | r = new WidgetDatabaseRecord; | 
|---|
| 381 | r->iconSet = "designer_pixlabel.png"; | 
|---|
| 382 | r->name = "PixmapLabel"; | 
|---|
| 383 | r->group = widgetGroup( "Display" ); | 
|---|
| 384 | r->toolTip = "Pixmap Label"; | 
|---|
| 385 | r->whatsThis = "The Pixmap Label provides a widget to display pixmaps."; | 
|---|
| 386 |  | 
|---|
| 387 | append( r ); | 
|---|
| 388 |  | 
|---|
| 389 | r = new WidgetDatabaseRecord; | 
|---|
| 390 | r->iconSet = "designer_lcdnumber.png"; | 
|---|
| 391 | r->name = "QLCDNumber"; | 
|---|
| 392 | r->group = widgetGroup( "Display" ); | 
|---|
| 393 | r->toolTip = "LCD Number"; | 
|---|
| 394 |  | 
|---|
| 395 | append( r ); | 
|---|
| 396 |  | 
|---|
| 397 | r = new WidgetDatabaseRecord; | 
|---|
| 398 | r->iconSet = "designer_line.png"; | 
|---|
| 399 | r->name = "Line"; | 
|---|
| 400 | r->group = widgetGroup( "Display" ); | 
|---|
| 401 | r->toolTip = "Line"; | 
|---|
| 402 | r->includeFile = "qframe.h"; | 
|---|
| 403 | r->whatsThis = "The Line widget provides horizontal and vertical lines."; | 
|---|
| 404 |  | 
|---|
| 405 | append( r ); | 
|---|
| 406 |  | 
|---|
| 407 | r = new WidgetDatabaseRecord; | 
|---|
| 408 | r->iconSet = "designer_progress.png"; | 
|---|
| 409 | r->name = "QProgressBar"; | 
|---|
| 410 | r->group = widgetGroup( "Display" ); | 
|---|
| 411 | r->toolTip = "Progress Bar"; | 
|---|
| 412 |  | 
|---|
| 413 | append( r ); | 
|---|
| 414 |  | 
|---|
| 415 | r = new WidgetDatabaseRecord; | 
|---|
| 416 | r->iconSet = "designer_textview.png"; | 
|---|
| 417 | r->name = "QTextView"; | 
|---|
| 418 | r->group = widgetGroup( "Temp" ); | 
|---|
| 419 | r->toolTip = "Text View"; | 
|---|
| 420 |  | 
|---|
| 421 | append( r ); | 
|---|
| 422 |  | 
|---|
| 423 | r = new WidgetDatabaseRecord; | 
|---|
| 424 | r->iconSet = "designer_textbrowser.png"; | 
|---|
| 425 | r->name = "QTextBrowser"; | 
|---|
| 426 | r->group = widgetGroup( "Display" ); | 
|---|
| 427 | r->toolTip = "Text Browser"; | 
|---|
| 428 |  | 
|---|
| 429 | append( r ); | 
|---|
| 430 |  | 
|---|
| 431 | r = new WidgetDatabaseRecord; | 
|---|
| 432 | r->iconSet = "designer_spacer.png"; | 
|---|
| 433 | r->name = "Spacer"; | 
|---|
| 434 | r->group = widgetGroup( "Temp" ); | 
|---|
| 435 | r->toolTip = "Spacer"; | 
|---|
| 436 | r->whatsThis = "The Spacer provides horizontal and vertical spacing to be able to manipulate the behaviour of layouts."; | 
|---|
| 437 |  | 
|---|
| 438 | append( r ); | 
|---|
| 439 |  | 
|---|
| 440 | r = new WidgetDatabaseRecord; | 
|---|
| 441 | r->name = "QWidget"; | 
|---|
| 442 | r->isForm = TRUE; | 
|---|
| 443 | r->group = widgetGroup( "Forms" ); | 
|---|
| 444 |  | 
|---|
| 445 | append( r ); | 
|---|
| 446 |  | 
|---|
| 447 | r = new WidgetDatabaseRecord; | 
|---|
| 448 | r->name = "QDialog"; | 
|---|
| 449 | r->group = widgetGroup( "Forms" ); | 
|---|
| 450 | r->isForm = TRUE; | 
|---|
| 451 |  | 
|---|
| 452 | append( r ); | 
|---|
| 453 |  | 
|---|
| 454 | r = new WidgetDatabaseRecord; | 
|---|
| 455 | r->name = "QWizard"; | 
|---|
| 456 | r->group = widgetGroup( "Forms" ); | 
|---|
| 457 | r->isContainer = TRUE; | 
|---|
| 458 |  | 
|---|
| 459 | append( r ); | 
|---|
| 460 |  | 
|---|
| 461 | r = new WidgetDatabaseRecord; | 
|---|
| 462 | r->name = "QDesignerWizard"; | 
|---|
| 463 | r->group = widgetGroup( "Forms" ); | 
|---|
| 464 | r->isContainer = TRUE; | 
|---|
| 465 |  | 
|---|
| 466 | append( r ); | 
|---|
| 467 |  | 
|---|
| 468 | r = new WidgetDatabaseRecord; | 
|---|
| 469 | r->name = "QLayoutWidget"; | 
|---|
| 470 | r->group = widgetGroup( "Temp" ); | 
|---|
| 471 | r->includeFile = ""; | 
|---|
| 472 | r->isContainer = TRUE; | 
|---|
| 473 |  | 
|---|
| 474 | append( r ); | 
|---|
| 475 |  | 
|---|
| 476 | r = new WidgetDatabaseRecord; | 
|---|
| 477 | r->name = "QSplitter"; | 
|---|
| 478 | r->group = widgetGroup( "Temp" ); | 
|---|
| 479 | r->includeFile = "qsplitter.h"; | 
|---|
| 480 | r->isContainer = TRUE; | 
|---|
| 481 |  | 
|---|
| 482 | append( r ); | 
|---|
| 483 |  | 
|---|
| 484 | r = new WidgetDatabaseRecord; | 
|---|
| 485 | r->iconSet = "designer_tabwidget.png"; | 
|---|
| 486 | r->name = "QDesignerTabWidget"; | 
|---|
| 487 | r->group = widgetGroup( "Temp" ); | 
|---|
| 488 | r->isContainer = TRUE; | 
|---|
| 489 |  | 
|---|
| 490 | append( r ); | 
|---|
| 491 |  | 
|---|
| 492 | r = new WidgetDatabaseRecord; | 
|---|
| 493 | r->iconSet = "designer_tabwidget.png"; | 
|---|
| 494 | r->name = "QDesignerWidget"; | 
|---|
| 495 | r->group = widgetGroup( "Temp" ); | 
|---|
| 496 | r->isContainer = TRUE; | 
|---|
| 497 |  | 
|---|
| 498 | append( r ); | 
|---|
| 499 |  | 
|---|
| 500 | r = new WidgetDatabaseRecord; | 
|---|
| 501 | r->iconSet = "designer_tabwidget.png"; | 
|---|
| 502 | r->name = "QDesignerDialog"; | 
|---|
| 503 | r->group = widgetGroup( "Temp" ); | 
|---|
| 504 | r->isContainer = TRUE; | 
|---|
| 505 |  | 
|---|
| 506 | append( r ); | 
|---|
| 507 |  | 
|---|
| 508 | r = new WidgetDatabaseRecord; | 
|---|
| 509 | r->iconSet = ""; | 
|---|
| 510 | r->name = "QMainWindow"; | 
|---|
| 511 | r->includeFile = "qmainwindow.h"; | 
|---|
| 512 | r->group = widgetGroup( "Temp" ); | 
|---|
| 513 | r->isContainer = TRUE; | 
|---|
| 514 |  | 
|---|
| 515 | append( r ); | 
|---|
| 516 |  | 
|---|
| 517 | r = new WidgetDatabaseRecord; | 
|---|
| 518 | r->iconSet = ""; | 
|---|
| 519 | r->name = "QDesignerAction"; | 
|---|
| 520 | r->includeFile = "qaction.h"; | 
|---|
| 521 | r->group = widgetGroup( "Temp" ); | 
|---|
| 522 | r->isContainer = FALSE; | 
|---|
| 523 |  | 
|---|
| 524 | append( r ); | 
|---|
| 525 |  | 
|---|
| 526 | r = new WidgetDatabaseRecord; | 
|---|
| 527 | r->iconSet = ""; | 
|---|
| 528 | r->name = "QDesignerActionGroup"; | 
|---|
| 529 | r->includeFile = "qaction.h"; | 
|---|
| 530 | r->group = widgetGroup( "Temp" ); | 
|---|
| 531 | r->isContainer = FALSE; | 
|---|
| 532 |  | 
|---|
| 533 | append( r ); | 
|---|
| 534 |  | 
|---|
| 535 | r = new WidgetDatabaseRecord; | 
|---|
| 536 | r->iconSet = ""; | 
|---|
| 537 | r->name = "QScrollView"; | 
|---|
| 538 | r->includeFile = "qscrollview.h"; | 
|---|
| 539 | r->group = widgetGroup( "Temp" ); | 
|---|
| 540 | r->isContainer = TRUE; | 
|---|
| 541 |  | 
|---|
| 542 | append( r ); | 
|---|
| 543 |  | 
|---|
| 544 | #ifndef QT_NO_SQL | 
|---|
| 545 | r = new WidgetDatabaseRecord; | 
|---|
| 546 | r->iconSet = ""; | 
|---|
| 547 | r->name = "QDataBrowser"; | 
|---|
| 548 | r->includeFile = "qdatabrowser.h"; | 
|---|
| 549 | r->group = widgetGroup( "Database" ); | 
|---|
| 550 | r->toolTip = "Data Browser"; | 
|---|
| 551 | r->iconSet = "designer_databrowser.png"; | 
|---|
| 552 | r->isContainer = TRUE; | 
|---|
| 553 |  | 
|---|
| 554 | append( r ); | 
|---|
| 555 |  | 
|---|
| 556 | r = new WidgetDatabaseRecord; | 
|---|
| 557 | r->iconSet = ""; | 
|---|
| 558 | r->name = "QDataView"; | 
|---|
| 559 | r->includeFile = "qdataview.h"; | 
|---|
| 560 | r->group = widgetGroup( "Database" ); | 
|---|
| 561 | r->toolTip = "Data View"; | 
|---|
| 562 | r->iconSet = "designer_dataview.png"; | 
|---|
| 563 | r->isContainer = TRUE; | 
|---|
| 564 |  | 
|---|
| 565 | append( r ); | 
|---|
| 566 | #endif | 
|---|
| 567 |  | 
|---|
| 568 | #ifndef UIC | 
|---|
| 569 | setupPlugins(); | 
|---|
| 570 | #endif | 
|---|
| 571 | } | 
|---|
| 572 |  | 
|---|
| 573 | void WidgetDatabase::setupPlugins() | 
|---|
| 574 | { | 
|---|
| 575 | if ( plugins_set_up ) | 
|---|
| 576 | return; | 
|---|
| 577 | plugins_set_up = TRUE; | 
|---|
| 578 | QStringList widgets = widgetManager()->featureList(); | 
|---|
| 579 | for ( QStringList::Iterator it = widgets.begin(); it != widgets.end(); ++it ) { | 
|---|
| 580 | if ( hasWidget( *it ) ) | 
|---|
| 581 | continue; | 
|---|
| 582 | WidgetDatabaseRecord *r = new WidgetDatabaseRecord; | 
|---|
| 583 | WidgetInterface *iface = 0; | 
|---|
| 584 | widgetManager()->queryInterface( *it, &iface ); | 
|---|
| 585 | if ( !iface ) | 
|---|
| 586 | continue; | 
|---|
| 587 |  | 
|---|
| 588 | #ifndef UIC | 
|---|
| 589 | QIconSet icon = iface->iconSet( *it ); | 
|---|
| 590 | if ( !icon.pixmap().isNull() ) | 
|---|
| 591 | r->icon = new QIconSet( icon ); | 
|---|
| 592 | #endif | 
|---|
| 593 | QString grp = iface->group( *it ); | 
|---|
| 594 | if ( grp.isEmpty() ) | 
|---|
| 595 | grp = "3rd party widgets"; | 
|---|
| 596 | r->group = widgetGroup( grp ); | 
|---|
| 597 | r->toolTip = iface->toolTip( *it ); | 
|---|
| 598 | r->whatsThis = iface->whatsThis( *it ); | 
|---|
| 599 | r->includeFile = iface->includeFile( *it ); | 
|---|
| 600 | r->isContainer = iface->isContainer( *it ); | 
|---|
| 601 | r->name = *it; | 
|---|
| 602 | r->isPlugin = TRUE; | 
|---|
| 603 | append( r ); | 
|---|
| 604 | iface->release(); | 
|---|
| 605 | } | 
|---|
| 606 | } | 
|---|
| 607 |  | 
|---|
| 608 | /*! | 
|---|
| 609 | Returns the number of elements in the widget database. | 
|---|
| 610 | */ | 
|---|
| 611 |  | 
|---|
| 612 | int WidgetDatabase::count() | 
|---|
| 613 | { | 
|---|
| 614 | setupDataBase( -1 ); | 
|---|
| 615 | return dbcount; | 
|---|
| 616 | } | 
|---|
| 617 |  | 
|---|
| 618 | /*! | 
|---|
| 619 | Returns the id at which the ids of custom widgets start. | 
|---|
| 620 | */ | 
|---|
| 621 |  | 
|---|
| 622 | int WidgetDatabase::startCustom() | 
|---|
| 623 | { | 
|---|
| 624 | setupDataBase( -1 ); | 
|---|
| 625 | return dbcustom; | 
|---|
| 626 | } | 
|---|
| 627 |  | 
|---|
| 628 | /*! | 
|---|
| 629 | Returns the iconset which represents the class registered as \a id. | 
|---|
| 630 | */ | 
|---|
| 631 |  | 
|---|
| 632 | QIconSet WidgetDatabase::iconSet( int id ) | 
|---|
| 633 | { | 
|---|
| 634 | setupDataBase( id ); | 
|---|
| 635 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 636 | if ( !r ) | 
|---|
| 637 | return QIconSet(); | 
|---|
| 638 | #if !defined(UIC) && !defined(RESOURCE) | 
|---|
| 639 | if ( !r->icon ) { | 
|---|
| 640 | if ( r->iconSet.isEmpty() ) | 
|---|
| 641 | return QIconSet(); | 
|---|
| 642 | QPixmap pix = QPixmap::fromMimeSource( r->iconSet ); | 
|---|
| 643 | if ( pix.isNull() ) | 
|---|
| 644 | pix = QPixmap( r->iconSet ); | 
|---|
| 645 | r->icon = new QIconSet( pix ); | 
|---|
| 646 | } | 
|---|
| 647 | return *r->icon; | 
|---|
| 648 | #else | 
|---|
| 649 | return QIconSet(); | 
|---|
| 650 | #endif | 
|---|
| 651 | } | 
|---|
| 652 |  | 
|---|
| 653 | /*! | 
|---|
| 654 | Returns the classname of the widget which is registered as \a id. | 
|---|
| 655 | */ | 
|---|
| 656 |  | 
|---|
| 657 | QString WidgetDatabase::className( int id ) | 
|---|
| 658 | { | 
|---|
| 659 | setupDataBase( id ); | 
|---|
| 660 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 661 | if ( !r ) | 
|---|
| 662 | return QString::null; | 
|---|
| 663 | return r->name; | 
|---|
| 664 | } | 
|---|
| 665 |  | 
|---|
| 666 | /*! | 
|---|
| 667 | Returns the group the widget registered as \a id belongs to. | 
|---|
| 668 | */ | 
|---|
| 669 |  | 
|---|
| 670 | QString WidgetDatabase::group( int id ) | 
|---|
| 671 | { | 
|---|
| 672 | setupDataBase( id ); | 
|---|
| 673 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 674 | if ( !r ) | 
|---|
| 675 | return QString::null; | 
|---|
| 676 | return r->group; | 
|---|
| 677 | } | 
|---|
| 678 |  | 
|---|
| 679 | /*! | 
|---|
| 680 | Returns the tooltip text of the widget which is registered as \a id. | 
|---|
| 681 | */ | 
|---|
| 682 |  | 
|---|
| 683 | QString WidgetDatabase::toolTip( int id ) | 
|---|
| 684 | { | 
|---|
| 685 | setupDataBase( id ); | 
|---|
| 686 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 687 | if ( !r ) | 
|---|
| 688 | return QString::null; | 
|---|
| 689 | return r->toolTip; | 
|---|
| 690 | } | 
|---|
| 691 |  | 
|---|
| 692 | /*! | 
|---|
| 693 | Returns the what's this? text of the widget which is registered as \a id. | 
|---|
| 694 | */ | 
|---|
| 695 |  | 
|---|
| 696 | QString WidgetDatabase::whatsThis( int id ) | 
|---|
| 697 | { | 
|---|
| 698 | setupDataBase( id ); | 
|---|
| 699 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 700 | if ( !r ) | 
|---|
| 701 | return QString::null; | 
|---|
| 702 | return r->whatsThis; | 
|---|
| 703 | } | 
|---|
| 704 |  | 
|---|
| 705 | /*! | 
|---|
| 706 | Returns the include file if the widget which is registered as \a id. | 
|---|
| 707 | */ | 
|---|
| 708 |  | 
|---|
| 709 | QString WidgetDatabase::includeFile( int id ) | 
|---|
| 710 | { | 
|---|
| 711 | setupDataBase( id ); | 
|---|
| 712 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 713 | if ( !r ) | 
|---|
| 714 | return QString::null; | 
|---|
| 715 | if ( r->includeFile.isNull() ) | 
|---|
| 716 | return r->name.lower() + ".h"; | 
|---|
| 717 | return r->includeFile; | 
|---|
| 718 | } | 
|---|
| 719 |  | 
|---|
| 720 | /*!  Returns whether the widget registered as \a id is a form. | 
|---|
| 721 | */ | 
|---|
| 722 | bool WidgetDatabase::isForm( int id ) | 
|---|
| 723 | { | 
|---|
| 724 | setupDataBase( id ); | 
|---|
| 725 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 726 | if ( !r ) | 
|---|
| 727 | return FALSE; | 
|---|
| 728 | return r->isForm; | 
|---|
| 729 | } | 
|---|
| 730 |  | 
|---|
| 731 | /*!  Returns whether the widget registered as \a id can have children. | 
|---|
| 732 | */ | 
|---|
| 733 |  | 
|---|
| 734 | bool WidgetDatabase::isContainer( int id ) | 
|---|
| 735 | { | 
|---|
| 736 | setupDataBase( id ); | 
|---|
| 737 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 738 | if ( !r ) | 
|---|
| 739 | return FALSE; | 
|---|
| 740 | return r->isContainer || r->isForm; | 
|---|
| 741 | } | 
|---|
| 742 |  | 
|---|
| 743 | bool WidgetDatabase::isCommon( int id ) | 
|---|
| 744 | { | 
|---|
| 745 | setupDataBase( id ); | 
|---|
| 746 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 747 | if ( !r ) | 
|---|
| 748 | return FALSE; | 
|---|
| 749 | return r->isCommon; | 
|---|
| 750 | } | 
|---|
| 751 |  | 
|---|
| 752 | QString WidgetDatabase::createWidgetName( int id ) | 
|---|
| 753 | { | 
|---|
| 754 | setupDataBase( id ); | 
|---|
| 755 | QString n = className( id ); | 
|---|
| 756 | if ( n == "QLayoutWidget" ) | 
|---|
| 757 | n = "Layout"; | 
|---|
| 758 | if ( n[ 0 ] == 'Q' && n[ 1 ].lower() != n[ 1 ] ) | 
|---|
| 759 | n = n.mid( 1 ); | 
|---|
| 760 | int colonColon = n.findRev( "::" ); | 
|---|
| 761 | if ( colonColon != -1 ) | 
|---|
| 762 | n = n.mid( colonColon + 2 ); | 
|---|
| 763 |  | 
|---|
| 764 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 765 | if ( !r ) | 
|---|
| 766 | return n; | 
|---|
| 767 | n += QString::number( ++r->nameCounter ); | 
|---|
| 768 | n[0] = n[0].lower(); | 
|---|
| 769 | return n; | 
|---|
| 770 | } | 
|---|
| 771 |  | 
|---|
| 772 | /*!  Returns the id for \a name or -1 if \a name is unknown. | 
|---|
| 773 | */ | 
|---|
| 774 | int WidgetDatabase::idFromClassName( const QString &name ) | 
|---|
| 775 | { | 
|---|
| 776 | setupDataBase( -1 ); | 
|---|
| 777 | if ( name.isEmpty() ) | 
|---|
| 778 | return 0; | 
|---|
| 779 | int *i = className2Id->find( name ); | 
|---|
| 780 | if ( i ) | 
|---|
| 781 | return *i; | 
|---|
| 782 | if ( name == "FormWindow" ) | 
|---|
| 783 | return idFromClassName( "QLayoutWidget" ); | 
|---|
| 784 | #ifdef UIC | 
|---|
| 785 | setupDataBase( -2 ); | 
|---|
| 786 | i = className2Id->find( name ); | 
|---|
| 787 | if ( i ) | 
|---|
| 788 | return *i; | 
|---|
| 789 | #endif | 
|---|
| 790 | return -1; | 
|---|
| 791 | } | 
|---|
| 792 |  | 
|---|
| 793 | bool WidgetDatabase::hasWidget( const QString &name ) | 
|---|
| 794 | { | 
|---|
| 795 | return className2Id->find( name ) != 0; | 
|---|
| 796 | } | 
|---|
| 797 |  | 
|---|
| 798 | WidgetDatabaseRecord *WidgetDatabase::at( int index ) | 
|---|
| 799 | { | 
|---|
| 800 | if ( index < 0 ) | 
|---|
| 801 | return 0; | 
|---|
| 802 | if ( index >= dbcustom && index < dbcustomcount ) | 
|---|
| 803 | return db[ index ]; | 
|---|
| 804 | if ( index < dbcount ) | 
|---|
| 805 | return db[ index ]; | 
|---|
| 806 | return 0; | 
|---|
| 807 | } | 
|---|
| 808 |  | 
|---|
| 809 | void WidgetDatabase::insert( int index, WidgetDatabaseRecord *r ) | 
|---|
| 810 | { | 
|---|
| 811 | if ( index < 0 || index >= dbsize ) | 
|---|
| 812 | return; | 
|---|
| 813 | db[ index ] = r; | 
|---|
| 814 | className2Id->insert( r->name, new int( index ) ); | 
|---|
| 815 | if ( index < dbcustom ) | 
|---|
| 816 | dbcount = QMAX( dbcount, index ); | 
|---|
| 817 | } | 
|---|
| 818 |  | 
|---|
| 819 | void WidgetDatabase::append( WidgetDatabaseRecord *r ) | 
|---|
| 820 | { | 
|---|
| 821 | if ( !was_in_setup ) | 
|---|
| 822 | setupDataBase( -1 ); | 
|---|
| 823 | insert( dbcount++, r ); | 
|---|
| 824 | } | 
|---|
| 825 |  | 
|---|
| 826 | QString WidgetDatabase::widgetGroup( const QString &g ) | 
|---|
| 827 | { | 
|---|
| 828 | if ( wGroups->find( g ) == -1 ) | 
|---|
| 829 | wGroups->append( g ); | 
|---|
| 830 | return g; | 
|---|
| 831 | } | 
|---|
| 832 |  | 
|---|
| 833 | bool WidgetDatabase::isGroupEmpty( const QString &grp ) | 
|---|
| 834 | { | 
|---|
| 835 | WidgetDatabaseRecord *r = 0; | 
|---|
| 836 | for ( int i = 0; i < dbcount; ++i ) { | 
|---|
| 837 | if ( !( r = db[ i ] ) ) | 
|---|
| 838 | continue; | 
|---|
| 839 | if ( r->group == grp ) | 
|---|
| 840 | return FALSE; | 
|---|
| 841 | } | 
|---|
| 842 | return TRUE; | 
|---|
| 843 | } | 
|---|
| 844 |  | 
|---|
| 845 | QString WidgetDatabase::widgetGroup( int i ) | 
|---|
| 846 | { | 
|---|
| 847 | setupDataBase( -1 ); | 
|---|
| 848 | if ( i >= 0 && i < (int)wGroups->count() ) | 
|---|
| 849 | return wGroups->at( i ); | 
|---|
| 850 | return QString::null; | 
|---|
| 851 | } | 
|---|
| 852 |  | 
|---|
| 853 | int WidgetDatabase::numWidgetGroups() | 
|---|
| 854 | { | 
|---|
| 855 | setupDataBase( -1 ); | 
|---|
| 856 | return wGroups->count(); | 
|---|
| 857 | } | 
|---|
| 858 |  | 
|---|
| 859 | bool WidgetDatabase::isGroupVisible( const QString &g ) | 
|---|
| 860 | { | 
|---|
| 861 | setupDataBase( -1 ); | 
|---|
| 862 | return invisibleGroups->find( g ) == -1; | 
|---|
| 863 | } | 
|---|
| 864 |  | 
|---|
| 865 | int WidgetDatabase::addCustomWidget( WidgetDatabaseRecord *r ) | 
|---|
| 866 | { | 
|---|
| 867 | insert( dbcustomcount++, r ); | 
|---|
| 868 | return dbcustomcount - 1; | 
|---|
| 869 | } | 
|---|
| 870 |  | 
|---|
| 871 | void WidgetDatabase::customWidgetClassNameChanged( const QString &oldName, | 
|---|
| 872 | const QString &newName ) | 
|---|
| 873 | { | 
|---|
| 874 | int id = idFromClassName( oldName ); | 
|---|
| 875 | if ( id == -1 ) | 
|---|
| 876 | return; | 
|---|
| 877 | WidgetDatabaseRecord *r = db[ id ]; | 
|---|
| 878 | r->name = newName; | 
|---|
| 879 | className2Id->remove( oldName ); | 
|---|
| 880 | className2Id->insert( newName, new int( id ) ); | 
|---|
| 881 | } | 
|---|
| 882 |  | 
|---|
| 883 | bool WidgetDatabase::isCustomWidget( int id ) | 
|---|
| 884 | { | 
|---|
| 885 | if ( id >= dbcustom && id < dbcustomcount ) | 
|---|
| 886 | return TRUE; | 
|---|
| 887 | return FALSE; | 
|---|
| 888 | } | 
|---|
| 889 |  | 
|---|
| 890 | bool WidgetDatabase::isCustomPluginWidget( int id ) | 
|---|
| 891 | { | 
|---|
| 892 | setupDataBase( id ); | 
|---|
| 893 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 894 | if ( !r ) | 
|---|
| 895 | return FALSE; | 
|---|
| 896 | return r->isPlugin; | 
|---|
| 897 | } | 
|---|
| 898 |  | 
|---|
| 899 | bool WidgetDatabase::isWhatsThisLoaded() | 
|---|
| 900 | { | 
|---|
| 901 | return whatsThisLoaded; | 
|---|
| 902 | } | 
|---|
| 903 |  | 
|---|
| 904 | void WidgetDatabase::loadWhatsThis( const QString &docPath ) | 
|---|
| 905 | { | 
|---|
| 906 | QString whatsthisFile = docPath + "/whatsthis"; | 
|---|
| 907 | QFile f( whatsthisFile ); | 
|---|
| 908 | if ( !f.open( IO_ReadOnly ) ) | 
|---|
| 909 | return; | 
|---|
| 910 | QTextStream ts( &f ); | 
|---|
| 911 | while ( !ts.atEnd() ) { | 
|---|
| 912 | QString s = ts.readLine(); | 
|---|
| 913 | QStringList l = QStringList::split( " | ", s ); | 
|---|
| 914 | int id = idFromClassName( l[ 1 ] ); | 
|---|
| 915 | WidgetDatabaseRecord *r = at( id ); | 
|---|
| 916 | if ( r ) | 
|---|
| 917 | r->whatsThis = l[ 0 ]; | 
|---|
| 918 | } | 
|---|
| 919 | whatsThisLoaded = TRUE; | 
|---|
| 920 | } | 
|---|
| 921 |  | 
|---|
| 922 |  | 
|---|
| 923 | // ### Qt 3.1: make these publically accessible via QWidgetDatabase API | 
|---|
| 924 | #if defined(UIC) | 
|---|
| 925 | bool dbnounload = FALSE; | 
|---|
| 926 | QStringList *dbpaths = 0; | 
|---|
| 927 | #else | 
|---|
| 928 | extern QString *qwf_plugin_dir; | 
|---|
| 929 | #endif | 
|---|
| 930 |  | 
|---|
| 931 |  | 
|---|
| 932 | QPluginManager<WidgetInterface> *widgetManager() | 
|---|
| 933 | { | 
|---|
| 934 | if ( !widgetPluginManager ) { | 
|---|
| 935 | QString pluginDir = "/designer"; | 
|---|
| 936 | #if !defined(UIC) | 
|---|
| 937 | if ( qwf_plugin_dir ) | 
|---|
| 938 | pluginDir = *qwf_plugin_dir; | 
|---|
| 939 | #endif | 
|---|
| 940 | widgetPluginManager = new QPluginManager<WidgetInterface>( IID_Widget, QApplication::libraryPaths(), pluginDir ); | 
|---|
| 941 | cleanup_manager.add( &widgetPluginManager ); | 
|---|
| 942 | #if defined(UIC) | 
|---|
| 943 | if ( dbnounload ) | 
|---|
| 944 | widgetPluginManager->setAutoUnload( FALSE ); | 
|---|
| 945 | if ( dbpaths ) { | 
|---|
| 946 | QStringList::ConstIterator it = dbpaths->begin(); | 
|---|
| 947 | for ( ; it != dbpaths->end(); ++it ) | 
|---|
| 948 | widgetPluginManager->addLibraryPath( *it ); | 
|---|
| 949 | } | 
|---|
| 950 | #endif | 
|---|
| 951 | } | 
|---|
| 952 | return widgetPluginManager; | 
|---|
| 953 | } | 
|---|