| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtoolbarlayout.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); | - | ||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | QToolBarItem::QToolBarItem(QWidget *widget) | - | ||||||||||||||||||
| 18 | : QWidgetItem(widget), action(0), customWidget(false) | - | ||||||||||||||||||
| 19 | { | - | ||||||||||||||||||
| 20 | } never executed: end of block | 0 | ||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | bool QToolBarItem::isEmpty() const | - | ||||||||||||||||||
| 23 | { | - | ||||||||||||||||||
| 24 | return never executed: action == 0 || !action->isVisible();return action == 0 || !action->isVisible();never executed: return action == 0 || !action->isVisible(); | 0 | ||||||||||||||||||
| 25 | } | - | ||||||||||||||||||
| 26 | - | |||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | QToolBarLayout::QToolBarLayout(QWidget *parent) | - | ||||||||||||||||||
| 32 | : QLayout(parent), expanded(false), animating(false), dirty(true), | - | ||||||||||||||||||
| 33 | expanding(false), empty(true), expandFlag(false), popupMenu(0) | - | ||||||||||||||||||
| 34 | { | - | ||||||||||||||||||
| 35 | QToolBar *tb = qobject_cast<QToolBar*>(parent); | - | ||||||||||||||||||
| 36 | if (!tb
| 0 | ||||||||||||||||||
| 37 | return; never executed: return; | 0 | ||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | extension = new QToolBarExtension(tb); | - | ||||||||||||||||||
| 40 | extension->setFocusPolicy(Qt::NoFocus); | - | ||||||||||||||||||
| 41 | extension->hide(); | - | ||||||||||||||||||
| 42 | QObject::connect(tb, qFlagLocation("2""orientationChanged(Qt::Orientation)" "\0" __FILE__ ":" "94"), | - | ||||||||||||||||||
| 43 | extension, qFlagLocation("1""setOrientation(Qt::Orientation)" "\0" __FILE__ ":" "95")); | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | setUsePopupMenu(qobject_cast<QMainWindow*>(tb->parentWidget()) == 0); | - | ||||||||||||||||||
| 46 | } never executed: end of block | 0 | ||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | QToolBarLayout::~QToolBarLayout() | - | ||||||||||||||||||
| 49 | { | - | ||||||||||||||||||
| 50 | while (!items.isEmpty()
| 0 | ||||||||||||||||||
| 51 | QToolBarItem *item = items.takeFirst(); | - | ||||||||||||||||||
| 52 | if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action)
| 0 | ||||||||||||||||||
| 53 | if (item->customWidget
| 0 | ||||||||||||||||||
| 54 | widgetAction->releaseWidget(item->widget()); never executed: widgetAction->releaseWidget(item->widget()); | 0 | ||||||||||||||||||
| 55 | } never executed: end of block | 0 | ||||||||||||||||||
| 56 | delete item; | - | ||||||||||||||||||
| 57 | } never executed: end of block | 0 | ||||||||||||||||||
| 58 | } never executed: end of block | 0 | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | void QToolBarLayout::updateMarginAndSpacing() | - | ||||||||||||||||||
| 61 | { | - | ||||||||||||||||||
| 62 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - | ||||||||||||||||||
| 63 | if (!tb
| 0 | ||||||||||||||||||
| 64 | return; never executed: return; | 0 | ||||||||||||||||||
| 65 | QStyle *style = tb->style(); | - | ||||||||||||||||||
| 66 | QStyleOptionToolBar opt; | - | ||||||||||||||||||
| 67 | tb->initStyleOption(&opt); | - | ||||||||||||||||||
| 68 | setMargin(style->pixelMetric(QStyle::PM_ToolBarItemMargin, &opt, tb) | - | ||||||||||||||||||
| 69 | + style->pixelMetric(QStyle::PM_ToolBarFrameWidth, &opt, tb)); | - | ||||||||||||||||||
| 70 | setSpacing(style->pixelMetric(QStyle::PM_ToolBarItemSpacing, &opt, tb)); | - | ||||||||||||||||||
| 71 | } never executed: end of block | 0 | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | bool QToolBarLayout::hasExpandFlag() const | - | ||||||||||||||||||
| 74 | { | - | ||||||||||||||||||
| 75 | return never executed: expandFlag;return expandFlag;never executed: return expandFlag; | 0 | ||||||||||||||||||
| 76 | } | - | ||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | void QToolBarLayout::setUsePopupMenu(bool set) | - | ||||||||||||||||||
| 79 | { | - | ||||||||||||||||||
| 80 | if (!dirty
| 0 | ||||||||||||||||||
| 81 | invalidate(); never executed: invalidate(); | 0 | ||||||||||||||||||
| 82 | if (!set
| 0 | ||||||||||||||||||
| 83 | QObject::connect(extension, qFlagLocation("2""clicked(bool)" "\0" __FILE__ ":" "135"), | - | ||||||||||||||||||
| 84 | this, qFlagLocation("1""setExpanded(bool)" "\0" __FILE__ ":" "136"), Qt::UniqueConnection); | - | ||||||||||||||||||
| 85 | extension->setPopupMode(QToolButton::DelayedPopup); | - | ||||||||||||||||||
| 86 | extension->setMenu(0); | - | ||||||||||||||||||
| 87 | delete popupMenu; | - | ||||||||||||||||||
| 88 | popupMenu = 0; | - | ||||||||||||||||||
| 89 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 90 | QObject::disconnect(extension, qFlagLocation("2""clicked(bool)" "\0" __FILE__ ":" "142"), | - | ||||||||||||||||||
| 91 | this, qFlagLocation("1""setExpanded(bool)" "\0" __FILE__ ":" "143")); | - | ||||||||||||||||||
| 92 | extension->setPopupMode(QToolButton::InstantPopup); | - | ||||||||||||||||||
| 93 | if (!popupMenu
| 0 | ||||||||||||||||||
| 94 | popupMenu = new QMenu(extension); | - | ||||||||||||||||||
| 95 | } never executed: end of block | 0 | ||||||||||||||||||
| 96 | extension->setMenu(popupMenu); | - | ||||||||||||||||||
| 97 | } never executed: end of block | 0 | ||||||||||||||||||
| 98 | } | - | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | void QToolBarLayout::checkUsePopupMenu() | - | ||||||||||||||||||
| 101 | { | - | ||||||||||||||||||
| 102 | QToolBar *tb = static_cast<QToolBar *>(parent()); | - | ||||||||||||||||||
| 103 | QMainWindow *mw = qobject_cast<QMainWindow *>(tb->parent()); | - | ||||||||||||||||||
| 104 | Qt::Orientation o = tb->orientation(); | - | ||||||||||||||||||
| 105 | setUsePopupMenu(!mw || tb->isFloating() || perp(o, expandedSize(mw->size())) >= perp(o, mw->size())); | - | ||||||||||||||||||
| 106 | } never executed: end of block | 0 | ||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | void QToolBarLayout::addItem(QLayoutItem*) | - | ||||||||||||||||||
| 109 | { | - | ||||||||||||||||||
| 110 | QMessageLogger(__FILE__, 162, __PRETTY_FUNCTION__).warning("QToolBarLayout::addItem(): please use addAction() instead"); | - | ||||||||||||||||||
| 111 | return; never executed: return; | 0 | ||||||||||||||||||
| 112 | } | - | ||||||||||||||||||
| 113 | - | |||||||||||||||||||
| 114 | QLayoutItem *QToolBarLayout::itemAt(int index) const | - | ||||||||||||||||||
| 115 | { | - | ||||||||||||||||||
| 116 | if (index < 0
| 0 | ||||||||||||||||||
| 117 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 118 | return never executed: items.at(index);return items.at(index);never executed: return items.at(index); | 0 | ||||||||||||||||||
| 119 | } | - | ||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | QLayoutItem *QToolBarLayout::takeAt(int index) | - | ||||||||||||||||||
| 122 | { | - | ||||||||||||||||||
| 123 | if (index < 0
| 0 | ||||||||||||||||||
| 124 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 125 | QToolBarItem *item = items.takeAt(index); | - | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | if (popupMenu
| 0 | ||||||||||||||||||
| 128 | popupMenu->removeAction(item->action); never executed: popupMenu->removeAction(item->action); | 0 | ||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action); | - | ||||||||||||||||||
| 131 | if (widgetAction != 0
| 0 | ||||||||||||||||||
| 132 | widgetAction->releaseWidget(item->widget()); | - | ||||||||||||||||||
| 133 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 134 | - | |||||||||||||||||||
| 135 | item->widget()->hide(); | - | ||||||||||||||||||
| 136 | item->widget()->deleteLater(); | - | ||||||||||||||||||
| 137 | } never executed: end of block | 0 | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | invalidate(); | - | ||||||||||||||||||
| 140 | return never executed: item;return item;never executed: return item; | 0 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | void QToolBarLayout::insertAction(int index, QAction *action) | - | ||||||||||||||||||
| 144 | { | - | ||||||||||||||||||
| 145 | index = qMax(0, index); | - | ||||||||||||||||||
| 146 | index = qMin(items.count(), index); | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | QToolBarItem *item = createItem(action); | - | ||||||||||||||||||
| 149 | if (item
| 0 | ||||||||||||||||||
| 150 | items.insert(index, item); | - | ||||||||||||||||||
| 151 | invalidate(); | - | ||||||||||||||||||
| 152 | } never executed: end of block | 0 | ||||||||||||||||||
| 153 | } never executed: end of block | 0 | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | int QToolBarLayout::indexOf(QAction *action) const | - | ||||||||||||||||||
| 156 | { | - | ||||||||||||||||||
| 157 | for (int i = 0; i < items.count()
| 0 | ||||||||||||||||||
| 158 | if (items.at(i)->action == action
| 0 | ||||||||||||||||||
| 159 | return never executed: i;return i;never executed: return i; | 0 | ||||||||||||||||||
| 160 | } never executed: end of block | 0 | ||||||||||||||||||
| 161 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 162 | } | - | ||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | int QToolBarLayout::count() const | - | ||||||||||||||||||
| 165 | { | - | ||||||||||||||||||
| 166 | return never executed: items.count();return items.count();never executed: return items.count(); | 0 | ||||||||||||||||||
| 167 | } | - | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | bool QToolBarLayout::isEmpty() const | - | ||||||||||||||||||
| 170 | { | - | ||||||||||||||||||
| 171 | if (dirty
| 0 | ||||||||||||||||||
| 172 | updateGeomArray(); never executed: updateGeomArray(); | 0 | ||||||||||||||||||
| 173 | return never executed: empty;return empty;never executed: return empty; | 0 | ||||||||||||||||||
| 174 | } | - | ||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | void QToolBarLayout::invalidate() | - | ||||||||||||||||||
| 177 | { | - | ||||||||||||||||||
| 178 | dirty = true; | - | ||||||||||||||||||
| 179 | QLayout::invalidate(); | - | ||||||||||||||||||
| 180 | } never executed: end of block | 0 | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | Qt::Orientations QToolBarLayout::expandingDirections() const | - | ||||||||||||||||||
| 183 | { | - | ||||||||||||||||||
| 184 | if (dirty
| 0 | ||||||||||||||||||
| 185 | updateGeomArray(); never executed: updateGeomArray(); | 0 | ||||||||||||||||||
| 186 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - | ||||||||||||||||||
| 187 | if (!tb
| 0 | ||||||||||||||||||
| 188 | return never executed: Qt::Orientations(0);return Qt::Orientations(0);never executed: return Qt::Orientations(0); | 0 | ||||||||||||||||||
| 189 | Qt::Orientation o = tb->orientation(); | - | ||||||||||||||||||
| 190 | return never executed: expanding ? Qt::Orientations(o) : Qt::Orientations(0);return expanding ? Qt::Orientations(o) : Qt::Orientations(0);never executed: return expanding ? Qt::Orientations(o) : Qt::Orientations(0); | 0 | ||||||||||||||||||
| 191 | } | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | bool QToolBarLayout::movable() const | - | ||||||||||||||||||
| 194 | { | - | ||||||||||||||||||
| 195 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - | ||||||||||||||||||
| 196 | if (!tb
| 0 | ||||||||||||||||||
| 197 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 198 | QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget()); | - | ||||||||||||||||||
| 199 | return never executed: tb->isMovable() && win != 0;return tb->isMovable() && win != 0;never executed: return tb->isMovable() && win != 0; | 0 | ||||||||||||||||||
| 200 | } | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | void QToolBarLayout::updateGeomArray() const | - | ||||||||||||||||||
| 203 | { | - | ||||||||||||||||||
| 204 | if (!dirty
| 0 | ||||||||||||||||||
| 205 | return; never executed: return; | 0 | ||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | QToolBarLayout *that = const_cast<QToolBarLayout*>(this); | - | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - | ||||||||||||||||||
| 210 | if (!tb
| 0 | ||||||||||||||||||
| 211 | return; never executed: return; | 0 | ||||||||||||||||||
| 212 | QStyle *style = tb->style(); | - | ||||||||||||||||||
| 213 | QStyleOptionToolBar opt; | - | ||||||||||||||||||
| 214 | tb->initStyleOption(&opt); | - | ||||||||||||||||||
| 215 | const int handleExtent = movable()
| 0 | ||||||||||||||||||
| 216 | ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0; | - | ||||||||||||||||||
| 217 | const int margin = this->margin(); | - | ||||||||||||||||||
| 218 | const int spacing = this->spacing(); | - | ||||||||||||||||||
| 219 | const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb); | - | ||||||||||||||||||
| 220 | Qt::Orientation o = tb->orientation(); | - | ||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | that->minSize = QSize(0, 0); | - | ||||||||||||||||||
| 223 | that->hint = QSize(0, 0); | - | ||||||||||||||||||
| 224 | rperp(o, that->minSize) = style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb); | - | ||||||||||||||||||
| 225 | rperp(o, that->hint) = style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb); | - | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | that->expanding = false; | - | ||||||||||||||||||
| 228 | that->empty = false; | - | ||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | QVector<QLayoutStruct> a(items.count() + 1); | - | ||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | int count = 0; | - | ||||||||||||||||||
| 233 | for (int i = 0; i < items.count()
| 0 | ||||||||||||||||||
| 234 | QToolBarItem *item = items.at(i); | - | ||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | QSize max = item->maximumSize(); | - | ||||||||||||||||||
| 237 | QSize min = item->minimumSize(); | - | ||||||||||||||||||
| 238 | QSize hint = item->sizeHint(); | - | ||||||||||||||||||
| 239 | Qt::Orientations exp = item->expandingDirections(); | - | ||||||||||||||||||
| 240 | bool empty = item->isEmpty(); | - | ||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | that->expanding = expanding
| 0 | ||||||||||||||||||
| 243 | - | |||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | if (item->widget()
| 0 | ||||||||||||||||||
| 246 | if ((
| 0 | ||||||||||||||||||
| 247 | that->expandFlag = true; | - | ||||||||||||||||||
| 248 | } never executed: end of block | 0 | ||||||||||||||||||
| 249 | } never executed: end of block | 0 | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | if (!empty
| 0 | ||||||||||||||||||
| 252 | if (count == 0
| 0 | ||||||||||||||||||
| 253 | rpick(o, that->minSize) += pick(o, min); never executed: rpick(o, that->minSize) += pick(o, min); | 0 | ||||||||||||||||||
| 254 | int s = perp(o, minSize); | - | ||||||||||||||||||
| 255 | rperp(o, that->minSize) = qMax(s, perp(o, min)); | - | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | rpick(o, that->hint) += (count == 0
| 0 | ||||||||||||||||||
| 259 | s = perp(o, that->hint); | - | ||||||||||||||||||
| 260 | rperp(o, that->hint) = qMax(s, perp(o, hint)); | - | ||||||||||||||||||
| 261 | ++count; | - | ||||||||||||||||||
| 262 | } never executed: end of block | 0 | ||||||||||||||||||
| 263 | - | |||||||||||||||||||
| 264 | a[i].sizeHint = pick(o, hint); | - | ||||||||||||||||||
| 265 | a[i].maximumSize = pick(o, max); | - | ||||||||||||||||||
| 266 | a[i].minimumSize = pick(o, min); | - | ||||||||||||||||||
| 267 | a[i].expansive = exp & o; | - | ||||||||||||||||||
| 268 | if (o == Qt::Horizontal
| 0 | ||||||||||||||||||
| 269 | a[i].stretch = item->widget()->sizePolicy().horizontalStretch(); never executed: a[i].stretch = item->widget()->sizePolicy().horizontalStretch(); | 0 | ||||||||||||||||||
| 270 | else | - | ||||||||||||||||||
| 271 | a[i].stretch = item->widget()->sizePolicy().verticalStretch(); never executed: a[i].stretch = item->widget()->sizePolicy().verticalStretch(); | 0 | ||||||||||||||||||
| 272 | a[i].empty = empty; | - | ||||||||||||||||||
| 273 | } never executed: end of block | 0 | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | that->geomArray = a; | - | ||||||||||||||||||
| 276 | that->empty = count == 0; | - | ||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | rpick(o, that->minSize) += handleExtent; | - | ||||||||||||||||||
| 279 | that->minSize += QSize(2*margin, 2*margin); | - | ||||||||||||||||||
| 280 | if (items.count() > 1
| 0 | ||||||||||||||||||
| 281 | rpick(o, that->minSize) += spacing + extensionExtent; never executed: rpick(o, that->minSize) += spacing + extensionExtent; | 0 | ||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | rpick(o, that->hint) += handleExtent; | - | ||||||||||||||||||
| 284 | that->hint += QSize(2*margin, 2*margin); | - | ||||||||||||||||||
| 285 | that->dirty = false; | - | ||||||||||||||||||
| 286 | } never executed: end of block | 0 | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | static bool defaultWidgetAction(QToolBarItem *item) | - | ||||||||||||||||||
| 289 | { | - | ||||||||||||||||||
| 290 | QWidgetAction *a = qobject_cast<QWidgetAction*>(item->action); | - | ||||||||||||||||||
| 291 | return never executed: a != 0 && a->defaultWidget() == item->widget();return a != 0 && a->defaultWidget() == item->widget();never executed: return a != 0 && a->defaultWidget() == item->widget(); | 0 | ||||||||||||||||||
| 292 | } | - | ||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 | void QToolBarLayout::updateMacBorderMetrics() | - | ||||||||||||||||||
| 295 | { | - | ||||||||||||||||||
| 296 | } | - | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | void QToolBarLayout::setGeometry(const QRect &rect) | - | ||||||||||||||||||
| 299 | { | - | ||||||||||||||||||
| 300 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - | ||||||||||||||||||
| 301 | if (!tb
| 0 | ||||||||||||||||||
| 302 | return; never executed: return; | 0 | ||||||||||||||||||
| 303 | QStyle *style = tb->style(); | - | ||||||||||||||||||
| 304 | QStyleOptionToolBar opt; | - | ||||||||||||||||||
| 305 | tb->initStyleOption(&opt); | - | ||||||||||||||||||
| 306 | const int margin = this->margin(); | - | ||||||||||||||||||
| 307 | const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb); | - | ||||||||||||||||||
| 308 | Qt::Orientation o = tb->orientation(); | - | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | QLayout::setGeometry(rect); | - | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | updateMacBorderMetrics(); | - | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | bool ranOutOfSpace = false; | - | ||||||||||||||||||
| 315 | if (!animating
| 0 | ||||||||||||||||||
| 316 | ranOutOfSpace = layoutActions(rect.size()); never executed: ranOutOfSpace = layoutActions(rect.size()); | 0 | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | if (expanded
| 0 | ||||||||||||||||||
| 319 | Qt::ToolBarArea area = Qt::TopToolBarArea; | - | ||||||||||||||||||
| 320 | if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())
| 0 | ||||||||||||||||||
| 321 | area = win->toolBarArea(tb); never executed: area = win->toolBarArea(tb); | 0 | ||||||||||||||||||
| 322 | QSize hint = sizeHint(); | - | ||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | QPoint pos; | - | ||||||||||||||||||
| 325 | rpick(o, pos) = pick(o, rect.bottomRight()) - margin - extensionExtent + 2; | - | ||||||||||||||||||
| 326 | if (area == Qt::LeftToolBarArea
| 0 | ||||||||||||||||||
| 327 | rperp(o, pos) = perp(o, rect.topLeft()) + margin; never executed: rperp(o, pos) = perp(o, rect.topLeft()) + margin; | 0 | ||||||||||||||||||
| 328 | else | - | ||||||||||||||||||
| 329 | rperp(o, pos) = perp(o, rect.bottomRight()) - margin - (perp(o, hint) - 2*margin) + 1; never executed: rperp(o, pos) = perp(o, rect.bottomRight()) - margin - (perp(o, hint) - 2*margin) + 1; | 0 | ||||||||||||||||||
| 330 | QSize size; | - | ||||||||||||||||||
| 331 | rpick(o, size) = extensionExtent; | - | ||||||||||||||||||
| 332 | rperp(o, size) = perp(o, hint) - 2*margin; | - | ||||||||||||||||||
| 333 | QRect r(pos, size); | - | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | if (o == Qt::Horizontal
| 0 | ||||||||||||||||||
| 336 | r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r); never executed: r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r); | 0 | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | extension->setGeometry(r); | - | ||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | if (extension->isHidden()
| 0 | ||||||||||||||||||
| 341 | extension->show(); never executed: extension->show(); | 0 | ||||||||||||||||||
| 342 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 343 | if (!extension->isHidden()
| 0 | ||||||||||||||||||
| 344 | extension->hide(); never executed: extension->hide(); | 0 | ||||||||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||||||||
| 346 | } | - | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | bool QToolBarLayout::layoutActions(const QSize &size) | - | ||||||||||||||||||
| 349 | { | - | ||||||||||||||||||
| 350 | if (dirty
| 0 | ||||||||||||||||||
| 351 | updateGeomArray(); never executed: updateGeomArray(); | 0 | ||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 | QRect rect(0, 0, size.width(), size.height()); | - | ||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | QList<QWidget*> showWidgets, hideWidgets; | - | ||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - | ||||||||||||||||||
| 358 | if (!tb
| 0 | ||||||||||||||||||
| 359 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 360 | QStyle *style = tb->style(); | - | ||||||||||||||||||
| 361 | QStyleOptionToolBar opt; | - | ||||||||||||||||||
| 362 | tb->initStyleOption(&opt); | - | ||||||||||||||||||
| 363 | const int handleExtent = movable()
| 0 | ||||||||||||||||||
| 364 | ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0; | - | ||||||||||||||||||
| 365 | const int margin = this->margin(); | - | ||||||||||||||||||
| 366 | const int spacing = this->spacing(); | - | ||||||||||||||||||
| 367 | const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb); | - | ||||||||||||||||||
| 368 | Qt::Orientation o = tb->orientation(); | - | ||||||||||||||||||
| 369 | bool extensionMenuContainsOnlyWidgetActions = true; | - | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | int space = pick(o, rect.size()) - 2*margin - handleExtent; | - | ||||||||||||||||||
| 372 | if (space <= 0
| 0 | ||||||||||||||||||
| 373 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 374 | - | |||||||||||||||||||
| 375 | if(popupMenu
| 0 | ||||||||||||||||||
| 376 | popupMenu->clear(); never executed: popupMenu->clear(); | 0 | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | bool ranOutOfSpace = false; | - | ||||||||||||||||||
| 379 | int rows = 0; | - | ||||||||||||||||||
| 380 | int rowPos = perp(o, rect.topLeft()) + margin; | - | ||||||||||||||||||
| 381 | int i = 0; | - | ||||||||||||||||||
| 382 | while (i < items.count()
| 0 | ||||||||||||||||||
| 383 | QVector<QLayoutStruct> a = geomArray; | - | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | int start = i; | - | ||||||||||||||||||
| 386 | int size = 0; | - | ||||||||||||||||||
| 387 | int prev = -1; | - | ||||||||||||||||||
| 388 | int rowHeight = 0; | - | ||||||||||||||||||
| 389 | int count = 0; | - | ||||||||||||||||||
| 390 | int maximumSize = 0; | - | ||||||||||||||||||
| 391 | bool expansiveRow = false; | - | ||||||||||||||||||
| 392 | for (; i < items.count()
| 0 | ||||||||||||||||||
| 393 | if (a[i].empty
| 0 | ||||||||||||||||||
| 394 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | int newSize = size + (count == 0
| 0 | ||||||||||||||||||
| 397 | if (prev != -1
| 0 | ||||||||||||||||||
| 398 | if (rows == 0
| 0 | ||||||||||||||||||
| 399 | ranOutOfSpace = true; never executed: ranOutOfSpace = true; | 0 | ||||||||||||||||||
| 400 | - | |||||||||||||||||||
| 401 | - | |||||||||||||||||||
| 402 | if (count > 1
| 0 | ||||||||||||||||||
| 403 | i = prev; never executed: i = prev; | 0 | ||||||||||||||||||
| 404 | break; never executed: break; | 0 | ||||||||||||||||||
| 405 | } | - | ||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | if (expanded
| 0 | ||||||||||||||||||
| 408 | rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint())); never executed: rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint())); | 0 | ||||||||||||||||||
| 409 | expansiveRow = expansiveRow
| 0 | ||||||||||||||||||
| 410 | size = newSize; | - | ||||||||||||||||||
| 411 | maximumSize += spacing + (a[i].expansive
| 0 | ||||||||||||||||||
| 412 | prev = i; | - | ||||||||||||||||||
| 413 | ++count; | - | ||||||||||||||||||
| 414 | } never executed: end of block | 0 | ||||||||||||||||||
| 415 | - | |||||||||||||||||||
| 416 | - | |||||||||||||||||||
| 417 | a[i].sizeHint = 0; | - | ||||||||||||||||||
| 418 | a[i].maximumSize = ((1<<24)-1); | - | ||||||||||||||||||
| 419 | a[i].minimumSize = 0; | - | ||||||||||||||||||
| 420 | a[i].expansive = true; | - | ||||||||||||||||||
| 421 | a[i].stretch = 0; | - | ||||||||||||||||||
| 422 | a[i].empty = true; | - | ||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | if (expansiveRow
| 0 | ||||||||||||||||||
| 425 | expansiveRow = false; | - | ||||||||||||||||||
| 426 | a[i].maximumSize = space - maximumSize; | - | ||||||||||||||||||
| 427 | } never executed: end of block | 0 | ||||||||||||||||||
| 428 | - | |||||||||||||||||||
| 429 | qGeomCalc(a, start, i - start + (expansiveRow ? 0 : 1), 0, | - | ||||||||||||||||||
| 430 | space - (ranOutOfSpace ? (extensionExtent + spacing) : 0), | - | ||||||||||||||||||
| 431 | spacing); | - | ||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | for (int j = start; j < i
| 0 | ||||||||||||||||||
| 434 | QToolBarItem *item = items.at(j); | - | ||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | if (a[j].empty
| 0 | ||||||||||||||||||
| 437 | if (!item->widget()->isHidden()
| 0 | ||||||||||||||||||
| 438 | hideWidgets << item->widget(); never executed: hideWidgets << item->widget(); | 0 | ||||||||||||||||||
| 439 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 440 | } | - | ||||||||||||||||||
| 441 | - | |||||||||||||||||||
| 442 | QPoint pos; | - | ||||||||||||||||||
| 443 | rpick(o, pos) = margin + handleExtent + a[j].pos; | - | ||||||||||||||||||
| 444 | rperp(o, pos) = rowPos; | - | ||||||||||||||||||
| 445 | QSize size; | - | ||||||||||||||||||
| 446 | rpick(o, size) = a[j].size; | - | ||||||||||||||||||
| 447 | if (expanded
| 0 | ||||||||||||||||||
| 448 | rperp(o, size) = rowHeight; never executed: rperp(o, size) = rowHeight; | 0 | ||||||||||||||||||
| 449 | else | - | ||||||||||||||||||
| 450 | rperp(o, size) = perp(o, rect.size()) - 2*margin; never executed: rperp(o, size) = perp(o, rect.size()) - 2*margin; | 0 | ||||||||||||||||||
| 451 | QRect r(pos, size); | - | ||||||||||||||||||
| 452 | - | |||||||||||||||||||
| 453 | if (o == Qt::Horizontal
| 0 | ||||||||||||||||||
| 454 | r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r); never executed: r = QStyle::visualRect(parentWidget()->layoutDirection(), rect, r); | 0 | ||||||||||||||||||
| 455 | - | |||||||||||||||||||
| 456 | item->setGeometry(r); | - | ||||||||||||||||||
| 457 | - | |||||||||||||||||||
| 458 | if (item->widget()->isHidden()
| 0 | ||||||||||||||||||
| 459 | showWidgets << item->widget(); never executed: showWidgets << item->widget(); | 0 | ||||||||||||||||||
| 460 | } never executed: end of block | 0 | ||||||||||||||||||
| 461 | - | |||||||||||||||||||
| 462 | if (!expanded
| 0 | ||||||||||||||||||
| 463 | for (int j = i; j < items.count()
| 0 | ||||||||||||||||||
| 464 | QToolBarItem *item = items.at(j); | - | ||||||||||||||||||
| 465 | if (!item->widget()->isHidden()
| 0 | ||||||||||||||||||
| 466 | hideWidgets << item->widget(); never executed: hideWidgets << item->widget(); | 0 | ||||||||||||||||||
| 467 | if (popupMenu
| 0 | ||||||||||||||||||
| 468 | if (!defaultWidgetAction(item)
| 0 | ||||||||||||||||||
| 469 | popupMenu->addAction(item->action); | - | ||||||||||||||||||
| 470 | extensionMenuContainsOnlyWidgetActions = false; | - | ||||||||||||||||||
| 471 | } never executed: end of block | 0 | ||||||||||||||||||
| 472 | } never executed: end of block | 0 | ||||||||||||||||||
| 473 | } never executed: end of block | 0 | ||||||||||||||||||
| 474 | break; never executed: break; | 0 | ||||||||||||||||||
| 475 | } | - | ||||||||||||||||||
| 476 | - | |||||||||||||||||||
| 477 | rowPos += rowHeight + spacing; | - | ||||||||||||||||||
| 478 | ++rows; | - | ||||||||||||||||||
| 479 | } never executed: end of block | 0 | ||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | - | |||||||||||||||||||
| 482 | - | |||||||||||||||||||
| 483 | - | |||||||||||||||||||
| 484 | - | |||||||||||||||||||
| 485 | extension->setEnabled(popupMenu == 0 || !extensionMenuContainsOnlyWidgetActions); | - | ||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | - | |||||||||||||||||||
| 488 | for (int i = 0; i < showWidgets.count()
| 0 | ||||||||||||||||||
| 489 | showWidgets.at(i)->show(); never executed: showWidgets.at(i)->show(); | 0 | ||||||||||||||||||
| 490 | for (int i = 0; i < hideWidgets.count()
| 0 | ||||||||||||||||||
| 491 | hideWidgets.at(i)->hide(); never executed: hideWidgets.at(i)->hide(); | 0 | ||||||||||||||||||
| 492 | - | |||||||||||||||||||
| 493 | return never executed: ranOutOfSpace;return ranOutOfSpace;never executed: return ranOutOfSpace; | 0 | ||||||||||||||||||
| 494 | } | - | ||||||||||||||||||
| 495 | - | |||||||||||||||||||
| 496 | QSize QToolBarLayout::expandedSize(const QSize &size) const | - | ||||||||||||||||||
| 497 | { | - | ||||||||||||||||||
| 498 | if (dirty
| 0 | ||||||||||||||||||
| 499 | updateGeomArray(); never executed: updateGeomArray(); | 0 | ||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - | ||||||||||||||||||
| 502 | if (!tb
| 0 | ||||||||||||||||||
| 503 | return never executed: QSize(0, 0);return QSize(0, 0);never executed: return QSize(0, 0); | 0 | ||||||||||||||||||
| 504 | QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget()); | - | ||||||||||||||||||
| 505 | Qt::Orientation o = tb->orientation(); | - | ||||||||||||||||||
| 506 | QStyle *style = tb->style(); | - | ||||||||||||||||||
| 507 | QStyleOptionToolBar opt; | - | ||||||||||||||||||
| 508 | tb->initStyleOption(&opt); | - | ||||||||||||||||||
| 509 | const int handleExtent = movable()
| 0 | ||||||||||||||||||
| 510 | ? style->pixelMetric(QStyle::PM_ToolBarHandleExtent, &opt, tb) : 0; | - | ||||||||||||||||||
| 511 | const int margin = this->margin(); | - | ||||||||||||||||||
| 512 | const int spacing = this->spacing(); | - | ||||||||||||||||||
| 513 | const int extensionExtent = style->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, tb); | - | ||||||||||||||||||
| 514 | - | |||||||||||||||||||
| 515 | int total_w = 0; | - | ||||||||||||||||||
| 516 | int count = 0; | - | ||||||||||||||||||
| 517 | for (int x = 0; x < items.count()
| 0 | ||||||||||||||||||
| 518 | if (!geomArray[x].empty
| 0 | ||||||||||||||||||
| 519 | total_w += (count == 0
| 0 | ||||||||||||||||||
| 520 | ++count; | - | ||||||||||||||||||
| 521 | } never executed: end of block | 0 | ||||||||||||||||||
| 522 | } never executed: end of block | 0 | ||||||||||||||||||
| 523 | if (count == 0
| 0 | ||||||||||||||||||
| 524 | return never executed: QSize(0, 0);return QSize(0, 0);never executed: return QSize(0, 0); | 0 | ||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | int min_w = pick(o, size); | - | ||||||||||||||||||
| 527 | int rows = (int)qSqrt(qreal(count)); | - | ||||||||||||||||||
| 528 | if (rows == 1
| 0 | ||||||||||||||||||
| 529 | ++ never executed: rows;++rows;never executed: ++rows; | 0 | ||||||||||||||||||
| 530 | int space = total_w/rows + spacing + extensionExtent; | - | ||||||||||||||||||
| 531 | space = qMax(space, min_w - 2*margin - handleExtent); | - | ||||||||||||||||||
| 532 | if (win != 0
| 0 | ||||||||||||||||||
| 533 | space = qMin(space, pick(o, win->size()) - 2*margin - handleExtent); never executed: space = qMin(space, pick(o, win->size()) - 2*margin - handleExtent); | 0 | ||||||||||||||||||
| 534 | - | |||||||||||||||||||
| 535 | int w = 0; | - | ||||||||||||||||||
| 536 | int h = 0; | - | ||||||||||||||||||
| 537 | int i = 0; | - | ||||||||||||||||||
| 538 | while (i < items.count()
| 0 | ||||||||||||||||||
| 539 | int count = 0; | - | ||||||||||||||||||
| 540 | int size = 0; | - | ||||||||||||||||||
| 541 | int prev = -1; | - | ||||||||||||||||||
| 542 | int rowHeight = 0; | - | ||||||||||||||||||
| 543 | for (; i < items.count()
| 0 | ||||||||||||||||||
| 544 | if (geomArray[i].empty
| 0 | ||||||||||||||||||
| 545 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 546 | - | |||||||||||||||||||
| 547 | int newSize = size + (count == 0
| 0 | ||||||||||||||||||
| 548 | rowHeight = qMax(rowHeight, perp(o, items.at(i)->sizeHint())); | - | ||||||||||||||||||
| 549 | if (prev != -1
| 0 | ||||||||||||||||||
| 550 | if (count > 1
| 0 | ||||||||||||||||||
| 551 | size -= spacing + geomArray[prev].minimumSize; | - | ||||||||||||||||||
| 552 | i = prev; | - | ||||||||||||||||||
| 553 | } never executed: end of block | 0 | ||||||||||||||||||
| 554 | break; never executed: break; | 0 | ||||||||||||||||||
| 555 | } | - | ||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | size = newSize; | - | ||||||||||||||||||
| 558 | prev = i; | - | ||||||||||||||||||
| 559 | ++count; | - | ||||||||||||||||||
| 560 | } never executed: end of block | 0 | ||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | w = qMax(size, w); | - | ||||||||||||||||||
| 563 | h += rowHeight + spacing; | - | ||||||||||||||||||
| 564 | } never executed: end of block | 0 | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | w += 2*margin + handleExtent + spacing + extensionExtent; | - | ||||||||||||||||||
| 567 | w = qMax(w, min_w); | - | ||||||||||||||||||
| 568 | if (win != 0
| 0 | ||||||||||||||||||
| 569 | w = qMin(w, pick(o, win->size())); never executed: w = qMin(w, pick(o, win->size())); | 0 | ||||||||||||||||||
| 570 | h += 2*margin - spacing; | - | ||||||||||||||||||
| 571 | - | |||||||||||||||||||
| 572 | QSize result; | - | ||||||||||||||||||
| 573 | rpick(o, result) = w; | - | ||||||||||||||||||
| 574 | rperp(o, result) = h; | - | ||||||||||||||||||
| 575 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||
| 576 | } | - | ||||||||||||||||||
| 577 | - | |||||||||||||||||||
| 578 | void QToolBarLayout::setExpanded(bool exp) | - | ||||||||||||||||||
| 579 | { | - | ||||||||||||||||||
| 580 | QWidget *tb = qobject_cast<QToolBar*>(parentWidget()); | - | ||||||||||||||||||
| 581 | if (!tb
| 0 | ||||||||||||||||||
| 582 | return; never executed: return; | 0 | ||||||||||||||||||
| 583 | if (exp == expanded
| 0 | ||||||||||||||||||
| 584 | return; never executed: return; | 0 | ||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | expanded = exp; | - | ||||||||||||||||||
| 587 | extension->setChecked(expanded); | - | ||||||||||||||||||
| 588 | - | |||||||||||||||||||
| 589 | if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())
| 0 | ||||||||||||||||||
| 590 | - | |||||||||||||||||||
| 591 | - | |||||||||||||||||||
| 592 | - | |||||||||||||||||||
| 593 | animating = !tb->isWindow()
| 0 | ||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | QMainWindowLayout *layout = qt_mainwindow_layout(win); | - | ||||||||||||||||||
| 596 | if (expanded
| 0 | ||||||||||||||||||
| 597 | tb->raise(); | - | ||||||||||||||||||
| 598 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 599 | QList<int> path = layout->layoutState.indexOf(tb); | - | ||||||||||||||||||
| 600 | if (!path.isEmpty()
| 0 | ||||||||||||||||||
| 601 | QRect rect = layout->layoutState.itemRect(path); | - | ||||||||||||||||||
| 602 | layoutActions(rect.size()); | - | ||||||||||||||||||
| 603 | } never executed: end of block | 0 | ||||||||||||||||||
| 604 | } never executed: end of block | 0 | ||||||||||||||||||
| 605 | layout->layoutState.toolBarAreaLayout.apply(animating); | - | ||||||||||||||||||
| 606 | } never executed: end of block | 0 | ||||||||||||||||||
| 607 | } never executed: end of block | 0 | ||||||||||||||||||
| 608 | - | |||||||||||||||||||
| 609 | QSize QToolBarLayout::minimumSize() const | - | ||||||||||||||||||
| 610 | { | - | ||||||||||||||||||
| 611 | if (dirty
| 0 | ||||||||||||||||||
| 612 | updateGeomArray(); never executed: updateGeomArray(); | 0 | ||||||||||||||||||
| 613 | return never executed: minSize;return minSize;never executed: return minSize; | 0 | ||||||||||||||||||
| 614 | } | - | ||||||||||||||||||
| 615 | - | |||||||||||||||||||
| 616 | QSize QToolBarLayout::sizeHint() const | - | ||||||||||||||||||
| 617 | { | - | ||||||||||||||||||
| 618 | if (dirty
| 0 | ||||||||||||||||||
| 619 | updateGeomArray(); never executed: updateGeomArray(); | 0 | ||||||||||||||||||
| 620 | return never executed: hint;return hint;never executed: return hint; | 0 | ||||||||||||||||||
| 621 | } | - | ||||||||||||||||||
| 622 | - | |||||||||||||||||||
| 623 | QToolBarItem *QToolBarLayout::createItem(QAction *action) | - | ||||||||||||||||||
| 624 | { | - | ||||||||||||||||||
| 625 | bool customWidget = false; | - | ||||||||||||||||||
| 626 | bool standardButtonWidget = false; | - | ||||||||||||||||||
| 627 | QWidget *widget = 0; | - | ||||||||||||||||||
| 628 | QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); | - | ||||||||||||||||||
| 629 | if (!tb
| 0 | ||||||||||||||||||
| 630 | return never executed: (QToolBarItem *)0;return (QToolBarItem *)0;never executed: return (QToolBarItem *)0; | 0 | ||||||||||||||||||
| 631 | - | |||||||||||||||||||
| 632 | if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action)
| 0 | ||||||||||||||||||
| 633 | widget = widgetAction->requestWidget(tb); | - | ||||||||||||||||||
| 634 | if (widget != 0
| 0 | ||||||||||||||||||
| 635 | widget->setAttribute(Qt::WA_LayoutUsesWidgetRect); | - | ||||||||||||||||||
| 636 | customWidget = true; | - | ||||||||||||||||||
| 637 | } never executed: end of block | 0 | ||||||||||||||||||
| 638 | } never executed: else if (action->isSeparator()end of block
| 0 | ||||||||||||||||||
| 639 | QToolBarSeparator *sep = new QToolBarSeparator(tb); | - | ||||||||||||||||||
| 640 | connect(tb, qFlagLocation("2""orientationChanged(Qt::Orientation)" "\0" __FILE__ ":" "719"), | - | ||||||||||||||||||
| 641 | sep, qFlagLocation("1""setOrientation(Qt::Orientation)" "\0" __FILE__ ":" "720")); | - | ||||||||||||||||||
| 642 | widget = sep; | - | ||||||||||||||||||
| 643 | } never executed: end of block | 0 | ||||||||||||||||||
| 644 | - | |||||||||||||||||||
| 645 | if (!widget
| 0 | ||||||||||||||||||
| 646 | QToolButton *button = new QToolButton(tb); | - | ||||||||||||||||||
| 647 | button->setAutoRaise(true); | - | ||||||||||||||||||
| 648 | button->setFocusPolicy(Qt::NoFocus); | - | ||||||||||||||||||
| 649 | button->setIconSize(tb->iconSize()); | - | ||||||||||||||||||
| 650 | button->setToolButtonStyle(tb->toolButtonStyle()); | - | ||||||||||||||||||
| 651 | QObject::connect(tb, qFlagLocation("2""iconSizeChanged(QSize)" "\0" __FILE__ ":" "730"), | - | ||||||||||||||||||
| 652 | button, qFlagLocation("1""setIconSize(QSize)" "\0" __FILE__ ":" "731")); | - | ||||||||||||||||||
| 653 | QObject::connect(tb, qFlagLocation("2""toolButtonStyleChanged(Qt::ToolButtonStyle)" "\0" __FILE__ ":" "732"), | - | ||||||||||||||||||
| 654 | button, qFlagLocation("1""setToolButtonStyle(Qt::ToolButtonStyle)" "\0" __FILE__ ":" "733")); | - | ||||||||||||||||||
| 655 | button->setDefaultAction(action); | - | ||||||||||||||||||
| 656 | QObject::connect(button, qFlagLocation("2""triggered(QAction*)" "\0" __FILE__ ":" "735"), tb, qFlagLocation("2""actionTriggered(QAction*)" "\0" __FILE__ ":" "735")); | - | ||||||||||||||||||
| 657 | widget = button; | - | ||||||||||||||||||
| 658 | standardButtonWidget = true; | - | ||||||||||||||||||
| 659 | } never executed: end of block | 0 | ||||||||||||||||||
| 660 | - | |||||||||||||||||||
| 661 | widget->hide(); | - | ||||||||||||||||||
| 662 | QToolBarItem *result = new QToolBarItem(widget); | - | ||||||||||||||||||
| 663 | if (standardButtonWidget
| 0 | ||||||||||||||||||
| 664 | result->setAlignment(Qt::AlignJustify); never executed: result->setAlignment(Qt::AlignJustify); | 0 | ||||||||||||||||||
| 665 | result->customWidget = customWidget; | - | ||||||||||||||||||
| 666 | result->action = action; | - | ||||||||||||||||||
| 667 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||
| 668 | } | - | ||||||||||||||||||
| 669 | - | |||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |