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