Changeset 846 for trunk/src/gui/dialogs


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:
63 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/dialogs/dialogs.pri

    r573 r846  
    5151
    5252win32 {
    53     HEADERS += dialogs/qwizard_win_p.h
     53    HEADERS += dialogs/qwizard_win_p.h \
     54               dialogs/qfiledialog_win_p.h
    5455    SOURCES += dialogs/qdialogsbinarycompat_win.cpp \
    5556               dialogs/qfiledialog_win.cpp \
     
    108109        dialogs/qprintpreviewdialog.cpp
    109110
     111symbian:contains(QT_CONFIG, s60) {
     112    LIBS += -lCommonDialogs
     113    SOURCES += dialogs/qfiledialog_symbian.cpp \
     114               dialogs/qcolordialog_symbian.cpp
     115}
     116
    110117FORMS += dialogs/qpagesetupwidget.ui
    111118RESOURCES += dialogs/qprintdialog.qrc
    112119RESOURCES += dialogs/qmessagebox.qrc
     120
     121# Compensate for lack of platform defines in Symbian3
     122symbian: DEFINES += SYMBIAN_VERSION_$$upper($$replace(SYMBIAN_VERSION,\\.,_))
  • trunk/src/gui/dialogs/qabstractpagesetupdialog.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/dialogs/qabstractpagesetupdialog.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/dialogs/qabstractpagesetupdialog_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/dialogs/qabstractprintdialog.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)
     
    6666    Use QPrintDialog to display a print dialog in your application.
    6767
     68    In Symbian, there is no support for printing. Hence, this dialog should not
     69    be used in Symbian.
     70
    6871    \sa QPrintDialog, QPrinter, {Printing with Qt}
    6972*/
     
    7780    \value Selection Only the selection should be printed.
    7881    \value PageRange The specified page range should be printed.
     82    \value CurrentPage Only the currently visible page should be printed.
    7983
    8084    \sa QPrinter::PrintRange
     
    9094    \value PrintSelection The print selection option is enabled.
    9195    \value PrintPageRange The page range selection option is enabled.
    92     \value PrintCollateCopies
     96    \value PrintShowPageSize  Show the page size + margins page only if this is enabled.
     97    \value PrintCollateCopies The collate copies option is enabled
     98    \value PrintCurrentPage The print current page option is enabled
    9399
    94100    This value is obsolete and does nothing since Qt 4.5:
     
    98104    This is no longer supported in Qt 4.5.  If you want to use sheets, use
    99105    QPrintDialog::open() instead.
    100 
    101     \value PrintShowPageSize  Show the page size + margins page only if this is enabled.
    102106*/
    103107
  • trunk/src/gui/dialogs/qabstractprintdialog.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        AllPages,
    6767        Selection,
    68         PageRange
     68        PageRange,
     69        CurrentPage
    6970    };
    7071
     
    7677        PrintShowPageSize       = 0x0008,
    7778        PrintCollateCopies      = 0x0010,
    78         DontUseSheet            = 0x0020
     79        DontUseSheet            = 0x0020,
     80        PrintCurrentPage        = 0x0040
    7981    };
    8082
  • trunk/src/gui/dialogs/qabstractprintdialog_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/dialogs/qcolordialog.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)
     
    19531953*/
    19541954
     1955/*
     1956    For Symbian color dialogs
     1957*/
     1958#ifdef Q_WS_S60
     1959extern QColor qtSymbianGetColor(const QColor &initial);
     1960#endif
    19551961/*!
    19561962    \since 4.5
     
    19621968
    19631969    The \a options argument allows you to customize the dialog.
     1970
     1971    On Symbian, this static function will use the native color dialog and not a QColorDialog.
     1972    On Symbian the parameters \a title and \a parent has no relevance and the
     1973    \a options parameter is only used to define if the native color dialog is
     1974    used or not.
    19641975*/
    19651976QColor QColorDialog::getColor(const QColor &initial, QWidget *parent, const QString &title,
    19661977                              ColorDialogOptions options)
    19671978{
     1979#ifdef Q_WS_S60
     1980    if (!(options & DontUseNativeDialog))
     1981        return qtSymbianGetColor(initial);
     1982#endif
    19681983    QColorDialog dlg(parent);
    19691984    if (!title.isEmpty())
     
    19801995    dialog is a child of \a parent. It returns an invalid (see
    19811996    QColor::isValid()) color if the user cancels the dialog.
     1997
     1998    On Symbian, this static function will use the native
     1999    color dialog and not a QColorDialog.
    19822000*/
    19832001
    19842002QColor QColorDialog::getColor(const QColor &initial, QWidget *parent)
    19852003{
     2004#ifdef Q_WS_S60
     2005    return qtSymbianGetColor(initial);
     2006#endif
    19862007    return getColor(initial, parent, QString(), ColorDialogOptions(0));
    19872008}
  • trunk/src/gui/dialogs/qcolordialog.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/dialogs/qcolordialog_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)
     
    6666QT_USE_NAMESPACE
    6767
    68 @class QCocoaColorPanelDelegate;
    69 
    70 @interface QCocoaColorPanelDelegate : NSObject<NSWindowDelegate> {
     68@class QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate);
     69
     70@interface QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) : NSObject<NSWindowDelegate> {
    7171    NSColorPanel *mColorPanel;
    7272    NSView *mStolenContentView;
     
    100100@end
    101101
    102 @implementation QCocoaColorPanelDelegate
     102@implementation QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate)
    103103- (id)initWithColorPanel:(NSColorPanel *)panel
    104104       stolenContentView:(NSView *)stolenContentView
     
    433433        }
    434434
    435         delegate = [[QCocoaColorPanelDelegate alloc] initWithColorPanel:colorPanel
     435        delegate = [[QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) alloc] initWithColorPanel:colorPanel
    436436            stolenContentView:stolenContentView
    437437            okButton:okButton
    438438            cancelButton:cancelButton
    439439            priv:this];
    440         [colorPanel setDelegate:static_cast<QCocoaColorPanelDelegate *>(delegate)];
     440        [colorPanel setDelegate:static_cast<QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *>(delegate)];
    441441    }
    442442    [delegate setResultSet:false];
    443443    setCocoaPanelColor(initial);
    444     [static_cast<QCocoaColorPanelDelegate *>(delegate) showColorPanel];
     444    [static_cast<QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *>(delegate) showColorPanel];
    445445}
    446446
    447447void QColorDialogPrivate::closeCocoaColorPanel()
    448448{
    449     [static_cast<QCocoaColorPanelDelegate *>(delegate) onCancelClicked];
     449    [static_cast<QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *>(delegate) onCancelClicked];
    450450}
    451451
    452452void QColorDialogPrivate::releaseCocoaColorPanelDelegate()
    453453{
    454     [static_cast<QCocoaColorPanelDelegate *>(delegate) release];
     454    [static_cast<QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *>(delegate) release];
    455455}
    456456
     
    472472void QColorDialogPrivate::_q_macRunNativeAppModalPanel()
    473473{
    474     [static_cast<QCocoaColorPanelDelegate *>(delegate) exec];
     474    [static_cast<QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *>(delegate) exec];
    475475}
    476476
     
    478478{
    479479    QMacCocoaAutoReleasePool pool;
    480     QCocoaColorPanelDelegate *theDelegate = static_cast<QCocoaColorPanelDelegate *>(delegate);
     480    QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *theDelegate = static_cast<QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *>(delegate);
    481481    NSColor *nsColor;
    482482    const QColor::Spec spec = color.spec();
  • trunk/src/gui/dialogs/qcolordialog_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/dialogs/qdialog.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)
     
    6868#   include "qfiledialog.h"
    6969#   include "qfontdialog.h"
    70 #   include "qcolordialog.h"
    7170#   include "qwizard.h"
     71#   include "private/qt_s60_p.h"
    7272#endif
    7373
    7474#if defined(Q_WS_S60)
    75 #include "private/qt_s60_p.h"
     75#include <AknUtils.h>               // AknLayoutUtils
    7676#endif
    7777
     
    259259QDialog::QDialog(QWidget *parent, Qt::WindowFlags f)
    260260    : QWidget(*new QDialogPrivate, parent,
    261               f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0))
     261              f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0)))
    262262{
    263263#ifdef Q_WS_WINCE
     
    283283    : QWidget(*new QDialogPrivate, parent,
    284284              f
    285               | QFlag(modal ? Qt::WShowModal : 0)
    286               | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0)
     285              | QFlag(modal ? Qt::WShowModal : Qt::WindowType(0))
     286              | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0))
    287287        )
    288288{
     
    296296*/
    297297QDialog::QDialog(QDialogPrivate &dd, QWidget *parent, Qt::WindowFlags f)
    298     : QWidget(dd, parent, f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0))
     298    : QWidget(dd, parent, f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0)))
    299299{
    300300#ifdef Q_WS_WINCE
     
    394394}
    395395
    396 #if defined(Q_WS_WINCE) || defined(Q_WS_S60)
     396#if defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
    397397#ifdef Q_WS_WINCE_WM
    398398void QDialogPrivate::_q_doneAction()
     
    414414        result = true;
    415415     }
    416 #else
     416#elif defined(Q_WS_S60)
    417417    if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) {
    418418        if (!testAttribute(Qt::WA_Moved)) {
     
    424424        }
    425425    }
     426    // TODO is Symbian, non-S60 behaviour required?
    426427#endif
    427428    return result;
     
    528529#endif //Q_WS_WINCE_WM
    529530
     531    bool showSystemDialogFullScreen = false;
    530532#ifdef Q_OS_SYMBIAN
    531533    if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) ||
    532         qobject_cast<QColorDialog *>(this) || qobject_cast<QWizard *>(this))
    533         showMaximized();
    534     else
     534        qobject_cast<QWizard *>(this)) {
     535        showSystemDialogFullScreen = true;
     536    }
    535537#endif // Q_OS_SYMBIAN
    536538
    537         show();
     539    if (showSystemDialogFullScreen) {
     540        setWindowFlags(windowFlags() | Qt::WindowSoftkeysVisibleHint);
     541        setWindowState(Qt::WindowFullScreen);
     542    }
     543    show();
    538544
    539545#ifdef Q_WS_MAC
     
    642648        w = w->isWindow() ? 0 : w->parentWidget();
    643649    if (w) {
    644         QMenu p(this);
    645         QAction *wt = p.addAction(tr("What's This?"));
    646         if (p.exec(e->globalPos()) == wt) {
     650        QWeakPointer<QMenu> p = new QMenu(this);
     651        QAction *wt = p.data()->addAction(tr("What's This?"));
     652        if (p.data()->exec(e->globalPos()) == wt) {
    647653            QHelpEvent e(QEvent::WhatsThis, w->rect().center(),
    648654                         w->mapToGlobal(w->rect().center()));
    649655            QApplication::sendEvent(w, &e);
    650656        }
     657        delete p.data();
    651658    }
    652659#endif
     
    818825#endif
    819826
    820 #ifdef Q_WS_S60
    821     if (s60AdjustedPosition())
     827#ifdef Q_OS_SYMBIAN
     828    if (symbianAdjustedPosition())
    822829        //dialog has already been positioned
    823830        return;
     
    887894}
    888895
     896#if defined(Q_OS_SYMBIAN)
     897/*! \internal */
     898bool QDialog::symbianAdjustedPosition()
     899{
    889900#if defined(Q_WS_S60)
    890 /*! \internal */
    891 bool QDialog::s60AdjustedPosition()
    892 {
    893901    QPoint p;
    894     const QSize mainAreaSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
    895     const int statusPaneHeight = (S60->screenHeightInPixels - mainAreaSize.height())>>1;
    896     const bool doS60Positioning = !(isFullScreen()||isMaximized());
    897     if (doS60Positioning) {
     902    QPoint oldPos = pos();
     903    if (isFullScreen()) {
     904        p.setX(0);
     905        p.setY(0);
     906    } else if (isMaximized()) {
     907        TRect statusPaneRect = TRect();
     908        if (S60->screenHeightInPixels > S60->screenWidthInPixels) {
     909            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane, statusPaneRect);
     910        } else {
     911            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStaconTop, statusPaneRect);
     912        }
     913
     914        p.setX(0);
     915        p.setY(statusPaneRect.Height());
     916    } else {
    898917        // naive way to deduce screen orientation
    899918        if (S60->screenHeightInPixels > S60->screenWidthInPixels) {
    900919            int cbaHeight;
    901             const CEikButtonGroupContainer* bgContainer = S60->buttonGroupContainer();
    902             if (!bgContainer) {
    903                 cbaHeight = 0;
    904             } else {
    905                 cbaHeight = qt_TSize2QSize(bgContainer->Size()).height();
    906             }
     920            TRect rect;
     921            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, rect);
     922            cbaHeight = rect.Height();
    907923            p.setY(S60->screenHeightInPixels - height() - cbaHeight);
    908924            p.setX(0);
     
    934950            }
    935951        }
     952    }
     953    if (oldPos != p || p.y() < 0)
    936954        move(p);
    937     }
    938     return doS60Positioning;
     955    return true;
     956#else
     957    // TODO - check positioning requirement for Symbian, non-s60
     958    return false;
     959#endif
    939960}
    940961#endif
     
    11021123    if (minimumSize() != maximumSize()) {
    11031124        // In S60, dialogs are always the width of screen (in portrait, regardless of current layout)
    1104         return QSize(qMax(S60->screenHeightInPixels, S60->screenWidthInPixels), QWidget::sizeHint().height());
     1125        return QSize(qMin(S60->screenHeightInPixels, S60->screenWidthInPixels), QWidget::sizeHint().height());
    11051126    } else {
    11061127        return QWidget::sizeHint();
  • trunk/src/gui/dialogs/qdialog.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)
     
    108108    QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = 0);
    109109
    110 #if defined(Q_WS_WINCE) || defined(Q_WS_S60)
     110#if defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
    111111    bool event(QEvent *e);
    112112#endif
     
    124124    Q_DISABLE_COPY(QDialog)
    125125
    126 #if defined(Q_WS_S60)
    127     bool s60AdjustedPosition();
     126#if defined(Q_OS_SYMBIAN)
     127    bool symbianAdjustedPosition();
    128128#endif
    129129
  • trunk/src/gui/dialogs/qdialog_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/dialogs/qdialogsbinarycompat_win.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/dialogs/qerrormessage.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)
     
    7171#if defined(QT_SOFTKEYS_ENABLED)
    7272#include <qaction.h>
     73#endif
    7374#ifdef Q_WS_S60
    7475#include "private/qt_s60_p.h"
    75 #endif
    7676#endif
    7777
  • trunk/src/gui/dialogs/qerrormessage.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/dialogs/qfiledialog.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)
     
    229229    \value ReadOnly Indicates that the model is readonly.
    230230
    231     \value HideNameFilterDetails Indicates if the is hidden or not.
     231    \value HideNameFilterDetails Indicates if the file name filter details are
     232    hidden or not.
    232233
    233234    \value DontUseSheet In previous versions of Qt, the static
     
    302303#include <qshortcut.h>
    303304#ifdef Q_WS_MAC
    304 #include <private/qunicodetables_p.h>
    305305#include <qmacstyle_mac.h>
    306306#endif
     
    723723            // updates the state correctly, but skips showing the non-native version:
    724724            setAttribute(Qt::WA_DontShowOnScreen);
     725#ifndef QT_NO_FSCOMPLETER
     726            //So the completer don't try to complete and therefore to show a popup
     727            d->completer->setModel(0);
     728#endif
    725729        } else {
    726730            d->nativeDialogInUse = false;
    727731            setAttribute(Qt::WA_DontShowOnScreen, false);
     732#ifndef QT_NO_FSCOMPLETER
     733            if (d->proxyModel != 0)
     734                d->completer->setModel(d->proxyModel);
     735            else
     736                d->completer->setModel(d->model);
     737#endif
    728738        }
    729739    }
     
    16071617#endif
    16081618
     1619/*
     1620    For Symbian file dialogs
     1621*/
     1622#if defined(Q_WS_S60)
     1623extern QString qtSymbianGetOpenFileName(const QString &caption,
     1624                                        const QString &dir,
     1625                                        const QString &filter);
     1626
     1627extern QStringList qtSymbianGetOpenFileNames(const QString &caption,
     1628                                             const QString &dir,
     1629                                             const QString &filter);
     1630
     1631extern QString qtSymbianGetSaveFileName(const QString &caption,
     1632                                        const QString &dir);
     1633
     1634extern QString qtSymbianGetExistingDirectory(const QString &caption,
     1635                                             const QString &dir);
     1636#endif
     1637
    16091638/*!
    16101639    This is a convenience static function that returns an existing file
     
    16351664    then a default caption will be used.
    16361665
    1637     On Windows and Mac OS X, this static function will use the native file
    1638     dialog and not a QFileDialog.
     1666    On Windows, Mac OS X and Symbian^3, this static function will use the
     1667    native file dialog and not a QFileDialog.
    16391668
    16401669    On Windows the dialog will spin a blocking modal event loop that will not
     
    16471676    \a options includes DontResolveSymlinks, the file dialog will treat
    16481677    symlinks as regular directories.
     1678
     1679    On Symbian^3 the parameter \a selectedFilter has no meaning and the
     1680    \a options parameter is only used to define if the native file dialog is
     1681    used.
    16491682
    16501683    \warning Do not delete \a parent during the execution of the dialog. If you
     
    16631696    if (qt_filedialog_open_filename_hook && !(options & DontUseNativeDialog))
    16641697        return qt_filedialog_open_filename_hook(parent, caption, dir, filter, selectedFilter, options);
     1698#if defined(Q_WS_S60)
     1699    if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog))
     1700        return qtSymbianGetOpenFileName(caption, dir, filter);
     1701#endif
    16651702    QFileDialogArgs args;
    16661703    args.parent = parent;
     
    17131750    then a default caption will be used.
    17141751
    1715     On Windows and Mac OS X, this static function will use the native file
    1716     dialog and not a QFileDialog.
     1752    On Windows, Mac OS X and Symbian^3, this static function will use the
     1753    native file dialog and not a QFileDialog.
    17171754
    17181755    On Windows the dialog will spin a blocking modal event loop that will not
     
    17321769    \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 10
    17331770
     1771    On Symbian^3 the parameter \a selectedFilter has no meaning and the
     1772    \a options parameter is only used to define if the native file dialog is
     1773    used. On Symbian^3, this function can only return a single filename.
     1774
    17341775    \warning Do not delete \a parent during the execution of the dialog. If you
    17351776    want to do this, you should create the dialog yourself using one of the
     
    17471788    if (qt_filedialog_open_filenames_hook && !(options & DontUseNativeDialog))
    17481789        return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options);
     1790#if defined(Q_WS_S60)
     1791    if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog))
     1792        return qtSymbianGetOpenFileNames(caption, dir, filter);
     1793#endif
    17491794    QFileDialogArgs args;
    17501795    args.parent = parent;
     
    18041849    a default caption will be used.
    18051850
    1806     On Windows and Mac OS X, this static function will use the native file
    1807     dialog and not a QFileDialog.
     1851    On Windows, Mac OS X and Symbian^3, this static function will use the
     1852    native file dialog and not a QFileDialog.
    18081853
    18091854    On Windows the dialog will spin a blocking modal event loop that will not
     
    18171862    \a options includes DontResolveSymlinks the file dialog will treat symlinks
    18181863    as regular directories.
     1864
     1865    On Symbian^3 the parameters \a filter and \a selectedFilter have no
     1866    meaning. The \a options parameter is only used to define if the native file
     1867    dialog is used.
    18191868
    18201869    \warning Do not delete \a parent during the execution of the dialog. If you
     
    18331882    if (qt_filedialog_save_filename_hook && !(options & DontUseNativeDialog))
    18341883        return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options);
     1884#if defined(Q_WS_S60)
     1885    if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog))
     1886        return qtSymbianGetSaveFileName(caption, dir);
     1887#endif
    18351888    QFileDialogArgs args;
    18361889    args.parent = parent;
     
    18811934    be set.
    18821935
    1883     On Windows and Mac OS X, this static function will use the native file
    1884     dialog and not a QFileDialog. On Windows CE, if the device has no native
    1885     file dialog, a QFileDialog will be used.
     1936    On Windows, Mac OS X and Symbian^3, this static function will use the
     1937    native file dialog and not a QFileDialog. On Windows CE, if the device has
     1938    no native file dialog, a QFileDialog will be used.
    18861939
    18871940    On Unix/X11, the normal behavior of the file dialog is to resolve and
     
    18951948    dialog just below the parent's title bar.
    18961949
     1950    On Symbian^3 the \a options parameter is only used to define if the native
     1951    file dialog is used.
     1952
    18971953    \warning Do not delete \a parent during the execution of the dialog. If you
    18981954    want to do this, you should create the dialog yourself using one of the
     
    19081964    if (qt_filedialog_existing_directory_hook && !(options & DontUseNativeDialog))
    19091965        return qt_filedialog_existing_directory_hook(parent, caption, dir, options);
     1966#if defined(Q_WS_S60)
     1967    if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog))
     1968        return qtSymbianGetExistingDirectory(caption, dir);
     1969#endif
    19101970    QFileDialogArgs args;
    19111971    args.parent = parent;
  • trunk/src/gui/dialogs/qfiledialog.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)
     
    6868    Q_OBJECT
    6969    Q_ENUMS(ViewMode FileMode AcceptMode Option)
     70    Q_FLAGS(Options)
    7071    Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
    7172    Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode)
  • trunk/src/gui/dialogs/qfiledialog.ui

    r769 r846  
    22 <comment>*********************************************************************
    33**
    4 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    55** All rights reserved.
    66** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/dialogs/qfiledialog_embedded.ui

    r651 r846  
    22 <comment>*********************************************************************
    33**
    4 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    55** All rights reserved.
    66** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/dialogs/qfiledialog_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)
     
    8383QT_USE_NAMESPACE
    8484
    85 @class QNSOpenSavePanelDelegate;
    86 
    87 @interface QNSOpenSavePanelDelegate : NSObject {
     85@class QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate);
     86
     87@interface QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) : NSObject {
    8888    @public
    8989    NSOpenPanel *mOpenPanel;
     
    120120- (void)createTextField;
    121121- (void)createPopUpButton:(const QString &)selectedFilter hideDetails:(BOOL)hideDetails;
     122- (QStringList)findStrippedFilterWithVisualFilterName:(QString)name;
    122123- (void)createAccessory;
    123124
    124125@end
    125126
    126 @implementation QNSOpenSavePanelDelegate
     127@implementation QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate)
    127128
    128129- (id)initWithAcceptMode:(QT_PREPEND_NAMESPACE(QFileDialog::AcceptMode))acceptMode
    129130    title:(const QString &)title
    130     nameFilters:(const QStringList &)nameFilters
    131     selectedNameFilter:(const QString &)selectedNameFilter
    132131    hideNameFilterDetails:(bool)hideNameFilterDetails
    133132    qDirFilter:(QT_PREPEND_NAMESPACE(QDir::Filters))qDirFilter
     
    159158    mLastFilterCheckPath = new QString;
    160159    mQDirFilterEntryList = new QStringList;
    161     mNameFilterDropDownList = new QStringList(nameFilters);
    162     mSelectedNameFilter = new QStringList(qt_clean_filter_list(selectedNameFilter));
     160    mNameFilterDropDownList = new QStringList(priv->nameFilters);
     161    QString selectedVisualNameFilter = priv->qFileDialogUi->fileTypeCombo->currentText();
     162    mSelectedNameFilter = new QStringList([self findStrippedFilterWithVisualFilterName:selectedVisualNameFilter]);
     163
    163164    QFileInfo sel(selectFile);
    164165    if (sel.isDir()){
     
    169170        mCurrentSelection = new QString(sel.absoluteFilePath());
    170171    }
     172
    171173    [mSavePanel setTitle:qt_mac_QStringToNSString(title)];
    172     [self createPopUpButton:selectedNameFilter hideDetails:hideNameFilterDetails];
     174    [self createPopUpButton:selectedVisualNameFilter hideDetails:hideNameFilterDetails];
    173175    [self createTextField];
    174176    [self createAccessory];
     
    285287        return NO;
    286288
     289    // Always accept directories regardless of their names (unless it is a bundle):
     290    BOOL isDir;
     291    if ([[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDir] && isDir) {
     292        if ([mSavePanel treatsFilePackagesAsDirectories] == NO) {
     293            if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename] == NO)
     294                return YES;
     295        }
     296    }
     297
    287298    QString qtFileName = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(filename);
    288299    QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C)));
     
    295306    if (!mQDirFilterEntryList->contains(info.fileName()))
    296307        return NO;
    297 
    298     // Always accept directories regardless of their names:
    299     BOOL isDir;
    300     if ([[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDir] && isDir)
    301         return YES;
    302308
    303309    // No filter means accept everything
     
    347353    Q_UNUSED(sender);
    348354    QString selection = mNameFilterDropDownList->value([mPopUpButton indexOfSelectedItem]);
    349     *mSelectedNameFilter = QT_PREPEND_NAMESPACE(qt_clean_filter_list)(selection);
     355    *mSelectedNameFilter = [self findStrippedFilterWithVisualFilterName:selection];
    350356    [mSavePanel validateVisibleColumns];
    351357    [self updateProperties];
     
    490496            QString filter = hideDetails ? [self removeExtensions:filters->at(i)] : filters->at(i);
    491497            [mPopUpButton addItemWithTitle:QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(filter)];
    492             if (filters->at(i) == selectedFilter)
     498            if (filters->at(i).startsWith(selectedFilter))
    493499                [mPopUpButton selectItemAtIndex:i];
    494500        }
    495501    }
     502}
     503
     504- (QStringList) findStrippedFilterWithVisualFilterName:(QString)name
     505{
     506    for (int i=0; i<mNameFilterDropDownList->size(); ++i) {
     507        if (mNameFilterDropDownList->at(i).startsWith(name))
     508            return qt_clean_filter_list(mNameFilterDropDownList->at(i));
     509    }
     510    return QStringList();
    496511}
    497512
     
    551566#else
    552567    QMacCocoaAutoReleasePool pool;
    553     QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     568    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    554569    [delegate->mSavePanel setDirectory:qt_mac_QStringToNSString(directory)];
    555570#endif
     
    562577#else
    563578    QMacCocoaAutoReleasePool pool;
    564     QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     579    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    565580    return qt_mac_NSStringToQString([delegate->mSavePanel directory]);
    566581#endif
     
    619634#else
    620635    QMacCocoaAutoReleasePool pool;
    621     QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     636    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    622637    return [delegate selectedFiles];
    623638#endif
     
    630645#else
    631646    QMacCocoaAutoReleasePool pool;
    632     QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     647    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    633648    bool hideDetails = q_func()->testOption(QFileDialog::HideNameFilterDetails);
    634649    [delegate setNameFilters:filters hideDetails:hideDetails];
     
    642657    Q_Q(QFileDialog);
    643658    QMacCocoaAutoReleasePool pool;
    644     QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     659    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    645660    *(delegate->mQDirFilter) = model->filter();
    646661    delegate->mFileMode = fileMode;
     
    665680#else
    666681        QMacCocoaAutoReleasePool pool;
    667         QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     682        QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    668683        [delegate->mPopUpButton selectItemAtIndex:index];
    669684        [delegate filterChanged:nil];
     
    678693#else
    679694    QMacCocoaAutoReleasePool pool;
    680     QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     695    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    681696    int index = [delegate->mPopUpButton indexOfSelectedItem];
    682697#endif
     
    693708#else
    694709    QMacCocoaAutoReleasePool pool;
    695     [reinterpret_cast<QNSOpenSavePanelDelegate *>(mDelegate) release];
     710    [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate) release];
    696711    mDelegate = 0;
    697712#endif
     
    704719    if (!visible == q->isHidden())
    705720        return false;
     721
     722    if (q->windowFlags() & Qt::WindowStaysOnTopHint) {
     723        // The native file dialog tries all it can to stay
     724        // on the NSModalPanel level. And it might also show
     725        // its own "create directory" dialog that we cannot control.
     726        // So we need to use the non-native version in this case...
     727        return false;
     728    }
    706729
    707730#ifndef QT_MAC_USE_COCOA
     
    726749    NavFileOrFolderInfo *theInfo = static_cast<NavFileOrFolderInfo *>(info);
    727750    QString file;
     751    QString path;
    728752    const QtMacFilterName &fn
    729753           = fileDialogPrivate->filterInfo.filters.at(fileDialogPrivate->filterInfo.currentSelection);
     
    733757        UInt8 str_buffer[1024];
    734758        FSRefMakePath(&ref, str_buffer, 1024);
    735         file = QString::fromUtf8(reinterpret_cast<const char *>(str_buffer));
    736         int slsh = file.lastIndexOf(QLatin1Char('/'));
     759        path = QString::fromUtf8(reinterpret_cast<const char *>(str_buffer));
     760        int slsh = path.lastIndexOf(QLatin1Char('/'));
    737761        if (slsh != -1)
    738             file = file.right(file.length() - slsh - 1);
     762            file = path.right(path.length() - slsh - 1);
     763        else
     764            file = path;
    739765    }
    740766    QStringList reg = fn.regexp.split(QLatin1String(";"));
     
    748774            return true;
    749775    }
    750     return (theInfo->isFolder && !file.endsWith(QLatin1String(".app")));
     776
     777    if (theInfo->isFolder) {
     778        if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:qt_mac_QStringToNSString(path)])
     779            return false;
     780        return true;
     781    }
     782    return false;
    751783}
    752784
     
    770802                                                       fileDialogPrivate->filterInfo.currentSelection);
    771803            QStringList reg = fn.regexp.split(QLatin1String(";"), QString::SkipEmptyParts);
    772             QString r = reg.first();
    773             r  = r.right(r.length()-1);      // Strip the *
    774             base += r;                        //"." + QString::number(s->menuType);
     804            if (reg.count()) {
     805                QString r = reg.first();
     806                r  = r.right(r.length()-1);      // Strip the *
     807                base += r;                        //"." + QString::number(s->menuType);
     808            }
    775809            NavDialogSetSaveFileName(p->context, QCFString::toCFStringRef(base));
    776810        }
     
    10221056    bool selectDir = q->selectedFiles().isEmpty();
    10231057    QString selection(selectDir ? q->directory().absolutePath() : q->selectedFiles().value(0));
    1024     QNSOpenSavePanelDelegate *delegate = [[QNSOpenSavePanelDelegate alloc]
     1058    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) alloc]
    10251059        initWithAcceptMode:acceptMode
    10261060        title:q->windowTitle()
    1027         nameFilters:q->nameFilters()
    1028         selectedNameFilter:q->selectedNameFilter()
    10291061        hideNameFilterDetails:q->testOption(QFileDialog::HideNameFilterDetails)
    10301062        qDirFilter:model->filter()
     
    10431075    QMacCocoaAutoReleasePool pool;
    10441076    createNSOpenSavePanelDelegate();
    1045     QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     1077    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    10461078    if (qt_mac_is_macsheet(q))
    10471079        [delegate showWindowModalSheet:q->parentWidget()];
     
    10591091    } else {
    10601092        QMacCocoaAutoReleasePool pool;
    1061         QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     1093        QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    10621094        [delegate closePanel];
    10631095        // Even when we hide it, we are still using a
     
    10921124    Q_Q(QFileDialog);
    10931125    QMacCocoaAutoReleasePool pool;
    1094     QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     1126    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    10951127    [delegate runApplicationModalPanel];
    10961128    dialogResultCode_sys() == QDialog::Accepted ? q->accept() : q->reject();
     
    11071139        return QDialog::Accepted;
    11081140#else
    1109     QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
     1141    QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
    11101142    return [delegate dialogResultCode];
    11111143#endif
  • trunk/src/gui/dialogs/qfiledialog_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/dialogs/qfiledialog_win.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)
     
    5353#include <qdir.h>
    5454#include <qstringlist.h>
    55 #include <qlibrary.h>
     55#include <private/qsystemlibrary_p.h>
     56#include "qfiledialog_win_p.h"
    5657
    5758#ifndef QT_NO_THREAD
     
    5960#endif
    6061
     62#ifdef Q_WS_WINCE
    6163#include <shlobj.h>
    62 //At some point we can hope that mingw will support that interface
    63 #if !defined(Q_WS_WINCE) && !defined(Q_CC_MINGW)
    64 #include <shobjidl.h>
     64#include <commdlg.h>
     65bool qt_priv_ptr_valid = false;
     66#else
     67//we have to declare them here because they're not present for all SDK/compilers
     68static const IID   QT_IID_IFileOpenDialog  = {0xd57c7288, 0xd4ad, 0x4768, {0xbe, 0x02, 0x9d, 0x96, 0x95, 0x32, 0xd9, 0x60} };
     69static const IID   QT_IID_IShellItem       = {0x43826d1e, 0xe718, 0x42ee, {0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe} };
     70static const CLSID QT_CLSID_FileOpenDialog = {0xdc1c5a9c, 0xe88a, 0x4dde, {0xa5, 0xa1, 0x60, 0xf8, 0x2a, 0x20, 0xae, 0xf7} };
    6571#endif
    6672
    67 #include <objbase.h>
    68 
    69 #if defined(__IFileDialog_INTERFACE_DEFINED__) \
    70         && defined(__IFileOpenDialog_INTERFACE_DEFINED__)
    71 #define USE_COMMON_ITEM_DIALOG
    72 #endif
    73 
    74 #ifdef Q_WS_WINCE
    75 #include <commdlg.h>
    76 #  ifndef BFFM_SETSELECTION
    77 #    define BFFM_SETSELECTION (WM_USER + 102)
    78 #  endif
    79 // Windows Mobile has a broken definition for BROWSEINFO
    80 // Only compile fix
    81 typedef struct qt_priv_browseinfo {
    82     HWND          hwndOwner;
    83     LPCITEMIDLIST pidlRoot;
    84     LPWSTR        pszDisplayName;
    85     LPCWSTR       lpszTitle;
    86     UINT          ulFlags;
    87     BFFCALLBACK   lpfn;
    88     LPARAM        lParam;
    89     int           iImage;
    90 } qt_BROWSEINFO;
    91 bool qt_priv_ptr_valid = false;
    92 #endif
    93 
    94 
    95 // Don't remove the lines below!
    96 //
    97 // resolving the W methods manually is needed, because Windows 95 doesn't include
    98 // these methods in Shell32.lib (not even stubs!), so you'd get an unresolved symbol
    99 // when Qt calls getExistingDirectory(), etc.
    100 typedef LPITEMIDLIST (WINAPI *PtrSHBrowseForFolder)(BROWSEINFO*);
     73
     74typedef qt_LPITEMIDLIST (WINAPI *PtrSHBrowseForFolder)(qt_BROWSEINFO*);
    10175static PtrSHBrowseForFolder ptrSHBrowseForFolder = 0;
    102 typedef BOOL (WINAPI *PtrSHGetPathFromIDList)(LPITEMIDLIST,LPWSTR);
     76typedef BOOL (WINAPI *PtrSHGetPathFromIDList)(qt_LPITEMIDLIST, LPWSTR);
    10377static PtrSHGetPathFromIDList ptrSHGetPathFromIDList = 0;
    10478typedef HRESULT (WINAPI *PtrSHGetMalloc)(LPMALLOC *);
     
    127101        triedResolve = true;
    128102#if !defined(Q_WS_WINCE)
    129         QLibrary lib(QLatin1String("shell32"));
    130         ptrSHBrowseForFolder = (PtrSHBrowseForFolder) lib.resolve("SHBrowseForFolderW");
    131         ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList) lib.resolve("SHGetPathFromIDListW");
    132         ptrSHGetMalloc = (PtrSHGetMalloc) lib.resolve("SHGetMalloc");
     103        QSystemLibrary lib(L"shell32");
     104        ptrSHBrowseForFolder = (PtrSHBrowseForFolder)lib.resolve("SHBrowseForFolderW");
     105        ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)lib.resolve("SHGetPathFromIDListW");
     106        ptrSHGetMalloc = (PtrSHGetMalloc)lib.resolve("SHGetMalloc");
    133107#else
    134108        // CE stores them in a different lib and does not use unicode version
    135         HINSTANCE handle = LoadLibraryW(L"Ceshell");
     109        HINSTANCE handle = LoadLibrary(L"Ceshell");
    136110        ptrSHBrowseForFolder = (PtrSHBrowseForFolder)GetProcAddress(handle, L"SHBrowseForFolder");
    137111        ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)GetProcAddress(handle, L"SHGetPathFromIDList");
     
    245219
    246220    ofn->lStructSize = sizeof(OPENFILENAME);
    247     Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
    248221    ofn->hwndOwner = parent ? parent->winId() : 0;
    249222    ofn->lpstrFilter = (wchar_t*)tFilters.utf16();
     
    422395
    423396
    424 #if defined(USE_COMMON_ITEM_DIALOG)
     397#ifndef Q_WS_WINCE
    425398
    426399typedef HRESULT (WINAPI *PtrSHCreateItemFromParsingName)(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv);
     
    437410    if (!pSHCreateItemFromParsingName) {
    438411        // This function is available only in Vista & above.
    439         QLibrary shellLib(QLatin1String("Shell32"));
     412        QSystemLibrary shellLib(QLatin1String("Shell32"));
    440413        pSHCreateItemFromParsingName = (PtrSHCreateItemFromParsingName)
    441414            shellLib.resolve("SHCreateItemFromParsingName");
     
    470443    if (numFilters) {
    471444        wchar_t *szData = (wchar_t*)winfilters.utf16();
    472         COMDLG_FILTERSPEC *filterSpec = new COMDLG_FILTERSPEC[numFilters];
     445        qt_COMDLG_FILTERSPEC *filterSpec = new qt_COMDLG_FILTERSPEC[numFilters];
    473446        for(int i = 0; i<numFilters; i++) {
    474447            filterSpec[i].pszName = szData+offsets[i*2];
     
    482455    if (!tInitDir.isEmpty()) {
    483456        IShellItem *psiDefaultFolder;
    484         hr = pSHCreateItemFromParsingName((wchar_t*)tInitDir.utf16(),
    485                                       NULL,
    486                                       IID_PPV_ARGS(&psiDefaultFolder));
     457        hr = pSHCreateItemFromParsingName((wchar_t*)tInitDir.utf16(), NULL, QT_IID_IShellItem,
     458            reinterpret_cast<void**>(&psiDefaultFolder));
    487459
    488460        if (SUCCEEDED(hr)) {
     
    523495}
    524496
    525 QStringList qt_win_CID_get_open_file_names(const QFileDialogArgs &args,
     497static QStringList qt_win_CID_get_open_file_names(const QFileDialogArgs &args,
    526498                                       QString *initialDirectory,
    527499                                       const QStringList &filterList,
     
    536508    // Multiple selection is allowed only in IFileOpenDialog.
    537509    IFileOpenDialog *pfd = 0;
    538     HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog,
    539                                   NULL,
    540                                   CLSCTX_INPROC_SERVER,
    541                                   IID_PPV_ARGS(&pfd));
     510    HRESULT hr = CoCreateInstance(QT_CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, QT_IID_IFileOpenDialog,
     511        reinterpret_cast<void**>(&pfd));
    542512
    543513    if (SUCCEEDED(hr)) {
     
    613583}
    614584
     585QString qt_win_CID_get_existing_directory(const QFileDialogArgs &args)
     586{
     587    QString result;
     588    QDialog modal_widget;
     589    modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
     590    modal_widget.setParent(args.parent, Qt::Window);
     591    QApplicationPrivate::enterModal(&modal_widget);
     592
     593    IFileOpenDialog *pfd = 0;
     594    HRESULT hr = CoCreateInstance(QT_CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER,
     595                                  QT_IID_IFileOpenDialog, reinterpret_cast<void**>(&pfd));
     596
     597    if (SUCCEEDED(hr)) {
     598        qt_win_set_IFileDialogOptions(pfd, args.selection,
     599                                      args.directory, args.caption,
     600                                      QStringList(), QFileDialog::ExistingFiles,
     601                                      args.options);
     602
     603        // Set the FOS_PICKFOLDERS flag
     604        DWORD newOptions;
     605        hr = pfd->GetOptions(&newOptions);
     606        newOptions |= FOS_PICKFOLDERS;
     607        if (SUCCEEDED(hr) && SUCCEEDED((hr = pfd->SetOptions(newOptions)))) {
     608            QWidget *parentWindow = args.parent;
     609            if (parentWindow)
     610                parentWindow = parentWindow->window();
     611            else
     612                parentWindow = QApplication::activeWindow();
     613
     614            // Show the file dialog.
     615            hr = pfd->Show(parentWindow ? parentWindow->winId() : 0);
     616            if (SUCCEEDED(hr)) {
     617                // Retrieve the result
     618                IShellItem *psi = 0;
     619                hr = pfd->GetResult(&psi);
     620                if (SUCCEEDED(hr)) {
     621                    // Retrieve the file name from shell item.
     622                    wchar_t *pszPath;
     623                    hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
     624                    if (SUCCEEDED(hr)) {
     625                        result = QString::fromWCharArray(pszPath);
     626                        CoTaskMemFree(pszPath);
     627                    }
     628                    psi->Release(); // Free the current item.
     629                }
     630            }
     631        }
     632    }
     633    QApplicationPrivate::leaveModal(&modal_widget);
     634
     635    qt_win_eatMouseMove();
     636
     637    if (pfd)
     638        pfd->Release();
     639    return result;
     640}
     641
    615642#endif
    616643
     
    644671    // GetOpenFileName() will return only one folder name for all the files. To retrieve
    645672    // the correct path for all selected files, we have to use Common Item Dialog interfaces.
    646 #if defined(USE_COMMON_ITEM_DIALOG)
     673#ifndef Q_WS_WINCE
    647674    if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)
    648675        return qt_win_CID_get_open_file_names(args, initialDirectory, filterLst, selectedFilter, idx);
     
    717744        if (ptrSHGetPathFromIDList) {
    718745            wchar_t path[MAX_PATH];
    719             ptrSHGetPathFromIDList(LPITEMIDLIST(lParam), path);
     746            ptrSHGetPathFromIDList(qt_LPITEMIDLIST(lParam), path);
    720747            QString tmpStr = QString::fromWCharArray(path);
    721748            if (!tmpStr.isEmpty())
     
    729756}
    730757
    731 #ifndef BIF_NEWDIALOGSTYLE
    732 #define BIF_NEWDIALOGSTYLE     0x0040   // Use the new dialog layout with the ability to resize
     758QString qt_win_get_existing_directory(const QFileDialogArgs &args)
     759{
     760#ifndef Q_WS_WINCE
     761    if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)
     762        return qt_win_CID_get_existing_directory(args);
    733763#endif
    734764
    735 
    736 QString qt_win_get_existing_directory(const QFileDialogArgs &args)
    737 {
    738765    QString currentDir = QDir::currentPath();
    739766    QString result;
     
    758785    tTitle = args.caption;
    759786
    760 #if !defined(Q_WS_WINCE)
    761     BROWSEINFO bi;
    762 #else
    763787    qt_BROWSEINFO bi;
    764 #endif
    765788
    766789    Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
     
    776799    qt_win_resolve_libs();
    777800    if (ptrSHBrowseForFolder) {
    778         LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder((BROWSEINFO*)&bi);
     801        qt_LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder(&bi);
    779802        if (pItemIDList) {
    780803            ptrSHGetPathFromIDList(pItemIDList, path);
  • trunk/src/gui/dialogs/qfileinfogatherer.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)
     
    5656#ifndef QT_NO_FILESYSTEMMODEL
    5757
    58 bool QFileInfoGatherer::fetchedRoot = false;
     58#ifdef QT_BUILD_INTERNAL
     59static bool fetchedRoot = false;
     60Q_AUTOTEST_EXPORT void qt_test_resetFetchedRoot()
     61{
     62    fetchedRoot = false;
     63}
     64
     65Q_AUTOTEST_EXPORT bool qt_test_isFetchedRoot()
     66{
     67    return fetchedRoot;
     68}
     69#endif
    5970
    6071/*!
     
    217228}
    218229
    219 /*
    220     QFileInfo::permissions is different depending upon your platform.
    221 
    222     "normalize this" so they can mean the same to us.
    223 */
    224 QFile::Permissions QFileInfoGatherer::translatePermissions(const QFileInfo &fileInfo) const {
    225     QFile::Permissions permissions = fileInfo.permissions();
    226 #ifdef Q_OS_WIN
    227     return permissions;
    228 #else
    229     QFile::Permissions p = permissions;
    230     p &= ~(QFile::ReadUser|QFile::WriteUser|QFile::ExeUser);
    231     if (                                     permissions & QFile::ReadOther
    232         || (fileInfo.ownerId() == userId  && permissions & QFile::ReadOwner)
    233         || (fileInfo.groupId() == groupId && permissions & QFile::ReadGroup))
    234         p |= QFile::ReadUser;
    235 
    236     if (                                     permissions & QFile::WriteOther
    237         || (fileInfo.ownerId() == userId  && permissions & QFile::WriteOwner)
    238         || (fileInfo.groupId() == groupId && permissions & QFile::WriteGroup))
    239         p |= QFile::WriteUser;
    240 
    241     if (                                     permissions & QFile::ExeOther
    242         || (fileInfo.ownerId() == userId  && permissions & QFile::ExeOwner)
    243         || (fileInfo.groupId() == groupId && permissions & QFile::ExeGroup))
    244         p |= QFile::ExeUser;
    245     return p;
    246 #endif
    247 }
    248 
    249230QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
    250231{
    251232    QExtendedInformation info(fileInfo);
    252233    info.icon = m_iconProvider->icon(fileInfo);
    253     info.setPermissions(translatePermissions(fileInfo));
    254234    info.displayType = m_iconProvider->type(fileInfo);
    255235#ifndef QT_NO_FILESYSTEMWATCHER
     
    310290    // List drives
    311291    if (path.isEmpty()) {
    312 #if defined Q_AUTOTEST_EXPORT
     292#ifdef QT_BUILD_INTERNAL
    313293        fetchedRoot = true;
    314294#endif
     
    329309    }
    330310
    331     QTime base = QTime::currentTime();
     311    QElapsedTimer base;
     312    base.start();
    332313    QFileInfo fileInfo;
    333314    bool firstTime = true;
     
    355336    if (!updatedFiles.isEmpty())
    356337        emit updates(path, updatedFiles);
    357 }
    358 
    359 void QFileInfoGatherer::fetch(const QFileInfo &fileInfo, QTime &base, bool &firstTime, QList<QPair<QString, QFileInfo> > &updatedFiles, const QString &path) {
     338    emit directoryLoaded(path);
     339}
     340
     341void QFileInfoGatherer::fetch(const QFileInfo &fileInfo, QElapsedTimer &base, bool &firstTime, QList<QPair<QString, QFileInfo> > &updatedFiles, const QString &path) {
    360342    updatedFiles.append(QPair<QString, QFileInfo>(fileInfo.fileName(), fileInfo));
    361     QTime current = QTime::currentTime();
     343    QElapsedTimer current;
     344    current.start();
    362345    if ((firstTime && updatedFiles.count() > 100) || base.msecsTo(current) > 1000) {
    363346        emit updates(path, updatedFiles);
  • trunk/src/gui/dialogs/qfileinfogatherer_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)
     
    6161#include <qfsfileengine.h>
    6262#include <qpair.h>
     63#include <qstack.h>
    6364#include <qdatetime.h>
    64 #include <qstack.h>
    6565#include <qdir.h>
     66#include <qelapsedtimer.h>
    6667
    6768QT_BEGIN_NAMESPACE
     
    8990    }
    9091    QFile::Permissions permissions() const {
    91         return mPermissions;
    92     }
    93 
    94     void setPermissions (QFile::Permissions permissions) {
    95         mPermissions = permissions;
     92        return mFileInfo.permissions();
    9693    }
    9794
     
    141138private :
    142139    QFileInfo mFileInfo;
    143     QFile::Permissions mPermissions;
    144140};
    145141
     
    156152    void newListOfFiles(const QString &directory, const QStringList &listOfFiles) const;
    157153    void nameResolved(const QString &fileName, const QString &resolvedName) const;
     154    void directoryLoaded(const QString &path);
    158155
    159156public:
     
    179176
    180177private:
    181     void fetch(const QFileInfo &info, QTime &base, bool &firstTime, QList<QPair<QString, QFileInfo> > &updatedFiles, const QString &path);
     178    void fetch(const QFileInfo &info, QElapsedTimer &base, bool &firstTime, QList<QPair<QString, QFileInfo> > &updatedFiles, const QString &path);
    182179    QString translateDriveName(const QFileInfo &drive) const;
    183     QFile::Permissions translatePermissions(const QFileInfo &fileInfo) const;
    184180
    185181    QMutex mutex;
     
    200196    uint groupId;
    201197#endif
    202 public :
    203     //for testing purpose
    204     static bool fetchedRoot;
    205198};
    206199#endif // QT_NO_FILESYSTEMMODEL
  • trunk/src/gui/dialogs/qfilesystemmodel.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)
     
    5252#include <qt_windows.h>
    5353#endif
     54#ifdef Q_OS_WIN32
     55#include <QtCore/QVarLengthArray>
     56#endif
    5457
    5558QT_BEGIN_NAMESPACE
     
    7780    directories. In the simplest case, it can be used with a suitable display
    7881    widget as part of a browser or filter.
    79 
    80     QFileSystemModel will not fetch any files or directories until setRootPath
    81     is called.  This will prevent any unnecessary querying on the file system
    82     until that point such as listing the drives on Windows.
    83 
    84     Unlike the QDirModel, QFileSystemModel uses a separate thread to populate
    85     itself so it will not cause the main thread to hang as the file system
    86     is being queried.  Calls to rowCount() will return 0 until the model
    87     populates a directory.
    88 
    89     QFileSystemModel keeps a cache with file information. The cache is
    90     automatically kept up to date using the QFileSystemWatcher.
    9182
    9283    QFileSystemModel can be accessed using the standard interface provided by
     
    9990    \note QFileSystemModel requires an instance of a GUI application.
    10091
     92    \section1 Example Usage
     93
     94    A directory model that displays the contents of a default directory
     95    is usually constructed with a parent object:
     96
     97    \snippet doc/src/snippets/shareddirmodel/main.cpp 2
     98
     99    A tree view can be used to display the contents of the model
     100
     101    \snippet doc/src/snippets/shareddirmodel/main.cpp 4
     102
     103    and the contents of a particular directory can be displayed by
     104    setting the tree view's root index:
     105
     106    \snippet doc/src/snippets/shareddirmodel/main.cpp 7
     107
     108    The view's root index can be used to control how much of a
     109    hierarchical model is displayed. QDirModel provides a convenience
     110    function that returns a suitable model index for a path to a
     111    directory within the model.
     112
     113    \section1 Caching and Performance
     114
     115    QFileSystemModel will not fetch any files or directories until setRootPath()
     116    is called.  This will prevent any unnecessary querying on the file system
     117    until that point such as listing the drives on Windows.
     118
     119    Unlike QDirModel, QFileSystemModel uses a separate thread to populate
     120    itself so it will not cause the main thread to hang as the file system
     121    is being queried.  Calls to rowCount() will return 0 until the model
     122    populates a directory.
     123
     124    QFileSystemModel keeps a cache with file information. The cache is
     125    automatically kept up to date using the QFileSystemWatcher.
     126
    101127    \sa {Model Classes}
    102128*/
     
    148174    This signal is emitted whenever a file with the \a oldName is successfully
    149175    renamed to \a newName.  The file is located in in the directory \a path.
     176*/
     177
     178/*!
     179    \since 4.7
     180    \fn void QFileSystemModel::directoryLoaded(const QString &path)
     181
     182    This signal is emitted when the gatherer thread has finished to load the \a path.
     183
    150184*/
    151185
     
    271305}
    272306
    273 #ifdef Q_OS_WIN
     307#ifdef Q_OS_WIN32
    274308static QString qt_GetLongPathName(const QString &strShortPath)
    275309{
    276     QString longPath;
    277     int i = 0;
    278     if (strShortPath == QLatin1String(".")
    279         || (strShortPath.startsWith(QLatin1String("//")))
    280         || (strShortPath.startsWith(QLatin1String("\\\\")))) // unc
     310    if (strShortPath.isEmpty()
     311        || strShortPath == QLatin1String(".") || strShortPath == QLatin1String(".."))
    281312        return strShortPath;
    282     QString::const_iterator it = strShortPath.constBegin();
    283     QString::const_iterator constEnd = strShortPath.constEnd();
    284     do {
    285         bool isSep = (*it == QLatin1Char('\\') || *it == QLatin1Char('/'));
    286         if (isSep || it == constEnd) {
    287             QString section = (it == constEnd ? strShortPath : strShortPath.left(i));
    288             // FindFirstFile does not handle volumes ("C:"), so we have to catch that ourselves.
    289             if (section.endsWith(QLatin1Char(':'))) {
    290                 longPath.append(section.toUpper());
    291             } else {
    292                 HANDLE h;
    293 #ifndef Q_OS_WINCE
    294                 //We add the extend length prefix to handle long path
    295                 QString longSection = QLatin1String("\\\\?\\")+QDir::toNativeSeparators(section);
    296 #else
    297                 QString longSection = QDir::toNativeSeparators(section);
    298 #endif
    299                 WIN32_FIND_DATA findData;
    300                 h = ::FindFirstFile((wchar_t*)longSection.utf16(), &findData);
    301                 if (h != INVALID_HANDLE_VALUE) {
    302                     longPath.append(QString::fromWCharArray(findData.cFileName));
    303                     ::FindClose(h);
    304                 } else {
    305                     longPath.append(section);
    306                     break;
    307                 }
    308             }
    309             if (it != constEnd)
    310                 longPath.append(*it);
    311             else
    312                 break;
    313         }
    314         ++it;
    315         if (isSep && it == constEnd)    // break out if the last character is a separator
    316             break;
    317         ++i;
    318     } while (true);
    319     return longPath;
     313    if (strShortPath.length() == 2 && strShortPath.endsWith(QLatin1Char(':')))
     314        return strShortPath.toUpper();
     315    const QString absPath = QDir(strShortPath).absolutePath();
     316    if (absPath.startsWith(QLatin1String("//"))
     317        || absPath.startsWith(QLatin1String("\\\\"))) // unc
     318        return QDir::fromNativeSeparators(absPath);
     319    if (absPath.startsWith(QLatin1Char('/')))
     320        return QString();
     321    const QString inputString = QLatin1String("\\\\?\\") + QDir::toNativeSeparators(absPath);
     322    QVarLengthArray<TCHAR, MAX_PATH> buffer(MAX_PATH);
     323    DWORD result = ::GetLongPathName((wchar_t*)inputString.utf16(),
     324                                     buffer.data(),
     325                                     buffer.size());
     326    if (result > DWORD(buffer.size())) {
     327        buffer.resize(result);
     328        result = ::GetLongPathName((wchar_t*)inputString.utf16(),
     329                                   buffer.data(),
     330                                   buffer.size());
     331    }
     332    if (result > 4) {
     333        QString longPath = QString::fromWCharArray(buffer.data() + 4); // ignoring prefix
     334        longPath[0] = longPath.at(0).toUpper(); // capital drive letters
     335        return QDir::fromNativeSeparators(longPath);
     336    } else {
     337        return QDir::fromNativeSeparators(strShortPath);
     338    }
    320339}
    321340#endif
     
    335354    // Construct the nodes up to the new root path if they need to be built
    336355    QString absolutePath;
    337 #ifdef Q_OS_WIN
     356#ifdef Q_OS_WIN32
    338357    QString longPath = qt_GetLongPathName(path);
    339358#else
     
    673692    case Qt::DisplayRole:
    674693        switch (index.column()) {
    675         case 0: return d->name(index);
     694        case 0: return d->displayName(index);
    676695        case 1: return d->size(index);
    677696        case 2: return d->type(index);
     
    789808            return resolvedSymLinks[fullPath];
    790809    }
    791     // ### TODO it would be nice to grab the volume name if dirNode->parent == root
    792810    return dirNode->fileName;
     811}
     812
     813/*!
     814    \internal
     815*/
     816QString QFileSystemModelPrivate::displayName(const QModelIndex &index) const
     817{
     818#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
     819    QFileSystemNode *dirNode = node(index);
     820    if (!dirNode->volumeName.isNull())
     821        return dirNode->volumeName + QLatin1String(" (") + name(index) + QLatin1Char(')');
     822#endif
     823    return name(index);
    793824}
    794825
     
    13371368    Q_D(QFileSystemModel);
    13381369#ifdef Q_OS_WIN
    1339     QString longNewPath = QDir::fromNativeSeparators(qt_GetLongPathName(newPath));
     1370#ifdef Q_OS_WIN32
     1371    QString longNewPath = qt_GetLongPathName(newPath);
     1372#else
     1373    QString longNewPath = QDir::fromNativeSeparators(newPath);
     1374#endif
    13401375#else
    13411376    QString longNewPath = newPath;
     
    16491684#ifndef QT_NO_FILESYSTEMWATCHER
    16501685    node->populate(info);
     1686#endif
     1687#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
     1688    //The parentNode is "" so we are listing the drives
     1689    if (parentNode->fileName.isEmpty()) {
     1690        wchar_t name[MAX_PATH + 1];
     1691        //GetVolumeInformation requires to add trailing backslash
     1692        const QString nodeName = fileName + QLatin1String("\\");
     1693        BOOL success = ::GetVolumeInformation((wchar_t *)(nodeName.utf16()),
     1694                name, MAX_PATH + 1, NULL, 0, NULL, NULL, 0);
     1695        if (success && name[0])
     1696            node->volumeName = QString::fromWCharArray(name);
     1697    }
    16511698#endif
    16521699    parentNode->children.insert(fileName, node);
     
    18861933    q->connect(&fileInfoGatherer, SIGNAL(nameResolved(QString,QString)),
    18871934            q, SLOT(_q_resolvedName(QString,QString)));
     1935    q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)),
     1936               q, SIGNAL(directoryLoaded(QString)));
    18881937    q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection);
     1938
     1939    QHash<int, QByteArray> roles = q->roleNames();
     1940    roles.insertMulti(QFileSystemModel::FileIconRole, "fileIcon"); // == Qt::decoration
     1941    roles.insert(QFileSystemModel::FilePathRole, "filePath");
     1942    roles.insert(QFileSystemModel::FileNameRole, "fileName");
     1943    roles.insert(QFileSystemModel::FilePermissions, "filePermissions");
     1944    q->setRoleNames(roles);
    18891945}
    18901946
  • trunk/src/gui/dialogs/qfilesystemmodel.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)
     
    7171    void rootPathChanged(const QString &newPath);
    7272    void fileRenamed(const QString &path, const QString &oldName, const QString &newName);
     73    void directoryLoaded(const QString &path);
    7374
    7475public:
  • trunk/src/gui/dialogs/qfilesystemmodel_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)
     
    121121
    122122        QString fileName;
     123#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
     124        QString volumeName;
     125#endif
    123126
    124127        inline qint64 size() const { if (info && !info->isDir()) return info->size(); return 0; }
     
    302305    QIcon icon(const QModelIndex &index) const;
    303306    QString name(const QModelIndex &index) const;
     307    QString displayName(const QModelIndex &index) const;
    304308    QString filePath(const QModelIndex &index) const;
    305309    QString size(const QModelIndex &index) const;
  • trunk/src/gui/dialogs/qfontdialog.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)
     
    175175    Q_Q(QFontDialog);
    176176
     177#ifdef Q_WS_MAC
     178    nativeDialogInUse = false;
     179    delegate = 0;
     180#endif
     181
    177182    q->setSizeGripEnabled(true);
    178183    q->setWindowTitle(QFontDialog::tr("Select Font"));
     
    330335    familyList->setFocus();
    331336    retranslateStrings();
    332 
    333 #ifdef Q_WS_MAC
    334     delegate = 0;
    335 #endif
    336337}
    337338
     
    346347    Q_D(QFontDialog);
    347348    if (d->delegate) {
    348         QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
    349         QFontDialogPrivate::sharedFontPanelAvailable = true;
     349        d->closeCocoaFontPanel();
    350350        return;
    351351    }
     
    429429                                  const QString &title, QFontDialog::FontDialogOptions options)
    430430{
    431 #ifdef Q_WS_MAC
    432     if (!(options & QFontDialog::DontUseNativeDialog)
    433             && QFontDialogPrivate::sharedFontPanelAvailable) {
    434         return QFontDialogPrivate::execCocoaFontPanel(ok, initial, parent,
    435                        title.isEmpty() ? QFontDialog::tr("Select Font") : title, options);
    436     }
    437 #endif
    438 
    439431    QFontDialog dlg(parent);
    440432    dlg.setOptions(options);
     
    989981void QFontDialog::setVisible(bool visible)
    990982{
    991     Q_D(QFontDialog);
    992     if (visible) {
    993         if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
    994             return;
    995     } else if  (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
     983    if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden) != visible)
    996984        return;
    997985#ifdef Q_WS_MAC
     986    Q_D(QFontDialog);
    998987    if (d->canBeNativeDialog()){
    999988        if (d->setVisible_sys(visible)){
  • trunk/src/gui/dialogs/qfontdialog.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/dialogs/qfontdialog_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)
     
    5959#endif
    6060
     61QT_BEGIN_NAMESPACE
     62
     63extern void macStartInterceptNSPanelCtor();
     64extern void macStopInterceptNSPanelCtor();
     65extern NSButton *macCreateButton(const char *text, NSView *superview);
     66extern bool qt_mac_is_macsheet(const QWidget *w); // qwidget_mac.mm
     67
     68QT_END_NAMESPACE
    6169QT_USE_NAMESPACE
    6270
     
    7583const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
    7684
    77 @class QCocoaFontPanelDelegate;
     85@class QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate);
    7886
    7987
     
    8694#endif
    8795
    88 @interface QCocoaFontPanelDelegate : NSObject <NSWindowDelegate> {
     96@interface QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) : NSObject <NSWindowDelegate> {
    8997    NSFontPanel *mFontPanel;
    9098    NSView *mStolenContentView;
     
    96104    CGFloat mDialogExtraWidth;
    97105    CGFloat mDialogExtraHeight;
    98     NSModalSession mModalSession;
     106    int mReturnCode;
     107    BOOL mAppModal;
    99108}
    100109- (id)initWithFontPanel:(NSFontPanel *)panel
     
    105114             extraWidth:(CGFloat)extraWidth
    106115            extraHeight:(CGFloat)extraHeight;
     116- (void)showModelessPanel;
     117- (void)showWindowModalSheet:(QWidget *)docWidget;
     118- (void)runApplicationModalPanel;
     119- (BOOL)isAppModal;
    107120- (void)changeFont:(id)sender;
    108121- (void)changeAttributes:(id)sender;
    109 - (void)setModalSession:(NSModalSession)session;
    110122- (BOOL)windowShouldClose:(id)window;
    111123- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
     
    121133- (void)finishOffWithCode:(NSInteger)result;
    122134- (void)cleanUpAfterMyself;
     135- (void)setSubwindowStacking;
    123136@end
    124137
     
    146159}
    147160
    148 @implementation QCocoaFontPanelDelegate
     161@implementation QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate)
    149162- (id)initWithFontPanel:(NSFontPanel *)panel
    150163       stolenContentView:(NSView *)stolenContentView
     
    164177    mDialogExtraWidth = extraWidth;
    165178    mDialogExtraHeight = extraHeight;
    166     mModalSession = 0;
     179    mReturnCode = -1;
     180    mAppModal = false;
    167181
    168182    if (mPanelHackedWithButtons) {
     
    175189        [cancelButton setTarget:self];
    176190    }
     191
    177192    mQtFont = new QFont();
    178193    return self;
    179194}
    180195
     196- (void)setSubwindowStacking
     197{
     198#ifdef QT_MAC_USE_COCOA
     199    // Stack the native dialog in front of its parent, if any:
     200    QFontDialog *q = mPriv->fontDialog();
     201    if (!qt_mac_is_macsheet(q)) {
     202        if (QWidget *parent = q->parentWidget()) {
     203            if (parent->isWindow()) {
     204                [qt_mac_window_for(parent)
     205                    addChildWindow:[mStolenContentView window] ordered:NSWindowAbove];
     206            }
     207        }
     208    }
     209#endif
     210}
     211
    181212- (void)dealloc
    182213{
    183214    delete mQtFont;
    184215    [super dealloc];
     216}
     217
     218- (void)showModelessPanel
     219{
     220    mAppModal = false;
     221    NSWindow *ourPanel = [mStolenContentView window];
     222    [ourPanel makeKeyAndOrderFront:self];
     223}
     224
     225- (void)runApplicationModalPanel
     226{
     227    QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
     228    mAppModal = true;
     229    NSWindow *ourPanel = [mStolenContentView window];
     230    [ourPanel setReleasedWhenClosed:NO];
     231    [NSApp runModalForWindow:ourPanel];
     232    QAbstractEventDispatcher::instance()->interrupt();
     233
     234    if (mReturnCode == NSOKButton)
     235        mPriv->fontDialog()->accept();
     236    else
     237        mPriv->fontDialog()->reject();
     238}
     239
     240- (BOOL)isAppModal
     241{
     242    return mAppModal;
     243}
     244
     245- (void)showWindowModalSheet:(QWidget *)docWidget
     246{
     247#ifdef QT_MAC_USE_COCOA
     248    NSWindow *window = qt_mac_window_for(docWidget);
     249#else
     250    WindowRef hiwindowRef = qt_mac_window_for(docWidget);
     251    NSWindow *window = [[NSWindow alloc] initWithWindowRef:hiwindowRef];
     252    CFRetain(hiwindowRef);
     253#endif
     254
     255    mAppModal = false;
     256    NSWindow *ourPanel = [mStolenContentView window];
     257    [NSApp beginSheet:ourPanel
     258        modalForWindow:window
     259        modalDelegate:0
     260        didEndSelector:0
     261        contextInfo:0 ];
     262
     263#ifndef QT_MAC_USE_COCOA
     264    CFRelease(hiwindowRef);
     265#endif
    185266}
    186267
     
    215296    if (mPriv)
    216297        mPriv->updateSampleFont(*mQtFont);
    217 }
    218 
    219 - (void)setModalSession:(NSModalSession)session
    220 {
    221     Q_ASSERT(!mModalSession);
    222     mModalSession = session;
    223298}
    224299
     
    283358
    284359    const CGFloat ButtonWidth = qMin(qMax(ButtonMinWidth,
    285                                           qMax(okSizeHint.width, cancelSizeHint.width)),
    286                                      CGFloat((frameSize.width - 2.0 * ButtonSideMargin
    287                                               - ButtonSpacing) * 0.5));
     360                qMax(okSizeHint.width, cancelSizeHint.width)),
     361            CGFloat((frameSize.width - 2.0 * ButtonSideMargin - ButtonSpacing) * 0.5));
    288362    const CGFloat ButtonHeight = qMax(ButtonMinHeight,
    289363                                     qMax(okSizeHint.height, cancelSizeHint.height));
     
    318392    [self setQtFont:qfontForCocoaFont([fontManager convertFont:[fontManager selectedFont]],
    319393                                      *mQtFont)];
    320     [[mStolenContentView window] close];
    321394    [self finishOffWithCode:NSOKButton];
    322395}
     
    325398{
    326399    Q_ASSERT(mPanelHackedWithButtons);
    327     [[mStolenContentView window] close];
    328400    [self finishOffWithCode:NSCancelButton];
    329401}
     
    369441- (void)finishOffWithCode:(NSInteger)code
    370442{
    371     if (mPriv) {
    372         if (mModalSession) {
    373             [NSApp endModalSession:mModalSession];
    374             mModalSession = 0;
     443#ifdef QT_MAC_USE_COCOA
     444    QFontDialog *q = mPriv->fontDialog();
     445    if (QWidget *parent = q->parentWidget()) {
     446        if (parent->isWindow()) {
     447            [qt_mac_window_for(parent) removeChildWindow:[mStolenContentView window]];
    375448        }
    376         // Hack alert!
    377         // Since this code path was never intended to be followed when starting from exec
    378         // we need to force the dialog to communicate the new font, otherwise the signal
    379         // won't get emitted.
    380         if(code == NSOKButton)
    381             mPriv->sampleEdit->setFont([self qtFont]);
    382         mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
     449    }
     450#endif
     451
     452    if(code == NSOKButton)
     453        mPriv->sampleEdit->setFont([self qtFont]);
     454
     455    if (mAppModal) {
     456        mReturnCode = code;
     457        [NSApp stopModalWithCode:code];
    383458    } else {
    384         [NSApp stopModalWithCode:code];
     459        if (code == NSOKButton)
     460            mPriv->fontDialog()->accept();
     461        else
     462            mPriv->fontDialog()->reject();
    385463    }
    386464}
     
    409487QT_BEGIN_NAMESPACE
    410488
    411 extern void macStartInterceptNSPanelCtor();
    412 extern void macStopInterceptNSPanelCtor();
    413 extern NSButton *macCreateButton(const char *text, NSView *superview);
    414 
    415 void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial,
    416         QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options,
    417         QFontDialogPrivate *priv)
    418 {
    419     Q_UNUSED(parent);   // we would use the parent if only NSFontPanel could be a sheet
     489void QFontDialogPrivate::closeCocoaFontPanel()
     490{
    420491    QMacCocoaAutoReleasePool pool;
    421 
    422     /*
    423         The standard Cocoa font panel has no OK or Cancel button and
    424         is created as a utility window. For strange reasons (which seem
    425         to stem from the fact that the font panel is based on a NIB
    426         file), the approach we use for the color panel doesn't work for
    427         the font panel (and, inversely, the approach we use here doesn't
    428         quite work for color panel, and crashed last time I tried). So
    429         instead, we take the following steps:
    430 
    431          1. Constructs a plain NSPanel that looks the way we want it
    432             to look. Specifically, if the NoButtons option is off, we
    433             construct a panel without the NSUtilityWindowMask flag
    434             and with buttons (OK and Cancel).
    435 
    436          2. Steal the content view from the shared NSFontPanel and
    437             put it inside our new NSPanel's content view, together
    438             with the OK and Cancel buttons.
    439 
    440          3. Lay out the original content view and the buttons when
    441             the font panel is shown and whenever it is resized.
    442 
    443          4. Clean up after ourselves.
    444 
    445          PS. Some customization is also done in QCocoaApplication
    446          validModesForFontPanel:.
    447     */
    448 
    449     Qt::WindowModality modality = Qt::ApplicationModal;
    450     if (priv)
    451         modality = priv->fontDialog()->windowModality();
    452 
    453     bool needButtons = !(options & QFontDialog::NoButtons);
    454     // don't need our own panel if the title bar isn't visible anyway (in a sheet)
    455     bool needOwnPanel = (needButtons && modality != Qt::WindowModal);
    456 
    457     bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists];
    458     NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel];
    459     [sharedFontPanel setHidesOnDeactivate:false];
    460 
    461     // hack to ensure that QCocoaApplication's validModesForFontPanel:
    462     // implementation is honored
    463     if (!sharedFontPanelExisted && needOwnPanel) {
    464         [sharedFontPanel makeKeyAndOrderFront:sharedFontPanel];
    465         [sharedFontPanel close];
    466     }
    467 
    468     NSPanel *ourPanel = 0;
    469     NSView *stolenContentView = 0;
    470     NSButton *okButton = 0;
    471     NSButton *cancelButton = 0;
    472 
    473     CGFloat dialogExtraWidth = 0.0;
    474     CGFloat dialogExtraHeight = 0.0;
    475 
    476     if (!needOwnPanel) {
    477         // we can reuse the NSFontPanel unchanged
    478         ourPanel = sharedFontPanel;
    479     } else {
    480         // compute dialogExtra{Width,Height}
    481         dialogExtraWidth = 2.0 * DialogSideMargin;
    482         dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight
    483                             + ButtonBottomMargin;
    484 
    485         // compute initial contents rectangle
    486         NSRect contentRect = [sharedFontPanel contentRectForFrameRect:[sharedFontPanel frame]];
    487         contentRect.size.width += dialogExtraWidth;
    488         contentRect.size.height += dialogExtraHeight;
    489 
    490         // create the new panel
    491         ourPanel = [[NSPanel alloc] initWithContentRect:contentRect
    492                                               styleMask:StyleMask
    493                                                 backing:NSBackingStoreBuffered
    494                                                   defer:YES];
    495         [ourPanel setReleasedWhenClosed:YES];
    496     }
    497 
    498     stolenContentView = [sharedFontPanel contentView];
    499 
    500     if (needButtons) {
    501         // steal the font panel's contents view
    502         [stolenContentView retain];
    503         [sharedFontPanel setContentView:0];
    504 
    505         // create a new content view and add the stolen one as a subview
    506         NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
    507         NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
    508         [ourContentView addSubview:stolenContentView];
    509 
    510         // create OK and Cancel buttons and add these as subviews
    511         okButton = macCreateButton("&OK", ourContentView);
    512         cancelButton = macCreateButton("Cancel", ourContentView);
    513 
    514         [ourPanel setContentView:ourContentView];
    515         [ourPanel setDefaultButtonCell:[okButton cell]];
    516     }
    517 
    518     // create a delegate and set it
    519     QCocoaFontPanelDelegate *delegate =
    520             [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel
    521                                              stolenContentView:stolenContentView
    522                                                       okButton:okButton
    523                                                   cancelButton:cancelButton
    524                                                           priv:priv
    525                                                     extraWidth:dialogExtraWidth
    526                                                    extraHeight:dialogExtraHeight];
    527     [ourPanel setDelegate:delegate];
    528     [[NSFontManager sharedFontManager] setDelegate:delegate];
    529 #ifdef QT_MAC_USE_COCOA
    530     [[NSFontManager sharedFontManager] setTarget:delegate];
    531 #endif
    532     setFont(delegate, initial);
    533 
    534     // hack to get correct initial layout
    535     NSRect frameRect = [ourPanel frame];
    536     frameRect.size.width += 1.0;
    537     [ourPanel setFrame:frameRect display:NO];
    538     frameRect.size.width -= 1.0;
    539     frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size];
    540     [ourPanel setFrame:frameRect display:NO];
    541     [ourPanel center];
    542 
    543     [ourPanel setTitle:(NSString*)(CFStringRef)QCFString(title)];
    544 
    545     if (priv) {
    546         switch (modality) {
    547         case Qt::WindowModal:
    548             if (parent) {
    549 #ifndef QT_MAC_USE_COCOA
    550                 WindowRef hiwindowRef = qt_mac_window_for(parent);
    551                 NSWindow *window =
    552                     [[NSWindow alloc] initWithWindowRef:hiwindowRef];
    553                 // Cocoa docs say I should retain the Carbon ref.
    554                 CFRetain(hiwindowRef);
    555 #else
    556                 NSWindow *window = qt_mac_window_for(parent);
    557 #endif
    558                 [NSApp beginSheet:ourPanel
    559                    modalForWindow:window
    560                     modalDelegate:0
    561                    didEndSelector:0
    562                       contextInfo:0];
    563 #ifndef QT_MAC_USE_COCOA
    564                 [window release];
    565 #endif
    566                 break;
    567             }
    568             // fallthrough
    569         case Qt::ApplicationModal:
    570             [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]];
    571             break;
    572         default:
    573             [ourPanel makeKeyAndOrderFront:ourPanel];
    574         }
    575     }
    576     return delegate;
    577 }
    578 
    579 void QFontDialogPrivate::closeCocoaFontPanel(void *delegate)
    580 {
    581     QMacCocoaAutoReleasePool pool;
    582     QCocoaFontPanelDelegate *theDelegate = static_cast<QCocoaFontPanelDelegate *>(delegate);
     492    QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *theDelegate = static_cast<QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *>(delegate);
    583493    NSWindow *ourPanel = [theDelegate actualPanel];
    584494    [ourPanel close];
     495    if ([theDelegate isAppModal])
     496        [ourPanel release];
    585497    [theDelegate cleanUpAfterMyself];
    586     [theDelegate autorelease];
    587 }
    588 
    589 QFont QFontDialogPrivate::execCocoaFontPanel(bool *ok, const QFont &initial,
    590         QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options)
    591 {
    592     QMacCocoaAutoReleasePool pool;
    593     QCocoaFontPanelDelegate *delegate =
    594             static_cast<QCocoaFontPanelDelegate *>(
    595                 openCocoaFontPanel(initial, parent, title, options));
    596     NSWindow *ourPanel = [delegate actualPanel];
    597     [ourPanel retain];
    598     int rval = [NSApp runModalForWindow:ourPanel];
    599     QFont font([delegate qtFont]);
    600     [ourPanel release];
    601     [delegate cleanUpAfterMyself];
    602     [delegate release];
    603     bool isOk = ((options & QFontDialog::NoButtons) || rval == NSOKButton);
    604     if (ok)
    605         *ok = isOk;
    606     if (isOk) {
    607         return font;
    608     } else {
    609         return initial;
    610     }
     498    [theDelegate release];
     499    this->delegate = 0;
     500    sharedFontPanelAvailable = true;
    611501}
    612502
     
    643533
    644534    [mgr setSelectedFont:nsFont isMultiple:NO];
    645     [static_cast<QCocoaFontPanelDelegate *>(delegate) setQtFont:font];
    646 }
    647 
    648 void *QFontDialogPrivate::_q_constructNativePanel()
    649 {
     535    [static_cast<QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *>(delegate) setQtFont:font];
     536}
     537
     538void QFontDialogPrivate::createNSFontPanelDelegate()
     539{
     540    if (delegate)
     541        return;
     542
     543    sharedFontPanelAvailable = false;
    650544    QMacCocoaAutoReleasePool pool;
    651 
    652545    bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists];
    653546    NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel];
     
    671564    // compute dialogExtra{Width,Height}
    672565    dialogExtraWidth = 2.0 * DialogSideMargin;
    673     dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight
    674                         + ButtonBottomMargin;
     566    dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight + ButtonBottomMargin;
    675567
    676568    // compute initial contents rectangle
     
    685577                        defer:YES];
    686578    [ourPanel setReleasedWhenClosed:YES];
    687 
    688579    stolenContentView = [sharedFontPanel contentView];
    689580
     
    705596        [ourPanel setDefaultButtonCell:[okButton cell]];
    706597    }
    707     // create a delegate and set it
    708     QCocoaFontPanelDelegate *delegate =
    709             [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel
     598
     599    // create the delegate and set it
     600    QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *del = [[QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) alloc] initWithFontPanel:sharedFontPanel
    710601                                             stolenContentView:stolenContentView
    711602                                                      okButton:okButton
     
    714605                                                    extraWidth:dialogExtraWidth
    715606                                                   extraHeight:dialogExtraHeight];
    716     [ourPanel setDelegate:delegate];
    717     [[NSFontManager sharedFontManager] setDelegate:delegate];
     607    delegate = del;
     608    [ourPanel setDelegate:del];
     609
     610    [[NSFontManager sharedFontManager] setDelegate:del];
    718611#ifdef QT_MAC_USE_COCOA
    719     [[NSFontManager sharedFontManager] setTarget:delegate];
    720 #endif
    721     setFont(delegate, QApplication::font());
     612    [[NSFontManager sharedFontManager] setTarget:del];
     613#endif
     614    setFont(del, q_func()->currentFont());
    722615
    723616    {
     
    727620        [ourPanel setFrame:frameRect display:NO];
    728621        frameRect.size.width -= 1.0;
    729         frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size];
     622        frameRect.size = [del windowWillResize:ourPanel toSize:frameRect.size];
    730623        [ourPanel setFrame:frameRect display:NO];
    731624        [ourPanel center];
    732625    }
     626    [del setSubwindowStacking];
    733627    NSString *title = @"Select font";
    734628    [ourPanel setTitle:title];
    735 
    736     [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]];
    737     return delegate;
    738629}
    739630
     
    760651void QFontDialogPrivate::_q_macRunNativeAppModalPanel()
    761652{
    762     QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
     653    createNSFontPanelDelegate();
     654    QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *del = static_cast<QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *>(delegate);
     655    [del runApplicationModalPanel];
     656}
     657
     658bool QFontDialogPrivate::showCocoaFontPanel()
     659{
     660    if (!sharedFontPanelAvailable)
     661        return false;
     662
    763663    Q_Q(QFontDialog);
    764     QCocoaFontPanelDelegate *delegate = (QCocoaFontPanelDelegate *)_q_constructNativePanel();
    765     NSWindow *ourPanel = [delegate actualPanel];
    766     [ourPanel retain];
    767     int rval = [NSApp runModalForWindow:ourPanel];
    768     QAbstractEventDispatcher::instance()->interrupt();
    769     [ourPanel release];
    770     [delegate cleanUpAfterMyself];
    771     [delegate release];
    772     bool isOk = (rval == NSOKButton);
    773     if(isOk)
    774         rescode = QDialog::Accepted;
     664    QMacCocoaAutoReleasePool pool;
     665    createNSFontPanelDelegate();
     666    QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *del = static_cast<QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *>(delegate);
     667    if (qt_mac_is_macsheet(q))
     668        [del showWindowModalSheet:q->parentWidget()];
    775669    else
    776         rescode = QDialog::Rejected;
    777 }
    778 
     670        [del showModelessPanel];
     671    return true;
     672}
     673
     674bool QFontDialogPrivate::hideCocoaFontPanel()
     675{
     676    if (!delegate){
     677        // Nothing to do. We return false to leave the question
     678        // open regarding whether or not to go native:
     679        return false;
     680    } else {
     681        closeCocoaFontPanel();
     682        // Even when we hide it, we are still using a
     683        // native dialog, so return true:
     684        return true;
     685    }
     686}
    779687bool QFontDialogPrivate::setVisible_sys(bool visible)
    780688{
     
    782690    if (!visible == q->isHidden())
    783691        return false;
    784     return visible;
     692
     693    return visible ? showCocoaFontPanel() : hideCocoaFontPanel();
    785694}
    786695
  • trunk/src/gui/dialogs/qfontdialog_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)
     
    140140
    141141#ifdef Q_WS_MAC
    142     static void *openCocoaFontPanel(const QFont &initial,
    143             QWidget *parent, const QString &title,
    144             QFontDialog::FontDialogOptions options,
    145             QFontDialogPrivate *priv = 0);
    146     static void closeCocoaFontPanel(void *delegate);
    147     static QFont execCocoaFontPanel(bool *ok, const QFont &initial, QWidget *parent,
    148             const QString &title, QFontDialog::FontDialogOptions options);
    149142    static void setFont(void *delegate, const QFont &font);
    150143
     
    153146
    154147    void *delegate;
     148    void closeCocoaFontPanel();
    155149    bool nativeDialogInUse;
    156150    bool canBeNativeDialog();
    157151    bool setVisible_sys(bool visible);
    158     void *_q_constructNativePanel();
     152    void createNSFontPanelDelegate();
    159153    void _q_macRunNativeAppModalPanel();
    160154    void mac_nativeDialogModalHelp();
     155    bool showCocoaFontPanel();
     156    bool hideCocoaFontPanel();
    161157
    162158    static bool sharedFontPanelAvailable;
  • trunk/src/gui/dialogs/qfscompleter_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/dialogs/qinputdialog.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)
     
    232232
    233233    mainLayout = new QVBoxLayout(q);
     234    //we want to let the input dialog grow to available size on Symbian.
     235#ifndef Q_OS_SYMBIAN
    234236    mainLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
     237#else
     238    label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     239#endif
    235240    mainLayout->addWidget(label);
    236241    mainLayout->addWidget(inputWidget);
     
    245250    if (!lineEdit) {
    246251        lineEdit = new QLineEdit(q);
     252#ifndef QT_NO_IM
     253        qt_widget_private(lineEdit)->inheritsInputMethodHints = 1;
     254#endif
    247255        lineEdit->hide();
    248256        QObject::connect(lineEdit, SIGNAL(textChanged(QString)),
     
    256264    if (!comboBox) {
    257265        comboBox = new QComboBox(q);
     266#ifndef QT_NO_IM
     267        qt_widget_private(comboBox)->inheritsInputMethodHints = 1;
     268#endif
    258269        comboBox->hide();
    259270        QObject::connect(comboBox, SIGNAL(editTextChanged(QString)),
     
    553564        d->label->setText(text);
    554565    }
     566#ifdef Q_OS_SYMBIAN
     567    d->label->setWordWrap(true);
     568#endif
    555569}
    556570
  • trunk/src/gui/dialogs/qinputdialog.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/dialogs/qmessagebox.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)
     
    9797#ifndef QT_NO_CONTEXTMENU
    9898            QMenu *menu = createStandardContextMenu();
    99             menu->exec(e->globalPos());
    100             delete menu;
     99            menu->setAttribute(Qt::WA_DeleteOnClose);
     100            menu->popup(e->globalPos());
    101101#else
    102102            Q_UNUSED(e);
     
    123123    void setText(const QString &text) { textEdit->setPlainText(text); }
    124124    QString text() const { return textEdit->toPlainText(); }
    125     QString label(DetailButtonLabel label)
    126         { return label == ShowLabel ? QMessageBox::tr("Show Details...")
    127                                     : QMessageBox::tr("Hide Details..."); }
    128125private:
    129126    TextEdit *textEdit;
    130127};
    131128#endif // QT_NO_TEXTEDIT
     129
     130class DetailButton : public QPushButton
     131{
     132public:
     133    DetailButton(QWidget *parent) : QPushButton(label(ShowLabel), parent)
     134    {
     135        setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     136    }
     137
     138    QString label(DetailButtonLabel label) const
     139    { return label == ShowLabel ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details..."); }
     140
     141    void setLabel(DetailButtonLabel lbl)
     142    { setText(label(lbl)); }
     143
     144    QSize sizeHint() const
     145    {
     146        ensurePolished();
     147        QStyleOptionButton opt;
     148        initStyleOption(&opt);
     149        const QFontMetrics fm = fontMetrics();
     150        opt.text = label(ShowLabel);
     151        QSize sz = fm.size(Qt::TextShowMnemonic, opt.text);
     152        QSize ret = style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
     153                      expandedTo(QApplication::globalStrut());
     154        opt.text = label(HideLabel);
     155        sz = fm.size(Qt::TextShowMnemonic, opt.text);
     156        ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
     157                      expandedTo(QApplication::globalStrut()));
     158        return ret;
     159    }
     160};
     161
    132162
    133163class QMessageBoxPrivate : public QDialogPrivate
     
    186216    QPushButton *defaultButton;
    187217    QAbstractButton *clickedButton;
    188     QPushButton *detailsButton;
     218    DetailButton *detailsButton;
    189219#ifndef QT_NO_TEXTEDIT
    190220    QMessageBoxDetailsText *detailsText;
     
    436466#ifndef QT_NO_TEXTEDIT
    437467    if (detailsButton && detailsText && button == detailsButton) {
    438         detailsButton->setText(detailsText->isHidden() ? detailsText->label(HideLabel) : detailsText->label(ShowLabel));
     468        detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel);
    439469        detailsText->setHidden(!detailsText->isHidden());
    440470        updateSize();
     
    747777    arguments are passed to the QDialog constructor.
    748778
    749     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    750     {application modal} dialog box. If \a parent is a widget, the
    751     message box is \l{Qt::WindowModal} {window modal} relative to \a
    752     parent.
     779    The message box is an \l{Qt::ApplicationModal} {application modal}
     780    dialog box.
    753781
    754782    On Mac OS X, if \a parent is not 0 and you want your message box
     
    15201548    {escape button} is returned.
    15211549
    1522     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    1523     {application modal} dialog box. If \a parent is a widget, the
    1524     message box is \l{Qt::WindowModal} {window modal} relative to \a
    1525     parent.
     1550    The message box is an \l{Qt::ApplicationModal} {application modal}
     1551    dialog box.
    15261552
    15271553    \sa question(), warning(), critical()
     
    15501576    {escape button} is returned.
    15511577
    1552     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    1553     {application modal} dialog box. If \a parent is a widget, the
    1554     message box is \l{Qt::WindowModal} {window modal} relative to \a
    1555     parent.
     1578    The message box is an \l{Qt::ApplicationModal} {application modal}
     1579    dialog box.
    15561580
    15571581    \sa information(), warning(), critical()
     
    15781602    {escape button} is returned.
    15791603
    1580     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    1581     {application modal} dialog box. If \a parent is a widget, the
    1582     message box is \l{Qt::WindowModal} {window modal} relative to \a
    1583     parent.
     1604    The message box is an \l{Qt::ApplicationModal} {application modal}
     1605    dialog box.
    15841606
    15851607    \sa question(), information(), critical()
     
    16061628    {escape button} is returned.
    16071629
    1608     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    1609     {application modal} dialog box. If \a parent is a widget, the
    1610     message box is \l{Qt::WindowModal} {window modal} relative to \a
    1611     parent.
     1630    The message box is an \l{Qt::ApplicationModal} {application modal}
     1631    dialog box.
    16121632
    16131633  \warning Do not delete \a parent during the execution of the dialog.
     
    16411661    The about box has a single button labelled "OK". On Mac OS X, the
    16421662    about box is popped up as a modeless window; on other platforms,
    1643     it is currently a window modal.
     1663    it is currently application modal.
    16441664
    16451665    \sa QWidget::windowIcon(), QApplication::activeWindow()
     
    16941714
    16951715    On Mac OS X, the about box is popped up as a modeless window; on
    1696     other platforms, it is currently window modal.
     1716    other platforms, it is currently application modal.
    16971717
    16981718    \sa QApplication::aboutQt()
     
    17421762        "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> "
    17431763        "for an overview of Qt licensing.</p>"
    1744         "<p>Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).</p>"
     1764        "<p>Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).</p>"
    17451765        "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> "
    17461766        "for more information.</p>"
     
    19061926#ifndef QT_NO_TEXTEDIT
    19071927    if (detailsButton)
    1908         detailsButton->setText(detailsText->isHidden() ? detailsText->label(HideLabel) : detailsText->label(ShowLabel));
     1928        detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel);
    19091929#endif
    19101930}
     
    19541974    \snippet doc/src/snippets/dialogs/dialogs.cpp 2
    19551975
    1956     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    1957     {application modal} dialog box. If \a parent is a widget, the
    1958     message box is \l{Qt::WindowModal} {window modal} relative to \a
    1959     parent.
     1976    The message box is an \l{Qt::ApplicationModal} {application modal}
     1977    dialog box.
    19601978
    19611979    The \a parent and \a f arguments are passed to
     
    20062024    of the button that was clicked.
    20072025
    2008     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    2009     {application modal} dialog box. If \a parent is a widget, the
    2010     message box is \l{Qt::WindowModal} {window modal} relative to \a
    2011     parent.
     2026    The message box is an \l{Qt::ApplicationModal} {application modal}
     2027    dialog box.
    20122028
    20132029  \warning Do not delete \a parent during the execution of the dialog.
     
    20442060    the relevant button.
    20452061
    2046     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    2047     {application modal} dialog box. If \a parent is a widget, the
    2048     message box is \l{Qt::WindowModal} {window modal} relative to \a
    2049     parent.
     2062    The message box is an \l{Qt::ApplicationModal} {application modal}
     2063    dialog box.
    20502064
    20512065  \warning Do not delete \a parent during the execution of the dialog.
     
    20962110    of the button that was clicked.
    20972111
    2098     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    2099     {application modal} dialog box. If \a parent is a widget, the
    2100     message box is \l{Qt::WindowModal} {window modal} relative to \a
    2101     parent.
     2112    The message box is an \l{Qt::ApplicationModal} {application modal}
     2113    dialog box.
    21022114
    21032115  \warning Do not delete \a parent during the execution of the dialog.
     
    21342146    the relevant button.
    21352147
    2136     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    2137     {application modal} dialog box. If \a parent is a widget, the
    2138     message box is \l{Qt::WindowModal} {window modal} relative to \a
    2139     parent.
     2148    The message box is an \l{Qt::ApplicationModal} {application modal}
     2149    dialog box.
    21402150
    21412151  \warning Do not delete \a parent during the execution of the dialog.
     
    21862196    of the button that was clicked.
    21872197
    2188     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    2189     {application modal} dialog box. If \a parent is a widget, the
    2190     message box is \l{Qt::WindowModal} {window modal} relative to \a
    2191     parent.
     2198    The message box is an \l{Qt::ApplicationModal} {application modal}
     2199    dialog box.
    21922200
    21932201  \warning Do not delete \a parent during the execution of the dialog.
     
    22242232    the relevant button.
    22252233
    2226     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    2227     {application modal} dialog box. If \a parent is a widget, the
    2228     message box is \l{Qt::WindowModal} {window modal} relative to \a
    2229     parent.
     2234    The message box is an \l{Qt::ApplicationModal} {application modal}
     2235    dialog box.
    22302236
    22312237  \warning Do not delete \a parent during the execution of the dialog.
     
    22752281    of the button that was clicked.
    22762282
    2277     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    2278     {application modal} dialog box. If \a parent is a widget, the
    2279     message box is \l{Qt::WindowModal} {window modal} relative to \a
    2280     parent.
     2283    The message box is an \l{Qt::ApplicationModal} {application modal}
     2284    dialog box.
    22812285
    22822286  \warning Do not delete \a parent during the execution of the dialog.
     
    23142318    the relevant button.
    23152319
    2316     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    2317     {application modal} dialog box. If \a parent is a widget, the
    2318     message box is \l{Qt::WindowModal} {window modal} relative to \a
    2319     parent.
     2320    The message box is an \l{Qt::ApplicationModal} {application modal}
     2321    dialog box.
    23202322
    23212323  \warning Do not delete \a parent during the execution of the dialog.
     
    24142416        d->detailsText->hide();
    24152417    }
    2416     if (!d->detailsButton) {
    2417         d->detailsButton = new QPushButton(d->detailsText->label(ShowLabel), this);
    2418         QPushButton hideDetails(d->detailsText->label(HideLabel));
    2419         d->detailsButton->setFixedSize(d->detailsButton->sizeHint().expandedTo(hideDetails.sizeHint()));
    2420     }
     2418    if (!d->detailsButton)
     2419        d->detailsButton = new DetailButton(this);
    24212420    d->detailsText->setText(text);
    24222421}
  • trunk/src/gui/dialogs/qmessagebox.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)
     
    355355 "%2, found Qt %3.").arg(qAppName()).arg(QString::fromLatin1(\
    356356str)).arg(QString::fromLatin1(qVersion())); QMessageBox::critical(0, QApplication::tr(\
    357 "Incompatible Qt Library Error"), s, QMessageBox::Abort, 0); qFatal(s.toLatin1().data()); }}
     357"Incompatible Qt Library Error"), s, QMessageBox::Abort, 0); qFatal("%s", s.toLatin1().data()); }}
    358358
    359359#endif // QT_NO_MESSAGEBOX
  • trunk/src/gui/dialogs/qnspanelproxy_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)
     
    5353QT_USE_NAMESPACE
    5454
    55 @class QNSPanelProxy;
    56 
    57 @interface QNSPanelProxy : NSWindow {
     55@class QT_MANGLE_NAMESPACE(QNSPanelProxy);
     56
     57@interface QT_MANGLE_NAMESPACE(QNSPanelProxy) : NSWindow {
    5858}
    5959- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
     
    6767@end
    6868
    69 @implementation QNSPanelProxy
     69@implementation QT_MANGLE_NAMESPACE(QNSPanelProxy)
    7070- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
    7171      backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
     
    109109@end
    110110
    111 @class QNSWindowProxy;
    112 
    113 @interface QNSWindowProxy : NSWindow {
     111@class QT_MANGLE_NAMESPACE(QNSWindowProxy);
     112
     113@interface QT_MANGLE_NAMESPACE(QNSWindowProxy) : NSWindow {
    114114}
    115115- (void)setTitle:(NSString *)title;
     
    117117@end
    118118
    119 @implementation QNSWindowProxy
     119@implementation QT_MANGLE_NAMESPACE(QNSWindowProxy)
    120120- (void)setTitle:(NSString *)title
    121121{
     
    191191    macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:),
    192192                      @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:),
    193                       [NSPanel class], [QNSPanelProxy class]);
     193                      [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
    194194    macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:),
    195195                      @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:),
    196                       [NSPanel class], [QNSPanelProxy class]);
     196                      [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
    197197}
    198198
     
    204204    macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:),
    205205                     @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:),
    206                      [NSPanel class], [QNSPanelProxy class]);
     206                     [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
    207207    macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:),
    208208                     @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:),
    209                      [NSPanel class], [QNSPanelProxy class]);
     209                     [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
    210210}
    211211
     
    218218    currentWindow = window;
    219219    macStartIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:),
    220                       [NSWindow class], [QNSWindowProxy class]);
     220                      [NSWindow class], [QT_MANGLE_NAMESPACE(QNSWindowProxy) class]);
    221221}
    222222
     
    228228    currentWindow = 0;
    229229    macStopIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:),
    230                      [NSWindow class], [QNSWindowProxy class]);
     230                     [NSWindow class], [QT_MANGLE_NAMESPACE(QNSWindowProxy) class]);
    231231}
    232232
  • trunk/src/gui/dialogs/qpagesetupdialog.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)
     
    6363    page setup dialog.
    6464
     65    In Symbian, there is no support for printing. Hence, this dialog should not
     66    be used in Symbian.
     67
    6568    \sa QPrinter, QPrintDialog
    6669*/
  • trunk/src/gui/dialogs/qpagesetupdialog.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/dialogs/qpagesetupdialog_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)
     
    5151QT_USE_NAMESPACE
    5252
    53 @class QCocoaPageLayoutDelegate;
    54 
    55 @interface QCocoaPageLayoutDelegate : NSObject {
     53@class QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate);
     54
     55@interface QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate) : NSObject {
    5656    QMacPrintEnginePrivate *pe;
    5757}
     
    6161@end
    6262
    63 @implementation QCocoaPageLayoutDelegate
     63@implementation QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate)
    6464- (id)initWithMacPrintEngine:(QMacPrintEnginePrivate *)printEngine;
    6565{
     
    214214    // Keep a copy to this since we plan on using it for a bit.
    215215    [pageLayout retain];
    216     QCocoaPageLayoutDelegate *delegate = [[QCocoaPageLayoutDelegate alloc] initWithMacPrintEngine:ep];
     216    QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate) alloc] initWithMacPrintEngine:ep];
    217217
    218218    if (modality == Qt::ApplicationModal) {
     
    233233void QPageSetupDialogPrivate::closeCocoaPageLayout()
    234234{
     235    // NSPageLayout can change the session behind our back and then our
     236    // d->ep->session object will become a dangling pointer. Update it
     237    // based on the "current" session
     238    ep->session = static_cast<PMPrintSession>([ep->printInfo PMPrintSession]);
     239
    235240    [pageLayout release];
    236241    pageLayout = 0;
  • trunk/src/gui/dialogs/qpagesetupdialog_unix.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/dialogs/qpagesetupdialog_unix_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/dialogs/qpagesetupdialog_win.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/dialogs/qprintdialog.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/dialogs/qprintdialog.qdoc

    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)
     
    77** This file is part of the documentation of the Qt Toolkit.
    88**
    9 ** $QT_BEGIN_LICENSE:LGPL$
     9** $QT_BEGIN_LICENSE:FDL$
    1010** Commercial Usage
    1111** Licensees holding valid Qt Commercial licenses may use this file in
    1212** accordance with the Qt Commercial License Agreement provided with the
    13 ** Software or, alternatively, in accordance with the terms contained in
    14 ** a written agreement between you and Nokia.
     13** Software or, alternatively, in accordance with the terms contained in a
     14** written agreement between you and Nokia.
    1515**
    16 ** GNU Lesser General Public License Usage
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
    18 ** General Public License version 2.1 as published by the Free Software
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
    20 ** packaging of this file.  Please review the following information to
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    23 **
    24 ** In addition, as a special exception, Nokia gives you certain additional
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    27 **
    28 ** GNU General Public License Usage
    29 ** Alternatively, this file may be used under the terms of the GNU
    30 ** General Public License version 3.0 as published by the Free Software
    31 ** Foundation and appearing in the file LICENSE.GPL included in the
    32 ** packaging of this file.  Please review the following information to
    33 ** ensure the GNU General Public License version 3.0 requirements will be
    34 ** met: http://www.gnu.org/copyleft/gpl.html.
     16** GNU Free Documentation License
     17** Alternatively, this file may be used under the terms of the GNU Free
     18** Documentation License version 1.3 as published by the Free Software
     19** Foundation and appearing in the file included in the packaging of this
     20** file.
    3521**
    3622** If you have questions regarding the use of this file, please contact
  • trunk/src/gui/dialogs/qprintdialog_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)
     
    125125#ifdef QT_MAC_USE_COCOA
    126126
    127 @class QCocoaPrintPanelDelegate;
    128 
    129 @interface QCocoaPrintPanelDelegate : NSObject {
     127@class QT_MANGLE_NAMESPACE(QCocoaPrintPanelDelegate);
     128
     129@interface QT_MANGLE_NAMESPACE(QCocoaPrintPanelDelegate) : NSObject {
    130130}
    131131- (void)printPanelDidEnd:(NSPrintPanel *)printPanel
     
    133133@end
    134134
    135 @implementation QCocoaPrintPanelDelegate
     135@implementation QT_MANGLE_NAMESPACE(QCocoaPrintPanelDelegate)
    136136- (void)printPanelDidEnd:(NSPrintPanel *)printPanel
    137137        returnCode:(int)returnCode contextInfo:(void *)contextInfo
     
    141141    QPrintDialogPrivate *d = static_cast<QPrintDialogPrivate *>(contextInfo);
    142142    QPrintDialog *dialog = d->printDialog();
    143     // temporary hack to work around bug in deleteLater() in Qt/Mac Cocoa
    144 #if 1
    145     bool deleteDialog = dialog->testAttribute(Qt::WA_DeleteOnClose);
    146     dialog->setAttribute(Qt::WA_DeleteOnClose, false);
    147 #endif
    148143
    149144    if (returnCode == NSOKButton) {
     
    193188
    194189    dialog->done((returnCode == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
    195 #if 1
    196     if (deleteDialog)
    197         delete dialog;
    198 #endif
    199190}
    200191@end
     
    314305    macStartInterceptWindowTitle(q);
    315306    printPanel = [NSPrintPanel printPanel];
    316     QCocoaPrintPanelDelegate *delegate = [[QCocoaPrintPanelDelegate alloc] init];
     307    QT_MANGLE_NAMESPACE(QCocoaPrintPanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QCocoaPrintPanelDelegate) alloc] init];
    317308    [printPanel setOptions:macOptions];
    318309
  • trunk/src/gui/dialogs/qprintdialog_qws.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)
     
    164164    printer->setPageOrder(pageOrder2);
    165165    printer->setColorMode(colorMode2);
    166     printer->setNumCopies(numCopies);
     166    printer->setCopyCount(numCopies);
    167167
    168168    switch ((rangeCombo->itemData(rangeCombo->currentIndex())).toInt()){
     
    178178        q->setPrintRange(QPrintDialog::PageRange);
    179179        q->setFromTo(firstPage->value(), lastPage->value());
     180        break;
     181    case (int)QPrintDialog::CurrentPage:
     182        q->setPrintRange(QPrintDialog::CurrentPage);
     183        q->setFromTo(0, 0);
    180184        break;
    181185    }
     
    376380    rangeCombo->addItem(QPrintDialog::tr("Print selection"), QPrintDialog::Selection);
    377381    rangeCombo->addItem(QPrintDialog::tr("Print range"), QPrintDialog::PageRange);
     382    rangeCombo->addItem(QPrintDialog::tr("Print current page"), QPrintDialog::CurrentPage);
    378383    QObject::connect(rangeCombo, SIGNAL(activated(int)),
    379384            q, SLOT(_q_printRangeSelected(int)));
     
    480485
    481486        // number of copies
    482         copies->setValue(p->numCopies());
    483         _q_setNumCopies(p->numCopies());
     487        copies->setValue(p->copyCount());
     488        _q_setNumCopies(p->copyCount());
    484489    }
    485490
     
    491496                && rangeCombo->findData(QPrintDialog::PageRange) > 0)
    492497            rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::PageRange));
     498        if (!q->isOptionEnabled(QPrintDialog::PrintCurrentPage)
     499                && rangeCombo->findData(QPrintDialog::CurrentPage) > 0)
     500            rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::CurrentPage));
    493501
    494502        switch (q->printRange()) {
     
    501509        case QPrintDialog::PageRange:
    502510            rangeCombo->setCurrentIndex((int)(QPrintDialog::PageRange));
     511            break;
     512        case QPrintDialog::CurrentPage:
     513            rangeCombo->setCurrentIndex((int)(QPrintDialog::CurrentPage));
    503514            break;
    504515        }
  • trunk/src/gui/dialogs/qprintdialog_unix.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)
     
    7373QT_BEGIN_NAMESPACE
    7474
    75 extern int qt_printerRealNumCopies(QPaintEngine *);
    76 
    7775class QOptionTreeItem;
    7876class QPPDOptionsModel;
     
    443441        options.duplexShort->setChecked(true); break;
    444442    }
    445     options.copies->setValue(qt_printerRealNumCopies(p->paintEngine()));
     443    options.copies->setValue(p->copyCount());
    446444    options.collate->setChecked(p->collateCopies());
    447445    options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst);
     
    508506        p->setPrintRange(QPrinter::Selection);
    509507        p->setFromTo(0,0);
     508    } else if (options.printCurrentPage->isChecked()) {
     509        p->setPrintRange(QPrinter::CurrentPage);
     510        p->setFromTo(0,0);
    510511    } else if (options.printRange->isChecked()) {
    511512        p->setPrintRange(QPrinter::PageRange);
     
    514515
    515516    // copies
    516     p->setNumCopies(options.copies->value());
     517    p->setCopyCount(options.copies->value());
    517518    p->setCollateCopies(options.collate->isChecked());
    518519
     
    524525    Q_Q(QPrintDialog);
    525526    options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) ||
    526                                 q->isOptionEnabled(QPrintDialog::PrintSelection));
     527                                     q->isOptionEnabled(QPrintDialog::PrintSelection) ||
     528                                     q->isOptionEnabled(QPrintDialog::PrintCurrentPage));
    527529
    528530    options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange));
    529531    options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection));
     532    options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage));
    530533    options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies));
    531534
     
    540543        options.printRange->setChecked(true);
    541544        break;
     545    case QPrintDialog::CurrentPage:
     546        if (q->isOptionEnabled(QPrintDialog::PrintCurrentPage))
     547            options.printCurrentPage->setChecked(true);
     548        break;
    542549    default:
    543550        break;
     
    699706#endif
    700707
    701 #ifndef QT_NO_FILESYSTEMMODEL
     708#if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER)
    702709    QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
    703710    fsm->setRootPath(QDir::homePath());
    704 #if !defined(QT_NO_FSCOMPLETER) && !defined(QT_NO_FILEDIALOG)
    705     widget.filename->setCompleter(new QFSCompleter(fsm, widget.filename));
    706 #endif
     711    widget.filename->setCompleter(new QCompleter(fsm, widget.filename));
    707712#endif
    708713    _q_printerChanged(currentPrinterIndex);
  • trunk/src/gui/dialogs/qprintdialog_win.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)
     
    5353#include <private/qprinter_p.h>
    5454
    55 #if defined(Q_CC_MINGW) && !defined(PD_NOCURRENTPAGE)
     55#if !defined(PD_NOCURRENTPAGE)
    5656#define PD_NOCURRENTPAGE    0x00800000
    5757#define PD_RESULT_PRINT 1
     
    129129        pd->Flags |= PD_NOPAGENUMS;
    130130
    131     // we don't have a 'current page' notion in the QPrinter API yet.
    132     // Neither do we support more than one page range, so limit those
    133     // options
    134     pd->Flags |= PD_NOCURRENTPAGE;
     131    // Disable Current Page option if not required as default is Enabled
     132    if (!pdlg->isOptionEnabled(QPrintDialog::PrintCurrentPage))
     133        pd->Flags |= PD_NOCURRENTPAGE;
     134
     135    // Default to showing the General tab first
    135136    pd->nStartPage = START_PAGE_GENERAL;
     137
     138    // We don't support more than one page range in the QPrinter API yet.
    136139    pd->nPageRanges = 1;
    137140    pd->nMaxPageRanges = 1;
     
    139142    if (d->ep->printToFile)
    140143        pd->Flags |= PD_PRINTTOFILE;
    141     Q_ASSERT(parent != 0 && parent->testAttribute(Qt::WA_WState_Created));
     144    Q_ASSERT(parent);
    142145    pd->hwndOwner = parent->window()->winId();
    143146    pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
     
    154157        pdlg->setPrintRange(QPrintDialog::PageRange);
    155158        pdlg->setFromTo(pd->lpPageRanges[0].nFromPage, pd->lpPageRanges[0].nToPage);
    156     } else {
     159    } else if (pd->Flags & PD_CURRENTPAGE) {
     160        pdlg->setPrintRange(QPrintDialog::CurrentPage);
     161        pdlg->setFromTo(0, 0);
     162    } else { // PD_ALLPAGES
    157163        pdlg->setPrintRange(QPrintDialog::AllPages);
    158164        pdlg->setFromTo(0, 0);
  • trunk/src/gui/dialogs/qprintpreviewdialog.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)
     
    677677    \endlist
    678678
     679    In Symbian, there is no support for printing. Hence, this dialog should not
     680    be used in Symbian.
    679681
    680682    \sa QPrinter, QPrintDialog, QPageSetupDialog, QPrintPreviewWidget
  • trunk/src/gui/dialogs/qprintpreviewdialog.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/dialogs/qprintsettingsoutput.ui

    r2 r846  
    1 <ui version="4.0" >
     1<?xml version="1.0" encoding="UTF-8"?>
     2<ui version="4.0">
    23 <class>QPrintSettingsOutput</class>
    3  <widget class="QWidget" name="QPrintSettingsOutput" >
    4   <property name="geometry" >
     4 <widget class="QWidget" name="QPrintSettingsOutput">
     5  <property name="geometry">
    56   <rect>
    67    <x>0</x>
    78    <y>0</y>
    8     <width>416</width>
    9     <height>166</height>
     9    <width>426</width>
     10    <height>171</height>
    1011   </rect>
    1112  </property>
    12   <property name="windowTitle" >
     13  <property name="windowTitle">
    1314   <string>Form</string>
    1415  </property>
    15   <layout class="QHBoxLayout" name="horizontalLayout_2" >
    16    <property name="margin" >
     16  <layout class="QHBoxLayout" name="horizontalLayout_2">
     17   <property name="margin">
    1718    <number>0</number>
    1819   </property>
    1920   <item>
    20     <widget class="QTabWidget" name="tabs" >
    21      <property name="currentIndex" >
     21    <widget class="QTabWidget" name="tabs">
     22     <property name="currentIndex">
    2223      <number>0</number>
    2324     </property>
    24      <widget class="QWidget" name="copiesTab" >
    25       <property name="geometry" >
    26        <rect>
    27         <x>0</x>
    28         <y>0</y>
    29         <width>412</width>
    30         <height>139</height>
    31        </rect>
    32       </property>
    33       <attribute name="title" >
     25     <widget class="QWidget" name="copiesTab">
     26      <attribute name="title">
    3427       <string>Copies</string>
    3528      </attribute>
    36       <layout class="QHBoxLayout" name="horizontalLayout" >
     29      <layout class="QHBoxLayout" name="horizontalLayout">
    3730       <item>
    38         <widget class="QGroupBox" name="gbPrintRange" >
    39          <property name="sizePolicy" >
    40           <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
     31        <widget class="QGroupBox" name="gbPrintRange">
     32         <property name="sizePolicy">
     33          <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
    4134           <horstretch>0</horstretch>
    4235           <verstretch>0</verstretch>
    4336          </sizepolicy>
    4437         </property>
    45          <property name="title" >
     38         <property name="title">
    4639          <string>Print range</string>
    4740         </property>
    48          <layout class="QVBoxLayout" name="_3" >
    49           <property name="spacing" >
     41         <layout class="QVBoxLayout" name="_3">
     42          <property name="spacing">
    5043           <number>4</number>
    5144          </property>
    52           <property name="margin" >
     45          <property name="margin">
    5346           <number>6</number>
    5447          </property>
    5548          <item>
    56            <widget class="QRadioButton" name="printAll" >
    57             <property name="text" >
     49           <widget class="QRadioButton" name="printAll">
     50            <property name="text">
    5851             <string>Print all</string>
    5952            </property>
    60             <property name="checked" >
     53            <property name="checked">
    6154             <bool>true</bool>
    6255            </property>
     
    6457          </item>
    6558          <item>
    66            <layout class="QHBoxLayout" name="_4" >
    67             <property name="spacing" >
     59           <layout class="QHBoxLayout" name="_4">
     60            <property name="spacing">
    6861             <number>6</number>
    6962            </property>
    70             <property name="margin" >
     63            <property name="margin">
    7164             <number>0</number>
    7265            </property>
    7366            <item>
    74              <widget class="QRadioButton" name="printRange" >
    75               <property name="text" >
     67             <widget class="QRadioButton" name="printRange">
     68              <property name="text">
    7669               <string>Pages from</string>
    7770              </property>
     
    7972            </item>
    8073            <item>
    81              <widget class="QSpinBox" name="from" >
    82               <property name="enabled" >
     74             <widget class="QSpinBox" name="from">
     75              <property name="enabled">
    8376               <bool>false</bool>
    8477              </property>
    85               <property name="minimum" >
     78              <property name="minimum">
    8679               <number>1</number>
    8780              </property>
    88               <property name="maximum" >
     81              <property name="maximum">
    8982               <number>999</number>
    9083              </property>
     
    9285            </item>
    9386            <item>
    94              <widget class="QLabel" name="label_3" >
    95               <property name="text" >
     87             <widget class="QLabel" name="label_3">
     88              <property name="text">
    9689               <string>to</string>
    9790              </property>
     
    9992            </item>
    10093            <item>
    101              <widget class="QSpinBox" name="to" >
    102               <property name="enabled" >
     94             <widget class="QSpinBox" name="to">
     95              <property name="enabled">
    10396               <bool>false</bool>
    10497              </property>
    105               <property name="minimum" >
     98              <property name="minimum">
    10699               <number>1</number>
    107100              </property>
    108               <property name="maximum" >
     101              <property name="maximum">
    109102               <number>999</number>
    110103              </property>
     
    113106            <item>
    114107             <spacer>
    115               <property name="orientation" >
     108              <property name="orientation">
    116109               <enum>Qt::Horizontal</enum>
    117110              </property>
    118               <property name="sizeHint" stdset="0" >
     111              <property name="sizeHint" stdset="0">
    119112               <size>
    120113                <width>0</width>
     
    127120          </item>
    128121          <item>
    129            <widget class="QRadioButton" name="printSelection" >
    130             <property name="text" >
     122           <widget class="QRadioButton" name="printCurrentPage">
     123            <property name="text">
     124             <string>Current Page</string>
     125            </property>
     126           </widget>
     127          </item>
     128          <item>
     129           <widget class="QRadioButton" name="printSelection">
     130            <property name="text">
    131131             <string>Selection</string>
    132132            </property>
     
    134134          </item>
    135135          <item>
    136            <spacer name="verticalSpacer" >
    137             <property name="orientation" >
     136           <spacer name="verticalSpacer">
     137            <property name="orientation">
    138138             <enum>Qt::Vertical</enum>
    139139            </property>
    140             <property name="sizeHint" stdset="0" >
     140            <property name="sizeHint" stdset="0">
    141141             <size>
    142142              <width>1</width>
     
    150150       </item>
    151151       <item>
    152         <widget class="QGroupBox" name="groupBox" >
    153          <property name="title" >
     152        <widget class="QGroupBox" name="groupBox">
     153         <property name="title">
    154154          <string>Output Settings</string>
    155155         </property>
    156          <layout class="QGridLayout" name="gridLayout" >
    157           <item row="0" column="0" >
    158            <widget class="QLabel" name="label" >
    159             <property name="text" >
     156         <layout class="QGridLayout" name="gridLayout">
     157          <item row="0" column="0">
     158           <widget class="QLabel" name="label">
     159            <property name="text">
    160160             <string>Copies:</string>
    161161            </property>
    162             <property name="buddy" >
     162            <property name="buddy">
    163163             <cstring>copies</cstring>
    164164            </property>
    165165           </widget>
    166166          </item>
    167           <item row="0" column="1" colspan="2" >
    168            <widget class="QSpinBox" name="copies" >
    169             <property name="minimum" >
     167          <item row="0" column="1" colspan="2">
     168           <widget class="QSpinBox" name="copies">
     169            <property name="minimum">
    170170             <number>1</number>
    171171            </property>
    172             <property name="maximum" >
     172            <property name="maximum">
    173173             <number>999</number>
    174174            </property>
    175175           </widget>
    176176          </item>
    177           <item row="0" column="3" >
    178            <spacer name="horizontalSpacer" >
    179             <property name="orientation" >
     177          <item row="0" column="3">
     178           <spacer name="horizontalSpacer">
     179            <property name="orientation">
    180180             <enum>Qt::Horizontal</enum>
    181181            </property>
    182             <property name="sizeHint" stdset="0" >
     182            <property name="sizeHint" stdset="0">
    183183             <size>
    184184              <width>91</width>
     
    188188           </spacer>
    189189          </item>
    190           <item row="1" column="0" colspan="2" >
    191            <widget class="QCheckBox" name="collate" >
    192             <property name="text" >
     190          <item row="1" column="0" colspan="2">
     191           <widget class="QCheckBox" name="collate">
     192            <property name="text">
    193193             <string>Collate</string>
    194194            </property>
    195195           </widget>
    196196          </item>
    197           <item rowspan="2" row="1" column="2" colspan="2" >
    198            <widget class="QLabel" name="outputIcon" >
    199             <property name="sizePolicy" >
    200              <sizepolicy vsizetype="Ignored" hsizetype="Ignored" >
     197          <item row="1" column="2" rowspan="2" colspan="2">
     198           <widget class="QLabel" name="outputIcon">
     199            <property name="sizePolicy">
     200             <sizepolicy hsizetype="Ignored" vsizetype="Ignored">
    201201              <horstretch>0</horstretch>
    202202              <verstretch>0</verstretch>
     
    205205           </widget>
    206206          </item>
    207           <item row="2" column="0" colspan="2" >
    208            <widget class="QCheckBox" name="reverse" >
    209             <property name="text" >
     207          <item row="2" column="0" colspan="2">
     208           <widget class="QCheckBox" name="reverse">
     209            <property name="text">
    210210             <string>Reverse</string>
    211211            </property>
    212212           </widget>
    213213          </item>
    214           <item row="3" column="0" colspan="4" >
    215            <spacer name="verticalSpacer_2" >
    216             <property name="orientation" >
     214          <item row="3" column="0" colspan="4">
     215           <spacer name="verticalSpacer_2">
     216            <property name="orientation">
    217217             <enum>Qt::Vertical</enum>
    218218            </property>
    219             <property name="sizeHint" stdset="0" >
     219            <property name="sizeHint" stdset="0">
    220220             <size>
    221221              <width>0</width>
     
    230230      </layout>
    231231     </widget>
    232      <widget class="QWidget" name="optionsTab" >
    233       <property name="geometry" >
    234        <rect>
    235         <x>0</x>
    236         <y>0</y>
    237         <width>412</width>
    238         <height>139</height>
    239        </rect>
    240       </property>
    241       <attribute name="title" >
     232     <widget class="QWidget" name="optionsTab">
     233      <attribute name="title">
    242234       <string>Options</string>
    243235      </attribute>
    244       <layout class="QGridLayout" name="gridLayout_2" >
    245        <item row="0" column="1" >
    246         <widget class="QGroupBox" name="colorMode" >
    247          <property name="title" >
     236      <layout class="QGridLayout" name="gridLayout_2">
     237       <item row="0" column="1">
     238        <widget class="QGroupBox" name="colorMode">
     239         <property name="title">
    248240          <string>Color Mode</string>
    249241         </property>
    250          <layout class="QGridLayout" name="gridLayout_4" >
    251           <item row="2" column="0" >
    252            <spacer name="verticalSpacer_6" >
    253             <property name="orientation" >
     242         <layout class="QGridLayout" name="gridLayout_4">
     243          <item row="2" column="0">
     244           <spacer name="verticalSpacer_6">
     245            <property name="orientation">
    254246             <enum>Qt::Vertical</enum>
    255247            </property>
    256             <property name="sizeHint" stdset="0" >
     248            <property name="sizeHint" stdset="0">
    257249             <size>
    258250              <width>1</width>
     
    262254           </spacer>
    263255          </item>
    264           <item row="0" column="0" >
    265            <widget class="QRadioButton" name="color" >
    266             <property name="text" >
     256          <item row="0" column="0">
     257           <widget class="QRadioButton" name="color">
     258            <property name="text">
    267259             <string>Color</string>
    268260            </property>
    269261           </widget>
    270262          </item>
    271           <item rowspan="3" row="0" column="1" >
    272            <widget class="QLabel" name="colorIcon" />
    273           </item>
    274           <item row="1" column="0" >
    275            <widget class="QRadioButton" name="grayscale" >
    276             <property name="text" >
     263          <item row="0" column="1" rowspan="3">
     264           <widget class="QLabel" name="colorIcon"/>
     265          </item>
     266          <item row="1" column="0">
     267           <widget class="QRadioButton" name="grayscale">
     268            <property name="text">
    277269             <string>Grayscale</string>
    278270            </property>
     
    282274        </widget>
    283275       </item>
    284        <item row="0" column="0" >
    285         <widget class="QGroupBox" name="duplex" >
    286          <property name="title" >
     276       <item row="0" column="0">
     277        <widget class="QGroupBox" name="duplex">
     278         <property name="title">
    287279          <string>Duplex Printing</string>
    288280         </property>
    289          <layout class="QVBoxLayout" name="verticalLayout" >
    290           <item>
    291            <widget class="QRadioButton" name="noDuplex" >
    292             <property name="text" >
     281         <layout class="QVBoxLayout" name="verticalLayout">
     282          <item>
     283           <widget class="QRadioButton" name="noDuplex">
     284            <property name="text">
    293285             <string>None</string>
    294286            </property>
    295             <property name="checked" >
     287            <property name="checked">
    296288             <bool>true</bool>
    297289            </property>
     
    299291          </item>
    300292          <item>
    301            <widget class="QRadioButton" name="duplexLong" >
    302             <property name="text" >
     293           <widget class="QRadioButton" name="duplexLong">
     294            <property name="text">
    303295             <string>Long side</string>
    304296            </property>
     
    306298          </item>
    307299          <item>
    308            <widget class="QRadioButton" name="duplexShort" >
    309             <property name="text" >
     300           <widget class="QRadioButton" name="duplexShort">
     301            <property name="text">
    310302             <string>Short side</string>
    311303            </property>
     
    313305          </item>
    314306          <item>
    315            <spacer name="verticalSpacer_42" >
    316             <property name="orientation" >
     307           <spacer name="verticalSpacer_42">
     308            <property name="orientation">
    317309             <enum>Qt::Vertical</enum>
    318310            </property>
    319             <property name="sizeHint" stdset="0" >
     311            <property name="sizeHint" stdset="0">
    320312             <size>
    321313              <width>1</width>
     
    342334   <slot>setEnabled(bool)</slot>
    343335   <hints>
    344     <hint type="sourcelabel" >
     336    <hint type="sourcelabel">
    345337     <x>76</x>
    346338     <y>59</y>
    347339    </hint>
    348     <hint type="destinationlabel" >
     340    <hint type="destinationlabel">
    349341     <x>122</x>
    350342     <y>57</y>
     
    358350   <slot>setEnabled(bool)</slot>
    359351   <hints>
    360     <hint type="sourcelabel" >
     352    <hint type="sourcelabel">
    361353     <x>69</x>
    362354     <y>67</y>
    363355    </hint>
    364     <hint type="destinationlabel" >
     356    <hint type="destinationlabel">
    365357     <x>215</x>
    366358     <y>67</y>
  • trunk/src/gui/dialogs/qprogressdialog.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 "qpainter.h"
    4848#include "qdrawutil.h"
    49 #include "qdatetime.h"
    5049#include "qlabel.h"
    5150#include "qprogressbar.h"
     
    5554#include "qcursor.h"
    5655#include "qtimer.h"
     56#include "qelapsedtimer.h"
    5757#include <private/qdialog_p.h>
    5858#include <limits.h>
     
    104104    bool shown_once;
    105105    bool cancellation_flag;
    106     QTime starttime;
     106    QElapsedTimer starttime;
    107107#ifndef QT_NO_CURSOR
    108108    QCursor parentCursor;
     
    154154        bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, 0, q));
    155155
     156    int additionalSpacing = 0;
     157#ifdef Q_OS_SYMBIAN
     158    //In Symbian, we need to have wider margins for dialog borders, as the actual border is some pixels
     159    //inside the dialog area (to enable transparent borders)
     160    additionalSpacing = mlr;
     161#endif
     162
    156163    QSize cs = cancel ? cancel->sizeHint() : QSize(0,0);
    157164    QSize bh = bar->sizeHint();
     
    186193
    187194    if (label)
    188         label->setGeometry(mlr, 0, q->width()-mlr*2, lh);
    189     bar->setGeometry(mlr, lh+sp, q->width()-mlr*2, bh.height());
     195        label->setGeometry(mlr, additionalSpacing, q->width() - mlr * 2, lh);
     196    bar->setGeometry(mlr, lh + sp + additionalSpacing, q->width() - mlr * 2, bh.height());
    190197}
    191198
  • trunk/src/gui/dialogs/qprogressdialog.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/dialogs/qsidebar.cpp

    r766 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/dialogs/qsidebar_p.h

    r765 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/dialogs/qwizard.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)
     
    219219      topLevelMarginBottom(-1), childMarginLeft(-1), childMarginRight(-1),
    220220      childMarginTop(-1), childMarginBottom(-1), hspacing(-1), vspacing(-1),
    221           wizStyle(QWizard::ClassicStyle), header(false), watermark(false), title(false),
    222           subTitle(false), extension(false) {}
     221      wizStyle(QWizard::ClassicStyle), header(false), watermark(false), title(false),
     222      subTitle(false), extension(false), sideWidget(false) {}
    223223
    224224    int topLevelMarginLeft;
     
    239239    bool subTitle;
    240240    bool extension;
     241    bool sideWidget;
    241242
    242243    bool operator==(const QWizardLayoutInfo &other);
     
    262263           && title == other.title
    263264           && subTitle == other.subTitle
    264            && extension == other.extension;
     265           && extension == other.extension
     266           && sideWidget == other.sideWidget;
    265267}
    266268
     
    426428};
    427429
     430class QWatermarkLabel : public QLabel
     431{
     432public:
     433    QWatermarkLabel(QWidget *parent, QWidget *sideWidget) : QLabel(parent), m_sideWidget(sideWidget) {
     434        m_layout = new QVBoxLayout(this);
     435        if (m_sideWidget)
     436            m_layout->addWidget(m_sideWidget);
     437    }
     438
     439    QSize minimumSizeHint() const {
     440        if (!pixmap() && !pixmap()->isNull())
     441            return pixmap()->size();
     442        return QFrame::minimumSizeHint();
     443    }
     444
     445    void setSideWidget(QWidget *widget) {
     446        if (m_sideWidget == widget)
     447            return;
     448        if (m_sideWidget) {
     449            m_layout->removeWidget(m_sideWidget);
     450            m_sideWidget->hide();
     451        }
     452        m_sideWidget = widget;
     453        if (m_sideWidget)
     454            m_layout->addWidget(m_sideWidget);
     455    }
     456    QWidget *sideWidget() const {
     457        return m_sideWidget;
     458    }
     459private:
     460    QVBoxLayout *m_layout;
     461    QWidget *m_sideWidget;
     462};
     463
    428464class QWizardPagePrivate : public QWidgetPrivate
    429465{
     
    502538    inline QWizardPrivate()
    503539        : start(-1)
     540        , startSetByUser(false)
    504541        , current(-1)
    505542        , canContinue(false)
     
    514551        , headerWidget(0)
    515552        , watermarkLabel(0)
     553        , sideWidget(0)
    516554        , titleLabel(0)
    517555        , subTitleLabel(0)
     
    582620    QSet<int> initialized; // ### remove and move bit to QWizardPage?
    583621    int start;
     622    bool startSetByUser;
    584623    int current;
    585624    bool canContinue;
     
    613652    QWidget *placeholderWidget2;
    614653    QWizardHeader *headerWidget;
    615     QLabel *watermarkLabel;
     654    QWatermarkLabel *watermarkLabel;
     655    QWidget *sideWidget;
    616656    QFrame *pageFrame;
    617657    QLabel *titleLabel;
     
    908948    info.header = (info.wizStyle == QWizard::ClassicStyle || info.wizStyle == QWizard::ModernStyle)
    909949        && !(opts & QWizard::IgnoreSubTitles) && !subTitleText.isEmpty();
     950    info.sideWidget = sideWidget;
    910951    info.watermark = (info.wizStyle != QWizard::MacStyle) && (info.wizStyle != QWizard::AeroStyle)
    911952        && !watermarkPixmap.isNull();
    912953    info.title = !info.header && !titleText.isEmpty();
    913954    info.subTitle = !(opts & QWizard::IgnoreSubTitles) && !info.header && !subTitleText.isEmpty();
    914     info.extension = info.watermark && (opts & QWizard::ExtendedWatermarkPixmap);
     955    info.extension = (info.watermark || info.sideWidget) && (opts & QWizard::ExtendedWatermarkPixmap);
    915956
    916957    return info;
     
    955996    if (mac) {
    956997        numColumns = 3;
    957     } else if (info.watermark) {
     998    } else if (info.watermark || info.sideWidget) {
    958999        numColumns = 2;
    9591000    } else {
     
    10971138    }
    10981139
    1099     if (info.watermark && !watermarkLabel) {
    1100         watermarkLabel = new QLabel(antiFlickerWidget);
     1140    if ((info.watermark || info.sideWidget) && !watermarkLabel) {
     1141        watermarkLabel = new QWatermarkLabel(antiFlickerWidget, sideWidget);
    11011142        watermarkLabel->setBackgroundRole(QPalette::Base);
    11021143        watermarkLabel->setMinimumHeight(1);
     
    11741215    mainLayout->addLayout(buttonLayout, row++, buttonStartColumn, 1, buttonNumColumns);
    11751216
    1176     if (info.watermark) {
     1217    if (info.watermark || info.sideWidget) {
    11771218        if (info.extension)
    11781219            watermarkEndRow = row;
     
    11941235        bottomRuler->setVisible(classic || modern);
    11951236    if (watermarkLabel)
    1196         watermarkLabel->setVisible(info.watermark);
     1237        watermarkLabel->setVisible(info.watermark || info.sideWidget);
    11971238
    11981239    layoutInfo = info;
     
    12341275    }
    12351276
    1236     if (info.watermark) {
    1237         Q_ASSERT(page);
    1238         watermarkLabel->setPixmap(page->pixmap(QWizard::WatermarkPixmap));
    1239     }
     1277    if (info.watermark || info.sideWidget) {
     1278        QPixmap pix;
     1279        if (info.watermark) {
     1280            if (page)
     1281                pix = page->pixmap(QWizard::WatermarkPixmap);
     1282            else
     1283                pix = q->pixmap(QWizard::WatermarkPixmap);
     1284        }
     1285        watermarkLabel->setPixmap(pix); // in case there is no watermark and we show the side widget we need to clear the watermark
     1286    }
     1287
    12401288    if (info.title) {
    12411289        Q_ASSERT(page);
     
    12681316        maximumSize.setWidth(headerWidget->maximumWidth());
    12691317    }
    1270     if (info.watermark) {
     1318    if (info.watermark && !info.sideWidget) {
    12711319        minimumSize.setHeight(mainLayout->totalSizeHint().height());
    12721320        maximumSize.setHeight(mainLayout->totalSizeHint().height());
     
    21502198    QWizard so far.
    21512199
    2152     \sa setPage(), page()
     2200    \sa setPage(), page(), pageAdded()
    21532201*/
    21542202int QWizard::addPage(QWizardPage *page)
     
    21672215    Adds the given \a page to the wizard with the given \a id.
    21682216
    2169     \sa addPage(), page()
     2217    \note Adding a page may influence the value of the startId property
     2218    in case it was not set explicitly.
     2219
     2220    \sa addPage(), page(), pageAdded()
    21702221*/
    21712222void QWizard::setPage(int theid, QWizardPage *page)
     
    22112262    page->hide();
    22122263    d->pageVBoxLayout->setEnabled(pageVBoxLayoutEnabled);
     2264
     2265    if (!d->startSetByUser && d->pageMap.constBegin().key() == theid)
     2266        d->start = theid;
     2267    emit pageAdded(theid);
    22132268}
    22142269
    22152270/*!
    22162271    Removes the page with the given \a id. cleanupPage() will be called if necessary.
     2272
     2273    \note Removing a page may influence the value of the startId property.
     2274
    22172275    \since 4.5
    2218     \sa addPage(), setPage()
     2276    \sa addPage(), setPage(), pageRemoved(), startId()
    22192277*/
    22202278void QWizard::removePage(int id)
     
    22242282    QWizardPage *removedPage = 0;
    22252283
    2226     if (d->start == id)
    2227         d->start = -1;
     2284    // update startItem accordingly
     2285    if (d->pageMap.count() > 0) { // only if we have any pages
     2286        if (d->start == id) {
     2287            const int firstId = d->pageMap.constBegin().key();
     2288            if (firstId == id) {
     2289                if (d->pageMap.count() > 1)
     2290                    d->start = (++d->pageMap.constBegin()).key(); // secondId
     2291                else
     2292                    d->start = -1; // removing the last page
     2293            } else { // startSetByUser has to be "true" here
     2294                d->start = firstId;
     2295            }
     2296            d->startSetByUser = false;
     2297        }
     2298    }
     2299
     2300    if (d->pageMap.contains(id))
     2301        emit pageRemoved(id);
    22282302
    22292303    if (!d->history.contains(id)) {
     
    23352409{
    23362410    Q_D(QWizard);
    2337     if (!d->pageMap.contains(theid)) {
    2338         qWarning("QWizard::setStartId: Invalid page ID %d", theid);
     2411    int newStart = theid;
     2412    if (theid == -1)
     2413        newStart = d->pageMap.count() ? d->pageMap.constBegin().key() : -1;
     2414
     2415    if (d->start == newStart) {
     2416        d->startSetByUser = theid != -1;
    23392417        return;
    23402418    }
    2341     d->start = theid;
     2419
     2420    if (!d->pageMap.contains(newStart)) {
     2421        qWarning("QWizard::setStartId: Invalid page ID %d", newStart);
     2422        return;
     2423    }
     2424    d->start = newStart;
     2425    d->startSetByUser = theid != -1;
    23422426}
    23432427
     
    23452429{
    23462430    Q_D(const QWizard);
    2347     if (d->start != -1)
    2348         return d->start;
    2349     if (!d->pageMap.isEmpty())
    2350         return d->pageMap.constBegin().key();
    2351     return -1;
     2431    return d->start;
    23522432}
    23532433
     
    28262906
    28272907/*!
     2908    \since 4.7
     2909
     2910    Sets the given \a widget to be shown on the left side of the wizard.
     2911    For styles which use the WatermarkPixmap (ClassicStyle and ModernStyle)
     2912    the side widget is displayed on top of the watermark, for other styles
     2913    or when the watermark is not provided the side widget is displayed
     2914    on the left side of the wizard.
     2915
     2916    Passing 0 shows no side widget.
     2917
     2918    When the \a widget is not 0 the wizard reparents it.
     2919
     2920    Any previous side widget is hidden.
     2921
     2922    You may call setSideWidget() with the same widget at different
     2923    times.
     2924
     2925    All widgets set here will be deleted by the wizard when it is
     2926    destroyed unless you separately reparent the widget after setting
     2927    some other side widget (or 0).
     2928
     2929    By default, no side widget is present.
     2930*/
     2931void QWizard::setSideWidget(QWidget *widget)
     2932{
     2933    Q_D(QWizard);
     2934
     2935    d->sideWidget = widget;
     2936    if (d->watermarkLabel) {
     2937        d->watermarkLabel->setSideWidget(widget);
     2938        d->updateLayout();
     2939    }
     2940}
     2941
     2942/*!
     2943    \since 4.7
     2944
     2945    Returns the widget on the left side of the wizard or 0.
     2946
     2947    By default, no side widget is present.
     2948*/
     2949QWidget *QWizard::sideWidget() const
     2950{
     2951    Q_D(const QWizard);
     2952
     2953    return d->sideWidget;
     2954}
     2955
     2956/*!
    28282957    \reimp
    28292958*/
     
    28763005
    28773006    \sa currentId(), currentPage()
     3007*/
     3008
     3009/*!
     3010    \fn void QWizard::pageAdded(int id)
     3011
     3012    \since 4.7
     3013
     3014    This signal is emitted whenever a page is added to the
     3015    wizard. The page's \a id is passed as parameter.
     3016
     3017    \sa addPage(), setPage(), startId()
     3018*/
     3019
     3020/*!
     3021    \fn void QWizard::pageRemoved(int id)
     3022
     3023    \since 4.7
     3024
     3025    This signal is emitted whenever a page is removed from the
     3026    wizard. The page's \a id is passed as parameter.
     3027
     3028    \sa removePage(), startId()
    28783029*/
    28793030
  • trunk/src/gui/dialogs/qwizard.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)
     
    166166    QPixmap pixmap(WizardPixmap which) const;
    167167
     168    void setSideWidget(QWidget *widget);
     169    QWidget *sideWidget() const;
     170
    168171    void setDefaultProperty(const char *className, const char *property,
    169172                            const char *changedSignal);
     
    176179    void helpRequested();
    177180    void customButtonClicked(int which);
     181    void pageAdded(int id);
     182    void pageRemoved(int id);
    178183
    179184public Q_SLOTS:
  • trunk/src/gui/dialogs/qwizard_win.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)
     
    4444
    4545#include "qwizard_win_p.h"
    46 #include "qlibrary.h"
     46#include <private/qsystemlibrary_p.h>
    4747#include "qwizard.h"
    4848#include "qpaintengine.h"
     
    181181{
    182182    ensurePolished();
    183     int width = 32, height = 32;
     183    int size = int(QStyleHelper::dpiScaled(32));
     184    int width = size, height = size;
    184185/*
    185186    HANDLE theme = pOpenThemeData(0, L"Navigation");
     
    214215    //RECT rect;
    215216    RECT clipRect;
    216     int xoffset = QWidget::mapToParent(r.topLeft()).x();
    217     int yoffset = QWidget::mapToParent(r.topLeft()).y();
     217    int xoffset = QWidget::mapToParent(r.topLeft()).x() - 1;
     218    int yoffset = QWidget::mapToParent(r.topLeft()).y() - 1;
    218219
    219220    clipRect.top = r.top() + yoffset;
     
    238239
    239240QVistaHelper::QVistaHelper(QWizard *wizard)
    240     : pressed(false)
     241    : QObject(wizard)
     242    , pressed(false)
    241243    , wizard(wizard)
    242244    , backButton_(0)
     
    245247    if (is_vista)
    246248        backButton_ = new QVistaBackButton(wizard);
     249
     250    // Handle diff between Windows 7 and Vista
     251    iconSpacing = QStyleHelper::dpiScaled(7);
     252    textSpacing = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ?
     253                  iconSpacing : QStyleHelper::dpiScaled(20);
    247254}
    248255
     
    308315void QVistaHelper::drawTitleBar(QPainter *painter)
    309316{
     317    HDC hdc = painter->paintEngine()->getDC();
     318
    310319    if (vistaState() == VistaAero)
    311         drawBlackRect(
    312             QRect(0, 0, wizard->width(), titleBarSize() + topOffset()),
    313             painter->paintEngine()->getDC());
    314 
     320        drawBlackRect(QRect(0, 0, wizard->width(),
     321                            titleBarSize() + topOffset()), hdc);
    315322    Q_ASSERT(backButton_);
    316323    const int btnTop = backButton_->mapToParent(QPoint()).y();
    317324    const int btnHeight = backButton_->size().height();
    318     const int verticalCenter = (btnTop + btnHeight / 2);
    319 
    320     wizard->windowIcon().paint(
    321         painter, QRect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize()));
     325    const int verticalCenter = (btnTop + btnHeight / 2) - 1;
    322326
    323327    const QString text = wizard->window()->windowTitle();
     
    327331    int textHeight = brect.height();
    328332    int textWidth = brect.width();
     333    int glowOffset = 0;
     334
    329335    if (vistaState() == VistaAero) {
    330336        textHeight += 2 * glowSize();
    331337        textWidth += 2 * glowSize();
    332     }
     338        glowOffset = glowSize();
     339    }
     340
    333341    drawTitleText(
    334342        painter, text,
    335         QRect(titleOffset(), verticalCenter - textHeight / 2, textWidth, textHeight),
    336         painter->paintEngine()->getDC());
     343        QRect(titleOffset() - glowOffset, verticalCenter - textHeight / 2, textWidth, textHeight),
     344        hdc);
     345
     346    if (!wizard->windowIcon().isNull()) {
     347        QRect rect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize());
     348        HICON hIcon = wizard->windowIcon().pixmap(iconSize()).toWinHICON();
     349        DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT);
     350        DestroyIcon(hIcon);
     351    }
    337352}
    338353
     
    692707    if (!tried) {
    693708        tried = true;
    694         QLibrary dwmLib(QString::fromAscii("dwmapi"));
     709        QSystemLibrary dwmLib(L"dwmapi");
    695710        pDwmIsCompositionEnabled =
    696711            (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
     
    700715                (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
    701716        }
    702         QLibrary themeLib(QString::fromAscii("uxtheme"));
     717        QSystemLibrary themeLib(L"uxtheme");
    703718        pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
    704719        if (pIsAppThemed) {
     
    734749int QVistaHelper::titleOffset()
    735750{
    736     int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + padding();
     751    int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + textSpacing;
    737752    return leftMargin() + iconOffset;
    738753}
  • trunk/src/gui/dialogs/qwizard_win_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#include <qabstractbutton.h>
    6363#include <QtGui/private/qwidget_p.h>
     64#include <QtGui/private/qstylehelper_p.h>
    6465
    6566QT_BEGIN_NAMESPACE
     
    8384class QVistaHelper : public QObject
    8485{
    85     Q_OBJECT
    8686public:
    8787    QVistaHelper(QWizard *wizard);
     
    102102    static VistaState vistaState();
    103103    static int titleBarSize() { return frameSize() + captionSize(); }
    104     static int topPadding() { return 8; }
    105     static int topOffset() { return titleBarSize() + (vistaState() == VistaAero ? 13 : 3); }
    106 
     104    static int topPadding() { // padding under text
     105        return int(QStyleHelper::dpiScaled(
     106                QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? 4 : 6));
     107    }
     108    static int topOffset() {
     109        static int aeroOffset = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ?
     110                                QStyleHelper::dpiScaled(4) : QStyleHelper::dpiScaled(13);
     111        return (titleBarSize() + (vistaState() == VistaAero ? aeroOffset : 3)); }
    107112private:
    108113    static HFONT getCaptionFont(HANDLE hTheme);
     
    113118    static int captionSize() { return GetSystemMetrics(SM_CYCAPTION); }
    114119
    115     static int backButtonSize() { return 31; } // ### should be queried from back button itself
     120    static int backButtonSize() { return int(QStyleHelper::dpiScaled(30)); }
    116121    static int iconSize() { return 16; } // Standard Aero
    117     static int padding() { return 7; } // Standard Aero
    118     static int leftMargin() { return backButtonSize() + padding(); }
    119122    static int glowSize() { return 10; }
     123    int leftMargin() { return backButton_->isVisible() ? backButtonSize() + iconSpacing : 0; }
    120124
    121125    int titleOffset();
     
    141145    QWizard *wizard;
    142146    QVistaBackButton *backButton_;
     147
     148    int titleBarOffset;  // Extra spacing above the text
     149    int iconSpacing;    // Space between button and icon
     150    int textSpacing;    // Space between icon and text
    143151};
    144152
Note: See TracChangeset for help on using the changeset viewer.