summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-07-01 10:49:16 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-07-01 10:49:16 (GMT)
commita3cd7065c5b630d9d949cc53db36f5c2d091c9fc (patch)
treefbf4f2d9b3e6bdbddf287771ef5f5a5e28cd3a3b
parentfed237ecdd891df6ed4bd1e8e5f5b9a414e12a22 (diff)
parent62f17a11be4ff2f545148a9e14a0d4806398765a (diff)
downloadQt-a3cd7065c5b630d9d949cc53db36f5c2d091c9fc.zip
Qt-a3cd7065c5b630d9d949cc53db36f5c2d091c9fc.tar.gz
Qt-a3cd7065c5b630d9d949cc53db36f5c2d091c9fc.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-water-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-water-staging: Cocoa: QFileDialog: fix filename filter not applied correctly Fix typo in docs: occurred. Cocoa: fix qtabwidget auto test failure Cocoa: fix qwidget auto test failures Cocoa: Fix qgraphicsproxywidget auto test Use Q_SLOTS instead of slots in public headers. Fix a11y crash: dock doesn't always have a widget. Fix typo in comment. Mac: respect WA_ShowWithoutActivating flag Remove misleading and incorrect information from dropMimeData docs. Provide the resetInternalData slot to cleanly reset data in proxy subclasses. Mac: switch raster off as default paint engine
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp35
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp37
-rw-r--r--src/corelib/kernel/qabstractitemmodel.h3
-rw-r--r--src/gui/accessible/qaccessible_mac.mm2
-rw-r--r--src/gui/dialogs/qfiledialog_mac.mm5
-rw-r--r--src/gui/kernel/qwidget_mac.mm5
-rw-r--r--src/gui/painting/qgraphicssystemfactory.cpp2
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.cpp19
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp4
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp138
-rw-r--r--tests/auto/qtabwidget/tst_qtabwidget.cpp5
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp19
12 files changed, 255 insertions, 19 deletions
diff --git a/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp b/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
index 5919c01..cf40f9a 100644
--- a/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
+++ b/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
@@ -86,3 +86,38 @@ beginMoveRows(parent, 2, 2, parent, 0);
//! [9]
beginMoveRows(parent, 2, 2, parent, 4);
//! [9]
+
+
+//! [10]
+class CustomDataProxy : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ CustomDataProxy(QObject *parent)
+ : QSortFilterProxyModel(parent)
+ {
+ }
+
+ ...
+
+ QVariant data(const QModelIndex &index, int role)
+ {
+ if (role != Qt::BackgroundRole)
+ return QSortFilterProxyModel::data(index, role);
+
+ if (m_customData.contains(index.row()))
+ return m_customData.value(index.row());
+ return QSortFilterProxyModel::data(index, role);
+ }
+
+private slots:
+ void resetInternalData()
+ {
+ m_customData.clear();
+ }
+
+private:
+ QHash<int, QVariant> m_customData;
+};
+//! [10]
+
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index b7ac6aa..ddf1fbb 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -1348,6 +1348,26 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
*/
/*!
+ \since 4.8
+
+ This slot is called just after the internal data of a model is cleared
+ while it is being reset.
+
+ This slot is provided the convenience of subclasses of concrete proxy
+ models, such as subclasses of QSortFilterProxyModel which maintain extra
+ data.
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 10
+
+ \sa modelAboutToBeReset(), modelReset()
+*/
+void QAbstractItemModel::resetInternalData()
+{
+
+}
+
+
+/*!
Constructs an abstract item model with the given \a parent.
*/
QAbstractItemModel::QAbstractItemModel(QObject *parent)
@@ -1747,18 +1767,19 @@ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const
Returns true if the data and action can be handled by the model; otherwise
returns false.
- Although the specified \a row, \a column and \a parent indicate the
- location of an item in the model where the operation ended, it is the
- responsibility of the view to provide a suitable location for where the
- data should be inserted.
+ The specified \a row, \a column and \a parent indicate the location of an
+ item in the model where the operation ended. It is the responsibility of
+ the model to complete the action at the correct location.
For instance, a drop action on an item in a QTreeView can result in new
items either being inserted as children of the item specified by \a row,
\a column, and \a parent, or as siblings of the item.
- When row and column are -1 it means that it is up to the model to decide
- where to place the data. This can occur in a tree when data is dropped on
- a parent. Models will usually append the data to the parent in this case.
+ When \a row and \a column are -1 it means that the dropped data should be
+ considered as dropped directly on \a parent. Usually this will mean
+ appending the data as child items of \a parent. If \a row and column are
+ greater than or equal zero, it means that the drop occurred just before the
+ specified \a row and \a column in the specified \a parent.
\sa supportedDropActions(), {Using drag and drop with item views}
*/
@@ -2888,6 +2909,7 @@ void QAbstractItemModel::reset()
Q_D(QAbstractItemModel);
emit modelAboutToBeReset();
d->invalidatePersistentIndexes();
+ QMetaObject::invokeMethod(this, "resetInternalData");
emit modelReset();
}
@@ -2930,6 +2952,7 @@ void QAbstractItemModel::endResetModel()
{
Q_D(QAbstractItemModel);
d->invalidatePersistentIndexes();
+ QMetaObject::invokeMethod(this, "resetInternalData");
emit modelReset();
}
diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/kernel/qabstractitemmodel.h
index c7af7a2..eab1475 100644
--- a/src/corelib/kernel/qabstractitemmodel.h
+++ b/src/corelib/kernel/qabstractitemmodel.h
@@ -303,6 +303,9 @@ protected:
void setRoleNames(const QHash<int,QByteArray> &roleNames);
+protected Q_SLOTS:
+ void resetInternalData();
+
private:
Q_DECLARE_PRIVATE(QAbstractItemModel)
Q_DISABLE_COPY(QAbstractItemModel)
diff --git a/src/gui/accessible/qaccessible_mac.mm b/src/gui/accessible/qaccessible_mac.mm
index 432b536..a250730 100644
--- a/src/gui/accessible/qaccessible_mac.mm
+++ b/src/gui/accessible/qaccessible_mac.mm
@@ -2427,7 +2427,7 @@ void QAccessible::updateAccessibility(QObject *object, int child, Event reason)
}
// There is no equivalent Mac notification for ObjectShow/Hide, so we call HIObjectSetAccessibilityIgnored
- // and isItIntersting which will mark the HIObject accociated with the element as ignored if the
+ // and isItInteresting which will mark the HIObject accociated with the element as ignored if the
// QAccessible::Invisible state bit is set.
QAInterface interface = accessibleHierarchyManager()->lookup(element);
if (interface.isValid()) {
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm
index fb52274..f1d3a4a 100644
--- a/src/gui/dialogs/qfiledialog_mac.mm
+++ b/src/gui/dialogs/qfiledialog_mac.mm
@@ -305,12 +305,13 @@ QT_USE_NAMESPACE
QString qtFileName = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(filename);
QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C)));
QString path = info.absolutePath();
+ QString name = info.fileName();
if (path != *mLastFilterCheckPath){
*mLastFilterCheckPath = path;
*mQDirFilterEntryList = info.dir().entryList(*mQDirFilter);
}
// Check if the QDir filter accepts the file:
- if (!mQDirFilterEntryList->contains(info.fileName()))
+ if (!mQDirFilterEntryList->contains(name))
return NO;
// No filter means accept everything
@@ -318,7 +319,7 @@ QT_USE_NAMESPACE
return YES;
// Check if the current file name filter accepts the file:
for (int i=0; i<mSelectedNameFilter->size(); ++i) {
- if (QDir::match(mSelectedNameFilter->at(i), qtFileName))
+ if (QDir::match(mSelectedNameFilter->at(i), name))
return YES;
}
return NO;
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index b3bf365..a51e295 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3490,7 +3490,10 @@ void QWidgetPrivate::show_sys()
QWidget *top = 0;
if (QApplicationPrivate::tryModalHelper(q, &top)) {
- [window makeKeyAndOrderFront:window];
+ if (q->testAttribute(Qt::WA_ShowWithoutActivating))
+ [window orderFront:window];
+ else
+ [window makeKeyAndOrderFront:window];
// If this window is app modal, we need to start spinning
// a modal session for it. Interrupting
// the event dispatcher will make this happend:
diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp
index 4309140..01ece09 100644
--- a/src/gui/painting/qgraphicssystemfactory.cpp
+++ b/src/gui/painting/qgraphicssystemfactory.cpp
@@ -74,7 +74,7 @@ QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key)
if (system.isEmpty()) {
system = QLatin1String("runtime");
}
-#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) || (defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA))
+#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11)
if (system.isEmpty()) {
system = QLatin1String("raster");
}
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
index c62624b..a0dde37 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
@@ -73,6 +73,9 @@ QT_BEGIN_NAMESPACE
using namespace QAccessible2;
+QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
+QString Q_GUI_EXPORT qt_accHotKey(const QString &text);
+
QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel)
{
if (widget == 0)
@@ -1139,8 +1142,8 @@ int QAccessibleTitleBar::childCount() const
QString QAccessibleTitleBar::text(Text t, int child) const
{
if (!child) {
- if (t == Value) {
- return dockWidget()->windowTitle();
+ if (t == Name || t == Value) {
+ return qt_accStripAmp(dockWidget()->windowTitle());
}
}
return QString();
@@ -1171,17 +1174,19 @@ QAccessible::State QAccessibleTitleBar::state(int child) const
return state;
}
-QRect QAccessibleTitleBar::rect (int child ) const
+QRect QAccessibleTitleBar::rect(int child) const
{
bool mapToGlobal = true;
QRect rect;
if (child == 0) {
if (dockWidget()->isFloating()) {
rect = dockWidget()->frameGeometry();
- QPoint globalPos = dockWidget()->mapToGlobal( dockWidget()->widget()->rect().topLeft() );
- globalPos.ry()--;
- rect.setBottom(globalPos.y());
- mapToGlobal = false;
+ if (dockWidget()->widget()) {
+ QPoint globalPos = dockWidget()->mapToGlobal(dockWidget()->widget()->rect().topLeft());
+ globalPos.ry()--;
+ rect.setBottom(globalPos.y());
+ mapToGlobal = false;
+ }
} else {
QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(dockWidget()->layout());
rect = layout->titleArea();
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 29c6591..8c52bb8 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -1498,6 +1498,10 @@ void tst_QGraphicsProxyWidget::scrollUpdate()
view.paintEventRegion = QRegion();
view.npaints = 0;
QTimer::singleShot(0, widget, SLOT(updateScroll()));
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QEXPECT_FAIL(0, "Cocoa will send us one aggregated update", Abort);
+#endif
QTRY_COMPARE(view.npaints, 2);
// QRect(0, 0, 200, 12) is the first update, expanded (-2, -2, 2, 2)
// QRect(0, 12, 102, 10) is the scroll update, expanded (-2, -2, 2, 2),
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 613c611..30589a8 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -149,6 +149,7 @@ private slots:
void testMultipleProxiesWithSelection();
void mapSelectionFromSource();
+ void testResetInternalData();
void filteredColumns();
protected:
@@ -3271,5 +3272,142 @@ void tst_QSortFilterProxyModel::taskQTBUG_17812_resetInvalidate()
QCOMPARE(ok, works);
}
+/**
+ * A proxy which changes the background color for items ending in 'y' or 'r'
+ */
+class CustomDataProxy : public QSortFilterProxyModel
+{
+ Q_OBJECT
+
+public:
+ CustomDataProxy(QObject *parent = 0)
+ : QSortFilterProxyModel(parent)
+ {
+ setDynamicSortFilter(true);
+ }
+
+ void setSourceModel(QAbstractItemModel *sourceModel)
+ {
+ // It would be possible to use only the modelReset signal of the source model to clear
+ // the data in *this, however, this requires that the slot is connected
+ // before QSortFilterProxyModel::setSourceModel is called, and even then depends
+ // on the order of invokation of slots being the same as the order of connection.
+ // ie, not reliable.
+// connect(sourceModel, SIGNAL(modelReset()), SLOT(resetInternalData()));
+ QSortFilterProxyModel::setSourceModel(sourceModel);
+ // Making the connect after the setSourceModel call clears the data too late.
+// connect(sourceModel, SIGNAL(modelReset()), SLOT(resetInternalData()));
+
+ // This could be done in data(), but the point is to need to cache something in the proxy
+ // which needs to be cleared on reset.
+ for (int i = 0; i < sourceModel->rowCount(); ++i)
+ {
+ if (sourceModel->index(i, 0).data().toString().endsWith(QLatin1Char('y')))
+ {
+ m_backgroundColours.insert(i, Qt::blue);
+ } else if (sourceModel->index(i, 0).data().toString().endsWith(QLatin1Char('r')))
+ {
+ m_backgroundColours.insert(i, Qt::red);
+ }
+ }
+ }
+
+ QVariant data(const QModelIndex &index, int role) const
+ {
+ if (role != Qt::BackgroundRole)
+ return QSortFilterProxyModel::data(index, role);
+ return m_backgroundColours.value(index.row());
+ }
+
+private slots:
+ void resetInternalData()
+ {
+ m_backgroundColours.clear();
+ }
+
+private:
+ QHash<int, QColor> m_backgroundColours;
+};
+
+class ModelObserver : public QObject
+{
+ Q_OBJECT
+public:
+ ModelObserver(QAbstractItemModel *model, QObject *parent = 0)
+ : QObject(parent), m_model(model)
+ {
+ connect(m_model, SIGNAL(modelAboutToBeReset()), SLOT(modelAboutToBeReset()));
+ connect(m_model, SIGNAL(modelReset()), SLOT(modelReset()));
+ }
+
+public slots:
+ void modelAboutToBeReset()
+ {
+ int reds = 0, blues = 0;
+ for (int i = 0; i < m_model->rowCount(); ++i)
+ {
+ QColor color = m_model->index(i, 0).data(Qt::BackgroundRole).value<QColor>();
+ if (color == Qt::blue)
+ ++blues;
+ if (color == Qt::red)
+ ++reds;
+ }
+ QCOMPARE(blues, 11);
+ QCOMPARE(reds, 4);
+ }
+
+ void modelReset()
+ {
+ int reds = 0, blues = 0;
+ for (int i = 0; i < m_model->rowCount(); ++i)
+ {
+ QColor color = m_model->index(i, 0).data(Qt::BackgroundRole).value<QColor>();
+ if (color == Qt::blue)
+ ++blues;
+ if (color == Qt::red)
+ ++reds;
+ }
+ QCOMPARE(reds, 0);
+ QCOMPARE(blues, 0);
+ }
+
+private:
+ QAbstractItemModel * const m_model;
+
+};
+
+void tst_QSortFilterProxyModel::testResetInternalData()
+{
+
+ QStringListModel model(QStringList() << "Monday"
+ << "Tuesday"
+ << "Wednesday"
+ << "Thursday"
+ << "Friday"
+ << "January"
+ << "February"
+ << "March"
+ << "April"
+ << "May"
+ << "Saturday"
+ << "June"
+ << "Sunday"
+ << "July"
+ << "August"
+ << "September"
+ << "October"
+ << "November"
+ << "December");
+
+ CustomDataProxy proxy;
+ proxy.setSourceModel(&model);
+
+ ModelObserver observer(&proxy);
+
+ // Cause the source model to reset.
+ model.setStringList(QStringList() << "Spam" << "Eggs");
+
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp
index cc3dfc1..77ae27f 100644
--- a/tests/auto/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp
@@ -44,6 +44,7 @@
#include <qtabwidget.h>
#include <qdebug.h>
#include <qapplication.h>
+#include <private/qapplication_p.h>
#include <qlabel.h>
#include <QtGui/qboxlayout.h>
@@ -618,6 +619,10 @@ void tst_QTabWidget::paintEventCount()
QTest::qWait(100);
QCOMPARE(tab1->count, initalPaintCount);
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QEXPECT_FAIL(0, "Cocoa sends an extra updates when the view is shown", Abort);
+#endif
QCOMPARE(tab2->count, 1);
tw->setCurrentIndex(0);
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 86773ad..ee06b53 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -4054,6 +4054,11 @@ public:
*/
void tst_QWidget::optimizedResizeMove()
{
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QSKIP("WA_StaticContents in Cocoa/Native paint engine lacks support", SkipAll);
+#endif
+
QWidget parent;
parent.resize(400, 400);
@@ -8260,6 +8265,10 @@ void tst_QWidget::doubleRepaint()
QCOMPARE(widget.numPaintEvents, 0);
widget.numPaintEvents = 0;
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QEXPECT_FAIL(0, "Cocoa will send us an update when showing the window", Continue);
+#endif
// Restore: Should not trigger a repaint.
widget.showNormal();
QTest::qWaitForWindowShown(&widget);
@@ -8369,6 +8378,11 @@ public slots:
void tst_QWidget::setMaskInResizeEvent()
{
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QSKIP("Updates on masked widgets are not optimized for Cocoa/native paint engine", SkipAll);
+#endif
+
UpdateWidget w;
w.reset();
w.resize(200, 200);
@@ -9043,6 +9057,11 @@ void tst_QWidget::setClearAndResizeMask()
void tst_QWidget::maskedUpdate()
{
+#if defined(QT_MAC_USE_COCOA)
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QSKIP("Updates on masked widgets are not optimized for Cocoa/native paint engine", SkipAll);
+#endif
+
UpdateWidget topLevel;
topLevel.resize(200, 200);
const QRegion topLevelMask(50, 50, 70, 70);