| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | QColumnView::QColumnView(QWidget * parent) | - |
| 8 | : QAbstractItemView(*new QColumnViewPrivate, parent) | - |
| 9 | { | - |
| 10 | QColumnViewPrivate * const d = d_func(); | - |
| 11 | d->initialize(); | - |
| 12 | } | 0 |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | QColumnView::QColumnView(QColumnViewPrivate & dd, QWidget * parent) | - |
| 18 | : QAbstractItemView(dd, parent) | - |
| 19 | { | - |
| 20 | QColumnViewPrivate * const d = d_func(); | - |
| 21 | d->initialize(); | - |
| 22 | } | 0 |
| 23 | | - |
| 24 | void QColumnViewPrivate::initialize() | - |
| 25 | { | - |
| 26 | QColumnView * const q = q_func(); | - |
| 27 | q->setTextElideMode(Qt::ElideMiddle); | - |
| 28 | | - |
| 29 | QObject::connect(¤tAnimation, "2""finished()", q, "1""_q_changeCurrentColumn()"); | - |
| 30 | currentAnimation.setDuration(150); | - |
| 31 | currentAnimation.setTargetObject(hbar); | - |
| 32 | currentAnimation.setPropertyName("value"); | - |
| 33 | currentAnimation.setEasingCurve(QEasingCurve::InOutQuad); | - |
| 34 | | - |
| 35 | delete itemDelegate; | - |
| 36 | q->setItemDelegate(new QColumnViewDelegate(q)); | - |
| 37 | } | 0 |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | QColumnView::~QColumnView() | - |
| 43 | { | - |
| 44 | } | - |
| 45 | void QColumnView::setResizeGripsVisible(bool visible) | - |
| 46 | { | - |
| 47 | QColumnViewPrivate * const d = d_func(); | - |
| 48 | if (d->showResizeGrips == visible) never evaluated: d->showResizeGrips == visible | 0 |
| 49 | return; | 0 |
| 50 | d->showResizeGrips = visible; | - |
| 51 | for (int i = 0; i < d->columns.count(); ++i) { never evaluated: i < d->columns.count() | 0 |
| 52 | QAbstractItemView *view = d->columns[i]; | - |
| 53 | if (visible) { | 0 |
| 54 | QColumnViewGrip *grip = new QColumnViewGrip(view); | - |
| 55 | view->setCornerWidget(grip); | - |
| 56 | connect(grip, "2""gripMoved(int)", this, "1""_q_gripMoved(int)"); | - |
| 57 | } else { | 0 |
| 58 | QWidget *widget = view->cornerWidget(); | - |
| 59 | view->setCornerWidget(0); | - |
| 60 | widget->deleteLater(); | - |
| 61 | } | 0 |
| 62 | } | - |
| 63 | } | 0 |
| 64 | | - |
| 65 | bool QColumnView::resizeGripsVisible() const | - |
| 66 | { | - |
| 67 | const QColumnViewPrivate * const d = d_func(); | - |
| 68 | return d->showResizeGrips; never executed: return d->showResizeGrips; | 0 |
| 69 | } | - |
| 70 | | - |
| 71 | | - |
| 72 | | - |
| 73 | | - |
| 74 | void QColumnView::setModel(QAbstractItemModel *model) | - |
| 75 | { | - |
| 76 | QColumnViewPrivate * const d = d_func(); | - |
| 77 | if (model == d->model) never evaluated: model == d->model | 0 |
| 78 | return; | 0 |
| 79 | d->closeColumns(); | - |
| 80 | QAbstractItemView::setModel(model); | - |
| 81 | } | 0 |
| 82 | | - |
| 83 | | - |
| 84 | | - |
| 85 | | - |
| 86 | void QColumnView::setRootIndex(const QModelIndex &index) | - |
| 87 | { | - |
| 88 | QColumnViewPrivate * const d = d_func(); | - |
| 89 | if (!model()) never evaluated: !model() | 0 |
| 90 | return; | 0 |
| 91 | | - |
| 92 | d->closeColumns(); | - |
| 93 | qt_noop(); | - |
| 94 | | - |
| 95 | QAbstractItemView *view = d->createColumn(index, true); | - |
| 96 | if (view->selectionModel()) never evaluated: view->selectionModel() | 0 |
| 97 | view->selectionModel()->deleteLater(); never executed: view->selectionModel()->deleteLater(); | 0 |
| 98 | if (view->model()) never evaluated: view->model() | 0 |
| 99 | view->setSelectionModel(selectionModel()); never executed: view->setSelectionModel(selectionModel()); | 0 |
| 100 | | - |
| 101 | QAbstractItemView::setRootIndex(index); | - |
| 102 | d->updateScrollbars(); | - |
| 103 | } | 0 |
| 104 | | - |
| 105 | | - |
| 106 | | - |
| 107 | | - |
| 108 | bool QColumnView::isIndexHidden(const QModelIndex &index) const | - |
| 109 | { | - |
| 110 | (void)index;; | - |
| 111 | return false; never executed: return false; | 0 |
| 112 | } | - |
| 113 | | - |
| 114 | | - |
| 115 | | - |
| 116 | | - |
| 117 | QModelIndex QColumnView::indexAt(const QPoint &point) const | - |
| 118 | { | - |
| 119 | const QColumnViewPrivate * const d = d_func(); | - |
| 120 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 121 | QPoint topLeft = d->columns.at(i)->frameGeometry().topLeft(); | - |
| 122 | QPoint adjustedPoint(point.x() - topLeft.x(), point.y() - topLeft.y()); | - |
| 123 | QModelIndex index = d->columns.at(i)->indexAt(adjustedPoint); | - |
| 124 | if (index.isValid()) never evaluated: index.isValid() | 0 |
| 125 | return index; never executed: return index; | 0 |
| 126 | } | 0 |
| 127 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
| 128 | } | - |
| 129 | | - |
| 130 | | - |
| 131 | | - |
| 132 | | - |
| 133 | QRect QColumnView::visualRect(const QModelIndex &index) const | - |
| 134 | { | - |
| 135 | if (!index.isValid()) never evaluated: !index.isValid() | 0 |
| 136 | return QRect(); never executed: return QRect(); | 0 |
| 137 | | - |
| 138 | const QColumnViewPrivate * const d = d_func(); | - |
| 139 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 140 | QRect rect = d->columns.at(i)->visualRect(index); | - |
| 141 | if (!rect.isNull()) { never evaluated: !rect.isNull() | 0 |
| 142 | rect.translate(d->columns.at(i)->frameGeometry().topLeft()); | - |
| 143 | return rect; never executed: return rect; | 0 |
| 144 | } | - |
| 145 | } | 0 |
| 146 | return QRect(); never executed: return QRect(); | 0 |
| 147 | } | - |
| 148 | | - |
| 149 | | - |
| 150 | | - |
| 151 | | - |
| 152 | void QColumnView::scrollContentsBy(int dx, int dy) | - |
| 153 | { | - |
| 154 | QColumnViewPrivate * const d = d_func(); | - |
| 155 | if (d->columns.isEmpty() || dx == 0) never evaluated: d->columns.isEmpty() | 0 |
| 156 | return; | 0 |
| 157 | | - |
| 158 | dx = isRightToLeft() ? -dx : dx; never evaluated: isRightToLeft() | 0 |
| 159 | for (int i = 0; i < d->columns.count(); ++i) never evaluated: i < d->columns.count() | 0 |
| 160 | d->columns.at(i)->move(d->columns.at(i)->x() + dx, 0); never executed: d->columns.at(i)->move(d->columns.at(i)->x() + dx, 0); | 0 |
| 161 | d->offset += dx; | - |
| 162 | QAbstractItemView::scrollContentsBy(dx, dy); | - |
| 163 | } | 0 |
| 164 | | - |
| 165 | | - |
| 166 | | - |
| 167 | | - |
| 168 | void QColumnView::scrollTo(const QModelIndex &index, ScrollHint hint) | - |
| 169 | { | - |
| 170 | QColumnViewPrivate * const d = d_func(); | - |
| 171 | (void)hint;; | - |
| 172 | if (!index.isValid() || d->columns.isEmpty()) never evaluated: !index.isValid() never evaluated: d->columns.isEmpty() | 0 |
| 173 | return; | 0 |
| 174 | | - |
| 175 | | - |
| 176 | if (d->currentAnimation.state() == QPropertyAnimation::Running) never evaluated: d->currentAnimation.state() == QPropertyAnimation::Running | 0 |
| 177 | return; | 0 |
| 178 | | - |
| 179 | d->currentAnimation.stop(); | - |
| 180 | | - |
| 181 | | - |
| 182 | | - |
| 183 | d->closeColumns(index, true); | - |
| 184 | | - |
| 185 | QModelIndex indexParent = index.parent(); | - |
| 186 | | - |
| 187 | int currentColumn = 0; | - |
| 188 | int leftEdge = 0; | - |
| 189 | while (currentColumn < d->columns.size()) { never evaluated: currentColumn < d->columns.size() | 0 |
| 190 | if (indexParent == d->columns.at(currentColumn)->rootIndex()) never evaluated: indexParent == d->columns.at(currentColumn)->rootIndex() | 0 |
| 191 | break; | 0 |
| 192 | leftEdge += d->columns.at(currentColumn)->width(); | - |
| 193 | ++currentColumn; | - |
| 194 | } | 0 |
| 195 | | - |
| 196 | | - |
| 197 | if (currentColumn == d->columns.size()) never evaluated: currentColumn == d->columns.size() | 0 |
| 198 | return; | 0 |
| 199 | | - |
| 200 | int indexColumn = currentColumn; | - |
| 201 | | - |
| 202 | int visibleWidth = d->columns.at(currentColumn)->width(); | - |
| 203 | | - |
| 204 | if (currentColumn + 1 < d->columns.size()) { never evaluated: currentColumn + 1 < d->columns.size() | 0 |
| 205 | ++currentColumn; | - |
| 206 | visibleWidth += d->columns.at(currentColumn)->width(); | - |
| 207 | } | 0 |
| 208 | | - |
| 209 | int rightEdge = leftEdge + visibleWidth; | - |
| 210 | if (isRightToLeft()) { never evaluated: isRightToLeft() | 0 |
| 211 | leftEdge = viewport()->width() - leftEdge; | - |
| 212 | rightEdge = leftEdge - visibleWidth; | - |
| 213 | qSwap(rightEdge, leftEdge); | - |
| 214 | } | 0 |
| 215 | | - |
| 216 | | - |
| 217 | if (leftEdge > -horizontalOffset() never evaluated: leftEdge > -horizontalOffset() | 0 |
| 218 | && rightEdge <= ( -horizontalOffset() + viewport()->size().width())) { never evaluated: rightEdge <= ( -horizontalOffset() + viewport()->size().width()) | 0 |
| 219 | d->columns.at(indexColumn)->scrollTo(index); | - |
| 220 | d->_q_changeCurrentColumn(); | - |
| 221 | return; | 0 |
| 222 | } | - |
| 223 | | - |
| 224 | int newScrollbarValue = 0; | - |
| 225 | if (isRightToLeft()) { never evaluated: isRightToLeft() | 0 |
| 226 | if (leftEdge < 0) { never evaluated: leftEdge < 0 | 0 |
| 227 | | - |
| 228 | newScrollbarValue = viewport()->size().width() - leftEdge; | - |
| 229 | } else { | 0 |
| 230 | | - |
| 231 | newScrollbarValue = rightEdge + horizontalOffset(); | - |
| 232 | } | 0 |
| 233 | } else { | - |
| 234 | if (leftEdge > -horizontalOffset()) { never evaluated: leftEdge > -horizontalOffset() | 0 |
| 235 | | - |
| 236 | newScrollbarValue = rightEdge - viewport()->size().width(); | - |
| 237 | } else { | 0 |
| 238 | | - |
| 239 | newScrollbarValue = leftEdge; | - |
| 240 | } | 0 |
| 241 | } | - |
| 242 | | - |
| 243 | | - |
| 244 | d->currentAnimation.setEndValue(newScrollbarValue); | - |
| 245 | d->currentAnimation.start(); | - |
| 246 | | - |
| 247 | | - |
| 248 | | - |
| 249 | } | 0 |
| 250 | | - |
| 251 | | - |
| 252 | | - |
| 253 | | - |
| 254 | | - |
| 255 | | - |
| 256 | QModelIndex QColumnView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) | - |
| 257 | { | - |
| 258 | | - |
| 259 | | - |
| 260 | (void)modifiers;; | - |
| 261 | if (!model()) never evaluated: !model() | 0 |
| 262 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
| 263 | | - |
| 264 | QModelIndex current = currentIndex(); | - |
| 265 | if (isRightToLeft()) { never evaluated: isRightToLeft() | 0 |
| 266 | if (cursorAction == MoveLeft) never evaluated: cursorAction == MoveLeft | 0 |
| 267 | cursorAction = MoveRight; never executed: cursorAction = MoveRight; | 0 |
| 268 | else if (cursorAction == MoveRight) never evaluated: cursorAction == MoveRight | 0 |
| 269 | cursorAction = MoveLeft; never executed: cursorAction = MoveLeft; | 0 |
| 270 | } | - |
| 271 | switch (cursorAction) { | - |
| 272 | case MoveLeft: | - |
| 273 | if (current.parent().isValid() && current.parent() != rootIndex()) never evaluated: current.parent().isValid() never evaluated: current.parent() != rootIndex() | 0 |
| 274 | return (current.parent()); never executed: return (current.parent()); | 0 |
| 275 | else | - |
| 276 | return current; never executed: return current; | 0 |
| 277 | | - |
| 278 | case MoveRight: | - |
| 279 | if (model()->hasChildren(current)) never evaluated: model()->hasChildren(current) | 0 |
| 280 | return model()->index(0, 0, current); never executed: return model()->index(0, 0, current); | 0 |
| 281 | else | - |
| 282 | return current.sibling(current.row() + 1, current.column()); never executed: return current.sibling(current.row() + 1, current.column()); | 0 |
| 283 | | - |
| 284 | default: | - |
| 285 | break; | 0 |
| 286 | } | - |
| 287 | | - |
| 288 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
| 289 | } | - |
| 290 | | - |
| 291 | | - |
| 292 | | - |
| 293 | | - |
| 294 | void QColumnView::resizeEvent(QResizeEvent *event) | - |
| 295 | { | - |
| 296 | QColumnViewPrivate * const d = d_func(); | - |
| 297 | d->doLayout(); | - |
| 298 | d->updateScrollbars(); | - |
| 299 | if (!isRightToLeft()) { never evaluated: !isRightToLeft() | 0 |
| 300 | int diff = event->oldSize().width() - event->size().width(); | - |
| 301 | if (diff < 0 && horizontalScrollBar()->isVisible() never evaluated: diff < 0 never evaluated: horizontalScrollBar()->isVisible() | 0 |
| 302 | && horizontalScrollBar()->value() == horizontalScrollBar()->maximum()) { never evaluated: horizontalScrollBar()->value() == horizontalScrollBar()->maximum() | 0 |
| 303 | horizontalScrollBar()->setMaximum(horizontalScrollBar()->maximum() + diff); | - |
| 304 | } | 0 |
| 305 | } | 0 |
| 306 | QAbstractItemView::resizeEvent(event); | - |
| 307 | } | 0 |
| 308 | | - |
| 309 | | - |
| 310 | | - |
| 311 | | - |
| 312 | void QColumnViewPrivate::updateScrollbars() | - |
| 313 | { | - |
| 314 | QColumnView * const q = q_func(); | - |
| 315 | | - |
| 316 | if (currentAnimation.state() == QPropertyAnimation::Running) never evaluated: currentAnimation.state() == QPropertyAnimation::Running | 0 |
| 317 | return; | 0 |
| 318 | | - |
| 319 | | - |
| 320 | | - |
| 321 | int horizontalLength = 0; | - |
| 322 | if (!columns.isEmpty()) { never evaluated: !columns.isEmpty() | 0 |
| 323 | horizontalLength = (columns.last()->x() + columns.last()->width()) - columns.first()->x(); | - |
| 324 | if (horizontalLength <= 0) never evaluated: horizontalLength <= 0 | 0 |
| 325 | horizontalLength = (columns.first()->x() + columns.first()->width()) - columns.last()->x(); never executed: horizontalLength = (columns.first()->x() + columns.first()->width()) - columns.last()->x(); | 0 |
| 326 | } | 0 |
| 327 | | - |
| 328 | QSize viewportSize = viewport->size(); | - |
| 329 | if (horizontalLength < viewportSize.width() && hbar->value() == 0) { never evaluated: horizontalLength < viewportSize.width() never evaluated: hbar->value() == 0 | 0 |
| 330 | hbar->setRange(0, 0); | - |
| 331 | } else { | 0 |
| 332 | int visibleLength = qMin(horizontalLength + q->horizontalOffset(), viewportSize.width()); | - |
| 333 | int hiddenLength = horizontalLength - visibleLength; | - |
| 334 | if (hiddenLength != hbar->maximum()) never evaluated: hiddenLength != hbar->maximum() | 0 |
| 335 | hbar->setRange(0, hiddenLength); never executed: hbar->setRange(0, hiddenLength); | 0 |
| 336 | } | 0 |
| 337 | if (!columns.isEmpty()) { never evaluated: !columns.isEmpty() | 0 |
| 338 | int pageStepSize = columns.at(0)->width(); | - |
| 339 | if (pageStepSize != hbar->pageStep()) never evaluated: pageStepSize != hbar->pageStep() | 0 |
| 340 | hbar->setPageStep(pageStepSize); never executed: hbar->setPageStep(pageStepSize); | 0 |
| 341 | } | 0 |
| 342 | bool visible = (hbar->maximum() > 0); | - |
| 343 | if (visible != hbar->isVisible()) never evaluated: visible != hbar->isVisible() | 0 |
| 344 | hbar->setVisible(visible); never executed: hbar->setVisible(visible); | 0 |
| 345 | } | 0 |
| 346 | | - |
| 347 | | - |
| 348 | | - |
| 349 | | - |
| 350 | int QColumnView::horizontalOffset() const | - |
| 351 | { | - |
| 352 | const QColumnViewPrivate * const d = d_func(); | - |
| 353 | return d->offset; never executed: return d->offset; | 0 |
| 354 | } | - |
| 355 | | - |
| 356 | | - |
| 357 | | - |
| 358 | | - |
| 359 | int QColumnView::verticalOffset() const | - |
| 360 | { | - |
| 361 | return 0; never executed: return 0; | 0 |
| 362 | } | - |
| 363 | | - |
| 364 | | - |
| 365 | | - |
| 366 | | - |
| 367 | QRegion QColumnView::visualRegionForSelection(const QItemSelection &selection) const | - |
| 368 | { | - |
| 369 | int ranges = selection.count(); | - |
| 370 | | - |
| 371 | if (ranges == 0) never evaluated: ranges == 0 | 0 |
| 372 | return QRect(); never executed: return QRect(); | 0 |
| 373 | | - |
| 374 | | - |
| 375 | | - |
| 376 | int firstRow = selection.at(0).top(); | - |
| 377 | int lastRow = selection.at(0).top(); | - |
| 378 | for (int i = 0; i < ranges; ++i) { never evaluated: i < ranges | 0 |
| 379 | firstRow = qMin(firstRow, selection.at(i).top()); | - |
| 380 | lastRow = qMax(lastRow, selection.at(i).bottom()); | - |
| 381 | } | 0 |
| 382 | | - |
| 383 | QModelIndex firstIdx = model()->index(qMin(firstRow, lastRow), 0, rootIndex()); | - |
| 384 | QModelIndex lastIdx = model()->index(qMax(firstRow, lastRow), 0, rootIndex()); | - |
| 385 | | - |
| 386 | if (firstIdx == lastIdx) never evaluated: firstIdx == lastIdx | 0 |
| 387 | return visualRect(firstIdx); never executed: return visualRect(firstIdx); | 0 |
| 388 | | - |
| 389 | QRegion firstRegion = visualRect(firstIdx); | - |
| 390 | QRegion lastRegion = visualRect(lastIdx); | - |
| 391 | return firstRegion.united(lastRegion); never executed: return firstRegion.united(lastRegion); | 0 |
| 392 | } | - |
| 393 | | - |
| 394 | | - |
| 395 | | - |
| 396 | | - |
| 397 | void QColumnView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) | - |
| 398 | { | - |
| 399 | (void)rect;; | - |
| 400 | (void)command;; | - |
| 401 | } | 0 |
| 402 | | - |
| 403 | | - |
| 404 | | - |
| 405 | | - |
| 406 | void QColumnView::setSelectionModel(QItemSelectionModel *newSelectionModel) | - |
| 407 | { | - |
| 408 | const QColumnViewPrivate * const d = d_func(); | - |
| 409 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 410 | if (d->columns.at(i)->selectionModel() == selectionModel()) { never evaluated: d->columns.at(i)->selectionModel() == selectionModel() | 0 |
| 411 | d->columns.at(i)->setSelectionModel(newSelectionModel); | - |
| 412 | break; | 0 |
| 413 | } | - |
| 414 | } | 0 |
| 415 | QAbstractItemView::setSelectionModel(newSelectionModel); | - |
| 416 | } | 0 |
| 417 | | - |
| 418 | | - |
| 419 | | - |
| 420 | | - |
| 421 | QSize QColumnView::sizeHint() const | - |
| 422 | { | - |
| 423 | const QColumnViewPrivate * const d = d_func(); | - |
| 424 | QSize sizeHint; | - |
| 425 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 426 | sizeHint += d->columns.at(i)->sizeHint(); | - |
| 427 | } | 0 |
| 428 | return sizeHint.expandedTo(QAbstractItemView::sizeHint()); never executed: return sizeHint.expandedTo(QAbstractItemView::sizeHint()); | 0 |
| 429 | } | - |
| 430 | | - |
| 431 | | - |
| 432 | | - |
| 433 | | - |
| 434 | | - |
| 435 | void QColumnViewPrivate::_q_gripMoved(int offset) | - |
| 436 | { | - |
| 437 | QColumnView * const q = q_func(); | - |
| 438 | | - |
| 439 | QObject *grip = q->sender(); | - |
| 440 | qt_noop(); | - |
| 441 | | - |
| 442 | if (q->isRightToLeft()) never evaluated: q->isRightToLeft() | 0 |
| 443 | offset = -1 * offset; never executed: offset = -1 * offset; | 0 |
| 444 | | - |
| 445 | bool found = false; | - |
| 446 | for (int i = 0; i < columns.size(); ++i) { never evaluated: i < columns.size() | 0 |
| 447 | if (!found && columns.at(i)->cornerWidget() == grip) { never evaluated: columns.at(i)->cornerWidget() == grip | 0 |
| 448 | found = true; | - |
| 449 | columnSizes[i] = columns.at(i)->width(); | - |
| 450 | if (q->isRightToLeft()) never evaluated: q->isRightToLeft() | 0 |
| 451 | columns.at(i)->move(columns.at(i)->x() + offset, 0); never executed: columns.at(i)->move(columns.at(i)->x() + offset, 0); | 0 |
| 452 | continue; never executed: continue; | 0 |
| 453 | } | - |
| 454 | if (!found) | 0 |
| 455 | continue; never executed: continue; | 0 |
| 456 | | - |
| 457 | int currentX = columns.at(i)->x(); | - |
| 458 | columns.at(i)->move(currentX + offset, 0); | - |
| 459 | } | 0 |
| 460 | | - |
| 461 | updateScrollbars(); | - |
| 462 | } | 0 |
| 463 | void QColumnViewPrivate::closeColumns(const QModelIndex &parent, bool build) | - |
| 464 | { | - |
| 465 | if (columns.isEmpty()) never evaluated: columns.isEmpty() | 0 |
| 466 | return; | 0 |
| 467 | | - |
| 468 | bool clearAll = !parent.isValid(); | - |
| 469 | bool passThroughRoot = false; | - |
| 470 | | - |
| 471 | QList<QModelIndex> dirsToAppend; | - |
| 472 | | - |
| 473 | | - |
| 474 | int currentColumn = -1; | - |
| 475 | QModelIndex parentIndex = parent; | - |
| 476 | while (currentColumn == -1 && parentIndex.isValid()) { never evaluated: currentColumn == -1 never evaluated: parentIndex.isValid() | 0 |
| 477 | if (columns.isEmpty()) never evaluated: columns.isEmpty() | 0 |
| 478 | break; | 0 |
| 479 | parentIndex = parentIndex.parent(); | - |
| 480 | if (root == parentIndex) never evaluated: root == parentIndex | 0 |
| 481 | passThroughRoot = true; never executed: passThroughRoot = true; | 0 |
| 482 | if (!parentIndex.isValid()) never evaluated: !parentIndex.isValid() | 0 |
| 483 | break; | 0 |
| 484 | for (int i = columns.size() - 1; i >= 0; --i) { | 0 |
| 485 | if (columns.at(i)->rootIndex() == parentIndex) { never evaluated: columns.at(i)->rootIndex() == parentIndex | 0 |
| 486 | currentColumn = i; | - |
| 487 | break; | 0 |
| 488 | } | - |
| 489 | } | 0 |
| 490 | if (currentColumn == -1) never evaluated: currentColumn == -1 | 0 |
| 491 | dirsToAppend.append(parentIndex); never executed: dirsToAppend.append(parentIndex); | 0 |
| 492 | } | 0 |
| 493 | | - |
| 494 | | - |
| 495 | | - |
| 496 | if (!clearAll && !passThroughRoot && currentColumn == -1) never evaluated: !clearAll never evaluated: !passThroughRoot never evaluated: currentColumn == -1 | 0 |
| 497 | return; | 0 |
| 498 | | - |
| 499 | if (currentColumn == -1 && parent.isValid()) never evaluated: currentColumn == -1 never evaluated: parent.isValid() | 0 |
| 500 | currentColumn = 0; never executed: currentColumn = 0; | 0 |
| 501 | | - |
| 502 | | - |
| 503 | bool alreadyExists = false; | - |
| 504 | if (build && columns.size() > currentColumn + 1) { never evaluated: columns.size() > currentColumn + 1 | 0 |
| 505 | bool viewingParent = (columns.at(currentColumn + 1)->rootIndex() == parent); | - |
| 506 | bool viewingChild = (!model->hasChildren(parent) never evaluated: !model->hasChildren(parent) | 0 |
| 507 | && !columns.at(currentColumn + 1)->rootIndex().isValid()); never evaluated: !columns.at(currentColumn + 1)->rootIndex().isValid() | 0 |
| 508 | if (viewingParent || viewingChild) { never evaluated: viewingParent never evaluated: viewingChild | 0 |
| 509 | currentColumn++; | - |
| 510 | alreadyExists = true; | - |
| 511 | } | 0 |
| 512 | } | 0 |
| 513 | | - |
| 514 | | - |
| 515 | for (int i = columns.size() - 1; i > currentColumn; --i) { never evaluated: i > currentColumn | 0 |
| 516 | QAbstractItemView* notShownAnymore = columns.at(i); | - |
| 517 | columns.removeAt(i); | - |
| 518 | notShownAnymore->setVisible(false); | - |
| 519 | if (notShownAnymore != previewColumn) never evaluated: notShownAnymore != previewColumn | 0 |
| 520 | notShownAnymore->deleteLater(); never executed: notShownAnymore->deleteLater(); | 0 |
| 521 | } | 0 |
| 522 | | - |
| 523 | if (columns.isEmpty()) { never evaluated: columns.isEmpty() | 0 |
| 524 | offset = 0; | - |
| 525 | updateScrollbars(); | - |
| 526 | } | 0 |
| 527 | | - |
| 528 | | - |
| 529 | while (!dirsToAppend.isEmpty()) { never evaluated: !dirsToAppend.isEmpty() | 0 |
| 530 | QAbstractItemView *newView = createColumn(dirsToAppend.takeLast(), true); | - |
| 531 | if (!dirsToAppend.isEmpty()) never evaluated: !dirsToAppend.isEmpty() | 0 |
| 532 | newView->setCurrentIndex(dirsToAppend.last()); never executed: newView->setCurrentIndex(dirsToAppend.last()); | 0 |
| 533 | } | 0 |
| 534 | | - |
| 535 | if (build && !alreadyExists) never evaluated: !alreadyExists | 0 |
| 536 | createColumn(parent, false); never executed: createColumn(parent, false); | 0 |
| 537 | } | 0 |
| 538 | | - |
| 539 | void QColumnViewPrivate::_q_clicked(const QModelIndex &index) | - |
| 540 | { | - |
| 541 | QColumnView * const q = q_func(); | - |
| 542 | QModelIndex parent = index.parent(); | - |
| 543 | QAbstractItemView *columnClicked = 0; | - |
| 544 | for (int column = 0; column < columns.count(); ++column) { never evaluated: column < columns.count() | 0 |
| 545 | if (columns.at(column)->rootIndex() == parent) { never evaluated: columns.at(column)->rootIndex() == parent | 0 |
| 546 | columnClicked = columns[column]; | - |
| 547 | break; | 0 |
| 548 | } | - |
| 549 | } | 0 |
| 550 | if (q->selectionModel() && columnClicked) { never evaluated: q->selectionModel() never evaluated: columnClicked | 0 |
| 551 | QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::Current; | - |
| 552 | if (columnClicked->selectionModel()->isSelected(index)) never evaluated: columnClicked->selectionModel()->isSelected(index) | 0 |
| 553 | flags |= QItemSelectionModel::Select; never executed: flags |= QItemSelectionModel::Select; | 0 |
| 554 | q->selectionModel()->setCurrentIndex(index, flags); | - |
| 555 | } | 0 |
| 556 | } | 0 |
| 557 | QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bool show) | - |
| 558 | { | - |
| 559 | QColumnView * const q = q_func(); | - |
| 560 | QAbstractItemView *view = 0; | - |
| 561 | if (model->hasChildren(index)) { never evaluated: model->hasChildren(index) | 0 |
| 562 | view = q->createColumn(index); | - |
| 563 | q->connect(view, "2""clicked(QModelIndex)", | - |
| 564 | q, "1""_q_clicked(QModelIndex)"); | - |
| 565 | } else { | 0 |
| 566 | if (!previewColumn) never evaluated: !previewColumn | 0 |
| 567 | setPreviewWidget(new QWidget(q)); never executed: setPreviewWidget(new QWidget(q)); | 0 |
| 568 | view = previewColumn; | - |
| 569 | view->setMinimumWidth(qMax(view->minimumWidth(), previewWidget->minimumWidth())); | - |
| 570 | } | 0 |
| 571 | | - |
| 572 | q->connect(view, "2""activated(QModelIndex)", | - |
| 573 | q, "2""activated(QModelIndex)"); | - |
| 574 | q->connect(view, "2""clicked(QModelIndex)", | - |
| 575 | q, "2""clicked(QModelIndex)"); | - |
| 576 | q->connect(view, "2""doubleClicked(QModelIndex)", | - |
| 577 | q, "2""doubleClicked(QModelIndex)"); | - |
| 578 | q->connect(view, "2""entered(QModelIndex)", | - |
| 579 | q, "2""entered(QModelIndex)"); | - |
| 580 | q->connect(view, "2""pressed(QModelIndex)", | - |
| 581 | q, "2""pressed(QModelIndex)"); | - |
| 582 | | - |
| 583 | view->setFocusPolicy(Qt::NoFocus); | - |
| 584 | view->setParent(viewport); | - |
| 585 | qt_noop(); | - |
| 586 | | - |
| 587 | | - |
| 588 | if (showResizeGrips) { never evaluated: showResizeGrips | 0 |
| 589 | QColumnViewGrip *grip = new QColumnViewGrip(view); | - |
| 590 | view->setCornerWidget(grip); | - |
| 591 | q->connect(grip, "2""gripMoved(int)", q, "1""_q_gripMoved(int)"); | - |
| 592 | } | 0 |
| 593 | | - |
| 594 | if (columnSizes.count() > columns.count()) { never evaluated: columnSizes.count() > columns.count() | 0 |
| 595 | view->setGeometry(0, 0, columnSizes.at(columns.count()), viewport->height()); | - |
| 596 | } else { | 0 |
| 597 | int initialWidth = view->sizeHint().width(); | - |
| 598 | if (q->isRightToLeft()) never evaluated: q->isRightToLeft() | 0 |
| 599 | view->setGeometry(viewport->width() - initialWidth, 0, initialWidth, viewport->height()); never executed: view->setGeometry(viewport->width() - initialWidth, 0, initialWidth, viewport->height()); | 0 |
| 600 | else | - |
| 601 | view->setGeometry(0, 0, initialWidth, viewport->height()); never executed: view->setGeometry(0, 0, initialWidth, viewport->height()); | 0 |
| 602 | columnSizes.resize(qMax(columnSizes.count(), columns.count() + 1)); | - |
| 603 | columnSizes[columns.count()] = initialWidth; | - |
| 604 | } | 0 |
| 605 | if (!columns.isEmpty() && columns.last()->isHidden()) never evaluated: !columns.isEmpty() never evaluated: columns.last()->isHidden() | 0 |
| 606 | columns.last()->setVisible(true); never executed: columns.last()->setVisible(true); | 0 |
| 607 | | - |
| 608 | columns.append(view); | - |
| 609 | doLayout(); | - |
| 610 | updateScrollbars(); | - |
| 611 | if (show && view->isHidden()) never evaluated: view->isHidden() | 0 |
| 612 | view->setVisible(true); never executed: view->setVisible(true); | 0 |
| 613 | return view; never executed: return view; | 0 |
| 614 | } | - |
| 615 | QAbstractItemView *QColumnView::createColumn(const QModelIndex &index) | - |
| 616 | { | - |
| 617 | QListView *view = new QListView(viewport()); | - |
| 618 | | - |
| 619 | initializeColumn(view); | - |
| 620 | | - |
| 621 | view->setRootIndex(index); | - |
| 622 | if (model()->canFetchMore(index)) never evaluated: model()->canFetchMore(index) | 0 |
| 623 | model()->fetchMore(index); never executed: model()->fetchMore(index); | 0 |
| 624 | | - |
| 625 | return view; never executed: return view; | 0 |
| 626 | } | - |
| 627 | void QColumnView::initializeColumn(QAbstractItemView *column) const | - |
| 628 | { | - |
| 629 | const QColumnViewPrivate * const d = d_func(); | - |
| 630 | | - |
| 631 | column->setFrameShape(QFrame::NoFrame); | - |
| 632 | column->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - |
| 633 | column->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | - |
| 634 | column->setMinimumWidth(100); | - |
| 635 | column->setAttribute(Qt::WA_MacShowFocusRect, false); | - |
| 636 | | - |
| 637 | | - |
| 638 | column->setDragDropMode(dragDropMode()); | - |
| 639 | column->setDragDropOverwriteMode(dragDropOverwriteMode()); | - |
| 640 | column->setDropIndicatorShown(showDropIndicator()); | - |
| 641 | | - |
| 642 | column->setAlternatingRowColors(alternatingRowColors()); | - |
| 643 | column->setAutoScroll(hasAutoScroll()); | - |
| 644 | column->setEditTriggers(editTriggers()); | - |
| 645 | column->setHorizontalScrollMode(horizontalScrollMode()); | - |
| 646 | column->setIconSize(iconSize()); | - |
| 647 | column->setSelectionBehavior(selectionBehavior()); | - |
| 648 | column->setSelectionMode(selectionMode()); | - |
| 649 | column->setTabKeyNavigation(tabKeyNavigation()); | - |
| 650 | column->setTextElideMode(textElideMode()); | - |
| 651 | column->setVerticalScrollMode(verticalScrollMode()); | - |
| 652 | | - |
| 653 | column->setModel(model()); | - |
| 654 | | - |
| 655 | | - |
| 656 | QMapIterator<int, QPointer<QAbstractItemDelegate> > i(d->rowDelegates); | - |
| 657 | while (i.hasNext()) { never evaluated: i.hasNext() | 0 |
| 658 | i.next(); | - |
| 659 | column->setItemDelegateForRow(i.key(), i.value()); | - |
| 660 | } | 0 |
| 661 | | - |
| 662 | | - |
| 663 | QAbstractItemDelegate *delegate = column->itemDelegate(); | - |
| 664 | column->setItemDelegate(d->itemDelegate); | - |
| 665 | delete delegate; | - |
| 666 | } | 0 |
| 667 | | - |
| 668 | | - |
| 669 | | - |
| 670 | | - |
| 671 | | - |
| 672 | | - |
| 673 | QWidget *QColumnView::previewWidget() const | - |
| 674 | { | - |
| 675 | const QColumnViewPrivate * const d = d_func(); | - |
| 676 | return d->previewWidget; never executed: return d->previewWidget; | 0 |
| 677 | } | - |
| 678 | void QColumnView::setPreviewWidget(QWidget *widget) | - |
| 679 | { | - |
| 680 | QColumnViewPrivate * const d = d_func(); | - |
| 681 | d->setPreviewWidget(widget); | - |
| 682 | } | 0 |
| 683 | | - |
| 684 | | - |
| 685 | | - |
| 686 | | - |
| 687 | void QColumnViewPrivate::setPreviewWidget(QWidget *widget) | - |
| 688 | { | - |
| 689 | QColumnView * const q = q_func(); | - |
| 690 | if (previewColumn) { never evaluated: previewColumn | 0 |
| 691 | if (!columns.isEmpty() && columns.last() == previewColumn) never evaluated: !columns.isEmpty() never evaluated: columns.last() == previewColumn | 0 |
| 692 | columns.removeLast(); never executed: columns.removeLast(); | 0 |
| 693 | previewColumn->deleteLater(); | - |
| 694 | } | 0 |
| 695 | QColumnViewPreviewColumn *column = new QColumnViewPreviewColumn(q); | - |
| 696 | column->setPreviewWidget(widget); | - |
| 697 | previewColumn = column; | - |
| 698 | previewColumn->hide(); | - |
| 699 | previewColumn->setFrameShape(QFrame::NoFrame); | - |
| 700 | previewColumn->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | - |
| 701 | previewColumn->setSelectionMode(QAbstractItemView::NoSelection); | - |
| 702 | previewColumn->setMinimumWidth(qMax(previewColumn->verticalScrollBar()->width(), | - |
| 703 | previewColumn->minimumWidth())); | - |
| 704 | previewWidget = widget; | - |
| 705 | previewWidget->setParent(previewColumn->viewport()); | - |
| 706 | } | 0 |
| 707 | void QColumnView::setColumnWidths(const QList<int> &list) | - |
| 708 | { | - |
| 709 | QColumnViewPrivate * const d = d_func(); | - |
| 710 | int i = 0; | - |
| 711 | for (; (i < list.count() && i < d->columns.count()); ++i) { never evaluated: i < list.count() never evaluated: i < d->columns.count() | 0 |
| 712 | d->columns.at(i)->resize(list.at(i), d->columns.at(i)->height()); | - |
| 713 | d->columnSizes[i] = list.at(i); | - |
| 714 | } | 0 |
| 715 | for (; i < list.count(); ++i) never evaluated: i < list.count() | 0 |
| 716 | d->columnSizes.append(list.at(i)); never executed: d->columnSizes.append(list.at(i)); | 0 |
| 717 | } | 0 |
| 718 | | - |
| 719 | | - |
| 720 | | - |
| 721 | | - |
| 722 | | - |
| 723 | | - |
| 724 | QList<int> QColumnView::columnWidths() const | - |
| 725 | { | - |
| 726 | const QColumnViewPrivate * const d = d_func(); | - |
| 727 | QList<int> list; | - |
| 728 | for (int i = 0; i < d->columns.count(); ++i) never evaluated: i < d->columns.count() | 0 |
| 729 | list.append(d->columnSizes.at(i)); never executed: list.append(d->columnSizes.at(i)); | 0 |
| 730 | return list; never executed: return list; | 0 |
| 731 | } | - |
| 732 | | - |
| 733 | | - |
| 734 | | - |
| 735 | | - |
| 736 | void QColumnView::rowsInserted(const QModelIndex &parent, int start, int end) | - |
| 737 | { | - |
| 738 | QAbstractItemView::rowsInserted(parent, start, end); | - |
| 739 | d_func()->checkColumnCreation(parent); | - |
| 740 | } | 0 |
| 741 | | - |
| 742 | | - |
| 743 | | - |
| 744 | | - |
| 745 | void QColumnView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | - |
| 746 | { | - |
| 747 | QColumnViewPrivate * const d = d_func(); | - |
| 748 | if (!current.isValid()) { never evaluated: !current.isValid() | 0 |
| 749 | QAbstractItemView::currentChanged(current, previous); | - |
| 750 | return; | 0 |
| 751 | } | - |
| 752 | | - |
| 753 | QModelIndex currentParent = current.parent(); | - |
| 754 | | - |
| 755 | if (currentParent == previous.parent() never evaluated: currentParent == previous.parent() | 0 |
| 756 | && model()->hasChildren(current) && model()->hasChildren(previous)) { never evaluated: model()->hasChildren(current) never evaluated: model()->hasChildren(previous) | 0 |
| 757 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 758 | if (currentParent == d->columns.at(i)->rootIndex()) { never evaluated: currentParent == d->columns.at(i)->rootIndex() | 0 |
| 759 | if (d->columns.size() > i + 1) { never evaluated: d->columns.size() > i + 1 | 0 |
| 760 | QAbstractItemView::currentChanged(current, previous); | - |
| 761 | return; | 0 |
| 762 | } | - |
| 763 | break; | 0 |
| 764 | } | - |
| 765 | } | 0 |
| 766 | } | 0 |
| 767 | | - |
| 768 | | - |
| 769 | bool found = false; | - |
| 770 | if (currentParent == previous) { never evaluated: currentParent == previous | 0 |
| 771 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 772 | if (currentParent == d->columns.at(i)->rootIndex()) { never evaluated: currentParent == d->columns.at(i)->rootIndex() | 0 |
| 773 | found = true; | - |
| 774 | if (d->columns.size() < i + 2) { never evaluated: d->columns.size() < i + 2 | 0 |
| 775 | d->createColumn(current, false); | - |
| 776 | } | 0 |
| 777 | break; | 0 |
| 778 | } | - |
| 779 | } | 0 |
| 780 | } | 0 |
| 781 | if (!found) | 0 |
| 782 | d->closeColumns(current, true); never executed: d->closeColumns(current, true); | 0 |
| 783 | | - |
| 784 | if (!model()->hasChildren(current)) never evaluated: !model()->hasChildren(current) | 0 |
| 785 | updatePreviewWidget(current); never executed: updatePreviewWidget(current); | 0 |
| 786 | | - |
| 787 | QAbstractItemView::currentChanged(current, previous); | - |
| 788 | } | 0 |
| 789 | | - |
| 790 | | - |
| 791 | | - |
| 792 | | - |
| 793 | | - |
| 794 | void QColumnViewPrivate::_q_changeCurrentColumn() | - |
| 795 | { | - |
| 796 | QColumnView * const q = q_func(); | - |
| 797 | if (columns.isEmpty()) never evaluated: columns.isEmpty() | 0 |
| 798 | return; | 0 |
| 799 | | - |
| 800 | QModelIndex current = q->currentIndex(); | - |
| 801 | if (!current.isValid()) never evaluated: !current.isValid() | 0 |
| 802 | return; | 0 |
| 803 | | - |
| 804 | | - |
| 805 | closeColumns(current, true); | - |
| 806 | | - |
| 807 | | - |
| 808 | int currentColumn = qMax(0, columns.size() - 2); | - |
| 809 | QAbstractItemView *parentColumn = columns.at(currentColumn); | - |
| 810 | if (q->hasFocus()) never evaluated: q->hasFocus() | 0 |
| 811 | parentColumn->setFocus(Qt::OtherFocusReason); never executed: parentColumn->setFocus(Qt::OtherFocusReason); | 0 |
| 812 | q->setFocusProxy(parentColumn); | - |
| 813 | | - |
| 814 | | - |
| 815 | for (int i = 0; i < columns.size(); ++i) { never evaluated: i < columns.size() | 0 |
| 816 | if (columns.at(i)->selectionModel() == q->selectionModel()) { never evaluated: columns.at(i)->selectionModel() == q->selectionModel() | 0 |
| 817 | QItemSelectionModel *replacementSelectionModel = | - |
| 818 | new QItemSelectionModel(parentColumn->model()); | - |
| 819 | replacementSelectionModel->setCurrentIndex( | - |
| 820 | q->selectionModel()->currentIndex(), QItemSelectionModel::Current); | - |
| 821 | replacementSelectionModel->select( | - |
| 822 | q->selectionModel()->selection(), QItemSelectionModel::Select); | - |
| 823 | QAbstractItemView *view = columns.at(i); | - |
| 824 | view->setSelectionModel(replacementSelectionModel); | - |
| 825 | view->setFocusPolicy(Qt::NoFocus); | - |
| 826 | if (columns.size() > i + 1) never evaluated: columns.size() > i + 1 | 0 |
| 827 | view->setCurrentIndex(columns.at(i+1)->rootIndex()); never executed: view->setCurrentIndex(columns.at(i+1)->rootIndex()); | 0 |
| 828 | break; | 0 |
| 829 | } | - |
| 830 | } | 0 |
| 831 | parentColumn->selectionModel()->deleteLater(); | - |
| 832 | parentColumn->setFocusPolicy(Qt::StrongFocus); | - |
| 833 | parentColumn->setSelectionModel(q->selectionModel()); | - |
| 834 | | - |
| 835 | if (currentColumn > 0) { never evaluated: currentColumn > 0 | 0 |
| 836 | parentColumn = columns.at(currentColumn - 1); | - |
| 837 | if (parentColumn->currentIndex() != current.parent()) never evaluated: parentColumn->currentIndex() != current.parent() | 0 |
| 838 | parentColumn->setCurrentIndex(current.parent()); never executed: parentColumn->setCurrentIndex(current.parent()); | 0 |
| 839 | } | 0 |
| 840 | | - |
| 841 | if (columns.last()->isHidden()) { never evaluated: columns.last()->isHidden() | 0 |
| 842 | columns.last()->setVisible(true); | - |
| 843 | } | 0 |
| 844 | if (columns.last()->selectionModel()) never evaluated: columns.last()->selectionModel() | 0 |
| 845 | columns.last()->selectionModel()->clear(); never executed: columns.last()->selectionModel()->clear(); | 0 |
| 846 | updateScrollbars(); | - |
| 847 | } | 0 |
| 848 | | - |
| 849 | | - |
| 850 | | - |
| 851 | | - |
| 852 | void QColumnView::selectAll() | - |
| 853 | { | - |
| 854 | if (!model() || !selectionModel()) never evaluated: !model() never evaluated: !selectionModel() | 0 |
| 855 | return; | 0 |
| 856 | | - |
| 857 | QModelIndexList indexList = selectionModel()->selectedIndexes(); | - |
| 858 | QModelIndex parent = rootIndex(); | - |
| 859 | QItemSelection selection; | - |
| 860 | if (indexList.count() >= 1) never evaluated: indexList.count() >= 1 | 0 |
| 861 | parent = indexList.at(0).parent(); never executed: parent = indexList.at(0).parent(); | 0 |
| 862 | if (indexList.count() == 1) { never evaluated: indexList.count() == 1 | 0 |
| 863 | parent = indexList.at(0); | - |
| 864 | if (!model()->hasChildren(parent)) never evaluated: !model()->hasChildren(parent) | 0 |
| 865 | parent = parent.parent(); never executed: parent = parent.parent(); | 0 |
| 866 | else | - |
| 867 | selection.append(QItemSelectionRange(parent, parent)); never executed: selection.append(QItemSelectionRange(parent, parent)); | 0 |
| 868 | } | - |
| 869 | | - |
| 870 | QModelIndex tl = model()->index(0, 0, parent); | - |
| 871 | QModelIndex br = model()->index(model()->rowCount(parent) - 1, | - |
| 872 | model()->columnCount(parent) - 1, | - |
| 873 | parent); | - |
| 874 | selection.append(QItemSelectionRange(tl, br)); | - |
| 875 | selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect); | - |
| 876 | } | 0 |
| 877 | | - |
| 878 | | - |
| 879 | | - |
| 880 | | - |
| 881 | QColumnViewPrivate::QColumnViewPrivate() | - |
| 882 | : QAbstractItemViewPrivate() | - |
| 883 | ,showResizeGrips(true) | - |
| 884 | ,offset(0) | - |
| 885 | ,previewWidget(0) | - |
| 886 | ,previewColumn(0) | - |
| 887 | { | - |
| 888 | } | 0 |
| 889 | | - |
| 890 | QColumnViewPrivate::~QColumnViewPrivate() | - |
| 891 | { | - |
| 892 | } | - |
| 893 | | - |
| 894 | | - |
| 895 | | - |
| 896 | | - |
| 897 | | - |
| 898 | void QColumnViewPrivate::_q_columnsInserted(const QModelIndex &parent, int start, int end) | - |
| 899 | { | - |
| 900 | QAbstractItemViewPrivate::_q_columnsInserted(parent, start, end); | - |
| 901 | checkColumnCreation(parent); | - |
| 902 | } | 0 |
| 903 | | - |
| 904 | | - |
| 905 | | - |
| 906 | | - |
| 907 | | - |
| 908 | | - |
| 909 | | - |
| 910 | void QColumnViewPrivate::checkColumnCreation(const QModelIndex &parent) | - |
| 911 | { | - |
| 912 | if (parent == q_func()->currentIndex() && model->hasChildren(parent)) { never evaluated: parent == q_func()->currentIndex() never evaluated: model->hasChildren(parent) | 0 |
| 913 | | - |
| 914 | | - |
| 915 | for (int i = 0; i < columns.count(); ++i) { never evaluated: i < columns.count() | 0 |
| 916 | QAbstractItemView *view = columns.at(i); | - |
| 917 | if (view->rootIndex() == parent) { never evaluated: view->rootIndex() == parent | 0 |
| 918 | if (view == previewColumn) { never evaluated: view == previewColumn | 0 |
| 919 | | - |
| 920 | closeColumns(parent, false); | - |
| 921 | createColumn(parent, true ); | - |
| 922 | } | 0 |
| 923 | break; | 0 |
| 924 | } | - |
| 925 | } | 0 |
| 926 | } | 0 |
| 927 | } | 0 |
| 928 | | - |
| 929 | | - |
| 930 | | - |
| 931 | | - |
| 932 | | - |
| 933 | void QColumnViewPrivate::doLayout() | - |
| 934 | { | - |
| 935 | QColumnView * const q = q_func(); | - |
| 936 | if (!model || columns.isEmpty()) never evaluated: columns.isEmpty() | 0 |
| 937 | return; | 0 |
| 938 | | - |
| 939 | int viewportHeight = viewport->height(); | - |
| 940 | int x = columns.at(0)->x(); | - |
| 941 | | - |
| 942 | if (q->isRightToLeft()) { never evaluated: q->isRightToLeft() | 0 |
| 943 | x = viewport->width() + q->horizontalOffset(); | - |
| 944 | for (int i = 0; i < columns.size(); ++i) { never evaluated: i < columns.size() | 0 |
| 945 | QAbstractItemView *view = columns.at(i); | - |
| 946 | x -= view->width(); | - |
| 947 | if (x != view->x() || viewportHeight != view->height()) never evaluated: x != view->x() never evaluated: viewportHeight != view->height() | 0 |
| 948 | view->setGeometry(x, 0, view->width(), viewportHeight); never executed: view->setGeometry(x, 0, view->width(), viewportHeight); | 0 |
| 949 | } | 0 |
| 950 | } else { | 0 |
| 951 | for (int i = 0; i < columns.size(); ++i) { never evaluated: i < columns.size() | 0 |
| 952 | QAbstractItemView *view = columns.at(i); | - |
| 953 | int currentColumnWidth = view->width(); | - |
| 954 | if (x != view->x() || viewportHeight != view->height()) never evaluated: x != view->x() never evaluated: viewportHeight != view->height() | 0 |
| 955 | view->setGeometry(x, 0, currentColumnWidth, viewportHeight); never executed: view->setGeometry(x, 0, currentColumnWidth, viewportHeight); | 0 |
| 956 | x += currentColumnWidth; | - |
| 957 | } | 0 |
| 958 | } | 0 |
| 959 | } | - |
| 960 | void QColumnViewDelegate::paint(QPainter *painter, | - |
| 961 | const QStyleOptionViewItem &option, | - |
| 962 | const QModelIndex &index) const | - |
| 963 | { | - |
| 964 | drawBackground(painter, option, index ); | - |
| 965 | | - |
| 966 | bool reverse = (option.direction == Qt::RightToLeft); | - |
| 967 | int width = ((option.rect.height() * 2) / 3); | - |
| 968 | | - |
| 969 | QStyleOptionViewItem opt = option; | - |
| 970 | if (reverse) | 0 |
| 971 | opt.rect.adjust(width,0,0,0); never executed: opt.rect.adjust(width,0,0,0); | 0 |
| 972 | else | - |
| 973 | opt.rect.adjust(0,0,-width,0); never executed: opt.rect.adjust(0,0,-width,0); | 0 |
| 974 | | - |
| 975 | if (!(index.model()->flags(index) & Qt::ItemIsEnabled)) { never evaluated: !(index.model()->flags(index) & Qt::ItemIsEnabled) | 0 |
| 976 | opt.showDecorationSelected = true; | - |
| 977 | opt.state |= QStyle::State_Selected; | - |
| 978 | } | 0 |
| 979 | | - |
| 980 | QItemDelegate::paint(painter, opt, index); | - |
| 981 | | - |
| 982 | if (reverse) | 0 |
| 983 | opt.rect = QRect(option.rect.x(), option.rect.y(), width, option.rect.height()); never executed: opt.rect = QRect(option.rect.x(), option.rect.y(), width, option.rect.height()); | 0 |
| 984 | else | - |
| 985 | opt.rect = QRect(option.rect.x() + option.rect.width() - width, option.rect.y(), | 0 |
| 986 | width, option.rect.height()); never executed: opt.rect = QRect(option.rect.x() + option.rect.width() - width, option.rect.y(), width, option.rect.height()); | 0 |
| 987 | | - |
| 988 | | - |
| 989 | if (index.model()->hasChildren(index)) { never evaluated: index.model()->hasChildren(index) | 0 |
| 990 | const QWidget *view = opt.widget; | - |
| 991 | QStyle *style = view ? view->style() : QApplication::style(); | 0 |
| 992 | style->drawPrimitive(QStyle::PE_IndicatorColumnViewArrow, &opt, painter, view); | - |
| 993 | } | 0 |
| 994 | } | 0 |
| 995 | | - |
| 996 | | - |
| 997 | | - |
| 998 | | - |
| | |