Ignore:
Timestamp:
Aug 26, 2009, 9:00:24 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Implemented QWidget::setParent_sys(). Many examples started to launch now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qwidget_pm.cpp

    r124 r128  
    12541254}
    12551255
     1256
     1257
     1258
     1259
     1260
     1261
     1262
     1263
     1264
     1265
     1266
     1267
     1268
     1269
     1270
     1271
     1272
     1273
     1274
     1275
     1276
     1277
     1278
     1279
     1280
     1281
     1282
     1283
     1284
     1285
     1286
     1287
     1288
     1289
     1290
     1291
     1292
    12561293void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
    12571294{
    1258     // @todo implement
     1295    Q_Q(QWidget);
     1296    bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
     1297    if (q->isVisible() && q->parentWidget() && parent != q->parentWidget())
     1298        q->parentWidget()->d_func()->invalidateBuffer(q->geometry());
     1299
     1300    WId old_fid = frameWinId();
     1301
     1302    // hide and reparent our own window away. Otherwise we might get
     1303    // destroyed when emitting the child remove event below. See QWorkspace.
     1304    if (q->isVisible() && old_fid != NULLHANDLE) {
     1305        qt_WinSetWindowPos(old_fid, 0, 0, 0, 0, 0, SWP_HIDE);
     1306        WinSetParent(old_fid, HWND_OBJECT, FALSE);
     1307        WinSetOwner(old_fid, NULLHANDLE);
     1308    }
     1309    bool dropSiteWasRegistered = false;
     1310    if (q->testAttribute(Qt::WA_DropSiteRegistered)) {
     1311        dropSiteWasRegistered = true;
     1312        q->setAttribute(Qt::WA_DropSiteRegistered, false); // ole dnd unregister (we will register again below)
     1313    }
     1314
     1315    if ((q->windowType() == Qt::Desktop))
     1316        old_fid = NULLHANDLE;
     1317    setWinId(0);
     1318
     1319    QObjectPrivate::setParent_helper(parent);
     1320    bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
     1321
     1322    data.window_flags = f;
     1323    data.fstrut_dirty = true;
     1324    q->setAttribute(Qt::WA_WState_Created, false);
     1325    q->setAttribute(Qt::WA_WState_Visible, false);
     1326    q->setAttribute(Qt::WA_WState_Hidden, false);
     1327    adjustFlags(data.window_flags, q);
     1328    // keep compatibility with previous versions, we need to preserve the created state
     1329    // (but we recreate the winId for the widget being reparented, again for compatibility)
     1330    if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created)))
     1331        createWinId();
     1332    if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden)
     1333        q->setAttribute(Qt::WA_WState_Hidden);
     1334    q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
     1335
     1336    if (wasCreated) {
     1337        reparentChildren();
     1338    }
     1339
     1340    if (extra && !extra->mask.isEmpty()) {
     1341        QRegion r = extra->mask;
     1342        extra->mask = QRegion();
     1343        q->setMask(r);
     1344    }
     1345    if (extra && extra->topextra && !extra->topextra->caption.isEmpty()) {
     1346        setWindowIcon_sys(true);
     1347        setWindowTitle_helper(extra->topextra->caption);
     1348    }
     1349    if (old_fid != NULLHANDLE)
     1350        qt_WinDestroyWindow(old_fid);
     1351
     1352    if (q->testAttribute(Qt::WA_AcceptDrops) || dropSiteWasRegistered
     1353        || (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
     1354        q->setAttribute(Qt::WA_DropSiteRegistered, true);
     1355
     1356    invalidateBuffer(q->rect());
    12591357}
    12601358
Note: See TracChangeset for help on using the changeset viewer.