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