diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2012-01-16 17:52:29 +0100 |
---|---|---|
committer | João Abecasis <joao.abecasis@nokia.com> | 2012-01-16 17:53:41 +0100 |
commit | 5b250d497fd798c476765b22a2906e1c0ff1e432 (patch) | |
tree | fd4215ca375cc2402e536bf670c2977cf64ae2ef /src/widgets | |
parent | 2c52e9a5c1d6ef6cbf4577430e14027375465c96 (diff) | |
parent | 7a0099183a1c107126bda3b59a47651aac612426 (diff) |
Merge remote-tracking branch 'gerrit/master' into containers
Change-Id: I2d358b912f1055ee6021d13de2f66fd459aaa355
Diffstat (limited to 'src/widgets')
542 files changed, 2350 insertions, 9361 deletions
diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in index b7e4594ca1..baf34b2fbc 100644 --- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in +++ b/src/widgets/Qt5WidgetsConfigExtras.cmake.in @@ -2,4 +2,4 @@ get_filename_component(_qt5_widgets_install_prefix ${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR} ABSOLUTE) # Not Required by default: -set(QT_UIC_EXECUTABLE \"${_qt5_widgets_install_prefix}/$$CMAKE_BIN_DIR/uic\") +set(QT_UIC_EXECUTABLE \"${_qt5_widgets_install_prefix}/$$CMAKE_BIN_DIR/uic$$CMAKE_BIN_SUFFIX\") diff --git a/src/widgets/Qt5WidgetsMacros.cmake b/src/widgets/Qt5WidgetsMacros.cmake index 7ebc7e6673..88f259191e 100644 --- a/src/widgets/Qt5WidgetsMacros.cmake +++ b/src/widgets/Qt5WidgetsMacros.cmake @@ -39,27 +39,27 @@ include(CMakeParseArguments) -# QT5_WRAP_UI(outfiles inputfile ... ) +# qt5_wrap_ui(outfiles inputfile ... ) -MACRO (QT5_WRAP_UI outfiles ) - set(options) - set(oneValueArgs) - set(multiValueArgs OPTIONS) +function(QT5_WRAP_UI outfiles ) + set(options) + set(oneValueArgs) + set(multiValueArgs OPTIONS) - cmake_parse_arguments(_WRAP_UI "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(_WRAP_UI "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - set(ui_files ${_WRAP_UI_UNPARSED_ARGUMENTS}) - set(ui_options ${_WRAP_UI_OPTIONS}) + set(ui_files ${_WRAP_UI_UNPARSED_ARGUMENTS}) + set(ui_options ${_WRAP_UI_OPTIONS}) - FOREACH (it ${ui_files}) - GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) - GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) - SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_UIC_EXECUTABLE} - ARGS ${ui_options} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile} VERBATIM) - SET(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH (it) - -ENDMACRO (QT5_WRAP_UI) + foreach(it ${ui_files}) + get_filename_component(outfile ${it} NAME_WE) + get_filename_component(infile ${it} ABSOLUTE) + set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) + add_custom_command(OUTPUT ${outfile} + COMMAND ${QT_UIC_EXECUTABLE} + ARGS ${ui_options} -o ${outfile} ${infile} + MAIN_DEPENDENCY ${infile} VERBATIM) + list(APPEND ${outfiles} ${outfile}) + endforeach() + set(${outfiles} ${${outfiles}} PARENT_SCOPE) +endfunction() diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index a1c53e934e..ae09b011dd 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -159,6 +159,8 @@ public: \ingroup accessibility \inmodule QtWidgets + This class is part of \l {Accessibility for QWidget Applications}. + This class is convenient to use as a base class for custom implementations of QAccessibleInterfaces that provide information about widget objects. @@ -188,6 +190,7 @@ QAccessibleWidget::QAccessibleWidget(QWidget *w, QAccessible::Role role, const Q d->asking = 0; } +/*! \reimp */ QWindow *QAccessibleWidget::window() const { return widget()->windowHandle(); @@ -222,28 +225,6 @@ QObject *QAccessibleWidget::parentObject() const } /*! \reimp */ -int QAccessibleWidget::childAt(int x, int y) const -{ - QWidget *w = widget(); - if (!w->isVisible()) - return -1; - QPoint gp = w->mapToGlobal(QPoint(0, 0)); - if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y)) - return -1; - - for (int i = 0; i < childCount(); ++i) { - QAccessibleInterface *childIface = child(i); - bool found = false; - if (childIface->rect().contains(x, y)) - found = true; - delete childIface; - if (found) - return i + 1; - } - return 0; -} - -/*! \reimp */ QRect QAccessibleWidget::rect() const { QWidget *w = widget(); @@ -385,11 +366,7 @@ QAccessible::Relation QAccessibleWidget::relationTo(const QAccessibleInterface * } QObject *parent = object()->parent(); - if (o == parent) - return relation | QAccessible::Child; - if (o->parent() == parent) { - relation |= QAccessible::Sibling; QAccessibleInterface *sibIface = QAccessible::queryAccessibleInterface(o); Q_ASSERT(sibIface); QRect wg = rect(); @@ -397,7 +374,7 @@ QAccessible::Relation QAccessibleWidget::relationTo(const QAccessibleInterface * if (wg.intersects(sg)) { QAccessibleInterface *pIface = 0; pIface = sibIface->parent(); - if (pIface && !((sibIface->state() | state()) & QAccessible::Invisible)) { + if (pIface && !(sibIface->state().invisible | state().invisible)) { int wi = pIface->indexOfChild(this); int si = pIface->indexOfChild(sibIface); @@ -407,31 +384,16 @@ QAccessible::Relation QAccessibleWidget::relationTo(const QAccessibleInterface * relation |= QAccessible::Covered; } delete pIface; - } else { - QPoint wc = wg.center(); - QPoint sc = sg.center(); - if (wc.x() < sc.x()) - relation |= QAccessible::Left; - else if(wc.x() > sc.x()) - relation |= QAccessible::Right; - if (wc.y() < sc.y()) - relation |= QAccessible::Up; - else if (wc.y() > sc.y()) - relation |= QAccessible::Down; } delete sibIface; return relation; } - if (isAncestor(o, object())) - return relation | QAccessible::Descendent; - if (isAncestor(object(), o)) - return relation | QAccessible::Ancestor; - return relation; } +/*! \reimp */ QAccessibleInterface *QAccessibleWidget::parent() const { QObject *parentWidget= widget()->parentWidget(); @@ -440,6 +402,7 @@ QAccessibleInterface *QAccessibleWidget::parent() const return QAccessible::queryAccessibleInterface(parentWidget); } +/*! \reimp */ QAccessibleInterface *QAccessibleWidget::child(int index) const { QWidgetList childList = childWidgets(widget()); @@ -459,132 +422,20 @@ int QAccessibleWidget::navigate(QAccessible::RelationFlag relation, int entry, QObject *targetObject = 0; switch (relation) { - // Hierarchical - case QAccessible::Self: - targetObject = object(); - break; - case QAccessible::Child: - qWarning() << "QAccessibleWidget::navigate is deprecated for QAccessible::Child in:" << object()->metaObject()->className(); - *target = child(entry - 1); - return *target ? 0 : -1; - case QAccessible::Ancestor: - qWarning() << "QAccessibleWidget::navigate is deprecated for QAccessible::Ancestor in:" << object()->metaObject()->className(); - *target = parent(); - return *target ? 0 : -1; - case QAccessible::Sibling: - { - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parentObject()); - if (!iface) - return -1; - - *target = iface->child(entry - 1); - delete iface; - if (*target) - return 0; - } - break; - - // Geometrical - case QAccessible::Left: - // fall through - case QAccessible::Right: - // fall through - case QAccessible::Up: - // fall through - case QAccessible::Down: - { - QAccessibleInterface *pIface = parent(); - if (!pIface) - return -1; - - QRect startg = rect(); - QPoint startc = startg.center(); - QAccessibleInterface *candidate = 0; - int mindist = 100000; - int sibCount = pIface->childCount(); - for (int i = 0; i < sibCount; ++i) { - QAccessibleInterface *sibling = 0; - sibling = pIface->child(i); - Q_ASSERT(sibling); - if ((relationTo(sibling) & QAccessible::Self) || (sibling->state() & QAccessible::Invisible)) { - //ignore ourself and invisible siblings - delete sibling; - continue; - } - - QRect sibg = sibling->rect(); - QPoint sibc = sibg.center(); - QPoint sibp; - QPoint startp; - QPoint distp; - switch (relation) { - case QAccessible::Left: - startp = QPoint(startg.left(), startg.top() + startg.height() / 2); - sibp = QPoint(sibg.right(), sibg.top() + sibg.height() / 2); - if (QPoint(sibc - startc).x() >= 0) { - delete sibling; - continue; - } - distp = sibp - startp; - break; - case QAccessible::Right: - startp = QPoint(startg.right(), startg.top() + startg.height() / 2); - sibp = QPoint(sibg.left(), sibg.top() + sibg.height() / 2); - if (QPoint(sibc - startc).x() <= 0) { - delete sibling; - continue; - } - distp = sibp - startp; - break; - case QAccessible::Up: - startp = QPoint(startg.left() + startg.width() / 2, startg.top()); - sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.bottom()); - if (QPoint(sibc - startc).y() >= 0) { - delete sibling; - continue; - } - distp = sibp - startp; - break; - case QAccessible::Down: - startp = QPoint(startg.left() + startg.width() / 2, startg.bottom()); - sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.top()); - if (QPoint(sibc - startc).y() <= 0) { - delete sibling; - continue; - } - distp = sibp - startp; - break; - default: - break; - } - - int dist = (int)qSqrt((qreal)distp.x() * distp.x() + distp.y() * distp.y()); - if (dist < mindist) { - delete candidate; - candidate = sibling; - mindist = dist; - } else { - delete sibling; - } - } - delete pIface; - *target = candidate; - if (*target) - return 0; - } - break; case QAccessible::Covers: if (entry > 0) { - QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject()); + QAccessibleInterface *pIface = parent(); if (!pIface) return -1; QRect r = rect(); int sibCount = pIface->childCount(); QAccessibleInterface *sibling = 0; - for (int i = pIface->indexOfChild(this) + 1; i <= sibCount && entry; ++i) { + // FIXME: this code looks very suspicious + // why start at this index? + for (int i = pIface->indexOfChild(this) + 2; i <= sibCount && entry; ++i) { sibling = pIface->child(i - 1); - if (!sibling || (sibling->state() & QAccessible::Invisible)) { + if (!sibling || (sibling->state().invisible)) { delete sibling; sibling = 0; continue; @@ -611,10 +462,11 @@ int QAccessibleWidget::navigate(QAccessible::RelationFlag relation, int entry, QRect r = rect(); int index = pIface->indexOfChild(this); QAccessibleInterface *sibling = 0; - for (int i = 1; i < index && entry; ++i) { - sibling = pIface->child(i - 1); + // FIXME: why end at index? + for (int i = 0; i < index && entry; ++i) { + sibling = pIface->child(i); Q_ASSERT(sibling); - if (!sibling || (sibling->state() & QAccessible::Invisible)) { + if (!sibling || (sibling->state().invisible)) { delete sibling; sibling = 0; continue; @@ -746,10 +598,7 @@ int QAccessibleWidget::childCount() const int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const { QWidgetList cl = childWidgets(widget()); - int index = cl.indexOf(qobject_cast<QWidget *>(child->object())); - if (index != -1) - ++index; - return index; + return cl.indexOf(qobject_cast<QWidget *>(child->object())); } // from qwidget.cpp @@ -808,6 +657,7 @@ QString QAccessibleWidget::text(QAccessible::Text t) const return str; } +/*! \reimp */ QStringList QAccessibleWidget::actionNames() const { QStringList names; @@ -818,6 +668,7 @@ QStringList QAccessibleWidget::actionNames() const return names; } +/*! \reimp */ void QAccessibleWidget::doAction(const QString &actionName) { if (!widget()->isEnabled()) @@ -830,6 +681,7 @@ void QAccessibleWidget::doAction(const QString &actionName) } } +/*! \reimp */ QStringList QAccessibleWidget::keyBindingsForAction(const QString & /* actionName */) const { return QStringList(); @@ -844,37 +696,40 @@ QAccessible::Role QAccessibleWidget::role() const /*! \reimp */ QAccessible::State QAccessibleWidget::state() const { - QAccessible::State state = QAccessible::Normal; + QAccessible::State state; QWidget *w = widget(); if (w->testAttribute(Qt::WA_WState_Visible) == false) - state |= QAccessible::Invisible; + state.invisible = true; if (w->focusPolicy() != Qt::NoFocus && w->isActiveWindow()) - state |= QAccessible::Focusable; + state.focusable = true; if (w->hasFocus()) - state |= QAccessible::Focused; + state.focused = true; if (!w->isEnabled()) - state |= QAccessible::Unavailable; + state.disabled = true; if (w->isWindow()) { if (w->windowFlags() & Qt::WindowSystemMenuHint) - state |= QAccessible::Movable; + state.movable = true; if (w->minimumSize() != w->maximumSize()) - state |= QAccessible::Sizeable; + state.sizeable = true; } return state; } +/*! \reimp */ QColor QAccessibleWidget::foregroundColor() const { return widget()->palette().color(widget()->foregroundRole()); } +/*! \reimp */ QColor QAccessibleWidget::backgroundColor() const { return widget()->palette().color(widget()->backgroundRole()); } +/*! \reimp */ void *QAccessibleWidget::interface_cast(QAccessible::InterfaceType t) { if (t == QAccessible::ActionInterface) diff --git a/src/widgets/accessible/qaccessiblewidget.h b/src/widgets/accessible/qaccessiblewidget.h index b807dbc088..da217b94ca 100644 --- a/src/widgets/accessible/qaccessiblewidget.h +++ b/src/widgets/accessible/qaccessiblewidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -64,7 +64,6 @@ public: int indexOfChild(const QAccessibleInterface *child) const; QAccessible::Relation relationTo(const QAccessibleInterface *other) const; - int childAt(int x, int y) const; QRect rect() const; QAccessibleInterface *parent() const; diff --git a/src/widgets/animation/qguivariantanimation.cpp b/src/widgets/animation/qguivariantanimation.cpp index f99b74e2ab..2167e4a173 100644 --- a/src/widgets/animation/qguivariantanimation.cpp +++ b/src/widgets/animation/qguivariantanimation.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 1803cba01d..777e4cc4ba 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -425,34 +425,13 @@ void QWellArray::keyPressEvent(QKeyEvent* e) //////////// QWellArray END -static bool initrgb = false; -static QRgb stdrgb[6*8]; -static QRgb cusrgb[2*8]; -static bool customSet = false; - - -static void initRGB() -{ - if (initrgb) - return; - initrgb = true; - int i = 0; - for (int g = 0; g < 4; g++) - for (int r = 0; r < 4; r++) - for (int b = 0; b < 3; b++) - stdrgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2); - - for (i = 0; i < 2*8; i++) - cusrgb[i] = 0xffffffff; -} - /*! Returns the number of custom colors supported by QColorDialog. All color dialogs share the same custom colors. */ int QColorDialog::customCount() { - return 2 * 8; + return QColorDialogOptions::customColorCount(); } /*! @@ -462,10 +441,7 @@ int QColorDialog::customCount() */ QRgb QColorDialog::customColor(int index) { - if (uint(index) >= uint(customCount())) - return qRgb(255, 255, 255); - initRGB(); - return cusrgb[index]; + return QColorDialogOptions::customColor(index); } /*! @@ -477,11 +453,7 @@ QRgb QColorDialog::customColor(int index) */ void QColorDialog::setCustomColor(int index, QRgb color) { - if (uint(index) >= uint(customCount())) - return; - initRGB(); - customSet = true; - cusrgb[index] = color; + QColorDialogOptions::setCustomColor(index, color); } /*! @@ -494,10 +466,7 @@ void QColorDialog::setCustomColor(int index, QRgb color) void QColorDialog::setStandardColor(int index, QRgb color) { - if (uint(index) >= uint(6 * 8)) - return; - initRGB(); - stdrgb[index] = color; + QColorDialogOptions::setStandardColor(index, color); } static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v) @@ -1421,9 +1390,10 @@ bool QColorDialogPrivate::selectColor(const QColor &col) int i = 0, j = 0; // Check standard colors if (standard) { + const QRgb *standardColors = QColorDialogOptions::standardColors(); for (i = 0; i < 6; i++) { for (j = 0; j < 8; j++) { - if (color == stdrgb[i + j*6]) { + if (color == standardColors[i + j*6]) { _q_newStandard(i, j); standard->setCurrent(i, j); standard->setSelected(i, j); @@ -1435,9 +1405,10 @@ bool QColorDialogPrivate::selectColor(const QColor &col) } // Check custom colors if (custom) { + const QRgb *customColors = QColorDialogOptions::customColors(); for (i = 0; i < 2; i++) { for (j = 0; j < 8; j++) { - if (color == cusrgb[i + j*2]) { + if (color == customColors[i + j*2]) { _q_newCustom(i, j); custom->setCurrent(i, j); custom->setSelected(i, j); @@ -1461,8 +1432,8 @@ void QColorDialogPrivate::_q_newColorTypedIn(QRgb rgb) void QColorDialogPrivate::_q_newCustom(int r, int c) { - int i = r+2*c; - setCurrentColor(cusrgb[i]); + const int i = r + 2 * c; + setCurrentColor(QColorDialogOptions::customColor(i)); nextCust = i; if (standard) standard->setSelected(-1,-1); @@ -1470,7 +1441,7 @@ void QColorDialogPrivate::_q_newCustom(int r, int c) void QColorDialogPrivate::_q_newStandard(int r, int c) { - setCurrentColor(stdrgb[r+c*6]); + setCurrentColor(QColorDialogOptions::standardColor(r + c * 6)); if (custom) custom->setSelected(-1,-1); } @@ -1509,21 +1480,6 @@ void QColorDialogPrivate::init(const QColor &initial) topLay->addLayout(leftLay); } - initRGB(); - -#ifndef QT_NO_SETTINGS - if (!customSet) { - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); - for (int i = 0; i < 2*8; ++i) { - QVariant v = settings.value(QLatin1String("Qt/customColors/") + QString::number(i)); - if (v.isValid()) { - QRgb rgb = v.toUInt(); - cusrgb[i] = rgb; - } - } - } -#endif - #if defined(QT_SMALL_COLORDIALOG) # if defined(Q_WS_S60) const bool nonTouchUI = !S60->hasTouchscreen; @@ -1533,7 +1489,7 @@ void QColorDialogPrivate::init(const QColor &initial) #endif if (!smallDisplay) { - standard = new QColorWell(q, 6, 8, stdrgb); + standard = new QColorWell(q, 6, 8, QColorDialogOptions::standardColors()); lblBasicColors = new QLabel(q); #ifndef QT_NO_SHORTCUT lblBasicColors->setBuddy(standard); @@ -1546,7 +1502,7 @@ void QColorDialogPrivate::init(const QColor &initial) leftLay->addStretch(); #endif - custom = new QColorWell(q, 2, 8, cusrgb); + custom = new QColorWell(q, 2, 8, QColorDialogOptions::customColors()); custom->setAcceptDrops(true); q->connect(custom, SIGNAL(selected(int,int)), SLOT(_q_newCustom(int,int))); @@ -1657,22 +1613,22 @@ void QColorDialogPrivate::initHelper(QPlatformDialogHelper *h) QColorDialog *d = q_func(); QObject::connect(h, SIGNAL(currentColorChanged(QColor)), d, SIGNAL(currentColorChanged(QColor))); QObject::connect(h, SIGNAL(colorSelected(QColor)), d, SIGNAL(colorSelected(QColor))); + static_cast<QPlatformColorDialogHelper *>(h)->setOptions(options); +} + +void QColorDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) +{ + options->setWindowTitle(q_func()->windowTitle()); } void QColorDialogPrivate::_q_addCustom() { - cusrgb[nextCust] = cs->currentColor(); + QColorDialogOptions::setCustomColor(nextCust, cs->currentColor()); if (custom) custom->update(); nextCust = (nextCust+1) % 16; } -void QColorDialogPrivate::_q_platformRunNativeAppModalPanel() -{ - if (nativeDialogInUse) - platformHelper()->_q_platformRunNativeAppModalPanel(); -} - void QColorDialogPrivate::retranslateStrings() { if (!smallDisplay) { @@ -1800,8 +1756,7 @@ QColor QColorDialog::selectedColor() const void QColorDialog::setOption(ColorDialogOption option, bool on) { Q_D(QColorDialog); - if (!(d->opts & option) != !on) - setOptions(d->opts ^ option); + d->options->setOption(static_cast<QColorDialogOptions::ColorDialogOption>(option), on); } /*! @@ -1815,7 +1770,7 @@ void QColorDialog::setOption(ColorDialogOption option, bool on) bool QColorDialog::testOption(ColorDialogOption option) const { Q_D(const QColorDialog); - return (d->opts & option) != 0; + return d->options->testOption(static_cast<QColorDialogOptions::ColorDialogOption>(option)); } /*! @@ -1834,11 +1789,10 @@ void QColorDialog::setOptions(ColorDialogOptions options) { Q_D(QColorDialog); - ColorDialogOptions changed = (options ^ d->opts); - if (!changed) + if (QColorDialog::options() == options) return; - d->opts = options; + d->options->setOptions(QColorDialogOptions::ColorDialogOptions(int(options))); d->buttons->setVisible(!(options & NoButtons)); d->showAlpha(options & ShowAlphaChannel); } @@ -1846,7 +1800,7 @@ void QColorDialog::setOptions(ColorDialogOptions options) QColorDialog::ColorDialogOptions QColorDialog::options() const { Q_D(const QColorDialog); - return d->opts; + return QColorDialog::ColorDialogOptions(int(d->options->options())); } /*! @@ -1922,7 +1876,7 @@ void QColorDialog::setVisible(bool visible) } #else - if (!(d->opts & DontUseNativeDialog)) + if (!(options() & DontUseNativeDialog)) d->setNativeDialogVisible(visible); if (d->nativeDialogInUse) { @@ -2026,14 +1980,6 @@ QColorDialog::~QColorDialog() QColorDialogPrivate::sharedColorPanelAvailable = true; } #endif - -#ifndef QT_NO_SETTINGS - if (!customSet) { - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); - for (int i = 0; i < 2*8; ++i) - settings.setValue(QLatin1String("Qt/customColors/") + QString::number(i), cusrgb[i]); - } -#endif } /*! diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h index 1d21c06f99..1bdb0b41a2 100644 --- a/src/widgets/dialogs/qcolordialog.h +++ b/src/widgets/dialogs/qcolordialog.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qcolordialog_mac.mm b/src/widgets/dialogs/qcolordialog_mac.mm index 1d77751e2b..bdf5e1cccd 100644 --- a/src/widgets/dialogs/qcolordialog_mac.mm +++ b/src/widgets/dialogs/qcolordialog_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h index 39d7192b1d..a6149017d7 100644 --- a/src/widgets/dialogs/qcolordialog_p.h +++ b/src/widgets/dialogs/qcolordialog_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -56,6 +56,7 @@ #include "private/qdialog_p.h" #include "qcolordialog.h" +#include "qsharedpointer.h" #ifndef QT_NO_COLORDIALOG @@ -75,6 +76,8 @@ class QColorDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QColorDialog) public: + QColorDialogPrivate() : options(new QColorDialogOptions) {} + QPlatformColorDialogHelper *platformColorDialogHelper() const { return static_cast<QPlatformColorDialogHelper *>(platformHelper()); } @@ -92,7 +95,6 @@ public: void retranslateStrings(); void _q_addCustom(); - void _q_platformRunNativeAppModalPanel(); void _q_newHsv(int h, int s, int v); void _q_newColorTypedIn(QRgb rgb); @@ -115,7 +117,8 @@ public: QColor selectedQColor; int nextCust; bool smallDisplay; - QColorDialog::ColorDialogOptions opts; + QSharedPointer<QColorDialogOptions> options; + QPointer<QObject> receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; @@ -138,6 +141,7 @@ public: #endif private: virtual void initHelper(QPlatformDialogHelper *h); + virtual void helperPrepareShow(QPlatformDialogHelper *h); }; #endif // QT_NO_COLORDIALOG diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 363d3bf592..af11fc971d 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -66,10 +66,16 @@ QPlatformDialogHelper *QDialogPrivate::platformHelper() const if (!m_platformHelperCreated) { QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this); m_platformHelperCreated = true; + QDialog *dialog = ncThis->q_func(); m_platformHelper = QGuiApplicationPrivate::platformTheme() - ->createPlatformDialogHelper(ncThis->q_func()); - if (m_platformHelper) + ->createPlatformDialogHelper(dialog); + if (m_platformHelper) { + QObject::connect(m_platformHelper, SIGNAL(accept()), dialog, SLOT(accept())); + QObject::connect(m_platformHelper, SIGNAL(reject()), dialog, SLOT(reject())); + QObject::connect(m_platformHelper, SIGNAL(launchNativeAppModalPanel()), + dialog, SLOT(_q_platformRunNativeAppModalPanel())); ncThis->initHelper(m_platformHelper); + } } return m_platformHelper; } @@ -85,7 +91,11 @@ bool QDialogPrivate::setNativeDialogVisible(bool visible) { if (QPlatformDialogHelper *helper = platformHelper()) { if (visible) { - nativeDialogInUse = helper->show_sys(parentWindow()); + helperPrepareShow(helper); + QPlatformDialogHelper::ShowFlags flags(0); + if (q_func()->isModal()) + flags |= QPlatformDialogHelper::ShowModal; + nativeDialogInUse = helper->show_sys(flags, q_func()->windowFlags(), parentWindow()); } else { helper->hide_sys(); } @@ -93,6 +103,13 @@ bool QDialogPrivate::setNativeDialogVisible(bool visible) return nativeDialogInUse; } +void QDialogPrivate::_q_platformRunNativeAppModalPanel() +{ + if (nativeDialogInUse) + platformHelper()->_q_platformRunNativeAppModalPanel(); +} + + QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const { if (const QPlatformDialogHelper *helper = platformHelper()) @@ -503,6 +520,8 @@ int QDialog::exec() setAttribute(Qt::WA_ShowModal, wasShowModal); int res = result(); + if (d->nativeDialogInUse) + d->helperDone(static_cast<QDialog::DialogCode>(res), d->platformHelper()); if (deleteOnClose) delete this; return res; diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h index d4171ece47..8329e6460a 100644 --- a/src/widgets/dialogs/qdialog.h +++ b/src/widgets/dialogs/qdialog.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -118,7 +118,7 @@ protected: private: Q_DECLARE_PRIVATE(QDialog) Q_DISABLE_COPY(QDialog) - + Q_PRIVATE_SLOT(d_func(), void _q_platformRunNativeAppModalPanel()) #ifdef Q_WS_WINCE_WM Q_PRIVATE_SLOT(d_func(), void _q_doneAction()) diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index 3d90686b6d..ecdfff03fd 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -79,6 +79,7 @@ public: nativeDialogInUse(false), m_platformHelper(0), m_platformHelperCreated(false) {} ~QDialogPrivate() { delete m_platformHelper; } + void _q_platformRunNativeAppModalPanel(); QWindow *parentWindow() const; bool setNativeDialogVisible(bool visible); @@ -115,6 +116,8 @@ public: private: virtual void initHelper(QPlatformDialogHelper *) {} + virtual void helperPrepareShow(QPlatformDialogHelper *) {} + virtual void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) {} mutable QPlatformDialogHelper *m_platformHelper; mutable bool m_platformHelperCreated; diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index e87551cd80..1c950a7158 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qerrormessage.h b/src/widgets/dialogs/qerrormessage.h index 3736526f93..c43df749f7 100644 --- a/src/widgets/dialogs/qerrormessage.h +++ b/src/widgets/dialogs/qerrormessage.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 0f107c6b0a..2f49a226e9 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -507,16 +507,14 @@ QFileDialogPrivate::QFileDialogPrivate() proxyModel(0), #endif model(0), - fileMode(QFileDialog::AnyFile), - acceptMode(QFileDialog::AcceptOpen), currentHistoryLocation(-1), renameAction(0), deleteAction(0), showHiddenAction(0), useDefaultCaption(true), defaultFileTypes(true), - fileNameLabelExplicitlySat(false), - qFileDialogUi(0) + qFileDialogUi(0), + options(new QFileDialogOptions) { } @@ -524,12 +522,49 @@ QFileDialogPrivate::~QFileDialogPrivate() { } +void QFileDialogPrivate::initHelper(QPlatformDialogHelper *h) +{ + QFileDialog *d = q_func(); + QObject::connect(h, SIGNAL(fileSelected(QString)), d, SIGNAL(fileSelected(QString))); + QObject::connect(h, SIGNAL(filesSelected(QStringList)), d, SIGNAL(filesSelected(QStringList))); + QObject::connect(h, SIGNAL(currentChanged(QString)), d, SIGNAL(currentChanged(QString))); + QObject::connect(h, SIGNAL(directoryEntered(QString)), d, SIGNAL(directoryEntered(QString))); + QObject::connect(h, SIGNAL(filterSelected(QString)), d, SIGNAL(filterSelected(QString))); + static_cast<QPlatformFileDialogHelper *>(h)->setOptions(options); +} + +void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) +{ + Q_Q(QFileDialog); + options->setWindowTitle(q->windowTitle()); + options->setViewMode(static_cast<QFileDialogOptions::ViewMode>(q->viewMode())); + options->setHistory(q->history()); + options->setSidebarUrls(qFileDialogUi->sidebar->urls()); + const QDir directory = q->directory(); + options->setInitialDirectory(directory.exists() ? + directory.absolutePath() : + QString()); + options->setInitiallySelectedNameFilter(q->selectedNameFilter()); + options->setInitiallySelectedFiles(q->selectedFiles()); +} + +void QFileDialogPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *) +{ + if (code == QDialog::Accepted) { + Q_Q(QFileDialog); + q->setViewMode(static_cast<QFileDialog::ViewMode>(options->viewMode())); + q->setSidebarUrls(options->sidebarUrls()); + q->setHistory(options->history()); + } +} + void QFileDialogPrivate::retranslateWindowTitle() { Q_Q(QFileDialog); if (!useDefaultCaption || setWindowTitle != q->windowTitle()) return; - if (acceptMode == QFileDialog::AcceptOpen) { + if (q->acceptMode() == QFileDialog::AcceptOpen) { + const QFileDialog::FileMode fileMode = q->fileMode(); if (fileMode == QFileDialog::DirectoryOnly || fileMode == QFileDialog::Directory) q->setWindowTitle(QFileDialog::tr("Find Directory")); else @@ -545,6 +580,46 @@ void QFileDialogPrivate::setLastVisitedDirectory(const QString &dir) *lastVisitedDir() = dir; } +void QFileDialogPrivate::updateFileNameLabel() +{ + if (!options->isLabelExplicitlySet(QFileDialogOptions::FileName)) { + switch (q_func()->fileMode()) { + case QFileDialog::DirectoryOnly: + case QFileDialog::Directory: + setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("Directory:")); + break; + default: + setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("File &name:")); + break; + } + } +} + +void QFileDialogPrivate::updateOkButtonText(bool saveAsOnFolder) +{ + Q_Q(QFileDialog); + // 'Save as' at a folder: Temporarily change to "Open". + if (saveAsOnFolder) { + setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Open")); + } else if (options->isLabelExplicitlySet(QFileDialogOptions::Accept)) { + setLabelTextControl(QFileDialog::Accept, options->labelText(QFileDialogOptions::Accept)); + return; + } else { + switch (q->fileMode()) { + case QFileDialog::DirectoryOnly: + case QFileDialog::Directory: + setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Choose")); + break; + default: + setLabelTextControl(QFileDialog::Accept, + q->acceptMode() == QFileDialog::AcceptOpen ? + QFileDialog::tr("&Open") : + QFileDialog::tr("&Save")); + break; + } + } +} + void QFileDialogPrivate::retranslateStrings() { Q_Q(QFileDialog); @@ -569,15 +644,7 @@ void QFileDialogPrivate::retranslateStrings() showHiddenAction->setText(QFileDialog::tr("Show &hidden files")); newFolderAction->setText(QFileDialog::tr("&New Folder")); qFileDialogUi->retranslateUi(q); - - if (!fileNameLabelExplicitlySat){ - if (fileMode == QFileDialog::DirectoryOnly || fileMode == QFileDialog::Directory) { - q->setLabelText(QFileDialog::FileName, QFileDialog::tr("Directory:")); - } else { - q->setLabelText(QFileDialog::FileName, QFileDialog::tr("File &name:")); - } - fileNameLabelExplicitlySat = false; - } + updateFileNameLabel(); } void QFileDialogPrivate::emitFilesSelected(const QStringList &files) @@ -595,7 +662,7 @@ bool QFileDialogPrivate::canBeNativeDialog() return true; if (q->testAttribute(Qt::WA_DontShowOnScreen)) return false; - if (opts & QFileDialog::DontUseNativeDialog) + if (q->options() & QFileDialog::DontUseNativeDialog) return false; QLatin1String staticName(QFileDialog::staticMetaObject.className()); @@ -612,9 +679,9 @@ bool QFileDialogPrivate::canBeNativeDialog() */ void QFileDialog::setOption(Option option, bool on) { - Q_D(QFileDialog); - if (!(d->opts & option) != !on) - setOptions(d->opts ^ option); + const QFileDialog::Options previousOptions = options(); + if (!(previousOptions & option) != !on) + setOptions(previousOptions ^ option); } /*! @@ -628,7 +695,7 @@ void QFileDialog::setOption(Option option, bool on) bool QFileDialog::testOption(Option option) const { Q_D(const QFileDialog); - return (d->opts & option) != 0; + return d->options->testOption(static_cast<QFileDialogOptions::FileDialogOption>(option)); } /*! @@ -648,11 +715,11 @@ void QFileDialog::setOptions(Options options) { Q_D(QFileDialog); - Options changed = (options ^ d->opts); + Options changed = (options ^ QFileDialog::options()); if (!changed) return; - d->opts = options; + d->options->setOptions(QFileDialogOptions::FileDialogOptions(int(options))); if (changed & DontResolveSymlinks) d->model->setResolveSymlinks(!(options & DontResolveSymlinks)); if (changed & ReadOnly) { @@ -663,7 +730,7 @@ void QFileDialog::setOptions(Options options) d->deleteAction->setEnabled(!ro); } if (changed & HideNameFilterDetails) - setNameFilters(d->nameFilters); + setNameFilters(d->options->nameFilters()); if (changed & ShowDirsOnly) setFilter((options & ShowDirsOnly) ? filter() & ~QDir::Files : filter() | QDir::Files); @@ -672,7 +739,7 @@ void QFileDialog::setOptions(Options options) QFileDialog::Options QFileDialog::options() const { Q_D(const QFileDialog); - return d->opts; + return QFileDialog::Options(int(d->options->options())); } /*! @@ -942,6 +1009,7 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList filesT QString name = toInternal(filesToFix.at(i)); QFileInfo info(name); // if the filename has no suffix, add the default suffix + const QString defaultSuffix = options->defaultSuffix(); if (!defaultSuffix.isEmpty() && !info.isDir() && name.lastIndexOf(QLatin1Char('.')) == -1) name += QLatin1Char('.') + defaultSuffix; if (info.isAbsolute()) { @@ -981,8 +1049,8 @@ QStringList QFileDialog::selectedFiles() const if (files.isEmpty() && !d->lineEdit()->text().isEmpty()) files = d->typedFiles(); - - if (files.isEmpty() && !(d->fileMode == ExistingFile || d->fileMode == ExistingFiles)) + const FileMode fm = fileMode(); + if (files.isEmpty() && !(fm == ExistingFile || fm == ExistingFiles)) files.append(d->rootIndex().data(QFileSystemModel::FilePathRole).toString()); return files; } @@ -1095,12 +1163,7 @@ void QFileDialog::setNameFilters(const QStringList &filters) for (int i = 0; i < filters.count(); ++i) { cleanedFilters << filters[i].simplified(); } - d->nameFilters = cleanedFilters; - - if (d->nativeDialogInUse){ - d->setNameFilters_sys(cleanedFilters); - return; - } + d->options->setNameFilters(cleanedFilters); d->qFileDialogUi->fileTypeCombo->clear(); if (cleanedFilters.isEmpty()) @@ -1132,7 +1195,7 @@ void QFileDialog::setFilters(const QStringList &filters) */ QStringList QFileDialog::nameFilters() const { - return d_func()->nameFilters; + return d_func()->options->nameFilters(); } /*! @@ -1236,6 +1299,7 @@ void QFileDialog::setFilter(QDir::Filters filters) { Q_D(QFileDialog); d->model->setFilter(filters); + d->options->setFilter(filters); if (d->nativeDialogInUse){ d->setFilter_sys(); return; @@ -1286,7 +1350,7 @@ QFileDialog::ViewMode QFileDialog::viewMode() const void QFileDialog::setFileMode(QFileDialog::FileMode mode) { Q_D(QFileDialog); - d->fileMode = mode; + d->options->setFileMode(static_cast<QFileDialogOptions::FileMode>(mode)); d->retranslateWindowTitle(); // keep ShowDirsOnly option in sync with fileMode (BTW, DirectoryOnly is obsolete) @@ -1303,24 +1367,13 @@ void QFileDialog::setFileMode(QFileDialog::FileMode mode) // set filter d->model->setFilter(d->filterForMode(filter())); // setup file type for directory - QString buttonText = (d->acceptMode == AcceptOpen ? tr("&Open") : tr("&Save")); if (mode == DirectoryOnly || mode == Directory) { d->qFileDialogUi->fileTypeCombo->clear(); d->qFileDialogUi->fileTypeCombo->addItem(tr("Directories")); d->qFileDialogUi->fileTypeCombo->setEnabled(false); - - if (!d->fileNameLabelExplicitlySat){ - setLabelText(FileName, tr("Directory:")); - d->fileNameLabelExplicitlySat = false; - } - buttonText = tr("&Choose"); - } else { - if (!d->fileNameLabelExplicitlySat){ - setLabelText(FileName, tr("File &name:")); - d->fileNameLabelExplicitlySat = false; - } } - setLabelText(Accept, buttonText); + d->updateFileNameLabel(); + d->updateOkButtonText(); if (d->nativeDialogInUse){ d->setFilter_sys(); return; @@ -1333,7 +1386,7 @@ void QFileDialog::setFileMode(QFileDialog::FileMode mode) QFileDialog::FileMode QFileDialog::fileMode() const { Q_D(const QFileDialog); - return d->fileMode; + return static_cast<FileMode>(d->options->fileMode()); } /*! @@ -1349,16 +1402,11 @@ QFileDialog::FileMode QFileDialog::fileMode() const void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode) { Q_D(QFileDialog); - d->acceptMode = mode; - bool directoryMode = (d->fileMode == Directory || d->fileMode == DirectoryOnly); + d->options->setAcceptMode(static_cast<QFileDialogOptions::AcceptMode>(mode)); QDialogButtonBox::StandardButton button = (mode == AcceptOpen ? QDialogButtonBox::Open : QDialogButtonBox::Save); d->qFileDialogUi->buttonBox->setStandardButtons(button | QDialogButtonBox::Cancel); d->qFileDialogUi->buttonBox->button(button)->setEnabled(false); d->_q_updateOkButton(); - if (mode == AcceptOpen && directoryMode) - setLabelText(Accept, tr("&Choose")); - else - setLabelText(Accept, (mode == AcceptOpen ? tr("&Open") : tr("&Save"))); if (mode == AcceptSave) { d->qFileDialogUi->lookInCombo->setEditable(false); } @@ -1415,7 +1463,7 @@ QModelIndex QFileDialogPrivate::select(const QModelIndex &index) const { QFileDialog::AcceptMode QFileDialog::acceptMode() const { Q_D(const QFileDialog); - return d->acceptMode; + return static_cast<AcceptMode>(d->options->acceptMode()); } /*! @@ -1490,13 +1538,13 @@ bool QFileDialog::confirmOverwrite() const void QFileDialog::setDefaultSuffix(const QString &suffix) { Q_D(QFileDialog); - d->defaultSuffix = suffix; + d->options->setDefaultSuffix(suffix); } QString QFileDialog::defaultSuffix() const { Q_D(const QFileDialog); - return d->defaultSuffix; + return d->options->defaultSuffix(); } /*! @@ -1587,42 +1635,46 @@ QFileIconProvider *QFileDialog::iconProvider() const return d->model->iconProvider(); } -/*! - Sets the \a text shown in the filedialog in the specified \a label. -*/ -void QFileDialog::setLabelText(DialogLabel label, const QString &text) +void QFileDialogPrivate::setLabelTextControl(QFileDialog::DialogLabel label, const QString &text) { - Q_D(QFileDialog); - QPushButton *button; switch (label) { - case LookIn: - d->qFileDialogUi->lookInLabel->setText(text); + case QFileDialog::LookIn: + qFileDialogUi->lookInLabel->setText(text); break; - case FileName: - d->qFileDialogUi->fileNameLabel->setText(text); - d->fileNameLabelExplicitlySat = true; + case QFileDialog::FileName: + qFileDialogUi->fileNameLabel->setText(text); break; - case FileType: - d->qFileDialogUi->fileTypeLabel->setText(text); + case QFileDialog::FileType: + qFileDialogUi->fileTypeLabel->setText(text); break; - case Accept: - d->acceptLabel = text; - if (acceptMode() == AcceptOpen) - button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Open); - else - button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Save); - if (button) - button->setText(text); + case QFileDialog::Accept: + if (q_func()->acceptMode() == QFileDialog::AcceptOpen) { + if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Open)) + button->setText(text); + } else { + if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Save)) + button->setText(text); + } break; - case Reject: - button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel); - if (button) + case QFileDialog::Reject: + if (QPushButton *button = qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel)) button->setText(text); break; } } /*! + Sets the \a text shown in the filedialog in the specified \a label. +*/ + +void QFileDialog::setLabelText(DialogLabel label, const QString &text) +{ + Q_D(QFileDialog); + d->options->setLabelText(static_cast<QFileDialogOptions::DialogLabel>(label), text); + d->setLabelTextControl(label, text); +} + +/*! Returns the text shown in the filedialog in the specified \a label. */ QString QFileDialog::labelText(DialogLabel label) const @@ -2136,7 +2188,7 @@ void QFileDialog::accept() return; } - switch (d->fileMode) { + switch (fileMode()) { case DirectoryOnly: case Directory: { QString fn = files.first(); @@ -2235,7 +2287,7 @@ void QFileDialogPrivate::init(const QString &directory, const QString &nameFilte createWidgets(); createMenuActions(); retranslateStrings(); - q->setFileMode(fileMode); + q->setFileMode(QFileDialog::AnyFile); #ifndef QT_NO_SETTINGS QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); @@ -2271,6 +2323,7 @@ void QFileDialogPrivate::createWidgets() { Q_Q(QFileDialog); model = new QFileSystemModel(q); + options->setFilter(model->filter()); model->setObjectName(QLatin1String("qt_filesystem_model")); if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) model->setNameFilterDisables(helper->defaultNameFilterDisables()); @@ -2290,22 +2343,21 @@ void QFileDialogPrivate::createWidgets() QList<QUrl> initialBookmarks; initialBookmarks << QUrl::fromLocalFile(QLatin1String("")) << QUrl::fromLocalFile(QDir::homePath()); - qFileDialogUi->sidebar->init(model, initialBookmarks); + qFileDialogUi->sidebar->setModelAndUrls(model, initialBookmarks); QFileDialog::connect(qFileDialogUi->sidebar, SIGNAL(goToUrl(QUrl)), q, SLOT(_q_goToUrl(QUrl))); QObject::connect(qFileDialogUi->buttonBox, SIGNAL(accepted()), q, SLOT(accept())); QObject::connect(qFileDialogUi->buttonBox, SIGNAL(rejected()), q, SLOT(reject())); - - qFileDialogUi->lookInCombo->init(this); + qFileDialogUi->lookInCombo->setFileDialogPrivate(this); QObject::connect(qFileDialogUi->lookInCombo, SIGNAL(activated(QString)), q, SLOT(_q_goToDirectory(QString))); qFileDialogUi->lookInCombo->setInsertPolicy(QComboBox::NoInsert); qFileDialogUi->lookInCombo->setDuplicatesEnabled(false); // filename - qFileDialogUi->fileNameEdit->init(this); + qFileDialogUi->fileNameEdit->setFileDialogPrivate(this); #ifndef QT_NO_SHORTCUT qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit); #endif @@ -2329,7 +2381,7 @@ void QFileDialogPrivate::createWidgets() QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(QString)), q, SIGNAL(filterSelected(QString))); - qFileDialogUi->listView->init(this); + qFileDialogUi->listView->setFileDialogPrivate(this); qFileDialogUi->listView->setModel(model); QObject::connect(qFileDialogUi->listView, SIGNAL(activated(QModelIndex)), q, SLOT(_q_enterDirectory(QModelIndex))); @@ -2341,7 +2393,7 @@ void QFileDialogPrivate::createWidgets() QObject::connect(shortcut, SIGNAL(activated()), q, SLOT(_q_deleteCurrent())); #endif - qFileDialogUi->treeView->init(this); + qFileDialogUi->treeView->setFileDialogPrivate(this); qFileDialogUi->treeView->setModel(model); QHeaderView *treeHeader = qFileDialogUi->treeView->header(); QFontMetrics fm(q->font()); @@ -2850,10 +2902,11 @@ void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text) void QFileDialogPrivate::_q_updateOkButton() { Q_Q(QFileDialog); - QPushButton *button = qFileDialogUi->buttonBox->button((acceptMode == QFileDialog::AcceptOpen) + QPushButton *button = qFileDialogUi->buttonBox->button((q->acceptMode() == QFileDialog::AcceptOpen) ? QDialogButtonBox::Open : QDialogButtonBox::Save); if (!button) return; + const QFileDialog::FileMode fileMode = q->fileMode(); bool enableButton = true; bool isOpenDirectory = false; @@ -2863,8 +2916,7 @@ void QFileDialogPrivate::_q_updateOkButton() if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1Char('\\'))) { button->setEnabled(true); - if (acceptMode == QFileDialog::AcceptSave) - button->setText(acceptLabel); + updateOkButtonText(); return; } @@ -2938,8 +2990,7 @@ void QFileDialogPrivate::_q_updateOkButton() } button->setEnabled(enableButton); - if (acceptMode == QFileDialog::AcceptSave) - button->setText(isOpenDirectory ? QFileDialog::tr("&Open") : acceptLabel); + updateOkButtonText(isOpenDirectory); } /*! @@ -2964,6 +3015,7 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index) QModelIndex sourceIndex = index.model() == proxyModel ? mapToSource(index) : index; QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString(); if (path.isEmpty() || model->isDir(sourceIndex)) { + const QFileDialog::FileMode fileMode = q->fileMode(); q->setDirectory(path); emit q->directoryEntered(path); if (fileMode == QFileDialog::Directory @@ -3032,14 +3084,16 @@ QStringList QFileDialogPrivate::qt_clean_filter_list(const QString &filter) */ void QFileDialogPrivate::_q_useNameFilter(int index) { + QStringList nameFilters = options->nameFilters(); if (index == nameFilters.size()) { QAbstractItemModel *comboModel = qFileDialogUi->fileTypeCombo->model(); nameFilters.append(comboModel->index(comboModel->rowCount() - 1, 0).data().toString()); + options->setNameFilters(nameFilters); } QString nameFilter = nameFilters.at(index); QStringList newNameFilters = qt_clean_filter_list(nameFilter); - if (acceptMode == QFileDialog::AcceptSave) { + if (q_func()->acceptMode() == QFileDialog::AcceptSave) { QString newNameFilterExtension; if (newNameFilters.count() > 0) newNameFilterExtension = QFileInfo(newNameFilters.at(0)).suffix(); @@ -3066,6 +3120,7 @@ void QFileDialogPrivate::_q_useNameFilter(int index) */ void QFileDialogPrivate::_q_selectionChanged() { + const QFileDialog::FileMode fileMode = q_func()->fileMode(); QModelIndexList indexes = qFileDialogUi->listView->selectionModel()->selectedRows(); bool stripDirs = (fileMode != QFileDialog::DirectoryOnly && fileMode != QFileDialog::Directory); @@ -3121,18 +3176,13 @@ void QFileDialogPrivate::_q_rowsInserted(const QModelIndex &parent) void QFileDialogPrivate::_q_fileRenamed(const QString &path, const QString oldName, const QString newName) { + const QFileDialog::FileMode fileMode = q_func()->fileMode(); if (fileMode == QFileDialog::Directory || fileMode == QFileDialog::DirectoryOnly) { if (path == rootPath() && lineEdit()->text() == oldName) lineEdit()->setText(newName); } } -void QFileDialogPrivate::_q_platformRunNativeAppModalPanel() -{ - if (nativeDialogInUse) - platformHelper()->_q_platformRunNativeAppModalPanel(); -} - /*! \internal @@ -3181,7 +3231,7 @@ QString QFileDialogPrivate::getEnvironmentVariable(const QString &string) return string; } -void QFileDialogComboBox::init(QFileDialogPrivate *d_pointer) { +void QFileDialogComboBox::setFileDialogPrivate(QFileDialogPrivate *d_pointer) { d_ptr = d_pointer; urlModel = new QUrlModel(this); urlModel->showFullPath = true; @@ -3257,7 +3307,7 @@ QFileDialogListView::QFileDialogListView(QWidget *parent) : QListView(parent) { } -void QFileDialogListView::init(QFileDialogPrivate *d_pointer) +void QFileDialogListView::setFileDialogPrivate(QFileDialogPrivate *d_pointer) { d_ptr = d_pointer; setSelectionBehavior(QAbstractItemView::SelectRows); @@ -3294,7 +3344,7 @@ QFileDialogTreeView::QFileDialogTreeView(QWidget *parent) : QTreeView(parent) { } -void QFileDialogTreeView::init(QFileDialogPrivate *d_pointer) +void QFileDialogTreeView::setFileDialogPrivate(QFileDialogPrivate *d_pointer) { d_ptr = d_pointer; setSelectionBehavior(QAbstractItemView::SelectRows); diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h index df33fdb265..ac011e634a 100644 --- a/src/widgets/dialogs/qfiledialog.h +++ b/src/widgets/dialogs/qfiledialog.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfiledialog.ui b/src/widgets/dialogs/qfiledialog.ui index 9d61de351f..ff86e9cc13 100644 --- a/src/widgets/dialogs/qfiledialog.ui +++ b/src/widgets/dialogs/qfiledialog.ui @@ -1,7 +1,7 @@ <ui version="4.0" > <comment>********************************************************************* ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfiledialog_embedded.ui b/src/widgets/dialogs/qfiledialog_embedded.ui index f067d31f62..5eb9f52a12 100644 --- a/src/widgets/dialogs/qfiledialog_embedded.ui +++ b/src/widgets/dialogs/qfiledialog_embedded.ui @@ -1,7 +1,7 @@ <ui version="4.0" > <comment>********************************************************************* ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfiledialog_mac.mm b/src/widgets/dialogs/qfiledialog_mac.mm index 1a9f36892d..fe3c41a4b7 100644 --- a/src/widgets/dialogs/qfiledialog_mac.mm +++ b/src/widgets/dialogs/qfiledialog_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index 383734950c..30c73ade7b 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -130,6 +130,9 @@ public: QStringList typedFiles() const; QStringList addDefaultSuffixToFiles(const QStringList filesToFix) const; bool removeDirectory(const QString &path); + void setLabelTextControl(QFileDialog::DialogLabel label, const QString &text); + inline void updateFileNameLabel(); + void updateOkButtonText(bool saveAsOnFolder = false); inline QModelIndex mapToSource(const QModelIndex &index) const; inline QModelIndex mapFromSource(const QModelIndex &index) const; @@ -170,6 +173,7 @@ public: QDir::Filters filterForMode(QDir::Filters filters) const { + const QFileDialog::FileMode fileMode = q_func()->fileMode(); if (fileMode == QFileDialog::DirectoryOnly) { filters |= QDir::Drives | QDir::AllDirs | QDir::Dirs; filters &= ~QDir::Files; @@ -224,7 +228,6 @@ public: void _q_autoCompleteFileName(const QString &); void _q_rowsInserted(const QModelIndex & parent); void _q_fileRenamed(const QString &path, const QString oldName, const QString newName); - void _q_platformRunNativeAppModalPanel(); static QStringList qt_clean_filter_list(const QString &filter); static const char *qt_file_dialog_filter_reg_exp; @@ -242,10 +245,6 @@ public: QFSCompleter *completer; #endif //QT_NO_FSCOMPLETER - QFileDialog::FileMode fileMode; - QFileDialog::AcceptMode acceptMode; - bool confirmOverwrite; - QString defaultSuffix; QString setWindowTitle; QStringList currentHistory; @@ -258,8 +257,6 @@ public: bool useDefaultCaption; bool defaultFileTypes; - bool fileNameLabelExplicitlySat; - QStringList nameFilters; // setVisible_sys returns true if it ends up showing a native // dialog. Returning false means that a non-native dialog must be @@ -273,7 +270,6 @@ public: void selectFile_sys(const QString &filename); QStringList selectedFiles_sys() const; void setFilter_sys(); - void setNameFilters_sys(const QStringList &filters); void selectNameFilter_sys(const QString &filter); QString selectedNameFilter_sys() const; ////////////////////////////////////////////// @@ -286,12 +282,14 @@ public: QByteArray memberToDisconnectOnClose; QByteArray signalToDisconnectOnClose; - QFileDialog::Options opts; + QSharedPointer<QFileDialogOptions> options; ~QFileDialogPrivate(); private: virtual void initHelper(QPlatformDialogHelper *); + virtual void helperPrepareShow(QPlatformDialogHelper *); + virtual void helperDone(QDialog::DialogCode, QPlatformDialogHelper *); Q_DISABLE_COPY(QFileDialogPrivate) }; @@ -300,7 +298,7 @@ class QFileDialogLineEdit : public QLineEdit { public: QFileDialogLineEdit(QWidget *parent = 0) : QLineEdit(parent), hideOnEsc(false), d_ptr(0){} - void init(QFileDialogPrivate *d_pointer) {d_ptr = d_pointer; } + void setFileDialogPrivate(QFileDialogPrivate *d_pointer) {d_ptr = d_pointer; } void keyPressEvent(QKeyEvent *e); bool hideOnEsc; private: @@ -311,7 +309,7 @@ class QFileDialogComboBox : public QComboBox { public: QFileDialogComboBox(QWidget *parent = 0) : QComboBox(parent), urlModel(0) {} - void init(QFileDialogPrivate *d_pointer); + void setFileDialogPrivate(QFileDialogPrivate *d_pointer); void showPopup(); void setHistory(const QStringList &paths); QStringList history() const { return m_history; } @@ -327,7 +325,7 @@ class QFileDialogListView : public QListView { public: QFileDialogListView(QWidget *parent = 0); - void init(QFileDialogPrivate *d_pointer); + void setFileDialogPrivate(QFileDialogPrivate *d_pointer); QSize sizeHint() const; protected: void keyPressEvent(QKeyEvent *e); @@ -339,7 +337,7 @@ class QFileDialogTreeView : public QTreeView { public: QFileDialogTreeView(QWidget *parent); - void init(QFileDialogPrivate *d_pointer); + void setFileDialogPrivate(QFileDialogPrivate *d_pointer); QSize sizeHint() const; protected: @@ -348,16 +346,6 @@ private: QFileDialogPrivate *d_ptr; }; -void QFileDialogPrivate::initHelper(QPlatformDialogHelper *h) -{ - QFileDialog *d = q_func(); - QObject::connect(h, SIGNAL(fileSelected(QString)), d, SIGNAL(fileSelected(QString))); - QObject::connect(h, SIGNAL(filesSelected(QStringList)), d, SIGNAL(filesSelected(QStringList))); - QObject::connect(h, SIGNAL(currentChanged(QString)), d, SIGNAL(currentChanged(QString))); - QObject::connect(h, SIGNAL(directoryEntered(QString)), d, SIGNAL(directoryEntered(QString))); - QObject::connect(h, SIGNAL(filterSelected(QString)), d, SIGNAL(filterSelected(QString))); -} - inline QModelIndex QFileDialogPrivate::mapToSource(const QModelIndex &index) const { #ifdef QT_NO_PROXYMODEL return index; @@ -427,12 +415,6 @@ inline void QFileDialogPrivate::setFilter_sys() helper->setFilter_sys(); } -inline void QFileDialogPrivate::setNameFilters_sys(const QStringList &filters) -{ - if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) - helper->setNameFilters_sys(filters); -} - inline void QFileDialogPrivate::selectNameFilter_sys(const QString &filter) { if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index 315b93131f..bce8b3ecc1 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -280,10 +280,11 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil { #ifndef QT_NO_FILESYSTEMWATCHER if (files.isEmpty() - && !watcher->directories().contains(path) && !path.isEmpty() && !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) { - watcher->addPath(path); + QMutexLocker locker(&mutex); + if (!watcher->directories().contains(path)) + watcher->addPath(path); } #endif diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h index 98217c1dc8..3621c6b6ad 100644 --- a/src/widgets/dialogs/qfileinfogatherer_p.h +++ b/src/widgets/dialogs/qfileinfogatherer_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 9de79e0e81..e44a9ea882 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h index ce907cd10e..09e8d9d529 100644 --- a/src/widgets/dialogs/qfilesystemmodel.h +++ b/src/widgets/dialogs/qfilesystemmodel.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index 3d5f5b7f00..2ab7838dad 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 1935a5aa73..c8fb36d9d6 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -495,6 +495,12 @@ void QFontDialogPrivate::initHelper(QPlatformDialogHelper *h) QFontDialog *d = q_func(); QObject::connect(h, SIGNAL(currentFontChanged(QFont)), d, SIGNAL(currentFontChanged(QFont))); QObject::connect(h, SIGNAL(fontSelected(QFont)), d, SIGNAL(fontSelected(QFont))); + static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options); +} + +void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) +{ + options->setWindowTitle(q_func()->windowTitle()); } /* @@ -888,8 +894,7 @@ QFont QFontDialog::selectedFont() const void QFontDialog::setOption(FontDialogOption option, bool on) { Q_D(QFontDialog); - if (!(d->opts & option) != !on) - setOptions(d->opts ^ option); + d->options->setOption(static_cast<QFontDialogOptions::FontDialogOption>(option), on); } /*! @@ -901,7 +906,7 @@ void QFontDialog::setOption(FontDialogOption option, bool on) bool QFontDialog::testOption(FontDialogOption option) const { Q_D(const QFontDialog); - return (d->opts & option) != 0; + return d->options->testOption(static_cast<QFontDialogOptions::FontDialogOption>(option)); } /*! @@ -921,18 +926,17 @@ void QFontDialog::setOptions(FontDialogOptions options) { Q_D(QFontDialog); - FontDialogOptions changed = (options ^ d->opts); - if (!changed) + if (QFontDialog::options() == options) return; - d->opts = options; + d->options->setOptions(QFontDialogOptions::FontDialogOptions(int(options))); d->buttonBox->setVisible(!(options & NoButtons)); } QFontDialog::FontDialogOptions QFontDialog::options() const { Q_D(const QFontDialog); - return d->opts; + return QFontDialog::FontDialogOptions(int(d->options->options())); } #ifdef Q_WS_MAC @@ -1043,7 +1047,7 @@ bool QFontDialogPrivate::canBeNativeDialog() return true; if (q->testAttribute(Qt::WA_DontShowOnScreen)) return false; - if (opts & QFontDialog::DontUseNativeDialog) + if (options->options() & QFontDialog::DontUseNativeDialog) return false; QLatin1String staticName(QFontDialog::staticMetaObject.className()); diff --git a/src/widgets/dialogs/qfontdialog.h b/src/widgets/dialogs/qfontdialog.h index 469a5680e1..f5353d512f 100644 --- a/src/widgets/dialogs/qfontdialog.h +++ b/src/widgets/dialogs/qfontdialog.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfontdialog_mac.mm b/src/widgets/dialogs/qfontdialog_mac.mm index d4d3c6a6f0..71b142cd48 100644 --- a/src/widgets/dialogs/qfontdialog_mac.mm +++ b/src/widgets/dialogs/qfontdialog_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h index ef4e933624..506d52b0b6 100644 --- a/src/widgets/dialogs/qfontdialog_p.h +++ b/src/widgets/dialogs/qfontdialog_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -58,6 +58,7 @@ #include "qfontdatabase.h" #include "qfontdialog.h" #include "qplatformdialoghelper_qpa.h" +#include "qsharedpointer.h" #ifndef QT_NO_FONTDIALOG @@ -78,7 +79,7 @@ class QFontDialogPrivate : public QDialogPrivate public: inline QFontDialogPrivate() - : writingSystem(QFontDatabase::Any) + : writingSystem(QFontDatabase::Any), options(new QFontDialogOptions) { } QPlatformFontDialogHelper *platformFontDialogHelper() const @@ -138,7 +139,7 @@ public: int size; bool smoothScalable; QFont selectedFont; - QFontDialog::FontDialogOptions opts; + QSharedPointer<QFontDialogOptions> options; QPointer<QObject> receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; @@ -163,6 +164,7 @@ public: private: virtual void initHelper(QPlatformDialogHelper *); + virtual void helperPrepareShow(QPlatformDialogHelper *); }; #endif // QT_NO_FONTDIALOG diff --git a/src/widgets/dialogs/qfscompleter_p.h b/src/widgets/dialogs/qfscompleter_p.h index e078542cdc..c25bcf20cb 100644 --- a/src/widgets/dialogs/qfscompleter_p.h +++ b/src/widgets/dialogs/qfscompleter_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index 808858a711..dc7e30368b 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qinputdialog.h b/src/widgets/dialogs/qinputdialog.h index 93abdaec22..164e0d1014 100644 --- a/src/widgets/dialogs/qinputdialog.h +++ b/src/widgets/dialogs/qinputdialog.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 1dbdeff1a7..fdba17d0ce 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -538,8 +538,8 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 6 This is the approach recommended in the - \l{http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGWindows/chapter_18_section_7.html} - {Mac OS X Guidlines}. Similar guidlines apply for the other + \l{http://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/AppleHIGuidelines/Windows/Windows.html#//apple_ref/doc/uid/20000961-BABCAJID} + {Mac OS X Guidelines}. Similar guidelines apply for the other platforms, but note the different ways the \l{QMessageBox::informativeText} {informative text} is handled for different platforms. @@ -1778,7 +1778,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) "to comply with the terms of the GNU GPL version 3.0.</p>" "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> " "for an overview of Qt licensing.</p>" - "<p>Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).</p>" + "<p>Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).</p>" "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> " "for more information.</p>" ); diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index ebfd28a1aa..4774389a69 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qnspanelproxy_mac.mm b/src/widgets/dialogs/qnspanelproxy_mac.mm index 1de548413a..4f171eab74 100644 --- a/src/widgets/dialogs/qnspanelproxy_mac.mm +++ b/src/widgets/dialogs/qnspanelproxy_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index c38d79e58c..3cf576462d 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qprogressdialog.h b/src/widgets/dialogs/qprogressdialog.h index b981e5ef63..6089de3f80 100644 --- a/src/widgets/dialogs/qprogressdialog.h +++ b/src/widgets/dialogs/qprogressdialog.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index 8efbb8dfcd..b62afec9bf 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -371,7 +371,7 @@ QSidebar::QSidebar(QWidget *parent) : QListView(parent) { } -void QSidebar::init(QFileSystemModel *model, const QList<QUrl> &newUrls) +void QSidebar::setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls) { // ### TODO make icon size dynamic setIconSize(QSize(24,24)); diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h index 6ad2716780..265408b4ef 100644 --- a/src/widgets/dialogs/qsidebar_p.h +++ b/src/widgets/dialogs/qsidebar_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -121,7 +121,7 @@ Q_SIGNALS: public: QSidebar(QWidget *parent = 0); - void init(QFileSystemModel *model, const QList<QUrl> &newUrls); + void setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls); ~QSidebar(); QSize sizeHint() const; diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 81e23fbb18..dbdff5e34d 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index 77eef53037..f9af57c0b1 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 075c8b81bb..06640a5864 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h index f53a9ba75c..ab16d293af 100644 --- a/src/widgets/dialogs/qwizard_win_p.h +++ b/src/widgets/dialogs/qwizard_win_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp index 45f31d8062..ac33bffd6c 100644 --- a/src/widgets/effects/qgraphicseffect.cpp +++ b/src/widgets/effects/qgraphicseffect.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/effects/qgraphicseffect.h b/src/widgets/effects/qgraphicseffect.h index 0ee6b26463..e8e97aa7e7 100644 --- a/src/widgets/effects/qgraphicseffect.h +++ b/src/widgets/effects/qgraphicseffect.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/effects/qgraphicseffect_p.h b/src/widgets/effects/qgraphicseffect_p.h index ac15f04d05..b2859f9a41 100644 --- a/src/widgets/effects/qgraphicseffect_p.h +++ b/src/widgets/effects/qgraphicseffect_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp index 9cdedc19a3..826bf2e93d 100644 --- a/src/widgets/effects/qpixmapfilter.cpp +++ b/src/widgets/effects/qpixmapfilter.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/effects/qpixmapfilter_p.h b/src/widgets/effects/qpixmapfilter_p.h index b0edd8d4b0..3f6ed069a1 100644 --- a/src/widgets/effects/qpixmapfilter_p.h +++ b/src/widgets/effects/qpixmapfilter_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraph_p.h b/src/widgets/graphicsview/qgraph_p.h index 3b9d839a17..676000ac3e 100644 --- a/src/widgets/graphicsview/qgraph_p.h +++ b/src/widgets/graphicsview/qgraph_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -121,8 +121,8 @@ public: private: const Graph *g; - Q_TYPENAME QHash<Vertex *, QHash<Vertex *, EdgeData *> * >::const_iterator row; - Q_TYPENAME QHash<Vertex *, EdgeData *>::const_iterator column; + typename QHash<Vertex *, QHash<Vertex *, EdgeData *> * >::const_iterator row; + typename QHash<Vertex *, EdgeData *>::const_iterator column; }; const_iterator constBegin() const { @@ -228,7 +228,7 @@ public: QString edges; QSet<Vertex *> setOfVertices = vertices(); - for (Q_TYPENAME QSet<Vertex*>::const_iterator it = setOfVertices.begin(); it != setOfVertices.end(); ++it) { + for (typename QSet<Vertex*>::const_iterator it = setOfVertices.begin(); it != setOfVertices.end(); ++it) { Vertex *v = *it; QList<Vertex*> adjacents = adjacentVertices(v); for (int i = 0; i < adjacents.count(); ++i) { diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp index 3bd83ae6c4..3fb768d30a 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.h b/src/widgets/graphicsview/qgraphicsanchorlayout.h index 4e57dbccf9..8db6391987 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout.h +++ b/src/widgets/graphicsview/qgraphicsanchorlayout.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index c9bda58123..2ac3953676 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h index d78e5c89c3..21524e9157 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp index dd4102fdb9..fb4cf954e4 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayout.cpp +++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.h b/src/widgets/graphicsview/qgraphicsgridlayout.h index c6bc2229b6..749af57b0a 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayout.h +++ b/src/widgets/graphicsview/qgraphicsgridlayout.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index b30d29e704..eb77aee9ae 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index 811305ac9d..3873857b8a 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h index 3cd77f3cdb..beedbfaa27 100644 --- a/src/widgets/graphicsview/qgraphicsitem_p.h +++ b/src/widgets/graphicsview/qgraphicsitem_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp index a0b7ea4002..10c292bed1 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp +++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h index a6425a50e4..1f17d7e2e5 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.h +++ b/src/widgets/graphicsview/qgraphicsitemanimation.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicslayout.cpp b/src/widgets/graphicsview/qgraphicslayout.cpp index 0f463334cc..6c8a2662be 100644 --- a/src/widgets/graphicsview/qgraphicslayout.cpp +++ b/src/widgets/graphicsview/qgraphicslayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicslayout.h b/src/widgets/graphicsview/qgraphicslayout.h index 6b19f0e622..4e5b2a982a 100644 --- a/src/widgets/graphicsview/qgraphicslayout.h +++ b/src/widgets/graphicsview/qgraphicslayout.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicslayout_p.cpp b/src/widgets/graphicsview/qgraphicslayout_p.cpp index c0df2c0d64..ce3525b68d 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicslayout_p.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicslayout_p.h b/src/widgets/graphicsview/qgraphicslayout_p.h index f11bfbf38c..ea98a4a679 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.h +++ b/src/widgets/graphicsview/qgraphicslayout_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.cpp b/src/widgets/graphicsview/qgraphicslayoutitem.cpp index 5eaf0a516e..ff53f1fd95 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem.cpp +++ b/src/widgets/graphicsview/qgraphicslayoutitem.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.h b/src/widgets/graphicsview/qgraphicslayoutitem.h index c617959a06..926a2b15dc 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem.h +++ b/src/widgets/graphicsview/qgraphicslayoutitem.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicslayoutitem_p.h b/src/widgets/graphicsview/qgraphicslayoutitem_p.h index 244c699faa..c13402dc49 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem_p.h +++ b/src/widgets/graphicsview/qgraphicslayoutitem_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp index ee0db09df0..eeb4c0b01c 100644 --- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp +++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.h b/src/widgets/graphicsview/qgraphicslinearlayout.h index 5d2d5c309f..6d869197cf 100644 --- a/src/widgets/graphicsview/qgraphicslinearlayout.h +++ b/src/widgets/graphicsview/qgraphicslinearlayout.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index 1b03879804..2eadec0ef1 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.h b/src/widgets/graphicsview/qgraphicsproxywidget.h index 9f0a711c46..141b61bf09 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.h +++ b/src/widgets/graphicsview/qgraphicsproxywidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsproxywidget_p.h b/src/widgets/graphicsview/qgraphicsproxywidget_p.h index 86aec5f86b..e3e2cd174b 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget_p.h +++ b/src/widgets/graphicsview/qgraphicsproxywidget_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 791f25aa27..a8c3f8dee6 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -5777,8 +5777,8 @@ void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouch for (int i = 0; i < touchPoints.count(); ++i) { QTouchEvent::TouchPoint &touchPoint = touchPoints[i]; touchPoint.setRect(item->mapFromScene(touchPoint.sceneRect()).boundingRect()); - touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), touchEvent->widget())); - touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), touchEvent->widget())); + touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), static_cast<QWidget *>(touchEvent->target()))); + touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), static_cast<QWidget *>(touchEvent->target()))); } touchEvent->setTouchPoints(touchPoints); } @@ -5819,7 +5819,7 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) // determine which item this touch point will go to cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(), touchPoint.scenePos(), - sceneTouchEvent->widget()); + static_cast<QWidget *>(sceneTouchEvent->target())); item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.first(); } @@ -5888,13 +5888,13 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) } QTouchEvent touchEvent(eventType); - touchEvent.setWidget(sceneTouchEvent->widget()); + touchEvent.setWindow(sceneTouchEvent->window()); + touchEvent.setTarget(sceneTouchEvent->target()); touchEvent.setDevice(sceneTouchEvent->device()); touchEvent.setModifiers(sceneTouchEvent->modifiers()); touchEvent.setTouchPointStates(it.value().first); touchEvent.setTouchPoints(it.value().second); touchEvent.setTimestamp(sceneTouchEvent->timestamp()); - touchEvent.setWindow(sceneTouchEvent->window()); switch (touchEvent.type()) { case QEvent::TouchBegin: @@ -5935,7 +5935,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first(); cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(), firstTouchPoint.scenePos(), - touchEvent->widget()); + static_cast<QWidget *>(touchEvent->target())); } Q_ASSERT(cachedItemsUnderMouse.first() == origin); diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index 1b475e4d02..4e06a7483e 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsscene_bsp.cpp b/src/widgets/graphicsview/qgraphicsscene_bsp.cpp index cc8a558ad3..8b35fb0022 100644 --- a/src/widgets/graphicsview/qgraphicsscene_bsp.cpp +++ b/src/widgets/graphicsview/qgraphicsscene_bsp.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsscene_bsp_p.h b/src/widgets/graphicsview/qgraphicsscene_bsp_p.h index 2e8149867b..d371ba5f66 100644 --- a/src/widgets/graphicsview/qgraphicsscene_bsp_p.h +++ b/src/widgets/graphicsview/qgraphicsscene_bsp_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h index 8cb24457d6..a693c0c309 100644 --- a/src/widgets/graphicsview/qgraphicsscene_p.h +++ b/src/widgets/graphicsview/qgraphicsscene_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp index 979ce6823b..1c4653d522 100644 --- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -601,7 +601,7 @@ QList<QGraphicsItem *> QGraphicsSceneBspTreeIndex::items(Qt::SortOrder order) co 10 items. */ -int QGraphicsSceneBspTreeIndex::bspTreeDepth() +int QGraphicsSceneBspTreeIndex::bspTreeDepth() const { Q_D(const QGraphicsSceneBspTreeIndex); return d->bspTreeDepth; diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h index 0b353c74a4..b3b31fca6a 100644 --- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -83,7 +83,7 @@ public: QList<QGraphicsItem *> estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const; QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const; - int bspTreeDepth(); + int bspTreeDepth() const; void setBspTreeDepth(int depth); protected Q_SLOTS: diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp index 4927b6933f..ca6ff59bec 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.cpp +++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicssceneevent.h b/src/widgets/graphicsview/qgraphicssceneevent.h index f3677fbef8..cf88a66e3c 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.h +++ b/src/widgets/graphicsview/qgraphicssceneevent.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicssceneindex.cpp b/src/widgets/graphicsview/qgraphicssceneindex.cpp index d5ca504cae..8fb6c666a0 100644 --- a/src/widgets/graphicsview/qgraphicssceneindex.cpp +++ b/src/widgets/graphicsview/qgraphicssceneindex.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicssceneindex_p.h b/src/widgets/graphicsview/qgraphicssceneindex_p.h index d7e01f64b3..eff75e89b1 100644 --- a/src/widgets/graphicsview/qgraphicssceneindex_p.h +++ b/src/widgets/graphicsview/qgraphicssceneindex_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp b/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp index 9a4b3389bc..08fcdaf08d 100644 --- a/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp +++ b/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h index 37ba363c1e..fdd6a82bda 100644 --- a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h +++ b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicstransform.cpp b/src/widgets/graphicsview/qgraphicstransform.cpp index c0cc571bd4..33e3a3cc4d 100644 --- a/src/widgets/graphicsview/qgraphicstransform.cpp +++ b/src/widgets/graphicsview/qgraphicstransform.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicstransform.h b/src/widgets/graphicsview/qgraphicstransform.h index 4bceecc47c..8e93a5ee76 100644 --- a/src/widgets/graphicsview/qgraphicstransform.h +++ b/src/widgets/graphicsview/qgraphicstransform.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h index d2b851fe97..976ffed2c3 100644 --- a/src/widgets/graphicsview/qgraphicstransform_p.h +++ b/src/widgets/graphicsview/qgraphicstransform_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 2ebd4ecc63..4c5c586ec9 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -2836,7 +2836,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) if (d->scene && d->sceneInteractionAllowed) { // Convert and deliver the touch event to the scene. QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); - touchEvent->setWidget(viewport()); + touchEvent->setTarget(viewport()); QGraphicsViewPrivate::translateTouchEvent(d, touchEvent); (void) QApplication::sendEvent(d->scene, touchEvent); } diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h index 19b5753938..2e33548a29 100644 --- a/src/widgets/graphicsview/qgraphicsview.h +++ b/src/widgets/graphicsview/qgraphicsview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicsview_p.h b/src/widgets/graphicsview/qgraphicsview_p.h index 535679f1d8..c8b36bc89f 100644 --- a/src/widgets/graphicsview/qgraphicsview_p.h +++ b/src/widgets/graphicsview/qgraphicsview_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index e1fbdd4aa8..c415c704bc 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h index 8222886411..b469b64acd 100644 --- a/src/widgets/graphicsview/qgraphicswidget.h +++ b/src/widgets/graphicsview/qgraphicswidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index fd5afaabf4..40333fd1b5 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgraphicswidget_p.h b/src/widgets/graphicsview/qgraphicswidget_p.h index 16c5303235..99f5661b98 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.h +++ b/src/widgets/graphicsview/qgraphicswidget_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgridlayoutengine.cpp b/src/widgets/graphicsview/qgridlayoutengine.cpp index 66b4a5b6b4..d5eeea68f2 100644 --- a/src/widgets/graphicsview/qgridlayoutengine.cpp +++ b/src/widgets/graphicsview/qgridlayoutengine.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qgridlayoutengine_p.h b/src/widgets/graphicsview/qgridlayoutengine_p.h index f947d67d5a..f8ef75ab12 100644 --- a/src/widgets/graphicsview/qgridlayoutengine_p.h +++ b/src/widgets/graphicsview/qgridlayoutengine_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp index eb8bcb8c1f..0a1472a384 100644 --- a/src/widgets/graphicsview/qsimplex_p.cpp +++ b/src/widgets/graphicsview/qsimplex_p.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/graphicsview/qsimplex_p.h b/src/widgets/graphicsview/qsimplex_p.h index 3df82c6ccf..82f65bac01 100644 --- a/src/widgets/graphicsview/qsimplex_p.h +++ b/src/widgets/graphicsview/qsimplex_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/itemviews.pri b/src/widgets/itemviews/itemviews.pri index 7ef704546e..d5a5012f83 100644 --- a/src/widgets/itemviews/itemviews.pri +++ b/src/widgets/itemviews/itemviews.pri @@ -4,7 +4,6 @@ HEADERS += \ itemviews/qabstractitemview.h \ itemviews/qabstractitemview_p.h \ itemviews/qheaderview.h \ - itemviews/qidentityproxymodel.h \ itemviews/qlistview.h \ itemviews/qlistview_p.h \ itemviews/qbsptree_p.h \ @@ -14,8 +13,6 @@ HEADERS += \ itemviews/qtreeview_p.h \ itemviews/qabstractitemdelegate.h \ itemviews/qitemdelegate.h \ - itemviews/qitemselectionmodel.h \ - itemviews/qitemselectionmodel_p.h \ itemviews/qdirmodel.h \ itemviews/qlistwidget.h \ itemviews/qlistwidget_p.h \ @@ -26,14 +23,10 @@ HEADERS += \ itemviews/qwidgetitemdata_p.h \ itemviews/qproxymodel.h \ itemviews/qproxymodel_p.h \ - itemviews/qabstractproxymodel.h \ - itemviews/qabstractproxymodel_p.h \ - itemviews/qsortfilterproxymodel.h \ itemviews/qitemeditorfactory.h \ itemviews/qitemeditorfactory_p.h \ itemviews/qstandarditemmodel.h \ itemviews/qstandarditemmodel_p.h \ - itemviews/qstringlistmodel.h \ itemviews/qtreewidgetitemiterator.h \ itemviews/qdatawidgetmapper.h \ itemviews/qfileiconprovider.h \ @@ -45,24 +38,19 @@ HEADERS += \ SOURCES += \ itemviews/qabstractitemview.cpp \ itemviews/qheaderview.cpp \ - itemviews/qidentityproxymodel.cpp \ itemviews/qlistview.cpp \ itemviews/qbsptree.cpp \ itemviews/qtableview.cpp \ itemviews/qtreeview.cpp \ itemviews/qabstractitemdelegate.cpp \ itemviews/qitemdelegate.cpp \ - itemviews/qitemselectionmodel.cpp \ itemviews/qdirmodel.cpp \ itemviews/qlistwidget.cpp \ itemviews/qtablewidget.cpp \ itemviews/qtreewidget.cpp \ itemviews/qproxymodel.cpp \ - itemviews/qabstractproxymodel.cpp \ - itemviews/qsortfilterproxymodel.cpp \ itemviews/qitemeditorfactory.cpp \ itemviews/qstandarditemmodel.cpp \ - itemviews/qstringlistmodel.cpp \ itemviews/qtreewidgetitemiterator.cpp \ itemviews/qdatawidgetmapper.cpp \ itemviews/qfileiconprovider.cpp \ diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index bdc5d69f56..5e000b4d70 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -347,7 +347,6 @@ QString QAbstractItemDelegate::elidedText(const QFontMetrics &fontMetrics, int w \sa QHelpEvent */ -// ### Qt 5: Make this a virtual non-slot function bool QAbstractItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, diff --git a/src/widgets/itemviews/qabstractitemdelegate.h b/src/widgets/itemviews/qabstractitemdelegate.h index f494f0b8c8..315feda69e 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.h +++ b/src/widgets/itemviews/qabstractitemdelegate.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -108,11 +108,10 @@ public: static QString elidedText(const QFontMetrics &fontMetrics, int width, Qt::TextElideMode mode, const QString &text); -public Q_SLOTS: - bool helpEvent(QHelpEvent *event, - QAbstractItemView *view, - const QStyleOptionViewItem &option, - const QModelIndex &index); + virtual bool helpEvent(QHelpEvent *event, + QAbstractItemView *view, + const QStyleOptionViewItem &option, + const QModelIndex &index); Q_SIGNALS: void commitData(QWidget *editor); diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 06544e3146..f4a45fb22e 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -673,8 +673,8 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) { disconnect(d->model, SIGNAL(destroyed()), this, SLOT(_q_modelDestroyed())); - disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(dataChanged(QModelIndex,QModelIndex))); + disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QSet<int>)), + this, SLOT(dataChanged(QModelIndex,QModelIndex,QSet<int>))); disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), this, SLOT(_q_headerDataChanged())); disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), @@ -683,6 +683,8 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); + disconnect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(_q_rowsInserted(QModelIndex,int,int))); disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), @@ -691,6 +693,8 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) this, SLOT(_q_columnsRemoved(QModelIndex,int,int))); disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(_q_columnsInserted(QModelIndex,int,int))); + disconnect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(reset())); disconnect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); @@ -709,8 +713,8 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) if (d->model != QAbstractItemModelPrivate::staticEmptyModel()) { connect(d->model, SIGNAL(destroyed()), this, SLOT(_q_modelDestroyed())); - connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(dataChanged(QModelIndex,QModelIndex))); + connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QSet<int>)), + this, SLOT(dataChanged(QModelIndex,QModelIndex,QSet<int>))); connect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), this, SLOT(_q_headerDataChanged())); connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), @@ -721,12 +725,16 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); + connect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); connect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int))); connect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(_q_columnsRemoved(QModelIndex,int,int))); connect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(_q_columnsInserted(QModelIndex,int,int))); + connect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int))); connect(d->model, SIGNAL(modelReset()), this, SLOT(reset())); connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); @@ -1658,15 +1666,11 @@ bool QAbstractItemView::viewportEvent(QEvent *event) QStyleOptionViewItemV4 option = d->viewOptionsV4(); option.rect = visualRect(index); option.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None); - bool retval = false; - // ### Qt 5: make this a normal function call to a virtual function - QMetaObject::invokeMethod(d->delegateForIndex(index), "helpEvent", - Q_RETURN_ARG(bool, retval), - Q_ARG(QHelpEvent *, he), - Q_ARG(QAbstractItemView *, this), - Q_ARG(QStyleOptionViewItem, option), - Q_ARG(QModelIndex, index)); - return retval; + + QAbstractItemDelegate *delegate = d->delegateForIndex(index); + if (!delegate) + return false; + return delegate->helpEvent(he, this, option, index); } case QEvent::FontChange: d->doDelayedItemsLayout(); // the size of the items will change @@ -3218,7 +3222,7 @@ void QAbstractItemView::update(const QModelIndex &index) inclusive. If just one item is changed \a topLeft == \a bottomRight. */ -void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &) { // Single item changed Q_D(QAbstractItemView); @@ -4292,6 +4296,7 @@ QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes, for (int j = 0; j < paintPairs.count(); ++j) { option.rect = paintPairs.at(j).first.translated(-r->topLeft()); const QModelIndex ¤t = paintPairs.at(j).second; + adjustViewOptionsForIndex(&option, current); delegateForIndex(current)->paint(&painter, option, current); } return pixmap; diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index 25501e67c5..5ab41bae23 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -44,7 +44,7 @@ #include <QtWidgets/qabstractscrollarea.h> #include <QtCore/qabstractitemmodel.h> -#include <QtWidgets/qitemselectionmodel.h> +#include <QtCore/qitemselectionmodel.h> #include <QtWidgets/qabstractitemdelegate.h> QT_BEGIN_HEADER @@ -241,7 +241,7 @@ public Q_SLOTS: void update(const QModelIndex &index); protected Q_SLOTS: - virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &roles = QSet<int>()); virtual void rowsInserted(const QModelIndex &parent, int start, int end); virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index 031e325cff..801bb82d85 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -197,6 +197,8 @@ public: #endif virtual QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; + // reimplemented in subclasses + virtual void adjustViewOptionsForIndex(QStyleOptionViewItemV4*, const QModelIndex&) const {} inline void releaseEditor(QWidget *editor) const { if (editor) { diff --git a/src/widgets/itemviews/qabstractproxymodel.cpp b/src/widgets/itemviews/qabstractproxymodel.cpp deleted file mode 100644 index 47810d6cc7..0000000000 --- a/src/widgets/itemviews/qabstractproxymodel.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qabstractproxymodel.h" - -#ifndef QT_NO_PROXYMODEL - -#include "qitemselectionmodel.h" -#include <private/qabstractproxymodel_p.h> -#include <QtCore/QSize> -#include <QtCore/QStringList> - - -QT_BEGIN_NAMESPACE - -/*! - \since 4.1 - \class QAbstractProxyModel - \brief The QAbstractProxyModel class provides a base class for proxy item - models that can do sorting, filtering or other data processing tasks. - \ingroup model-view - \inmodule QtWidgets - - This class defines the standard interface that proxy models must use to be - able to interoperate correctly with other model/view components. It is not - supposed to be instantiated directly. - - All standard proxy models are derived from the QAbstractProxyModel class. - If you need to create a new proxy model class, it is usually better to - subclass an existing class that provides the closest behavior to the one - you want to provide. - - Proxy models that filter or sort items of data from a source model should - be created by using or subclassing QSortFilterProxyModel. - - To subclass QAbstractProxyModel, you need to implement mapFromSource() and - mapToSource(). The mapSelectionFromSource() and mapSelectionToSource() - functions only need to be reimplemented if you need a behavior different - from the default behavior. - - \note If the source model is deleted or no source model is specified, the - proxy model operates on a empty placeholder model. - - \sa QSortFilterProxyModel, QAbstractItemModel, {Model/View Programming} -*/ - -//detects the deletion of the source model -void QAbstractProxyModelPrivate::_q_sourceModelDestroyed() -{ - model = QAbstractItemModelPrivate::staticEmptyModel(); -} - -/*! - Constructs a proxy model with the given \a parent. -*/ - -QAbstractProxyModel::QAbstractProxyModel(QObject *parent) - :QAbstractItemModel(*new QAbstractProxyModelPrivate, parent) -{ - setSourceModel(QAbstractItemModelPrivate::staticEmptyModel()); -} - -/*! - \internal -*/ - -QAbstractProxyModel::QAbstractProxyModel(QAbstractProxyModelPrivate &dd, QObject *parent) - : QAbstractItemModel(dd, parent) -{ - setSourceModel(QAbstractItemModelPrivate::staticEmptyModel()); -} - -/*! - Destroys the proxy model. -*/ -QAbstractProxyModel::~QAbstractProxyModel() -{ - -} - -/*! - Sets the given \a sourceModel to be processed by the proxy model. -*/ -void QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel) -{ - Q_D(QAbstractProxyModel); - if (d->model) - disconnect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed())); - - if (sourceModel) { - d->model = sourceModel; - connect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed())); - } else { - d->model = QAbstractItemModelPrivate::staticEmptyModel(); - } - d->roleNames = d->model->roleNames(); -} - -/*! - Returns the model that contains the data that is available through the proxy model. -*/ -QAbstractItemModel *QAbstractProxyModel::sourceModel() const -{ - Q_D(const QAbstractProxyModel); - if (d->model == QAbstractItemModelPrivate::staticEmptyModel()) - return 0; - return d->model; -} - -/*! - \reimp - */ -bool QAbstractProxyModel::submit() -{ - Q_D(QAbstractProxyModel); - return d->model->submit(); -} - -/*! - \reimp - */ -void QAbstractProxyModel::revert() -{ - Q_D(QAbstractProxyModel); - d->model->revert(); -} - - -/*! - \fn QModelIndex QAbstractProxyModel::mapToSource(const QModelIndex &proxyIndex) const - - Reimplement this function to return the model index in the source model that - corresponds to the \a proxyIndex in the proxy model. - - \sa mapFromSource() -*/ - -/*! - \fn QModelIndex QAbstractProxyModel::mapFromSource(const QModelIndex &sourceIndex) const - - Reimplement this function to return the model index in the proxy model that - corresponds to the \a sourceIndex from the source model. - - \sa mapToSource() -*/ - -/*! - Returns a source selection mapped from the specified \a proxySelection. - - Reimplement this method to map proxy selections to source selections. - */ -QItemSelection QAbstractProxyModel::mapSelectionToSource(const QItemSelection &proxySelection) const -{ - QModelIndexList proxyIndexes = proxySelection.indexes(); - QItemSelection sourceSelection; - for (int i = 0; i < proxyIndexes.size(); ++i) { - const QModelIndex proxyIdx = mapToSource(proxyIndexes.at(i)); - if (!proxyIdx.isValid()) - continue; - sourceSelection << QItemSelectionRange(proxyIdx); - } - return sourceSelection; -} - -/*! - Returns a proxy selection mapped from the specified \a sourceSelection. - - Reimplement this method to map source selections to proxy selections. -*/ -QItemSelection QAbstractProxyModel::mapSelectionFromSource(const QItemSelection &sourceSelection) const -{ - QModelIndexList sourceIndexes = sourceSelection.indexes(); - QItemSelection proxySelection; - for (int i = 0; i < sourceIndexes.size(); ++i) { - const QModelIndex srcIdx = mapFromSource(sourceIndexes.at(i)); - if (!srcIdx.isValid()) - continue; - proxySelection << QItemSelectionRange(srcIdx); - } - return proxySelection; -} - -/*! - \reimp - */ -QVariant QAbstractProxyModel::data(const QModelIndex &proxyIndex, int role) const -{ - Q_D(const QAbstractProxyModel); - return d->model->data(mapToSource(proxyIndex), role); -} - -/*! - \reimp - */ -QVariant QAbstractProxyModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - Q_D(const QAbstractProxyModel); - int sourceSection; - if (orientation == Qt::Horizontal) { - const QModelIndex proxyIndex = index(0, section); - sourceSection = mapToSource(proxyIndex).column(); - } else { - const QModelIndex proxyIndex = index(section, 0); - sourceSection = mapToSource(proxyIndex).row(); - } - return d->model->headerData(sourceSection, orientation, role); -} - -/*! - \reimp - */ -QMap<int, QVariant> QAbstractProxyModel::itemData(const QModelIndex &proxyIndex) const -{ - Q_D(const QAbstractProxyModel); - return d->model->itemData(mapToSource(proxyIndex)); -} - -/*! - \reimp - */ -Qt::ItemFlags QAbstractProxyModel::flags(const QModelIndex &index) const -{ - Q_D(const QAbstractProxyModel); - return d->model->flags(mapToSource(index)); -} - -/*! - \reimp - */ -bool QAbstractProxyModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - Q_D(QAbstractProxyModel); - return d->model->setData(mapToSource(index), value, role); -} - -/*! - \reimp - */ -bool QAbstractProxyModel::setItemData(const QModelIndex &index, const QMap< int, QVariant >& roles) -{ - Q_D(QAbstractProxyModel); - return d->model->setItemData(mapToSource(index), roles); -} - -/*! - \reimp - */ -bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) -{ - Q_D(QAbstractProxyModel); - int sourceSection; - if (orientation == Qt::Horizontal) { - const QModelIndex proxyIndex = index(0, section); - sourceSection = mapToSource(proxyIndex).column(); - } else { - const QModelIndex proxyIndex = index(section, 0); - sourceSection = mapToSource(proxyIndex).row(); - } - return d->model->setHeaderData(sourceSection, orientation, value, role); -} - -/*! - \reimp - */ -QModelIndex QAbstractProxyModel::buddy(const QModelIndex &index) const -{ - Q_D(const QAbstractProxyModel); - return mapFromSource(d->model->buddy(mapToSource(index))); -} - -/*! - \reimp - */ -bool QAbstractProxyModel::canFetchMore(const QModelIndex &parent) const -{ - Q_D(const QAbstractProxyModel); - return d->model->canFetchMore(mapToSource(parent)); -} - -/*! - \reimp - */ -void QAbstractProxyModel::fetchMore(const QModelIndex &parent) -{ - Q_D(QAbstractProxyModel); - d->model->fetchMore(mapToSource(parent)); -} - -/*! - \reimp - */ -void QAbstractProxyModel::sort(int column, Qt::SortOrder order) -{ - Q_D(QAbstractProxyModel); - d->model->sort(column, order); -} - -/*! - \reimp - */ -QSize QAbstractProxyModel::span(const QModelIndex &index) const -{ - Q_D(const QAbstractProxyModel); - return d->model->span(mapToSource(index)); -} - -/*! - \reimp - */ -bool QAbstractProxyModel::hasChildren(const QModelIndex &parent) const -{ - Q_D(const QAbstractProxyModel); - return d->model->hasChildren(mapToSource(parent)); -} - -/*! - \reimp - */ -QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const -{ - Q_D(const QAbstractProxyModel); - QModelIndexList list; - foreach(const QModelIndex &index, indexes) - list << mapToSource(index); - return d->model->mimeData(list); -} - -/*! - \reimp - */ -QStringList QAbstractProxyModel::mimeTypes() const -{ - Q_D(const QAbstractProxyModel); - return d->model->mimeTypes(); -} - -/*! - \reimp - */ -Qt::DropActions QAbstractProxyModel::supportedDropActions() const -{ - Q_D(const QAbstractProxyModel); - return d->model->supportedDropActions(); -} - -QT_END_NAMESPACE - -#include "moc_qabstractproxymodel.cpp" - -#endif // QT_NO_PROXYMODEL diff --git a/src/widgets/itemviews/qabstractproxymodel.h b/src/widgets/itemviews/qabstractproxymodel.h deleted file mode 100644 index a24755b556..0000000000 --- a/src/widgets/itemviews/qabstractproxymodel.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTPROXYMODEL_H -#define QABSTRACTPROXYMODEL_H - -#include <QtCore/qabstractitemmodel.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_PROXYMODEL - -class QAbstractProxyModelPrivate; -class QItemSelection; - -class Q_WIDGETS_EXPORT QAbstractProxyModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - QAbstractProxyModel(QObject *parent = 0); - ~QAbstractProxyModel(); - - virtual void setSourceModel(QAbstractItemModel *sourceModel); - QAbstractItemModel *sourceModel() const; - - virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const = 0; - virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const = 0; - - virtual QItemSelection mapSelectionToSource(const QItemSelection &selection) const; - virtual QItemSelection mapSelectionFromSource(const QItemSelection &selection) const; - - bool submit(); - void revert(); - - QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QMap<int, QVariant> itemData(const QModelIndex &index) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - bool setItemData(const QModelIndex& index, const QMap<int, QVariant> &roles); - bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole); - - QModelIndex buddy(const QModelIndex &index) const; - bool canFetchMore(const QModelIndex &parent) const; - void fetchMore(const QModelIndex &parent); - void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); - QSize span(const QModelIndex &index) const; - bool hasChildren(const QModelIndex &parent = QModelIndex()) const; - - QMimeData* mimeData(const QModelIndexList &indexes) const; - QStringList mimeTypes() const; - Qt::DropActions supportedDropActions() const; - -protected: - QAbstractProxyModel(QAbstractProxyModelPrivate &, QObject *parent); - -private: - Q_DECLARE_PRIVATE(QAbstractProxyModel) - Q_DISABLE_COPY(QAbstractProxyModel) - Q_PRIVATE_SLOT(d_func(), void _q_sourceModelDestroyed()) -}; - -#endif // QT_NO_PROXYMODEL - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QABSTRACTPROXYMODEL_H diff --git a/src/widgets/itemviews/qabstractproxymodel_p.h b/src/widgets/itemviews/qabstractproxymodel_p.h deleted file mode 100644 index 9bd38d1cdc..0000000000 --- a/src/widgets/itemviews/qabstractproxymodel_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTPROXYMODEL_P_H -#define QABSTRACTPROXYMODEL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of QAbstractItemModel*. This header file may change from version -// to version without notice, or even be removed. -// -// We mean it. -// -// - -#include "private/qabstractitemmodel_p.h" - -#ifndef QT_NO_PROXYMODEL - -QT_BEGIN_NAMESPACE - -class QAbstractProxyModelPrivate : public QAbstractItemModelPrivate -{ - Q_DECLARE_PUBLIC(QAbstractProxyModel) -public: - QAbstractProxyModelPrivate() : QAbstractItemModelPrivate(), model(0) {} - QAbstractItemModel *model; - virtual void _q_sourceModelDestroyed(); -}; - -QT_END_NAMESPACE - -#endif // QT_NO_PROXYMODEL - -#endif // QABSTRACTPROXYMODEL_P_H diff --git a/src/widgets/itemviews/qbsptree.cpp b/src/widgets/itemviews/qbsptree.cpp index 89f98f50f3..a049b9d095 100644 --- a/src/widgets/itemviews/qbsptree.cpp +++ b/src/widgets/itemviews/qbsptree.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qbsptree_p.h b/src/widgets/itemviews/qbsptree_p.h index c98efba6fa..d7404010d1 100644 --- a/src/widgets/itemviews/qbsptree_p.h +++ b/src/widgets/itemviews/qbsptree_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index 3b4bcae847..8b4db02961 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qcolumnview.h b/src/widgets/itemviews/qcolumnview.h index b6d8687808..ac734c131d 100644 --- a/src/widgets/itemviews/qcolumnview.h +++ b/src/widgets/itemviews/qcolumnview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h index 0da719e756..ce1275e220 100644 --- a/src/widgets/itemviews/qcolumnview_p.h +++ b/src/widgets/itemviews/qcolumnview_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qcolumnviewgrip.cpp b/src/widgets/itemviews/qcolumnviewgrip.cpp index 19b8c1aa78..ce25fdac03 100644 --- a/src/widgets/itemviews/qcolumnviewgrip.cpp +++ b/src/widgets/itemviews/qcolumnviewgrip.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qcolumnviewgrip_p.h b/src/widgets/itemviews/qcolumnviewgrip_p.h index 13bdb3694b..2991f070eb 100644 --- a/src/widgets/itemviews/qcolumnviewgrip_p.h +++ b/src/widgets/itemviews/qcolumnviewgrip_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp index 8f5203936d..34699039c4 100644 --- a/src/widgets/itemviews/qdatawidgetmapper.cpp +++ b/src/widgets/itemviews/qdatawidgetmapper.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -104,7 +104,7 @@ public: void populate(); // private slots - void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &); void _q_commitData(QWidget *); void _q_closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint); void _q_modelDestroyed(); @@ -182,7 +182,7 @@ static bool qContainsIndex(const QModelIndex &idx, const QModelIndex &topLeft, && idx.column() >= topLeft.column() && idx.column() <= bottomRight.column(); } -void QDataWidgetMapperPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +void QDataWidgetMapperPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &) { if (topLeft.parent() != rootIndex) return; // not in our hierarchy @@ -369,8 +369,8 @@ void QDataWidgetMapper::setModel(QAbstractItemModel *model) return; if (d->model) { - disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, - SLOT(_q_dataChanged(QModelIndex,QModelIndex))); + disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QSet<int>)), this, + SLOT(_q_dataChanged(QModelIndex,QModelIndex,QSet<int>))); disconnect(d->model, SIGNAL(destroyed()), this, SLOT(_q_modelDestroyed())); } @@ -380,8 +380,8 @@ void QDataWidgetMapper::setModel(QAbstractItemModel *model) d->model = model; - connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - SLOT(_q_dataChanged(QModelIndex,QModelIndex))); + connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QSet<int>)), + SLOT(_q_dataChanged(QModelIndex,QModelIndex,QSet<int>))); connect(model, SIGNAL(destroyed()), SLOT(_q_modelDestroyed())); } diff --git a/src/widgets/itemviews/qdatawidgetmapper.h b/src/widgets/itemviews/qdatawidgetmapper.h index ebb180fa20..5ffb666fbd 100644 --- a/src/widgets/itemviews/qdatawidgetmapper.h +++ b/src/widgets/itemviews/qdatawidgetmapper.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -113,7 +113,7 @@ Q_SIGNALS: private: Q_DECLARE_PRIVATE(QDataWidgetMapper) Q_DISABLE_COPY(QDataWidgetMapper) - Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &, const QModelIndex &)) + Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &, const QModelIndex &, const QSet<int> &)) Q_PRIVATE_SLOT(d_func(), void _q_commitData(QWidget *)) Q_PRIVATE_SLOT(d_func(), void _q_closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)) Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed()) diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index c80662414a..aa74f604e5 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qdirmodel.h b/src/widgets/itemviews/qdirmodel.h index 4ad89065f9..ee6ec3f4aa 100644 --- a/src/widgets/itemviews/qdirmodel.h +++ b/src/widgets/itemviews/qdirmodel.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index 1821171de8..a085f37d6c 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qfileiconprovider.h b/src/widgets/itemviews/qfileiconprovider.h index fcaaa9f78e..2b90e800a9 100644 --- a/src/widgets/itemviews/qfileiconprovider.h +++ b/src/widgets/itemviews/qfileiconprovider.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 36784f6424..c9bc3423b0 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -370,6 +370,8 @@ void QHeaderView::setModel(QAbstractItemModel *model) this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); QObject::disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); + QObject::disconnect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_layoutAboutToBeChanged())); } else { QObject::disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(sectionsInserted(QModelIndex,int,int))); @@ -377,11 +379,13 @@ void QHeaderView::setModel(QAbstractItemModel *model) this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); QObject::disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); + QObject::disconnect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_layoutAboutToBeChanged())); } QObject::disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), this, SLOT(headerDataChanged(Qt::Orientation,int,int))); - QObject::disconnect(d->model, SIGNAL(layoutAboutToBeChanged()), - this, SLOT(_q_layoutAboutToBeChanged())); + QObject::disconnect(d->model, SIGNAL(layoutAboutToBeChanged()), + this, SLOT(_q_layoutAboutToBeChanged())); } if (model && model != QAbstractItemModelPrivate::staticEmptyModel()) { @@ -389,9 +393,11 @@ void QHeaderView::setModel(QAbstractItemModel *model) QObject::connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(sectionsInserted(QModelIndex,int,int))); QObject::connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); + this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), - this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); + this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); + QObject::connect(model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_layoutAboutToBeChanged())); } else { QObject::connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(sectionsInserted(QModelIndex,int,int))); @@ -399,6 +405,8 @@ void QHeaderView::setModel(QAbstractItemModel *model) this, SLOT(sectionsAboutToBeRemoved(QModelIndex,int,int))); QObject::connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(_q_sectionsRemoved(QModelIndex,int,int))); + QObject::connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), + this, SLOT(_q_layoutAboutToBeChanged())); } QObject::connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), this, SLOT(headerDataChanged(Qt::Orientation,int,int))); @@ -884,8 +892,12 @@ void QHeaderView::resizeSection(int logical, int size) if (stretchLastSection() && visual == d->lastVisibleVisualIndex()) d->lastSectionSize = size; - if (size != oldSize) - d->createSectionSpan(visual, visual, size, d->headerSectionResizeMode(visual)); + d->createSectionSpan(visual, visual, size, d->headerSectionResizeMode(visual)); + + if (!updatesEnabled()) { + emit sectionResized(logical, oldSize, size); + return; + } int w = d->viewport->width(); int h = d->viewport->height(); @@ -2405,7 +2417,13 @@ bool QHeaderView::viewportEvent(QEvent *e) } return true; } #endif // QT_NO_STATUSTIP - case QEvent::Hide: + case QEvent::Hide: { + d->invalidateCachedSizeHint(); + QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea *>(parentWidget()); + if (parent && parent->isVisible()) // Only resize if we have a visible parent + resizeSections(); + emit geometriesChanged(); + break;} case QEvent::Show: case QEvent::FontChange: case QEvent::StyleChange: @@ -2637,7 +2655,7 @@ void QHeaderView::scrollContentsBy(int dx, int dy) \reimp \internal */ -void QHeaderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +void QHeaderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &) { Q_D(QHeaderView); d->invalidateCachedSizeHint(); diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h index c9793759a1..1ad79a96e1 100644 --- a/src/widgets/itemviews/qheaderview.h +++ b/src/widgets/itemviews/qheaderview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -211,7 +211,7 @@ protected: void updateGeometries(); void scrollContentsBy(int dx, int dy); - void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &roles = QSet<int>()); void rowsInserted(const QModelIndex &parent, int start, int end); QRect visualRect(const QModelIndex &index) const; diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index b2b8d686b5..923ab36f72 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qidentityproxymodel.cpp b/src/widgets/itemviews/qidentityproxymodel.cpp deleted file mode 100644 index c891565794..0000000000 --- a/src/widgets/itemviews/qidentityproxymodel.cpp +++ /dev/null @@ -1,578 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qidentityproxymodel.h" - -#ifndef QT_NO_IDENTITYPROXYMODEL - -#include "qitemselectionmodel.h" -#include <private/qabstractproxymodel_p.h> - -QT_BEGIN_NAMESPACE - -class QIdentityProxyModelPrivate : public QAbstractProxyModelPrivate -{ - QIdentityProxyModelPrivate() - { - - } - - Q_DECLARE_PUBLIC(QIdentityProxyModel) - - QList<QPersistentModelIndex> layoutChangePersistentIndexes; - QModelIndexList proxyIndexes; - - void _q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end); - void _q_sourceRowsInserted(const QModelIndex &parent, int start, int end); - void _q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void _q_sourceRowsRemoved(const QModelIndex &parent, int start, int end); - void _q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); - void _q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); - - void _q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end); - void _q_sourceColumnsInserted(const QModelIndex &parent, int start, int end); - void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void _q_sourceColumnsRemoved(const QModelIndex &parent, int start, int end); - void _q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); - void _q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest); - - void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); - void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last); - - void _q_sourceLayoutAboutToBeChanged(); - void _q_sourceLayoutChanged(); - void _q_sourceModelAboutToBeReset(); - void _q_sourceModelReset(); - -}; - -/*! - \since 4.8 - \class QIdentityProxyModel - \brief The QIdentityProxyModel class proxies its source model unmodified - - \ingroup model-view - \inmodule QtWidgets - - QIdentityProxyModel can be used to forward the structure of a source model exactly, with no sorting, filtering or other transformation. - This is similar in concept to an identity matrix where A.I = A. - - Because it does no sorting or filtering, this class is most suitable to proxy models which transform the data() of the source model. - For example, a proxy model could be created to define the font used, or the background colour, or the tooltip etc. This removes the - need to implement all data handling in the same class that creates the structure of the model, and can also be used to create - re-usable components. - - This also provides a way to change the data in the case where a source model is supplied by a third party which can not be modified. - - \snippet doc/src/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp 0 - - \sa QAbstractProxyModel, {Model/View Programming}, QAbstractItemModel - -*/ - -/*! - Constructs an identity model with the given \a parent. -*/ -QIdentityProxyModel::QIdentityProxyModel(QObject* parent) - : QAbstractProxyModel(*new QIdentityProxyModelPrivate, parent) -{ - -} - -/*! \internal - */ -QIdentityProxyModel::QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent) - : QAbstractProxyModel(dd, parent) -{ - -} - -/*! - Destroys this identity model. -*/ -QIdentityProxyModel::~QIdentityProxyModel() -{ -} - -/*! - \reimp - */ -int QIdentityProxyModel::columnCount(const QModelIndex& parent) const -{ - Q_ASSERT(parent.isValid() ? parent.model() == this : true); - Q_D(const QIdentityProxyModel); - return d->model->columnCount(mapToSource(parent)); -} - -/*! - \reimp - */ -bool QIdentityProxyModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) -{ - Q_ASSERT(parent.isValid() ? parent.model() == this : true); - Q_D(QIdentityProxyModel); - return d->model->dropMimeData(data, action, row, column, mapToSource(parent)); -} - -/*! - \reimp - */ -QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex& parent) const -{ - Q_ASSERT(parent.isValid() ? parent.model() == this : true); - Q_D(const QIdentityProxyModel); - if (!hasIndex(row, column, parent)) - return QModelIndex(); - const QModelIndex sourceParent = mapToSource(parent); - const QModelIndex sourceIndex = d->model->index(row, column, sourceParent); - Q_ASSERT(sourceIndex.isValid()); - return mapFromSource(sourceIndex); -} - -/*! - \reimp - */ -bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex& parent) -{ - Q_ASSERT(parent.isValid() ? parent.model() == this : true); - Q_D(QIdentityProxyModel); - return d->model->insertColumns(column, count, mapToSource(parent)); -} - -/*! - \reimp - */ -bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex& parent) -{ - Q_ASSERT(parent.isValid() ? parent.model() == this : true); - Q_D(QIdentityProxyModel); - return d->model->insertRows(row, count, mapToSource(parent)); -} - -/*! - \reimp - */ -QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex& sourceIndex) const -{ - Q_D(const QIdentityProxyModel); - if (!d->model || !sourceIndex.isValid()) - return QModelIndex(); - - Q_ASSERT(sourceIndex.model() == d->model); - return createIndex(sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer()); -} - -/*! - \reimp - */ -QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection& selection) const -{ - Q_D(const QIdentityProxyModel); - QItemSelection proxySelection; - - if (!d->model) - return proxySelection; - - QItemSelection::const_iterator it = selection.constBegin(); - const QItemSelection::const_iterator end = selection.constEnd(); - for ( ; it != end; ++it) { - Q_ASSERT(it->model() == d->model); - const QItemSelectionRange range(mapFromSource(it->topLeft()), mapFromSource(it->bottomRight())); - proxySelection.append(range); - } - - return proxySelection; -} - -/*! - \reimp - */ -QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection& selection) const -{ - Q_D(const QIdentityProxyModel); - QItemSelection sourceSelection; - - if (!d->model) - return sourceSelection; - - QItemSelection::const_iterator it = selection.constBegin(); - const QItemSelection::const_iterator end = selection.constEnd(); - for ( ; it != end; ++it) { - Q_ASSERT(it->model() == this); - const QItemSelectionRange range(mapToSource(it->topLeft()), mapToSource(it->bottomRight())); - sourceSelection.append(range); - } - - return sourceSelection; -} - -/*! - \reimp - */ -QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex& proxyIndex) const -{ - Q_D(const QIdentityProxyModel); - if (!d->model || !proxyIndex.isValid()) - return QModelIndex(); - Q_ASSERT(proxyIndex.model() == this); - return d->model->createIndex(proxyIndex.row(), proxyIndex.column(), proxyIndex.internalPointer()); -} - -/*! - \reimp - */ -QModelIndexList QIdentityProxyModel::match(const QModelIndex& start, int role, const QVariant& value, int hits, Qt::MatchFlags flags) const -{ - Q_D(const QIdentityProxyModel); - Q_ASSERT(start.isValid() ? start.model() == this : true); - if (!d->model) - return QModelIndexList(); - - const QModelIndexList sourceList = d->model->match(mapToSource(start), role, value, hits, flags); - QModelIndexList::const_iterator it = sourceList.constBegin(); - const QModelIndexList::const_iterator end = sourceList.constEnd(); - QModelIndexList proxyList; - for ( ; it != end; ++it) - proxyList.append(mapFromSource(*it)); - return proxyList; -} - -/*! - \reimp - */ -QModelIndex QIdentityProxyModel::parent(const QModelIndex& child) const -{ - Q_ASSERT(child.isValid() ? child.model() == this : true); - const QModelIndex sourceIndex = mapToSource(child); - const QModelIndex sourceParent = sourceIndex.parent(); - return mapFromSource(sourceParent); -} - -/*! - \reimp - */ -bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex& parent) -{ - Q_ASSERT(parent.isValid() ? parent.model() == this : true); - Q_D(QIdentityProxyModel); - return d->model->removeColumns(column, count, mapToSource(parent)); -} - -/*! - \reimp - */ -bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex& parent) -{ - Q_ASSERT(parent.isValid() ? parent.model() == this : true); - Q_D(QIdentityProxyModel); - return d->model->removeRows(row, count, mapToSource(parent)); -} - -/*! - \reimp - */ -int QIdentityProxyModel::rowCount(const QModelIndex& parent) const -{ - Q_ASSERT(parent.isValid() ? parent.model() == this : true); - Q_D(const QIdentityProxyModel); - return d->model->rowCount(mapToSource(parent)); -} - -/*! - \reimp - */ -void QIdentityProxyModel::setSourceModel(QAbstractItemModel* sourceModel) -{ - beginResetModel(); - - if (sourceModel) { - disconnect(sourceModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), - this, SLOT(_q_sourceRowsAboutToBeInserted(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(_q_sourceRowsInserted(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), - this, SLOT(_q_sourceRowsAboutToBeRemoved(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(_q_sourceRowsRemoved(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), - this, SLOT(_q_sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - disconnect(sourceModel, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), - this, SLOT(_q_sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - disconnect(sourceModel, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)), - this, SLOT(_q_sourceColumnsAboutToBeInserted(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(columnsInserted(const QModelIndex &, int, int)), - this, SLOT(_q_sourceColumnsInserted(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)), - this, SLOT(_q_sourceColumnsAboutToBeRemoved(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(columnsRemoved(const QModelIndex &, int, int)), - this, SLOT(_q_sourceColumnsRemoved(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), - this, SLOT(_q_sourceColumnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - disconnect(sourceModel, SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), - this, SLOT(_q_sourceColumnsMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - disconnect(sourceModel, SIGNAL(modelAboutToBeReset()), - this, SLOT(_q_sourceModelAboutToBeReset())); - disconnect(sourceModel, SIGNAL(modelReset()), - this, SLOT(_q_sourceModelReset())); - disconnect(sourceModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - this, SLOT(_q_sourceDataChanged(const QModelIndex &, const QModelIndex &))); - disconnect(sourceModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), - this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int))); - disconnect(sourceModel, SIGNAL(layoutAboutToBeChanged()), - this, SLOT(_q_sourceLayoutAboutToBeChanged())); - disconnect(sourceModel, SIGNAL(layoutChanged()), - this, SLOT(_q_sourceLayoutChanged())); - } - - QAbstractProxyModel::setSourceModel(sourceModel); - - if (sourceModel) { - connect(sourceModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), - SLOT(_q_sourceRowsAboutToBeInserted(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), - SLOT(_q_sourceRowsInserted(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), - SLOT(_q_sourceRowsAboutToBeRemoved(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - SLOT(_q_sourceRowsRemoved(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), - SLOT(_q_sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - connect(sourceModel, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), - SLOT(_q_sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - connect(sourceModel, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)), - SLOT(_q_sourceColumnsAboutToBeInserted(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(columnsInserted(const QModelIndex &, int, int)), - SLOT(_q_sourceColumnsInserted(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)), - SLOT(_q_sourceColumnsAboutToBeRemoved(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(columnsRemoved(const QModelIndex &, int, int)), - SLOT(_q_sourceColumnsRemoved(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), - SLOT(_q_sourceColumnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - connect(sourceModel, SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), - SLOT(_q_sourceColumnsMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - connect(sourceModel, SIGNAL(modelAboutToBeReset()), - SLOT(_q_sourceModelAboutToBeReset())); - connect(sourceModel, SIGNAL(modelReset()), - SLOT(_q_sourceModelReset())); - connect(sourceModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - SLOT(_q_sourceDataChanged(const QModelIndex &, const QModelIndex &))); - connect(sourceModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), - SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int))); - connect(sourceModel, SIGNAL(layoutAboutToBeChanged()), - SLOT(_q_sourceLayoutAboutToBeChanged())); - connect(sourceModel, SIGNAL(layoutChanged()), - SLOT(_q_sourceLayoutChanged())); - } - - endResetModel(); -} - -void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end) -{ - Q_ASSERT(parent.isValid() ? parent.model() == model : true); - Q_Q(QIdentityProxyModel); - q->beginInsertColumns(q->mapFromSource(parent), start, end); -} - -void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -{ - Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true); - Q_ASSERT(destParent.isValid() ? destParent.model() == model : true); - Q_Q(QIdentityProxyModel); - q->beginMoveColumns(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest); -} - -void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end) -{ - Q_ASSERT(parent.isValid() ? parent.model() == model : true); - Q_Q(QIdentityProxyModel); - q->beginRemoveColumns(q->mapFromSource(parent), start, end); -} - -void QIdentityProxyModelPrivate::_q_sourceColumnsInserted(const QModelIndex &parent, int start, int end) -{ - Q_ASSERT(parent.isValid() ? parent.model() == model : true); - Q_Q(QIdentityProxyModel); - Q_UNUSED(parent) - Q_UNUSED(start) - Q_UNUSED(end) - q->endInsertColumns(); -} - -void QIdentityProxyModelPrivate::_q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -{ - Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true); - Q_ASSERT(destParent.isValid() ? destParent.model() == model : true); - Q_Q(QIdentityProxyModel); - Q_UNUSED(sourceParent) - Q_UNUSED(sourceStart) - Q_UNUSED(sourceEnd) - Q_UNUSED(destParent) - Q_UNUSED(dest) - q->endMoveColumns(); -} - -void QIdentityProxyModelPrivate::_q_sourceColumnsRemoved(const QModelIndex &parent, int start, int end) -{ - Q_ASSERT(parent.isValid() ? parent.model() == model : true); - Q_Q(QIdentityProxyModel); - Q_UNUSED(parent) - Q_UNUSED(start) - Q_UNUSED(end) - q->endRemoveColumns(); -} - -void QIdentityProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) -{ - Q_ASSERT(topLeft.isValid() ? topLeft.model() == model : true); - Q_ASSERT(bottomRight.isValid() ? bottomRight.model() == model : true); - Q_Q(QIdentityProxyModel); - q->dataChanged(q->mapFromSource(topLeft), q->mapFromSource(bottomRight)); -} - -void QIdentityProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last) -{ - Q_Q(QIdentityProxyModel); - q->headerDataChanged(orientation, first, last); -} - -void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged() -{ - Q_Q(QIdentityProxyModel); - - foreach(const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) { - proxyIndexes << proxyPersistentIndex; - Q_ASSERT(proxyPersistentIndex.isValid()); - const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); - Q_ASSERT(srcPersistentIndex.isValid()); - layoutChangePersistentIndexes << srcPersistentIndex; - } - - q->layoutAboutToBeChanged(); -} - -void QIdentityProxyModelPrivate::_q_sourceLayoutChanged() -{ - Q_Q(QIdentityProxyModel); - - for (int i = 0; i < proxyIndexes.size(); ++i) { - q->changePersistentIndex(proxyIndexes.at(i), q->mapFromSource(layoutChangePersistentIndexes.at(i))); - } - - layoutChangePersistentIndexes.clear(); - proxyIndexes.clear(); - - q->layoutChanged(); -} - -void QIdentityProxyModelPrivate::_q_sourceModelAboutToBeReset() -{ - Q_Q(QIdentityProxyModel); - q->beginResetModel(); -} - -void QIdentityProxyModelPrivate::_q_sourceModelReset() -{ - Q_Q(QIdentityProxyModel); - q->endResetModel(); -} - -void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end) -{ - Q_ASSERT(parent.isValid() ? parent.model() == model : true); - Q_Q(QIdentityProxyModel); - q->beginInsertRows(q->mapFromSource(parent), start, end); -} - -void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -{ - Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true); - Q_ASSERT(destParent.isValid() ? destParent.model() == model : true); - Q_Q(QIdentityProxyModel); - q->beginMoveRows(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest); -} - -void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) -{ - Q_ASSERT(parent.isValid() ? parent.model() == model : true); - Q_Q(QIdentityProxyModel); - q->beginRemoveRows(q->mapFromSource(parent), start, end); -} - -void QIdentityProxyModelPrivate::_q_sourceRowsInserted(const QModelIndex &parent, int start, int end) -{ - Q_ASSERT(parent.isValid() ? parent.model() == model : true); - Q_Q(QIdentityProxyModel); - Q_UNUSED(parent) - Q_UNUSED(start) - Q_UNUSED(end) - q->endInsertRows(); -} - -void QIdentityProxyModelPrivate::_q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -{ - Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true); - Q_ASSERT(destParent.isValid() ? destParent.model() == model : true); - Q_Q(QIdentityProxyModel); - Q_UNUSED(sourceParent) - Q_UNUSED(sourceStart) - Q_UNUSED(sourceEnd) - Q_UNUSED(destParent) - Q_UNUSED(dest) - q->endMoveRows(); -} - -void QIdentityProxyModelPrivate::_q_sourceRowsRemoved(const QModelIndex &parent, int start, int end) -{ - Q_ASSERT(parent.isValid() ? parent.model() == model : true); - Q_Q(QIdentityProxyModel); - Q_UNUSED(parent) - Q_UNUSED(start) - Q_UNUSED(end) - q->endRemoveRows(); -} - -QT_END_NAMESPACE - -#include "moc_qidentityproxymodel.cpp" - -#endif // QT_NO_IDENTITYPROXYMODEL diff --git a/src/widgets/itemviews/qidentityproxymodel.h b/src/widgets/itemviews/qidentityproxymodel.h deleted file mode 100644 index 8a8422244f..0000000000 --- a/src/widgets/itemviews/qidentityproxymodel.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#ifndef QIDENTITYPROXYMODEL_H -#define QIDENTITYPROXYMODEL_H - -#include <QtWidgets/qabstractproxymodel.h> - -#ifndef QT_NO_IDENTITYPROXYMODEL - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QIdentityProxyModelPrivate; - -class Q_WIDGETS_EXPORT QIdentityProxyModel : public QAbstractProxyModel -{ - Q_OBJECT -public: - explicit QIdentityProxyModel(QObject* parent = 0); - ~QIdentityProxyModel(); - - int columnCount(const QModelIndex& parent = QModelIndex()) const; - QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const; - QModelIndex mapFromSource(const QModelIndex& sourceIndex) const; - QModelIndex mapToSource(const QModelIndex& proxyIndex) const; - QModelIndex parent(const QModelIndex& child) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; - bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent); - - QItemSelection mapSelectionFromSource(const QItemSelection& selection) const; - QItemSelection mapSelectionToSource(const QItemSelection& selection) const; - QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const; - void setSourceModel(QAbstractItemModel* sourceModel); - - bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex()); - bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()); - bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()); - bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()); - -protected: - QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent); - -private: - Q_DECLARE_PRIVATE(QIdentityProxyModel) - Q_DISABLE_COPY(QIdentityProxyModel) - - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(QModelIndex,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(QModelIndex,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(QModelIndex,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)) - - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(QModelIndex,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(QModelIndex,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)) - - Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex,QModelIndex)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last)) - - Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged()) - Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged()) - Q_PRIVATE_SLOT(d_func(), void _q_sourceModelAboutToBeReset()) - Q_PRIVATE_SLOT(d_func(), void _q_sourceModelReset()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QT_NO_IDENTITYPROXYMODEL - -#endif // QIDENTITYPROXYMODEL_H - diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp index 72f358ce68..e130953c38 100644 --- a/src/widgets/itemviews/qitemdelegate.cpp +++ b/src/widgets/itemviews/qitemdelegate.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -468,7 +468,7 @@ void QItemDelegate::paint(QPainter *painter, value = index.data(Qt::CheckStateRole); if (value.isValid()) { checkState = static_cast<Qt::CheckState>(value.toInt()); - checkRect = check(opt, opt.rect, value); + checkRect = doCheck(opt, opt.rect, value); } // do the layout @@ -625,7 +625,7 @@ void QItemDelegate::updateEditorGeometry(QWidget *editor, QString text = QItemDelegatePrivate::replaceNewLine(index.data(Qt::DisplayRole).toString()); QRect pixmapRect = QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect()); QRect textRect = textRectangle(0, option.rect, option.font, text); - QRect checkRect = check(option, textRect, index.data(Qt::CheckStateRole)); + QRect checkRect = doCheck(option, textRect, index.data(Qt::CheckStateRole)); QStyleOptionViewItem opt = option; opt.showDecorationSelected = true; // let the editor take up all available space doLayout(opt, &checkRect, &pixmapRect, &textRect, false); @@ -1079,7 +1079,7 @@ QRect QItemDelegate::rect(const QStyleOptionViewItem &option, Q_D(const QItemDelegate); QVariant value = index.data(role); if (role == Qt::CheckStateRole) - return check(option, option.rect, value); + return doCheck(option, option.rect, value); if (value.isValid() && !value.isNull()) { switch (value.type()) { case QVariant::Invalid: @@ -1109,20 +1109,8 @@ QRect QItemDelegate::rect(const QStyleOptionViewItem &option, /*! \internal - - Note that on Mac, if /usr/include/AssertMacros.h is included prior - to QItemDelegate, and the application is building in debug mode, the - check(assertion) will conflict with QItemDelegate::check. - - To avoid this problem, add - - #ifdef check - #undef check - #endif - - after including AssertMacros.h */ -QRect QItemDelegate::check(const QStyleOptionViewItem &option, +QRect QItemDelegate::doCheck(const QStyleOptionViewItem &option, const QRect &bounding, const QVariant &value) const { if (value.isValid()) { @@ -1280,7 +1268,7 @@ bool QItemDelegate::editorEvent(QEvent *event, if ((event->type() == QEvent::MouseButtonRelease) || (event->type() == QEvent::MouseButtonDblClick) || (event->type() == QEvent::MouseButtonPress)) { - QRect checkRect = check(option, option.rect, Qt::Checked); + QRect checkRect = doCheck(option, option.rect, Qt::Checked); QRect emptyRect; doLayout(option, &checkRect, &emptyRect, &emptyRect, false); QMouseEvent *me = static_cast<QMouseEvent*>(event); diff --git a/src/widgets/itemviews/qitemdelegate.h b/src/widgets/itemviews/qitemdelegate.h index 97f3cc820e..5ea6b33f2d 100644 --- a/src/widgets/itemviews/qitemdelegate.h +++ b/src/widgets/itemviews/qitemdelegate.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -120,7 +120,7 @@ protected: QPixmap decoration(const QStyleOptionViewItem &option, const QVariant &variant) const; QPixmap *selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const; - QRect check(const QStyleOptionViewItem &option, const QRect &bounding, + QRect doCheck(const QStyleOptionViewItem &option, const QRect &bounding, const QVariant &variant) const; QRect textRectangle(QPainter *painter, const QRect &rect, const QFont &font, const QString &text) const; diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index 7ff3622ec4..506ca79702 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qitemeditorfactory.h b/src/widgets/itemviews/qitemeditorfactory.h index b48cac224f..3d3359dc1a 100644 --- a/src/widgets/itemviews/qitemeditorfactory.h +++ b/src/widgets/itemviews/qitemeditorfactory.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qitemeditorfactory_p.h b/src/widgets/itemviews/qitemeditorfactory_p.h index effa6f26a2..613d4e0e81 100644 --- a/src/widgets/itemviews/qitemeditorfactory_p.h +++ b/src/widgets/itemviews/qitemeditorfactory_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qitemselectionmodel.cpp b/src/widgets/itemviews/qitemselectionmodel.cpp deleted file mode 100644 index 08470a4300..0000000000 --- a/src/widgets/itemviews/qitemselectionmodel.cpp +++ /dev/null @@ -1,1641 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qitemselectionmodel.h" -#include <private/qitemselectionmodel_p.h> -#include <qdebug.h> - -#ifndef QT_NO_ITEMVIEWS - -QT_BEGIN_NAMESPACE - -/*! - \class QItemSelectionRange - - \brief The QItemSelectionRange class manages information about a - range of selected items in a model. - - \ingroup model-view - \inmodule QtWidgets - - A QItemSelectionRange contains information about a range of - selected items in a model. A range of items is a contiguous array - of model items, extending to cover a number of adjacent rows and - columns with a common parent item; this can be visualized as a - two-dimensional block of cells in a table. A selection range has a - top(), left() a bottom(), right() and a parent(). - - The QItemSelectionRange class is one of the \l{Model/View Classes} - and is part of Qt's \l{Model/View Programming}{model/view framework}. - - The model items contained in the selection range can be obtained - using the indexes() function. Use QItemSelectionModel::selectedIndexes() - to get a list of all selected items for a view. - - You can determine whether a given model item lies within a - particular range by using the contains() function. Ranges can also - be compared using the overloaded operators for equality and - inequality, and the intersects() function allows you to determine - whether two ranges overlap. - - \sa {Model/View Programming}, QAbstractItemModel, QItemSelection, - QItemSelectionModel -*/ - -/*! - \fn QItemSelectionRange::QItemSelectionRange() - - Constructs an empty selection range. -*/ - -/*! - \fn QItemSelectionRange::QItemSelectionRange(const QItemSelectionRange &other) - - Copy constructor. Constructs a new selection range with the same contents - as the \a other range given. - -*/ - -/*! - \fn QItemSelectionRange::QItemSelectionRange(const QModelIndex &topLeft, const QModelIndex &bottomRight) - - Constructs a new selection range containing only the index specified - by the \a topLeft and the index \a bottomRight. - -*/ - -/*! - \fn QItemSelectionRange::QItemSelectionRange(const QModelIndex &index) - - Constructs a new selection range containing only the model item specified - by the model index \a index. -*/ - -/*! - \fn int QItemSelectionRange::top() const - - Returns the row index corresponding to the uppermost selected row in the - selection range. - -*/ - -/*! - \fn int QItemSelectionRange::left() const - - Returns the column index corresponding to the leftmost selected column in the - selection range. -*/ - -/*! - \fn int QItemSelectionRange::bottom() const - - Returns the row index corresponding to the lowermost selected row in the - selection range. - -*/ - -/*! - \fn int QItemSelectionRange::right() const - - Returns the column index corresponding to the rightmost selected column in - the selection range. - -*/ - -/*! - \fn int QItemSelectionRange::width() const - - Returns the number of selected columns in the selection range. - -*/ - -/*! - \fn int QItemSelectionRange::height() const - - Returns the number of selected rows in the selection range. - -*/ - -/*! - \fn const QAbstractItemModel *QItemSelectionRange::model() const - - Returns the model that the items in the selection range belong to. -*/ - -/*! - \fn QModelIndex QItemSelectionRange::topLeft() const - - Returns the index for the item located at the top-left corner of - the selection range. - - \sa top(), left(), bottomRight() -*/ - -/*! - \fn QModelIndex QItemSelectionRange::bottomRight() const - - Returns the index for the item located at the bottom-right corner - of the selection range. - - \sa bottom(), right(), topLeft() -*/ - -/*! - \fn QModelIndex QItemSelectionRange::parent() const - - Returns the parent model item index of the items in the selection range. - -*/ - -/*! - \fn bool QItemSelectionRange::contains(const QModelIndex &index) const - - Returns true if the model item specified by the \a index lies within the - range of selected items; otherwise returns false. -*/ - -/*! - \fn bool QItemSelectionRange::contains(int row, int column, - const QModelIndex &parentIndex) const - \overload - - Returns true if the model item specified by (\a row, \a column) - and with \a parentIndex as the parent item lies within the range - of selected items; otherwise returns false. -*/ - -/*! - \fn bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const - - Returns true if this selection range intersects (overlaps with) the \a other - range given; otherwise returns false. - -*/ -bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const -{ - return (isValid() && other.isValid() - && parent() == other.parent() - && model() == other.model() - && ((top() <= other.top() && bottom() >= other.top()) - || (top() >= other.top() && top() <= other.bottom())) - && ((left() <= other.left() && right() >= other.left()) - || (left() >= other.left() && left() <= other.right()))); -} - -/*! - \fn QItemSelectionRange QItemSelectionRange::intersect(const QItemSelectionRange &other) const - \obsolete - - Use intersected(\a other) instead. -*/ - -/*! - \fn QItemSelectionRange QItemSelectionRange::intersected(const QItemSelectionRange &other) const - \since 4.2 - - Returns a new selection range containing only the items that are found in - both the selection range and the \a other selection range. -*/ - -QItemSelectionRange QItemSelectionRange::intersect(const QItemSelectionRange &other) const -{ - if (model() == other.model() && parent() == other.parent()) { - QModelIndex topLeft = model()->index(qMax(top(), other.top()), - qMax(left(), other.left()), - other.parent()); - QModelIndex bottomRight = model()->index(qMin(bottom(), other.bottom()), - qMin(right(), other.right()), - other.parent()); - return QItemSelectionRange(topLeft, bottomRight); - } - return QItemSelectionRange(); -} - -/*! - \fn bool QItemSelectionRange::operator==(const QItemSelectionRange &other) const - - Returns true if the selection range is exactly the same as the \a other - range given; otherwise returns false. - -*/ - -/*! - \fn bool QItemSelectionRange::operator!=(const QItemSelectionRange &other) const - - Returns true if the selection range differs from the \a other range given; - otherwise returns false. - -*/ - -/*! - \fn bool QItemSelectionRange::isValid() const - - Returns true if the selection range is valid; otherwise returns false. - -*/ - -/* - \internal - - utility function for getting the indexes from a range - it avoid concatenating list and works on one - */ - -static void indexesFromRange(const QItemSelectionRange &range, QModelIndexList &result) -{ - if (range.isValid() && range.model()) { - for (int column = range.left(); column <= range.right(); ++column) { - for (int row = range.top(); row <= range.bottom(); ++row) { - QModelIndex index = range.model()->index(row, column, range.parent()); - Qt::ItemFlags flags = range.model()->flags(index); - if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) - result.append(index); - } - } - } -} - -/*! - Returns true if the selection range contains no selectable item - \since 4.7 -*/ - -bool QItemSelectionRange::isEmpty() const -{ - if (!isValid() || !model()) - return true; - - for (int column = left(); column <= right(); ++column) { - for (int row = top(); row <= bottom(); ++row) { - QModelIndex index = model()->index(row, column, parent()); - Qt::ItemFlags flags = model()->flags(index); - if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) - return false; - } - } - return true; -} - -/*! - Returns the list of model index items stored in the selection. -*/ - -QModelIndexList QItemSelectionRange::indexes() const -{ - QModelIndexList result; - indexesFromRange(*this, result); - return result; -} - -/*! - \class QItemSelection - - \brief The QItemSelection class manages information about selected items in a model. - - \ingroup model-view - \inmodule QtWidgets - - A QItemSelection describes the items in a model that have been - selected by the user. A QItemSelection is basically a list of - selection ranges, see QItemSelectionRange. It provides functions for - creating and manipulating selections, and selecting a range of items - from a model. - - The QItemSelection class is one of the \l{Model/View Classes} - and is part of Qt's \l{Model/View Programming}{model/view framework}. - - An item selection can be constructed and initialized to contain a - range of items from an existing model. The following example constructs - a selection that contains a range of items from the given \c model, - beginning at the \c topLeft, and ending at the \c bottomRight. - - \snippet doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp 0 - - An empty item selection can be constructed, and later populated as - required. So, if the model is going to be unavailable when we construct - the item selection, we can rewrite the above code in the following way: - - \snippet doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp 1 - - QItemSelection saves memory, and avoids unnecessary work, by working with - selection ranges rather than recording the model item index for each - item in the selection. Generally, an instance of this class will contain - a list of non-overlapping selection ranges. - - Use merge() to merge one item selection into another without making - overlapping ranges. Use split() to split one selection range into - smaller ranges based on a another selection range. - - \sa {Model/View Programming}, QItemSelectionModel -*/ - -/*! - \fn QItemSelection::QItemSelection() - - Constructs an empty selection. -*/ - -/*! - Constructs an item selection that extends from the top-left model item, - specified by the \a topLeft index, to the bottom-right item, specified - by \a bottomRight. -*/ -QItemSelection::QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight) -{ - select(topLeft, bottomRight); -} - -/*! - Adds the items in the range that extends from the top-left model - item, specified by the \a topLeft index, to the bottom-right item, - specified by \a bottomRight to the list. - - \note \a topLeft and \a bottomRight must have the same parent. -*/ -void QItemSelection::select(const QModelIndex &topLeft, const QModelIndex &bottomRight) -{ - if (!topLeft.isValid() || !bottomRight.isValid()) - return; - - if ((topLeft.model() != bottomRight.model()) - || topLeft.parent() != bottomRight.parent()) { - qWarning("Can't select indexes from different model or with different parents"); - return; - } - if (topLeft.row() > bottomRight.row() || topLeft.column() > bottomRight.column()) { - int top = qMin(topLeft.row(), bottomRight.row()); - int bottom = qMax(topLeft.row(), bottomRight.row()); - int left = qMin(topLeft.column(), bottomRight.column()); - int right = qMax(topLeft.column(), bottomRight.column()); - QModelIndex tl = topLeft.sibling(top, left); - QModelIndex br = bottomRight.sibling(bottom, right); - append(QItemSelectionRange(tl, br)); - return; - } - append(QItemSelectionRange(topLeft, bottomRight)); -} - -/*! - Returns true if the selection contains the given \a index; otherwise - returns false. -*/ - -bool QItemSelection::contains(const QModelIndex &index) const -{ - if (index.flags() & Qt::ItemIsSelectable) { - QList<QItemSelectionRange>::const_iterator it = begin(); - for (; it != end(); ++it) - if ((*it).contains(index)) - return true; - } - return false; -} - -/*! - Returns a list of model indexes that correspond to the selected items. -*/ - -QModelIndexList QItemSelection::indexes() const -{ - QModelIndexList result; - QList<QItemSelectionRange>::const_iterator it = begin(); - for (; it != end(); ++it) - indexesFromRange(*it, result); - return result; -} - -/*! - Merges the \a other selection with this QItemSelection using the - \a command given. This method guarantees that no ranges are overlapping. - - Note that only QItemSelectionModel::Select, - QItemSelectionModel::Deselect, and QItemSelectionModel::Toggle are - supported. - - \sa split() -*/ -void QItemSelection::merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command) -{ - if (other.isEmpty() || - !(command & QItemSelectionModel::Select || - command & QItemSelectionModel::Deselect || - command & QItemSelectionModel::Toggle)) - return; - - QItemSelection newSelection = other; - // Collect intersections - QItemSelection intersections; - QItemSelection::iterator it = newSelection.begin(); - while (it != newSelection.end()) { - if (!(*it).isValid()) { - it = newSelection.erase(it); - continue; - } - for (int t = 0; t < count(); ++t) { - if ((*it).intersects(at(t))) - intersections.append(at(t).intersected(*it)); - } - ++it; - } - - // Split the old (and new) ranges using the intersections - for (int i = 0; i < intersections.count(); ++i) { // for each intersection - for (int t = 0; t < count();) { // splitt each old range - if (at(t).intersects(intersections.at(i))) { - split(at(t), intersections.at(i), this); - removeAt(t); - } else { - ++t; - } - } - // only split newSelection if Toggle is specified - for (int n = 0; (command & QItemSelectionModel::Toggle) && n < newSelection.count();) { - if (newSelection.at(n).intersects(intersections.at(i))) { - split(newSelection.at(n), intersections.at(i), &newSelection); - newSelection.removeAt(n); - } else { - ++n; - } - } - } - // do not add newSelection for Deselect - if (!(command & QItemSelectionModel::Deselect)) - operator+=(newSelection); -} - -/*! - Splits the selection \a range using the selection \a other range. - Removes all items in \a other from \a range and puts the result in \a result. - This can be compared with the semantics of the \e subtract operation of a set. - \sa merge() -*/ - -void QItemSelection::split(const QItemSelectionRange &range, - const QItemSelectionRange &other, QItemSelection *result) -{ - if (range.parent() != other.parent() || range.model() != other.model()) - return; - - QModelIndex parent = other.parent(); - int top = range.top(); - int left = range.left(); - int bottom = range.bottom(); - int right = range.right(); - int other_top = other.top(); - int other_left = other.left(); - int other_bottom = other.bottom(); - int other_right = other.right(); - const QAbstractItemModel *model = range.model(); - Q_ASSERT(model); - if (other_top > top) { - QModelIndex tl = model->index(top, left, parent); - QModelIndex br = model->index(other_top - 1, right, parent); - result->append(QItemSelectionRange(tl, br)); - top = other_top; - } - if (other_bottom < bottom) { - QModelIndex tl = model->index(other_bottom + 1, left, parent); - QModelIndex br = model->index(bottom, right, parent); - result->append(QItemSelectionRange(tl, br)); - bottom = other_bottom; - } - if (other_left > left) { - QModelIndex tl = model->index(top, left, parent); - QModelIndex br = model->index(bottom, other_left - 1, parent); - result->append(QItemSelectionRange(tl, br)); - left = other_left; - } - if (other_right < right) { - QModelIndex tl = model->index(top, other_right + 1, parent); - QModelIndex br = model->index(bottom, right, parent); - result->append(QItemSelectionRange(tl, br)); - right = other_right; - } -} - - -void QItemSelectionModelPrivate::initModel(QAbstractItemModel *model) -{ - this->model = model; - if (model) { - Q_Q(QItemSelectionModel); - QObject::connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int))); - QObject::connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), - q, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int))); - QObject::connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - q, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int))); - QObject::connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), - q, SLOT(_q_columnsAboutToBeInserted(QModelIndex,int,int))); - QObject::connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), - q, SLOT(_q_layoutAboutToBeChanged())); - QObject::connect(model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), - q, SLOT(_q_layoutAboutToBeChanged())); - QObject::connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), - q, SLOT(_q_layoutChanged())); - QObject::connect(model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), - q, SLOT(_q_layoutChanged())); - QObject::connect(model, SIGNAL(layoutAboutToBeChanged()), - q, SLOT(_q_layoutAboutToBeChanged())); - QObject::connect(model, SIGNAL(layoutChanged()), - q, SLOT(_q_layoutChanged())); - } -} - -/*! - \internal - - returns a QItemSelection where all ranges have been expanded to: - Rows: left: 0 and right: columnCount()-1 - Columns: top: 0 and bottom: rowCount()-1 -*/ - -QItemSelection QItemSelectionModelPrivate::expandSelection(const QItemSelection &selection, - QItemSelectionModel::SelectionFlags command) const -{ - if (selection.isEmpty() && !((command & QItemSelectionModel::Rows) || - (command & QItemSelectionModel::Columns))) - return selection; - - QItemSelection expanded; - if (command & QItemSelectionModel::Rows) { - for (int i = 0; i < selection.count(); ++i) { - QModelIndex parent = selection.at(i).parent(); - int colCount = model->columnCount(parent); - QModelIndex tl = model->index(selection.at(i).top(), 0, parent); - QModelIndex br = model->index(selection.at(i).bottom(), colCount - 1, parent); - //we need to merge because the same row could have already been inserted - expanded.merge(QItemSelection(tl, br), QItemSelectionModel::Select); - } - } - if (command & QItemSelectionModel::Columns) { - for (int i = 0; i < selection.count(); ++i) { - QModelIndex parent = selection.at(i).parent(); - int rowCount = model->rowCount(parent); - QModelIndex tl = model->index(0, selection.at(i).left(), parent); - QModelIndex br = model->index(rowCount - 1, selection.at(i).right(), parent); - //we need to merge because the same column could have already been inserted - expanded.merge(QItemSelection(tl, br), QItemSelectionModel::Select); - } - } - return expanded; -} - -/*! - \internal -*/ -void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &parent, - int start, int end) -{ - Q_Q(QItemSelectionModel); - finalize(); - - // update current index - if (currentIndex.isValid() && parent == currentIndex.parent() - && currentIndex.row() >= start && currentIndex.row() <= end) { - QModelIndex old = currentIndex; - if (start > 0) // there are rows left above the change - currentIndex = model->index(start - 1, old.column(), parent); - else if (model && end < model->rowCount(parent) - 1) // there are rows left below the change - currentIndex = model->index(end + 1, old.column(), parent); - else // there are no rows left in the table - currentIndex = QModelIndex(); - emit q->currentChanged(currentIndex, old); - emit q->currentRowChanged(currentIndex, old); - if (currentIndex.column() != old.column()) - emit q->currentColumnChanged(currentIndex, old); - } - - QItemSelection deselected; - QItemSelection newParts; - 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 (itParent.isValid() && start <= itParent.row() && itParent.row() <= end) { - deselected.append(*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 = 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 = 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 = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent())); - ++it; - } else if (it->top() < start && end < it->bottom()) { // Middle intersection - // If the parent contains (1, 2, 3, 4, 5, 6, 7, 8) and [3, 4, 5, 6] is selected, - // and [4, 5] is removed, we need to split [3, 4, 5, 6] into [3], [4, 5] and [6]. - // [4, 5] is appended to deselected, and [3] and [6] remain part of the selection - // in ranges. - const QItemSelectionRange removedRange(model->index(start, it->right(), it->parent()), - model->index(end, it->left(), it->parent())); - deselected.append(removedRange); - QItemSelection::split(*it, removedRange, &newParts); - it = ranges.erase(it); - } else - ++it; - } - ranges.append(newParts); - - if (!deselected.isEmpty()) - emit q->selectionChanged(QItemSelection(), deselected); -} - -/*! - \internal -*/ -void QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &parent, - int start, int end) -{ - Q_Q(QItemSelectionModel); - - // update current index - if (currentIndex.isValid() && parent == currentIndex.parent() - && currentIndex.column() >= start && currentIndex.column() <= end) { - QModelIndex old = currentIndex; - if (start > 0) // there are columns to the left of the change - currentIndex = model->index(old.row(), start - 1, parent); - else if (model && end < model->columnCount() - 1) // there are columns to the right of the change - currentIndex = model->index(old.row(), end + 1, parent); - else // there are no columns left in the table - currentIndex = QModelIndex(); - emit q->currentChanged(currentIndex, old); - if (currentIndex.row() != old.row()) - emit q->currentRowChanged(currentIndex, old); - emit q->currentColumnChanged(currentIndex, old); - } - - // update selections - QModelIndex tl = model->index(0, start, parent); - QModelIndex br = model->index(model->rowCount(parent) - 1, end, parent); - q->select(QItemSelection(tl, br), QItemSelectionModel::Deselect); - finalize(); -} - -/*! - \internal - - Split selection ranges if columns are about to be inserted in the middle. -*/ -void QItemSelectionModelPrivate::_q_columnsAboutToBeInserted(const QModelIndex &parent, - int start, int end) -{ - Q_UNUSED(end); - finalize(); - QList<QItemSelectionRange> split; - QList<QItemSelectionRange>::iterator it = ranges.begin(); - for (; it != ranges.end(); ) { - if ((*it).isValid() && (*it).parent() == parent - && (*it).left() < start && (*it).right() >= start) { - QModelIndex bottomMiddle = model->index((*it).bottom(), start - 1, (*it).parent()); - QItemSelectionRange left((*it).topLeft(), bottomMiddle); - QModelIndex topMiddle = model->index((*it).top(), start, (*it).parent()); - QItemSelectionRange right(topMiddle, (*it).bottomRight()); - it = ranges.erase(it); - split.append(left); - split.append(right); - } else { - ++it; - } - } - ranges += split; -} - -/*! - \internal - - Split selection ranges if rows are about to be inserted in the middle. -*/ -void QItemSelectionModelPrivate::_q_rowsAboutToBeInserted(const QModelIndex &parent, - int start, int end) -{ - Q_UNUSED(end); - finalize(); - QList<QItemSelectionRange> split; - QList<QItemSelectionRange>::iterator it = ranges.begin(); - for (; it != ranges.end(); ) { - if ((*it).isValid() && (*it).parent() == parent - && (*it).top() < start && (*it).bottom() >= start) { - QModelIndex middleRight = model->index(start - 1, (*it).right(), (*it).parent()); - QItemSelectionRange top((*it).topLeft(), middleRight); - QModelIndex middleLeft = model->index(start, (*it).left(), (*it).parent()); - QItemSelectionRange bottom(middleLeft, (*it).bottomRight()); - it = ranges.erase(it); - split.append(top); - split.append(bottom); - } else { - ++it; - } - } - ranges += split; -} - -/*! - \internal - - Split selection into individual (persistent) indexes. This is done in - preparation for the layoutChanged() signal, where the indexes can be - merged again. -*/ -void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged() -{ - savedPersistentIndexes.clear(); - savedPersistentCurrentIndexes.clear(); - - // optimization 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(); - tableRowCount = model->rowCount(parent); - tableColCount = model->columnCount(parent); - if (tableRowCount * tableColCount > 1000 - && range.top() == 0 - && range.left() == 0 - && range.bottom() == tableRowCount - 1 - && range.right() == tableColCount - 1) { - tableSelected = true; - tableParent = parent; - return; - } - } - tableSelected = false; - - QModelIndexList indexes = ranges.indexes(); - QModelIndexList::const_iterator it; - for (it = indexes.constBegin(); it != indexes.constEnd(); ++it) - savedPersistentIndexes.append(QPersistentModelIndex(*it)); - indexes = currentSelection.indexes(); - for (it = indexes.constBegin(); it != indexes.constEnd(); ++it) - savedPersistentCurrentIndexes.append(QPersistentModelIndex(*it)); -} - -/*! - \internal - - Merges \a indexes into an item selection made up of ranges. - Assumes that the indexes are sorted. -*/ -static QItemSelection mergeIndexes(const QList<QPersistentModelIndex> &indexes) -{ - QItemSelection colSpans; - // merge columns - int i = 0; - while (i < indexes.count()) { - QModelIndex tl = indexes.at(i); - QModelIndex br = tl; - while (++i < indexes.count()) { - QModelIndex next = indexes.at(i); - if ((next.parent() == br.parent()) - && (next.row() == br.row()) - && (next.column() == br.column() + 1)) - br = next; - else - break; - } - colSpans.append(QItemSelectionRange(tl, br)); - } - // merge rows - QItemSelection rowSpans; - i = 0; - while (i < colSpans.count()) { - QModelIndex tl = colSpans.at(i).topLeft(); - QModelIndex br = colSpans.at(i).bottomRight(); - QModelIndex prevTl = tl; - while (++i < colSpans.count()) { - QModelIndex nextTl = colSpans.at(i).topLeft(); - QModelIndex nextBr = colSpans.at(i).bottomRight(); - - if (nextTl.parent() != tl.parent()) - break; // we can't merge selection ranges from different parents - - if ((nextTl.column() == prevTl.column()) && (nextBr.column() == br.column()) - && (nextTl.row() == prevTl.row() + 1) && (nextBr.row() == br.row() + 1)) { - br = nextBr; - prevTl = nextTl; - } else { - break; - } - } - rowSpans.append(QItemSelectionRange(tl, br)); - } - return rowSpans; -} - -/*! - \internal - - Merge the selected indexes into selection ranges again. -*/ -void QItemSelectionModelPrivate::_q_layoutChanged() -{ - // special case for when all indexes are selected - if (tableSelected && tableColCount == model->columnCount(tableParent) - && tableRowCount == model->rowCount(tableParent)) { - ranges.clear(); - currentSelection.clear(); - int bottom = tableRowCount - 1; - int right = tableColCount - 1; - QModelIndex tl = model->index(0, 0, tableParent); - QModelIndex br = model->index(bottom, right, tableParent); - currentSelection << QItemSelectionRange(tl, br); - tableParent = QModelIndex(); - tableSelected = false; - return; - } - - if (savedPersistentCurrentIndexes.isEmpty() && savedPersistentIndexes.isEmpty()) { - // either the selection was actually empty, or we - // didn't get the layoutAboutToBeChanged() signal - return; - } - // clear the "old" selection - ranges.clear(); - currentSelection.clear(); - - // sort the "new" selection, as preparation for merging - qStableSort(savedPersistentIndexes.begin(), savedPersistentIndexes.end()); - qStableSort(savedPersistentCurrentIndexes.begin(), savedPersistentCurrentIndexes.end()); - - // update the selection by merging the individual indexes - ranges = mergeIndexes(savedPersistentIndexes); - currentSelection = mergeIndexes(savedPersistentCurrentIndexes); - - // release the persistent indexes - savedPersistentIndexes.clear(); - savedPersistentCurrentIndexes.clear(); -} - -/*! - \class QItemSelectionModel - - \brief The QItemSelectionModel class keeps track of a view's selected items. - - \ingroup model-view - \inmodule QtWidgets - - A QItemSelectionModel keeps track of the selected items in a view, or - in several views onto the same model. It also keeps track of the - currently selected item in a view. - - The QItemSelectionModel class is one of the \l{Model/View Classes} - and is part of Qt's \l{Model/View Programming}{model/view framework}. - - The selected items are stored using ranges. Whenever you want to - modify the selected items use select() and provide either a - QItemSelection, or a QModelIndex and a QItemSelectionModel::SelectionFlag. - - The QItemSelectionModel takes a two layer approach to selection - management, dealing with both selected items that have been committed - and items that are part of the current selection. The current - selected items are part of the current interactive selection (for - example with rubber-band selection or keyboard-shift selections). - - To update the currently selected items, use the bitwise OR of - QItemSelectionModel::Current and any of the other SelectionFlags. - If you omit the QItemSelectionModel::Current command, a new current - selection will be created, and the previous one added to the whole - selection. All functions operate on both layers; for example, - selectedItems() will return items from both layers. - - \sa {Model/View Programming}, QAbstractItemModel, {Chart Example} -*/ - -/*! - Constructs a selection model that operates on the specified item \a model. -*/ -QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model) - : QObject(*new QItemSelectionModelPrivate, model) -{ - d_func()->initModel(model); -} - -/*! - Constructs a selection model that operates on the specified item \a model with \a parent. -*/ -QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model, QObject *parent) - : QObject(*new QItemSelectionModelPrivate, parent) -{ - d_func()->initModel(model); -} - -/*! - \internal -*/ -QItemSelectionModel::QItemSelectionModel(QItemSelectionModelPrivate &dd, QAbstractItemModel *model) - : QObject(dd, model) -{ - dd.initModel(model); -} - -/*! - Destroys the selection model. -*/ -QItemSelectionModel::~QItemSelectionModel() -{ -} - -/*! - Selects the model item \a index using the specified \a command, and emits - selectionChanged(). - - \sa QItemSelectionModel::SelectionFlags -*/ -void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) -{ - QItemSelection selection(index, index); - select(selection, command); -} - -/*! - \fn void QItemSelectionModel::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) - - This signal is emitted whenever the current item changes. The \a previous - model item index is replaced by the \a current index as the selection's - current item. - - Note that this signal will not be emitted when the item model is reset. - - \sa currentIndex() setCurrentIndex() selectionChanged() -*/ - -/*! - \fn void QItemSelectionModel::currentColumnChanged(const QModelIndex ¤t, const QModelIndex &previous) - - This signal is emitted if the \a current item changes and its column is - different to the column of the \a previous current item. - - Note that this signal will not be emitted when the item model is reset. - - \sa currentChanged() currentRowChanged() currentIndex() setCurrentIndex() -*/ - -/*! - \fn void QItemSelectionModel::currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous) - - This signal is emitted if the \a current item changes and its row is - different to the row of the \a previous current item. - - Note that this signal will not be emitted when the item model is reset. - - \sa currentChanged() currentColumnChanged() currentIndex() setCurrentIndex() -*/ - -/*! - \fn void QItemSelectionModel::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) - - This signal is emitted whenever the selection changes. The change in the - selection is represented as an item selection of \a deselected items and - an item selection of \a selected items. - - Note the that the current index changes independently from the selection. - Also note that this signal will not be emitted when the item model is reset. - - \sa select() currentChanged() -*/ - -/*! - \enum QItemSelectionModel::SelectionFlag - - This enum describes the way the selection model will be updated. - - \value NoUpdate No selection will be made. - \value Clear The complete selection will be cleared. - \value Select All specified indexes will be selected. - \value Deselect All specified indexes will be deselected. - \value Toggle All specified indexes will be selected or - deselected depending on their current state. - \value Current The current selection will be updated. - \value Rows All indexes will be expanded to span rows. - \value Columns All indexes will be expanded to span columns. - \value SelectCurrent A combination of Select and Current, provided for - convenience. - \value ToggleCurrent A combination of Toggle and Current, provided for - convenience. - \value ClearAndSelect A combination of Clear and Select, provided for - convenience. -*/ - -/*! - Selects the item \a selection using the specified \a command, and emits - selectionChanged(). - - \sa QItemSelectionModel::SelectionFlag -*/ -void QItemSelectionModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) -{ - Q_D(QItemSelectionModel); - if (command == NoUpdate) - return; - - // store old selection - QItemSelection sel = selection; - // If d->ranges is non-empty when the source model is reset the persistent indexes - // it contains will be invalid. We can't clear them in a modelReset slot because that might already - // be too late if another model observer is connected to the same modelReset slot and is invoked first - // it might call select() on this selection model before any such QItemSelectionModelPrivate::_q_modelReset() slot - // is invoked, so it would not be cleared yet. We clear it invalid ranges in it here. - QItemSelection::iterator it = d->ranges.begin(); - while (it != d->ranges.end()) { - if (!it->isValid()) - it = d->ranges.erase(it); - else - ++it; - } - - QItemSelection old = d->ranges; - old.merge(d->currentSelection, d->currentCommand); - - // expand selection according to SelectionBehavior - if (command & Rows || command & Columns) - sel = d->expandSelection(sel, command); - - // clear ranges and currentSelection - if (command & Clear) { - d->ranges.clear(); - d->currentSelection.clear(); - } - - // merge and clear currentSelection if Current was not set (ie. start new currentSelection) - if (!(command & Current)) - d->finalize(); - - // update currentSelection - if (command & Toggle || command & Select || command & Deselect) { - d->currentCommand = command; - d->currentSelection = sel; - } - - // generate new selection, compare with old and emit selectionChanged() - QItemSelection newSelection = d->ranges; - newSelection.merge(d->currentSelection, d->currentCommand); - emitSelectionChanged(newSelection, old); -} - -/*! - Clears the selection model. Emits selectionChanged() and currentChanged(). -*/ -void QItemSelectionModel::clear() -{ - clearSelection(); - clearCurrentIndex(); -} - -/*! - Clears the current index. Emits currentChanged(). - */ -void QItemSelectionModel::clearCurrentIndex() -{ - Q_D(QItemSelectionModel); - QModelIndex previous = d->currentIndex; - d->currentIndex = QModelIndex(); - if (previous.isValid()) { - emit currentChanged(d->currentIndex, previous); - emit currentRowChanged(d->currentIndex, previous); - emit currentColumnChanged(d->currentIndex, previous); - } -} - -/*! - Clears the selection model. Does not emit any signals. -*/ -void QItemSelectionModel::reset() -{ - bool block = blockSignals(true); - clear(); - blockSignals(block); -} - -/*! - \since 4.2 - Clears the selection in the selection model. Emits selectionChanged(). -*/ -void QItemSelectionModel::clearSelection() -{ - Q_D(QItemSelectionModel); - if (d->ranges.count() == 0 && d->currentSelection.count() == 0) - return; - - select(QItemSelection(), Clear); -} - - -/*! - Sets the model item \a index to be the current item, and emits - currentChanged(). The current item is used for keyboard navigation and - focus indication; it is independent of any selected items, although a - selected item can also be the current item. - - Depending on the specified \a command, the \a index can also become part - of the current selection. - \sa select() -*/ -void QItemSelectionModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) -{ - Q_D(QItemSelectionModel); - if (index == d->currentIndex) { - if (command != NoUpdate) - select(index, command); // select item - return; - } - QPersistentModelIndex previous = d->currentIndex; - d->currentIndex = index; // set current before emitting selection changed below - if (command != NoUpdate) - select(d->currentIndex, command); // select item - emit currentChanged(d->currentIndex, previous); - if (d->currentIndex.row() != previous.row() || - d->currentIndex.parent() != previous.parent()) - emit currentRowChanged(d->currentIndex, previous); - if (d->currentIndex.column() != previous.column() || - d->currentIndex.parent() != previous.parent()) - emit currentColumnChanged(d->currentIndex, previous); -} - -/*! - Returns the model item index for the current item, or an invalid index - if there is no current item. -*/ -QModelIndex QItemSelectionModel::currentIndex() const -{ - return static_cast<QModelIndex>(d_func()->currentIndex); -} - -/*! - Returns true if the given model item \a index is selected. -*/ -bool QItemSelectionModel::isSelected(const QModelIndex &index) const -{ - Q_D(const QItemSelectionModel); - if (d->model != index.model() || !index.isValid()) - return false; - - bool selected = false; - // search model ranges - QList<QItemSelectionRange>::const_iterator it = d->ranges.begin(); - for (; it != d->ranges.end(); ++it) { - if ((*it).isValid() && (*it).contains(index)) { - selected = true; - break; - } - } - - // check currentSelection - if (d->currentSelection.count()) { - if ((d->currentCommand & Deselect) && selected) - selected = !d->currentSelection.contains(index); - else if (d->currentCommand & Toggle) - selected ^= d->currentSelection.contains(index); - else if ((d->currentCommand & Select) && !selected) - selected = d->currentSelection.contains(index); - } - - if (selected) { - Qt::ItemFlags flags = d->model->flags(index); - return (flags & Qt::ItemIsSelectable); - } - - return false; -} - -/*! - Returns true if all items are selected in the \a row with the given - \a parent. - - Note that this function is usually faster than calling isSelected() - on all items in the same row and that unselectable items are - ignored. -*/ -bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent) const -{ - Q_D(const QItemSelectionModel); - if (parent.isValid() && d->model != parent.model()) - return false; - - // return false if row exist in currentSelection (Deselect) - if (d->currentCommand & Deselect && d->currentSelection.count()) { - for (int i=0; i<d->currentSelection.count(); ++i) { - if (d->currentSelection.at(i).parent() == parent && - row >= d->currentSelection.at(i).top() && - row <= d->currentSelection.at(i).bottom()) - return false; - } - } - // return false if ranges in both currentSelection and ranges - // intersect and have the same row contained - if (d->currentCommand & Toggle && d->currentSelection.count()) { - for (int i=0; i<d->currentSelection.count(); ++i) - if (d->currentSelection.at(i).top() <= row && - d->currentSelection.at(i).bottom() >= row) - for (int j=0; j<d->ranges.count(); ++j) - if (d->ranges.at(j).top() <= row && d->ranges.at(j).bottom() >= row - && d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid()) - return false; - } - // add ranges and currentSelection and check through them all - QList<QItemSelectionRange>::const_iterator it; - QList<QItemSelectionRange> joined = d->ranges; - if (d->currentSelection.count()) - joined += d->currentSelection; - int colCount = d->model->columnCount(parent); - for (int column = 0; column < colCount; ++column) { - for (it = joined.constBegin(); it != joined.constEnd(); ++it) { - if ((*it).contains(row, column, parent)) { - bool selectable = false; - for (int i = column; !selectable && i <= (*it).right(); ++i) { - Qt::ItemFlags flags = d->model->index(row, i, parent).flags(); - selectable = flags & Qt::ItemIsSelectable; - } - if (selectable){ - column = qMax(column, (*it).right()); - break; - } - } - } - if (it == joined.constEnd()) - return false; - } - return colCount > 0; // no columns means no selected items -} - -/*! - Returns true if all items are selected in the \a column with the given - \a parent. - - Note that this function is usually faster than calling isSelected() - on all items in the same column and that unselectable items are - ignored. -*/ -bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent) const -{ - Q_D(const QItemSelectionModel); - if (parent.isValid() && d->model != parent.model()) - return false; - - // return false if column exist in currentSelection (Deselect) - if (d->currentCommand & Deselect && d->currentSelection.count()) { - for (int i = 0; i < d->currentSelection.count(); ++i) { - if (d->currentSelection.at(i).parent() == parent && - column >= d->currentSelection.at(i).left() && - column <= d->currentSelection.at(i).right()) - return false; - } - } - // return false if ranges in both currentSelection and the selection model - // intersect and have the same column contained - if (d->currentCommand & Toggle && d->currentSelection.count()) { - for (int i = 0; i < d->currentSelection.count(); ++i) { - if (d->currentSelection.at(i).left() <= column && - d->currentSelection.at(i).right() >= column) { - for (int j = 0; j < d->ranges.count(); ++j) { - if (d->ranges.at(j).left() <= column && d->ranges.at(j).right() >= column - && d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid()) { - return false; - } - } - } - } - } - // add ranges and currentSelection and check through them all - QList<QItemSelectionRange>::const_iterator it; - QList<QItemSelectionRange> joined = d->ranges; - if (d->currentSelection.count()) - joined += d->currentSelection; - int rowCount = d->model->rowCount(parent); - for (int row = 0; row < rowCount; ++row) { - for (it = joined.constBegin(); it != joined.constEnd(); ++it) { - if ((*it).contains(row, column, parent)) { - Qt::ItemFlags flags = d->model->index(row, column, parent).flags(); - if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) { - row = qMax(row, (*it).bottom()); - break; - } - } - } - if (it == joined.constEnd()) - return false; - } - return rowCount > 0; // no rows means no selected items -} - -/*! - Returns true if there are any items selected in the \a row with the given - \a parent. -*/ -bool QItemSelectionModel::rowIntersectsSelection(int row, const QModelIndex &parent) const -{ - Q_D(const QItemSelectionModel); - if (parent.isValid() && d->model != parent.model()) - return false; - - QItemSelection sel = d->ranges; - sel.merge(d->currentSelection, d->currentCommand); - for (int i = 0; i < sel.count(); ++i) { - int top = sel.at(i).top(); - int bottom = sel.at(i).bottom(); - int left = sel.at(i).left(); - int right = sel.at(i).right(); - if (top <= row && bottom >= row) { - for (int j = left; j <= right; j++) { - const Qt::ItemFlags flags = d->model->index(row, j, parent).flags(); - if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) - return true; - } - } - } - - return false; -} - -/*! - Returns true if there are any items selected in the \a column with the given - \a parent. -*/ -bool QItemSelectionModel::columnIntersectsSelection(int column, const QModelIndex &parent) const -{ - Q_D(const QItemSelectionModel); - if (parent.isValid() && d->model != parent.model()) - return false; - - QItemSelection sel = d->ranges; - sel.merge(d->currentSelection, d->currentCommand); - for (int i = 0; i < sel.count(); ++i) { - int left = sel.at(i).left(); - int right = sel.at(i).right(); - int top = sel.at(i).top(); - int bottom = sel.at(i).bottom(); - if (left <= column && right >= column) { - for (int j = top; j <= bottom; j++) { - const Qt::ItemFlags flags = d->model->index(j, column, parent).flags(); - if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) - return true; - } - } - } - - return false; -} - -/*! - \since 4.2 - - Returns true if the selection model contains any selection ranges; - otherwise returns false. -*/ -bool QItemSelectionModel::hasSelection() const -{ - Q_D(const QItemSelectionModel); - if (d->currentCommand & (Toggle | Deselect)) { - QItemSelection sel = d->ranges; - sel.merge(d->currentSelection, d->currentCommand); - return !sel.isEmpty(); - } else { - return !(d->ranges.isEmpty() && d->currentSelection.isEmpty()); - } -} - -/*! - Returns a list of all selected model item indexes. The list contains no - duplicates, and is not sorted. -*/ -QModelIndexList QItemSelectionModel::selectedIndexes() const -{ - Q_D(const QItemSelectionModel); - QItemSelection selected = d->ranges; - selected.merge(d->currentSelection, d->currentCommand); - return selected.indexes(); -} - -/*! - \since 4.2 - Returns the indexes in the given \a column for the rows where all columns are selected. - - \sa selectedIndexes(), selectedColumns() -*/ - -QModelIndexList QItemSelectionModel::selectedRows(int column) const -{ - QModelIndexList indexes; - //the QSet contains pairs of parent modelIndex - //and row number - QSet< QPair<QModelIndex, int> > rowsSeen; - - const QItemSelection ranges = selection(); - for (int i = 0; i < ranges.count(); ++i) { - const QItemSelectionRange &range = ranges.at(i); - QModelIndex parent = range.parent(); - for (int row = range.top(); row <= range.bottom(); row++) { - QPair<QModelIndex, int> rowDef = qMakePair(parent, row); - if (!rowsSeen.contains(rowDef)) { - rowsSeen << rowDef; - if (isRowSelected(row, parent)) { - indexes.append(model()->index(row, column, parent)); - } - } - } - } - - return indexes; -} - -/*! - \since 4.2 - Returns the indexes in the given \a row for columns where all rows are selected. - - \sa selectedIndexes(), selectedRows() -*/ - -QModelIndexList QItemSelectionModel::selectedColumns(int row) const -{ - QModelIndexList indexes; - //the QSet contains pairs of parent modelIndex - //and column number - QSet< QPair<QModelIndex, int> > columnsSeen; - - const QItemSelection ranges = selection(); - for (int i = 0; i < ranges.count(); ++i) { - const QItemSelectionRange &range = ranges.at(i); - QModelIndex parent = range.parent(); - for (int column = range.left(); column <= range.right(); column++) { - QPair<QModelIndex, int> columnDef = qMakePair(parent, column); - if (!columnsSeen.contains(columnDef)) { - columnsSeen << columnDef; - if (isColumnSelected(column, parent)) { - indexes.append(model()->index(row, column, parent)); - } - } - } - } - - return indexes; -} - -/*! - Returns the selection ranges stored in the selection model. -*/ -const QItemSelection QItemSelectionModel::selection() const -{ - Q_D(const QItemSelectionModel); - QItemSelection selected = d->ranges; - selected.merge(d->currentSelection, d->currentCommand); - int i = 0; - // make sure we have no invalid ranges - // ### should probably be handled more generic somewhere else - while (i<selected.count()) { - if (selected.at(i).isValid()) - ++i; - else - (selected.removeAt(i)); - } - return selected; -} - -/*! - Returns the item model operated on by the selection model. -*/ -const QAbstractItemModel *QItemSelectionModel::model() const -{ - return d_func()->model; -} - -/*! - Compares the two selections \a newSelection and \a oldSelection - and emits selectionChanged() with the deselected and selected items. -*/ -void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelection, - const QItemSelection &oldSelection) -{ - // if both selections are empty or equal we return - if ((oldSelection.isEmpty() && newSelection.isEmpty()) || - oldSelection == newSelection) - return; - - // if either selection is empty we do not need to compare - if (oldSelection.isEmpty() || newSelection.isEmpty()) { - emit selectionChanged(newSelection, oldSelection); - return; - } - - QItemSelection deselected = oldSelection; - QItemSelection selected = newSelection; - - // remove equal ranges - bool advance; - for (int o = 0; o < deselected.count(); ++o) { - advance = true; - for (int s = 0; s < selected.count() && o < deselected.count();) { - if (deselected.at(o) == selected.at(s)) { - deselected.removeAt(o); - selected.removeAt(s); - advance = false; - } else { - ++s; - } - } - if (advance) - ++o; - } - - // find intersections - QItemSelection intersections; - for (int o = 0; o < deselected.count(); ++o) { - for (int s = 0; s < selected.count(); ++s) { - if (deselected.at(o).intersects(selected.at(s))) - intersections.append(deselected.at(o).intersected(selected.at(s))); - } - } - - // compare remaining ranges with intersections and split them to find deselected and selected - for (int i = 0; i < intersections.count(); ++i) { - // split deselected - for (int o = 0; o < deselected.count();) { - if (deselected.at(o).intersects(intersections.at(i))) { - QItemSelection::split(deselected.at(o), intersections.at(i), &deselected); - deselected.removeAt(o); - } else { - ++o; - } - } - // split selected - for (int s = 0; s < selected.count();) { - if (selected.at(s).intersects(intersections.at(i))) { - QItemSelection::split(selected.at(s), intersections.at(i), &selected); - selected.removeAt(s); - } else { - ++s; - } - } - } - - if (!selected.isEmpty() || !deselected.isEmpty()) - emit selectionChanged(selected, deselected); -} - -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QItemSelectionRange &range) -{ -#ifndef Q_BROKEN_DEBUG_STREAM - dbg.nospace() << "QItemSelectionRange(" << range.topLeft() - << ',' << range.bottomRight() << ')'; - return dbg.space(); -#else - qWarning("This compiler doesn't support streaming QItemSelectionRange to QDebug"); - return dbg; - Q_UNUSED(range); -#endif -} -#endif - -QT_END_NAMESPACE - -#include "moc_qitemselectionmodel.cpp" - -#endif // QT_NO_ITEMVIEWS diff --git a/src/widgets/itemviews/qitemselectionmodel.h b/src/widgets/itemviews/qitemselectionmodel.h deleted file mode 100644 index ea0528a590..0000000000 --- a/src/widgets/itemviews/qitemselectionmodel.h +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QITEMSELECTIONMODEL_H -#define QITEMSELECTIONMODEL_H - -#include <QtCore/qset.h> -#include <QtCore/qvector.h> -#include <QtCore/qlist.h> -#include <QtCore/qabstractitemmodel.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_ITEMVIEWS - -class Q_WIDGETS_EXPORT QItemSelectionRange -{ - -public: - inline QItemSelectionRange() {} - inline QItemSelectionRange(const QItemSelectionRange &other) - : tl(other.tl), br(other.br) {} - inline QItemSelectionRange(const QModelIndex &topLeft, const QModelIndex &bottomRight); - explicit inline QItemSelectionRange(const QModelIndex &index) - { tl = index; br = tl; } - - inline int top() const { return tl.row(); } - inline int left() const { return tl.column(); } - inline int bottom() const { return br.row(); } - inline int right() const { return br.column(); } - inline int width() const { return br.column() - tl.column() + 1; } - inline int height() const { return br.row() - tl.row() + 1; } - - inline QModelIndex topLeft() const { return QModelIndex(tl); } - inline QModelIndex bottomRight() const { return QModelIndex(br); } - inline QModelIndex parent() const { return tl.parent(); } - inline const QAbstractItemModel *model() const { return tl.model(); } - - inline bool contains(const QModelIndex &index) const - { - return (parent() == index.parent() - && tl.row() <= index.row() && tl.column() <= index.column() - && br.row() >= index.row() && br.column() >= index.column()); - } - - inline bool contains(int row, int column, const QModelIndex &parentIndex) const - { - return (parent() == parentIndex - && tl.row() <= row && tl.column() <= column - && br.row() >= row && br.column() >= column); - } - - bool intersects(const QItemSelectionRange &other) const; - QItemSelectionRange intersect(const QItemSelectionRange &other) const; // ### Qt 5: make QT4_SUPPORT - inline QItemSelectionRange intersected(const QItemSelectionRange &other) const - { return intersect(other); } - - inline bool operator==(const QItemSelectionRange &other) const - { return (tl == other.tl && br == other.br); } - inline bool operator!=(const QItemSelectionRange &other) const - { return !operator==(other); } - inline bool operator<(const QItemSelectionRange &other) const - { - // Comparing parents will compare the models, but if two equivalent ranges - // in two different models have invalid parents, they would appear the same - if (other.tl.model() == tl.model()) { - // parent has to be calculated, so we only do so once. - const QModelIndex topLeftParent = tl.parent(); - const QModelIndex otherTopLeftParent = other.tl.parent(); - if (topLeftParent == otherTopLeftParent) { - if (other.tl.row() == tl.row()) { - if (other.tl.column() == tl.column()) { - if (other.br.row() == br.row()) { - return br.column() < other.br.column(); - } - return br.row() < other.br.row(); - } - return tl.column() < other.tl.column(); - } - return tl.row() < other.tl.row(); - } - return topLeftParent < otherTopLeftParent; - } - return tl.model() < other.tl.model(); - } - - inline bool isValid() const - { - return (tl.isValid() && br.isValid() && tl.parent() == br.parent() - && top() <= bottom() && left() <= right()); - } - - bool isEmpty() const; - - QModelIndexList indexes() const; - -private: - QPersistentModelIndex tl, br; -}; -Q_DECLARE_TYPEINFO(QItemSelectionRange, Q_MOVABLE_TYPE); - -inline QItemSelectionRange::QItemSelectionRange(const QModelIndex &atopLeft, - const QModelIndex &abottomRight) -{ tl = atopLeft; br = abottomRight; } - -class QItemSelection; -class QItemSelectionModelPrivate; - -class Q_WIDGETS_EXPORT QItemSelectionModel : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QItemSelectionModel) - Q_FLAGS(SelectionFlags) - -public: - - enum SelectionFlag { - NoUpdate = 0x0000, - Clear = 0x0001, - Select = 0x0002, - Deselect = 0x0004, - Toggle = 0x0008, - Current = 0x0010, - Rows = 0x0020, - Columns = 0x0040, - SelectCurrent = Select | Current, - ToggleCurrent = Toggle | Current, - ClearAndSelect = Clear | Select - }; - - Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag) - - explicit QItemSelectionModel(QAbstractItemModel *model); - explicit QItemSelectionModel(QAbstractItemModel *model, QObject *parent); - virtual ~QItemSelectionModel(); - - QModelIndex currentIndex() const; - - bool isSelected(const QModelIndex &index) const; - bool isRowSelected(int row, const QModelIndex &parent) const; - bool isColumnSelected(int column, const QModelIndex &parent) const; - - bool rowIntersectsSelection(int row, const QModelIndex &parent) const; - bool columnIntersectsSelection(int column, const QModelIndex &parent) const; - - bool hasSelection() const; - - QModelIndexList selectedIndexes() const; - QModelIndexList selectedRows(int column = 0) const; - QModelIndexList selectedColumns(int row = 0) const; - const QItemSelection selection() const; - - const QAbstractItemModel *model() const; - -public Q_SLOTS: - virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command); - virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command); - virtual void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command); - virtual void clear(); - virtual void reset(); - - void clearSelection(); - virtual void clearCurrentIndex(); - -Q_SIGNALS: - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); - void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); - void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous); - void currentColumnChanged(const QModelIndex ¤t, const QModelIndex &previous); - -protected: - QItemSelectionModel(QItemSelectionModelPrivate &dd, QAbstractItemModel *model); - void emitSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection); - -private: - Q_DISABLE_COPY(QItemSelectionModel) - Q_PRIVATE_SLOT(d_func(), void _q_columnsAboutToBeRemoved(const QModelIndex&, int, int)) - Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeRemoved(const QModelIndex&, int, int)) - Q_PRIVATE_SLOT(d_func(), void _q_columnsAboutToBeInserted(const QModelIndex&, int, int)) - Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeInserted(const QModelIndex&, int, int)) - Q_PRIVATE_SLOT(d_func(), void _q_layoutAboutToBeChanged()) - Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged()) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags) - -// dummy implentation of qHash() necessary for instantiating QList<QItemSelectionRange>::toSet() with MSVC -inline uint qHash(const QItemSelectionRange &) { return 0; } - -class Q_WIDGETS_EXPORT QItemSelection : public QList<QItemSelectionRange> -{ -public: - QItemSelection() {} - QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight); - void select(const QModelIndex &topLeft, const QModelIndex &bottomRight); - bool contains(const QModelIndex &index) const; - QModelIndexList indexes() const; - void merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command); - static void split(const QItemSelectionRange &range, - const QItemSelectionRange &other, - QItemSelection *result); -}; - -#ifndef QT_NO_DEBUG_STREAM -Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QItemSelectionRange &); -#endif - -#endif // QT_NO_ITEMVIEWS - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QITEMSELECTIONMODEL_H diff --git a/src/widgets/itemviews/qitemselectionmodel_p.h b/src/widgets/itemviews/qitemselectionmodel_p.h deleted file mode 100644 index 5eb9ecccda..0000000000 --- a/src/widgets/itemviews/qitemselectionmodel_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QITEMSELECTIONMODEL_P_H -#define QITEMSELECTIONMODEL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qobject_p.h" - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ITEMVIEWS -class QItemSelectionModelPrivate: public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QItemSelectionModel) -public: - QItemSelectionModelPrivate() - : model(0), - currentCommand(QItemSelectionModel::NoUpdate), - tableSelected(false), tableColCount(0), tableRowCount(0) {} - - QItemSelection expandSelection(const QItemSelection &selection, - QItemSelectionModel::SelectionFlags command) const; - - void initModel(QAbstractItemModel *model); - - void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void _q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void _q_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); - void _q_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end); - void _q_layoutAboutToBeChanged(); - void _q_layoutChanged(); - - inline void remove(QList<QItemSelectionRange> &r) - { - QList<QItemSelectionRange>::const_iterator it = r.constBegin(); - for (; it != r.constEnd(); ++it) - ranges.removeAll(*it); - } - - inline void finalize() - { - ranges.merge(currentSelection, currentCommand); - if (!currentSelection.isEmpty()) // ### perhaps this should be in QList - currentSelection.clear(); - } - - QPointer<QAbstractItemModel> model; - QItemSelection ranges; - QItemSelection currentSelection; - QPersistentModelIndex currentIndex; - QItemSelectionModel::SelectionFlags currentCommand; - QList<QPersistentModelIndex> savedPersistentIndexes; - QList<QPersistentModelIndex> savedPersistentCurrentIndexes; - // optimization when all indexes are selected - bool tableSelected; - QPersistentModelIndex tableParent; - int tableColCount, tableRowCount; -}; - -#endif // QT_NO_ITEMVIEWS - -QT_END_NAMESPACE - -#endif // QITEMSELECTIONMODEL_P_H diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 44ae7246c4..d0b5821c93 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -730,10 +730,10 @@ QSize QListView::contentsSize() const /*! \reimp */ -void QListView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +void QListView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &roles) { d_func()->commonListView->dataChanged(topLeft, bottomRight); - QAbstractItemView::dataChanged(topLeft, bottomRight); + QAbstractItemView::dataChanged(topLeft, bottomRight, roles); } /*! diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h index 8e1a04492f..f78806fef1 100644 --- a/src/widgets/itemviews/qlistview.h +++ b/src/widgets/itemviews/qlistview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -147,7 +147,7 @@ protected: void resizeContents(int width, int height); QSize contentsSize() const; - void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &roles = QSet<int>()); void rowsInserted(const QModelIndex &parent, int start, int end); void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h index 6a7acf669d..b959e66686 100644 --- a/src/widgets/itemviews/qlistview_p.h +++ b/src/widgets/itemviews/qlistview_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index a4aaa6b4b6..d99d63c15f 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h index 750b85b4c1..b119b62046 100644 --- a/src/widgets/itemviews/qlistwidget.h +++ b/src/widgets/itemviews/qlistwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -45,7 +45,7 @@ #include <QtWidgets/qlistview.h> #include <QtCore/qvariant.h> #include <QtCore/qvector.h> -#include <QtWidgets/qitemselectionmodel.h> +#include <QtCore/qitemselectionmodel.h> QT_BEGIN_HEADER diff --git a/src/widgets/itemviews/qlistwidget_p.h b/src/widgets/itemviews/qlistwidget_p.h index 2e879cc5d7..9d6b28d813 100644 --- a/src/widgets/itemviews/qlistwidget_p.h +++ b/src/widgets/itemviews/qlistwidget_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qproxymodel.cpp b/src/widgets/itemviews/qproxymodel.cpp index bc76bf1623..861cb95ca4 100644 --- a/src/widgets/itemviews/qproxymodel.cpp +++ b/src/widgets/itemviews/qproxymodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qproxymodel.h b/src/widgets/itemviews/qproxymodel.h index 948f9a07c9..870ea7b003 100644 --- a/src/widgets/itemviews/qproxymodel.h +++ b/src/widgets/itemviews/qproxymodel.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qproxymodel_p.h b/src/widgets/itemviews/qproxymodel_p.h index 0a8668d2f8..3b73e844dc 100644 --- a/src/widgets/itemviews/qproxymodel_p.h +++ b/src/widgets/itemviews/qproxymodel_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qsortfilterproxymodel.cpp b/src/widgets/itemviews/qsortfilterproxymodel.cpp deleted file mode 100644 index f29ad7bc57..0000000000 --- a/src/widgets/itemviews/qsortfilterproxymodel.cpp +++ /dev/null @@ -1,2703 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsortfilterproxymodel.h" - -#ifndef QT_NO_SORTFILTERPROXYMODEL - -#include "qitemselectionmodel.h" -#include <qsize.h> -#include <qdebug.h> -#include <qdatetime.h> -#include <qpair.h> -#include <qstringlist.h> -#include <private/qabstractitemmodel_p.h> -#include <private/qabstractproxymodel_p.h> - -QT_BEGIN_NAMESPACE - -typedef QList<QPair<QModelIndex, QPersistentModelIndex> > QModelIndexPairList; - -static inline QSet<int> qVectorToSet(const QVector<int> &vector) -{ - QSet<int> set; - set.reserve(vector.size()); - for(int i=0; i < vector.size(); ++i) - set << vector.at(i); - return set; -} - -class QSortFilterProxyModelLessThan -{ -public: - inline QSortFilterProxyModelLessThan(int column, const QModelIndex &parent, - const QAbstractItemModel *source, - const QSortFilterProxyModel *proxy) - : sort_column(column), source_parent(parent), source_model(source), proxy_model(proxy) {} - - inline bool operator()(int r1, int r2) const - { - QModelIndex i1 = source_model->index(r1, sort_column, source_parent); - QModelIndex i2 = source_model->index(r2, sort_column, source_parent); - return proxy_model->lessThan(i1, i2); - } - -private: - int sort_column; - QModelIndex source_parent; - const QAbstractItemModel *source_model; - const QSortFilterProxyModel *proxy_model; -}; - -class QSortFilterProxyModelGreaterThan -{ -public: - inline QSortFilterProxyModelGreaterThan(int column, const QModelIndex &parent, - const QAbstractItemModel *source, - const QSortFilterProxyModel *proxy) - : sort_column(column), source_parent(parent), - source_model(source), proxy_model(proxy) {} - - inline bool operator()(int r1, int r2) const - { - QModelIndex i1 = source_model->index(r1, sort_column, source_parent); - QModelIndex i2 = source_model->index(r2, sort_column, source_parent); - return proxy_model->lessThan(i2, i1); - } - -private: - int sort_column; - QModelIndex source_parent; - const QAbstractItemModel *source_model; - const QSortFilterProxyModel *proxy_model; -}; - - -//this struct is used to store what are the rows that are removed -//between a call to rowsAboutToBeRemoved and rowsRemoved -//it avoids readding rows to the mapping that are currently being removed -struct QRowsRemoval -{ - QRowsRemoval(const QModelIndex &parent_source, int start, int end) : parent_source(parent_source), start(start), end(end) - { - } - - QRowsRemoval() : start(-1), end(-1) - { - } - - bool contains(QModelIndex parent, int row) - { - do { - if (parent == parent_source) - return row >= start && row <= end; - row = parent.row(); - parent = parent.parent(); - } while (row >= 0); - return false; - } -private: - QModelIndex parent_source; - int start; - int end; -}; - -class QSortFilterProxyModelPrivate : public QAbstractProxyModelPrivate -{ - Q_DECLARE_PUBLIC(QSortFilterProxyModel) - -public: - struct Mapping { - QVector<int> source_rows; - QVector<int> source_columns; - QVector<int> proxy_rows; - QVector<int> proxy_columns; - QVector<QModelIndex> mapped_children; - QHash<QModelIndex, Mapping *>::const_iterator map_iter; - }; - - mutable QHash<QModelIndex, Mapping*> source_index_mapping; - - int source_sort_column; - int proxy_sort_column; - Qt::SortOrder sort_order; - Qt::CaseSensitivity sort_casesensitivity; - int sort_role; - bool sort_localeaware; - - int filter_column; - QRegExp filter_regexp; - int filter_role; - - bool dynamic_sortfilter; - QRowsRemoval itemsBeingRemoved; - - QModelIndexPairList saved_persistent_indexes; - - QHash<QModelIndex, Mapping *>::const_iterator create_mapping( - const QModelIndex &source_parent) const; - QModelIndex proxy_to_source(const QModelIndex &proxyIndex) const; - QModelIndex source_to_proxy(const QModelIndex &sourceIndex) const; - bool can_create_mapping(const QModelIndex &source_parent) const; - - void remove_from_mapping(const QModelIndex &source_parent); - - inline QHash<QModelIndex, Mapping *>::const_iterator index_to_iterator( - const QModelIndex &proxy_index) const - { - Q_ASSERT(proxy_index.isValid()); - Q_ASSERT(proxy_index.model() == q_func()); - const void *p = proxy_index.internalPointer(); - Q_ASSERT(p); - QHash<QModelIndex, Mapping *>::const_iterator it = - static_cast<const Mapping*>(p)->map_iter; - Q_ASSERT(it != source_index_mapping.constEnd()); - Q_ASSERT(it.value()); - return it; - } - - inline QModelIndex create_index(int row, int column, - QHash<QModelIndex, Mapping*>::const_iterator it) const - { - return q_func()->createIndex(row, column, *it); - } - - void _q_sourceDataChanged(const QModelIndex &source_top_left, - const QModelIndex &source_bottom_right); - void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end); - - void _q_sourceAboutToBeReset(); - void _q_sourceReset(); - - void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents); - void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents); - - void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, - int start, int end); - void _q_sourceRowsInserted(const QModelIndex &source_parent, - int start, int end); - void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, - int start, int end); - void _q_sourceRowsRemoved(const QModelIndex &source_parent, - int start, int end); - void _q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, - int sourceStart, int sourceEnd, - const QModelIndex &destParent, int dest); - void _q_sourceRowsMoved(const QModelIndex &sourceParent, - int sourceStart, int sourceEnd, - const QModelIndex &destParent, int dest); - void _q_sourceColumnsAboutToBeInserted(const QModelIndex &source_parent, - int start, int end); - void _q_sourceColumnsInserted(const QModelIndex &source_parent, - int start, int end); - void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &source_parent, - int start, int end); - void _q_sourceColumnsRemoved(const QModelIndex &source_parent, - int start, int end); - void _q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, - int sourceStart, int sourceEnd, - const QModelIndex &destParent, int dest); - void _q_sourceColumnsMoved(const QModelIndex &sourceParent, - int sourceStart, int sourceEnd, - const QModelIndex &destParent, int dest); - - void _q_clearMapping(); - - void sort(); - bool update_source_sort_column(); - void sort_source_rows(QVector<int> &source_rows, - const QModelIndex &source_parent) const; - QVector<QPair<int, QVector<int > > > proxy_intervals_for_source_items_to_add( - const QVector<int> &proxy_to_source, const QVector<int> &source_items, - const QModelIndex &source_parent, Qt::Orientation orient) const; - QVector<QPair<int, int > > proxy_intervals_for_source_items( - const QVector<int> &source_to_proxy, const QVector<int> &source_items) const; - void insert_source_items( - QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, - const QVector<int> &source_items, const QModelIndex &source_parent, - Qt::Orientation orient, bool emit_signal = true); - void remove_source_items( - QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, - const QVector<int> &source_items, const QModelIndex &source_parent, - Qt::Orientation orient, bool emit_signal = true); - void remove_proxy_interval( - QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, - int proxy_start, int proxy_end, const QModelIndex &proxy_parent, - Qt::Orientation orient, bool emit_signal = true); - void build_source_to_proxy_mapping( - const QVector<int> &proxy_to_source, QVector<int> &source_to_proxy) const; - void source_items_inserted(const QModelIndex &source_parent, - int start, int end, Qt::Orientation orient); - void source_items_about_to_be_removed(const QModelIndex &source_parent, - int start, int end, Qt::Orientation orient); - void source_items_removed(const QModelIndex &source_parent, - int start, int end, Qt::Orientation orient); - void proxy_item_range( - const QVector<int> &source_to_proxy, const QVector<int> &source_items, - int &proxy_low, int &proxy_high) const; - - QModelIndexPairList store_persistent_indexes(); - void update_persistent_indexes(const QModelIndexPairList &source_indexes); - - void filter_changed(const QModelIndex &source_parent = QModelIndex()); - QSet<int> handle_filter_changed( - QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, - const QModelIndex &source_parent, Qt::Orientation orient); - - void updateChildrenMapping(const QModelIndex &source_parent, Mapping *parent_mapping, - Qt::Orientation orient, int start, int end, int delta_item_count, bool remove); - - virtual void _q_sourceModelDestroyed(); -}; - -typedef QHash<QModelIndex, QSortFilterProxyModelPrivate::Mapping *> IndexMap; - -void QSortFilterProxyModelPrivate::_q_sourceModelDestroyed() -{ - QAbstractProxyModelPrivate::_q_sourceModelDestroyed(); - _q_clearMapping(); -} - -void QSortFilterProxyModelPrivate::remove_from_mapping(const QModelIndex &source_parent) -{ - if (Mapping *m = source_index_mapping.take(source_parent)) { - for (int i = 0; i < m->mapped_children.size(); ++i) - remove_from_mapping(m->mapped_children.at(i)); - delete m; - } -} - -void QSortFilterProxyModelPrivate::_q_clearMapping() -{ - // store the persistent indexes - QModelIndexPairList source_indexes = store_persistent_indexes(); - - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - if (dynamic_sortfilter && update_source_sort_column()) { - //update_source_sort_column might have created wrong mapping so we have to clear it again - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - } - - // update the persistent indexes - update_persistent_indexes(source_indexes); -} - -IndexMap::const_iterator QSortFilterProxyModelPrivate::create_mapping( - const QModelIndex &source_parent) const -{ - Q_Q(const QSortFilterProxyModel); - - IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); - if (it != source_index_mapping.constEnd()) // was mapped already - return it; - - Mapping *m = new Mapping; - - int source_rows = model->rowCount(source_parent); - m->source_rows.reserve(source_rows); - for (int i = 0; i < source_rows; ++i) { - if (q->filterAcceptsRow(i, source_parent)) - m->source_rows.append(i); - } - int source_cols = model->columnCount(source_parent); - m->source_columns.reserve(source_cols); - for (int i = 0; i < source_cols; ++i) { - if (q->filterAcceptsColumn(i, source_parent)) - m->source_columns.append(i); - } - - sort_source_rows(m->source_rows, source_parent); - m->proxy_rows.resize(source_rows); - build_source_to_proxy_mapping(m->source_rows, m->proxy_rows); - m->proxy_columns.resize(source_cols); - build_source_to_proxy_mapping(m->source_columns, m->proxy_columns); - - it = IndexMap::const_iterator(source_index_mapping.insert(source_parent, m)); - m->map_iter = it; - - if (source_parent.isValid()) { - QModelIndex source_grand_parent = source_parent.parent(); - IndexMap::const_iterator it2 = create_mapping(source_grand_parent); - Q_ASSERT(it2 != source_index_mapping.constEnd()); - it2.value()->mapped_children.append(source_parent); - } - - Q_ASSERT(it != source_index_mapping.constEnd()); - Q_ASSERT(it.value()); - - return it; -} - -QModelIndex QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex &proxy_index) const -{ - if (!proxy_index.isValid()) - return QModelIndex(); // for now; we may want to be able to set a root index later - if (proxy_index.model() != q_func()) { - qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapToSource"; - Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapToSource"); - return QModelIndex(); - } - IndexMap::const_iterator it = index_to_iterator(proxy_index); - Mapping *m = it.value(); - if ((proxy_index.row() >= m->source_rows.size()) || (proxy_index.column() >= m->source_columns.size())) - return QModelIndex(); - int source_row = m->source_rows.at(proxy_index.row()); - int source_col = m->source_columns.at(proxy_index.column()); - return model->index(source_row, source_col, it.key()); -} - -QModelIndex QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex &source_index) const -{ - if (!source_index.isValid()) - return QModelIndex(); // for now; we may want to be able to set a root index later - if (source_index.model() != model) { - qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapFromSource"; - Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapFromSource"); - return QModelIndex(); - } - QModelIndex source_parent = source_index.parent(); - IndexMap::const_iterator it = create_mapping(source_parent); - Mapping *m = it.value(); - if ((source_index.row() >= m->proxy_rows.size()) || (source_index.column() >= m->proxy_columns.size())) - return QModelIndex(); - int proxy_row = m->proxy_rows.at(source_index.row()); - int proxy_column = m->proxy_columns.at(source_index.column()); - if (proxy_row == -1 || proxy_column == -1) - return QModelIndex(); - return create_index(proxy_row, proxy_column, it); -} - -bool QSortFilterProxyModelPrivate::can_create_mapping(const QModelIndex &source_parent) const -{ - if (source_parent.isValid()) { - QModelIndex source_grand_parent = source_parent.parent(); - IndexMap::const_iterator it = source_index_mapping.constFind(source_grand_parent); - if (it == source_index_mapping.constEnd()) { - // Don't care, since we don't have mapping for the grand parent - return false; - } - Mapping *gm = it.value(); - if (gm->proxy_rows.at(source_parent.row()) == -1 || - gm->proxy_columns.at(source_parent.column()) == -1) { - // Don't care, since parent is filtered - return false; - } - } - return true; -} - -/*! - \internal - - Sorts the existing mappings. -*/ -void QSortFilterProxyModelPrivate::sort() -{ - Q_Q(QSortFilterProxyModel); - emit q->layoutAboutToBeChanged(); - QModelIndexPairList source_indexes = store_persistent_indexes(); - IndexMap::const_iterator it = source_index_mapping.constBegin(); - for (; it != source_index_mapping.constEnd(); ++it) { - QModelIndex source_parent = it.key(); - Mapping *m = it.value(); - sort_source_rows(m->source_rows, source_parent); - build_source_to_proxy_mapping(m->source_rows, m->proxy_rows); - } - update_persistent_indexes(source_indexes); - emit q->layoutChanged(); -} - -/*! - \internal - - update the source_sort_column according to the proxy_sort_column - return true if the column was changed -*/ -bool QSortFilterProxyModelPrivate::update_source_sort_column() -{ - Q_Q(QSortFilterProxyModel); - QModelIndex proxy_index = q->index(0, proxy_sort_column, QModelIndex()); - int old_source_sort_colum = source_sort_column; - source_sort_column = q->mapToSource(proxy_index).column(); - return old_source_sort_colum != source_sort_column; -} - - -/*! - \internal - - Sorts the given \a source_rows according to current sort column and order. -*/ -void QSortFilterProxyModelPrivate::sort_source_rows( - QVector<int> &source_rows, const QModelIndex &source_parent) const -{ - Q_Q(const QSortFilterProxyModel); - if (source_sort_column >= 0) { - if (sort_order == Qt::AscendingOrder) { - QSortFilterProxyModelLessThan lt(source_sort_column, source_parent, model, q); - qStableSort(source_rows.begin(), source_rows.end(), lt); - } else { - QSortFilterProxyModelGreaterThan gt(source_sort_column, source_parent, model, q); - qStableSort(source_rows.begin(), source_rows.end(), gt); - } - } else { // restore the source model order - qStableSort(source_rows.begin(), source_rows.end()); - } -} - -/*! - \internal - - Given source-to-proxy mapping \a source_to_proxy and the set of - source items \a source_items (which are part of that mapping), - determines the corresponding proxy item intervals that should - be removed from the proxy model. - - The result is a vector of pairs, where each pair represents a - (start, end) tuple, sorted in ascending order. -*/ -QVector<QPair<int, int > > QSortFilterProxyModelPrivate::proxy_intervals_for_source_items( - const QVector<int> &source_to_proxy, const QVector<int> &source_items) const -{ - QVector<QPair<int, int> > proxy_intervals; - if (source_items.isEmpty()) - return proxy_intervals; - - int source_items_index = 0; - while (source_items_index < source_items.size()) { - int first_proxy_item = source_to_proxy.at(source_items.at(source_items_index)); - Q_ASSERT(first_proxy_item != -1); - int last_proxy_item = first_proxy_item; - ++source_items_index; - // Find end of interval - while ((source_items_index < source_items.size()) - && (source_to_proxy.at(source_items.at(source_items_index)) == last_proxy_item + 1)) { - ++last_proxy_item; - ++source_items_index; - } - // Add interval to result - proxy_intervals.append(QPair<int, int>(first_proxy_item, last_proxy_item)); - } - qStableSort(proxy_intervals.begin(), proxy_intervals.end()); - return proxy_intervals; -} - -/*! - \internal - - Given source-to-proxy mapping \a src_to_proxy and proxy-to-source mapping - \a proxy_to_source, removes \a source_items from this proxy model. - The corresponding proxy items are removed in intervals, so that the proper - rows/columnsRemoved(start, end) signals will be generated. -*/ -void QSortFilterProxyModelPrivate::remove_source_items( - QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, - const QVector<int> &source_items, const QModelIndex &source_parent, - Qt::Orientation orient, bool emit_signal) -{ - Q_Q(QSortFilterProxyModel); - QModelIndex proxy_parent = q->mapFromSource(source_parent); - if (!proxy_parent.isValid() && source_parent.isValid()) - return; // nothing to do (already removed) - - QVector<QPair<int, int> > proxy_intervals; - proxy_intervals = proxy_intervals_for_source_items(source_to_proxy, source_items); - - for (int i = proxy_intervals.size()-1; i >= 0; --i) { - QPair<int, int> interval = proxy_intervals.at(i); - int proxy_start = interval.first; - int proxy_end = interval.second; - remove_proxy_interval(source_to_proxy, proxy_to_source, proxy_start, proxy_end, - proxy_parent, orient, emit_signal); - } -} - -/*! - \internal - - Given source-to-proxy mapping \a source_to_proxy and proxy-to-source mapping - \a proxy_to_source, removes items from \a proxy_start to \a proxy_end - (inclusive) from this proxy model. -*/ -void QSortFilterProxyModelPrivate::remove_proxy_interval( - QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, int proxy_start, int proxy_end, - const QModelIndex &proxy_parent, Qt::Orientation orient, bool emit_signal) -{ - Q_Q(QSortFilterProxyModel); - if (emit_signal) { - if (orient == Qt::Vertical) - q->beginRemoveRows(proxy_parent, proxy_start, proxy_end); - else - q->beginRemoveColumns(proxy_parent, proxy_start, proxy_end); - } - - // Remove items from proxy-to-source mapping - proxy_to_source.remove(proxy_start, proxy_end - proxy_start + 1); - - build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); - - if (emit_signal) { - if (orient == Qt::Vertical) - q->endRemoveRows(); - else - q->endRemoveColumns(); - } -} - -/*! - \internal - - Given proxy-to-source mapping \a proxy_to_source and a set of - unmapped source items \a source_items, determines the proxy item - intervals at which the subsets of source items should be inserted - (but does not actually add them to the mapping). - - The result is a vector of pairs, each pair representing a tuple (start, - items), where items is a vector containing the (sorted) source items that - should be inserted at that proxy model location. -*/ -QVector<QPair<int, QVector<int > > > QSortFilterProxyModelPrivate::proxy_intervals_for_source_items_to_add( - const QVector<int> &proxy_to_source, const QVector<int> &source_items, - const QModelIndex &source_parent, Qt::Orientation orient) const -{ - Q_Q(const QSortFilterProxyModel); - QVector<QPair<int, QVector<int> > > proxy_intervals; - if (source_items.isEmpty()) - return proxy_intervals; - - int proxy_low = 0; - int proxy_item = 0; - int source_items_index = 0; - QVector<int> source_items_in_interval; - bool compare = (orient == Qt::Vertical && source_sort_column >= 0 && dynamic_sortfilter); - while (source_items_index < source_items.size()) { - source_items_in_interval.clear(); - int first_new_source_item = source_items.at(source_items_index); - source_items_in_interval.append(first_new_source_item); - ++source_items_index; - - // Find proxy item at which insertion should be started - int proxy_high = proxy_to_source.size() - 1; - QModelIndex i1 = compare ? model->index(first_new_source_item, source_sort_column, source_parent) : QModelIndex(); - while (proxy_low <= proxy_high) { - proxy_item = (proxy_low + proxy_high) / 2; - if (compare) { - QModelIndex i2 = model->index(proxy_to_source.at(proxy_item), source_sort_column, source_parent); - if ((sort_order == Qt::AscendingOrder) ? q->lessThan(i1, i2) : q->lessThan(i2, i1)) - proxy_high = proxy_item - 1; - else - proxy_low = proxy_item + 1; - } else { - if (first_new_source_item < proxy_to_source.at(proxy_item)) - proxy_high = proxy_item - 1; - else - proxy_low = proxy_item + 1; - } - } - proxy_item = proxy_low; - - // Find the sequence of new source items that should be inserted here - if (proxy_item >= proxy_to_source.size()) { - for ( ; source_items_index < source_items.size(); ++source_items_index) - source_items_in_interval.append(source_items.at(source_items_index)); - } else { - i1 = compare ? model->index(proxy_to_source.at(proxy_item), source_sort_column, source_parent) : QModelIndex(); - for ( ; source_items_index < source_items.size(); ++source_items_index) { - int new_source_item = source_items.at(source_items_index); - if (compare) { - QModelIndex i2 = model->index(new_source_item, source_sort_column, source_parent); - if ((sort_order == Qt::AscendingOrder) ? q->lessThan(i1, i2) : q->lessThan(i2, i1)) - break; - } else { - if (proxy_to_source.at(proxy_item) < new_source_item) - break; - } - source_items_in_interval.append(new_source_item); - } - } - - // Add interval to result - proxy_intervals.append(QPair<int, QVector<int> >(proxy_item, source_items_in_interval)); - } - return proxy_intervals; -} - -/*! - \internal - - Given source-to-proxy mapping \a source_to_proxy and proxy-to-source mapping - \a proxy_to_source, inserts the given \a source_items into this proxy model. - The source items are inserted in intervals (based on some sorted order), so - that the proper rows/columnsInserted(start, end) signals will be generated. -*/ -void QSortFilterProxyModelPrivate::insert_source_items( - QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, - const QVector<int> &source_items, const QModelIndex &source_parent, - Qt::Orientation orient, bool emit_signal) -{ - Q_Q(QSortFilterProxyModel); - QModelIndex proxy_parent = q->mapFromSource(source_parent); - if (!proxy_parent.isValid() && source_parent.isValid()) - return; // nothing to do (source_parent is not mapped) - - QVector<QPair<int, QVector<int> > > proxy_intervals; - proxy_intervals = proxy_intervals_for_source_items_to_add( - proxy_to_source, source_items, source_parent, orient); - - for (int i = proxy_intervals.size()-1; i >= 0; --i) { - QPair<int, QVector<int> > interval = proxy_intervals.at(i); - int proxy_start = interval.first; - QVector<int> source_items = interval.second; - int proxy_end = proxy_start + source_items.size() - 1; - - if (emit_signal) { - if (orient == Qt::Vertical) - q->beginInsertRows(proxy_parent, proxy_start, proxy_end); - else - q->beginInsertColumns(proxy_parent, proxy_start, proxy_end); - } - - for (int i = 0; i < source_items.size(); ++i) - proxy_to_source.insert(proxy_start + i, source_items.at(i)); - - build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); - - if (emit_signal) { - if (orient == Qt::Vertical) - q->endInsertRows(); - else - q->endInsertColumns(); - } - } -} - -/*! - \internal - - Handles source model items insertion (columnsInserted(), rowsInserted()). - Determines - 1) which of the inserted items to also insert into proxy model (filtering), - 2) where to insert the items into the proxy model (sorting), - then inserts those items. - The items are inserted into the proxy model in intervals (based on - sorted order), so that the proper rows/columnsInserted(start, end) - signals will be generated. -*/ -void QSortFilterProxyModelPrivate::source_items_inserted( - const QModelIndex &source_parent, int start, int end, Qt::Orientation orient) -{ - Q_Q(QSortFilterProxyModel); - if ((start < 0) || (end < 0)) - return; - IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); - if (it == source_index_mapping.constEnd()) { - if (!can_create_mapping(source_parent)) - return; - it = create_mapping(source_parent); - Mapping *m = it.value(); - QModelIndex proxy_parent = q->mapFromSource(source_parent); - if (m->source_rows.count() > 0) { - q->beginInsertRows(proxy_parent, 0, m->source_rows.count() - 1); - q->endInsertRows(); - } - if (m->source_columns.count() > 0) { - q->beginInsertColumns(proxy_parent, 0, m->source_columns.count() - 1); - q->endInsertColumns(); - } - return; - } - - Mapping *m = it.value(); - QVector<int> &source_to_proxy = (orient == Qt::Vertical) ? m->proxy_rows : m->proxy_columns; - QVector<int> &proxy_to_source = (orient == Qt::Vertical) ? m->source_rows : m->source_columns; - - int delta_item_count = end - start + 1; - int old_item_count = source_to_proxy.size(); - - updateChildrenMapping(source_parent, m, orient, start, end, delta_item_count, false); - - // Expand source-to-proxy mapping to account for new items - if (start < 0 || start > source_to_proxy.size()) { - qWarning("QSortFilterProxyModel: invalid inserted rows reported by source model"); - remove_from_mapping(source_parent); - return; - } - source_to_proxy.insert(start, delta_item_count, -1); - - if (start < old_item_count) { - // Adjust existing "stale" indexes in proxy-to-source mapping - int proxy_count = proxy_to_source.size(); - for (int proxy_item = 0; proxy_item < proxy_count; ++proxy_item) { - int source_item = proxy_to_source.at(proxy_item); - if (source_item >= start) - proxy_to_source.replace(proxy_item, source_item + delta_item_count); - } - build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); - } - - // Figure out which items to add to mapping based on filter - QVector<int> source_items; - for (int i = start; i <= end; ++i) { - if ((orient == Qt::Vertical) - ? q->filterAcceptsRow(i, source_parent) - : q->filterAcceptsColumn(i, source_parent)) { - source_items.append(i); - } - } - - if (model->rowCount(source_parent) == delta_item_count) { - // Items were inserted where there were none before. - // If it was new rows make sure to create mappings for columns so that a - // valid mapping can be retrieved later and vice-versa. - - QVector<int> &orthogonal_proxy_to_source = (orient == Qt::Horizontal) ? m->source_rows : m->source_columns; - QVector<int> &orthogonal_source_to_proxy = (orient == Qt::Horizontal) ? m->proxy_rows : m->proxy_columns; - - if (orthogonal_source_to_proxy.isEmpty()) { - const int ortho_end = (orient == Qt::Horizontal) ? model->rowCount(source_parent) : model->columnCount(source_parent); - - orthogonal_source_to_proxy.resize(ortho_end); - - for (int ortho_item = 0; ortho_item < ortho_end; ++ortho_item) { - if ((orient == Qt::Horizontal) ? q->filterAcceptsRow(ortho_item, source_parent) - : q->filterAcceptsColumn(ortho_item, source_parent)) { - orthogonal_proxy_to_source.append(ortho_item); - } - } - if (orient == Qt::Horizontal) { - // We're reacting to columnsInserted, but we've just inserted new rows. Sort them. - sort_source_rows(orthogonal_proxy_to_source, source_parent); - } - build_source_to_proxy_mapping(orthogonal_proxy_to_source, orthogonal_source_to_proxy); - } - } - - // Sort and insert the items - if (orient == Qt::Vertical) // Only sort rows - sort_source_rows(source_items, source_parent); - insert_source_items(source_to_proxy, proxy_to_source, source_items, source_parent, orient); -} - -/*! - \internal - - Handles source model items removal - (columnsAboutToBeRemoved(), rowsAboutToBeRemoved()). -*/ -void QSortFilterProxyModelPrivate::source_items_about_to_be_removed( - const QModelIndex &source_parent, int start, int end, Qt::Orientation orient) -{ - if ((start < 0) || (end < 0)) - return; - IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); - if (it == source_index_mapping.constEnd()) { - // Don't care, since we don't have mapping for this index - return; - } - - Mapping *m = it.value(); - QVector<int> &source_to_proxy = (orient == Qt::Vertical) ? m->proxy_rows : m->proxy_columns; - QVector<int> &proxy_to_source = (orient == Qt::Vertical) ? m->source_rows : m->source_columns; - - // figure out which items to remove - QVector<int> source_items_to_remove; - int proxy_count = proxy_to_source.size(); - for (int proxy_item = 0; proxy_item < proxy_count; ++proxy_item) { - int source_item = proxy_to_source.at(proxy_item); - if ((source_item >= start) && (source_item <= end)) - source_items_to_remove.append(source_item); - } - - remove_source_items(source_to_proxy, proxy_to_source, source_items_to_remove, - source_parent, orient); -} - -/*! - \internal - - Handles source model items removal (columnsRemoved(), rowsRemoved()). -*/ -void QSortFilterProxyModelPrivate::source_items_removed( - const QModelIndex &source_parent, int start, int end, Qt::Orientation orient) -{ - if ((start < 0) || (end < 0)) - return; - IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); - if (it == source_index_mapping.constEnd()) { - // Don't care, since we don't have mapping for this index - return; - } - - Mapping *m = it.value(); - QVector<int> &source_to_proxy = (orient == Qt::Vertical) ? m->proxy_rows : m->proxy_columns; - QVector<int> &proxy_to_source = (orient == Qt::Vertical) ? m->source_rows : m->source_columns; - - if (end >= source_to_proxy.size()) - end = source_to_proxy.size() - 1; - - // Shrink the source-to-proxy mapping to reflect the new item count - int delta_item_count = end - start + 1; - source_to_proxy.remove(start, delta_item_count); - - int proxy_count = proxy_to_source.size(); - if (proxy_count > source_to_proxy.size()) { - // mapping is in an inconsistent state -- redo the whole mapping - qWarning("QSortFilterProxyModel: inconsistent changes reported by source model"); - remove_from_mapping(source_parent); - Q_Q(QSortFilterProxyModel); - q->reset(); - return; - } - - // Adjust "stale" indexes in proxy-to-source mapping - for (int proxy_item = 0; proxy_item < proxy_count; ++proxy_item) { - int source_item = proxy_to_source.at(proxy_item); - if (source_item >= start) { - Q_ASSERT(source_item - delta_item_count >= 0); - proxy_to_source.replace(proxy_item, source_item - delta_item_count); - } - } - build_source_to_proxy_mapping(proxy_to_source, source_to_proxy); - - updateChildrenMapping(source_parent, m, orient, start, end, delta_item_count, true); - -} - - -/*! - \internal - updates the mapping of the children when inserting or removing items -*/ -void QSortFilterProxyModelPrivate::updateChildrenMapping(const QModelIndex &source_parent, Mapping *parent_mapping, - Qt::Orientation orient, int start, int end, int delta_item_count, bool remove) -{ - // see if any mapped children should be (re)moved - QVector<QPair<QModelIndex, Mapping*> > moved_source_index_mappings; - QVector<QModelIndex>::iterator it2 = parent_mapping->mapped_children.begin(); - for ( ; it2 != parent_mapping->mapped_children.end();) { - const QModelIndex source_child_index = *it2; - const int pos = (orient == Qt::Vertical) - ? source_child_index.row() - : source_child_index.column(); - if (pos < start) { - // not affected - ++it2; - } else if (remove && pos <= end) { - // in the removed interval - it2 = parent_mapping->mapped_children.erase(it2); - remove_from_mapping(source_child_index); - } else { - // below the removed items -- recompute the index - QModelIndex new_index; - const int newpos = remove ? pos - delta_item_count : pos + delta_item_count; - if (orient == Qt::Vertical) { - new_index = model->index(newpos, - source_child_index.column(), - source_parent); - } else { - new_index = model->index(source_child_index.row(), - newpos, - source_parent); - } - *it2 = new_index; - ++it2; - - // update mapping - Mapping *cm = source_index_mapping.take(source_child_index); - Q_ASSERT(cm); - // we do not reinsert right away, because the new index might be identical with another, old index - moved_source_index_mappings.append(QPair<QModelIndex, Mapping*>(new_index, cm)); - } - } - - // reinsert moved, mapped indexes - QVector<QPair<QModelIndex, Mapping*> >::iterator it = moved_source_index_mappings.begin(); - for (; it != moved_source_index_mappings.end(); ++it) { -#ifdef QT_STRICT_ITERATORS - source_index_mapping.insert((*it).first, (*it).second); - (*it).second->map_iter = source_index_mapping.constFind((*it).first); -#else - (*it).second->map_iter = source_index_mapping.insert((*it).first, (*it).second); -#endif - } -} - -/*! - \internal -*/ -void QSortFilterProxyModelPrivate::proxy_item_range( - const QVector<int> &source_to_proxy, const QVector<int> &source_items, - int &proxy_low, int &proxy_high) const -{ - proxy_low = INT_MAX; - proxy_high = INT_MIN; - for (int i = 0; i < source_items.count(); ++i) { - int proxy_item = source_to_proxy.at(source_items.at(i)); - Q_ASSERT(proxy_item != -1); - if (proxy_item < proxy_low) - proxy_low = proxy_item; - if (proxy_item > proxy_high) - proxy_high = proxy_item; - } -} - -/*! - \internal -*/ -void QSortFilterProxyModelPrivate::build_source_to_proxy_mapping( - const QVector<int> &proxy_to_source, QVector<int> &source_to_proxy) const -{ - source_to_proxy.fill(-1); - int proxy_count = proxy_to_source.size(); - for (int i = 0; i < proxy_count; ++i) - source_to_proxy[proxy_to_source.at(i)] = i; -} - -/*! - \internal - - Maps the persistent proxy indexes to source indexes and - returns the list of source indexes. -*/ -QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes() -{ - Q_Q(QSortFilterProxyModel); - QModelIndexPairList source_indexes; - foreach (QPersistentModelIndexData *data, persistent.indexes) { - QModelIndex proxy_index = data->index; - QModelIndex source_index = q->mapToSource(proxy_index); - source_indexes.append(qMakePair(proxy_index, QPersistentModelIndex(source_index))); - } - return source_indexes; -} - -/*! - \internal - - Maps \a source_indexes to proxy indexes and stores those - as persistent indexes. -*/ -void QSortFilterProxyModelPrivate::update_persistent_indexes( - const QModelIndexPairList &source_indexes) -{ - Q_Q(QSortFilterProxyModel); - QModelIndexList from, to; - for (int i = 0; i < source_indexes.count(); ++i) { - QModelIndex source_index = source_indexes.at(i).second; - QModelIndex old_proxy_index = source_indexes.at(i).first; - create_mapping(source_index.parent()); - QModelIndex proxy_index = q->mapFromSource(source_index); - from << old_proxy_index; - to << proxy_index; - } - q->changePersistentIndexList(from, to); -} - - -/*! - \internal - - Updates the proxy model (adds/removes rows) based on the - new filter. -*/ -void QSortFilterProxyModelPrivate::filter_changed(const QModelIndex &source_parent) -{ - IndexMap::const_iterator it = source_index_mapping.constFind(source_parent); - if (it == source_index_mapping.constEnd()) - return; - Mapping *m = it.value(); - QSet<int> rows_removed = handle_filter_changed(m->proxy_rows, m->source_rows, source_parent, Qt::Vertical); - QSet<int> columns_removed = handle_filter_changed(m->proxy_columns, m->source_columns, source_parent, Qt::Horizontal); - QVector<QModelIndex>::iterator it2 = m->mapped_children.end(); - while (it2 != m->mapped_children.begin()) { - --it2; - const QModelIndex source_child_index = *it2; - if (rows_removed.contains(source_child_index.row()) || columns_removed.contains(source_child_index.column())) { - it2 = m->mapped_children.erase(it2); - remove_from_mapping(source_child_index); - } else { - filter_changed(source_child_index); - } - } -} - -/*! - \internal - returns the removed items indexes -*/ -QSet<int> QSortFilterProxyModelPrivate::handle_filter_changed( - QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, - const QModelIndex &source_parent, Qt::Orientation orient) -{ - Q_Q(QSortFilterProxyModel); - // Figure out which mapped items to remove - QVector<int> source_items_remove; - for (int i = 0; i < proxy_to_source.count(); ++i) { - const int source_item = proxy_to_source.at(i); - if ((orient == Qt::Vertical) - ? !q->filterAcceptsRow(source_item, source_parent) - : !q->filterAcceptsColumn(source_item, source_parent)) { - // This source item does not satisfy the filter, so it must be removed - source_items_remove.append(source_item); - } - } - // Figure out which non-mapped items to insert - QVector<int> source_items_insert; - int source_count = source_to_proxy.size(); - for (int source_item = 0; source_item < source_count; ++source_item) { - if (source_to_proxy.at(source_item) == -1) { - if ((orient == Qt::Vertical) - ? q->filterAcceptsRow(source_item, source_parent) - : q->filterAcceptsColumn(source_item, source_parent)) { - // This source item satisfies the filter, so it must be added - source_items_insert.append(source_item); - } - } - } - if (!source_items_remove.isEmpty() || !source_items_insert.isEmpty()) { - // Do item removal and insertion - remove_source_items(source_to_proxy, proxy_to_source, - source_items_remove, source_parent, orient); - if (orient == Qt::Vertical) - sort_source_rows(source_items_insert, source_parent); - insert_source_items(source_to_proxy, proxy_to_source, - source_items_insert, source_parent, orient); - } - return qVectorToSet(source_items_remove); -} - -void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &source_top_left, - const QModelIndex &source_bottom_right) -{ - Q_Q(QSortFilterProxyModel); - if (!source_top_left.isValid() || !source_bottom_right.isValid()) - return; - QModelIndex source_parent = source_top_left.parent(); - IndexMap::const_iterator it = source_index_mapping.find(source_parent); - if (it == source_index_mapping.constEnd()) { - // Don't care, since we don't have mapping for this index - return; - } - Mapping *m = it.value(); - - // Figure out how the source changes affect us - QVector<int> source_rows_remove; - QVector<int> source_rows_insert; - QVector<int> source_rows_change; - QVector<int> source_rows_resort; - int end = qMin(source_bottom_right.row(), m->proxy_rows.count() - 1); - for (int source_row = source_top_left.row(); source_row <= end; ++source_row) { - if (dynamic_sortfilter) { - if (m->proxy_rows.at(source_row) != -1) { - if (!q->filterAcceptsRow(source_row, source_parent)) { - // This source row no longer satisfies the filter, so it must be removed - source_rows_remove.append(source_row); - } else if (source_sort_column >= source_top_left.column() && source_sort_column <= source_bottom_right.column()) { - // This source row has changed in a way that may affect sorted order - source_rows_resort.append(source_row); - } else { - // This row has simply changed, without affecting filtering nor sorting - source_rows_change.append(source_row); - } - } else { - if (!itemsBeingRemoved.contains(source_parent, source_row) && q->filterAcceptsRow(source_row, source_parent)) { - // This source row now satisfies the filter, so it must be added - source_rows_insert.append(source_row); - } - } - } else { - if (m->proxy_rows.at(source_row) != -1) - source_rows_change.append(source_row); - } - } - - if (!source_rows_remove.isEmpty()) { - remove_source_items(m->proxy_rows, m->source_rows, - source_rows_remove, source_parent, Qt::Vertical); - QSet<int> source_rows_remove_set = qVectorToSet(source_rows_remove); - QVector<QModelIndex>::iterator it = m->mapped_children.end(); - while (it != m->mapped_children.begin()) { - --it; - const QModelIndex source_child_index = *it; - if (source_rows_remove_set.contains(source_child_index.row())) { - it = m->mapped_children.erase(it); - remove_from_mapping(source_child_index); - } - } - } - - if (!source_rows_resort.isEmpty()) { - // Re-sort the rows of this level - QList<QPersistentModelIndex> parents; - parents << q->mapFromSource(source_parent); - emit q->layoutAboutToBeChanged(parents); - QModelIndexPairList source_indexes = store_persistent_indexes(); - remove_source_items(m->proxy_rows, m->source_rows, source_rows_resort, - source_parent, Qt::Vertical, false); - sort_source_rows(source_rows_resort, source_parent); - insert_source_items(m->proxy_rows, m->source_rows, source_rows_resort, - source_parent, Qt::Vertical, false); - update_persistent_indexes(source_indexes); - emit q->layoutChanged(parents); - // Make sure we also emit dataChanged for the rows - source_rows_change += source_rows_resort; - } - - if (!source_rows_change.isEmpty()) { - // Find the proxy row range - int proxy_start_row; - int proxy_end_row; - proxy_item_range(m->proxy_rows, source_rows_change, - proxy_start_row, proxy_end_row); - // ### Find the proxy column range also - if (proxy_end_row >= 0) { - // the row was accepted, but some columns might still be filtered out - int source_left_column = source_top_left.column(); - while (source_left_column < source_bottom_right.column() - && m->proxy_columns.at(source_left_column) == -1) - ++source_left_column; - const QModelIndex proxy_top_left = create_index( - proxy_start_row, m->proxy_columns.at(source_left_column), it); - int source_right_column = source_bottom_right.column(); - while (source_right_column > source_top_left.column() - && m->proxy_columns.at(source_right_column) == -1) - --source_right_column; - const QModelIndex proxy_bottom_right = create_index( - proxy_end_row, m->proxy_columns.at(source_right_column), it); - emit q->dataChanged(proxy_top_left, proxy_bottom_right); - } - } - - if (!source_rows_insert.isEmpty()) { - sort_source_rows(source_rows_insert, source_parent); - insert_source_items(m->proxy_rows, m->source_rows, - source_rows_insert, source_parent, Qt::Vertical); - } -} - -void QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orientation, - int start, int end) -{ - Q_Q(QSortFilterProxyModel); - Mapping *m = create_mapping(QModelIndex()).value(); - int proxy_start = (orientation == Qt::Vertical - ? m->proxy_rows.at(start) - : m->proxy_columns.at(start)); - int proxy_end = (orientation == Qt::Vertical - ? m->proxy_rows.at(end) - : m->proxy_columns.at(end)); - emit q->headerDataChanged(orientation, proxy_start, proxy_end); -} - -void QSortFilterProxyModelPrivate::_q_sourceAboutToBeReset() -{ - Q_Q(QSortFilterProxyModel); - q->beginResetModel(); -} - -void QSortFilterProxyModelPrivate::_q_sourceReset() -{ - Q_Q(QSortFilterProxyModel); - invalidatePersistentIndexes(); - _q_clearMapping(); - // All internal structures are deleted in clear() - q->endResetModel(); - update_source_sort_column(); - if (dynamic_sortfilter) - sort(); -} - -void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents) -{ - Q_Q(QSortFilterProxyModel); - saved_persistent_indexes.clear(); - - QList<QPersistentModelIndex> parents; - foreach (const QPersistentModelIndex &parent, sourceParents) { - if (!parent.isValid()) { - parents << QModelIndex(); - continue; - } - const QModelIndex mappedParent = q->mapFromSource(parent); - // Might be filtered out. - if (mappedParent.isValid()) - parents << mappedParent; - } - - // All parents filtered out. - if (!sourceParents.isEmpty() && parents.isEmpty()) - return; - - emit q->layoutAboutToBeChanged(parents); - if (persistent.indexes.isEmpty()) - return; - - saved_persistent_indexes = store_persistent_indexes(); -} - -void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents) -{ - Q_Q(QSortFilterProxyModel); - - // Optimize: We only actually have to clear the mapping related to the contents of - // sourceParents, not everything. - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - - update_persistent_indexes(saved_persistent_indexes); - saved_persistent_indexes.clear(); - - if (dynamic_sortfilter && update_source_sort_column()) { - //update_source_sort_column might have created wrong mapping so we have to clear it again - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - } - - QList<QPersistentModelIndex> parents; - foreach (const QPersistentModelIndex &parent, sourceParents) { - if (!parent.isValid()) { - parents << QModelIndex(); - continue; - } - const QModelIndex mappedParent = q->mapFromSource(parent); - if (mappedParent.isValid()) - parents << mappedParent; - } - - if (!sourceParents.isEmpty() && parents.isEmpty()) - return; - - emit q->layoutChanged(parents); -} - -void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeInserted( - const QModelIndex &source_parent, int start, int end) -{ - Q_UNUSED(start); - Q_UNUSED(end); - //Force the creation of a mapping now, even if its empty. - //We need it because the proxy can be acessed at the moment it emits rowsAboutToBeInserted in insert_source_items - if (can_create_mapping(source_parent)) - create_mapping(source_parent); -} - -void QSortFilterProxyModelPrivate::_q_sourceRowsInserted( - const QModelIndex &source_parent, int start, int end) -{ - source_items_inserted(source_parent, start, end, Qt::Vertical); - if (update_source_sort_column() && dynamic_sortfilter) //previous call to update_source_sort_column may fail if the model has no column. - sort(); // now it should succeed so we need to make sure to sort again -} - -void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeRemoved( - const QModelIndex &source_parent, int start, int end) -{ - itemsBeingRemoved = QRowsRemoval(source_parent, start, end); - source_items_about_to_be_removed(source_parent, start, end, - Qt::Vertical); -} - -void QSortFilterProxyModelPrivate::_q_sourceRowsRemoved( - const QModelIndex &source_parent, int start, int end) -{ - itemsBeingRemoved = QRowsRemoval(); - source_items_removed(source_parent, start, end, Qt::Vertical); -} - -void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeMoved( - const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -{ - Q_Q(QSortFilterProxyModel); - // Because rows which are contiguous in the source model might not be contiguous - // in the proxy due to sorting, the best thing we can do here is be specific about what - // parents are having their children changed. - // Optimize: Emit move signals if the proxy is not sorted. Will need to account for rows - // being filtered out though. - - saved_persistent_indexes.clear(); - - QList<QPersistentModelIndex> parents; - parents << q->mapFromSource(sourceParent); - if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutAboutToBeChanged(parents); - if (persistent.indexes.isEmpty()) - return; - saved_persistent_indexes = store_persistent_indexes(); -} - -void QSortFilterProxyModelPrivate::_q_sourceRowsMoved( - const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -{ - Q_Q(QSortFilterProxyModel); - - // Optimize: We only need to clear and update the persistent indexes which are children of - // sourceParent or destParent - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - - update_persistent_indexes(saved_persistent_indexes); - saved_persistent_indexes.clear(); - - if (dynamic_sortfilter && update_source_sort_column()) { - //update_source_sort_column might have created wrong mapping so we have to clear it again - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - } - - QList<QPersistentModelIndex> parents; - parents << q->mapFromSource(sourceParent); - if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutChanged(parents); -} - -void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeInserted( - const QModelIndex &source_parent, int start, int end) -{ - Q_UNUSED(start); - Q_UNUSED(end); - //Force the creation of a mapping now, even if its empty. - //We need it because the proxy can be acessed at the moment it emits columnsAboutToBeInserted in insert_source_items - if (can_create_mapping(source_parent)) - create_mapping(source_parent); -} - -void QSortFilterProxyModelPrivate::_q_sourceColumnsInserted( - const QModelIndex &source_parent, int start, int end) -{ - Q_Q(const QSortFilterProxyModel); - source_items_inserted(source_parent, start, end, Qt::Horizontal); - - if (source_parent.isValid()) - return; //we sort according to the root column only - if (source_sort_column == -1) { - //we update the source_sort_column depending on the proxy_sort_column - if (update_source_sort_column() && dynamic_sortfilter) - sort(); - } else { - if (start <= source_sort_column) - source_sort_column += end - start + 1; - - proxy_sort_column = q->mapFromSource(model->index(0,source_sort_column, source_parent)).column(); - } -} - -void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeRemoved( - const QModelIndex &source_parent, int start, int end) -{ - source_items_about_to_be_removed(source_parent, start, end, - Qt::Horizontal); -} - -void QSortFilterProxyModelPrivate::_q_sourceColumnsRemoved( - const QModelIndex &source_parent, int start, int end) -{ - Q_Q(const QSortFilterProxyModel); - source_items_removed(source_parent, start, end, Qt::Horizontal); - - if (source_parent.isValid()) - return; //we sort according to the root column only - if (start <= source_sort_column) { - if (end < source_sort_column) - source_sort_column -= end - start + 1; - else - source_sort_column = -1; - } - - proxy_sort_column = q->mapFromSource(model->index(0,source_sort_column, source_parent)).column(); -} - -void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeMoved( - const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -{ - Q_Q(QSortFilterProxyModel); - - saved_persistent_indexes.clear(); - - QList<QPersistentModelIndex> parents; - parents << q->mapFromSource(sourceParent); - if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutAboutToBeChanged(parents); - - if (persistent.indexes.isEmpty()) - return; - saved_persistent_indexes = store_persistent_indexes(); -} - -void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved( - const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest) -{ - Q_Q(QSortFilterProxyModel); - - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - - update_persistent_indexes(saved_persistent_indexes); - saved_persistent_indexes.clear(); - - if (dynamic_sortfilter && update_source_sort_column()) { - qDeleteAll(source_index_mapping); - source_index_mapping.clear(); - } - - QList<QPersistentModelIndex> parents; - parents << q->mapFromSource(sourceParent); - if (sourceParent != destParent) - parents << q->mapFromSource(destParent); - emit q->layoutChanged(parents); -} - -/*! - \since 4.1 - \class QSortFilterProxyModel - \brief The QSortFilterProxyModel class provides support for sorting and - filtering data passed between another model and a view. - - \ingroup model-view - \inmodule QtWidgets - - QSortFilterProxyModel can be used for sorting items, filtering out items, - or both. The model transforms the structure of a source model by mapping - the model indexes it supplies to new indexes, corresponding to different - locations, for views to use. This approach allows a given source model to - be restructured as far as views are concerned without requiring any - transformations on the underlying data, and without duplicating the data in - memory. - - Let's assume that we want to sort and filter the items provided by a custom - model. The code to set up the model and the view, \e without sorting and - filtering, would look like this: - - \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 1 - - To add sorting and filtering support to \c MyItemModel, we need to create - a QSortFilterProxyModel, call setSourceModel() with the \c MyItemModel as - argument, and install the QSortFilterProxyModel on the view: - - \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 0 - \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 2 - - At this point, neither sorting nor filtering is enabled; the original data - is displayed in the view. Any changes made through the - QSortFilterProxyModel are applied to the original model. - - The QSortFilterProxyModel acts as a wrapper for the original model. If you - need to convert source \l{QModelIndex}es to sorted/filtered model indexes - or vice versa, use mapToSource(), mapFromSource(), mapSelectionToSource(), - and mapSelectionFromSource(). - - \note By default, the model does not dynamically re-sort and re-filter data - whenever the original model changes. This behavior can be changed by - setting the \l{QSortFilterProxyModel::dynamicSortFilter}{dynamicSortFilter} - property. - - The \l{itemviews/basicsortfiltermodel}{Basic Sort/Filter Model} and - \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} examples - illustrate how to use QSortFilterProxyModel to perform basic sorting and - filtering and how to subclass it to implement custom behavior. - - \section1 Sorting - - QTableView and QTreeView have a - \l{QTreeView::sortingEnabled}{sortingEnabled} property that controls - whether the user can sort the view by clicking the view's horizontal - header. For example: - - \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 3 - - When this feature is on (the default is off), clicking on a header section - sorts the items according to that column. By clicking repeatedly, the user - can alternate between ascending and descending order. - - \image qsortfilterproxymodel-sorting.png A sorted QTreeView - - Behind the scene, the view calls the sort() virtual function on the model - to reorder the data in the model. To make your data sortable, you can - either implement sort() in your model, or use a QSortFilterProxyModel to - wrap your model -- QSortFilterProxyModel provides a generic sort() - reimplementation that operates on the sortRole() (Qt::DisplayRole by - default) of the items and that understands several data types, including - \c int, QString, and QDateTime. For hierarchical models, sorting is applied - recursively to all child items. String comparisons are case sensitive by - default; this can be changed by setting the \l{QSortFilterProxyModel::} - {sortCaseSensitivity} property. - - Custom sorting behavior is achieved by subclassing - QSortFilterProxyModel and reimplementing lessThan(), which is - used to compare items. For example: - - \snippet examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 5 - - (This code snippet comes from the - \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} - example.) - - An alternative approach to sorting is to disable sorting on the view and to - impose a certain order to the user. This is done by explicitly calling - sort() with the desired column and order as arguments on the - QSortFilterProxyModel (or on the original model if it implements sort()). - For example: - - \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 4 - - QSortFilterProxyModel can be sorted by column -1, in which case it returns - to the sort order of the underlying source model. - - \section1 Filtering - - In addition to sorting, QSortFilterProxyModel can be used to hide items - that do not match a certain filter. The filter is specified using a QRegExp - object and is applied to the filterRole() (Qt::DisplayRole by default) of - each item, for a given column. The QRegExp object can be used to match a - regular expression, a wildcard pattern, or a fixed string. For example: - - \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 5 - - For hierarchical models, the filter is applied recursively to all children. - If a parent item doesn't match the filter, none of its children will be - shown. - - A common use case is to let the user specify the filter regexp, wildcard - pattern, or fixed string in a QLineEdit and to connect the - \l{QLineEdit::textChanged()}{textChanged()} signal to setFilterRegExp(), - setFilterWildcard(), or setFilterFixedString() to reapply the filter. - - Custom filtering behavior can be achieved by reimplementing the - filterAcceptsRow() and filterAcceptsColumn() functions. For - example (from the \l{itemviews/customsortfiltermodel} - {Custom Sort/Filter Model} example), the following implementation ignores - the \l{QSortFilterProxyModel::filterKeyColumn}{filterKeyColumn} property - and performs filtering on columns 0, 1, and 2: - - \snippet examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 3 - - (This code snippet comes from the - \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} - example.) - - If you are working with large amounts of filtering and have to invoke - invalidateFilter() repeatedly, using reset() may be more efficient, - depending on the implementation of your model. However, reset() returns the - proxy model to its original state, losing selection information, and will - cause the proxy model to be repopulated. - - \section1 Subclassing - - Since QAbstractProxyModel and its subclasses are derived from - QAbstractItemModel, much of the same advice about subclassing normal models - also applies to proxy models. In addition, it is worth noting that many of - the default implementations of functions in this class are written so that - they call the equivalent functions in the relevant source model. This - simple proxying mechanism may need to be overridden for source models with - more complex behavior; for example, if the source model provides a custom - hasChildren() implementation, you should also provide one in the proxy - model. - - \note Some general guidelines for subclassing models are available in the - \l{Model Subclassing Reference}. - - \sa QAbstractProxyModel, QAbstractItemModel, {Model/View Programming}, - {Basic Sort/Filter Model Example}, {Custom Sort/Filter Model Example}, QIdentityProxyModel -*/ - -/*! - Constructs a sorting filter model with the given \a parent. -*/ - -QSortFilterProxyModel::QSortFilterProxyModel(QObject *parent) - : QAbstractProxyModel(*new QSortFilterProxyModelPrivate, parent) -{ - Q_D(QSortFilterProxyModel); - d->proxy_sort_column = d->source_sort_column = -1; - d->sort_order = Qt::AscendingOrder; - d->sort_casesensitivity = Qt::CaseSensitive; - d->sort_role = Qt::DisplayRole; - d->sort_localeaware = false; - d->filter_column = 0; - d->filter_role = Qt::DisplayRole; - d->dynamic_sortfilter = false; - connect(this, SIGNAL(modelReset()), this, SLOT(_q_clearMapping())); -} - -/*! - Destroys this sorting filter model. -*/ -QSortFilterProxyModel::~QSortFilterProxyModel() -{ - Q_D(QSortFilterProxyModel); - qDeleteAll(d->source_index_mapping); - d->source_index_mapping.clear(); -} - -/*! - \reimp -*/ -void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) -{ - Q_D(QSortFilterProxyModel); - - beginResetModel(); - - disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); - - disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), - this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int))); - - disconnect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int))); - - disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsInserted(QModelIndex,int,int))); - - disconnect(d->model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))); - - disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int))); - - disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))); - - disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int))); - - disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))); - - disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int))); - - disconnect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - - disconnect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))); - - disconnect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - - disconnect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))); - - disconnect(d->model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)), - this, SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>))); - - disconnect(d->model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)), - this, SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>))); - - disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset())); - disconnect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); - - QAbstractProxyModel::setSourceModel(sourceModel); - - connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); - - connect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), - this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int))); - - connect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int))); - - connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsInserted(QModelIndex,int,int))); - - connect(d->model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))); - - connect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int))); - - connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))); - - connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int))); - - connect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))); - - connect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int))); - - connect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - - connect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))); - - connect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - - connect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))); - - connect(d->model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)), - this, SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>))); - - connect(d->model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)), - this, SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>))); - - connect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset())); - connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); - - d->_q_clearMapping(); - endResetModel(); - if (d->update_source_sort_column() && d->dynamic_sortfilter) - d->sort(); -} - -/*! - \reimp -*/ -QModelIndex QSortFilterProxyModel::index(int row, int column, const QModelIndex &parent) const -{ - Q_D(const QSortFilterProxyModel); - if (row < 0 || column < 0) - return QModelIndex(); - - QModelIndex source_parent = mapToSource(parent); // parent is already mapped at this point - IndexMap::const_iterator it = d->create_mapping(source_parent); // but make sure that the children are mapped - if (it.value()->source_rows.count() <= row || it.value()->source_columns.count() <= column) - return QModelIndex(); - - return d->create_index(row, column, it); -} - -/*! - \reimp -*/ -QModelIndex QSortFilterProxyModel::parent(const QModelIndex &child) const -{ - Q_D(const QSortFilterProxyModel); - if (!d->indexValid(child)) - return QModelIndex(); - IndexMap::const_iterator it = d->index_to_iterator(child); - Q_ASSERT(it != d->source_index_mapping.constEnd()); - QModelIndex source_parent = it.key(); - QModelIndex proxy_parent = mapFromSource(source_parent); - return proxy_parent; -} - -/*! - \reimp -*/ -int QSortFilterProxyModel::rowCount(const QModelIndex &parent) const -{ - Q_D(const QSortFilterProxyModel); - QModelIndex source_parent = mapToSource(parent); - if (parent.isValid() && !source_parent.isValid()) - return 0; - IndexMap::const_iterator it = d->create_mapping(source_parent); - return it.value()->source_rows.count(); -} - -/*! - \reimp -*/ -int QSortFilterProxyModel::columnCount(const QModelIndex &parent) const -{ - Q_D(const QSortFilterProxyModel); - QModelIndex source_parent = mapToSource(parent); - if (parent.isValid() && !source_parent.isValid()) - return 0; - IndexMap::const_iterator it = d->create_mapping(source_parent); - return it.value()->source_columns.count(); -} - -/*! - \reimp -*/ -bool QSortFilterProxyModel::hasChildren(const QModelIndex &parent) const -{ - Q_D(const QSortFilterProxyModel); - QModelIndex source_parent = mapToSource(parent); - if (parent.isValid() && !source_parent.isValid()) - return false; - if (!d->model->hasChildren(source_parent)) - return false; - - if (d->model->canFetchMore(source_parent)) - return true; //we assume we might have children that can be fetched - - QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - return m->source_rows.count() != 0 && m->source_columns.count() != 0; -} - -/*! - \reimp -*/ -QVariant QSortFilterProxyModel::data(const QModelIndex &index, int role) const -{ - Q_D(const QSortFilterProxyModel); - QModelIndex source_index = mapToSource(index); - if (index.isValid() && !source_index.isValid()) - return QVariant(); - return d->model->data(source_index, role); -} - -/*! - \reimp -*/ -bool QSortFilterProxyModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - Q_D(QSortFilterProxyModel); - QModelIndex source_index = mapToSource(index); - if (index.isValid() && !source_index.isValid()) - return false; - return d->model->setData(source_index, value, role); -} - -/*! - \reimp -*/ -QVariant QSortFilterProxyModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - Q_D(const QSortFilterProxyModel); - IndexMap::const_iterator it = d->create_mapping(QModelIndex()); - if (it.value()->source_rows.count() * it.value()->source_columns.count() > 0) - return QAbstractProxyModel::headerData(section, orientation, role); - int source_section; - if (orientation == Qt::Vertical) { - if (section < 0 || section >= it.value()->source_rows.count()) - return QVariant(); - source_section = it.value()->source_rows.at(section); - } else { - if (section < 0 || section >= it.value()->source_columns.count()) - return QVariant(); - source_section = it.value()->source_columns.at(section); - } - return d->model->headerData(source_section, orientation, role); -} - -/*! - \reimp -*/ -bool QSortFilterProxyModel::setHeaderData(int section, Qt::Orientation orientation, - const QVariant &value, int role) -{ - Q_D(QSortFilterProxyModel); - IndexMap::const_iterator it = d->create_mapping(QModelIndex()); - if (it.value()->source_rows.count() * it.value()->source_columns.count() > 0) - return QAbstractProxyModel::setHeaderData(section, orientation, value, role); - int source_section; - if (orientation == Qt::Vertical) { - if (section < 0 || section >= it.value()->source_rows.count()) - return false; - source_section = it.value()->source_rows.at(section); - } else { - if (section < 0 || section >= it.value()->source_columns.count()) - return false; - source_section = it.value()->source_columns.at(section); - } - return d->model->setHeaderData(source_section, orientation, value, role); -} - -/*! - \reimp -*/ -QMimeData *QSortFilterProxyModel::mimeData(const QModelIndexList &indexes) const -{ - Q_D(const QSortFilterProxyModel); - QModelIndexList source_indexes; - for (int i = 0; i < indexes.count(); ++i) - source_indexes << mapToSource(indexes.at(i)); - return d->model->mimeData(source_indexes); -} - -/*! - \reimp -*/ -QStringList QSortFilterProxyModel::mimeTypes() const -{ - Q_D(const QSortFilterProxyModel); - return d->model->mimeTypes(); -} - -/*! - \reimp -*/ -Qt::DropActions QSortFilterProxyModel::supportedDropActions() const -{ - Q_D(const QSortFilterProxyModel); - return d->model->supportedDropActions(); -} - -/*! - \reimp -*/ -bool QSortFilterProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) -{ - Q_D(QSortFilterProxyModel); - if ((row == -1) && (column == -1)) - return d->model->dropMimeData(data, action, -1, -1, mapToSource(parent)); - int source_destination_row = -1; - int source_destination_column = -1; - QModelIndex source_parent; - if (row == rowCount(parent)) { - source_parent = mapToSource(parent); - source_destination_row = d->model->rowCount(source_parent); - } else { - QModelIndex proxy_index = index(row, column, parent); - QModelIndex source_index = mapToSource(proxy_index); - source_destination_row = source_index.row(); - source_destination_column = source_index.column(); - source_parent = source_index.parent(); - } - return d->model->dropMimeData(data, action, source_destination_row, - source_destination_column, source_parent); -} - -/*! - \reimp -*/ -bool QSortFilterProxyModel::insertRows(int row, int count, const QModelIndex &parent) -{ - Q_D(QSortFilterProxyModel); - if (row < 0 || count <= 0) - return false; - QModelIndex source_parent = mapToSource(parent); - if (parent.isValid() && !source_parent.isValid()) - return false; - QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - if (row > m->source_rows.count()) - return false; - int source_row = (row >= m->source_rows.count() - ? m->source_rows.count() - : m->source_rows.at(row)); - return d->model->insertRows(source_row, count, source_parent); -} - -/*! - \reimp -*/ -bool QSortFilterProxyModel::insertColumns(int column, int count, const QModelIndex &parent) -{ - Q_D(QSortFilterProxyModel); - if (column < 0|| count <= 0) - return false; - QModelIndex source_parent = mapToSource(parent); - if (parent.isValid() && !source_parent.isValid()) - return false; - QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - if (column > m->source_columns.count()) - return false; - int source_column = (column >= m->source_columns.count() - ? m->source_columns.count() - : m->source_columns.at(column)); - return d->model->insertColumns(source_column, count, source_parent); -} - -/*! - \reimp -*/ -bool QSortFilterProxyModel::removeRows(int row, int count, const QModelIndex &parent) -{ - Q_D(QSortFilterProxyModel); - if (row < 0 || count <= 0) - return false; - QModelIndex source_parent = mapToSource(parent); - if (parent.isValid() && !source_parent.isValid()) - return false; - QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - if (row + count > m->source_rows.count()) - return false; - if ((count == 1) - || ((d->source_sort_column < 0) && (m->proxy_rows.count() == m->source_rows.count()))) { - int source_row = m->source_rows.at(row); - return d->model->removeRows(source_row, count, source_parent); - } - // remove corresponding source intervals - // ### if this proves to be slow, we can switch to single-row removal - QVector<int> rows; - for (int i = row; i < row + count; ++i) - rows.append(m->source_rows.at(i)); - qSort(rows.begin(), rows.end()); - - int pos = rows.count() - 1; - bool ok = true; - while (pos >= 0) { - const int source_end = rows.at(pos--); - int source_start = source_end; - while ((pos >= 0) && (rows.at(pos) == (source_start - 1))) { - --source_start; - --pos; - } - ok = ok && d->model->removeRows(source_start, source_end - source_start + 1, - source_parent); - } - return ok; -} - -/*! - \reimp -*/ -bool QSortFilterProxyModel::removeColumns(int column, int count, const QModelIndex &parent) -{ - Q_D(QSortFilterProxyModel); - if (column < 0 || count <= 0) - return false; - QModelIndex source_parent = mapToSource(parent); - if (parent.isValid() && !source_parent.isValid()) - return false; - QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); - if (column + count > m->source_columns.count()) - return false; - if ((count == 1) || (m->proxy_columns.count() == m->source_columns.count())) { - int source_column = m->source_columns.at(column); - return d->model->removeColumns(source_column, count, source_parent); - } - // remove corresponding source intervals - QVector<int> columns; - for (int i = column; i < column + count; ++i) - columns.append(m->source_columns.at(i)); - - int pos = columns.count() - 1; - bool ok = true; - while (pos >= 0) { - const int source_end = columns.at(pos--); - int source_start = source_end; - while ((pos >= 0) && (columns.at(pos) == (source_start - 1))) { - --source_start; - --pos; - } - ok = ok && d->model->removeColumns(source_start, source_end - source_start + 1, - source_parent); - } - return ok; -} - -/*! - \reimp -*/ -void QSortFilterProxyModel::fetchMore(const QModelIndex &parent) -{ - Q_D(QSortFilterProxyModel); - QModelIndex source_parent; - if (d->indexValid(parent)) - source_parent = mapToSource(parent); - d->model->fetchMore(source_parent); -} - -/*! - \reimp -*/ -bool QSortFilterProxyModel::canFetchMore(const QModelIndex &parent) const -{ - Q_D(const QSortFilterProxyModel); - QModelIndex source_parent; - if (d->indexValid(parent)) - source_parent = mapToSource(parent); - return d->model->canFetchMore(source_parent); -} - -/*! - \reimp -*/ -Qt::ItemFlags QSortFilterProxyModel::flags(const QModelIndex &index) const -{ - Q_D(const QSortFilterProxyModel); - QModelIndex source_index; - if (d->indexValid(index)) - source_index = mapToSource(index); - return d->model->flags(source_index); -} - -/*! - \reimp -*/ -QModelIndex QSortFilterProxyModel::buddy(const QModelIndex &index) const -{ - Q_D(const QSortFilterProxyModel); - if (!d->indexValid(index)) - return QModelIndex(); - QModelIndex source_index = mapToSource(index); - QModelIndex source_buddy = d->model->buddy(source_index); - if (source_index == source_buddy) - return index; - return mapFromSource(source_buddy); -} - -/*! - \reimp -*/ -QModelIndexList QSortFilterProxyModel::match(const QModelIndex &start, int role, - const QVariant &value, int hits, - Qt::MatchFlags flags) const -{ - return QAbstractProxyModel::match(start, role, value, hits, flags); -} - -/*! - \reimp -*/ -QSize QSortFilterProxyModel::span(const QModelIndex &index) const -{ - Q_D(const QSortFilterProxyModel); - QModelIndex source_index = mapToSource(index); - if (index.isValid() && !source_index.isValid()) - return QSize(); - return d->model->span(source_index); -} - -/*! - \reimp -*/ -void QSortFilterProxyModel::sort(int column, Qt::SortOrder order) -{ - Q_D(QSortFilterProxyModel); - if (d->dynamic_sortfilter && d->proxy_sort_column == column && d->sort_order == order) - return; - d->sort_order = order; - d->proxy_sort_column = column; - d->update_source_sort_column(); - d->sort(); -} - -/*! - \since 4.5 - \brief the column currently used for sorting - - This returns the most recently used sort column. -*/ -int QSortFilterProxyModel::sortColumn() const -{ - Q_D(const QSortFilterProxyModel); - return d->proxy_sort_column; -} - -/*! - \since 4.5 - \brief the order currently used for sorting - - This returns the most recently used sort order. -*/ -Qt::SortOrder QSortFilterProxyModel::sortOrder() const -{ - Q_D(const QSortFilterProxyModel); - return d->sort_order; -} - -/*! - \property QSortFilterProxyModel::filterRegExp - \brief the QRegExp used to filter the contents of the source model - - Setting this property overwrites the current - \l{QSortFilterProxyModel::filterCaseSensitivity}{filterCaseSensitivity}. - By default, the QRegExp is an empty string matching all contents. - - If no QRegExp or an empty string is set, everything in the source model - will be accepted. - - \sa filterCaseSensitivity, setFilterWildcard(), setFilterFixedString() -*/ -QRegExp QSortFilterProxyModel::filterRegExp() const -{ - Q_D(const QSortFilterProxyModel); - return d->filter_regexp; -} - -void QSortFilterProxyModel::setFilterRegExp(const QRegExp ®Exp) -{ - Q_D(QSortFilterProxyModel); - d->filter_regexp = regExp; - d->filter_changed(); -} - -/*! - \property QSortFilterProxyModel::filterKeyColumn - \brief the column where the key used to filter the contents of the - source model is read from. - - The default value is 0. If the value is -1, the keys will be read - from all columns. -*/ -int QSortFilterProxyModel::filterKeyColumn() const -{ - Q_D(const QSortFilterProxyModel); - return d->filter_column; -} - -void QSortFilterProxyModel::setFilterKeyColumn(int column) -{ - Q_D(QSortFilterProxyModel); - d->filter_column = column; - d->filter_changed(); -} - -/*! - \property QSortFilterProxyModel::filterCaseSensitivity - - \brief the case sensitivity of the QRegExp pattern used to filter the - contents of the source model - - By default, the filter is case sensitive. - - \sa filterRegExp, sortCaseSensitivity -*/ -Qt::CaseSensitivity QSortFilterProxyModel::filterCaseSensitivity() const -{ - Q_D(const QSortFilterProxyModel); - return d->filter_regexp.caseSensitivity(); -} - -void QSortFilterProxyModel::setFilterCaseSensitivity(Qt::CaseSensitivity cs) -{ - Q_D(QSortFilterProxyModel); - if (cs == d->filter_regexp.caseSensitivity()) - return; - d->filter_regexp.setCaseSensitivity(cs); - d->filter_changed(); -} - -/*! - \since 4.2 - \property QSortFilterProxyModel::sortCaseSensitivity - \brief the case sensitivity setting used for comparing strings when sorting - - By default, sorting is case sensitive. - - \sa filterCaseSensitivity, lessThan() -*/ -Qt::CaseSensitivity QSortFilterProxyModel::sortCaseSensitivity() const -{ - Q_D(const QSortFilterProxyModel); - return d->sort_casesensitivity; -} - -void QSortFilterProxyModel::setSortCaseSensitivity(Qt::CaseSensitivity cs) -{ - Q_D(QSortFilterProxyModel); - if (d->sort_casesensitivity == cs) - return; - - d->sort_casesensitivity = cs; - d->sort(); -} - -/*! - \since 4.3 - \property QSortFilterProxyModel::isSortLocaleAware - \brief the local aware setting used for comparing strings when sorting - - By default, sorting is not local aware. - - \sa sortCaseSensitivity, lessThan() -*/ -bool QSortFilterProxyModel::isSortLocaleAware() const -{ - Q_D(const QSortFilterProxyModel); - return d->sort_localeaware; -} - -void QSortFilterProxyModel::setSortLocaleAware(bool on) -{ - Q_D(QSortFilterProxyModel); - if (d->sort_localeaware == on) - return; - - d->sort_localeaware = on; - d->sort(); -} - -/*! - \overload - - Sets the regular expression used to filter the contents - of the source model to \a pattern. - - \sa setFilterCaseSensitivity(), setFilterWildcard(), setFilterFixedString(), filterRegExp() -*/ -void QSortFilterProxyModel::setFilterRegExp(const QString &pattern) -{ - Q_D(QSortFilterProxyModel); - d->filter_regexp.setPatternSyntax(QRegExp::RegExp); - d->filter_regexp.setPattern(pattern); - d->filter_changed(); -} - -/*! - Sets the wildcard expression used to filter the contents - of the source model to the given \a pattern. - - \sa setFilterCaseSensitivity(), setFilterRegExp(), setFilterFixedString(), filterRegExp() -*/ -void QSortFilterProxyModel::setFilterWildcard(const QString &pattern) -{ - Q_D(QSortFilterProxyModel); - d->filter_regexp.setPatternSyntax(QRegExp::Wildcard); - d->filter_regexp.setPattern(pattern); - d->filter_changed(); -} - -/*! - Sets the fixed string used to filter the contents - of the source model to the given \a pattern. - - \sa setFilterCaseSensitivity(), setFilterRegExp(), setFilterWildcard(), filterRegExp() -*/ -void QSortFilterProxyModel::setFilterFixedString(const QString &pattern) -{ - Q_D(QSortFilterProxyModel); - d->filter_regexp.setPatternSyntax(QRegExp::FixedString); - d->filter_regexp.setPattern(pattern); - d->filter_changed(); -} - -/*! - \since 4.2 - \property QSortFilterProxyModel::dynamicSortFilter - \brief whether the proxy model is dynamically sorted and filtered - whenever the contents of the source model change - - Note that you should not update the source model through the proxy - model when dynamicSortFilter is true. For instance, if you set the - proxy model on a QComboBox, then using functions that update the - model, e.g., \l{QComboBox::}{addItem()}, will not work as - expected. An alternative is to set dynamicSortFilter to false and - call \l{QSortFilterProxyModel::}{sort()} after adding items to the - QComboBox. - - The default value is false. -*/ -bool QSortFilterProxyModel::dynamicSortFilter() const -{ - Q_D(const QSortFilterProxyModel); - return d->dynamic_sortfilter; -} - -void QSortFilterProxyModel::setDynamicSortFilter(bool enable) -{ - Q_D(QSortFilterProxyModel); - d->dynamic_sortfilter = enable; - if (enable) - d->sort(); -} - -/*! - \since 4.2 - \property QSortFilterProxyModel::sortRole - \brief the item role that is used to query the source model's data when sorting items - - The default value is Qt::DisplayRole. - - \sa lessThan() -*/ -int QSortFilterProxyModel::sortRole() const -{ - Q_D(const QSortFilterProxyModel); - return d->sort_role; -} - -void QSortFilterProxyModel::setSortRole(int role) -{ - Q_D(QSortFilterProxyModel); - if (d->sort_role == role) - return; - d->sort_role = role; - d->sort(); -} - -/*! - \since 4.2 - \property QSortFilterProxyModel::filterRole - \brief the item role that is used to query the source model's data when filtering items - - The default value is Qt::DisplayRole. - - \sa filterAcceptsRow() -*/ -int QSortFilterProxyModel::filterRole() const -{ - Q_D(const QSortFilterProxyModel); - return d->filter_role; -} - -void QSortFilterProxyModel::setFilterRole(int role) -{ - Q_D(QSortFilterProxyModel); - if (d->filter_role == role) - return; - d->filter_role = role; - d->filter_changed(); -} - -/*! - \obsolete - - This function is obsolete. Use invalidate() instead. -*/ -void QSortFilterProxyModel::clear() -{ - Q_D(QSortFilterProxyModel); - emit layoutAboutToBeChanged(); - d->_q_clearMapping(); - emit layoutChanged(); -} - -/*! - \since 4.3 - - Invalidates the current sorting and filtering. - - \sa invalidateFilter() -*/ -void QSortFilterProxyModel::invalidate() -{ - Q_D(QSortFilterProxyModel); - emit layoutAboutToBeChanged(); - d->_q_clearMapping(); - emit layoutChanged(); -} - -/*! - \obsolete - - This function is obsolete. Use invalidateFilter() instead. -*/ -void QSortFilterProxyModel::filterChanged() -{ - Q_D(QSortFilterProxyModel); - d->filter_changed(); -} - -/*! - \since 4.3 - - Invalidates the current filtering. - - This function should be called if you are implementing custom filtering - (e.g. filterAcceptsRow()), and your filter parameters have changed. - - \sa invalidate() -*/ -void QSortFilterProxyModel::invalidateFilter() -{ - Q_D(QSortFilterProxyModel); - d->filter_changed(); -} - -/*! - Returns true if the value of the item referred to by the given - index \a left is less than the value of the item referred to by - the given index \a right, otherwise returns false. - - This function is used as the < operator when sorting, and handles - the following QVariant types: - - \list - \o QVariant::Int - \o QVariant::UInt - \o QVariant::LongLong - \o QVariant::ULongLong - \o QVariant::Double - \o QVariant::Char - \o QVariant::Date - \o QVariant::Time - \o QVariant::DateTime - \o QVariant::String - \endlist - - Any other type will be converted to a QString using - QVariant::toString(). - - Comparison of \l{QString}s is case sensitive by default; this can - be changed using the \l {QSortFilterProxyModel::sortCaseSensitivity} - {sortCaseSensitivity} property. - - By default, the Qt::DisplayRole associated with the - \l{QModelIndex}es is used for comparisons. This can be changed by - setting the \l {QSortFilterProxyModel::sortRole} {sortRole} property. - - \note The indices passed in correspond to the source model. - - \sa sortRole, sortCaseSensitivity, dynamicSortFilter -*/ -bool QSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const -{ - Q_D(const QSortFilterProxyModel); - QVariant l = (left.model() ? left.model()->data(left, d->sort_role) : QVariant()); - QVariant r = (right.model() ? right.model()->data(right, d->sort_role) : QVariant()); - switch (l.userType()) { - case QVariant::Invalid: - return (r.type() != QVariant::Invalid); - case QVariant::Int: - return l.toInt() < r.toInt(); - case QVariant::UInt: - return l.toUInt() < r.toUInt(); - case QVariant::LongLong: - return l.toLongLong() < r.toLongLong(); - case QVariant::ULongLong: - return l.toULongLong() < r.toULongLong(); - case QMetaType::Float: - return l.toFloat() < r.toFloat(); - case QVariant::Double: - return l.toDouble() < r.toDouble(); - case QVariant::Char: - return l.toChar() < r.toChar(); - case QVariant::Date: - return l.toDate() < r.toDate(); - case QVariant::Time: - return l.toTime() < r.toTime(); - case QVariant::DateTime: - return l.toDateTime() < r.toDateTime(); - case QVariant::String: - default: - if (d->sort_localeaware) - return l.toString().localeAwareCompare(r.toString()) < 0; - else - return l.toString().compare(r.toString(), d->sort_casesensitivity) < 0; - } - return false; -} - -/*! - Returns true if the item in the row indicated by the given \a source_row - and \a source_parent should be included in the model; otherwise returns - false. - - The default implementation returns true if the value held by the relevant item - matches the filter string, wildcard string or regular expression. - - \note By default, the Qt::DisplayRole is used to determine if the row - should be accepted or not. This can be changed by setting the - \l{QSortFilterProxyModel::filterRole}{filterRole} property. - - \sa filterAcceptsColumn(), setFilterFixedString(), setFilterRegExp(), setFilterWildcard() -*/ -bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const -{ - Q_D(const QSortFilterProxyModel); - if (d->filter_regexp.isEmpty()) - return true; - if (d->filter_column == -1) { - int column_count = d->model->columnCount(source_parent); - for (int column = 0; column < column_count; ++column) { - QModelIndex source_index = d->model->index(source_row, column, source_parent); - QString key = d->model->data(source_index, d->filter_role).toString(); - if (key.contains(d->filter_regexp)) - return true; - } - return false; - } - QModelIndex source_index = d->model->index(source_row, d->filter_column, source_parent); - if (!source_index.isValid()) // the column may not exist - return true; - QString key = d->model->data(source_index, d->filter_role).toString(); - return key.contains(d->filter_regexp); -} - -/*! - Returns true if the item in the column indicated by the given \a source_column - and \a source_parent should be included in the model; otherwise returns false. - - The default implementation returns true if the value held by the relevant item - matches the filter string, wildcard string or regular expression. - - \note By default, the Qt::DisplayRole is used to determine if the row - should be accepted or not. This can be changed by setting the \l - filterRole property. - - \sa filterAcceptsRow(), setFilterFixedString(), setFilterRegExp(), setFilterWildcard() -*/ -bool QSortFilterProxyModel::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const -{ - Q_UNUSED(source_column); - Q_UNUSED(source_parent); - return true; -} - -/*! - Returns the source model index corresponding to the given \a - proxyIndex from the sorting filter model. - - \sa mapFromSource() -*/ -QModelIndex QSortFilterProxyModel::mapToSource(const QModelIndex &proxyIndex) const -{ - Q_D(const QSortFilterProxyModel); - return d->proxy_to_source(proxyIndex); -} - -/*! - Returns the model index in the QSortFilterProxyModel given the \a - sourceIndex from the source model. - - \sa mapToSource() -*/ -QModelIndex QSortFilterProxyModel::mapFromSource(const QModelIndex &sourceIndex) const -{ - Q_D(const QSortFilterProxyModel); - return d->source_to_proxy(sourceIndex); -} - -/*! - \reimp -*/ -QItemSelection QSortFilterProxyModel::mapSelectionToSource(const QItemSelection &proxySelection) const -{ - return QAbstractProxyModel::mapSelectionToSource(proxySelection); -} - -/*! - \reimp -*/ -QItemSelection QSortFilterProxyModel::mapSelectionFromSource(const QItemSelection &sourceSelection) const -{ - return QAbstractProxyModel::mapSelectionFromSource(sourceSelection); -} - -/*! - \fn QObject *QSortFilterProxyModel::parent() const - \internal -*/ - -QT_END_NAMESPACE - -#include "moc_qsortfilterproxymodel.cpp" - -#endif // QT_NO_SORTFILTERPROXYMODEL diff --git a/src/widgets/itemviews/qsortfilterproxymodel.h b/src/widgets/itemviews/qsortfilterproxymodel.h deleted file mode 100644 index bbeec1470c..0000000000 --- a/src/widgets/itemviews/qsortfilterproxymodel.h +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSORTFILTERPROXYMODEL_H -#define QSORTFILTERPROXYMODEL_H - -#include <QtWidgets/qabstractproxymodel.h> - -#ifndef QT_NO_SORTFILTERPROXYMODEL - -#include <QtCore/qregexp.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QSortFilterProxyModelPrivate; -class QSortFilterProxyModelLessThan; -class QSortFilterProxyModelGreaterThan; - -class Q_WIDGETS_EXPORT QSortFilterProxyModel : public QAbstractProxyModel -{ - friend class QSortFilterProxyModelLessThan; - friend class QSortFilterProxyModelGreaterThan; - - Q_OBJECT - Q_PROPERTY(QRegExp filterRegExp READ filterRegExp WRITE setFilterRegExp) - Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn) - Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter) - Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity) - Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity) - Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware) - Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole) - Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole) - -public: - QSortFilterProxyModel(QObject *parent = 0); - ~QSortFilterProxyModel(); - - void setSourceModel(QAbstractItemModel *sourceModel); - - QModelIndex mapToSource(const QModelIndex &proxyIndex) const; - QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; - - QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const; - QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const; - - QRegExp filterRegExp() const; - void setFilterRegExp(const QRegExp ®Exp); - - int filterKeyColumn() const; - void setFilterKeyColumn(int column); - - Qt::CaseSensitivity filterCaseSensitivity() const; - void setFilterCaseSensitivity(Qt::CaseSensitivity cs); - - Qt::CaseSensitivity sortCaseSensitivity() const; - void setSortCaseSensitivity(Qt::CaseSensitivity cs); - - bool isSortLocaleAware() const; - void setSortLocaleAware(bool on); - - int sortColumn() const; - Qt::SortOrder sortOrder() const; - - bool dynamicSortFilter() const; - void setDynamicSortFilter(bool enable); - - int sortRole() const; - void setSortRole(int role); - - int filterRole() const; - void setFilterRole(int role); - -public Q_SLOTS: - void setFilterRegExp(const QString &pattern); - void setFilterWildcard(const QString &pattern); - void setFilterFixedString(const QString &pattern); - void clear(); - void invalidate(); - -protected: - virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; - virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const; - virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const; - - void filterChanged(); - void invalidateFilter(); - -public: -#ifdef Q_NO_USING_KEYWORD - inline QObject *parent() const { return QObject::parent(); } -#else - using QObject::parent; -#endif - - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - bool hasChildren(const QModelIndex &parent = QModelIndex()) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - bool setHeaderData(int section, Qt::Orientation orientation, - const QVariant &value, int role = Qt::EditRole); - - QMimeData *mimeData(const QModelIndexList &indexes) const; - bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent); - - bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()); - bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()); - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); - bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()); - - void fetchMore(const QModelIndex &parent); - bool canFetchMore(const QModelIndex &parent) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - - QModelIndex buddy(const QModelIndex &index) const; - QModelIndexList match(const QModelIndex &start, int role, - const QVariant &value, int hits = 1, - Qt::MatchFlags flags = - Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const; - QSize span(const QModelIndex &index) const; - void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); - - QStringList mimeTypes() const; - Qt::DropActions supportedDropActions() const; -private: - Q_DECLARE_PRIVATE(QSortFilterProxyModel) - Q_DISABLE_COPY(QSortFilterProxyModel) - - 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(const QList<QPersistentModelIndex> &sourceParents)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(const QModelIndex &source_parent, int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(const QModelIndex &source_parent, int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(const QModelIndex &source_parent, int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(const QModelIndex &source_parent, int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(const QModelIndex &source_parent, int start, int end)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)) - Q_PRIVATE_SLOT(d_func(), void _q_clearMapping()) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QT_NO_SORTFILTERPROXYMODEL - -#endif // QSORTFILTERPROXYMODEL_H diff --git a/src/widgets/itemviews/qstandarditemmodel.cpp b/src/widgets/itemviews/qstandarditemmodel.cpp index 293420beb7..7bfece75ac 100644 --- a/src/widgets/itemviews/qstandarditemmodel.cpp +++ b/src/widgets/itemviews/qstandarditemmodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qstandarditemmodel.h b/src/widgets/itemviews/qstandarditemmodel.h index b1e70fffad..41047f7ed5 100644 --- a/src/widgets/itemviews/qstandarditemmodel.h +++ b/src/widgets/itemviews/qstandarditemmodel.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qstandarditemmodel_p.h b/src/widgets/itemviews/qstandarditemmodel_p.h index dc2b5b9a3f..9fcddbe7d1 100644 --- a/src/widgets/itemviews/qstandarditemmodel_p.h +++ b/src/widgets/itemviews/qstandarditemmodel_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qstringlistmodel.cpp b/src/widgets/itemviews/qstringlistmodel.cpp deleted file mode 100644 index 9faaca0dd4..0000000000 --- a/src/widgets/itemviews/qstringlistmodel.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - A simple model that uses a QStringList as its data source. -*/ - -#include "qstringlistmodel.h" - -#ifndef QT_NO_STRINGLISTMODEL - -QT_BEGIN_NAMESPACE - -/*! - \class QStringListModel - \brief The QStringListModel class provides a model that supplies strings to views. - - \ingroup model-view - \inmodule QtWidgets - - QStringListModel is an editable model that can be used for simple - cases where you need to display a number of strings in a view - widget, such as a QListView or a QComboBox. - - The model provides all the standard functions of an editable - model, representing the data in the string list as a model with - one column and a number of rows equal to the number of items in - the list. - - Model indexes corresponding to items are obtained with the - \l{QAbstractListModel::index()}{index()} function, and item flags - are obtained with flags(). Item data is read with the data() - function and written with setData(). The number of rows (and - number of items in the string list) can be found with the - rowCount() function. - - The model can be constructed with an existing string list, or - strings can be set later with the setStringList() convenience - function. Strings can also be inserted in the usual way with the - insertRows() function, and removed with removeRows(). The contents - of the string list can be retrieved with the stringList() - convenience function. - - An example usage of QStringListModel: - - \snippet doc/src/snippets/qstringlistmodel/main.cpp 0 - - \sa QAbstractListModel, QAbstractItemModel, {Model Classes} -*/ - -/*! - Constructs a string list model with the given \a parent. -*/ - -QStringListModel::QStringListModel(QObject *parent) - : QAbstractListModel(parent) -{ -} - -/*! - Constructs a string list model containing the specified \a strings - with the given \a parent. -*/ - -QStringListModel::QStringListModel(const QStringList &strings, QObject *parent) - : QAbstractListModel(parent), lst(strings) -{ -} - -/*! - Returns the number of rows in the model. This value corresponds to the - number of items in the model's internal string list. - - The optional \a parent argument is in most models used to specify - the parent of the rows to be counted. Because this is a list if a - valid parent is specified, the result will always be 0. - - \sa insertRows(), removeRows(), QAbstractItemModel::rowCount() -*/ - -int QStringListModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return lst.count(); -} - -/*! - Returns data for the specified \a role, from the item with the - given \a index. - - If the view requests an invalid index, an invalid variant is returned. - - \sa setData() -*/ - -QVariant QStringListModel::data(const QModelIndex &index, int role) const -{ - if (index.row() < 0 || index.row() >= lst.size()) - return QVariant(); - - if (role == Qt::DisplayRole || role == Qt::EditRole) - return lst.at(index.row()); - - return QVariant(); -} - -/*! - Returns the flags for the item with the given \a index. - - Valid items are enabled, selectable, editable, drag enabled and drop enabled. - - \sa QAbstractItemModel::flags() -*/ - -Qt::ItemFlags QStringListModel::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return QAbstractItemModel::flags(index) | Qt::ItemIsDropEnabled; - - return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; -} - -/*! - Sets the data for the specified \a role in the item with the given - \a index in the model, to the provided \a value. - - The dataChanged() signal is emitted if the item is changed. - - \sa Qt::ItemDataRole, data() -*/ - -bool QStringListModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (index.row() >= 0 && index.row() < lst.size() - && (role == Qt::EditRole || role == Qt::DisplayRole)) { - lst.replace(index.row(), value.toString()); - emit dataChanged(index, index); - return true; - } - return false; -} - -/*! - Inserts \a count rows into the model, beginning at the given \a row. - - The \a parent index of the rows is optional and is only used for - consistency with QAbstractItemModel. By default, a null index is - specified, indicating that the rows are inserted in the top level of - the model. - - \sa QAbstractItemModel::insertRows() -*/ - -bool QStringListModel::insertRows(int row, int count, const QModelIndex &parent) -{ - if (count < 1 || row < 0 || row > rowCount(parent)) - return false; - - beginInsertRows(QModelIndex(), row, row + count - 1); - - for (int r = 0; r < count; ++r) - lst.insert(row, QString()); - - endInsertRows(); - - return true; -} - -/*! - Removes \a count rows from the model, beginning at the given \a row. - - The \a parent index of the rows is optional and is only used for - consistency with QAbstractItemModel. By default, a null index is - specified, indicating that the rows are removed in the top level of - the model. - - \sa QAbstractItemModel::removeRows() -*/ - -bool QStringListModel::removeRows(int row, int count, const QModelIndex &parent) -{ - if (count <= 0 || row < 0 || (row + count) > rowCount(parent)) - return false; - - beginRemoveRows(QModelIndex(), row, row + count - 1); - - for (int r = 0; r < count; ++r) - lst.removeAt(row); - - endRemoveRows(); - - return true; -} - -static bool ascendingLessThan(const QPair<QString, int> &s1, const QPair<QString, int> &s2) -{ - return s1.first < s2.first; -} - -static bool decendingLessThan(const QPair<QString, int> &s1, const QPair<QString, int> &s2) -{ - return s1.first > s2.first; -} - -/*! - \reimp -*/ -void QStringListModel::sort(int, Qt::SortOrder order) -{ - emit layoutAboutToBeChanged(); - - QList<QPair<QString, int> > list; - for (int i = 0; i < lst.count(); ++i) - list.append(QPair<QString, int>(lst.at(i), i)); - - if (order == Qt::AscendingOrder) - qSort(list.begin(), list.end(), ascendingLessThan); - else - qSort(list.begin(), list.end(), decendingLessThan); - - lst.clear(); - QVector<int> forwarding(list.count()); - for (int i = 0; i < list.count(); ++i) { - lst.append(list.at(i).first); - forwarding[list.at(i).second] = i; - } - - QModelIndexList oldList = persistentIndexList(); - QModelIndexList newList; - for (int i = 0; i < oldList.count(); ++i) - newList.append(index(forwarding.at(oldList.at(i).row()), 0)); - changePersistentIndexList(oldList, newList); - - emit layoutChanged(); -} - -/*! - Returns the string list used by the model to store data. -*/ -QStringList QStringListModel::stringList() const -{ - return lst; -} - -/*! - Sets the model's internal string list to \a strings. The model will - notify any attached views that its underlying data has changed. - - \sa dataChanged() -*/ -void QStringListModel::setStringList(const QStringList &strings) -{ - emit beginResetModel(); - lst = strings; - emit endResetModel(); -} - -/*! - \reimp -*/ -Qt::DropActions QStringListModel::supportedDropActions() const -{ - return QAbstractItemModel::supportedDropActions() | Qt::MoveAction; -} - -QT_END_NAMESPACE - -#endif // QT_NO_STRINGLISTMODEL diff --git a/src/widgets/itemviews/qstringlistmodel.h b/src/widgets/itemviews/qstringlistmodel.h deleted file mode 100644 index 5efed8753e..0000000000 --- a/src/widgets/itemviews/qstringlistmodel.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSTRINGLISTMODEL_H -#define QSTRINGLISTMODEL_H - -#include <QtCore/qstringlist.h> -#include <QtWidgets/qabstractitemview.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_STRINGLISTMODEL - -class Q_WIDGETS_EXPORT QStringListModel : public QAbstractListModel -{ - Q_OBJECT -public: - explicit QStringListModel(QObject *parent = 0); - QStringListModel(const QStringList &strings, QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - - QVariant data(const QModelIndex &index, int role) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - - Qt::ItemFlags flags(const QModelIndex &index) const; - - bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()); - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); - - void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); - - QStringList stringList() const; - void setStringList(const QStringList &strings); - - Qt::DropActions supportedDropActions() const; - -private: - Q_DISABLE_COPY(QStringListModel) - QStringList lst; -}; - -#endif // QT_NO_STRINGLISTMODEL - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSTRINGLISTMODEL_H diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index 35d8d3d85b..bf6cbdb7a4 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qstyleditemdelegate.h b/src/widgets/itemviews/qstyleditemdelegate.h index 6dda0041c9..67f7182446 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.h +++ b/src/widgets/itemviews/qstyleditemdelegate.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index ec629cad8e..625a7e353b 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h index 29f3793836..d2773c650e 100644 --- a/src/widgets/itemviews/qtableview.h +++ b/src/widgets/itemviews/qtableview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index dce0ed06ac..49ec36f680 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 6485fa503d..abfba19117 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h index d7332542d2..37b6d0f530 100644 --- a/src/widgets/itemviews/qtablewidget.h +++ b/src/widgets/itemviews/qtablewidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtablewidget_p.h b/src/widgets/itemviews/qtablewidget_p.h index 7b7fc21ce8..881c4bd8a3 100644 --- a/src/widgets/itemviews/qtablewidget_p.h +++ b/src/widgets/itemviews/qtablewidget_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 5674162b05..368be3a6c8 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -664,7 +664,7 @@ void QTreeView::setFirstColumnSpanned(int row, const QModelIndex &parent, bool s /*! \reimp */ -void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &roles) { Q_D(QTreeView); @@ -706,7 +706,7 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto d->updateScrollBars(); d->viewport->update(); } - QAbstractItemView::dataChanged(topLeft, bottomRight); + QAbstractItemView::dataChanged(topLeft, bottomRight, roles); } /*! @@ -1378,6 +1378,31 @@ QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList return ret; } +void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex ¤t) const +{ + const int row = current.row(); + option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None) + | (viewItems.at(row).hasChildren ? QStyle::State_Children : QStyle::State_None) + | (viewItems.at(row).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None); + + option->showDecorationSelected = (selectionBehavior & QTreeView::SelectRows) + || option->showDecorationSelected; + + QVector<int> logicalIndices; // index = visual index of visible columns only. data = logical index. + QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex, visible columns only. + calcLogicalIndices(&logicalIndices, &viewItemPosList); + + int columnIndex = 0; + for (int visualIndex = 0; visualIndex < current.column(); ++visualIndex) { + int logicalIndex = header->logicalIndex(visualIndex); + if (!header->isSectionHidden(logicalIndex)) { + ++columnIndex; + } + } + + option->viewItemPosition = viewItemPosList.at(columnIndex); +} + /*! \since 4.2 @@ -1463,6 +1488,59 @@ static inline bool ancestorOf(QObject *widget, QObject *other) return false; } +void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions) const +{ + const int left = (spanning ? header->visualIndex(0) : leftAndRight.first); + const int right = (spanning ? header->visualIndex(0) : leftAndRight.second); + const int columnCount = header->count(); + /* 'left' and 'right' are the left-most and right-most visible visual indices. + Compute the first visible logical indices before and after the left and right. + We will use these values to determine the QStyleOptionViewItemV4::viewItemPosition. */ + int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1; + for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) { + int logicalIndex = header->logicalIndex(visualIndex); + if (!header->isSectionHidden(logicalIndex)) { + logicalIndexBeforeLeft = logicalIndex; + break; + } + } + + for (int visualIndex = left; visualIndex < columnCount; ++visualIndex) { + int logicalIndex = header->logicalIndex(visualIndex); + if (!header->isSectionHidden(logicalIndex)) { + if (visualIndex > right) { + logicalIndexAfterRight = logicalIndex; + break; + } + logicalIndices->append(logicalIndex); + } + } + + itemPositions->resize(logicalIndices->count()); + for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices->count(); ++currentLogicalSection) { + const int headerSection = logicalIndices->at(currentLogicalSection); + // determine the viewItemPosition depending on the position of column 0 + int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices->count() + ? logicalIndexAfterRight + : logicalIndices->at(currentLogicalSection + 1); + int prevLogicalSection = currentLogicalSection - 1 < 0 + ? logicalIndexBeforeLeft + : logicalIndices->at(currentLogicalSection - 1); + QStyleOptionViewItemV4::ViewItemPosition pos; + if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1) + || (headerSection == 0 && nextLogicalSection == -1) || spanning) + pos = QStyleOptionViewItemV4::OnlyOne; + else if (headerSection == 0 || (nextLogicalSection != 0 && prevLogicalSection == -1)) + pos = QStyleOptionViewItemV4::Beginning; + else if (nextLogicalSection == 0 || nextLogicalSection == -1) + pos = QStyleOptionViewItemV4::End; + else + pos = QStyleOptionViewItemV4::Middle; + (*itemPositions)[currentLogicalSection] = pos; + } +} + + /*! Draws the row in the tree view that contains the model item \a index, using the \a painter given. The \a option control how the item is @@ -1531,33 +1609,13 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, int width, height = option.rect.height(); int position; QModelIndex modelIndex; - int columnCount = header->count(); const bool hoverRow = selectionBehavior() == QAbstractItemView::SelectRows && index.parent() == hover.parent() && index.row() == hover.row(); - /* 'left' and 'right' are the left-most and right-most visible visual indices. - Compute the first visible logical indices before and after the left and right. - We will use these values to determine the QStyleOptionViewItemV4::viewItemPosition. */ - int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1; - for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) { - int logicalIndex = header->logicalIndex(visualIndex); - if (!header->isSectionHidden(logicalIndex)) { - logicalIndexBeforeLeft = logicalIndex; - break; - } - } - QVector<int> logicalIndices; // vector of currently visibly logical indices - for (int visualIndex = left; visualIndex < columnCount; ++visualIndex) { - int logicalIndex = header->logicalIndex(visualIndex); - if (!header->isSectionHidden(logicalIndex)) { - if (visualIndex > right) { - logicalIndexAfterRight = logicalIndex; - break; - } - logicalIndices.append(logicalIndex); - } - } + QVector<int> logicalIndices; + QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex + d->calcLogicalIndices(&logicalIndices, &viewItemPosList); for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count(); ++currentLogicalSection) { int headerSection = logicalIndices.at(currentLogicalSection); @@ -1579,22 +1637,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, continue; opt.state = state; - // determine the viewItemPosition depending on the position of column 0 - int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices.count() - ? logicalIndexAfterRight - : logicalIndices.at(currentLogicalSection + 1); - int prevLogicalSection = currentLogicalSection - 1 < 0 - ? logicalIndexBeforeLeft - : logicalIndices.at(currentLogicalSection - 1); - if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1) - || (headerSection == 0 && nextLogicalSection == -1) || spanning) - opt.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; - else if (headerSection == 0 || (nextLogicalSection != 0 && prevLogicalSection == -1)) - opt.viewItemPosition = QStyleOptionViewItemV4::Beginning; - else if (nextLogicalSection == 0 || nextLogicalSection == -1) - opt.viewItemPosition = QStyleOptionViewItemV4::End; - else - opt.viewItemPosition = QStyleOptionViewItemV4::Middle; + opt.viewItemPosition = viewItemPosList.at(currentLogicalSection); // fake activeness when row editor has focus if (indexWidgetHasFocus) diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h index 8c49375d1d..bc68fd413a 100644 --- a/src/widgets/itemviews/qtreeview.h +++ b/src/widgets/itemviews/qtreeview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -144,7 +144,7 @@ public: void sortByColumn(int column, Qt::SortOrder order); - void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QSet<int> &roles = QSet<int>()); void selectAll(); Q_SIGNALS: diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h index 5a90b15389..7f6413d76c 100644 --- a/src/widgets/itemviews/qtreeview_p.h +++ b/src/widgets/itemviews/qtreeview_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -97,6 +97,7 @@ public: void initialize(); QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; + void adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex ¤t) const; #ifndef QT_NO_ANIMATION struct AnimatedOperation : public QVariantAnimation @@ -167,6 +168,10 @@ public: void paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItemV4 *option, int y, int bottom) const; + // logicalIndices: vector of currently visibly logical indices + // itemPositions: vector of view item positions (beginning/middle/end/onlyone) + void calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions) const; + QHeaderView *header; int indent; diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 8c32e0ce87..71797b182c 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h index ec4b0d8585..9f30e94580 100644 --- a/src/widgets/itemviews/qtreewidget.h +++ b/src/widgets/itemviews/qtreewidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtreewidget_p.h b/src/widgets/itemviews/qtreewidget_p.h index 1ead6837c1..a26666dd40 100644 --- a/src/widgets/itemviews/qtreewidget_p.h +++ b/src/widgets/itemviews/qtreewidget_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtreewidgetitemiterator.cpp b/src/widgets/itemviews/qtreewidgetitemiterator.cpp index f538917a09..5fdab5d024 100644 --- a/src/widgets/itemviews/qtreewidgetitemiterator.cpp +++ b/src/widgets/itemviews/qtreewidgetitemiterator.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtreewidgetitemiterator.h b/src/widgets/itemviews/qtreewidgetitemiterator.h index 8d27afe2c3..d994b88b12 100644 --- a/src/widgets/itemviews/qtreewidgetitemiterator.h +++ b/src/widgets/itemviews/qtreewidgetitemiterator.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qtreewidgetitemiterator_p.h b/src/widgets/itemviews/qtreewidgetitemiterator_p.h index 5ece7fd7b6..c338b944a1 100644 --- a/src/widgets/itemviews/qtreewidgetitemiterator_p.h +++ b/src/widgets/itemviews/qtreewidgetitemiterator_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/itemviews/qwidgetitemdata_p.h b/src/widgets/itemviews/qwidgetitemdata_p.h index e7a08de378..cae3e8d1ff 100644 --- a/src/widgets/itemviews/qwidgetitemdata_p.h +++ b/src/widgets/itemviews/qwidgetitemdata_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 22162895f7..408e088f0f 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -1185,22 +1185,19 @@ void QAction::activate(ActionEvent event) { Q_D(QAction); if(event == Trigger) { - QObject *guard = this; - QMetaObject::addGuard(&guard); + QWeakPointer<QObject> guard = this; if(d->checkable) { // the checked action of an exclusive group cannot be unchecked if (d->checked && (d->group && d->group->isExclusive() && d->group->checkedAction() == this)) { - if (guard) + if (!guard.isNull()) emit triggered(true); - QMetaObject::removeGuard(&guard); return; } setChecked(!d->checked); } - if (guard) + if (!guard.isNull()) emit triggered(d->checked); - QMetaObject::removeGuard(&guard); } else if(event == Hover) { emit hovered(); } @@ -1266,97 +1263,6 @@ void QAction::activate(ActionEvent event) */ /*! - \fn void QAction::setMenuText(const QString &text) - - Use setText() instead. -*/ - -/*! - \fn QString QAction::menuText() const - - Use text() instead. -*/ - -/*! - \fn bool QAction::isOn() const - - Use isChecked() instead. -*/ - -/*! - \fn void QAction::setOn(bool b) - - Use setChecked() instead. -*/ - -/*! - \fn bool QAction::isToggleAction() const - - Use isCheckable() instead. -*/ - -/*! - \fn void QAction::setToggleAction(bool b) - - Use setCheckable() instead. -*/ - -/*! - \fn void QAction::setIconSet(const QIcon &i) - - Use setIcon() instead. -*/ - -/*! - \fn bool QAction::addTo(QWidget *w) - - Use QWidget::addAction() instead. - - \oldcode - action->addTo(widget); - \newcode - widget->addAction(action); - \endcode -*/ - -/*! - \fn bool QAction::removeFrom(QWidget *w) - - Use QWidget::removeAction() instead. - - \oldcode - action->removeFrom(widget); - \newcode - widget->removeAction(action); - \endcode -*/ - -/*! - \fn void QAction::setAccel(const QKeySequence &shortcut) - - Use setShortcut() instead. -*/ - -/*! - \fn QIcon QAction::iconSet() const - - Use icon() instead. -*/ - -/*! - \fn QKeySequence QAction::accel() const - - Use shortcut() instead. -*/ - -/*! - \fn void QAction::activated(int i); - - Use triggered() instead. -*/ - - -/*! \property QAction::menuRole \brief the action's menu role \since 4.2 diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index 5c163c2314..a2cafa2027 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h index 8f9e1f0f8e..d57cd05cff 100644 --- a/src/widgets/kernel/qaction_p.h +++ b/src/widgets/kernel/qaction_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp index 0397883009..67e0ee7adf 100644 --- a/src/widgets/kernel/qactiongroup.cpp +++ b/src/widgets/kernel/qactiongroup.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qactiongroup.h b/src/widgets/kernel/qactiongroup.h index 5379ef4197..bdef33294c 100644 --- a/src/widgets/kernel/qactiongroup.h +++ b/src/widgets/kernel/qactiongroup.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index afd5fb70e1..fc295eb874 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -139,7 +139,6 @@ QT_BEGIN_NAMESPACE Q_CORE_EXPORT void qt_call_post_routines(); -QApplication::Type qt_appType=QApplication::Tty; QApplicationPrivate *QApplicationPrivate::self = 0; QInputContext *QApplicationPrivate::inputContext = 0; @@ -157,7 +156,6 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T : QApplicationPrivateBase(argc, argv, flags) { application_type = type; - qt_appType = type; #ifndef QT_NO_SESSIONMANAGER is_session_restored = false; @@ -366,14 +364,6 @@ QApplicationPrivate::~QApplicationPrivate() */ /*! - \enum QApplication::Type - - \value Tty a console application - \value GuiClient a GUI client application - \value GuiServer a GUI server application (for Qt for Embedded Linux) -*/ - -/*! \enum QApplication::ColorSpec \value NormalColor the default color allocation policy @@ -441,7 +431,6 @@ bool QApplicationPrivate::obey_desktop_settings = true; // use winsys res #ifndef QT_NO_WHEELEVENT int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll #endif -bool qt_is_gui_used; bool Q_WIDGETS_EXPORT qt_tab_all_widgets = true; bool qt_in_tab_key_event = false; int qt_antialiasing_threshold = -1; @@ -743,11 +732,11 @@ void QApplicationPrivate::construct( { initResources(); - qt_is_gui_used = (qt_appType != QApplication::Tty); + qt_is_gui_used = (application_type != QApplication::Tty); process_cmdline(); // Must be called before initialize() - qt_init(this, qt_appType + qt_init(this, application_type #ifdef Q_WS_X11 , dpy, visual, cmap #endif @@ -873,7 +862,7 @@ void QApplicationPrivate::initialize() QWidgetPrivate::mapper = new QWidgetMapper; QWidgetPrivate::allWidgets = new QWidgetSet; - if (qt_appType != QApplication::Tty) + if (application_type != QApplication::Tty) (void) QApplication::style(); // trigger creation of application style #ifndef QT_NO_STATEMACHINE // trigger registering of QStateMachine's GUI types @@ -917,7 +906,9 @@ void QApplicationPrivate::initialize() */ QApplication::Type QApplication::type() { - return qt_appType; + if (QApplicationPrivate::instance()) + return (QCoreApplication::Type)QApplicationPrivate::instance()->application_type; + return Tty; } /***************************************************************************** @@ -1275,7 +1266,7 @@ QStyle *QApplication::style() { if (QApplicationPrivate::app_style) return QApplicationPrivate::app_style; - if (!qt_is_gui_used) { + if (qApp->type() == QApplication::Tty) { Q_ASSERT(!"No style available in non-gui applications!"); return 0; } @@ -2311,9 +2302,6 @@ void QApplication::setActiveWindow(QWidget* act) } } -#if !defined(Q_WS_MAC) - QWidget *previousActiveWindow = QApplicationPrivate::active_window; -#endif QApplicationPrivate::active_window = window; if (QApplicationPrivate::active_window) { @@ -2335,13 +2323,6 @@ void QApplication::setActiveWindow(QWidget* act) QEvent windowActivate(QEvent::WindowActivate); QEvent windowDeactivate(QEvent::WindowDeactivate); -#if !defined(Q_WS_MAC) - if (!previousActiveWindow) { - QEvent appActivate(QEvent::ApplicationActivate); - sendSpontaneousEvent(qApp, &appActivate); - } -#endif - for (int i = 0; i < toBeActivated.size(); ++i) { QWidget *w = toBeActivated.at(i); sendSpontaneousEvent(w, &windowActivate); @@ -2361,13 +2342,6 @@ void QApplication::setActiveWindow(QWidget* act) sendSpontaneousEvent(w, &activationChange); } -#if !defined(Q_WS_MAC) - if (!QApplicationPrivate::active_window) { - QEvent appDeactivate(QEvent::ApplicationDeactivate); - sendSpontaneousEvent(qApp, &appDeactivate); - } -#endif - if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode() // then focus events if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) { @@ -3449,8 +3423,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) case QEvent::Style: case QEvent::IconDrag: case QEvent::StyleChange: - case QEvent::AccessibilityHelp: - case QEvent::AccessibilityDescription: case QEvent::GraphicsSceneDragEnter: case QEvent::GraphicsSceneDragMove: case QEvent::GraphicsSceneDragLeave: @@ -3896,7 +3868,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) while (widget) { // first, try to deliver the touch event bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); - touchEvent->setWidget(widget); + touchEvent->setTarget(widget); touchEvent->setAccepted(acceptTouchEvents); QWeakPointer<QWidget> p = widget; res = acceptTouchEvents && d->notify_helper(widget, touchEvent); @@ -3912,7 +3884,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // the first widget to accept the TouchBegin gets an implicit grab. for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i); - d->widgetForTouchPointId[touchPoint.id()] = widget; + d->activeTouchPoints[QGuiApplicationPrivate::ActiveTouchPointsKey(touchEvent->device(), touchPoint.id())].target = widget; } break; } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) { @@ -3920,7 +3892,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } QPoint offset = widget->pos(); widget = widget->parentWidget(); - touchEvent->setWidget(widget); + touchEvent->setTarget(widget); for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) { QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i]; QRectF rect = pt.rect(); @@ -4965,31 +4937,29 @@ int QApplication::keyboardInputInterval() // Input Method support // ************************************************************************ -/*! +/* This function replaces the QInputContext instance used by the application with \a inputContext. Qt takes ownership of the given \a inputContext. - - \sa inputContext() */ -void QApplication::setInputContext(QInputContext *inputContext) +void QApplicationPrivate::setInputContext(QInputContext *newInputContext) { - if (inputContext == QApplicationPrivate::inputContext) + Q_Q(QApplication); + + if (newInputContext == inputContext) return; - if (!inputContext) { - qWarning("QApplication::setInputContext: called with 0 input context"); + if (!newInputContext) { + qWarning("QApplicationPrivate::setInputContext: called with 0 input context"); return; } - delete QApplicationPrivate::inputContext; - QApplicationPrivate::inputContext = inputContext; - QApplicationPrivate::inputContext->setParent(this); + delete inputContext; + inputContext = newInputContext; + inputContext->setParent(q); } /*! Returns the QInputContext instance used by the application. - - \sa setInputContext() */ QInputContext *QApplication::inputContext() const { @@ -5176,41 +5146,43 @@ void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta); touchPoint.d->rect = rect; - if (touchPoint.state() == Qt::TouchPointPressed) { - touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; - touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; - } + touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; + touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; } } void QApplicationPrivate::initializeMultitouch() { - widgetForTouchPointId.clear(); - appCurrentTouchPoints.clear(); - initializeMultitouch_sys(); } void QApplicationPrivate::cleanupMultitouch() { cleanupMultitouch_sys(); - - widgetForTouchPointId.clear(); - appCurrentTouchPoints.clear(); } -int QApplicationPrivate::findClosestTouchPointId(const QPointF &screenPos) +QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos) { int closestTouchPointId = -1; + QObject *closestTarget = 0; qreal closestDistance = qreal(0.); - foreach (const QTouchEvent::TouchPoint &touchPoint, appCurrentTouchPoints) { - qreal distance = QLineF(screenPos, touchPoint.screenPos()).length(); - if (closestTouchPointId == -1 || distance < closestDistance) { - closestTouchPointId = touchPoint.id(); - closestDistance = distance; + QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it = activeTouchPoints.constBegin(), + ite = activeTouchPoints.constEnd(); + while (it != ite) { + if (it.key().device == device) { + const QTouchEvent::TouchPoint &touchPoint = it->touchPoint; + qreal dx = screenPos.x() - touchPoint.screenPos().x(); + qreal dy = screenPos.y() - touchPoint.screenPos().y(); + qreal distance = dx * dx + dy * dy; + if (closestTouchPointId == -1 || distance < closestDistance) { + closestTouchPointId = touchPoint.id(); + closestDistance = distance; + closestTarget = it.value().target.data(); + } } + ++it; } - return closestTouchPointId; + return static_cast<QWidget *>(closestTarget); } void QApplicationPrivate::translateRawTouchEvent(QWidget *window, @@ -5230,94 +5202,47 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, touchPoint.d = touchPoint.d->detach(); // update state - QWeakPointer<QWidget> widget; - switch (touchPoint.state()) { - case Qt::TouchPointPressed: - { + QWeakPointer<QObject> target; + ActiveTouchPointsKey touchInfoKey(device, touchPoint.id()); + ActiveTouchPointsValue &touchInfo = d->activeTouchPoints[touchInfoKey]; + if (touchPoint.state() == Qt::TouchPointPressed) { if (device->type() == QTouchDevice::TouchPad) { // on touch-pads, send all touch points to the same widget - widget = d->widgetForTouchPointId.isEmpty() - ? QWeakPointer<QWidget>() - : d->widgetForTouchPointId.constBegin().value(); + target = d->activeTouchPoints.isEmpty() + ? QWeakPointer<QObject>() + : d->activeTouchPoints.constBegin().value().target; } - if (!widget) { + if (!target) { // determine which widget this event will go to if (!window) window = QApplication::topLevelAt(touchPoint.screenPos().toPoint()); if (!window) continue; - widget = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint())); - if (!widget) - widget = window; + target = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint())); + if (!target) + target = window; } if (device->type() == QTouchDevice::TouchScreen) { - int closestTouchPointId = d->findClosestTouchPointId(touchPoint.screenPos()); - QWidget *closestWidget = d->widgetForTouchPointId.value(closestTouchPointId).data(); + QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint.screenPos()); + QWidget *widget = static_cast<QWidget *>(target.data()); if (closestWidget - && (widget.data()->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget.data()))) { - widget = closestWidget; + && (widget->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget))) { + target = closestWidget; } } - d->widgetForTouchPointId[touchPoint.id()] = widget; - touchPoint.d->startScreenPos = touchPoint.screenPos(); - touchPoint.d->lastScreenPos = touchPoint.screenPos(); - touchPoint.d->startNormalizedPos = touchPoint.normalizedPos(); - touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos(); - if (touchPoint.pressure() < qreal(0.)) - touchPoint.d->pressure = qreal(1.); - - d->appCurrentTouchPoints.insert(touchPoint.id(), touchPoint); - break; - } - case Qt::TouchPointReleased: - { - widget = d->widgetForTouchPointId.take(touchPoint.id()); - if (!widget) - continue; - - QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.take(touchPoint.id()); - touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); - touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); - touchPoint.d->startPos = previousTouchPoint.startPos(); - touchPoint.d->lastPos = previousTouchPoint.pos(); - touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); - touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); - if (touchPoint.pressure() < qreal(0.)) - touchPoint.d->pressure = qreal(0.); - break; - } - default: - widget = d->widgetForTouchPointId.value(touchPoint.id()); - if (!widget) + touchInfo.target = target; + } else { + target = touchInfo.target; + if (!target) continue; - - Q_ASSERT(d->appCurrentTouchPoints.contains(touchPoint.id())); - QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.value(touchPoint.id()); - touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); - touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); - touchPoint.d->startPos = previousTouchPoint.startPos(); - touchPoint.d->lastPos = previousTouchPoint.pos(); - touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); - touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); - if (touchPoint.pressure() < qreal(0.)) - touchPoint.d->pressure = qreal(1.); - d->appCurrentTouchPoints[touchPoint.id()] = touchPoint; - break; } - Q_ASSERT(widget.data() != 0); - - // make the *scene* functions return the same as the *screen* functions - touchPoint.d->sceneRect = touchPoint.screenRect(); - touchPoint.d->startScenePos = touchPoint.startScreenPos(); - touchPoint.d->lastScenePos = touchPoint.lastScreenPos(); + Q_ASSERT(target.data() != 0); - StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget.data()]; + StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[static_cast<QWidget *>(target.data())]; maskAndPoints.first |= touchPoint.state(); - if (touchPoint.isPrimary()) - maskAndPoints.first |= Qt::TouchPointPrimary; maskAndPoints.second.append(touchPoint); } @@ -5332,7 +5257,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, continue; QEvent::Type eventType; - switch (it.value().first & Qt::TouchPointStateMask) { + switch (it.value().first) { case Qt::TouchPointPressed: eventType = QEvent::TouchBegin; break; @@ -5355,6 +5280,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, updateTouchPointsForWidget(widget, &touchEvent); touchEvent.setTimestamp(timestamp); touchEvent.setWindow(window->windowHandle()); + touchEvent.setTarget(widget); switch (touchEvent.type()) { case QEvent::TouchBegin: @@ -5376,14 +5302,6 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, } } -Q_WIDGETS_EXPORT void qt_translateRawTouchEvent(QWidget *window, - QTouchDevice *device, - const QList<QTouchEvent::TouchPoint> &touchPoints, - ulong timestamp) -{ - QApplicationPrivate::translateRawTouchEvent(window, device, touchPoints, timestamp); -} - #ifndef QT_NO_GESTURES QGestureManager* QGestureManager::instance() { diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 1792d2f05d..4347aa3521 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -98,7 +98,6 @@ class Q_WIDGETS_EXPORT QApplication : public QGuiApplication Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled) public: - enum Type { Tty, GuiClient, GuiServer }; #ifndef qdoc QApplication(int &argc, char **argv, int = ApplicationFlags); @@ -224,7 +223,6 @@ public: #endif #ifndef QT_NO_IM - void setInputContext(QInputContext *); QInputContext *inputContext() const; #endif @@ -243,7 +241,6 @@ public: #endif Q_SIGNALS: - void lastWindowClosed(); void focusChanged(QWidget *old, QWidget *now); #ifndef QT_NO_SESSIONMANAGER void commitDataRequest(QSessionManager &sessionManager); diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 3841cef62f..f8d02ed437 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -88,7 +88,7 @@ class QTouchDevice; class QGestureManager; #endif -extern bool qt_is_gui_used; +extern Q_GUI_EXPORT bool qt_is_gui_used; #ifndef QT_NO_CLIPBOARD extern QClipboard *qt_clipboard; #endif @@ -120,37 +120,6 @@ struct QTabletDeviceData inline QPointF scaleCoord(int coordX, int coordY, int outOriginX, int outExtentX, int outOriginY, int outExtentY) const; #endif - -#ifdef Q_WS_X11 - QPointer<QWidget> widgetToGetPress; -#endif - -#ifdef Q_WS_X11 - int deviceType; - enum { - TOTAL_XINPUT_EVENTS = 64 - }; - void *device; - int eventCount; - long unsigned int eventList[TOTAL_XINPUT_EVENTS]; // XEventClass is in fact a long unsigned int - - int xinput_motion; - int xinput_key_press; - int xinput_key_release; - int xinput_button_press; - int xinput_button_release; - int xinput_proximity_in; - int xinput_proximity_out; -#elif defined(Q_WS_WIN) - qint64 llId; - int currentDevice; - int currentPointerType; -#elif defined(Q_WS_MAC) - quint64 tabletUniqueID; - int tabletDeviceType; - int tabletPointerType; - int capabilityMask; -#endif }; static inline int sign(int x) @@ -189,80 +158,6 @@ QMacTabletHash *qt_mac_tablet_hash(); # endif #endif - -#if defined(Q_WS_WIN) -typedef BOOL (WINAPI *PtrRegisterTouchWindow)(HWND, ULONG); -typedef BOOL (WINAPI *PtrGetTouchInputInfo)(HANDLE, UINT, PVOID, int); -typedef BOOL (WINAPI *PtrCloseTouchInputHandle)(HANDLE); - -#ifndef QT_NO_GESTURES -typedef BOOL (WINAPI *PtrGetGestureInfo)(HANDLE, PVOID); -typedef BOOL (WINAPI *PtrGetGestureExtraArgs)(HANDLE, UINT, PBYTE); -typedef BOOL (WINAPI *PtrCloseGestureInfoHandle)(HANDLE); -typedef BOOL (WINAPI *PtrSetGestureConfig)(HWND, DWORD, UINT, PVOID, UINT); -typedef BOOL (WINAPI *PtrGetGestureConfig)(HWND, DWORD, DWORD, PUINT, PVOID, UINT); - -typedef BOOL (WINAPI *PtrBeginPanningFeedback)(HWND); -typedef BOOL (WINAPI *PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL); -typedef BOOL (WINAPI *PtrEndPanningFeedback)(HWND, BOOL); - -#ifndef WM_GESTURE -# define WM_GESTURE 0x0119 - -# define GID_BEGIN 1 -# define GID_END 2 -# define GID_ZOOM 3 -# define GID_PAN 4 -# define GID_ROTATE 5 -# define GID_TWOFINGERTAP 6 -# define GID_ROLLOVER 7 - -typedef struct tagGESTUREINFO -{ - UINT cbSize; - DWORD dwFlags; - DWORD dwID; - HWND hwndTarget; - POINTS ptsLocation; - DWORD dwInstanceID; - DWORD dwSequenceID; - ULONGLONG ullArguments; - UINT cbExtraArgs; -} GESTUREINFO; - -# define GC_PAN 0x00000001 -# define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002 -# define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004 - -# define GC_ZOOM 0x00000001 -# define GC_ROTATE 0x00000001 - -typedef struct tagGESTURECONFIG -{ - DWORD dwID; - DWORD dwWant; - DWORD dwBlock; -} GESTURECONFIG; - -# define GID_ROTATE_ANGLE_FROM_ARGUMENT(arg) ((((double)(arg) / 65535.0) * 4.0 * 3.14159265) - 2.0*3.14159265) - -#endif // WM_GESTURE - -#if defined(Q_WS_WINCE_WM) && defined(QT_WINCE_GESTURES) -#undef GID_ZOOM -#define GID_ZOOM 0xf000 -#undef GID_ROTATE -#define GID_ROTATE 0xf001 -#undef GID_TWOFINGERTAP -#define GID_TWOFINGERTAP 0xf002 -#undef GID_ROLLOVER -#define GID_ROLLOVER 0xf003 -#endif - -#endif // QT_NO_GESTURES - -#endif // Q_WS_WIN - struct FontHash : public QHash<QByteArray, QFont> { FontHash(); @@ -356,6 +251,10 @@ public: QPoint toolTipPos, toolTipGlobalPos, hoverGlobalPos; QPointer<QWidget> toolTipWidget; +#ifndef QT_NO_IM + void setInputContext(QInputContext *); +#endif + static QInputContext *inputContext; static Qt::MouseButtons mouse_buttons; @@ -472,14 +371,12 @@ public: QPixmap *ignore_cursor; #endif - QMap<int, QWeakPointer<QWidget> > widgetForTouchPointId; - QMap<int, QTouchEvent::TouchPoint> appCurrentTouchPoints; static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent); void initializeMultitouch(); void initializeMultitouch_sys(); void cleanupMultitouch(); void cleanupMultitouch_sys(); - int findClosestTouchPointId(const QPointF &screenPos); + QWidget *findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos); void appendTouchPoint(const QTouchEvent::TouchPoint &touchPoint); void removeTouchPoint(int touchPointId); static void translateRawTouchEvent(QWidget *widget, @@ -487,62 +384,11 @@ public: const QList<QTouchEvent::TouchPoint> &touchPoints, ulong timestamp); -#if defined(Q_WS_WIN) - static bool HasTouchSupport; - static PtrRegisterTouchWindow RegisterTouchWindow; - static PtrGetTouchInputInfo GetTouchInputInfo; - static PtrCloseTouchInputHandle CloseTouchInputHandle; - - QHash<DWORD, int> touchInputIDToTouchPointID; - bool translateTouchEvent(const MSG &msg); - -#ifndef QT_NO_GESTURES - PtrGetGestureInfo GetGestureInfo; - PtrGetGestureExtraArgs GetGestureExtraArgs; - PtrCloseGestureInfoHandle CloseGestureInfoHandle; - PtrSetGestureConfig SetGestureConfig; - PtrGetGestureConfig GetGestureConfig; - PtrBeginPanningFeedback BeginPanningFeedback; - PtrUpdatePanningFeedback UpdatePanningFeedback; - PtrEndPanningFeedback EndPanningFeedback; -#endif // QT_NO_GESTURES -#endif - -#ifdef QT_RX71_MULTITOUCH - bool hasRX71MultiTouch; - - struct RX71TouchPointState { - QSocketNotifier *socketNotifier; - QTouchEvent::TouchPoint touchPoint; - - int minX, maxX, scaleX; - int minY, maxY, scaleY; - int minZ, maxZ; - }; - QList<RX71TouchPointState> allRX71TouchPoints; - - bool readRX71MultiTouchEvents(int deviceNumber); - void fakeMouseEventFromRX71TouchEvent(); - void _q_readRX71MultiTouchEvents(); -#endif - -#if defined(Q_OS_SYMBIAN) - int pressureSupported; - int maxTouchPressure; - QList<QTouchEvent::TouchPoint> appAllTouchPoints; - - bool useTranslucentEGLSurfaces; -#endif - private: #ifdef Q_WS_QWS QMap<const QScreen*, QRect> maxWindowRects; #endif -#ifdef Q_OS_SYMBIAN - QHash<TInt, TUint> scanCodeCache; -#endif - static QApplicationPrivate *self; static void giveFocusAccordingToFocusPolicy(QWidget *w, @@ -554,11 +400,6 @@ private: static bool isAlien(QWidget *); }; -Q_WIDGETS_EXPORT void qt_translateRawTouchEvent(QWidget *window, - QTouchDevice *device, - const QList<QTouchEvent::TouchPoint> &touchPoints, - ulong timestamp); - #if defined(Q_WS_WIN) extern void qt_win_set_cursor(QWidget *, bool); #elif defined(Q_WS_X11) diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index 8732a194e8..d61b8560a8 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -383,7 +383,7 @@ QPlatformNativeInterface *QApplication::platformNativeInterface() return pi->nativeInterface(); } -void qt_init(QApplicationPrivate *, int type) +void qt_init(QApplicationPrivate *priv, int type) { Q_UNUSED(type); @@ -393,7 +393,7 @@ void qt_init(QApplicationPrivate *, int type) qApp->setObjectName(appName); #ifndef QT_NO_QWS_INPUTMETHODS - qApp->setInputContext(new QInputContext(qApp)); + priv->setInputContext(new QInputContext(qApp)); #endif } diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index 059c59fa1c..e8d653e25d 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qboxlayout.h b/src/widgets/kernel/qboxlayout.h index 5031972226..8df0fbca94 100644 --- a/src/widgets/kernel/qboxlayout.h +++ b/src/widgets/kernel/qboxlayout.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index 8c25d72f84..871715fed4 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qdesktopwidget.h b/src/widgets/kernel/qdesktopwidget.h index e1ed8cfa07..ec38b32239 100644 --- a/src/widgets/kernel/qdesktopwidget.h +++ b/src/widgets/kernel/qdesktopwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qdesktopwidget.qdoc b/src/widgets/kernel/qdesktopwidget.qdoc index 06a52af893..10690dfe35 100644 --- a/src/widgets/kernel/qdesktopwidget.qdoc +++ b/src/widgets/kernel/qdesktopwidget.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qdesktopwidget_qpa.cpp b/src/widgets/kernel/qdesktopwidget_qpa.cpp index 380daee8c0..8ac2b357c6 100644 --- a/src/widgets/kernel/qdesktopwidget_qpa.cpp +++ b/src/widgets/kernel/qdesktopwidget_qpa.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qdesktopwidget_qpa_p.h b/src/widgets/kernel/qdesktopwidget_qpa_p.h index 01ba44875d..50b5f4826e 100644 --- a/src/widgets/kernel/qdesktopwidget_qpa_p.h +++ b/src/widgets/kernel/qdesktopwidget_qpa_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 6430472462..955ef4e3c7 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -93,7 +93,7 @@ void FixedColumnMatrix<T, NumColumns>::addRow(const T &value) template <class T, int NumColumns> void FixedColumnMatrix<T, NumColumns>::insertRow(int r, const T &value) { - Q_TYPENAME Storage::iterator it = m_storage.begin(); + typename Storage::iterator it = m_storage.begin(); it += r * NumColumns; m_storage.insert(it, NumColumns, value); } diff --git a/src/widgets/kernel/qformlayout.h b/src/widgets/kernel/qformlayout.h index 05bb57d981..b37d2b6e3a 100644 --- a/src/widgets/kernel/qformlayout.h +++ b/src/widgets/kernel/qformlayout.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp index 12a0eaf45a..f79b577765 100644 --- a/src/widgets/kernel/qgesture.cpp +++ b/src/widgets/kernel/qgesture.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h index 610ae2b9f6..25dba1c886 100644 --- a/src/widgets/kernel/qgesture.h +++ b/src/widgets/kernel/qgesture.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h index 85d1c85884..be8e38cd7f 100644 --- a/src/widgets/kernel/qgesture_p.h +++ b/src/widgets/kernel/qgesture_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 5b5d8dcb2a..5abbbde4cb 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qgesturemanager_p.h b/src/widgets/kernel/qgesturemanager_p.h index 6c8cbb9cd0..800d7c5ad9 100644 --- a/src/widgets/kernel/qgesturemanager_p.h +++ b/src/widgets/kernel/qgesturemanager_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qgesturerecognizer.cpp b/src/widgets/kernel/qgesturerecognizer.cpp index 98f8b0a758..fc0e918987 100644 --- a/src/widgets/kernel/qgesturerecognizer.cpp +++ b/src/widgets/kernel/qgesturerecognizer.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qgesturerecognizer.h b/src/widgets/kernel/qgesturerecognizer.h index 019f856f09..92f9f622c0 100644 --- a/src/widgets/kernel/qgesturerecognizer.h +++ b/src/widgets/kernel/qgesturerecognizer.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index 9168346e30..80834a0105 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h index ef95d29cd1..f72ed32dcb 100644 --- a/src/widgets/kernel/qgridlayout.h +++ b/src/widgets/kernel/qgridlayout.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qguiplatformplugin.cpp b/src/widgets/kernel/qguiplatformplugin.cpp index 8acc7ec90d..7faf17b9ab 100644 --- a/src/widgets/kernel/qguiplatformplugin.cpp +++ b/src/widgets/kernel/qguiplatformplugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -148,7 +148,7 @@ QString QGuiPlatformPlugin::styleName() return QLatin1String("CDE"); // default style for X11 on Solaris #elif defined(Q_WS_X11) && defined(Q_OS_IRIX) return QLatin1String("SGI"); // default style for X11 on IRIX -#elif defined(Q_WS_MAC) +#elif defined(Q_OS_MAC) return QLatin1String("Macintosh"); // default style for all Mac's #elif defined(Q_WS_X11) QString stylename; diff --git a/src/widgets/kernel/qguiplatformplugin_p.h b/src/widgets/kernel/qguiplatformplugin_p.h index 84319b71a0..74a01b9d58 100644 --- a/src/widgets/kernel/qguiplatformplugin_p.h +++ b/src/widgets/kernel/qguiplatformplugin_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp index de7544f09a..185542420e 100644 --- a/src/widgets/kernel/qicon.cpp +++ b/src/widgets/kernel/qicon.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -1161,6 +1161,14 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon) #endif //QT_NO_DATASTREAM +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QIcon &i) +{ + dbg.nospace() << "QIcon(" << i.name() << ')'; + return dbg.space(); +} +#endif + /*! \fn DataPtr &QIcon::data_ptr() \internal diff --git a/src/widgets/kernel/qicon.h b/src/widgets/kernel/qicon.h index 3c527eb974..a72ae236f1 100644 --- a/src/widgets/kernel/qicon.h +++ b/src/widgets/kernel/qicon.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -136,6 +136,10 @@ Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &); Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QIcon &); #endif +#ifndef QT_NO_DEBUG_STREAM +Q_WIDGETS_EXPORT QDebug operator<<(QDebug dbg, const QIcon &); +#endif + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/widgets/kernel/qicon_p.h b/src/widgets/kernel/qicon_p.h index 7ba471b002..02ac3afed4 100644 --- a/src/widgets/kernel/qicon_p.h +++ b/src/widgets/kernel/qicon_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qiconengine.cpp b/src/widgets/kernel/qiconengine.cpp index 52e8cfd384..930d7e1699 100644 --- a/src/widgets/kernel/qiconengine.cpp +++ b/src/widgets/kernel/qiconengine.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qiconengine.h b/src/widgets/kernel/qiconengine.h index 63cfcbff5e..083ceee33d 100644 --- a/src/widgets/kernel/qiconengine.h +++ b/src/widgets/kernel/qiconengine.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qiconengineplugin.cpp b/src/widgets/kernel/qiconengineplugin.cpp index 2775fb201d..895572120e 100644 --- a/src/widgets/kernel/qiconengineplugin.cpp +++ b/src/widgets/kernel/qiconengineplugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qiconengineplugin.h b/src/widgets/kernel/qiconengineplugin.h index c228e8666b..1bd9075866 100644 --- a/src/widgets/kernel/qiconengineplugin.h +++ b/src/widgets/kernel/qiconengineplugin.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qiconloader.cpp b/src/widgets/kernel/qiconloader.cpp index 45959c03ef..d8bef74dd8 100644 --- a/src/widgets/kernel/qiconloader.cpp +++ b/src/widgets/kernel/qiconloader.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qiconloader_p.h b/src/widgets/kernel/qiconloader_p.h index 1c6c0cb1a5..840a2858b6 100644 --- a/src/widgets/kernel/qiconloader_p.h +++ b/src/widgets/kernel/qiconloader_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qinputcontext.cpp b/src/widgets/kernel/qinputcontext.cpp index 66595e8ee4..27576193e9 100644 --- a/src/widgets/kernel/qinputcontext.cpp +++ b/src/widgets/kernel/qinputcontext.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qinputcontext.h b/src/widgets/kernel/qinputcontext.h index 8a80d72ac2..147061f221 100644 --- a/src/widgets/kernel/qinputcontext.h +++ b/src/widgets/kernel/qinputcontext.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index ebf9cf6cae..a682354df1 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h index 65fccb13fa..4d9213c1ec 100644 --- a/src/widgets/kernel/qlayout.h +++ b/src/widgets/kernel/qlayout.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h index e282360418..cc80987500 100644 --- a/src/widgets/kernel/qlayout_p.h +++ b/src/widgets/kernel/qlayout_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qlayoutengine.cpp b/src/widgets/kernel/qlayoutengine.cpp index a7470aabaa..38e6555658 100644 --- a/src/widgets/kernel/qlayoutengine.cpp +++ b/src/widgets/kernel/qlayoutengine.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h index 9be9ecd321..5f5d0aa49e 100644 --- a/src/widgets/kernel/qlayoutengine_p.h +++ b/src/widgets/kernel/qlayoutengine_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 5fcda5dfea..732c941c74 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -42,6 +42,7 @@ #include "qlayout.h" #include "qapplication.h" +#include "qdebug.h" #include "qlayoutengine_p.h" #include "qmenubar.h" #include "qtoolbar.h" @@ -836,4 +837,13 @@ int QWidgetItemV2::heightForWidth(int width) const return height; } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QSizePolicy &p) +{ + dbg.nospace() << "QSizePolicy(horizontalPolicy = " << p.horizontalPolicy() + << ", verticalPolicy = " << p.verticalPolicy() << ')'; + return dbg.space(); +} +#endif + QT_END_NAMESPACE diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h index d03f77654b..a09dcf33de 100644 --- a/src/widgets/kernel/qlayoutitem.h +++ b/src/widgets/kernel/qlayoutitem.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qplatformdialoghelper_qpa.cpp b/src/widgets/kernel/qplatformdialoghelper_qpa.cpp index daf864ff30..cfe2b15572 100644 --- a/src/widgets/kernel/qplatformdialoghelper_qpa.cpp +++ b/src/widgets/kernel/qplatformdialoghelper_qpa.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** - ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -42,6 +42,11 @@ #include "qplatformdialoghelper_qpa.h" #include <QtCore/QVariant> +#include <QtCore/QSharedData> +#include <QtCore/QSettings> +#include <QtCore/QHash> +#include <QtCore/QUrl> +#include <QtGui/QColor> QT_BEGIN_NAMESPACE @@ -87,4 +92,465 @@ QVariant QPlatformDialogHelper::defaultStyleHint(QPlatformDialogHelper::StyleHi return QVariant(); } +void QPlatformDialogHelper::emitLaunchNativeAppModalPanel() +{ + emit launchNativeAppModalPanel(); +} + +// Font dialog + +class QFontDialogOptionsPrivate : public QSharedData +{ +public: + QFontDialogOptionsPrivate() : options(0) {} + + QFontDialogOptions::FontDialogOptions options; + QString windowTitle; +}; + +QFontDialogOptions::QFontDialogOptions() : d(new QFontDialogOptionsPrivate) +{ +} + +QFontDialogOptions::QFontDialogOptions(const QFontDialogOptions &rhs) : d(rhs.d) +{ +} + +QFontDialogOptions &QFontDialogOptions::operator=(const QFontDialogOptions &rhs) +{ + if (this != &rhs) + d = rhs.d; + return *this; +} + +QFontDialogOptions::~QFontDialogOptions() +{ +} + +QString QFontDialogOptions::windowTitle() const +{ + return d->windowTitle; +} + +void QFontDialogOptions::setWindowTitle(const QString &title) +{ + d->windowTitle = title; +} + +void QFontDialogOptions::setOption(QFontDialogOptions::FontDialogOption option, bool on) +{ + if (!(d->options & option) != !on) + setOptions(d->options ^ option); +} + +bool QFontDialogOptions::testOption(QFontDialogOptions::FontDialogOption option) const +{ + return d->options & option; +} + +void QFontDialogOptions::setOptions(FontDialogOptions options) +{ + if (options != d->options) + d->options = options; +} + +QFontDialogOptions::FontDialogOptions QFontDialogOptions::options() const +{ + return d->options; +} + +const QSharedPointer<QFontDialogOptions> &QPlatformFontDialogHelper::options() const +{ + return m_options; +} + +void QPlatformFontDialogHelper::setOptions(const QSharedPointer<QFontDialogOptions> &options) +{ + m_options = options; +} + +// Color dialog + +class QColorDialogStaticData +{ +public: + enum { CustomColorCount = 16, StandardColorCount = 6 * 8 }; + + QColorDialogStaticData(); + inline void readSettings(); + inline void writeSettings() const; + + QRgb customRgb[CustomColorCount]; + QRgb standardRgb[StandardColorCount]; + bool customSet; +}; + +QColorDialogStaticData::QColorDialogStaticData() : customSet(false) +{ + int i = 0; + for (int g = 0; g < 4; ++g) + for (int r = 0; r < 4; ++r) + for (int b = 0; b < 3; ++b) + standardRgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2); + qFill(customRgb, customRgb + CustomColorCount, 0xffffffff); + readSettings(); +} + +void QColorDialogStaticData::readSettings() +{ +#ifndef QT_NO_SETTINGS + const QSettings settings(QSettings::UserScope, QStringLiteral("Trolltech")); + for (int i = 0; i < int(CustomColorCount); ++i) { + const QVariant v = settings.value(QStringLiteral("Qt/customColors/") + QString::number(i)); + if (v.isValid()) + customRgb[i] = v.toUInt(); + } +#endif +} + +void QColorDialogStaticData::writeSettings() const +{ +#ifndef QT_NO_SETTINGS + if (!customSet) { + QSettings settings(QSettings::UserScope, QStringLiteral("Trolltech")); + for (int i = 0; i < int(CustomColorCount); ++i) + settings.setValue(QStringLiteral("Qt/customColors/") + QString::number(i), customRgb[i]); + } +#endif +} + +Q_GLOBAL_STATIC(QColorDialogStaticData, qColorDialogStaticData) + +class QColorDialogOptionsPrivate : public QSharedData +{ +public: + QColorDialogOptionsPrivate() : options(0) {} + // Write out settings around destruction of dialogs + ~QColorDialogOptionsPrivate() { qColorDialogStaticData()->writeSettings(); } + + QColorDialogOptions::ColorDialogOptions options; + QString windowTitle; +}; + +QColorDialogOptions::QColorDialogOptions() : d(new QColorDialogOptionsPrivate) +{ +} + +QColorDialogOptions::QColorDialogOptions(const QColorDialogOptions &rhs) : d(rhs.d) +{ +} + +QColorDialogOptions &QColorDialogOptions::operator=(const QColorDialogOptions &rhs) +{ + if (this != &rhs) + d = rhs.d; + return *this; +} + +QColorDialogOptions::~QColorDialogOptions() +{ +} + +QString QColorDialogOptions::windowTitle() const +{ + return d->windowTitle; +} + +void QColorDialogOptions::setWindowTitle(const QString &title) +{ + d->windowTitle = title; +} + +void QColorDialogOptions::setOption(QColorDialogOptions::ColorDialogOption option, bool on) +{ + if (!(d->options & option) != !on) + setOptions(d->options ^ option); +} + +bool QColorDialogOptions::testOption(QColorDialogOptions::ColorDialogOption option) const +{ + return d->options & option; +} + +void QColorDialogOptions::setOptions(ColorDialogOptions options) +{ + if (options != d->options) + d->options = options; +} + +QColorDialogOptions::ColorDialogOptions QColorDialogOptions::options() const +{ + return d->options; +} + +int QColorDialogOptions::customColorCount() +{ + return QColorDialogStaticData::CustomColorCount; +} + +QRgb QColorDialogOptions::customColor(int index) +{ + if (uint(index) >= uint(QColorDialogStaticData::CustomColorCount)) + return qRgb(255, 255, 255); + return qColorDialogStaticData()->customRgb[index]; +} + +QRgb *QColorDialogOptions::customColors() +{ + return qColorDialogStaticData()->customRgb; +} + +void QColorDialogOptions::setCustomColor(int index, QRgb color) +{ + if (uint(index) >= uint(QColorDialogStaticData::CustomColorCount)) + return; + qColorDialogStaticData()->customSet; + qColorDialogStaticData()->customRgb[index] = color; +} + +QRgb *QColorDialogOptions::standardColors() +{ + return qColorDialogStaticData()->standardRgb; +} + +QRgb QColorDialogOptions::standardColor(int index) +{ + if (uint(index) >= uint(QColorDialogStaticData::StandardColorCount)) + return qRgb(255, 255, 255); + return qColorDialogStaticData()->standardRgb[index]; +} + +void QColorDialogOptions::setStandardColor(int index, QRgb color) +{ + if (uint(index) >= uint(QColorDialogStaticData::StandardColorCount)) + return; + qColorDialogStaticData()->standardRgb[index] = color; +} + +const QSharedPointer<QColorDialogOptions> &QPlatformColorDialogHelper::options() const +{ + return m_options; +} + +void QPlatformColorDialogHelper::setOptions(const QSharedPointer<QColorDialogOptions> &options) +{ + m_options = options; +} + +// File dialog + +class QFileDialogOptionsPrivate : public QSharedData +{ +public: + QFileDialogOptionsPrivate() : options(0), + viewMode(QFileDialogOptions::Detail), + fileMode(QFileDialogOptions::AnyFile), + acceptMode(QFileDialogOptions::AcceptOpen), + filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs) + {} + + QFileDialogOptions::FileDialogOptions options; + QString windowTitle; + + QFileDialogOptions::ViewMode viewMode; + QFileDialogOptions::FileMode fileMode; + QFileDialogOptions::AcceptMode acceptMode; + QString labels[QFileDialogOptions::DialogLabelCount]; + QDir::Filters filters; + QList<QUrl> sidebarUrls; + QStringList nameFilters; + QString defaultSuffix; + QStringList history; + QString initialDirectory; + QString initiallySelectedNameFilter; + QStringList initiallySelectedFiles; +}; + +QFileDialogOptions::QFileDialogOptions() : d(new QFileDialogOptionsPrivate) +{ +} + +QFileDialogOptions::QFileDialogOptions(const QFileDialogOptions &rhs) : d(rhs.d) +{ +} + +QFileDialogOptions &QFileDialogOptions::operator=(const QFileDialogOptions &rhs) +{ + if (this != &rhs) + d = rhs.d; + return *this; +} + +QFileDialogOptions::~QFileDialogOptions() +{ +} + +QString QFileDialogOptions::windowTitle() const +{ + return d->windowTitle; +} + +void QFileDialogOptions::setWindowTitle(const QString &title) +{ + d->windowTitle = title; +} + +void QFileDialogOptions::setOption(QFileDialogOptions::FileDialogOption option, bool on) +{ + if (!(d->options & option) != !on) + setOptions(d->options ^ option); +} + +bool QFileDialogOptions::testOption(QFileDialogOptions::FileDialogOption option) const +{ + return d->options & option; +} + +void QFileDialogOptions::setOptions(FileDialogOptions options) +{ + if (options != d->options) + d->options = options; +} + +QFileDialogOptions::FileDialogOptions QFileDialogOptions::options() const +{ + return d->options; +} + +QDir::Filters QFileDialogOptions::filter() const +{ + return d->filters; +} + +void QFileDialogOptions::setFilter(QDir::Filters filters) +{ + d->filters = filters; +} + +void QFileDialogOptions::setViewMode(QFileDialogOptions::ViewMode mode) +{ + d->viewMode = mode; +} + +QFileDialogOptions::ViewMode QFileDialogOptions::viewMode() const +{ + return d->viewMode; +} + +void QFileDialogOptions::setFileMode(QFileDialogOptions::FileMode mode) +{ + d->fileMode = mode; +} + +QFileDialogOptions::FileMode QFileDialogOptions::fileMode() const +{ + return d->fileMode; +} + +void QFileDialogOptions::setAcceptMode(QFileDialogOptions::AcceptMode mode) +{ + d->acceptMode = mode; +} + +QFileDialogOptions::AcceptMode QFileDialogOptions::acceptMode() const +{ + return d->acceptMode; +} + +void QFileDialogOptions::setSidebarUrls(const QList<QUrl> &urls) +{ + d->sidebarUrls = urls; +} + +QList<QUrl> QFileDialogOptions::sidebarUrls() const +{ + return d->sidebarUrls; +} + +void QFileDialogOptions::setNameFilters(const QStringList &filters) +{ + d->nameFilters = filters; +} + +QStringList QFileDialogOptions::nameFilters() const +{ + return d->nameFilters; +} + +void QFileDialogOptions::setDefaultSuffix(const QString &suffix) +{ + d->defaultSuffix = suffix; +} + +QString QFileDialogOptions::defaultSuffix() const +{ + return d->defaultSuffix; +} + +void QFileDialogOptions::setHistory(const QStringList &paths) +{ + d->history = paths; +} + +QStringList QFileDialogOptions::history() const +{ + return d->history; +} + +void QFileDialogOptions::setLabelText(QFileDialogOptions::DialogLabel label, const QString &text) +{ + if (label >= 0 && label < DialogLabelCount) + d->labels[label] = text; +} + +QString QFileDialogOptions::labelText(QFileDialogOptions::DialogLabel label) const +{ + return (label >= 0 && label < DialogLabelCount) ? d->labels[label] : QString(); +} + +bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label) +{ + return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty(); +} + +QString QFileDialogOptions::initialDirectory() const +{ + return d->initialDirectory; +} + +void QFileDialogOptions::setInitialDirectory(const QString &directory) +{ + d->initialDirectory = directory; +} + +QString QFileDialogOptions::initiallySelectedNameFilter() const +{ + return d->initiallySelectedNameFilter; +} + +void QFileDialogOptions::setInitiallySelectedNameFilter(const QString &filter) +{ + d->initiallySelectedNameFilter = filter; +} + +QStringList QFileDialogOptions::initiallySelectedFiles() const +{ + return d->initiallySelectedFiles; +} + +void QFileDialogOptions::setInitiallySelectedFiles(const QStringList &files) +{ + d->initiallySelectedFiles = files; +} + +const QSharedPointer<QFileDialogOptions> &QPlatformFileDialogHelper::options() const +{ + return m_options; +} + +void QPlatformFileDialogHelper::setOptions(const QSharedPointer<QFileDialogOptions> &options) +{ + m_options = options; +} + QT_END_NAMESPACE diff --git a/src/widgets/kernel/qplatformdialoghelper_qpa.h b/src/widgets/kernel/qplatformdialoghelper_qpa.h index 970de611bc..b0b8b3a5b3 100644 --- a/src/widgets/kernel/qplatformdialoghelper_qpa.h +++ b/src/widgets/kernel/qplatformdialoghelper_qpa.h @@ -1,6 +1,6 @@ /**************************************************************************** ** - ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -42,8 +42,13 @@ #ifndef QPLATFORMDIALOGHELPER_H #define QPLATFORMDIALOGHELPER_H -#include <qglobal.h> -#include <qobject.h> +#include <QtCore/QtGlobal> +#include <QtCore/QObject> +#include <QtCore/QList> +#include <QtCore/QSharedDataPointer> +#include <QtCore/QSharedPointer> +#include <QtCore/QDir> +#include <QtGui/QRgb> QT_BEGIN_HEADER @@ -56,6 +61,10 @@ class QColor; class QFont; class QWindow; class QVariant; +class QUrl; +class QColorDialogOptionsPrivate; +class QFontDialogOptionsPrivate; +class QFileDialogOptionsPrivate; class Q_WIDGETS_EXPORT QPlatformDialogHelper : public QObject { @@ -65,6 +74,11 @@ public: SnapToDefaultButton }; enum DialogCode { Rejected, Accepted }; + enum ShowFlag { + ShowModal = 0x00000001 + }; + + Q_DECLARE_FLAGS(ShowFlags, ShowFlag) QPlatformDialogHelper(); virtual ~QPlatformDialogHelper(); @@ -75,24 +89,104 @@ public: virtual void _q_platformRunNativeAppModalPanel() = 0; virtual void deleteNativeDialog_sys() = 0; - virtual bool show_sys(QWindow *parent) = 0; + virtual bool show_sys(ShowFlags showFlags, + Qt::WindowFlags windowFlags, + QWindow *parent) = 0; virtual void hide_sys() = 0; virtual DialogCode dialogResultCode_sys() = 0; static QVariant defaultStyleHint(QPlatformDialogHelper::StyleHint hint); + +Q_SIGNALS: + void launchNativeAppModalPanel(); + void accept(); + void reject(); + +protected Q_SLOTS: + void emitLaunchNativeAppModalPanel(); +}; + +class Q_WIDGETS_EXPORT QColorDialogOptions +{ +public: + enum ColorDialogOption { + ShowAlphaChannel = 0x00000001, + NoButtons = 0x00000002, + DontUseNativeDialog = 0x00000004 + }; + + Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) + + QColorDialogOptions(); + QColorDialogOptions(const QColorDialogOptions &rhs); + QColorDialogOptions &operator=(const QColorDialogOptions &rhs); + ~QColorDialogOptions(); + + QString windowTitle() const; + void setWindowTitle(const QString &); + + void setOption(ColorDialogOption option, bool on = true); + bool testOption(ColorDialogOption option) const; + void setOptions(ColorDialogOptions options); + ColorDialogOptions options() const; + + static int customColorCount(); + static QRgb customColor(int index); + static QRgb *customColors(); + static void setCustomColor(int index, QRgb color); + + static QRgb *standardColors(); + static QRgb standardColor(int index); + static void setStandardColor(int index, QRgb color); + +private: + QSharedDataPointer<QColorDialogOptionsPrivate> d; }; class Q_WIDGETS_EXPORT QPlatformColorDialogHelper : public QPlatformDialogHelper { Q_OBJECT public: + const QSharedPointer<QColorDialogOptions> &options() const; + void setOptions(const QSharedPointer<QColorDialogOptions> &options); + virtual void setCurrentColor_sys(const QColor &) = 0; virtual QColor currentColor_sys() const = 0; Q_SIGNALS: void currentColorChanged(const QColor &color); void colorSelected(const QColor &color); + +private: + QSharedPointer<QColorDialogOptions> m_options; +}; + +class Q_WIDGETS_EXPORT QFontDialogOptions +{ +public: + enum FontDialogOption { + NoButtons = 0x00000001, + DontUseNativeDialog = 0x00000002 + }; + + Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) + + QFontDialogOptions(); + QFontDialogOptions(const QFontDialogOptions &rhs); + QFontDialogOptions &operator=(const QFontDialogOptions &rhs); + ~QFontDialogOptions(); + + QString windowTitle() const; + void setWindowTitle(const QString &); + + void setOption(FontDialogOption option, bool on = true); + bool testOption(FontDialogOption option) const; + void setOptions(FontDialogOptions options); + FontDialogOptions options() const; + +private: + QSharedDataPointer<QFontDialogOptionsPrivate> d; }; class Q_WIDGETS_EXPORT QPlatformFontDialogHelper : public QPlatformDialogHelper @@ -102,9 +196,89 @@ public: virtual void setCurrentFont_sys(const QFont &) = 0; virtual QFont currentFont_sys() const = 0; + const QSharedPointer<QFontDialogOptions> &options() const; + void setOptions(const QSharedPointer<QFontDialogOptions> &options); + Q_SIGNALS: void currentFontChanged(const QFont &font); void fontSelected(const QFont &font); + +private: + QSharedPointer<QFontDialogOptions> m_options; +}; + +class Q_WIDGETS_EXPORT QFileDialogOptions +{ +public: + enum ViewMode { Detail, List }; + enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly }; + enum AcceptMode { AcceptOpen, AcceptSave }; + enum DialogLabel { LookIn, FileName, FileType, Accept, Reject, DialogLabelCount }; + + enum FileDialogOption + { + ShowDirsOnly = 0x00000001, + DontResolveSymlinks = 0x00000002, + DontConfirmOverwrite = 0x00000004, + DontUseSheet = 0x00000008, + DontUseNativeDialog = 0x00000010, + ReadOnly = 0x00000020, + HideNameFilterDetails = 0x00000040 + }; + Q_DECLARE_FLAGS(FileDialogOptions, FileDialogOption) + + QFileDialogOptions(); + QFileDialogOptions(const QFileDialogOptions &rhs); + QFileDialogOptions &operator=(const QFileDialogOptions &rhs); + ~QFileDialogOptions(); + + QString windowTitle() const; + void setWindowTitle(const QString &); + + void setOption(FileDialogOption option, bool on = true); + bool testOption(FileDialogOption option) const; + void setOptions(FileDialogOptions options); + FileDialogOptions options() const; + + QDir::Filters filter() const; + void setFilter(QDir::Filters filters); + + void setViewMode(ViewMode mode); + ViewMode viewMode() const; + + void setFileMode(FileMode mode); + FileMode fileMode() const; + + void setAcceptMode(AcceptMode mode); + AcceptMode acceptMode() const; + + void setSidebarUrls(const QList<QUrl> &urls); + QList<QUrl> sidebarUrls() const; + + void setNameFilters(const QStringList &filters); + QStringList nameFilters() const; + + void setDefaultSuffix(const QString &suffix); + QString defaultSuffix() const; + + void setHistory(const QStringList &paths); + QStringList history() const; + + void setLabelText(DialogLabel label, const QString &text); + QString labelText(DialogLabel label) const; + bool isLabelExplicitlySet(DialogLabel label); + + QString initialDirectory() const; + void setInitialDirectory(const QString &); + + QString initiallySelectedNameFilter() const; + void setInitiallySelectedNameFilter(const QString &); + + QStringList initiallySelectedFiles() const; + void setInitiallySelectedFiles(const QStringList &); + +private: + QSharedDataPointer<QFileDialogOptionsPrivate> d; }; class Q_WIDGETS_EXPORT QPlatformFileDialogHelper : public QPlatformDialogHelper @@ -117,16 +291,21 @@ public: virtual void selectFile_sys(const QString &filename) = 0; virtual QStringList selectedFiles_sys() const = 0; virtual void setFilter_sys() = 0; - virtual void setNameFilters_sys(const QStringList &filters) = 0; virtual void selectNameFilter_sys(const QString &filter) = 0; virtual QString selectedNameFilter_sys() const = 0; + const QSharedPointer<QFileDialogOptions> &options() const; + void setOptions(const QSharedPointer<QFileDialogOptions> &options); + Q_SIGNALS: void fileSelected(const QString &file); void filesSelected(const QStringList &files); void currentChanged(const QString &path); void directoryEntered(const QString &directory); void filterSelected(const QString &filter); + +private: + QSharedPointer<QFileDialogOptions> m_options; }; QT_END_NAMESPACE diff --git a/src/widgets/kernel/qplatformmenu_qpa.cpp b/src/widgets/kernel/qplatformmenu_qpa.cpp index fd5cc78bf0..2a11884a67 100644 --- a/src/widgets/kernel/qplatformmenu_qpa.cpp +++ b/src/widgets/kernel/qplatformmenu_qpa.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qplatformmenu_qpa.h b/src/widgets/kernel/qplatformmenu_qpa.h index d2736ed354..b6473c0b15 100644 --- a/src/widgets/kernel/qplatformmenu_qpa.h +++ b/src/widgets/kernel/qplatformmenu_qpa.h @@ -1,6 +1,6 @@ /**************************************************************************** ** - ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index 94f809d199..cb2d08956b 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -521,9 +521,9 @@ void QShortcut::setContext(Qt::ShortcutContext context) d->redoGrab(qApp->d_func()->shortcutMap); } -Qt::ShortcutContext QShortcut::context() +Qt::ShortcutContext QShortcut::context() const { - Q_D(QShortcut); + Q_D(const QShortcut); return d->sc_context; } diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h index 6e3c647852..077028ccd3 100644 --- a/src/widgets/kernel/qshortcut.h +++ b/src/widgets/kernel/qshortcut.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -77,7 +77,7 @@ public: bool isEnabled() const; void setContext(Qt::ShortcutContext context); - Qt::ShortcutContext context(); + Qt::ShortcutContext context() const; void setWhatsThis(const QString &text); QString whatsThis() const; diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 826991ceb3..8932eb8ed8 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -181,6 +181,10 @@ Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &); Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); #endif +#ifndef QT_NO_DEBUG_STREAM +Q_WIDGETS_EXPORT QDebug operator<<(QDebug dbg, const QSizePolicy &); +#endif + inline void QSizePolicy::transpose() { Policy hData = horizontalPolicy(); Policy vData = verticalPolicy(); diff --git a/src/widgets/kernel/qsizepolicy.qdoc b/src/widgets/kernel/qsizepolicy.qdoc index e4d1cc137c..a0e565caff 100644 --- a/src/widgets/kernel/qsizepolicy.qdoc +++ b/src/widgets/kernel/qsizepolicy.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qsoftkeymanager.cpp b/src/widgets/kernel/qsoftkeymanager.cpp index 7d7c56fe84..a7c128337f 100644 --- a/src/widgets/kernel/qsoftkeymanager.cpp +++ b/src/widgets/kernel/qsoftkeymanager.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qsoftkeymanager_common_p.h b/src/widgets/kernel/qsoftkeymanager_common_p.h index fc484dc3c6..121d4f8e22 100644 --- a/src/widgets/kernel/qsoftkeymanager_common_p.h +++ b/src/widgets/kernel/qsoftkeymanager_common_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qsoftkeymanager_p.h b/src/widgets/kernel/qsoftkeymanager_p.h index d58b546d74..ad49a1b586 100644 --- a/src/widgets/kernel/qsoftkeymanager_p.h +++ b/src/widgets/kernel/qsoftkeymanager_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp index 950db2178c..7179ddc62c 100644 --- a/src/widgets/kernel/qstackedlayout.cpp +++ b/src/widgets/kernel/qstackedlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qstackedlayout.h b/src/widgets/kernel/qstackedlayout.h index d895d139ab..e80e909eae 100644 --- a/src/widgets/kernel/qstackedlayout.h +++ b/src/widgets/kernel/qstackedlayout.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp index a557342023..3a9bd2bc38 100644 --- a/src/widgets/kernel/qstandardgestures.cpp +++ b/src/widgets/kernel/qstandardgestures.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qstandardgestures_p.h b/src/widgets/kernel/qstandardgestures_p.h index be30d70058..28b0b71797 100644 --- a/src/widgets/kernel/qstandardgestures_p.h +++ b/src/widgets/kernel/qstandardgestures_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qt_widgets_pch.h b/src/widgets/kernel/qt_widgets_pch.h index 012d92ce8c..8e8985d21f 100644 --- a/src/widgets/kernel/qt_widgets_pch.h +++ b/src/widgets/kernel/qt_widgets_pch.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index fb1b67922d..fc0efc3dc2 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qtooltip.h b/src/widgets/kernel/qtooltip.h index 3d537f40af..8218a18338 100644 --- a/src/widgets/kernel/qtooltip.h +++ b/src/widgets/kernel/qtooltip.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 7a53dc3415..e1a1cd05ef 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -43,6 +43,7 @@ #ifndef QT_NO_WHATSTHIS #include "qpointer.h" #include "qapplication.h" +#include <private/qguiapplication_p.h> #include "qdesktopwidget.h" #include "qevent.h" #include "qpixmap.h" @@ -59,12 +60,6 @@ #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif -#if defined(Q_WS_WIN) -#include "qt_windows.h" -#ifndef SPI_GETDROPSHADOW -#define SPI_GETDROPSHADOW 0x1024 -#endif -#endif QT_BEGIN_NAMESPACE @@ -221,15 +216,9 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor + Qt::TextWordWrap + Qt::TextExpandTabs, text); } -#if defined(Q_WS_WIN) - if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP - && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) - { - BOOL shadow; - SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0); - shadowWidth = shadow ? 0 : 6; - } -#endif + shadowWidth = + QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::DropShadow).toBool() ? + 0 : 6; resize(r.width() + 2*hMargin + shadowWidth, r.height() + 2*vMargin + shadowWidth); } diff --git a/src/widgets/kernel/qwhatsthis.h b/src/widgets/kernel/qwhatsthis.h index 9ef96e7197..93e97ddff8 100644 --- a/src/widgets/kernel/qwhatsthis.h +++ b/src/widgets/kernel/qwhatsthis.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 7ec37bb929..531a217b1d 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -1469,10 +1469,6 @@ QWidget::~QWidget() delete d->needsFlush; d->needsFlush = 0; - // set all QPointers for this object to zero - if (d->hasGuards) - QObjectPrivate::clearGuards(this); - if (d->declarativeData) { QAbstractDeclarativeData::destroyed(d->declarativeData, this); d->declarativeData = 0; // don't activate again in ~QObject @@ -6559,6 +6555,9 @@ QByteArray QWidget::saveGeometry() const #ifdef Q_WS_MAC << newFramePosition << newNormalPosition +#else + << frameGeometry() + << normalGeometry() #endif // Q_WS_MAC << qint32(QApplication::desktop()->screenNumber(this)) << quint8(windowState() & Qt::WindowMaximized) @@ -8188,26 +8187,6 @@ bool QWidget::event(QEvent *event) event->ignore(); break; #endif -#ifndef QT_NO_ACCESSIBILITY - case QEvent::AccessibilityDescription: - case QEvent::AccessibilityHelp: { - QAccessibleEvent *ev = static_cast<QAccessibleEvent *>(event); - switch (ev->type()) { -#ifndef QT_NO_TOOLTIP - case QEvent::AccessibilityDescription: - ev->setValue(d->toolTip); - break; -#endif -#ifndef QT_NO_WHATSTHIS - case QEvent::AccessibilityHelp: - ev->setValue(d->whatsThis); - break; -#endif - default: - return false; - } - break; } -#endif case QEvent::EmbeddingControl: d->topData()->frameStrut.setCoords(0 ,0, 0, 0); data->fstrut_dirty = false; @@ -8248,40 +8227,7 @@ bool QWidget::event(QEvent *event) case QEvent::TouchUpdate: case QEvent::TouchEnd: { -#ifndef Q_WS_MAC - QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); - const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first(); - if (touchPoint.isPrimary() || touchEvent->device()->type() == QTouchDevice::TouchPad) - break; - - // fake a mouse event! - QEvent::Type eventType = QEvent::None; - switch (touchEvent->type()) { - case QEvent::TouchBegin: - eventType = QEvent::MouseButtonPress; - break; - case QEvent::TouchUpdate: - eventType = QEvent::MouseMove; - break; - case QEvent::TouchEnd: - eventType = QEvent::MouseButtonRelease; - break; - default: - Q_ASSERT(!true); - break; - } - if (eventType == QEvent::None) - break; - - QMouseEvent mouseEvent(eventType, - touchPoint.pos(), - touchPoint.scenePos(), - touchPoint.screenPos(), - Qt::LeftButton, - Qt::LeftButton, - touchEvent->modifiers()); - (void) QApplication::sendEvent(this, &mouseEvent); -#endif // Q_WS_MAC + event->ignore(); break; } #ifndef QT_NO_GESTURES @@ -10317,45 +10263,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) d->registerTouchWindow(); #endif break; - case Qt::WA_LockPortraitOrientation: - case Qt::WA_LockLandscapeOrientation: - case Qt::WA_AutoOrientation: { - const Qt::WidgetAttribute orientations[3] = { - Qt::WA_LockPortraitOrientation, - Qt::WA_LockLandscapeOrientation, - Qt::WA_AutoOrientation - }; - - if (on) { - // We can only have one of these set at a time - for (int i = 0; i < 3; ++i) { - if (orientations[i] != attribute) - setAttribute_internal(orientations[i], false, data, d); - } - } - -#ifdef Q_WS_S60 - CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>(CEikonEnv::Static()->EikAppUi()); - const CAknAppUiBase::TAppUiOrientation s60orientations[] = { - CAknAppUiBase::EAppUiOrientationPortrait, - CAknAppUiBase::EAppUiOrientationLandscape, - CAknAppUiBase::EAppUiOrientationAutomatic - }; - CAknAppUiBase::TAppUiOrientation s60orientation = CAknAppUiBase::EAppUiOrientationUnspecified; - for (int i = 0; i < 3; ++i) { - if (testAttribute(orientations[i])) { - s60orientation = s60orientations[i]; - break; - } - } - QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation)); - S60->orientationSet = true; - QSymbianControl *window = static_cast<QSymbianControl *>(internalWinId()); - if (window) - window->ensureFixNativeOrientation(); -#endif - break; - } default: break; } @@ -10834,337 +10741,6 @@ void QWidget::stackUnder(QWidget* w) QApplication::sendEvent(this, &e); } -/*! - \enum QWidget::BackgroundOrigin - - \compat - - \value WidgetOrigin - \value ParentOrigin - \value WindowOrigin - \value AncestorOrigin - -*/ - -/*! - \fn bool QWidget::isVisibleToTLW() const - - Use isVisible() instead. -*/ - -/*! - \fn void QWidget::iconify() - - Use showMinimized() instead. -*/ - -/*! - \fn void QWidget::constPolish() const - - Use ensurePolished() instead. -*/ - -/*! - \fn void QWidget::reparent(QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt) - - Use setParent() to change the parent or the widget's widget flags; - use move() to move the widget, and use show() to show the widget. -*/ - -/*! - \fn void QWidget::reparent(QWidget *parent, const QPoint &p, bool showIt) - - Use setParent() to change the parent; use move() to move the - widget, and use show() to show the widget. -*/ - -/*! - \fn void QWidget::recreate(QWidget *parent, Qt::WindowFlags f, const QPoint & p, bool showIt) - - Use setParent() to change the parent or the widget's widget flags; - use move() to move the widget, and use show() to show the widget. -*/ - -/*! - \fn bool QWidget::hasMouse() const - - Use testAttribute(Qt::WA_UnderMouse) instead. -*/ - -/*! - \fn bool QWidget::ownCursor() const - - Use testAttribute(Qt::WA_SetCursor) instead. -*/ - -/*! - \fn bool QWidget::ownFont() const - - Use testAttribute(Qt::WA_SetFont) instead. -*/ - -/*! - \fn void QWidget::unsetFont() - - Use setFont(QFont()) instead. -*/ - -/*! - \fn bool QWidget::ownPalette() const - - Use testAttribute(Qt::WA_SetPalette) instead. -*/ - -/*! - \fn void QWidget::unsetPalette() - - Use setPalette(QPalette()) instead. -*/ - -/*! - \fn void QWidget::setEraseColor(const QColor &color) - - Use the palette instead. - - \oldcode - widget->setEraseColor(color); - \newcode - QPalette palette; - palette.setColor(widget->backgroundRole(), color); - widget->setPalette(palette); - \endcode -*/ - -/*! - \fn void QWidget::setErasePixmap(const QPixmap &pixmap) - - Use the palette instead. - - \oldcode - widget->setErasePixmap(pixmap); - \newcode - QPalette palette; - palette.setBrush(widget->backgroundRole(), QBrush(pixmap)); - widget->setPalette(palette); - \endcode -*/ - -/*! - \fn void QWidget::setPaletteForegroundColor(const QColor &color) - - Use the palette directly. - - \oldcode - widget->setPaletteForegroundColor(color); - \newcode - QPalette palette; - palette.setColor(widget->foregroundRole(), color); - widget->setPalette(palette); - \endcode -*/ - -/*! - \fn void QWidget::setPaletteBackgroundColor(const QColor &color) - - Use the palette directly. - - \oldcode - widget->setPaletteBackgroundColor(color); - \newcode - QPalette palette; - palette.setColor(widget->backgroundRole(), color); - widget->setPalette(palette); - \endcode -*/ - -/*! - \fn void QWidget::setPaletteBackgroundPixmap(const QPixmap &pixmap) - - Use the palette directly. - - \oldcode - widget->setPaletteBackgroundPixmap(pixmap); - \newcode - QPalette palette; - palette.setBrush(widget->backgroundRole(), QBrush(pixmap)); - widget->setPalette(palette); - \endcode -*/ - -/*! - \fn void QWidget::setBackgroundPixmap(const QPixmap &pixmap) - - Use the palette instead. - - \oldcode - widget->setBackgroundPixmap(pixmap); - \newcode - QPalette palette; - palette.setBrush(widget->backgroundRole(), QBrush(pixmap)); - widget->setPalette(palette); - \endcode -*/ - -/*! - \fn void QWidget::setBackgroundColor(const QColor &color) - - Use the palette instead. - - \oldcode - widget->setBackgroundColor(color); - \newcode - QPalette palette; - palette.setColor(widget->backgroundRole(), color); - widget->setPalette(palette); - \endcode -*/ - - -/*! - \fn QWidget *QWidget::parentWidget(bool sameWindow) const - - Use the no-argument overload instead. -*/ - -/*! - \fn void QWidget::setKeyCompression(bool b) - - Use setAttribute(Qt::WA_KeyCompression, b) instead. -*/ - -/*! - \fn void QWidget::setFont(const QFont &f, bool b) - - Use the single-argument overload instead. -*/ - -/*! - \fn void QWidget::setPalette(const QPalette &p, bool b) - - Use the single-argument overload instead. -*/ - -/*! - \fn void QWidget::setBackgroundOrigin(BackgroundOrigin background) - - \obsolete -*/ - -/*! - \fn BackgroundOrigin QWidget::backgroundOrigin() const - - \obsolete - - Always returns \c WindowOrigin. -*/ - -/*! - \fn QPoint QWidget::backgroundOffset() const - - \obsolete - - Always returns QPoint(). -*/ - -/*! - \fn void QWidget::repaint(bool b) - - The boolean parameter \a b is ignored. Use the no-argument overload instead. -*/ - -/*! - \fn void QWidget::repaint(int x, int y, int w, int h, bool b) - - The boolean parameter \a b is ignored. Use the four-argument overload instead. -*/ - -/*! - \fn void QWidget::repaint(const QRect &r, bool b) - - The boolean parameter \a b is ignored. Use the single rect-argument overload instead. -*/ - -/*! - \fn void QWidget::repaint(const QRegion &rgn, bool b) - - The boolean parameter \a b is ignored. Use the single region-argument overload instead. -*/ - -/*! - \fn void QWidget::erase() - - Drawing may only take place in a QPaintEvent. Overload - paintEvent() to do your erasing and call update() to schedule a - replaint whenever necessary. See also QPainter. -*/ - -/*! - \fn void QWidget::erase(int x, int y, int w, int h) - - Drawing may only take place in a QPaintEvent. Overload - paintEvent() to do your erasing and call update() to schedule a - replaint whenever necessary. See also QPainter. -*/ - -/*! - \fn void QWidget::erase(const QRect &rect) - - Drawing may only take place in a QPaintEvent. Overload - paintEvent() to do your erasing and call update() to schedule a - replaint whenever necessary. See also QPainter. -*/ - -/*! - \fn void QWidget::drawText(const QPoint &p, const QString &s) - - Drawing may only take place in a QPaintEvent. Overload - paintEvent() to do your drawing and call update() to schedule a - replaint whenever necessary. See also QPainter. -*/ - -/*! - \fn void QWidget::drawText(int x, int y, const QString &s) - - Drawing may only take place in a QPaintEvent. Overload - paintEvent() to do your drawing and call update() to schedule a - replaint whenever necessary. See also QPainter. -*/ - -/*! - \fn QWidget *QWidget::childAt(const QPoint &p, bool includeThis) const - - Use the single point argument overload instead. -*/ - -/*! - \fn void QWidget::setCaption(const QString &c) - - Use setWindowTitle() instead. -*/ - -/*! - \fn void QWidget::setIcon(const QPixmap &i) - - Use setWindowIcon() instead. -*/ - -/*! - \fn void QWidget::setIconText(const QString &it) - - Use setWindowIconText() instead. -*/ - -/*! - \fn QString QWidget::caption() const - - Use windowTitle() instead. -*/ - -/*! - \fn QString QWidget::iconText() const - - Use windowIconText() instead. -*/ /*! \fn bool QWidget::isTopLevel() const @@ -11184,84 +10760,6 @@ void QWidget::stackUnder(QWidget* w) */ /*! - \fn void QWidget::setInputMethodEnabled(bool enabled) - - Use setAttribute(Qt::WA_InputMethodEnabled, \a enabled) instead. -*/ - -/*! - \fn bool QWidget::isInputMethodEnabled() const - - Use testAttribute(Qt::WA_InputMethodEnabled) instead. -*/ - -/*! - \fn void QWidget::setActiveWindow() - - Use activateWindow() instead. -*/ - -/*! - \fn bool QWidget::isShown() const - - Use !isHidden() instead (notice the exclamation mark), or use isVisible() to check whether the widget is visible. -*/ - -/*! - \fn bool QWidget::isDialog() const - - Use windowType() == Qt::Dialog instead. -*/ - -/*! - \fn bool QWidget::isPopup() const - - Use windowType() == Qt::Popup instead. -*/ - -/*! - \fn bool QWidget::isDesktop() const - - Use windowType() == Qt::Desktop instead. -*/ - -/*! - \fn void QWidget::polish() - - Use ensurePolished() instead. -*/ - -/*! - \fn QWidget *QWidget::childAt(int x, int y, bool includeThis) const - - Use the childAt() overload that doesn't have an \a includeThis parameter. - - \oldcode - return widget->childAt(x, y, true); - \newcode - QWidget *child = widget->childAt(x, y, true); - if (child) - return child; - if (widget->rect().contains(x, y)) - return widget; - \endcode -*/ - -/*! - \fn void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw) - \compat - - Use the \l sizePolicy property and heightForWidth() function instead. -*/ - -/*! - \fn bool QWidget::isUpdatesEnabled() const - \compat - - Use the \l updatesEnabled property instead. -*/ - -/*! \macro QWIDGETSIZE_MAX \relates QWidget diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index f97b343463..60d4b8b698 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -746,16 +746,8 @@ private: #endif // QT_NO_GESTURES friend class QWidgetEffectSourcePrivate; -#ifdef Q_WS_MAC - friend class QCoreGraphicsPaintEnginePrivate; - friend QPoint qt_mac_posInWindow(const QWidget *w); - friend OSWindowRef qt_mac_window_for(const QWidget *w); +#ifdef Q_OS_MAC friend bool qt_mac_is_metal(const QWidget *w); - friend OSViewRef qt_mac_nativeview_for(const QWidget *w); - friend void qt_event_request_window_change(QWidget *widget); - friend bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref); - friend class QRasterWindowSurface; - friend class QUnifiedToolbarSurface; #endif friend Q_WIDGETS_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget); friend Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index c890dfe70c..43c3eaeff0 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index f1e0835b8b..fb4543cd14 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwidgetaction.cpp b/src/widgets/kernel/qwidgetaction.cpp index a2c2477922..caab1c16e6 100644 --- a/src/widgets/kernel/qwidgetaction.cpp +++ b/src/widgets/kernel/qwidgetaction.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwidgetaction.h b/src/widgets/kernel/qwidgetaction.h index 31d58a819a..62ef05596b 100644 --- a/src/widgets/kernel/qwidgetaction.h +++ b/src/widgets/kernel/qwidgetaction.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwidgetaction_p.h b/src/widgets/kernel/qwidgetaction_p.h index 99439d9919..ff8a37425c 100644 --- a/src/widgets/kernel/qwidgetaction_p.h +++ b/src/widgets/kernel/qwidgetaction_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index d151d5e9e1..0eb9407925 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index 4d43a90322..2d28cae88e 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index 18fec508ea..f2ca99d040 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE - +namespace { static void construct(QVariant::Private *x, const void *copy) { switch (x->type) { @@ -97,10 +97,8 @@ static bool isNull(const QVariant::Private *d) case QVariant::Icon: return v_cast<QIcon>(d)->isNull(); #endif - default: - Q_ASSERT(false); } - return true; + return false; } static bool compare(const QVariant::Private *a, const QVariant::Private *b) @@ -119,6 +117,34 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b) return false; } +static bool convert(const QVariant::Private *d, QVariant::Type type, void *result, bool *ok) +{ + Q_UNUSED(d); + Q_UNUSED(type); + Q_UNUSED(result); + if (ok) + *ok = false; + return false; +} + +#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +static void streamDebug(QDebug dbg, const QVariant &v) +{ + QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr()); + switch (d->type) { +#ifndef QT_NO_ICON + case QVariant::Icon: + dbg.nospace() << *v_cast<QIcon>(d); + break; +#endif + case QVariant::SizePolicy: + dbg.nospace() << *v_cast<QSizePolicy>(d); + break; + default: + dbg.nospace() << "QVariant::Type(" << d->type << ")"; + } +} +#endif static const QVariant::Handler widgets_handler = { construct, @@ -129,19 +155,17 @@ static const QVariant::Handler widgets_handler = { 0, #endif compare, - 0, + convert, 0, #if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) - 0 + streamDebug #else 0 #endif }; -extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper; - #define QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES(MetaTypeName, MetaTypeId, RealName) \ - QMetaTypeInterface(static_cast<RealName*>(0)), + QT_METATYPE_INTERFACE_INIT(RealName), static const QMetaTypeInterface qVariantWidgetsHelper[] = { QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES) @@ -149,18 +173,20 @@ static const QMetaTypeInterface qVariantWidgetsHelper[] = { #undef QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES -extern Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler; +} // namespace + +extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper; void qRegisterWidgetsVariant() { - qt_widgets_variant_handler = &widgets_handler; qMetaTypeWidgetsHelper = qVariantWidgetsHelper; + QVariantPrivate::registerHandler(QModulesPrivate::Widgets, &widgets_handler); } Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant) void qUnregisterWidgetsVariant() { - qt_widgets_variant_handler = 0; + QVariantPrivate::unregisterHandler(QModulesPrivate::Widgets); qMetaTypeWidgetsHelper = 0; } Q_DESTRUCTOR_FUNCTION(qUnregisterWidgetsVariant) diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index e3178db8c9..b89dca7357 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/kernel/qwidgetwindow_qpa_p.h b/src/widgets/kernel/qwidgetwindow_qpa_p.h index 906b96c47b..82448ab5fd 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa_p.h +++ b/src/widgets/kernel/qwidgetwindow_qpa_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qapplication_mac.mm b/src/widgets/platforms/mac/qapplication_mac.mm index cab207e667..13fb6fd624 100644 --- a/src/widgets/platforms/mac/qapplication_mac.mm +++ b/src/widgets/platforms/mac/qapplication_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qclipboard_mac.cpp b/src/widgets/platforms/mac/qclipboard_mac.cpp index b8a4d2915d..3ec4bfb8c1 100644 --- a/src/widgets/platforms/mac/qclipboard_mac.cpp +++ b/src/widgets/platforms/mac/qclipboard_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoaintrospection_mac.mm b/src/widgets/platforms/mac/qcocoaintrospection_mac.mm index 7388f5a4e9..e68aacb4a0 100644 --- a/src/widgets/platforms/mac/qcocoaintrospection_mac.mm +++ b/src/widgets/platforms/mac/qcocoaintrospection_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoaintrospection_p.h b/src/widgets/platforms/mac/qcocoaintrospection_p.h index e18646d063..9521957382 100644 --- a/src/widgets/platforms/mac/qcocoaintrospection_p.h +++ b/src/widgets/platforms/mac/qcocoaintrospection_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoapanel_mac.mm b/src/widgets/platforms/mac/qcocoapanel_mac.mm index 2dca64d5ff..115f78b153 100644 --- a/src/widgets/platforms/mac/qcocoapanel_mac.mm +++ b/src/widgets/platforms/mac/qcocoapanel_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoapanel_mac_p.h b/src/widgets/platforms/mac/qcocoapanel_mac_p.h index 43282be7c6..19eab92dbf 100644 --- a/src/widgets/platforms/mac/qcocoapanel_mac_p.h +++ b/src/widgets/platforms/mac/qcocoapanel_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h b/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h index f5a93d98d2..edafcfccdf 100644 --- a/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h +++ b/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoaview_mac.mm b/src/widgets/platforms/mac/qcocoaview_mac.mm index 61a5ee10ff..f4b2b8d707 100644 --- a/src/widgets/platforms/mac/qcocoaview_mac.mm +++ b/src/widgets/platforms/mac/qcocoaview_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoaview_mac_p.h b/src/widgets/platforms/mac/qcocoaview_mac_p.h index 928e489abe..e534e7ab47 100644 --- a/src/widgets/platforms/mac/qcocoaview_mac_p.h +++ b/src/widgets/platforms/mac/qcocoaview_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoawindow_mac.mm b/src/widgets/platforms/mac/qcocoawindow_mac.mm index 730504f672..918e5a0a13 100644 --- a/src/widgets/platforms/mac/qcocoawindow_mac.mm +++ b/src/widgets/platforms/mac/qcocoawindow_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoawindow_mac_p.h b/src/widgets/platforms/mac/qcocoawindow_mac_p.h index 704e6bd01c..83ecb7c13e 100644 --- a/src/widgets/platforms/mac/qcocoawindow_mac_p.h +++ b/src/widgets/platforms/mac/qcocoawindow_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac.mm b/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac.mm index 9e3b4cfee7..f1b38148be 100644 --- a/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac.mm +++ b/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac_p.h b/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac_p.h index 7ac8a28539..cd497849a7 100644 --- a/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac_p.h +++ b/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoawindowdelegate_mac.mm b/src/widgets/platforms/mac/qcocoawindowdelegate_mac.mm index 44fb9b6eba..fc89821f41 100644 --- a/src/widgets/platforms/mac/qcocoawindowdelegate_mac.mm +++ b/src/widgets/platforms/mac/qcocoawindowdelegate_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcocoawindowdelegate_mac_p.h b/src/widgets/platforms/mac/qcocoawindowdelegate_mac_p.h index 261d1d192a..27906e116c 100644 --- a/src/widgets/platforms/mac/qcocoawindowdelegate_mac_p.h +++ b/src/widgets/platforms/mac/qcocoawindowdelegate_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qcolormap_mac.cpp b/src/widgets/platforms/mac/qcolormap_mac.cpp index 0c3fd70468..de920d7144 100644 --- a/src/widgets/platforms/mac/qcolormap_mac.cpp +++ b/src/widgets/platforms/mac/qcolormap_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qdesktopwidget_mac.mm b/src/widgets/platforms/mac/qdesktopwidget_mac.mm index 0bf213303e..9869eeeab2 100644 --- a/src/widgets/platforms/mac/qdesktopwidget_mac.mm +++ b/src/widgets/platforms/mac/qdesktopwidget_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qdesktopwidget_mac_p.h b/src/widgets/platforms/mac/qdesktopwidget_mac_p.h index e1ca7e7a37..a2d7552120 100644 --- a/src/widgets/platforms/mac/qdesktopwidget_mac_p.h +++ b/src/widgets/platforms/mac/qdesktopwidget_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qdnd_mac.mm b/src/widgets/platforms/mac/qdnd_mac.mm index 73acb93f0b..b5543024c0 100644 --- a/src/widgets/platforms/mac/qdnd_mac.mm +++ b/src/widgets/platforms/mac/qdnd_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qeventdispatcher_mac.mm b/src/widgets/platforms/mac/qeventdispatcher_mac.mm index 2a5227c19f..0056ebeca8 100644 --- a/src/widgets/platforms/mac/qeventdispatcher_mac.mm +++ b/src/widgets/platforms/mac/qeventdispatcher_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qeventdispatcher_mac_p.h b/src/widgets/platforms/mac/qeventdispatcher_mac_p.h index 241adf2fce..57797b070b 100644 --- a/src/widgets/platforms/mac/qeventdispatcher_mac_p.h +++ b/src/widgets/platforms/mac/qeventdispatcher_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qkeymapper_mac.cpp b/src/widgets/platforms/mac/qkeymapper_mac.cpp index df18511b4f..3cacb098aa 100644 --- a/src/widgets/platforms/mac/qkeymapper_mac.cpp +++ b/src/widgets/platforms/mac/qkeymapper_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qmacdefines_mac.h b/src/widgets/platforms/mac/qmacdefines_mac.h index d0accf872f..9f27dfa584 100644 --- a/src/widgets/platforms/mac/qmacdefines_mac.h +++ b/src/widgets/platforms/mac/qmacdefines_mac.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qmacgesturerecognizer_mac.mm b/src/widgets/platforms/mac/qmacgesturerecognizer_mac.mm index 6e77f41d2d..54823aa04f 100644 --- a/src/widgets/platforms/mac/qmacgesturerecognizer_mac.mm +++ b/src/widgets/platforms/mac/qmacgesturerecognizer_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qmacgesturerecognizer_mac_p.h b/src/widgets/platforms/mac/qmacgesturerecognizer_mac_p.h index 8d1bd337d7..c77ead3c21 100644 --- a/src/widgets/platforms/mac/qmacgesturerecognizer_mac_p.h +++ b/src/widgets/platforms/mac/qmacgesturerecognizer_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qmacinputcontext_mac.cpp b/src/widgets/platforms/mac/qmacinputcontext_mac.cpp index 43da4a911f..ee0bf70427 100644 --- a/src/widgets/platforms/mac/qmacinputcontext_mac.cpp +++ b/src/widgets/platforms/mac/qmacinputcontext_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qmacinputcontext_p.h b/src/widgets/platforms/mac/qmacinputcontext_p.h index 4fb3eb57b6..7a7ef9687b 100644 --- a/src/widgets/platforms/mac/qmacinputcontext_p.h +++ b/src/widgets/platforms/mac/qmacinputcontext_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qmime_mac.cpp b/src/widgets/platforms/mac/qmime_mac.cpp index a9843b7e87..730f672ecd 100644 --- a/src/widgets/platforms/mac/qmime_mac.cpp +++ b/src/widgets/platforms/mac/qmime_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qnsframeview_mac_p.h b/src/widgets/platforms/mac/qnsframeview_mac_p.h index 72245c1782..1534ad1461 100644 --- a/src/widgets/platforms/mac/qnsframeview_mac_p.h +++ b/src/widgets/platforms/mac/qnsframeview_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qnsthemeframe_mac_p.h b/src/widgets/platforms/mac/qnsthemeframe_mac_p.h index a1fa4ef1d8..1768ad8687 100644 --- a/src/widgets/platforms/mac/qnsthemeframe_mac_p.h +++ b/src/widgets/platforms/mac/qnsthemeframe_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qnstitledframe_mac_p.h b/src/widgets/platforms/mac/qnstitledframe_mac_p.h index 18a6155925..531b943646 100644 --- a/src/widgets/platforms/mac/qnstitledframe_mac_p.h +++ b/src/widgets/platforms/mac/qnstitledframe_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qpaintdevice_mac.cpp b/src/widgets/platforms/mac/qpaintdevice_mac.cpp index 50bd4b8490..01f4a18bf6 100644 --- a/src/widgets/platforms/mac/qpaintdevice_mac.cpp +++ b/src/widgets/platforms/mac/qpaintdevice_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -100,53 +100,4 @@ Q_WIDGETS_EXPORT GrafPtr qt_mac_qd_context(const QPaintDevice *device) extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *pdev); -/*! \internal - - Returns the CoreGraphics CGContextRef of the paint device. 0 is - returned if it can't be obtained. It is the caller's responsiblity to - CGContextRelease the context when finished using it. - - \warning This function is only available on Mac OS X. -*/ - -Q_WIDGETS_EXPORT CGContextRef qt_mac_cg_context(const QPaintDevice *pdev) -{ - if (pdev->devType() == QInternal::Pixmap) { - const QPixmap *pm = static_cast<const QPixmap*>(pdev); - CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pdev); - uint flags = kCGImageAlphaPremultipliedFirst; -#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version - flags |= kCGBitmapByteOrder32Host; -#endif - CGContextRef ret = 0; - - // It would make sense to put this into a mac #ifdef'ed - // virtual function in the QPlatformPixmap at some point - if (pm->data->classId() == QPlatformPixmap::MacClass) { - const QMacPlatformPixmap *pmData = static_cast<const QMacPlatformPixmap*>(pm->data.data()); - ret = CGBitmapContextCreate(pmData->pixels, pmData->w, pmData->h, - 8, pmData->bytesPerRow, colorspace, - flags); - if(!ret) - qWarning("QPaintDevice: Unable to create context for pixmap (%d/%d/%d)", - pmData->w, pmData->h, (pmData->bytesPerRow * pmData->h)); - } else if (pm->data->classId() == QPlatformPixmap::RasterClass) { - QImage *image = pm->data->buffer(); - ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(), - 8, image->bytesPerLine(), colorspace, flags); - } - - CGContextTranslateCTM(ret, 0, pm->height()); - CGContextScaleCTM(ret, 1, -1); - return ret; - } else if (pdev->devType() == QInternal::Widget) { - CGContextRef ret = static_cast<CGContextRef>(static_cast<const QWidget *>(pdev)->macCGHandle()); - CGContextRetain(ret); - return ret; - } else if (pdev->devType() == QInternal::MacQuartz) { - return static_cast<const QMacQuartzPaintDevice *>(pdev)->cgContext(); - } - return 0; -} - QT_END_NAMESPACE diff --git a/src/widgets/platforms/mac/qpaintengine_mac.cpp b/src/widgets/platforms/mac/qpaintengine_mac.cpp index af8e0e36c3..f1e397e7b0 100644 --- a/src/widgets/platforms/mac/qpaintengine_mac.cpp +++ b/src/widgets/platforms/mac/qpaintengine_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -87,60 +87,6 @@ extern QPixmap qt_pixmapForBrush(int, bool); //qbrush.cpp void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform); -//Implemented for qt_mac_p.h -QMacCGContext::QMacCGContext(QPainter *p) -{ - QPaintEngine *pe = p->paintEngine(); - if (pe->type() == QPaintEngine::MacPrinter) - pe = static_cast<QMacPrintEngine*>(pe)->paintEngine(); - pe->syncState(); - context = 0; - if(pe->type() == QPaintEngine::CoreGraphics) - context = static_cast<QCoreGraphicsPaintEngine*>(pe)->handle(); - - int devType = p->device()->devType(); - if (pe->type() == QPaintEngine::Raster - && (devType == QInternal::Widget || - devType == QInternal::Pixmap || - devType == QInternal::Image)) { - - extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice); - CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pe->paintDevice()); - uint flags = kCGImageAlphaPremultipliedFirst; -#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version - flags |= kCGBitmapByteOrder32Host; -#endif - const QImage *image = (const QImage *) pe->paintDevice(); - - context = CGBitmapContextCreate((void *) image->bits(), image->width(), image->height(), - 8, image->bytesPerLine(), colorspace, flags); - - CGContextTranslateCTM(context, 0, image->height()); - CGContextScaleCTM(context, 1, -1); - - if (devType == QInternal::Widget) { - QRegion clip = p->paintEngine()->systemClip(); - QTransform native = p->deviceTransform(); - QTransform logical = p->combinedTransform(); - - if (p->hasClipping()) { - QRegion r = p->clipRegion(); - r.translate(native.dx(), native.dy()); - if (clip.isEmpty()) - clip = r; - else - clip &= r; - } - qt_mac_clip_cg(context, clip, 0); - - CGContextTranslateCTM(context, native.dx(), native.dy()); - } - } else { - CGContextRetain(context); - } -} - - /***************************************************************************** QCoreGraphicsPaintEngine utility functions *****************************************************************************/ @@ -152,13 +98,6 @@ CGAffineTransform qt_mac_convert_transform_to_cg(const QTransform &t) { return CGAffineTransformMake(t.m11(), t.m12(), t.m21(), t.m22(), t.dx(), t.dy()); } -CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice) -{ - bool isWidget = (paintDevice->devType() == QInternal::Widget); - return QCoreGraphicsPaintEngine::macDisplayColorSpace(isWidget ? static_cast<const QWidget *>(paintDevice) - : 0); -} - inline static QCFType<CGColorRef> cgColorForQColor(const QColor &col, QPaintDevice *pdev) { CGFloat components[] = { @@ -317,46 +256,6 @@ CGColorSpaceRef QCoreGraphicsPaintEngine::macGenericColorSpace() return macDisplayColorSpace(); #endif } -void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform) -{ - CGAffineTransform old_xform = CGAffineTransformIdentity; - if(orig_xform) { //setup xforms - old_xform = CGContextGetCTM(hd); - CGContextConcatCTM(hd, CGAffineTransformInvert(old_xform)); - CGContextConcatCTM(hd, *orig_xform); - } - - //do the clipping - CGContextBeginPath(hd); - if(rgn.isEmpty()) { - CGContextAddRect(hd, CGRectMake(0, 0, 0, 0)); - } else { -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { - QCFType<HIMutableShapeRef> shape = rgn.toHIMutableShape(); - Q_ASSERT(!HIShapeIsEmpty(shape)); - HIShapeReplacePathInCGContext(shape, hd); - } else -#endif - { - QVector<QRect> rects = rgn.rects(); - const int count = rects.size(); - for(int i = 0; i < count; i++) { - const QRect &r = rects[i]; - CGRect mac_r = CGRectMake(r.x(), r.y(), r.width(), r.height()); - CGContextAddRect(hd, mac_r); - } - } - - } - CGContextClip(hd); - - if(orig_xform) {//reset xforms - CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd))); - CGContextConcatCTM(hd, old_xform); - } -} - //pattern handling (tiling) #if 1 diff --git a/src/widgets/platforms/mac/qpaintengine_mac_p.h b/src/widgets/platforms/mac/qpaintengine_mac_p.h index 2434011e52..a8e27a808d 100644 --- a/src/widgets/platforms/mac/qpaintengine_mac_p.h +++ b/src/widgets/platforms/mac/qpaintengine_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qpixmap_mac.cpp b/src/widgets/platforms/mac/qpixmap_mac.cpp index 48835c7d46..3b2452c37c 100644 --- a/src/widgets/platforms/mac/qpixmap_mac.cpp +++ b/src/widgets/platforms/mac/qpixmap_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qpixmap_mac_p.h b/src/widgets/platforms/mac/qpixmap_mac_p.h index 4f53160074..582eef27b6 100644 --- a/src/widgets/platforms/mac/qpixmap_mac_p.h +++ b/src/widgets/platforms/mac/qpixmap_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qprintengine_mac.mm b/src/widgets/platforms/mac/qprintengine_mac.mm index b01d7a5762..9902b3216d 100644 --- a/src/widgets/platforms/mac/qprintengine_mac.mm +++ b/src/widgets/platforms/mac/qprintengine_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qprintengine_mac_p.h b/src/widgets/platforms/mac/qprintengine_mac_p.h index 6c17818fbd..349dfd10f2 100644 --- a/src/widgets/platforms/mac/qprintengine_mac_p.h +++ b/src/widgets/platforms/mac/qprintengine_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qprinterinfo_mac.cpp b/src/widgets/platforms/mac/qprinterinfo_mac.cpp index 455510d5d3..98492a5af6 100644 --- a/src/widgets/platforms/mac/qprinterinfo_mac.cpp +++ b/src/widgets/platforms/mac/qprinterinfo_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qregion_mac.cpp b/src/widgets/platforms/mac/qregion_mac.cpp index b929d9c283..71e7a3b44b 100644 --- a/src/widgets/platforms/mac/qregion_mac.cpp +++ b/src/widgets/platforms/mac/qregion_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -47,75 +47,4 @@ QT_BEGIN_NAMESPACE QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0 }; - -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) -OSStatus QRegion::shape2QRegionHelper(int inMessage, HIShapeRef, - const CGRect *inRect, void *inRefcon) -{ - QRegion *region = static_cast<QRegion *>(inRefcon); - if (!region) - return paramErr; - - switch (inMessage) { - case kHIShapeEnumerateRect: - *region += QRect(inRect->origin.x, inRect->origin.y, - inRect->size.width, inRect->size.height); - break; - case kHIShapeEnumerateInit: - // Assume the region is already setup correctly - case kHIShapeEnumerateTerminate: - default: - break; - } - return noErr; -} -#endif - -/*! - \internal - Create's a mutable shape, it's the caller's responsibility to release. - WARNING: this function clamps the coordinates to SHRT_MIN/MAX on 10.4 and below. -*/ -HIMutableShapeRef QRegion::toHIMutableShape() const -{ - HIMutableShapeRef shape = HIShapeCreateMutable(); -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { - if (d->qt_rgn && d->qt_rgn->numRects) { - int n = d->qt_rgn->numRects; - const QRect *qt_r = (n == 1) ? &d->qt_rgn->extents : d->qt_rgn->rects.constData(); - while (n--) { - CGRect cgRect = CGRectMake(qt_r->x(), qt_r->y(), qt_r->width(), qt_r->height()); - HIShapeUnionWithRect(shape, &cgRect); - ++qt_r; - } - } - } else -#endif - { - } - return shape; -} - - - -QRegion QRegion::fromHIShapeRef(HIShapeRef shape) -{ - QRegion returnRegion; - returnRegion.detach(); - // Begin gratuitous #if-defery -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) -# ifndef Q_WS_MAC64 - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { -# endif - HIShapeEnumerate(shape, kHIShapeParseFromTopLeft, shape2QRegionHelper, &returnRegion); -# ifndef Q_WS_MAC64 - } else -# endif -#endif - { - } - return returnRegion; -} - QT_END_NAMESPACE diff --git a/src/widgets/platforms/mac/qt_cocoa_helpers_mac.mm b/src/widgets/platforms/mac/qt_cocoa_helpers_mac.mm index 20bb6bffbb..348b989ec6 100644 --- a/src/widgets/platforms/mac/qt_cocoa_helpers_mac.mm +++ b/src/widgets/platforms/mac/qt_cocoa_helpers_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -219,12 +219,6 @@ DnDParams *macCurrentDnDParameters() } #endif -bool macWindowIsTextured( void * /*OSWindowRef*/ window ) -{ - OSWindowRef wnd = static_cast<OSWindowRef>(window); - return ( [wnd styleMask] & NSTexturedBackgroundWindowMask ) ? true : false; -} - void macWindowToolbarShow(const QWidget *widget, bool show ) { OSWindowRef wnd = qt_mac_window_for(widget); diff --git a/src/widgets/platforms/mac/qt_cocoa_helpers_mac_p.h b/src/widgets/platforms/mac/qt_cocoa_helpers_mac_p.h index c85d39010c..bae479ec6a 100644 --- a/src/widgets/platforms/mac/qt_cocoa_helpers_mac_p.h +++ b/src/widgets/platforms/mac/qt_cocoa_helpers_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -129,7 +129,6 @@ QT_BEGIN_NAMESPACE Qt::MouseButtons qt_mac_get_buttons(int buttons); Qt::MouseButton qt_mac_get_button(EventMouseButton button); void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds = 0.15); -bool macWindowIsTextured(void * /*OSWindowRef*/ window); void macWindowToolbarShow(const QWidget *widget, bool show ); void macWindowToolbarSet( void * /*OSWindowRef*/ window, void* toolbarRef ); bool macWindowToolbarIsVisible( void * /*OSWindowRef*/ window ); @@ -140,7 +139,6 @@ void qt_mac_updateContentBorderMetricts(void * /*OSWindowRef */window, const ::H void qt_mac_replaceDrawRect(void * /*OSWindowRef */window, QWidgetPrivate *widget); void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivate *widget); void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show); -void * /*NSImage */qt_mac_create_nsimage(const QPixmap &pm); void qt_mac_update_mouseTracking(QWidget *widget); OSStatus qt_mac_drawCGImage(CGContextRef cg, const CGRect *inbounds, CGImageRef); bool qt_mac_checkForNativeSizeGrip(const QWidget *widget); diff --git a/src/widgets/platforms/mac/qt_mac.cpp b/src/widgets/platforms/mac/qt_mac.cpp index b3c9371d24..adf8f70cab 100644 --- a/src/widgets/platforms/mac/qt_mac.cpp +++ b/src/widgets/platforms/mac/qt_mac.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -67,24 +67,6 @@ QFont qfontForThemeFont(ThemeFontID themeID) } #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) -static QColor qcolorFromCGColor(CGColorRef cgcolor) -{ - QColor pc; - CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(cgcolor)); - const CGFloat *components = CGColorGetComponents(cgcolor); - if (model == kCGColorSpaceModelRGB) { - pc.setRgbF(components[0], components[1], components[2], components[3]); - } else if (model == kCGColorSpaceModelCMYK) { - pc.setCmykF(components[0], components[1], components[2], components[3]); - } else if (model == kCGColorSpaceModelMonochrome) { - pc.setRgbF(components[0], components[0], components[0], components[1]); - } else { - // Colorspace we can't deal with. - qWarning("Qt: qcolorFromCGColor: cannot convert from colorspace model: %d", model); - Q_ASSERT(false); - } - return pc; -} static inline QColor leopardBrush(ThemeBrush brush) { diff --git a/src/widgets/platforms/mac/qt_mac_p.h b/src/widgets/platforms/mac/qt_mac_p.h index 5a1d4ee42e..3b679c32ec 100644 --- a/src/widgets/platforms/mac/qt_mac_p.h +++ b/src/widgets/platforms/mac/qt_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/platforms/mac/qwidget_mac.mm b/src/widgets/platforms/mac/qwidget_mac.mm index dd958761a1..6c8413e42e 100644 --- a/src/widgets/platforms/mac/qwidget_mac.mm +++ b/src/widgets/platforms/mac/qwidget_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/statemachine/qbasickeyeventtransition.cpp b/src/widgets/statemachine/qbasickeyeventtransition.cpp index 615e642a7e..fca11eb036 100644 --- a/src/widgets/statemachine/qbasickeyeventtransition.cpp +++ b/src/widgets/statemachine/qbasickeyeventtransition.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/statemachine/qbasickeyeventtransition_p.h b/src/widgets/statemachine/qbasickeyeventtransition_p.h index 6a51260155..379c151e60 100644 --- a/src/widgets/statemachine/qbasickeyeventtransition_p.h +++ b/src/widgets/statemachine/qbasickeyeventtransition_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/statemachine/qbasicmouseeventtransition.cpp b/src/widgets/statemachine/qbasicmouseeventtransition.cpp index 0edf430af6..c05b262b66 100644 --- a/src/widgets/statemachine/qbasicmouseeventtransition.cpp +++ b/src/widgets/statemachine/qbasicmouseeventtransition.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/statemachine/qbasicmouseeventtransition_p.h b/src/widgets/statemachine/qbasicmouseeventtransition_p.h index 3a608cb0af..98a8f28ca8 100644 --- a/src/widgets/statemachine/qbasicmouseeventtransition_p.h +++ b/src/widgets/statemachine/qbasicmouseeventtransition_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp index f717662ace..928bbd5a53 100644 --- a/src/widgets/statemachine/qguistatemachine.cpp +++ b/src/widgets/statemachine/qguistatemachine.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -285,13 +285,6 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::HoverMove: return new QHoverEvent(*static_cast<QHoverEvent*>(e)); - case QEvent::AccessibilityHelp: - Q_ASSERT_X(false, "cloneEvent()", "not implemented"); - break; - case QEvent::AccessibilityDescription: - Q_ASSERT_X(false, "cloneEvent()", "not implemented"); - break; - #ifdef QT_KEYPAD_NAVIGATION case QEvent::EnterEditFocus: return new QEvent(*e); diff --git a/src/widgets/statemachine/qkeyeventtransition.cpp b/src/widgets/statemachine/qkeyeventtransition.cpp index b1ff2e33b2..175d4924a9 100644 --- a/src/widgets/statemachine/qkeyeventtransition.cpp +++ b/src/widgets/statemachine/qkeyeventtransition.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/statemachine/qkeyeventtransition.h b/src/widgets/statemachine/qkeyeventtransition.h index 7862bd41d7..b22a4e0934 100644 --- a/src/widgets/statemachine/qkeyeventtransition.h +++ b/src/widgets/statemachine/qkeyeventtransition.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/statemachine/qmouseeventtransition.cpp b/src/widgets/statemachine/qmouseeventtransition.cpp index 416529bddd..60c2c85159 100644 --- a/src/widgets/statemachine/qmouseeventtransition.cpp +++ b/src/widgets/statemachine/qmouseeventtransition.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/statemachine/qmouseeventtransition.h b/src/widgets/statemachine/qmouseeventtransition.h index 7255a968ac..bdd64c5f3f 100644 --- a/src/widgets/statemachine/qmouseeventtransition.h +++ b/src/widgets/statemachine/qmouseeventtransition.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qcdestyle.cpp b/src/widgets/styles/qcdestyle.cpp index 426ab19007..518461c279 100644 --- a/src/widgets/styles/qcdestyle.cpp +++ b/src/widgets/styles/qcdestyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qcdestyle.h b/src/widgets/styles/qcdestyle.h index 854bfc6c69..b5293d30f3 100644 --- a/src/widgets/styles/qcdestyle.h +++ b/src/widgets/styles/qcdestyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qcleanlooksstyle.cpp b/src/widgets/styles/qcleanlooksstyle.cpp index 567efa8851..42f9b38bd4 100644 --- a/src/widgets/styles/qcleanlooksstyle.cpp +++ b/src/widgets/styles/qcleanlooksstyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qcleanlooksstyle.h b/src/widgets/styles/qcleanlooksstyle.h index 1b35aa7969..94b3aa889c 100644 --- a/src/widgets/styles/qcleanlooksstyle.h +++ b/src/widgets/styles/qcleanlooksstyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qcleanlooksstyle_p.h b/src/widgets/styles/qcleanlooksstyle_p.h index 4df13c8a43..d9968bb531 100644 --- a/src/widgets/styles/qcleanlooksstyle_p.h +++ b/src/widgets/styles/qcleanlooksstyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 31311a50f4..c874770fdb 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -44,6 +44,7 @@ #include <qfile.h> #include <qapplication.h> +#include <private/qguiapplication_p.h> #include <qbitmap.h> #include <qcache.h> #include <qdockwidget.h> @@ -72,6 +73,7 @@ #include <qfileinfo.h> #include <qdir.h> #include <qsettings.h> +#include <qvariant.h> #include <qpixmapcache.h> #include <private/qguiplatformplugin_p.h> @@ -4313,7 +4315,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; #endif case PM_MaximumDragDistance: - ret = -1; + ret = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::MaximumScrollBarDragDistance).toInt(); break; #ifndef QT_NO_SLIDER @@ -4550,7 +4552,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid } break; case PM_TextCursorWidth: - ret = 1; + ret = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::TextCursorWidth).toInt(); break; case PM_TabBar_ScrollButtonOverlap: ret = 1; diff --git a/src/widgets/styles/qcommonstyle.h b/src/widgets/styles/qcommonstyle.h index a4a7ac11c5..e023c702da 100644 --- a/src/widgets/styles/qcommonstyle.h +++ b/src/widgets/styles/qcommonstyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h index 554a8130f6..10a9cd875a 100644 --- a/src/widgets/styles/qcommonstyle_p.h +++ b/src/widgets/styles/qcommonstyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qcommonstylepixmaps_p.h b/src/widgets/styles/qcommonstylepixmaps_p.h index 93cd837fb7..73c183d485 100644 --- a/src/widgets/styles/qcommonstylepixmaps_p.h +++ b/src/widgets/styles/qcommonstylepixmaps_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qdrawutil.cpp b/src/widgets/styles/qdrawutil.cpp index 5cd7bae658..fd8a272851 100644 --- a/src/widgets/styles/qdrawutil.cpp +++ b/src/widgets/styles/qdrawutil.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qdrawutil.h b/src/widgets/styles/qdrawutil.h index 2f35d236b7..74347b09c1 100644 --- a/src/widgets/styles/qdrawutil.h +++ b/src/widgets/styles/qdrawutil.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qgtkpainter.cpp b/src/widgets/styles/qgtkpainter.cpp index 373732f924..a9d1ed2281 100644 --- a/src/widgets/styles/qgtkpainter.cpp +++ b/src/widgets/styles/qgtkpainter.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qgtkpainter_p.h b/src/widgets/styles/qgtkpainter_p.h index a9d4dc0dcd..b0874d2315 100644 --- a/src/widgets/styles/qgtkpainter_p.h +++ b/src/widgets/styles/qgtkpainter_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp index da39c95a58..30e1371354 100644 --- a/src/widgets/styles/qgtkstyle.cpp +++ b/src/widgets/styles/qgtkstyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qgtkstyle.h b/src/widgets/styles/qgtkstyle.h index 1ca6e3cc85..26665dcd51 100644 --- a/src/widgets/styles/qgtkstyle.h +++ b/src/widgets/styles/qgtkstyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp index a2fabde736..f3b41e0ba1 100644 --- a/src/widgets/styles/qgtkstyle_p.cpp +++ b/src/widgets/styles/qgtkstyle_p.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qgtkstyle_p.h b/src/widgets/styles/qgtkstyle_p.h index 55089268b3..656a187ded 100644 --- a/src/widgets/styles/qgtkstyle_p.h +++ b/src/widgets/styles/qgtkstyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qmacstyle.qdoc b/src/widgets/styles/qmacstyle.qdoc index 709332aa1d..97baf80e9d 100644 --- a/src/widgets/styles/qmacstyle.qdoc +++ b/src/widgets/styles/qmacstyle.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qmacstyle_mac.h b/src/widgets/styles/qmacstyle_mac.h index bb9175cca8..7a3a4248b3 100644 --- a/src/widgets/styles/qmacstyle_mac.h +++ b/src/widgets/styles/qmacstyle_mac.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) +#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) class QPalette; diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index f6eacd28dc..ca9b5cf234 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -45,17 +45,15 @@ */ #include "qmacstyle_mac.h" +#include "qmacstyle_mac_p.h" +#include "qmacstylepixmaps_mac_p.h" -#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) #define QMAC_QAQUASTYLE_SIZE_CONSTRAIN //#define DEBUG_SIZE_CONSTRAINT -#include <private/qapplication_p.h> +#include <private/qcore_mac_p.h> #include <private/qcombobox_p.h> -#include <private/qmacstylepixmaps_mac_p.h> -#include <private/qpaintengine_mac_p.h> #include <private/qpainter_p.h> -#include <private/qprintengine_mac_p.h> #include <qapplication.h> #include <qbitmap.h> #include <qcheckbox.h> @@ -97,11 +95,10 @@ #include <qlibrary.h> #include <qdatetimeedit.h> #include <qmath.h> -#include <QtGui/qgraphicsproxywidget.h> -#include <QtGui/qgraphicsview.h> -#include <private/qt_cocoa_helpers_mac_p.h> -#include "qmacstyle_mac_p.h" +#include <QtWidgets/qgraphicsproxywidget.h> +#include <QtWidgets/qgraphicsview.h> #include <private/qstylehelper_p.h> +#include <QtGui/QPlatformFontDatabase> QT_BEGIN_NAMESPACE @@ -138,9 +135,6 @@ typedef HIRect * (*PtrHIShapeGetBounds)(HIShapeRef, HIRect *); static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0; static int closeButtonSize = 12; - -extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp - static bool isVerticalTabs(const QTabBar::Shape shape) { return (shape == QTabBar::RoundedEast || shape == QTabBar::TriangularEast @@ -417,18 +411,247 @@ static inline ThemeTabDirection getTabDirection(QTabBar::Shape shape) return ttd; } -QT_BEGIN_INCLUDE_NAMESPACE -#include "moc_qmacstyle_mac.cpp" -#include "moc_qmacstyle_mac_p.cpp" -QT_END_INCLUDE_NAMESPACE +static QString qt_mac_removeMnemonics(const QString &original) +{ + QString returnText(original.size(), 0); + int finalDest = 0; + int currPos = 0; + int l = original.length(); + while (l) { + if (original.at(currPos) == QLatin1Char('&') + && (l == 1 || original.at(currPos + 1) != QLatin1Char('&'))) { + ++currPos; + --l; + if (l == 0) + break; + } + returnText[finalDest] = original.at(currPos); + ++currPos; + ++finalDest; + --l; + } + returnText.truncate(finalDest); + return returnText; +} -/***************************************************************************** - External functions - *****************************************************************************/ -extern CGContextRef qt_mac_cg_context(const QPaintDevice *); //qpaintdevice_mac.cpp -extern QRegion qt_mac_convert_mac_region(HIShapeRef); //qregion_mac.cpp -void qt_mac_dispose_rgn(RgnHandle r); //qregion_mac.cpp -extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp +class QMacCGContext +{ + CGContextRef context; +public: + QMacCGContext(QPainter *p); //qpaintengine_mac.cpp + inline QMacCGContext() { context = 0; } + inline QMacCGContext(const QPaintDevice *pdev) { + extern CGContextRef qt_mac_cg_context(const QPaintDevice *); + context = qt_mac_cg_context(pdev); + } + inline QMacCGContext(CGContextRef cg, bool takeOwnership=false) { + context = cg; + if (!takeOwnership) + CGContextRetain(context); + } + inline QMacCGContext(const QMacCGContext ©) : context(0) { *this = copy; } + inline ~QMacCGContext() { + if (context) + CGContextRelease(context); + } + inline bool isNull() const { return context; } + inline operator CGContextRef() { return context; } + inline QMacCGContext &operator=(const QMacCGContext ©) { + if (context) + CGContextRelease(context); + context = copy.context; + CGContextRetain(context); + return *this; + } + inline QMacCGContext &operator=(CGContextRef cg) { + if (context) + CGContextRelease(context); + context = cg; + CGContextRetain(context); //we do not take ownership + return *this; + } +}; + +static QColor qcolorFromCGColor(CGColorRef cgcolor) +{ + QColor pc; + CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(cgcolor)); + const CGFloat *components = CGColorGetComponents(cgcolor); + if (model == kCGColorSpaceModelRGB) { + pc.setRgbF(components[0], components[1], components[2], components[3]); + } else if (model == kCGColorSpaceModelCMYK) { + pc.setCmykF(components[0], components[1], components[2], components[3]); + } else if (model == kCGColorSpaceModelMonochrome) { + pc.setRgbF(components[0], components[0], components[0], components[1]); + } else { + // Colorspace we can't deal with. + qWarning("Qt: qcolorFromCGColor: cannot convert from colorspace model: %d", model); + Q_ASSERT(false); + } + return pc; +} + +static inline QColor leopardBrush(ThemeBrush brush) +{ + QCFType<CGColorRef> cgClr = 0; + HIThemeBrushCreateCGColor(brush, &cgClr); + return qcolorFromCGColor(cgClr); +} + +QColor qcolorForTheme(ThemeBrush brush) +{ + return leopardBrush(brush); +} + +OSStatus qt_mac_shape2QRegionHelper(int inMessage, HIShapeRef, const CGRect *inRect, void *inRefcon) +{ + QRegion *region = static_cast<QRegion *>(inRefcon); + if (!region) + return paramErr; + + switch (inMessage) { + case kHIShapeEnumerateRect: + *region += QRect(inRect->origin.x, inRect->origin.y, + inRect->size.width, inRect->size.height); + break; + case kHIShapeEnumerateInit: + // Assume the region is already setup correctly + case kHIShapeEnumerateTerminate: + default: + break; + } + return noErr; +} + + +/*! + \internal + Create's a mutable shape, it's the caller's responsibility to release. + WARNING: this function clamps the coordinates to SHRT_MIN/MAX on 10.4 and below. +*/ +HIMutableShapeRef qt_mac_toHIMutableShape(const QRegion ®ion) +{ + HIMutableShapeRef shape = HIShapeCreateMutable(); + if (region.rectCount() < 2 ) { + QRect qtRect = region.boundingRect(); + CGRect cgRect = CGRectMake(qtRect.x(), qtRect.y(), qtRect.width(), qtRect.height()); + HIShapeUnionWithRect(shape, &cgRect); + } else { + foreach (const QRect &qtRect, region.rects()) { + CGRect cgRect = CGRectMake(qtRect.x(), qtRect.y(), qtRect.width(), qtRect.height()); + HIShapeUnionWithRect(shape, &cgRect); + } + } + return shape; +} + +QRegion qt_mac_fromHIShapeRef(HIShapeRef shape) +{ + QRegion returnRegion; + //returnRegion.detach(); + HIShapeEnumerate(shape, kHIShapeParseFromTopLeft, qt_mac_shape2QRegionHelper, &returnRegion); + return returnRegion; +} + +CGColorSpaceRef m_genericColorSpace = 0; +QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash; +bool m_postRoutineRegistered = false; + +CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget); +CGColorSpaceRef qt_mac_genericColorSpace() +{ +#if 0 + if (!m_genericColorSpace) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { + m_genericColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + } else +#endif + { + m_genericColorSpace = CGColorSpaceCreateDeviceRGB(); + } + if (!m_postRoutineRegistered) { + m_postRoutineRegistered = true; + qAddPostRoutine(QCoreGraphicsPaintEngine::cleanUpMacColorSpaces); + } + } + return m_genericColorSpace; +#else + // Just return the main display colorspace for the moment. + return qt_mac_displayColorSpace(0); +#endif +} + +/* + Ideally, we should pass the widget in here, and use CGGetDisplaysWithRect() etc. + to support multiple displays correctly. +*/ +CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget) +{ + CGColorSpaceRef colorSpace; + + CGDirectDisplayID displayID; + CMProfileRef displayProfile = 0; + if (widget == 0) { + displayID = CGMainDisplayID(); + } else { + displayID = CGMainDisplayID(); + /* + ### get correct display + const QRect &qrect = widget->window()->geometry(); + CGRect rect = CGRectMake(qrect.x(), qrect.y(), qrect.width(), qrect.height()); + CGDisplayCount throwAway; + CGDisplayErr dErr = CGGetDisplaysWithRect(rect, 1, &displayID, &throwAway); + if (dErr != kCGErrorSuccess) + return macDisplayColorSpace(0); // fall back on main display + */ + } + if ((colorSpace = m_displayColorSpaceHash.value(displayID))) + return colorSpace; + + CMError err = CMGetProfileByAVID((CMDisplayIDType)displayID, &displayProfile); + if (err == noErr) { + colorSpace = CGColorSpaceCreateWithPlatformColorSpace(displayProfile); + } else if (widget) { + return qt_mac_displayColorSpace(0); // fall back on main display + } + + if (colorSpace == 0) + colorSpace = CGColorSpaceCreateDeviceRGB(); + + m_displayColorSpaceHash.insert(displayID, colorSpace); + CMCloseProfile(displayProfile); + if (!m_postRoutineRegistered) { + m_postRoutineRegistered = true; + void qt_mac_cleanUpMacColorSpaces(); + qAddPostRoutine(qt_mac_cleanUpMacColorSpaces); + } + return colorSpace; +} + +void qt_mac_cleanUpMacColorSpaces() +{ + if (m_genericColorSpace) { + CFRelease(m_genericColorSpace); + m_genericColorSpace = 0; + } + QHash<CGDirectDisplayID, CGColorSpaceRef>::const_iterator it = m_displayColorSpaceHash.constBegin(); + while (it != m_displayColorSpaceHash.constEnd()) { + if (it.value()) + CFRelease(it.value()); + ++it; + } + m_displayColorSpaceHash.clear(); +} + +bool qt_macWindowIsTextured(const QWidget *window) +{ + NSWindow *nswindow = static_cast<NSWindow*>( + QApplication::platformNativeInterface()->nativeResourceForWindow("NSWindow", window->windowHandle())); + if (!nswindow) + return false; + return ([nswindow styleMask] & NSTexturedBackgroundWindowMask) ? true : false; +} /***************************************************************************** QMacCGStyle globals @@ -467,7 +690,7 @@ inline bool qt_mac_is_metal(const QWidget *w) if (w->testAttribute(Qt::WA_MacBrushedMetal)) return true; if (w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) { // If not created will fall through to the opaque check and be fine anyway. - return macWindowIsTextured(qt_mac_window_for(w)); + return qt_macWindowIsTextured(w); } if (w->d_func()->isOpaque) break; @@ -1382,7 +1605,6 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti tdi->trackInfo.scrollbar.viewsize = slider->pageStep; } } -#endif QMacStylePrivate::QMacStylePrivate(QMacStyle *style) : timerID(-1), progressFrame(0), q(style), mouseDown(false) @@ -1750,8 +1972,9 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush QPoint dummy; const QPaintDevice *target = painter->device(); const QPaintDevice *redirected = QPainter::redirected(target, &dummy); - const bool usePainter = redirected && redirected != target; + //const bool usePainter = redirected && redirected != target; +#if 0 if (!usePainter && qt_mac_backgroundPattern && qt_mac_backgroundPattern->cacheKey() == brush.texture().cacheKey()) { @@ -1772,10 +1995,11 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush CGContextRestoreGState(cg); } else { +#endif const QRect rect(rgn.boundingRect()); painter->setClipRegion(rgn); painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); - } +// } } void QMacStyle::polish(QPalette &pal) @@ -1831,8 +2055,9 @@ void QMacStyle::polish(QWidget* w) mtinfo.version = qt_mac_hitheme_version; mtinfo.menuType = kThemeMenuTypePopUp; HIRect rect = CGRectMake(0, 0, px.width(), px.height()); - HIThemeDrawMenuBackground(&rect, &mtinfo, QCFType<CGContextRef>(qt_mac_cg_context(&px)), - kHIThemeOrientationNormal); + // ### + //HIThemeDrawMenuBackground(&rect, &mtinfo, QCFType<CGContextRef>(qt_mac_cg_context(&px)), + // kHIThemeOrientationNormal); QPalette pal = w->palette(); QBrush background(px); pal.setBrush(QPalette::All, QPalette::Window, background); @@ -2309,11 +2534,12 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w ret = 100; break; case SH_ScrollBar_LeftClickAbsolutePosition: { - extern bool qt_scrollbar_jump_to_pos; //qapplication_mac.cpp if(QApplication::keyboardModifiers() & Qt::AltModifier) - ret = !qt_scrollbar_jump_to_pos; + ret = false; + //ret = !qt_scrollbar_jump_to_pos; else - ret = qt_scrollbar_jump_to_pos; + ret = true; + //ret = qt_scrollbar_jump_to_pos; break; } case SH_TabBar_PreferNoArrows: ret = true; @@ -2547,7 +2773,8 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w mdi.menuType = kThemeMenuTypePopUp; QCFType<HIShapeRef> shape; HIThemeGetMenuBackgroundShape(&menuRect, &mdi, &shape); - mask->region = QRegion::fromHIShapeRef(shape); + + mask->region = qt_mac_fromHIShapeRef(shape); } } break; @@ -3404,7 +3631,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QColor textColor = btn->palette.buttonText().color(); CGFloat colorComp[] = { textColor.redF(), textColor.greenF(), textColor.blueF(), textColor.alphaF() }; - CGContextSetFillColorSpace(cg, QCoreGraphicsPaintEngine::macGenericColorSpace()); + CGContextSetFillColorSpace(cg, qt_mac_genericColorSpace()); CGContextSetFillColor(cg, colorComp); tti.fontID = themeId; tti.horizontalFlushness = kHIThemeTextHorizontalFlushCenter; @@ -3629,7 +3856,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QColor textColor = myTab.palette.windowText().color(); CGFloat colorComp[] = { textColor.redF(), textColor.greenF(), textColor.blueF(), textColor.alphaF() }; - CGContextSetFillColorSpace(cg, QCoreGraphicsPaintEngine::macGenericColorSpace()); + CGContextSetFillColorSpace(cg, qt_mac_genericColorSpace()); CGContextSetFillColor(cg, colorComp); switch (d->aquaSizeConstrain(opt, w)) { default: @@ -3810,7 +4037,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QColor textColor = p->pen().color(); CGFloat colorComp[] = { textColor.redF(), textColor.greenF(), textColor.blueF(), textColor.alphaF() }; - CGContextSetFillColorSpace(cg, QCoreGraphicsPaintEngine::macGenericColorSpace()); + CGContextSetFillColorSpace(cg, qt_mac_genericColorSpace()); CGContextSetFillColor(cg, colorComp); HIThemeTextInfo tti; tti.version = qt_mac_hitheme_version; @@ -4946,7 +5173,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex QColor textColor = groupBox->palette.windowText().color(); CGFloat colorComp[] = { textColor.redF(), textColor.greenF(), textColor.blueF(), textColor.alphaF() }; - CGContextSetFillColorSpace(cg, QCoreGraphicsPaintEngine::macGenericColorSpace()); + CGContextSetFillColorSpace(cg, qt_mac_genericColorSpace()); CGContextSetFillColor(cg, colorComp); tti.fontID = checkable ? kThemeSystemFont : kThemeSmallSystemFont; tti.horizontalFlushness = kHIThemeTextHorizontalFlushCenter; @@ -6075,4 +6302,135 @@ int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, return_SIZE(10, 8, 6); // guess } +void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform) +{ + CGAffineTransform old_xform = CGAffineTransformIdentity; + if (orig_xform) { //setup xforms + old_xform = CGContextGetCTM(hd); + CGContextConcatCTM(hd, CGAffineTransformInvert(old_xform)); + CGContextConcatCTM(hd, *orig_xform); + } + + //do the clipping + CGContextBeginPath(hd); + if (rgn.isEmpty()) { + CGContextAddRect(hd, CGRectMake(0, 0, 0, 0)); + } else { + QCFType<HIMutableShapeRef> shape = qt_mac_toHIMutableShape(rgn); + Q_ASSERT(!HIShapeIsEmpty(shape)); + HIShapeReplacePathInCGContext(shape, hd); + } + CGContextClip(hd); + + if (orig_xform) {//reset xforms + CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd))); + CGContextConcatCTM(hd, old_xform); + } +} + +QMacCGContext::QMacCGContext(QPainter *p) +{ + QPaintEngine *pe = p->paintEngine(); + pe->syncState(); + context = 0; + + int devType = p->device()->devType(); + if (pe->type() == QPaintEngine::Raster + && (devType == QInternal::Widget || + devType == QInternal::Pixmap || + devType == QInternal::Image)) { + + extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice); + CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pe->paintDevice()); + uint flags = kCGImageAlphaPremultipliedFirst; + flags |= kCGBitmapByteOrder32Host; + + const QImage *image = (const QImage *) pe->paintDevice(); + + context = CGBitmapContextCreate((void *) image->bits(), image->width(), image->height(), + 8, image->bytesPerLine(), colorspace, flags); + + CGContextTranslateCTM(context, 0, image->height()); + CGContextScaleCTM(context, 1, -1); + + if (devType == QInternal::Widget) { + QRegion clip = p->paintEngine()->systemClip(); + QTransform native = p->deviceTransform(); + QTransform logical = p->combinedTransform(); + + if (p->hasClipping()) { + QRegion r = p->clipRegion(); + r.translate(native.dx(), native.dy()); + if (clip.isEmpty()) + clip = r; + else + clip &= r; + } + qt_mac_clip_cg(context, clip, 0); + + CGContextTranslateCTM(context, native.dx(), native.dy()); + } + } else { + qDebug() << "QMacCGContext:: Unsupported painter devtype type" << devType; + } +} + +CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice) +{ + bool isWidget = (paintDevice->devType() == QInternal::Widget); + return qt_mac_displayColorSpace(isWidget ? static_cast<const QWidget *>(paintDevice) : 0); +} + +/*! \internal + + Returns the CoreGraphics CGContextRef of the paint device. 0 is + returned if it can't be obtained. It is the caller's responsibility to + CGContextRelease the context when finished using it. + + \warning This function is only available on Mac OS X. +*/ + +CGContextRef qt_mac_cg_context(const QPaintDevice *pdev) +{ + if (pdev->devType() == QInternal::Pixmap) { + const QPixmap *pm = static_cast<const QPixmap*>(pdev); + CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pdev); + uint flags = kCGImageAlphaPremultipliedFirst; + flags |= kCGBitmapByteOrder32Host; + CGContextRef ret = 0; + + QPlatformPixmap *data = const_cast<QPixmap *>(pm)->data_ptr().data(); + if (data->classId() == QPlatformPixmap::RasterClass) { + QImage *image = data->buffer(); + ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(), + 8, image->bytesPerLine(), colorspace, flags); + } else { + qDebug() << "qt_mac_cg_context: Unsupported pixmap class"; + } + + CGContextTranslateCTM(ret, 0, pm->height()); + CGContextScaleCTM(ret, 1, -1); + return ret; + } else if (pdev->devType() == QInternal::Widget) { + //CGContextRef ret = static_cast<CGContextRef>(static_cast<const QWidget *>(pdev)->macCGHandle()); + ///CGContextRetain(ret); + //return ret; + qDebug() << "qt_mac_cg_context: not implemented: Widget class"; + return 0; + } + return 0; +} + +/* +FontHash::FontHash() +{ + QHash<QByteArray, QFont>::operator=(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFonts()); +} + +Q_GLOBAL_STATIC(FontHash, app_fonts) +FontHash *qt_app_fonts_hash() +{ + return app_fonts(); +} +*/ QT_END_NAMESPACE diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h index 747779249c..1739a382f3 100644 --- a/src/widgets/styles/qmacstyle_mac_p.h +++ b/src/widgets/styles/qmacstyle_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -43,13 +43,13 @@ #ifndef QMACSTYLE_MAC_P_H #define QMACSTYLE_MAC_P_H -#include <qmacstyle_mac.h> +#include <Carbon/Carbon.h> +#undef check + +#include "qmacstyle_mac.h" #include <private/qapplication_p.h> #include <private/qcombobox_p.h> -#include <private/qmacstylepixmaps_mac_p.h> -#include <private/qpaintengine_mac_p.h> #include <private/qpainter_p.h> -#include <private/qprintengine_mac_p.h> #include <private/qstylehelper_p.h> #include <qapplication.h> #include <qbitmap.h> @@ -94,7 +94,8 @@ #include <qmath.h> #include <QtWidgets/qgraphicsproxywidget.h> #include <QtWidgets/qgraphicsview.h> -#include <private/qt_cocoa_helpers_mac_p.h> + + // // W A R N I N G @@ -109,21 +110,6 @@ QT_BEGIN_NAMESPACE -#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5) -enum { - kThemePushButtonTextured = 31, - kThemePushButtonTexturedSmall = 32, - kThemePushButtonTexturedMini = 33 -}; - -/* Search fields */ -enum { - kHIThemeFrameTextFieldRound = 1000, - kHIThemeFrameTextFieldRoundSmall = 1001, - kHIThemeFrameTextFieldRoundMini = 1002 -}; -#endif - /* AHIG: Apple Human Interface Guidelines diff --git a/src/widgets/styles/qmacstylepixmaps_mac_p.h b/src/widgets/styles/qmacstylepixmaps_mac_p.h index 7bd1a2b43e..3f852a63f3 100644 --- a/src/widgets/styles/qmacstylepixmaps_mac_p.h +++ b/src/widgets/styles/qmacstylepixmaps_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qmotifstyle.cpp b/src/widgets/styles/qmotifstyle.cpp index 46a64eb575..fc697454c1 100644 --- a/src/widgets/styles/qmotifstyle.cpp +++ b/src/widgets/styles/qmotifstyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qmotifstyle.h b/src/widgets/styles/qmotifstyle.h index 35b3448289..0aa506d2ac 100644 --- a/src/widgets/styles/qmotifstyle.h +++ b/src/widgets/styles/qmotifstyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qmotifstyle_p.h b/src/widgets/styles/qmotifstyle_p.h index 90e0c6d530..83394059e8 100644 --- a/src/widgets/styles/qmotifstyle_p.h +++ b/src/widgets/styles/qmotifstyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qplastiquestyle.cpp b/src/widgets/styles/qplastiquestyle.cpp index 65e269f800..750d0765ef 100644 --- a/src/widgets/styles/qplastiquestyle.cpp +++ b/src/widgets/styles/qplastiquestyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qplastiquestyle.h b/src/widgets/styles/qplastiquestyle.h index d0afce6cf0..837e07a75f 100644 --- a/src/widgets/styles/qplastiquestyle.h +++ b/src/widgets/styles/qplastiquestyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp index b41e85f31c..56e3dc56b4 100644 --- a/src/widgets/styles/qproxystyle.cpp +++ b/src/widgets/styles/qproxystyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qproxystyle.h b/src/widgets/styles/qproxystyle.h index 96c5c34f18..e5d05eb3e5 100644 --- a/src/widgets/styles/qproxystyle.h +++ b/src/widgets/styles/qproxystyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qproxystyle_p.h b/src/widgets/styles/qproxystyle_p.h index 9ccd382cd3..3dc960afcd 100644 --- a/src/widgets/styles/qproxystyle_p.h +++ b/src/widgets/styles/qproxystyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 44b8f3bc0f..e4000bef19 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 6b296871d4..fcc8412414 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstyle_p.h b/src/widgets/styles/qstyle_p.h index dfb0e95731..3fd221938d 100644 --- a/src/widgets/styles/qstyle_p.h +++ b/src/widgets/styles/qstyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp index 8c1b9cb7e1..cc19a895d0 100644 --- a/src/widgets/styles/qstylefactory.cpp +++ b/src/widgets/styles/qstylefactory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE -#if !defined(QT_NO_STYLE_MAC) && defined(Q_WS_MAC) +#if !defined(QT_NO_STYLE_MAC) && defined(Q_OS_MAC) QT_BEGIN_INCLUDE_NAMESPACE # include "qmacstyle_mac.h" QT_END_INCLUDE_NAMESPACE diff --git a/src/widgets/styles/qstylefactory.h b/src/widgets/styles/qstylefactory.h index b972c8e0e6..f98d37b26e 100644 --- a/src/widgets/styles/qstylefactory.h +++ b/src/widgets/styles/qstylefactory.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index bf7cb49bcf..8f2d7364c1 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -46,17 +46,13 @@ #include <private/qstyle_p.h> #include <qmath.h> -#if defined(Q_WS_WIN) -#include "qt_windows.h" -#elif defined(Q_WS_MAC) -#include <private/qt_cocoa_helpers_mac_p.h> -#endif - #include "qstylehelper_p.h" #include <qstringbuilder.h> QT_BEGIN_NAMESPACE +Q_GUI_EXPORT int qt_defaultDpiX(); + namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) @@ -81,20 +77,7 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & qreal dpiScaled(qreal value) { - static qreal scale = -1; - if (scale < 0) { - scale = 1.0; -#if defined(Q_WS_WIN) - { - HDC hdcScreen = GetDC(0); - int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX); - ReleaseDC(0, hdcScreen); - scale = dpi/96.0; - } -#elif defined(Q_WS_MAC) - scale = qt_mac_get_scalefactor(); -#endif - } + static const qreal scale = qreal(qt_defaultDpiX()) / 96.0; return value * scale; } diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index f2bb81929c..a193e2ec78 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 01e3f0e384..0e4a1e98f8 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index 0640eef606..56203a6615 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstylepainter.cpp b/src/widgets/styles/qstylepainter.cpp index 3dc3f9dce7..9870f01dd0 100644 --- a/src/widgets/styles/qstylepainter.cpp +++ b/src/widgets/styles/qstylepainter.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstylepainter.h b/src/widgets/styles/qstylepainter.h index ccb591c0f9..56c6684507 100644 --- a/src/widgets/styles/qstylepainter.h +++ b/src/widgets/styles/qstylepainter.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstyleplugin.cpp b/src/widgets/styles/qstyleplugin.cpp index 836f388c23..8a169d9797 100644 --- a/src/widgets/styles/qstyleplugin.cpp +++ b/src/widgets/styles/qstyleplugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstyleplugin.h b/src/widgets/styles/qstyleplugin.h index ab55cdf54c..c9a35caaa4 100644 --- a/src/widgets/styles/qstyleplugin.h +++ b/src/widgets/styles/qstyleplugin.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index ab611aedde..b384ff7681 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstylesheetstyle_default.cpp b/src/widgets/styles/qstylesheetstyle_default.cpp index c9cfc435fa..580232f326 100644 --- a/src/widgets/styles/qstylesheetstyle_default.cpp +++ b/src/widgets/styles/qstylesheetstyle_default.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h index 1d38627edf..2d89f784d4 100644 --- a/src/widgets/styles/qstylesheetstyle_p.h +++ b/src/widgets/styles/qstylesheetstyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowscestyle.cpp b/src/widgets/styles/qwindowscestyle.cpp index 39174f9855..fd3a391e54 100644 --- a/src/widgets/styles/qwindowscestyle.cpp +++ b/src/widgets/styles/qwindowscestyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowscestyle.h b/src/widgets/styles/qwindowscestyle.h index 3db9be58e2..dbb83a910e 100644 --- a/src/widgets/styles/qwindowscestyle.h +++ b/src/widgets/styles/qwindowscestyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowscestyle_p.h b/src/widgets/styles/qwindowscestyle_p.h index d32ac99d52..6b3b9a8bfe 100644 --- a/src/widgets/styles/qwindowscestyle_p.h +++ b/src/widgets/styles/qwindowscestyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsmobilestyle.cpp b/src/widgets/styles/qwindowsmobilestyle.cpp index 1e029a30e0..efba73fe80 100644 --- a/src/widgets/styles/qwindowsmobilestyle.cpp +++ b/src/widgets/styles/qwindowsmobilestyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsmobilestyle.h b/src/widgets/styles/qwindowsmobilestyle.h index 050f641888..65eb08707f 100644 --- a/src/widgets/styles/qwindowsmobilestyle.h +++ b/src/widgets/styles/qwindowsmobilestyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsmobilestyle_p.h b/src/widgets/styles/qwindowsmobilestyle_p.h index 32ebe911ef..23b395e3a6 100644 --- a/src/widgets/styles/qwindowsmobilestyle_p.h +++ b/src/widgets/styles/qwindowsmobilestyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index f883ace67e..1029433fe6 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -392,16 +392,9 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW break; #endif case PM_MaximumDragDistance: -#if defined(Q_OS_WIN) - { - HDC hdcScreen = GetDC(0); - int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX); - ReleaseDC(0, hdcScreen); - ret = (int)(dpi * 1.375); - } -#else - ret = 60; -#endif + ret = QCommonStyle::pixelMetric(PM_MaximumDragDistance); + if (ret == -1) + ret = 60; break; #ifndef QT_NO_SLIDER @@ -530,13 +523,6 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW ret = GetSystemMetrics(SM_CYFRAME); #endif break; - case PM_TextCursorWidth: { - DWORD caretWidth = 1; -#if defined(SPI_GETCARETWIDTH) - SystemParametersInfo(SPI_GETCARETWIDTH, 0, &caretWidth, 0); -#endif - ret = (int)caretWidth; - break; } #endif case PM_ToolBarItemMargin: ret = 1; diff --git a/src/widgets/styles/qwindowsstyle.h b/src/widgets/styles/qwindowsstyle.h index acecfa9140..5392409882 100644 --- a/src/widgets/styles/qwindowsstyle.h +++ b/src/widgets/styles/qwindowsstyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h index 1e517e9e79..9861172873 100644 --- a/src/widgets/styles/qwindowsstyle_p.h +++ b/src/widgets/styles/qwindowsstyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index d83ad855c2..bbc07a5bd9 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsvistastyle.h b/src/widgets/styles/qwindowsvistastyle.h index 68b489107e..dec8f16aee 100644 --- a/src/widgets/styles/qwindowsvistastyle.h +++ b/src/widgets/styles/qwindowsvistastyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsvistastyle_p.h b/src/widgets/styles/qwindowsvistastyle_p.h index 4167bc4d0f..8ed2ec421e 100644 --- a/src/widgets/styles/qwindowsvistastyle_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 8b13794d05..d8b33f3b0f 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsxpstyle.h b/src/widgets/styles/qwindowsxpstyle.h index 1cfd16479b..87bccc2271 100644 --- a/src/widgets/styles/qwindowsxpstyle.h +++ b/src/widgets/styles/qwindowsxpstyle.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/qwindowsxpstyle_p.h b/src/widgets/styles/qwindowsxpstyle_p.h index 05ab2ec2e4..1fb89cb478 100644 --- a/src/widgets/styles/qwindowsxpstyle_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri index cf7ee5a0a4..ef6827f74f 100644 --- a/src/widgets/styles/styles.pri +++ b/src/widgets/styles/styles.pri @@ -37,8 +37,7 @@ contains( styles, all ) { styles = mac windows windowsxp windowsvista } -# TODO, re-enable qmacstyle in tests/auto/widgets/styles/sytles.pro when done -styles -= mac +!macx-*:styles -= mac x11{ QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE diff --git a/src/widgets/util/qcolormap.h b/src/widgets/util/qcolormap.h index ebb5142768..c0c3643985 100644 --- a/src/widgets/util/qcolormap.h +++ b/src/widgets/util/qcolormap.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qcolormap.qdoc b/src/widgets/util/qcolormap.qdoc index 88deabcfd6..fd6da862ec 100644 --- a/src/widgets/util/qcolormap.qdoc +++ b/src/widgets/util/qcolormap.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qcolormap_qpa.cpp b/src/widgets/util/qcolormap_qpa.cpp index 6ad3abb3aa..284809af24 100644 --- a/src/widgets/util/qcolormap_qpa.cpp +++ b/src/widgets/util/qcolormap_qpa.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index e99dd9ffc5..aa38aba08e 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -147,7 +147,7 @@ #ifndef QT_NO_COMPLETER #include "QtWidgets/qscrollbar.h" -#include "QtWidgets/qstringlistmodel.h" +#include "QtCore/qstringlistmodel.h" #include "QtWidgets/qdirmodel.h" #include "QtWidgets/qfilesystemmodel.h" #include "QtWidgets/qheaderview.h" diff --git a/src/widgets/util/qcompleter.h b/src/widgets/util/qcompleter.h index c7e1b6e945..68fe22f88f 100644 --- a/src/widgets/util/qcompleter.h +++ b/src/widgets/util/qcompleter.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h index 639c875568..94287c1ebf 100644 --- a/src/widgets/util/qcompleter_p.h +++ b/src/widgets/util/qcompleter_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -59,7 +59,7 @@ #ifndef QT_NO_COMPLETER #include "QtWidgets/qtreeview.h" -#include "QtWidgets/qabstractproxymodel.h" +#include "QtCore/qabstractproxymodel.h" #include "qcompleter.h" #include "QtWidgets/qitemdelegate.h" #include "QtGui/qpainter.h" diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index fbbefcf89f..843a2fa95c 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qflickgesture_p.h b/src/widgets/util/qflickgesture_p.h index 23c8b6e788..6a9630ede6 100644 --- a/src/widgets/util/qflickgesture_p.h +++ b/src/widgets/util/qflickgesture_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index 2ab19c40ab..fac6809ac6 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -1524,10 +1524,8 @@ void QScrollerPrivate::handleDrag(const QPointF &position, qint64 timestamp) dragDistance += deltaPixel; // } //qScrollerDebug() << "######################" << deltaPixel << position.y() << lastPosition.y(); - if (canScrollX) - lastPosition.setX(position.x()); - if (canScrollY) - lastPosition.setY(position.y()); + + lastPosition = position; lastTimestamp = timestamp; } diff --git a/src/widgets/util/qscroller.h b/src/widgets/util/qscroller.h index 3484139cbb..01d45a908e 100644 --- a/src/widgets/util/qscroller.h +++ b/src/widgets/util/qscroller.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qscroller_mac.mm b/src/widgets/util/qscroller_mac.mm index 81d18aaf6b..495469a04b 100644 --- a/src/widgets/util/qscroller_mac.mm +++ b/src/widgets/util/qscroller_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qscroller_p.h b/src/widgets/util/qscroller_p.h index b4f4db5e34..3b9fa988fe 100644 --- a/src/widgets/util/qscroller_p.h +++ b/src/widgets/util/qscroller_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qscrollerproperties.cpp b/src/widgets/util/qscrollerproperties.cpp index dda83c2b33..3a41aa7eb9 100644 --- a/src/widgets/util/qscrollerproperties.cpp +++ b/src/widgets/util/qscrollerproperties.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qscrollerproperties.h b/src/widgets/util/qscrollerproperties.h index 73c1125fe0..e7bcdbebe3 100644 --- a/src/widgets/util/qscrollerproperties.h +++ b/src/widgets/util/qscrollerproperties.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qscrollerproperties_p.h b/src/widgets/util/qscrollerproperties_p.h index 2e57a3f7dd..8c51f7aa4b 100644 --- a/src/widgets/util/qscrollerproperties_p.h +++ b/src/widgets/util/qscrollerproperties_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 3ca5d459a7..5803c2fef4 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qsystemtrayicon.h b/src/widgets/util/qsystemtrayicon.h index 3327ce4223..0f1e7d74ee 100644 --- a/src/widgets/util/qsystemtrayicon.h +++ b/src/widgets/util/qsystemtrayicon.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qsystemtrayicon_mac.mm b/src/widgets/util/qsystemtrayicon_mac.mm index 5553c63723..278fa72a1a 100644 --- a/src/widgets/util/qsystemtrayicon_mac.mm +++ b/src/widgets/util/qsystemtrayicon_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h index ce2404ae8b..7b743021e0 100644 --- a/src/widgets/util/qsystemtrayicon_p.h +++ b/src/widgets/util/qsystemtrayicon_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qsystemtrayicon_qpa.cpp b/src/widgets/util/qsystemtrayicon_qpa.cpp index 9a4f12d02d..ce0e067648 100644 --- a/src/widgets/util/qsystemtrayicon_qpa.cpp +++ b/src/widgets/util/qsystemtrayicon_qpa.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index 7a572849b0..6045116da5 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qsystemtrayicon_wince.cpp b/src/widgets/util/qsystemtrayicon_wince.cpp index 7a403a3ee5..b1dbb8b85e 100644 --- a/src/widgets/util/qsystemtrayicon_wince.cpp +++ b/src/widgets/util/qsystemtrayicon_wince.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 86c27499b4..3ac3755f84 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qundogroup.cpp b/src/widgets/util/qundogroup.cpp index 44c00afe98..fd063b7e9f 100644 --- a/src/widgets/util/qundogroup.cpp +++ b/src/widgets/util/qundogroup.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qundogroup.h b/src/widgets/util/qundogroup.h index ce2dac2503..fe06a678eb 100644 --- a/src/widgets/util/qundogroup.h +++ b/src/widgets/util/qundogroup.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp index 9841a09ce6..5f2ba870e0 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/widgets/util/qundostack.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qundostack.h b/src/widgets/util/qundostack.h index 493d11fdb7..fc2c82ecf4 100644 --- a/src/widgets/util/qundostack.h +++ b/src/widgets/util/qundostack.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qundostack_p.h b/src/widgets/util/qundostack_p.h index 1e5f99bc6c..31dff8452c 100644 --- a/src/widgets/util/qundostack_p.h +++ b/src/widgets/util/qundostack_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp index c95e89f76e..c498355f1f 100644 --- a/src/widgets/util/qundoview.cpp +++ b/src/widgets/util/qundoview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/util/qundoview.h b/src/widgets/util/qundoview.h index 9df2995f9d..ee944dd259 100644 --- a/src/widgets/util/qundoview.h +++ b/src/widgets/util/qundoview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index ae5b06024a..efe0ff3389 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index 6527c6cd32..9b3aa5642a 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qabstractbutton_p.h b/src/widgets/widgets/qabstractbutton_p.h index d2d4c06bff..9688d27773 100644 --- a/src/widgets/widgets/qabstractbutton_p.h +++ b/src/widgets/widgets/qabstractbutton_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 801160d080..655ed83069 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -572,7 +572,7 @@ void QAbstractScrollArea::setViewport(QWidget *widget) d->layoutChildren(); if (isVisible()) d->viewport->show(); - QMetaObject::invokeMethod(this, "setupViewport", Q_ARG(QWidget *, widget)); + setupViewport(widget); delete oldViewport; } } diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h index 3f2a273297..fe602468f9 100644 --- a/src/widgets/widgets/qabstractscrollarea.h +++ b/src/widgets/widgets/qabstractscrollarea.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -90,8 +90,7 @@ public: QSize sizeHint() const; -protected Q_SLOTS: - void setupViewport(QWidget *viewport); + virtual void setupViewport(QWidget *viewport); protected: QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0); diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h index 5511d08f4e..2fe7e4423a 100644 --- a/src/widgets/widgets/qabstractscrollarea_p.h +++ b/src/widgets/widgets/qabstractscrollarea_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index 694db0e125..d3dddde409 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -943,60 +943,4 @@ bool QAbstractSlider::event(QEvent *e) return QWidget::event(e); } -/*! \fn int QAbstractSlider::minValue() const - - Use minimum() instead. -*/ - -/*! \fn int QAbstractSlider::maxValue() const - - Use maximum() instead. -*/ - -/*! \fn int QAbstractSlider::lineStep() const - - Use singleStep() instead. -*/ - -/*! \fn void QAbstractSlider::setMinValue(int v) - - Use setMinimum() instead. -*/ - -/*! \fn void QAbstractSlider::setMaxValue(int v) - - Use setMaximum() instead. -*/ - -/*! \fn void QAbstractSlider::setLineStep(int v) - - Use setSingleStep() instead. -*/ - -/*! \fn void QAbstractSlider::addPage() - - Use triggerAction(QAbstractSlider::SliderPageStepAdd) instead. -*/ - -/*! \fn void QAbstractSlider::subtractPage() - - Use triggerAction(QAbstractSlider::SliderPageStepSub) instead. -*/ - -/*! \fn void QAbstractSlider::addLine() - - Use triggerAction(QAbstractSlider::SliderSingleStepAdd) instead. -*/ - -/*! \fn void QAbstractSlider::subtractLine() - - Use triggerAction(QAbstractSlider::SliderSingleStepSub) instead. -*/ - -/*! \fn void QAbstractSlider::setSteps(int single, int page) - - Use setSingleStep(\a single) followed by setPageStep(\a page) - instead. -*/ - QT_END_NAMESPACE diff --git a/src/widgets/widgets/qabstractslider.h b/src/widgets/widgets/qabstractslider.h index b1f63a2c89..a19fc37451 100644 --- a/src/widgets/widgets/qabstractslider.h +++ b/src/widgets/widgets/qabstractslider.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qabstractslider_p.h b/src/widgets/widgets/qabstractslider_p.h index fdbc0f9534..a4589c5d18 100644 --- a/src/widgets/widgets/qabstractslider_p.h +++ b/src/widgets/widgets/qabstractslider_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 82340d15ed..4f5a135842 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -48,6 +48,7 @@ #ifndef QT_NO_SPINBOX #include <qapplication.h> +#include <qstylehints.h> #include <qclipboard.h> #include <qdatetime.h> #include <qdatetimeedit.h> @@ -1169,15 +1170,6 @@ void QAbstractSpinBox::hideEvent(QHideEvent *event) Remember that time value should be given in msecs. */ -static int getKeyboardAutoRepeatRate() { - int ret = 30; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - DWORD time; - if (SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &time, 0) != FALSE) - ret = static_cast<int>(1000 / static_cast<int>(time)); // msecs -#endif - return ret; // msecs -} /*! \reimp @@ -1192,7 +1184,7 @@ void QAbstractSpinBox::timerEvent(QTimerEvent *event) killTimer(d->spinClickThresholdTimerId); d->spinClickThresholdTimerId = -1; d->effectiveSpinRepeatRate = d->buttonState & Keyboard - ? getKeyboardAutoRepeatRate() + ? qApp->styleHints()->keyboardAutoRepeatRate() : d->spinClickTimerInterval; d->spinClickTimerId = startTimer(d->effectiveSpinRepeatRate); doStep = true; diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h index fb3ae2f5ee..8f963dce0d 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h index 33d4e32875..67a09622a2 100644 --- a/src/widgets/widgets/qabstractspinbox_p.h +++ b/src/widgets/widgets/qabstractspinbox_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index 101488a359..992c542674 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -258,13 +258,3 @@ \sa setId() */ - -/*! \fn void QButtonGroup::insert(QAbstractButton *b) - - Use addButton() instead. -*/ - -/*! \fn void QButtonGroup::remove(QAbstractButton *b) - - Use removeButton() instead. -*/ diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h index 56f93c0332..17c60e9609 100644 --- a/src/widgets/widgets/qbuttongroup.h +++ b/src/widgets/widgets/qbuttongroup.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcalendartextnavigator_p.h b/src/widgets/widgets/qcalendartextnavigator_p.h index b602c6d51e..2ce5233cec 100644 --- a/src/widgets/widgets/qcalendartextnavigator_p.h +++ b/src/widgets/widgets/qcalendartextnavigator_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index f16a594953..3bd1e3ec4f 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcalendarwidget.h b/src/widgets/widgets/qcalendarwidget.h index e73192c12d..1ab519386e 100644 --- a/src/widgets/widgets/qcalendarwidget.h +++ b/src/widgets/widgets/qcalendarwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp index cd49747f8c..386bd2b169 100644 --- a/src/widgets/widgets/qcheckbox.cpp +++ b/src/widgets/widgets/qcheckbox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h index d9a1aaaf3d..37461f1f10 100644 --- a/src/widgets/widgets/qcheckbox.h +++ b/src/widgets/widgets/qcheckbox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcocoatoolbardelegate_mac.mm b/src/widgets/widgets/qcocoatoolbardelegate_mac.mm index c6be7f131c..1127d01b19 100644 --- a/src/widgets/widgets/qcocoatoolbardelegate_mac.mm +++ b/src/widgets/widgets/qcocoatoolbardelegate_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h b/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h index 846c6933d8..56a4f4f062 100644 --- a/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h +++ b/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 2764833b48..4cbd7eab7d 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index e297dae1b5..4a5050b945 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 2d3f261d6e..a9d792f07d 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcommandlinkbutton.cpp b/src/widgets/widgets/qcommandlinkbutton.cpp index afd14f63c5..d61eeb6131 100644 --- a/src/widgets/widgets/qcommandlinkbutton.cpp +++ b/src/widgets/widgets/qcommandlinkbutton.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h index 9d01e37b1b..726e0360d2 100644 --- a/src/widgets/widgets/qcommandlinkbutton.h +++ b/src/widgets/widgets/qcommandlinkbutton.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index f6b52658c7..871a394a80 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h index a57a5f29e9..77c76c483e 100644 --- a/src/widgets/widgets/qdatetimeedit.h +++ b/src/widgets/widgets/qdatetimeedit.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 57799d5bc0..0669c7c330 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp index bc77faf993..26cea362c2 100644 --- a/src/widgets/widgets/qdial.cpp +++ b/src/widgets/widgets/qdial.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -488,24 +488,6 @@ bool QDial::event(QEvent *e) return QAbstractSlider::event(e); } -/*! - \fn void QDial::dialPressed(); - - Use QAbstractSlider::sliderPressed() instead. -*/ - -/*! - \fn void QDial::dialMoved(int value); - - Use QAbstractSlider::sliderMoved() instead. -*/ - -/*! - \fn void QDial::dialReleased(); - - Use QAbstractSlider::sliderReleased() instead. -*/ - QT_END_NAMESPACE #endif // QT_NO_DIAL diff --git a/src/widgets/widgets/qdial.h b/src/widgets/widgets/qdial.h index 317a50df35..724028d129 100644 --- a/src/widgets/widgets/qdial.h +++ b/src/widgets/widgets/qdial.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 8085369a3f..e53bd55129 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdialogbuttonbox.h b/src/widgets/widgets/qdialogbuttonbox.h index 0a6e231e3f..2fca5a5791 100644 --- a/src/widgets/widgets/qdialogbuttonbox.h +++ b/src/widgets/widgets/qdialogbuttonbox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 1a1f16a493..1acd93ed60 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index a341ad487b..46ac966798 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index c02c13fe1e..32a73c54ed 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h index cc81db2fc2..d6270e4a99 100644 --- a/src/widgets/widgets/qdockwidget.h +++ b/src/widgets/widgets/qdockwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index 4d3c4f4d70..2bf50d8aa6 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index adf1cc1f87..ab04e2314f 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qeffects_p.h b/src/widgets/widgets/qeffects_p.h index bae2bbf54a..e26810835e 100644 --- a/src/widgets/widgets/qeffects_p.h +++ b/src/widgets/widgets/qeffects_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qfocusframe.cpp b/src/widgets/widgets/qfocusframe.cpp index 86187c2c4a..62dc8b64f2 100644 --- a/src/widgets/widgets/qfocusframe.cpp +++ b/src/widgets/widgets/qfocusframe.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -147,7 +147,7 @@ void QFocusFrame::initStyleOption(QStyleOption *option) const The focus frame will not monitor \a parent for updates but rather can be placed manually or by using QFocusFrame::setWidget. A QFocusFrame sets Qt::WA_NoChildEventsForParent attribute; as a - result the parent will not receive a QEvent::ChildInserted event, + result the parent will not receive a QEvent::ChildAdded event, this will make it possible to manually set the geometry of the QFocusFrame inside of a QSplitter or other child event monitoring widget. diff --git a/src/widgets/widgets/qfocusframe.h b/src/widgets/widgets/qfocusframe.h index f4f1d1c854..ed117ddd6c 100644 --- a/src/widgets/widgets/qfocusframe.h +++ b/src/widgets/widgets/qfocusframe.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index 9090230029..845f37ccf1 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qfontcombobox.h b/src/widgets/widgets/qfontcombobox.h index b0007207da..33eec561af 100644 --- a/src/widgets/widgets/qfontcombobox.h +++ b/src/widgets/widgets/qfontcombobox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp index e017513541..d0de825467 100644 --- a/src/widgets/widgets/qframe.cpp +++ b/src/widgets/widgets/qframe.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qframe.h b/src/widgets/widgets/qframe.h index 4e11a6289b..51cd391185 100644 --- a/src/widgets/widgets/qframe.h +++ b/src/widgets/widgets/qframe.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qframe_p.h b/src/widgets/widgets/qframe_p.h index 8825abaf92..a74780fa60 100644 --- a/src/widgets/widgets/qframe_p.h +++ b/src/widgets/widgets/qframe_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index c850021bdd..1bad9a5b56 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h index a4e2327267..70bc4cde38 100644 --- a/src/widgets/widgets/qgroupbox.h +++ b/src/widgets/widgets/qgroupbox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index 2f0f43fbf4..1503085661 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h index e249c2d876..5d61cafab0 100644 --- a/src/widgets/widgets/qlabel.h +++ b/src/widgets/widgets/qlabel.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h index b6f2db6a25..8de0e301fd 100644 --- a/src/widgets/widgets/qlabel_p.h +++ b/src/widgets/widgets/qlabel_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp index 1b5fbe3417..48836a52d7 100644 --- a/src/widgets/widgets/qlcdnumber.cpp +++ b/src/widgets/widgets/qlcdnumber.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qlcdnumber.h b/src/widgets/widgets/qlcdnumber.h index 6af2b185ea..fcea53ef28 100644 --- a/src/widgets/widgets/qlcdnumber.h +++ b/src/widgets/widgets/qlcdnumber.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 4dc30d6542..5714052059 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -68,10 +68,6 @@ #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif -#ifndef QT_NO_IM -#include "qinputcontext.h" -#include "qlist.h" -#endif #include "qabstractitemview.h" #include "private/qstylesheetstyle_p.h" @@ -490,9 +486,9 @@ void QLineEdit::setEchoMode(EchoMode mode) imHints &= ~Qt::ImhHiddenText; } if (mode != Normal) { - imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); } else { - imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); } setInputMethodHints(imHints); d->control->setEchoMode(mode); @@ -2062,15 +2058,6 @@ QMenu *QLineEdit::createStandardContextMenu() d->selectAllAction = action; connect(action, SIGNAL(triggered()), SLOT(selectAll())); -#if !defined(QT_NO_IM) - QInputContext *qic = inputContext(); - if (qic) { - QList<QAction *> imActions = qic->actions(); - for (int i = 0; i < imActions.size(); ++i) - popup->addAction(imActions.at(i)); - } -#endif - #if defined(Q_WS_WIN) || defined(Q_WS_X11) if (!d->control->isReadOnly() && qt_use_rtl_extensions) { #else diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 107710eccc..2daa893b3b 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index b17651e1d3..c54f60f62e 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -51,7 +51,7 @@ #include "qaccessible.h" #endif #ifndef QT_NO_IM -#include "qinputcontext.h" +#include "qinputpanel.h" #include "qlist.h" #endif @@ -249,23 +249,22 @@ void QLineEditPrivate::resetInputPanel() /*! This function is not intended as polymorphic usage. Just a shared code - fragment that calls QInputContext::mouseHandler for this + fragment that calls QInputPanel::invokeAction for this class. */ bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e ) { #if !defined QT_NO_IM - Q_Q(QLineEdit); if ( control->composeMode() ) { int tmp_cursor = xToPos(e->pos().x()); int mousePos = tmp_cursor - control->cursor(); if ( mousePos < 0 || mousePos > control->preeditAreaText().length() ) mousePos = -1; - QInputContext *qic = q->inputContext(); - if (qic && mousePos >= 0) { - // may be causing reset() in some input methods - qic->mouseHandler(mousePos, e); + if (mousePos >= 0) { + if (e->type() == QEvent::MouseButtonRelease) + qApp->inputPanel()->invokeAction(QInputPanel::Click, mousePos); + return true; } } diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 076f2fcf11..206e835a74 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h index 48eac4f490..8824fde912 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm index b79ee3d4e0..8facb4db61 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h index 935feac58e..2b4d4fbdae 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.h +++ b/src/widgets/widgets/qmacnativewidget_mac.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm index 08f78158ee..925ef3d8a9 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.mm +++ b/src/widgets/widgets/qmacnativewidget_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 014700f389..ad1890a708 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index 88cff31841..43d269ef6f 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index ebabf2d93c..32d893630f 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmainwindowlayout_mac.mm b/src/widgets/widgets/qmainwindowlayout_mac.mm index ba5d1d5673..b6fcca88fa 100644 --- a/src/widgets/widgets/qmainwindowlayout_mac.mm +++ b/src/widgets/widgets/qmainwindowlayout_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 9d3f127158..34d94119ad 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index f66c71315a..021af9be0b 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmdiarea.h b/src/widgets/widgets/qmdiarea.h index f1ffb29e53..fbd07ad249 100644 --- a/src/widgets/widgets/qmdiarea.h +++ b/src/widgets/widgets/qmdiarea.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h index 18a022d7dd..e80c6b5ecb 100644 --- a/src/widgets/widgets/qmdiarea_p.h +++ b/src/widgets/widgets/qmdiarea_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 7fd2bd2a58..f2190313e9 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h index 88074c7ca5..332619c3b4 100644 --- a/src/widgets/widgets/qmdisubwindow.h +++ b/src/widgets/widgets/qmdisubwindow.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index d04a7d4b75..83a91fb39b 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index b8ba2cdf5d..a255b840dc 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -500,7 +500,7 @@ void QMenuPrivate::hideMenu(QMenu *menu, bool justRegister) menu->blockSignals(false); #endif // QT_NO_EFFECTS if (!justRegister) - menu->hide(); + menu->close(); } void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst) diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 49bf8295ec..645a15bdc8 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index df15512b3e..a6e700b528 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmenu_wince.cpp b/src/widgets/widgets/qmenu_wince.cpp index b0c6c1bd12..26a9302efb 100644 --- a/src/widgets/widgets/qmenu_wince.cpp +++ b/src/widgets/widgets/qmenu_wince.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmenu_wince_resource_p.h b/src/widgets/widgets/qmenu_wince_resource_p.h index 42de05f319..b40a9526e5 100644 --- a/src/widgets/widgets/qmenu_wince_resource_p.h +++ b/src/widgets/widgets/qmenu_wince_resource_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 1ceea3e78c..2908d4723e 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h index 0eb668e373..84fb378064 100644 --- a/src/widgets/widgets/qmenubar.h +++ b/src/widgets/widgets/qmenubar.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h index e9201fc877..de1ab37a19 100644 --- a/src/widgets/widgets/qmenubar_p.h +++ b/src/widgets/widgets/qmenubar_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 98a8999a98..9f92406a04 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index d5fa71bbb7..9860914b98 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h index 190156a684..8f880d9772 100644 --- a/src/widgets/widgets/qplaintextedit_p.h +++ b/src/widgets/widgets/qplaintextedit_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 3db91a6b6e..e731b63c66 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -192,9 +192,8 @@ bool QProgressBarPrivate::repaintRequired() const If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps. This is useful, for - example, when using QFtp or QNetworkAccessManager to download - items when they are unable to determine the size of the item being - downloaded. + example, when using QNetworkAccessManager to download items when + they are unable to determine the size of the item being downloaded. \table \row \o \inlineimage macintosh-progressbar.png Screenshot of a Macintosh style progress bar diff --git a/src/widgets/widgets/qprogressbar.h b/src/widgets/widgets/qprogressbar.h index ac34f64a2e..cdb6d36dfd 100644 --- a/src/widgets/widgets/qprogressbar.h +++ b/src/widgets/widgets/qprogressbar.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index e3993167ef..ff477ec1d7 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h index fefbd9e81f..1dc0a19542 100644 --- a/src/widgets/widgets/qpushbutton.h +++ b/src/widgets/widgets/qpushbutton.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qpushbutton_p.h b/src/widgets/widgets/qpushbutton_p.h index 0056288a98..d77b69a341 100644 --- a/src/widgets/widgets/qpushbutton_p.h +++ b/src/widgets/widgets/qpushbutton_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qradiobutton.cpp b/src/widgets/widgets/qradiobutton.cpp index b9567a0a11..1cf321bd16 100644 --- a/src/widgets/widgets/qradiobutton.cpp +++ b/src/widgets/widgets/qradiobutton.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h index f1d9f5500a..aa3458bf95 100644 --- a/src/widgets/widgets/qradiobutton.h +++ b/src/widgets/widgets/qradiobutton.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qrubberband.cpp b/src/widgets/widgets/qrubberband.cpp index d0ea05f5cd..bb67b292af 100644 --- a/src/widgets/widgets/qrubberband.cpp +++ b/src/widgets/widgets/qrubberband.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qrubberband.h b/src/widgets/widgets/qrubberband.h index 3d30004770..05b35a772b 100644 --- a/src/widgets/widgets/qrubberband.h +++ b/src/widgets/widgets/qrubberband.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp index 48c179a9ab..9912b5e211 100644 --- a/src/widgets/widgets/qscrollarea.cpp +++ b/src/widgets/widgets/qscrollarea.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h index 2d62cc1bc4..0dcd280894 100644 --- a/src/widgets/widgets/qscrollarea.h +++ b/src/widgets/widgets/qscrollarea.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h index 0e5e21b7c0..e36e99add2 100644 --- a/src/widgets/widgets/qscrollarea_p.h +++ b/src/widgets/widgets/qscrollarea_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index b8cd81c6a7..47a10de702 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qscrollbar.h b/src/widgets/widgets/qscrollbar.h index f51a000a12..ac6146cc3f 100644 --- a/src/widgets/widgets/qscrollbar.h +++ b/src/widgets/widgets/qscrollbar.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index d4cfce984d..9f02c131ea 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qsizegrip.h b/src/widgets/widgets/qsizegrip.h index 144eb8e160..acac950b44 100644 --- a/src/widgets/widgets/qsizegrip.h +++ b/src/widgets/widgets/qsizegrip.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qslider.cpp b/src/widgets/widgets/qslider.cpp index 9dd73f8c96..0f646fc19d 100644 --- a/src/widgets/widgets/qslider.cpp +++ b/src/widgets/widgets/qslider.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qslider.h b/src/widgets/widgets/qslider.h index c6620d253b..a050f229fb 100644 --- a/src/widgets/widgets/qslider.h +++ b/src/widgets/widgets/qslider.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index 47cc8bbcf3..89743740de 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -1250,36 +1250,6 @@ QString QDoubleSpinBoxPrivate::textFromValue(const QVariant &f) const return q->textFromValue(f.toDouble()); } -/*! - \fn void QSpinBox::setLineStep(int step) - - Use setSingleStep() instead. -*/ - -/*! - \fn void QSpinBox::setMaxValue(int value) - - Use setMaximum() instead. -*/ - -/*! - \fn void QSpinBox::setMinValue(int value) - - Use setMinimum() instead. -*/ - -/*! - \fn int QSpinBox::maxValue() const - - Use maximum() instead. -*/ - -/*! - \fn int QSpinBox::minValue() const - - Use minimum() instead. -*/ - /*! \reimp */ bool QSpinBox::event(QEvent *event) { diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h index 0846103cca..bfc91b1ecf 100644 --- a/src/widgets/widgets/qspinbox.h +++ b/src/widgets/widgets/qspinbox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index 7140487463..4fb0f3fa76 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h index 133146943e..f58b78adcb 100644 --- a/src/widgets/widgets/qsplashscreen.h +++ b/src/widgets/widgets/qsplashscreen.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index b725ee039a..ca22e0718a 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -1675,7 +1675,6 @@ void QSplitter::setStretchFactor(int index, int stretch) } -#ifndef QT_NO_TEXTSTREAM /*! \relates QSplitter \obsolete @@ -1706,7 +1705,6 @@ QTextStream& operator>>(QTextStream& ts, QSplitter& splitter) splitter.restoreState(line.toAscii()); return ts; } -#endif // QT_NO_TEXTSTREAM QT_END_NAMESPACE diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h index 71252ede24..ee62ab76f2 100644 --- a/src/widgets/widgets/qsplitter.h +++ b/src/widgets/widgets/qsplitter.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -133,10 +133,8 @@ private: friend class QSplitterHandle; }; -#ifndef QT_NO_TEXTSTREAM Q_WIDGETS_EXPORT QTextStream& operator<<(QTextStream&, const QSplitter&); Q_WIDGETS_EXPORT QTextStream& operator>>(QTextStream&, QSplitter&); -#endif class QSplitterHandlePrivate; class Q_WIDGETS_EXPORT QSplitterHandle : public QWidget diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h index 05e7a35165..a06b65c5d3 100644 --- a/src/widgets/widgets/qsplitter_p.h +++ b/src/widgets/widgets/qsplitter_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp index 4e9349e348..5544f241a9 100644 --- a/src/widgets/widgets/qstackedwidget.cpp +++ b/src/widgets/widgets/qstackedwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qstackedwidget.h b/src/widgets/widgets/qstackedwidget.h index e0275fe27f..8dc24dd56f 100644 --- a/src/widgets/widgets/qstackedwidget.h +++ b/src/widgets/widgets/qstackedwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp index 295d509444..357c3c72d1 100644 --- a/src/widgets/widgets/qstatusbar.cpp +++ b/src/widgets/widgets/qstatusbar.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h index c983f6d199..e24e9da150 100644 --- a/src/widgets/widgets/qstatusbar.h +++ b/src/widgets/widgets/qstatusbar.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 4fd7a31c41..c939c4aa7c 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h index d33e6bbb1b..cfe9a90b47 100644 --- a/src/widgets/widgets/qtabbar.h +++ b/src/widgets/widgets/qtabbar.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index 69ca361967..2060e169f2 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp index a01316145e..636a68994a 100644 --- a/src/widgets/widgets/qtabwidget.cpp +++ b/src/widgets/widgets/qtabwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -154,15 +154,6 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QTabWidget::selected(const QString &tabLabel) - - This signal is emitted whenever a tab is selected (raised), - including during the first show(). - - You can normally use currentChanged() instead. -*/ - -/*! \fn void QTabWidget::currentChanged(int index) This signal is emitted whenever the current page index changes. @@ -1345,153 +1336,6 @@ void QTabWidget::clear() removeTab(0); } -/*! - \fn void QTabWidget::insertTab(QWidget *widget, const QString &label, int index) - - Use insertTab(index, widget, label) instead. -*/ - -/*! - \fn void QTabWidget::insertTab(QWidget *widget, const QIcon& icon, const QString &label, int index) - - Use insertTab(index, widget, icon, label) instead. -*/ - -/*! - \fn void QTabWidget::changeTab(QWidget *widget, const QString - &label) - - Use setTabText() instead. - -*/ - -/*! - \fn void QTabWidget::changeTab(QWidget *widget, const QIcon& icon, const QString &label) - - Use setTabText() and setTabIcon() instead. -*/ - -/*! - \fn bool QTabWidget::isTabEnabled( QWidget *widget) const - - Use isTabEnabled(tabWidget->indexOf(widget)) instead. -*/ - -/*! - \fn void QTabWidget::setTabEnabled(QWidget *widget, bool b) - - Use setTabEnabled(tabWidget->indexOf(widget), b) instead. -*/ - -/*! - \fn QString QTabWidget::tabLabel(QWidget *widget) const - - Use tabText(tabWidget->indexOf(widget)) instead. -*/ - -/*! - \fn void QTabWidget::setTabLabel(QWidget *widget, const QString - &label) - - Use setTabText(tabWidget->indexOf(widget), label) instead. -*/ - -/*! - \fn QIcon QTabWidget::tabIconSet(QWidget * widget) const - - Use tabIcon(tabWidget->indexOf(widget)) instead. -*/ - -/*! - \fn void QTabWidget::setTabIconSet(QWidget * widget, const QIcon & icon) - - Use setTabIcon(tabWidget->indexOf(widget), icon) instead. -*/ - -/*! - \fn void QTabWidget::removeTabToolTip(QWidget * widget) - - Use setTabToolTip(tabWidget->indexOf(widget), QString()) instead. -*/ - -/*! - \fn void QTabWidget::setTabToolTip(QWidget * widget, const QString & tip) - - Use setTabToolTip(tabWidget->indexOf(widget), tip) instead. -*/ - -/*! - \fn QString QTabWidget::tabToolTip(QWidget * widget) const - - Use tabToolTip(tabWidget->indexOf(widget)) instead. -*/ - -/*! - \fn QWidget * QTabWidget::currentPage() const - - Use currentWidget() instead. -*/ - -/*! - \fn QWidget *QTabWidget::page(int index) const - - Use widget() instead. -*/ - -/*! - \fn QString QTabWidget::label(int index) const - - Use tabText() instead. -*/ - -/*! - \fn int QTabWidget::currentPageIndex() const - - Use currentIndex() instead. -*/ - -/*! - \fn int QTabWidget::margin() const - - This function is kept only to make old code compile. - This functionality is no longer supported by QTabWidget. - - \sa contentsRect(), setContentsMargins() -*/ - -/*! - \fn void QTabWidget::setMargin(int margin) - - This function is kept only to make old code compile. - This functionality is no longer supported by QTabWidget. - - \sa contentsRect(), setContentsMargins() -*/ - -/*! - \fn void QTabWidget::setCurrentPage(int index) - - Use setCurrentIndex() instead. -*/ - -/*! - \fn void QTabWidget::showPage(QWidget *widget) - - Use setCurrentIndex(indexOf(widget)) instead. -*/ - -/*! - \fn void QTabWidget::removePage(QWidget *widget) - - Use removeTab(indexOf(widget)) instead. -*/ - -/*! - \fn void QTabWidget::currentChanged(QWidget *widget) - - Use currentChanged(int) instead. -*/ - QT_END_NAMESPACE #include "moc_qtabwidget.cpp" diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h index ff734ed722..432870df25 100644 --- a/src/widgets/widgets/qtabwidget.h +++ b/src/widgets/widgets/qtabwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index e8fad6cebc..dbda9e3b94 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h index b7ec942753..ee977be23b 100644 --- a/src/widgets/widgets/qtextbrowser.h +++ b/src/widgets/widgets/qtextbrowser.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index cd55716daf..acd663eb8c 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -179,7 +179,6 @@ void QTextEditPrivate::init(const QString &html) q->setFocusPolicy(Qt::WheelFocus); q->setAttribute(Qt::WA_KeyCompression); q->setAttribute(Qt::WA_InputMethodEnabled); - q->setInputMethodHints(Qt::ImhMultiLine); #ifndef QT_NO_CURSOR viewport->setCursor(Qt::IBeamCursor); diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index ae9865977f..b86c0e0999 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtextedit_p.h b/src/widgets/widgets/qtextedit_p.h index 3512c80ac4..e7f172ec0f 100644 --- a/src/widgets/widgets/qtextedit_p.h +++ b/src/widgets/widgets/qtextedit_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 3d3ef4f7b5..6b1d414830 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -435,7 +435,7 @@ void QToolBarPrivate::plug(const QRect &r) pop up a menu containing the items that does not currently fit in the toolbar. - When a QToolBar is not a child of a QMainWindow, it looses the ability + When a QToolBar is not a child of a QMainWindow, it loses the ability to populate the extension pop up with widgets added to the toolbar using addWidget(). Please use widget actions created by inheriting QWidgetAction and implementing QWidgetAction::createWidget() instead. diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h index 3e85d74e49..4f51cf045d 100644 --- a/src/widgets/widgets/qtoolbar.h +++ b/src/widgets/widgets/qtoolbar.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h index 70f1b6dca1..14ec575dc5 100644 --- a/src/widgets/widgets/qtoolbar_p.h +++ b/src/widgets/widgets/qtoolbar_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index fbd5ef2cd7..2650f7676e 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h index 940901df96..b61b2c76c9 100644 --- a/src/widgets/widgets/qtoolbararealayout_p.h +++ b/src/widgets/widgets/qtoolbararealayout_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbarextension.cpp b/src/widgets/widgets/qtoolbarextension.cpp index c522b416f2..341bd9cbb3 100644 --- a/src/widgets/widgets/qtoolbarextension.cpp +++ b/src/widgets/widgets/qtoolbarextension.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbarextension_p.h b/src/widgets/widgets/qtoolbarextension_p.h index d7f28bf0f3..a60584f755 100644 --- a/src/widgets/widgets/qtoolbarextension_p.h +++ b/src/widgets/widgets/qtoolbarextension_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index ac9be12ee2..2e5aaa61f2 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h index 4e4a8eab84..7c2a60d51a 100644 --- a/src/widgets/widgets/qtoolbarlayout_p.h +++ b/src/widgets/widgets/qtoolbarlayout_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbarseparator.cpp b/src/widgets/widgets/qtoolbarseparator.cpp index bd0ed9854f..4dd11679fa 100644 --- a/src/widgets/widgets/qtoolbarseparator.cpp +++ b/src/widgets/widgets/qtoolbarseparator.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbarseparator_p.h b/src/widgets/widgets/qtoolbarseparator_p.h index 0f1eb05abc..5807c9f0b8 100644 --- a/src/widgets/widgets/qtoolbarseparator_p.h +++ b/src/widgets/widgets/qtoolbarseparator_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp index a0bd1708fe..2bf0dc0d9d 100644 --- a/src/widgets/widgets/qtoolbox.cpp +++ b/src/widgets/widgets/qtoolbox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbox.h b/src/widgets/widgets/qtoolbox.h index ac4125229c..8e7ac52646 100644 --- a/src/widgets/widgets/qtoolbox.h +++ b/src/widgets/widgets/qtoolbox.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index ba0db96272..5b3a328dcc 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index 5ec507904a..c451e2cc13 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp index 9df7dfc0eb..de92a53257 100644 --- a/src/widgets/widgets/qwidgetanimator.cpp +++ b/src/widgets/widgets/qwidgetanimator.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qwidgetanimator_p.h b/src/widgets/widgets/qwidgetanimator_p.h index 40a2f274eb..d6e7a86e7b 100644 --- a/src/widgets/widgets/qwidgetanimator_p.h +++ b/src/widgets/widgets/qwidgetanimator_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 027512b6ae..e52193e20c 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -56,6 +56,22 @@ QT_BEGIN_NAMESPACE +#ifdef QT_GUI_PASSWORD_ECHO_DELAY +static const int qt_passwordEchoDelay = QT_GUI_PASSWORD_ECHO_DELAY; +#endif + +/*! + \macro QT_GUI_PASSWORD_ECHO_DELAY + + \internal + + Defines the amount of time in milliseconds the last entered character + should be displayed unmasked in the Password echo mode. + + If not defined in qplatformdefs.h there will be no delay in masking + password characters. +*/ + /*! \internal @@ -93,9 +109,25 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) else str = m_text; - if (m_echoMode == QLineEdit::Password || (m_echoMode == QLineEdit::PasswordEchoOnEdit - && !m_passwordEchoEditing)) + if (m_echoMode == QLineEdit::Password) { str.fill(m_passwordCharacter); +#ifdef QT_GUI_PASSWORD_ECHO_DELAY + if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.length()) { + int cursor = m_cursor - 1; + QChar uc = m_text.at(cursor); + str[cursor] = uc; + if (cursor > 0 && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) { + // second half of a surrogate, check if we have the first half as well, + // if yes restore both at once + uc = m_text.at(cursor - 1); + if (uc.unicode() >= 0xd800 && uc.unicode() < 0xdc00) + str[cursor - 1] = uc; + } + } +#endif + } else if (m_echoMode == QLineEdit::PasswordEchoOnEdit && !m_passwordEchoEditing) { + str.fill(m_passwordCharacter); + } // replace certain non-printable characters with spaces (to avoid // drawing boxes when using fonts that don't have glyphs for such @@ -354,6 +386,7 @@ void QWidgetLineControl::init(const QString &txt) */ void QWidgetLineControl::updatePasswordEchoEditing(bool editing) { + cancelPasswordEchoTimer(); m_passwordEchoEditing = editing; updateDisplayText(); } @@ -694,6 +727,8 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e m_selDirty = false; emit selectionChanged(); } + if (m_cursor == m_lastCursorPos) + updateMicroFocus(); emitCursorPositionChanged(); return true; } @@ -705,6 +740,7 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e */ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edited) { + cancelPasswordEchoTimer(); internalDeselect(); emit resetInputContext(); QString oldText = m_text; @@ -757,6 +793,13 @@ void QWidgetLineControl::addCommand(const Command &cmd) */ void QWidgetLineControl::internalInsert(const QString &s) { +#ifdef QT_GUI_PASSWORD_ECHO_DELAY + if (m_echoMode == QLineEdit::Password) { + if (m_passwordEchoTimer != 0) + killTimer(m_passwordEchoTimer); + m_passwordEchoTimer = startTimer(qt_passwordEchoDelay); + } +#endif if (hasSelectedText()) addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); if (m_maskData) { @@ -794,6 +837,7 @@ void QWidgetLineControl::internalInsert(const QString &s) void QWidgetLineControl::internalDelete(bool wasBackspace) { if (m_cursor < (int) m_text.length()) { + cancelPasswordEchoTimer(); if (hasSelectedText()) addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); addCommand(Command((CommandType)((m_maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)), @@ -820,6 +864,7 @@ void QWidgetLineControl::internalDelete(bool wasBackspace) void QWidgetLineControl::removeSelectedText() { if (m_selstart < m_selend && m_selend <= (int) m_text.length()) { + cancelPasswordEchoTimer(); separate(); int i ; addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); @@ -1218,6 +1263,7 @@ void QWidgetLineControl::internalUndo(int until) { if (!isUndoAvailable()) return; + cancelPasswordEchoTimer(); internalDeselect(); while (m_undoState && m_undoState > until) { Command& cmd = m_history[--m_undoState]; @@ -1422,6 +1468,12 @@ void QWidgetLineControl::timerEvent(QTimerEvent *event) } else if (event->timerId() == m_tripleClickTimer) { killTimer(m_tripleClickTimer); m_tripleClickTimer = 0; +#ifdef QT_GUI_PASSWORD_ECHO_DELAY + } else if (event->timerId() == m_passwordEchoTimer) { + killTimer(m_passwordEchoTimer); + m_passwordEchoTimer = 0; + updateDisplayText(); +#endif } } diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index e0c304279e..d8f27a4003 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -62,12 +62,15 @@ #include "QtWidgets/qstyleoption.h" #include "QtCore/qpointer.h" #include "QtGui/qclipboard.h" +#include "QtGui/qinputpanel.h" #include "QtCore/qpoint.h" #include "QtWidgets/qcompleter.h" #include "QtCore/qthread.h" #include "qplatformdefs.h" +#include "qplatformdefs.h" + QT_BEGIN_HEADER #ifdef DrawText @@ -252,6 +255,7 @@ public: uint echoMode() const { return m_echoMode; } void setEchoMode(uint mode) { + cancelPasswordEchoTimer(); m_echoMode = mode; m_passwordEchoEditing = false; updateDisplayText(); @@ -301,7 +305,13 @@ public: QString preeditAreaText() const { return m_textLayout.preeditAreaText(); } void updatePasswordEchoEditing(bool editing); - bool passwordEchoEditing() const { return m_passwordEchoEditing; } + bool passwordEchoEditing() const { +#ifdef QT_GUI_PASSWORD_ECHO_DELAY + if (m_passwordEchoTimer != 0) + return true; +#endif + return m_passwordEchoEditing ; + } QChar passwordCharacter() const { return m_passwordCharacter; } void setPasswordCharacter(const QChar &character) { m_passwordCharacter = character; updateDisplayText(); } @@ -309,7 +319,7 @@ public: Qt::LayoutDirection layoutDirection() const { if (m_layoutDirection == Qt::LayoutDirectionAuto) { if (m_text.isEmpty()) - return QApplication::keyboardInputDirection(); + return qApp->inputPanel()->inputDirection(); return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight; } return m_layoutDirection; @@ -474,6 +484,18 @@ private: bool m_passwordEchoEditing; QChar m_passwordCharacter; +#ifdef QT_GUI_PASSWORD_ECHO_DELAY + int m_passwordEchoTimer; +#endif + void cancelPasswordEchoTimer() + { +#ifdef QT_GUI_PASSWORD_ECHO_DELAY + if (m_passwordEchoTimer != 0) { + killTimer(m_passwordEchoTimer); + m_passwordEchoTimer = 0; + } +#endif + } int redoTextLayout() const; #if defined(Q_WS_MAC) diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index f43e0f7dfa..5881d2360d 100644 --- a/src/widgets/widgets/qwidgetresizehandler.cpp +++ b/src/widgets/widgets/qwidgetresizehandler.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h index 9d09d63967..5a355611fd 100644 --- a/src/widgets/widgets/qwidgetresizehandler_p.h +++ b/src/widgets/widgets/qwidgetresizehandler_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index a55e001fc4..628848b0d7 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -75,7 +75,7 @@ #include <qvariant.h> #include <qurl.h> #include <qdesktopservices.h> -#include <qinputcontext.h> +#include <qinputpanel.h> #include <qtooltip.h> #include <qstyleoption.h> #include <QtWidgets/qlineedit.h> @@ -691,20 +691,30 @@ void QWidgetTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX)) return; - // keep the already selected word even when moving to the left - // (#39164) - if (suggestedNewPosition < selectedWordOnDoubleClick.position()) - cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); - else - cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); + if (wordSelectionEnabled) { + if (suggestedNewPosition < selectedWordOnDoubleClick.position()) { + cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); + setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); + } else { + cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); + setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); + } + } else { + // keep the already selected word even when moving to the left + // (#39164) + if (suggestedNewPosition < selectedWordOnDoubleClick.position()) + cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); + else + cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); - const qreal differenceToStart = mouseXPosition - wordStartX; - const qreal differenceToEnd = wordEndX - mouseXPosition; + const qreal differenceToStart = mouseXPosition - wordStartX; + const qreal differenceToEnd = wordEndX - mouseXPosition; - if (differenceToStart < differenceToEnd) - setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); - else - setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); + if (differenceToStart < differenceToEnd) + setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); + else + setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); + } if (interactionFlags & Qt::TextSelectableByMouse) { #ifndef QT_NO_CLIPBOARD @@ -1678,16 +1688,15 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button emit q->cursorPositionChanged(); _q_updateCurrentCharFormatAndSelection(); #ifndef QT_NO_IM - if (contextWidget) { - if (QInputContext *ic = qApp->inputContext()) { - ic->update(); - } - } + if (contextWidget) + qApp->inputPanel()->update(Qt::ImQueryInput); #endif //QT_NO_IM } else { //emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1))); - if (cursor.position() != oldCursorPos) + if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); + emit q->microFocusChanged(); + } } selectionChanged(true); repaintOldAndNewSelection(oldSelection); @@ -1734,8 +1743,10 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but repaintOldAndNewSelection(oldSelection); - if (cursor.position() != oldCursorPos) + if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); + emit q->microFocusChanged(); + } if (interactionFlags & Qt::LinksAccessibleByMouse) { if (!(button & Qt::LeftButton)) @@ -1807,34 +1818,32 @@ bool QWidgetTextControlPrivate::sendMouseEventToInputContext( QEvent *e, QEvent::Type eventType, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos) { + Q_UNUSED(eventType); + Q_UNUSED(button); + Q_UNUSED(pos); + Q_UNUSED(modifiers); + Q_UNUSED(buttons); + Q_UNUSED(globalPos); #if !defined(QT_NO_IM) Q_Q(QWidgetTextControl); if (contextWidget && isPreediting()) { QTextLayout *layout = cursor.block().layout(); - QInputContext *ctx = qApp->inputContext(); int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position(); if (cursorPos < 0 || cursorPos > layout->preeditAreaText().length()) cursorPos = -1; - if (ctx && cursorPos >= 0) { - QMouseEvent ev(eventType, contextWidget->mapFromGlobal(globalPos), - contextWidget->topLevelWidget()->mapFromGlobal(globalPos), globalPos, - button, buttons, modifiers); - ctx->mouseHandler(cursorPos, &ev); - e->setAccepted(ev.isAccepted()); + if (cursorPos >= 0) { + if (e->type() == QEvent::MouseButtonRelease) + qApp->inputPanel()->invokeAction(QInputPanel::Click, cursorPos); + + e->setAccepted(true); return true; } } #else Q_UNUSED(e); - Q_UNUSED(eventType); - Q_UNUSED(button); - Q_UNUSED(pos); - Q_UNUSED(modifiers); - Q_UNUSED(buttons); - Q_UNUSED(globalPos); #endif return false; } @@ -2157,17 +2166,6 @@ QMenu *QWidgetTextControl::createStandardContextMenu(const QPointF &pos, QWidget a->setEnabled(!d->doc->isEmpty()); } -#if !defined(QT_NO_IM) - if (d->contextWidget) { - QInputContext *qic = qApp->inputContext(); - if (qic) { - QList<QAction *> imActions = qic->actions(); - for (int i = 0; i < imActions.size(); ++i) - menu->addAction(imActions.at(i)); - } - } -#endif - #if defined(Q_WS_WIN) || defined(Q_WS_X11) if ((d->interactionFlags & Qt::TextEditable) && qt_use_rtl_extensions) { #else diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 1550959ebe..7425a7d878 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h index cf493aff71..7e49be7f7b 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qworkspace.cpp b/src/widgets/widgets/qworkspace.cpp index 0d74635881..7aaeeb7282 100644 --- a/src/widgets/widgets/qworkspace.cpp +++ b/src/widgets/widgets/qworkspace.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/src/widgets/widgets/qworkspace.h b/src/widgets/widgets/qworkspace.h index 843879a8e7..66fa57f5a4 100644 --- a/src/widgets/widgets/qworkspace.h +++ b/src/widgets/widgets/qworkspace.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** |