summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qtoolbararealayout.cpp
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2009-06-25 14:48:02 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2009-06-25 14:48:02 (GMT)
commit2d16fc8c596402fe44bb8891733118719f077385 (patch)
tree2f9163c3d8c7584f98314b59a76b903cd06e6850 /src/gui/widgets/qtoolbararealayout.cpp
parent93e3a72f56d4b9ab020c58a2a3fac79be5fe49eb (diff)
parent3e36b311710009039e8ffdfa46702e012f25785b (diff)
downloadQt-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/widgets/qtoolbararealayout.cpp')
-rw-r--r--src/gui/widgets/qtoolbararealayout.cpp36
1 files changed, 19 insertions, 17 deletions
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