Changeset 846 for trunk/src/gui/widgets


Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
158 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/widgets/qabstractbutton.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qabstractbutton.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qabstractbutton_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qabstractscrollarea.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    296296    layoutChildren();
    297297#ifndef Q_WS_MAC
     298#ifndef QT_NO_GESTURES
    298299    viewport->grabGesture(Qt::PanGesture);
     300#endif
    299301#endif
    300302}
     
    547549        d->viewport->installEventFilter(d->viewportFilter.data());
    548550#ifndef Q_WS_MAC
     551#ifndef QT_NO_GESTURES
    549552        d->viewport->grabGesture(Qt::PanGesture);
     553#endif
    550554#endif
    551555        d->layoutChildren();
     
    961965    case QEvent::TouchEnd:
    962966        return false;
     967#ifndef QT_NO_GESTURES
    963968    case QEvent::Gesture:
    964969    {
     
    981986        return false;
    982987    }
     988#endif // QT_NO_GESTURES
    983989    case QEvent::StyleChange:
    984990    case QEvent::LayoutDirectionChange:
    985991    case QEvent::ApplicationLayoutDirectionChange:
     992    case QEvent::LayoutRequest:
    986993        d->layoutChildren();
    987994        // fall through
     
    10061013  using one of the specialized event handlers instead.
    10071014
    1008   Specialised handlers for viewport events are: paintEvent(),
     1015  Specialized handlers for viewport events are: paintEvent(),
    10091016  mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(),
    10101017  mouseMoveEvent(), wheelEvent(), dragEnterEvent(), dragMoveEvent(),
     
    10361043        return QFrame::event(e);
    10371044    case QEvent::LayoutRequest:
     1045#ifndef QT_NO_GESTURES
    10381046    case QEvent::Gesture:
    10391047    case QEvent::GestureOverride:
    10401048        return event(e);
     1049#endif
    10411050    default:
    10421051        break;
  • trunk/src/gui/widgets/qabstractscrollarea.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qabstractscrollarea_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6363class QScrollBar;
    6464class QAbstractScrollAreaScrollBarContainer;
    65 class Q_AUTOTEST_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
     65class Q_GUI_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
    6666{
    6767    Q_DECLARE_PUBLIC(QAbstractScrollArea)
  • trunk/src/gui/widgets/qabstractslider.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    220220      , isAutoRepeating(false)
    221221      , repeatMultiplier(1)
    222 #endif
    223 {
     222{
     223    firstRepeat.invalidate();
     224#else
     225{
     226#endif
     227
    224228}
    225229
     
    713717
    714718        offset_accumulated += stepsToScrollF;
     719#ifndef Q_WS_MAC
     720        // Don't scroll more than one page in any case:
    715721        stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep);
     722#else
     723        // Native UI-elements on Mac can scroll hundreds of lines at a time as
     724        // a result of acceleration. So keep the same behaviour in Qt, and
     725        // don't restrict stepsToScroll to certain maximum (pageStep):
     726        stepsToScroll = int(offset_accumulated);
     727#endif
    716728        offset_accumulated -= int(offset_accumulated);
    717729        if (stepsToScroll == 0)
     
    757769#ifdef QT_KEYPAD_NAVIGATION
    758770    if (ev->isAutoRepeat()) {
    759         if (d->firstRepeat.isNull())
    760             d->firstRepeat = QTime::currentTime();
     771        if (!d->firstRepeat.isValid())
     772            d->firstRepeat.start();
    761773        else if (1 == d->repeatMultiplier) {
    762774            // This is the interval in milli seconds which one key repetition
    763775            // takes.
    764             const int repeatMSecs = d->firstRepeat.msecsTo(QTime::currentTime());
     776            const int repeatMSecs = d->firstRepeat.elapsed();
    765777
    766778            /**
     
    780792
    781793    }
    782     else if (!d->firstRepeat.isNull()) {
    783         d->firstRepeat = QTime();
     794    else if (d->firstRepeat.isValid()) {
     795        d->firstRepeat.invalidate();
    784796        d->repeatMultiplier = 1;
    785797    }
  • trunk/src/gui/widgets/qabstractslider.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qabstractslider_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5555
    5656#include "QtCore/qbasictimer.h"
     57#include "QtCore/qelapsedtimer.h"
    5758#include "private/qwidget_p.h"
    5859#include "qstyle.h"
     
    104105     * The time of when the first auto repeating key press event occurs.
    105106     */
    106     QTime firstRepeat;
     107    QElapsedTimer firstRepeat;
    107108
    108109#endif
  • trunk/src/gui/widgets/qabstractspinbox.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    12491249    Q_D(QAbstractSpinBox);
    12501250
     1251    QPointer<QMenu> menu = d->edit->createStandardContextMenu();
     1252    if (!menu)
     1253        return;
     1254
    12511255    d->reset();
    1252     QPointer<QMenu> menu = d->edit->createStandardContextMenu();
    12531256
    12541257    QAction *selAll = new QAction(tr("&Select All"), menu);
  • trunk/src/gui/widgets/qabstractspinbox.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qabstractspinbox_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qbuttongroup.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qbuttongroup.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qcalendartextnavigator_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qcalendarwidget.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qcalendarwidget.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qcheckbox.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    292292    QStyleOptionButton opt;
    293293    initStyleOption(&opt);
    294     QSize sz = style()->itemTextRect(fm, QRect(0, 0, 1, 1), Qt::TextShowMnemonic, false,
     294    QSize sz = style()->itemTextRect(fm, QRect(), Qt::TextShowMnemonic, false,
    295295                                     text()).size();
    296296    if (!opt.icon.isNull())
  • trunk/src/gui/widgets/qcheckbox.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qcocoamenu_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747#include <private/qt_cocoa_helpers_mac_p.h>
    4848#include <private/qapplication_p.h>
     49#include <private/qaction_p.h>
    4950
    5051#include <QtGui/QMenu>
     
    7172    if (self) {
    7273        qmenu = menu;
     74        previousAction = 0;
    7375        [self setAutoenablesItems:NO];
    7476        [self setDelegate:self];
     
    8284
    8385    if (!item) {
    84         // ### According to the docs everything will be highlighted. Not sure what we should do in
    85         // Qt, so just return.
     86        if (previousAction) {
     87            qt_mac_clear_status_text(previousAction);
     88            previousAction = 0;
     89        }
    8690        return;
    8791    }
    8892
    89     if (QAction *action = reinterpret_cast<QAction *>([item tag]))
     93    if (QAction *action = reinterpret_cast<QAction *>([item tag])) {
     94        QMenu *qtmenu = static_cast<QT_MANGLE_NAMESPACE(QCocoaMenu) *>(menu)->qmenu;
     95        previousAction = action;
    9096        action->activate(QAction::Hover);
     97        qt_mac_menu_emit_hovered(qtmenu, action);
     98        action->showStatusText(0); // 0 widget -> action's parent
     99    }
    91100}
    92101
     
    101110}
    102111
    103 - (void)menuWillClose:(NSMenu*)menu;
     112- (void)menuDidClose:(NSMenu*)menu;
    104113{
    105114    qt_mac_emit_menuSignals(((QT_MANGLE_NAMESPACE(QCocoaMenu) *)menu)->qmenu, false);
     115    if (previousAction) {
     116        qt_mac_clear_status_text(previousAction);
     117        previousAction = 0;
     118    }
    106119}
    107120
     
    176189}
    177190
     191- (NSInteger)indexOfItemWithTarget:(id)anObject andAction:(SEL)actionSelector
     192{
     193     NSInteger index = [super indexOfItemWithTarget:anObject andAction:actionSelector];
     194     static SEL selForOFCP = NSSelectorFromString(@"orderFrontCharacterPalette:");
     195     if (index == -1 && selForOFCP == actionSelector) {
     196         // Check if the 'orderFrontCharacterPalette' SEL exists for QCocoaMenuLoader object
     197         QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
     198         return [super indexOfItemWithTarget:loader andAction:actionSelector];
     199     }
     200     return index;
     201}
     202
    178203@end
    179204
     
    195220    qt_mac_menus_open_count += delta;
    196221}
     222
     223void qt_mac_clear_status_text(QAction *action)
     224{
     225    action->d_func()->showStatusText(0, QString());
     226}
     227
     228void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action)
     229{
     230    emit menu->hovered(action);
     231}
     232
     233
    197234QT_END_NAMESPACE
    198235
  • trunk/src/gui/widgets/qcocoamenu_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5656
    5757QT_FORWARD_DECLARE_CLASS(QMenu)
     58QT_FORWARD_DECLARE_CLASS(QAction)
    5859
    5960#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
     
    6263- (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item;
    6364- (void)menuWillOpen:(NSMenu*)menu;
    64 - (void)menuWillClose:(NSMenu*)menu;
     65- (void)menuDidClose:(NSMenu*)menu;
    6566- (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteger)modifier
    6667  whichItem:(NSMenuItem**)outItem;
     
    7273{
    7374    QMenu *qmenu;
     75    QAction *previousAction;
    7476}
    7577- (id)initWithQMenu:(QMenu*)menu;
    7678- (BOOL)menuHasKeyEquivalent:(NSMenu *)menu forEvent:(NSEvent *)event target:(id *)target action:(SEL *)action;
     79- (NSInteger)indexOfItemWithTarget:(id)anObject andAction:(SEL)actionSelector;
    7780@end
    7881#endif
  • trunk/src/gui/widgets/qcocoatoolbardelegate_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5959QT_FORWARD_DECLARE_CLASS(QCFString);
    6060
    61 @implementation QCocoaToolBarDelegate
     61@implementation QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate)
    6262
    6363- (id)initWithMainWindowLayout:(QMainWindowLayout *)layout
  • trunk/src/gui/widgets/qcocoatoolbardelegate_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6262@class NSToolbarItem;
    6363
    64 @interface QCocoaToolBarDelegate : NSObject {
     64@interface QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) : NSObject {
    6565    QT_PREPEND_NAMESPACE(QMainWindowLayout) *mainWindowLayout;
    6666    NSToolbarItem *toolbarItem;
  • trunk/src/gui/widgets/qcombobox.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5757#include <qtreeview.h>
    5858#include <qheaderview.h>
     59#include <qmath.h>
    5960#ifndef QT_NO_IM
    6061#include "qinputcontext.h"
     
    113114{
    114115    QStyleOptionMenuItem menuOption;
    115     menuOption.palette = option.palette.resolve(QApplication::palette("QMenu"));
     116
     117    QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu"));
     118    QVariant value = index.data(Qt::ForegroundRole);
     119    if (qVariantCanConvert<QBrush>(value)) {
     120        resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value));
     121        resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value));
     122        resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
     123    }
     124    menuOption.palette = resolvedpalette;
    116125    menuOption.state = QStyle::State_None;
    117126    if (mCombo->window()->isActiveWindow())
     
    324333
    325334        // height
    326         sh.setHeight(qMax(fm.height(), 14) + 2);
     335        sh.setHeight(qMax(qCeil(QFontMetricsF(fm).height()), 14) + 2);
    327336        if (hasIcon) {
    328337            sh.setHeight(qMax(sh.height(), iconSize.height() + 2));
     
    390399    QStyleOptionComboBox opt = comboStyleOption();
    391400    if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo))
    392         view->clearSelection();
     401        view->setCurrentIndex(QModelIndex());
    393402#endif
    394403}
     
    696705    emit resetButton();
    697706    combo->update();
     707    // QGraphicsScenePrivate::removePopup closes the combo box popup, it hides it non-explicitly.
     708    // Hiding/showing the QComboBox after this will unexpectedly show the popup as well.
     709    // Re-hiding the popup container makes sure it is explicitly hidden.
     710    if (QGraphicsProxyWidget *proxy = graphicsProxyWidget())
     711        proxy->hide();
    698712}
    699713
     
    897911    highlights an item in the combobox popup list. All three signals
    898912    exist in two versions, one with a QString argument and one with an
    899     \c int argument. If the user selectes or highlights a pixmap, only
     913    \c int argument. If the user selects or highlights a pixmap, only
    900914    the \c int signals are emitted. Whenever the text of an editable
    901915    combobox is changed the editTextChanged() signal is emitted.
     
    12841298    By default, this property has a value of 10.
    12851299
    1286     \note This property is ignored for non-editable comboboxes in Mac style.
     1300    \note This property is ignored for non-editable comboboxes in styles that returns
     1301    false for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style.
    12871302*/
    12881303int QComboBox::maxVisibleItems() const
     
    23642379#endif
    23652380                ++count;
    2366                 if (!usePopup && count > d->maxVisibleItems) {
     2381                if (!usePopup && count >= d->maxVisibleItems) {
    23672382                    toCheck.clear();
    23682383                    break;
     
    24622477            //by default popup is centered on screen in landscape
    24632478            listRect.moveCenter(screen.center());
    2464             if (staConTopRect.IsEmpty()) {
     2479            if (staConTopRect.IsEmpty() && AknLayoutUtils::CbaLocation() != AknLayoutUtils::EAknCbaLocationBottom) {
    24652480                // landscape without stacon, menu should be at the right
    24662481                (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
     
    28352850            d->updateArrow(QStyle::State_Sunken);
    28362851#ifdef QT_KEYPAD_NAVIGATION
    2837         if (!d->lineEdit) {
     2852        //if the container already exists, then d->viewContainer() is safe to call
     2853        if (d->container) {
    28382854#endif
    28392855            // We've restricted the next couple of lines, because by not calling
  • trunk/src/gui/widgets/qcombobox.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    112112
    113113    inline int findText(const QString &text,
    114                         Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const
     114                        Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const
    115115        { return findData(text, Qt::DisplayRole, flags); }
    116116    int findData(const QVariant &data, int role = Qt::UserRole,
    117                  Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const;
     117                 Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const;
    118118
    119119    enum InsertPolicy {
  • trunk/src/gui/widgets/qcombobox_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qcommandlinkbutton.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747#include "qcolor.h"
    4848#include "qfont.h"
     49#include <qmath.h>
    4950
    5051#include "private/qpushbutton_p.h"
     
    118119    int leftMargin() const { return 7; }
    119120    int rightMargin() const { return 4; }
    120     int bottomMargin() const { return 4; }
     121    int bottomMargin() const { return 10; }
    121122
    122123    QString description;
     
    174175{
    175176    Q_Q(const QCommandLinkButton);
    176     return q->rect().adjusted(textOffset(), topMargin(),
    177                               -rightMargin(), 0);
     177    QRect r = q->rect().adjusted(textOffset(), topMargin(), -rightMargin(), 0);
     178    if (description.isEmpty())
     179    {
     180        QFontMetrics fm(titleFont());
     181        r.setTop(r.top() + qMax(0, (q->icon().actualSize(q->iconSize()).height()
     182                 - fm.height()) / 2));
     183    }
     184
     185    return r;
    178186}
    179187
     
    243251        layout.endLayout();
    244252    }
    245     return qRound(descriptionheight);
     253    return qCeil(descriptionheight);
    246254}
    247255
     
    254262    QSize size = sizeHint();
    255263    int minimumHeight = qMax(d->descriptionOffset() + d->bottomMargin(),
    256                              iconSize().height() + d->topMargin());
     264                             icon().actualSize(iconSize()).height() + d->topMargin());
    257265    size.setHeight(minimumHeight);
    258266    return size;
     
    328336    // find the width available for the description area
    329337    return qMax(heightWithoutDescription + d->descriptionHeight(width),
    330                 iconSize().height() + d->topMargin() + d->bottomMargin());
     338                icon().actualSize(iconSize()).height() + d->topMargin() +
     339                d->bottomMargin());
    331340}
    332341
     
    341350    initStyleOption(&option);
    342351
    343     //Enable command link appearence on Vista
     352    //Enable command link appearance on Vista
    344353    option.features |= QStyleOptionButton::CommandLinkButton;
    345354    option.text = QString();
  • trunk/src/gui/widgets/qcommandlinkbutton.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qdatetimeedit.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    249249/*!
    250250  \property QDateTimeEdit::date
    251   \brief the QDate that is set in the QDateTimeEdit
     251  \brief the QDate that is set in the widget
    252252
    253253  By default, this property contains a date that refers to January 1, 2000.
     
    280280/*!
    281281  \property QDateTimeEdit::time
    282   \brief the QTime that is set in the QDateTimeEdit
     282  \brief the QTime that is set in the widget
    283283
    284284  By default, this property contains a time of 00:00:00 and 0 milliseconds.
     
    755755  pop-up. The editor does not automatically take ownership of the calendar widget.
    756756
     757  \note calendarPopup must be set to true before setting the calendar widget.
    757758  \sa calendarPopup
    758759*/
     
    832833  and QDateTime::fromString()
    833834
    834   Example format strings(assuming that the date is 2nd of July 1969):
     835  Example format strings (assuming that the date is 2nd of July 1969):
    835836
    836837  \table
    837838  \header \i Format \i Result
    838   \row \i dd.MM.yyyy    \i 02.07.1969
     839  \row \i dd.MM.yyyy \i 02.07.1969
    839840  \row \i MMM d yy \i Jul 2 69
    840841  \row \i MMMM d yy \i July 2 69
     
    902903/*!
    903904    \property QDateTimeEdit::calendarPopup
    904     \brief the current calender pop-up showing mode.
     905    \brief the current calendar pop-up showing mode.
    905906    \since 4.2
    906907
     
    11761177    }
    11771178    QAbstractSpinBox::keyPressEvent(event);
    1178     if (select && !(event->modifiers() & Qt::ShiftModifier) && !d->edit->hasSelectedText()) {
     1179    if (select && !d->edit->hasSelectedText()) {
    11791180        if (inserted && d->sectionAt(d->edit->cursorPosition()) == QDateTimeParser::NoSectionIndex) {
    11801181            QString str = d->displayText();
     
    15551556}
    15561557
    1557 /*!
    1558     \property QTimeEdit::time
    1559     \brief the QTime that is shown in the widget
    1560 
    1561     By default, this property contains a time of 00:00:00 and 0 milliseconds.
    1562 */
    1563 
    15641558
    15651559/*!
     
    16151609{
    16161610}
    1617 
    1618 /*!
    1619     \property QDateEdit::date
    1620     \brief the QDate that is shown in the widget
    1621 
    1622     By default, this property contains a date referring to January 1, 2000.
    1623 */
    16241611
    16251612
  • trunk/src/gui/widgets/qdatetimeedit.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    207207{
    208208    Q_OBJECT
    209     Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged USER true)
    210209public:
    211210    QTimeEdit(QWidget *parent = 0);
     
    216215{
    217216    Q_OBJECT
    218     Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged USER true)
    219217public:
    220218    QDateEdit(QWidget *parent = 0);
  • trunk/src/gui/widgets/qdatetimeedit_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qdial.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qdial.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qdialogbuttonbox.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    104104
    105105    Currently the buttons are laid out in the following way if the button box is horizontal:
    106     \table 100%
     106    \table
    107107    \row \o \inlineimage buttonbox-gnomelayout-horizontal.png GnomeLayout Horizontal
    108108         \o Button box laid out in horizontal GnomeLayout
     
    117117    The buttons are laid out the following way if the button box is vertical:
    118118
    119     \table 100%
     119    \table
     120    \row \o GnomeLayout
     121         \o KdeLayout
     122         \o MacLayout
     123         \o WinLayout
    120124    \row \o \inlineimage buttonbox-gnomelayout-vertical.png GnomeLayout Vertical
    121          \o Button box laid out in vertical GnomeLayout
    122     \row \o \inlineimage buttonbox-kdelayout-vertical.png KdeLayout Vertical
    123          \o Button box laid out in vertical KdeLayout
    124     \row \o \inlineimage buttonbox-maclayout-vertical.png MacLayout Vertical
    125          \o Button box laid out in vertical MacLayout
    126     \row \o \inlineimage buttonbox-winlayout-vertical.png WinLayout Vertical
    127          \o Button box laid out in vertical WinLayout
     125         \o \inlineimage buttonbox-kdelayout-vertical.png KdeLayout Vertical
     126         \o \inlineimage buttonbox-maclayout-vertical.png MacLayout Vertical
     127         \o \inlineimage buttonbox-winlayout-vertical.png WinLayout Vertical
    128128    \endtable
    129129
    130130    Additionally, button boxes that contain only buttons with ActionRole or
    131     HelpRole can be considered modeless and have an alternate look on the mac:
    132 
    133     \table 100%
    134     \row \o \inlineimage buttonbox-mac-modeless-horizontal.png Screenshot of modeless horizontal MacLayout
    135          \o modeless horizontal MacLayout
    136     \row \o \inlineimage buttonbox-mac-modeless-vertical.png Screenshot of modeless vertical MacLayout
    137          \o modeless vertical MacLayout
     131    HelpRole can be considered modeless and have an alternate look on Mac OS X:
     132
     133    \table
     134    \row \o modeless horizontal MacLayout
     135         \o \inlineimage buttonbox-mac-modeless-horizontal.png Screenshot of modeless horizontal MacLayout
    138136    \endtable
    139137
     
    261259};
    262260
     261#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
    263262class QDialogButtonEnabledProxy : public QObject
    264263{
     
    284283    QAction *target;
    285284};
    286 
     285#endif
    287286
    288287class QDialogButtonBoxPrivate : public QWidgetPrivate
     
    317316    void retranslateStrings();
    318317    const char *standardButtonText(QDialogButtonBox::StandardButton sbutton) const;
    319 #ifdef QT_SOFTKEYS_ENABLED
     318#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
    320319    QAction *createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role);
    321320#endif
     
    574573    QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed()));
    575574    buttonLists[role].append(button);
    576 #ifdef QT_SOFTKEYS_ENABLED
     575#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
    577576    QAction *action = createSoftKey(button, role);
    578577    softKeyActions.insert(button, action);
     
    583582}
    584583
    585 #ifdef QT_SOFTKEYS_ENABLED
     584#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
    586585QAction* QDialogButtonBoxPrivate::createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role)
    587586{
     
    721720            QPushButton *button = it.key();
    722721            button->setText(QDialogButtonBox::tr(buttonText));
    723 #ifdef QT_SOFTKEYS_ENABLED
     722#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
    724723            QAction *action = softKeyActions.value(button, 0);
    725724            if (action)
     
    1000999        }
    10011000    }
    1002 #ifdef QT_SOFTKEYS_ENABLED
     1001#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
    10031002    QAction *action = d->softKeyActions.value(button, 0);
    10041003    if (action) {
     
    12461245        d->retranslateStrings();
    12471246    }
    1248 #ifdef QT_SOFTKEYS_ENABLED
     1247#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
    12491248    else if (event->type() == QEvent::ParentChange) {
    12501249        QWidget *dialog = 0;
  • trunk/src/gui/widgets/qdialogbuttonbox.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qdockarealayout.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6161QT_BEGIN_NAMESPACE
    6262
     63// qmainwindow.cpp
     64extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
     65
    6366enum { StateFlagVisible = 1, StateFlagFloating = 2 };
    6467
     
    221224#endif
    222225
     226static const int zero = 0;
     227
    223228QDockAreaLayoutInfo::QDockAreaLayoutInfo()
    224     : sep(0), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)
    225 #ifndef QT_NO_TABBAR
    226     , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth), tabBarVisible(false)
    227 #endif
    228 {
    229 }
    230 
    231 QDockAreaLayoutInfo::QDockAreaLayoutInfo(int _sep, QInternal::DockPosition _dockPos,
     229    : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)
     230#ifndef QT_NO_TABBAR
     231    , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth)
     232#endif
     233{
     234}
     235
     236QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos,
    232237                                            Qt::Orientation _o, int tbshape,
    233238                                            QMainWindow *window)
    234239    : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)
    235240#ifndef QT_NO_TABBAR
    236     , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)), tabBarVisible(false)
     241    , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
    237242#endif
    238243{
     
    282287        {
    283288            if (!first)
    284                 a += sep;
     289                a += *sep;
    285290            a += pick(o, min_size);
    286291        }
     
    295300
    296301#ifndef QT_NO_TABBAR
    297     if (tabbed) {
    298         QSize tbm = tabBarMinimumSize();
     302    QSize tbm = tabBarMinimumSize();
     303    if (!tbm.isNull()) {
    299304        switch (tabBarShape) {
    300305            case QTabBar::RoundedNorth:
     
    350355        {
    351356            if (!first)
    352                 a += sep;
     357                a += *sep;
    353358            a += pick(o, max_size);
    354359        }
     
    368373
    369374#ifndef QT_NO_TABBAR
    370     if (tabbed) {
    371         QSize tbh = tabBarSizeHint();
     375    QSize tbh = tabBarSizeHint();
     376    if (!tbh.isNull()) {
    372377        switch (tabBarShape) {
    373378            case QTabBar::RoundedNorth:
     
    416421            if (previous && !gap && !(previous->flags &  QDockAreaLayoutItem::GapItem)
    417422                && !previous->hasFixedSize(o)) {
    418                 a += sep;
     423                a += *sep;
    419424            }
    420425            a += gap ? item.size : pick(o, size_hint);
     
    492497
    493498        if (!first)
    494             result += info.sep;
     499            result += *info.sep;
    495500        result += min;
    496501
     
    517522
    518523        if (!first)
    519             result += info.sep;
     524            result += *info.sep;
    520525        result += max;
    521526
     
    556561                QLayoutStruct &ls = layout_struct_list[j++];
    557562                ls.init();
    558                 ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : sep;
     563                ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : *sep;
    559564                ls.empty = false;
    560565            }
     
    939944            ls.empty = true;
    940945        } else {
    941             const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;
     946            const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
    942947            ls.empty = false;
    943948            ls.pos = item.pos;
     
    957962            continue;
    958963        QLayoutStruct &ls = list[i];
    959         const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;
     964        const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
    960965        item.size = ls.size - separatorSpace;
    961966        item.pos = ls.pos;
     
    10421047
    10431048        if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
    1044             item.pos += sep;
    1045             item.size -= sep;
     1049            item.pos += *sep;
     1050            item.size -= *sep;
    10461051        }
    10471052        if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
    1048             item.size -= sep;
     1053            item.size -= *sep;
    10491054
    10501055        QPoint pos;
     
    10841089    {
    10851090        if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
    1086             item.pos -= sep;
    1087             item.size += sep;
     1091            item.pos -= *sep;
     1092            item.size += *sep;
    10881093        }
    10891094        if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
    1090             item.size += sep;
     1095            item.size += *sep;
    10911096    }
    10921097
     
    12561261            gap_size = pick(o, r.size());
    12571262        if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem))
    1258                 sep_size += sep;
     1263                sep_size += *sep;
    12591264            if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
    1260                 sep_size += sep;
     1265                sep_size += *sep;
    12611266        }
    12621267        if (gap_size + sep_size > space)
     
    13651370    rpick(o, pos) = item.pos + item.size;
    13661371    QSize s = rect.size();
    1367     rpick(o, s) = sep;
     1372    rpick(o, s) = *sep;
    13681373
    13691374    return QRect(pos, s);
     
    14141419
    14151420        QRect sepRect = separatorRect(i);
    1416         if (!sepRect.isNull() && sep == 1)
     1421        if (!sepRect.isNull() && *sep == 1)
    14171422            sepRect.adjust(-2, -2, 2, 2);
    14181423        //we also make sure we don't find a separator that's not there
     
    14791484QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const
    14801485{
    1481     QMainWindowLayout *result = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
     1486    QMainWindowLayout *result = qt_mainwindow_layout(mainWindow);
    14821487    Q_ASSERT(result != 0);
    14831488    return result;
     
    14991504        QSize tbh = tabBarSizeHint();
    15001505
    1501         if (tabBarVisible) {
     1506        if (!tbh.isNull()) {
    15021507            switch (tabBarShape) {
    15031508                case QTabBar::RoundedNorth:
     
    15611566    }
    15621567#ifndef QT_NO_TABBAR
    1563     if (sep == 1)
     1568    if (*sep == 1)
    15641569        updateSeparatorWidgets();
    15651570#endif //QT_NO_TABBAR
     
    19841989                    }
    19851990                }
    1986 
     1991                if (testing) {
     1992                  //was it is not really added to the layout, we need to delete the object here
     1993                  delete item.widgetItem;
     1994                }
    19871995            }
    19881996        } else if (nextMarker == SequenceMarker) {
     
    20142022        setCurrentTabId(tabId(item_list.at(index)));
    20152023    }
    2016     if (!testing && sep == 1)
     2024    if (!testing && *sep == 1)
    20172025        updateSeparatorWidgets();
    20182026#endif
     
    20752083
    20762084#ifndef QT_NO_TABBAR
    2077 void QDockAreaLayoutInfo::updateTabBar() const
     2085//returns whether the tabbar is visible or not
     2086bool QDockAreaLayoutInfo::updateTabBar() const
    20782087{
    20792088    if (!tabbed)
    2080         return;
     2089        return false;
    20812090
    20822091    QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);
     
    21462155    tabBar->blockSignals(blocked);
    21472156
    2148     that->tabBarVisible = ( (gap ? 1 : 0) + tabBar->count()) > 1;
    2149 
    2150     if (changed || !tabBarMin.isValid() | !tabBarHint.isValid()) {
    2151         that->tabBarMin = tabBar->minimumSizeHint();
    2152         that->tabBarHint = tabBar->sizeHint();
    2153     }
     2157    //returns if the tabbar is visible or not
     2158    return ( (gap ? 1 : 0) + tabBar->count()) > 1;
    21542159}
    21552160
     
    21592164        return;
    21602165    tabBarShape = shape;
    2161     if (tabBar != 0) {
     2166    if (tabBar != 0)
    21622167        tabBar->setShape(static_cast<QTabBar::Shape>(shape));
    2163         tabBarMin = QSize();
    2164         tabBarHint = QSize();
    2165     }
    21662168
    21672169    for (int i = 0; i < item_list.count(); ++i) {
     
    21742176QSize QDockAreaLayoutInfo::tabBarMinimumSize() const
    21752177{
    2176     if (!tabbed)
     2178    if (!updateTabBar())
    21772179        return QSize(0, 0);
    21782180
    2179     updateTabBar();
    2180 
    2181     return tabBarMin;
     2181    return tabBar->minimumSizeHint();
    21822182}
    21832183
    21842184QSize QDockAreaLayoutInfo::tabBarSizeHint() const
    21852185{
    2186     if (!tabbed)
     2186    if (!updateTabBar())
    21872187        return QSize(0, 0);
    21882188
    2189     updateTabBar();
    2190 
    2191     return tabBarHint;
     2189    return tabBar->sizeHint();
    21922190}
    21932191
     
    22362234    QSize tbh = tabBarSizeHint();
    22372235
    2238     if (tabBarVisible) {
     2236    if (!tbh.isNull()) {
    22392237        switch (tabBarShape) {
    22402238            case QTabBar::RoundedNorth:
     
    22772275#endif
    22782276    docks[QInternal::LeftDock]
    2279         = QDockAreaLayoutInfo(sep, QInternal::LeftDock, Qt::Vertical, tabShape, win);
     2277        = QDockAreaLayoutInfo(&sep, QInternal::LeftDock, Qt::Vertical, tabShape, win);
    22802278    docks[QInternal::RightDock]
    2281         = QDockAreaLayoutInfo(sep, QInternal::RightDock, Qt::Vertical, tabShape, win);
     2279        = QDockAreaLayoutInfo(&sep, QInternal::RightDock, Qt::Vertical, tabShape, win);
    22822280    docks[QInternal::TopDock]
    2283         = QDockAreaLayoutInfo(sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);
     2281        = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);
    22842282    docks[QInternal::BottomDock]
    2285         = QDockAreaLayoutInfo(sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);
     2283        = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);
    22862284    centralWidgetItem = 0;
    22872285
     
    29952993        dockWidget->d_func()->setWindowState(true, true, r);
    29962994    }
    2997     dockWidget->show();
    2998 //    dockWidget->setVisible(!placeHolder->hidden);
     2995    dockWidget->setVisible(!placeHolder->hidden);
    29992996#ifdef Q_WS_X11
    30002997    if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag
     
    30323029        int tbshape = 0;
    30333030#endif
    3034         QDockAreaLayoutInfo new_info(sep, pos, orientation, tbshape, mainWindow);
     3031        QDockAreaLayoutInfo new_info(&sep, pos, orientation, tbshape, mainWindow);
    30353032        new_info.item_list.append(new QDockAreaLayoutInfo(info));
    30363033        new_info.item_list.append(dockWidgetItem);
     
    30773074void QDockAreaLayout::apply(bool animate)
    30783075{
    3079     QWidgetAnimator &widgetAnimator
    3080         = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->widgetAnimator;
     3076    QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator;
    30813077
    30823078    for (int i = 0; i < QInternal::DockCount; ++i)
     
    31683164
    31693165#ifndef QT_NO_TABBAR
    3170 // Sets the correct positions for the seperator widgets
     3166// Sets the correct positions for the separator widgets
    31713167// Allocates new sepearator widgets with getSeparatorWidget
    31723168void QDockAreaLayout::updateSeparatorWidgets() const
     
    31833179            sepWidget = separatorWidgets.at(j);
    31843180        } else {
    3185             sepWidget = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->getSeparatorWidget();
     3181            sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget();
    31863182            separatorWidgets.append(sepWidget);
    31873183        }
     
    33283324}
    33293325
     3326void QDockAreaLayout::styleChangedEvent()
     3327{
     3328    sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow);
     3329    fitLayout();
     3330}
     3331
    33303332QT_END_NAMESPACE
    33313333
  • trunk/src/gui/widgets/qdockarealayout_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8484// a widgetItem if this is a node of the tree (QDockAreaLayoutItem::widgetItem)
    8585//
    86 // A path indetifies uniquely one object in this tree, the first number beeing the side and all the following
     86// A path indetifies uniquely one object in this tree, the first number being the side and all the following
    8787// indexes into the QDockAreaLayoutInfo::item_list.
    8888
     
    129129public:
    130130    QDockAreaLayoutInfo();
    131     QDockAreaLayoutInfo(int _sep, QInternal::DockPosition _dockPos, Qt::Orientation _o,
     131    QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos, Qt::Orientation _o,
    132132                        int tbhape, QMainWindow *window);
    133133
     
    190190    QMainWindowLayout *mainWindowLayout() const;
    191191
    192     int sep;
     192    const int *sep;
    193193    mutable QVector<QWidget*> separatorWidgets;
    194194    QInternal::DockPosition dockPos;
     
    209209    bool tabbed;
    210210    QTabBar *tabBar;
    211     QSize tabBarMin, tabBarHint;
    212211    int tabBarShape;
    213     bool tabBarVisible;
    214 
    215     void updateTabBar() const;
     212
     213    bool updateTabBar() const;
    216214    void setTabBarShape(int shape);
    217215    QSize tabBarMinimumSize() const;
     
    301299    QSet<QWidget*> usedSeparatorWidgets() const;
    302300#endif //QT_NO_TABBAR
     301    void styleChangedEvent();
    303302};
    304303
  • trunk/src/gui/widgets/qdockwidget.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6969extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp
    7070
     71// qmainwindow.cpp
     72extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
     73
    7174static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
    7275{ return (priv->features & feature) == feature; }
     
    691694    QMainWindow *win = qobject_cast<QMainWindow*>(parent);
    692695    Q_ASSERT(win != 0);
    693     QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
     696    QMainWindowLayout *layout = qt_mainwindow_layout(win);
    694697    Q_ASSERT(layout != 0);
    695698    if (layout->pluggingWidget != 0) // the main window is animating a docking operation
     
    712715        return;
    713716
    714     QMainWindowLayout *layout
    715         = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     717    QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    716718    Q_ASSERT(layout != 0);
    717719
     
    740742
    741743    if (state->dragging) {
    742         QMainWindowLayout *mwLayout =
    743             qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     744        QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    744745        Q_ASSERT(mwLayout != 0);
    745746
     
    781782        return false;
    782783
    783     QMainWindowLayout *mainWinLayout
    784         = qobject_cast<QMainWindowLayout*>(mainWin->layout());
     784    QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin);
    785785    if (mainWinLayout == 0)
    786786        return false;
     
    848848
    849849    QDockWidgetLayout *dwlayout
    850         = qobject_cast<QDockWidgetLayout*>(layout);
    851     QMainWindowLayout *mwlayout
    852         = qobject_cast<QMainWindowLayout*>(q->parentWidget()->layout());
     850        = qobject_cast<QDockWidgetLayout *>(layout);
     851    QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    853852    if (!dwlayout->nativeWindowDeco()) {
    854853        if (!state->dragging
     
    944943#ifdef Q_OS_MAC
    945944            else { // workaround for lack of mouse-grab on Mac
    946                 QMainWindowLayout *layout
    947                     = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     945                QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    948946                Q_ASSERT(layout != 0);
    949947
     
    981979        return;
    982980
    983     QMainWindowLayout *layout
    984         = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     981    QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    985982    Q_ASSERT(layout != 0);
    986983
     
    10101007
    10111008    if (!floating && parent) {
    1012         QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
    1013         if (!mwlayout || mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
     1009        QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
     1010        if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
    10141011            return; // this dockwidget can't be redocked
    10151012    }
     
    10561053        emit q->topLevelChanged(floating);
    10571054        if (!floating && parent) {
    1058             QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     1055            QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    10591056            if (mwlayout)
    10601057                emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
     
    12701267
    12711268    d->setWindowState(floating, false, floating ? r : QRect());
     1269
    12721270    if (floating && r.isNull()) {
    1273         QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
    1274         QRect titleArea = layout->titleArea();
    1275         int h = layout->verticalTitleBar ? titleArea.width() : titleArea.height();
    1276         QPoint p = mapToGlobal(QPoint(h, h));
    1277         move(p);
     1271        if (x() < 0 || y() < 0) //may happen if we have been hidden
     1272            move(QPoint());
     1273        setAttribute(Qt::WA_Moved, false); //we want it at the default position
    12781274    }
    12791275}
     
    13281324        {
    13291325            QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
    1330             if (QMainWindowLayout *winLayout =
    1331                 (win ? qobject_cast<QMainWindowLayout*>(win->layout()) : 0))
     1326            if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
    13321327                if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
    13331328                    info->updateTabBar();
     1329            }
    13341330        }
    13351331#endif // QT_NO_TABBAR
     
    13841380
    13851381    QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
    1386     QMainWindowLayout *layout = 0;
    1387     if (win != 0)
    1388         layout = qobject_cast<QMainWindowLayout*>(win->layout());
     1382    QMainWindowLayout *layout = qt_mainwindow_layout(win);
    13891383
    13901384    switch (event->type()) {
     
    15381532/*!
    15391533    \since 4.3
     1534
    15401535    Sets an arbitrary \a widget as the dock widget's title bar. If \a widget
    1541     is 0, the title bar widget is removed, but not deleted.
     1536    is 0, any custom title bar widget previously set on the dock widget is
     1537    removed, but not deleted, and the default title bar will be used
     1538    instead.
    15421539
    15431540    If a title bar widget is set, QDockWidget will not use native window
     
    15471544
    15481545    \list
    1549     \i Mouse events that are not explicitly handled by the title bar widget
     1546    \o Mouse events that are not explicitly handled by the title bar widget
    15501547       must be ignored by calling QMouseEvent::ignore(). These events then
    15511548       propagate to the QDockWidget parent, which handles them in the usual
     
    15531550       when it is double-clicked, etc.
    15541551
    1555     \i When DockWidgetVerticalTitleBar is set on QDockWidget, the title
     1552    \o When DockWidgetVerticalTitleBar is set on QDockWidget, the title
    15561553       bar widget is repositioned accordingly. In resizeEvent(), the title
    15571554       bar should check what orientation it should assume:
    15581555       \snippet doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp 0
    15591556
    1560     \i The title bar widget must have a valid QWidget::sizeHint() and
     1557    \o The title bar widget must have a valid QWidget::sizeHint() and
    15611558       QWidget::minimumSizeHint(). These functions should take into account
    15621559       the current orientation of the title bar.
     1560
     1561    \o It is not possible to remove a title bar from a dock widget. However,
     1562       a similar effect can be achieved by setting a default constructed
     1563       QWidget as the title bar widget.
    15631564    \endlist
    15641565
    1565     Using qobject_cast as shown above, the title bar widget has full access
     1566    Using qobject_cast() as shown above, the title bar widget has full access
    15661567    to its parent QDockWidget. Hence it can perform such operations as docking
    15671568    and hiding in response to user actions.
  • trunk/src/gui/widgets/qdockwidget.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qdockwidget_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    170170};
    171171
    172 /* The size hints of a QDockWidget will depend on wether it is docked or not.
     172/* The size hints of a QDockWidget will depend on whether it is docked or not.
    173173   This layout item always returns the size hints as if the dock widget was docked. */
    174174
  • trunk/src/gui/widgets/qeffects.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4242#include "qapplication.h"
    4343#ifndef QT_NO_EFFECTS
    44 #include "qdatetime.h"
    4544#include "qdesktopwidget.h"
    4645#include "qeffects_p.h"
     
    5150#include "qpointer.h"
    5251#include "qtimer.h"
     52#include "qelapsedtimer.h"
    5353#include "qdebug.h"
    5454
     
    104104    bool showWidget;
    105105    QTimer anim;
    106     QTime checkTime;
     106    QElapsedTimer checkTime;
    107107    double windowOpacity;
    108108};
     
    385385
    386386    QTimer anim;
    387     QTime checkTime;
     387    QElapsedTimer checkTime;
    388388
    389389    QPixmap pm;
  • trunk/src/gui/widgets/qeffects_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qfocusframe.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5454    Q_DECLARE_PUBLIC(QFocusFrame)
    5555    QWidget *widget;
    56 
     56    QWidget *frameParent;
     57    bool showFrameAboveWidget;
    5758public:
    5859    QFocusFramePrivate() {
    5960        widget = 0;
     61        frameParent = 0;
    6062        sendChildEvents = false;
     63        showFrameAboveWidget = false;
    6164    }
    6265    void updateSize();
     
    6770{
    6871    Q_Q(QFocusFrame);
    69     q->setParent(widget->parentWidget());
     72    q->setParent(frameParent);
    7073    updateSize();
    7174    if (q->parentWidget()->rect().intersects(q->geometry())) {
    72         if (q->style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, q))
     75        if (showFrameAboveWidget)
    7376            q->raise();
    7477        else
     
    8588    int vmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameVMargin),
    8689        hmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
    87     QRect geom(widget->x()-hmargin, widget->y()-vmargin,
     90    QPoint pos(widget->x(), widget->y());
     91    if (q->parentWidget() != widget->parentWidget())
     92        pos = widget->parentWidget()->mapTo(q->parentWidget(), pos);
     93    QRect geom(pos.x()-hmargin, pos.y()-vmargin,
    8894               widget->width()+(hmargin*2), widget->height()+(vmargin*2));
    8995    if(q->geometry() == geom)
     
    177183{
    178184    Q_D(QFocusFrame);
    179     if(widget == d->widget)
     185
     186    if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this))
     187        d->showFrameAboveWidget = true;
     188    else
     189        d->showFrameAboveWidget = false;
     190
     191    if (widget == d->widget)
    180192        return;
    181 
    182     if(d->widget)
    183         d->widget->removeEventFilter(this);
    184     if(widget && !widget->isWindow() && widget->parentWidget()->windowType() != Qt::SubWindow) {
     193    if (d->widget) {
     194        // Remove event filters from the widget hierarchy.
     195        QWidget *p = d->widget;
     196        do {
     197            p->removeEventFilter(this);
     198            if (!d->showFrameAboveWidget || p == d->frameParent)
     199                break;
     200            p = p->parentWidget();
     201        }while (p);
     202    }
     203    if (widget && !widget->isWindow() && widget->parentWidget()->windowType() != Qt::SubWindow) {
    185204        d->widget = widget;
    186         widget->installEventFilter(this);
     205        d->widget->installEventFilter(this);
     206        QWidget *p = widget->parentWidget();
     207        QWidget *prev = 0;
     208        if (d->showFrameAboveWidget) {
     209            // Find the right parent for the focus frame.
     210            while (p) {
     211                // Traverse the hirerarchy of the 'widget' for setting event filter.
     212                // During this if come across toolbar or a top level, use that
     213                // as the parent for the focus frame. If we find a scroll area
     214                // use its viewport as the parent.
     215                bool isScrollArea = false;
     216                if (p->isWindow() || p->inherits("QToolBar") || (isScrollArea = p->inherits("QAbstractScrollArea"))) {
     217                    d->frameParent = p;
     218                    // The previous one in the hierarchy will be the viewport.
     219                    if (prev && isScrollArea)
     220                        d->frameParent = prev;
     221                    break;
     222                } else {
     223                    p->installEventFilter(this);
     224                    prev = p;
     225                    p = p->parentWidget();
     226                }
     227            }
     228        } else {
     229            d->frameParent = p;
     230        }
    187231        d->update();
    188232    } else {
     
    211255QFocusFrame::paintEvent(QPaintEvent *)
    212256{
     257    Q_D(QFocusFrame);
    213258    QStylePainter p(this);
    214259    QStyleOption option;
    215260    initStyleOption(&option);
     261    int vmargin = style()->pixelMetric(QStyle::PM_FocusFrameVMargin);
     262    int hmargin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
     263    QWidgetPrivate *wd = qt_widget_private(d->widget);
     264    QRect rect = wd->clipRect().adjusted(0, 0, hmargin*2, vmargin*2);
     265    p.setClipRect(rect);
    216266    p.drawControl(QStyle::CE_FocusFrame, option);
    217267}
     
    234284            break;
    235285        case QEvent::ParentChange:
    236             d->update();
     286            if (d->showFrameAboveWidget) {
     287                QWidget *w = d->widget;
     288                setWidget(0);
     289                setWidget(w);
     290            } else {
     291                d->update();
     292            }
    237293            break;
    238294        case QEvent::Show:
     
    255311            break;
    256312        }
     313    } else if (d->showFrameAboveWidget) {
     314        // Handle changes in the parent widgets we are monitoring.
     315        switch(e->type()) {
     316        case QEvent::Move:
     317        case QEvent::Resize:
     318            d->updateSize();
     319            break;
     320        case QEvent::ZOrderChange:
     321            raise();
     322            break;
     323        default:
     324            break;
     325        }
    257326    }
    258327    return false;
  • trunk/src/gui/widgets/qfocusframe.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qfontcombobox.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qfontcombobox.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qframe.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    245245    Returns the frame style.
    246246
    247     The default value is QFrame::NoFrame.
     247    The default value is QFrame::Plain.
    248248
    249249    \sa setFrameStyle(), frameShape(), frameShadow()
  • trunk/src/gui/widgets/qframe.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qframe_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qgroupbox.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qgroupbox.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qlabel.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5454#include "qlabel_p.h"
    5555#include "private/qstylesheetstyle_p.h"
     56#include <qmath.h>
    5657
    5758QT_BEGIN_NAMESPACE
     
    635636#endif
    636637    else if (isTextLabel) {
    637         int align = QStyle::visualAlignment(q->layoutDirection(), QFlag(this->align));
     638        int align = QStyle::visualAlignment(textDirection(), QFlag(this->align));
    638639        // Add indentation
    639640        int m = indent;
     
    662663                control->setTextWidth(-1);
    663664            }
    664             br = QRect(QPoint(0, 0), control->size().toSize());
     665
     666            QSizeF controlSize = control->size();
     667            br = QRect(QPoint(0, 0), QSize(qCeil(controlSize.width()), qCeil(controlSize.height())));
    665668
    666669            // restore state
     
    680683            bool tryWidth = (w < 0) && (align & Qt::TextWordWrap);
    681684            if (tryWidth)
    682                 w = fm.averageCharWidth() * 80;
     685                w = qMin(fm.averageCharWidth() * 80, q->maximumSize().width());
    683686            else if (w < 0)
    684687                w = 2000;
     
    782785}
    783786
     787/*!
     788    Selects text from position \a start and for \a length characters.
     789
     790    \sa selectedText()
     791
     792    \bold{Note:} The textInteractionFlags set on the label need to include
     793    either TextSelectableByMouse or TextSelectableByKeyboard.
     794
     795    \since 4.7
     796*/
     797void QLabel::setSelection(int start, int length)
     798{
     799    Q_D(QLabel);
     800    if (d->control) {
     801        d->ensureTextPopulated();
     802        QTextCursor cursor = d->control->textCursor();
     803        cursor.setPosition(start);
     804        cursor.setPosition(start + length, QTextCursor::KeepAnchor);
     805        d->control->setTextCursor(cursor);
     806    }
     807}
     808
     809/*!
     810    \property QLabel::hasSelectedText
     811    \brief whether there is any text selected
     812
     813    hasSelectedText() returns true if some or all of the text has been
     814    selected by the user; otherwise returns false.
     815
     816    By default, this property is false.
     817
     818    \sa selectedText()
     819
     820    \bold{Note:} The textInteractionFlags set on the label need to include
     821    either TextSelectableByMouse or TextSelectableByKeyboard.
     822
     823    \since 4.7
     824*/
     825bool QLabel::hasSelectedText() const
     826{
     827    Q_D(const QLabel);
     828    if (d->control)
     829        return d->control->textCursor().hasSelection();
     830    return false;
     831}
     832
     833/*!
     834    \property QLabel::selectedText
     835    \brief the selected text
     836
     837    If there is no selected text this property's value is
     838    an empty string.
     839
     840    By default, this property contains an empty string.
     841
     842    \sa hasSelectedText()
     843
     844    \bold{Note:} The textInteractionFlags set on the label need to include
     845    either TextSelectableByMouse or TextSelectableByKeyboard.
     846
     847    \since 4.7
     848*/
     849QString QLabel::selectedText() const
     850{
     851    Q_D(const QLabel);
     852    if (d->control)
     853        return d->control->textCursor().selectedText();
     854    return QString();
     855}
     856
     857/*!
     858    selectionStart() returns the index of the first selected character in the
     859    label or -1 if no text is selected.
     860
     861    \sa selectedText()
     862
     863    \bold{Note:} The textInteractionFlags set on the label need to include
     864    either TextSelectableByMouse or TextSelectableByKeyboard.
     865
     866    \since 4.7
     867*/
     868int QLabel::selectionStart() const
     869{
     870    Q_D(const QLabel);
     871    if (d->control && d->control->textCursor().hasSelection())
     872        return d->control->textCursor().selectionStart();
     873    return -1;
     874}
     875
    784876/*!\reimp
    785877*/
     
    863955    }
    864956    ev->accept();
    865     menu->exec(ev->globalPos());
    866     delete menu;
     957    menu->setAttribute(Qt::WA_DeleteOnClose);
     958    menu->popup(ev->globalPos());
    867959#endif
    868960}
     
    9681060    QRect cr = contentsRect();
    9691061    cr.adjust(d->margin, d->margin, -d->margin, -d->margin);
    970     int align = QStyle::visualAlignment(layoutDirection(), QFlag(d->align));
     1062    int align = QStyle::visualAlignment(d->isTextLabel ? d->textDirection()
     1063                                                       : layoutDirection(), QFlag(d->align));
    9711064
    9721065#ifndef QT_NO_MOVIE
     
    10281121            painter.restore();
    10291122        } else {
    1030             int flags = align;
     1123            int flags = align | (d->textDirection() == Qt::LeftToRight ? Qt::TextForceLeftToRight
     1124                                                                       : Qt::TextForceRightToLeft);
    10311125            if (d->hasShortcut) {
    10321126                flags |= Qt::TextShowMnemonic;
     
    13561450    } else if (ev->type() == QEvent::ContentsRectChange) {
    13571451        d->updateLabel();
    1358     } else if (ev->type() == QEvent::LayoutDirectionChange) {
    1359         if (d->isTextLabel && d->control) {
    1360             d->sendControlEvent(ev);
    1361         }
    13621452    }
    13631453    QFrame::changeEvent(ev);
     
    13951485}
    13961486
     1487Qt::LayoutDirection QLabelPrivate::textDirection() const
     1488{
     1489    if (control) {
     1490        QTextOption opt = control->document()->defaultTextOption();
     1491        return opt.textDirection();
     1492    }
     1493
     1494    return text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
     1495}
    13971496
    13981497/*!
     
    14121511    QRect cr = q->contentsRect();
    14131512    cr.adjust(margin, margin, -margin, -margin);
    1414     const int align = QStyle::visualAlignment(q->layoutDirection(), QFlag(this->align));
     1513    const int align = QStyle::visualAlignment(isTextLabel ? textDirection()
     1514                                                          : q->layoutDirection(), QFlag(this->align));
    14151515    int m = indent;
    14161516    if (m < 0 && q->frameWidth()) // no indent, but we do have a frame
     
    14731573        return;
    14741574    ensureTextPopulated();
    1475     Q_Q(const QLabel);
    14761575    if (control) {
    14771576        QTextDocument *doc = control->document();
     
    14841583        else
    14851584            opt.setWrapMode(QTextOption::ManualWrap);
    1486 
    1487         opt.setTextDirection(q->layoutDirection());
    14881585
    14891586        doc->setDefaultTextOption(opt);
  • trunk/src/gui/widgets/qlabel.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6666    Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
    6767    Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
     68    Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
     69    Q_PROPERTY(QString selectedText READ selectedText)
    6870
    6971public:
     
    111113    void setTextInteractionFlags(Qt::TextInteractionFlags flags);
    112114    Qt::TextInteractionFlags textInteractionFlags() const;
     115
     116    void setSelection(int, int);
     117    bool hasSelectedText() const;
     118    QString selectedText() const;
     119    int selectionStart() const;
    113120
    114121public Q_SLOTS:
  • trunk/src/gui/widgets/qlabel_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5656#include "qlabel.h"
    5757
    58 #include "../text/qtextdocumentlayout_p.h"
     58#include "private/qtextdocumentlayout_p.h"
    5959#include "private/qtextcontrol_p.h"
    6060#include "qtextdocumentfragment.h"
     
    133133    QRect documentRect() const;
    134134    QPoint layoutPoint(const QPoint& p) const;
     135    Qt::LayoutDirection textDirection() const;
    135136#ifndef QT_NO_CONTEXTMENU
    136137    QMenu *createStandardContextMenu(const QPoint &pos);
  • trunk/src/gui/widgets/qlcdnumber.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qlcdnumber.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qlinecontrol.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    137137    \sa insert()
    138138*/
    139 void QLineControl::paste()
    140 {
    141     QString clip = QApplication::clipboard()->text(QClipboard::Clipboard);
     139void QLineControl::paste(QClipboard::Mode clipboardMode)
     140{
     141    QString clip = QApplication::clipboard()->text(clipboardMode);
    142142    if (!clip.isEmpty() || hasSelectedText()) {
    143143        separate(); //make it a separate undo/redo command
     
    420420
    421421    int c = m_cursor; // cursor position after insertion of commit string
    422     if (event->replacementStart() == 0)
     422    if (event->replacementStart() <= 0)
    423423        c += event->commitString().length() + qMin(-event->replacementStart(), event->replacementLength());
    424424
     
    528528        if (m_preeditCursor != -1)
    529529            cursor += m_preeditCursor;
    530         if(!m_blinkPeriod || m_blinkStatus)
     530        if (!m_hideCursor && (!m_blinkPeriod || m_blinkStatus))
    531531            m_textLayout.drawCursor(painter, offset, cursor, m_cursorWidth);
    532532    }
     
    537537
    538538    Sets the selection to cover the word at the given cursor position.
    539     The word boundries is defined by the behavior of QTextLayout::SkipWords
     539    The word boundaries are defined by the behavior of QTextLayout::SkipWords
    540540    cursor mode.
    541541*/
     
    12121212    \internal
    12131213
    1214     If the current cursor position differs from the last emited cursor
     1214    If the current cursor position differs from the last emitted cursor
    12151215    position, emits cursorPositionChanged().
    12161216*/
     
    13071307    }
    13081308    m_blinkPeriod = msec;
     1309}
     1310
     1311void QLineControl::resetCursorBlinkTimer()
     1312{
     1313    if (m_blinkPeriod == 0 || m_blinkTimer == 0)
     1314        return;
     1315    killTimer(m_blinkTimer);
     1316    m_blinkTimer = startTimer(m_blinkPeriod / 2);
     1317    m_blinkStatus = 1;
    13091318}
    13101319
     
    13511360    switch(ev->type()){
    13521361#ifndef QT_NO_GRAPHICSVIEW
     1362        case QEvent::GraphicsSceneMouseDoubleClick:
    13531363        case QEvent::GraphicsSceneMouseMove:
    13541364        case QEvent::GraphicsSceneMouseRelease:
     
    14401450            break;
    14411451        }
     1452        case QEvent::GraphicsSceneMouseDoubleClick:
    14421453        case QEvent::MouseButtonDblClick:
    14431454            if (ev->button() == Qt::LeftButton) {
     
    15771588    }
    15781589    else if (event == QKeySequence::Paste) {
    1579         if (!isReadOnly())
    1580             paste();
     1590        if (!isReadOnly()) {
     1591            QClipboard::Mode mode = QClipboard::Clipboard;
     1592#ifdef Q_WS_X11
     1593            if (event->modifiers() == (Qt::CTRL | Qt::SHIFT) && event->key() == Qt::Key_Insert)
     1594                mode = QClipboard::Selection;
     1595#endif
     1596            paste(mode);
     1597        }
    15811598    }
    15821599    else if (event == QKeySequence::Cut) {
     
    17621779                break;
    17631780#endif
    1764 
    17651781            default:
    17661782                if (!handled)
  • trunk/src/gui/widgets/qlinecontrol_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7979public:
    8080    QLineControl(const QString &txt = QString())
    81         : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LeftToRight),
     81        : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LayoutDirectionAuto),
    8282        m_hideCursor(false), m_separator(0), m_readOnly(0),
    8383        m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0),
     
    9595    }
    9696
    97     int nextMaskBlank(int pos);
    98     int prevMaskBlank(int pos);
    99 
    100     bool isUndoAvailable() const;
    101     bool isRedoAvailable() const;
    102     void clearUndo();
    103     bool isModified() const;
    104     void setModified(bool modified);
    105 
    106     bool allSelected() const;
    107     bool hasSelectedText() const;
    108 
    109     int width() const;
    110     int height() const;
    111     int ascent() const;
    112     qreal naturalTextWidth() const;
     97    int nextMaskBlank(int pos)
     98    {
     99        int c = findInMask(pos, true, false);
     100        m_separator |= (c != pos);
     101        return (c != -1 ?  c : m_maxLength);
     102    }
     103
     104    int prevMaskBlank(int pos)
     105    {
     106        int c = findInMask(pos, false, false);
     107        m_separator |= (c != pos);
     108        return (c != -1 ? c : 0);
     109    }
     110
     111    bool isUndoAvailable() const { return !m_readOnly && m_undoState; }
     112    bool isRedoAvailable() const { return !m_readOnly && m_undoState < (int)m_history.size(); }
     113    void clearUndo() { m_history.clear(); m_modifiedState = m_undoState = 0; }
     114
     115    bool isModified() const { return m_modifiedState != m_undoState; }
     116    void setModified(bool modified) { m_modifiedState = modified ? -1 : m_undoState; }
     117
     118    bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); }
     119    bool hasSelectedText() const { return !m_text.isEmpty() && m_selend > m_selstart; }
     120
     121    int width() const { return qRound(m_textLayout.lineAt(0).width()) + 1; }
     122    int height() const { return qRound(m_textLayout.lineAt(0).height()) + 1; }
     123    int ascent() const { return m_ascent; }
     124    qreal naturalTextWidth() const { return m_textLayout.lineAt(0).naturalTextWidth(); }
    113125
    114126    void setSelection(int start, int length);
    115127
    116     QString selectedText() const;
    117     QString textBeforeSelection() const;
    118     QString textAfterSelection() const;
    119 
    120     int selectionStart() const;
    121     int selectionEnd() const;
    122     bool inSelection(int x) const;
    123 
    124     void removeSelection();
    125 
    126     int start() const;
    127     int end() const;
     128    inline QString selectedText() const { return hasSelectedText() ? m_text.mid(m_selstart, m_selend - m_selstart) : QString(); }
     129    QString textBeforeSelection() const { return hasSelectedText() ? m_text.left(m_selstart) : QString(); }
     130    QString textAfterSelection() const { return hasSelectedText() ? m_text.mid(m_selend) : QString(); }
     131
     132    int selectionStart() const { return hasSelectedText() ? m_selstart : -1; }
     133    int selectionEnd() const { return hasSelectedText() ? m_selend : -1; }
     134    bool inSelection(int x) const
     135    {
     136        if (m_selstart >= m_selend)
     137            return false;
     138        int pos = xToPos(x, QTextLine::CursorOnCharacter);
     139        return pos >= m_selstart && pos < m_selend;
     140    }
     141
     142    void removeSelection()
     143    {
     144        int priorState = m_undoState;
     145        removeSelectedText();
     146        finishChange(priorState);
     147    }
     148
     149    int start() const { return 0; }
     150    int end() const { return m_text.length(); }
    128151
    129152#ifndef QT_NO_CLIPBOARD
    130153    void copy(QClipboard::Mode mode = QClipboard::Clipboard) const;
    131     void paste();
    132 #endif
    133 
    134     int cursor() const;
    135     int preeditCursor() const;
    136 
    137     int cursorWidth() const;
    138     void setCursorWidth(int value);
     154    void paste(QClipboard::Mode mode = QClipboard::Clipboard);
     155#endif
     156
     157    int cursor() const{ return m_cursor; }
     158    int preeditCursor() const { return m_preeditCursor; }
     159
     160    int cursorWidth() const { return m_cursorWidth; }
     161    void setCursorWidth(int value) { m_cursorWidth = value; }
     162
    139163
    140164    void moveCursor(int pos, bool mark = false);
    141     void cursorForward(bool mark, int steps);
    142     void cursorWordForward(bool mark);
    143     void cursorWordBackward(bool mark);
    144     void home(bool mark);
    145     void end(bool mark);
     165    void cursorForward(bool mark, int steps)
     166    {
     167        int c = m_cursor;
     168        if (steps > 0) {
     169            while (steps--)
     170                c = m_textLayout.nextCursorPosition(c);
     171        } else if (steps < 0) {
     172            while (steps++)
     173                c = m_textLayout.previousCursorPosition(c);
     174        }
     175        moveCursor(c, mark);
     176    }
     177
     178    void cursorWordForward(bool mark) { moveCursor(m_textLayout.nextCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
     179    void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
     180
     181    void home(bool mark) { moveCursor(0, mark); }
     182    void end(bool mark) { moveCursor(text().length(), mark); }
    146183
    147184    int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
    148185    QRect cursorRect() const;
    149186
    150     qreal cursorToX(int cursor) const;
    151     qreal cursorToX() const;
    152 
    153     bool isReadOnly() const;
    154     void setReadOnly(bool enable);
    155 
    156     QString text() const;
    157     void setText(const QString &txt);
    158 
    159     QString displayText() const;
     187    qreal cursorToX(int cursor) const { return m_textLayout.lineAt(0).cursorToX(cursor); }
     188    qreal cursorToX() const
     189    {
     190        int cursor = m_cursor;
     191        if (m_preeditCursor != -1)
     192            cursor += m_preeditCursor;
     193        return cursorToX(cursor);
     194    }
     195
     196    bool isReadOnly() const { return m_readOnly; }
     197    void setReadOnly(bool enable) { m_readOnly = enable; }
     198
     199    QString text() const
     200    {
     201        QString res = m_maskData ? stripString(m_text) : m_text;
     202        return (res.isNull() ? QString::fromLatin1("") : res);
     203    }
     204    void setText(const QString &txt) { internalSetText(txt, -1, false); }
     205    QString displayText() const { return m_textLayout.text(); }
    160206
    161207    void backspace();
    162208    void del();
    163     void deselect();
    164     void selectAll();
     209    void deselect() { internalDeselect(); finishChange(); }
     210    void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.length(), true); }
     211
    165212    void insert(const QString &);
    166213    void clear();
    167     void undo();
    168     void redo();
     214    void undo() { internalUndo(); finishChange(-1, true); }
     215    void redo() { internalRedo(); finishChange(); }
    169216    void selectWordAtPos(int);
    170217
    171     uint echoMode() const;
    172     void setEchoMode(uint mode);
    173 
    174     void setMaxLength(int maxLength);
    175     int maxLength() const;
     218    uint echoMode() const { return m_echoMode; }
     219    void setEchoMode(uint mode)
     220    {
     221        m_echoMode = mode;
     222        m_passwordEchoEditing = false;
     223        updateDisplayText();
     224    }
     225
     226    int maxLength() const { return m_maxLength; }
     227    void setMaxLength(int maxLength)
     228    {
     229        if (m_maskData)
     230            return;
     231        m_maxLength = maxLength;
     232        setText(m_text);
     233    }
    176234
    177235#ifndef QT_NO_VALIDATOR
    178     const QValidator *validator() const;
    179     void setValidator(const QValidator *);
     236    const QValidator *validator() const { return m_validator; }
     237    void setValidator(const QValidator *v) { m_validator = const_cast<QValidator*>(v); }
    180238#endif
    181239
    182240#ifndef QT_NO_COMPLETER
    183     QCompleter *completer() const;
    184     void setCompleter(const QCompleter*);
     241    QCompleter *completer() const { return m_completer; }
     242    /* Note that you must set the widget for the completer separately */
     243    void setCompleter(const QCompleter *c) { m_completer = const_cast<QCompleter*>(c); }
    185244    void complete(int key);
    186245#endif
    187246
    188     void setCursorPosition(int pos);
    189     int cursorPosition() const;
    190 
    191     bool hasAcceptableInput() const;
     247    int cursorPosition() const { return m_cursor; }
     248    void setCursorPosition(int pos) { if (pos <= m_text.length()) moveCursor(qMax(0, pos)); }
     249
     250    bool hasAcceptableInput() const { return hasAcceptableInput(m_text); }
    192251    bool fixup();
    193252
    194     QString inputMask() const;
    195     void setInputMask(const QString &mask);
     253    QString inputMask() const { return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString(); }
     254    void setInputMask(const QString &mask)
     255    {
     256        parseInputMask(mask);
     257        if (m_maskData)
     258            moveCursor(nextMaskBlank(0));
     259    }
    196260
    197261    // input methods
    198262#ifndef QT_NO_IM
    199     bool composeMode() const;
    200     void setPreeditArea(int cursor, const QString &text);
    201 #endif
    202 
    203     QString preeditAreaText() const;
     263    bool composeMode() const { return !m_textLayout.preeditAreaText().isEmpty(); }
     264    void setPreeditArea(int cursor, const QString &text) { m_textLayout.setPreeditArea(cursor, text); }
     265#endif
     266
     267    QString preeditAreaText() const { return m_textLayout.preeditAreaText(); }
    204268
    205269    void updatePasswordEchoEditing(bool editing);
    206     bool passwordEchoEditing() const;
    207 
    208     QChar passwordCharacter() const;
    209     void setPasswordCharacter(const QChar &character);
    210 
    211     Qt::LayoutDirection layoutDirection() const;
    212     void setLayoutDirection(Qt::LayoutDirection direction);
    213     void setFont(const QFont &font);
     270    bool passwordEchoEditing() const { return m_passwordEchoEditing; }
     271
     272    QChar passwordCharacter() const { return m_passwordCharacter; }
     273    void setPasswordCharacter(const QChar &character) { m_passwordCharacter = character; updateDisplayText(); }
     274
     275    Qt::LayoutDirection layoutDirection() const {
     276        if (m_layoutDirection == Qt::LayoutDirectionAuto) {
     277            if (m_text.isEmpty())
     278                return QApplication::keyboardInputDirection();
     279            return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
     280        }
     281        return m_layoutDirection;
     282    }
     283    void setLayoutDirection(Qt::LayoutDirection direction)
     284    {
     285        if (direction != m_layoutDirection) {
     286            m_layoutDirection = direction;
     287            updateDisplayText();
     288        }
     289    }
     290
     291    void setFont(const QFont &font) { m_textLayout.setFont(font); updateDisplayText(); }
    214292
    215293    void processInputMethodEvent(QInputMethodEvent *event);
     
    217295    void processKeyEvent(QKeyEvent* ev);
    218296
    219     int cursorBlinkPeriod() const;
     297    int cursorBlinkPeriod() const { return m_blinkPeriod; }
    220298    void setCursorBlinkPeriod(int msec);
    221 
    222     QString cancelText() const;
    223     void setCancelText(const QString &text);
    224 
    225     const QPalette &palette() const;
    226     void setPalette(const QPalette &);
     299    void resetCursorBlinkTimer();
     300
     301    QString cancelText() const { return m_cancelText; }
     302    void setCancelText(const QString &text) { m_cancelText = text; }
     303
     304    const QPalette &palette() const { return m_palette; }
     305    void setPalette(const QPalette &p) { m_palette = p; }
    227306
    228307    enum DrawFlags {
     
    364443};
    365444
    366 inline int QLineControl::nextMaskBlank(int pos)
    367 {
    368     int c = findInMask(pos, true, false);
    369     m_separator |= (c != pos);
    370     return (c != -1 ?  c : m_maxLength);
    371 }
    372 
    373 inline int QLineControl::prevMaskBlank(int pos)
    374 {
    375     int c = findInMask(pos, false, false);
    376     m_separator |= (c != pos);
    377     return (c != -1 ? c : 0);
    378 }
    379 
    380 inline bool QLineControl::isUndoAvailable() const
    381 {
    382     return !m_readOnly && m_undoState;
    383 }
    384 
    385 inline bool QLineControl::isRedoAvailable() const
    386 {
    387     return !m_readOnly && m_undoState < (int)m_history.size();
    388 }
    389 
    390 inline void QLineControl::clearUndo()
    391 {
    392     m_history.clear();
    393     m_modifiedState = m_undoState = 0;
    394 }
    395 
    396 inline bool QLineControl::isModified() const
    397 {
    398     return m_modifiedState != m_undoState;
    399 }
    400 
    401 inline void QLineControl::setModified(bool modified)
    402 {
    403     m_modifiedState = modified ? -1 : m_undoState;
    404 }
    405 
    406 inline bool QLineControl::allSelected() const
    407 {
    408     return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length();
    409 }
    410 
    411 inline bool QLineControl::hasSelectedText() const
    412 {
    413     return !m_text.isEmpty() && m_selend > m_selstart;
    414 }
    415 
    416 inline int QLineControl::width() const
    417 {
    418     return qRound(m_textLayout.lineAt(0).width()) + 1;
    419 }
    420 
    421 inline qreal QLineControl::naturalTextWidth() const
    422 {
    423     return m_textLayout.lineAt(0).naturalTextWidth();
    424 }
    425 
    426 inline int QLineControl::height() const
    427 {
    428     return qRound(m_textLayout.lineAt(0).height()) + 1;
    429 }
    430 
    431 inline int QLineControl::ascent() const
    432 {
    433     return m_ascent;
    434 }
    435 
    436 inline QString QLineControl::selectedText() const
    437 {
    438     if (hasSelectedText())
    439         return m_text.mid(m_selstart, m_selend - m_selstart);
    440     return QString();
    441 }
    442 
    443 inline QString QLineControl::textBeforeSelection() const
    444 {
    445     if (hasSelectedText())
    446         return m_text.left(m_selstart);
    447     return QString();
    448 }
    449 
    450 inline QString QLineControl::textAfterSelection() const
    451 {
    452     if (hasSelectedText())
    453         return m_text.mid(m_selend);
    454     return QString();
    455 }
    456 
    457 inline int QLineControl::selectionStart() const
    458 {
    459     return hasSelectedText() ? m_selstart : -1;
    460 }
    461 
    462 inline int QLineControl::selectionEnd() const
    463 {
    464     return hasSelectedText() ? m_selend : -1;
    465 }
    466 
    467 inline int QLineControl::start() const
    468 {
    469     return 0;
    470 }
    471 
    472 inline int QLineControl::end() const
    473 {
    474     return m_text.length();
    475 }
    476 
    477 inline void QLineControl::removeSelection()
    478 {
    479     int priorState = m_undoState;
    480     removeSelectedText();
    481     finishChange(priorState);
    482 }
    483 
    484 inline bool QLineControl::inSelection(int x) const
    485 {
    486     if (m_selstart >= m_selend)
    487         return false;
    488     int pos = xToPos(x, QTextLine::CursorOnCharacter);
    489     return pos >= m_selstart && pos < m_selend;
    490 }
    491 
    492 inline int QLineControl::cursor() const
    493 {
    494     return m_cursor;
    495 }
    496 
    497 inline int QLineControl::preeditCursor() const
    498 {
    499     return m_preeditCursor;
    500 }
    501 
    502 inline int QLineControl::cursorWidth() const
    503 {
    504     return m_cursorWidth;
    505 }
    506 
    507 inline void QLineControl::setCursorWidth(int value)
    508 {
    509     m_cursorWidth = value;
    510 }
    511 
    512 inline void QLineControl::cursorForward(bool mark, int steps)
    513 {
    514     int c = m_cursor;
    515     if (steps > 0) {
    516         while (steps--)
    517             c = m_textLayout.nextCursorPosition(c);
    518     } else if (steps < 0) {
    519         while (steps++)
    520             c = m_textLayout.previousCursorPosition(c);
    521     }
    522     moveCursor(c, mark);
    523 }
    524 
    525 inline void QLineControl::cursorWordForward(bool mark)
    526 {
    527     moveCursor(m_textLayout.nextCursorPosition(m_cursor, QTextLayout::SkipWords), mark);
    528 }
    529 
    530 inline void QLineControl::home(bool mark)
    531 {
    532     moveCursor(0, mark);
    533 }
    534 
    535 inline void QLineControl::end(bool mark)
    536 {
    537     moveCursor(text().length(), mark);
    538 }
    539 
    540 inline void QLineControl::cursorWordBackward(bool mark)
    541 {
    542     moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark);
    543 }
    544 
    545 inline qreal QLineControl::cursorToX(int cursor) const
    546 {
    547     return m_textLayout.lineAt(0).cursorToX(cursor);
    548 }
    549 
    550 inline qreal QLineControl::cursorToX() const
    551 {
    552     int cursor = m_cursor;
    553     if (m_preeditCursor != -1)
    554         cursor += m_preeditCursor;
    555     return cursorToX(cursor);
    556 }
    557 
    558 inline bool QLineControl::isReadOnly() const
    559 {
    560     return m_readOnly;
    561 }
    562 
    563 inline void QLineControl::setReadOnly(bool enable)
    564 {
    565     m_readOnly = enable;
    566 }
    567 
    568 inline QString QLineControl::text() const
    569 {
    570     QString res = m_maskData ? stripString(m_text) : m_text;
    571     return (res.isNull() ? QString::fromLatin1("") : res);
    572 }
    573 
    574 inline void QLineControl::setText(const QString &txt)
    575 {
    576     internalSetText(txt, -1, false);
    577 }
    578 
    579 inline QString QLineControl::displayText() const
    580 {
    581     return m_textLayout.text();
    582 }
    583 
    584 inline void QLineControl::deselect()
    585 {
    586     internalDeselect();
    587     finishChange();
    588 }
    589 
    590 inline void QLineControl::selectAll()
    591 {
    592     m_selstart = m_selend = m_cursor = 0;
    593     moveCursor(m_text.length(), true);
    594 }
    595 
    596 inline void QLineControl::undo()
    597 {
    598     internalUndo();
    599     finishChange(-1, true);
    600 }
    601 
    602 inline void QLineControl::redo()
    603 {
    604     internalRedo();
    605     finishChange();
    606 }
    607 
    608 inline uint QLineControl::echoMode() const
    609 {
    610     return m_echoMode;
    611 }
    612 
    613 inline void QLineControl::setEchoMode(uint mode)
    614 {
    615     m_echoMode = mode;
    616     m_passwordEchoEditing = false;
    617     updateDisplayText();
    618 }
    619 
    620 inline void QLineControl::setMaxLength(int maxLength)
    621 {
    622     if (m_maskData)
    623         return;
    624     m_maxLength = maxLength;
    625     setText(m_text);
    626 }
    627 
    628 inline int QLineControl::maxLength() const
    629 {
    630     return m_maxLength;
    631 }
    632 
    633 #ifndef QT_NO_VALIDATOR
    634 inline const QValidator *QLineControl::validator() const
    635 {
    636     return m_validator;
    637 }
    638 
    639 inline void QLineControl::setValidator(const QValidator *v)
    640 {
    641     m_validator = const_cast<QValidator*>(v);
    642 }
    643 #endif
    644 
    645 #ifndef QT_NO_COMPLETER
    646 inline QCompleter *QLineControl::completer() const
    647 {
    648     return m_completer;
    649 }
    650 
    651 /* Note that you must set the widget for the completer seperately */
    652 inline void QLineControl::setCompleter(const QCompleter* c)
    653 {
    654     m_completer = const_cast<QCompleter*>(c);
    655 }
    656 #endif
    657 
    658 inline void QLineControl::setCursorPosition(int pos)
    659 {
    660     if (pos < 0)
    661         pos = 0;
    662     if (pos <= m_text.length())
    663         moveCursor(pos);
    664 }
    665 
    666 inline int QLineControl::cursorPosition() const
    667 {
    668     return m_cursor;
    669 }
    670 
    671 inline bool QLineControl::hasAcceptableInput() const
    672 {
    673     return hasAcceptableInput(m_text);
    674 }
    675 
    676 inline QString QLineControl::inputMask() const
    677 {
    678     return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString();
    679 }
    680 
    681 inline void QLineControl::setInputMask(const QString &mask)
    682 {
    683     parseInputMask(mask);
    684     if (m_maskData)
    685         moveCursor(nextMaskBlank(0));
    686 }
    687 
    688 // input methods
    689 #ifndef QT_NO_IM
    690 inline bool QLineControl::composeMode() const
    691 {
    692     return !m_textLayout.preeditAreaText().isEmpty();
    693 }
    694 
    695 inline void QLineControl::setPreeditArea(int cursor, const QString &text)
    696 {
    697     m_textLayout.setPreeditArea(cursor, text);
    698 }
    699 #endif
    700 
    701 inline QString QLineControl::preeditAreaText() const
    702 {
    703     return m_textLayout.preeditAreaText();
    704 }
    705 
    706 inline bool QLineControl::passwordEchoEditing() const
    707 {
    708     return m_passwordEchoEditing;
    709 }
    710 
    711 inline QChar QLineControl::passwordCharacter() const
    712 {
    713     return m_passwordCharacter;
    714 }
    715 
    716 inline void QLineControl::setPasswordCharacter(const QChar &character)
    717 {
    718     m_passwordCharacter = character;
    719     updateDisplayText();
    720 }
    721 
    722 inline Qt::LayoutDirection QLineControl::layoutDirection() const
    723 {
    724     return m_layoutDirection;
    725 }
    726 
    727 inline void QLineControl::setLayoutDirection(Qt::LayoutDirection direction)
    728 {
    729     if (direction != m_layoutDirection) {
    730         m_layoutDirection = direction;
    731         updateDisplayText();
    732     }
    733 }
    734 
    735 inline void QLineControl::setFont(const QFont &font)
    736 {
    737     m_textLayout.setFont(font);
    738     updateDisplayText();
    739 }
    740 
    741 inline int QLineControl::cursorBlinkPeriod() const
    742 {
    743     return m_blinkPeriod;
    744 }
    745 
    746 inline QString QLineControl::cancelText() const
    747 {
    748     return m_cancelText;
    749 }
    750 
    751 inline void QLineControl::setCancelText(const QString &text)
    752 {
    753     m_cancelText = text;
    754 }
    755 
    756 inline const QPalette & QLineControl::palette() const
    757 {
    758     return m_palette;
    759 }
    760 
    761 inline void QLineControl::setPalette(const QPalette &p)
    762 {
    763     m_palette = p;
    764 }
    765 
    766445QT_END_NAMESPACE
    767446
  • trunk/src/gui/widgets/qlineedit.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    140140    The length of the text can be constrained to maxLength(). The text
    141141    can be arbitrarily constrained using a validator() or an
    142     inputMask(), or both.
     142    inputMask(), or both. When switching between a validator and an input mask
     143    on the same line edit, it is best to clear the validator or input mask to
     144    prevent undefined behavior.
     145
    143146
    144147    A related class is QTextEdit which allows multi-line, rich text
     
    384387}
    385388
    386 // ### Qt 4.7: remove this #if guard
    387 #if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)
    388389/*!
    389390    \since 4.7
     
    415416    }
    416417}
    417 #endif
    418418
    419419/*!
     
    543543        return;
    544544    Qt::InputMethodHints imHints = inputMethodHints();
    545     if (mode == Password) {
     545    if (mode == Password || mode == NoEcho) {
    546546        imHints |= Qt::ImhHiddenText;
    547547    } else {
    548548        imHints &= ~Qt::ImhHiddenText;
     549    }
     550    if (mode != Normal) {
     551        imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
     552    } else {
     553        imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
    549554    }
    550555    setInputMethodHints(imHints);
     
    16441649                    if (!event->text().isEmpty() && event->text().at(0).isPrint()
    16451650                        && !isReadOnly())
    1646                     {
    16471651                        setEditFocus(true);
    1648 #ifndef Q_OS_SYMBIAN
    1649                         clear();
    1650 #endif
    1651                     } else {
     1652                    else {
    16521653                        event->ignore();
    16531654                        return;
     
    16661667#endif
    16671668    d->control->processKeyEvent(event);
    1668     if (event->isAccepted())
     1669    if (event->isAccepted()) {
     1670        if (layoutDirection() != d->control->layoutDirection())
     1671            setLayoutDirection(d->control->layoutDirection());
    16691672        d->control->setCursorBlinkPeriod(0);
     1673    }
    16701674}
    16711675
     
    17051709    if (QApplication::keypadNavigationEnabled()
    17061710        && hasFocus() && !hasEditFocus()
    1707         && !e->preeditString().isEmpty()) {
     1711        && !e->preeditString().isEmpty())
    17081712        setEditFocus(true);
    1709 #ifndef Q_OS_SYMBIAN
    1710         selectAll();        // so text is replaced rather than appended to
    1711 #endif
    1712     }
    17131713#endif
    17141714
     
    18671867
    18681868    QFontMetrics fm = fontMetrics();
    1869     Qt::Alignment va = QStyle::visualAlignment(layoutDirection(), QFlag(d->alignment));
     1869    Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment));
    18701870    switch (va & Qt::AlignVertical_Mask) {
    18711871     case Qt::AlignBottom:
     
    18821882    QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height());
    18831883
     1884    int minLB = qMax(0, -fm.minLeftBearing());
     1885    int minRB = qMax(0, -fm.minRightBearing());
     1886
    18841887    if (d->control->text().isEmpty()) {
    18851888        if (!hasFocus() && !d->placeholderText.isEmpty()) {
     
    18881891            QPen oldpen = p.pen();
    18891892            p.setPen(col);
    1890             p.drawText(lineRect, va, d->placeholderText);
     1893            lineRect.adjust(minLB, 0, 0, 0);
     1894            QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width());
     1895            p.drawText(lineRect, va, elidedText);
    18911896            p.setPen(oldpen);
    18921897            return;
     
    19021907    // minLB, minRB), the line edit rect (lineRect) and the cursor position
    19031908    // (cix).
    1904     int minLB = qMax(0, -fm.minLeftBearing());
    1905     int minRB = qMax(0, -fm.minRightBearing());
    19061909    int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB;
    19071910    if ((minLB + widthUsed) <=  lineRect.width()) {
     
    19301933        // right
    19311934        d->hscroll = widthUsed - lineRect.width() + 1;
    1932     }
     1935    } else {
     1936        //in case the text is bigger than the lineedit, the hscroll can never be negative
     1937        d->hscroll = qMax(0, d->hscroll);
     1938    }
     1939
    19331940    // the y offset is there to keep the baseline constant in case we have script changes in the text.
    19341941    QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
     
    19501957        flags |= QLineControl::DrawSelections;
    19511958        // Palette only used for selections/mask and may not be in sync
    1952         if(d->control->palette() != pal)
     1959        if (d->control->palette() != pal
     1960           || d->control->palette().currentColorGroup() != pal.currentColorGroup())
    19531961            d->control->setPalette(pal);
    19541962    }
     
    20532061void QLineEdit::contextMenuEvent(QContextMenuEvent *event)
    20542062{
    2055     QPointer<QMenu> menu = createStandardContextMenu();
    2056     menu->exec(event->globalPos());
    2057     delete menu;
    2058 }
    2059 
    2060 #if defined(Q_WS_WIN)
     2063    if (QMenu *menu = createStandardContextMenu()) {
     2064        menu->setAttribute(Qt::WA_DeleteOnClose);
     2065        menu->popup(event->globalPos());
     2066    }
     2067}
     2068
     2069#if defined(Q_WS_WIN) || defined(Q_WS_X11)
    20612070    extern bool qt_use_rtl_extensions;
    20622071#endif
     
    21302139#endif
    21312140
    2132 #if defined(Q_WS_WIN)
     2141#if defined(Q_WS_WIN) || defined(Q_WS_X11)
    21332142    if (!d->control->isReadOnly() && qt_use_rtl_extensions) {
    21342143#else
     
    21632172        }
    21642173        update();
    2165         break;
    2166     case QEvent::LayoutDirectionChange:
    2167         d->control->setLayoutDirection(layoutDirection());
    21682174        break;
    21692175    default:
  • trunk/src/gui/widgets/qlineedit.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8484    Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
    8585    Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
    86 // ### Qt 4.7: remove this #if guard
    87 #if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)
    8886    Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
    89 #endif
    9087
    9188public:
     
    103100    QString displayText() const;
    104101
    105 // ### Qt 4.7: remove this #if guard
    106 #if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)
    107102    QString placeholderText() const;
    108103    void setPlaceholderText(const QString &);
    109 #endif
    110104
    111105    int maxLength() const;
  • trunk/src/gui/widgets/qlineedit_p.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qlineedit_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmaccocoaviewcontainer_mac.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmaccocoaviewcontainer_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmacnativewidget_mac.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmacnativewidget_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmainwindow.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4040****************************************************************************/
    4141
     42//#define QT_EXPERIMENTAL_CLIENT_DECORATIONS
     43
    4244#include "qmainwindow.h"
    4345#include "qmainwindowlayout_p.h"
     
    7779#ifdef Q_WS_MAC
    7880            , useHIToolBar(false)
     81            , activateUnifiedToolbarAfterFullScreen(false)
    7982#endif
    8083#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
     
    8891#ifdef Q_WS_MAC
    8992    bool useHIToolBar;
     93    bool activateUnifiedToolbarAfterFullScreen;
    9094#endif
    9195    void init();
     
    100104    uint cursorAdjusted : 1;
    101105#endif
     106
     107    static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow)
     108    {
     109        return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0);
     110    }
    102111};
    103112
     113QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow)
     114{
     115    return QMainWindowPrivate::mainWindowLayout(mainWindow);
     116}
     117
     118#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS
     119Q_GUI_EXPORT void qt_setMainWindowTitleWidget(QMainWindow *mainWindow, Qt::DockWidgetArea area, QWidget *widget)
     120{
     121    QGridLayout *topLayout = qobject_cast<QGridLayout *>(mainWindow->layout());
     122    Q_ASSERT(topLayout);
     123
     124    int row = 0;
     125    int column = 0;
     126
     127    switch (area) {
     128    case Qt::LeftDockWidgetArea:
     129        row = 1;
     130        column = 0;
     131        break;
     132    case Qt::TopDockWidgetArea:
     133        row = 0;
     134        column = 1;
     135        break;
     136    case Qt::BottomDockWidgetArea:
     137        row = 2;
     138        column = 1;
     139        break;
     140    case Qt::RightDockWidgetArea:
     141        row = 1;
     142        column = 2;
     143        break;
     144    default:
     145        Q_ASSERT_X(false, "qt_setMainWindowTitleWidget", "Unknown area");
     146        return;
     147    }
     148
     149    if (QLayoutItem *oldItem = topLayout->itemAtPosition(row, column))
     150        delete oldItem->widget();
     151    topLayout->addWidget(widget, row, column);
     152}
     153#endif
     154
    104155void QMainWindowPrivate::init()
    105156{
    106157    Q_Q(QMainWindow);
    107     layout = new QMainWindowLayout(q);
     158
     159#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS
     160    QGridLayout *topLayout = new QGridLayout(q);
     161    topLayout->setContentsMargins(0, 0, 0, 0);
     162
     163    layout = new QMainWindowLayout(q, topLayout);
     164
     165    topLayout->addItem(layout, 1, 1);
     166#else
     167    layout = new QMainWindowLayout(q, 0);
     168#endif
     169
    108170    const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
    109171    iconSize = QSize(metric, metric);
     
    443505QMenuBar *QMainWindow::menuBar() const
    444506{
    445     QMenuBar *menuBar = qobject_cast<QMenuBar *>(d_func()->layout->menuBar());
     507    QMenuBar *menuBar = qobject_cast<QMenuBar *>(layout()->menuBar());
    446508    if (!menuBar) {
    447509        QMainWindow *self = const_cast<QMainWindow *>(this);
     
    462524void QMainWindow::setMenuBar(QMenuBar *menuBar)
    463525{
    464     Q_D(QMainWindow);
    465     if (d->layout->menuBar() && d->layout->menuBar() != menuBar) {
     526    QLayout *topLayout = layout();
     527
     528    if (topLayout->menuBar() && topLayout->menuBar() != menuBar) {
    466529        // Reparent corner widgets before we delete the old menu bar.
    467         QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(d->layout->menuBar());
     530        QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar());
    468531        if (menuBar) {
    469532            // TopLeftCorner widget.
     
    479542        oldMenuBar->deleteLater();
    480543    }
    481     d->layout->setMenuBar(menuBar);
     544    topLayout->setMenuBar(menuBar);
    482545}
    483546
     
    13751438
    13761439        case QEvent::StyleChange:
     1440#ifndef QT_NO_DOCKWIDGET
     1441            d->layout->layoutState.dockAreaLayout.styleChangedEvent();
     1442#endif
    13771443            if (!d->explicitIconSize)
    13781444                setIconSize(QSize());
     
    14381504        disappear since it is considered to be part of the title bar. Qt 4.5 and up will now work around this by pulling
    14391505        the toolbars out and back into the regular toolbar and vice versa when you swap out.
    1440         However, a good practice would be that turning off the unified toolbar before you call
    1441         showFullScreen() and restoring it after you call showNormal().
    14421506    \endlist
    14431507
     
    14541518
    14551519    // ### Disable the unified toolbar when using anything but the native graphics system.
    1456     if (windowSurface())
     1520    // ### Disable when using alien widgets as well
     1521    if (windowSurface() || testAttribute(Qt::WA_NativeWindow) == false)
    14571522        return;
    14581523
     
    15361601#ifndef QT_NO_MENU
    15371602    QMenu *popup = createPopupMenu();
    1538     if (popup && !popup->isEmpty()) {
    1539         popup->exec(event->globalPos());
    1540         event->accept();
    1541     }
    1542     delete popup;
     1603    if (popup) {
     1604        if (!popup->isEmpty()) {
     1605            popup->setAttribute(Qt::WA_DeleteOnClose);
     1606            popup->popup(event->globalPos());
     1607            event->accept();
     1608        } else {
     1609            delete popup;
     1610        }
     1611    }
    15431612#endif
    15441613}
  • trunk/src/gui/widgets/qmainwindow.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmainwindowlayout.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    161161void qt_dumpLayout(QTextStream &qout, QMainWindow *window)
    162162{
    163     QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(window->layout());
     163    QMainWindowLayout *layout = qt_mainwindow_layout(window);
    164164    dumpLayout(qout, layout->layoutState.dockAreaLayout, QString());
    165165}
     
    236236#else
    237237    if (centralWidgetItem != 0) {
    238         QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
     238        QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);
    239239        Q_ASSERT(layout != 0);
    240240        layout->widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, animated);
     
    944944    if (layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) {
    945945        // If we hit this case, someone has pressed the "toolbar button" which will
    946         // toggle the unified toolbar visiblity, because that's what the user wants.
     946        // toggle the unified toolbar visibility, because that's what the user wants.
    947947        // We might be in a situation where someone has hidden all the toolbars
    948948        // beforehand (maybe in construction), but now they've hit this button and
     
    16751675}
    16761676
    1677 QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow)
    1678     : QLayout(mainwindow)
     1677QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout)
     1678    : QLayout(parentLayout ? static_cast<QWidget *>(0) : mainwindow)
    16791679    , layoutState(mainwindow)
    16801680    , savedState(mainwindow)
     
    16991699#endif
    17001700{
     1701    if (parentLayout)
     1702        setParent(parentLayout);
     1703
    17011704#ifndef QT_NO_DOCKWIDGET
    17021705#ifndef QT_NO_TABBAR
  • trunk/src/gui/widgets/qmainwindowlayout_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4949#else
    5050#include <private/qcocoatoolbardelegate_mac_p.h>
     51#import  <private/qcocoawindowdelegate_mac_p.h>
    5152#endif
    5253
     
    338339
    339340    layoutState.mainWindow->setUpdatesEnabled(false);  // reduces a little bit of flicker, not all though
     341#if defined(QT_MAC_USE_COCOA)
     342    QMacCocoaAutoReleasePool pool;
     343    NSView *cView = [qt_mac_window_for(layoutState.mainWindow) contentView];
     344    if (useMacToolbar) {
     345        [cView setPostsFrameChangedNotifications:YES];
     346        [[NSNotificationCenter defaultCenter] addObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate]
     347                                                 selector: @selector(syncContentViewFrame:)
     348                                                     name: NSViewFrameDidChangeNotification
     349                                                   object: cView];
     350    }
     351#endif
    340352    if (!useMacToolbar) {
    341353        macWindowToolbarShow(layoutState.mainWindow, false);
     
    357369        syncUnifiedToolbarVisibility();
    358370    }
     371#if defined(QT_MAC_USE_COCOA)
     372    if (!useMacToolbar) {
     373        [cView setPostsFrameChangedNotifications:NO];
     374        [[NSNotificationCenter defaultCenter] removeObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate]
     375                                                        name: NSViewFrameDidChangeNotification
     376                                                      object: cView];
     377    }
     378#endif
    359379    layoutState.mainWindow->setUpdatesEnabled(true);
    360380}
     
    411431        [macToolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
    412432        [macToolbar setSizeMode:NSToolbarSizeModeRegular];
    413         [macToolbar setDelegate:[[QCocoaToolBarDelegate alloc] initWithMainWindowLayout:this]];
     433        [macToolbar setDelegate:[[QT_MANGLE_NAMESPACE(QCocoaToolBarDelegate) alloc] initWithMainWindowLayout:this]];
    414434        [window setToolbar:macToolbar];
    415435        [macToolbar release];
  • trunk/src/gui/widgets/qmainwindowlayout_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    160160    QMainWindowLayoutState layoutState, savedState;
    161161
    162     explicit QMainWindowLayout(QMainWindow *mainwindow);
     162    QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout);
    163163    ~QMainWindowLayout();
    164164
     
    336336    void fixSizeInUnifiedToolbar(QToolBar *tb) const;
    337337    bool useHIToolBar;
     338    bool activateUnifiedToolbarAfterFullScreen;
    338339    void syncUnifiedToolbarVisibility();
    339340    bool blockVisiblityCheck;
  • trunk/src/gui/widgets/qmdiarea.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmdiarea.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmdiarea_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmdisubwindow.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmdisubwindow.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmdisubwindow_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmenu.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8686QT_BEGIN_NAMESPACE
    8787
    88 QPointer<QMenu> QMenuPrivate::mouseDown;
    89 QBasicTimer QMenuPrivate::menuDelayTimer;
    90 QBasicTimer QMenuPrivate::sloppyDelayTimer;
     88QMenu *QMenuPrivate::mouseDown = 0;
     89int QMenuPrivate::sloppyDelayTimer = 0;
    9190
    9291/* QMenu code */
     
    264263    const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
    265264
    266     //for compatability now - will have to refactor this away..
     265    //for compatibility now - will have to refactor this away
    267266    tabWidth = 0;
    268267    maxIconWidth = 0;
     
    489488        if (!delay)
    490489            q->internalDelayedPopup();
    491         else
    492             QMenuPrivate::menuDelayTimer.start(delay, q);
     490        else if (!menuDelayTimer.isActive() && (!action->menu() || !action->menu()->isVisible()))
     491            menuDelayTimer.start(delay, q);
    493492        if (activateFirst && action->menu())
    494493            action->menu()->d_func()->setFirstActionActive();
     
    545544    Q_Q(QMenu);
    546545    tearoffHighlighted = 0;
    547     if (action == currentAction) {
    548         if (!action || !action->menu() || action->menu() == activeMenu) {
    549             if(QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {
    550                 if(causedPopup.action && menu->d_func()->activeMenu == q)
    551                     menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
    552             }
    553         }
    554         return;
    555     }
    556546    if (currentAction)
    557547        q->update(actionRect(currentAction));
     
    567557    emitHighlighted = action;
    568558#endif
     559
    569560    currentAction = action;
    570561    if (action) {
     
    11641155bool QMenuPrivate::hasMouseMoved(const QPoint &globalPos)
    11651156{
    1166     //determines if the mouse has moved (ie its intial position has
     1157    //determines if the mouse has moved (ie its initial position has
    11671158    //changed by more than QApplication::startDragDistance()
    11681159    //or if there were at least 6 mouse motions)
     
    13301321    addActions() and insertAction() functions.
    13311322
     1323    \warning To make QMenu visible on the screen, exec() or popup() should be
     1324    used instead of show().
     1325
    13321326    \section1 QMenu on Qt for Windows CE
    13331327
     
    18051799{
    18061800    Q_D(QMenu);
    1807     if (d->scroll) { //reset scroll state from last popup
     1801#ifndef Q_OS_SYMBIAN
     1802    if (d->scroll) { // reset scroll state from last popup
    18081803        d->scroll->scrollOffset = 0;
    18091804        d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
    18101805    }
     1806#endif
    18111807    d->tearoffHighlighted = 0;
    18121808    d->motions = 0;
     
    18341830    QRect screen;
    18351831#ifndef QT_NO_GRAPHICSVIEW
    1836     bool isEmbedded = d->nearestGraphicsProxyWidget(this);
     1832    bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this);
    18371833    if (isEmbedded)
    18381834        screen = d->popupGeometry(this);
     
    18601856#endif
    18611857    if (d->ncols > 1) {
    1862         pos.setY(screen.top()+desktopFrame);
     1858        pos.setY(screen.top() + desktopFrame);
    18631859    } else if (atAction) {
    1864         for(int i = 0, above_height = 0; i < d->actions.count(); i++) {
     1860        for (int i = 0, above_height = 0; i < d->actions.count(); i++) {
    18651861            QAction *action = d->actions.at(i);
    18661862            if (action == atAction) {
     
    18771873                    && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)) {
    18781874                    int below_height = above_height + d->scroll->scrollOffset;
    1879                     for(int i2 = i; i2 < d->actionRects.count(); i2++)
     1875                    for (int i2 = i; i2 < d->actionRects.count(); i2++)
    18801876                        below_height += d->actionRects.at(i2).height();
    18811877                    size.setHeight(below_height);
     
    18901886    QPoint mouse = QCursor::pos();
    18911887    d->mousePopupPos = mouse;
    1892     const bool snapToMouse = (QRect(p.x()-3, p.y()-3, 6, 6).contains(mouse));
     1888    const bool snapToMouse = (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
    18931889
    18941890    if (adjustToDesktop) {
    1895         //handle popup falling "off screen"
     1891        // handle popup falling "off screen"
    18961892        if (isRightToLeft()) {
    1897             if(snapToMouse) //position flowing left from the mouse
    1898                 pos.setX(mouse.x()-size.width());
     1893            if (snapToMouse) // position flowing left from the mouse
     1894                pos.setX(mouse.x() - size.width());
    18991895
    19001896#ifndef QT_NO_MENUBAR
    1901             //if in a menubar, it should be right-aligned
     1897            // if in a menubar, it should be right-aligned
    19021898            if (qobject_cast<QMenuBar*>(d->causedPopup.widget))
    19031899                pos.rx() -= size.width();
    19041900#endif //QT_NO_MENUBAR
    19051901
    1906             if (pos.x() < screen.left()+desktopFrame)
    1907                 pos.setX(qMax(p.x(), screen.left()+desktopFrame));
    1908             if (pos.x()+size.width()-1 > screen.right()-desktopFrame)
    1909                 pos.setX(qMax(p.x()-size.width(), screen.right()-desktopFrame-size.width()+1));
     1902            if (pos.x() < screen.left() + desktopFrame)
     1903                pos.setX(qMax(p.x(), screen.left() + desktopFrame));
     1904            if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
     1905                pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1));
    19101906        } else {
    1911             if (pos.x()+size.width()-1 > screen.right()-desktopFrame)
    1912                 pos.setX(screen.right()-desktopFrame-size.width()+1);
    1913             if (pos.x() < screen.left()+desktopFrame)
     1907            if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
     1908                pos.setX(screen.right() - desktopFrame - size.width() + 1);
     1909            if (pos.x() < screen.left() + desktopFrame)
    19141910                pos.setX(screen.left() + desktopFrame);
    19151911        }
     
    19251921        if (pos.y() < screen.top() + desktopFrame)
    19261922            pos.setY(screen.top() + desktopFrame);
    1927         if (pos.y()+size.height()-1 > screen.bottom() - desktopFrame) {
     1923        if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) {
    19281924            if (d->scroll) {
    19291925                d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
    19301926                int y = qMax(screen.y(),pos.y());
    1931                 size.setHeight(screen.bottom()-(desktopFrame*2)-y);
     1927                size.setHeight(screen.bottom() - (desktopFrame * 2) - y);
    19321928            } else {
    19331929                // Too big for screen, bias to see bottom of menu (for some reason)
    1934                 pos.setY(screen.bottom()-size.height()+1);
     1930                pos.setY(screen.bottom() - size.height() + 1);
    19351931            }
    19361932        }
     
    19411937    int vGuess = QEffects::DownScroll;
    19421938    if (isRightToLeft()) {
    1943         if ((snapToMouse && (pos.x() + size.width()/2 > mouse.x())) ||
    1944            (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 > d->causedPopup.widget->x()))
     1939        if ((snapToMouse && (pos.x() + size.width() / 2 > mouse.x())) ||
     1940           (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 > d->causedPopup.widget->x()))
    19451941            hGuess = QEffects::RightScroll;
    19461942    } else {
    1947         if ((snapToMouse && (pos.x() + size.width()/2 < mouse.x())) ||
    1948            (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 < d->causedPopup.widget->x()))
     1943        if ((snapToMouse && (pos.x() + size.width() / 2 < mouse.x())) ||
     1944           (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 < d->causedPopup.widget->x()))
    19491945            hGuess = QEffects::LeftScroll;
    19501946    }
    19511947
    19521948#ifndef QT_NO_MENUBAR
    1953     if ((snapToMouse && (pos.y() + size.height()/2 < mouse.y())) ||
     1949    if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) ||
    19541950       (qobject_cast<QMenuBar*>(d->causedPopup.widget) &&
    1955         pos.y() + size.width()/2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
     1951        pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
    19561952       vGuess = QEffects::UpScroll;
    19571953#endif
     
    23032299
    23042300    if (action && action == d->currentAction) {
    2305         if (action->menu())
    2306             action->menu()->d_func()->setFirstActionActive();
    2307         else {
     2301        if (!action->menu()){
    23082302#if defined(Q_WS_WIN)
    23092303            //On Windows only context menus can be activated with the right button
     
    23792373    } break;
    23802374    case QEvent::ContextMenu:
    2381         if(QMenuPrivate::menuDelayTimer.isActive()) {
    2382             QMenuPrivate::menuDelayTimer.stop();
     2375        if(d->menuDelayTimer.isActive()) {
     2376            d->menuDelayTimer.stop();
    23832377            internalDelayedPopup();
    23842378        }
     
    28152809    if (d->sloppyRegion.contains(e->pos())) {
    28162810        d->sloppyAction = action;
    2817         QMenuPrivate::sloppyDelayTimer.start(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6, this);
     2811        QMenuPrivate::sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6);
    28182812    } else {
    28192813        d->setCurrentAction(action, style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this));
     
    28532847        if (d->scroll->scrollFlags == QMenuPrivate::QMenuScroller::ScrollNone)
    28542848            d->scroll->scrollTimer.stop();
    2855     } else if(QMenuPrivate::menuDelayTimer.timerId() == e->timerId()) {
    2856         QMenuPrivate::menuDelayTimer.stop();
     2849    } else if(d->menuDelayTimer.timerId() == e->timerId()) {
     2850        d->menuDelayTimer.stop();
    28572851        internalDelayedPopup();
    2858     } else if(QMenuPrivate::sloppyDelayTimer.timerId() == e->timerId()) {
    2859         QMenuPrivate::sloppyDelayTimer.stop();
     2852    } else if(QMenuPrivate::sloppyDelayTimer == e->timerId()) {
     2853        killTimer(QMenuPrivate::sloppyDelayTimer);
     2854        QMenuPrivate::sloppyDelayTimer = 0;
    28602855        internalSetSloppyAction();
    28612856    } else if(d->searchBufferTimer.timerId() == e->timerId()) {
  • trunk/src/gui/widgets/qmenu.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    418418    friend bool qt_mac_activate_action(OSMenuRef, uint, QAction::ActionEvent, bool);
    419419    friend void qt_mac_emit_menuSignals(QMenu *, bool);
     420    friend void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action);
    420421#endif
    421422};
  • trunk/src/gui/widgets/qmenu_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    248248    //now walk up firing for each "caused" widget (like in the platform independent menu)
    249249    QWidget *caused = 0;
    250     if (GetMenuItemProperty(menu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), 0, &caused) == noErr) {
     250    if (action_e == QAction::Hover && GetMenuItemProperty(menu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), 0, &caused) == noErr) {
    251251        MenuRef caused_menu = 0;
    252252        if (QMenu *qmenu2 = qobject_cast<QMenu*>(caused))
     
    261261            GetMenuItemProperty(caused_menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(widget), 0, &widget);
    262262            if (QMenu *qmenu = qobject_cast<QMenu*>(widget)) {
    263                 if (action_e == QAction::Trigger) {
    264                     emit qmenu->triggered(action->action);
    265                 } else if (action_e == QAction::Hover) {
    266                     action->action->showStatusText(widget);
    267                     emit qmenu->hovered(action->action);
    268                 }
     263                action->action->showStatusText(widget);
     264                emit qmenu->hovered(action->action);
    269265            } else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)) {
    270                 if (action_e == QAction::Trigger) {
    271                     emit qmenubar->triggered(action->action);
    272                 } else if (action_e == QAction::Hover) {
    273                     action->action->showStatusText(widget);
    274                     emit qmenubar->hovered(action->action);
    275                 }
     266                action->action->showStatusText(widget);
     267                emit qmenubar->hovered(action->action);
    276268                break; //nothing more..
    277269            }
     
    279271            //walk up
    280272            if (GetMenuItemProperty(caused_menu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget,
    281                                    sizeof(caused), 0, &caused) != noErr)
     273                                    sizeof(caused), 0, &caused) != noErr)
    282274                break;
    283275            if (QMenu *qmenu2 = qobject_cast<QMenu*>(caused))
     
    650642                         initWithTitle:qt_mac_QStringToNSString(title)
    651643                         action:@selector(qtDispatcherToQAction:) keyEquivalent:@""];
    652     [item setTarget:getMenuLoader()];
     644    [item setTarget:nil];
    653645    return item;
    654646}
     
    674666    }
    675667#else
     668    bool modalWindowOnScreen = qApp->activeModalWidget() != 0;
    676669    for (NSMenuItem *item in [menu itemArray]) {
    677670        OSMenuRef submenu = [item submenu];
     
    683676                if ([item tag]) {
    684677                    QAction *action = reinterpret_cast<QAction *>([item tag]);
    685                      syncNSMenuItemEnabled(item, action->isEnabled());
    686                  } else {
    687                      syncNSMenuItemEnabled(item, YES);
    688                  }
     678                    syncNSMenuItemEnabled(item, action->isEnabled());
     679                } else {
     680                    syncNSMenuItemEnabled(item, YES);
     681                }
     682                // We sneak in some extra code here to handle a menu problem:
     683                // If there is no window on screen, we cannot set 'nil' as
     684                // menu item target, because then cocoa will disable the item
     685                // (guess it assumes that there will be no first responder to
     686                // catch the trigger anyway?) OTOH, If we have a modal window,
     687                // then setting the menu loader as target will make cocoa not
     688                // deliver the trigger because the loader is then seen as modally
     689                // shaddowed). So either way there are shortcomings. Instead, we
     690                // decide the target as late as possible:
     691                [item setTarget:modalWindowOnScreen ? nil : getMenuLoader()];
    689692            } else {
    690693                syncNSMenuItemEnabled(item, NO);
     
    750753}
    751754
    752 void qt_mac_clear_menubar()
    753 {
    754     if (QApplication::testAttribute(Qt::AA_MacPluginApplication))
    755         return;
    756 
    757 #ifndef QT_MAC_USE_COCOA
    758     MenuRef clear_menu = 0;
    759     if (CreateNewMenu(0, 0, &clear_menu) == noErr) {
    760         SetRootMenu(clear_menu);
    761         ReleaseMenu(clear_menu);
    762     } else {
    763         qWarning("QMenu: Internal error at %s:%d", __FILE__, __LINE__);
    764     }
    765     ClearMenuBar();
    766     qt_mac_command_set_enabled(0, kHICommandPreferences, false);
    767     InvalMenuBar();
    768 #else
    769     QMacCocoaAutoReleasePool pool;
    770     QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
    771     NSMenu *menu = [loader menu];
    772     [loader ensureAppMenuInMenu:menu];
    773     [NSApp setMainMenu:menu];
    774 #endif
    775 }
    776 
    777 
    778755QMacMenuAction::~QMacMenuAction()
    779756{
     
    944921{
    945922    QString ret;
     923    extern QString qt_mac_applicationmenu_string(int type);
    946924#ifdef QT_MAC_USE_COCOA
    947925    QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
     
    951929#ifndef QT_MAC_USE_COCOA
    952930    else if (action->command == kHICommandAbout)
    953         ret = QMenuBar::tr("About %1").arg(qAppName());
     931        ret = qt_mac_applicationmenu_string(6).arg(qAppName());
    954932    else if (action->command == kHICommandAboutQt)
    955933        ret = QMenuBar::tr("About Qt");
    956934    else if (action->command == kHICommandPreferences)
    957         ret = QMenuBar::tr("Preferences");
     935        ret = qt_mac_applicationmenu_string(4);
    958936    else if (action->command == kHICommandQuit)
    959         ret = QMenuBar::tr("Quit %1").arg(qAppName());
    960 #else
    961     else if (action->menuItem == [loader aboutMenuItem])
    962         ret = QMenuBar::tr("About %1").arg(qAppName());
    963     else if (action->menuItem == [loader aboutQtMenuItem])
    964         ret = QMenuBar::tr("About Qt");
    965     else if (action->menuItem == [loader preferencesMenuItem])
    966         ret = QMenuBar::tr("Preferences");
    967     else if (action->menuItem == [loader quitMenuItem])
    968         ret = QMenuBar::tr("Quit %1").arg(qAppName());
     937        ret = qt_mac_applicationmenu_string(5).arg(qAppName());
     938#else
     939    else if (action->menuItem == [loader aboutMenuItem]) {
     940        ret = qt_mac_applicationmenu_string(6).arg(qAppName());
     941    } else if (action->menuItem == [loader aboutQtMenuItem]) {
     942        if (action->action->text() == QString("About Qt"))
     943            ret = QMenuBar::tr("About Qt");
     944        else
     945            ret = action->action->text();
     946    } else if (action->menuItem == [loader preferencesMenuItem]) {
     947        ret = qt_mac_applicationmenu_string(4);
     948    } else if (action->menuItem == [loader quitMenuItem]) {
     949        ret = qt_mac_applicationmenu_string(5).arg(qAppName());
     950    }
    969951#endif
    970952    return ret;
     
    11311113                [cmd retain];
    11321114                [cmd setAction:@selector(qtDispatcherToQAction:)];
    1133                 [cmd setTarget:getMenuLoader()];
     1115                [cmd setTarget:nil];
    11341116                [action->menuItem release];
    11351117                action->menuItem = cmd;
     
    14211403        [item setTitle: qt_mac_QStringToNSString(finalString)];
    14221404    }
    1423     [item setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(text))];
     1405
     1406    if (action->action->menuRole() == QAction::AboutRole || action->action->menuRole() == QAction::QuitRole)
     1407        [item setTitle:qt_mac_QStringToNSString(text)];
     1408    else
     1409        [item setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(text))];
    14241410
    14251411    // Cocoa Enabled
     
    18461832    mac_menubar = 0;
    18471833
    1848     if (qt_mac_current_menubar.qmenubar == q) {
     1834    if (!qt_mac_current_menubar.qmenubar || qt_mac_current_menubar.qmenubar == q) {
    18491835#ifdef QT_MAC_USE_COCOA
    18501836        QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
     
    19371923    based on the modality type of modalWidget.
    19381924*/
    1939 static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget)
    1940 {
    1941     if (modalWidget == 0 || menuBar == 0)
     1925static bool qt_mac_should_disable_menu(QMenuBar *menuBar)
     1926{
     1927    QWidget *modalWidget = qApp->activeModalWidget();
     1928    if (!modalWidget)
    19421929        return false;
    19431930
    1944     // If there is an application modal window on
    1945     // screen, the entries of the menubar should be disabled:
     1931    if (menuBar && menuBar == menubars()->value(modalWidget))
     1932        // The menu bar is owned by the modal widget.
     1933        // In that case we should enable it:
     1934        return false;
     1935
     1936    // When there is an application modal window on screen, the entries of
     1937    // the menubar should be disabled. The exception in Qt is that if the
     1938    // modal window is the only window on screen, then we enable the menu bar.
    19461939    QWidget *w = modalWidget;
     1940    QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
    19471941    while (w) {
    1948         if (w->isVisible() && w->windowModality() == Qt::ApplicationModal)
    1949             return true;
     1942        if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) {
     1943            for (int i=0; i<topLevelWidgets.size(); ++i) {
     1944                QWidget *top = topLevelWidgets.at(i);
     1945                if (w != top && top->isVisible()) {
     1946                    // INVARIANT: we found another visible window
     1947                    // on screen other than our modalWidget. We therefore
     1948                    // disable the menu bar to follow normal modality logic:
     1949                    return true;
     1950                }
     1951            }
     1952            // INVARIANT: We have only one window on screen that happends
     1953            // to be application modal. We choose to enable the menu bar
     1954            // in that case to e.g. enable the quit menu item.
     1955            return false;
     1956        }
    19501957        w = w->parentWidget();
    19511958    }
    19521959
    19531960    // INVARIANT: modalWidget is window modal. Disable menu entries
    1954     // if the menu bar belongs to an ancestor of modalWidget:
    1955     return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget);
    1956 }
    1957 
    1958 /*!
    1959   \internal
    1960 
    1961   This function will update the current menu bar and set it as the
    1962   active menu bar in the Menu Manager.
    1963 
    1964   \warning This function is not portable.
    1965 
    1966   \sa QMenu::macMenu(), QMenuBar::macMenu()
    1967 */
    1968 bool QMenuBar::macUpdateMenuBar()
    1969 {
    1970     cancelAllMenuTracking();
    1971     QMenuBar *mb = 0;
    1972     //find a menu bar
     1961    // if the menu bar belongs to an ancestor of modalWidget. If menuBar
     1962    // is nil, we understand it as the default menu bar set by the nib:
     1963    return menuBar ? qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget) : false;
     1964}
     1965
     1966static QWidget *findWindowThatShouldDisplayMenubar()
     1967{
    19731968    QWidget *w = qApp->activeWindow();
    1974 
    19751969    if (!w) {
     1970        // We have no active window on screen. Try to
     1971        // find a window from the list of top levels:
    19761972        QWidgetList tlws = QApplication::topLevelWidgets();
    19771973        for(int i = 0; i < tlws.size(); ++i) {
     
    19841980        }
    19851981    }
     1982    return w;
     1983}
     1984
     1985static QMenuBar *findMenubarForWindow(QWidget *w)
     1986{
     1987    QMenuBar *mb = 0;
    19861988    if (w) {
    19871989        mb = menubars()->value(w);
     
    19971999            mb = menubars()->value((w = w->parentWidget()));
    19982000    }
    1999     if (!mb)
     2001
     2002    if (!mb) {
     2003        // We could not find a menu bar for the window. Lets
     2004        // check if we have a global (parentless) menu bar instead:
    20002005        mb = fallback;
    2001     //now set it
     2006    }
     2007
     2008    return mb;
     2009}
     2010
     2011void qt_mac_clear_menubar()
     2012{
     2013    if (QApplication::testAttribute(Qt::AA_MacPluginApplication))
     2014        return;
     2015
     2016#ifndef QT_MAC_USE_COCOA
     2017    MenuRef clear_menu = 0;
     2018    if (CreateNewMenu(0, 0, &clear_menu) == noErr) {
     2019        SetRootMenu(clear_menu);
     2020        ReleaseMenu(clear_menu);
     2021    } else {
     2022        qWarning("QMenu: Internal error at %s:%d", __FILE__, __LINE__);
     2023    }
     2024    ClearMenuBar();
     2025    qt_mac_command_set_enabled(0, kHICommandPreferences, false);
     2026    InvalMenuBar();
     2027#else
     2028    QMacCocoaAutoReleasePool pool;
     2029    QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
     2030    NSMenu *menu = [loader menu];
     2031    [loader ensureAppMenuInMenu:menu];
     2032    [NSApp setMainMenu:menu];
     2033    const bool modal = qt_mac_should_disable_menu(0);
     2034    if (qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal)
     2035        qt_mac_set_modal_state(menu, modal);
     2036    qt_mac_current_menubar.qmenubar = 0;
     2037    qt_mac_current_menubar.modal = modal;
     2038#endif
     2039}
     2040
     2041/*!
     2042  \internal
     2043
     2044  This function will update the current menu bar and set it as the
     2045  active menu bar in the Menu Manager.
     2046
     2047  \warning This function is not portable.
     2048
     2049  \sa QMenu::macMenu(), QMenuBar::macMenu()
     2050*/
     2051bool QMenuBar::macUpdateMenuBar()
     2052{
     2053#ifdef QT_MAC_USE_COCOA
     2054    QMacCocoaAutoReleasePool pool;
     2055    if (!qt_cocoaPostMessage(getMenuLoader(), @selector(qtUpdateMenubar)))
     2056        return QMenuBarPrivate::macUpdateMenuBarImmediatly();
     2057    return true;
     2058#else
     2059    return QMenuBarPrivate::macUpdateMenuBarImmediatly();
     2060#endif
     2061}
     2062
     2063bool QMenuBarPrivate::macUpdateMenuBarImmediatly()
     2064{
    20022065    bool ret = false;
     2066    cancelAllMenuTracking();
     2067    QWidget *w = findWindowThatShouldDisplayMenubar();
     2068    QMenuBar *mb = findMenubarForWindow(w);
     2069    extern bool qt_mac_app_fullscreen; //qapplication_mac.mm
     2070
     2071    // We need to see if we are in full screen mode, if so we need to
     2072    // switch the full screen mode to be able to show or hide the menubar.
     2073    if(w && mb) {
     2074        // This case means we are creating a menubar, check if full screen
     2075        if(w->isFullScreen()) {
     2076            // Ok, switch to showing the menubar when hovering over it.
     2077            SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
     2078            qt_mac_app_fullscreen = true;
     2079        }
     2080    } else if(w) {
     2081        // Removing a menubar
     2082        if(w->isFullScreen()) {
     2083            // Ok, switch to not showing the menubar when hovering on it
     2084            SetSystemUIMode(kUIModeAllHidden, 0);
     2085            qt_mac_app_fullscreen = true;
     2086        }
     2087    }
     2088
    20032089    if (mb && mb->isNativeMenuBar()) {
     2090        bool modal = QApplicationPrivate::modalState();
    20042091#ifdef QT_MAC_USE_COCOA
    20052092        QMacCocoaAutoReleasePool pool;
     
    20312118            }
    20322119#endif
    2033             QWidget *modalWidget = qApp->activeModalWidget();
    2034             if (mb != menubars()->value(modalWidget)) {
    2035                 qt_mac_set_modal_state(menu, qt_mac_should_disable_menu(mb, modalWidget));
    2036             }
     2120            // Check if menu is modally shaddowed and should  be disabled:
     2121            modal = qt_mac_should_disable_menu(mb);
     2122            if (mb != qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal)
     2123                qt_mac_set_modal_state(menu, modal);
    20372124        }
    20382125        qt_mac_current_menubar.qmenubar = mb;
    2039         qt_mac_current_menubar.modal = QApplicationPrivate::modalState();
     2126        qt_mac_current_menubar.modal = modal;
    20402127        ret = true;
    20412128    } else if (qt_mac_current_menubar.qmenubar && qt_mac_current_menubar.qmenubar->isNativeMenuBar()) {
    2042         const bool modal = QApplicationPrivate::modalState();
     2129        // INVARIANT: The currently active menu bar (if any) is not native. But we do have a
     2130        // native menu bar from before. So we need to decide whether or not is should be enabled:
     2131        const bool modal = qt_mac_should_disable_menu(qt_mac_current_menubar.qmenubar);
    20432132        if (modal != qt_mac_current_menubar.modal) {
    20442133            ret = true;
     
    20522141                syncMenuBarItemsVisiblity(qt_mac_current_menubar.qmenubar->d_func()->mac_menubar);
    20532142#endif
    2054                 QWidget *modalWidget = qApp->activeModalWidget();
    2055                 if (qt_mac_current_menubar.qmenubar != menubars()->value(modalWidget)) {
    2056                     qt_mac_set_modal_state(menu, qt_mac_should_disable_menu(mb, modalWidget));
    2057                 }
     2143                qt_mac_set_modal_state(menu, modal);
    20582144            }
    20592145            qt_mac_current_menubar.modal = modal;
    20602146        }
    20612147    }
    2062     if(!ret)
     2148
     2149    if (!ret) {
    20632150        qt_mac_clear_menubar();
     2151    }
    20642152    return ret;
    20652153}
     
    21322220
    21332221QT_END_NAMESPACE
     2222
  • trunk/src/gui/widgets/qmenu_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    203203
    204204    //selection
    205     static QPointer<QMenu> mouseDown;
     205    static QMenu *mouseDown;
    206206    QPoint mousePopupPos;
    207207    uint hasHadMouse : 1;
     
    213213    QAction *cancelAction;
    214214#endif
    215     static QBasicTimer menuDelayTimer;
     215    QBasicTimer menuDelayTimer;
    216216    enum SelectionReason {
    217217        SelectedFromKeyboard,
     
    273273
    274274    //sloppy selection
    275     static QBasicTimer sloppyDelayTimer;
     275    static int sloppyDelayTimer;
    276276    mutable QAction *sloppyAction;
    277277    QRegion sloppyRegion;
  • trunk/src/gui/widgets/qmenu_symbian.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4949#include <private/qmenu_p.h>
    5050#include <private/qmenubar_p.h>
    51 #include <qt_s60_p.h>
     51#include <private/qt_s60_p.h>
    5252#include <QtCore/qlibrary.h>
    5353
     
    169169            if (action->action->menu()->actions().size() > 0) {
    170170                for (int c2= 0; c2 < action->action->menu()->actions().size(); ++c2) {
    171                     QSymbianMenuAction *symbianAction2 = new QSymbianMenuAction;
     171                    QScopedPointer<QSymbianMenuAction> symbianAction2(new QSymbianMenuAction);
    172172                    symbianAction2->action = action->action->menu()->actions().at(c2);
    173173                    QMenu * menu = symbianAction2->action->menu();
    174174                    symbianAction2->command = qt_symbian_menu_static_cmd_id++;
    175                     qt_symbian_insert_action(symbianAction2, &(menuItem->children));
     175                    qt_symbian_insert_action(symbianAction2.data(), &(menuItem->children));
    176176                }
    177177            }
     
    433433{
    434434    for (int i = 0; i <actions.size(); ++i) {
    435         QSymbianMenuAction *symbianActionTopLevel = new QSymbianMenuAction;
     435        QScopedPointer<QSymbianMenuAction> symbianActionTopLevel(new QSymbianMenuAction);
    436436        symbianActionTopLevel->action = actions.at(i);
    437437        symbianActionTopLevel->parent = 0;
    438438        symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++;
    439         qt_symbian_insert_action(symbianActionTopLevel, &symbianMenus);
     439        qt_symbian_insert_action(symbianActionTopLevel.data(), &symbianMenus);
    440440    }
    441441}
  • trunk/src/gui/widgets/qmenu_wince.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmenu_wince_resource_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmenubar.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    103103    QStyleOptionToolButton opt;
    104104    initStyleOption(&opt);
    105     // We do not need to draw both extention arrows
     105    // We do not need to draw both extension arrows
    106106    opt.features &= ~QStyleOptionToolButton::HasMenu;
    107107    p.drawComplexControl(QStyle::CC_ToolButton, opt);
     
    269269QRect QMenuBarPrivate::actionRect(QAction *act) const
    270270{
    271     Q_Q(const QMenuBar);
    272271    const int index = actions.indexOf(act);
    273     if (index == -1)
    274         return QRect();
    275272
    276273    //makes sure the geometries are up-to-date
    277274    const_cast<QMenuBarPrivate*>(this)->updateGeometries();
    278275
    279     if (index >= actionRects.count())
     276    if (index < 0 || index >= actionRects.count())
    280277        return QRect(); // that can happen in case of native menubar
    281278
    282     QRect ret = actionRects.at(index);
    283     return QStyle::visualRect(q->layoutDirection(), q->rect(), ret);
     279    return actionRects.at(index);
    284280}
    285281
     
    506502        //keep moving along..
    507503        x += rect.width() + itemSpacing;
     504
     505        //make sure we follow the layout direction
     506        rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect);
    508507    }
    509508}
     
    770769    const int end =  increment == -1 ? 0 : actions.count() - 1;
    771770
    772     for (int i = start; start != end;) {
     771    for (int i = start; i != end;) {
    773772        i += increment;
    774773        QAction *current = actions.at(i);
     
    16301629
    16311630/*!
    1632   \internal
    1633 
    1634   Return the item at \a pt, or 0 if there is no item there or if it is
    1635   a separator item.
     1631  Returns the QAction at \a pt. Returns 0 if there is no action at \a pt or if
     1632the location has a separator.
     1633
     1634    \sa addAction(), addSeparator()
    16361635*/
    16371636QAction *QMenuBar::actionAt(const QPoint &pt) const
     
    16421641
    16431642/*!
    1644   \internal
    1645 
    1646   Returns the geometry of action \a act.
     1643  Returns the geometry of action \a act as a QRect.
     1644
     1645    \sa actionAt()
    16471646*/
    16481647QRect QMenuBar::actionGeometry(QAction *act) const
     
    18381837
    18391838/*!
    1840   \internal
    1841 
    1842   This sets widget \a w to be shown directly on the left of the first or
    1843   the right of the last menu item, depending on \a corner.
     1839    \fn void QMenuBar::setCornerWidget(QWidget *widget, Qt::Corner corner)
     1840
     1841    This sets the given \a widget to be shown directly on the left of the first
     1842    menu item, or on the right of the last menu item, depending on \a corner.
     1843
     1844    The menu bar takes ownership of \a widget, reparenting it into the menu bar.
     1845    However, if the \a corner already contains a widget, this previous widget
     1846    will no longer be managed and will still be a visible child of the menu bar.
     1847
     1848   \note Using a corner other than Qt::TopRightCorner or Qt::TopLeftCorner
     1849    will result in a warning.
    18441850*/
    18451851void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner)
     
    18711877
    18721878/*!
    1873   \internal
    1874 
    1875   Returns the widget in the left of the first or the right of the last menu
    1876   item, depending on \a corner.
     1879    Returns the widget on the left of the first or on the right of the last menu
     1880    item, depending on \a corner.
     1881
     1882   \note Using a corner other than Qt::TopRightCorner or Qt::TopLeftCorner
     1883    will result in a warning.
    18771884*/
    18781885QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const
     
    19331940        }
    19341941        macUpdateMenuBar();
    1935         updateGeometry();
    1936         setVisible(false);
    1937         setVisible(true);
     1942        updateGeometry();
     1943        if (!d->nativeMenuBar && parentWidget())
     1944            setVisible(true);
    19381945#endif
    19391946    }
  • trunk/src/gui/widgets/qmenubar.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmenubar_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    197197        }
    198198    } *mac_menubar;
     199    static bool macUpdateMenuBarImmediatly();
    199200    bool macWidgetHasNativeMenubar(QWidget *widget);
    200201    void macCreateMenuBar(QWidget *);
     
    269270    } *symbian_menubar;
    270271    static int symbianCommands(int command);
     272#endif
    271273#ifdef QT_SOFTKEYS_ENABLED
    272274    QAction *menuBarAction;
    273275#endif
    274 #endif
    275276};
    276277#endif
  • trunk/src/gui/widgets/qmenudata.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qmenudata.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qplaintextedit.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    912912
    913913        if (moveCursor) {
     914            cursor.setVisualNavigation(true);
    914915            // move using movePosition to keep the cursor's x
    915916            lastY += verticalOffset();
     
    944945    if (!centerOnScroll && q->isVisible()) {
    945946        QTextBlock block = doc->lastBlock();
    946         const int visible = static_cast<int>(viewport->rect().height() - margin - 1);
    947         int y = 0;
     947        const qreal visible = viewport->rect().height() - margin - 1;
     948        qreal y = 0;
    948949        int visibleFromBottom = 0;
    949950
     
    953954                continue;
    954955            }
    955             y += int(documentLayout->blockBoundingRect(block).height());
     956            y += documentLayout->blockBoundingRect(block).height();
    956957
    957958            QTextLayout *layout = block.layout();
     
    962963                    QTextLine line = layout->lineAt(lineNumber);
    963964                    const QRectF lr = line.naturalTextRect();
    964                     if (int(lr.top()) >= y - visible)
     965                    if (lr.top() >= y - visible)
    965966                        break;
    966967                    ++lineNumber;
     
    13201321}
    13211322
     1323/*!
     1324    Returns the reference of the anchor at position \a pos, or an
     1325    empty string if no anchor exists at that point.
     1326
     1327    \since 4.7
     1328 */
     1329QString QPlainTextEdit::anchorAt(const QPoint &pos) const
     1330{
     1331    Q_D(const QPlainTextEdit);
     1332    int cursorPos = d->control->hitTest(pos + QPoint(d->horizontalOffset(),
     1333                                                     d->verticalOffset()),
     1334                                        Qt::ExactHit);
     1335    if (cursorPos < 0)
     1336        return QString();
     1337
     1338    QTextDocumentPrivate *pieceTable = document()->docHandle();
     1339    QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos);
     1340    QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format);
     1341    return fmt.anchorHref();
     1342}
    13221343
    13231344/*!
     
    14561477    }
    14571478#endif
     1479#ifndef QT_NO_GESTURES
    14581480    else if (e->type() == QEvent::Gesture) {
    14591481        QGestureEvent *ge = static_cast<QGestureEvent *>(e);
     
    14791501        return true;
    14801502    }
     1503#endif // QT_NO_GESTURES
    14811504    return QAbstractScrollArea::event(e);
    14821505}
     
    23942417
    23952418    The default value depends on whether the QPlainTextEdit is read-only
    2396     or editable, and whether it is a QTextBrowser or not.
     2419    or editable.
    23972420*/
    23982421
  • trunk/src/gui/widgets/qplaintextedit.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    160160    QRect cursorRect() const;
    161161
     162    QString anchorAt(const QPoint &pos) const;
     163
    162164    bool overwriteMode() const;
    163165    void setOverwriteMode(bool overwrite);
  • trunk/src/gui/widgets/qplaintextedit_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qprintpreviewwidget.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    470470
    471471    Construct the QPrintPreviewWidget either by passing in an
    472     exisiting QPrinter object, or have QPrintPreviewWidget create a
     472    existing QPrinter object, or have QPrintPreviewWidget create a
    473473    default constructed QPrinter object for you.
    474474
  • trunk/src/gui/widgets/qprintpreviewwidget.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qprogressbar.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qprogressbar.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    9494
    9595    void setInvertedAppearance(bool invert);
    96     bool invertedAppearance();
     96    bool invertedAppearance(); //### Qt5 make const
     97    bool invertedAppearance() const { return const_cast<QProgressBar *>(this)->invertedAppearance(); }
    9798    void setTextDirection(QProgressBar::Direction textDirection);
    98     QProgressBar::Direction textDirection();
     99    QProgressBar::Direction textDirection(); //### Qt5 make const
     100    QProgressBar::Direction textDirection() const { return const_cast<QProgressBar *>(this)->textDirection(); }
    99101
    100102    void setFormat(const QString &format);
  • trunk/src/gui/widgets/qpushbutton.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5959#include "qlayoutitem.h"
    6060#include "qdialogbuttonbox.h"
     61#ifdef Q_WS_MAC
     62#include "qmacstyle_mac.h"
     63#include "private/qmacstyle_mac_p.h"
     64#endif // Q_WS_MAC
    6165
    6266#ifndef QT_NO_ACCESSIBILITY
     
    680684}
    681685
     686#ifdef Q_WS_MAC
     687/*! \reimp */
     688bool QPushButton::hitButton(const QPoint &pos) const
     689{
     690    QStyleOptionButton opt;
     691    initStyleOption(&opt);
     692    if (qt_mac_buttonIsRenderedFlat(this, &opt))
     693        return QAbstractButton::hitButton(pos);
     694
     695    // Now that we know we are using the native style, let's proceed.
     696    Q_D(const QPushButton);
     697    QPushButtonPrivate *nonConst = const_cast<QPushButtonPrivate *>(d);
     698    // In OSX buttons are round, which causes the hit method to be special.
     699    // We cannot simply relay on detecting if something is inside the rect or not,
     700    // we need to check if it is inside the "rounded area" or not. A point might
     701    // be inside the rect but not inside the rounded area.
     702    // Notice this method is only reimplemented for OSX.
     703    return nonConst->hitButton(pos);
     704}
     705
     706bool QPushButtonPrivate::hitButton(const QPoint &pos)
     707{
     708    Q_Q(QPushButton);
     709    QRect roundedRect(q->rect().left() + QMacStylePrivate::PushButtonLeftOffset,
     710                      q->rect().top() + QMacStylePrivate::PushButtonContentPadding,
     711                      q->rect().width() - QMacStylePrivate::PushButtonRightOffset,
     712                      q->rect().height() - QMacStylePrivate::PushButtonBottomOffset);
     713    return roundedRect.contains(pos);
     714}
     715#endif // Q_WS_MAC
     716
    682717#ifdef QT3_SUPPORT
    683718/*!
  • trunk/src/gui/widgets/qpushbutton.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    9292protected:
    9393    bool event(QEvent *e);
     94#ifdef Q_WS_MAC
     95    bool hitButton(const QPoint &pos) const;
     96#endif // Q_WS_MAC
    9497    void paintEvent(QPaintEvent *);
    9598    void keyPressEvent(QKeyEvent *);
  • trunk/src/gui/widgets/qpushbutton_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7070    inline void init() { resetLayoutItemMargins(); }
    7171    static QPushButtonPrivate* get(QPushButton *b) { return b->d_func(); }
     72#ifdef Q_WS_MAC
     73    bool hitButton(const QPoint &pos);
     74#endif
    7275#ifndef QT_NO_MENU
    7376    QPoint adjustedMenuPosition();
  • trunk/src/gui/widgets/qradiobutton.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    196196    QStyleOptionButton opt;
    197197    initStyleOption(&opt);
    198     QSize sz = style()->itemTextRect(fontMetrics(), QRect(0, 0, 1, 1), Qt::TextShowMnemonic,
     198    QSize sz = style()->itemTextRect(fontMetrics(), QRect(), Qt::TextShowMnemonic,
    199199                                     false, text()).size();
    200200    if (!opt.icon.isNull())
  • trunk/src/gui/widgets/qradiobutton.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qrubberband.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qrubberband.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qscrollarea.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    122122    If a scroll area is used to display the contents of a widget that
    123123    contains child widgets arranged in a layout, it is important to
    124     realise that the size policy of the layout will also determine the
     124    realize that the size policy of the layout will also determine the
    125125    size of the widget. This is especially useful to know if you intend
    126126    to dynamically change the contents of the layout. In such cases,
     
    483483    else if (focusRect.right() > visibleRect.right())
    484484        d->hbar->setValue(focusRect.right() - d->viewport->width());
    485     else
     485    else if (focusRect.left() < visibleRect.left())
    486486        d->hbar->setValue(focusRect.left());
    487487
     
    490490    else if (focusRect.bottom() > visibleRect.bottom())
    491491        d->vbar->setValue(focusRect.bottom() - d->viewport->height());
    492     else
     492    else if (focusRect.top() < visibleRect.top())
    493493        d->vbar->setValue(focusRect.top());
    494494}
  • trunk/src/gui/widgets/qscrollarea.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qscrollarea_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qscrollbar.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4848#include "qstyleoption.h"
    4949#include "qmenu.h"
    50 #include <QtCore/qdatetime.h>
     50#include <QtCore/qelapsedtimer.h>
    5151
    5252#ifndef QT_NO_SCROLLBAR
     
    524524#ifndef QT_NO_WHEELEVENT
    525525    case QEvent::Wheel: {
     526        event->ignore();
    526527        // override wheel event without adding virtual function override
    527528        QWheelEvent *ev = static_cast<QWheelEvent *>(event);
     
    613614    const int initialDelay = 500; // default threshold
    614615    d->activateControl(d->pressedControl, initialDelay);
    615     QTime time;
     616    QElapsedTimer time;
    616617    time.start();
    617618    repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this));
  • trunk/src/gui/widgets/qscrollbar.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qsizegrip.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qsizegrip.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qslider.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    622622
    623623    This is a value interval, not a pixel interval. If it is 0, the
    624     slider will choose between lineStep() and pageStep().
     624    slider will choose between singleStep() and pageStep().
    625625
    626626    The default value is 0.
  • trunk/src/gui/widgets/qslider.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qspinbox.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qspinbox.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qsplashscreen.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    186186    Draws the \a message text onto the splash screen with color \a
    187187    color and aligns the text according to the flags in \a alignment.
     188
     189    To make sure the splash screen is repainted immediately, you can
     190    call \l{QCoreApplication}'s
     191    \l{QCoreApplication::}{processEvents()} after the call to
     192    showMessage(). You usually want this to make sure that the message
     193    is kept up to date with what your application is doing (e.g.,
     194    loading files).
    188195
    189196    \sa Qt::Alignment, clearMessage()
  • trunk/src/gui/widgets/qsplashscreen.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qsplitter.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    125125/*!
    126126    Sets the orientation of the splitter handle to \a orientation.
    127     This is usually propogated from the QSplitter.
     127    This is usually propagated from the QSplitter.
    128128
    129129    \sa QSplitter::setOrientation()
     
    223223    return parentWidget()->style()->sizeFromContents(QStyle::CT_Splitter, &opt, QSize(hw, hw), d->s)
    224224        .expandedTo(QApplication::globalStrut());
     225}
     226
     227/*!
     228    \reimp
     229*/
     230void QSplitterHandle::resizeEvent(QResizeEvent *event)
     231{
     232    Q_D(const QSplitterHandle);
     233
     234    // When splitters are only 1 pixel large we increase the
     235    // actual grab area to five pixels
     236
     237    // Note that QSplitter uses contentsRect for layouting
     238    // and ensures that handles are drawn on top of widgets
     239    // We simply use the contents margins for draggin and only
     240    // paint the mask area
     241    bool useTinyMode = (d->s->handleWidth() == 1);
     242    setAttribute(Qt::WA_MouseNoMask, useTinyMode);
     243    if (useTinyMode) {
     244        if (orientation() == Qt::Horizontal)
     245            setContentsMargins(2, 0, 2, 0);
     246        else
     247            setContentsMargins(0, 2, 0, 2);
     248        setMask(QRegion(contentsRect()));
     249    }
     250
     251    QWidget::resizeEvent(event);
    225252}
    226253
     
    302329    QPainter p(this);
    303330    QStyleOption opt(0);
    304     opt.rect = rect();
     331    opt.rect = contentsRect();
    305332    opt.palette = palette();
    306333    if (orientation() == Qt::Horizontal)
     
    12771304        return;
    12781305    QWidget *w = static_cast<QWidget*>(c->child());
    1279 
    12801306    if (c->added() && !d->blockChildAdd && !w->isWindow() && !d->findWidget(w)) {
    12811307        d->insertWidget_helper(d->list.count(), w, false);
     
    13071333    if (pos < 0) {
    13081334        if (d->rubberBand)
    1309             QTimer::singleShot(0, d->rubberBand, SLOT(deleteLater()));
     1335            d->rubberBand->deleteLater();
    13101336        return;
    13111337    }
     
    13141340    int hw = handleWidth();
    13151341    if (!d->rubberBand) {
    1316         d->rubberBand = new QRubberBand(QRubberBand::Line);
     1342        QBoolBlocker b(d->blockChildAdd);
     1343        d->rubberBand = new QRubberBand(QRubberBand::Line, this);
    13171344        // For accessibility to identify this special widget.
    13181345        d->rubberBand->setObjectName(QLatin1String("qt_rubberband"));
    13191346    }
    1320     if (d->orient == Qt::Horizontal)
    1321         d->rubberBand->setGeometry(QRect(QPoint(pos + hw / 2 - rBord, r.y()),
    1322                                          QSize(2 * rBord, r.height())).translated(mapToGlobal(QPoint())));
    1323     else
    1324         d->rubberBand->setGeometry(QRect(QPoint(r.x(), pos + hw / 2 - rBord),
    1325                                    QSize(r.width(), 2 * rBord)).translated(mapToGlobal(QPoint())));
    1326     if (!d->rubberBand->isVisible())
    1327         d->rubberBand->show();
     1347
     1348    const QRect newGeom = d->orient == Qt::Horizontal ? QRect(QPoint(pos + hw / 2 - rBord, r.y()), QSize(2 * rBord, r.height()))
     1349                                                      : QRect(QPoint(r.x(), pos + hw / 2 - rBord), QSize(r.width(), 2 * rBord));
     1350    d->rubberBand->setGeometry(newGeom);
     1351    d->rubberBand->show();
    13281352}
    13291353
     
    15561580    int l = 0;
    15571581    int t = 0;
    1558     QObjectList childList = children();
    1559     for (int i = 0; i < childList.size(); ++i) {
    1560         if (QWidget *w = qobject_cast<QWidget *>(childList.at(i))) {
    1561             if (w->isHidden())
    1562                 continue;
    1563             QSize s = w->sizeHint();
    1564             if (s.isValid()) {
    1565                 l += d->pick(s);
    1566                 t = qMax(t, d->trans(s));
    1567             }
     1582    for (int i = 0; i < d->list.size(); ++i) {
     1583        QWidget *w = d->list.at(i)->widget;
     1584        if (w->isHidden())
     1585            continue;
     1586        QSize s = w->sizeHint();
     1587        if (s.isValid()) {
     1588            l += d->pick(s);
     1589            t = qMax(t, d->trans(s));
    15681590        }
    15691591    }
     
    16681690    By default, this property contains a value that depends on the user's platform
    16691691    and style preferences.
     1692
     1693    If you set handleWidth to 1, the actual grab area will grow to overlap a
     1694    few pixels of it's respective widgets.
    16701695*/
    16711696
  • trunk/src/gui/widgets/qsplitter.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    173173    void mousePressEvent(QMouseEvent *);
    174174    void mouseReleaseEvent(QMouseEvent *);
     175    void resizeEvent(QResizeEvent *);
    175176    bool event(QEvent *);
    176177
  • trunk/src/gui/widgets/qsplitter_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qstackedwidget.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    187187
    188188/*!
    189     Removes the given \a widget from the QStackedWidget.
    190 
    191     \bold{Note:} The ownership of \a widget remains the same.
    192     The widget is \e not deleted, but simply removed from the widget's
    193     stacked layout, causing it to be hidden.
     189    Removes \a widget from the QStackedWidget. i.e., \a widget is \e
     190    not deleted but simply removed from the stacked layout, causing it
     191    to be hidden.
     192
     193    \bold{Note:} Ownership of \a widget reverts to the application.
    194194
    195195    \sa addWidget(), insertWidget(), currentWidget()
  • trunk/src/gui/widgets/qstackedwidget.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qstatusbar.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    576576    vbox->addSpacing(2);
    577577    d->box->activate();
    578     repaint();
     578    update();
    579579}
    580580
  • trunk/src/gui/widgets/qstatusbar.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtabbar.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7474QT_BEGIN_NAMESPACE
    7575
     76
    7677inline static bool verticalTabs(QTabBar::Shape shape)
    7778{
     
    100101        metrics.right = 0;
    101102        qt_mac_updateContentBorderMetricts(window, metrics);
    102        
    103         // hide the base line separator if the tabs have docuemnt mode enabled (Cocoa)
    104         qt_mac_showBaseLineSeparator(window, !documentMode);
     103#if QT_MAC_USE_COCOA
     104        // In Cocoa we need to keep track of the drawRect method.
     105        // If documentMode is enabled we need to change it, unless
     106        // a toolbar is present.
     107        // Notice that all the information is kept in the window,
     108        // that's why we get the private widget for it instead of
     109        // the private widget for this widget.
     110        QWidgetPrivate *privateWidget = qt_widget_private(q->window());
     111        if(privateWidget)
     112            privateWidget->changeMethods = documentMode;
     113        // Since in Cocoa there is no simple way to remove the baseline, so we just ask the
     114        // top level to do the magic for us.
     115        privateWidget->syncUnifiedMode();
     116#endif // QT_MAC_USE_COCOA
    105117    }
    106118#endif
     
    620632}
    621633
    622 void QTabBarPrivate::layoutWidgets(int index)
     634void QTabBarPrivate::layoutWidgets(int start)
    623635{
    624636    Q_Q(QTabBar);
    625     int start = 0;
    626     int end = q->count();
    627     if (index != -1) {
    628         start = qMax(index, 0);
    629         end = qMin(end, start + 1);
    630     }
    631     for (int i = start; i < end; ++i) {
     637    for (int i = start; i < q->count(); ++i) {
    632638        layoutTab(i);
    633639    }
     
    12111217        d->makeVisible(index);
    12121218        d->tabList[index].lastTab = oldIndex;
    1213         d->layoutWidgets(oldIndex);
    1214         d->layoutWidgets(index);
     1219        if (oldIndex >= 0 && oldIndex < count())
     1220            d->layoutTab(oldIndex);
     1221        d->layoutTab(index);
     1222#ifndef QT_NO_ACCESSIBILITY
     1223        if (QAccessible::isActive()) {
     1224            QAccessible::updateAccessibility(this, index + 1, QAccessible::Focus);
     1225            QAccessible::updateAccessibility(this, index + 1, QAccessible::Selection);
     1226        }
     1227#endif
    12151228#ifdef QT3_SUPPORT
    12161229        emit selected(index);
     
    19872000    Q_D(QTabBar);
    19882001    if (event->type() == QEvent::StyleChange) {
    1989         d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this));
     2002        if (!d->elideModeSetByUser)
     2003            d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this));
    19902004        if (!d->useScrollButtonsSetByUser)
    19912005            d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this);
     
    20202034    Q_D(QTabBar);
    20212035    d->elideMode = mode;
     2036    d->elideModeSetByUser = true;
    20222037    d->refresh();
    20232038}
     
    22362251{
    22372252    Q_D(QTabBar);
     2253
    22382254    d->documentMode = enabled;
    22392255    d->updateMacBorderMetrics();
  • trunk/src/gui/widgets/qtabbar.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtabbar_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7676    QTabBarPrivate()
    7777        :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false),
    78         drawBase(true), scrollOffset(0), useScrollButtonsSetByUser(false) , expanding(true), closeButtonOnTabs(false),
     78        drawBase(true), scrollOffset(0), elideModeSetByUser(false), useScrollButtonsSetByUser(false), expanding(true), closeButtonOnTabs(false),
    7979        selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false),
    8080        dragInProgress(false), documentMode(false), movingTab(0)
     
    179179    void refresh();
    180180    void layoutTabs();
    181     void layoutWidgets(int index = -1);
     181    void layoutWidgets(int start = 0);
    182182    void layoutTab(int index);
    183183    void updateMacBorderMetrics();
     
    187187    QSize iconSize;
    188188    Qt::TextElideMode elideMode;
     189    bool elideModeSetByUser;
    189190    bool useScrollButtons;
    190191    bool useScrollButtonsSetByUser;
  • trunk/src/gui/widgets/qtabwidget.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    543543    Q_D(QTabWidget);
    544544    d->tabs->setTabEnabled(index, enable);
     545    if (QWidget *widget = d->stack->widget(index))
     546        widget->setEnabled(enable);
    545547}
    546548
  • trunk/src/gui/widgets/qtabwidget.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtextbrowser.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtextbrowser.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtextedit.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    774774    remains the owner of the object.
    775775
    776     If the current document is a child of the text editor, then it is deleted.
     776    The editor does not delete the current document, even if it is a child of the editor.
    777777
    778778    \sa document()
     
    12131213            if (QApplication::keypadNavigationEnabled()) {
    12141214                if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) {
    1215                     if (e->text()[0].isPrint()) {
     1215                    if (e->text()[0].isPrint())
    12161216                        setEditFocus(true);
    1217 #ifndef Q_OS_SYMBIAN
    1218                         clear();
    1219 #endif
    1220                     } else {
     1217                    else {
    12211218                        e->ignore();
    12221219                        return;
     
    16781675    if (d->control->textInteractionFlags() & Qt::TextEditable
    16791676        && QApplication::keypadNavigationEnabled()
    1680         && !hasEditFocus()) {
     1677        && !hasEditFocus())
    16811678        setEditFocus(true);
    1682 #ifndef Q_OS_SYMBIAN
    1683         selectAll();    // so text is replaced rather than appended to
    1684 #endif
    1685     }
    16861679#endif
    16871680    d->sendControlEvent(e);
  • trunk/src/gui/widgets/qtextedit.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtextedit_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbar.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8383#endif
    8484
     85// qmainwindow.cpp
     86extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
     87
    8588/******************************************************************************
    8689** QToolBarPrivate
     
    198201    QMainWindow *win = qobject_cast<QMainWindow*>(parent);
    199202    Q_ASSERT(win != 0);
    200     QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
     203    QMainWindowLayout *layout = qt_mainwindow_layout(win);
    201204    Q_ASSERT(layout != 0);
    202205    if (layout->pluggingWidget != 0) // the main window is animating a docking operation
     
    224227    QMainWindow *win = qobject_cast<QMainWindow*>(parent);
    225228    Q_ASSERT(win != 0);
    226     QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
     229    QMainWindowLayout *layout = qt_mainwindow_layout(win);
    227230    Q_ASSERT(layout != 0);
    228231
     
    248251
    249252    if (state->dragging) {
    250         QMainWindowLayout *layout =
    251             qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     253        QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    252254        Q_ASSERT(layout != 0);
    253255
     
    341343        return true;
    342344
    343     QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
     345    QMainWindowLayout *layout = qt_mainwindow_layout(win);
    344346    Q_ASSERT(layout != 0);
    345347
     
    534536
    535537/*!
     538    \fn void QToolBar::visibilityChanged(bool visible)
     539    \since 4.7
     540
     541    This signal is emitted when the toolbar becomes \a visible (or
     542    invisible). This happens when the widget is hidden or shown.
     543*/
     544
     545/*!
    536546    Constructs a QToolBar with the given \a parent.
    537547*/
     
    581591    if (mainwindow) {
    582592#ifdef Q_WS_MAC
    583         QMainWindowLayout *mainwin_layout = qobject_cast<QMainWindowLayout *>(mainwindow->layout());
     593        QMainWindowLayout *mainwin_layout = qt_mainwindow_layout(mainwindow);
    584594        if (mainwin_layout && mainwin_layout->layoutState.toolBarAreaLayout.isEmpty()
    585595                && mainwindow->testAttribute(Qt::WA_WState_Created))
     
    11231133    case QEvent::Show:
    11241134        d->toggleViewAction->setChecked(event->type() == QEvent::Show);
     1135        emit visibilityChanged(event->type() == QEvent::Show);
    11251136#if defined(Q_WS_MAC)
    11261137        if (toolbarInUnifiedToolBar(this)) {
    11271138             // I can static_cast because I did the qobject_cast in the if above, therefore
    11281139            // we must have a QMainWindowLayout here.
    1129             QMainWindowLayout *mwLayout = static_cast<QMainWindowLayout *>(parentWidget()->layout());
     1140            QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(parentWidget()));
    11301141            mwLayout->fixSizeInUnifiedToolbar(this);
    11311142            mwLayout->syncUnifiedToolbarVisibility();
     
    12811292}
    12821293
     1294extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
     1295
    12831296/*!
    12841297    \internal
     
    13071320        return;
    13081321
    1309     QMainWindowLayout *layout = qobject_cast<QMainWindowLayout *>(mainWindow->layout());
     1322    QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);
    13101323    Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()",
    13111324               "QMainWindow->layout() != QMainWindowLayout");
  • trunk/src/gui/widgets/qtoolbar.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    144144    void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
    145145    void topLevelChanged(bool topLevel);
     146    void visibilityChanged(bool visible);
    146147
    147148protected:
  • trunk/src/gui/widgets/qtoolbar_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbararealayout.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6060QT_BEGIN_NAMESPACE
    6161
     62// qmainwindow.cpp
     63extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow);
     64
    6265QSize QToolBarAreaLayoutItem::minimumSize() const
    6366{
     
    873876void QToolBarAreaLayout::apply(bool animate)
    874877{
    875     QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
     878    QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);
    876879    Q_ASSERT(layout != 0);
    877880
  • trunk/src/gui/widgets/qtoolbararealayout_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbarextension.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7676    QStyleOptionToolButton opt;
    7777    initStyleOption(&opt);
    78     // We do not need to draw both extention arrows
     78    // We do not need to draw both extension arrows
    7979    opt.features &= ~QStyleOptionToolButton::HasMenu;
    8080    p.drawComplexControl(QStyle::CC_ToolButton, opt);
  • trunk/src/gui/widgets/qtoolbarextension_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbarlayout.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5858QT_BEGIN_NAMESPACE
    5959
     60// qmainwindow.cpp
     61extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
     62
    6063/******************************************************************************
    6164** QToolBarItem
     
    405408        Qt::ToolBarArea area = win->toolBarArea(tb);
    406409        if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) {
    407             static_cast<QMainWindowLayout *>(win->layout())->fixSizeInUnifiedToolbar(tb);
     410            qt_mainwindow_layout(win)->fixSizeInUnifiedToolbar(tb);
    408411        }
    409412    }
     
    655658        return;
    656659    if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) {
     660#ifdef QT_NO_DOCKWIDGET
     661        animating = false;
     662#else
    657663        animating = !tb->isWindow() && win->isAnimated();
    658         QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
     664#endif
     665        QMainWindowLayout *layout = qt_mainwindow_layout(win);
    659666        if (expanded) {
    660667            tb->raise();
  • trunk/src/gui/widgets/qtoolbarlayout_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbarseparator.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbarseparator_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbox.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbox.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbutton.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qtoolbutton.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qvalidator.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    401401    if (overflow || !ok)
    402402        return Invalid;
    403     if (entered >= b && entered <= t)
    404         return Acceptable;
     403    if (entered >= b && entered <= t) {
     404        locale().toInt(input, &ok);
     405        return ok ? Acceptable : Intermediate;
     406    }
    405407
    406408    if (entered >= 0) {
     
    413415}
    414416
     417/*! \reimp */
     418void QIntValidator::fixup(QString &input) const
     419{
     420    QByteArray buff;
     421    if (!locale().d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) {
     422        QLocale cl(QLocale::C);
     423        if (!cl.d()->validateChars(input, QLocalePrivate::IntegerMode, &buff))
     424            return;
     425    }
     426    bool ok, overflow;
     427    qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
     428    if (ok && !overflow)
     429        input = locale().toString(entered);
     430}
    415431
    416432/*!
     
    484500
    485501    QDoubleValidator::Notation notation;
     502
     503    QValidator::State validateWithLocale(QString & input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const;
    486504};
    487505
     
    508526    In addition, QDoubleValidator is always guaranteed to accept a number
    509527    formatted according to the "C" locale. QDoubleValidator will not accept
    510     numbers with thousand-seperators.
     528    numbers with thousand-separators.
    511529
    512530    \sa QIntValidator, QRegExpValidator, {Line Edits Example}
     
    639657    }
    640658
     659    State currentLocaleValidation = d->validateWithLocale(input, numMode, locale());
     660    if (currentLocaleValidation == Acceptable || locale().language() == QLocale::C)
     661        return currentLocaleValidation;
     662    State cLocaleValidation = d->validateWithLocale(input, numMode, QLocale(QLocale::C));
     663    return qMax(currentLocaleValidation, cLocaleValidation);
     664}
     665
     666QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const
     667{
     668    Q_Q(const QDoubleValidator);
    641669    QByteArray buff;
    642     if (!locale().d()->validateChars(input, numMode, &buff, dec)) {
    643         QLocale cl(QLocale::C);
    644         if (!cl.d()->validateChars(input, numMode, &buff, dec))
    645             return Invalid;
    646     }
     670    if (!locale.d()->validateChars(input, numMode, &buff, q->dec))
     671        return QValidator::Invalid;
    647672
    648673    if (buff.isEmpty())
    649         return Intermediate;
    650 
    651     if (b >= 0 && buff.startsWith('-'))
    652         return Invalid;
    653 
    654     if (t < 0 && buff.startsWith('+'))
    655         return Invalid;
     674        return QValidator::Intermediate;
     675
     676    if (q->b >= 0 && buff.startsWith('-'))
     677        return QValidator::Invalid;
     678
     679    if (q->t < 0 && buff.startsWith('+'))
     680        return QValidator::Invalid;
    656681
    657682    bool ok, overflow;
    658683    double i = QLocalePrivate::bytearrayToDouble(buff.constData(), &ok, &overflow);
    659684    if (overflow)
    660         return Invalid;
     685        return QValidator::Invalid;
    661686    if (!ok)
    662         return Intermediate;
    663 
    664     if (i >= b && i <= t)
    665         return Acceptable;
    666 
    667     if (d->notation == StandardNotation) {
    668         double max = qMax(qAbs(b), qAbs(t));
     687        return QValidator::Intermediate;
     688
     689    if (i >= q->b && i <= q->t)
     690        return QValidator::Acceptable;
     691
     692    if (notation == QDoubleValidator::StandardNotation) {
     693        double max = qMax(qAbs(q->b), qAbs(q->t));
    669694        if (max < LLONG_MAX) {
    670695            qlonglong n = pow10(numDigits(qlonglong(max))) - 1;
    671696            if (qAbs(i) > n)
    672                 return Invalid;
     697                return QValidator::Invalid;
    673698        }
    674699    }
    675700
    676     return Intermediate;
     701    return QValidator::Intermediate;
    677702}
    678703
  • trunk/src/gui/widgets/qvalidator.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    106106
    107107    QValidator::State validate(QString &, int &) const;
     108    void fixup(QString &input) const;
    108109
    109110    void setBottom(int);
     
    137138    Q_PROPERTY(double top READ top WRITE setTop)
    138139    Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
     140    Q_ENUMS(Notation)
    139141    Q_PROPERTY(Notation notation READ notation WRITE setNotation)
    140142
    141143public:
    142     explicit QDoubleValidator(QObject * parent);
     144    explicit QDoubleValidator(QObject * parent = 0);
    143145    QDoubleValidator(double bottom, double top, int decimals, QObject * parent);
    144146    ~QDoubleValidator();
     
    184186
    185187public:
    186     explicit QRegExpValidator(QObject *parent);
     188    explicit QRegExpValidator(QObject *parent = 0);
    187189    QRegExpValidator(const QRegExp& rx, QObject *parent);
    188190    ~QRegExpValidator();
  • trunk/src/gui/widgets/qwidgetanimator.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qwidgetanimator_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qwidgetresizehandler.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qwidgetresizehandler_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/qworkspace.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4545#include "qbitmap.h"
    4646#include "qcursor.h"
    47 #include "qdatetime.h"
    4847#include "qdesktopwidget.h"
    4948#include "qevent.h"
     
    6059#include "qstyle.h"
    6160#include "qstyleoption.h"
     61#include "qelapsedtimer.h"
    6262#include "qtooltip.h"
    6363#include "qdebug.h"
     
    451451            if (d->flags & Qt::WindowSystemMenuHint) {
    452452                d->buttonDown = QStyle::SC_None;
    453                 static QTime *t = 0;
     453                static QElapsedTimer *t = 0;
    454454                static QWorkspaceTitleBar *tc = 0;
    455455                if (!t)
    456                     t = new QTime;
     456                    t = new QElapsedTimer;
    457457                if (tc != this || t->elapsed() > QApplication::doubleClickInterval()) {
    458458                    emit showOperationMenu();
     
    18401840{
    18411841    Q_D(QWorkspace);
    1842     static QTime* t = 0;
     1842    static QElapsedTimer* t = 0;
    18431843    static QWorkspace* tc = 0;
    18441844    if (o == d->maxtools) {
     
    18481848                QMenuBar* b = (QMenuBar*)o->parent();
    18491849                if (!t)
    1850                     t = new QTime;
     1850                    t = new QElapsedTimer;
    18511851                if (tc != this || t->elapsed() > QApplication::doubleClickInterval()) {
    18521852                    if (isRightToLeft()) {
  • trunk/src/gui/widgets/qworkspace.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/widgets/widgets.pri

    r561 r846  
    165165}
    166166
    167 symbian*: {
     167symbian: {
    168168    SOURCES += widgets/qmenu_symbian.cpp
    169169}
Note: See TracChangeset for help on using the changeset viewer.