summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qabstractitemdelegate.cpp32
-rw-r--r--src/gui/itemviews/qabstractitemdelegate.h30
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp251
-rw-r--r--src/gui/itemviews/qabstractitemview.h38
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h72
-rw-r--r--src/gui/itemviews/qabstractproxymodel.cpp30
-rw-r--r--src/gui/itemviews/qabstractproxymodel.h30
-rw-r--r--src/gui/itemviews/qabstractproxymodel_p.h30
-rw-r--r--src/gui/itemviews/qbsptree.cpp30
-rw-r--r--src/gui/itemviews/qbsptree_p.h30
-rw-r--r--src/gui/itemviews/qcolumnview.cpp56
-rw-r--r--src/gui/itemviews/qcolumnview.h30
-rw-r--r--src/gui/itemviews/qcolumnview_p.h36
-rw-r--r--src/gui/itemviews/qcolumnviewgrip.cpp30
-rw-r--r--src/gui/itemviews/qcolumnviewgrip_p.h30
-rw-r--r--src/gui/itemviews/qdatawidgetmapper.cpp30
-rw-r--r--src/gui/itemviews/qdatawidgetmapper.h30
-rw-r--r--src/gui/itemviews/qdirmodel.cpp57
-rw-r--r--src/gui/itemviews/qdirmodel.h30
-rw-r--r--src/gui/itemviews/qfileiconprovider.cpp72
-rw-r--r--src/gui/itemviews/qfileiconprovider.h35
-rw-r--r--src/gui/itemviews/qheaderview.cpp83
-rw-r--r--src/gui/itemviews/qheaderview.h30
-rw-r--r--src/gui/itemviews/qheaderview_p.h30
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp38
-rw-r--r--src/gui/itemviews/qitemdelegate.h30
-rw-r--r--src/gui/itemviews/qitemeditorfactory.cpp30
-rw-r--r--src/gui/itemviews/qitemeditorfactory.h30
-rw-r--r--src/gui/itemviews/qitemeditorfactory_p.h30
-rw-r--r--src/gui/itemviews/qitemselectionmodel.cpp71
-rw-r--r--src/gui/itemviews/qitemselectionmodel.h30
-rw-r--r--src/gui/itemviews/qitemselectionmodel_p.h30
-rw-r--r--src/gui/itemviews/qlistview.cpp1197
-rw-r--r--src/gui/itemviews/qlistview.h30
-rw-r--r--src/gui/itemviews/qlistview_p.h250
-rw-r--r--src/gui/itemviews/qlistwidget.cpp66
-rw-r--r--src/gui/itemviews/qlistwidget.h30
-rw-r--r--src/gui/itemviews/qlistwidget_p.h33
-rw-r--r--src/gui/itemviews/qproxymodel.cpp30
-rw-r--r--src/gui/itemviews/qproxymodel.h30
-rw-r--r--src/gui/itemviews/qproxymodel_p.h30
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp47
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.h31
-rw-r--r--src/gui/itemviews/qstandarditemmodel.cpp65
-rw-r--r--src/gui/itemviews/qstandarditemmodel.h32
-rw-r--r--src/gui/itemviews/qstandarditemmodel_p.h36
-rw-r--r--src/gui/itemviews/qstringlistmodel.cpp32
-rw-r--r--src/gui/itemviews/qstringlistmodel.h30
-rw-r--r--src/gui/itemviews/qstyleditemdelegate.cpp36
-rw-r--r--src/gui/itemviews/qstyleditemdelegate.h30
-rw-r--r--src/gui/itemviews/qtableview.cpp735
-rw-r--r--src/gui/itemviews/qtableview.h34
-rw-r--r--src/gui/itemviews/qtableview_p.h61
-rw-r--r--src/gui/itemviews/qtablewidget.cpp42
-rw-r--r--src/gui/itemviews/qtablewidget.h30
-rw-r--r--src/gui/itemviews/qtablewidget_p.h30
-rw-r--r--src/gui/itemviews/qtreeview.cpp152
-rw-r--r--src/gui/itemviews/qtreeview.h30
-rw-r--r--src/gui/itemviews/qtreeview_p.h39
-rw-r--r--src/gui/itemviews/qtreewidget.cpp56
-rw-r--r--src/gui/itemviews/qtreewidget.h30
-rw-r--r--src/gui/itemviews/qtreewidget_p.h30
-rw-r--r--src/gui/itemviews/qtreewidgetitemiterator.cpp33
-rw-r--r--src/gui/itemviews/qtreewidgetitemiterator.h33
-rw-r--r--src/gui/itemviews/qtreewidgetitemiterator_p.h30
-rw-r--r--src/gui/itemviews/qwidgetitemdata_p.h30
66 files changed, 2929 insertions, 1942 deletions
diff --git a/src/gui/itemviews/qabstractitemdelegate.cpp b/src/gui/itemviews/qabstractitemdelegate.cpp
index 22b96fcf9..848abef81 100644
--- a/src/gui/itemviews/qabstractitemdelegate.cpp
+++ b/src/gui/itemviews/qabstractitemdelegate.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
data items from a model.
\ingroup model-view
- \mainclass
+
A QAbstractItemDelegate provides the interface and common functionality
for delegates in the model/view architecture. Delegates display
diff --git a/src/gui/itemviews/qabstractitemdelegate.h b/src/gui/itemviews/qabstractitemdelegate.h
index 8d51206c4..44b8b8202 100644
--- a/src/gui/itemviews/qabstractitemdelegate.h
+++ b/src/gui/itemviews/qabstractitemdelegate.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 7b5148327..de6e6cb2a 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -61,6 +61,7 @@
#ifndef QT_NO_ACCESSIBILITY
#include <qaccessible.h>
#endif
+#include <private/qsoftkeymanager_p.h>
QT_BEGIN_NAMESPACE
@@ -68,6 +69,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()
: model(QAbstractItemModelPrivate::staticEmptyModel()),
itemDelegate(0),
selectionModel(0),
+ ctrlDragSelectionFlag(QItemSelectionModel::NoUpdate),
selectionMode(QAbstractItemView::ExtendedSelection),
selectionBehavior(QAbstractItemView::SelectItems),
currentlyCommittingEditor(0),
@@ -85,11 +87,16 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()
dragDropMode(QAbstractItemView::NoDragDrop),
overwrite(false),
dropIndicatorPosition(QAbstractItemView::OnItem),
+ defaultDropAction(Qt::IgnoreAction),
+#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ doneSoftKey(0),
#endif
autoScroll(true),
autoScrollMargin(16),
autoScrollCount(0),
shouldScrollToCurrentOnShow(false),
+ shouldClearStatusTip(false),
alternatingColors(false),
textElideMode(Qt::ElideRight),
verticalScrollMode(QAbstractItemView::ScrollPerItem),
@@ -126,12 +133,28 @@ void QAbstractItemViewPrivate::init()
doDelayedItemsLayout();
q->setAttribute(Qt::WA_InputMethodEnabled);
+
+#ifdef QT_SOFTKEYS_ENABLED
+ doneSoftKey = QSoftKeyManager::createKeyedAction(QSoftKeyManager::DoneSoftKey, Qt::Key_Back, q);
+#endif
+}
+
+void QAbstractItemViewPrivate::setHoverIndex(const QPersistentModelIndex &index)
+{
+ Q_Q(QAbstractItemView);
+ if (hover == index)
+ return;
+
+ q->update(hover); //update the old one
+ hover = index;
+ q->update(hover); //update the new one
}
void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index)
{
//we take a persistent model index because the model might change by emitting signals
Q_Q(QAbstractItemView);
+ setHoverIndex(index);
if (viewportEnteredNeeded || enteredIndex != index) {
viewportEnteredNeeded = false;
@@ -139,14 +162,15 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index
emit q->entered(index);
#ifndef QT_NO_STATUSTIP
QString statustip = model->data(index, Qt::StatusTipRole).toString();
- if (parent && !statustip.isEmpty()) {
+ if (parent && (shouldClearStatusTip || !statustip.isEmpty())) {
QStatusTipEvent tip(statustip);
QApplication::sendEvent(parent, &tip);
+ shouldClearStatusTip = !statustip.isEmpty();
}
#endif
} else {
#ifndef QT_NO_STATUSTIP
- if (parent) {
+ if (parent && shouldClearStatusTip) {
QString emptyString;
QStatusTipEvent tip( emptyString );
QApplication::sendEvent(parent, &tip);
@@ -166,7 +190,7 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index
item view classes.
\ingroup model-view
- \mainclass
+
QAbstractItemView class is the base class for every standard view
that uses a QAbstractItemModel. QAbstractItemView is an abstract
@@ -175,7 +199,45 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index
slots mechanism, enabling subclasses to be kept up-to-date with
changes to their models. This class provides standard support for
keyboard and mouse navigation, viewport scrolling, item editing,
- and selections.
+ and selections. The keyboard navigation implements this
+ functionality:
+
+ \table
+ \header
+ \o Keys
+ \o Functionality
+ \row
+ \o Arrow keys
+ \o Changes the current item and selects it.
+ \row
+ \o Ctrl+Arrow keys
+ \o Changes the current item but does not select it.
+ \row
+ \o Shift+Arrow keys
+ \o Changes the current item and selects it. The previously
+ selected item(s) is not deselected.
+ \row
+ \o Ctr+Space
+ \o Toggles selection of the current item.
+ \row
+ \o Tab/Backtab
+ \o Changes the current item to the next/previous item.
+ \row
+ \o Home/End
+ \o Selects the first/last item in the model.
+ \row
+ \o Page up/Page down
+ \o Scrolls the rows shown up/down by the number of
+ visible rows in the view.
+ \row
+ \o Ctrl+A
+ \o Selects all items in the model.
+ \endtable
+
+ Note that the above table assumes that the
+ \l{selectionMode}{selection mode} allows the operations. For
+ instance, you cannot select items if the selection mode is
+ QAbstractItemView::NoSelection.
The QAbstractItemView class is one of the \l{Model/View Classes}
and is part of Qt's \l{Model/View Programming}{model/view framework}.
@@ -557,6 +619,8 @@ void QAbstractItemView::setModel(QAbstractItemModel *model)
this, SLOT(_q_modelDestroyed()));
disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(dataChanged(QModelIndex,QModelIndex)));
+ disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+ this, SLOT(_q_headerDataChanged()));
disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(rowsInserted(QModelIndex,int,int)));
disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
@@ -589,6 +653,8 @@ void QAbstractItemView::setModel(QAbstractItemModel *model)
this, SLOT(_q_modelDestroyed()));
connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(dataChanged(QModelIndex,QModelIndex)));
+ connect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+ this, SLOT(_q_headerDataChanged()));
connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(rowsInserted(QModelIndex,int,int)));
connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
@@ -703,7 +769,6 @@ void QAbstractItemView::setItemDelegate(QAbstractItemDelegate *delegate)
}
}
-
if (delegate) {
if (d->delegateRefCount(delegate) == 0) {
connect(delegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),
@@ -714,6 +779,7 @@ void QAbstractItemView::setItemDelegate(QAbstractItemDelegate *delegate)
}
}
d->itemDelegate = delegate;
+ viewport()->update();
}
/*!
@@ -778,6 +844,7 @@ void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *de
}
d->rowDelegates.insert(row, delegate);
}
+ viewport()->update();
}
/*!
@@ -834,6 +901,7 @@ void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelega
}
d->columnDelegates.insert(column, delegate);
}
+ viewport()->update();
}
/*!
@@ -907,7 +975,9 @@ QAbstractItemView::SelectionBehavior QAbstractItemView::selectionBehavior() cons
/*!
Sets the current item to be the item at \a index.
- Depending on the current selection mode, the item may also be selected.
+
+ Unless the current selection mode is
+ \l{QAbstractItemView::}{NoSelection}, the item is also be selected.
Note that this function also updates the starting position for any
new selections the user performs.
@@ -953,6 +1023,7 @@ QModelIndex QAbstractItemView::currentIndex() const
void QAbstractItemView::reset()
{
Q_D(QAbstractItemView);
+ d->delayedReset.stop(); //make sure we stop the timer
QList<QEditorInfo>::const_iterator it = d->editors.constBegin();
for (; it != d->editors.constEnd(); ++it)
d->releaseEditor(it->editor);
@@ -1321,6 +1392,28 @@ QAbstractItemView::DragDropMode QAbstractItemView::dragDropMode() const
return NoDragDrop;
}
+/*!
+ \property QAbstractItemView::defaultDropAction
+ \brief the drop action that will be used by default in QAbstractItemView::drag()
+
+ If the property is not set, the drop action is CopyAction when the supported
+ actions support CopyAction.
+
+ \since 4.6
+ \sa showDropIndicator dragDropOverwriteMode
+*/
+void QAbstractItemView::setDefaultDropAction(Qt::DropAction dropAction)
+{
+ Q_D(QAbstractItemView);
+ d->defaultDropAction = dropAction;
+}
+
+Qt::DropAction QAbstractItemView::defaultDropAction() const
+{
+ Q_D(const QAbstractItemView);
+ return d->defaultDropAction;
+}
+
#endif // QT_NO_DRAGANDDROP
/*!
@@ -1457,26 +1550,25 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
{
Q_D(QAbstractItemView);
switch (event->type()) {
- case QEvent::HoverEnter: {
- QHoverEvent *he = static_cast<QHoverEvent*>(event);
- d->hover = indexAt(he->pos());
- update(d->hover);
- break; }
- case QEvent::HoverLeave: {
- update(d->hover); // update old
- d->hover = QModelIndex();
- break; }
- case QEvent::HoverMove: {
- QHoverEvent *he = static_cast<QHoverEvent*>(event);
- QModelIndex old = d->hover;
- d->hover = indexAt(he->pos());
- if (d->hover != old)
- d->viewport->update(visualRect(old)|visualRect(d->hover));
- break; }
+ case QEvent::HoverMove:
+ case QEvent::HoverEnter:
+ d->setHoverIndex(indexAt(static_cast<QHoverEvent*>(event)->pos()));
+ break;
+ case QEvent::HoverLeave:
+ d->setHoverIndex(QModelIndex());
+ break;
case QEvent::Enter:
d->viewportEnteredNeeded = true;
break;
case QEvent::Leave:
+ #ifndef QT_NO_STATUSTIP
+ if (d->shouldClearStatusTip && d->parent) {
+ QString empty;
+ QStatusTipEvent tip(empty);
+ QApplication::sendEvent(d->parent, &tip);
+ d->shouldClearStatusTip = false;
+ }
+ #endif
d->enteredIndex = QModelIndex();
break;
case QEvent::ToolTip:
@@ -1533,8 +1625,7 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event)
QPoint offset = d->offset();
if ((command & QItemSelectionModel::Current) == 0)
d->pressedPosition = pos + offset;
-
- if (d->pressedPosition == QPoint(-1, -1))
+ else if (!indexAt(d->pressedPosition - offset).isValid())
d->pressedPosition = visualRect(currentIndex()).center() + offset;
if (edit(index, NoEditTriggers, event))
@@ -1548,6 +1639,11 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event)
d->selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
d->autoScroll = autoScroll;
QRect rect(d->pressedPosition - offset, pos);
+ if (command.testFlag(QItemSelectionModel::Toggle)) {
+ command &= ~QItemSelectionModel::Toggle;
+ d->ctrlDragSelectionFlag = d->selectionModel->isSelected(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
+ command |= d->ctrlDragSelectionFlag;
+ }
setSelection(rect, command);
// signal handlers may change the model
@@ -1618,6 +1714,10 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)
if ((event->buttons() & Qt::LeftButton) && d->selectionAllowed(index) && d->selectionModel) {
setState(DragSelectingState);
QItemSelectionModel::SelectionFlags command = selectionCommand(index, event);
+ if (d->ctrlDragSelectionFlag != QItemSelectionModel::NoUpdate && command.testFlag(QItemSelectionModel::Toggle)) {
+ command &= ~QItemSelectionModel::Toggle;
+ command |= d->ctrlDragSelectionFlag;
+ }
// Do the normalize ourselves, since QRect::normalized() is flawed
QRect selectionRect = QRect(topLeft, bottomRight);
@@ -1658,8 +1758,11 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)
EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers);
bool edited = edit(index, trigger, event);
- if (d->selectionModel)
- d->selectionModel->select(index, selectionCommand(index, event));
+ d->ctrlDragSelectionFlag = QItemSelectionModel::NoUpdate;
+
+ //in the case the user presses on no item we might decide to clear the selection
+ if (d->selectionModel && !index.isValid())
+ d->selectionModel->select(QModelIndex(), selectionCommand(index, event));
setState(NoState);
@@ -2010,15 +2113,22 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
if (QApplication::keypadNavigationEnabled()) {
if (!hasEditFocus()) {
setEditFocus(true);
+#ifdef QT_SOFTKEYS_ENABLED
+ addAction(d->doneSoftKey);
+#endif
return;
}
}
break;
case Qt::Key_Back:
- if (QApplication::keypadNavigationEnabled() && hasEditFocus())
+ if (QApplication::keypadNavigationEnabled() && hasEditFocus()) {
+#ifdef QT_SOFTKEYS_ENABLED
+ removeAction(d->doneSoftKey);
+#endif
setEditFocus(false);
- else
+ } else {
event->ignore();
+ }
return;
default:
if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
@@ -2085,13 +2195,16 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
// note that we don't check if the new current index is enabled because moveCursor() makes sure it is
if (command & QItemSelectionModel::Current) {
d->selectionModel->setCurrentIndex(newCurrent, QItemSelectionModel::NoUpdate);
- if (d->pressedPosition == QPoint(-1, -1))
- d->pressedPosition = visualRect(oldCurrent).center();
+ if (!indexAt(d->pressedPosition - d->offset()).isValid())
+ d->pressedPosition = visualRect(oldCurrent).center() + d->offset();
QRect rect(d->pressedPosition - d->offset(), visualRect(newCurrent).center());
setSelection(rect, command);
} else {
d->selectionModel->setCurrentIndex(newCurrent, command);
d->pressedPosition = visualRect(newCurrent).center() + d->offset();
+ // We copy the same behaviour as for mousePressEvent().
+ QRect rect(d->pressedPosition - d->offset(), QSize(1, 1));
+ setSelection(rect, command);
}
return;
}
@@ -2109,6 +2222,12 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
#endif
case Qt::Key_Left:
case Qt::Key_Right:
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {
+ event->accept(); // don't change horizontal focus in directional mode
+ break;
+ }
+#endif // QT_KEYPAD_NAVIGATION
case Qt::Key_Home:
case Qt::Key_End:
case Qt::Key_PageUp:
@@ -2205,7 +2324,9 @@ void QAbstractItemView::timerEvent(QTimerEvent *event)
Q_D(QAbstractItemView);
if (event->timerId() == d->fetchMoreTimer.timerId())
d->fetchMore();
- if (event->timerId() == d->autoScrollTimer.timerId())
+ else if (event->timerId() == d->delayedReset.timerId())
+ reset();
+ else if (event->timerId() == d->autoScrollTimer.timerId())
doAutoScroll();
else if (event->timerId() == d->updateTimer.timerId())
d->updateDirtyRegion();
@@ -2431,7 +2552,9 @@ void QAbstractItemView::verticalScrollbarValueChanged(int value)
Q_D(QAbstractItemView);
if (verticalScrollBar()->maximum() == value && d->model->canFetchMore(d->root))
d->model->fetchMore(d->root);
- d->checkMouseMove(viewport()->mapFromGlobal(QCursor::pos()));
+ QPoint posInVp = viewport()->mapFromGlobal(QCursor::pos());
+ if (viewport()->rect().contains(posInVp))
+ d->checkMouseMove(posInVp);
}
/*!
@@ -2442,7 +2565,9 @@ void QAbstractItemView::horizontalScrollbarValueChanged(int value)
Q_D(QAbstractItemView);
if (horizontalScrollBar()->maximum() == value && d->model->canFetchMore(d->root))
d->model->fetchMore(d->root);
- d->checkMouseMove(viewport()->mapFromGlobal(QCursor::pos()));
+ QPoint posInVp = viewport()->mapFromGlobal(QCursor::pos());
+ if (viewport()->rect().contains(posInVp))
+ d->checkMouseMove(posInVp);
}
/*!
@@ -2925,7 +3050,7 @@ void QAbstractItemView::update(const QModelIndex &index)
//this test is important for peformance reason
//For example in dataChanged we simply update all the cells without checking
//it can be a major bottleneck to update rects that aren't even part of the viewport
- if (d->viewport->geometry().intersects(rect))
+ if (d->viewport->rect().intersects(rect))
d->viewport->update(rect);
}
}
@@ -3129,9 +3254,8 @@ void QAbstractItemViewPrivate::_q_columnsInserted(const QModelIndex &, int, int)
*/
void QAbstractItemViewPrivate::_q_modelDestroyed()
{
- Q_Q(QAbstractItemView);
model = QAbstractItemModelPrivate::staticEmptyModel();
- QMetaObject::invokeMethod(q, "reset", Qt::QueuedConnection);
+ doDelayedReset();
}
/*!
@@ -3222,7 +3346,9 @@ void QAbstractItemView::startDrag(Qt::DropActions supportedActions)
drag->setMimeData(data);
drag->setHotSpot(d->pressedPosition - rect.topLeft());
Qt::DropAction defaultDropAction = Qt::IgnoreAction;
- if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove)
+ if (d->defaultDropAction != Qt::IgnoreAction && (supportedActions & d->defaultDropAction))
+ defaultDropAction = d->defaultDropAction;
+ else if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove)
defaultDropAction = Qt::CopyAction;
if (drag->exec(supportedActions, defaultDropAction) == Qt::MoveAction)
d->clearOrRemove();
@@ -3378,11 +3504,7 @@ QPoint QAbstractItemView::dirtyRegionOffset() const
*/
void QAbstractItemView::startAutoScroll()
{
- Q_D(QAbstractItemView);
- // ### it would be nice to make this into a style hint one day
- int scrollInterval = (verticalScrollMode() == QAbstractItemView::ScrollPerItem) ? 150 : 50;
- d->autoScrollTimer.start(scrollInterval, this);
- d->autoScrollCount = 0;
+ d_func()->startAutoScroll();
}
/*!
@@ -3390,9 +3512,7 @@ void QAbstractItemView::startAutoScroll()
*/
void QAbstractItemView::stopAutoScroll()
{
- Q_D(QAbstractItemView);
- d->autoScrollTimer.stop();
- d->autoScrollCount = 0;
+ d_func()->stopAutoScroll();
}
/*!
@@ -3538,7 +3658,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC
const bool controlKeyPressed = modifiers & Qt::ControlModifier;
if (((index == pressedIndex && selectionModel->isSelected(index))
|| !index.isValid()) && state != QAbstractItemView::DragSelectingState
- && !shiftKeyPressed && !controlKeyPressed && !rightButtonPressed)
+ && !shiftKeyPressed && !controlKeyPressed && (!rightButtonPressed || !index.isValid()))
return QItemSelectionModel::ClearAndSelect|selectionBehaviorFlags();
return QItemSelectionModel::NoUpdate;
}
@@ -3557,12 +3677,13 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC
case Qt::Key_PageUp:
case Qt::Key_PageDown:
case Qt::Key_Tab:
+ if (modifiers & Qt::ControlModifier
#ifdef QT_KEYPAD_NAVIGATION
- return QItemSelectionModel::NoUpdate;
-#else
- if (modifiers & Qt::ControlModifier)
- return QItemSelectionModel::NoUpdate;
+ // Preserve historical tab order navigation behavior
+ || QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
#endif
+ )
+ return QItemSelectionModel::NoUpdate;
break;
case Qt::Key_Select:
return QItemSelectionModel::Toggle|selectionBehaviorFlags();
diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h
index 3e5747099..ea5d259f0 100644
--- a/src/gui/itemviews/qabstractitemview.h
+++ b/src/gui/itemviews/qabstractitemview.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -74,6 +74,7 @@ class Q_GUI_EXPORT QAbstractItemView : public QAbstractScrollArea
Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
Q_PROPERTY(bool dragDropOverwriteMode READ dragDropOverwriteMode WRITE setDragDropOverwriteMode)
Q_PROPERTY(DragDropMode dragDropMode READ dragDropMode WRITE setDragDropMode)
+ Q_PROPERTY(Qt::DropAction defaultDropAction READ defaultDropAction WRITE setDefaultDropAction)
#endif
Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
@@ -181,7 +182,11 @@ public:
void setDragDropMode(DragDropMode behavior);
DragDropMode dragDropMode() const;
+
+ void setDefaultDropAction(Qt::DropAction dropAction);
+ Qt::DropAction defaultDropAction() const;
#endif
+
void setAlternatingRowColors(bool enable);
bool alternatingRowColors() const;
@@ -353,9 +358,12 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex&, int, int))
Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged())
friend class QTreeViewPrivate; // needed to compile with MSVC
friend class QAccessibleItemRow;
+ friend class QListModeViewBase;
+ friend class QListViewPrivate; // needed to compile for Symbian emulator
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemView::EditTriggers)
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
index 2ba027dba..0b5cfbee1 100644
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ b/src/gui/itemviews/qabstractitemview_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -117,7 +117,8 @@ public:
virtual void _q_columnsInserted(const QModelIndex &parent, int start, int end);
virtual void _q_modelDestroyed();
virtual void _q_layoutChanged();
-
+ void _q_headerDataChanged() { doDelayedItemsLayout(); }
+
void fetchMore();
bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const;
@@ -126,6 +127,15 @@ public:
void doDelayedItemsLayout(int delay = 0);
void interruptDelayedItemsLayout() const;
+ void startAutoScroll()
+ { // ### it would be nice to make this into a style hint one day
+ int scrollInterval = (verticalScrollMode == QAbstractItemView::ScrollPerItem) ? 150 : 50;
+ autoScrollTimer.start(scrollInterval, q_func());
+ autoScrollCount = 0;
+ }
+ void stopAutoScroll() { autoScrollTimer.stop(); autoScrollCount = 0;}
+
+
bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index);
bool droppingOnItself(QDropEvent *event, const QModelIndex &index);
@@ -142,6 +152,8 @@ public:
const QEvent *event) const;
virtual void selectAll(QItemSelectionModel::SelectionFlags command);
+ void setHoverIndex(const QPersistentModelIndex &index);
+
void checkMouseMove(const QPersistentModelIndex &index);
inline void checkMouseMove(const QPoint &pos) { checkMouseMove(q_func()->indexAt(pos)); }
@@ -155,7 +167,8 @@ public:
}
#ifndef QT_NO_DRAGANDDROP
- QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;
+ virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;
+
inline bool canDecode(QDropEvent *e) const {
QStringList modelTypes = model->mimeTypes();
const QMimeData *mime = e->mimeData();
@@ -306,24 +319,34 @@ public:
}
return ref;
}
-
+
/**
* return true if the index is registered as a QPersistentModelIndex
*/
inline bool isPersistent(const QModelIndex &index) const
{
- return static_cast<QAbstractItemModelPrivate *>(model->d_ptr)->persistent.indexes.contains(index);
+ return static_cast<QAbstractItemModelPrivate *>(model->d_ptr.data())->persistent.indexes.contains(index);
}
QModelIndexList selectedDraggableIndexes() const;
QStyleOptionViewItemV4 viewOptionsV4() const;
+ void doDelayedReset()
+ {
+ //we delay the reset of the timer because some views (QTableView)
+ //with headers can't handle the fact that the model has been destroyed
+ //all _q_modelDestroyed slots must have been called
+ if (!delayedReset.isActive())
+ delayedReset.start(0, q_func());
+ }
+
QAbstractItemModel *model;
QPointer<QAbstractItemDelegate> itemDelegate;
QMap<int, QPointer<QAbstractItemDelegate> > rowDelegates;
QMap<int, QPointer<QAbstractItemDelegate> > columnDelegates;
QPointer<QItemSelectionModel> selectionModel;
+ QItemSelectionModel::SelectionFlag ctrlDragSelectionFlag;
QAbstractItemView::SelectionMode selectionMode;
QAbstractItemView::SelectionBehavior selectionBehavior;
@@ -337,8 +360,8 @@ public:
Qt::KeyboardModifiers pressedModifiers;
QPoint pressedPosition;
bool pressedAlreadySelected;
-
- //forces the next mouseMoveEvent to send the viewportEntered signal
+
+ //forces the next mouseMoveEvent to send the viewportEntered signal
//if the mouse is over the viewport and not over an item
bool viewportEnteredNeeded;
@@ -358,6 +381,11 @@ public:
QAbstractItemView::DragDropMode dragDropMode;
bool overwrite;
QAbstractItemView::DropIndicatorPosition dropIndicatorPosition;
+ Qt::DropAction defaultDropAction;
+#endif
+
+#ifdef QT_SOFTKEYS_ENABLED
+ QAction *doneSoftKey;
#endif
QString keyboardInput;
@@ -368,6 +396,7 @@ public:
int autoScrollMargin;
int autoScrollCount;
bool shouldScrollToCurrentOnShow; //used to know if we should scroll to current on show event
+ bool shouldClearStatusTip; //if there is a statustip currently shown that need to be cleared when leaving.
bool alternatingColors;
@@ -380,6 +409,7 @@ public:
QBasicTimer updateTimer;
QBasicTimer delayedEditing;
QBasicTimer delayedAutoScroll; //used when an item is clicked
+ QBasicTimer delayedReset;
QAbstractItemView::ScrollMode verticalScrollMode;
QAbstractItemView::ScrollMode horizontalScrollMode;
diff --git a/src/gui/itemviews/qabstractproxymodel.cpp b/src/gui/itemviews/qabstractproxymodel.cpp
index 499c6707c..0b479c34e 100644
--- a/src/gui/itemviews/qabstractproxymodel.cpp
+++ b/src/gui/itemviews/qabstractproxymodel.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qabstractproxymodel.h b/src/gui/itemviews/qabstractproxymodel.h
index 15b046d3b..638dbb614 100644
--- a/src/gui/itemviews/qabstractproxymodel.h
+++ b/src/gui/itemviews/qabstractproxymodel.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qabstractproxymodel_p.h b/src/gui/itemviews/qabstractproxymodel_p.h
index f5b56046f..1ae77380a 100644
--- a/src/gui/itemviews/qabstractproxymodel_p.h
+++ b/src/gui/itemviews/qabstractproxymodel_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qbsptree.cpp b/src/gui/itemviews/qbsptree.cpp
index d50ea2600..d774a7024 100644
--- a/src/gui/itemviews/qbsptree.cpp
+++ b/src/gui/itemviews/qbsptree.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qbsptree_p.h b/src/gui/itemviews/qbsptree_p.h
index e0ce6dfb9..4f61cda0b 100644
--- a/src/gui/itemviews/qbsptree_p.h
+++ b/src/gui/itemviews/qbsptree_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qcolumnview.cpp b/src/gui/itemviews/qcolumnview.cpp
index fd8106f78..da3e5a0b8 100644
--- a/src/gui/itemviews/qcolumnview.cpp
+++ b/src/gui/itemviews/qcolumnview.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
\brief The QColumnView class provides a model/view implementation of a column view.
\ingroup model-view
\ingroup advanced
- \mainclass
+
QColumnView displays a model in a number of QListViews, one for each
hierarchy in the tree. This is sometimes referred to as a cascading list.
@@ -672,8 +672,8 @@ QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bo
QAbstractItemView *view = 0;
if (model->hasChildren(index)) {
view = q->createColumn(index);
- q->connect(view, SIGNAL(clicked(const QModelIndex &)),
- q, SLOT(_q_clicked(const QModelIndex &)));
+ q->connect(view, SIGNAL(clicked(QModelIndex)),
+ q, SLOT(_q_clicked(QModelIndex)));
} else {
if (!previewColumn)
setPreviewWidget(new QWidget(q));
@@ -681,16 +681,16 @@ QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bo
view->setMinimumWidth(qMax(view->minimumWidth(), previewWidget->minimumWidth()));
}
- q->connect(view, SIGNAL(activated(const QModelIndex &)),
- q, SIGNAL(activated(const QModelIndex &)));
- q->connect(view, SIGNAL(clicked(const QModelIndex &)),
- q, SIGNAL(clicked(const QModelIndex &)));
- q->connect(view, SIGNAL(doubleClicked(const QModelIndex &)),
- q, SIGNAL(doubleClicked(const QModelIndex &)));
- q->connect(view, SIGNAL(entered(const QModelIndex &)),
- q, SIGNAL(entered(const QModelIndex &)));
- q->connect(view, SIGNAL(pressed(const QModelIndex &)),
- q, SIGNAL(pressed(const QModelIndex &)));
+ q->connect(view, SIGNAL(activated(QModelIndex)),
+ q, SIGNAL(activated(QModelIndex)));
+ q->connect(view, SIGNAL(clicked(QModelIndex)),
+ q, SIGNAL(clicked(QModelIndex)));
+ q->connect(view, SIGNAL(doubleClicked(QModelIndex)),
+ q, SIGNAL(doubleClicked(QModelIndex)));
+ q->connect(view, SIGNAL(entered(QModelIndex)),
+ q, SIGNAL(entered(QModelIndex)));
+ q->connect(view, SIGNAL(pressed(QModelIndex)),
+ q, SIGNAL(pressed(QModelIndex)));
view->setFocusPolicy(Qt::NoFocus);
view->setParent(viewport);
diff --git a/src/gui/itemviews/qcolumnview.h b/src/gui/itemviews/qcolumnview.h
index a9433ab0a..c847172e2 100644
--- a/src/gui/itemviews/qcolumnview.h
+++ b/src/gui/itemviews/qcolumnview.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qcolumnview_p.h b/src/gui/itemviews/qcolumnview_p.h
index eb5a27929..0c096bf45 100644
--- a/src/gui/itemviews/qcolumnview_p.h
+++ b/src/gui/itemviews/qcolumnview_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -55,7 +55,7 @@
#include "qcolumnview.h"
-#ifndef QT_NO_QCOlUMNVIEW
+#ifndef QT_NO_QCOLUMNVIEW
#include <private/qabstractitemview_p.h>
@@ -174,8 +174,8 @@ class QColumnViewDelegate : public QItemDelegate
{
public:
- explicit QColumnViewDelegate(QObject *parent = 0) : QItemDelegate(parent) {};
- ~QColumnViewDelegate() {};
+ explicit QColumnViewDelegate(QObject *parent = 0) : QItemDelegate(parent) {}
+ ~QColumnViewDelegate() {}
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
diff --git a/src/gui/itemviews/qcolumnviewgrip.cpp b/src/gui/itemviews/qcolumnviewgrip.cpp
index b35a59fa5..498385612 100644
--- a/src/gui/itemviews/qcolumnviewgrip.cpp
+++ b/src/gui/itemviews/qcolumnviewgrip.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qcolumnviewgrip_p.h b/src/gui/itemviews/qcolumnviewgrip_p.h
index 0b9417fff..2da382fae 100644
--- a/src/gui/itemviews/qcolumnviewgrip_p.h
+++ b/src/gui/itemviews/qcolumnviewgrip_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qdatawidgetmapper.cpp b/src/gui/itemviews/qdatawidgetmapper.cpp
index 4a8db9ef9..ce8b6587f 100644
--- a/src/gui/itemviews/qdatawidgetmapper.cpp
+++ b/src/gui/itemviews/qdatawidgetmapper.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qdatawidgetmapper.h b/src/gui/itemviews/qdatawidgetmapper.h
index 615b95ff2..8d1da7dda 100644
--- a/src/gui/itemviews/qdatawidgetmapper.h
+++ b/src/gui/itemviews/qdatawidgetmapper.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qdirmodel.cpp b/src/gui/itemviews/qdirmodel.cpp
index b1b2ced69..942cfd709 100644
--- a/src/gui/itemviews/qdirmodel.cpp
+++ b/src/gui/itemviews/qdirmodel.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -190,6 +190,9 @@ void QDirModelPrivate::invalidate()
\ingroup model-view
+ \note The usage of QDirModel is not recommended anymore. The
+ QFileSystemModel class is a more performant alternative.
+
This class provides access to the local filesystem, providing functions
for renaming and removing files and directories, and for creating new
directories. In the simplest case, it can be used with a suitable display
@@ -228,10 +231,7 @@ void QDirModelPrivate::invalidate()
\note QDirModel requires an instance of a GUI application.
- \note The usage of QDirModel is not recommended anymore. The
- QFileSystemModel class is a more performant alternative.
-
- \sa nameFilters(), setFilter(), filter(), QListView, QTreeView, QFileSystemModel
+ \sa nameFilters(), setFilter(), filter(), QListView, QTreeView, QFileSystemModel,
{Dir View Example}, {Model Classes}
*/
@@ -872,8 +872,10 @@ QModelIndex QDirModel::index(const QString &path, int column) const
return QModelIndex();
QString absolutePath = QDir(path).absolutePath();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
absolutePath = absolutePath.toLower();
+#endif
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
// On Windows, "filename......." and "filename" are equivalent
if (absolutePath.endsWith(QLatin1Char('.'))) {
int i;
@@ -913,7 +915,10 @@ QModelIndex QDirModel::index(const QString &path, int column) const
pathElements.pop_front();
if (childAppended)
emit const_cast<QDirModel*>(this)->layoutChanged();
- } else if (pathElements.at(0).endsWith(QLatin1Char(':'))) {
+ } else
+#endif
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
+ if (pathElements.at(0).endsWith(QLatin1Char(':'))) {
pathElements[0] += QLatin1Char('/');
}
#else
@@ -935,11 +940,9 @@ QModelIndex QDirModel::index(const QString &path, int column) const
for (int j = parent->children.count() - 1; j >= 0; --j) {
const QFileInfo& fi = parent->children.at(j).info;
QString childFileName;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
childFileName = idx.isValid() ? fi.fileName() : fi.absoluteFilePath();
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
childFileName = childFileName.toLower();
-#else
- childFileName = idx.isValid() ? fi.fileName() : fi.absoluteFilePath();
#endif
if (childFileName == element) {
if (i == pathElements.count() - 1)
@@ -956,7 +959,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const
if (parent->info.isRoot())
newPath = parent->info.absoluteFilePath() + element;
else
- newPath= parent->info.absoluteFilePath() + QLatin1Char('/') + element;
+ newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element;
#else
QString newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element;
#endif
@@ -1308,6 +1311,8 @@ QString QDirModelPrivate::name(const QModelIndex &index) const
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
if (name.startsWith(QLatin1Char('/'))) // UNC host
return info.fileName();
+#endif
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
if (name.endsWith(QLatin1Char('/')))
name.chop(1);
#endif
@@ -1346,7 +1351,7 @@ QString QDirModelPrivate::size(const QModelIndex &index) const
return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
if (bytes >= kb)
return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
- return QFileSystemModel::tr("%1 bytes").arg(QLocale().toString(bytes));
+ return QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes));
}
QString QDirModelPrivate::type(const QModelIndex &index) const
diff --git a/src/gui/itemviews/qdirmodel.h b/src/gui/itemviews/qdirmodel.h
index 81b73a4d5..7694b78ff 100644
--- a/src/gui/itemviews/qdirmodel.h
+++ b/src/gui/itemviews/qdirmodel.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp
index b833bb759..631679713 100644
--- a/src/gui/itemviews/qfileiconprovider.cpp
+++ b/src/gui/itemviews/qfileiconprovider.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -47,18 +47,24 @@
#include <qdir.h>
#include <qpixmapcache.h>
#if defined(Q_WS_WIN)
-#define _WIN32_IE 0x0500
-#include <qt_windows.h>
-#include <commctrl.h>
-#include <objbase.h>
-#include <private/qpixmapdata_p.h>
+# define _WIN32_IE 0x0500
+# include <qt_windows.h>
+# include <commctrl.h>
+# include <objbase.h>
#elif defined(Q_WS_MAC)
-#include <private/qt_cocoa_helpers_mac_p.h>
+# include <private/qt_cocoa_helpers_mac_p.h>
#endif
+
#include <private/qfunctions_p.h>
+#include <private/qguiplatformplugin_p.h>
+
+#if defined(Q_WS_X11) && !defined(Q_NO_STYLE_GTK)
+# include <private/qgtkstyle_p.h>
+# include <private/qt_x11_p.h>
+#endif
#ifndef SHGFI_ADDOVERLAYS
-#define SHGFI_ADDOVERLAYS 0x000000020
+# define SHGFI_ADDOVERLAYS 0x000000020
#endif
QT_BEGIN_NAMESPACE
@@ -179,7 +185,6 @@ QFileIconProvider::QFileIconProvider()
QFileIconProvider::~QFileIconProvider()
{
- delete d_ptr;
}
/*!
@@ -263,9 +268,9 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const
}
if (pixmap.isNull()) {
#ifndef Q_OS_WINCE
- pixmap = convertHIconToPixmap(info.hIcon);
+ pixmap = QPixmap::fromWinHICON(info.hIcon);
#else
- pixmap = convertHIconToPixmap(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL));
+ pixmap = QPixmap::fromWinHICON(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL));
#endif
if (!pixmap.isNull()) {
retIcon.addPixmap(pixmap);
@@ -293,9 +298,9 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const
key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
}
#ifndef Q_OS_WINCE
- pixmap = convertHIconToPixmap(info.hIcon);
+ pixmap = QPixmap::fromWinHICON(info.hIcon);
#else
- pixmap = convertHIconToPixmap(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL), true);
+ pixmap = QPixmap::fromWinHICON(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL));
#endif
if (!pixmap.isNull()) {
retIcon.addPixmap(pixmap);
@@ -380,6 +385,19 @@ QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const
QIcon QFileIconProvider::icon(const QFileInfo &info) const
{
Q_D(const QFileIconProvider);
+
+ QIcon platformIcon = qt_guiPlatformPlugin()->fileSystemIcon(info);
+ if (!platformIcon.isNull())
+ return platformIcon;
+
+#if defined(Q_WS_X11) && !defined(QT_NO_STYLE_GTK)
+ if (X11->desktopEnvironment == DE_GNOME) {
+ QIcon gtkIcon = QGtkStylePrivate::getFilesystemIcon(info);
+ if (!gtkIcon.isNull())
+ return gtkIcon;
+ }
+#endif
+
#ifdef Q_WS_MAC
QIcon retIcon = d->getMacIcon(info);
if (!retIcon.isNull())
diff --git a/src/gui/itemviews/qfileiconprovider.h b/src/gui/itemviews/qfileiconprovider.h
index 8bb05b16f..70a1de962 100644
--- a/src/gui/itemviews/qfileiconprovider.h
+++ b/src/gui/itemviews/qfileiconprovider.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -42,8 +42,9 @@
#ifndef QFILEICONPROVIDER_H
#define QFILEICONPROVIDER_H
-#include <QtGui/qicon.h>
#include <QtCore/qfileinfo.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtGui/qicon.h>
QT_BEGIN_HEADER
@@ -67,7 +68,7 @@ public:
private:
Q_DECLARE_PRIVATE(QFileIconProvider)
- QFileIconProviderPrivate *d_ptr;
+ QScopedPointer<QFileIconProviderPrivate> d_ptr;
Q_DISABLE_COPY(QFileIconProvider)
};
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 96df758a6..6f0fba6a2 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -88,7 +88,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span)
item views.
\ingroup model-view
- \mainclass
+
A QHeaderView displays the headers used in item views such as the
QTableView and QTreeView classes. It takes the place of Qt3's \c QHeader
@@ -1047,7 +1047,9 @@ int QHeaderView::visualIndex(int logicalIndex) const
/*!
Returns the logicalIndex for the section at the given \a visualIndex
- position, or -1 otherwise.
+ position, or -1 if visualIndex < 0 or visualIndex >= QHeaderView::count().
+
+ Note that the visualIndex is not affected by hidden sections.
\sa visualIndex(), sectionPosition()
*/
@@ -1195,7 +1197,8 @@ QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const
{
Q_D(const QHeaderView);
int visual = visualIndex(logicalIndex);
- Q_ASSERT(visual != -1);
+ if (visual == -1)
+ return Fixed; //the default value
return d->headerSectionResizeMode(visual);
}
@@ -1416,7 +1419,7 @@ int QHeaderView::minimumSectionSize() const
int margin = style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this);
if (d->orientation == Qt::Horizontal)
return qMax(strut.width(), (fontMetrics().maxWidth() + margin));
- return qMax(strut.height(), (fontMetrics().lineSpacing() + margin));
+ return qMax(strut.height(), (fontMetrics().height() + margin));
}
return d->minimumSectionSize;
}
@@ -1910,7 +1913,6 @@ void QHeaderView::initializeSections(int start, int end)
Q_ASSERT(start >= 0);
Q_ASSERT(end >= 0);
- d->executePostedLayout();
d->invalidateCachedSizeHint();
if (end + 1 < d->sectionCount) {
@@ -1936,11 +1938,25 @@ void QHeaderView::initializeSections(int start, int end)
d->sectionCount = end + 1;
if (!d->logicalIndices.isEmpty()) {
- d->logicalIndices.resize(d->sectionCount);
- d->visualIndices.resize(d->sectionCount);
- for (int i = start; i < d->sectionCount; ++i){
- d->logicalIndices[i] = i;
- d->visualIndices[i] = i;
+ if (oldCount <= d->sectionCount) {
+ d->logicalIndices.resize(d->sectionCount);
+ d->visualIndices.resize(d->sectionCount);
+ for (int i = oldCount; i < d->sectionCount; ++i) {
+ d->logicalIndices[i] = i;
+ d->visualIndices[i] = i;
+ }
+ } else {
+ int j = 0;
+ for (int i = 0; i < oldCount; ++i) {
+ int v = d->logicalIndices.at(i);
+ if (v < d->sectionCount) {
+ d->logicalIndices[j] = v;
+ d->visualIndices[v] = j;
+ j++;
+ }
+ }
+ d->logicalIndices.resize(d->sectionCount);
+ d->visualIndices.resize(d->sectionCount);
}
}
@@ -2393,7 +2409,12 @@ bool QHeaderView::viewportEvent(QEvent *e)
d->state = QHeaderViewPrivate::NoState;
d->pressed = d->section = d->target = -1;
d->updateSectionIndicator(d->section, -1);
- }
+ break; }
+ case QEvent::Wheel: {
+ QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea *>(parentWidget());
+ if (asa)
+ return QApplication::sendEvent(asa->viewport(), e);
+ break; }
default:
break;
}
@@ -2513,6 +2534,8 @@ QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const
Q_D(const QHeaderView);
Q_ASSERT(logicalIndex >= 0);
+ ensurePolished();
+
// use SizeHintRole
QVariant variant = d->model->headerData(logicalIndex, d->orientation, Qt::SizeHintRole);
if (variant.isValid())
@@ -2821,16 +2844,12 @@ void QHeaderViewPrivate::setupSectionIndicator(int section, int position)
sectionIndicator = new QLabel(viewport);
}
- int x, y, w, h;
+ int w, h;
int p = q->sectionViewportPosition(section);
if (orientation == Qt::Horizontal) {
- x = p;
- y = 0;
w = q->sectionSize(section);
h = viewport->height();
} else {
- x = 0;
- y = p;
w = viewport->width();
h = q->sectionSize(section);
}
@@ -3561,7 +3580,7 @@ bool QHeaderViewPrivate::read(QDataStream &in)
in >> minimumSectionSize;
in >> align;
- defaultAlignment = (Qt::Alignment)align;
+ defaultAlignment = Qt::Alignment(align);
in >> global;
globalResizeMode = (QHeaderView::ResizeMode)global;
diff --git a/src/gui/itemviews/qheaderview.h b/src/gui/itemviews/qheaderview.h
index 99f85b8a6..0319d7466 100644
--- a/src/gui/itemviews/qheaderview.h
+++ b/src/gui/itemviews/qheaderview.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qheaderview_p.h b/src/gui/itemviews/qheaderview_p.h
index ffccce7f0..34c825456 100644
--- a/src/gui/itemviews/qheaderview_p.h
+++ b/src/gui/itemviews/qheaderview_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index 1e36f7245..3e00dba9f 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -185,7 +185,7 @@ QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const
data items from a model.
\ingroup model-view
- \mainclass
+
QItemDelegate can be used to provide custom display features and editor
widgets for item views based on QAbstractItemView subclasses. Using a
@@ -255,7 +255,7 @@ QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const
\row \o \l Qt::BackgroundRole \o QBrush
\row \o \l Qt::BackgroundColorRole \o QColor (obsolete; use Qt::BackgroundRole instead)
\row \o \l Qt::CheckStateRole \o Qt::CheckState
- \row \o \l Qt::DecorationRole \o QIcon and QColor
+ \row \o \l Qt::DecorationRole \o QIcon, QPixmap and QColor
\row \o \l Qt::DisplayRole \o QString and types with a string representation
\row \o \l Qt::EditRole \o See QItemEditorFactory for details
\row \o \l Qt::FontRole \o QFont
@@ -1059,7 +1059,7 @@ QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette,
painter.end();
QPixmap selected = QPixmap(QPixmap::fromImage(img));
- int n = (img.numBytes() >> 10) + 1;
+ int n = (img.byteCount() >> 10) + 1;
if (QPixmapCache::cacheLimit() < n)
QPixmapCache::setCacheLimit(n);
@@ -1327,7 +1327,7 @@ QStyleOptionViewItem QItemDelegate::setOptions(const QModelIndex &index,
// set text alignment
value = index.data(Qt::TextAlignmentRole);
if (value.isValid())
- opt.displayAlignment = (Qt::Alignment)value.toInt();
+ opt.displayAlignment = Qt::Alignment(value.toInt());
// set foreground brush
value = index.data(Qt::ForegroundRole);
diff --git a/src/gui/itemviews/qitemdelegate.h b/src/gui/itemviews/qitemdelegate.h
index b61735197..ba3852248 100644
--- a/src/gui/itemviews/qitemdelegate.h
+++ b/src/gui/itemviews/qitemdelegate.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qitemeditorfactory.cpp b/src/gui/itemviews/qitemeditorfactory.cpp
index 3ec224fe1..e58444d7b 100644
--- a/src/gui/itemviews/qitemeditorfactory.cpp
+++ b/src/gui/itemviews/qitemeditorfactory.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qitemeditorfactory.h b/src/gui/itemviews/qitemeditorfactory.h
index 70eb59e4b..7303d241b 100644
--- a/src/gui/itemviews/qitemeditorfactory.h
+++ b/src/gui/itemviews/qitemeditorfactory.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qitemeditorfactory_p.h b/src/gui/itemviews/qitemeditorfactory_p.h
index 378549571..c7e617cbb 100644
--- a/src/gui/itemviews/qitemeditorfactory_p.h
+++ b/src/gui/itemviews/qitemeditorfactory_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index 98810a04e..2e4a6021d 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -573,6 +573,7 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
int start, int end)
{
Q_Q(QItemSelectionModel);
+ finalize();
// update current index
if (currentIndex.isValid() && parent == currentIndex.parent()
@@ -591,33 +592,31 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
}
QItemSelection deselected;
- QItemSelection::iterator it = currentSelection.begin();
- while (it != currentSelection.end()) {
+ QItemSelection::iterator it = ranges.begin();
+ while (it != ranges.end()) {
if (it->topLeft().parent() != parent) { // Check parents until reaching root or contained in range
QModelIndex itParent = it->topLeft().parent();
while (itParent.isValid() && itParent.parent() != parent)
itParent = itParent.parent();
- if (parent.isValid() && start <= itParent.row() && itParent.row() <= end) {
+ if (itParent.isValid() && start <= itParent.row() && itParent.row() <= end) {
deselected.append(*it);
- it = currentSelection.erase(it);
+ it = ranges.erase(it);
} else {
++it;
}
} else if (start <= it->bottom() && it->bottom() <= end // Full inclusion
&& start <= it->top() && it->top() <= end) {
deselected.append(*it);
- it = currentSelection.erase(it);
+ it = ranges.erase(it);
} else if (start <= it->top() && it->top() <= end) { // Top intersection
deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->left(), it->parent())));
- it = currentSelection.insert(it, QItemSelectionRange(model->index(end + 1, it->left(), it->parent()),
- it->bottomRight()));
- it = currentSelection.erase(++it);
+ *it = QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), it->bottomRight());
+ ++it;
} else if (start <= it->bottom() && it->bottom() <= end) { // Bottom intersection
deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight()));
- it = currentSelection.insert(it, QItemSelectionRange(it->topLeft(),
- model->index(start - 1, it->right(), it->parent())));
- it = currentSelection.erase(++it);
+ *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent()));
+ ++it;
} else {
if (it->top() < start && end < it->bottom()) // Middle intersection (do nothing)
deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()),
@@ -626,7 +625,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
}
}
- emit q->selectionChanged(QItemSelection(), deselected);
+ if (!deselected.isEmpty())
+ emit q->selectionChanged(QItemSelection(), deselected);
}
/*!
@@ -730,18 +730,20 @@ void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged()
savedPersistentIndexes.clear();
savedPersistentCurrentIndexes.clear();
- // special case for when all indexes are selected
+ // optimisation for when all indexes are selected
+ // (only if there is lots of items (1000) because this is not entirely correct)
if (ranges.isEmpty() && currentSelection.count() == 1) {
QItemSelectionRange range = currentSelection.first();
QModelIndex parent = range.parent();
- if (range.top() == 0
+ tableRowCount = model->rowCount(parent);
+ tableColCount = model->columnCount(parent);
+ if (tableRowCount * tableColCount > 1000
+ && range.top() == 0
&& range.left() == 0
- && range.bottom() == model->rowCount(parent) - 1
- && range.right() == model->columnCount(parent) - 1) {
+ && range.bottom() == tableRowCount - 1
+ && range.right() == tableColCount - 1) {
tableSelected = true;
tableParent = parent;
- tableColCount = model->columnCount(parent);
- tableRowCount = model->rowCount(parent);
return;
}
}
@@ -1586,7 +1588,8 @@ void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelectio
}
}
- emit selectionChanged(selected, deselected);
+ if (!selected.isEmpty() || !deselected.isEmpty())
+ emit selectionChanged(selected, deselected);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/itemviews/qitemselectionmodel.h b/src/gui/itemviews/qitemselectionmodel.h
index 21b28b95c..a5b09b37b 100644
--- a/src/gui/itemviews/qitemselectionmodel.h
+++ b/src/gui/itemviews/qitemselectionmodel.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/gui/itemviews/qitemselectionmodel_p.h
index e9e6bb1f3..bbcd7aa41 100644
--- a/src/gui/itemviews/qitemselectionmodel_p.h
+++ b/src/gui/itemviews/qitemselectionmodel_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index b055d322f..d03cdd357 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -1,6 +1,7 @@
-/***************************************************************************
+/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE
\ingroup model-view
\ingroup advanced
- \mainclass
+
A QListView presents items stored in a model, either as a simple
non-hierarchical list, or as a collection of icons. This class is used
@@ -357,7 +357,7 @@ QListView::LayoutMode QListView::layoutMode() const
/*!
\property QListView::spacing
- \brief the space between items in the layout
+ \brief the space around the items in the layout
This property is the size of the empty space that is padded around
an item in the layout.
@@ -458,13 +458,13 @@ QSize QListView::gridSize() const
void QListView::setViewMode(ViewMode mode)
{
Q_D(QListView);
+ if (d->commonListView && d->viewMode == mode)
+ return;
d->viewMode = mode;
+ delete d->commonListView;
if (mode == ListMode) {
- delete d->dynamicListView;
- d->dynamicListView = 0;
- if (!d->staticListView)
- d->staticListView = new QStaticListViewBase(this, d);
+ d->commonListView = new QListModeViewBase(this, d);
if (!(d->modeProperties & QListViewPrivate::Wrap))
d->setWrapping(false);
if (!(d->modeProperties & QListViewPrivate::Spacing))
@@ -480,10 +480,7 @@ void QListView::setViewMode(ViewMode mode)
if (!(d->modeProperties & QListViewPrivate::SelectionRectVisible))
d->showElasticBand = false;
} else {
- delete d->staticListView;
- d->staticListView = 0;
- if (!d->dynamicListView)
- d->dynamicListView = new QDynamicListViewBase(this, d);
+ d->commonListView = new QIconModeViewBase(this, d);
if (!(d->modeProperties & QListViewPrivate::Wrap))
d->setWrapping(true);
if (!(d->modeProperties & QListViewPrivate::Spacing))
@@ -547,24 +544,12 @@ void QListView::setRowHidden(int row, bool hide)
{
Q_D(QListView);
const bool hidden = d->isHidden(row);
- if (d->viewMode == ListMode) {
- if (hide && !hidden)
- d->hiddenRows.append(d->model->index(row, 0));
- else if (!hide && hidden)
- d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0)));
- d->doDelayedItemsLayout();
- } else {
- if (hide && !hidden) {
- d->dynamicListView->removeItem(row);
- d->hiddenRows.append(d->model->index(row, 0));
- } else if (!hide && hidden) {
- d->hiddenRows.remove(d->hiddenRows.indexOf(d->model->index(row, 0)));
- d->dynamicListView->insertItem(row);
- }
- if (d->resizeMode == Adjust)
- d->doDelayedItemsLayout();
- d->viewport->update();
- }
+ if (hide && !hidden)
+ d->commonListView->appendHiddenRow(row);
+ else if (!hide && hidden)
+ d->commonListView->removeHiddenRow(row);
+ d->doDelayedItemsLayout();
+ d->viewport->update();
}
/*!
@@ -573,7 +558,7 @@ void QListView::setRowHidden(int row, bool hide)
QRect QListView::visualRect(const QModelIndex &index) const
{
Q_D(const QListView);
- return d->mapToViewport(rectForIndex(index), d->viewMode == QListView::ListMode);
+ return d->mapToViewport(rectForIndex(index));
}
/*!
@@ -610,69 +595,17 @@ int QListViewPrivate::horizontalScrollToValue(const QModelIndex &index, const QR
const bool rightOf = q->isRightToLeft()
? rect.right() > area.right()
: (rect.right() > area.right()) && (rect.left() > area.left());
- int horizontalValue = hbar->value();
-
- // ScrollPerItem
- if (q->horizontalScrollMode() == QAbstractItemView::ScrollPerItem && viewMode == QListView::ListMode) {
- const QListViewItem item = indexToListViewItem(index);
- const QRect rect = q->visualRect(index);
- horizontalValue = staticListView->horizontalPerItemValue(itemIndex(item),
- horizontalValue, area.width(),
- leftOf, rightOf, isWrapping(), hint, rect.width());
- } else { // ScrollPerPixel
- if (q->isRightToLeft()) {
- if (hint == QListView::PositionAtCenter) {
- horizontalValue += ((area.width() - rect.width()) / 2) - rect.left();
- } else {
- if (leftOf)
- horizontalValue -= rect.left();
- else if (rightOf)
- horizontalValue += qMin(rect.left(), area.width() - rect.right());
- }
- } else {
- if (hint == QListView::PositionAtCenter) {
- horizontalValue += rect.left() - ((area.width()- rect.width()) / 2);
- } else {
- if (leftOf)
- horizontalValue += rect.left();
- else if (rightOf)
- horizontalValue += qMin(rect.left(), rect.right() - area.width());
- }
- }
- }
- return horizontalValue;
+ return commonListView->horizontalScrollToValue(q->visualIndex(index), hint, leftOf, rightOf, area, rect);
}
int QListViewPrivate::verticalScrollToValue(const QModelIndex &index, const QRect &rect,
QListView::ScrollHint hint) const
{
Q_Q(const QListView);
-
const QRect area = viewport->rect();
const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
const bool below = (hint == QListView::EnsureVisible && rect.bottom() > area.bottom());
-
- int verticalValue = vbar->value();
-
- // ScrollPerItem
- if (verticalScrollMode == QAbstractItemView::ScrollPerItem && viewMode == QListView::ListMode) {
- const QListViewItem item = indexToListViewItem(index);
- const QRect rect = q->visualRect(index);
- verticalValue = staticListView->verticalPerItemValue(itemIndex(item),
- verticalValue, area.height(),
- above, below, isWrapping(), hint, rect.height());
-
- } else { // ScrollPerPixel
- QRect adjusted = rect.adjusted(-spacing(), -spacing(), spacing(), spacing());
- if (hint == QListView::PositionAtTop || above)
- verticalValue += adjusted.top();
- else if (hint == QListView::PositionAtBottom || below)
- verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1);
- else if (hint == QListView::PositionAtCenter)
- verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2);
- }
-
- return verticalValue;
+ return commonListView->verticalScrollToValue(q->visualIndex(index), hint, above, below, area, rect);
}
void QListViewPrivate::selectAll(QItemSelectionModel::SelectionFlags command)
@@ -764,23 +697,12 @@ void QListView::setRootIndex(const QModelIndex &index)
Scroll the view contents by \a dx and \a dy.
*/
+
void QListView::scrollContentsBy(int dx, int dy)
{
Q_D(QListView);
-
d->delayedAutoScroll.stop(); // auto scroll was canceled by the user scrolling
-
- if (d->viewMode == ListMode)
- d->staticListView->scrollContentsBy(dx, dy);
- else if (state() == DragSelectingState)
- d->scrollElasticBandBy(isRightToLeft() ? -dx : dx, dy);
-
- d->scrollContentsBy(isRightToLeft() ? -dx : dx, dy);
-
- // update the dragged items
- if (d->viewMode == IconMode) // ### move to dynamic class
- if (!d->dynamicListView->draggedItems.isEmpty())
- d->viewport->update(d->dynamicListView->draggedItemsRect().translated(dx, dy));
+ d->commonListView->scrollContentsBy(dx, dy, d->state == QListView::DragSelectingState);
}
/*!
@@ -809,9 +731,7 @@ QSize QListView::contentsSize() const
*/
void QListView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
- Q_D(QListView);
- if (d->viewMode == IconMode)
- d->dynamicListView->dataChanged(topLeft, bottomRight);
+ d_func()->commonListView->dataChanged(topLeft, bottomRight);
QAbstractItemView::dataChanged(topLeft, bottomRight);
}
@@ -853,7 +773,7 @@ void QListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e
void QListView::mouseMoveEvent(QMouseEvent *e)
{
if (!isVisible())
- return;
+ return;
Q_D(QListView);
QAbstractItemView::mouseMoveEvent(e);
if (state() == DragSelectingState
@@ -862,7 +782,7 @@ void QListView::mouseMoveEvent(QMouseEvent *e)
&& d->selectionMode != NoSelection) {
QRect rect(d->pressedPosition, e->pos() + QPoint(horizontalOffset(), verticalOffset()));
rect = rect.normalized();
- d->viewport->update(d->mapToViewport(rect.united(d->elasticBand), d->viewMode == QListView::ListMode));
+ d->viewport->update(d->mapToViewport(rect.united(d->elasticBand)));
d->elasticBand = rect;
}
}
@@ -876,7 +796,7 @@ void QListView::mouseReleaseEvent(QMouseEvent *e)
QAbstractItemView::mouseReleaseEvent(e);
// #### move this implementation into a dynamic class
if (d->showElasticBand && d->elasticBand.isValid()) {
- d->viewport->update(d->mapToViewport(d->elasticBand, d->viewMode == QListView::ListMode));
+ d->viewport->update(d->mapToViewport(d->elasticBand));
d->elasticBand = QRect();
}
}
@@ -912,16 +832,16 @@ void QListView::resizeEvent(QResizeEvent *e)
return;
bool listWrap = (d->viewMode == ListMode) && d->wrapItemText;
- bool flowDimensionChanged = (d->flow == LeftToRight && delta.width() != 0)
- || (d->flow == TopToBottom && delta.height() != 0);
+ bool flowDimensionChanged = (d->flow == LeftToRight && delta.width() != 0)
+ || (d->flow == TopToBottom && delta.height() != 0);
// We post a delayed relayout in the following cases :
// - we're wrapping
// - the state is NoState, we're adjusting and the size has changed in the flowing direction
- if (listWrap
+ if (listWrap
|| (state() == NoState && d->resizeMode == Adjust && flowDimensionChanged)) {
- d->doDelayedItemsLayout(100); // wait 1/10 sec before starting the layout
- } else {
+ d->doDelayedItemsLayout(100); // wait 1/10 sec before starting the layout
+ } else {
QAbstractItemView::resizeEvent(e);
}
}
@@ -933,69 +853,32 @@ void QListView::resizeEvent(QResizeEvent *e)
*/
void QListView::dragMoveEvent(QDragMoveEvent *e)
{
- // ### move implementation to dynamic
Q_D(QListView);
- if (e->source() == this && d->viewMode == IconMode) {
- // the ignore by default
- e->ignore();
- if (d->canDecode(e)) {
- // get old dragged items rect
- QRect itemsRect = d->dynamicListView->itemsRect(d->dynamicListView->draggedItems);
- d->viewport->update(itemsRect.translated(d->dynamicListView->draggedItemsDelta()));
- // update position
- d->dynamicListView->draggedItemsPos = e->pos();
- // get new items rect
- d->viewport->update(itemsRect.translated(d->dynamicListView->draggedItemsDelta()));
- // set the item under the cursor to current
- QModelIndex index;
- if (d->movement == Snap) {
- QRect rect(d->dynamicListView->snapToGrid(e->pos() + d->offset()), d->gridSize());
- const QVector<QModelIndex> intersectVector = d->intersectingSet(rect);
- index = intersectVector.count() > 0
- ? intersectVector.last() : QModelIndex();
- } else {
- index = indexAt(e->pos());
- }
- // check if we allow drops here
- if (e->source() == this && d->dynamicListView->draggedItems.contains(index))
- e->accept(); // allow changing item position
- else if (d->model->flags(index) & Qt::ItemIsDropEnabled)
- e->accept(); // allow dropping on dropenabled items
- else if (!index.isValid())
- e->accept(); // allow dropping in empty areas
- }
- // do autoscrolling
- if (d->shouldAutoScroll(e->pos()))
- startAutoScroll();
- } else { // not internal
- QAbstractItemView::dragMoveEvent(e);
+ if (!d->commonListView->filterDragMoveEvent(e)) {
+ if (viewMode() == QListView::ListMode && flow() == QListView::LeftToRight)
+ static_cast<QListModeViewBase *>(d->commonListView)->dragMoveEvent(e);
+ else
+ QAbstractItemView::dragMoveEvent(e);
}
}
+
/*!
\reimp
*/
void QListView::dragLeaveEvent(QDragLeaveEvent *e)
{
- // ### move implementation to dynamic
- Q_D(QListView);
- if (d->viewMode == IconMode) {
- d->viewport->update(d->dynamicListView->draggedItemsRect()); // erase the area
- d->dynamicListView->draggedItemsPos = QPoint(-1, -1); // don't draw the dragged items
- }
- QAbstractItemView::dragLeaveEvent(e);
+ if (!d_func()->commonListView->filterDragLeaveEvent(e))
+ QAbstractItemView::dragLeaveEvent(e);
}
/*!
\reimp
*/
-void QListView::dropEvent(QDropEvent *event)
+void QListView::dropEvent(QDropEvent *e)
{
- Q_D(QListView);
- if (event->source() == this && d->viewMode == IconMode)
- internalDrop(event); // ### move to dynamic
- else
- QAbstractItemView::dropEvent(event);
+ if (!d_func()->commonListView->filterDropEvent(e))
+ QAbstractItemView::dropEvent(e);
}
/*!
@@ -1003,10 +886,7 @@ void QListView::dropEvent(QDropEvent *event)
*/
void QListView::startDrag(Qt::DropActions supportedActions)
{
- Q_D(QListView);
- if (d->viewMode == IconMode) // ### move to dynamic
- internalDrag(supportedActions);
- else
+ if (!d_func()->commonListView->filterStartDrag(supportedActions))
QAbstractItemView::startDrag(supportedActions);
}
@@ -1018,41 +898,8 @@ void QListView::startDrag(Qt::DropActions supportedActions)
*/
void QListView::internalDrop(QDropEvent *event)
{
- Q_D(QListView);
- if (d->viewMode == QListView::ListMode)
- return;
-
- // ### move to dynamic class
- QPoint offset(horizontalOffset(), verticalOffset());
- QPoint end = event->pos() + offset;
- QPoint start = d->pressedPosition;
- QPoint delta = (d->movement == Snap ?
- d->dynamicListView->snapToGrid(end)
- - d->dynamicListView->snapToGrid(start) : end - start);
- QSize contents = d->contentsSize();
- QList<QModelIndex> indexes = d->selectionModel->selectedIndexes();
- for (int i = 0; i < indexes.count(); ++i) {
- QModelIndex index = indexes.at(i);
- QRect rect = rectForIndex(index);
- d->viewport->update(d->mapToViewport(rect, d->viewMode == QListView::ListMode));
- QPoint dest = rect.topLeft() + delta;
- if (isRightToLeft())
- dest.setX(d->flipX(dest.x()) - rect.width());
- d->dynamicListView->moveItem(index.row(), dest);
- update(index);
- }
- stopAutoScroll();
- d->dynamicListView->draggedItems.clear();
- emit indexesMoved(indexes);
- event->accept(); // we have handled the event
- // if the size has not grown, we need to check if it has shrinked
- if (d->dynamicListView
- && (d->contentsSize().width() <= contents.width()
- || d->contentsSize().height() <= contents.height())) {
- d->dynamicListView->updateContentsSize();
- }
- if (d->contentsSize() != contents)
- updateGeometries();
+ // ### Qt5: remove that function
+ Q_UNUSED(event);
}
/*!
@@ -1063,31 +910,8 @@ void QListView::internalDrop(QDropEvent *event)
*/
void QListView::internalDrag(Qt::DropActions supportedActions)
{
- Q_D(QListView);
- if (d->viewMode == QListView::ListMode)
- return;
-
- // #### move to dynamic class
-
- // This function does the same thing as in QAbstractItemView::startDrag(),
- // plus adding viewitems to the draggedItems list.
- // We need these items to draw the drag items
- QModelIndexList indexes = d->selectionModel->selectedIndexes();
- if (indexes.count() > 0 ) {
- if (d->viewport->acceptDrops()) {
- QModelIndexList::ConstIterator it = indexes.constBegin();
- for (; it != indexes.constEnd(); ++it)
- if (d->model->flags(*it) & Qt::ItemIsDragEnabled
- && (*it).column() == d->column)
- d->dynamicListView->draggedItems.push_back(*it);
- }
- QDrag *drag = new QDrag(this);
- drag->setMimeData(d->model->mimeData(indexes));
- Qt::DropAction action = drag->exec(supportedActions, Qt::CopyAction);
- d->dynamicListView->draggedItems.clear();
- if (action == Qt::MoveAction)
- d->clearOrRemove();
- }
+ // ### Qt5: remove that function
+ Q_UNUSED(supportedActions);
}
#endif // QT_NO_DRAGANDDROP
@@ -1115,6 +939,7 @@ QStyleOptionViewItem QListView::viewOptions() const
return option;
}
+
/*!
\reimp
*/
@@ -1141,10 +966,20 @@ void QListView::paintEvent(QPaintEvent *e)
bool alternateBase = false;
int previousRow = -2; // trigger the alternateBase adjustment on first pass
+ int maxSize = (flow() == TopToBottom)
+ ? qMax(viewport()->size().width(), d->contentsSize().width()) - 2 * d->spacing()
+ : qMax(viewport()->size().height(), d->contentsSize().height()) - 2 * d->spacing();
+
QVector<QModelIndex>::const_iterator end = toBeRendered.constEnd();
for (QVector<QModelIndex>::const_iterator it = toBeRendered.constBegin(); it != end; ++it) {
Q_ASSERT((*it).isValid());
option.rect = visualRect(*it);
+
+ if (flow() == TopToBottom)
+ option.rect.setWidth(qMin(maxSize, option.rect.width()));
+ else
+ option.rect.setHeight(qMin(maxSize, option.rect.height()));
+
option.state = state;
if (selections && selections->isSelected(*it))
option.state |= QStyle::State_Selected;
@@ -1211,18 +1046,7 @@ void QListView::paintEvent(QPaintEvent *e)
}
#ifndef QT_NO_DRAGANDDROP
- // #### move this implementation into a dynamic class
- if (d->viewMode == IconMode)
- if (!d->dynamicListView->draggedItems.isEmpty()
- && d->viewport->rect().contains(d->dynamicListView->draggedItemsPos)) {
- QPoint delta = d->dynamicListView->draggedItemsDelta();
- painter.translate(delta.x(), delta.y());
- d->dynamicListView->drawItems(&painter, d->dynamicListView->draggedItems);
- }
- // FIXME: Until the we can provide a proper drop indicator
- // in IconMode, it makes no sense to show it
- if (d->viewMode == ListMode)
- d->paintDropIndicator(&painter);
+ d->commonListView->paintDragDrop(&painter);
#endif
#ifndef QT_NO_RUBBERBAND
@@ -1261,31 +1085,7 @@ QModelIndex QListView::indexAt(const QPoint &p) const
*/
int QListView::horizontalOffset() const
{
- Q_D(const QListView);
- // ### split into static and dynamic
- if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem && d->viewMode == ListMode) {
- if (d->isWrapping()) {
- if (d->flow == TopToBottom && !d->staticListView->segmentPositions.isEmpty()) {
- const int max = d->staticListView->segmentPositions.count() - 1;
- int currentValue = qBound(0, horizontalScrollBar()->value(), max);
- int position = d->staticListView->segmentPositions.at(currentValue);
- int maximumValue = qBound(0, horizontalScrollBar()->maximum(), max);
- int maximum = d->staticListView->segmentPositions.at(maximumValue);
- return (isRightToLeft() ? maximum - position : position);
- }
- //return 0;
- } else {
- if (d->flow == LeftToRight && !d->staticListView->flowPositions.isEmpty()) {
- int position = d->staticListView->flowPositions.at(horizontalScrollBar()->value());
- int maximum = d->staticListView->flowPositions.at(horizontalScrollBar()->maximum());
- return (isRightToLeft() ? maximum - position : position);
- }
- //return 0;
- }
- }
- return (isRightToLeft()
- ? horizontalScrollBar()->maximum() - horizontalScrollBar()->value()
- : horizontalScrollBar()->value());
+ return d_func()->commonListView->horizontalOffset();
}
/*!
@@ -1293,30 +1093,7 @@ int QListView::horizontalOffset() const
*/
int QListView::verticalOffset() const
{
- // ## split into static and dynamic
- Q_D(const QListView);
- if (verticalScrollMode() == QAbstractItemView::ScrollPerItem && d->viewMode == ListMode) {
- if (d->isWrapping()) {
- if (d->flow == LeftToRight && !d->staticListView->segmentPositions.isEmpty()) {
- int value = verticalScrollBar()->value();
- if (value >= d->staticListView->segmentPositions.count()) {
- //qWarning("QListView: Vertical scroll bar is out of bounds");
- return 0;
- }
- return d->staticListView->segmentPositions.at(value);
- }
- } else {
- if (d->flow == TopToBottom && !d->staticListView->flowPositions.isEmpty()) {
- int value = verticalScrollBar()->value();
- if (value > d->staticListView->flowPositions.count()) {
- //qWarning("QListView: Vertical scroll bar is out of bounds");
- return 0;
- }
- return d->staticListView->flowPositions.at(value) - d->spacing();
- }
- }
- }
- return verticalScrollBar()->value();
+ return d_func()->commonListView->verticalOffset();
}
/*!
@@ -1337,13 +1114,13 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
++row;
if (row >= rowCount)
return QModelIndex();
- return d->model->index(row, 0, d->root);
+ return d->model->index(row, d->column, d->root);
}
const QRect initialRect = rectForIndex(current);
QRect rect = initialRect;
if (rect.isEmpty()) {
- return d->model->index(0, 0, d->root);
+ return d->model->index(0, d->column, d->root);
}
if (d->gridSize().isValid()) rect.setSize(d->gridSize());
@@ -1374,7 +1151,9 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
}
return d->closestIndex(initialRect, intersectVector);
case MovePageUp:
- rect.moveTop(rect.top() - d->viewport->height());
+ // move current by (visibileRowCount - 1) items.
+ // rect.translate(0, -rect.height()); will happen in the switch fallthrough for MoveUp.
+ rect.moveTop(rect.top() - d->viewport->height() + 2 * rect.height());
if (rect.top() < rect.height())
rect.moveTop(rect.height());
case MovePrevious:
@@ -1400,7 +1179,9 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
}
return d->closestIndex(initialRect, intersectVector);
case MovePageDown:
- rect.moveTop(rect.top() + d->viewport->height());
+ // move current by (visibileRowCount - 1) items.
+ // rect.translate(0, rect.height()); will happen in the switch fallthrough for MoveDown.
+ rect.moveTop(rect.top() + d->viewport->height() - 2 * rect.height());
if (rect.bottom() > contents.height() - rect.height())
rect.moveBottom(contents.height() - rect.height());
case MoveNext:
@@ -1442,15 +1223,7 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
*/
QRect QListView::rectForIndex(const QModelIndex &index) const
{
- Q_D(const QListView);
- if (!d->isIndexValid(index)
- || index.parent() != d->root
- || index.column() != d->column
- || isIndexHidden(index))
- return QRect();
- d->executePostedLayout();
- QListViewItem item = d->indexToListViewItem(index);
- return d->viewItemRect(item);
+ return d_func()->rectForIndex(index);
}
/*!
@@ -1458,8 +1231,8 @@ QRect QListView::rectForIndex(const QModelIndex &index) const
Sets the contents position of the item at \a index in the model to the given
\a position.
- If the list view's movement mode is Static, this function will have no
- effect.
+ If the list view's movement mode is Static or its view mode is ListView,
+ this function will have no effect.
*/
void QListView::setPositionForIndex(const QPoint &position, const QModelIndex &index)
{
@@ -1471,15 +1244,7 @@ void QListView::setPositionForIndex(const QPoint &position, const QModelIndex &i
return;
d->executePostedLayout();
- if (index.row() >= d->dynamicListView->items.count())
- return;
- const QSize oldContents = d->contentsSize();
- update(index); // update old position
- d->dynamicListView->moveItem(index.row(), position);
- update(index); // update new position
-
- if (d->contentsSize() != oldContents)
- updateGeometries(); // update the scroll bars
+ d->commonListView->setPositionForIndex(position, index);
}
/*!
@@ -1688,7 +1453,7 @@ void QListView::doItemsLayout()
// so we set the state to expanding to avoid
// triggering another layout
QAbstractItemView::State oldState = state();
- setState(ExpandingState);
+ setState(ExpandingState);
if (d->model->columnCount(d->root) > 0) { // no columns means no contents
d->resetBatchStartRow();
if (layoutMode() == SinglePass)
@@ -1715,99 +1480,8 @@ void QListView::updateGeometries()
QModelIndex index = d->model->index(0, d->column, d->root);
QStyleOptionViewItemV4 option = d->viewOptionsV4();
QSize step = d->itemSize(option, index);
-
- QSize csize = d->contentsSize();
- QSize vsize = d->viewport->size();
- QSize max = maximumViewportSize();
- if (max.width() >= d->contentsSize().width() && max.height() >= d->contentsSize().height())
- vsize = max;
-
- // ### reorder the logic
-
- // ### split into static and dynamic
-
- const bool vertical = verticalScrollMode() == QAbstractItemView::ScrollPerItem;
- const bool horizontal = horizontalScrollMode() == QAbstractItemView::ScrollPerItem;
-
- if (d->flow == TopToBottom) {
- if (horizontal && d->isWrapping() && d->viewMode == ListMode) {
- const QVector<int> segmentPositions = d->staticListView->segmentPositions;
- const int steps = segmentPositions.count() - 1;
- if (steps > 0) {
- int pageSteps = d->staticListView->perItemScrollingPageSteps(vsize.width(),
- csize.width(),
- isWrapping());
- horizontalScrollBar()->setSingleStep(1);
- horizontalScrollBar()->setPageStep(pageSteps);
- horizontalScrollBar()->setRange(0, steps - pageSteps);
- } else {
- horizontalScrollBar()->setRange(0, 0);
- }
- } else {
- horizontalScrollBar()->setSingleStep(step.width() + d->spacing());
- horizontalScrollBar()->setPageStep(vsize.width());
- horizontalScrollBar()->setRange(0, d->contentsSize().width() - vsize.width());
- }
- if (vertical && !d->isWrapping() && d->viewMode == ListMode) {
- const QVector<int> flowPositions = d->staticListView->flowPositions;
- const int steps = flowPositions.count() - 1;
- if (steps > 0) {
- int pageSteps = d->staticListView->perItemScrollingPageSteps(vsize.height(),
- csize.height(),
- isWrapping());
- verticalScrollBar()->setSingleStep(1);
- verticalScrollBar()->setPageStep(pageSteps);
- verticalScrollBar()->setRange(0, steps - pageSteps);
- } else {
- verticalScrollBar()->setRange(0, 0);
- }
- // } else if (vertical && d->isWrapping() && d->movement == Static) {
- // ### wrapped scrolling in flow direction
- } else {
- verticalScrollBar()->setSingleStep(step.height() + d->spacing());
- verticalScrollBar()->setPageStep(vsize.height());
- verticalScrollBar()->setRange(0, d->contentsSize().height() - vsize.height());
- }
- } else { // LeftToRight
- if (horizontal && !d->isWrapping() && d->viewMode == ListMode) {
- const QVector<int> flowPositions = d->staticListView->flowPositions;
- int steps = flowPositions.count() - 1;
- if (steps > 0) {
- int pageSteps = d->staticListView->perItemScrollingPageSteps(vsize.width(),
- csize.width(),
- isWrapping());
- horizontalScrollBar()->setSingleStep(1);
- horizontalScrollBar()->setPageStep(pageSteps);
- horizontalScrollBar()->setRange(0, steps - pageSteps);
- } else {
- horizontalScrollBar()->setRange(0, 0);
- }
- // } else if (horizontal && d->isWrapping() && d->movement == Static) {
- // ### wrapped scrolling in flow direction
- } else {
- horizontalScrollBar()->setSingleStep(step.width() + d->spacing());
- horizontalScrollBar()->setPageStep(vsize.width());
- horizontalScrollBar()->setRange(0, d->contentsSize().width() - vsize.width());
- }
- if (vertical && d->isWrapping() && d->viewMode == ListMode) {
- const QVector<int> segmentPositions = d->staticListView->segmentPositions;
- int steps = segmentPositions.count() - 1;
- if (steps > 0) {
- int pageSteps = d->staticListView->perItemScrollingPageSteps(vsize.height(),
- csize.height(),
- isWrapping());
- verticalScrollBar()->setSingleStep(1);
- verticalScrollBar()->setPageStep(pageSteps);
- verticalScrollBar()->setRange(0, steps - pageSteps);
- } else {
- verticalScrollBar()->setRange(0, 0);
- }
- } else {
- verticalScrollBar()->setSingleStep(step.height() + d->spacing());
- verticalScrollBar()->setPageStep(vsize.height());
- verticalScrollBar()->setRange(0, d->contentsSize().height() - vsize.height());
- }
- }
+ d->commonListView->updateHorizontalScrollBar(step);
+ d->commonListView->updateVerticalScrollBar(step);
}
QAbstractItemView::updateGeometries();
@@ -1956,7 +1630,7 @@ bool QListView::event(QEvent *e)
QListViewPrivate::QListViewPrivate()
: QAbstractItemViewPrivate(),
- dynamicListView(0),
+ commonListView(0),
wrap(false),
space(0),
flow(QListView::TopToBottom),
@@ -1974,21 +1648,14 @@ QListViewPrivate::QListViewPrivate()
QListViewPrivate::~QListViewPrivate()
{
- if (viewMode == QListView::ListMode)
- delete staticListView;
- else
- delete dynamicListView;
+ delete commonListView;
}
void QListViewPrivate::clear()
{
- // ### split into dynamic and static
// initialization of data structs
cachedItemSize = QSize();
- if (viewMode == QListView::ListMode)
- staticListView->clear();
- else
- dynamicListView->clear();
+ commonListView->clear();
}
void QListViewPrivate::prepareItemsLayout()
@@ -1997,7 +1664,7 @@ void QListViewPrivate::prepareItemsLayout()
clear();
//take the size as if there were scrollbar in order to prevent scrollbar to blink
- layoutBounds = QRect(QPoint(0,0), q->maximumViewportSize());
+ layoutBounds = QRect(QPoint(), q->maximumViewportSize());
int frameAroundContents = 0;
if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents))
@@ -2015,15 +1682,8 @@ void QListViewPrivate::prepareItemsLayout()
layoutBounds.adjust(0, 0, -verticalMargin, -horizontalMargin);
- int rowCount = model->rowCount(root);
- int colCount = model->columnCount(root);
- if (colCount <= 0)
- rowCount = 0; // no contents
- if (viewMode == QListView::ListMode) {
- staticListView->flowPositions.resize(rowCount);
- } else {
- dynamicListView->tree.create(qMax(rowCount - hiddenRows.count(), 0));
- }
+ int rowCount = model->columnCount(root) <= 0 ? 0 : model->rowCount(root);
+ commonListView->setRowCount(rowCount);
}
/*!
@@ -2031,7 +1691,6 @@ void QListViewPrivate::prepareItemsLayout()
*/
bool QListViewPrivate::doItemsLayout(int delta)
{
- // ### split into static and dynamic
int max = model->rowCount(root) - 1;
int first = batchStartRow();
int last = qMin(first + delta - 1, max);
@@ -2055,9 +1714,7 @@ bool QListViewPrivate::doItemsLayout(int delta)
info.flow = flow;
info.max = max;
- if (viewMode == QListView::ListMode)
- return staticListView->doBatchedItemLayout(info, max);
- return dynamicListView->doBatchedItemLayout(info, max);
+ return commonListView->doBatchedItemLayout(info, max);
}
QListViewItem QListViewPrivate::indexToListViewItem(const QModelIndex &index) const
@@ -2065,33 +1722,19 @@ QListViewItem QListViewPrivate::indexToListViewItem(const QModelIndex &index) co
if (!index.isValid() || isHidden(index.row()))
return QListViewItem();
- if (viewMode == QListView::ListMode)
- return staticListView->indexToListViewItem(index);
- return dynamicListView->indexToListViewItem(index);
-}
-
-
-int QListViewPrivate::itemIndex(const QListViewItem &item) const
-{
- if (viewMode == QListView::ListMode)
- return staticListView->itemIndex(item);
- return dynamicListView->itemIndex(item);
+ return commonListView->indexToListViewItem(index);
}
-QRect QListViewPrivate::mapToViewport(const QRect &rect, bool greedy) const
+QRect QListViewPrivate::mapToViewport(const QRect &rect, bool extend) const
{
Q_Q(const QListView);
if (!rect.isValid())
return rect;
- QRect result = rect;
- if (greedy)
- result = staticListView->mapToViewport(rect);
-
+ QRect result = extend ? commonListView->mapToViewport(rect) : rect;
int dx = -q->horizontalOffset();
int dy = -q->verticalOffset();
- result.adjust(dx, dy, dx, dy);
- return result;
+ return result.adjusted(dx, dy, dx, dy);
}
QModelIndex QListViewPrivate::closestIndex(const QRect &target,
@@ -2174,47 +1817,326 @@ QItemSelection QListViewPrivate::selection(const QRect &rect) const
return selection;
}
+#ifndef QT_NO_DRAGANDDROP
+QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const
+{
+ if (viewMode == QListView::ListMode && flow == QListView::LeftToRight)
+ return static_cast<QListModeViewBase *>(commonListView)->position(pos, rect, idx);
+ else
+ return QAbstractItemViewPrivate::position(pos, rect, idx);
+}
+#endif
+
+/*
+ * Common ListView Implementation
+*/
+
+void QCommonListViewBase::appendHiddenRow(int row)
+{
+ dd->hiddenRows.append(dd->model->index(row, 0, qq->rootIndex()));
+}
+
+void QCommonListViewBase::removeHiddenRow(int row)
+{
+ dd->hiddenRows.remove(dd->hiddenRows.indexOf(dd->model->index(row, 0, qq->rootIndex())));
+}
+
+void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step)
+{
+ horizontalScrollBar()->setSingleStep(step.width() + spacing());
+ horizontalScrollBar()->setPageStep(viewport()->width());
+ horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width() - 2 * spacing());
+}
+
+void QCommonListViewBase::updateVerticalScrollBar(const QSize &step)
+{
+ verticalScrollBar()->setSingleStep(step.height() + spacing());
+ verticalScrollBar()->setPageStep(viewport()->height());
+ verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height() - 2 * spacing());
+}
+
+void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/)
+{
+ dd->scrollContentsBy(isRightToLeft() ? -dx : dx, dy);
+}
+
+int QCommonListViewBase::verticalScrollToValue(int /*index*/, QListView::ScrollHint hint,
+ bool above, bool below, const QRect &area, const QRect &rect) const
+{
+ int verticalValue = verticalScrollBar()->value();
+ QRect adjusted = rect.adjusted(-spacing(), -spacing(), spacing(), spacing());
+ if (hint == QListView::PositionAtTop || above)
+ verticalValue += adjusted.top();
+ else if (hint == QListView::PositionAtBottom || below)
+ verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1);
+ else if (hint == QListView::PositionAtCenter)
+ verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2);
+ return verticalValue;
+}
+
+int QCommonListViewBase::horizontalOffset() const
+{
+ return (isRightToLeft() ? horizontalScrollBar()->maximum() - horizontalScrollBar()->value() : horizontalScrollBar()->value());
+}
+
+int QCommonListViewBase::horizontalScrollToValue(const int /*index*/, QListView::ScrollHint hint,
+ bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const
+{
+ int horizontalValue = horizontalScrollBar()->value();
+ if (isRightToLeft()) {
+ if (hint == QListView::PositionAtCenter) {
+ horizontalValue += ((area.width() - rect.width()) / 2) - rect.left();
+ } else {
+ if (leftOf)
+ horizontalValue -= rect.left();
+ else if (rightOf)
+ horizontalValue += qMin(rect.left(), area.width() - rect.right());
+ }
+ } else {
+ if (hint == QListView::PositionAtCenter) {
+ horizontalValue += rect.left() - ((area.width()- rect.width()) / 2);
+ } else {
+ if (leftOf)
+ horizontalValue += rect.left();
+ else if (rightOf)
+ horizontalValue += qMin(rect.left(), rect.right() - area.width());
+ }
+ }
+ return horizontalValue;
+}
+
/*
- * Static ListView Implementation
+ * ListMode ListView Implementation
*/
-int QStaticListViewBase::verticalPerItemValue(int itemIndex, int verticalValue, int areaHeight,
- bool above, bool below, bool wrap,
- QListView::ScrollHint hint, int itemHeight) const
+#ifndef QT_NO_DRAGANDDROP
+void QListModeViewBase::paintDragDrop(QPainter *painter)
{
- int value = qBound(0, verticalValue, flowPositions.count() - 1);
- if (above)
- return perItemScrollToValue(itemIndex, value, areaHeight, QListView::PositionAtTop,
- Qt::Vertical,wrap, itemHeight);
- else if (below)
- return perItemScrollToValue(itemIndex, value, areaHeight, QListView::PositionAtBottom,
- Qt::Vertical, wrap, itemHeight);
- else if (hint != QListView::EnsureVisible)
- return perItemScrollToValue(itemIndex, value, areaHeight, hint, Qt::Vertical, wrap, itemHeight);
- return value;
+ // FIXME: Until the we can provide a proper drop indicator
+ // in IconMode, it makes no sense to show it
+ dd->paintDropIndicator(painter);
+}
+
+QAbstractItemView::DropIndicatorPosition QListModeViewBase::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const
+{
+ QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport;
+ if (!dd->overwrite) {
+ const int margin = 2;
+ if (pos.x() - rect.left() < margin) {
+ r = QAbstractItemView::AboveItem; // Visually, on the left
+ } else if (rect.right() - pos.x() < margin) {
+ r = QAbstractItemView::BelowItem; // Visually, on the right
+ } else if (rect.contains(pos, true)) {
+ r = QAbstractItemView::OnItem;
+ }
+ } else {
+ QRect touchingRect = rect;
+ touchingRect.adjust(-1, -1, 1, 1);
+ if (touchingRect.contains(pos, false)) {
+ r = QAbstractItemView::OnItem;
+ }
+ }
+
+ if (r == QAbstractItemView::OnItem && (!(dd->model->flags(index) & Qt::ItemIsDropEnabled)))
+ r = pos.x() < rect.center().x() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem;
+
+ return r;
}
-int QStaticListViewBase::horizontalPerItemValue(int itemIndex, int horizontalValue, int areaWidth,
- bool leftOf, bool rightOf, bool wrap,
- QListView::ScrollHint hint, int itemWidth) const
+void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
{
- int value = qBound(0, horizontalValue, flowPositions.count() - 1);
+ if (qq->dragDropMode() == QAbstractItemView::InternalMove
+ && (event->source() != qq || !(event->possibleActions() & Qt::MoveAction)))
+ return;
+
+ // ignore by default
+ event->ignore();
+
+ QModelIndex index = qq->indexAt(event->pos());
+ dd->hover = index;
+ if (!dd->droppingOnItself(event, index)
+ && dd->canDecode(event)) {
+
+ if (index.isValid() && dd->showDropIndicator) {
+ QRect rect = qq->visualRect(index);
+ dd->dropIndicatorPosition = position(event->pos(), rect, index);
+ switch (dd->dropIndicatorPosition) {
+ case QAbstractItemView::AboveItem:
+ if (dd->isIndexDropEnabled(index.parent())) {
+ dd->dropIndicatorRect = QRect(rect.left(), rect.top(), 0, rect.height());
+ event->accept();
+ } else {
+ dd->dropIndicatorRect = QRect();
+ }
+ break;
+ case QAbstractItemView::BelowItem:
+ if (dd->isIndexDropEnabled(index.parent())) {
+ dd->dropIndicatorRect = QRect(rect.right(), rect.top(), 0, rect.height());
+ event->accept();
+ } else {
+ dd->dropIndicatorRect = QRect();
+ }
+ break;
+ case QAbstractItemView::OnItem:
+ if (dd->isIndexDropEnabled(index)) {
+ dd->dropIndicatorRect = rect;
+ event->accept();
+ } else {
+ dd->dropIndicatorRect = QRect();
+ }
+ break;
+ case QAbstractItemView::OnViewport:
+ dd->dropIndicatorRect = QRect();
+ if (dd->isIndexDropEnabled(qq->rootIndex())) {
+ event->accept(); // allow dropping in empty areas
+ }
+ break;
+ }
+ } else {
+ dd->dropIndicatorRect = QRect();
+ dd->dropIndicatorPosition = QAbstractItemView::OnViewport;
+ if (dd->isIndexDropEnabled(qq->rootIndex())) {
+ event->accept(); // allow dropping in empty areas
+ }
+ }
+ dd->viewport->update();
+ } // can decode
+
+ if (dd->shouldAutoScroll(event->pos()))
+ qq->startAutoScroll();
+}
+
+#endif //QT_NO_DRAGANDDROP
+
+void QListModeViewBase::updateVerticalScrollBar(const QSize &step)
+{
+ if (verticalScrollMode() == QAbstractItemView::ScrollPerItem
+ && ((flow() == QListView::TopToBottom && !isWrapping())
+ || (flow() == QListView::LeftToRight && isWrapping()))) {
+ const int steps = (flow() == QListView::TopToBottom ? scrollValueMap : segmentPositions).count() - 1;
+ if (steps > 0) {
+ const int pageSteps = perItemScrollingPageSteps(viewport()->height(), contentsSize.height(), isWrapping());
+ verticalScrollBar()->setSingleStep(1);
+ verticalScrollBar()->setPageStep(pageSteps);
+ verticalScrollBar()->setRange(0, steps - pageSteps);
+ } else {
+ verticalScrollBar()->setRange(0, 0);
+ }
+ // } else if (vertical && d->isWrapping() && d->movement == Static) {
+ // ### wrapped scrolling in flow direction
+ } else {
+ QCommonListViewBase::updateVerticalScrollBar(step);
+ }
+}
+
+void QListModeViewBase::updateHorizontalScrollBar(const QSize &step)
+{
+ if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem
+ && ((flow() == QListView::TopToBottom && isWrapping())
+ || (flow() == QListView::LeftToRight && !isWrapping()))) {
+ int steps = (flow() == QListView::TopToBottom ? segmentPositions : scrollValueMap).count() - 1;
+ if (steps > 0) {
+ const int pageSteps = perItemScrollingPageSteps(viewport()->width(), contentsSize.width(), isWrapping());
+ horizontalScrollBar()->setSingleStep(1);
+ horizontalScrollBar()->setPageStep(pageSteps);
+ horizontalScrollBar()->setRange(0, steps - pageSteps);
+ } else {
+ horizontalScrollBar()->setRange(0, 0);
+ }
+ } else {
+ QCommonListViewBase::updateHorizontalScrollBar(step);
+ }
+}
+
+int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hint,
+ bool above, bool below, const QRect &area, const QRect &rect) const
+{
+ if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
+ int value;
+ if (scrollValueMap.isEmpty())
+ value = 0;
+ else
+ value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()), flowPositions.count() - 1);
+ if (above)
+ hint = QListView::PositionAtTop;
+ else if (below)
+ hint = QListView::PositionAtBottom;
+ if (hint == QListView::EnsureVisible)
+ return value;
+
+ return perItemScrollToValue(index, value, area.height(), hint, Qt::Vertical, isWrapping(), rect.height());
+ }
+
+ return QCommonListViewBase::verticalScrollToValue(index, hint, above, below, area, rect);
+}
+
+int QListModeViewBase::horizontalOffset() const
+{
+ if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {
+ if (isWrapping()) {
+ if (flow() == QListView::TopToBottom && !segmentPositions.isEmpty()) {
+ const int max = segmentPositions.count() - 1;
+ int currentValue = qBound(0, horizontalScrollBar()->value(), max);
+ int position = segmentPositions.at(currentValue);
+ int maximumValue = qBound(0, horizontalScrollBar()->maximum(), max);
+ int maximum = segmentPositions.at(maximumValue);
+ return (isRightToLeft() ? maximum - position : position);
+ }
+ } else if (flow() == QListView::LeftToRight && !flowPositions.isEmpty()) {
+ int position = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->value()));
+ int maximum = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->maximum()));
+ return (isRightToLeft() ? maximum - position : position);
+ }
+ }
+ return QCommonListViewBase::horizontalOffset();
+}
+
+int QListModeViewBase::verticalOffset() const
+{
+ if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
+ if (isWrapping()) {
+ if (flow() == QListView::LeftToRight && !segmentPositions.isEmpty()) {
+ int value = verticalScrollBar()->value();
+ if (value >= segmentPositions.count())
+ return 0;
+ return segmentPositions.at(value);
+ }
+ } else if (flow() == QListView::TopToBottom && !flowPositions.isEmpty()) {
+ int value = verticalScrollBar()->value();
+ if (value > scrollValueMap.count())
+ return 0;
+ return flowPositions.at(scrollValueMap.at(value)) - spacing();
+ }
+ }
+ return QCommonListViewBase::verticalOffset();
+}
+
+int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint hint,
+ bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const
+{
+ if (horizontalScrollMode() != QAbstractItemView::ScrollPerItem)
+ return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect);
+
+ int value;
+ if (scrollValueMap.isEmpty())
+ value = 0;
+ else
+ value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1);
if (leftOf)
- return perItemScrollToValue(itemIndex, value, areaWidth, QListView::PositionAtTop,
- Qt::Horizontal, wrap, itemWidth);
+ hint = QListView::PositionAtTop;
else if (rightOf)
- return perItemScrollToValue(itemIndex, value, areaWidth, QListView::PositionAtBottom,
- Qt::Horizontal, wrap, itemWidth);
- else if (hint != QListView::EnsureVisible)
- return perItemScrollToValue(itemIndex, value, areaWidth, hint, Qt::Horizontal, wrap, itemWidth);
- return value;
+ hint = QListView::PositionAtBottom;
+ if (hint == QListView::EnsureVisible)
+ return value;
+
+ return perItemScrollToValue(index, value, area.width(), hint, Qt::Horizontal, isWrapping(), rect.width());
}
-void QStaticListViewBase::scrollContentsBy(int &dx, int &dy)
+void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
{
// ### reorder this logic
- const int verticalValue = verticalScrollBarValue();
- const int horizontalValue = horizontalScrollBarValue();
+ const int verticalValue = verticalScrollBar()->value();
+ const int horizontalValue = horizontalScrollBar()->value();
const bool vertical = (verticalScrollMode() == QAbstractItemView::ScrollPerItem);
const bool horizontal = (horizontalScrollMode() == QAbstractItemView::ScrollPerItem);
@@ -2242,20 +2164,21 @@ void QStaticListViewBase::scrollContentsBy(int &dx, int &dy)
if (vertical && flow() == QListView::TopToBottom && dy != 0) {
int currentValue = qBound(0, verticalValue, max);
int previousValue = qBound(0, currentValue + dy, max);
- int currentCoordinate = flowPositions.at(currentValue);
- int previousCoordinate = flowPositions.at(previousValue);
+ int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue));
+ int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue));
dy = previousCoordinate - currentCoordinate;
} else if (horizontal && flow() == QListView::LeftToRight && dx != 0) {
int currentValue = qBound(0, horizontalValue, max);
int previousValue = qBound(0, currentValue + dx, max);
- int currentCoordinate = flowPositions.at(currentValue);
- int previousCoordinate = flowPositions.at(previousValue);
+ int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue));
+ int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue));
dx = previousCoordinate - currentCoordinate;
}
}
+ QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand);
}
-bool QStaticListViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
+bool QListModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
{
doStaticLayout(info);
if (batchStartRow > max) { // stop items layout
@@ -2267,7 +2190,7 @@ bool QStaticListViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, i
return false; // not done
}
-QListViewItem QStaticListViewBase::indexToListViewItem(const QModelIndex &index) const
+QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) const
{
if (flowPositions.isEmpty()
|| segmentPositions.isEmpty()
@@ -2303,7 +2226,7 @@ QListViewItem QStaticListViewBase::indexToListViewItem(const QModelIndex &index)
return QListViewItem(QRect(pos, size), index.row());
}
-QPoint QStaticListViewBase::initStaticLayout(const QListViewLayoutInfo &info)
+QPoint QListModeViewBase::initStaticLayout(const QListViewLayoutInfo &info)
{
int x, y;
if (info.first == 0) {
@@ -2311,6 +2234,7 @@ QPoint QStaticListViewBase::initStaticLayout(const QListViewLayoutInfo &info)
segmentPositions.clear();
segmentStartRows.clear();
segmentExtents.clear();
+ scrollValueMap.clear();
x = info.bounds.left() + info.spacing;
y = info.bounds.top() + info.spacing;
segmentPositions.append(info.flow == QListView::LeftToRight ? y : x);
@@ -2338,7 +2262,7 @@ QPoint QStaticListViewBase::initStaticLayout(const QListViewLayoutInfo &info)
/*!
\internal
*/
-void QStaticListViewBase::doStaticLayout(const QListViewLayoutInfo &info)
+void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info)
{
const bool useItemSize = !info.grid.isValid();
const QPoint topLeft = initStaticLayout(info);
@@ -2402,6 +2326,7 @@ void QStaticListViewBase::doStaticLayout(const QListViewLayoutInfo &info)
deltaSegPosition = 0;
}
// save the flow position of this item
+ scrollValueMap.append(flowPositions.count());
flowPositions.append(flowPosition);
// prepare for the next item
deltaSegPosition = qMax(deltaSegHint, deltaSegPosition);
@@ -2427,6 +2352,7 @@ void QStaticListViewBase::doStaticLayout(const QListViewLayoutInfo &info)
// if it is the last batch, save the end of the segments
if (info.last == info.max) {
segmentExtents.append(flowPosition);
+ scrollValueMap.append(flowPositions.count());
flowPositions.append(flowPosition);
segmentPositions.append(info.wrap ? segPosition + deltaSegPosition : INT_MAX);
}
@@ -2441,7 +2367,7 @@ void QStaticListViewBase::doStaticLayout(const QListViewLayoutInfo &info)
Finds the set of items intersecting with \a area.
In this function, itemsize is counted from topleft to the start of the next item.
*/
-QVector<QModelIndex> QStaticListViewBase::intersectingStaticSet(const QRect &area) const
+QVector<QModelIndex> QListModeViewBase::intersectingSet(const QRect &area) const
{
QVector<QModelIndex> ret;
int segStartPosition;
@@ -2478,39 +2404,46 @@ QVector<QModelIndex> QStaticListViewBase::intersectingStaticSet(const QRect &are
ret += index;
#if 0 // for debugging
else
- qWarning("intersectingStaticSet: row %d was invalid", row);
+ qWarning("intersectingSet: row %d was invalid", row);
#endif
}
}
return ret;
}
-int QStaticListViewBase::itemIndex(const QListViewItem &item) const
+void QListModeViewBase::dataChanged(const QModelIndex &, const QModelIndex &)
{
- return item.indexHint;
+ dd->doDelayedItemsLayout();
}
-QRect QStaticListViewBase::mapToViewport(const QRect &rect) const
+
+QRect QListModeViewBase::mapToViewport(const QRect &rect) const
{
if (isWrapping())
return rect;
// If the listview is in "listbox-mode", the items are as wide as the view.
+ // But we don't shrink the items.
QRect result = rect;
- QSize vsize = viewport()->size();
- QSize csize = contentsSize;
if (flow() == QListView::TopToBottom) {
result.setLeft(spacing());
- result.setWidth(qMax(csize.width(), vsize.width()) - 2 * spacing());
+ result.setWidth(qMax(rect.width(), qMax(contentsSize.width(), viewport()->width()) - 2 * spacing()));
} else { // LeftToRight
result.setTop(spacing());
- result.setHeight(qMax(csize.height(), vsize.height()) - 2 * spacing());
+ result.setHeight(qMax(rect.height(), qMax(contentsSize.height(), viewport()->height()) - 2 * spacing()));
}
return result;
}
-int QStaticListViewBase::perItemScrollingPageSteps(int length, int bounds, bool wrap) const
+int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wrap) const
{
- const QVector<int> positions = (wrap ? segmentPositions : flowPositions);
+ QVector<int> positions;
+ if (wrap)
+ positions = segmentPositions;
+ else if (!flowPositions.isEmpty()) {
+ positions.reserve(scrollValueMap.size());
+ foreach (int itemShown, scrollValueMap)
+ positions.append(flowPositions.at(itemShown));
+ }
if (positions.isEmpty() || bounds <= length)
return positions.count();
if (uniformItemSizes()) {
@@ -2536,7 +2469,7 @@ int QStaticListViewBase::perItemScrollingPageSteps(int length, int bounds, bool
return qMax(pageSteps, 1);
}
-int QStaticListViewBase::perItemScrollToValue(int index, int scrollValue, int viewportSize,
+int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int viewportSize,
QAbstractItemView::ScrollHint hint,
Qt::Orientation orientation, bool wrap, int itemExtent) const
{
@@ -2596,7 +2529,7 @@ int QStaticListViewBase::perItemScrollToValue(int index, int scrollValue, int vi
return scrollValue;
}
-void QStaticListViewBase::clear()
+void QListModeViewBase::clear()
{
flowPositions.clear();
segmentPositions.clear();
@@ -2608,10 +2541,175 @@ void QStaticListViewBase::clear()
}
/*
- * Dynamic ListView Implementation
+ * IconMode ListView Implementation
*/
-void QDynamicListViewBase::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+void QIconModeViewBase::setPositionForIndex(const QPoint &position, const QModelIndex &index)
+{
+ if (index.row() >= items.count())
+ return;
+ const QSize oldContents = contentsSize;
+ qq->update(index); // update old position
+ moveItem(index.row(), position);
+ qq->update(index); // update new position
+
+ if (contentsSize != oldContents)
+ dd->viewUpdateGeometries(); // update the scroll bars
+}
+
+void QIconModeViewBase::appendHiddenRow(int row)
+{
+ if (row >= 0 && row < items.count()) //remove item
+ tree.removeLeaf(items.at(row).rect(), row);
+ QCommonListViewBase::appendHiddenRow(row);
+}
+
+void QIconModeViewBase::removeHiddenRow(int row)
+{
+ QCommonListViewBase::removeHiddenRow(row);
+ if (row >= 0 && row < items.count()) //insert item
+ tree.insertLeaf(items.at(row).rect(), row);
+}
+
+#ifndef QT_NO_DRAGANDDROP
+void QIconModeViewBase::paintDragDrop(QPainter *painter)
+{
+ if (!draggedItems.isEmpty() && viewport()->rect().contains(draggedItemsPos)) {
+ //we need to draw the items that arre dragged
+ painter->translate(draggedItemsDelta());
+ QStyleOptionViewItemV4 option = viewOptions();
+ option.state &= ~QStyle::State_MouseOver;
+ QVector<QModelIndex>::const_iterator it = draggedItems.begin();
+ QListViewItem item = indexToListViewItem(*it);
+ for (; it != draggedItems.end(); ++it) {
+ item = indexToListViewItem(*it);
+ option.rect = viewItemRect(item);
+ delegate(*it)->paint(painter, option, *it);
+ }
+ }
+}
+
+bool QIconModeViewBase::filterStartDrag(Qt::DropActions supportedActions)
+{
+ // This function does the same thing as in QAbstractItemView::startDrag(),
+ // plus adding viewitems to the draggedItems list.
+ // We need these items to draw the drag items
+ QModelIndexList indexes = dd->selectionModel->selectedIndexes();
+ if (indexes.count() > 0 ) {
+ if (viewport()->acceptDrops()) {
+ QModelIndexList::ConstIterator it = indexes.constBegin();
+ for (; it != indexes.constEnd(); ++it)
+ if (dd->model->flags(*it) & Qt::ItemIsDragEnabled
+ && (*it).column() == dd->column)
+ draggedItems.push_back(*it);
+ }
+ QDrag *drag = new QDrag(qq);
+ drag->setMimeData(dd->model->mimeData(indexes));
+ Qt::DropAction action = drag->exec(supportedActions, Qt::CopyAction);
+ draggedItems.clear();
+ if (action == Qt::MoveAction)
+ dd->clearOrRemove();
+ }
+ return true;
+}
+
+bool QIconModeViewBase::filterDropEvent(QDropEvent *e)
+{
+ if (e->source() != qq)
+ return false;
+
+ const QSize contents = contentsSize;
+ QPoint offset(horizontalOffset(), verticalOffset());
+ QPoint end = e->pos() + offset;
+ QPoint start = dd->pressedPosition;
+ QPoint delta = (dd->movement == QListView::Snap ? snapToGrid(end) - snapToGrid(start) : end - start);
+ QList<QModelIndex> indexes = dd->selectionModel->selectedIndexes();
+ for (int i = 0; i < indexes.count(); ++i) {
+ QModelIndex index = indexes.at(i);
+ QRect rect = dd->rectForIndex(index);
+ viewport()->update(dd->mapToViewport(rect, false));
+ QPoint dest = rect.topLeft() + delta;
+ if (qq->isRightToLeft())
+ dest.setX(dd->flipX(dest.x()) - rect.width());
+ moveItem(index.row(), dest);
+ qq->update(index);
+ }
+ dd->stopAutoScroll();
+ draggedItems.clear();
+ dd->emitIndexesMoved(indexes);
+ e->accept(); // we have handled the event
+ // if the size has not grown, we need to check if it has shrinked
+ if (contentsSize != contents) {
+ if ((contentsSize.width() <= contents.width()
+ || contentsSize.height() <= contents.height())) {
+ updateContentsSize();
+ }
+ dd->viewUpdateGeometries();
+ }
+ return true;
+}
+
+bool QIconModeViewBase::filterDragLeaveEvent(QDragLeaveEvent *e)
+{
+ viewport()->update(draggedItemsRect()); // erase the area
+ draggedItemsPos = QPoint(-1, -1); // don't draw the dragged items
+ return QCommonListViewBase::filterDragLeaveEvent(e);
+}
+
+bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e)
+{
+ if (e->source() != qq || !dd->canDecode(e))
+ return false;
+
+ // ignore by default
+ e->ignore();
+ // get old dragged items rect
+ QRect itemsRect = this->itemsRect(draggedItems);
+ viewport()->update(itemsRect.translated(draggedItemsDelta()));
+ // update position
+ draggedItemsPos = e->pos();
+ // get new items rect
+ viewport()->update(itemsRect.translated(draggedItemsDelta()));
+ // set the item under the cursor to current
+ QModelIndex index;
+ if (movement() == QListView::Snap) {
+ QRect rect(snapToGrid(e->pos() + offset()), gridSize());
+ const QVector<QModelIndex> intersectVector = intersectingSet(rect);
+ index = intersectVector.count() > 0 ? intersectVector.last() : QModelIndex();
+ } else {
+ index = qq->indexAt(e->pos());
+ }
+ // check if we allow drops here
+ if (draggedItems.contains(index))
+ e->accept(); // allow changing item position
+ else if (dd->model->flags(index) & Qt::ItemIsDropEnabled)
+ e->accept(); // allow dropping on dropenabled items
+ else if (!index.isValid())
+ e->accept(); // allow dropping in empty areas
+
+ // the event was treated. do autoscrolling
+ if (dd->shouldAutoScroll(e->pos()))
+ dd->startAutoScroll();
+ return true;
+}
+#endif // QT_NO_DRAGANDDROP
+
+void QIconModeViewBase::setRowCount(int rowCount)
+{
+ tree.create(qMax(rowCount - hiddenCount(), 0));
+}
+
+void QIconModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
+{
+ if (scrollElasticBand)
+ dd->scrollElasticBandBy(isRightToLeft() ? -dx : dx, dy);
+
+ QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand);
+ if (!draggedItems.isEmpty())
+ viewport()->update(draggedItemsRect().translated(dx, dy));
+}
+
+void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
if (column() >= topLeft.column() && column() <= bottomRight.column()) {
QStyleOptionViewItemV4 option = viewOptions();
@@ -2621,23 +2719,29 @@ void QDynamicListViewBase::dataChanged(const QModelIndex &topLeft, const QModelI
}
}
-bool QDynamicListViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
+bool QIconModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
{
if (info.last >= items.count()) {
- createItems(info.last + 1);
+ //first we create the items
+ QStyleOptionViewItemV4 option = viewOptions();
+ for (int row = items.count(); row <= info.last; ++row) {
+ QSize size = itemSize(option, modelIndex(row));
+ QListViewItem item(QRect(0, 0, size.width(), size.height()), row); // default pos
+ items.append(item);
+ }
doDynamicLayout(info);
}
return (batchStartRow > max); // done
}
-QListViewItem QDynamicListViewBase::indexToListViewItem(const QModelIndex &index) const
+QListViewItem QIconModeViewBase::indexToListViewItem(const QModelIndex &index) const
{
if (index.isValid() && index.row() < items.count())
return items.at(index.row());
return QListViewItem();
}
-void QDynamicListViewBase::initBspTree(const QSize &contents)
+void QIconModeViewBase::initBspTree(const QSize &contents)
{
// remove all items from the tree
int leafCount = tree.leafCount();
@@ -2654,7 +2758,7 @@ void QDynamicListViewBase::initBspTree(const QSize &contents)
tree.init(QRect(0, 0, contents.width(), contents.height()), type);
}
-QPoint QDynamicListViewBase::initDynamicLayout(const QListViewLayoutInfo &info)
+QPoint QIconModeViewBase::initDynamicLayout(const QListViewLayoutInfo &info)
{
int x, y;
if (info.first == 0) {
@@ -2676,7 +2780,7 @@ QPoint QDynamicListViewBase::initDynamicLayout(const QListViewLayoutInfo &info)
/*!
\internal
*/
-void QDynamicListViewBase::doDynamicLayout(const QListViewLayoutInfo &info)
+void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info)
{
const bool useItemSize = !info.grid.isValid();
const QPoint topLeft = initDynamicLayout(info);
@@ -2710,7 +2814,7 @@ void QDynamicListViewBase::doDynamicLayout(const QListViewLayoutInfo &info)
if (moved.count() != items.count())
moved.resize(items.count());
- QRect rect(QPoint(0, 0), topLeft);
+ QRect rect(QPoint(), topLeft);
QListViewItem *item = 0;
for (int row = info.first; row <= info.last; ++row) {
item = &items[row];
@@ -2803,43 +2907,18 @@ void QDynamicListViewBase::doDynamicLayout(const QListViewLayoutInfo &info)
viewport()->update();
}
-QVector<QModelIndex> QDynamicListViewBase::intersectingDynamicSet(const QRect &area) const
+QVector<QModelIndex> QIconModeViewBase::intersectingSet(const QRect &area) const
{
- QDynamicListViewBase *that = const_cast<QDynamicListViewBase*>(this);
+ QIconModeViewBase *that = const_cast<QIconModeViewBase*>(this);
QBspTree::Data data(static_cast<void*>(that));
QVector<QModelIndex> res;
that->interSectingVector = &res;
- that->tree.climbTree(area, &QDynamicListViewBase::addLeaf, data);
+ that->tree.climbTree(area, &QIconModeViewBase::addLeaf, data);
that->interSectingVector = 0;
return res;
}
-void QDynamicListViewBase::createItems(int to)
-{
- int count = items.count();
- QSize size;
- QStyleOptionViewItemV4 option = viewOptions();
- for (int row = count; row < to; ++row) {
- size = itemSize(option, modelIndex(row));
- QListViewItem item(QRect(0, 0, size.width(), size.height()), row); // default pos
- items.append(item);
- }
-}
-
-void QDynamicListViewBase::drawItems(QPainter *painter, const QVector<QModelIndex> &indexes) const
-{
- QStyleOptionViewItemV4 option = viewOptions();
- option.state &= ~QStyle::State_MouseOver;
- QVector<QModelIndex>::const_iterator it = indexes.begin();
- QListViewItem item = indexToListViewItem(*it);
- for (; it != indexes.end(); ++it) {
- item = indexToListViewItem(*it);
- option.rect = viewItemRect(item);
- delegate(*it)->paint(painter, option, *it);
- }
-}
-
-QRect QDynamicListViewBase::itemsRect(const QVector<QModelIndex> &indexes) const
+QRect QIconModeViewBase::itemsRect(const QVector<QModelIndex> &indexes) const
{
QVector<QModelIndex>::const_iterator it = indexes.begin();
QListViewItem item = indexToListViewItem(*it);
@@ -2851,7 +2930,7 @@ QRect QDynamicListViewBase::itemsRect(const QVector<QModelIndex> &indexes) const
return rect;
}
-int QDynamicListViewBase::itemIndex(const QListViewItem &item) const
+int QIconModeViewBase::itemIndex(const QListViewItem &item) const
{
if (!item.isValid())
return -1;
@@ -2887,11 +2966,11 @@ int QDynamicListViewBase::itemIndex(const QListViewItem &item) const
return -1;
}
-void QDynamicListViewBase::addLeaf(QVector<int> &leaf, const QRect &area,
+void QIconModeViewBase::addLeaf(QVector<int> &leaf, const QRect &area,
uint visited, QBspTree::Data data)
{
QListViewItem *vi;
- QDynamicListViewBase *_this = static_cast<QDynamicListViewBase *>(data.ptr);
+ QIconModeViewBase *_this = static_cast<QIconModeViewBase *>(data.ptr);
for (int i = 0; i < leaf.count(); ++i) {
int idx = leaf.at(i);
if (idx < 0 || idx >= _this->items.count())
@@ -2907,19 +2986,7 @@ void QDynamicListViewBase::addLeaf(QVector<int> &leaf, const QRect &area,
}
}
-void QDynamicListViewBase::insertItem(int index)
-{
- if (index >= 0 && index < items.count())
- tree.insertLeaf(items.at(index).rect(), index);
-}
-
-void QDynamicListViewBase::removeItem(int index)
-{
- if (index >= 0 && index < items.count())
- tree.removeLeaf(items.at(index).rect(), index);
-}
-
-void QDynamicListViewBase::moveItem(int index, const QPoint &dest)
+void QIconModeViewBase::moveItem(int index, const QPoint &dest)
{
// does not impact on the bintree itself or the contents rect
QListViewItem *item = &items[index];
@@ -2939,14 +3006,14 @@ void QDynamicListViewBase::moveItem(int index, const QPoint &dest)
moved.setBit(index, true);
}
-QPoint QDynamicListViewBase::snapToGrid(const QPoint &pos) const
+QPoint QIconModeViewBase::snapToGrid(const QPoint &pos) const
{
int x = pos.x() - (pos.x() % gridSize().width());
int y = pos.y() - (pos.y() % gridSize().height());
return QPoint(x, y);
}
-QPoint QDynamicListViewBase::draggedItemsDelta() const
+QPoint QIconModeViewBase::draggedItemsDelta() const
{
if (movement() == QListView::Snap) {
QPoint snapdelta = QPoint((offset().x() % gridSize().width()),
@@ -2956,7 +3023,7 @@ QPoint QDynamicListViewBase::draggedItemsDelta() const
return draggedItemsPos - pressedPosition();
}
-QRect QDynamicListViewBase::draggedItemsRect() const
+QRect QIconModeViewBase::draggedItemsRect() const
{
QRect rect = itemsRect(draggedItems);
rect.translate(draggedItemsDelta());
@@ -2975,7 +3042,7 @@ void QListViewPrivate::scrollElasticBandBy(int dx, int dy)
elasticBand.moveTop(elasticBand.top() - dy);
}
-void QDynamicListViewBase::clear()
+void QIconModeViewBase::clear()
{
tree.destroy();
items.clear();
@@ -2984,7 +3051,7 @@ void QDynamicListViewBase::clear()
batchSavedDeltaSeg = 0;
}
-void QDynamicListViewBase::updateContentsSize()
+void QIconModeViewBase::updateContentsSize()
{
QRect bounding;
for (int i = 0; i < items.count(); ++i)
@@ -3037,7 +3104,7 @@ int QListView::visualIndex(const QModelIndex &index) const
Q_D(const QListView);
d->executePostedLayout();
QListViewItem itm = d->indexToListViewItem(index);
- return d->itemIndex(itm);
+ return d->commonListView->itemIndex(itm);
}
QT_END_NAMESPACE
diff --git a/src/gui/itemviews/qlistview.h b/src/gui/itemviews/qlistview.h
index 527cdf1da..7cf2fcd40 100644
--- a/src/gui/itemviews/qlistview.h
+++ b/src/gui/itemviews/qlistview.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qlistview_p.h b/src/gui/itemviews/qlistview_p.h
index 6c8d324ef..31459b07e 100644
--- a/src/gui/itemviews/qlistview_p.h
+++ b/src/gui/itemviews/qlistview_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -67,8 +67,8 @@ QT_BEGIN_NAMESPACE
class QListViewItem
{
friend class QListViewPrivate;
- friend class QStaticListViewBase;
- friend class QDynamicListViewBase;
+ friend class QListModeViewBase;
+ friend class QIconModeViewBase;
public:
inline QListViewItem()
: x(-1), y(-1), w(0), h(0), indexHint(-1), visited(0xffff) {}
@@ -120,8 +120,42 @@ class QListViewPrivate;
class QCommonListViewBase
{
public:
- inline QCommonListViewBase(QListView *q, QListViewPrivate *d) : dd(d), qq(q) {}
-
+ inline QCommonListViewBase(QListView *q, QListViewPrivate *d) : dd(d), qq(q), batchStartRow(0), batchSavedDeltaSeg(0) {}
+ virtual ~QCommonListViewBase() {}
+
+ //common interface
+ virtual int itemIndex(const QListViewItem &item) const = 0;
+ virtual QListViewItem indexToListViewItem(const QModelIndex &index) const = 0;
+ virtual bool doBatchedItemLayout(const QListViewLayoutInfo &info, int max) = 0;
+ virtual void clear() = 0;
+ virtual void setRowCount(int) = 0;
+ virtual QVector<QModelIndex> intersectingSet(const QRect &area) const = 0;
+ virtual void dataChanged(const QModelIndex &, const QModelIndex &) = 0;
+
+ virtual int horizontalScrollToValue(int index, QListView::ScrollHint hint,
+ bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const;
+ virtual int verticalScrollToValue(int index, QListView::ScrollHint hint,
+ bool above, bool below, const QRect &area, const QRect &rect) const;
+ virtual void scrollContentsBy(int dx, int dy, bool scrollElasticBand);
+ virtual QRect mapToViewport(const QRect &rect) const {return rect;}
+ virtual int horizontalOffset() const;
+ virtual int verticalOffset() const { return verticalScrollBar()->value(); }
+ virtual void updateHorizontalScrollBar(const QSize &step);
+ virtual void updateVerticalScrollBar(const QSize &step);
+ virtual void appendHiddenRow(int row);
+ virtual void removeHiddenRow(int row);
+ virtual void setPositionForIndex(const QPoint &, const QModelIndex &) { }
+
+#ifndef QT_NO_DRAGANDDROP
+ virtual void paintDragDrop(QPainter *painter) = 0;
+ virtual bool filterDragMoveEvent(QDragMoveEvent *) { return false; }
+ virtual bool filterDragLeaveEvent(QDragLeaveEvent *) { return false; }
+ virtual bool filterDropEvent(QDropEvent *) { return false; }
+ virtual bool filterStartDrag(Qt::DropActions) { return false; }
+#endif
+
+
+ //other inline members
inline int spacing() const;
inline bool isWrapping() const;
inline QSize gridSize() const;
@@ -133,8 +167,8 @@ public:
inline bool uniformItemSizes() const;
inline int column() const;
- inline int verticalScrollBarValue() const;
- inline int horizontalScrollBarValue() const;
+ inline QScrollBar *verticalScrollBar() const;
+ inline QScrollBar *horizontalScrollBar() const;
inline QListView::ScrollMode verticalScrollMode() const;
inline QListView::ScrollMode horizontalScrollMode() const;
@@ -157,110 +191,114 @@ public:
QListViewPrivate *dd;
QListView *qq;
+ QSize contentsSize;
+ int batchStartRow;
+ int batchSavedDeltaSeg;
};
-// ### rename to QListModeViewBase
-class QStaticListViewBase : public QCommonListViewBase
+class QListModeViewBase : public QCommonListViewBase
{
- friend class QListViewPrivate;
public:
- QStaticListViewBase(QListView *q, QListViewPrivate *d) : QCommonListViewBase(q, d),
- batchStartRow(0), batchSavedDeltaSeg(0), batchSavedPosition(0) {}
+ QListModeViewBase(QListView *q, QListViewPrivate *d) : QCommonListViewBase(q, d) {}
QVector<int> flowPositions;
QVector<int> segmentPositions;
QVector<int> segmentStartRows;
QVector<int> segmentExtents;
-
- QSize contentsSize;
+ QVector<int> scrollValueMap;
// used when laying out in batches
- int batchStartRow;
- int batchSavedDeltaSeg;
int batchSavedPosition;
+ //reimplementations
+ int itemIndex(const QListViewItem &item) const { return item.indexHint; }
+ QListViewItem indexToListViewItem(const QModelIndex &index) const;
bool doBatchedItemLayout(const QListViewLayoutInfo &info, int max);
+ void clear();
+ void setRowCount(int rowCount) { flowPositions.resize(rowCount); }
+ QVector<QModelIndex> intersectingSet(const QRect &area) const;
+ void dataChanged(const QModelIndex &, const QModelIndex &);
+
+ int horizontalScrollToValue(int index, QListView::ScrollHint hint,
+ bool leftOf, bool rightOf,const QRect &area, const QRect &rect) const;
+ int verticalScrollToValue(int index, QListView::ScrollHint hint,
+ bool above, bool below, const QRect &area, const QRect &rect) const;
+ void scrollContentsBy(int dx, int dy, bool scrollElasticBand);
+ QRect mapToViewport(const QRect &rect) const;
+ int horizontalOffset() const;
+ int verticalOffset() const;
+ void updateHorizontalScrollBar(const QSize &step);
+ void updateVerticalScrollBar(const QSize &step);
- QPoint initStaticLayout(const QListViewLayoutInfo &info);
- void doStaticLayout(const QListViewLayoutInfo &info);
- QVector<QModelIndex> intersectingStaticSet(const QRect &area) const;
-
- int itemIndex(const QListViewItem &item) const;
+#ifndef QT_NO_DRAGANDDROP
+ void paintDragDrop(QPainter *painter);
- int perItemScrollingPageSteps(int length, int bounds, bool wrap) const;
+ // The next two methods are to be used on LefToRight flow only.
+ // WARNING: Plenty of duplicated code from QAbstractItemView{,Private}.
+ QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;
+ void dragMoveEvent(QDragMoveEvent *e);
+#endif
+private:
+ QPoint initStaticLayout(const QListViewLayoutInfo &info);
+ void doStaticLayout(const QListViewLayoutInfo &info);
int perItemScrollToValue(int index, int value, int height,
QAbstractItemView::ScrollHint hint,
Qt::Orientation orientation, bool wrap, int extent) const;
-
- QRect mapToViewport(const QRect &rect) const;
-
- QListViewItem indexToListViewItem(const QModelIndex &index) const;
-
- void scrollContentsBy(int &dx, int &dy);
-
- int verticalPerItemValue(int itemIndex, int verticalValue, int areaHeight,
- bool above, bool below, bool wrap, QListView::ScrollHint hint, int itemHeight) const;
- int horizontalPerItemValue(int itemIndex, int horizontalValue, int areaWidth,
- bool leftOf, bool rightOf, bool wrap, QListView::ScrollHint hint, int itemWidth) const;
-
- void clear();
+ int perItemScrollingPageSteps(int length, int bounds, bool wrap) const;
};
-// ### rename to QIconModeViewBase
-class QDynamicListViewBase : public QCommonListViewBase
+class QIconModeViewBase : public QCommonListViewBase
{
- friend class QListViewPrivate;
public:
- QDynamicListViewBase(QListView *q, QListViewPrivate *d) : QCommonListViewBase(q, d),
- batchStartRow(0), batchSavedDeltaSeg(0), interSectingVector(0) {}
+ QIconModeViewBase(QListView *q, QListViewPrivate *d) : QCommonListViewBase(q, d), interSectingVector(0) {}
QBspTree tree;
QVector<QListViewItem> items;
QBitArray moved;
- QSize contentsSize;
-
QVector<QModelIndex> draggedItems; // indices to the tree.itemVector
mutable QPoint draggedItemsPos;
// used when laying out in batches
- int batchStartRow;
- int batchSavedDeltaSeg;
- QVector<QModelIndex> *interSectingVector; //used from within intersectingDynamicSet
+ QVector<QModelIndex> *interSectingVector; //used from within intersectingSet
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ //reimplementations
+ int itemIndex(const QListViewItem &item) const;
+ QListViewItem indexToListViewItem(const QModelIndex &index) const;
bool doBatchedItemLayout(const QListViewLayoutInfo &info, int max);
+ void clear();
+ void setRowCount(int rowCount);
+ QVector<QModelIndex> intersectingSet(const QRect &area) const;
+ void scrollContentsBy(int dx, int dy, bool scrollElasticBand);
+ void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void appendHiddenRow(int row);
+ void removeHiddenRow(int row);
+ void setPositionForIndex(const QPoint &position, const QModelIndex &index);
+
+#ifndef QT_NO_DRAGANDDROP
+ void paintDragDrop(QPainter *painter);
+ bool filterDragMoveEvent(QDragMoveEvent *);
+ bool filterDragLeaveEvent(QDragLeaveEvent *);
+ bool filterDropEvent(QDropEvent *e);
+ bool filterStartDrag(Qt::DropActions);
+#endif
+
+private:
void initBspTree(const QSize &contents);
QPoint initDynamicLayout(const QListViewLayoutInfo &info);
void doDynamicLayout(const QListViewLayoutInfo &info);
- QVector<QModelIndex> intersectingDynamicSet(const QRect &area) const;
-
static void addLeaf(QVector<int> &leaf, const QRect &area,
uint visited, QBspTree::Data data);
-
- void insertItem(int index);
- void removeItem(int index);
- void moveItem(int index, const QPoint &dest);
-
- int itemIndex(const QListViewItem &item) const;
-
- void createItems(int to);
- void drawItems(QPainter *painter, const QVector<QModelIndex> &indexes) const;
QRect itemsRect(const QVector<QModelIndex> &indexes) const;
-
- QPoint draggedItemsDelta() const;
QRect draggedItemsRect() const;
-
QPoint snapToGrid(const QPoint &pos) const;
-
- void scrollElasticBandBy(int dx, int dy);
-
- QListViewItem indexToListViewItem(const QModelIndex &index) const;
-
- void clear();
void updateContentsSize();
+ QPoint draggedItemsDelta() const;
+ void drawItems(QPainter *painter, const QVector<QModelIndex> &indexes) const;
+ void moveItem(int index, const QPoint &dest);
+
};
class QListViewPrivate: public QAbstractItemViewPrivate
@@ -278,23 +316,13 @@ public:
inline QVector<QModelIndex> intersectingSet(const QRect &area, bool doLayout = true) const {
if (doLayout) executePostedLayout();
QRect a = (q_func()->isRightToLeft() ? flipX(area.normalized()) : area.normalized());
- return (viewMode == QListView::ListMode) ? staticListView->intersectingStaticSet(a)
- : dynamicListView->intersectingDynamicSet(a);
+ return commonListView->intersectingSet(a);
}
- // ### FIXME:
- inline void resetBatchStartRow()
- { if (viewMode == QListView::ListMode) staticListView->batchStartRow = 0;
- else dynamicListView->batchStartRow = 0; }
- inline int batchStartRow() const
- { return (viewMode == QListView::ListMode
- ? staticListView->batchStartRow : dynamicListView->batchStartRow); }
- inline QSize contentsSize() const
- { return (viewMode == QListView::ListMode
- ? staticListView->contentsSize : dynamicListView->contentsSize); }
- inline void setContentsSize(int w, int h)
- { if (viewMode == QListView::ListMode) staticListView->contentsSize = QSize(w, h);
- else dynamicListView->contentsSize = QSize(w, h); }
+ inline void resetBatchStartRow() { commonListView->batchStartRow = 0; }
+ inline int batchStartRow() const { return commonListView->batchStartRow; }
+ inline QSize contentsSize() const { return commonListView->contentsSize; }
+ inline void setContentsSize(int w, int h) { commonListView->contentsSize = QSize(w, h); }
inline int flipX(int x) const
{ return qMax(viewport->width(), contentsSize().width()) - x; }
@@ -305,12 +333,22 @@ public:
inline QRect viewItemRect(const QListViewItem &item) const
{ if (q_func()->isRightToLeft()) return flipX(item.rect()); return item.rect(); }
- int itemIndex(const QListViewItem &item) const;
QListViewItem indexToListViewItem(const QModelIndex &index) const;
inline QModelIndex listViewItemToIndex(const QListViewItem &item) const
- { return model->index(itemIndex(item), column, root); }
+ { return model->index(commonListView->itemIndex(item), column, root); }
+
+ QRect rectForIndex(const QModelIndex &index) const
+ {
+ if (!isIndexValid(index) || index.parent() != root || index.column() != column || isHidden(index.row()))
+ return QRect();
+ executePostedLayout();
+ return viewItemRect(indexToListViewItem(index));
+ }
+
+ void viewUpdateGeometries() { q_func()->updateGeometries(); }
+
- QRect mapToViewport(const QRect &rect, bool greedy = false) const;
+ QRect mapToViewport(const QRect &rect, bool extend = true) const;
QModelIndex closestIndex(const QRect &target, const QVector<QModelIndex> &candidates) const;
QSize itemSize(const QStyleOptionViewItem &option, const QModelIndex &index) const;
@@ -324,6 +362,10 @@ public:
QItemSelection selection(const QRect &rect) const;
void selectAll(QItemSelectionModel::SelectionFlags command);
+#ifndef QT_NO_DRAGANDDROP
+ virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;
+#endif
+
inline void setGridSize(const QSize &size) { grid = size; }
inline QSize gridSize() const { return grid; }
inline void setWrapping(bool b) { wrap = b; }
@@ -351,10 +393,10 @@ public:
QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
- union {
- QDynamicListViewBase *dynamicListView;
- QStaticListViewBase *staticListView;
- };
+ void emitIndexesMoved(const QModelIndexList &indexes) { emit q_func()->indexesMoved(indexes); }
+
+
+ QCommonListViewBase *commonListView;
// ### FIXME: see if we can move the members into the dynamic/static classes
@@ -412,8 +454,8 @@ inline QPoint QCommonListViewBase::pressedPosition() const { return dd->pressedP
inline bool QCommonListViewBase::uniformItemSizes() const { return dd->uniformItemSizes; }
inline int QCommonListViewBase::column() const { return dd->column; }
-inline int QCommonListViewBase::verticalScrollBarValue() const { return qq->verticalScrollBar()->value(); }
-inline int QCommonListViewBase::horizontalScrollBarValue() const { return qq->horizontalScrollBar()->value(); }
+inline QScrollBar *QCommonListViewBase::verticalScrollBar() const { return qq->verticalScrollBar(); }
+inline QScrollBar *QCommonListViewBase::horizontalScrollBar() const { return qq->horizontalScrollBar(); }
inline QListView::ScrollMode QCommonListViewBase::verticalScrollMode() const { return qq->verticalScrollMode(); }
inline QListView::ScrollMode QCommonListViewBase::horizontalScrollMode() const { return qq->horizontalScrollMode(); }
diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp
index a1f828849..5dd1d76bb 100644
--- a/src/gui/itemviews/qlistwidget.cpp
+++ b/src/gui/itemviews/qlistwidget.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -169,6 +169,20 @@ QListWidgetItem *QListModel::take(int row)
return item;
}
+void QListModel::move(int srcRow, int dstRow)
+{
+ if (srcRow == dstRow
+ || srcRow < 0 || srcRow >= items.count()
+ || dstRow < 0 || dstRow >= items.count())
+ return;
+
+ beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow);
+ if (srcRow < dstRow)
+ --dstRow;
+ items.move(srcRow, dstRow);
+ endMoveRows();
+}
+
int QListModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : items.count();
@@ -1125,7 +1139,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
\brief The QListWidget class provides an item-based list widget.
\ingroup model-view
- \mainclass
+
QListWidget is a convenience class that provides a list view similar to the
one supplied by QListView, but with a classic item-based interface for
@@ -1432,7 +1446,8 @@ QListWidgetItem *QListWidget::currentItem() const
/*!
Sets the current item to \a item.
- Depending on the current selection mode, the item may also be selected.
+ Unless the selection mode is \l{QAbstractItemView::}{NoSelection},
+ the item is also be selected.
*/
void QListWidget::setCurrentItem(QListWidgetItem *item)
{
@@ -1803,22 +1818,15 @@ void QListWidget::dropEvent(QDropEvent *event) {
if (persIndexes.contains(topIndex))
return;
+ qSort(persIndexes); // The dropped items will remain in the same visual order.
QPersistentModelIndex dropRow = model()->index(row, col, topIndex);
- QList<QListWidgetItem *> taken;
- for (int i = 0; i < persIndexes.count(); ++i)
- taken.append(takeItem(persIndexes.at(i).row()));
-
- // insert them back in at their new positions
+ int r = row == -1 ? count() : (dropRow.row() >= 0 ? dropRow.row() : row);
for (int i = 0; i < persIndexes.count(); ++i) {
- // Either at a specific point or appended
- if (row == -1) {
- insertItem(count(), taken.takeFirst());
- } else {
- int r = dropRow.row() >= 0 ? dropRow.row() : row;
- insertItem(qMin(r, count()), taken.takeFirst());
- }
+ const QPersistentModelIndex &pIndex = persIndexes.at(i);
+ d->listModel()->move(pIndex.row(), r);
+ r = pIndex.row() + 1; // Dropped items are inserted contiguously and in the right order.
}
event->accept();
diff --git a/src/gui/itemviews/qlistwidget.h b/src/gui/itemviews/qlistwidget.h
index 9d831a0d7..2b5dd6dbe 100644
--- a/src/gui/itemviews/qlistwidget.h
+++ b/src/gui/itemviews/qlistwidget.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qlistwidget_p.h b/src/gui/itemviews/qlistwidget_p.h
index 0851e2003..b5f28e33d 100644
--- a/src/gui/itemviews/qlistwidget_p.h
+++ b/src/gui/itemviews/qlistwidget_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -77,7 +77,7 @@ public:
{ return *i2 < *i1; }
};
-class QListModel : public QAbstractListModel
+class Q_AUTOTEST_EXPORT QListModel : public QAbstractListModel
{
Q_OBJECT
public:
@@ -90,6 +90,7 @@ public:
void insert(int row, const QStringList &items);
void remove(QListWidgetItem *item);
QListWidgetItem *take(int row);
+ void move(int srcRow, int dstRow);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
diff --git a/src/gui/itemviews/qproxymodel.cpp b/src/gui/itemviews/qproxymodel.cpp
index e568c220d..8ddb04ce5 100644
--- a/src/gui/itemviews/qproxymodel.cpp
+++ b/src/gui/itemviews/qproxymodel.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qproxymodel.h b/src/gui/itemviews/qproxymodel.h
index 643aedd24..f4ed5fb6d 100644
--- a/src/gui/itemviews/qproxymodel.h
+++ b/src/gui/itemviews/qproxymodel.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qproxymodel_p.h b/src/gui/itemviews/qproxymodel_p.h
index a5702d8c1..a7b9f82db 100644
--- a/src/gui/itemviews/qproxymodel_p.h
+++ b/src/gui/itemviews/qproxymodel_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index d173efe97..fc82f3061 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -174,6 +174,7 @@ public:
const QModelIndex &source_bottom_right);
void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end);
+ void _q_sourceAboutToBeReset();
void _q_sourceReset();
void _q_sourceLayoutAboutToBeChanged();
@@ -1148,11 +1149,19 @@ void QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation or
emit q->headerDataChanged(orientation, proxy_start, proxy_end);
}
+void QSortFilterProxyModelPrivate::_q_sourceAboutToBeReset()
+{
+ Q_Q(QSortFilterProxyModel);
+ q->beginResetModel();
+ invalidatePersistentIndexes();
+ clear_mapping();
+}
+
void QSortFilterProxyModelPrivate::_q_sourceReset()
{
Q_Q(QSortFilterProxyModel);
// All internal structures are deleted in clear()
- q->reset();
+ q->endResetModel();
update_source_sort_column();
if (dynamic_sortfilter)
sort();
@@ -1463,6 +1472,8 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
Q_D(QSortFilterProxyModel);
+ beginResetModel();
+
disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
@@ -1499,6 +1510,7 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
disconnect(d->model, SIGNAL(layoutChanged()),
this, SLOT(_q_sourceLayoutChanged()));
+ disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset()));
disconnect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset()));
QAbstractProxyModel::setSourceModel(sourceModel);
@@ -1539,10 +1551,11 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
connect(d->model, SIGNAL(layoutChanged()),
this, SLOT(_q_sourceLayoutChanged()));
+ connect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset()));
connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset()));
d->clear_mapping();
- reset();
+ endResetModel();
if (d->update_source_sort_column() && d->dynamic_sortfilter)
d->sort();
}
diff --git a/src/gui/itemviews/qsortfilterproxymodel.h b/src/gui/itemviews/qsortfilterproxymodel.h
index 12baa19eb..79af6af53 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.h
+++ b/src/gui/itemviews/qsortfilterproxymodel.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -177,6 +177,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right))
Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceAboutToBeReset())
Q_PRIVATE_SLOT(d_func(), void _q_sourceReset())
Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged())
Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged())
diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp
index 168d42365..3924a412c 100644
--- a/src/gui/itemviews/qstandarditemmodel.cpp
+++ b/src/gui/itemviews/qstandarditemmodel.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -329,7 +329,6 @@ QStandardItemModelPrivate::QStandardItemModelPrivate()
*/
QStandardItemModelPrivate::~QStandardItemModelPrivate()
{
- delete root;
delete itemPrototype;
qDeleteAll(columnHeaderItems);
qDeleteAll(rowHeaderItems);
@@ -554,7 +553,7 @@ void QStandardItemModelPrivate::rowsInserted(QStandardItem *parent,
int row, int count)
{
Q_Q(QStandardItemModel);
- if (parent == root)
+ if (parent == root.data())
rowHeaderItems.insert(row, count, 0);
q->endInsertRows();
}
@@ -566,7 +565,7 @@ void QStandardItemModelPrivate::columnsInserted(QStandardItem *parent,
int column, int count)
{
Q_Q(QStandardItemModel);
- if (parent == root)
+ if (parent == root.data())
columnHeaderItems.insert(column, count, 0);
q->endInsertColumns();
}
@@ -578,7 +577,7 @@ void QStandardItemModelPrivate::rowsRemoved(QStandardItem *parent,
int row, int count)
{
Q_Q(QStandardItemModel);
- if (parent == root) {
+ if (parent == root.data()) {
for (int i = row; i < row + count; ++i) {
QStandardItem *oldItem = rowHeaderItems.at(i);
if (oldItem)
@@ -597,7 +596,7 @@ void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent,
int column, int count)
{
Q_Q(QStandardItemModel);
- if (parent == root) {
+ if (parent == root.data()) {
for (int i = column; i < column + count; ++i) {
QStandardItem *oldItem = columnHeaderItems.at(i);
if (oldItem)
@@ -778,8 +777,6 @@ QStandardItem &QStandardItem::operator=(const QStandardItem &other)
*/
QStandardItem::~QStandardItem()
{
- Q_D(QStandardItem);
- delete d;
}
/*!
@@ -790,7 +787,7 @@ QStandardItem::~QStandardItem()
QStandardItem *QStandardItem::parent() const
{
Q_D(const QStandardItem);
- if (!d->model || (d->model->d_func()->root != d->parent))
+ if (!d->model || (d->model->d_func()->root.data() != d->parent))
return d->parent;
return 0;
}
@@ -899,7 +896,7 @@ Qt::ItemFlags QStandardItem::flags() const
if (!v.isValid())
return (Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable
|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled);
- return ((Qt::ItemFlags)(v.toInt()));
+ return Qt::ItemFlags(v.toInt());
}
/*!
@@ -1900,7 +1897,7 @@ void QStandardItem::read(QDataStream &in)
in >> d->values;
qint32 flags;
in >> flags;
- setFlags((Qt::ItemFlags)flags);
+ setFlags(Qt::ItemFlags(flags));
}
/*!
@@ -2089,8 +2086,7 @@ QStandardItemModel::~QStandardItemModel()
void QStandardItemModel::clear()
{
Q_D(QStandardItemModel);
- delete d->root;
- d->root = new QStandardItem;
+ d->root.reset(new QStandardItem);
d->root->d_func()->setModel(this);
qDeleteAll(d->columnHeaderItems);
d->columnHeaderItems.clear();
@@ -2237,7 +2233,7 @@ QStandardItem *QStandardItemModel::item(int row, int column) const
QStandardItem *QStandardItemModel::invisibleRootItem() const
{
Q_D(const QStandardItemModel);
- return d->root;
+ return d->root.data();
}
/*!
@@ -2739,7 +2735,7 @@ QModelIndex QStandardItemModel::index(int row, int column, const QModelIndex &pa
bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex &parent)
{
Q_D(QStandardItemModel);
- QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root;
+ QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data();
if (item == 0)
return false;
return item->d_func()->insertColumns(column, count, QList<QStandardItem*>());
@@ -2751,7 +2747,7 @@ bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex
bool QStandardItemModel::insertRows(int row, int count, const QModelIndex &parent)
{
Q_D(QStandardItemModel);
- QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root;
+ QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data();
if (item == 0)
return false;
return item->d_func()->insertRows(row, count, QList<QStandardItem*>());
@@ -2975,7 +2971,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
Used by QStandardItemModel::dropMimeData
stream out an item and his children
*/
-static void decodeDataRecursive(QDataStream &stream, QStandardItem *item)
+void QStandardItemModelPrivate::decodeDataRecursive(QDataStream &stream, QStandardItem *item)
{
int colCount, childCount;
stream >> *item;
@@ -2986,7 +2982,7 @@ static void decodeDataRecursive(QDataStream &stream, QStandardItem *item)
while(childPos > 0) {
childPos--;
- QStandardItem *child = new QStandardItem;
+ QStandardItem *child = createItem();
decodeDataRecursive(stream, child);
item->setChild( childPos / colCount, childPos % colCount, child);
}
@@ -2999,6 +2995,7 @@ static void decodeDataRecursive(QDataStream &stream, QStandardItem *item)
bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent)
{
+ Q_D(QStandardItemModel);
// check if the action is supported
if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction))
return false;
@@ -3030,9 +3027,9 @@ bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
while (!stream.atEnd()) {
int r, c;
- QStandardItem *item = new QStandardItem;
+ QStandardItem *item = d->createItem();
stream >> r >> c;
- decodeDataRecursive(stream, item);
+ d->decodeDataRecursive(stream, item);
rows.append(r);
columns.append(c);
diff --git a/src/gui/itemviews/qstandarditemmodel.h b/src/gui/itemviews/qstandarditemmodel.h
index fdaa99799..ea8bee930 100644
--- a/src/gui/itemviews/qstandarditemmodel.h
+++ b/src/gui/itemviews/qstandarditemmodel.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -240,7 +240,7 @@ protected:
QStandardItem(const QStandardItem &other);
QStandardItem(QStandardItemPrivate &dd);
QStandardItem &operator=(const QStandardItem &other);
- QStandardItemPrivate *d_ptr;
+ QScopedPointer<QStandardItemPrivate> d_ptr;
void emitDataChanged();
diff --git a/src/gui/itemviews/qstandarditemmodel_p.h b/src/gui/itemviews/qstandarditemmodel_p.h
index 5984a5945..3f6e0ca62 100644
--- a/src/gui/itemviews/qstandarditemmodel_p.h
+++ b/src/gui/itemviews/qstandarditemmodel_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -153,7 +153,7 @@ public:
inline QStandardItem *itemFromIndex(const QModelIndex &index) const {
Q_Q(const QStandardItemModel);
if (!index.isValid())
- return root;
+ return root.data();
if (index.model() != q)
return 0;
QStandardItem *parent = static_cast<QStandardItem*>(index.internalPointer());
@@ -176,9 +176,11 @@ public:
void _q_emitItemChanged(const QModelIndex &topLeft,
const QModelIndex &bottomRight);
+ void decodeDataRecursive(QDataStream &stream, QStandardItem *item);
+
QVector<QStandardItem*> columnHeaderItems;
QVector<QStandardItem*> rowHeaderItems;
- QStandardItem *root;
+ QScopedPointer<QStandardItem> root;
const QStandardItem *itemPrototype;
int sortRole;
};
diff --git a/src/gui/itemviews/qstringlistmodel.cpp b/src/gui/itemviews/qstringlistmodel.cpp
index d57de1aae..c1004c315 100644
--- a/src/gui/itemviews/qstringlistmodel.cpp
+++ b/src/gui/itemviews/qstringlistmodel.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE
\brief The QStringListModel class provides a model that supplies strings to views.
\ingroup model-view
- \mainclass
+
QStringListModel is an editable model that can be used for simple
cases where you need to display a number of strings in a view
diff --git a/src/gui/itemviews/qstringlistmodel.h b/src/gui/itemviews/qstringlistmodel.h
index 609760439..dfbc49881 100644
--- a/src/gui/itemviews/qstringlistmodel.h
+++ b/src/gui/itemviews/qstringlistmodel.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp
index a8ea218fd..1ca03915f 100644
--- a/src/gui/itemviews/qstyleditemdelegate.cpp
+++ b/src/gui/itemviews/qstyleditemdelegate.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -112,7 +112,7 @@ public:
data items from a model.
\ingroup model-view
- \mainclass
+
\since 4.4
When displaying data from models in Qt item views, e.g., a
@@ -148,7 +148,7 @@ public:
\row \o \l Qt::BackgroundRole \o QBrush
\row \o \l Qt::BackgroundColorRole \o QColor (obsolete; use Qt::BackgroundRole instead)
\row \o \l Qt::CheckStateRole \o Qt::CheckState
- \row \o \l Qt::DecorationRole \o QIcon and QColor
+ \row \o \l Qt::DecorationRole \o QIcon, QPixmap, QImage and QColor
\row \o \l Qt::DisplayRole \o QString and types with a string representation
\row \o \l Qt::EditRole \o See QItemEditorFactory for details
\row \o \l Qt::FontRole \o QFont
@@ -323,7 +323,7 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
value = index.data(Qt::TextAlignmentRole);
if (value.isValid() && !value.isNull())
- option->displayAlignment = (Qt::Alignment)value.toInt();
+ option->displayAlignment = Qt::Alignment(value.toInt());
value = index.data(Qt::ForegroundRole);
if (qVariantCanConvert<QBrush>(value))
diff --git a/src/gui/itemviews/qstyleditemdelegate.h b/src/gui/itemviews/qstyleditemdelegate.h
index 30399eedf..dffc12b59 100644
--- a/src/gui/itemviews/qstyleditemdelegate.h
+++ b/src/gui/itemviews/qstyleditemdelegate.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index 61c2b603d..d27e693ca 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -114,10 +114,10 @@ void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height)
}
} else if (old_height > span->height()) {
//remove the span from all the subspans lists that intersect the columns not covered anymore
- Index::iterator it_y = index.lowerBound(-span->bottom());
+ Index::iterator it_y = index.lowerBound(qMin(-span->bottom(), 0));
Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list
while (-it_y.key() <= span->top() + old_height -1) {
- if(-it_y.key() != span->bottom()) {
+ if (-it_y.key() > span->bottom()) {
(*it_y).remove(-span->left());
if (it_y->isEmpty()) {
it_y = index.erase(it_y) - 1;
@@ -191,6 +191,400 @@ QList<QSpanCollection::Span *> QSpanCollection::spansInRect(int x, int y, int w,
return list.toList();
}
+#undef DEBUG_SPAN_UPDATE
+
+#ifdef DEBUG_SPAN_UPDATE
+QDebug operator<<(QDebug str, const QSpanCollection::Span &span)
+{
+ str << "(" << span.top() << "," << span.left() << "," << span.bottom() << "," << span.right() << ")";
+ return str;
+}
+#endif
+
+/** \internal
+* Updates the span collection after row insertion.
+*/
+void QSpanCollection::updateInsertedRows(int start, int end)
+{
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << Q_FUNC_INFO;
+ qDebug() << start << end;
+ qDebug() << index;
+#endif
+ if (spans.isEmpty())
+ return;
+
+ int delta = end - start + 1;
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug("Before");
+#endif
+ for (SpanList::iterator it = spans.begin(); it != spans.end(); ++it) {
+ Span *span = *it;
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << span << *span;
+#endif
+ if (span->m_bottom < start)
+ continue;
+ if (span->m_top >= start)
+ span->m_top += delta;
+ span->m_bottom += delta;
+ }
+
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug("After");
+ foreach (QSpanCollection::Span *span, spans)
+ qDebug() << span << *span;
+#endif
+
+ for (Index::iterator it_y = index.begin(); it_y != index.end(); ) {
+ int y = -it_y.key();
+ if (y < start) {
+ ++it_y;
+ continue;
+ }
+
+ index.insert(-y - delta, it_y.value());
+ it_y = index.erase(it_y);
+ }
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << index;
+#endif
+}
+
+/** \internal
+* Updates the span collection after column insertion.
+*/
+void QSpanCollection::updateInsertedColumns(int start, int end)
+{
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << Q_FUNC_INFO;
+ qDebug() << start << end;
+ qDebug() << index;
+#endif
+ if (spans.isEmpty())
+ return;
+
+ int delta = end - start + 1;
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug("Before");
+#endif
+ for (SpanList::iterator it = spans.begin(); it != spans.end(); ++it) {
+ Span *span = *it;
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << span << *span;
+#endif
+ if (span->m_right < start)
+ continue;
+ if (span->m_left >= start)
+ span->m_left += delta;
+ span->m_right += delta;
+ }
+
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug("After");
+ foreach (QSpanCollection::Span *span, spans)
+ qDebug() << span << *span;
+#endif
+
+ for (Index::iterator it_y = index.begin(); it_y != index.end(); ++it_y) {
+ SubIndex &subindex = it_y.value();
+ for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ) {
+ int x = -it.key();
+ if (x < start) {
+ ++it;
+ continue;
+ }
+ subindex.insert(-x - delta, it.value());
+ it = subindex.erase(it);
+ }
+ }
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << index;
+#endif
+}
+
+/** \internal
+* Cleans a subindex from to be deleted spans. The update argument is used
+* to move the spans inside the subindex, in case their anchor changed.
+* \return true if no span in this subindex starts at y, and should thus be deleted.
+*/
+bool QSpanCollection::cleanSpanSubIndex(QSpanCollection::SubIndex &subindex, int y, bool update)
+{
+ if (subindex.isEmpty())
+ return true;
+
+ bool should_be_deleted = true;
+ SubIndex::iterator it = subindex.end();
+ do {
+ --it;
+ int x = -it.key();
+ Span *span = it.value();
+ if (span->will_be_deleted) {
+ it = subindex.erase(it);
+ continue;
+ }
+ if (update && span->m_left != x) {
+ subindex.insert(-span->m_left, span);
+ it = subindex.erase(it);
+ }
+ if (should_be_deleted && span->m_top == y)
+ should_be_deleted = false;
+ } while (it != subindex.begin());
+
+ return should_be_deleted;
+}
+
+/** \internal
+* Updates the span collection after row removal.
+*/
+void QSpanCollection::updateRemovedRows(int start, int end)
+{
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << Q_FUNC_INFO;
+ qDebug() << start << end;
+ qDebug() << index;
+#endif
+ if (spans.isEmpty())
+ return;
+
+ SpanList spansToBeDeleted;
+ int delta = end - start + 1;
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug("Before");
+#endif
+ for (SpanList::iterator it = spans.begin(); it != spans.end(); ) {
+ Span *span = *it;
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << span << *span;
+#endif
+ if (span->m_bottom < start) {
+ ++it;
+ continue;
+ }
+ if (span->m_top < start) {
+ if (span->m_bottom <= end)
+ span->m_bottom = start - 1;
+ else
+ span->m_bottom -= delta;
+ } else {
+ if (span->m_bottom > end) {
+ if (span->m_top <= end)
+ span->m_top = start;
+ else
+ span->m_top -= delta;
+ span->m_bottom -= delta;
+ } else {
+ span->will_be_deleted = true;
+ }
+ }
+ if (span->m_top == span->m_bottom && span->m_left == span->m_right)
+ span->will_be_deleted = true;
+ if (span->will_be_deleted) {
+ spansToBeDeleted.append(span);
+ it = spans.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug("After");
+ foreach (QSpanCollection::Span *span, spans)
+ qDebug() << span << *span;
+#endif
+ if (spans.isEmpty()) {
+ qDeleteAll(spansToBeDeleted);
+ index.clear();
+ return;
+ }
+
+ Index::iterator it_y = index.end();
+ do {
+ --it_y;
+ int y = -it_y.key();
+ SubIndex &subindex = it_y.value();
+ if (y < start) {
+ if (cleanSpanSubIndex(subindex, y))
+ it_y = index.erase(it_y);
+ } else if (y >= start && y <= end) {
+ bool span_at_start = false;
+ SubIndex spansToBeMoved;
+ for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ++it) {
+ Span *span = it.value();
+ if (span->will_be_deleted)
+ continue;
+ if (!span_at_start && span->m_top == start)
+ span_at_start = true;
+ spansToBeMoved.insert(it.key(), span);
+ }
+
+ if (y == start && span_at_start)
+ subindex.clear();
+ else
+ it_y = index.erase(it_y);
+
+ if (span_at_start) {
+ Index::iterator it_start;
+ if (y == start)
+ it_start = it_y;
+ else {
+ it_start = index.find(-start);
+ if (it_start == index.end())
+ it_start = index.insert(-start, SubIndex());
+ }
+ SubIndex &start_subindex = it_start.value();
+ for (SubIndex::iterator it = spansToBeMoved.begin(); it != spansToBeMoved.end(); ++it)
+ start_subindex.insert(it.key(), it.value());
+ }
+ } else {
+ if (y == end + 1) {
+ Index::iterator it_top = index.find(-y + delta);
+ if (it_top == index.end())
+ it_top = index.insert(-y + delta, SubIndex());
+ for (SubIndex::iterator it = subindex.begin(); it != subindex.end(); ) {
+ Span *span = it.value();
+ if (!span->will_be_deleted)
+ it_top.value().insert(it.key(), span);
+ ++it;
+ }
+ } else {
+ index.insert(-y + delta, subindex);
+ }
+ it_y = index.erase(it_y);
+ }
+ } while (it_y != index.begin());
+
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << index;
+ qDebug("Deleted");
+ foreach (QSpanCollection::Span *span, spansToBeDeleted)
+ qDebug() << span << *span;
+#endif
+ qDeleteAll(spansToBeDeleted);
+}
+
+/** \internal
+* Updates the span collection after column removal.
+*/
+void QSpanCollection::updateRemovedColumns(int start, int end)
+{
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << Q_FUNC_INFO;
+ qDebug() << start << end;
+ qDebug() << index;
+#endif
+ if (spans.isEmpty())
+ return;
+
+ SpanList toBeDeleted;
+ int delta = end - start + 1;
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug("Before");
+#endif
+ for (SpanList::iterator it = spans.begin(); it != spans.end(); ) {
+ Span *span = *it;
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << span << *span;
+#endif
+ if (span->m_right < start) {
+ ++it;
+ continue;
+ }
+ if (span->m_left < start) {
+ if (span->m_right <= end)
+ span->m_right = start - 1;
+ else
+ span->m_right -= delta;
+ } else {
+ if (span->m_right > end) {
+ if (span->m_left <= end)
+ span->m_left = start;
+ else
+ span->m_left -= delta;
+ span->m_right -= delta;
+ } else {
+ span->will_be_deleted = true;
+ }
+ }
+ if (span->m_top == span->m_bottom && span->m_left == span->m_right)
+ span->will_be_deleted = true;
+ if (span->will_be_deleted) {
+ toBeDeleted.append(span);
+ it = spans.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug("After");
+ foreach (QSpanCollection::Span *span, spans)
+ qDebug() << span << *span;
+#endif
+ if (spans.isEmpty()) {
+ qDeleteAll(toBeDeleted);
+ index.clear();
+ return;
+ }
+
+ for (Index::iterator it_y = index.begin(); it_y != index.end(); ) {
+ int y = -it_y.key();
+ if (cleanSpanSubIndex(it_y.value(), y, true))
+ it_y = index.erase(it_y);
+ else
+ ++it_y;
+ }
+
+#ifdef DEBUG_SPAN_UPDATE
+ qDebug() << index;
+ qDebug("Deleted");
+ foreach (QSpanCollection::Span *span, toBeDeleted)
+ qDebug() << span << *span;
+#endif
+ qDeleteAll(toBeDeleted);
+}
+
+#ifdef QT_BUILD_INTERNAL
+/*!
+ \internal
+ Checks whether the span index structure is self-consistent, and consistent with the spans list.
+*/
+bool QSpanCollection::checkConsistency() const
+{
+ for (Index::const_iterator it_y = index.begin(); it_y != index.end(); ++it_y) {
+ int y = -it_y.key();
+ const SubIndex &subIndex = it_y.value();
+ for (SubIndex::const_iterator it = subIndex.begin(); it != subIndex.end(); ++it) {
+ int x = -it.key();
+ Span *span = it.value();
+ if (!spans.contains(span) || span->left() != x
+ || y < span->top() || y > span->bottom())
+ return false;
+ }
+ }
+
+ foreach (const Span *span, spans) {
+ if (span->width() < 1 || span->height() < 1
+ || (span->width() == 1 && span->height() == 1))
+ return false;
+ for (int y = span->top(); y <= span->bottom(); ++y) {
+ Index::const_iterator it_y = index.find(-y);
+ if (it_y == index.end()) {
+ if (y == span->top())
+ return false;
+ else
+ continue;
+ }
+ const SubIndex &subIndex = it_y.value();
+ SubIndex::const_iterator it = subIndex.find(-span->left());
+ if (it == subIndex.end() || it.value() != span)
+ return false;
+ }
+ }
+ return true;
+}
+#endif
+
class QTableCornerButton : public QAbstractButton
{
Q_OBJECT
@@ -299,6 +693,9 @@ void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan
sp->m_right = column + columnSpan - 1;
spans.updateSpan(sp, old_height);
return;
+ } else if (rowSpan == 1 && columnSpan == 1) {
+ qWarning() << "QTableView::setSpan: single cell span won't be added";
+ return;
}
sp = new QSpanCollection::Span(row, column, rowSpan, columnSpan);
spans.addSpan(sp);
@@ -423,8 +820,6 @@ void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter,
foreach (QSpanCollection::Span *span, visibleSpans) {
int row = span->top();
int col = span->left();
- if (isHidden(row, col))
- continue;
QModelIndex index = model->index(row, col, root);
if (!index.isValid())
continue;
@@ -460,6 +855,46 @@ void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter,
/*!
\internal
+ Updates spans after row insertion.
+*/
+void QTableViewPrivate::_q_updateSpanInsertedRows(const QModelIndex &parent, int start, int end)
+{
+ Q_UNUSED(parent)
+ spans.updateInsertedRows(start, end);
+}
+
+/*!
+ \internal
+ Updates spans after column insertion.
+*/
+void QTableViewPrivate::_q_updateSpanInsertedColumns(const QModelIndex &parent, int start, int end)
+{
+ Q_UNUSED(parent)
+ spans.updateInsertedColumns(start, end);
+}
+
+/*!
+ \internal
+ Updates spans after row removal.
+*/
+void QTableViewPrivate::_q_updateSpanRemovedRows(const QModelIndex &parent, int start, int end)
+{
+ Q_UNUSED(parent)
+ spans.updateRemovedRows(start, end);
+}
+
+/*!
+ \internal
+ Updates spans after column removal.
+*/
+void QTableViewPrivate::_q_updateSpanRemovedColumns(const QModelIndex &parent, int start, int end)
+{
+ Q_UNUSED(parent)
+ spans.updateRemovedColumns(start, end);
+}
+
+/*!
+ \internal
Draws a table cell.
*/
void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index)
@@ -508,7 +943,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItemV4
\ingroup model-view
\ingroup advanced
- \mainclass
+
A QTableView implements a table view that displays items from a
model. This class is used to provide standard tables that were
@@ -629,6 +1064,29 @@ QTableView::~QTableView()
void QTableView::setModel(QAbstractItemModel *model)
{
Q_D(QTableView);
+ if (model == d->model)
+ return;
+ //let's disconnect from the old model
+ if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) {
+ disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
+ this, SLOT(_q_updateSpanInsertedRows(QModelIndex,int,int)));
+ disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)),
+ this, SLOT(_q_updateSpanInsertedColumns(QModelIndex,int,int)));
+ disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_updateSpanRemovedRows(QModelIndex,int,int)));
+ disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_updateSpanRemovedColumns(QModelIndex,int,int)));
+ }
+ if (model) { //and connect to the new one
+ connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
+ this, SLOT(_q_updateSpanInsertedRows(QModelIndex,int,int)));
+ connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)),
+ this, SLOT(_q_updateSpanInsertedColumns(QModelIndex,int,int)));
+ connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_updateSpanRemovedRows(QModelIndex,int,int)));
+ connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_updateSpanRemovedColumns(QModelIndex,int,int)));
+ }
d->verticalHeader->setModel(model);
d->horizontalHeader->setModel(model);
QAbstractItemView::setModel(model);
@@ -715,6 +1173,9 @@ void QTableView::setHorizontalHeader(QHeaderView *header)
connect(d->horizontalHeader, SIGNAL(sectionHandleDoubleClicked(int)),
this, SLOT(resizeColumnToContents(int)));
connect(d->horizontalHeader, SIGNAL(geometriesChanged()), this, SLOT(updateGeometries()));
+
+ //update the sorting enabled states on the new header
+ setSortingEnabled(d->sortingEnabled);
}
/*!
@@ -1076,12 +1537,30 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
++column;
while (isRowHidden(d->logicalRow(row)) && row < bottom)
++row;
+ d->visualCursor = QPoint(column, row);
return d->model->index(d->logicalRow(row), d->logicalColumn(column), d->root);
}
- int visualRow = d->visualRow(current.row());
+ // Update visual cursor if current index has changed.
+ QPoint visualCurrent(d->visualColumn(current.column()), d->visualRow(current.row()));
+ if (visualCurrent != d->visualCursor) {
+ if (d->hasSpans()) {
+ QSpanCollection::Span span = d->span(current.row(), current.column());
+ if (span.top() > d->visualCursor.y() || d->visualCursor.y() > span.bottom()
+ || span.left() > d->visualCursor.x() || d->visualCursor.x() > span.right())
+ d->visualCursor = visualCurrent;
+ } else {
+ d->visualCursor = visualCurrent;
+ }
+ }
+
+ int visualRow = d->visualCursor.y();
+ if (visualRow > bottom)
+ visualRow = bottom;
Q_ASSERT(visualRow != -1);
- int visualColumn = d->visualColumn(current.column());
+ int visualColumn = d->visualCursor.x();
+ if (visualColumn > right)
+ visualColumn = right;
Q_ASSERT(visualColumn != -1);
if (isRightToLeft()) {
@@ -1092,22 +1571,33 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
}
switch (cursorAction) {
- case MoveUp:
+ case MoveUp: {
+ int originalRow = visualRow;
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled() && visualRow == 0)
visualRow = d->visualRow(model()->rowCount() - 1) + 1;
+ // FIXME? visualRow = bottom + 1;
#endif
- --visualRow;
- while (visualRow > 0 && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn))
+ int r = d->logicalRow(visualRow);
+ int c = d->logicalColumn(visualColumn);
+ if (r != -1 && d->hasSpans()) {
+ QSpanCollection::Span span = d->span(r, c);
+ if (span.width() > 1 || span.height() > 1)
+ visualRow = d->visualRow(span.top());
+ }
+ while (visualRow >= 0) {
--visualRow;
- if (d->hasSpans()) {
- int row = d->logicalRow(visualRow);
- QSpanCollection::Span span = d->span(row, current.column());
- visualRow = d->visualRow(span.top());
- visualColumn = d->visualColumn(span.left());
+ r = d->logicalRow(visualRow);
+ c = d->logicalColumn(visualColumn);
+ if (r == -1 || (!isRowHidden(r) && d->isCellEnabled(r, c)))
+ break;
}
+ if (visualRow < 0)
+ visualRow = originalRow;
break;
- case MoveDown:
+ }
+ case MoveDown: {
+ int originalRow = visualRow;
if (d->hasSpans()) {
QSpanCollection::Span span = d->span(current.row(), current.column());
visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height()));
@@ -1116,71 +1606,106 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
if (QApplication::keypadNavigationEnabled() && visualRow >= bottom)
visualRow = -1;
#endif
- ++visualRow;
- while (visualRow < bottom && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn))
+ int r = d->logicalRow(visualRow);
+ int c = d->logicalColumn(visualColumn);
+ if (r != -1 && d->hasSpans()) {
+ QSpanCollection::Span span = d->span(r, c);
+ if (span.width() > 1 || span.height() > 1)
+ visualRow = d->visualRow(d->rowSpanEndLogical(span.top(), span.height()));
+ }
+ while (visualRow <= bottom) {
++visualRow;
- if (d->hasSpans()) {
- int row = d->logicalRow(visualRow);
- QSpanCollection::Span span = d->span(row, current.column());
- visualColumn = d->visualColumn(span.left());
+ r = d->logicalRow(visualRow);
+ c = d->logicalColumn(visualColumn);
+ if (r == -1 || (!isRowHidden(r) && d->isCellEnabled(r, c)))
+ break;
}
+ if (visualRow > bottom)
+ visualRow = originalRow;
break;
- case MovePrevious: {
- int left = 0;
- while (d->isVisualColumnHiddenOrDisabled(visualRow, left) && left < right)
- ++left;
- if (visualColumn == left) {
- visualColumn = right;
- int top = 0;
- while (top < bottom && d->isVisualRowHiddenOrDisabled(top, visualColumn))
- ++top;
- if (visualRow == top)
+ }
+ case MovePrevious:
+ case MoveLeft: {
+ int originalRow = visualRow;
+ int originalColumn = visualColumn;
+ bool firstTime = true;
+ bool looped = false;
+ bool wrapped = false;
+ do {
+ int r = d->logicalRow(visualRow);
+ int c = d->logicalColumn(visualColumn);
+ if (firstTime && c != -1 && d->hasSpans()) {
+ firstTime = false;
+ QSpanCollection::Span span = d->span(r, c);
+ if (span.width() > 1 || span.height() > 1)
+ visualColumn = d->visualColumn(span.left());
+ }
+ while (visualColumn >= 0) {
+ --visualColumn;
+ r = d->logicalRow(visualRow);
+ c = d->logicalColumn(visualColumn);
+ if (r == -1 || c == -1 || (!isRowHidden(r) && !isColumnHidden(c) && d->isCellEnabled(r, c)))
+ break;
+ if (wrapped && (originalRow < visualRow || (originalRow == visualRow && originalColumn <= visualColumn))) {
+ looped = true;
+ break;
+ }
+ }
+ if (cursorAction == MoveLeft || visualColumn >= 0)
+ break;
+ visualColumn = right + 1;
+ if (visualRow == 0) {
+ wrapped = true;
visualRow = bottom;
- else
- --visualRow;
- while (visualRow > 0 && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn))
+ } else {
--visualRow;
- break;
- } // else MoveLeft
- }
- case MoveLeft:
- --visualColumn;
- while (visualColumn > 0 && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn))
- --visualColumn;
- if (d->hasSpans()) {
- int column = d->logicalColumn(visualColumn);
- QSpanCollection::Span span = d->span(current.row(), column);
- visualRow = d->visualRow(span.top());
- visualColumn = d->visualColumn(span.left());
- }
+ }
+ } while (!looped);
+ if (visualColumn < 0)
+ visualColumn = originalColumn;
break;
+ }
case MoveNext:
- if (visualColumn == right) {
- visualColumn = 0;
- while (visualColumn < right && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn))
+ case MoveRight: {
+ int originalRow = visualRow;
+ int originalColumn = visualColumn;
+ bool firstTime = true;
+ bool looped = false;
+ bool wrapped = false;
+ do {
+ int r = d->logicalRow(visualRow);
+ int c = d->logicalColumn(visualColumn);
+ if (firstTime && c != -1 && d->hasSpans()) {
+ firstTime = false;
+ QSpanCollection::Span span = d->span(r, c);
+ if (span.width() > 1 || span.height() > 1)
+ visualColumn = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width()));
+ }
+ while (visualColumn <= right) {
++visualColumn;
- if (visualRow == bottom)
+ r = d->logicalRow(visualRow);
+ c = d->logicalColumn(visualColumn);
+ if (r == -1 || c == -1 || (!isRowHidden(r) && !isColumnHidden(c) && d->isCellEnabled(r, c)))
+ break;
+ if (wrapped && (originalRow > visualRow || (originalRow == visualRow && originalColumn >= visualColumn))) {
+ looped = true;
+ break;
+ }
+ }
+ if (cursorAction == MoveRight || visualColumn <= right)
+ break;
+ visualColumn = -1;
+ if (visualRow == bottom) {
+ wrapped = true;
visualRow = 0;
- else
- ++visualRow;
- while (visualRow < bottom && d->isVisualRowHiddenOrDisabled(visualRow, visualColumn))
+ } else {
++visualRow;
- break;
- } // else MoveRight
- case MoveRight:
- if (d->hasSpans()) {
- QSpanCollection::Span span = d->span(current.row(), current.column());
- visualColumn = d->visualColumn(d->columnSpanEndLogical(span.left(), span.width()));
- }
- ++visualColumn;
- while (visualColumn < right && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn))
- ++visualColumn;
- if (d->hasSpans()) {
- int column = d->logicalColumn(visualColumn);
- QSpanCollection::Span span = d->span(current.row(), column);
- visualRow = d->visualRow(span.top());
- }
+ }
+ } while (!looped);
+ if (visualColumn > right)
+ visualColumn = originalColumn;
break;
+ }
case MoveHome:
visualColumn = 0;
while (visualColumn < right && d->isVisualColumnHiddenOrDisabled(visualRow, visualColumn))
@@ -1209,14 +1734,15 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
return d->model->index(newRow, current.column(), d->root);
}}
+ d->visualCursor = QPoint(visualColumn, visualRow);
int logicalRow = d->logicalRow(visualRow);
int logicalColumn = d->logicalColumn(visualColumn);
if (!d->model->hasIndex(logicalRow, logicalColumn, d->root))
return QModelIndex();
QModelIndex result = d->model->index(logicalRow, logicalColumn, d->root);
- if (!isIndexHidden(result) && d->isIndexEnabled(result))
- return d->model->index(logicalRow, logicalColumn, d->root);
+ if (!d->isRowHidden(logicalRow) && !d->isColumnHidden(logicalColumn) && d->isIndexEnabled(result))
+ return result;
return QModelIndex();
}
@@ -1595,6 +2121,8 @@ int QTableView::sizeHintForRow(int row) const
if (!model())
return -1;
+ ensurePolished();
+
int left = qMax(0, columnAt(0));
int right = columnAt(d->viewport->width());
if (right == -1) // the table don't have enough columns to fill the viewport
@@ -1652,6 +2180,8 @@ int QTableView::sizeHintForColumn(int column) const
if (!model())
return -1;
+ ensurePolished();
+
int top = qMax(0, rowAt(0));
int bottom = rowAt(d->viewport->height());
if (!isVisible() || bottom == -1) // the table don't have enough rows to fill the viewport
@@ -1971,7 +2501,8 @@ bool QTableView::isCornerButtonEnabled() const
QRect QTableView::visualRect(const QModelIndex &index) const
{
Q_D(const QTableView);
- if (!d->isIndexValid(index) || index.parent() != d->root || isIndexHidden(index) )
+ if (!d->isIndexValid(index) || index.parent() != d->root
+ || (!d->hasSpans() && isIndexHidden(index)))
return QRect();
d->executePostedLayout();
@@ -2519,9 +3050,21 @@ void QTableViewPrivate::selectRow(int row, bool anchor)
QModelIndex index = model->index(row, column, root);
QItemSelectionModel::SelectionFlags command = q->selectionCommand(index);
selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
- if ((!(command & QItemSelectionModel::Current) && anchor)
+ if ((anchor && !(command & QItemSelectionModel::Current))
|| (q->selectionMode() == QTableView::SingleSelection))
rowSectionAnchor = row;
+
+ if (q->selectionMode() != QTableView::SingleSelection
+ && command.testFlag(QItemSelectionModel::Toggle)) {
+ if (anchor)
+ ctrlDragSelectionFlag = verticalHeader->selectionModel()->selectedRows().contains(index)
+ ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
+ command &= ~QItemSelectionModel::Toggle;
+ command |= ctrlDragSelectionFlag;
+ if (!anchor)
+ command |= QItemSelectionModel::Current;
+ }
+
QModelIndex tl = model->index(qMin(rowSectionAnchor, row), 0, root);
QModelIndex br = model->index(qMax(rowSectionAnchor, row), model->columnCount(root) - 1, root);
if (verticalHeader->sectionsMoved() && tl.row() != br.row())
@@ -2545,9 +3088,21 @@ void QTableViewPrivate::selectColumn(int column, bool anchor)
QModelIndex index = model->index(row, column, root);
QItemSelectionModel::SelectionFlags command = q->selectionCommand(index);
selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
- if ((!(command & QItemSelectionModel::Current) && anchor)
+ if ((anchor && !(command & QItemSelectionModel::Current))
|| (q->selectionMode() == QTableView::SingleSelection))
columnSectionAnchor = column;
+
+ if (q->selectionMode() != QTableView::SingleSelection
+ && command.testFlag(QItemSelectionModel::Toggle)) {
+ if (anchor)
+ ctrlDragSelectionFlag = horizontalHeader->selectionModel()->selectedColumns().contains(index)
+ ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
+ command &= ~QItemSelectionModel::Toggle;
+ command |= ctrlDragSelectionFlag;
+ if (!anchor)
+ command |= QItemSelectionModel::Current;
+ }
+
QModelIndex tl = model->index(0, qMin(columnSectionAnchor, column), root);
QModelIndex br = model->index(model->rowCount(root) - 1,
qMax(columnSectionAnchor, column), root);
diff --git a/src/gui/itemviews/qtableview.h b/src/gui/itemviews/qtableview.h
index a8d446704..541c41947 100644
--- a/src/gui/itemviews/qtableview.h
+++ b/src/gui/itemviews/qtableview.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -182,6 +182,10 @@ private:
Q_DISABLE_COPY(QTableView)
Q_PRIVATE_SLOT(d_func(), void _q_selectRow(int))
Q_PRIVATE_SLOT(d_func(), void _q_selectColumn(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedRows(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedColumns(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedRows(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedColumns(QModelIndex,int,int))
};
#endif // QT_NO_TABLEVIEW
diff --git a/src/gui/itemviews/qtableview_p.h b/src/gui/itemviews/qtableview_p.h
index 41a87b124..6b19ded58 100644
--- a/src/gui/itemviews/qtableview_p.h
+++ b/src/gui/itemviews/qtableview_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -54,6 +54,7 @@
//
#include <QtCore/QList>
+#include <QtCore/QLinkedList>
#include <QtCore/QMap>
#include <QtCore/QSet>
#include <QtCore/QDebug>
@@ -73,7 +74,7 @@ QT_BEGIN_NAMESPACE
* The key of the first map is the row where the subspan starts, the value of the first map is
* a list (map) of all subspans that starts at the same row. It is indexed with its row
*/
-class QSpanCollection
+class Q_AUTOTEST_EXPORT QSpanCollection
{
public:
struct Span
@@ -82,10 +83,11 @@ public:
int m_left;
int m_bottom;
int m_right;
+ bool will_be_deleted;
Span()
- : m_top(-1), m_left(-1), m_bottom(-1), m_right(-1) { }
+ : m_top(-1), m_left(-1), m_bottom(-1), m_right(-1), will_be_deleted(false) { }
Span(int row, int column, int rowCount, int columnCount)
- : m_top(row), m_left(column), m_bottom(row+rowCount-1), m_right(column+columnCount-1) { }
+ : m_top(row), m_left(column), m_bottom(row+rowCount-1), m_right(column+columnCount-1), will_be_deleted(false) { }
inline int top() const { return m_top; }
inline int left() const { return m_left; }
inline int bottom() const { return m_bottom; }
@@ -105,12 +107,24 @@ public:
void clear();
QList<Span *> spansInRect(int x, int y, int w, int h) const;
- QList<Span *> spans; //lists of all spans
+ void updateInsertedRows(int start, int end);
+ void updateInsertedColumns(int start, int end);
+ void updateRemovedRows(int start, int end);
+ void updateRemovedColumns(int start, int end);
+
+#ifdef QT_BUILD_INTERNAL
+ bool checkConsistency() const;
+#endif
+
+ typedef QLinkedList<Span *> SpanList;
+ SpanList spans; //lists of all spans
private:
//the indexes are negative so the QMap::lowerBound do what i need.
typedef QMap<int, Span *> SubIndex;
typedef QMap<int, SubIndex> Index;
Index index;
+
+ bool cleanSpanSubIndex(SubIndex &subindex, int end, bool update = false);
};
Q_DECLARE_TYPEINFO ( QSpanCollection::Span, Q_MOVABLE_TYPE);
@@ -125,7 +139,8 @@ public:
rowSectionAnchor(-1), columnSectionAnchor(-1),
columnResizeTimerID(0), rowResizeTimerID(0),
horizontalHeader(0), verticalHeader(0),
- sortingEnabled(false), geometryRecursionBlock(false)
+ sortingEnabled(false), geometryRecursionBlock(false),
+ visualCursor(QPoint())
{
wrapItemText = true;
#ifndef QT_NO_DRAGANDDROP
@@ -173,6 +188,7 @@ public:
QWidget *cornerWidget;
bool sortingEnabled;
bool geometryRecursionBlock;
+ QPoint visualCursor; // (Row,column) cell coordinates to track through span navigation.
QSpanCollection spans;
@@ -227,6 +243,11 @@ public:
void selectRow(int row, bool anchor);
void selectColumn(int column, bool anchor);
+
+ void _q_updateSpanInsertedRows(const QModelIndex &parent, int start, int end);
+ void _q_updateSpanInsertedColumns(const QModelIndex &parent, int start, int end);
+ void _q_updateSpanRemovedRows(const QModelIndex &parent, int start, int end);
+ void _q_updateSpanRemovedColumns(const QModelIndex &parent, int start, int end);
};
QT_END_NAMESPACE
diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp
index de8ebde3c..d9b834647 100644
--- a/src/gui/itemviews/qtablewidget.cpp
+++ b/src/gui/itemviews/qtablewidget.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -226,6 +226,8 @@ QTableWidgetItem *QTableModel::takeItem(int row, int column)
itm->view = 0;
itm->d->id = -1;
tableItems[i] = 0;
+ QModelIndex ind = index(itm);
+ emit dataChanged(ind, ind);
}
return itm;
}
@@ -569,6 +571,8 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
colItems.remove(oldRow);
vit = sortedInsertionIterator(vit, colItems.end(), order, item);
int newRow = qMax((int)(vit - colItems.begin()), 0);
+ if ((newRow < oldRow) && !(*item < *colItems.at(oldRow - 1)) && !(*colItems.at(oldRow - 1) < *item))
+ newRow = oldRow;
vit = colItems.insert(vit, item);
if (newRow != oldRow) {
changed = true;
@@ -1486,7 +1490,7 @@ QTableWidgetItem &QTableWidgetItem::operator=(const QTableWidgetItem &other)
\brief The QTableWidget class provides an item-based table view with a default model.
\ingroup model-view
- \mainclass
+
Table widgets provide standard table display facilities for applications.
The items in a QTableWidget are provided by QTableWidgetItem.
@@ -2115,8 +2119,8 @@ QTableWidgetItem *QTableWidget::currentItem() const
/*!
Sets the current item to \a item.
- Depending on the current \l{QAbstractItemView::SelectionMode}{selection mode},
- the item may also be selected.
+ Unless the selection mode is \l{QAbstractItemView::}{NoSelection},
+ the item is also be selected.
\sa currentItem(), setCurrentCell()
*/
@@ -2454,7 +2458,7 @@ const QTableWidgetItem *QTableWidget::itemPrototype() const
The table widget will use the item prototype clone function when it needs
to create a new table item. For example when the user is editing
- editing in an empty cell. This is useful when you have a QTableWidgetItem
+ in an empty cell. This is useful when you have a QTableWidgetItem
subclass and want to make sure that QTableWidget creates instances of
your subclass.
diff --git a/src/gui/itemviews/qtablewidget.h b/src/gui/itemviews/qtablewidget.h
index de4f3ebcd..4acddc18d 100644
--- a/src/gui/itemviews/qtablewidget.h
+++ b/src/gui/itemviews/qtablewidget.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qtablewidget_p.h b/src/gui/itemviews/qtablewidget_p.h
index 46756f877..85c6d56de 100644
--- a/src/gui/itemviews/qtablewidget_p.h
+++ b/src/gui/itemviews/qtablewidget_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 539a642ac..3ad9fbb67 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE
\ingroup model-view
\ingroup advanced
- \mainclass
+
A QTreeView implements a tree representation of items from a
model. This class is used to provide standard hierarchical lists that
@@ -215,6 +215,13 @@ void QTreeView::setModel(QAbstractItemModel *model)
Q_D(QTreeView);
if (model == d->model)
return;
+ if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) {
+ disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+ this, SLOT(rowsRemoved(QModelIndex,int,int)));
+
+ disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_modelAboutToBeReset()));
+ }
+
if (d->selectionModel) { // support row editing
disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
d->model, SLOT(submit()));
@@ -838,10 +845,10 @@ void QTreeView::setSortingEnabled(bool enable)
// because otherwise it will not call sort on the model.
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
- this, SLOT(_q_sortIndicatorChanged(int, Qt::SortOrder)), Qt::UniqueConnection);
+ this, SLOT(_q_sortIndicatorChanged(int,Qt::SortOrder)), Qt::UniqueConnection);
} else {
disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
- this, SLOT(_q_sortIndicatorChanged(int, Qt::SortOrder)));
+ this, SLOT(_q_sortIndicatorChanged(int,Qt::SortOrder)));
}
d->sortingEnabled = enable;
}
@@ -1226,8 +1233,12 @@ bool QTreeView::viewportEvent(QEvent *event)
if (oldIndex != newIndex) {
QRect oldRect = visualRect(oldIndex);
QRect newRect = visualRect(newIndex);
- viewport()->update(oldRect.left() - d->indent, oldRect.top(), d->indent, oldRect.height());
- viewport()->update(newRect.left() - d->indent, newRect.top(), d->indent, newRect.height());
+ oldRect.setLeft(oldRect.left() - d->indent);
+ newRect.setLeft(newRect.left() - d->indent);
+ //we need to paint the whole items (including the decoration) so that when the user
+ //moves the mouse over those elements they are updated
+ viewport()->update(oldRect);
+ viewport()->update(newRect);
}
}
if (selectionBehavior() == QAbstractItemView::SelectRows) {
@@ -1422,8 +1433,9 @@ void QTreeView::drawTree(QPainter *painter, const QRegion &region) const
for (; i < viewItems.count() && y <= area.bottom(); ++i) {
const int itemHeight = d->itemHeight(i);
option.rect.setRect(0, y, viewportWidth, itemHeight);
- option.state = state | (viewItems.at(i).expanded
- ? QStyle::State_Open : QStyle::State_None);
+ option.state = state | (viewItems.at(i).expanded ? QStyle::State_Open : QStyle::State_None)
+ | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None)
+ | (viewItems.at(i).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None);
d->current = i;
d->spanning = viewItems.at(i).spanning;
if (!multipleRects || !drawn.contains(i)) {
@@ -1748,14 +1760,8 @@ void QTreeView::drawBranches(QPainter *painter, const QRect &rect,
opt.rect = primitive;
const bool expanded = viewItem.expanded;
- const bool children = (((expanded && viewItem.total > 0)) // already laid out and has children
- || d->hasVisibleChildren(index)); // not laid out yet, so we don't know
- bool moreSiblings = false;
- if (d->hiddenIndexes.isEmpty())
- moreSiblings = (d->model->rowCount(parent) - 1 > index.row());
- else
- moreSiblings = ((d->viewItems.size() > item +1)
- && (d->viewItems.at(item + 1).index.parent() == parent));
+ const bool children = viewItem.hasChildren;
+ bool moreSiblings = viewItem.hasMoreSiblings;
opt.state = QStyle::State_Item | extraFlags
| (moreSiblings ? QStyle::State_Sibling : QStyle::State_None)
@@ -1845,9 +1851,7 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event)
return; // user clicked outside the items
const QPersistentModelIndex firstColumnIndex = d->viewItems.at(i).index;
-
- int column = d->header->logicalIndexAt(event->x());
- QPersistentModelIndex persistent = firstColumnIndex.sibling(firstColumnIndex.row(), column);
+ const QPersistentModelIndex persistent = indexAt(event->pos());
if (d->pressedIndex != persistent) {
mousePressEvent(event);
@@ -2116,6 +2120,12 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
if (vi < 0)
vi = qMax(0, d->viewIndex(current));
+ if (isRightToLeft()) {
+ if (cursorAction == MoveRight)
+ cursorAction = MoveLeft;
+ else if (cursorAction == MoveLeft)
+ cursorAction = MoveRight;
+ }
switch (cursorAction) {
case MoveNext:
case MoveDown:
@@ -2437,7 +2447,9 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end)
return;
}
- if (parent != d->root && !d->isIndexExpanded(parent) && d->model->rowCount(parent) > (end - start) + 1) {
+ const int parentRowCount = d->model->rowCount(parent);
+ const int delta = end - start + 1;
+ if (parent != d->root && !d->isIndexExpanded(parent) && parentRowCount > delta) {
QAbstractItemView::rowsInserted(parent, start, end);
return;
}
@@ -2452,11 +2464,29 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end)
? d->viewItems.count()
: d->viewItems.at(parentItem).total) - 1;
- const int delta = end - start + 1;
+ if (parentRowCount == end + 1 && start > 0) {
+ //need to Update hasMoreSiblings
+ int previousRow = start - 1;
+ QModelIndex previousSibilingModelIndex = d->model->index(previousRow, 0, parent);
+ bool isHidden = d->isRowHidden(previousSibilingModelIndex);
+ while (isHidden && previousRow > 0) {
+ previousRow--;
+ previousSibilingModelIndex = d->model->index(previousRow, 0, parent);
+ isHidden = d->isRowHidden(previousSibilingModelIndex);
+ }
+ if (!isHidden) {
+ const int previousSibilling = d->viewIndex(previousSibilingModelIndex);
+ if(previousSibilling != -1)
+ d->viewItems[previousSibilling].hasMoreSiblings = true;
+ }
+ }
+
QVector<QTreeViewItem> insertedItems(delta);
for (int i = 0; i < delta; ++i) {
insertedItems[i].index = d->model->index(i + start, 0, parent);
insertedItems[i].level = childLevel;
+ insertedItems[i].hasChildren = d->hasVisibleChildren(insertedItems[i].index);
+ insertedItems[i].hasMoreSiblings = !((i == delta - 1) && (parentRowCount == end +1));
}
if (d->viewItems.isEmpty())
d->defaultItemHeight = indexRowSizeHint(insertedItems[0].index);
@@ -2498,13 +2528,17 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end)
d->viewItems.begin() + insertPos + 1);
}
+ if (parentItem != -1)
+ d->viewItems[parentItem].hasChildren = true;
d->updateChildCount(parentItem, delta);
+
updateGeometries();
viewport()->update();
} else if ((parentItem != -1) && d->viewItems.at(parentItem).expanded) {
d->doDelayedItemsLayout();
} else if (parentItem != -1 && (d->model->rowCount(parent) == end - start + 1)) {
- // the parent just went from 0 children to having some update to re-paint the decoration
+ // the parent just went from 0 children to more. update to re-paint the decoration
+ d->viewItems[parentItem].hasChildren = true;
viewport()->update();
}
QAbstractItemView::rowsInserted(parent, start, end);
@@ -2908,6 +2942,8 @@ void QTreeViewPrivate::expand(int item, bool emitSignal)
layout(item);
q->setState(oldState);
+ if (model->canFetchMore(index))
+ model->fetchMore(index);
if (emitSignal) {
emit q->expanded(index);
#ifndef QT_NO_ANIMATION
@@ -2915,8 +2951,6 @@ void QTreeViewPrivate::expand(int item, bool emitSignal)
beginAnimatedOperation();
#endif //QT_NO_ANIMATION
}
- if (model->canFetchMore(index))
- model->fetchMore(index);
}
void QTreeViewPrivate::collapse(int item, bool emitSignal)
@@ -3005,10 +3039,12 @@ void QTreeViewPrivate::beginAnimatedOperation()
animatedOperation.setEndValue(animatedOperation.top() + h);
}
- animatedOperation.after = renderTreeToPixmapForAnimation(rect);
+ if (!rect.isEmpty()) {
+ animatedOperation.after = renderTreeToPixmapForAnimation(rect);
- q->setState(QAbstractItemView::AnimatingState);
- animatedOperation.start(); //let's start the animation
+ q->setState(QAbstractItemView::AnimatingState);
+ animatedOperation.start(); //let's start the animation
+ }
}
void QTreeViewPrivate::drawAnimatedOperation(QPainter *painter) const
@@ -3125,7 +3161,7 @@ void QTreeViewPrivate::layout(int i)
int hidden = 0;
int last = 0;
int children = 0;
-
+ QTreeViewItem *item = 0;
for (int j = first; j < first + count; ++j) {
current = model->index(j - first, 0, parent);
if (isRowHidden(current)) {
@@ -3133,17 +3169,25 @@ void QTreeViewPrivate::layout(int i)
last = j - hidden + children;
} else {
last = j - hidden + children;
- viewItems[last].index = current;
- viewItems[last].level = level;
- viewItems[last].height = 0;
- viewItems[last].spanning = q->isFirstColumnSpanned(current.row(), parent);
- viewItems[last].expanded = false;
- viewItems[last].total = 0;
+ if (item)
+ item->hasMoreSiblings = true;
+ item = &viewItems[last];
+ item->index = current;
+ item->level = level;
+ item->height = 0;
+ item->spanning = q->isFirstColumnSpanned(current.row(), parent);
+ item->expanded = false;
+ item->total = 0;
+ item->hasMoreSiblings = false;
if (isIndexExpanded(current)) {
- viewItems[last].expanded = true;
+ item->expanded = true;
layout(last);
- children += viewItems[last].total;
+ item = &viewItems[last];
+ children += item->total;
+ item->hasChildren = item->total > 0;
last = j - hidden + children;
+ } else {
+ item->hasChildren = hasVisibleChildren(current);
}
}
}
@@ -3699,6 +3743,7 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent,
const int delta = end - start + 1;
+ int previousSibiling = -1;
int removedCount = 0;
for (int item = firstChildItem; item <= lastChildItem; ) {
Q_ASSERT(viewItems.at(item).level == childLevel);
@@ -3706,6 +3751,7 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent,
//Q_ASSERT(modelIndex.parent() == parent);
const int count = viewItems.at(item).total + 1;
if (modelIndex.row() < start) {
+ previousSibiling = item;
// not affected by the removal
item += count;
} else if (modelIndex.row() <= end) {
@@ -3723,7 +3769,13 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent,
}
}
+ if (previousSibiling != -1 && after && model->rowCount(parent) == start)
+ viewItems[previousSibiling].hasMoreSiblings = false;
+
+
updateChildCount(parentItem, -removedCount);
+ if (parentItem != -1 && viewItems.at(parentItem).total == 0)
+ viewItems[parentItem].hasChildren = false; //every children have been removed;
if (after) {
q->updateGeometries();
viewport->update();
diff --git a/src/gui/itemviews/qtreeview.h b/src/gui/itemviews/qtreeview.h
index 2ae89e82c..9cb423d02 100644
--- a/src/gui/itemviews/qtreeview.h
+++ b/src/gui/itemviews/qtreeview.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h
index 1bbba8904..d58dea34c 100644
--- a/src/gui/itemviews/qtreeview_p.h
+++ b/src/gui/itemviews/qtreeview_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -62,11 +62,14 @@ QT_BEGIN_NAMESPACE
struct QTreeViewItem
{
- QTreeViewItem() : expanded(false), spanning(false), total(0), level(0), height(0) {}
+ QTreeViewItem() : expanded(false), spanning(false), hasChildren(false),
+ hasMoreSiblings(false), total(0), level(0), height(0) {}
QModelIndex index; // we remove items whenever the indexes are invalidated
uint expanded : 1;
uint spanning : 1;
- uint total : 30; // total number of children visible
+ uint hasChildren : 1; // if the item has visible children (even if collapsed)
+ uint hasMoreSiblings : 1;
+ uint total : 28; // total number of children visible
uint level : 16; // indentation
int height : 16; // row height
};
@@ -102,7 +105,7 @@ public:
int top() const { return startValue().toInt(); }
QRect rect() const { QRect rect = viewport->rect(); rect.moveTop(top()); return rect; }
void updateCurrentValue(const QVariant &) { viewport->update(rect()); }
- void updateState(State, State state) { if (state == Stopped) before = after = QPixmap(); }
+ void updateState(State state, State) { if (state == Stopped) before = after = QPixmap(); }
} animatedOperation;
void prepareAnimatedOperation(int item, QVariantAnimation::Direction d);
void beginAnimatedOperation();
diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp
index f48e393ee..948ca79af 100644
--- a/src/gui/itemviews/qtreewidget.cpp
+++ b/src/gui/itemviews/qtreewidget.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -75,7 +75,7 @@ public:
\brief The QTreeModel class manages the items stored in a tree view.
\ingroup model-view
- \mainclass
+
*/
/*!
@@ -622,6 +622,10 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
QTreeWidgetItem *item = lst.takeAt(oldRow);
lit = sortedInsertionIterator(lit, lst.end(), order, item);
int newRow = qMax(lit - lst.begin(), 0);
+
+ if ((newRow < oldRow) && !(*item < *lst.at(oldRow - 1)) && !(*lst.at(oldRow - 1) < *item ))
+ newRow = oldRow;
+
lit = lst.insert(lit, item);
if (newRow != oldRow) {
// we are going to change the persistent indexes, so we need to prepare
@@ -853,7 +857,7 @@ void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortO
items->replace(r, item);
for (int c = 0; c < colCount; ++c) {
QModelIndex from = createIndex(oldRow, c, item);
- if (static_cast<QAbstractItemModelPrivate *>(d_ptr)->persistent.indexes.contains(from)) {
+ if (static_cast<QAbstractItemModelPrivate *>(d_ptr.data())->persistent.indexes.contains(from)) {
QModelIndex to = createIndex(r, c, item);
fromList << from;
toList << to;
@@ -1576,7 +1580,7 @@ void QTreeWidgetItem::setChildIndicatorPolicy(QTreeWidgetItem::ChildIndicatorPol
if (!view)
return;
- view->viewport()->update( view->d_func()->itemDecorationRect(view->d_func()->index(this)));
+ view->scheduleDelayedItemsLayout();
}
/*!
@@ -2074,7 +2078,7 @@ void QTreeWidgetItemPrivate::sortChildren(int column, Qt::SortOrder order, bool
{
QTreeModel *model = (q->view ? qobject_cast<QTreeModel*>(q->view->model()) : 0);
if (!model)
- return;
+ return;
model->sortItems(&q->children, column, order);
if (climb) {
QList<QTreeWidgetItem*>::iterator it = q->children.begin();
@@ -2329,7 +2333,7 @@ void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
tree model.
\ingroup model-view
- \mainclass
+
The QTreeWidget class is a convenience class that provides a standard
tree widget with a classic item-based interface similar to that used by
@@ -2784,7 +2788,8 @@ int QTreeWidget::currentColumn() const
/*!
Sets the current \a item in the tree widget.
- Depending on the current selection mode, the item may also be selected.
+ Unless the selection mode is \l{QAbstractItemView::}{NoSelection},
+ the item is also be selected.
\sa currentItem(), currentItemChanged()
*/
@@ -2846,7 +2851,14 @@ QTreeWidgetItem *QTreeWidget::itemAt(const QPoint &p) const
QRect QTreeWidget::visualItemRect(const QTreeWidgetItem *item) const
{
Q_D(const QTreeWidget);
- return visualRect(d->index(item));
+ //the visual rect for an item is across all columns. So we need to determine
+ //what is the first and last column and get their visual index rects
+ QModelIndex base = d->index(item);
+ const int firstVisiblesection = header()->logicalIndexAt(- header()->offset());
+ const int lastVisibleSection = header()->logicalIndexAt(header()->length() - header()->offset() - 1);
+ QModelIndex first = base.sibling(base.row(), header()->logicalIndex(firstVisiblesection));
+ QModelIndex last = base.sibling(base.row(), header()->logicalIndex(lastVisibleSection));
+ return visualRect(first) | visualRect(last);
}
/*!
diff --git a/src/gui/itemviews/qtreewidget.h b/src/gui/itemviews/qtreewidget.h
index 44c8ebdf7..d9d421e50 100644
--- a/src/gui/itemviews/qtreewidget.h
+++ b/src/gui/itemviews/qtreewidget.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qtreewidget_p.h b/src/gui/itemviews/qtreewidget_p.h
index 729e81ae9..40133ecbc 100644
--- a/src/gui/itemviews/qtreewidget_p.h
+++ b/src/gui/itemviews/qtreewidget_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qtreewidgetitemiterator.cpp b/src/gui/itemviews/qtreewidgetitemiterator.cpp
index 4b87c1a16..c503067b1 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator.cpp
+++ b/src/gui/itemviews/qtreewidgetitemiterator.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -97,7 +97,7 @@ QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFl
Q_ASSERT(widget);
QTreeModel *model = qobject_cast<QTreeModel*>(widget->model());
Q_ASSERT(model);
- d_ptr = new QTreeWidgetItemIteratorPrivate(this, model);
+ d_ptr.reset(new QTreeWidgetItemIteratorPrivate(this, model));
model->iterators.append(this);
if (!model->rootItem->children.isEmpty()) current = model->rootItem->children.first();
if (current && !matchesFlags(current))
@@ -150,7 +150,6 @@ QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidgetItem *item, Iterator
QTreeWidgetItemIterator::~QTreeWidgetItemIterator()
{
d_func()->m_model->iterators.removeAll(this);
- delete d_ptr;
}
/*!
diff --git a/src/gui/itemviews/qtreewidgetitemiterator.h b/src/gui/itemviews/qtreewidgetitemiterator.h
index b7b3fecef..5474958f1 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator.h
+++ b/src/gui/itemviews/qtreewidgetitemiterator.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -43,6 +43,7 @@
#define QTREEWIDGETITEMITERATOR_H
#include <QtCore/qglobal.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -105,7 +106,7 @@ public:
private:
bool matchesFlags(const QTreeWidgetItem *item) const;
- QTreeWidgetItemIteratorPrivate *d_ptr;
+ QScopedPointer<QTreeWidgetItemIteratorPrivate> d_ptr;
QTreeWidgetItem *current;
IteratorFlags flags;
Q_DECLARE_PRIVATE(QTreeWidgetItemIterator)
diff --git a/src/gui/itemviews/qtreewidgetitemiterator_p.h b/src/gui/itemviews/qtreewidgetitemiterator_p.h
index ee0808c86..726989d1c 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator_p.h
+++ b/src/gui/itemviews/qtreewidgetitemiterator_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/itemviews/qwidgetitemdata_p.h b/src/gui/itemviews/qwidgetitemdata_p.h
index 47f8a630e..11adbc0ad 100644
--- a/src/gui/itemviews/qwidgetitemdata_p.h
+++ b/src/gui/itemviews/qwidgetitemdata_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/