Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    156156}
    157157
     158bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const
     159{
     160    return perp(o, minimumSize()) == perp(o, maximumSize());
     161}
     162
    158163bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const
    159164{
     
    217222
    218223QDockAreaLayoutInfo::QDockAreaLayoutInfo()
    219     : sep(0), dockPos(QInternal::LeftDock), o(Qt::Horizontal), rect(0, 0, -1, -1), mainWindow(0)
    220 #ifndef QT_NO_TABBAR
    221     , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth)
     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)
    222227#endif
    223228{
     
    227232                                            Qt::Orientation _o, int tbshape,
    228233                                            QMainWindow *window)
    229     : sep(_sep), dockPos(_dockPos), o(_o), rect(0, 0, -1, -1), mainWindow(window)
    230 #ifndef QT_NO_TABBAR
    231     , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
     234    : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)
     235#ifndef QT_NO_TABBAR
     236    , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)), tabBarVisible(false)
    232237#endif
    233238{
     
    245250{
    246251    item_list.clear();
    247     rect = QRect(0, 0, -1, -1);
     252    rect = QRect();
    248253#ifndef QT_NO_TABBAR
    249254    tabbed = false;
     
    389394
    390395    int a = 0, b = 0;
    391     bool prev_gap = false;
    392     bool first = true;
    393396    int min_perp = 0;
    394397    int max_perp = QWIDGETSIZE_MAX;
     398    const QDockAreaLayoutItem *previous = 0;
    395399    for (int i = 0; i < item_list.size(); ++i) {
    396400        const QDockAreaLayoutItem &item = item_list.at(i);
     
    410414#endif
    411415        {
    412             if (!first && !gap && !prev_gap)
     416            if (previous && !gap && !(previous->flags &  QDockAreaLayoutItem::GapItem)
     417                && !previous->hasFixedSize(o)) {
    413418                a += sep;
     419            }
    414420            a += gap ? item.size : pick(o, size_hint);
    415421        }
    416422        b = qMax(b, perp(o, size_hint));
    417423
    418         prev_gap = gap;
    419         first = false;
     424        previous = &item;
    420425    }
    421426
     
    540545    int last_index = -1;
    541546
    542     bool prev_gap = false;
    543     bool first = true;
     547    const QDockAreaLayoutItem *previous = 0;
    544548    for (int i = 0; i < item_list.size(); ++i) {
    545549        QDockAreaLayoutItem &item = item_list[i];
     
    548552
    549553        bool gap = item.flags & QDockAreaLayoutItem::GapItem;
    550         if (!first && !gap && !prev_gap) {
    551             QLayoutStruct &ls = layout_struct_list[j++];
    552             ls.init();
    553             ls.minimumSize = sep;
    554             ls.maximumSize = sep;
    555             ls.sizeHint = sep;
    556             ls.empty = false;
     554        if (previous && !gap) {
     555            if (!(previous->flags & QDockAreaLayoutItem::GapItem)) {
     556                QLayoutStruct &ls = layout_struct_list[j++];
     557                ls.init();
     558                ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : sep;
     559                ls.empty = false;
     560            }
    557561        }
    558562
     
    593597
    594598        item.flags &= ~QDockAreaLayoutItem::KeepSize;
    595         prev_gap = gap;
    596         first = false;
     599        previous = &item;
    597600    }
    598601    layout_struct_list.resize(j);
     
    608611
    609612    j = 0;
    610     prev_gap = false;
    611     first = true;
     613    bool prev_gap = false;
     614    bool first = true;
    612615    for (int i = 0; i < item_list.size(); ++i) {
    613616        QDockAreaLayoutItem &item = item_list[i];
     
    922925}
    923926
    924 int QDockAreaLayoutInfo::separatorMove(int index, int delta, QVector<QLayoutStruct> *cache)
     927int QDockAreaLayoutInfo::separatorMove(int index, int delta)
    925928{
    926929#ifndef QT_NO_TABBAR
     
    928931#endif
    929932
    930     if (cache->isEmpty()) {
    931         QVector<QLayoutStruct> &list = *cache;
    932         list.resize(item_list.size());
    933         for (int i = 0; i < item_list.size(); ++i) {
    934             const QDockAreaLayoutItem &item = item_list.at(i);
    935             QLayoutStruct &ls = list[i];
    936             Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem));
    937             if (item.skip()) {
    938                 ls.empty = true;
    939             } else {
    940                 ls.empty = false;
    941                 ls.pos = item.pos;
    942                 ls.size = item.size;
    943                 ls.minimumSize = pick(o, item.minimumSize());
    944                 ls.maximumSize = pick(o, item.maximumSize());
    945             }
    946         }
    947     }
    948 
    949     QVector<QLayoutStruct> list = *cache;
    950 
    951     delta = separatorMoveHelper(list, index, delta, sep);
    952 
    953     for (int i = 0; i < item_list.size(); ++i) {
     933    QVector<QLayoutStruct> list(item_list.size());
     934    for (int i = 0; i < list.size(); ++i) {
     935        const QDockAreaLayoutItem &item = item_list.at(i);
     936        QLayoutStruct &ls = list[i];
     937        Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem));
     938        if (item.skip()) {
     939            ls.empty = true;
     940        } else {
     941            const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;
     942            ls.empty = false;
     943            ls.pos = item.pos;
     944            ls.size = item.size + separatorSpace;
     945            ls.minimumSize = pick(o, item.minimumSize()) + separatorSpace;
     946            ls.maximumSize = pick(o, item.maximumSize()) + separatorSpace;
     947
     948        }
     949    }
     950
     951    //the separator space has been added to the size, so we pass 0 as a parameter
     952    delta = separatorMoveHelper(list, index, delta, 0 /*separator*/);
     953
     954    for (int i = 0; i < list.size(); ++i) {
    954955        QDockAreaLayoutItem &item = item_list[i];
    955956        if (item.skip())
    956957            continue;
    957958        QLayoutStruct &ls = list[i];
    958         item.size = ls.size;
     959        const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;
     960        item.size = ls.size - separatorSpace;
    959961        item.pos = ls.pos;
    960 
    961962        if (item.subinfo != 0) {
    962963            item.subinfo->rect = itemRect(i);
     
    994995}
    995996
    996 void QDockAreaLayoutInfo::remove(QList<int> path)
     997void QDockAreaLayoutInfo::remove(const QList<int> &path)
    997998{
    998999    Q_ASSERT(!path.isEmpty());
    9991000
    10001001    if (path.count() > 1) {
    1001         int index = path.takeFirst();
     1002        const int index = path.first();
    10021003        QDockAreaLayoutItem &item = item_list[index];
    10031004        Q_ASSERT(item.subinfo != 0);
    1004         item.subinfo->remove(path);
     1005        item.subinfo->remove(path.mid(1));
    10051006        unnest(index);
    10061007    } else {
     
    10101011}
    10111012
    1012 QLayoutItem *QDockAreaLayoutInfo::plug(QList<int> path)
     1013QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path)
    10131014{
    10141015    Q_ASSERT(!path.isEmpty());
    10151016
    1016     int index = path.takeFirst();
     1017    int index = path.first();
    10171018    if (index < 0)
    10181019        index = -index - 1;
    10191020
    1020     if (!path.isEmpty()) {
     1021    if (path.count() > 1) {
    10211022        const QDockAreaLayoutItem &item = item_list.at(index);
    10221023        Q_ASSERT(item.subinfo != 0);
    1023         return item.subinfo->plug(path);
     1024        return item.subinfo->plug(path.mid(1));
    10241025    }
    10251026
     
    10591060}
    10601061
    1061 QLayoutItem *QDockAreaLayoutInfo::unplug(QList<int> path)
     1062QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)
    10621063{
    10631064    Q_ASSERT(!path.isEmpty());
    10641065
     1066    const int index = path.first();
    10651067    if (path.count() > 1) {
    1066         int index = path.takeFirst();
    10671068        const QDockAreaLayoutItem &item = item_list.at(index);
    10681069        Q_ASSERT(item.subinfo != 0);
    1069         return item.subinfo->unplug(path);
    1070     }
    1071 
    1072     int index = path.first();
     1070        return item.subinfo->unplug(path.mid(1));
     1071    }
     1072
    10731073    QDockAreaLayoutItem &item = item_list[index];
    10741074    int prev = this->prev(index);
     
    11421142}
    11431143
    1144 bool QDockAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *dockWidgetItem)
     1144bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)
    11451145{
    11461146    Q_ASSERT(!path.isEmpty());
    11471147
    11481148    bool insert_tabbed = false;
    1149     int index = path.takeFirst();
     1149    int index = path.first();
    11501150    if (index < 0) {
    11511151        insert_tabbed = true;
     
    11551155//    dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString());
    11561156
    1157     if (!path.isEmpty()) {
     1157    if (path.count() > 1) {
    11581158        QDockAreaLayoutItem &item = item_list[index];
    11591159
     
    11681168            QDockAreaLayoutInfo *subinfo = item.subinfo;
    11691169            QLayoutItem *widgetItem = item.widgetItem;
    1170             QRect r = subinfo == 0 ? dockedGeometry(widgetItem->widget()) : subinfo->rect;
     1170            QPlaceHolderItem *placeHolderItem = item.placeHolderItem;
     1171            QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;
    11711172
    11721173            Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
     
    11771178                = new QDockAreaLayoutInfo(sep, dockPos, opposite, tabBarShape, mainWindow);
    11781179
     1180            //item become a new top-level
    11791181            item.subinfo = new_info;
    11801182            item.widgetItem = 0;
     1183            item.placeHolderItem = 0;
    11811184
    11821185            QDockAreaLayoutItem new_item
    11831186                = widgetItem == 0
    11841187                    ? QDockAreaLayoutItem(subinfo)
    1185                     : QDockAreaLayoutItem(widgetItem);
     1188                    : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem);
    11861189            new_item.size = pick(opposite, r.size());
    11871190            new_item.pos = pick(opposite, r.topLeft());
     
    11941197        }
    11951198
    1196         bool result = item.subinfo->insertGap(path, dockWidgetItem);
    1197         return result;
     1199        return item.subinfo->insertGap(path.mid(1), dockWidgetItem);
    11981200    }
    11991201
     
    12951297}
    12961298
    1297 QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QList<int> path)
    1298 {
    1299     int index = path.takeFirst();
     1299QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path)
     1300{
     1301    int index = path.first();
    13001302    if (index < 0)
    13011303        index = -index - 1;
    13021304    if (index >= item_list.count())
    13031305        return this;
    1304     if (path.isEmpty() || item_list.at(index).subinfo == 0)
     1306    if (path.count() == 1 || item_list[index].subinfo == 0)
    13051307        return this;
    1306     return item_list.at(index).subinfo->info(path);
     1308    return item_list[index].subinfo->info(path.mid(1));
    13071309}
    13081310
     
    13351337}
    13361338
    1337 QRect QDockAreaLayoutInfo::itemRect(QList<int> path) const
     1339QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const
    13381340{
    13391341    Q_ASSERT(!path.isEmpty());
    13401342
     1343    const int index = path.first();
    13411344    if (path.count() > 1) {
    1342         const QDockAreaLayoutItem &item = item_list.at(path.takeFirst());
     1345        const QDockAreaLayoutItem &item = item_list.at(index);
    13431346        Q_ASSERT(item.subinfo != 0);
    1344         return item.subinfo->itemRect(path);
    1345     }
    1346 
    1347     return itemRect(path.first());
     1347        return item.subinfo->itemRect(path.mid(1));
     1348    }
     1349
     1350    return itemRect(index);
    13481351}
    13491352
     
    13671370}
    13681371
    1369 QRect QDockAreaLayoutInfo::separatorRect(QList<int> path) const
     1372QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const
    13701373{
    13711374    Q_ASSERT(!path.isEmpty());
    13721375
     1376    const int index = path.first();
    13731377    if (path.count() > 1) {
    1374         const QDockAreaLayoutItem &item = item_list.at(path.takeFirst());
     1378        const QDockAreaLayoutItem &item = item_list.at(index);
    13751379        Q_ASSERT(item.subinfo != 0);
    1376         return item.subinfo->separatorRect(path);
    1377     }
    1378     return separatorRect(path.first());
     1380        return item.subinfo->separatorRect(path.mid(1));
     1381    }
     1382    return separatorRect(index);
    13791383}
    13801384
     
    14091413            continue;
    14101414
    1411         int margin = (sep == 1? 2 : 0);
    1412         if (pos >= item.pos + item.size - margin && item.pos + item.size + sep + margin > pos) {
    1413             QList<int> result;
    1414             result.append(i);
    1415             return result;
     1415        QRect sepRect = separatorRect(i);
     1416        if (!sepRect.isNull() && sep == 1)
     1417            sepRect.adjust(-2, -2, 2, 2);
     1418        //we also make sure we don't find a separator that's not there
     1419        if (sepRect.contains(_pos) && !item.hasFixedSize(o)) {
     1420            return QList<int>() << i;
    14161421        }
    14171422
     
    14791484}
    14801485
     1486bool QDockAreaLayoutInfo::hasFixedSize() const
     1487{
     1488    return perp(o, minimumSize()) == perp(o, maximumSize());
     1489}
     1490
     1491
    14811492void QDockAreaLayoutInfo::apply(bool animate)
    14821493{
    1483     QWidgetAnimator *widgetAnimator = mainWindowLayout()->widgetAnimator;
     1494    QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator;
    14841495
    14851496#ifndef QT_NO_TABBAR
     
    15141525        }
    15151526
    1516         widgetAnimator->animate(tabBar, tab_rect, animate);
     1527        widgetAnimator.animate(tabBar, tab_rect, animate);
    15171528    }
    15181529#endif // QT_NO_TABBAR
     
    15371548
    15381549        QRect geo = w->geometry();
    1539         widgetAnimator->animate(w, r, animate);
    1540         if (!w->isHidden()) {
     1550        widgetAnimator.animate(w, r, animate);
     1551        if (!w->isHidden() && w->window()->isVisible()) {
    15411552            QDockWidget *dw = qobject_cast<QDockWidget*>(w);
    15421553            if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) {
     
    15491560        }
    15501561    }
    1551 
     1562#ifndef QT_NO_TABBAR
    15521563    if (sep == 1)
    15531564        updateSeparatorWidgets();
     1565#endif //QT_NO_TABBAR
    15541566}
    15551567
     
    16301642            break;
    16311643        QRect r = separatorRect(i);
    1632         if (clip.contains(r))
     1644        if (clip.contains(r) && !item.hasFixedSize(o))
    16331645            paintSep(p, widget, r, o, r.contains(mouse));
    16341646    }
     
    16951707}
    16961708
    1697 QDockAreaLayoutItem &QDockAreaLayoutInfo::item(QList<int> path)
     1709QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path)
    16981710{
    16991711    Q_ASSERT(!path.isEmpty());
     1712    const int index = path.first();
    17001713    if (path.count() > 1) {
    1701         QDockAreaLayoutItem &item = item_list[path.takeFirst()];
     1714        const QDockAreaLayoutItem &item = item_list[index];
    17021715        Q_ASSERT(item.subinfo != 0);
    1703         return item.subinfo->item(path);
    1704     }
    1705     return item_list[path.first()];
     1716        return item.subinfo->item(path.mid(1));
     1717    }
     1718    return item_list[index];
    17061719}
    17071720
     
    18321845}
    18331846
    1834 #ifdef Q_WS_MAC
    18351847static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
    18361848{
     
    18441856    return Qt::NoDockWidgetArea;
    18451857}
    1846 #endif
    18471858
    18481859static QRect constrainedRect(QRect rect, const QRect &desktop)
     
    19611972                    if (!testing) {
    19621973                        widget->setVisible(flags & StateFlagVisible);
     1974                        item_list.append(item);
    19631975                    }
    19641976                } else {
    19651977                    int dummy;
    19661978                    stream >> item.pos >> item.size >> dummy >> dummy;
    1967     //                qDebug() << widget << item.pos << item.size;
    19681979                    if (!testing) {
     1980                        item_list.append(item);
    19691981                        widget->setFloating(false);
    19701982                        widget->setVisible(flags & StateFlagVisible);
     1983                        emit widget->dockLocationChanged(toDockWidgetArea(dockPos));
    19711984                    }
    19721985                }
    19731986
    1974                 if (!testing) {
    1975                     item_list.append(item);
    1976                 }
    19771987            }
    19781988        } else if (nextMarker == SequenceMarker) {
     
    20012011        setCurrentTabId(tabId(item_list.at(index)));
    20022012    }
    2003 #endif
    20042013    if (!testing && sep == 1)
    20052014        updateSeparatorWidgets();
     2015#endif
    20062016
    20072017    return true;
    20082018}
    20092019
     2020#ifndef QT_NO_TABBAR
    20102021void QDockAreaLayoutInfo::updateSeparatorWidgets() const
    20112022{
    2012     QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);
    2013 
    20142023    if (tabbed) {
    2015         that->separatorWidgets.clear();
     2024        separatorWidgets.clear();
    20162025        return;
    20172026    }
     
    20412050        } else {
    20422051            sepWidget = mainWindowLayout()->getSeparatorWidget();
    2043             that->separatorWidgets.append(sepWidget);
     2052            separatorWidgets.append(sepWidget);
    20442053        }
    20452054        j++;
     
    20542063    }
    20552064
    2056     for (int k = j; k < that->separatorWidgets.size(); ++k) {
    2057         that->separatorWidgets[k]->hide();
    2058     }
    2059     that->separatorWidgets.resize(j);
     2065    for (int k = j; k < separatorWidgets.size(); ++k) {
     2066        separatorWidgets[k]->hide();
     2067    }
     2068    separatorWidgets.resize(j);
    20602069    Q_ASSERT(separatorWidgets.size() == j);
    20612070}
     2071#endif //QT_NO_TABBAR
    20622072
    20632073#ifndef QT_NO_TABBAR
     
    20692079    QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);
    20702080
    2071     if (tabBar == 0) {
     2081    if (that->tabBar == 0) {
    20722082        that->tabBar = mainWindowLayout()->getTabBar();
    20732083        that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape));
     
    22032213    QSet<QWidget*> result;
    22042214
    2205     foreach (QWidget *sepWidget, separatorWidgets)
    2206         result << sepWidget;
     2215    for (int i = 0; i < separatorWidgets.count(); ++i)
     2216        result << separatorWidgets.at(i);
    22072217
    22082218    for (int i = 0; i < item_list.count(); ++i) {
     
    22542264*/
    22552265
    2256 QDockAreaLayout::QDockAreaLayout(QMainWindow *win)
     2266QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true)
    22572267{
    22582268    mainWindow = win;
     
    22722282        = QDockAreaLayoutInfo(sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);
    22732283    centralWidgetItem = 0;
    2274     centralWidgetRect = QRect(0, 0, -1, -1);
     2284
    22752285
    22762286    corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea;
     
    23412351                corners[i] = static_cast<Qt::DockWidgetArea>(cornerData[i]);
    23422352        }
     2353
     2354        if (!testing)
     2355            fallbackToSizeHints = false;
    23432356    }
    23442357
     
    24432456            continue;
    24442457        QRect rect = separatorRect(i);
    2445         if (sep == 1)
     2458        if (!rect.isNull() && sep == 1)
    24462459            rect.adjust(-2, -2, 2, 2);
    2447         if (rect.contains(pos)) {
     2460        if (rect.contains(pos) && !info.hasFixedSize()) {
    24482461            result << i;
    24492462            break;
     
    24702483}
    24712484
    2472 QDockAreaLayoutInfo *QDockAreaLayout::info(QList<int> path)
     2485QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path)
    24732486{
    24742487    Q_ASSERT(!path.isEmpty());
    2475     int index = path.takeFirst();
     2488    const int index = path.first();
    24762489    Q_ASSERT(index >= 0 && index < QInternal::DockCount);
    24772490
    2478     if (path.isEmpty())
     2491    if (path.count() == 1)
    24792492        return &docks[index];
    24802493
    2481     return docks[index].info(path);
    2482 }
    2483 
    2484 const QDockAreaLayoutInfo *QDockAreaLayout::info(QList<int> path) const
     2494    return docks[index].info(path.mid(1));
     2495}
     2496
     2497const QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const
    24852498{
    24862499    return const_cast<QDockAreaLayout*>(this)->info(path);
    24872500}
    24882501
    2489 QDockAreaLayoutItem &QDockAreaLayout::item(QList<int> path)
     2502QDockAreaLayoutItem &QDockAreaLayout::item(const QList<int> &path)
    24902503{
    24912504    Q_ASSERT(!path.isEmpty());
    2492     int index = path.takeFirst();
     2505    const int index = path.first();
    24932506    Q_ASSERT(index >= 0 && index < QInternal::DockCount);
    2494     return docks[index].item(path);
    2495 }
    2496 
    2497 QRect QDockAreaLayout::itemRect(QList<int> path) const
     2507    return docks[index].item(path.mid(1));
     2508}
     2509
     2510QRect QDockAreaLayout::itemRect(const QList<int> &path) const
    24982511{
    24992512    Q_ASSERT(!path.isEmpty());
    2500     int index = path.takeFirst();
     2513    const int index = path.first();
    25012514    Q_ASSERT(index >= 0 && index < QInternal::DockCount);
    2502     return docks[index].itemRect(path);
     2515    return docks[index].itemRect(path.mid(1));
    25032516}
    25042517
    25052518QRect QDockAreaLayout::separatorRect(int index) const
    25062519{
    2507     if (docks[index].isEmpty())
     2520    const QDockAreaLayoutInfo &dock = docks[index];
     2521    if (dock.isEmpty())
    25082522        return QRect();
    2509     QRect r = docks[index].rect;
     2523    QRect r = dock.rect;
    25102524    switch (index) {
    25112525        case QInternal::LeftDock:
     
    25232537}
    25242538
    2525 QRect QDockAreaLayout::separatorRect(QList<int> path) const
     2539QRect QDockAreaLayout::separatorRect(const QList<int> &path) const
    25262540{
    25272541    Q_ASSERT(!path.isEmpty());
    25282542
    2529     int index = path.takeFirst();
     2543    const int index = path.first();
    25302544    Q_ASSERT(index >= 0 && index < QInternal::DockCount);
    25312545
    2532     if (path.isEmpty())
     2546    if (path.count() == 1)
    25332547        return separatorRect(index);
    25342548    else
    2535         return docks[index].separatorRect(path);
    2536 }
    2537 
    2538 bool QDockAreaLayout::insertGap(QList<int> path, QLayoutItem *dockWidgetItem)
     2549        return docks[index].separatorRect(path.mid(1));
     2550}
     2551
     2552bool QDockAreaLayout::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)
    25392553{
    25402554    Q_ASSERT(!path.isEmpty());
    2541     int index = path.takeFirst();
     2555    const int index = path.first();
    25422556    Q_ASSERT(index >= 0 && index < QInternal::DockCount);
    2543     return docks[index].insertGap(path, dockWidgetItem);
    2544 }
    2545 
    2546 QLayoutItem *QDockAreaLayout::plug(QList<int> path)
     2557    return docks[index].insertGap(path.mid(1), dockWidgetItem);
     2558}
     2559
     2560QLayoutItem *QDockAreaLayout::plug(const QList<int> &path)
    25472561{
    25482562    Q_ASSERT(!path.isEmpty());
    2549     int index = path.takeFirst();
     2563    const int index = path.first();
    25502564    Q_ASSERT(index >= 0 && index < QInternal::DockCount);
    2551     return docks[index].plug(path);
    2552 }
    2553 
    2554 QLayoutItem *QDockAreaLayout::unplug(QList<int> path)
     2565    return docks[index].plug(path.mid(1));
     2566}
     2567
     2568QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path)
    25552569{
    25562570    Q_ASSERT(!path.isEmpty());
    2557     int index = path.takeFirst();
     2571    const int index = path.first();
    25582572    Q_ASSERT(index >= 0 && index < QInternal::DockCount);
    2559     return docks[index].unplug(path);
    2560 }
    2561 
    2562 void QDockAreaLayout::remove(QList<int> path)
     2573    return docks[index].unplug(path.mid(1));
     2574}
     2575
     2576void QDockAreaLayout::remove(const QList<int> &path)
    25632577{
    25642578    Q_ASSERT(!path.isEmpty());
    2565     int index = path.takeFirst();
     2579    const int index = path.first();
    25662580    Q_ASSERT(index >= 0 && index < QInternal::DockCount);
    2567     docks[index].remove(path);
     2581    docks[index].remove(path.mid(1));
    25682582}
    25692583
     
    25762590    QSize center_hint(0, 0);
    25772591    QSize center_min(0, 0);
    2578     bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();
     2592    const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();
    25792593    if (have_central) {
    25802594        center_hint = centralWidgetRect.size();
     
    25952609
    25962610    QSize left_hint = docks[QInternal::LeftDock].size();
    2597     if (!left_hint.isValid())
     2611    if (left_hint.isNull() || fallbackToSizeHints)
    25982612        left_hint = docks[QInternal::LeftDock].sizeHint();
    25992613    QSize left_min = docks[QInternal::LeftDock].minimumSize();
     
    26022616
    26032617    QSize right_hint = docks[QInternal::RightDock].size();
    2604     if (!right_hint.isValid())
     2618    if (right_hint.isNull() || fallbackToSizeHints)
    26052619        right_hint = docks[QInternal::RightDock].sizeHint();
    26062620    QSize right_min = docks[QInternal::RightDock].minimumSize();
     
    26092623
    26102624    QSize top_hint = docks[QInternal::TopDock].size();
    2611     if (!top_hint.isValid())
     2625    if (top_hint.isNull() || fallbackToSizeHints)
    26122626        top_hint = docks[QInternal::TopDock].sizeHint();
    26132627    QSize top_min = docks[QInternal::TopDock].minimumSize();
     
    26162630
    26172631    QSize bottom_hint = docks[QInternal::BottomDock].size();
    2618     if (!bottom_hint.isValid())
     2632    if (bottom_hint.isNull() || fallbackToSizeHints)
    26192633        bottom_hint = docks[QInternal::BottomDock].sizeHint();
    26202634    QSize bottom_min = docks[QInternal::BottomDock].minimumSize();
    26212635    QSize bottom_max = docks[QInternal::BottomDock].maximumSize();
    26222636    bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);
     2637
     2638    fallbackToSizeHints = !have_central;
    26232639
    26242640    if (_ver_struct_list != 0) {
     
    28552871        docks[i].clear();
    28562872
    2857     rect = QRect(0, 0, -1, -1);
    2858     centralWidgetRect = QRect(0, 0, -1, -1);
     2873    rect = QRect();
     2874    centralWidgetRect = QRect();
    28592875}
    28602876
     
    30583074void QDockAreaLayout::apply(bool animate)
    30593075{
    3060     QWidgetAnimator *widgetAnimator
     3076    QWidgetAnimator &widgetAnimator
    30613077        = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->widgetAnimator;
    30623078
     
    30643080        docks[i].apply(animate);
    30653081    if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) {
    3066         widgetAnimator->animate(centralWidgetItem->widget(), centralWidgetRect,
     3082        widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect,
    30673083                                animate);
    30683084    }
    3069 
     3085#ifndef QT_NO_TABBAR
    30703086    if (sep == 1)
    30713087        updateSeparatorWidgets();
     3088#endif //QT_NO_TABBAR
    30723089}
    30733090
     
    30813098            continue;
    30823099        QRect r = separatorRect(i);
    3083         if (clip.contains(r)) {
     3100        if (clip.contains(r) && !dock.hasFixedSize()) {
    30843101            Qt::Orientation opposite = dock.o == Qt::Horizontal
    30853102                                        ? Qt::Vertical : Qt::Horizontal;
     
    31063123}
    31073124
    3108 int QDockAreaLayout::separatorMove(QList<int> separator, const QPoint &origin,
    3109                                                 const QPoint &dest,
    3110                                                 QVector<QLayoutStruct> *cache)
     3125int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &origin,
     3126                                                const QPoint &dest)
    31113127{
    31123128    int delta = 0;
     
    31173133        delta = pick(info->o, dest - origin);
    31183134        if (delta != 0)
    3119             delta = info->separatorMove(index, delta, cache);
     3135            delta = info->separatorMove(index, delta);
    31203136        info->apply(false);
    31213137        return delta;
    31223138    }
    31233139
    3124     if (cache->isEmpty()) {
    3125         QVector<QLayoutStruct> &list = *cache;
    3126 
    3127         if (index == QInternal::LeftDock || index == QInternal::RightDock)
    3128             getGrid(0, &list);
    3129         else
    3130             getGrid(&list, 0);
    3131     }
    3132 
    3133     QVector<QLayoutStruct> list = *cache;
     3140    QVector<QLayoutStruct> list;
     3141
     3142    if (index == QInternal::LeftDock || index == QInternal::RightDock)
     3143        getGrid(0, &list);
     3144    else
     3145        getGrid(&list, 0);
     3146
    31343147    int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock
    31353148                        ? 0 : 1;
     
    31513164}
    31523165
     3166#ifndef QT_NO_TABBAR
    31533167// Sets the correct positions for the seperator widgets
    31543168// Allocates new sepearator widgets with getSeparatorWidget
    31553169void QDockAreaLayout::updateSeparatorWidgets() const
    31563170{
    3157     QDockAreaLayout *that = const_cast<QDockAreaLayout*>(this);
    3158 
    31593171    int j = 0;
    31603172
     
    31693181        } else {
    31703182            sepWidget = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->getSeparatorWidget();
    3171             that->separatorWidgets.append(sepWidget);
     3183            separatorWidgets.append(sepWidget);
    31723184        }
    31733185        j++;
     
    31843196        separatorWidgets.at(i)->hide();
    31853197
    3186     that->separatorWidgets.resize(j);
    3187 }
     3198    separatorWidgets.resize(j);
     3199}
     3200#endif //QT_NO_TABBAR
    31883201
    31893202QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const
     
    32383251    return result;
    32393252}
    3240 #endif
    32413253
    32423254// Returns the set of all used separator widgets
     
    32453257    QSet<QWidget*> result;
    32463258
    3247     foreach (QWidget *sepWidget, separatorWidgets)
    3248         result << sepWidget;
     3259    for (int i = 0; i < separatorWidgets.count(); ++i)
     3260        result << separatorWidgets.at(i);
    32493261    for (int i = 0; i < QInternal::DockCount; ++i) {
    32503262        const QDockAreaLayoutInfo &dock = docks[i];
     
    32533265    return result;
    32543266}
    3255 
    3256 QRect QDockAreaLayout::gapRect(QList<int> path) const
     3267#endif
     3268
     3269QRect QDockAreaLayout::gapRect(const QList<int> &path) const
    32573270{
    32583271    const QDockAreaLayoutInfo *info = this->info(path);
Note: See TracChangeset for help on using the changeset viewer.