summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp3
-rw-r--r--src/widgets/itemviews/qheaderview.cpp2
-rw-r--r--src/widgets/itemviews/qtableview.cpp8
-rw-r--r--src/widgets/itemviews/qtreeview.cpp34
4 files changed, 10 insertions, 37 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index d4c83cb82c..089f398e71 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1966,6 +1966,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)
if ((event->button() == Qt::LeftButton) && !edit(persistent, DoubleClicked, event)
&& !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))
emit activated(persistent);
+ d->pressedIndex = QModelIndex();
}
#if QT_CONFIG(draganddrop)
@@ -3727,12 +3728,10 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const
option.state &= ~QStyle::State_MouseOver;
option.font = font();
-#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
// On mac the focus appearance follows window activation
// not widget activation
if (!hasFocus())
option.state &= ~QStyle::State_Active;
-#endif
option.state &= ~QStyle::State_HasFocus;
if (d->iconSize.isValid()) {
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index c4766a74bd..d7bdf6aa4c 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2570,7 +2570,6 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
if (pos < 0 && d->state != QHeaderViewPrivate::SelectSections)
return;
if (e->buttons() == Qt::NoButton) {
-#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
// Under Cocoa, when the mouse button is released, may include an extra
// simulated mouse moved event. The state of the buttons when this event
// is generated is already "no button" and the code below gets executed
@@ -2578,7 +2577,6 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
// column dragging from working. So this code is disabled under Cocoa.
d->state = QHeaderViewPrivate::NoState;
d->pressed = -1;
-#endif
}
switch (d->state) {
case QHeaderViewPrivate::ResizeSection: {
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index e706af1a42..c50156bbce 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -3186,14 +3186,18 @@ void QTableView::sortByColumn(int column)
/*!
\since 4.2
- Sorts the model by the values in the given \a column in the given \a order.
+ Sorts the model by the values in the given \a column and \a order.
+
+ \a column may be -1, in which case no sort indicator will be shown
+ and the model will return to its natural, unsorted order. Note that not
+ all models support this and may even crash in this case.
\sa sortingEnabled
*/
void QTableView::sortByColumn(int column, Qt::SortOrder order)
{
Q_D(QTableView);
- if (column < 0)
+ if (column < -1)
return;
// If sorting is enabled it will emit a signal connected to
// _q_sortIndicatorChanged, which then actually sorts
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 23a530821f..413cc2a9cd 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1943,6 +1943,7 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event)
if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))
emit activated(persistent);
+ d->pressedIndex = QModelIndex();
d->executePostedLayout(); // we need to make sure viewItems is updated
if (d->itemsExpandable
&& d->expandsOnDoubleClick
@@ -2173,35 +2174,6 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
return QModelIndex();
}
int vi = -1;
-#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(style_mac)
- // Selection behavior is slightly different on the Mac.
- if (d->selectionMode == QAbstractItemView::ExtendedSelection
- && d->selectionModel
- && d->selectionModel->hasSelection()) {
-
- const bool moveUpDown = (cursorAction == MoveUp || cursorAction == MoveDown);
- const bool moveNextPrev = (cursorAction == MoveNext || cursorAction == MovePrevious);
- const bool contiguousSelection = moveUpDown && (modifiers & Qt::ShiftModifier);
-
- // Use the outermost index in the selection as the current index
- if (!contiguousSelection && (moveUpDown || moveNextPrev)) {
-
- // Find outermost index.
- const bool useTopIndex = (cursorAction == MoveUp || cursorAction == MovePrevious);
- int index = useTopIndex ? INT_MAX : INT_MIN;
- const QItemSelection selection = d->selectionModel->selection();
- for (int i = 0; i < selection.count(); ++i) {
- const QItemSelectionRange &range = selection.at(i);
- int candidate = d->viewIndex(useTopIndex ? range.topLeft() : range.bottomRight());
- if (candidate >= 0)
- index = useTopIndex ? qMin(index, candidate) : qMax(index, candidate);
- }
-
- if (index >= 0 && index < INT_MAX)
- vi = index;
- }
- }
-#endif
if (vi < 0)
vi = qMax(0, d->viewIndex(current));
@@ -2619,7 +2591,7 @@ void QTreeView::sortByColumn(int column)
/*!
\since 4.2
- Sets the model up for sorting by the values in the given \a column and \a order.
+ Sorts the model by the values in the given \a column and \a order.
\a column may be -1, in which case no sort indicator will be shown
and the model will return to its natural, unsorted order. Note that not
@@ -2630,7 +2602,7 @@ void QTreeView::sortByColumn(int column)
void QTreeView::sortByColumn(int column, Qt::SortOrder order)
{
Q_D(QTreeView);
- if (column < 0)
+ if (column < -1)
return;
// If sorting is enabled it will emit a signal connected to
// _q_sortIndicatorChanged, which then actually sorts