| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include <qglobal.h> | - |
| 43 | | - |
| 44 | #ifndef QT_NO_COLUMNVIEW | - |
| 45 | | - |
| 46 | #include "qcolumnview.h" | - |
| 47 | #include "qcolumnview_p.h" | - |
| 48 | #include "qcolumnviewgrip_p.h" | - |
| 49 | | - |
| 50 | #include <qlistview.h> | - |
| 51 | #include <qabstractitemdelegate.h> | - |
| 52 | #include <qscrollbar.h> | - |
| 53 | #include <qpainter.h> | - |
| 54 | #include <qdebug.h> | - |
| 55 | | - |
| 56 | QT_BEGIN_NAMESPACE | - |
| 57 | | - |
| 58 | #define ANIMATION_DURATION_MSEC 150 | - |
| 59 | | - |
| 60 | /*! | - |
| 61 | \since 4.3 | - |
| 62 | \class QColumnView | - |
| 63 | \brief The QColumnView class provides a model/view implementation of a column view. | - |
| 64 | \ingroup model-view | - |
| 65 | \ingroup advanced | - |
| 66 | \inmodule QtWidgets | - |
| 67 | | - |
| 68 | QColumnView displays a model in a number of QListViews, one for each | - |
| 69 | hierarchy in the tree. This is sometimes referred to as a cascading list. | - |
| 70 | | - |
| 71 | The QColumnView class is one of the \l{Model/View Classes} | - |
| 72 | and is part of Qt's \l{Model/View Programming}{model/view framework}. | - |
| 73 | | - |
| 74 | QColumnView implements the interfaces defined by the | - |
| 75 | QAbstractItemView class to allow it to display data provided by | - |
| 76 | models derived from the QAbstractItemModel class. | - |
| 77 | | - |
| 78 | \image qcolumnview.png | - |
| 79 | | - |
| 80 | \sa {Model/View Programming} | - |
| 81 | */ | - |
| 82 | | - |
| 83 | /*! | - |
| 84 | Constructs a column view with a \a parent to represent a model's | - |
| 85 | data. Use setModel() to set the model. | - |
| 86 | | - |
| 87 | \sa QAbstractItemModel | - |
| 88 | */ | - |
| 89 | QColumnView::QColumnView(QWidget * parent) | - |
| 90 | : QAbstractItemView(*new QColumnViewPrivate, parent) | - |
| 91 | { | - |
| 92 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 93 | d->initialize(); never executed (the execution status of this line is deduced): d->initialize(); | - |
| 94 | } | 0 |
| 95 | | - |
| 96 | /*! | - |
| 97 | \internal | - |
| 98 | */ | - |
| 99 | QColumnView::QColumnView(QColumnViewPrivate & dd, QWidget * parent) | - |
| 100 | : QAbstractItemView(dd, parent) | - |
| 101 | { | - |
| 102 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 103 | d->initialize(); never executed (the execution status of this line is deduced): d->initialize(); | - |
| 104 | } | 0 |
| 105 | | - |
| 106 | void QColumnViewPrivate::initialize() | - |
| 107 | { | - |
| 108 | Q_Q(QColumnView); never executed (the execution status of this line is deduced): QColumnView * const q = q_func(); | - |
| 109 | q->setTextElideMode(Qt::ElideMiddle); never executed (the execution status of this line is deduced): q->setTextElideMode(Qt::ElideMiddle); | - |
| 110 | #ifndef QT_NO_ANIMATION | - |
| 111 | QObject::connect(¤tAnimation, SIGNAL(finished()), q, SLOT(_q_changeCurrentColumn())); never executed (the execution status of this line is deduced): QObject::connect(¤tAnimation, "2""finished()", q, "1""_q_changeCurrentColumn()"); | - |
| 112 | currentAnimation.setDuration(ANIMATION_DURATION_MSEC); never executed (the execution status of this line is deduced): currentAnimation.setDuration(150); | - |
| 113 | currentAnimation.setTargetObject(hbar); never executed (the execution status of this line is deduced): currentAnimation.setTargetObject(hbar); | - |
| 114 | currentAnimation.setPropertyName("value"); never executed (the execution status of this line is deduced): currentAnimation.setPropertyName("value"); | - |
| 115 | currentAnimation.setEasingCurve(QEasingCurve::InOutQuad); never executed (the execution status of this line is deduced): currentAnimation.setEasingCurve(QEasingCurve::InOutQuad); | - |
| 116 | #endif //QT_NO_ANIMATION | - |
| 117 | delete itemDelegate; never executed (the execution status of this line is deduced): delete itemDelegate; | - |
| 118 | q->setItemDelegate(new QColumnViewDelegate(q)); never executed (the execution status of this line is deduced): q->setItemDelegate(new QColumnViewDelegate(q)); | - |
| 119 | } | 0 |
| 120 | | - |
| 121 | /*! | - |
| 122 | Destroys the column view. | - |
| 123 | */ | - |
| 124 | QColumnView::~QColumnView() | - |
| 125 | { | - |
| 126 | } | - |
| 127 | | - |
| 128 | /*! | - |
| 129 | \property QColumnView::resizeGripsVisible | - |
| 130 | \brief the way to specify if the list views gets resize grips or not | - |
| 131 | | - |
| 132 | By default, \c visible is set to true | - |
| 133 | | - |
| 134 | \sa setRootIndex() | - |
| 135 | */ | - |
| 136 | void QColumnView::setResizeGripsVisible(bool visible) | - |
| 137 | { | - |
| 138 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 139 | if (d->showResizeGrips == visible) never evaluated: d->showResizeGrips == visible | 0 |
| 140 | return; | 0 |
| 141 | d->showResizeGrips = visible; never executed (the execution status of this line is deduced): d->showResizeGrips = visible; | - |
| 142 | for (int i = 0; i < d->columns.count(); ++i) { never evaluated: i < d->columns.count() | 0 |
| 143 | QAbstractItemView *view = d->columns[i]; never executed (the execution status of this line is deduced): QAbstractItemView *view = d->columns[i]; | - |
| 144 | if (visible) { | 0 |
| 145 | QColumnViewGrip *grip = new QColumnViewGrip(view); never executed (the execution status of this line is deduced): QColumnViewGrip *grip = new QColumnViewGrip(view); | - |
| 146 | view->setCornerWidget(grip); never executed (the execution status of this line is deduced): view->setCornerWidget(grip); | - |
| 147 | connect(grip, SIGNAL(gripMoved(int)), this, SLOT(_q_gripMoved(int))); never executed (the execution status of this line is deduced): connect(grip, "2""gripMoved(int)", this, "1""_q_gripMoved(int)"); | - |
| 148 | } else { | 0 |
| 149 | QWidget *widget = view->cornerWidget(); never executed (the execution status of this line is deduced): QWidget *widget = view->cornerWidget(); | - |
| 150 | view->setCornerWidget(0); never executed (the execution status of this line is deduced): view->setCornerWidget(0); | - |
| 151 | widget->deleteLater(); never executed (the execution status of this line is deduced): widget->deleteLater(); | - |
| 152 | } | 0 |
| 153 | } | - |
| 154 | } | 0 |
| 155 | | - |
| 156 | bool QColumnView::resizeGripsVisible() const | - |
| 157 | { | - |
| 158 | Q_D(const QColumnView); never executed (the execution status of this line is deduced): const QColumnViewPrivate * const d = d_func(); | - |
| 159 | return d->showResizeGrips; never executed: return d->showResizeGrips; | 0 |
| 160 | } | - |
| 161 | | - |
| 162 | /*! | - |
| 163 | \reimp | - |
| 164 | */ | - |
| 165 | void QColumnView::setModel(QAbstractItemModel *model) | - |
| 166 | { | - |
| 167 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 168 | if (model == d->model) never evaluated: model == d->model | 0 |
| 169 | return; | 0 |
| 170 | d->closeColumns(); never executed (the execution status of this line is deduced): d->closeColumns(); | - |
| 171 | QAbstractItemView::setModel(model); never executed (the execution status of this line is deduced): QAbstractItemView::setModel(model); | - |
| 172 | } | 0 |
| 173 | | - |
| 174 | /*! | - |
| 175 | \reimp | - |
| 176 | */ | - |
| 177 | void QColumnView::setRootIndex(const QModelIndex &index) | - |
| 178 | { | - |
| 179 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 180 | if (!model()) never evaluated: !model() | 0 |
| 181 | return; | 0 |
| 182 | | - |
| 183 | d->closeColumns(); never executed (the execution status of this line is deduced): d->closeColumns(); | - |
| 184 | Q_ASSERT(d->columns.count() == 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 185 | | - |
| 186 | QAbstractItemView *view = d->createColumn(index, true); never executed (the execution status of this line is deduced): QAbstractItemView *view = d->createColumn(index, true); | - |
| 187 | if (view->selectionModel()) never evaluated: view->selectionModel() | 0 |
| 188 | view->selectionModel()->deleteLater(); never executed: view->selectionModel()->deleteLater(); | 0 |
| 189 | if (view->model()) never evaluated: view->model() | 0 |
| 190 | view->setSelectionModel(selectionModel()); never executed: view->setSelectionModel(selectionModel()); | 0 |
| 191 | | - |
| 192 | QAbstractItemView::setRootIndex(index); never executed (the execution status of this line is deduced): QAbstractItemView::setRootIndex(index); | - |
| 193 | d->updateScrollbars(); never executed (the execution status of this line is deduced): d->updateScrollbars(); | - |
| 194 | } | 0 |
| 195 | | - |
| 196 | /*! | - |
| 197 | \reimp | - |
| 198 | */ | - |
| 199 | bool QColumnView::isIndexHidden(const QModelIndex &index) const | - |
| 200 | { | - |
| 201 | Q_UNUSED(index); never executed (the execution status of this line is deduced): (void)index;; | - |
| 202 | return false; never executed: return false; | 0 |
| 203 | } | - |
| 204 | | - |
| 205 | /*! | - |
| 206 | \reimp | - |
| 207 | */ | - |
| 208 | QModelIndex QColumnView::indexAt(const QPoint &point) const | - |
| 209 | { | - |
| 210 | Q_D(const QColumnView); never executed (the execution status of this line is deduced): const QColumnViewPrivate * const d = d_func(); | - |
| 211 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 212 | QPoint topLeft = d->columns.at(i)->frameGeometry().topLeft(); never executed (the execution status of this line is deduced): QPoint topLeft = d->columns.at(i)->frameGeometry().topLeft(); | - |
| 213 | QPoint adjustedPoint(point.x() - topLeft.x(), point.y() - topLeft.y()); never executed (the execution status of this line is deduced): QPoint adjustedPoint(point.x() - topLeft.x(), point.y() - topLeft.y()); | - |
| 214 | QModelIndex index = d->columns.at(i)->indexAt(adjustedPoint); never executed (the execution status of this line is deduced): QModelIndex index = d->columns.at(i)->indexAt(adjustedPoint); | - |
| 215 | if (index.isValid()) never evaluated: index.isValid() | 0 |
| 216 | return index; never executed: return index; | 0 |
| 217 | } | 0 |
| 218 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
| 219 | } | - |
| 220 | | - |
| 221 | /*! | - |
| 222 | \reimp | - |
| 223 | */ | - |
| 224 | QRect QColumnView::visualRect(const QModelIndex &index) const | - |
| 225 | { | - |
| 226 | if (!index.isValid()) never evaluated: !index.isValid() | 0 |
| 227 | return QRect(); never executed: return QRect(); | 0 |
| 228 | | - |
| 229 | Q_D(const QColumnView); never executed (the execution status of this line is deduced): const QColumnViewPrivate * const d = d_func(); | - |
| 230 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 231 | QRect rect = d->columns.at(i)->visualRect(index); never executed (the execution status of this line is deduced): QRect rect = d->columns.at(i)->visualRect(index); | - |
| 232 | if (!rect.isNull()) { never evaluated: !rect.isNull() | 0 |
| 233 | rect.translate(d->columns.at(i)->frameGeometry().topLeft()); never executed (the execution status of this line is deduced): rect.translate(d->columns.at(i)->frameGeometry().topLeft()); | - |
| 234 | return rect; never executed: return rect; | 0 |
| 235 | } | - |
| 236 | } | 0 |
| 237 | return QRect(); never executed: return QRect(); | 0 |
| 238 | } | - |
| 239 | | - |
| 240 | /*! | - |
| 241 | \reimp | - |
| 242 | */ | - |
| 243 | void QColumnView::scrollContentsBy(int dx, int dy) | - |
| 244 | { | - |
| 245 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 246 | if (d->columns.isEmpty() || dx == 0) never evaluated: d->columns.isEmpty() never evaluated: dx == 0 | 0 |
| 247 | return; | 0 |
| 248 | | - |
| 249 | dx = isRightToLeft() ? -dx : dx; never evaluated: isRightToLeft() | 0 |
| 250 | for (int i = 0; i < d->columns.count(); ++i) never evaluated: i < d->columns.count() | 0 |
| 251 | 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 |
| 252 | d->offset += dx; never executed (the execution status of this line is deduced): d->offset += dx; | - |
| 253 | QAbstractItemView::scrollContentsBy(dx, dy); never executed (the execution status of this line is deduced): QAbstractItemView::scrollContentsBy(dx, dy); | - |
| 254 | } | 0 |
| 255 | | - |
| 256 | /*! | - |
| 257 | \reimp | - |
| 258 | */ | - |
| 259 | void QColumnView::scrollTo(const QModelIndex &index, ScrollHint hint) | - |
| 260 | { | - |
| 261 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 262 | Q_UNUSED(hint); never executed (the execution status of this line is deduced): (void)hint;; | - |
| 263 | if (!index.isValid() || d->columns.isEmpty()) never evaluated: !index.isValid() never evaluated: d->columns.isEmpty() | 0 |
| 264 | return; | 0 |
| 265 | | - |
| 266 | #ifndef QT_NO_ANIMATION | - |
| 267 | if (d->currentAnimation.state() == QPropertyAnimation::Running) never evaluated: d->currentAnimation.state() == QPropertyAnimation::Running | 0 |
| 268 | return; | 0 |
| 269 | | - |
| 270 | d->currentAnimation.stop(); never executed (the execution status of this line is deduced): d->currentAnimation.stop(); | - |
| 271 | #endif //QT_NO_ANIMATION | - |
| 272 | | - |
| 273 | // Fill up what is needed to get to index | - |
| 274 | d->closeColumns(index, true); never executed (the execution status of this line is deduced): d->closeColumns(index, true); | - |
| 275 | | - |
| 276 | QModelIndex indexParent = index.parent(); never executed (the execution status of this line is deduced): QModelIndex indexParent = index.parent(); | - |
| 277 | // Find the left edge of the column that contains index | - |
| 278 | int currentColumn = 0; never executed (the execution status of this line is deduced): int currentColumn = 0; | - |
| 279 | int leftEdge = 0; never executed (the execution status of this line is deduced): int leftEdge = 0; | - |
| 280 | while (currentColumn < d->columns.size()) { never evaluated: currentColumn < d->columns.size() | 0 |
| 281 | if (indexParent == d->columns.at(currentColumn)->rootIndex()) never evaluated: indexParent == d->columns.at(currentColumn)->rootIndex() | 0 |
| 282 | break; | 0 |
| 283 | leftEdge += d->columns.at(currentColumn)->width(); never executed (the execution status of this line is deduced): leftEdge += d->columns.at(currentColumn)->width(); | - |
| 284 | ++currentColumn; never executed (the execution status of this line is deduced): ++currentColumn; | - |
| 285 | } | 0 |
| 286 | | - |
| 287 | // Don't let us scroll above the root index | - |
| 288 | if (currentColumn == d->columns.size()) never evaluated: currentColumn == d->columns.size() | 0 |
| 289 | return; | 0 |
| 290 | | - |
| 291 | int indexColumn = currentColumn; never executed (the execution status of this line is deduced): int indexColumn = currentColumn; | - |
| 292 | // Find the width of what we want to show (i.e. the right edge) | - |
| 293 | int visibleWidth = d->columns.at(currentColumn)->width(); never executed (the execution status of this line is deduced): int visibleWidth = d->columns.at(currentColumn)->width(); | - |
| 294 | // We want to always try to show two columns | - |
| 295 | if (currentColumn + 1 < d->columns.size()) { never evaluated: currentColumn + 1 < d->columns.size() | 0 |
| 296 | ++currentColumn; never executed (the execution status of this line is deduced): ++currentColumn; | - |
| 297 | visibleWidth += d->columns.at(currentColumn)->width(); never executed (the execution status of this line is deduced): visibleWidth += d->columns.at(currentColumn)->width(); | - |
| 298 | } | 0 |
| 299 | | - |
| 300 | int rightEdge = leftEdge + visibleWidth; never executed (the execution status of this line is deduced): int rightEdge = leftEdge + visibleWidth; | - |
| 301 | if (isRightToLeft()) { never evaluated: isRightToLeft() | 0 |
| 302 | leftEdge = viewport()->width() - leftEdge; never executed (the execution status of this line is deduced): leftEdge = viewport()->width() - leftEdge; | - |
| 303 | rightEdge = leftEdge - visibleWidth; never executed (the execution status of this line is deduced): rightEdge = leftEdge - visibleWidth; | - |
| 304 | qSwap(rightEdge, leftEdge); never executed (the execution status of this line is deduced): qSwap(rightEdge, leftEdge); | - |
| 305 | } | 0 |
| 306 | | - |
| 307 | // If it is already visible don't animate | - |
| 308 | if (leftEdge > -horizontalOffset() never evaluated: leftEdge > -horizontalOffset() | 0 |
| 309 | && rightEdge <= ( -horizontalOffset() + viewport()->size().width())) { never evaluated: rightEdge <= ( -horizontalOffset() + viewport()->size().width()) | 0 |
| 310 | d->columns.at(indexColumn)->scrollTo(index); never executed (the execution status of this line is deduced): d->columns.at(indexColumn)->scrollTo(index); | - |
| 311 | d->_q_changeCurrentColumn(); never executed (the execution status of this line is deduced): d->_q_changeCurrentColumn(); | - |
| 312 | return; | 0 |
| 313 | } | - |
| 314 | | - |
| 315 | int newScrollbarValue = 0; never executed (the execution status of this line is deduced): int newScrollbarValue = 0; | - |
| 316 | if (isRightToLeft()) { never evaluated: isRightToLeft() | 0 |
| 317 | if (leftEdge < 0) { never evaluated: leftEdge < 0 | 0 |
| 318 | // scroll to the right | - |
| 319 | newScrollbarValue = viewport()->size().width() - leftEdge; never executed (the execution status of this line is deduced): newScrollbarValue = viewport()->size().width() - leftEdge; | - |
| 320 | } else { | 0 |
| 321 | // scroll to the left | - |
| 322 | newScrollbarValue = rightEdge + horizontalOffset(); never executed (the execution status of this line is deduced): newScrollbarValue = rightEdge + horizontalOffset(); | - |
| 323 | } | 0 |
| 324 | } else { | - |
| 325 | if (leftEdge > -horizontalOffset()) { never evaluated: leftEdge > -horizontalOffset() | 0 |
| 326 | // scroll to the right | - |
| 327 | newScrollbarValue = rightEdge - viewport()->size().width(); never executed (the execution status of this line is deduced): newScrollbarValue = rightEdge - viewport()->size().width(); | - |
| 328 | } else { | 0 |
| 329 | // scroll to the left | - |
| 330 | newScrollbarValue = leftEdge; never executed (the execution status of this line is deduced): newScrollbarValue = leftEdge; | - |
| 331 | } | 0 |
| 332 | } | - |
| 333 | | - |
| 334 | #ifndef QT_NO_ANIMATION | - |
| 335 | d->currentAnimation.setEndValue(newScrollbarValue); never executed (the execution status of this line is deduced): d->currentAnimation.setEndValue(newScrollbarValue); | - |
| 336 | d->currentAnimation.start(); never executed (the execution status of this line is deduced): d->currentAnimation.start(); | - |
| 337 | #else | - |
| 338 | horizontalScrollBar()->setValue(newScrollbarValue); | - |
| 339 | #endif //QT_NO_ANIMATION | - |
| 340 | } | 0 |
| 341 | | - |
| 342 | /*! | - |
| 343 | \reimp | - |
| 344 | Move left should go to the parent index | - |
| 345 | Move right should go to the child index or down if there is no child | - |
| 346 | */ | - |
| 347 | QModelIndex QColumnView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) | - |
| 348 | { | - |
| 349 | // the child views which have focus get to deal with this first and if | - |
| 350 | // they don't accept it then it comes up this view and we only grip left/right | - |
| 351 | Q_UNUSED(modifiers); never executed (the execution status of this line is deduced): (void)modifiers;; | - |
| 352 | if (!model()) never evaluated: !model() | 0 |
| 353 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
| 354 | | - |
| 355 | QModelIndex current = currentIndex(); never executed (the execution status of this line is deduced): QModelIndex current = currentIndex(); | - |
| 356 | if (isRightToLeft()) { never evaluated: isRightToLeft() | 0 |
| 357 | if (cursorAction == MoveLeft) never evaluated: cursorAction == MoveLeft | 0 |
| 358 | cursorAction = MoveRight; never executed: cursorAction = MoveRight; | 0 |
| 359 | else if (cursorAction == MoveRight) never evaluated: cursorAction == MoveRight | 0 |
| 360 | cursorAction = MoveLeft; never executed: cursorAction = MoveLeft; | 0 |
| 361 | } | - |
| 362 | switch (cursorAction) { | - |
| 363 | case MoveLeft: | - |
| 364 | if (current.parent().isValid() && current.parent() != rootIndex()) never evaluated: current.parent().isValid() never evaluated: current.parent() != rootIndex() | 0 |
| 365 | return (current.parent()); never executed: return (current.parent()); | 0 |
| 366 | else | - |
| 367 | return current; never executed: return current; | 0 |
| 368 | | - |
| 369 | case MoveRight: | - |
| 370 | if (model()->hasChildren(current)) never evaluated: model()->hasChildren(current) | 0 |
| 371 | return model()->index(0, 0, current); never executed: return model()->index(0, 0, current); | 0 |
| 372 | else | - |
| 373 | return current.sibling(current.row() + 1, current.column()); never executed: return current.sibling(current.row() + 1, current.column()); | 0 |
| 374 | | - |
| 375 | default: | - |
| 376 | break; | 0 |
| 377 | } | - |
| 378 | | - |
| 379 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
| 380 | } | - |
| 381 | | - |
| 382 | /*! | - |
| 383 | \reimp | - |
| 384 | */ | - |
| 385 | void QColumnView::resizeEvent(QResizeEvent *event) | - |
| 386 | { | - |
| 387 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 388 | d->doLayout(); never executed (the execution status of this line is deduced): d->doLayout(); | - |
| 389 | d->updateScrollbars(); never executed (the execution status of this line is deduced): d->updateScrollbars(); | - |
| 390 | if (!isRightToLeft()) { never evaluated: !isRightToLeft() | 0 |
| 391 | int diff = event->oldSize().width() - event->size().width(); never executed (the execution status of this line is deduced): int diff = event->oldSize().width() - event->size().width(); | - |
| 392 | if (diff < 0 && horizontalScrollBar()->isVisible() never evaluated: diff < 0 never evaluated: horizontalScrollBar()->isVisible() | 0 |
| 393 | && horizontalScrollBar()->value() == horizontalScrollBar()->maximum()) { never evaluated: horizontalScrollBar()->value() == horizontalScrollBar()->maximum() | 0 |
| 394 | horizontalScrollBar()->setMaximum(horizontalScrollBar()->maximum() + diff); never executed (the execution status of this line is deduced): horizontalScrollBar()->setMaximum(horizontalScrollBar()->maximum() + diff); | - |
| 395 | } | 0 |
| 396 | } | 0 |
| 397 | QAbstractItemView::resizeEvent(event); never executed (the execution status of this line is deduced): QAbstractItemView::resizeEvent(event); | - |
| 398 | } | 0 |
| 399 | | - |
| 400 | /*! | - |
| 401 | \internal | - |
| 402 | */ | - |
| 403 | void QColumnViewPrivate::updateScrollbars() | - |
| 404 | { | - |
| 405 | Q_Q(QColumnView); never executed (the execution status of this line is deduced): QColumnView * const q = q_func(); | - |
| 406 | #ifndef QT_NO_ANIMATION | - |
| 407 | if (currentAnimation.state() == QPropertyAnimation::Running) never evaluated: currentAnimation.state() == QPropertyAnimation::Running | 0 |
| 408 | return; | 0 |
| 409 | #endif //QT_NO_ANIMATION | - |
| 410 | | - |
| 411 | // find the total horizontal length of the laid out columns | - |
| 412 | int horizontalLength = 0; never executed (the execution status of this line is deduced): int horizontalLength = 0; | - |
| 413 | if (!columns.isEmpty()) { never evaluated: !columns.isEmpty() | 0 |
| 414 | horizontalLength = (columns.last()->x() + columns.last()->width()) - columns.first()->x(); never executed (the execution status of this line is deduced): horizontalLength = (columns.last()->x() + columns.last()->width()) - columns.first()->x(); | - |
| 415 | if (horizontalLength <= 0) // reverse mode never evaluated: horizontalLength <= 0 | 0 |
| 416 | horizontalLength = (columns.first()->x() + columns.first()->width()) - columns.last()->x(); never executed: horizontalLength = (columns.first()->x() + columns.first()->width()) - columns.last()->x(); | 0 |
| 417 | } | 0 |
| 418 | | - |
| 419 | QSize viewportSize = viewport->size(); never executed (the execution status of this line is deduced): QSize viewportSize = viewport->size(); | - |
| 420 | if (horizontalLength < viewportSize.width() && hbar->value() == 0) { never evaluated: horizontalLength < viewportSize.width() never evaluated: hbar->value() == 0 | 0 |
| 421 | hbar->setRange(0, 0); never executed (the execution status of this line is deduced): hbar->setRange(0, 0); | - |
| 422 | } else { | 0 |
| 423 | int visibleLength = qMin(horizontalLength + q->horizontalOffset(), viewportSize.width()); never executed (the execution status of this line is deduced): int visibleLength = qMin(horizontalLength + q->horizontalOffset(), viewportSize.width()); | - |
| 424 | int hiddenLength = horizontalLength - visibleLength; never executed (the execution status of this line is deduced): int hiddenLength = horizontalLength - visibleLength; | - |
| 425 | if (hiddenLength != hbar->maximum()) never evaluated: hiddenLength != hbar->maximum() | 0 |
| 426 | hbar->setRange(0, hiddenLength); never executed: hbar->setRange(0, hiddenLength); | 0 |
| 427 | } | 0 |
| 428 | if (!columns.isEmpty()) { never evaluated: !columns.isEmpty() | 0 |
| 429 | int pageStepSize = columns.at(0)->width(); never executed (the execution status of this line is deduced): int pageStepSize = columns.at(0)->width(); | - |
| 430 | if (pageStepSize != hbar->pageStep()) never evaluated: pageStepSize != hbar->pageStep() | 0 |
| 431 | hbar->setPageStep(pageStepSize); never executed: hbar->setPageStep(pageStepSize); | 0 |
| 432 | } | 0 |
| 433 | bool visible = (hbar->maximum() > 0); never executed (the execution status of this line is deduced): bool visible = (hbar->maximum() > 0); | - |
| 434 | if (visible != hbar->isVisible()) never evaluated: visible != hbar->isVisible() | 0 |
| 435 | hbar->setVisible(visible); never executed: hbar->setVisible(visible); | 0 |
| 436 | } | 0 |
| 437 | | - |
| 438 | /*! | - |
| 439 | \reimp | - |
| 440 | */ | - |
| 441 | int QColumnView::horizontalOffset() const | - |
| 442 | { | - |
| 443 | Q_D(const QColumnView); never executed (the execution status of this line is deduced): const QColumnViewPrivate * const d = d_func(); | - |
| 444 | return d->offset; never executed: return d->offset; | 0 |
| 445 | } | - |
| 446 | | - |
| 447 | /*! | - |
| 448 | \reimp | - |
| 449 | */ | - |
| 450 | int QColumnView::verticalOffset() const | - |
| 451 | { | - |
| 452 | return 0; never executed: return 0; | 0 |
| 453 | } | - |
| 454 | | - |
| 455 | /*! | - |
| 456 | \reimp | - |
| 457 | */ | - |
| 458 | QRegion QColumnView::visualRegionForSelection(const QItemSelection &selection) const | - |
| 459 | { | - |
| 460 | int ranges = selection.count(); never executed (the execution status of this line is deduced): int ranges = selection.count(); | - |
| 461 | | - |
| 462 | if (ranges == 0) never evaluated: ranges == 0 | 0 |
| 463 | return QRect(); never executed: return QRect(); | 0 |
| 464 | | - |
| 465 | // Note that we use the top and bottom functions of the selection range | - |
| 466 | // since the data is stored in rows. | - |
| 467 | int firstRow = selection.at(0).top(); never executed (the execution status of this line is deduced): int firstRow = selection.at(0).top(); | - |
| 468 | int lastRow = selection.at(0).top(); never executed (the execution status of this line is deduced): int lastRow = selection.at(0).top(); | - |
| 469 | for (int i = 0; i < ranges; ++i) { never evaluated: i < ranges | 0 |
| 470 | firstRow = qMin(firstRow, selection.at(i).top()); never executed (the execution status of this line is deduced): firstRow = qMin(firstRow, selection.at(i).top()); | - |
| 471 | lastRow = qMax(lastRow, selection.at(i).bottom()); never executed (the execution status of this line is deduced): lastRow = qMax(lastRow, selection.at(i).bottom()); | - |
| 472 | } | 0 |
| 473 | | - |
| 474 | QModelIndex firstIdx = model()->index(qMin(firstRow, lastRow), 0, rootIndex()); never executed (the execution status of this line is deduced): QModelIndex firstIdx = model()->index(qMin(firstRow, lastRow), 0, rootIndex()); | - |
| 475 | QModelIndex lastIdx = model()->index(qMax(firstRow, lastRow), 0, rootIndex()); never executed (the execution status of this line is deduced): QModelIndex lastIdx = model()->index(qMax(firstRow, lastRow), 0, rootIndex()); | - |
| 476 | | - |
| 477 | if (firstIdx == lastIdx) never evaluated: firstIdx == lastIdx | 0 |
| 478 | return visualRect(firstIdx); never executed: return visualRect(firstIdx); | 0 |
| 479 | | - |
| 480 | QRegion firstRegion = visualRect(firstIdx); never executed (the execution status of this line is deduced): QRegion firstRegion = visualRect(firstIdx); | - |
| 481 | QRegion lastRegion = visualRect(lastIdx); never executed (the execution status of this line is deduced): QRegion lastRegion = visualRect(lastIdx); | - |
| 482 | return firstRegion.united(lastRegion); never executed: return firstRegion.united(lastRegion); | 0 |
| 483 | } | - |
| 484 | | - |
| 485 | /*! | - |
| 486 | \reimp | - |
| 487 | */ | - |
| 488 | void QColumnView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) | - |
| 489 | { | - |
| 490 | Q_UNUSED(rect); never executed (the execution status of this line is deduced): (void)rect;; | - |
| 491 | Q_UNUSED(command); never executed (the execution status of this line is deduced): (void)command;; | - |
| 492 | } | 0 |
| 493 | | - |
| 494 | /*! | - |
| 495 | \reimp | - |
| 496 | */ | - |
| 497 | void QColumnView::setSelectionModel(QItemSelectionModel *newSelectionModel) | - |
| 498 | { | - |
| 499 | Q_D(const QColumnView); never executed (the execution status of this line is deduced): const QColumnViewPrivate * const d = d_func(); | - |
| 500 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 501 | if (d->columns.at(i)->selectionModel() == selectionModel()) { never evaluated: d->columns.at(i)->selectionModel() == selectionModel() | 0 |
| 502 | d->columns.at(i)->setSelectionModel(newSelectionModel); never executed (the execution status of this line is deduced): d->columns.at(i)->setSelectionModel(newSelectionModel); | - |
| 503 | break; | 0 |
| 504 | } | - |
| 505 | } | 0 |
| 506 | QAbstractItemView::setSelectionModel(newSelectionModel); never executed (the execution status of this line is deduced): QAbstractItemView::setSelectionModel(newSelectionModel); | - |
| 507 | } | 0 |
| 508 | | - |
| 509 | /*! | - |
| 510 | \reimp | - |
| 511 | */ | - |
| 512 | QSize QColumnView::sizeHint() const | - |
| 513 | { | - |
| 514 | Q_D(const QColumnView); never executed (the execution status of this line is deduced): const QColumnViewPrivate * const d = d_func(); | - |
| 515 | QSize sizeHint; never executed (the execution status of this line is deduced): QSize sizeHint; | - |
| 516 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 517 | sizeHint += d->columns.at(i)->sizeHint(); never executed (the execution status of this line is deduced): sizeHint += d->columns.at(i)->sizeHint(); | - |
| 518 | } | 0 |
| 519 | return sizeHint.expandedTo(QAbstractItemView::sizeHint()); never executed: return sizeHint.expandedTo(QAbstractItemView::sizeHint()); | 0 |
| 520 | } | - |
| 521 | | - |
| 522 | /*! | - |
| 523 | \internal | - |
| 524 | Move all widgets from the corner grip and to the right | - |
| 525 | */ | - |
| 526 | void QColumnViewPrivate::_q_gripMoved(int offset) | - |
| 527 | { | - |
| 528 | Q_Q(QColumnView); never executed (the execution status of this line is deduced): QColumnView * const q = q_func(); | - |
| 529 | | - |
| 530 | QObject *grip = q->sender(); never executed (the execution status of this line is deduced): QObject *grip = q->sender(); | - |
| 531 | Q_ASSERT(grip); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 532 | | - |
| 533 | if (q->isRightToLeft()) never evaluated: q->isRightToLeft() | 0 |
| 534 | offset = -1 * offset; never executed: offset = -1 * offset; | 0 |
| 535 | | - |
| 536 | bool found = false; never executed (the execution status of this line is deduced): bool found = false; | - |
| 537 | for (int i = 0; i < columns.size(); ++i) { never evaluated: i < columns.size() | 0 |
| 538 | if (!found && columns.at(i)->cornerWidget() == grip) { never evaluated: !found never evaluated: columns.at(i)->cornerWidget() == grip | 0 |
| 539 | found = true; never executed (the execution status of this line is deduced): found = true; | - |
| 540 | columnSizes[i] = columns.at(i)->width(); never executed (the execution status of this line is deduced): columnSizes[i] = columns.at(i)->width(); | - |
| 541 | if (q->isRightToLeft()) never evaluated: q->isRightToLeft() | 0 |
| 542 | columns.at(i)->move(columns.at(i)->x() + offset, 0); never executed: columns.at(i)->move(columns.at(i)->x() + offset, 0); | 0 |
| 543 | continue; never executed: continue; | 0 |
| 544 | } | - |
| 545 | if (!found) | 0 |
| 546 | continue; never executed: continue; | 0 |
| 547 | | - |
| 548 | int currentX = columns.at(i)->x(); never executed (the execution status of this line is deduced): int currentX = columns.at(i)->x(); | - |
| 549 | columns.at(i)->move(currentX + offset, 0); never executed (the execution status of this line is deduced): columns.at(i)->move(currentX + offset, 0); | - |
| 550 | } | 0 |
| 551 | | - |
| 552 | updateScrollbars(); never executed (the execution status of this line is deduced): updateScrollbars(); | - |
| 553 | } | 0 |
| 554 | | - |
| 555 | /*! | - |
| 556 | \internal | - |
| 557 | | - |
| 558 | Find where the current columns intersect parent's columns | - |
| 559 | | - |
| 560 | Delete any extra columns and insert any needed columns. | - |
| 561 | */ | - |
| 562 | void QColumnViewPrivate::closeColumns(const QModelIndex &parent, bool build) | - |
| 563 | { | - |
| 564 | if (columns.isEmpty()) never evaluated: columns.isEmpty() | 0 |
| 565 | return; | 0 |
| 566 | | - |
| 567 | bool clearAll = !parent.isValid(); never executed (the execution status of this line is deduced): bool clearAll = !parent.isValid(); | - |
| 568 | bool passThroughRoot = false; never executed (the execution status of this line is deduced): bool passThroughRoot = false; | - |
| 569 | | - |
| 570 | QList<QModelIndex> dirsToAppend; never executed (the execution status of this line is deduced): QList<QModelIndex> dirsToAppend; | - |
| 571 | | - |
| 572 | // Find the last column that matches the parent's tree | - |
| 573 | int currentColumn = -1; never executed (the execution status of this line is deduced): int currentColumn = -1; | - |
| 574 | QModelIndex parentIndex = parent; never executed (the execution status of this line is deduced): QModelIndex parentIndex = parent; | - |
| 575 | while (currentColumn == -1 && parentIndex.isValid()) { never evaluated: currentColumn == -1 never evaluated: parentIndex.isValid() | 0 |
| 576 | if (columns.isEmpty()) never evaluated: columns.isEmpty() | 0 |
| 577 | break; | 0 |
| 578 | parentIndex = parentIndex.parent(); never executed (the execution status of this line is deduced): parentIndex = parentIndex.parent(); | - |
| 579 | if (root == parentIndex) never evaluated: root == parentIndex | 0 |
| 580 | passThroughRoot = true; never executed: passThroughRoot = true; | 0 |
| 581 | if (!parentIndex.isValid()) never evaluated: !parentIndex.isValid() | 0 |
| 582 | break; | 0 |
| 583 | for (int i = columns.size() - 1; i >= 0; --i) { | 0 |
| 584 | if (columns.at(i)->rootIndex() == parentIndex) { never evaluated: columns.at(i)->rootIndex() == parentIndex | 0 |
| 585 | currentColumn = i; never executed (the execution status of this line is deduced): currentColumn = i; | - |
| 586 | break; | 0 |
| 587 | } | - |
| 588 | } | 0 |
| 589 | if (currentColumn == -1) never evaluated: currentColumn == -1 | 0 |
| 590 | dirsToAppend.append(parentIndex); never executed: dirsToAppend.append(parentIndex); | 0 |
| 591 | } | 0 |
| 592 | | - |
| 593 | // Someone wants to go to an index that can be reached without changing | - |
| 594 | // the root index, don't allow them | - |
| 595 | if (!clearAll && !passThroughRoot && currentColumn == -1) never evaluated: !clearAll never evaluated: !passThroughRoot never evaluated: currentColumn == -1 | 0 |
| 596 | return; | 0 |
| 597 | | - |
| 598 | if (currentColumn == -1 && parent.isValid()) never evaluated: currentColumn == -1 never evaluated: parent.isValid() | 0 |
| 599 | currentColumn = 0; never executed: currentColumn = 0; | 0 |
| 600 | | - |
| 601 | // Optimization so we don't go deleting and then creating the same thing | - |
| 602 | bool alreadyExists = false; never executed (the execution status of this line is deduced): bool alreadyExists = false; | - |
| 603 | if (build && columns.size() > currentColumn + 1) { never evaluated: build never evaluated: columns.size() > currentColumn + 1 | 0 |
| 604 | bool viewingParent = (columns.at(currentColumn + 1)->rootIndex() == parent); never executed (the execution status of this line is deduced): bool viewingParent = (columns.at(currentColumn + 1)->rootIndex() == parent); | - |
| 605 | bool viewingChild = (!model->hasChildren(parent) never evaluated: !model->hasChildren(parent) | 0 |
| 606 | && !columns.at(currentColumn + 1)->rootIndex().isValid()); never evaluated: !columns.at(currentColumn + 1)->rootIndex().isValid() | 0 |
| 607 | if (viewingParent || viewingChild) { never evaluated: viewingParent never evaluated: viewingChild | 0 |
| 608 | currentColumn++; never executed (the execution status of this line is deduced): currentColumn++; | - |
| 609 | alreadyExists = true; never executed (the execution status of this line is deduced): alreadyExists = true; | - |
| 610 | } | 0 |
| 611 | } | 0 |
| 612 | | - |
| 613 | // Delete columns that don't match our path | - |
| 614 | for (int i = columns.size() - 1; i > currentColumn; --i) { never evaluated: i > currentColumn | 0 |
| 615 | QAbstractItemView* notShownAnymore = columns.at(i); never executed (the execution status of this line is deduced): QAbstractItemView* notShownAnymore = columns.at(i); | - |
| 616 | columns.removeAt(i); never executed (the execution status of this line is deduced): columns.removeAt(i); | - |
| 617 | notShownAnymore->setVisible(false); never executed (the execution status of this line is deduced): notShownAnymore->setVisible(false); | - |
| 618 | if (notShownAnymore != previewColumn) never evaluated: notShownAnymore != previewColumn | 0 |
| 619 | notShownAnymore->deleteLater(); never executed: notShownAnymore->deleteLater(); | 0 |
| 620 | } | 0 |
| 621 | | - |
| 622 | if (columns.isEmpty()) { never evaluated: columns.isEmpty() | 0 |
| 623 | offset = 0; never executed (the execution status of this line is deduced): offset = 0; | - |
| 624 | updateScrollbars(); never executed (the execution status of this line is deduced): updateScrollbars(); | - |
| 625 | } | 0 |
| 626 | | - |
| 627 | // Now fill in missing columns | - |
| 628 | while (!dirsToAppend.isEmpty()) { never evaluated: !dirsToAppend.isEmpty() | 0 |
| 629 | QAbstractItemView *newView = createColumn(dirsToAppend.takeLast(), true); never executed (the execution status of this line is deduced): QAbstractItemView *newView = createColumn(dirsToAppend.takeLast(), true); | - |
| 630 | if (!dirsToAppend.isEmpty()) never evaluated: !dirsToAppend.isEmpty() | 0 |
| 631 | newView->setCurrentIndex(dirsToAppend.last()); never executed: newView->setCurrentIndex(dirsToAppend.last()); | 0 |
| 632 | } | 0 |
| 633 | | - |
| 634 | if (build && !alreadyExists) never evaluated: build never evaluated: !alreadyExists | 0 |
| 635 | createColumn(parent, false); never executed: createColumn(parent, false); | 0 |
| 636 | } | 0 |
| 637 | | - |
| 638 | void QColumnViewPrivate::_q_clicked(const QModelIndex &index) | - |
| 639 | { | - |
| 640 | Q_Q(QColumnView); never executed (the execution status of this line is deduced): QColumnView * const q = q_func(); | - |
| 641 | QModelIndex parent = index.parent(); never executed (the execution status of this line is deduced): QModelIndex parent = index.parent(); | - |
| 642 | QAbstractItemView *columnClicked = 0; never executed (the execution status of this line is deduced): QAbstractItemView *columnClicked = 0; | - |
| 643 | for (int column = 0; column < columns.count(); ++column) { never evaluated: column < columns.count() | 0 |
| 644 | if (columns.at(column)->rootIndex() == parent) { never evaluated: columns.at(column)->rootIndex() == parent | 0 |
| 645 | columnClicked = columns[column]; never executed (the execution status of this line is deduced): columnClicked = columns[column]; | - |
| 646 | break; | 0 |
| 647 | } | - |
| 648 | } | 0 |
| 649 | if (q->selectionModel() && columnClicked) { never evaluated: q->selectionModel() never evaluated: columnClicked | 0 |
| 650 | QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::Current; never executed (the execution status of this line is deduced): QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::Current; | - |
| 651 | if (columnClicked->selectionModel()->isSelected(index)) never evaluated: columnClicked->selectionModel()->isSelected(index) | 0 |
| 652 | flags |= QItemSelectionModel::Select; never executed: flags |= QItemSelectionModel::Select; | 0 |
| 653 | q->selectionModel()->setCurrentIndex(index, flags); never executed (the execution status of this line is deduced): q->selectionModel()->setCurrentIndex(index, flags); | - |
| 654 | } | 0 |
| 655 | } | 0 |
| 656 | | - |
| 657 | /*! | - |
| 658 | \internal | - |
| 659 | Create a new column for \a index. A grip is attached if requested and it is shown | - |
| 660 | if requested. | - |
| 661 | | - |
| 662 | Return the new view | - |
| 663 | | - |
| 664 | \sa createColumn(), setPreviewWidget() | - |
| 665 | \sa doLayout() | - |
| 666 | */ | - |
| 667 | QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bool show) | - |
| 668 | { | - |
| 669 | Q_Q(QColumnView); never executed (the execution status of this line is deduced): QColumnView * const q = q_func(); | - |
| 670 | QAbstractItemView *view = 0; never executed (the execution status of this line is deduced): QAbstractItemView *view = 0; | - |
| 671 | if (model->hasChildren(index)) { never evaluated: model->hasChildren(index) | 0 |
| 672 | view = q->createColumn(index); never executed (the execution status of this line is deduced): view = q->createColumn(index); | - |
| 673 | q->connect(view, SIGNAL(clicked(QModelIndex)), never executed (the execution status of this line is deduced): q->connect(view, "2""clicked(QModelIndex)", | - |
| 674 | q, SLOT(_q_clicked(QModelIndex))); never executed (the execution status of this line is deduced): q, "1""_q_clicked(QModelIndex)"); | - |
| 675 | } else { | 0 |
| 676 | if (!previewColumn) never evaluated: !previewColumn | 0 |
| 677 | setPreviewWidget(new QWidget(q)); never executed: setPreviewWidget(new QWidget(q)); | 0 |
| 678 | view = previewColumn; never executed (the execution status of this line is deduced): view = previewColumn; | - |
| 679 | view->setMinimumWidth(qMax(view->minimumWidth(), previewWidget->minimumWidth())); never executed (the execution status of this line is deduced): view->setMinimumWidth(qMax(view->minimumWidth(), previewWidget->minimumWidth())); | - |
| 680 | } | 0 |
| 681 | | - |
| 682 | q->connect(view, SIGNAL(activated(QModelIndex)), never executed (the execution status of this line is deduced): q->connect(view, "2""activated(QModelIndex)", | - |
| 683 | q, SIGNAL(activated(QModelIndex))); never executed (the execution status of this line is deduced): q, "2""activated(QModelIndex)"); | - |
| 684 | q->connect(view, SIGNAL(clicked(QModelIndex)), never executed (the execution status of this line is deduced): q->connect(view, "2""clicked(QModelIndex)", | - |
| 685 | q, SIGNAL(clicked(QModelIndex))); never executed (the execution status of this line is deduced): q, "2""clicked(QModelIndex)"); | - |
| 686 | q->connect(view, SIGNAL(doubleClicked(QModelIndex)), never executed (the execution status of this line is deduced): q->connect(view, "2""doubleClicked(QModelIndex)", | - |
| 687 | q, SIGNAL(doubleClicked(QModelIndex))); never executed (the execution status of this line is deduced): q, "2""doubleClicked(QModelIndex)"); | - |
| 688 | q->connect(view, SIGNAL(entered(QModelIndex)), never executed (the execution status of this line is deduced): q->connect(view, "2""entered(QModelIndex)", | - |
| 689 | q, SIGNAL(entered(QModelIndex))); never executed (the execution status of this line is deduced): q, "2""entered(QModelIndex)"); | - |
| 690 | q->connect(view, SIGNAL(pressed(QModelIndex)), never executed (the execution status of this line is deduced): q->connect(view, "2""pressed(QModelIndex)", | - |
| 691 | q, SIGNAL(pressed(QModelIndex))); never executed (the execution status of this line is deduced): q, "2""pressed(QModelIndex)"); | - |
| 692 | | - |
| 693 | view->setFocusPolicy(Qt::NoFocus); never executed (the execution status of this line is deduced): view->setFocusPolicy(Qt::NoFocus); | - |
| 694 | view->setParent(viewport); never executed (the execution status of this line is deduced): view->setParent(viewport); | - |
| 695 | Q_ASSERT(view); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 696 | | - |
| 697 | // Setup corner grip | - |
| 698 | if (showResizeGrips) { never evaluated: showResizeGrips | 0 |
| 699 | QColumnViewGrip *grip = new QColumnViewGrip(view); never executed (the execution status of this line is deduced): QColumnViewGrip *grip = new QColumnViewGrip(view); | - |
| 700 | view->setCornerWidget(grip); never executed (the execution status of this line is deduced): view->setCornerWidget(grip); | - |
| 701 | q->connect(grip, SIGNAL(gripMoved(int)), q, SLOT(_q_gripMoved(int))); never executed (the execution status of this line is deduced): q->connect(grip, "2""gripMoved(int)", q, "1""_q_gripMoved(int)"); | - |
| 702 | } | 0 |
| 703 | | - |
| 704 | if (columnSizes.count() > columns.count()) { never evaluated: columnSizes.count() > columns.count() | 0 |
| 705 | view->setGeometry(0, 0, columnSizes.at(columns.count()), viewport->height()); never executed (the execution status of this line is deduced): view->setGeometry(0, 0, columnSizes.at(columns.count()), viewport->height()); | - |
| 706 | } else { | 0 |
| 707 | int initialWidth = view->sizeHint().width(); never executed (the execution status of this line is deduced): int initialWidth = view->sizeHint().width(); | - |
| 708 | if (q->isRightToLeft()) never evaluated: q->isRightToLeft() | 0 |
| 709 | view->setGeometry(viewport->width() - initialWidth, 0, initialWidth, viewport->height()); never executed: view->setGeometry(viewport->width() - initialWidth, 0, initialWidth, viewport->height()); | 0 |
| 710 | else | - |
| 711 | view->setGeometry(0, 0, initialWidth, viewport->height()); never executed: view->setGeometry(0, 0, initialWidth, viewport->height()); | 0 |
| 712 | columnSizes.resize(qMax(columnSizes.count(), columns.count() + 1)); never executed (the execution status of this line is deduced): columnSizes.resize(qMax(columnSizes.count(), columns.count() + 1)); | - |
| 713 | columnSizes[columns.count()] = initialWidth; never executed (the execution status of this line is deduced): columnSizes[columns.count()] = initialWidth; | - |
| 714 | } | 0 |
| 715 | if (!columns.isEmpty() && columns.last()->isHidden()) never evaluated: !columns.isEmpty() never evaluated: columns.last()->isHidden() | 0 |
| 716 | columns.last()->setVisible(true); never executed: columns.last()->setVisible(true); | 0 |
| 717 | | - |
| 718 | columns.append(view); never executed (the execution status of this line is deduced): columns.append(view); | - |
| 719 | doLayout(); never executed (the execution status of this line is deduced): doLayout(); | - |
| 720 | updateScrollbars(); never executed (the execution status of this line is deduced): updateScrollbars(); | - |
| 721 | if (show && view->isHidden()) never evaluated: show never evaluated: view->isHidden() | 0 |
| 722 | view->setVisible(true); never executed: view->setVisible(true); | 0 |
| 723 | return view; never executed: return view; | 0 |
| 724 | } | - |
| 725 | | - |
| 726 | /*! | - |
| 727 | \fn void QColumnView::updatePreviewWidget(const QModelIndex &index) | - |
| 728 | | - |
| 729 | This signal is emitted when the preview widget should be updated to | - |
| 730 | provide rich information about \a index | - |
| 731 | | - |
| 732 | \sa previewWidget() | - |
| 733 | */ | - |
| 734 | | - |
| 735 | /*! | - |
| 736 | To use a custom widget for the final column when you select | - |
| 737 | an item overload this function and return a widget. | - |
| 738 | \a index is the root index that will be assigned to the view. | - |
| 739 | | - |
| 740 | Return the new view. QColumnView will automatically take ownership of the widget. | - |
| 741 | | - |
| 742 | \sa setPreviewWidget() | - |
| 743 | */ | - |
| 744 | QAbstractItemView *QColumnView::createColumn(const QModelIndex &index) | - |
| 745 | { | - |
| 746 | QListView *view = new QListView(viewport()); never executed (the execution status of this line is deduced): QListView *view = new QListView(viewport()); | - |
| 747 | | - |
| 748 | initializeColumn(view); never executed (the execution status of this line is deduced): initializeColumn(view); | - |
| 749 | | - |
| 750 | view->setRootIndex(index); never executed (the execution status of this line is deduced): view->setRootIndex(index); | - |
| 751 | if (model()->canFetchMore(index)) never evaluated: model()->canFetchMore(index) | 0 |
| 752 | model()->fetchMore(index); never executed: model()->fetchMore(index); | 0 |
| 753 | | - |
| 754 | return view; never executed: return view; | 0 |
| 755 | } | - |
| 756 | | - |
| 757 | /*! | - |
| 758 | Copies the behavior and options of the column view and applies them to | - |
| 759 | the \a column such as the iconSize(), textElideMode() and | - |
| 760 | alternatingRowColors(). This can be useful when reimplementing | - |
| 761 | createColumn(). | - |
| 762 | | - |
| 763 | \since 4.4 | - |
| 764 | \sa createColumn() | - |
| 765 | */ | - |
| 766 | void QColumnView::initializeColumn(QAbstractItemView *column) const | - |
| 767 | { | - |
| 768 | Q_D(const QColumnView); never executed (the execution status of this line is deduced): const QColumnViewPrivate * const d = d_func(); | - |
| 769 | | - |
| 770 | column->setFrameShape(QFrame::NoFrame); never executed (the execution status of this line is deduced): column->setFrameShape(QFrame::NoFrame); | - |
| 771 | column->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); never executed (the execution status of this line is deduced): column->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - |
| 772 | column->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); never executed (the execution status of this line is deduced): column->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | - |
| 773 | column->setMinimumWidth(100); never executed (the execution status of this line is deduced): column->setMinimumWidth(100); | - |
| 774 | column->setAttribute(Qt::WA_MacShowFocusRect, false); never executed (the execution status of this line is deduced): column->setAttribute(Qt::WA_MacShowFocusRect, false); | - |
| 775 | | - |
| 776 | #ifndef QT_NO_DRAGANDDROP | - |
| 777 | column->setDragDropMode(dragDropMode()); never executed (the execution status of this line is deduced): column->setDragDropMode(dragDropMode()); | - |
| 778 | column->setDragDropOverwriteMode(dragDropOverwriteMode()); never executed (the execution status of this line is deduced): column->setDragDropOverwriteMode(dragDropOverwriteMode()); | - |
| 779 | column->setDropIndicatorShown(showDropIndicator()); never executed (the execution status of this line is deduced): column->setDropIndicatorShown(showDropIndicator()); | - |
| 780 | #endif | - |
| 781 | column->setAlternatingRowColors(alternatingRowColors()); never executed (the execution status of this line is deduced): column->setAlternatingRowColors(alternatingRowColors()); | - |
| 782 | column->setAutoScroll(hasAutoScroll()); never executed (the execution status of this line is deduced): column->setAutoScroll(hasAutoScroll()); | - |
| 783 | column->setEditTriggers(editTriggers()); never executed (the execution status of this line is deduced): column->setEditTriggers(editTriggers()); | - |
| 784 | column->setHorizontalScrollMode(horizontalScrollMode()); never executed (the execution status of this line is deduced): column->setHorizontalScrollMode(horizontalScrollMode()); | - |
| 785 | column->setIconSize(iconSize()); never executed (the execution status of this line is deduced): column->setIconSize(iconSize()); | - |
| 786 | column->setSelectionBehavior(selectionBehavior()); never executed (the execution status of this line is deduced): column->setSelectionBehavior(selectionBehavior()); | - |
| 787 | column->setSelectionMode(selectionMode()); never executed (the execution status of this line is deduced): column->setSelectionMode(selectionMode()); | - |
| 788 | column->setTabKeyNavigation(tabKeyNavigation()); never executed (the execution status of this line is deduced): column->setTabKeyNavigation(tabKeyNavigation()); | - |
| 789 | column->setTextElideMode(textElideMode()); never executed (the execution status of this line is deduced): column->setTextElideMode(textElideMode()); | - |
| 790 | column->setVerticalScrollMode(verticalScrollMode()); never executed (the execution status of this line is deduced): column->setVerticalScrollMode(verticalScrollMode()); | - |
| 791 | | - |
| 792 | column->setModel(model()); never executed (the execution status of this line is deduced): column->setModel(model()); | - |
| 793 | | - |
| 794 | // Copy the custom delegate per row | - |
| 795 | QMapIterator<int, QPointer<QAbstractItemDelegate> > i(d->rowDelegates); never executed (the execution status of this line is deduced): QMapIterator<int, QPointer<QAbstractItemDelegate> > i(d->rowDelegates); | - |
| 796 | while (i.hasNext()) { never evaluated: i.hasNext() | 0 |
| 797 | i.next(); never executed (the execution status of this line is deduced): i.next(); | - |
| 798 | column->setItemDelegateForRow(i.key(), i.value()); never executed (the execution status of this line is deduced): column->setItemDelegateForRow(i.key(), i.value()); | - |
| 799 | } | 0 |
| 800 | | - |
| 801 | // set the delegate to be the columnview delegate | - |
| 802 | QAbstractItemDelegate *delegate = column->itemDelegate(); never executed (the execution status of this line is deduced): QAbstractItemDelegate *delegate = column->itemDelegate(); | - |
| 803 | column->setItemDelegate(d->itemDelegate); never executed (the execution status of this line is deduced): column->setItemDelegate(d->itemDelegate); | - |
| 804 | delete delegate; never executed (the execution status of this line is deduced): delete delegate; | - |
| 805 | } | 0 |
| 806 | | - |
| 807 | /*! | - |
| 808 | Returns the preview widget, or 0 if there is none. | - |
| 809 | | - |
| 810 | \sa setPreviewWidget(), updatePreviewWidget() | - |
| 811 | */ | - |
| 812 | QWidget *QColumnView::previewWidget() const | - |
| 813 | { | - |
| 814 | Q_D(const QColumnView); never executed (the execution status of this line is deduced): const QColumnViewPrivate * const d = d_func(); | - |
| 815 | return d->previewWidget; never executed: return d->previewWidget; | 0 |
| 816 | } | - |
| 817 | | - |
| 818 | /*! | - |
| 819 | Sets the preview \a widget. | - |
| 820 | | - |
| 821 | The \a widget becomes a child of the column view, and will be | - |
| 822 | destroyed when the column area is deleted or when a new widget is | - |
| 823 | set. | - |
| 824 | | - |
| 825 | \sa previewWidget(), updatePreviewWidget() | - |
| 826 | */ | - |
| 827 | void QColumnView::setPreviewWidget(QWidget *widget) | - |
| 828 | { | - |
| 829 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 830 | d->setPreviewWidget(widget); never executed (the execution status of this line is deduced): d->setPreviewWidget(widget); | - |
| 831 | } | 0 |
| 832 | | - |
| 833 | /*! | - |
| 834 | \internal | - |
| 835 | */ | - |
| 836 | void QColumnViewPrivate::setPreviewWidget(QWidget *widget) | - |
| 837 | { | - |
| 838 | Q_Q(QColumnView); never executed (the execution status of this line is deduced): QColumnView * const q = q_func(); | - |
| 839 | if (previewColumn) { never evaluated: previewColumn | 0 |
| 840 | if (!columns.isEmpty() && columns.last() == previewColumn) never evaluated: !columns.isEmpty() never evaluated: columns.last() == previewColumn | 0 |
| 841 | columns.removeLast(); never executed: columns.removeLast(); | 0 |
| 842 | previewColumn->deleteLater(); never executed (the execution status of this line is deduced): previewColumn->deleteLater(); | - |
| 843 | } | 0 |
| 844 | QColumnViewPreviewColumn *column = new QColumnViewPreviewColumn(q); never executed (the execution status of this line is deduced): QColumnViewPreviewColumn *column = new QColumnViewPreviewColumn(q); | - |
| 845 | column->setPreviewWidget(widget); never executed (the execution status of this line is deduced): column->setPreviewWidget(widget); | - |
| 846 | previewColumn = column; never executed (the execution status of this line is deduced): previewColumn = column; | - |
| 847 | previewColumn->hide(); never executed (the execution status of this line is deduced): previewColumn->hide(); | - |
| 848 | previewColumn->setFrameShape(QFrame::NoFrame); never executed (the execution status of this line is deduced): previewColumn->setFrameShape(QFrame::NoFrame); | - |
| 849 | previewColumn->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); never executed (the execution status of this line is deduced): previewColumn->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | - |
| 850 | previewColumn->setSelectionMode(QAbstractItemView::NoSelection); never executed (the execution status of this line is deduced): previewColumn->setSelectionMode(QAbstractItemView::NoSelection); | - |
| 851 | previewColumn->setMinimumWidth(qMax(previewColumn->verticalScrollBar()->width(), never executed (the execution status of this line is deduced): previewColumn->setMinimumWidth(qMax(previewColumn->verticalScrollBar()->width(), | - |
| 852 | previewColumn->minimumWidth())); never executed (the execution status of this line is deduced): previewColumn->minimumWidth())); | - |
| 853 | previewWidget = widget; never executed (the execution status of this line is deduced): previewWidget = widget; | - |
| 854 | previewWidget->setParent(previewColumn->viewport()); never executed (the execution status of this line is deduced): previewWidget->setParent(previewColumn->viewport()); | - |
| 855 | } | 0 |
| 856 | | - |
| 857 | /*! | - |
| 858 | Sets the column widths to the values given in the \a list. Extra values in the list are | - |
| 859 | kept and used when the columns are created. | - |
| 860 | | - |
| 861 | If list contains too few values, only width of the rest of the columns will not be modified. | - |
| 862 | | - |
| 863 | \sa columnWidths(), createColumn() | - |
| 864 | */ | - |
| 865 | void QColumnView::setColumnWidths(const QList<int> &list) | - |
| 866 | { | - |
| 867 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 868 | int i = 0; never executed (the execution status of this line is deduced): int i = 0; | - |
| 869 | for (; (i < list.count() && i < d->columns.count()); ++i) { never evaluated: i < list.count() never evaluated: i < d->columns.count() | 0 |
| 870 | d->columns.at(i)->resize(list.at(i), d->columns.at(i)->height()); never executed (the execution status of this line is deduced): d->columns.at(i)->resize(list.at(i), d->columns.at(i)->height()); | - |
| 871 | d->columnSizes[i] = list.at(i); never executed (the execution status of this line is deduced): d->columnSizes[i] = list.at(i); | - |
| 872 | } | 0 |
| 873 | for (; i < list.count(); ++i) never evaluated: i < list.count() | 0 |
| 874 | d->columnSizes.append(list.at(i)); never executed: d->columnSizes.append(list.at(i)); | 0 |
| 875 | } | 0 |
| 876 | | - |
| 877 | /*! | - |
| 878 | Returns a list of the width of all the columns in this view. | - |
| 879 | | - |
| 880 | \sa setColumnWidths() | - |
| 881 | */ | - |
| 882 | QList<int> QColumnView::columnWidths() const | - |
| 883 | { | - |
| 884 | Q_D(const QColumnView); never executed (the execution status of this line is deduced): const QColumnViewPrivate * const d = d_func(); | - |
| 885 | QList<int> list; never executed (the execution status of this line is deduced): QList<int> list; | - |
| 886 | for (int i = 0; i < d->columns.count(); ++i) never evaluated: i < d->columns.count() | 0 |
| 887 | list.append(d->columnSizes.at(i)); never executed: list.append(d->columnSizes.at(i)); | 0 |
| 888 | return list; never executed: return list; | 0 |
| 889 | } | - |
| 890 | | - |
| 891 | /*! | - |
| 892 | \reimp | - |
| 893 | */ | - |
| 894 | void QColumnView::rowsInserted(const QModelIndex &parent, int start, int end) | - |
| 895 | { | - |
| 896 | QAbstractItemView::rowsInserted(parent, start, end); never executed (the execution status of this line is deduced): QAbstractItemView::rowsInserted(parent, start, end); | - |
| 897 | d_func()->checkColumnCreation(parent); never executed (the execution status of this line is deduced): d_func()->checkColumnCreation(parent); | - |
| 898 | } | 0 |
| 899 | | - |
| 900 | /*! | - |
| 901 | \reimp | - |
| 902 | */ | - |
| 903 | void QColumnView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) | - |
| 904 | { | - |
| 905 | Q_D(QColumnView); never executed (the execution status of this line is deduced): QColumnViewPrivate * const d = d_func(); | - |
| 906 | if (!current.isValid()) { never evaluated: !current.isValid() | 0 |
| 907 | QAbstractItemView::currentChanged(current, previous); never executed (the execution status of this line is deduced): QAbstractItemView::currentChanged(current, previous); | - |
| 908 | return; | 0 |
| 909 | } | - |
| 910 | | - |
| 911 | QModelIndex currentParent = current.parent(); never executed (the execution status of this line is deduced): QModelIndex currentParent = current.parent(); | - |
| 912 | // optimize for just moving up/down in a list where the child view doesn't change | - |
| 913 | if (currentParent == previous.parent() never evaluated: currentParent == previous.parent() | 0 |
| 914 | && model()->hasChildren(current) && model()->hasChildren(previous)) { never evaluated: model()->hasChildren(current) never evaluated: model()->hasChildren(previous) | 0 |
| 915 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 916 | if (currentParent == d->columns.at(i)->rootIndex()) { never evaluated: currentParent == d->columns.at(i)->rootIndex() | 0 |
| 917 | if (d->columns.size() > i + 1) { never evaluated: d->columns.size() > i + 1 | 0 |
| 918 | QAbstractItemView::currentChanged(current, previous); never executed (the execution status of this line is deduced): QAbstractItemView::currentChanged(current, previous); | - |
| 919 | return; | 0 |
| 920 | } | - |
| 921 | break; | 0 |
| 922 | } | - |
| 923 | } | 0 |
| 924 | } | 0 |
| 925 | | - |
| 926 | // Scrolling to the right we need to have an empty spot | - |
| 927 | bool found = false; never executed (the execution status of this line is deduced): bool found = false; | - |
| 928 | if (currentParent == previous) { never evaluated: currentParent == previous | 0 |
| 929 | for (int i = 0; i < d->columns.size(); ++i) { never evaluated: i < d->columns.size() | 0 |
| 930 | if (currentParent == d->columns.at(i)->rootIndex()) { never evaluated: currentParent == d->columns.at(i)->rootIndex() | 0 |
| 931 | found = true; never executed (the execution status of this line is deduced): found = true; | - |
| 932 | if (d->columns.size() < i + 2) { never evaluated: d->columns.size() < i + 2 | 0 |
| 933 | d->createColumn(current, false); never executed (the execution status of this line is deduced): d->createColumn(current, false); | - |
| 934 | } | 0 |
| 935 | break; | 0 |
| 936 | } | - |
| 937 | } | 0 |
| 938 | } | 0 |
| 939 | if (!found) | 0 |
| 940 | d->closeColumns(current, true); never executed: d->closeColumns(current, true); | 0 |
| 941 | | - |
| 942 | if (!model()->hasChildren(current)) never evaluated: !model()->hasChildren(current) | 0 |
| 943 | emit updatePreviewWidget(current); never executed: updatePreviewWidget(current); | 0 |
| 944 | | - |
| 945 | QAbstractItemView::currentChanged(current, previous); never executed (the execution status of this line is deduced): QAbstractItemView::currentChanged(current, previous); | - |
| 946 | } | 0 |
| 947 | | - |
| 948 | /* | - |
| 949 | We have change the current column and need to update focus and selection models | - |
| 950 | on the new current column. | - |
| 951 | */ | - |
| 952 | void QColumnViewPrivate::_q_changeCurrentColumn() | - |
| 953 | { | - |
| 954 | Q_Q(QColumnView); never executed (the execution status of this line is deduced): QColumnView * const q = q_func(); | - |
| 955 | if (columns.isEmpty()) never evaluated: columns.isEmpty() | 0 |
| 956 | return; | 0 |
| 957 | | - |
| 958 | QModelIndex current = q->currentIndex(); never executed (the execution status of this line is deduced): QModelIndex current = q->currentIndex(); | - |
| 959 | if (!current.isValid()) never evaluated: !current.isValid() | 0 |
| 960 | return; | 0 |
| 961 | | - |
| 962 | // We might have scrolled far to the left so we need to close all of the children | - |
| 963 | closeColumns(current, true); never executed (the execution status of this line is deduced): closeColumns(current, true); | - |
| 964 | | - |
| 965 | // Set up the "current" column with focus | - |
| 966 | int currentColumn = qMax(0, columns.size() - 2); never executed (the execution status of this line is deduced): int currentColumn = qMax(0, columns.size() - 2); | - |
| 967 | QAbstractItemView *parentColumn = columns.at(currentColumn); never executed (the execution status of this line is deduced): QAbstractItemView *parentColumn = columns.at(currentColumn); | - |
| 968 | if (q->hasFocus()) never evaluated: q->hasFocus() | 0 |
| 969 | parentColumn->setFocus(Qt::OtherFocusReason); never executed: parentColumn->setFocus(Qt::OtherFocusReason); | 0 |
| 970 | q->setFocusProxy(parentColumn); never executed (the execution status of this line is deduced): q->setFocusProxy(parentColumn); | - |
| 971 | | - |
| 972 | // find the column that is our current selection model and give it a new one. | - |
| 973 | for (int i = 0; i < columns.size(); ++i) { never evaluated: i < columns.size() | 0 |
| 974 | if (columns.at(i)->selectionModel() == q->selectionModel()) { never evaluated: columns.at(i)->selectionModel() == q->selectionModel() | 0 |
| 975 | QItemSelectionModel *replacementSelectionModel = never executed (the execution status of this line is deduced): QItemSelectionModel *replacementSelectionModel = | - |
| 976 | new QItemSelectionModel(parentColumn->model()); never executed (the execution status of this line is deduced): new QItemSelectionModel(parentColumn->model()); | - |
| 977 | replacementSelectionModel->setCurrentIndex( never executed (the execution status of this line is deduced): replacementSelectionModel->setCurrentIndex( | - |
| 978 | q->selectionModel()->currentIndex(), QItemSelectionModel::Current); never executed (the execution status of this line is deduced): q->selectionModel()->currentIndex(), QItemSelectionModel::Current); | - |
| 979 | replacementSelectionModel->select( never executed (the execution status of this line is deduced): replacementSelectionModel->select( | - |
| 980 | q->selectionModel()->selection(), QItemSelectionModel::Select); never executed (the execution status of this line is deduced): q->selectionModel()->selection(), QItemSelectionModel::Select); | - |
| 981 | QAbstractItemView *view = columns.at(i); never executed (the execution status of this line is deduced): QAbstractItemView *view = columns.at(i); | - |
| 982 | view->setSelectionModel(replacementSelectionModel); never executed (the execution status of this line is deduced): view->setSelectionModel(replacementSelectionModel); | - |
| 983 | view->setFocusPolicy(Qt::NoFocus); never executed (the execution status of this line is deduced): view->setFocusPolicy(Qt::NoFocus); | - |
| 984 | if (columns.size() > i + 1) never evaluated: columns.size() > i + 1 | 0 |
| 985 | view->setCurrentIndex(columns.at(i+1)->rootIndex()); never executed: view->setCurrentIndex(columns.at(i+1)->rootIndex()); | 0 |
| 986 | break; | 0 |
| 987 | } | - |
| 988 | } | 0 |
| 989 | parentColumn->selectionModel()->deleteLater(); never executed (the execution status of this line is deduced): parentColumn->selectionModel()->deleteLater(); | - |
| 990 | parentColumn->setFocusPolicy(Qt::StrongFocus); never executed (the execution status of this line is deduced): parentColumn->setFocusPolicy(Qt::StrongFocus); | - |
| 991 | parentColumn->setSelectionModel(q->selectionModel()); never executed (the execution status of this line is deduced): parentColumn->setSelectionModel(q->selectionModel()); | - |
| 992 | // We want the parent selection to stay highlighted (but dimmed depending upon the color theme) | - |
| 993 | if (currentColumn > 0) { never evaluated: currentColumn > 0 | 0 |
| 994 | parentColumn = columns.at(currentColumn - 1); never executed (the execution status of this line is deduced): parentColumn = columns.at(currentColumn - 1); | - |
| 995 | if (parentColumn->currentIndex() != current.parent()) never evaluated: parentColumn->currentIndex() != current.parent() | 0 |
| 996 | parentColumn->setCurrentIndex(current.parent()); never executed: parentColumn->setCurrentIndex(current.parent()); | 0 |
| 997 | } | 0 |
| 998 | | - |
| 999 | if (columns.last()->isHidden()) { never evaluated: columns.last()->isHidden() | 0 |
| 1000 | columns.last()->setVisible(true); never executed (the execution status of this line is deduced): columns.last()->setVisible(true); | - |
| 1001 | } | 0 |
| 1002 | if (columns.last()->selectionModel()) never evaluated: columns.last()->selectionModel() | 0 |
| 1003 | columns.last()->selectionModel()->clear(); never executed: columns.last()->selectionModel()->clear(); | 0 |
| 1004 | updateScrollbars(); never executed (the execution status of this line is deduced): updateScrollbars(); | - |
| 1005 | } | 0 |
| 1006 | | - |
| 1007 | /*! | - |
| 1008 | \reimp | - |
| 1009 | */ | - |
| 1010 | void QColumnView::selectAll() | - |
| 1011 | { | - |
| 1012 | if (!model() || !selectionModel()) never evaluated: !model() never evaluated: !selectionModel() | 0 |
| 1013 | return; | 0 |
| 1014 | | - |
| 1015 | QModelIndexList indexList = selectionModel()->selectedIndexes(); never executed (the execution status of this line is deduced): QModelIndexList indexList = selectionModel()->selectedIndexes(); | - |
| 1016 | QModelIndex parent = rootIndex(); never executed (the execution status of this line is deduced): QModelIndex parent = rootIndex(); | - |
| 1017 | QItemSelection selection; never executed (the execution status of this line is deduced): QItemSelection selection; | - |
| 1018 | if (indexList.count() >= 1) never evaluated: indexList.count() >= 1 | 0 |
| 1019 | parent = indexList.at(0).parent(); never executed: parent = indexList.at(0).parent(); | 0 |
| 1020 | if (indexList.count() == 1) { never evaluated: indexList.count() == 1 | 0 |
| 1021 | parent = indexList.at(0); never executed (the execution status of this line is deduced): parent = indexList.at(0); | - |
| 1022 | if (!model()->hasChildren(parent)) never evaluated: !model()->hasChildren(parent) | 0 |
| 1023 | parent = parent.parent(); never executed: parent = parent.parent(); | 0 |
| 1024 | else | - |
| 1025 | selection.append(QItemSelectionRange(parent, parent)); never executed: selection.append(QItemSelectionRange(parent, parent)); | 0 |
| 1026 | } | - |
| 1027 | | - |
| 1028 | QModelIndex tl = model()->index(0, 0, parent); never executed (the execution status of this line is deduced): QModelIndex tl = model()->index(0, 0, parent); | - |
| 1029 | QModelIndex br = model()->index(model()->rowCount(parent) - 1, never executed (the execution status of this line is deduced): QModelIndex br = model()->index(model()->rowCount(parent) - 1, | - |
| 1030 | model()->columnCount(parent) - 1, never executed (the execution status of this line is deduced): model()->columnCount(parent) - 1, | - |
| 1031 | parent); never executed (the execution status of this line is deduced): parent); | - |
| 1032 | selection.append(QItemSelectionRange(tl, br)); never executed (the execution status of this line is deduced): selection.append(QItemSelectionRange(tl, br)); | - |
| 1033 | selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect); never executed (the execution status of this line is deduced): selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect); | - |
| 1034 | } | 0 |
| 1035 | | - |
| 1036 | /* | - |
| 1037 | * private object implementation | - |
| 1038 | */ | - |
| 1039 | QColumnViewPrivate::QColumnViewPrivate() | - |
| 1040 | : QAbstractItemViewPrivate() | - |
| 1041 | ,showResizeGrips(true) | - |
| 1042 | ,offset(0) | - |
| 1043 | ,previewWidget(0) | - |
| 1044 | ,previewColumn(0) | - |
| 1045 | { | - |
| 1046 | } | 0 |
| 1047 | | - |
| 1048 | QColumnViewPrivate::~QColumnViewPrivate() | - |
| 1049 | { | - |
| 1050 | } | - |
| 1051 | | - |
| 1052 | /*! | - |
| 1053 | \internal | - |
| 1054 | | - |
| 1055 | */ | - |
| 1056 | void QColumnViewPrivate::_q_columnsInserted(const QModelIndex &parent, int start, int end) | - |
| 1057 | { | - |
| 1058 | QAbstractItemViewPrivate::_q_columnsInserted(parent, start, end); never executed (the execution status of this line is deduced): QAbstractItemViewPrivate::_q_columnsInserted(parent, start, end); | - |
| 1059 | checkColumnCreation(parent); never executed (the execution status of this line is deduced): checkColumnCreation(parent); | - |
| 1060 | } | 0 |
| 1061 | | - |
| 1062 | /*! | - |
| 1063 | \internal | - |
| 1064 | | - |
| 1065 | Makes sure we create a corresponding column as a result of changing the model. | - |
| 1066 | | - |
| 1067 | */ | - |
| 1068 | void QColumnViewPrivate::checkColumnCreation(const QModelIndex &parent) | - |
| 1069 | { | - |
| 1070 | if (parent == q_func()->currentIndex() && model->hasChildren(parent)) { never evaluated: parent == q_func()->currentIndex() never evaluated: model->hasChildren(parent) | 0 |
| 1071 | //the parent has children and is the current | - |
| 1072 | //let's try to find out if there is already a mapping that is good | - |
| 1073 | for (int i = 0; i < columns.count(); ++i) { never evaluated: i < columns.count() | 0 |
| 1074 | QAbstractItemView *view = columns.at(i); never executed (the execution status of this line is deduced): QAbstractItemView *view = columns.at(i); | - |
| 1075 | if (view->rootIndex() == parent) { never evaluated: view->rootIndex() == parent | 0 |
| 1076 | if (view == previewColumn) { never evaluated: view == previewColumn | 0 |
| 1077 | //let's recreate the parent | - |
| 1078 | closeColumns(parent, false); never executed (the execution status of this line is deduced): closeColumns(parent, false); | - |
| 1079 | createColumn(parent, true /*show*/); never executed (the execution status of this line is deduced): createColumn(parent, true ); | - |
| 1080 | } | 0 |
| 1081 | break; | 0 |
| 1082 | } | - |
| 1083 | } | 0 |
| 1084 | } | 0 |
| 1085 | } | 0 |
| 1086 | | - |
| 1087 | /*! | - |
| 1088 | \internal | - |
| 1089 | Place all of the columns where they belong inside of the viewport, resize as necessary. | - |
| 1090 | */ | - |
| 1091 | void QColumnViewPrivate::doLayout() | - |
| 1092 | { | - |
| 1093 | Q_Q(QColumnView); never executed (the execution status of this line is deduced): QColumnView * const q = q_func(); | - |
| 1094 | if (!model || columns.isEmpty()) never evaluated: !model never evaluated: columns.isEmpty() | 0 |
| 1095 | return; | 0 |
| 1096 | | - |
| 1097 | int viewportHeight = viewport->height(); never executed (the execution status of this line is deduced): int viewportHeight = viewport->height(); | - |
| 1098 | int x = columns.at(0)->x(); never executed (the execution status of this line is deduced): int x = columns.at(0)->x(); | - |
| 1099 | | - |
| 1100 | if (q->isRightToLeft()) { never evaluated: q->isRightToLeft() | 0 |
| 1101 | x = viewport->width() + q->horizontalOffset(); never executed (the execution status of this line is deduced): x = viewport->width() + q->horizontalOffset(); | - |
| 1102 | for (int i = 0; i < columns.size(); ++i) { never evaluated: i < columns.size() | 0 |
| 1103 | QAbstractItemView *view = columns.at(i); never executed (the execution status of this line is deduced): QAbstractItemView *view = columns.at(i); | - |
| 1104 | x -= view->width(); never executed (the execution status of this line is deduced): x -= view->width(); | - |
| 1105 | if (x != view->x() || viewportHeight != view->height()) never evaluated: x != view->x() never evaluated: viewportHeight != view->height() | 0 |
| 1106 | view->setGeometry(x, 0, view->width(), viewportHeight); never executed: view->setGeometry(x, 0, view->width(), viewportHeight); | 0 |
| 1107 | } | 0 |
| 1108 | } else { | 0 |
| 1109 | for (int i = 0; i < columns.size(); ++i) { never evaluated: i < columns.size() | 0 |
| 1110 | QAbstractItemView *view = columns.at(i); never executed (the execution status of this line is deduced): QAbstractItemView *view = columns.at(i); | - |
| 1111 | int currentColumnWidth = view->width(); never executed (the execution status of this line is deduced): int currentColumnWidth = view->width(); | - |
| 1112 | if (x != view->x() || viewportHeight != view->height()) never evaluated: x != view->x() never evaluated: viewportHeight != view->height() | 0 |
| 1113 | view->setGeometry(x, 0, currentColumnWidth, viewportHeight); never executed: view->setGeometry(x, 0, currentColumnWidth, viewportHeight); | 0 |
| 1114 | x += currentColumnWidth; never executed (the execution status of this line is deduced): x += currentColumnWidth; | - |
| 1115 | } | 0 |
| 1116 | } | 0 |
| 1117 | } | - |
| 1118 | | - |
| 1119 | /*! | - |
| 1120 | \internal | - |
| 1121 | | - |
| 1122 | Draws a delegate with a > if an object has children. | - |
| 1123 | | - |
| 1124 | \sa {Model/View Programming}, QItemDelegate | - |
| 1125 | */ | - |
| 1126 | void QColumnViewDelegate::paint(QPainter *painter, | - |
| 1127 | const QStyleOptionViewItem &option, | - |
| 1128 | const QModelIndex &index) const | - |
| 1129 | { | - |
| 1130 | drawBackground(painter, option, index ); never executed (the execution status of this line is deduced): drawBackground(painter, option, index ); | - |
| 1131 | | - |
| 1132 | bool reverse = (option.direction == Qt::RightToLeft); never executed (the execution status of this line is deduced): bool reverse = (option.direction == Qt::RightToLeft); | - |
| 1133 | int width = ((option.rect.height() * 2) / 3); never executed (the execution status of this line is deduced): int width = ((option.rect.height() * 2) / 3); | - |
| 1134 | // Modify the options to give us room to add an arrow | - |
| 1135 | QStyleOptionViewItem opt = option; never executed (the execution status of this line is deduced): QStyleOptionViewItem opt = option; | - |
| 1136 | if (reverse) | 0 |
| 1137 | opt.rect.adjust(width,0,0,0); never executed: opt.rect.adjust(width,0,0,0); | 0 |
| 1138 | else | - |
| 1139 | opt.rect.adjust(0,0,-width,0); never executed: opt.rect.adjust(0,0,-width,0); | 0 |
| 1140 | | - |
| 1141 | if (!(index.model()->flags(index) & Qt::ItemIsEnabled)) { never evaluated: !(index.model()->flags(index) & Qt::ItemIsEnabled) | 0 |
| 1142 | opt.showDecorationSelected = true; never executed (the execution status of this line is deduced): opt.showDecorationSelected = true; | - |
| 1143 | opt.state |= QStyle::State_Selected; never executed (the execution status of this line is deduced): opt.state |= QStyle::State_Selected; | - |
| 1144 | } | 0 |
| 1145 | | - |
| 1146 | QItemDelegate::paint(painter, opt, index); never executed (the execution status of this line is deduced): QItemDelegate::paint(painter, opt, index); | - |
| 1147 | | - |
| 1148 | if (reverse) | 0 |
| 1149 | 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 |
| 1150 | else | - |
| 1151 | opt.rect = QRect(option.rect.x() + option.rect.width() - width, option.rect.y(), never executed: opt.rect = QRect(option.rect.x() + option.rect.width() - width, option.rect.y(), width, option.rect.height()); | 0 |
| 1152 | width, option.rect.height()); never executed: opt.rect = QRect(option.rect.x() + option.rect.width() - width, option.rect.y(), width, option.rect.height()); | 0 |
| 1153 | | - |
| 1154 | // Draw > | - |
| 1155 | if (index.model()->hasChildren(index)) { never evaluated: index.model()->hasChildren(index) | 0 |
| 1156 | const QWidget *view = opt.widget; never executed (the execution status of this line is deduced): const QWidget *view = opt.widget; | - |
| 1157 | QStyle *style = view ? view->style() : QApplication::style(); | 0 |
| 1158 | style->drawPrimitive(QStyle::PE_IndicatorColumnViewArrow, &opt, painter, view); never executed (the execution status of this line is deduced): style->drawPrimitive(QStyle::PE_IndicatorColumnViewArrow, &opt, painter, view); | - |
| 1159 | } | 0 |
| 1160 | } | 0 |
| 1161 | | - |
| 1162 | QT_END_NAMESPACE | - |
| 1163 | | - |
| 1164 | #include "moc_qcolumnview.cpp" | - |
| 1165 | | - |
| 1166 | #endif // QT_NO_COLUMNVIEW | - |
| 1167 | | - |
| | |