| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtoolbararealayout.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow); | - | ||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||
| 14 | QSize QToolBarAreaLayoutItem::minimumSize() const | - | ||||||||||||||||||||||||
| 15 | { | - | ||||||||||||||||||||||||
| 16 | if (skip()
| 0 | ||||||||||||||||||||||||
| 17 | return never executed: QSize(0, 0);return QSize(0, 0);never executed: return QSize(0, 0); | 0 | ||||||||||||||||||||||||
| 18 | return never executed: qSmartMinSize(static_cast<QWidgetItem*>(widgetItem));return qSmartMinSize(static_cast<QWidgetItem*>(widgetItem));never executed: return qSmartMinSize(static_cast<QWidgetItem*>(widgetItem)); | 0 | ||||||||||||||||||||||||
| 19 | } | - | ||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | QSize QToolBarAreaLayoutItem::sizeHint() const | - | ||||||||||||||||||||||||
| 22 | { | - | ||||||||||||||||||||||||
| 23 | if (skip()
| 0 | ||||||||||||||||||||||||
| 24 | return never executed: QSize(0, 0);return QSize(0, 0);never executed: return QSize(0, 0); | 0 | ||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | return never executed: realSizeHint();return realSizeHint();never executed: return realSizeHint(); | 0 | ||||||||||||||||||||||||
| 27 | } | - | ||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | QSize QToolBarAreaLayoutItem::realSizeHint() const | - | ||||||||||||||||||||||||
| 31 | { | - | ||||||||||||||||||||||||
| 32 | QWidget *wid = widgetItem->widget(); | - | ||||||||||||||||||||||||
| 33 | QSize s = wid->sizeHint().expandedTo(wid->minimumSizeHint()); | - | ||||||||||||||||||||||||
| 34 | if (wid->sizePolicy().horizontalPolicy() == QSizePolicy::Ignored
| 0 | ||||||||||||||||||||||||
| 35 | s.setWidth(0); never executed: s.setWidth(0); | 0 | ||||||||||||||||||||||||
| 36 | if (wid->sizePolicy().verticalPolicy() == QSizePolicy::Ignored
| 0 | ||||||||||||||||||||||||
| 37 | s.setHeight(0); never executed: s.setHeight(0); | 0 | ||||||||||||||||||||||||
| 38 | s = s.boundedTo(wid->maximumSize()) | - | ||||||||||||||||||||||||
| 39 | .expandedTo(wid->minimumSize()); | - | ||||||||||||||||||||||||
| 40 | return never executed: s;return s;never executed: return s; | 0 | ||||||||||||||||||||||||
| 41 | } | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | bool QToolBarAreaLayoutItem::skip() const | - | ||||||||||||||||||||||||
| 44 | { | - | ||||||||||||||||||||||||
| 45 | if (gap
| 0 | ||||||||||||||||||||||||
| 46 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 47 | return never executed: widgetItem == 0 || widgetItem->isEmpty();return widgetItem == 0 || widgetItem->isEmpty();never executed: return widgetItem == 0 || widgetItem->isEmpty(); | 0 | ||||||||||||||||||||||||
| 48 | } | - | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||
| 54 | QToolBarAreaLayoutLine::QToolBarAreaLayoutLine(Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 55 | : o(orientation) | - | ||||||||||||||||||||||||
| 56 | { | - | ||||||||||||||||||||||||
| 57 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | QSize QToolBarAreaLayoutLine::sizeHint() const | - | ||||||||||||||||||||||||
| 60 | { | - | ||||||||||||||||||||||||
| 61 | int a = 0, b = 0; | - | ||||||||||||||||||||||||
| 62 | for (int i = 0; i < toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 63 | const QToolBarAreaLayoutItem &item = toolBarItems.at(i); | - | ||||||||||||||||||||||||
| 64 | if (item.skip()
| 0 | ||||||||||||||||||||||||
| 65 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | QSize sh = item.sizeHint(); | - | ||||||||||||||||||||||||
| 68 | a += item.preferredSize > 0
| 0 | ||||||||||||||||||||||||
| 69 | b = qMax(b, perp(o, sh)); | - | ||||||||||||||||||||||||
| 70 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | QSize result; | - | ||||||||||||||||||||||||
| 73 | rpick(o, result) = a; | - | ||||||||||||||||||||||||
| 74 | rperp(o, result) = b; | - | ||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||
| 76 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 77 | } | - | ||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | QSize QToolBarAreaLayoutLine::minimumSize() const | - | ||||||||||||||||||||||||
| 80 | { | - | ||||||||||||||||||||||||
| 81 | int a = 0, b = 0; | - | ||||||||||||||||||||||||
| 82 | for (int i = 0; i < toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 83 | const QToolBarAreaLayoutItem &item = toolBarItems[i]; | - | ||||||||||||||||||||||||
| 84 | if (item.skip()
| 0 | ||||||||||||||||||||||||
| 85 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | QSize ms = item.minimumSize(); | - | ||||||||||||||||||||||||
| 88 | a += pick(o, ms); | - | ||||||||||||||||||||||||
| 89 | b = qMax(b, perp(o, ms)); | - | ||||||||||||||||||||||||
| 90 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | QSize result; | - | ||||||||||||||||||||||||
| 93 | rpick(o, result) = a; | - | ||||||||||||||||||||||||
| 94 | rperp(o, result) = b; | - | ||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 97 | } | - | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | void QToolBarAreaLayoutLine::fitLayout() | - | ||||||||||||||||||||||||
| 100 | { | - | ||||||||||||||||||||||||
| 101 | int last = -1; | - | ||||||||||||||||||||||||
| 102 | int min = pick(o, minimumSize()); | - | ||||||||||||||||||||||||
| 103 | int space = pick(o, rect.size()); | - | ||||||||||||||||||||||||
| 104 | int extra = qMax(0, space - min); | - | ||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||
| 106 | for (int i = 0; i < toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 107 | QToolBarAreaLayoutItem &item = toolBarItems[i]; | - | ||||||||||||||||||||||||
| 108 | if (item.skip()
| 0 | ||||||||||||||||||||||||
| 109 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | if (QToolBarLayout *tblayout = qobject_cast<QToolBarLayout*>(item.widgetItem->widget()->layout())
| 0 | ||||||||||||||||||||||||
| 112 | tblayout->checkUsePopupMenu(); never executed: tblayout->checkUsePopupMenu(); | 0 | ||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||
| 114 | const int itemMin = pick(o, item.minimumSize()); | - | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | item.size = item.preferredSize > 0
| 0 | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||
| 119 | const int extraSpace = qMin(item.size - itemMin, extra); | - | ||||||||||||||||||||||||
| 120 | item.size = itemMin + extraSpace; | - | ||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | extra -= extraSpace; | - | ||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||
| 124 | last = i; | - | ||||||||||||||||||||||||
| 125 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | int pos = 0; | - | ||||||||||||||||||||||||
| 129 | for (int i = 0; i < toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 130 | QToolBarAreaLayoutItem &item = toolBarItems[i]; | - | ||||||||||||||||||||||||
| 131 | if (item.skip()
| 0 | ||||||||||||||||||||||||
| 132 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | item.pos = pos; | - | ||||||||||||||||||||||||
| 135 | if (i == last
| 0 | ||||||||||||||||||||||||
| 136 | item.size = qMax(0, pick(o, rect.size()) - item.pos); never executed: item.size = qMax(0, pick(o, rect.size()) - item.pos); | 0 | ||||||||||||||||||||||||
| 137 | pos += item.size; | - | ||||||||||||||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 139 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | bool QToolBarAreaLayoutLine::skip() const | - | ||||||||||||||||||||||||
| 142 | { | - | ||||||||||||||||||||||||
| 143 | for (int i = 0; i < toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 144 | if (!toolBarItems.at(i).skip()
| 0 | ||||||||||||||||||||||||
| 145 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 146 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 147 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 148 | } | - | ||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | QToolBarAreaLayoutInfo::QToolBarAreaLayoutInfo(QInternal::DockPosition pos) | - | ||||||||||||||||||||||||
| 155 | : dockPos(pos), dirty(false) | - | ||||||||||||||||||||||||
| 156 | { | - | ||||||||||||||||||||||||
| 157 | switch (pos) { | - | ||||||||||||||||||||||||
| 158 | case never executed: QInternal::LeftDock:case QInternal::LeftDock:never executed: case QInternal::LeftDock: | 0 | ||||||||||||||||||||||||
| 159 | case never executed: QInternal::RightDock:case QInternal::RightDock:never executed: case QInternal::RightDock: | 0 | ||||||||||||||||||||||||
| 160 | o = Qt::Vertical; | - | ||||||||||||||||||||||||
| 161 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 162 | case never executed: QInternal::TopDock:case QInternal::TopDock:never executed: case QInternal::TopDock: | 0 | ||||||||||||||||||||||||
| 163 | case never executed: QInternal::BottomDock:case QInternal::BottomDock:never executed: case QInternal::BottomDock: | 0 | ||||||||||||||||||||||||
| 164 | o = Qt::Horizontal; | - | ||||||||||||||||||||||||
| 165 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 166 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 167 | o = Qt::Horizontal; | - | ||||||||||||||||||||||||
| 168 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 169 | } | - | ||||||||||||||||||||||||
| 170 | } | - | ||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | QSize QToolBarAreaLayoutInfo::sizeHint() const | - | ||||||||||||||||||||||||
| 173 | { | - | ||||||||||||||||||||||||
| 174 | int a = 0, b = 0; | - | ||||||||||||||||||||||||
| 175 | for (int i = 0; i < lines.count()
| 0 | ||||||||||||||||||||||||
| 176 | const QToolBarAreaLayoutLine &l = lines.at(i); | - | ||||||||||||||||||||||||
| 177 | if (l.skip()
| 0 | ||||||||||||||||||||||||
| 178 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | QSize hint = l.sizeHint(); | - | ||||||||||||||||||||||||
| 181 | a = qMax(a, pick(o, hint)); | - | ||||||||||||||||||||||||
| 182 | b += perp(o, hint); | - | ||||||||||||||||||||||||
| 183 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | QSize result; | - | ||||||||||||||||||||||||
| 186 | rpick(o, result) = a; | - | ||||||||||||||||||||||||
| 187 | rperp(o, result) = b; | - | ||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||
| 189 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 190 | } | - | ||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||
| 192 | QSize QToolBarAreaLayoutInfo::minimumSize() const | - | ||||||||||||||||||||||||
| 193 | { | - | ||||||||||||||||||||||||
| 194 | int a = 0, b = 0; | - | ||||||||||||||||||||||||
| 195 | for (int i = 0; i < lines.count()
| 0 | ||||||||||||||||||||||||
| 196 | const QToolBarAreaLayoutLine &l = lines.at(i); | - | ||||||||||||||||||||||||
| 197 | if (l.skip()
| 0 | ||||||||||||||||||||||||
| 198 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | QSize m = l.minimumSize(); | - | ||||||||||||||||||||||||
| 201 | a = qMax(a, pick(o, m)); | - | ||||||||||||||||||||||||
| 202 | b += perp(o, m); | - | ||||||||||||||||||||||||
| 203 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||
| 205 | QSize result; | - | ||||||||||||||||||||||||
| 206 | rpick(o, result) = a; | - | ||||||||||||||||||||||||
| 207 | rperp(o, result) = b; | - | ||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||
| 209 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 210 | } | - | ||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||
| 212 | void QToolBarAreaLayoutInfo::fitLayout() | - | ||||||||||||||||||||||||
| 213 | { | - | ||||||||||||||||||||||||
| 214 | dirty = false; | - | ||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||
| 216 | int b = 0; | - | ||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | bool reverse = dockPos == QInternal::RightDock
| 0 | ||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | int i = reverse
| 0 | ||||||||||||||||||||||||
| 221 | for (;;) { | - | ||||||||||||||||||||||||
| 222 | if ((reverse
| 0 | ||||||||||||||||||||||||
| 223 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | QToolBarAreaLayoutLine &l = lines[i]; | - | ||||||||||||||||||||||||
| 226 | if (!l.skip()
| 0 | ||||||||||||||||||||||||
| 227 | if (o == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 228 | l.rect.setLeft(rect.left()); | - | ||||||||||||||||||||||||
| 229 | l.rect.setRight(rect.right()); | - | ||||||||||||||||||||||||
| 230 | l.rect.setTop(b + rect.top()); | - | ||||||||||||||||||||||||
| 231 | b += l.sizeHint().height(); | - | ||||||||||||||||||||||||
| 232 | l.rect.setBottom(b - 1 + rect.top()); | - | ||||||||||||||||||||||||
| 233 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 234 | l.rect.setTop(rect.top()); | - | ||||||||||||||||||||||||
| 235 | l.rect.setBottom(rect.bottom()); | - | ||||||||||||||||||||||||
| 236 | l.rect.setLeft(b + rect.left()); | - | ||||||||||||||||||||||||
| 237 | b += l.sizeHint().width(); | - | ||||||||||||||||||||||||
| 238 | l.rect.setRight(b - 1 + rect.left()); | - | ||||||||||||||||||||||||
| 239 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 | l.fitLayout(); | - | ||||||||||||||||||||||||
| 242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | i += reverse
| 0 | ||||||||||||||||||||||||
| 245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 246 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||
| 248 | QLayoutItem *QToolBarAreaLayoutInfo::insertToolBar(QToolBar *before, QToolBar *toolBar) | - | ||||||||||||||||||||||||
| 249 | { | - | ||||||||||||||||||||||||
| 250 | toolBar->setOrientation(o); | - | ||||||||||||||||||||||||
| 251 | QLayoutItem *item = new QWidgetItemV2(toolBar); | - | ||||||||||||||||||||||||
| 252 | insertItem(before, item); | - | ||||||||||||||||||||||||
| 253 | return never executed: item;return item;never executed: return item; | 0 | ||||||||||||||||||||||||
| 254 | } | - | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | void QToolBarAreaLayoutInfo::insertItem(QToolBar *before, QLayoutItem *item) | - | ||||||||||||||||||||||||
| 257 | { | - | ||||||||||||||||||||||||
| 258 | if (before == 0
| 0 | ||||||||||||||||||||||||
| 259 | if (lines.isEmpty()
| 0 | ||||||||||||||||||||||||
| 260 | lines.append(QToolBarAreaLayoutLine(o)); never executed: lines.append(QToolBarAreaLayoutLine(o)); | 0 | ||||||||||||||||||||||||
| 261 | lines.last().toolBarItems.append(item); | - | ||||||||||||||||||||||||
| 262 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 263 | } | - | ||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | for (int j = 0; j < lines.count()
| 0 | ||||||||||||||||||||||||
| 266 | QToolBarAreaLayoutLine &line = lines[j]; | - | ||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 269 | if (line.toolBarItems.at(k).widgetItem->widget() == before
| 0 | ||||||||||||||||||||||||
| 270 | line.toolBarItems.insert(k, item); | - | ||||||||||||||||||||||||
| 271 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 272 | } | - | ||||||||||||||||||||||||
| 273 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 274 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 275 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||
| 277 | void QToolBarAreaLayoutInfo::removeToolBar(QToolBar *toolBar) | - | ||||||||||||||||||||||||
| 278 | { | - | ||||||||||||||||||||||||
| 279 | for (int j = 0; j < lines.count()
| 0 | ||||||||||||||||||||||||
| 280 | QToolBarAreaLayoutLine &line = lines[j]; | - | ||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 283 | QToolBarAreaLayoutItem &item = line.toolBarItems[k]; | - | ||||||||||||||||||||||||
| 284 | if (item.widgetItem->widget() == toolBar
| 0 | ||||||||||||||||||||||||
| 285 | delete item.widgetItem; | - | ||||||||||||||||||||||||
| 286 | item.widgetItem = 0; | - | ||||||||||||||||||||||||
| 287 | line.toolBarItems.removeAt(k); | - | ||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | if (line.toolBarItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 290 | lines.removeAt(j); never executed: lines.removeAt(j); | 0 | ||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||
| 292 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 293 | } | - | ||||||||||||||||||||||||
| 294 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 295 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 296 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | void QToolBarAreaLayoutInfo::insertToolBarBreak(QToolBar *before) | - | ||||||||||||||||||||||||
| 299 | { | - | ||||||||||||||||||||||||
| 300 | if (before == 0
| 0 | ||||||||||||||||||||||||
| 301 | if (!lines.isEmpty()
| 0 | ||||||||||||||||||||||||
| 302 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 303 | lines.append(QToolBarAreaLayoutLine(o)); | - | ||||||||||||||||||||||||
| 304 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 305 | } | - | ||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||
| 307 | for (int j = 0; j < lines.count()
| 0 | ||||||||||||||||||||||||
| 308 | QToolBarAreaLayoutLine &line = lines[j]; | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 311 | if (line.toolBarItems.at(k).widgetItem->widget() == before
| 0 | ||||||||||||||||||||||||
| 312 | if (k == 0
| 0 | ||||||||||||||||||||||||
| 313 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||
| 315 | QToolBarAreaLayoutLine newLine(o); | - | ||||||||||||||||||||||||
| 316 | newLine.toolBarItems = line.toolBarItems.mid(k); | - | ||||||||||||||||||||||||
| 317 | line.toolBarItems = line.toolBarItems.mid(0, k); | - | ||||||||||||||||||||||||
| 318 | lines.insert(j + 1, newLine); | - | ||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 321 | } | - | ||||||||||||||||||||||||
| 322 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 323 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 324 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | void QToolBarAreaLayoutInfo::removeToolBarBreak(QToolBar *before) | - | ||||||||||||||||||||||||
| 327 | { | - | ||||||||||||||||||||||||
| 328 | for (int j = 0; j < lines.count()
| 0 | ||||||||||||||||||||||||
| 329 | const QToolBarAreaLayoutLine &line = lines.at(j); | - | ||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||
| 331 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 332 | if (line.toolBarItems.at(k).widgetItem->widget() == before
| 0 | ||||||||||||||||||||||||
| 333 | if (k != 0
| 0 | ||||||||||||||||||||||||
| 334 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 335 | if (j == 0
| 0 | ||||||||||||||||||||||||
| 336 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | lines[j - 1].toolBarItems += lines[j].toolBarItems; | - | ||||||||||||||||||||||||
| 339 | lines.removeAt(j); | - | ||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 342 | } | - | ||||||||||||||||||||||||
| 343 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 344 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||
| 347 | void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos) | - | ||||||||||||||||||||||||
| 348 | { | - | ||||||||||||||||||||||||
| 349 | if (dirty
| 0 | ||||||||||||||||||||||||
| 350 | fitLayout(); never executed: fitLayout(); | 0 | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | dirty = true; | - | ||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||
| 354 | if (o == Qt::Vertical
| 0 | ||||||||||||||||||||||||
| 355 | pos -= rect.top(); never executed: pos -= rect.top(); | 0 | ||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 | for (int j = 0; j < lines.count()
| 0 | ||||||||||||||||||||||||
| 359 | QToolBarAreaLayoutLine &line = lines[j]; | - | ||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||
| 361 | int previousIndex = -1; | - | ||||||||||||||||||||||||
| 362 | int minPos = 0; | - | ||||||||||||||||||||||||
| 363 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 364 | QToolBarAreaLayoutItem ¤t = line.toolBarItems[k]; | - | ||||||||||||||||||||||||
| 365 | if (current.widgetItem->widget() == toolbar
| 0 | ||||||||||||||||||||||||
| 366 | int newPos = current.pos; | - | ||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | if (previousIndex >= 0
| 0 | ||||||||||||||||||||||||
| 369 | QToolBarAreaLayoutItem &previous = line.toolBarItems[previousIndex]; | - | ||||||||||||||||||||||||
| 370 | if (pos < current.pos
| 0 | ||||||||||||||||||||||||
| 371 | newPos = qMax(pos, minPos); | - | ||||||||||||||||||||||||
| 372 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | int maxPos = pick(o, rect.size()); | - | ||||||||||||||||||||||||
| 375 | for(int l = k; l < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 376 | const QToolBarAreaLayoutItem &item = line.toolBarItems.at(l); | - | ||||||||||||||||||||||||
| 377 | if (!item.skip()
| 0 | ||||||||||||||||||||||||
| 378 | maxPos -= pick(o, item.minimumSize()); | - | ||||||||||||||||||||||||
| 379 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 380 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 381 | newPos = qMin(pos, maxPos); | - | ||||||||||||||||||||||||
| 382 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||
| 385 | int extra = newPos - current.pos; | - | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | const int diff = pick(o, previous.sizeHint()) - (previous.size + extra); | - | ||||||||||||||||||||||||
| 390 | if (qAbs(diff) < QApplication::startDragDistance()
| 0 | ||||||||||||||||||||||||
| 391 | - | |||||||||||||||||||||||||
| 392 | extra += diff; | - | ||||||||||||||||||||||||
| 393 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | - | |||||||||||||||||||||||||
| 396 | current.extendSize(line.o, -extra); | - | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | if (extra >= 0
| 0 | ||||||||||||||||||||||||
| 399 | previous.extendSize(line.o, extra); | - | ||||||||||||||||||||||||
| 400 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | extra = -extra; | - | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | for(int l = previousIndex; l >=0
| 0 | ||||||||||||||||||||||||
| 405 | QToolBarAreaLayoutItem &item = line.toolBarItems[l]; | - | ||||||||||||||||||||||||
| 406 | if (!item.skip()
| 0 | ||||||||||||||||||||||||
| 407 | const int minPreferredSize = pick(o, item.minimumSize()); | - | ||||||||||||||||||||||||
| 408 | const int margin = item.size - minPreferredSize; | - | ||||||||||||||||||||||||
| 409 | if (margin < extra
| 0 | ||||||||||||||||||||||||
| 410 | item.resize(line.o, minPreferredSize); | - | ||||||||||||||||||||||||
| 411 | extra -= margin; | - | ||||||||||||||||||||||||
| 412 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 413 | item.extendSize(line.o, -extra); | - | ||||||||||||||||||||||||
| 414 | extra = 0; | - | ||||||||||||||||||||||||
| 415 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 416 | } | - | ||||||||||||||||||||||||
| 417 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 418 | ((!(extra == 0)) ? qt_assert("extra == 0",__FILE__,467) : qt_noop()); | - | ||||||||||||||||||||||||
| 419 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 420 | } else { | - | ||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | } else if (!current.skip()
| 0 | ||||||||||||||||||||||||
| 427 | previousIndex = k; | - | ||||||||||||||||||||||||
| 428 | minPos += pick(o, current.minimumSize()); | - | ||||||||||||||||||||||||
| 429 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 430 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 431 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 432 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||
| 435 | QList<int> QToolBarAreaLayoutInfo::gapIndex(const QPoint &pos, int *minDistance) const | - | ||||||||||||||||||||||||
| 436 | { | - | ||||||||||||||||||||||||
| 437 | if (rect.contains(pos)
| 0 | ||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||
| 441 | const int p = pick(o, pos - rect.topLeft()); | - | ||||||||||||||||||||||||
| 442 | - | |||||||||||||||||||||||||
| 443 | for (int j = 0; j < lines.count()
| 0 | ||||||||||||||||||||||||
| 444 | const QToolBarAreaLayoutLine &line = lines.at(j); | - | ||||||||||||||||||||||||
| 445 | if (line.skip()
| 0 | ||||||||||||||||||||||||
| 446 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 447 | if (!line.rect.contains(pos)
| 0 | ||||||||||||||||||||||||
| 448 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | int k = 0; | - | ||||||||||||||||||||||||
| 451 | for (; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 452 | const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); | - | ||||||||||||||||||||||||
| 453 | if (item.skip()
| 0 | ||||||||||||||||||||||||
| 454 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | int size = qMin(item.size, pick(o, item.sizeHint())); | - | ||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | if (p > item.pos + size
| 0 | ||||||||||||||||||||||||
| 459 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 460 | if (p > item.pos + size/2
| 0 | ||||||||||||||||||||||||
| 461 | ++ never executed: k;++k;never executed: ++k; | 0 | ||||||||||||||||||||||||
| 462 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 463 | } | - | ||||||||||||||||||||||||
| 464 | - | |||||||||||||||||||||||||
| 465 | QList<int> result; | - | ||||||||||||||||||||||||
| 466 | result << j << k; | - | ||||||||||||||||||||||||
| 467 | *minDistance = 0; | - | ||||||||||||||||||||||||
| 468 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 469 | } | - | ||||||||||||||||||||||||
| 470 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 471 | const int dist = distance(pos); | - | ||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | if (dist >= 0
| 0 | ||||||||||||||||||||||||
| 474 | *minDistance = dist; | - | ||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||
| 476 | QList<int> result; | - | ||||||||||||||||||||||||
| 477 | result << lines.count() << 0; | - | ||||||||||||||||||||||||
| 478 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 479 | } | - | ||||||||||||||||||||||||
| 480 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 481 | - | |||||||||||||||||||||||||
| 482 | return never executed: QList<int>();return QList<int>();never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 483 | } | - | ||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||
| 485 | bool QToolBarAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *item) | - | ||||||||||||||||||||||||
| 486 | { | - | ||||||||||||||||||||||||
| 487 | ((!(path.count() == 2)) ? qt_assert("path.count() == 2",__FILE__,536) : qt_noop()); | - | ||||||||||||||||||||||||
| 488 | int j = path.first(); | - | ||||||||||||||||||||||||
| 489 | if (j == lines.count()
| 0 | ||||||||||||||||||||||||
| 490 | lines.append(QToolBarAreaLayoutLine(o)); never executed: lines.append(QToolBarAreaLayoutLine(o)); | 0 | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | QToolBarAreaLayoutLine &line = lines[j]; | - | ||||||||||||||||||||||||
| 493 | const int k = path.at(1); | - | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | QToolBarAreaLayoutItem gap_item; | - | ||||||||||||||||||||||||
| 496 | gap_item.gap = true; | - | ||||||||||||||||||||||||
| 497 | gap_item.widgetItem = item; | - | ||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||
| 500 | for(int p = k - 1 ; p >= 0
| 0 | ||||||||||||||||||||||||
| 501 | QToolBarAreaLayoutItem &previous = line.toolBarItems[p]; | - | ||||||||||||||||||||||||
| 502 | if (!previous.skip()
| 0 | ||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||
| 504 | int previousSizeHint = pick(line.o, previous.sizeHint()); | - | ||||||||||||||||||||||||
| 505 | int previousExtraSpace = previous.size - previousSizeHint; | - | ||||||||||||||||||||||||
| 506 | - | |||||||||||||||||||||||||
| 507 | if (previousExtraSpace > 0
| 0 | ||||||||||||||||||||||||
| 508 | - | |||||||||||||||||||||||||
| 509 | previous.preferredSize = -1; | - | ||||||||||||||||||||||||
| 510 | previous.size = previousSizeHint; | - | ||||||||||||||||||||||||
| 511 | - | |||||||||||||||||||||||||
| 512 | gap_item.resize(o, previousExtraSpace); | - | ||||||||||||||||||||||||
| 513 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 514 | - | |||||||||||||||||||||||||
| 515 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 516 | } | - | ||||||||||||||||||||||||
| 517 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | line.toolBarItems.insert(k, gap_item); | - | ||||||||||||||||||||||||
| 520 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||
| 522 | } | - | ||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | void QToolBarAreaLayoutInfo::clear() | - | ||||||||||||||||||||||||
| 525 | { | - | ||||||||||||||||||||||||
| 526 | lines.clear(); | - | ||||||||||||||||||||||||
| 527 | rect = QRect(); | - | ||||||||||||||||||||||||
| 528 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 529 | - | |||||||||||||||||||||||||
| 530 | QRect QToolBarAreaLayoutInfo::itemRect(const QList<int> &path) const | - | ||||||||||||||||||||||||
| 531 | { | - | ||||||||||||||||||||||||
| 532 | ((!(path.count() == 2)) ? qt_assert("path.count() == 2",__FILE__,581) : qt_noop()); | - | ||||||||||||||||||||||||
| 533 | int j = path.at(0); | - | ||||||||||||||||||||||||
| 534 | int k = path.at(1); | - | ||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | const QToolBarAreaLayoutLine &line = lines.at(j); | - | ||||||||||||||||||||||||
| 537 | const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); | - | ||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||
| 539 | QRect result = line.rect; | - | ||||||||||||||||||||||||
| 540 | - | |||||||||||||||||||||||||
| 541 | if (o == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 542 | result.setLeft(item.pos + line.rect.left()); | - | ||||||||||||||||||||||||
| 543 | result.setWidth(item.size); | - | ||||||||||||||||||||||||
| 544 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 545 | result.setTop(item.pos + line.rect.top()); | - | ||||||||||||||||||||||||
| 546 | result.setHeight(item.size); | - | ||||||||||||||||||||||||
| 547 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 548 | - | |||||||||||||||||||||||||
| 549 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 550 | } | - | ||||||||||||||||||||||||
| 551 | - | |||||||||||||||||||||||||
| 552 | int QToolBarAreaLayoutInfo::distance(const QPoint &pos) const | - | ||||||||||||||||||||||||
| 553 | { | - | ||||||||||||||||||||||||
| 554 | switch (dockPos) { | - | ||||||||||||||||||||||||
| 555 | case never executed: QInternal::LeftDock:case QInternal::LeftDock:never executed: case QInternal::LeftDock: | 0 | ||||||||||||||||||||||||
| 556 | if (pos.y() < rect.bottom()
| 0 | ||||||||||||||||||||||||
| 557 | return never executed: pos.x() - rect.right();return pos.x() - rect.right();never executed: return pos.x() - rect.right(); | 0 | ||||||||||||||||||||||||
| 558 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 559 | case never executed: QInternal::RightDock:case QInternal::RightDock:never executed: case QInternal::RightDock: | 0 | ||||||||||||||||||||||||
| 560 | if (pos.y() < rect.bottom()
| 0 | ||||||||||||||||||||||||
| 561 | return never executed: rect.left() - pos.x();return rect.left() - pos.x();never executed: return rect.left() - pos.x(); | 0 | ||||||||||||||||||||||||
| 562 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 563 | case never executed: QInternal::TopDock:case QInternal::TopDock:never executed: case QInternal::TopDock: | 0 | ||||||||||||||||||||||||
| 564 | if (pos.x() < rect.right()
| 0 | ||||||||||||||||||||||||
| 565 | return never executed: pos.y() - rect.bottom();return pos.y() - rect.bottom();never executed: return pos.y() - rect.bottom(); | 0 | ||||||||||||||||||||||||
| 566 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 567 | case never executed: QInternal::BottomDock:case QInternal::BottomDock:never executed: case QInternal::BottomDock: | 0 | ||||||||||||||||||||||||
| 568 | if (pos.x() < rect.right()
| 0 | ||||||||||||||||||||||||
| 569 | return never executed: rect.top() - pos.y();return rect.top() - pos.y();never executed: return rect.top() - pos.y(); | 0 | ||||||||||||||||||||||||
| 570 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||
| 572 | case never executed: QInternal::DockCount:case QInternal::DockCount:never executed: case QInternal::DockCount: | 0 | ||||||||||||||||||||||||
| 573 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 574 | } | - | ||||||||||||||||||||||||
| 575 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 576 | } | - | ||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||
| 578 | - | |||||||||||||||||||||||||
| 579 | - | |||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||
| 581 | - | |||||||||||||||||||||||||
| 582 | QToolBarAreaLayout::QToolBarAreaLayout(const QMainWindow *win) : mainWindow(win), visible(true) | - | ||||||||||||||||||||||||
| 583 | { | - | ||||||||||||||||||||||||
| 584 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 585 | QInternal::DockPosition pos = static_cast<QInternal::DockPosition>(i); | - | ||||||||||||||||||||||||
| 586 | docks[i] = QToolBarAreaLayoutInfo(pos); | - | ||||||||||||||||||||||||
| 587 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 588 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||
| 590 | QRect QToolBarAreaLayout::fitLayout() | - | ||||||||||||||||||||||||
| 591 | { | - | ||||||||||||||||||||||||
| 592 | if (!visible
| 0 | ||||||||||||||||||||||||
| 593 | return never executed: rect;return rect;never executed: return rect; | 0 | ||||||||||||||||||||||||
| 594 | - | |||||||||||||||||||||||||
| 595 | QSize left_hint = docks[QInternal::LeftDock].sizeHint(); | - | ||||||||||||||||||||||||
| 596 | QSize right_hint = docks[QInternal::RightDock].sizeHint(); | - | ||||||||||||||||||||||||
| 597 | QSize top_hint = docks[QInternal::TopDock].sizeHint(); | - | ||||||||||||||||||||||||
| 598 | QSize bottom_hint = docks[QInternal::BottomDock].sizeHint(); | - | ||||||||||||||||||||||||
| 599 | - | |||||||||||||||||||||||||
| 600 | QRect center = rect.adjusted(left_hint.width(), top_hint.height(), | - | ||||||||||||||||||||||||
| 601 | -right_hint.width(), -bottom_hint.height()); | - | ||||||||||||||||||||||||
| 602 | - | |||||||||||||||||||||||||
| 603 | docks[QInternal::TopDock].rect = QRect(rect.left(), rect.top(), | - | ||||||||||||||||||||||||
| 604 | rect.width(), top_hint.height()); | - | ||||||||||||||||||||||||
| 605 | docks[QInternal::LeftDock].rect = QRect(rect.left(), center.top(), | - | ||||||||||||||||||||||||
| 606 | left_hint.width(), center.height()); | - | ||||||||||||||||||||||||
| 607 | docks[QInternal::RightDock].rect = QRect(center.right() + 1, center.top(), | - | ||||||||||||||||||||||||
| 608 | right_hint.width(), center.height()); | - | ||||||||||||||||||||||||
| 609 | docks[QInternal::BottomDock].rect = QRect(rect.left(), center.bottom() + 1, | - | ||||||||||||||||||||||||
| 610 | rect.width(), bottom_hint.height()); | - | ||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||
| 612 | docks[QInternal::TopDock].fitLayout(); | - | ||||||||||||||||||||||||
| 613 | docks[QInternal::LeftDock].fitLayout(); | - | ||||||||||||||||||||||||
| 614 | docks[QInternal::RightDock].fitLayout(); | - | ||||||||||||||||||||||||
| 615 | docks[QInternal::BottomDock].fitLayout(); | - | ||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||
| 617 | return never executed: center;return center;never executed: return center; | 0 | ||||||||||||||||||||||||
| 618 | } | - | ||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | QSize QToolBarAreaLayout::minimumSize(const QSize ¢erMin) const | - | ||||||||||||||||||||||||
| 621 | { | - | ||||||||||||||||||||||||
| 622 | if (!visible
| 0 | ||||||||||||||||||||||||
| 623 | return never executed: centerMin;return centerMin;never executed: return centerMin; | 0 | ||||||||||||||||||||||||
| 624 | - | |||||||||||||||||||||||||
| 625 | QSize result = centerMin; | - | ||||||||||||||||||||||||
| 626 | - | |||||||||||||||||||||||||
| 627 | QSize left_min = docks[QInternal::LeftDock].minimumSize(); | - | ||||||||||||||||||||||||
| 628 | QSize right_min = docks[QInternal::RightDock].minimumSize(); | - | ||||||||||||||||||||||||
| 629 | QSize top_min = docks[QInternal::TopDock].minimumSize(); | - | ||||||||||||||||||||||||
| 630 | QSize bottom_min = docks[QInternal::BottomDock].minimumSize(); | - | ||||||||||||||||||||||||
| 631 | - | |||||||||||||||||||||||||
| 632 | result.setWidth(qMax(top_min.width(), result.width())); | - | ||||||||||||||||||||||||
| 633 | result.setWidth(qMax(bottom_min.width(), result.width())); | - | ||||||||||||||||||||||||
| 634 | result.setHeight(qMax(left_min.height(), result.height())); | - | ||||||||||||||||||||||||
| 635 | result.setHeight(qMax(right_min.height(), result.height())); | - | ||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||
| 637 | result.rwidth() += left_min.width() + right_min.width(); | - | ||||||||||||||||||||||||
| 638 | result.rheight() += top_min.height() + bottom_min.height(); | - | ||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 641 | } | - | ||||||||||||||||||||||||
| 642 | - | |||||||||||||||||||||||||
| 643 | QSize QToolBarAreaLayout::sizeHint(const QSize ¢erHint) const | - | ||||||||||||||||||||||||
| 644 | { | - | ||||||||||||||||||||||||
| 645 | if (!visible
| 0 | ||||||||||||||||||||||||
| 646 | return never executed: centerHint;return centerHint;never executed: return centerHint; | 0 | ||||||||||||||||||||||||
| 647 | - | |||||||||||||||||||||||||
| 648 | QSize result = centerHint; | - | ||||||||||||||||||||||||
| 649 | - | |||||||||||||||||||||||||
| 650 | QSize left_hint = docks[QInternal::LeftDock].sizeHint(); | - | ||||||||||||||||||||||||
| 651 | QSize right_hint = docks[QInternal::RightDock].sizeHint(); | - | ||||||||||||||||||||||||
| 652 | QSize top_hint = docks[QInternal::TopDock].sizeHint(); | - | ||||||||||||||||||||||||
| 653 | QSize bottom_hint = docks[QInternal::BottomDock].sizeHint(); | - | ||||||||||||||||||||||||
| 654 | - | |||||||||||||||||||||||||
| 655 | result.setWidth(qMax(top_hint.width(), result.width())); | - | ||||||||||||||||||||||||
| 656 | result.setWidth(qMax(bottom_hint.width(), result.width())); | - | ||||||||||||||||||||||||
| 657 | result.setHeight(qMax(left_hint.height(), result.height())); | - | ||||||||||||||||||||||||
| 658 | result.setHeight(qMax(right_hint.height(), result.height())); | - | ||||||||||||||||||||||||
| 659 | - | |||||||||||||||||||||||||
| 660 | result.rwidth() += left_hint.width() + right_hint.width(); | - | ||||||||||||||||||||||||
| 661 | result.rheight() += top_hint.height() + bottom_hint.height(); | - | ||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||
| 663 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 664 | } | - | ||||||||||||||||||||||||
| 665 | - | |||||||||||||||||||||||||
| 666 | QRect QToolBarAreaLayout::rectHint(const QRect &r) const | - | ||||||||||||||||||||||||
| 667 | { | - | ||||||||||||||||||||||||
| 668 | int coef = visible
| 0 | ||||||||||||||||||||||||
| 669 | - | |||||||||||||||||||||||||
| 670 | QRect result = r; | - | ||||||||||||||||||||||||
| 671 | - | |||||||||||||||||||||||||
| 672 | QSize left_hint = docks[QInternal::LeftDock].sizeHint(); | - | ||||||||||||||||||||||||
| 673 | QSize right_hint = docks[QInternal::RightDock].sizeHint(); | - | ||||||||||||||||||||||||
| 674 | QSize top_hint = docks[QInternal::TopDock].sizeHint(); | - | ||||||||||||||||||||||||
| 675 | QSize bottom_hint = docks[QInternal::BottomDock].sizeHint(); | - | ||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||
| 677 | result.adjust(-left_hint.width()*coef, -top_hint.height()*coef, | - | ||||||||||||||||||||||||
| 678 | right_hint.width()*coef, bottom_hint.height()*coef); | - | ||||||||||||||||||||||||
| 679 | - | |||||||||||||||||||||||||
| 680 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 681 | } | - | ||||||||||||||||||||||||
| 682 | - | |||||||||||||||||||||||||
| 683 | QLayoutItem *QToolBarAreaLayout::itemAt(int *x, int index) const | - | ||||||||||||||||||||||||
| 684 | { | - | ||||||||||||||||||||||||
| 685 | ((!(x != 0)) ? qt_assert("x != 0",__FILE__,734) : qt_noop()); | - | ||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||
| 687 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 688 | const QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 691 | const QToolBarAreaLayoutLine &line = dock.lines.at(j); | - | ||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 694 | if ((*
| 0 | ||||||||||||||||||||||||
| 695 | return never executed: line.toolBarItems.at(k).widgetItem;return line.toolBarItems.at(k).widgetItem;never executed: return line.toolBarItems.at(k).widgetItem; | 0 | ||||||||||||||||||||||||
| 696 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 697 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 698 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 701 | } | - | ||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | QLayoutItem *QToolBarAreaLayout::takeAt(int *x, int index) | - | ||||||||||||||||||||||||
| 704 | { | - | ||||||||||||||||||||||||
| 705 | ((!(x != 0)) ? qt_assert("x != 0",__FILE__,754) : qt_noop()); | - | ||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||
| 707 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 708 | QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 711 | QToolBarAreaLayoutLine &line = dock.lines[j]; | - | ||||||||||||||||||||||||
| 712 | - | |||||||||||||||||||||||||
| 713 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 714 | if ((*
| 0 | ||||||||||||||||||||||||
| 715 | QLayoutItem *result = line.toolBarItems.takeAt(k).widgetItem; | - | ||||||||||||||||||||||||
| 716 | if (line.toolBarItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 717 | dock.lines.removeAt(j); never executed: dock.lines.removeAt(j); | 0 | ||||||||||||||||||||||||
| 718 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 719 | } | - | ||||||||||||||||||||||||
| 720 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 721 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 722 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 723 | - | |||||||||||||||||||||||||
| 724 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 725 | } | - | ||||||||||||||||||||||||
| 726 | - | |||||||||||||||||||||||||
| 727 | void QToolBarAreaLayout::deleteAllLayoutItems() | - | ||||||||||||||||||||||||
| 728 | { | - | ||||||||||||||||||||||||
| 729 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 730 | QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||
| 732 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 733 | QToolBarAreaLayoutLine &line = dock.lines[j]; | - | ||||||||||||||||||||||||
| 734 | - | |||||||||||||||||||||||||
| 735 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 736 | QToolBarAreaLayoutItem &item = line.toolBarItems[k]; | - | ||||||||||||||||||||||||
| 737 | if (!item.gap
| 0 | ||||||||||||||||||||||||
| 738 | delete item.widgetItem; never executed: delete item.widgetItem; | 0 | ||||||||||||||||||||||||
| 739 | item.widgetItem = 0; | - | ||||||||||||||||||||||||
| 740 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 741 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 742 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 743 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||
| 745 | QInternal::DockPosition QToolBarAreaLayout::findToolBar(QToolBar *toolBar) const | - | ||||||||||||||||||||||||
| 746 | { | - | ||||||||||||||||||||||||
| 747 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 748 | const QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||
| 750 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 751 | const QToolBarAreaLayoutLine &line = dock.lines.at(j); | - | ||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 754 | if (line.toolBarItems.at(k).widgetItem->widget() == toolBar
| 0 | ||||||||||||||||||||||||
| 755 | return never executed: static_cast<QInternal::DockPosition>(i);return static_cast<QInternal::DockPosition>(i);never executed: return static_cast<QInternal::DockPosition>(i); | 0 | ||||||||||||||||||||||||
| 756 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 757 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 758 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 759 | - | |||||||||||||||||||||||||
| 760 | return never executed: QInternal::DockCount;return QInternal::DockCount;never executed: return QInternal::DockCount; | 0 | ||||||||||||||||||||||||
| 761 | } | - | ||||||||||||||||||||||||
| 762 | - | |||||||||||||||||||||||||
| 763 | QLayoutItem *QToolBarAreaLayout::insertToolBar(QToolBar *before, QToolBar *toolBar) | - | ||||||||||||||||||||||||
| 764 | { | - | ||||||||||||||||||||||||
| 765 | QInternal::DockPosition pos = findToolBar(before); | - | ||||||||||||||||||||||||
| 766 | if (pos == QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 767 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 768 | - | |||||||||||||||||||||||||
| 769 | return never executed: docks[pos].insertToolBar(before, toolBar);return docks[pos].insertToolBar(before, toolBar);never executed: return docks[pos].insertToolBar(before, toolBar); | 0 | ||||||||||||||||||||||||
| 770 | } | - | ||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||
| 772 | void QToolBarAreaLayout::removeToolBar(QToolBar *toolBar) | - | ||||||||||||||||||||||||
| 773 | { | - | ||||||||||||||||||||||||
| 774 | QInternal::DockPosition pos = findToolBar(toolBar); | - | ||||||||||||||||||||||||
| 775 | if (pos == QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 776 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 777 | docks[pos].removeToolBar(toolBar); | - | ||||||||||||||||||||||||
| 778 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 779 | - | |||||||||||||||||||||||||
| 780 | QLayoutItem *QToolBarAreaLayout::addToolBar(QInternal::DockPosition pos, QToolBar *toolBar) | - | ||||||||||||||||||||||||
| 781 | { | - | ||||||||||||||||||||||||
| 782 | return never executed: docks[pos].insertToolBar(0, toolBar);return docks[pos].insertToolBar(0, toolBar);never executed: return docks[pos].insertToolBar(0, toolBar); | 0 | ||||||||||||||||||||||||
| 783 | } | - | ||||||||||||||||||||||||
| 784 | - | |||||||||||||||||||||||||
| 785 | void QToolBarAreaLayout::insertToolBarBreak(QToolBar *before) | - | ||||||||||||||||||||||||
| 786 | { | - | ||||||||||||||||||||||||
| 787 | QInternal::DockPosition pos = findToolBar(before); | - | ||||||||||||||||||||||||
| 788 | if (pos == QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 789 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 790 | docks[pos].insertToolBarBreak(before); | - | ||||||||||||||||||||||||
| 791 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 792 | - | |||||||||||||||||||||||||
| 793 | void QToolBarAreaLayout::removeToolBarBreak(QToolBar *before) | - | ||||||||||||||||||||||||
| 794 | { | - | ||||||||||||||||||||||||
| 795 | QInternal::DockPosition pos = findToolBar(before); | - | ||||||||||||||||||||||||
| 796 | if (pos == QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 797 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 798 | docks[pos].removeToolBarBreak(before); | - | ||||||||||||||||||||||||
| 799 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 800 | - | |||||||||||||||||||||||||
| 801 | void QToolBarAreaLayout::addToolBarBreak(QInternal::DockPosition pos) | - | ||||||||||||||||||||||||
| 802 | { | - | ||||||||||||||||||||||||
| 803 | docks[pos].insertToolBarBreak(0); | - | ||||||||||||||||||||||||
| 804 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||
| 806 | void QToolBarAreaLayout::moveToolBar(QToolBar *toolbar, int p) | - | ||||||||||||||||||||||||
| 807 | { | - | ||||||||||||||||||||||||
| 808 | QInternal::DockPosition pos = findToolBar(toolbar); | - | ||||||||||||||||||||||||
| 809 | if (pos == QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 810 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 811 | docks[pos].moveToolBar(toolbar, p); | - | ||||||||||||||||||||||||
| 812 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 813 | - | |||||||||||||||||||||||||
| 814 | - | |||||||||||||||||||||||||
| 815 | void QToolBarAreaLayout::insertItem(QInternal::DockPosition pos, QLayoutItem *item) | - | ||||||||||||||||||||||||
| 816 | { | - | ||||||||||||||||||||||||
| 817 | if (docks[pos].lines.isEmpty()
| 0 | ||||||||||||||||||||||||
| 818 | docks[pos].lines.append(QToolBarAreaLayoutLine(docks[pos].o)); never executed: docks[pos].lines.append(QToolBarAreaLayoutLine(docks[pos].o)); | 0 | ||||||||||||||||||||||||
| 819 | docks[pos].lines.last().toolBarItems.append(item); | - | ||||||||||||||||||||||||
| 820 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 821 | - | |||||||||||||||||||||||||
| 822 | void QToolBarAreaLayout::insertItem(QToolBar *before, QLayoutItem *item) | - | ||||||||||||||||||||||||
| 823 | { | - | ||||||||||||||||||||||||
| 824 | QInternal::DockPosition pos = findToolBar(before); | - | ||||||||||||||||||||||||
| 825 | if (pos == QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 826 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 827 | - | |||||||||||||||||||||||||
| 828 | docks[pos].insertItem(before, item); | - | ||||||||||||||||||||||||
| 829 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | void QToolBarAreaLayout::apply(bool animate) | - | ||||||||||||||||||||||||
| 832 | { | - | ||||||||||||||||||||||||
| 833 | QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); | - | ||||||||||||||||||||||||
| 834 | ((!(layout != 0)) ? qt_assert("layout != 0",__FILE__,883) : qt_noop()); | - | ||||||||||||||||||||||||
| 835 | - | |||||||||||||||||||||||||
| 836 | Qt::LayoutDirection dir = mainWindow->layoutDirection(); | - | ||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||
| 838 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 839 | const QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 840 | - | |||||||||||||||||||||||||
| 841 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 842 | const QToolBarAreaLayoutLine &line = dock.lines.at(j); | - | ||||||||||||||||||||||||
| 843 | if (line.skip()
| 0 | ||||||||||||||||||||||||
| 844 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 845 | - | |||||||||||||||||||||||||
| 846 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 847 | const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); | - | ||||||||||||||||||||||||
| 848 | if (item.skip()
| 0 | ||||||||||||||||||||||||
| 849 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 850 | - | |||||||||||||||||||||||||
| 851 | QRect geo; | - | ||||||||||||||||||||||||
| 852 | if (visible
| 0 | ||||||||||||||||||||||||
| 853 | if (line.o == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 854 | geo.setTop(line.rect.top()); | - | ||||||||||||||||||||||||
| 855 | geo.setBottom(line.rect.bottom()); | - | ||||||||||||||||||||||||
| 856 | geo.setLeft(line.rect.left() + item.pos); | - | ||||||||||||||||||||||||
| 857 | geo.setRight(line.rect.left() + item.pos + item.size - 1); | - | ||||||||||||||||||||||||
| 858 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 859 | geo.setLeft(line.rect.left()); | - | ||||||||||||||||||||||||
| 860 | geo.setRight(line.rect.right()); | - | ||||||||||||||||||||||||
| 861 | geo.setTop(line.rect.top() + item.pos); | - | ||||||||||||||||||||||||
| 862 | geo.setBottom(line.rect.top() + item.pos + item.size - 1); | - | ||||||||||||||||||||||||
| 863 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 864 | } | - | ||||||||||||||||||||||||
| 865 | - | |||||||||||||||||||||||||
| 866 | QWidget *widget = item.widgetItem->widget(); | - | ||||||||||||||||||||||||
| 867 | if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)
| 0 | ||||||||||||||||||||||||
| 868 | QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(toolBar->layout()); | - | ||||||||||||||||||||||||
| 869 | if (tbl->expanded
| 0 | ||||||||||||||||||||||||
| 870 | QPoint tr = geo.topRight(); | - | ||||||||||||||||||||||||
| 871 | QSize size = tbl->expandedSize(geo.size()); | - | ||||||||||||||||||||||||
| 872 | geo.setSize(size); | - | ||||||||||||||||||||||||
| 873 | geo.moveTopRight(tr); | - | ||||||||||||||||||||||||
| 874 | if (geo.bottom() > rect.bottom()
| 0 | ||||||||||||||||||||||||
| 875 | geo.moveBottom(rect.bottom()); never executed: geo.moveBottom(rect.bottom()); | 0 | ||||||||||||||||||||||||
| 876 | if (geo.right() > rect.right()
| 0 | ||||||||||||||||||||||||
| 877 | geo.moveRight(rect.right()); never executed: geo.moveRight(rect.right()); | 0 | ||||||||||||||||||||||||
| 878 | if (geo.left() < 0
| 0 | ||||||||||||||||||||||||
| 879 | geo.moveLeft(0); never executed: geo.moveLeft(0); | 0 | ||||||||||||||||||||||||
| 880 | if (geo.top() < 0
| 0 | ||||||||||||||||||||||||
| 881 | geo.moveTop(0); never executed: geo.moveTop(0); | 0 | ||||||||||||||||||||||||
| 882 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 883 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 884 | - | |||||||||||||||||||||||||
| 885 | if (visible
| 0 | ||||||||||||||||||||||||
| 886 | geo = QStyle::visualRect(dir, line.rect, geo); never executed: geo = QStyle::visualRect(dir, line.rect, geo); | 0 | ||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||
| 888 | layout->widgetAnimator.animate(widget, geo, animate); | - | ||||||||||||||||||||||||
| 889 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 890 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 891 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 892 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||
| 894 | bool QToolBarAreaLayout::toolBarBreak(QToolBar *toolBar) const | - | ||||||||||||||||||||||||
| 895 | { | - | ||||||||||||||||||||||||
| 896 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 897 | const QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 898 | - | |||||||||||||||||||||||||
| 899 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 900 | const QToolBarAreaLayoutLine &line = dock.lines.at(j); | - | ||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||
| 902 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 903 | if (line.toolBarItems.at(k).widgetItem->widget() == toolBar
| 0 | ||||||||||||||||||||||||
| 904 | return never executed: j > 0 && k == 0;return j > 0 && k == 0;never executed: return j > 0 && k == 0; | 0 | ||||||||||||||||||||||||
| 905 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 906 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 907 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 908 | - | |||||||||||||||||||||||||
| 909 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 910 | } | - | ||||||||||||||||||||||||
| 911 | - | |||||||||||||||||||||||||
| 912 | void QToolBarAreaLayout::getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const | - | ||||||||||||||||||||||||
| 913 | { | - | ||||||||||||||||||||||||
| 914 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 915 | const QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 916 | - | |||||||||||||||||||||||||
| 917 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 918 | const QToolBarAreaLayoutLine &line = dock.lines.at(j); | - | ||||||||||||||||||||||||
| 919 | - | |||||||||||||||||||||||||
| 920 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 921 | if (line.toolBarItems.at(k).widgetItem->widget() == toolBar
| 0 | ||||||||||||||||||||||||
| 922 | if (line.toolBarItems.count() == 1
| 0 | ||||||||||||||||||||||||
| 923 | option->positionWithinLine = QStyleOptionToolBar::OnlyOne; never executed: option->positionWithinLine = QStyleOptionToolBar::OnlyOne; | 0 | ||||||||||||||||||||||||
| 924 | else if (k == 0
| 0 | ||||||||||||||||||||||||
| 925 | option->positionWithinLine = QStyleOptionToolBar::Beginning; never executed: option->positionWithinLine = QStyleOptionToolBar::Beginning; | 0 | ||||||||||||||||||||||||
| 926 | else if (k == line.toolBarItems.count() - 1
| 0 | ||||||||||||||||||||||||
| 927 | option->positionWithinLine = QStyleOptionToolBar::End; never executed: option->positionWithinLine = QStyleOptionToolBar::End; | 0 | ||||||||||||||||||||||||
| 928 | else | - | ||||||||||||||||||||||||
| 929 | option->positionWithinLine = QStyleOptionToolBar::Middle; never executed: option->positionWithinLine = QStyleOptionToolBar::Middle; | 0 | ||||||||||||||||||||||||
| 930 | - | |||||||||||||||||||||||||
| 931 | if (dock.lines.count() == 1
| 0 | ||||||||||||||||||||||||
| 932 | option->positionOfLine = QStyleOptionToolBar::OnlyOne; never executed: option->positionOfLine = QStyleOptionToolBar::OnlyOne; | 0 | ||||||||||||||||||||||||
| 933 | else if (j == 0
| 0 | ||||||||||||||||||||||||
| 934 | option->positionOfLine = QStyleOptionToolBar::Beginning; never executed: option->positionOfLine = QStyleOptionToolBar::Beginning; | 0 | ||||||||||||||||||||||||
| 935 | else if (j == dock.lines.count() - 1
| 0 | ||||||||||||||||||||||||
| 936 | option->positionOfLine = QStyleOptionToolBar::End; never executed: option->positionOfLine = QStyleOptionToolBar::End; | 0 | ||||||||||||||||||||||||
| 937 | else | - | ||||||||||||||||||||||||
| 938 | option->positionOfLine = QStyleOptionToolBar::Middle; never executed: option->positionOfLine = QStyleOptionToolBar::Middle; | 0 | ||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||
| 940 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 941 | } | - | ||||||||||||||||||||||||
| 942 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 943 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 944 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 945 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 946 | - | |||||||||||||||||||||||||
| 947 | QList<int> QToolBarAreaLayout::indexOf(QWidget *toolBar) const | - | ||||||||||||||||||||||||
| 948 | { | - | ||||||||||||||||||||||||
| 949 | QList<int> result; | - | ||||||||||||||||||||||||
| 950 | - | |||||||||||||||||||||||||
| 951 | bool found = false; | - | ||||||||||||||||||||||||
| 952 | - | |||||||||||||||||||||||||
| 953 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 954 | const QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 955 | - | |||||||||||||||||||||||||
| 956 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 957 | const QToolBarAreaLayoutLine &line = dock.lines.at(j); | - | ||||||||||||||||||||||||
| 958 | - | |||||||||||||||||||||||||
| 959 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 960 | const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); | - | ||||||||||||||||||||||||
| 961 | if (!item.gap
| 0 | ||||||||||||||||||||||||
| 962 | found = true; | - | ||||||||||||||||||||||||
| 963 | result.prepend(k); | - | ||||||||||||||||||||||||
| 964 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 965 | } | - | ||||||||||||||||||||||||
| 966 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 967 | - | |||||||||||||||||||||||||
| 968 | if (found
| 0 | ||||||||||||||||||||||||
| 969 | result.prepend(j); | - | ||||||||||||||||||||||||
| 970 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 971 | } | - | ||||||||||||||||||||||||
| 972 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 973 | - | |||||||||||||||||||||||||
| 974 | if (found
| 0 | ||||||||||||||||||||||||
| 975 | result.prepend(i); | - | ||||||||||||||||||||||||
| 976 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 977 | } | - | ||||||||||||||||||||||||
| 978 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 979 | - | |||||||||||||||||||||||||
| 980 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 981 | } | - | ||||||||||||||||||||||||
| 982 | - | |||||||||||||||||||||||||
| 983 | - | |||||||||||||||||||||||||
| 984 | QList<int> QToolBarAreaLayout::gapIndex(const QPoint &pos) const | - | ||||||||||||||||||||||||
| 985 | { | - | ||||||||||||||||||||||||
| 986 | Qt::LayoutDirection dir = mainWindow->layoutDirection(); | - | ||||||||||||||||||||||||
| 987 | int minDistance = 80; | - | ||||||||||||||||||||||||
| 988 | QList<int> ret; | - | ||||||||||||||||||||||||
| 989 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 990 | QPoint p = pos; | - | ||||||||||||||||||||||||
| 991 | if (docks[i].o == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 992 | p = QStyle::visualPos(dir, docks[i].rect, p); never executed: p = QStyle::visualPos(dir, docks[i].rect, p); | 0 | ||||||||||||||||||||||||
| 993 | QList<int> result = docks[i].gapIndex(p, &minDistance); | - | ||||||||||||||||||||||||
| 994 | if (!result.isEmpty()
| 0 | ||||||||||||||||||||||||
| 995 | result.prepend(i); | - | ||||||||||||||||||||||||
| 996 | ret = result; | - | ||||||||||||||||||||||||
| 997 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 998 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||
| 1000 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1001 | } | - | ||||||||||||||||||||||||
| 1002 | - | |||||||||||||||||||||||||
| 1003 | QList<int> QToolBarAreaLayout::currentGapIndex() const | - | ||||||||||||||||||||||||
| 1004 | { | - | ||||||||||||||||||||||||
| 1005 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 1006 | const QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 1007 | - | |||||||||||||||||||||||||
| 1008 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 1009 | const QToolBarAreaLayoutLine &line = dock.lines[j]; | - | ||||||||||||||||||||||||
| 1010 | - | |||||||||||||||||||||||||
| 1011 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 1012 | if (line.toolBarItems[k].gap
| 0 | ||||||||||||||||||||||||
| 1013 | QList<int> result; | - | ||||||||||||||||||||||||
| 1014 | result << i << j << k; | - | ||||||||||||||||||||||||
| 1015 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 1016 | } | - | ||||||||||||||||||||||||
| 1017 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1018 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1019 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1020 | return never executed: QList<int>();return QList<int>();never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 1021 | } | - | ||||||||||||||||||||||||
| 1022 | - | |||||||||||||||||||||||||
| 1023 | bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item) | - | ||||||||||||||||||||||||
| 1024 | { | - | ||||||||||||||||||||||||
| 1025 | ((!(path.count() == 3)) ? qt_assert("path.count() == 3",__FILE__,1074) : qt_noop()); | - | ||||||||||||||||||||||||
| 1026 | const int i = path.first(); | - | ||||||||||||||||||||||||
| 1027 | ((!(i >= 0 && i < QInternal::DockCount)) ? qt_assert("i >= 0 && i < QInternal::DockCount",__FILE__,1076) : qt_noop()); | - | ||||||||||||||||||||||||
| 1028 | return never executed: docks[i].insertGap(path.mid(1), item);return docks[i].insertGap(path.mid(1), item);never executed: return docks[i].insertGap(path.mid(1), item); | 0 | ||||||||||||||||||||||||
| 1029 | } | - | ||||||||||||||||||||||||
| 1030 | - | |||||||||||||||||||||||||
| 1031 | void QToolBarAreaLayout::remove(const QList<int> &path) | - | ||||||||||||||||||||||||
| 1032 | { | - | ||||||||||||||||||||||||
| 1033 | ((!(path.count() == 3)) ? qt_assert("path.count() == 3",__FILE__,1082) : qt_noop()); | - | ||||||||||||||||||||||||
| 1034 | docks[path.at(0)].lines[path.at(1)].toolBarItems.removeAt(path.at(2)); | - | ||||||||||||||||||||||||
| 1035 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1036 | - | |||||||||||||||||||||||||
| 1037 | void QToolBarAreaLayout::remove(QLayoutItem *item) | - | ||||||||||||||||||||||||
| 1038 | { | - | ||||||||||||||||||||||||
| 1039 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 1040 | QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 1041 | - | |||||||||||||||||||||||||
| 1042 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 1043 | QToolBarAreaLayoutLine &line = dock.lines[j]; | - | ||||||||||||||||||||||||
| 1044 | - | |||||||||||||||||||||||||
| 1045 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 1046 | if (line.toolBarItems[k].widgetItem == item
| 0 | ||||||||||||||||||||||||
| 1047 | line.toolBarItems.removeAt(k); | - | ||||||||||||||||||||||||
| 1048 | if (line.toolBarItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1049 | dock.lines.removeAt(j); never executed: dock.lines.removeAt(j); | 0 | ||||||||||||||||||||||||
| 1050 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1051 | } | - | ||||||||||||||||||||||||
| 1052 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1053 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1054 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1055 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1056 | - | |||||||||||||||||||||||||
| 1057 | void QToolBarAreaLayout::clear() | - | ||||||||||||||||||||||||
| 1058 | { | - | ||||||||||||||||||||||||
| 1059 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 1060 | docks[i].clear(); never executed: docks[i].clear(); | 0 | ||||||||||||||||||||||||
| 1061 | rect = QRect(); | - | ||||||||||||||||||||||||
| 1062 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1063 | - | |||||||||||||||||||||||||
| 1064 | QToolBarAreaLayoutItem *QToolBarAreaLayout::item(const QList<int> &path) | - | ||||||||||||||||||||||||
| 1065 | { | - | ||||||||||||||||||||||||
| 1066 | ((!(path.count() == 3)) ? qt_assert("path.count() == 3",__FILE__,1115) : qt_noop()); | - | ||||||||||||||||||||||||
| 1067 | - | |||||||||||||||||||||||||
| 1068 | if (path.at(0) < 0
| 0 | ||||||||||||||||||||||||
| 1069 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1070 | QToolBarAreaLayoutInfo &info = docks[path.at(0)]; | - | ||||||||||||||||||||||||
| 1071 | if (path.at(1) < 0
| 0 | ||||||||||||||||||||||||
| 1072 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1073 | QToolBarAreaLayoutLine &line = info.lines[path.at(1)]; | - | ||||||||||||||||||||||||
| 1074 | if (path.at(2) < 0
| 0 | ||||||||||||||||||||||||
| 1075 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1076 | return never executed: &(line.toolBarItems[path.at(2)]);return &(line.toolBarItems[path.at(2)]);never executed: return &(line.toolBarItems[path.at(2)]); | 0 | ||||||||||||||||||||||||
| 1077 | } | - | ||||||||||||||||||||||||
| 1078 | - | |||||||||||||||||||||||||
| 1079 | QRect QToolBarAreaLayout::itemRect(const QList<int> &path) const | - | ||||||||||||||||||||||||
| 1080 | { | - | ||||||||||||||||||||||||
| 1081 | const int i = path.first(); | - | ||||||||||||||||||||||||
| 1082 | - | |||||||||||||||||||||||||
| 1083 | QRect r = docks[i].itemRect(path.mid(1)); | - | ||||||||||||||||||||||||
| 1084 | if (docks[i].o == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 1085 | r = QStyle::visualRect(mainWindow->layoutDirection(), never executed: r = QStyle::visualRect(mainWindow->layoutDirection(), docks[i].rect, r); | 0 | ||||||||||||||||||||||||
| 1086 | docks[i].rect, r); never executed: r = QStyle::visualRect(mainWindow->layoutDirection(), docks[i].rect, r); | 0 | ||||||||||||||||||||||||
| 1087 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||||||||
| 1088 | } | - | ||||||||||||||||||||||||
| 1089 | - | |||||||||||||||||||||||||
| 1090 | QLayoutItem *QToolBarAreaLayout::plug(const QList<int> &path) | - | ||||||||||||||||||||||||
| 1091 | { | - | ||||||||||||||||||||||||
| 1092 | QToolBarAreaLayoutItem *item = this->item(path); | - | ||||||||||||||||||||||||
| 1093 | if (__builtin_expect(!!(!item), false)
| 0 | ||||||||||||||||||||||||
| 1094 | QMessageLogger(__FILE__, 1143, __PRETTY_FUNCTION__).warning() << "No item at" << path; | - | ||||||||||||||||||||||||
| 1095 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1096 | } | - | ||||||||||||||||||||||||
| 1097 | ((!(item->gap)) ? qt_assert("item->gap",__FILE__,1146) : qt_noop()); | - | ||||||||||||||||||||||||
| 1098 | ((!(item->widgetItem != 0)) ? qt_assert("item->widgetItem != 0",__FILE__,1147) : qt_noop()); | - | ||||||||||||||||||||||||
| 1099 | item->gap = false; | - | ||||||||||||||||||||||||
| 1100 | return never executed: item->widgetItem;return item->widgetItem;never executed: return item->widgetItem; | 0 | ||||||||||||||||||||||||
| 1101 | } | - | ||||||||||||||||||||||||
| 1102 | - | |||||||||||||||||||||||||
| 1103 | QLayoutItem *QToolBarAreaLayout::unplug(const QList<int> &path, QToolBarAreaLayout *other) | - | ||||||||||||||||||||||||
| 1104 | { | - | ||||||||||||||||||||||||
| 1105 | - | |||||||||||||||||||||||||
| 1106 | ((!(path.count() == 3)) ? qt_assert("path.count() == 3",__FILE__,1155) : qt_noop()); | - | ||||||||||||||||||||||||
| 1107 | QToolBarAreaLayoutItem *item = this->item(path); | - | ||||||||||||||||||||||||
| 1108 | ((!(item)) ? qt_assert("item",__FILE__,1157) : qt_noop()); | - | ||||||||||||||||||||||||
| 1109 | - | |||||||||||||||||||||||||
| 1110 | - | |||||||||||||||||||||||||
| 1111 | QToolBarAreaLayoutInfo &info = docks[path.at(0)]; | - | ||||||||||||||||||||||||
| 1112 | QToolBarAreaLayoutLine &line = info.lines[path.at(1)]; | - | ||||||||||||||||||||||||
| 1113 | if (item->size != pick(line.o, item->realSizeHint())
| 0 | ||||||||||||||||||||||||
| 1114 | - | |||||||||||||||||||||||||
| 1115 | - | |||||||||||||||||||||||||
| 1116 | int newExtraSpace = 0; | - | ||||||||||||||||||||||||
| 1117 | - | |||||||||||||||||||||||||
| 1118 | - | |||||||||||||||||||||||||
| 1119 | for (int i = path.at(2) - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 1120 | QToolBarAreaLayoutItem &previous = line.toolBarItems[i]; | - | ||||||||||||||||||||||||
| 1121 | if (!previous.skip()
| 0 | ||||||||||||||||||||||||
| 1122 | - | |||||||||||||||||||||||||
| 1123 | - | |||||||||||||||||||||||||
| 1124 | for (int j = path.at(2) + 1; j < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 1125 | const QToolBarAreaLayoutItem &next = line.toolBarItems.at(j); | - | ||||||||||||||||||||||||
| 1126 | if (!next.skip()
| 0 | ||||||||||||||||||||||||
| 1127 | newExtraSpace = next.pos - previous.pos - pick(line.o, previous.sizeHint()); | - | ||||||||||||||||||||||||
| 1128 | previous.resize(line.o, next.pos - previous.pos); | - | ||||||||||||||||||||||||
| 1129 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1130 | } | - | ||||||||||||||||||||||||
| 1131 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1132 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1133 | } | - | ||||||||||||||||||||||||
| 1134 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1135 | - | |||||||||||||||||||||||||
| 1136 | if (other
| 0 | ||||||||||||||||||||||||
| 1137 | QToolBarAreaLayoutInfo &info = other->docks[path.at(0)]; | - | ||||||||||||||||||||||||
| 1138 | QToolBarAreaLayoutLine &line = info.lines[path.at(1)]; | - | ||||||||||||||||||||||||
| 1139 | for (int i = path.at(2) - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 1140 | QToolBarAreaLayoutItem &previous = line.toolBarItems[i]; | - | ||||||||||||||||||||||||
| 1141 | if (!previous.skip()
| 0 | ||||||||||||||||||||||||
| 1142 | previous.resize(line.o, pick(line.o, previous.sizeHint()) + newExtraSpace); | - | ||||||||||||||||||||||||
| 1143 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1144 | } | - | ||||||||||||||||||||||||
| 1145 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1146 | - | |||||||||||||||||||||||||
| 1147 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1149 | - | |||||||||||||||||||||||||
| 1150 | ((!(!item->gap)) ? qt_assert("!item->gap",__FILE__,1199) : qt_noop()); | - | ||||||||||||||||||||||||
| 1151 | item->gap = true; | - | ||||||||||||||||||||||||
| 1152 | return never executed: item->widgetItem;return item->widgetItem;never executed: return item->widgetItem; | 0 | ||||||||||||||||||||||||
| 1153 | } | - | ||||||||||||||||||||||||
| 1154 | - | |||||||||||||||||||||||||
| 1155 | static QRect unpackRect(uint geom0, uint geom1, bool *floating) | - | ||||||||||||||||||||||||
| 1156 | { | - | ||||||||||||||||||||||||
| 1157 | *floating = geom0 & 1; | - | ||||||||||||||||||||||||
| 1158 | if (!*floating
| 0 | ||||||||||||||||||||||||
| 1159 | return never executed: QRect();return QRect();never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 1160 | - | |||||||||||||||||||||||||
| 1161 | geom0 >>= 1; | - | ||||||||||||||||||||||||
| 1162 | - | |||||||||||||||||||||||||
| 1163 | int x = (int)(geom0 & 0x0000ffff) - 0x7FFF; | - | ||||||||||||||||||||||||
| 1164 | int y = (int)(geom1 & 0x0000ffff) - 0x7FFF; | - | ||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||
| 1166 | geom0 >>= 16; | - | ||||||||||||||||||||||||
| 1167 | geom1 >>= 16; | - | ||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||
| 1169 | int w = geom0 & 0x0000ffff; | - | ||||||||||||||||||||||||
| 1170 | int h = geom1 & 0x0000ffff; | - | ||||||||||||||||||||||||
| 1171 | - | |||||||||||||||||||||||||
| 1172 | return never executed: QRect(x, y, w, h);return QRect(x, y, w, h);never executed: return QRect(x, y, w, h); | 0 | ||||||||||||||||||||||||
| 1173 | } | - | ||||||||||||||||||||||||
| 1174 | - | |||||||||||||||||||||||||
| 1175 | static void packRect(uint *geom0, uint *geom1, const QRect &rect, bool floating) | - | ||||||||||||||||||||||||
| 1176 | { | - | ||||||||||||||||||||||||
| 1177 | *geom0 = 0; | - | ||||||||||||||||||||||||
| 1178 | *geom1 = 0; | - | ||||||||||||||||||||||||
| 1179 | - | |||||||||||||||||||||||||
| 1180 | if (!floating
| 0 | ||||||||||||||||||||||||
| 1181 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1182 | - | |||||||||||||||||||||||||
| 1183 | - | |||||||||||||||||||||||||
| 1184 | - | |||||||||||||||||||||||||
| 1185 | - | |||||||||||||||||||||||||
| 1186 | *geom0 |= qMax(0, rect.width()) & 0x0000ffff; | - | ||||||||||||||||||||||||
| 1187 | *geom1 |= qMax(0, rect.height()) & 0x0000ffff; | - | ||||||||||||||||||||||||
| 1188 | - | |||||||||||||||||||||||||
| 1189 | *geom0 <<= 16; | - | ||||||||||||||||||||||||
| 1190 | *geom1 <<= 16; | - | ||||||||||||||||||||||||
| 1191 | - | |||||||||||||||||||||||||
| 1192 | *geom0 |= qMax(0, rect.x() + 0x7FFF) & 0x0000ffff; | - | ||||||||||||||||||||||||
| 1193 | *geom1 |= qMax(0, rect.y() + 0x7FFF) & 0x0000ffff; | - | ||||||||||||||||||||||||
| 1194 | - | |||||||||||||||||||||||||
| 1195 | - | |||||||||||||||||||||||||
| 1196 | - | |||||||||||||||||||||||||
| 1197 | *geom0 <<= 1; | - | ||||||||||||||||||||||||
| 1198 | *geom0 |= 1; | - | ||||||||||||||||||||||||
| 1199 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1200 | - | |||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||
| 1202 | void QToolBarAreaLayout::saveState(QDataStream &stream) const | - | ||||||||||||||||||||||||
| 1203 | { | - | ||||||||||||||||||||||||
| 1204 | - | |||||||||||||||||||||||||
| 1205 | stream << (uchar) ToolBarStateMarkerEx; | - | ||||||||||||||||||||||||
| 1206 | - | |||||||||||||||||||||||||
| 1207 | int lineCount = 0; | - | ||||||||||||||||||||||||
| 1208 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 1209 | lineCount += docks[i].lines.count(); never executed: lineCount += docks[i].lines.count(); | 0 | ||||||||||||||||||||||||
| 1210 | - | |||||||||||||||||||||||||
| 1211 | stream << lineCount; | - | ||||||||||||||||||||||||
| 1212 | - | |||||||||||||||||||||||||
| 1213 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 1214 | const QToolBarAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 1215 | - | |||||||||||||||||||||||||
| 1216 | for (int j = 0; j < dock.lines.count()
| 0 | ||||||||||||||||||||||||
| 1217 | const QToolBarAreaLayoutLine &line = dock.lines.at(j); | - | ||||||||||||||||||||||||
| 1218 | - | |||||||||||||||||||||||||
| 1219 | stream << i << line.toolBarItems.count(); | - | ||||||||||||||||||||||||
| 1220 | - | |||||||||||||||||||||||||
| 1221 | for (int k = 0; k < line.toolBarItems.count()
| 0 | ||||||||||||||||||||||||
| 1222 | const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k); | - | ||||||||||||||||||||||||
| 1223 | QWidget *widget = const_cast<QLayoutItem*>(item.widgetItem)->widget(); | - | ||||||||||||||||||||||||
| 1224 | QString objectName = widget->objectName(); | - | ||||||||||||||||||||||||
| 1225 | if (__builtin_expect(!!(objectName.isEmpty()), false)
| 0 | ||||||||||||||||||||||||
| 1226 | QMessageLogger(__FILE__, 1275, __PRETTY_FUNCTION__).warning("QMainWindow::saveState(): 'objectName' not set for QToolBar %p '%s'", | - | ||||||||||||||||||||||||
| 1227 | widget, widget->windowTitle().toLocal8Bit().constData()); | - | ||||||||||||||||||||||||
| 1228 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1229 | stream << objectName; | - | ||||||||||||||||||||||||
| 1230 | - | |||||||||||||||||||||||||
| 1231 | - | |||||||||||||||||||||||||
| 1232 | - | |||||||||||||||||||||||||
| 1233 | uchar shownOrientation = (uchar)!widget->isHidden(); | - | ||||||||||||||||||||||||
| 1234 | if (QToolBar * tb= qobject_cast<QToolBar*>(widget)
| 0 | ||||||||||||||||||||||||
| 1235 | if (tb->orientation() == Qt::Vertical
| 0 | ||||||||||||||||||||||||
| 1236 | shownOrientation |= 2; never executed: shownOrientation |= 2; | 0 | ||||||||||||||||||||||||
| 1237 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1238 | stream << shownOrientation; | - | ||||||||||||||||||||||||
| 1239 | stream << item.pos; | - | ||||||||||||||||||||||||
| 1240 | - | |||||||||||||||||||||||||
| 1241 | stream << item.preferredSize; | - | ||||||||||||||||||||||||
| 1242 | - | |||||||||||||||||||||||||
| 1243 | uint geom0, geom1; | - | ||||||||||||||||||||||||
| 1244 | packRect(&geom0, &geom1, widget->geometry(), widget->isWindow()); | - | ||||||||||||||||||||||||
| 1245 | stream << geom0 << geom1; | - | ||||||||||||||||||||||||
| 1246 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1247 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1248 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1249 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1250 | - | |||||||||||||||||||||||||
| 1251 | static inline int getInt(QDataStream &stream) | - | ||||||||||||||||||||||||
| 1252 | { | - | ||||||||||||||||||||||||
| 1253 | int x; | - | ||||||||||||||||||||||||
| 1254 | stream >> x; | - | ||||||||||||||||||||||||
| 1255 | return never executed: x;return x;never executed: return x; | 0 | ||||||||||||||||||||||||
| 1256 | } | - | ||||||||||||||||||||||||
| 1257 | - | |||||||||||||||||||||||||
| 1258 | - | |||||||||||||||||||||||||
| 1259 | bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*> &_toolBars, uchar tmarker, bool testing) | - | ||||||||||||||||||||||||
| 1260 | { | - | ||||||||||||||||||||||||
| 1261 | QList<QToolBar*> toolBars = _toolBars; | - | ||||||||||||||||||||||||
| 1262 | int lines; | - | ||||||||||||||||||||||||
| 1263 | stream >> lines; | - | ||||||||||||||||||||||||
| 1264 | - | |||||||||||||||||||||||||
| 1265 | for (int j = 0; j < lines
| 0 | ||||||||||||||||||||||||
| 1266 | int pos; | - | ||||||||||||||||||||||||
| 1267 | stream >> pos; | - | ||||||||||||||||||||||||
| 1268 | if (pos < 0
| 0 | ||||||||||||||||||||||||
| 1269 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1270 | int cnt; | - | ||||||||||||||||||||||||
| 1271 | stream >> cnt; | - | ||||||||||||||||||||||||
| 1272 | - | |||||||||||||||||||||||||
| 1273 | QToolBarAreaLayoutInfo &dock = docks[pos]; | - | ||||||||||||||||||||||||
| 1274 | const bool applyingLayout = !testing; | - | ||||||||||||||||||||||||
| 1275 | QToolBarAreaLayoutLine line(dock.o); | - | ||||||||||||||||||||||||
| 1276 | - | |||||||||||||||||||||||||
| 1277 | for (int k = 0; k < cnt
| 0 | ||||||||||||||||||||||||
| 1278 | QToolBarAreaLayoutItem item; | - | ||||||||||||||||||||||||
| 1279 | - | |||||||||||||||||||||||||
| 1280 | QString objectName; | - | ||||||||||||||||||||||||
| 1281 | stream >> objectName; | - | ||||||||||||||||||||||||
| 1282 | uchar shown; | - | ||||||||||||||||||||||||
| 1283 | stream >> shown; | - | ||||||||||||||||||||||||
| 1284 | item.pos = getInt(stream); | - | ||||||||||||||||||||||||
| 1285 | item.size = getInt(stream); | - | ||||||||||||||||||||||||
| 1286 | QRect rect; | - | ||||||||||||||||||||||||
| 1287 | bool floating = false; | - | ||||||||||||||||||||||||
| 1288 | uint geom0, geom1; | - | ||||||||||||||||||||||||
| 1289 | geom0 = getInt(stream); | - | ||||||||||||||||||||||||
| 1290 | if (tmarker == ToolBarStateMarkerEx
| 0 | ||||||||||||||||||||||||
| 1291 | geom1 = getInt(stream); | - | ||||||||||||||||||||||||
| 1292 | rect = unpackRect(geom0, geom1, &floating); | - | ||||||||||||||||||||||||
| 1293 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1294 | - | |||||||||||||||||||||||||
| 1295 | QToolBar *toolBar = 0; | - | ||||||||||||||||||||||||
| 1296 | for (int x = 0; x < toolBars.count()
| 0 | ||||||||||||||||||||||||
| 1297 | if (toolBars.at(x)->objectName() == objectName
| 0 | ||||||||||||||||||||||||
| 1298 | toolBar = toolBars.takeAt(x); | - | ||||||||||||||||||||||||
| 1299 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1300 | } | - | ||||||||||||||||||||||||
| 1301 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1302 | if (toolBar == 0
| 0 | ||||||||||||||||||||||||
| 1303 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1304 | } | - | ||||||||||||||||||||||||
| 1305 | - | |||||||||||||||||||||||||
| 1306 | if (applyingLayout
| 0 | ||||||||||||||||||||||||
| 1307 | item.widgetItem = new QWidgetItemV2(toolBar); | - | ||||||||||||||||||||||||
| 1308 | toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o); | - | ||||||||||||||||||||||||
| 1309 | toolBar->setVisible(shown & 1); | - | ||||||||||||||||||||||||
| 1310 | toolBar->d_func()->setWindowState(floating, true, rect); | - | ||||||||||||||||||||||||
| 1311 | - | |||||||||||||||||||||||||
| 1312 | item.preferredSize = item.size; | - | ||||||||||||||||||||||||
| 1313 | line.toolBarItems.append(item); | - | ||||||||||||||||||||||||
| 1314 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1315 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1316 | - | |||||||||||||||||||||||||
| 1317 | if (applyingLayout
| 0 | ||||||||||||||||||||||||
| 1318 | dock.lines.append(line); | - | ||||||||||||||||||||||||
| 1319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1320 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1321 | - | |||||||||||||||||||||||||
| 1322 | - | |||||||||||||||||||||||||
| 1323 | return never executed: stream.status() == QDataStream::Ok;return stream.status() == QDataStream::Ok;never executed: return stream.status() == QDataStream::Ok; | 0 | ||||||||||||||||||||||||
| 1324 | } | - | ||||||||||||||||||||||||
| 1325 | - | |||||||||||||||||||||||||
| 1326 | bool QToolBarAreaLayout::isEmpty() const | - | ||||||||||||||||||||||||
| 1327 | { | - | ||||||||||||||||||||||||
| 1328 | for (int i = 0; i < QInternal::DockCount
| 0 | ||||||||||||||||||||||||
| 1329 | if (!docks[i].lines.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1330 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1331 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1332 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1333 | } | - | ||||||||||||||||||||||||
| 1334 | - | |||||||||||||||||||||||||
| 1335 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |