diff options
author | David Boddie <dboddie@trolltech.com> | 2009-06-25 14:48:02 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-06-25 14:48:02 (GMT) |
commit | 2d16fc8c596402fe44bb8891733118719f077385 (patch) | |
tree | 2f9163c3d8c7584f98314b59a76b903cd06e6850 /src/gui | |
parent | 93e3a72f56d4b9ab020c58a2a3fac79be5fe49eb (diff) | |
parent | 3e36b311710009039e8ffdfa46702e012f25785b (diff) | |
download | Qt-2d16fc8c596402fe44bb8891733118719f077385.zip Qt-2d16fc8c596402fe44bb8891733118719f077385.tar.gz Qt-2d16fc8c596402fe44bb8891733118719f077385.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/dialogs/qcolordialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_win.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qmime_mac.cpp | 7 | ||||
-rw-r--r-- | src/gui/statemachine/qguistatemachine.cpp | 16 | ||||
-rw-r--r-- | src/gui/styles/qcommonstyle.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/qdockarealayout.cpp | 125 | ||||
-rw-r--r-- | src/gui/widgets/qdockarealayout_p.h | 38 | ||||
-rw-r--r-- | src/gui/widgets/qtoolbararealayout.cpp | 36 | ||||
-rw-r--r-- | src/gui/widgets/qtoolbararealayout_p.h | 20 |
10 files changed, 135 insertions, 122 deletions
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp index 416e14a..42d3a9a 100644 --- a/src/gui/dialogs/qcolordialog.cpp +++ b/src/gui/dialogs/qcolordialog.cpp @@ -1262,7 +1262,7 @@ void QColorShower::retranslateStrings() void QColorShower::updateQColor() { QColor oldQColor(curQColor); - curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), qAlpha(curCol))); + curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), currentAlpha())); if (curQColor != oldQColor) emit currentColorChanged(curQColor); } diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 0c74cfa..324fac7 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1905,10 +1905,14 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam // don't show resize-cursors for fixed-size widgets QRect fs = widget->frameStrut(); if (!widget->isMinimized()) { + if (widget->minimumHeight() == widget->maximumHeight()) { + if (pos.y() < -(fs.top() - fs.left())) + return HTCAPTION; + if (pos.y() >= widget->height()) + return HTBORDER; + } if (widget->minimumWidth() == widget->maximumWidth() && (pos.x() < 0 || pos.x() >= widget->width())) - break; - if (widget->minimumHeight() == widget->maximumHeight() && (pos.y() < -(fs.top() - fs.left()) || pos.y() >= widget->height())) - break; + return HTBORDER; } } diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp index 31c66e4..903b677 100644 --- a/src/gui/kernel/qmime_mac.cpp +++ b/src/gui/kernel/qmime_mac.cpp @@ -502,6 +502,8 @@ QList<QByteArray> QMacPasteboardMimeHTMLText::convertFromMime(const QString &mim #ifdef Q_WS_MAC32 +// This can be removed once 10.6 is the minimum (or we have to require 64-bit) whichever comes first. + #include <QuickTime/QuickTime.h> #include <qlibrary.h> @@ -1099,7 +1101,10 @@ void QMacPasteboardMime::initialize() //standard types that we wrap new QMacPasteboardMimeTiff; #ifdef Q_WS_MAC32 - new QMacPasteboardMimePict; + // 10.6 does automatic synthesis to and from PICT to standard image types (like TIFF), + // so don't bother doing it ourselves, especially since it's not available in 64-bit. + if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6) + new QMacPasteboardMimePict; #endif new QMacPasteboardMimeUnicodeText; new QMacPasteboardMimePlainText; diff --git a/src/gui/statemachine/qguistatemachine.cpp b/src/gui/statemachine/qguistatemachine.cpp index fd14cf9..7fba78e 100644 --- a/src/gui/statemachine/qguistatemachine.cpp +++ b/src/gui/statemachine/qguistatemachine.cpp @@ -154,7 +154,8 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::DeferredDelete: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - case QEvent::DragEnter: +#ifndef QT_NO_DRAGANDDROP + case QEvent::DragEnter: return new QDragEnterEvent(*static_cast<QDragEnterEvent*>(e)); case QEvent::DragMove: return new QDragMoveEvent(*static_cast<QDragMoveEvent*>(e)); @@ -165,6 +166,7 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::DragResponse: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; +#endif case QEvent::ChildAdded: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; @@ -295,12 +297,12 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::StatusTip: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - +#ifndef QT_NO_ACTION case QEvent::ActionChanged: case QEvent::ActionAdded: case QEvent::ActionRemoved: return new QActionEvent(*static_cast<QActionEvent*>(e)); - +#endif case QEvent::FileOpen: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; @@ -386,7 +388,7 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::ZeroTimerEvent: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - +#ifndef QT_NO_GRAPHICSVIEW case QEvent::GraphicsSceneMouseMove: case QEvent::GraphicsSceneMousePress: case QEvent::GraphicsSceneMouseRelease: @@ -450,7 +452,7 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::GraphicsSceneWheel: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - +#endif case QEvent::KeyboardLayoutChange: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; @@ -494,7 +496,7 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::FutureCallOut: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; - +#ifndef QT_NO_GRAPHICSVIEW case QEvent::GraphicsSceneResize: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; @@ -506,7 +508,7 @@ static QEvent *cloneEvent(QEvent *e) me2->setOldPos(me->oldPos()); return me2; } - +#endif case QEvent::CursorChange: Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 24ff792..ed3bdb5 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -3197,7 +3197,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, //have all the information we need (ie. the layout's margin) const QToolBar *tb = qobject_cast<const QToolBar*>(widget); const int margin = tb && tb->layout() ? tb->layout()->margin() : 2; - const int handleExtent = pixelMetric(QStyle::PM_ToolBarExtensionExtent, opt, tb); + const int handleExtent = pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb); if (tbopt->state & QStyle::State_Horizontal) { r = QRect(margin, margin, handleExtent, tbopt->rect.height() - 2*margin); r = QStyle::visualRect(tbopt->direction, tbopt->rect, r); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 829ac12..407fcb6 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2210,6 +2210,7 @@ bool QTextEngine::atWordSeparator(int position) const case '\'': case '"': case '~': + case '|': return true; default: return false; diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index cbfa5bf..ea5e323 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -994,15 +994,15 @@ void QDockAreaLayoutInfo::unnest(int index) } } -void QDockAreaLayoutInfo::remove(QList<int> path) +void QDockAreaLayoutInfo::remove(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); if (path.count() > 1) { - int index = path.takeFirst(); + const int index = path.first(); QDockAreaLayoutItem &item = item_list[index]; Q_ASSERT(item.subinfo != 0); - item.subinfo->remove(path); + item.subinfo->remove(path.mid(1)); unnest(index); } else { int index = path.first(); @@ -1010,18 +1010,18 @@ void QDockAreaLayoutInfo::remove(QList<int> path) } } -QLayoutItem *QDockAreaLayoutInfo::plug(QList<int> path) +QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + int index = path.first(); if (index < 0) index = -index - 1; - if (!path.isEmpty()) { + if (path.count() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->plug(path); + return item.subinfo->plug(path.mid(1)); } QDockAreaLayoutItem &item = item_list[index]; @@ -1059,18 +1059,17 @@ QLayoutItem *QDockAreaLayoutInfo::plug(QList<int> path) return item.widgetItem; } -QLayoutItem *QDockAreaLayoutInfo::unplug(QList<int> path) +QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); + const int index = path.first(); if (path.count() > 1) { - int index = path.takeFirst(); const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->unplug(path); + return item.subinfo->unplug(path.mid(1)); } - int index = path.first(); QDockAreaLayoutItem &item = item_list[index]; int prev = this->prev(index); int next = this->next(index); @@ -1142,12 +1141,12 @@ static QRect dockedGeometry(QWidget *widget) return result; } -bool QDockAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *dockWidgetItem) +bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem) { Q_ASSERT(!path.isEmpty()); bool insert_tabbed = false; - int index = path.takeFirst(); + int index = path.first(); if (index < 0) { insert_tabbed = true; index = -index - 1; @@ -1155,7 +1154,7 @@ bool QDockAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *dockWidgetItem // dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString()); - if (!path.isEmpty()) { + if (path.count() > 1) { QDockAreaLayoutItem &item = item_list[index]; if (item.subinfo == 0 @@ -1194,8 +1193,7 @@ bool QDockAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *dockWidgetItem #endif } - bool result = item.subinfo->insertGap(path, dockWidgetItem); - return result; + return item.subinfo->insertGap(path.mid(1), dockWidgetItem); } // create the gap item @@ -1295,16 +1293,16 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget) return 0; } -QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QList<int> path) +QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) { - int index = path.takeFirst(); + int index = path.first(); if (index < 0) index = -index - 1; if (index >= item_list.count()) return this; - if (path.isEmpty() || item_list.at(index).subinfo == 0) + if (path.count() == 1 || item_list.at(index).subinfo == 0) return this; - return item_list.at(index).subinfo->info(path); + return item_list.at(index).subinfo->info(path.mid(1)); } QRect QDockAreaLayoutInfo::itemRect(int index) const @@ -1335,17 +1333,18 @@ QRect QDockAreaLayoutInfo::itemRect(int index) const return result; } -QRect QDockAreaLayoutInfo::itemRect(QList<int> path) const +QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const { Q_ASSERT(!path.isEmpty()); + const int index = path.first(); if (path.count() > 1) { - const QDockAreaLayoutItem &item = item_list.at(path.takeFirst()); + const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->itemRect(path); + return item.subinfo->itemRect(path.mid(1)); } - return itemRect(path.first()); + return itemRect(index); } QRect QDockAreaLayoutInfo::separatorRect(int index) const @@ -1367,16 +1366,17 @@ QRect QDockAreaLayoutInfo::separatorRect(int index) const return QRect(pos, s); } -QRect QDockAreaLayoutInfo::separatorRect(QList<int> path) const +QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const { Q_ASSERT(!path.isEmpty()); + const int index = path.first(); if (path.count() > 1) { - const QDockAreaLayoutItem &item = item_list.at(path.takeFirst()); + const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->separatorRect(path); + return item.subinfo->separatorRect(path.mid(1)); } - return separatorRect(path.first()); + return separatorRect(index); } QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const @@ -1702,15 +1702,16 @@ void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation, } } -QDockAreaLayoutItem &QDockAreaLayoutInfo::item(QList<int> path) +QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); + const int index = path.first(); if (path.count() > 1) { - QDockAreaLayoutItem &item = item_list[path.takeFirst()]; + const QDockAreaLayoutItem &item = item_list.at(index); Q_ASSERT(item.subinfo != 0); - return item.subinfo->item(path); + return item.subinfo->item(path.mid(1)); } - return item_list[path.first()]; + return item_list[index]; } QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const @@ -2474,37 +2475,37 @@ QDockAreaLayoutInfo *QDockAreaLayout::info(QWidget *widget) return 0; } -QDockAreaLayoutInfo *QDockAreaLayout::info(QList<int> path) +QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - if (path.isEmpty()) + if (path.count() == 1) return &docks[index]; - return docks[index].info(path); + return docks[index].info(path.mid(1)); } -const QDockAreaLayoutInfo *QDockAreaLayout::info(QList<int> path) const +const QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const { return const_cast<QDockAreaLayout*>(this)->info(path); } -QDockAreaLayoutItem &QDockAreaLayout::item(QList<int> path) +QDockAreaLayoutItem &QDockAreaLayout::item(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].item(path); + return docks[index].item(path.mid(1)); } -QRect QDockAreaLayout::itemRect(QList<int> path) const +QRect QDockAreaLayout::itemRect(const QList<int> &path) const { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].itemRect(path); + return docks[index].itemRect(path.mid(1)); } QRect QDockAreaLayout::separatorRect(int index) const @@ -2528,49 +2529,49 @@ QRect QDockAreaLayout::separatorRect(int index) const return QRect(); } -QRect QDockAreaLayout::separatorRect(QList<int> path) const +QRect QDockAreaLayout::separatorRect(const QList<int> &path) const { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - if (path.isEmpty()) + if (path.count() == 1) return separatorRect(index); else - return docks[index].separatorRect(path); + return docks[index].separatorRect(path.mid(1)); } -bool QDockAreaLayout::insertGap(QList<int> path, QLayoutItem *dockWidgetItem) +bool QDockAreaLayout::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].insertGap(path, dockWidgetItem); + return docks[index].insertGap(path.mid(1), dockWidgetItem); } -QLayoutItem *QDockAreaLayout::plug(QList<int> path) +QLayoutItem *QDockAreaLayout::plug(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].plug(path); + return docks[index].plug(path.mid(1)); } -QLayoutItem *QDockAreaLayout::unplug(QList<int> path) +QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].unplug(path); + return docks[index].unplug(path.mid(1)); } -void QDockAreaLayout::remove(QList<int> path) +void QDockAreaLayout::remove(const QList<int> &path) { Q_ASSERT(!path.isEmpty()); - int index = path.takeFirst(); + const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - docks[index].remove(path); + docks[index].remove(path.mid(1)); } static inline int qMin(int i1, int i2, int i3) { return qMin(i1, qMin(i2, i3)); } @@ -3111,14 +3112,12 @@ QRegion QDockAreaLayout::separatorRegion() const return result; } -int QDockAreaLayout::separatorMove(QList<int> separator, const QPoint &origin, +int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &origin, const QPoint &dest) { int delta = 0; int index = separator.last(); - - if (separator.count() > 1) { QDockAreaLayoutInfo *info = this->info(separator); delta = pick(info->o, dest - origin); @@ -3255,7 +3254,7 @@ QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const return result; } -QRect QDockAreaLayout::gapRect(QList<int> path) const +QRect QDockAreaLayout::gapRect(const QList<int> &path) const { const QDockAreaLayoutInfo *info = this->info(path); if (info == 0) diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h index 771aa52..543a201 100644 --- a/src/gui/widgets/qdockarealayout_p.h +++ b/src/gui/widgets/qdockarealayout_p.h @@ -136,18 +136,18 @@ public: QSize sizeHint() const; QSize size() const; - bool insertGap(QList<int> path, QLayoutItem *dockWidgetItem); - QLayoutItem *plug(QList<int> path); - QLayoutItem *unplug(QList<int> path); + bool insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem); + QLayoutItem *plug(const QList<int> &path); + QLayoutItem *unplug(const QList<int> &path); enum TabMode { NoTabs, AllowTabs, ForceTabs }; QList<int> gapIndex(const QPoint &pos, bool nestingEnabled, TabMode tabMode) const; - void remove(QList<int> path); + void remove(const QList<int> &path); void unnest(int index); void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem); void tab(int index, QLayoutItem *dockWidgetItem); - QDockAreaLayoutItem &item(QList<int> path); - QDockAreaLayoutInfo *info(QList<int> path); + QDockAreaLayoutItem &item(const QList<int> &path); + QDockAreaLayoutInfo *info(const QList<int> &path); QDockAreaLayoutInfo *info(QWidget *widget); enum { // sentinel values used to validate state data @@ -162,9 +162,9 @@ public: bool expansive(Qt::Orientation o) const; int changeSize(int index, int size, bool below); QRect itemRect(int index) const; - QRect itemRect(QList<int> path) const; + QRect itemRect(const QList<int> &path) const; QRect separatorRect(int index) const; - QRect separatorRect(QList<int> path) const; + QRect separatorRect(const QList<int> &path) const; void clear(); bool isEmpty() const; @@ -246,18 +246,18 @@ public: QList<int> gapIndex(const QPoint &pos) const; QList<int> findSeparator(const QPoint &pos) const; - QDockAreaLayoutItem &item(QList<int> path); - QDockAreaLayoutInfo *info(QList<int> path); - const QDockAreaLayoutInfo *info(QList<int> path) const; + QDockAreaLayoutItem &item(const QList<int> &path); + QDockAreaLayoutInfo *info(const QList<int> &path); + const QDockAreaLayoutInfo *info(const QList<int> &path) const; QDockAreaLayoutInfo *info(QWidget *widget); - QRect itemRect(QList<int> path) const; + QRect itemRect(const QList<int> &path) const; QRect separatorRect(int index) const; - QRect separatorRect(QList<int> path) const; + QRect separatorRect(const QList<int> &path) const; - bool insertGap(QList<int> path, QLayoutItem *dockWidgetItem); - QLayoutItem *plug(QList<int> path); - QLayoutItem *unplug(QList<int> path); - void remove(QList<int> path); + bool insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem); + QLayoutItem *plug(const QList<int> &path); + QLayoutItem *unplug(const QList<int> &path); + void remove(const QList<int> &path); void fitLayout(); @@ -277,7 +277,7 @@ public: void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const; QRegion separatorRegion() const; - int separatorMove(QList<int> separator, const QPoint &origin, const QPoint &dest); + int separatorMove(const QList<int> &separator, const QPoint &origin, const QPoint &dest); void updateSeparatorWidgets() const; QLayoutItem *itemAt(int *x, int index) const; @@ -289,7 +289,7 @@ public: void setGrid(QVector<QLayoutStruct> *ver_struct_list, QVector<QLayoutStruct> *hor_struct_list); - QRect gapRect(QList<int> path) const; + QRect gapRect(const QList<int> &path) const; void keepSize(QDockWidget *w); diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index 8a10355..db2afd6 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -526,9 +526,10 @@ QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos) const return QList<int>(); } -bool QToolBarAreaLayoutInfo::insertGap(QList<int> path, QLayoutItem *item) +bool QToolBarAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *item) { - int j = path.at(0); + Q_ASSERT(path.count() == 2); + int j = path.first(); if (j == lines.count()) lines.append(QToolBarAreaLayoutLine(o)); @@ -570,8 +571,9 @@ void QToolBarAreaLayoutInfo::clear() rect = QRect(); } -QRect QToolBarAreaLayoutInfo::itemRect(QList<int> path) const +QRect QToolBarAreaLayoutInfo::itemRect(const QList<int> &path) const { + Q_ASSERT(path.count() == 2); int j = path.at(0); int k = path.at(1); @@ -623,10 +625,8 @@ QRect QToolBarAreaLayoutInfo::appendLineDropRect() const ** QToolBarAreaLayout */ -QToolBarAreaLayout::QToolBarAreaLayout(QMainWindow *win) +QToolBarAreaLayout::QToolBarAreaLayout(const QMainWindow *win) : mainWindow(win), visible(true) { - visible = true; - mainWindow = win; for (int i = 0; i < QInternal::DockCount; ++i) { QInternal::DockPosition pos = static_cast<QInternal::DockPosition>(i); docks[i] = QToolBarAreaLayoutInfo(pos); @@ -1064,16 +1064,17 @@ QList<int> QToolBarAreaLayout::currentGapIndex() const return QList<int>(); } -bool QToolBarAreaLayout::insertGap(QList<int> path, QLayoutItem *item) +bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item) { - Q_ASSERT(!path.isEmpty()); - int i = path.takeFirst(); + Q_ASSERT(path.count() == 3); + const int i = path.first(); Q_ASSERT(i >= 0 && i < QInternal::DockCount); - return docks[i].insertGap(path, item); + return docks[i].insertGap(path.mid(1), item); } -void QToolBarAreaLayout::remove(QList<int> path) +void QToolBarAreaLayout::remove(const QList<int> &path) { + Q_ASSERT(path.count() == 3); docks[path.at(0)].lines[path.at(1)].toolBarItems.removeAt(path.at(2)); } @@ -1104,7 +1105,7 @@ void QToolBarAreaLayout::clear() rect = QRect(); } -QToolBarAreaLayoutItem &QToolBarAreaLayout::item(QList<int> path) +QToolBarAreaLayoutItem &QToolBarAreaLayout::item(const QList<int> &path) { Q_ASSERT(path.count() == 3); @@ -1116,18 +1117,18 @@ QToolBarAreaLayoutItem &QToolBarAreaLayout::item(QList<int> path) return line.toolBarItems[path.at(2)]; } -QRect QToolBarAreaLayout::itemRect(QList<int> path) const +QRect QToolBarAreaLayout::itemRect(const QList<int> &path) const { - int i = path.takeFirst(); + const int i = path.first(); - QRect r = docks[i].itemRect(path); + QRect r = docks[i].itemRect(path.mid(1)); if (docks[i].o == Qt::Horizontal) r = QStyle::visualRect(mainWindow->layoutDirection(), docks[i].rect, r); return r; } -QLayoutItem *QToolBarAreaLayout::plug(QList<int> path) +QLayoutItem *QToolBarAreaLayout::plug(const QList<int> &path) { QToolBarAreaLayoutItem &item = this->item(path); Q_ASSERT(item.gap); @@ -1136,9 +1137,10 @@ QLayoutItem *QToolBarAreaLayout::plug(QList<int> path) return item.widgetItem; } -QLayoutItem *QToolBarAreaLayout::unplug(QList<int> path, QToolBarAreaLayout *other) +QLayoutItem *QToolBarAreaLayout::unplug(const QList<int> &path, QToolBarAreaLayout *other) { //other needs to be update as well + Q_ASSERT(path.count() == 3); QToolBarAreaLayoutItem &item = this->item(path); //update the leading space here diff --git a/src/gui/widgets/qtoolbararealayout_p.h b/src/gui/widgets/qtoolbararealayout_p.h index a44fbc7..636c9ca 100644 --- a/src/gui/widgets/qtoolbararealayout_p.h +++ b/src/gui/widgets/qtoolbararealayout_p.h @@ -174,9 +174,9 @@ public: void moveToolBar(QToolBar *toolbar, int pos); QList<int> gapIndex(const QPoint &pos) const; - bool insertGap(QList<int> path, QLayoutItem *item); + bool insertGap(const QList<int> &path, QLayoutItem *item); void clear(); - QRect itemRect(QList<int> path) const; + QRect itemRect(const QList<int> &path) const; QRect appendLineDropRect() const; QRect rect; @@ -194,11 +194,11 @@ public: }; QRect rect; - QMainWindow *mainWindow; + const QMainWindow *mainWindow; QToolBarAreaLayoutInfo docks[4]; bool visible; - QToolBarAreaLayout(QMainWindow *win); + QToolBarAreaLayout(const QMainWindow *win); QRect fitLayout(); @@ -230,14 +230,14 @@ public: QList<int> indexOf(QWidget *toolBar) const; QList<int> gapIndex(const QPoint &pos) const; QList<int> currentGapIndex() const; - bool insertGap(QList<int> path, QLayoutItem *item); - void remove(QList<int> path); + bool insertGap(const QList<int> &path, QLayoutItem *item); + void remove(const QList<int> &path); void remove(QLayoutItem *item); void clear(); - QToolBarAreaLayoutItem &item(QList<int> path); - QRect itemRect(QList<int> path) const; - QLayoutItem *plug(QList<int> path); - QLayoutItem *unplug(QList<int> path, QToolBarAreaLayout *other); + QToolBarAreaLayoutItem &item(const QList<int> &path); + QRect itemRect(const QList<int> &path) const; + QLayoutItem *plug(const QList<int> &path); + QLayoutItem *unplug(const QList<int> &path, QToolBarAreaLayout *other); void saveState(QDataStream &stream) const; bool restoreState(QDataStream &stream, const QList<QToolBar*> &toolBars, uchar tmarker, bool pre43, bool testing = false); |