Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/widgets/qdockarealayout.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6161QT_BEGIN_NAMESPACE
    6262
     63// qmainwindow.cpp
     64extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
     65
    6366enum { StateFlagVisible = 1, StateFlagFloating = 2 };
    6467
     
    221224#endif
    222225
     226static const int zero = 0;
     227
    223228QDockAreaLayoutInfo::QDockAreaLayoutInfo()
    224     : sep(0), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)
    225 #ifndef QT_NO_TABBAR
    226     , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth), tabBarVisible(false)
    227 #endif
    228 {
    229 }
    230 
    231 QDockAreaLayoutInfo::QDockAreaLayoutInfo(int _sep, QInternal::DockPosition _dockPos,
     229    : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)
     230#ifndef QT_NO_TABBAR
     231    , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth)
     232#endif
     233{
     234}
     235
     236QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos,
    232237                                            Qt::Orientation _o, int tbshape,
    233238                                            QMainWindow *window)
    234239    : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)
    235240#ifndef QT_NO_TABBAR
    236     , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)), tabBarVisible(false)
     241    , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
    237242#endif
    238243{
     
    282287        {
    283288            if (!first)
    284                 a += sep;
     289                a += *sep;
    285290            a += pick(o, min_size);
    286291        }
     
    295300
    296301#ifndef QT_NO_TABBAR
    297     if (tabbed) {
    298         QSize tbm = tabBarMinimumSize();
     302    QSize tbm = tabBarMinimumSize();
     303    if (!tbm.isNull()) {
    299304        switch (tabBarShape) {
    300305            case QTabBar::RoundedNorth:
     
    350355        {
    351356            if (!first)
    352                 a += sep;
     357                a += *sep;
    353358            a += pick(o, max_size);
    354359        }
     
    368373
    369374#ifndef QT_NO_TABBAR
    370     if (tabbed) {
    371         QSize tbh = tabBarSizeHint();
     375    QSize tbh = tabBarSizeHint();
     376    if (!tbh.isNull()) {
    372377        switch (tabBarShape) {
    373378            case QTabBar::RoundedNorth:
     
    416421            if (previous && !gap && !(previous->flags &  QDockAreaLayoutItem::GapItem)
    417422                && !previous->hasFixedSize(o)) {
    418                 a += sep;
     423                a += *sep;
    419424            }
    420425            a += gap ? item.size : pick(o, size_hint);
     
    492497
    493498        if (!first)
    494             result += info.sep;
     499            result += *info.sep;
    495500        result += min;
    496501
     
    517522
    518523        if (!first)
    519             result += info.sep;
     524            result += *info.sep;
    520525        result += max;
    521526
     
    556561                QLayoutStruct &ls = layout_struct_list[j++];
    557562                ls.init();
    558                 ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : sep;
     563                ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : *sep;
    559564                ls.empty = false;
    560565            }
     
    939944            ls.empty = true;
    940945        } else {
    941             const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;
     946            const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
    942947            ls.empty = false;
    943948            ls.pos = item.pos;
     
    957962            continue;
    958963        QLayoutStruct &ls = list[i];
    959         const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;
     964        const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
    960965        item.size = ls.size - separatorSpace;
    961966        item.pos = ls.pos;
     
    10421047
    10431048        if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
    1044             item.pos += sep;
    1045             item.size -= sep;
     1049            item.pos += *sep;
     1050            item.size -= *sep;
    10461051        }
    10471052        if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
    1048             item.size -= sep;
     1053            item.size -= *sep;
    10491054
    10501055        QPoint pos;
     
    10841089    {
    10851090        if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
    1086             item.pos -= sep;
    1087             item.size += sep;
     1091            item.pos -= *sep;
     1092            item.size += *sep;
    10881093        }
    10891094        if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
    1090             item.size += sep;
     1095            item.size += *sep;
    10911096    }
    10921097
     
    12561261            gap_size = pick(o, r.size());
    12571262        if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem))
    1258                 sep_size += sep;
     1263                sep_size += *sep;
    12591264            if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
    1260                 sep_size += sep;
     1265                sep_size += *sep;
    12611266        }
    12621267        if (gap_size + sep_size > space)
     
    13651370    rpick(o, pos) = item.pos + item.size;
    13661371    QSize s = rect.size();
    1367     rpick(o, s) = sep;
     1372    rpick(o, s) = *sep;
    13681373
    13691374    return QRect(pos, s);
     
    14141419
    14151420        QRect sepRect = separatorRect(i);
    1416         if (!sepRect.isNull() && sep == 1)
     1421        if (!sepRect.isNull() && *sep == 1)
    14171422            sepRect.adjust(-2, -2, 2, 2);
    14181423        //we also make sure we don't find a separator that's not there
     
    14791484QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const
    14801485{
    1481     QMainWindowLayout *result = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
     1486    QMainWindowLayout *result = qt_mainwindow_layout(mainWindow);
    14821487    Q_ASSERT(result != 0);
    14831488    return result;
     
    14991504        QSize tbh = tabBarSizeHint();
    15001505
    1501         if (tabBarVisible) {
     1506        if (!tbh.isNull()) {
    15021507            switch (tabBarShape) {
    15031508                case QTabBar::RoundedNorth:
     
    15611566    }
    15621567#ifndef QT_NO_TABBAR
    1563     if (sep == 1)
     1568    if (*sep == 1)
    15641569        updateSeparatorWidgets();
    15651570#endif //QT_NO_TABBAR
     
    19841989                    }
    19851990                }
    1986 
     1991                if (testing) {
     1992                  //was it is not really added to the layout, we need to delete the object here
     1993                  delete item.widgetItem;
     1994                }
    19871995            }
    19881996        } else if (nextMarker == SequenceMarker) {
     
    20142022        setCurrentTabId(tabId(item_list.at(index)));
    20152023    }
    2016     if (!testing && sep == 1)
     2024    if (!testing && *sep == 1)
    20172025        updateSeparatorWidgets();
    20182026#endif
     
    20752083
    20762084#ifndef QT_NO_TABBAR
    2077 void QDockAreaLayoutInfo::updateTabBar() const
     2085//returns whether the tabbar is visible or not
     2086bool QDockAreaLayoutInfo::updateTabBar() const
    20782087{
    20792088    if (!tabbed)
    2080         return;
     2089        return false;
    20812090
    20822091    QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);
     
    21462155    tabBar->blockSignals(blocked);
    21472156
    2148     that->tabBarVisible = ( (gap ? 1 : 0) + tabBar->count()) > 1;
    2149 
    2150     if (changed || !tabBarMin.isValid() | !tabBarHint.isValid()) {
    2151         that->tabBarMin = tabBar->minimumSizeHint();
    2152         that->tabBarHint = tabBar->sizeHint();
    2153     }
     2157    //returns if the tabbar is visible or not
     2158    return ( (gap ? 1 : 0) + tabBar->count()) > 1;
    21542159}
    21552160
     
    21592164        return;
    21602165    tabBarShape = shape;
    2161     if (tabBar != 0) {
     2166    if (tabBar != 0)
    21622167        tabBar->setShape(static_cast<QTabBar::Shape>(shape));
    2163         tabBarMin = QSize();
    2164         tabBarHint = QSize();
    2165     }
    21662168
    21672169    for (int i = 0; i < item_list.count(); ++i) {
     
    21742176QSize QDockAreaLayoutInfo::tabBarMinimumSize() const
    21752177{
    2176     if (!tabbed)
     2178    if (!updateTabBar())
    21772179        return QSize(0, 0);
    21782180
    2179     updateTabBar();
    2180 
    2181     return tabBarMin;
     2181    return tabBar->minimumSizeHint();
    21822182}
    21832183
    21842184QSize QDockAreaLayoutInfo::tabBarSizeHint() const
    21852185{
    2186     if (!tabbed)
     2186    if (!updateTabBar())
    21872187        return QSize(0, 0);
    21882188
    2189     updateTabBar();
    2190 
    2191     return tabBarHint;
     2189    return tabBar->sizeHint();
    21922190}
    21932191
     
    22362234    QSize tbh = tabBarSizeHint();
    22372235
    2238     if (tabBarVisible) {
     2236    if (!tbh.isNull()) {
    22392237        switch (tabBarShape) {
    22402238            case QTabBar::RoundedNorth:
     
    22772275#endif
    22782276    docks[QInternal::LeftDock]
    2279         = QDockAreaLayoutInfo(sep, QInternal::LeftDock, Qt::Vertical, tabShape, win);
     2277        = QDockAreaLayoutInfo(&sep, QInternal::LeftDock, Qt::Vertical, tabShape, win);
    22802278    docks[QInternal::RightDock]
    2281         = QDockAreaLayoutInfo(sep, QInternal::RightDock, Qt::Vertical, tabShape, win);
     2279        = QDockAreaLayoutInfo(&sep, QInternal::RightDock, Qt::Vertical, tabShape, win);
    22822280    docks[QInternal::TopDock]
    2283         = QDockAreaLayoutInfo(sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);
     2281        = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);
    22842282    docks[QInternal::BottomDock]
    2285         = QDockAreaLayoutInfo(sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);
     2283        = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);
    22862284    centralWidgetItem = 0;
    22872285
     
    29952993        dockWidget->d_func()->setWindowState(true, true, r);
    29962994    }
    2997     dockWidget->show();
    2998 //    dockWidget->setVisible(!placeHolder->hidden);
     2995    dockWidget->setVisible(!placeHolder->hidden);
    29992996#ifdef Q_WS_X11
    30002997    if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag
     
    30323029        int tbshape = 0;
    30333030#endif
    3034         QDockAreaLayoutInfo new_info(sep, pos, orientation, tbshape, mainWindow);
     3031        QDockAreaLayoutInfo new_info(&sep, pos, orientation, tbshape, mainWindow);
    30353032        new_info.item_list.append(new QDockAreaLayoutInfo(info));
    30363033        new_info.item_list.append(dockWidgetItem);
     
    30773074void QDockAreaLayout::apply(bool animate)
    30783075{
    3079     QWidgetAnimator &widgetAnimator
    3080         = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->widgetAnimator;
     3076    QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator;
    30813077
    30823078    for (int i = 0; i < QInternal::DockCount; ++i)
     
    31683164
    31693165#ifndef QT_NO_TABBAR
    3170 // Sets the correct positions for the seperator widgets
     3166// Sets the correct positions for the separator widgets
    31713167// Allocates new sepearator widgets with getSeparatorWidget
    31723168void QDockAreaLayout::updateSeparatorWidgets() const
     
    31833179            sepWidget = separatorWidgets.at(j);
    31843180        } else {
    3185             sepWidget = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->getSeparatorWidget();
     3181            sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget();
    31863182            separatorWidgets.append(sepWidget);
    31873183        }
     
    33283324}
    33293325
     3326void QDockAreaLayout::styleChangedEvent()
     3327{
     3328    sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow);
     3329    fitLayout();
     3330}
     3331
    33303332QT_END_NAMESPACE
    33313333
Note: See TracChangeset for help on using the changeset viewer.