Changeset 561 for trunk/src/gui/dialogs


Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
58 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk

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

    r2 r561  
    88        dialogs/qcolordialog.h \
    99        dialogs/qcolordialog_p.h \
     10        dialogs/qfscompleter_p.h \
    1011        dialogs/qdialog.h \
    1112        dialogs/qdialog_p.h \
     
    2829
    2930!embedded:mac {
    30     OBJECTIVE_SOURCES += dialogs/qcolordialog_mac.mm \
    31                          dialogs/qfiledialog_mac.mm \
     31    OBJECTIVE_SOURCES += dialogs/qfiledialog_mac.mm \
    3232                         dialogs/qfontdialog_mac.mm \
    3333                         dialogs/qnspanelproxy_mac.mm \
    3434                         dialogs/qpagesetupdialog_mac.mm \
    3535                         dialogs/qprintdialog_mac.mm
     36
     37# Compile qcolordialog_mac.mm with exception support, disregarding the -no-exceptions
     38# configure option. (qcolordialog_mac needs to catch exceptions thrown by cocoa)
     39    EXCEPTION_SOURCES = dialogs/qcolordialog_mac.mm
     40    exceptions_compiler.commands = $$QMAKE_CXX -c
     41    exceptions_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
     42    exceptions_compiler.commands += -fexceptions
     43    exceptions_compiler.dependency_type = TYPE_C
     44    exceptions_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
     45    exceptions_compiler.input = EXCEPTION_SOURCES
     46    exceptions_compiler.variable_out = OBJECTS
     47    exceptions_compiler.name = compiling[exceptopns] ${QMAKE_FILE_IN}
     48    silent:exceptions_compiler.commands = @echo compiling[exceptopns] ${QMAKE_FILE_IN} && $$exceptions_compiler.commands
     49    QMAKE_EXTRA_COMPILERS += exceptions_compiler
    3650}
     51
    3752win32 {
    3853    HEADERS += dialogs/qwizard_win_p.h
     
    4661}
    4762
    48 !mac:!embedded:unix {
     63!mac:!embedded:!symbian:unix {
    4964        HEADERS += dialogs/qpagesetupdialog_unix_p.h
    5065        SOURCES += dialogs/qprintdialog_unix.cpp \
     
    7186}
    7287
    73 wince*: FORMS += dialogs/qfiledialog_wince.ui
     88wince*|symbian: FORMS += dialogs/qfiledialog_embedded.ui
    7489else: FORMS += dialogs/qfiledialog.ui
    7590
  • trunk/src/gui/dialogs/qabstractpagesetupdialog.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qabstractpagesetupdialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qabstractpagesetupdialog_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qabstractprintdialog.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5959    \brief The QAbstractPrintDialog class provides a base implementation for
    6060    print dialogs used to configure printers.
     61
     62    \ingroup printing
    6163
    6264    This class implements getter and setter functions that are used to
     
    358360    the printer's configuration.
    359361
    360     \ingroup dialogs
     362    \ingroup standard-dialogs
     363    \ingroup printing
    361364
    362365    The dialog allows users to change document-related settings, such
     
    396399    On Windows and Mac OS X, the native print dialog is used, which means that
    397400    some QWidget and QDialog properties set on the dialog won't be respected.
    398     The native print dialog on
    399     Mac OS X does not support setting printer options, i.e.
    400     QAbstractPrintDialog::setEnabledOptions() and
    401     QAbstractPrintDialog::addEnabledOption() have no effect.
    402 
    403     In Qt 4.4, it was possible to use the satic functions to show a sheet on
     401    The native print dialog on Mac OS X does not support setting printer options,
     402    i.e. setOptions() and setOption() have no effect.
     403
     404    In Qt 4.4, it was possible to use the static functions to show a sheet on
    404405    Mac OS X. This is no longer supported in Qt 4.5. If you want this
    405406    functionality, use QPrintDialog::open().
  • trunk/src/gui/dialogs/qabstractprintdialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qabstractprintdialog_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qcolordialog.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6363#include "qspinbox.h"
    6464#include "qdialogbuttonbox.h"
     65#include "private/qguiplatformplugin_p.h"
     66
     67#ifdef Q_WS_S60
     68#include "private/qt_s60_p.h"
     69#endif
    6570
    6671QT_BEGIN_NAMESPACE
     
    10671072    gl->setMargin(gl->spacing());
    10681073    lab = new QColorShowLabel(this);
    1069 #ifndef Q_OS_WINCE
     1074
     1075#ifdef Q_WS_S60
     1076    QS60Data s60Data = QS60Data();
     1077    const bool nonTouchUI = !s60Data.hasTouchscreen;
     1078#endif
     1079
     1080
     1081#ifndef Q_WS_WINCE
     1082#ifdef Q_WS_S60
     1083    lab->setMinimumHeight(60);
     1084#endif
    10701085    lab->setMinimumWidth(60);
    10711086#else
    10721087    lab->setMinimumWidth(20);
    10731088#endif
     1089
     1090// In S60, due to small screen and different screen layouts need to re-arrange the widgets.
     1091// For QVGA screens only the comboboxes and color label are visible.
     1092// For nHD screens only color and luminence pickers and color label are visible.
     1093#ifndef Q_WS_S60
    10741094    gl->addWidget(lab, 0, 0, -1, 1);
     1095#else
     1096    if (nonTouchUI)
     1097        gl->addWidget(lab, 0, 0, 1, -1);
     1098    else
     1099        gl->addWidget(lab, 0, 0, -1, 1);
     1100#endif
    10751101    connect(lab, SIGNAL(colorDropped(QRgb)), this, SIGNAL(newCol(QRgb)));
    10761102    connect(lab, SIGNAL(colorDropped(QRgb)), this, SLOT(setRgb(QRgb)));
     
    10831109#endif
    10841110    lblHue->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
     1111#ifndef Q_WS_S60
    10851112    gl->addWidget(lblHue, 0, 1);
    10861113    gl->addWidget(hEd, 0, 2);
     1114#else
     1115    if (nonTouchUI) {
     1116        gl->addWidget(lblHue, 1, 0);
     1117        gl->addWidget(hEd, 2, 0);
     1118    } else {
     1119        lblHue->hide();
     1120        hEd->hide();
     1121    }
     1122#endif
    10871123
    10881124    sEd = new QColSpinBox(this);
     
    10921128#endif
    10931129    lblSat->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
     1130#ifndef Q_WS_S60
    10941131    gl->addWidget(lblSat, 1, 1);
    10951132    gl->addWidget(sEd, 1, 2);
     1133#else
     1134    if (nonTouchUI) {
     1135        gl->addWidget(lblSat, 1, 1);
     1136        gl->addWidget(sEd, 2, 1);
     1137    } else {
     1138        lblSat->hide();
     1139        sEd->hide();
     1140    }
     1141#endif
    10961142
    10971143    vEd = new QColSpinBox(this);
     
    11011147#endif
    11021148    lblVal->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
     1149#ifndef Q_WS_S60
    11031150    gl->addWidget(lblVal, 2, 1);
    11041151    gl->addWidget(vEd, 2, 2);
     1152#else
     1153    if (nonTouchUI) {
     1154        gl->addWidget(lblVal, 1, 2);
     1155        gl->addWidget(vEd, 2, 2);
     1156    } else {
     1157        lblVal->hide();
     1158        vEd->hide();
     1159    }
     1160#endif
    11051161
    11061162    rEd = new QColSpinBox(this);
     
    11101166#endif
    11111167    lblRed->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
     1168#ifndef Q_WS_S60
    11121169    gl->addWidget(lblRed, 0, 3);
    11131170    gl->addWidget(rEd, 0, 4);
     1171#else
     1172    if (nonTouchUI) {
     1173        gl->addWidget(lblRed, 3, 0);
     1174        gl->addWidget(rEd, 4, 0);
     1175    } else {
     1176        lblRed->hide();
     1177        rEd->hide();
     1178    }
     1179#endif
    11141180
    11151181    gEd = new QColSpinBox(this);
     
    11191185#endif
    11201186    lblGreen->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
     1187#ifndef Q_WS_S60
    11211188    gl->addWidget(lblGreen, 1, 3);
    11221189    gl->addWidget(gEd, 1, 4);
     1190#else
     1191    if (nonTouchUI) {
     1192        gl->addWidget(lblGreen, 3, 1);
     1193        gl->addWidget(gEd, 4, 1);
     1194    } else {
     1195        lblGreen->hide();
     1196        gEd->hide();
     1197    }
     1198#endif
    11231199
    11241200    bEd = new QColSpinBox(this);
     
    11281204#endif
    11291205    lblBlue->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
     1206#ifndef Q_WS_S60
    11301207    gl->addWidget(lblBlue, 2, 3);
    11311208    gl->addWidget(bEd, 2, 4);
     1209#else
     1210    if (nonTouchUI) {
     1211        gl->addWidget(lblBlue, 3, 2);
     1212        gl->addWidget(bEd, 4, 2);
     1213    } else {
     1214        lblBlue->hide();
     1215        bEd->hide();
     1216    }
     1217#endif
    11321218
    11331219    alphaEd = new QColSpinBox(this);
     
    11371223#endif
    11381224    alphaLab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
     1225#ifndef Q_WS_S60
    11391226    gl->addWidget(alphaLab, 3, 1, 1, 3);
    11401227    gl->addWidget(alphaEd, 3, 4);
     1228#else
     1229    if (nonTouchUI) {
     1230        gl->addWidget(alphaLab, 1, 3, 3, 1);
     1231        gl->addWidget(alphaEd, 4, 3);
     1232    } else {
     1233        alphaLab->hide();
     1234        alphaEd->hide();
     1235    }
     1236#endif
    11411237    alphaEd->hide();
    11421238    alphaLab->hide();
     
    12631359{
    12641360    QColor oldQColor(curQColor);
    1265     curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), qAlpha(curCol)));
     1361    curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), currentAlpha()));
    12661362    if (curQColor != oldQColor)
    12671363        emit currentColorChanged(curQColor);
     
    13601456    q->setWindowTitle(QColorDialog::tr("Select Color"));
    13611457
     1458    nativeDialogInUse = false;
     1459
    13621460    nextCust = 0;
    13631461    QVBoxLayout *mainLay = new QVBoxLayout(q);
     
    13701468    leftLay = 0;
    13711469
    1372 #if defined(Q_OS_WINCE)
     1470#if (defined(Q_WS_WINCE) || defined(Q_WS_S60))
    13731471    smallDisplay = true;
    13741472    const int lumSpace = 20;
     
    13761474    // small displays (e.g. PDAs) cannot fit the full color dialog,
    13771475    // so just use the color picker.
    1378     smallDisplay = (qApp->desktop()->width() < 480 || qApp->desktop()->height() < 350);
     1476    smallDisplay = (QApplication::desktop()->width() < 480 || QApplication::desktop()->height() < 350);
    13791477    const int lumSpace = topLay->spacing() / 2;
    13801478#endif
     
    14001498#endif
    14011499
     1500#if defined(Q_WS_S60)
     1501    QS60Data s60Data = QS60Data();
     1502    const bool nonTouchUI = !s60Data.hasTouchscreen;
     1503#endif
     1504
    14021505    if (!smallDisplay) {
    14031506        standard = new QColorWell(q, 6, 8, stdrgb);
     
    14101513        leftLay->addWidget(standard);
    14111514
    1412 #if !defined(Q_OS_WINCE)
     1515#if !defined(Q_WS_WINCE)
    14131516        leftLay->addStretch();
    14141517#endif
     
    14301533    } else {
    14311534        // better color picker size for small displays
     1535#ifdef Q_WS_S60
     1536        QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
     1537        pWidth = pHeight = qMin(screenSize.width(), screenSize.height());
     1538        pHeight -= 20;
     1539        if(screenSize.height() > screenSize.width())
     1540            pWidth -= 20;
     1541#else
    14321542        pWidth = 150;
    14331543        pHeight = 100;
     1544#endif
    14341545        custom = 0;
    14351546        standard = 0;
     
    14471558
    14481559    cp->setFrameStyle(QFrame::Panel + QFrame::Sunken);
     1560
     1561#if defined(Q_WS_S60)
     1562    if (!nonTouchUI) {
     1563        pickLay->addWidget(cp);
     1564        cLay->addSpacing(lumSpace);
     1565    } else {
     1566        cp->hide();
     1567    }
     1568#else
    14491569    cLay->addSpacing(lumSpace);
    14501570    cLay->addWidget(cp);
     1571#endif
    14511572    cLay->addSpacing(lumSpace);
    14521573
    14531574    lp = new QColorLuminancePicker(q);
     1575#if defined(Q_WS_S60)
     1576    QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
     1577    const int minDimension = qMin(screenSize.height(), screenSize.width());
     1578    //set picker to be finger-usable
     1579    int pickerWidth = !nonTouchUI ? minDimension/9 : minDimension/12;
     1580    lp->setFixedWidth(pickerWidth);
     1581    if (!nonTouchUI)
     1582        pickLay->addWidget(lp);
     1583    else
     1584        lp->hide();
     1585#else
    14541586    lp->setFixedWidth(20);
    14551587    pickLay->addWidget(lp);
     1588#endif
    14561589
    14571590    QObject::connect(cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)));
     
    14621595    cs = new QColorShower(q);
    14631596    QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb)));
    1464     QObject::connect(cs, SIGNAL(currentColorChanged(const QColor&)),
    1465                      q, SIGNAL(currentColorChanged(const QColor&)));
     1597    QObject::connect(cs, SIGNAL(currentColorChanged(QColor)),
     1598                     q, SIGNAL(currentColorChanged(QColor)));
     1599#if defined(Q_WS_S60)
     1600    if (!nonTouchUI)
     1601        pWidth -= cp->size().width();
     1602    topLay->addWidget(cs);
     1603#else
    14661604    rightLay->addWidget(cs);
     1605#endif
    14671606
    14681607    buttons = new QDialogButtonBox(q);
     
    15111650    \brief The QColorDialog class provides a dialog widget for specifying colors.
    15121651
    1513     \mainclass
    1514     \ingroup dialogs
    1515     \ingroup multimedia
     1652    \ingroup standard-dialogs
    15161653
    15171654    The color dialog's function is to allow users to choose colors.
     
    15791716    Q_D(QColorDialog);
    15801717    d->setCurrentColor(color.rgb());
    1581     d->selectColor(color.rgb());
     1718    d->selectColor(color);
    15821719    d->setCurrentAlpha(color.alpha());
    15831720
    15841721#ifdef Q_WS_MAC
    1585     if (d->delegate)
    1586         QColorDialogPrivate::setColor(d->delegate, color);
    1587 #endif
     1722    d->setCurrentQColor(color);
     1723    d->setCocoaPanelColor(color);
     1724#endif
     1725    if (d->nativeDialogInUse)
     1726        qt_guiPlatformPlugin()->colorDialogSetCurrentColor(this, color);
    15881727}
    15891728
     
    17251864#if defined(Q_WS_MAC)
    17261865    if (visible) {
    1727         if (!d->delegate && QColorDialogPrivate::sharedColorPanelAvailable &&
    1728                 !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog))){
    1729             d->delegate = QColorDialogPrivate::openCocoaColorPanel(
    1730                     currentColor(), parentWidget(), windowTitle(), options(), d);
     1866        if (d->delegate || (QColorDialogPrivate::sharedColorPanelAvailable &&
     1867                !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog)))){
     1868            d->openCocoaColorPanel(currentColor(), parentWidget(), windowTitle(), options());
    17311869            QColorDialogPrivate::sharedColorPanelAvailable = false;
    17321870            setAttribute(Qt::WA_DontShowOnScreen);
     
    17351873    } else {
    17361874        if (d->delegate) {
    1737             QColorDialogPrivate::closeCocoaColorPanel(d->delegate);
    1738             d->delegate = 0;
    1739             QColorDialogPrivate::sharedColorPanelAvailable = true;
     1875            d->closeCocoaColorPanel();
    17401876            setAttribute(Qt::WA_DontShowOnScreen, false);
    17411877        }
    17421878    }
     1879#else
     1880
     1881    if (!(d->opts & DontUseNativeDialog) && qt_guiPlatformPlugin()->colorDialogSetVisible(this, visible)) {
     1882        d->nativeDialogInUse = true;
     1883        // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
     1884        // updates the state correctly, but skips showing the non-native version:
     1885        setAttribute(Qt::WA_DontShowOnScreen);
     1886    } else {
     1887        d->nativeDialogInUse = false;
     1888        setAttribute(Qt::WA_DontShowOnScreen, false);
     1889    }
    17431890#endif
    17441891
     
    17501897    \since 4.5
    17511898
    1752     Opens the dialog and connects its accepted() signal to the slot specified
     1899    Opens the dialog and connects its colorSelected() signal to the slot specified
    17531900    by \a receiver and \a member.
    17541901
     
    17581905{
    17591906    Q_D(QColorDialog);
    1760     connect(this, SIGNAL(colorSelected(const QColor&)), receiver, member);
     1907    connect(this, SIGNAL(colorSelected(QColor)), receiver, member);
    17611908    d->receiverToDisconnectOnClose = receiver;
    17621909    d->memberToDisconnectOnClose = member;
     
    18401987QColorDialog::~QColorDialog()
    18411988{
     1989    Q_D(QColorDialog);
     1990#if defined(Q_WS_MAC)
     1991    if (d->delegate) {
     1992        d->releaseCocoaColorPanelDelegate();
     1993        QColorDialogPrivate::sharedColorPanelAvailable = true;
     1994    }
     1995#endif
     1996
    18421997#ifndef QT_NO_SETTINGS
    18431998    if (!customSet) {
     
    18472002    }
    18482003#endif
     2004    if (d->nativeDialogInUse)
     2005        qt_guiPlatformPlugin()->colorDialogDelete(this);
     2006
    18492007}
    18502008
     
    18732031    QDialog::done(result);
    18742032    if (result == Accepted) {
    1875         d->selectedQColor = d->currentQColor(); 
     2033        d->selectedQColor = d->currentQColor();
    18762034        emit colorSelected(d->selectedQColor);
    18772035    } else {
     
    18792037    }
    18802038    if (d->receiverToDisconnectOnClose) {
    1881         disconnect(this, SIGNAL(colorSelected(const QColor&)),
     2039        disconnect(this, SIGNAL(colorSelected(QColor)),
    18822040                   d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
    18832041        d->receiverToDisconnectOnClose = 0;
  • trunk/src/gui/dialogs/qcolordialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qcolordialog_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545#include <qtimer.h>
    4646#include <qdialogbuttonbox.h>
     47#include <qabstracteventdispatcher.h>
    4748#include <private/qapplication_p.h>
    4849#include <private/qt_mac_p.h>
     
    5556#endif
    5657
     58
     59#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
     60@protocol NSWindowDelegate <NSObject>
     61- (void)windowDidResize:(NSNotification *)notification;
     62- (BOOL)windowShouldClose:(id)window;
     63@end
     64#endif
     65
    5766QT_USE_NAMESPACE
    5867
    5968@class QCocoaColorPanelDelegate;
    6069
    61 @interface QCocoaColorPanelDelegate : NSObject {
     70@interface QCocoaColorPanelDelegate : NSObject<NSWindowDelegate> {
    6271    NSColorPanel *mColorPanel;
    6372    NSView *mStolenContentView;
     
    6978    CGFloat mExtraHeight;   // currently unused
    7079    BOOL mHackedPanel;
     80    NSInteger mResultCode;
     81    BOOL mDialogIsExecuting;
     82    BOOL mResultSet;
    7183}
    7284- (id)initWithColorPanel:(NSColorPanel *)panel
     
    7587            cancelButton:(NSButton *)cancelButton
    7688                    priv:(QColorDialogPrivate *)priv;
    77 - (BOOL)windowShouldClose:(id)window;
    78 - (void)windowDidResize:(NSNotification *)notification;
    7989- (void)colorChanged:(NSNotification *)notification;
    8090- (void)relayout;
     
    8595- (QColor)qtColor;
    8696- (void)finishOffWithCode:(NSInteger)result;
    87 - (void)cleanUpAfterMyself;
     97- (void)showColorPanel;
     98- (void)exec;
    8899@end
    89100
     
    105116    mExtraHeight = 0.0;
    106117    mHackedPanel = (okButton != 0);
     118    mResultCode = NSCancelButton;
     119    mDialogIsExecuting = false;
     120    mResultSet = false;
    107121
    108122    if (mHackedPanel) {
     
    116130    }
    117131
    118     if (mPriv)
    119         [[NSNotificationCenter defaultCenter] addObserver:self
    120                                               selector:@selector(colorChanged:)
    121                                               name:NSColorPanelColorDidChangeNotification
    122                                               object:mColorPanel];
     132    [[NSNotificationCenter defaultCenter] addObserver:self
     133        selector:@selector(colorChanged:)
     134        name:NSColorPanelColorDidChangeNotification
     135        object:mColorPanel];
     136
    123137    mQtColor = new QColor();
    124138    return self;
     
    127141- (void)dealloc
    128142{
    129     if (mPriv)
    130         [[NSNotificationCenter defaultCenter] removeObserver:self];
     143    QMacCocoaAutoReleasePool pool;
     144    if (mHackedPanel) {
     145        NSView *ourContentView = [mColorPanel contentView];
     146
     147        // return stolen stuff to its rightful owner
     148        [mStolenContentView removeFromSuperview];
     149        [mColorPanel setContentView:mStolenContentView];
     150
     151        [mOkButton release];
     152        [mCancelButton release];
     153        [ourContentView release];
     154    }
     155    [mColorPanel setDelegate:nil];
     156    [[NSNotificationCenter defaultCenter] removeObserver:self];
    131157    delete mQtColor;
    132158    [super dealloc];
     
    136162{
    137163    Q_UNUSED(window);
    138     if (mHackedPanel) {
    139         [self onCancelClicked];
     164    if (!mHackedPanel)
     165        [self updateQtColor];
     166    if (mDialogIsExecuting) {
     167        [self finishOffWithCode:NSCancelButton];
    140168    } else {
    141         [self updateQtColor];
    142         [self finishOffWithCode:NSCancelButton];
     169        mResultSet = true;
     170        mPriv->colorDialog()->reject();
    143171    }
    144172    return true;
     
    155183{
    156184    Q_UNUSED(notification);
    157     if (mPriv)
    158         [self updateQtColor];
     185    [self updateQtColor];
    159186}
    160187
     
    218245- (void)onCancelClicked
    219246{
    220     Q_ASSERT(mHackedPanel);
    221     [[mStolenContentView window] close];
    222     delete mQtColor;
    223     mQtColor = new QColor();
    224     [self finishOffWithCode:NSCancelButton];
     247    if (mHackedPanel) {
     248        [[mStolenContentView window] close];
     249        delete mQtColor;
     250        mQtColor = new QColor();
     251        [self finishOffWithCode:NSCancelButton];
     252    }
    225253}
    226254
     
    230258    mQtColor = new QColor();
    231259    NSColor *color = [mColorPanel color];
    232     NSString *colorSpace = [color colorSpaceName];
    233     if (colorSpace == NSDeviceCMYKColorSpace) {
    234         CGFloat cyan, magenta, yellow, black, alpha;
     260    NSString *colorSpaceName = [color colorSpaceName];
     261    if (colorSpaceName == NSDeviceCMYKColorSpace) {
     262        CGFloat cyan = 0, magenta = 0, yellow = 0, black = 0, alpha = 0;
    235263        [color getCyan:&cyan magenta:&magenta yellow:&yellow black:&black alpha:&alpha];
    236264        mQtColor->setCmykF(cyan, magenta, yellow, black, alpha);
    237     } else {
    238         NSColor *tmpColor;
    239         if (colorSpace == NSCalibratedRGBColorSpace || colorSpace == NSDeviceRGBColorSpace) {
    240             tmpColor = color;
    241         } else {
    242             tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
    243         }
    244         CGFloat red, green, blue, alpha;
     265    } else if (colorSpaceName == NSCalibratedRGBColorSpace || colorSpaceName == NSDeviceRGBColorSpace)  {
     266        CGFloat red = 0, green = 0, blue = 0, alpha = 0;
     267        [color getRed:&red green:&green blue:&blue alpha:&alpha];
     268        mQtColor->setRgbF(red, green, blue, alpha);
     269    } else if (colorSpaceName == NSNamedColorSpace) {
     270        NSColor *tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
     271        CGFloat red = 0, green = 0, blue = 0, alpha = 0;
    245272        [tmpColor getRed:&red green:&green blue:&blue alpha:&alpha];
    246273        mQtColor->setRgbF(red, green, blue, alpha);
    247     }
    248 
    249     if (mPriv)
    250         mPriv->setCurrentQColor(*mQtColor);
     274    } else {
     275        NSColorSpace *colorSpace = [color colorSpace];
     276        if ([colorSpace colorSpaceModel] == NSCMYKColorSpaceModel && [color numberOfComponents] == 5){
     277            CGFloat components[5];
     278            [color getComponents:components];
     279            mQtColor->setCmykF(components[0], components[1], components[2], components[3], components[4]);
     280        } else {
     281            NSColor *tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
     282            CGFloat red = 0, green = 0, blue = 0, alpha = 0;
     283            [tmpColor getRed:&red green:&green blue:&blue alpha:&alpha];
     284            mQtColor->setRgbF(red, green, blue, alpha);
     285        }
     286    }
     287
     288    mPriv->setCurrentQColor(*mQtColor);
    251289}
    252290
     
    263301- (void)finishOffWithCode:(NSInteger)code
    264302{
    265     if (mPriv) {
    266         // Finish the QColorDialog as well. But since a call to accept or reject will
    267         // close down the QEventLoop found in QDialog, we need to make sure that the
    268         // current thread has exited the native dialogs modal session/run loop first.
    269         // We ensure this by posting the call:
     303    mResultCode = code;
     304    if (mDialogIsExecuting) {
     305        // We stop the current modal event loop. The control
     306        // will then return inside -(void)exec below.
     307        // It's important that the modal event loop is stopped before
     308        // we accept/reject QColorDialog, since QColorDialog has its
     309        // own event loop that needs to be stopped last.
    270310        [NSApp stopModalWithCode:code];
    271         if (code == NSOKButton)
    272             QMetaObject::invokeMethod(mPriv->colorDialog(), "accept", Qt::QueuedConnection);
    273         else
    274             QMetaObject::invokeMethod(mPriv->colorDialog(), "reject", Qt::QueuedConnection);
    275311    } else {
    276         [NSApp stopModalWithCode:code];
    277     }
    278 }
    279 
    280 - (void)cleanUpAfterMyself
    281 {
    282     if (mHackedPanel) {
    283         NSView *ourContentView = [mColorPanel contentView];
    284 
    285         // return stolen stuff to its rightful owner
    286         [mStolenContentView removeFromSuperview];
    287         [mColorPanel setContentView:mStolenContentView];
    288 
    289         [mOkButton release];
    290         [mCancelButton release];
    291         [ourContentView release];
    292     }
    293     [mColorPanel setDelegate:nil];
    294 }
     312        // Since we are not in a modal event loop, we can safely close
     313        // down QColorDialog
     314        // Calling accept() or reject() can in turn call closeCocoaColorPanel.
     315        // This check will prevent any such recursion.
     316        if (!mResultSet) {
     317            mResultSet = true;
     318            if (mResultCode == NSCancelButton) {
     319                mPriv->colorDialog()->reject();
     320            } else {
     321                mPriv->colorDialog()->accept();
     322            }
     323        }
     324    }
     325}
     326
     327- (void)showColorPanel
     328{
     329    mDialogIsExecuting = false;
     330    [mColorPanel makeKeyAndOrderFront:mColorPanel];
     331}
     332
     333- (void)exec
     334{
     335    QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
     336    QMacCocoaAutoReleasePool pool;
     337    mDialogIsExecuting = true;
     338    bool modalEnded = false;
     339    while (!modalEnded) {
     340        @try {
     341            [NSApp runModalForWindow:mColorPanel];
     342            modalEnded = true;
     343        } @catch (NSException *) {
     344            // For some reason, NSColorPanel throws an exception when
     345            // clicking on 'SelectedMenuItemColor' from the 'Developer'
     346            // palette (tab three).
     347        }
     348    }
     349
     350    if (mResultCode == NSCancelButton)
     351        mPriv->colorDialog()->reject();
     352    else
     353        mPriv->colorDialog()->accept();
     354}
     355
    295356@end
    296357
     
    301362extern NSButton *macCreateButton(const char *text, NSView *superview);
    302363
    303 void *QColorDialogPrivate::openCocoaColorPanel(const QColor &initial,
    304         QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options,
    305         QColorDialogPrivate *priv)
     364void QColorDialogPrivate::openCocoaColorPanel(const QColor &initial,
     365        QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options)
    306366{
    307367    Q_UNUSED(parent);   // we would use the parent if only NSColorPanel could be a sheet
    308368    QMacCocoaAutoReleasePool pool;
    309369
    310     /*
    311         The standard Cocoa color panel has no OK or Cancel button and
    312         is created as a utility window, whereas we want something like
    313         the Carbon color panel. We need to take the following steps:
    314 
    315          1. Intercept the color panel constructor to turn off the
    316             NSUtilityWindowMask flag. This is done by temporarily
    317             replacing initWithContentRect:styleMask:backing:defer:
    318             in NSPanel by our own method.
    319 
    320          2. Modify the color panel so that its content view is part
    321             of a new content view that contains it as well as two
    322             buttons (OK and Cancel).
    323 
    324          3. Lay out the original content view and the buttons when
    325             the color panel is shown and whenever it is resized.
    326 
    327          4. Clean up after ourselves.
    328     */
    329 
    330     bool hackColorPanel = !(options & QColorDialog::NoButtons);
    331 
    332     if (hackColorPanel)
    333         macStartInterceptNSPanelCtor();
    334     NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel];
    335     if (hackColorPanel)
    336         macStopInterceptNSPanelCtor();
    337 
    338     [colorPanel setHidesOnDeactivate:false];
    339 
    340     // set up the Cocoa color panel
    341     [colorPanel setShowsAlpha:options & QColorDialog::ShowAlphaChannel];
    342     [colorPanel setTitle:(NSString*)(CFStringRef)QCFString(title)];
    343 
    344     NSView *stolenContentView = 0;
    345     NSButton *okButton = 0;
    346     NSButton *cancelButton = 0;
    347 
    348     if (hackColorPanel) {
    349         // steal the color panel's contents view
    350         stolenContentView = [colorPanel contentView];
    351         [stolenContentView retain];
    352         [colorPanel setContentView:0];
    353 
    354         // create a new content view and add the stolen one as a subview
    355         NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
    356         NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
    357         [ourContentView addSubview:stolenContentView];
    358 
    359         // create OK and Cancel buttons and add these as subviews
    360         okButton = macCreateButton("&OK", ourContentView);
    361         cancelButton = macCreateButton("Cancel", ourContentView);
    362 
    363         [colorPanel setContentView:ourContentView];
    364         [colorPanel setDefaultButtonCell:[okButton cell]];
    365     }
    366 
    367     // create a delegate and set it
    368     QCocoaColorPanelDelegate *delegate =
    369             [[QCocoaColorPanelDelegate alloc] initWithColorPanel:colorPanel
    370                                                stolenContentView:stolenContentView
    371                                                         okButton:okButton
    372                                                     cancelButton:cancelButton
    373                                                             priv:priv];
    374     [colorPanel setDelegate:delegate];
    375     setColor(delegate, initial);
    376     [colorPanel makeKeyAndOrderFront:colorPanel];
    377 
    378     return delegate;
    379 }
    380 
    381 void QColorDialogPrivate::closeCocoaColorPanel(void *delegate)
    382 {
    383     QMacCocoaAutoReleasePool pool;
    384     QCocoaColorPanelDelegate *theDelegate = static_cast<QCocoaColorPanelDelegate *>(delegate);
    385     [[theDelegate colorPanel] close];
    386     [theDelegate cleanUpAfterMyself];
    387     [theDelegate autorelease];
     370    if (!delegate) {
     371        /*
     372           The standard Cocoa color panel has no OK or Cancel button and
     373           is created as a utility window, whereas we want something like
     374           the Carbon color panel. We need to take the following steps:
     375
     376           1. Intercept the color panel constructor to turn off the
     377           NSUtilityWindowMask flag. This is done by temporarily
     378           replacing initWithContentRect:styleMask:backing:defer:
     379           in NSPanel by our own method.
     380
     381           2. Modify the color panel so that its content view is part
     382           of a new content view that contains it as well as two
     383           buttons (OK and Cancel).
     384
     385           3. Lay out the original content view and the buttons when
     386           the color panel is shown and whenever it is resized.
     387
     388           4. Clean up after ourselves.
     389         */
     390
     391        bool hackColorPanel = !(options & QColorDialog::NoButtons);
     392
     393        if (hackColorPanel)
     394            macStartInterceptNSPanelCtor();
     395        NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel];
     396        if (hackColorPanel)
     397            macStopInterceptNSPanelCtor();
     398
     399        [colorPanel setHidesOnDeactivate:false];
     400
     401        // set up the Cocoa color panel
     402        [colorPanel setShowsAlpha:options & QColorDialog::ShowAlphaChannel];
     403        [colorPanel setTitle:(NSString*)(CFStringRef)QCFString(title)];
     404
     405        NSView *stolenContentView = 0;
     406        NSButton *okButton = 0;
     407        NSButton *cancelButton = 0;
     408
     409        if (hackColorPanel) {
     410            // steal the color panel's contents view
     411            stolenContentView = [colorPanel contentView];
     412            [stolenContentView retain];
     413            [colorPanel setContentView:0];
     414
     415            // create a new content view and add the stolen one as a subview
     416            NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
     417            NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
     418            [ourContentView addSubview:stolenContentView];
     419
     420            // create OK and Cancel buttons and add these as subviews
     421            okButton = macCreateButton("&OK", ourContentView);
     422            cancelButton = macCreateButton("Cancel", ourContentView);
     423
     424            [colorPanel setContentView:ourContentView];
     425            [colorPanel setDefaultButtonCell:[okButton cell]];
     426        }
     427
     428        delegate = [[QCocoaColorPanelDelegate alloc] initWithColorPanel:colorPanel
     429            stolenContentView:stolenContentView
     430            okButton:okButton
     431            cancelButton:cancelButton
     432            priv:this];
     433        [colorPanel setDelegate:static_cast<QCocoaColorPanelDelegate *>(delegate)];
     434    }
     435
     436    setCocoaPanelColor(initial);
     437    [static_cast<QCocoaColorPanelDelegate *>(delegate) showColorPanel];
     438}
     439
     440void QColorDialogPrivate::closeCocoaColorPanel()
     441{
     442    [static_cast<QCocoaColorPanelDelegate *>(delegate) onCancelClicked];
     443}
     444
     445void QColorDialogPrivate::releaseCocoaColorPanelDelegate()
     446{
     447    [static_cast<QCocoaColorPanelDelegate *>(delegate) release];
    388448}
    389449
     
    405465void QColorDialogPrivate::_q_macRunNativeAppModalPanel()
    406466{
    407     QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
    408     QMacCocoaAutoReleasePool pool;
    409     QCocoaColorPanelDelegate *delegateCasted = static_cast<QCocoaColorPanelDelegate *>(delegate);
    410     [NSApp runModalForWindow:[delegateCasted colorPanel]];
    411 }
    412 
    413 void QColorDialogPrivate::setColor(void *delegate, const QColor &color)
     467    [static_cast<QCocoaColorPanelDelegate *>(delegate) exec];
     468}
     469
     470void QColorDialogPrivate::setCocoaPanelColor(const QColor &color)
    414471{
    415472    QMacCocoaAutoReleasePool pool;
    416473    QCocoaColorPanelDelegate *theDelegate = static_cast<QCocoaColorPanelDelegate *>(delegate);
    417     NSColor *nsColor = [NSColor colorWithCalibratedRed:color.red() / 255.0
    418                                                  green:color.green() / 255.0
    419                                                   blue:color.blue() / 255.0
    420                                                  alpha:color.alpha() / 255.0];
     474    NSColor *nsColor;
     475    const QColor::Spec spec = color.spec();
     476    if (spec == QColor::Cmyk) {
     477        nsColor = [NSColor colorWithDeviceCyan:color.cyanF()
     478                                       magenta:color.magentaF()
     479                                        yellow:color.yellowF()
     480                                         black:color.blackF()
     481                                         alpha:color.alphaF()];
     482    } else {
     483        nsColor = [NSColor colorWithCalibratedRed:color.redF()
     484                                            green:color.greenF()
     485                                             blue:color.blueF()
     486                                            alpha:color.alphaF()];
     487    }
    421488    [[theDelegate colorPanel] setColor:nsColor];
    422489}
  • trunk/src/gui/dialogs/qcolordialog_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    115115    QPointer<QObject> receiverToDisconnectOnClose;
    116116    QByteArray memberToDisconnectOnClose;
     117    bool nativeDialogInUse;
    117118
    118119#ifdef Q_WS_MAC
    119     static void *openCocoaColorPanel(const QColor &initial,
    120             QWidget *parent, const QString &title,
    121             QColorDialog::ColorDialogOptions options,
    122             QColorDialogPrivate *priv = 0);
    123     static void closeCocoaColorPanel(void *delegate);
    124     static QColor execCocoaColorPanel(const QColor &initial, QWidget *parent,
    125             const QString &title, QColorDialog::ColorDialogOptions options);
    126     static void setColor(void *delegate, const QColor &color);
     120    void openCocoaColorPanel(const QColor &initial,
     121            QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options);
     122    void closeCocoaColorPanel();
     123    void releaseCocoaColorPanelDelegate();
     124    void setCocoaPanelColor(const QColor &color);
    127125
    128126    inline void done(int result) { q_func()->done(result); }
  • trunk/src/gui/dialogs/qdialog.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5656#include "qaccessible.h"
    5757#endif
    58 #if defined(Q_OS_WINCE)
     58#if defined(Q_WS_WINCE)
    5959#include "qt_windows.h"
    6060#include "qmenubar.h"
     
    6565#elif defined(Q_WS_X11)
    6666#  include "../kernel/qt_x11_p.h"
     67#elif defined(Q_OS_SYMBIAN)
     68#   include "qfiledialog.h"
     69#   include "qfontdialog.h"
     70#   include "qcolordialog.h"
     71#   include "qwizard.h"
     72#   include "qmenubar.h"
     73#endif
     74
     75#if defined(Q_WS_S60)
     76#include "private/qt_s60_p.h"
    6777#endif
    6878
    6979#ifndef SPI_GETSNAPTODEFBUTTON
    70 define SPI_GETSNAPTODEFBUTTON  95
     80 define SPI_GETSNAPTODEFBUTTON  95
    7181#endif
    7282
     
    7787    \brief The QDialog class is the base class of dialog windows.
    7888
    79     \ingroup dialogs
     89    \ingroup dialog-classes
    8090    \ingroup abstractwidgets
    81     \mainclass
     91
    8292
    8393    A dialog window is a top-level window mostly used for short-term
     
    252262              f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0))
    253263{
    254 #ifdef Q_OS_WINCE
     264#ifdef Q_WS_WINCE
    255265    if (!qt_wince_is_smartphone())
    256266        setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint));
     
    281291    : QWidget(dd, parent, f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0))
    282292{
    283 #ifdef Q_OS_WINCE
     293#ifdef Q_WS_WINCE
    284294    if (!qt_wince_is_smartphone())
    285295        setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint));
     
    293303QDialog::~QDialog()
    294304{
    295     // Need to hide() here, as our (to-be) overridden hide()
    296     // will not be called in ~QWidget.
    297     hide();
     305    QT_TRY {
     306        // Need to hide() here, as our (to-be) overridden hide()
     307        // will not be called in ~QWidget.
     308        hide();
     309    } QT_CATCH(...) {
     310        // we're in the destructor - just swallow the exception
     311    }
    298312}
    299313
     
    365379}
    366380
    367 #ifdef Q_OS_WINCE
    368 #ifdef Q_OS_WINCE_WM
     381#if defined(Q_WS_WINCE) || defined(Q_WS_S60)
     382#ifdef Q_WS_WINCE_WM
    369383void QDialogPrivate::_q_doneAction()
    370384{
     
    380394{
    381395    bool result = QWidget::event(e);
     396#ifdef Q_WS_WINCE
    382397    if (e->type() == QEvent::OkRequest) {
    383398        accept();
    384399        result = true;
    385400     }
     401#else
     402    if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize ))
     403        adjustPosition(parentWidget());
     404#endif
    386405    return result;
    387406}
     
    474493
    475494//On Windows Mobile we create an empty menu to hide the current menu
    476 #ifdef Q_OS_WINCE_WM
     495#ifdef Q_WS_WINCE_WM
    477496#ifndef QT_NO_MENUBAR
    478497    QMenuBar *menuBar = 0;
     
    485504    }
    486505#endif //QT_NO_MENUBAR
    487 #endif //Q_OS_WINCE_WM
    488 
    489     show();
     506#endif //Q_WS_WINCE_WM
     507
     508#ifdef Q_OS_SYMBIAN
     509#ifndef QT_NO_MENUBAR
     510    QMenuBar *menuBar = 0;
     511    if (!findChild<QMenuBar *>())
     512        menuBar = new QMenuBar(this);
     513#endif
     514
     515    if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) ||
     516        qobject_cast<QColorDialog *>(this) || qobject_cast<QWizard *>(this))
     517        showMaximized();
     518    else
     519#endif // Q_OS_SYMBIAN
     520
     521        show();
    490522
    491523#ifdef Q_WS_MAC
     
    506538    if (deleteOnClose)
    507539        delete this;
    508 #ifdef Q_OS_WINCE_WM
     540#ifdef Q_WS_WINCE_WM
    509541#ifndef QT_NO_MENUBAR
    510542    else if (menuBar)
    511543        delete menuBar;
    512544#endif //QT_NO_MENUBAR
    513 #endif //Q_OS_WINCE_WM
     545#endif //Q_WS_WINCE_WM
     546#ifdef Q_OS_SYMBIAN
     547#ifndef QT_NO_MENUBAR
     548    else if (menuBar)
     549        delete menuBar;
     550#endif //QT_NO_MENUBAR
     551#endif //Q_OS_SYMBIAN
     552
    514553    return res;
    515554}
     
    634673        case Qt::Key_Escape:
    635674            reject();
    636             break;
    637         case Qt::Key_Up:
    638         case Qt::Key_Left:
    639             if (focusWidget() &&
    640                  (focusWidget()->focusPolicy() == Qt::StrongFocus ||
    641                    focusWidget()->focusPolicy() == Qt::WheelFocus)) {
    642                 e->ignore();
    643                 break;
    644             }
    645             // call ours, since c++ blocks us from calling the one
    646             // belonging to focusWidget().
    647             focusNextPrevChild(false);
    648             break;
    649         case Qt::Key_Down:
    650         case Qt::Key_Right:
    651             if (focusWidget() &&
    652                  (focusWidget()->focusPolicy() == Qt::StrongFocus ||
    653                    focusWidget()->focusPolicy() == Qt::WheelFocus)) {
    654                 e->ignore();
    655                 break;
    656             }
    657             focusNextPrevChild(true);
    658675            break;
    659676        default:
     
    763780    if (d->mainDef && isActiveWindow()) {
    764781        BOOL snapToDefault = false;
    765         if ( QT_WA_INLINE( SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0) ,
    766                            SystemParametersInfoA(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0) )) {
     782        if (SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0)) {
    767783            if (snapToDefault)
    768784                QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center()));
     
    790806    // if the WM advertises that it will place the windows properly for us, let it do it :)
    791807    if (X11->isSupportedByWM(ATOM(_NET_WM_FULL_PLACEMENT)))
     808        return;
     809#endif
     810
     811#ifdef Q_WS_S60
     812    if (s60AdjustedPosition())
     813        //dialog has already been positioned
    792814        return;
    793815#endif
     
    856878}
    857879
     880#if defined(Q_WS_S60)
     881/*! \internal */
     882bool QDialog::s60AdjustedPosition()
     883{
     884    QPoint p;
     885    const QSize mainAreaSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
     886    const int statusPaneHeight = (S60->screenHeightInPixels - mainAreaSize.height())>>1;
     887    const bool doS60Positioning = !(isFullScreen()||isMaximized());
     888    if (doS60Positioning) {
     889        // naive way to deduce screen orientation
     890        if (S60->screenHeightInPixels > S60->screenWidthInPixels) {
     891            int cbaHeight;
     892            const CEikButtonGroupContainer* bgContainer = S60->buttonGroupContainer();
     893            if (!bgContainer) {
     894                cbaHeight = 0;
     895            } else {
     896                cbaHeight = qt_TSize2QSize(bgContainer->Size()).height();
     897            }
     898            p.setY(S60->screenHeightInPixels-height()-cbaHeight);
     899            p.setX(0);
     900        } else {
     901            const int scrollbarWidth = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
     902            TRect cbaRect = TRect();
     903            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane, cbaRect);
     904            AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation();
     905            switch (cbaLocation) {
     906            case AknLayoutUtils::EAknCbaLocationBottom:
     907                p.setY(S60->screenHeightInPixels - height()-cbaRect.Height());
     908                p.setX((S60->screenWidthInPixels - width())>>1);
     909                break;
     910            case AknLayoutUtils::EAknCbaLocationRight:
     911                p.setY((S60->screenHeightInPixels - height())>>1);
     912                p.setX(qMax(0,S60->screenWidthInPixels-width()-scrollbarWidth-cbaRect.Width()));
     913                break;
     914            case AknLayoutUtils::EAknCbaLocationLeft:
     915                p.setY((S60->screenHeightInPixels - height())>>1);
     916                p.setX(qMax(0,scrollbarWidth+cbaRect.Width()));
     917                break;
     918            }
     919        }
     920        move(p);
     921    }
     922    return doS60Positioning;
     923}
     924#endif
    858925
    859926/*!
     
    10151082                        QWidget::sizeHint().height());
    10161083    }
    1017 
     1084#if defined(Q_WS_S60)
     1085    // if size is not fixed, try to adjust it according to S60 layoutting
     1086    if (minimumSize() != maximumSize()) {
     1087        // In S60, dialogs are always the width of screen (in portrait, regardless of current layout)
     1088        return QSize(qMax(S60->screenHeightInPixels, S60->screenWidthInPixels), QWidget::sizeHint().height());
     1089    } else {
     1090        return QWidget::sizeHint();
     1091    }
     1092#else
    10181093    return QWidget::sizeHint();
     1094#endif //Q_WS_S60
    10191095}
    10201096
  • trunk/src/gui/dialogs/qdialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    108108    QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = 0);
    109109
    110 #ifdef Q_OS_WINCE
     110#if defined(Q_WS_WINCE) || defined(Q_WS_S60)
    111111    bool event(QEvent *e);
    112112#endif
     
    120120    bool eventFilter(QObject *, QEvent *);
    121121    void adjustPosition(QWidget*);
    122 
    123122private:
    124123    Q_DECLARE_PRIVATE(QDialog)
    125124    Q_DISABLE_COPY(QDialog)
    126125
    127 #ifdef Q_OS_WINCE_WM
     126#if defined(Q_WS_S60)
     127    bool s60AdjustedPosition();
     128#endif
     129
     130
     131#ifdef Q_WS_WINCE_WM
    128132    Q_PRIVATE_SLOT(d_func(), void _q_doneAction())
    129133#endif
  • trunk/src/gui/dialogs/qdialog_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    9494    void resetModalitySetByOpen();
    9595
    96 #ifdef Q_OS_WINCE_WM
     96#ifdef Q_WS_WINCE_WM
    9797    void _q_doneAction();
    9898#endif
    9999
    100100#ifdef Q_WS_MAC
    101     virtual void mac_nativeDialogModalHelp(){};
     101    virtual void mac_nativeDialogModalHelp() {}
    102102#endif
    103103
  • trunk/src/gui/dialogs/qdialogsbinarycompat_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qerrormessage.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6262#include <stdlib.h>
    6363
    64 #ifdef Q_OS_WINCE
     64#ifdef Q_WS_WINCE
    6565extern bool qt_wince_is_mobile();    //defined in qguifunctions_wince.cpp
    6666extern bool qt_wince_is_high_dpi();  //defined in qguifunctions_wince.cpp
    6767
    6868#include "qguifunctions_wince.h"
     69#endif
     70
     71#if defined(QT_SOFTKEYS_ENABLED)
     72#include <qaction.h>
     73#ifdef Q_WS_S60
     74#include "private/qt_s60_p.h"
     75#endif
    6976#endif
    7077
     
    7986    QTextEdit * errors;
    8087    QLabel * icon;
     88#ifdef QT_SOFTKEYS_ENABLED
     89    QAction *okAction;
     90#endif
    8191    QQueue<QPair<QString, QString> > pending;
    8292    QSet<QString> doNotShow;
     
    101111QSize QErrorMessageTextView::minimumSizeHint() const
    102112{
    103 #ifdef Q_OS_WINCE
     113#ifdef Q_WS_WINCE
    104114    if (qt_wince_is_mobile())
    105115         if (qt_wince_is_high_dpi())
     
    116126QSize QErrorMessageTextView::sizeHint() const
    117127{
    118 #ifdef Q_OS_WINCE
     128#ifdef Q_WS_WINCE
    119129    if (qt_wince_is_mobile())
    120130         if (qt_wince_is_high_dpi())
     
    125135      return QSize(300, 100);
    126136#else
     137
     138#ifdef Q_WS_S60
     139    const int smallerDimension = qMin(S60->screenHeightInPixels, S60->screenWidthInPixels);
     140    // In S60 layout data, error messages seem to be one third of the screen height (in portrait) minus two.
     141    return QSize(smallerDimension, smallerDimension/3-2);
     142#else
    127143    return QSize(250, 75);
    128 #endif
     144#endif //Q_WS_S60
     145#endif //Q_WS_WINCE
    129146}
    130147
     
    134151    \brief The QErrorMessage class provides an error message display dialog.
    135152
    136     \ingroup dialogs
    137     \ingroup misc
     153    \ingroup standard-dialog
    138154
    139155    An error message widget consists of a text label and a checkbox. The
     
    241257    grid->addWidget(d->again, 1, 1, Qt::AlignTop);
    242258    d->ok = new QPushButton(this);
    243 #ifdef Q_OS_WINCE
     259#ifdef QT_SOFTKEYS_ENABLED
     260    d->okAction = new QAction(d->ok);
     261    d->okAction->setSoftKeyRole(QAction::PositiveSoftKey);
     262    connect(d->okAction, SIGNAL(triggered()), this, SLOT(accept()));
     263    addAction(d->okAction);
     264#endif
     265
     266
     267#if defined(Q_WS_WINCE) || defined(Q_WS_S60)
    244268    d->ok->setFixedSize(0,0);
    245269#endif
     
    301325        qtMessageHandler = new QErrorMessage(0);
    302326        qAddPostRoutine(deleteStaticcQErrorMessage); // clean up
    303         qtMessageHandler->setWindowTitle(qApp->applicationName());
     327        qtMessageHandler->setWindowTitle(QApplication::applicationName());
    304328        qInstallMsgHandler(jump);
    305329    }
     
    374398}
    375399
    376 
    377400/*!
    378401    \reimp
     
    391414    again->setText(QErrorMessage::tr("&Show this message again"));
    392415    ok->setText(QErrorMessage::tr("&OK"));
     416#ifdef QT_SOFTKEYS_ENABLED
     417    okAction->setText(ok->text());
     418#endif
    393419}
    394420
  • trunk/src/gui/dialogs/qerrormessage.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qfiledialog.cpp

    r172 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5959#include <qapplication.h>
    6060#include <qstylepainter.h>
    61 #ifndef Q_OS_WINCE
     61#if !defined(Q_WS_WINCE) && !defined(Q_OS_SYMBIAN)
    6262#include "ui_qfiledialog.h"
    6363#else
    64 #include "ui_qfiledialog_wince.h"
     64#define Q_EMBEDDED_SMALLSCREEN
     65#include "ui_qfiledialog_embedded.h"
     66#if defined(Q_OS_WINCE)
    6567extern bool qt_priv_ptr_valid;
     68#endif
    6669#endif
    6770
     
    9093  \class QFileDialog
    9194  \brief The QFileDialog class provides a dialog that allow users to select files or directories.
    92   \ingroup dialogs
    93   \mainclass
     95  \ingroup standard-dialogs
     96
    9497
    9598  The QFileDialog class enables a user to traverse the file system in
     
    97100
    98101  The easiest way to create a QFileDialog is to use the static
    99   functions. On Windows, these static functions will call the native
    100   Windows file dialog, and on Mac OS X these static function will call
    101   the native Mac OS X file dialog.
     102  functions. On Windows, Mac OS X, KDE and GNOME, these static functions will
     103  call the native file dialog when possible.
    102104
    103105  \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 0
     
    211213    \enum QFileDialog::Option
    212214
    213     \value ShowDirsOnly Only show directories in the file dialog. By default both files and
    214     directories are shown. (Valid only in the \l Directory file mode.)
    215     \value DontResolveSymlinks Don't resolve symlinks in the file dialog. By default symlinks
    216     are resolved.
    217     \value DontConfirmOverwrite Don't ask for confirmation if an existing file is selected.
    218     By default confirmation is requested.
    219     \value DontUseNativeDialog Don't use the native file dialog. By default on Mac OS X and Windows,
    220     the native file dialog is used unless you use a subclass of QFileDialog that contains the
    221     Q_OBJECT macro.
     215    \value ShowDirsOnly Only show directories in the file dialog. By
     216    default both files and directories are shown. (Valid only in the
     217    \l Directory file mode.)
     218
     219    \value DontResolveSymlinks Don't resolve symlinks in the file
     220    dialog. By default symlinks are resolved.
     221
     222    \value DontConfirmOverwrite Don't ask for confirmation if an
     223    existing file is selected.  By default confirmation is requested.
     224
     225    \value DontUseNativeDialog Don't use the native file dialog. By
     226    default, the native file dialog is used unless you use a subclass
     227    of QFileDialog that contains the Q_OBJECT macro.
     228
    222229    \value ReadOnly Indicates that the model is readonly.
     230
    223231    \value HideNameFilterDetails Indicates if the is hidden or not.
    224 
    225232    This value is obsolete and does nothing since Qt 4.5:
    226233
    227     \value DontUseSheet In previous versions of Qt, the static functions would
    228     create a sheet by default if the static function was given a parent. This
    229     is no longer supported in Qt 4.5, The static functions will always be an
    230     application modal dialog. If you want to use sheets, use
    231     QFileDialog::open() instead.
     234    \value DontUseSheet In previous versions of Qt, the static
     235    functions would create a sheet by default if the static function
     236    was given a parent. This is no longer supported in Qt 4.5, The
     237    static functions will always be an application modal dialog. If
     238    you want to use sheets, use QFileDialog::open() instead.
    232239
    233240*/
     
    311318    Q_D(QFileDialog);
    312319    d->init();
     320    d->lineEdit()->selectAll();
    313321}
    314322
     
    328336    Q_D(QFileDialog);
    329337    d->init(directory, filter, caption);
     338    d->lineEdit()->selectAll();
    330339}
    331340
     
    355364    settings.setValue(QLatin1String("filedialog"), saveState());
    356365#endif
    357     delete d->qFileDialogUi;
    358366    d->deleteNativeDialog_sys();
    359367}
     
    390398
    391399static const qint32 QFileDialogMagic = 0xbe;
     400
     401const char *qt_file_dialog_filter_reg_exp =
     402"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
    392403
    393404/*!
     
    487498}
    488499
     500QFileDialogPrivate::QFileDialogPrivate()
     501    :
     502#ifndef QT_NO_PROXYMODEL
     503        proxyModel(0),
     504#endif
     505        model(0),
     506        fileMode(QFileDialog::AnyFile),
     507        acceptMode(QFileDialog::AcceptOpen),
     508        currentHistoryLocation(-1),
     509        renameAction(0),
     510        deleteAction(0),
     511        showHiddenAction(0),
     512        useDefaultCaption(true),
     513        defaultFileTypes(true),
     514        fileNameLabelExplicitlySat(false),
     515        nativeDialogInUse(false),
     516#ifdef Q_WS_MAC
     517        mDelegate(0),
     518#ifndef QT_MAC_USE_COCOA
     519        mDialog(0),
     520        mDialogStarted(false),
     521        mDialogClosed(true),
     522#endif
     523#endif
     524        qFileDialogUi(0)
     525{
     526}
     527
     528QFileDialogPrivate::~QFileDialogPrivate()
     529{
     530}
     531
    489532void QFileDialogPrivate::retranslateWindowTitle()
    490533{
     
    567610
    568611/*!
    569     Sets the given \a option to be enabled if \a on is true;
    570     otherwise, clears the given \a option.
     612    \since 4.5
     613    Sets the given \a option to be enabled if \a on is true; otherwise,
     614    clears the given \a option.
    571615
    572616    \sa options, testOption()
     
    639683    \since 4.5
    640684
    641     Opens the dialog and connects its accepted() signal to the slot specified
    642     by \a receiver and \a member.
     685    This function connects one of its signals to the slot specified by \a receiver
     686    and \a member. The specific signal depends is filesSelected() if fileMode is
     687    ExistingFiles and fileSelected() if fileMode is anything else.
    643688
    644689    The signal will be disconnected from the slot when the dialog is closed.
     
    647692{
    648693    Q_D(QFileDialog);
    649     const char *signal = (fileMode() == ExistingFiles) ? SIGNAL(filesSelected(const QStringList&))
    650                                                        : SIGNAL(fileSelected(const QString&));
     694    const char *signal = (fileMode() == ExistingFiles) ? SIGNAL(filesSelected(QStringList))
     695                                                       : SIGNAL(fileSelected(QString));
    651696    connect(this, signal, receiver, member);
    652697    d->signalToDisconnectOnClose = signal;
     
    694739void QFileDialogPrivate::_q_goToUrl(const QUrl &url)
    695740{
    696     QModelIndex idx = model->index(url.toLocalFile());
     741    //The shortcut in the side bar may have a parent that is not fetched yet (e.g. an hidden file)
     742    //so we force the fetching
     743    QFileSystemModelPrivate::QFileSystemNode *node = model->d_func()->node(url.toLocalFile(), true);
     744    QModelIndex idx =  model->d_func()->index(node);
    697745    _q_enterDirectory(idx);
    698746}
     
    730778    d->qFileDialogUi->newFolderButton->setEnabled(d->model->flags(root) & Qt::ItemIsDropEnabled);
    731779    if (root != d->rootIndex()) {
    732 #ifndef QT_NO_COMPLETER
     780#ifndef QT_NO_FSCOMPLETER
    733781    if (directory.endsWith(QLatin1Char('/')))
    734782        d->completer->setCompletionPrefix(newDirectory);
     
    775823
    776824    QModelIndex index = d->model->index(filename);
     825    QString file;
    777826    if (!index.isValid()) {
    778827        // save as dialog where we want to input a default value
     
    789838                text = text.remove(0,1);
    790839        }
    791         if (!isVisible() || !d->lineEdit()->hasFocus())
    792             d->lineEdit()->setText(text);
     840        file = text;
    793841    } else {
    794         d->qFileDialogUi->listView->selectionModel()->clear();
    795         if (!isVisible() || !d->lineEdit()->hasFocus())
    796             d->lineEdit()->setText(index.data().toString());
    797     }
     842        file = index.data().toString();
     843    }
     844    d->qFileDialogUi->listView->selectionModel()->clear();
     845    if (!isVisible() || !d->lineEdit()->hasFocus())
     846        d->lineEdit()->setText(file);
    798847}
    799848
     
    836885            // and on Windows it already ends with slash.
    837886            QString path = rootPath();
    838             if (!path.endsWith(QLatin1String("/")))
    839                 path += QLatin1String("/");
     887            if (!path.endsWith(QLatin1Char('/')))
     888                path += QLatin1Char('/');
    840889            path += name;
    841890            files.append(path);
     
    9581007    Q_D(QFileDialog);
    9591008    d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)")));
    960     d->nameFilters = filters;
     1009    QStringList cleanedFilters;
     1010    for (int i = 0; i < filters.count(); ++i) {
     1011        cleanedFilters << filters[i].simplified();
     1012    }
     1013    d->nameFilters = cleanedFilters;
    9611014
    9621015    if (d->nativeDialogInUse){
    963         d->setNameFilters_sys(filters);
     1016        d->setNameFilters_sys(cleanedFilters);
    9641017        return;
    9651018    }
    9661019
    9671020    d->qFileDialogUi->fileTypeCombo->clear();
    968     if (filters.isEmpty())
     1021    if (cleanedFilters.isEmpty())
    9691022        return;
    9701023
    9711024    if (testOption(HideNameFilterDetails)) {
    9721025        QStringList strippedFilters;
    973         for (int i = 0; i < filters.count(); ++i) {
    974             strippedFilters.append(filters[i].mid(0, filters[i].indexOf(QLatin1String(" ("))));
     1026        QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
     1027        for (int i = 0; i < cleanedFilters.count(); ++i) {
     1028            QString filterName;
     1029            int index = r.indexIn(cleanedFilters[i]);
     1030            if (index >= 0)
     1031                filterName = r.cap(1);
     1032            strippedFilters.append(filterName.simplified());
    9751033        }
    9761034        d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters);
    9771035    } else {
    978         d->qFileDialogUi->fileTypeCombo->addItems(filters);
     1036        d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters);
    9791037    }
    9801038    d->_q_useNameFilter(0);
     
    14341492    Q_D(QFileDialog);
    14351493    d->model->setIconProvider(provider);
     1494    //It forces the refresh of all entries in the side bar, then we can get new icons
     1495    d->qFileDialogUi->sidebar->setUrls(d->qFileDialogUi->sidebar->urls());
    14361496}
    14371497
     
    15301590
    15311591/*!
    1532   This is a convenience static function that returns an existing file
    1533   selected by the user. If the user presses Cancel, it returns a null
    1534   string.
    1535 
    1536   \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 8
    1537 
    1538   The function creates a modal file dialog with the given \a parent widget.
    1539   If the parent is not 0, the dialog will be shown centered over the
    1540   parent widget.
    1541 
    1542   The file dialog's working directory will be set to \a dir.  If \a
    1543   dir includes a file name, the file will be selected. Only files
    1544   that match the given \a filter are shown. The filter selected is
    1545   set to \a selectedFilter. The parameters \a dir, \a
    1546   selectedFilter, and \a filter may be empty strings. If you want
    1547   multiple filters, separate them with ';;', for example:
    1548 
    1549   \code
     1592    This is a convenience static function that returns an existing file
     1593    selected by the user. If the user presses Cancel, it returns a null string.
     1594
     1595    \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 8
     1596
     1597    The function creates a modal file dialog with the given \a parent widget.
     1598    If \a parent is not 0, the dialog will be shown centered over the parent
     1599    widget.
     1600
     1601    The file dialog's working directory will be set to \a dir. If \a dir
     1602    includes a file name, the file will be selected. Only files that match the
     1603    given \a filter are shown. The filter selected is set to \a selectedFilter.
     1604    The parameters \a dir, \a selectedFilter, and \a filter may be empty
     1605    strings. If you want multiple filters, separate them with ';;', for
     1606    example:
     1607
     1608    \code
    15501609    "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
    1551   \endcode
    1552 
    1553   The \a options argument holds various
    1554   options about how to run the dialog, see the QFileDialog::Option enum for
    1555   more information on the flags you can pass.
    1556 
    1557   The dialog's caption is set to \a caption. If \a caption is not
    1558   specified then a default caption will be used.
    1559 
    1560   Under Windows and Mac OS X, this static function will use the native
    1561   file dialog and not a QFileDialog.
    1562 
    1563   Note that on Windows the dialog will spin a blocking modal event loop
    1564   that will not dispatch any QTimers, and if parent is not 0 then it will
    1565   position the dialog just under the parent's title bar.
    1566 
    1567   Under Unix/X11, the normal behavior of the file dialog is to resolve
    1568   and follow symlinks. For example, if \c{/usr/tmp} is a symlink to
    1569   \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after
    1570   entering \c{/usr/tmp}. If \a options includes DontResolveSymlinks,
    1571   the file dialog will treat symlinks as regular directories.
    1572 
    1573   \warning Do not delete \a parent during the execution of the dialog.
    1574            If you want to do this, you should create the dialog
    1575            yourself using one of the QFileDialog constructors.
    1576 
    1577   \sa getOpenFileNames(), getSaveFileName(), getExistingDirectory()
     1610    \endcode
     1611
     1612    The \a options argument holds various options about how to run the dialog,
     1613    see the QFileDialog::Option enum for more information on the flags you can
     1614    pass.
     1615
     1616    The dialog's caption is set to \a caption. If \a caption is not specified
     1617    then a default caption will be used.
     1618
     1619    On Windows and Mac OS X, this static function will use the native file
     1620    dialog and not a QFileDialog.
     1621
     1622    On Windows the dialog will spin a blocking modal event loop that will not
     1623    dispatch any QTimers, and if \a parent is not 0 then it will position the
     1624    dialog just below the parent's title bar.
     1625
     1626    On Unix/X11, the normal behavior of the file dialog is to resolve and
     1627    follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},
     1628    the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If
     1629    \a options includes DontResolveSymlinks, the file dialog will treat
     1630    symlinks as regular directories.
     1631
     1632    \warning Do not delete \a parent during the execution of the dialog. If you
     1633    want to do this, you should create the dialog yourself using one of the
     1634    QFileDialog constructors.
     1635
     1636    \sa getOpenFileNames(), getSaveFileName(), getExistingDirectory()
    15781637*/
    15791638QString QFileDialog::getOpenFileName(QWidget *parent,
     
    16131672
    16141673/*!
    1615   This is a convenience static function that will return one or more
    1616   existing files selected by the user.
    1617 
    1618   \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 9
    1619 
    1620   This function creates a modal file dialog with the given \a parent
    1621   widget. If the parent is not 0, the dialog will be shown centered
    1622   over the parent widget.
    1623 
    1624   The file dialog's working directory will be set to \a dir. If \a
    1625   dir includes a file name, the file will be selected. The filter
    1626   is set to \a filter so that only those files which match the filter
    1627   are shown. The filter selected is set to \a selectedFilter. The parameters
    1628   \a dir, \a selectedFilter and \a filter may be empty strings. If you
    1629   need multiple filters, separate them with ';;', for instance:
    1630 
    1631   \code
     1674    This is a convenience static function that will return one or more existing
     1675    files selected by the user.
     1676
     1677    \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 9
     1678
     1679    This function creates a modal file dialog with the given \a parent widget.
     1680    If \a parent is not 0, the dialog will be shown centered over the parent
     1681    widget.
     1682
     1683    The file dialog's working directory will be set to \a dir. If \a dir
     1684    includes a file name, the file will be selected. The filter is set to
     1685    \a filter so that only those files which match the filter are shown. The
     1686    filter selected is set to \a selectedFilter. The parameters \a dir,
     1687    \a selectedFilter and \a filter may be empty strings. If you need multiple
     1688    filters, separate them with ';;', for instance:
     1689
     1690    \code
    16321691    "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
    1633   \endcode
    1634 
    1635   The dialog's caption is set to \a caption. If \a caption is not
    1636   specified then a default caption will be used.
    1637 
    1638   Under Windows and Mac OS X, this static function will use the native
    1639   file dialog and not a QFileDialog. On Mac OS X, the \a dir argument
    1640   is ignored, the native dialog always displays the last visited directory.
    1641 
    1642   Note that on Windows the dialog will spin a blocking modal event loop
    1643   that will not dispatch any QTimers, and if parent is not 0 then it will
    1644   position the dialog just under the parent's title bar.
    1645 
    1646   Under Unix/X11, the normal behavior of the file dialog is to resolve
    1647   and follow symlinks. For example, if \c{/usr/tmp} is a symlink to
    1648   \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after
    1649   entering \c{/usr/tmp}. The \a options argument holds various
    1650   options about how to run the dialog, see the QFileDialog::Option enum for
    1651   more information on the flags you can pass.
    1652 
    1653   Note that if you want to iterate over the list of files, you should
    1654   iterate over a copy. For example:
     1692    \endcode
     1693
     1694    The dialog's caption is set to \a caption. If \a caption is not specified
     1695    then a default caption will be used.
     1696
     1697    On Windows and Mac OS X, this static function will use the native file
     1698    dialog and not a QFileDialog.
     1699
     1700    On Windows the dialog will spin a blocking modal event loop that will not
     1701    dispatch any QTimers, and if \a parent is not 0 then it will position the
     1702    dialog just below the parent's title bar.
     1703
     1704    On Unix/X11, the normal behavior of the file dialog is to resolve and
     1705    follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},
     1706    the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}.
     1707    The \a options argument holds various options about how to run the dialog,
     1708    see the QFileDialog::Option enum for more information on the flags you can
     1709    pass.
     1710
     1711    \note If you want to iterate over the list of files, you should iterate
     1712    over a copy. For example:
    16551713
    16561714    \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 10
    16571715
    1658   \warning Do not delete \a parent during the execution of the dialog.
    1659            If you want to do this, you should create the dialog
    1660            yourself using one of the QFileDialog constructors.
    1661 
    1662   \sa getOpenFileName(), getSaveFileName(), getExistingDirectory()
     1716    \warning Do not delete \a parent during the execution of the dialog. If you
     1717    want to do this, you should create the dialog yourself using one of the
     1718    QFileDialog constructors.
     1719
     1720    \sa getOpenFileName(), getSaveFileName(), getExistingDirectory()
    16631721*/
    16641722QStringList QFileDialog::getOpenFileNames(QWidget *parent,
     
    16691727                                          Options options)
    16701728{
    1671     if (qt_filedialog_open_filenames_hook)
     1729    if (qt_filedialog_open_filenames_hook && !(options & DontUseNativeDialog))
    16721730        return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options);
    16731731    QFileDialogArgs args;
     
    16991757
    17001758/*!
    1701   This is a convenience static function that will return a file name
    1702   selected by the user. The file does not have to exist.
    1703 
    1704   It creates a modal file dialog with the given \a parent widget. If the
    1705   parent is not 0, the dialog will be shown centered over the parent
    1706   widget.
    1707 
    1708   \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 11
    1709 
    1710   The file dialog's working directory will be set to \a dir. If \a
    1711   dir includes a file name, the file will be selected. Only files that
    1712   match the \a filter are shown. The filter selected is set to
    1713   \a selectedFilter. The parameters \a dir, \a selectedFilter, and
    1714   \a filter may be empty strings. Multiple filters are separated with ';;'.
    1715   For instance:
    1716 
    1717   \code
     1759    This is a convenience static function that will return a file name selected
     1760    by the user. The file does not have to exist.
     1761
     1762    It creates a modal file dialog with the given \a parent widget. If
     1763    \a parent is not 0, the dialog will be shown centered over the parent
     1764    widget.
     1765
     1766    \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 11
     1767
     1768    The file dialog's working directory will be set to \a dir. If \a dir
     1769    includes a file name, the file will be selected. Only files that match the
     1770    \a filter are shown. The filter selected is set to \a selectedFilter. The
     1771    parameters \a dir, \a selectedFilter, and \a filter may be empty strings.
     1772    Multiple filters are separated with ';;'. For instance:
     1773
     1774    \code
    17181775    "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
    1719   \endcode
    1720 
    1721   The \a options argument holds various
    1722   options about how to run the dialog, see the QFileDialog::Option enum for
    1723   more information on the flags you can pass.
    1724 
    1725   The default filter can be chosen by setting \a selectedFilter to the desired value.
    1726 
    1727   The dialog's caption is set to \a caption. If \a caption is not
    1728   specified then a default caption will be used.
    1729 
    1730   Under Windows and Mac OS X, this static function will use the native
    1731   file dialog and not a QFileDialog.
    1732 
    1733   Note that on Windows the dialog will spin a blocking modal event loop
    1734   that will not dispatch any QTimers, and if parent is not 0 then it will
    1735   position the dialog just under the parent's title bar.
    1736   On Mac OS X, the filter argument is ignored.
    1737 
    1738   Under Unix/X11, the normal behavior of the file dialog is to resolve
    1739   and follow symlinks. For example, if \c{/usr/tmp} is a symlink to
    1740   \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after
    1741   entering \c{/usr/tmp}. If \a options includes DontResolveSymlinks,
    1742   the file dialog will treat symlinks as regular directories.
    1743 
    1744   \warning Do not delete \a parent during the execution of the dialog.
    1745            If you want to do this, you should create the dialog
    1746            yourself using one of the QFileDialog constructors.
    1747 
    1748   \sa getOpenFileName(), getOpenFileNames(), getExistingDirectory()
     1776    \endcode
     1777
     1778    The \a options argument holds various options about how to run the dialog,
     1779    see the QFileDialog::Option enum for more information on the flags you can
     1780    pass.
     1781
     1782    The default filter can be chosen by setting \a selectedFilter to the
     1783    desired value.
     1784
     1785    The dialog's caption is set to \a caption. If \a caption is not specified,
     1786    a default caption will be used.
     1787
     1788    On Windows and Mac OS X, this static function will use the native file
     1789    dialog and not a QFileDialog.
     1790
     1791    On Windows the dialog will spin a blocking modal event loop that will not
     1792    dispatch any QTimers, and if \a parent is not 0 then it will position the
     1793    dialog just below the parent's title bar. On Mac OS X, with its native file
     1794    dialog, the filter argument is ignored.
     1795
     1796    On Unix/X11, the normal behavior of the file dialog is to resolve and
     1797    follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},
     1798    the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If
     1799    \a options includes DontResolveSymlinks the file dialog will treat symlinks
     1800    as regular directories.
     1801
     1802    \warning Do not delete \a parent during the execution of the dialog. If you
     1803    want to do this, you should create the dialog yourself using one of the
     1804    QFileDialog constructors.
     1805
     1806    \sa getOpenFileName(), getOpenFileNames(), getExistingDirectory()
    17491807*/
    17501808QString QFileDialog::getSaveFileName(QWidget *parent,
     
    17551813                                     Options options)
    17561814{
    1757     if (qt_filedialog_save_filename_hook)
     1815    if (qt_filedialog_save_filename_hook && !(options & DontUseNativeDialog))
    17581816        return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options);
    17591817    QFileDialogArgs args;
     
    17871845
    17881846/*!
    1789   This is a convenience static function that will return an existing
    1790   directory selected by the user.
    1791 
    1792   \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 12
    1793 
    1794   This function creates a modal file dialog with the given \a parent
    1795   widget. If the parent is not 0, the dialog will be shown centered over
    1796   the parent widget.
    1797 
    1798   The dialog's working directory is set to \a dir, and the caption is
    1799   set to \a caption. Either of these may be an empty string in which case
    1800   the current directory and a default caption will be used
    1801   respectively.
    1802 
    1803   The \a options argument holds various
    1804   options about how to run the dialog, see the QFileDialog::Option enum for
    1805   more information on the flags you can pass. Note that \l{QFileDialog::}{ShowDirsOnly}
    1806   must be set to ensure a native file dialog.
    1807 
    1808   Under Windows and Mac OS X, this static function will use the native
    1809   file dialog and not a QFileDialog. On Mac OS X, the \a dir argument
    1810   is ignored, the native dialog always displays the last visited directory.
    1811   On Windows CE, if the device has no native file dialog, a QFileDialog
    1812   will be used.
    1813 
    1814   Under Unix/X11, the normal behavior of the file dialog is to resolve
    1815   and follow symlinks. For example, if \c{/usr/tmp} is a symlink to
    1816   \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after
    1817   entering \c{/usr/tmp}. If \a options includes DontResolveSymlinks,
    1818   the file dialog will treat symlinks as regular directories.
    1819 
    1820   Note that on Windows the dialog will spin a blocking modal event loop
    1821   that will not dispatch any QTimers, and if parent is not 0 then it will
    1822   position the dialog just under the parent's title bar.
    1823 
    1824   \warning Do not delete \a parent during the execution of the dialog.
    1825            If you want to do this, you should create the dialog
    1826            yourself using one of the QFileDialog constructors.
    1827 
    1828   \sa getOpenFileName(), getOpenFileNames(), getSaveFileName()
     1847    This is a convenience static function that will return an existing
     1848    directory selected by the user.
     1849
     1850    \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 12
     1851
     1852    This function creates a modal file dialog with the given \a parent widget.
     1853    If \a parent is not 0, the dialog will be shown centered over the parent
     1854    widget.
     1855
     1856    The dialog's working directory is set to \a dir, and the caption is set to
     1857    \a caption. Either of these may be an empty string in which case the
     1858    current directory and a default caption will be used respectively.
     1859
     1860    The \a options argument holds various options about how to run the dialog,
     1861    see the QFileDialog::Option enum for more information on the flags you can
     1862    pass. To ensure a native file dialog, \l{QFileDialog::}{ShowDirsOnly} must
     1863    be set.
     1864
     1865    On Windows and Mac OS X, this static function will use the native file
     1866    dialog and not a QFileDialog. On Windows CE, if the device has no native
     1867    file dialog, a QFileDialog will be used.
     1868
     1869    On Unix/X11, the normal behavior of the file dialog is to resolve and
     1870    follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},
     1871    the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If
     1872    \a options includes DontResolveSymlinks, the file dialog will treat
     1873    symlinks as regular directories.
     1874
     1875    On Windows the dialog will spin a blocking modal event loop that will not
     1876    dispatch any QTimers, and if \a parent is not 0 then it will position the
     1877    dialog just below the parent's title bar.
     1878
     1879    \warning Do not delete \a parent during the execution of the dialog. If you
     1880    want to do this, you should create the dialog yourself using one of the
     1881    QFileDialog constructors.
     1882
     1883    \sa getOpenFileName(), getOpenFileNames(), getSaveFileName()
    18291884*/
    18301885QString QFileDialog::getExistingDirectory(QWidget *parent,
     
    18331888                                          Options options)
    18341889{
    1835     if (qt_filedialog_existing_directory_hook)
     1890    if (qt_filedialog_existing_directory_hook && !(options & DontUseNativeDialog))
    18361891        return qt_filedialog_existing_directory_hook(parent, caption, dir, options);
    18371892    QFileDialogArgs args;
     
    18441899#if defined(Q_WS_WIN)
    18451900    if (qt_use_native_dialogs && !(args.options & DontUseNativeDialog) && (options & ShowDirsOnly)
    1846 #if defined(Q_OS_WINCE)
     1901#if defined(Q_WS_WINCE)
    18471902        && qt_priv_ptr_valid
    18481903#endif
     
    20582113#endif
    20592114
    2060 #ifdef Q_OS_WINCE
     2115#if defined(Q_EMBEDDED_SMALLSCREEN)
    20612116    qFileDialogUi->lookInLabel->setVisible(false);
    20622117    qFileDialogUi->fileNameLabel->setVisible(false);
     
    20902145    model->setNameFilterDisables(false);
    20912146#endif
    2092     QFileDialog::connect(model, SIGNAL(fileRenamed(const QString &, const QString &, const QString &)), q, SLOT(_q_fileRenamed(const QString &, const QString &, const QString &)));
    2093     QFileDialog::connect(model, SIGNAL(rootPathChanged(const QString &)),
    2094             q, SLOT(_q_pathChanged(const QString &)));
    2095     QFileDialog::connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
    2096             q, SLOT(_q_rowsInserted(const QModelIndex &)));
     2147    model->d_func()->disableRecursiveSort = true;
     2148    QFileDialog::connect(model, SIGNAL(fileRenamed(QString,QString,QString)), q, SLOT(_q_fileRenamed(QString,QString,QString)));
     2149    QFileDialog::connect(model, SIGNAL(rootPathChanged(QString)),
     2150            q, SLOT(_q_pathChanged(QString)));
     2151    QFileDialog::connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
     2152            q, SLOT(_q_rowsInserted(QModelIndex)));
    20972153    model->setReadOnly(false);
    20982154
    2099     qFileDialogUi = new Ui_QFileDialog();
     2155    qFileDialogUi.reset(new Ui_QFileDialog());
    21002156    qFileDialogUi->setupUi(q);
    21012157
     
    21042160                     << QUrl::fromLocalFile(QDir::homePath());
    21052161    qFileDialogUi->sidebar->init(model, initialBookmarks);
    2106     QFileDialog::connect(qFileDialogUi->sidebar, SIGNAL(goToUrl(const QUrl &)),
    2107                          q, SLOT(_q_goToUrl(const QUrl &)));
     2162    QFileDialog::connect(qFileDialogUi->sidebar, SIGNAL(goToUrl(QUrl)),
     2163                         q, SLOT(_q_goToUrl(QUrl)));
    21082164
    21092165    QObject::connect(qFileDialogUi->buttonBox, SIGNAL(accepted()), q, SLOT(accept()));
     
    21222178    qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit);
    21232179#endif
    2124 #ifndef QT_NO_COMPLETER
    2125     completer = new QFSCompletor(model, q);
     2180#ifndef QT_NO_FSCOMPLETER
     2181    completer = new QFSCompleter(model, q);
    21262182    qFileDialogUi->fileNameEdit->setCompleter(completer);
    2127     completer->sourceModel = model;
    21282183    QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),
    21292184            q, SLOT(_q_autoCompleteFileName(QString)));
    2130 #endif // QT_NO_COMPLETER
     2185#endif // QT_NO_FSCOMPLETER
    21312186    QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),
    21322187                     q, SLOT(_q_updateOkButton()));
     
    21402195    QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(int)),
    21412196                     q, SLOT(_q_useNameFilter(int)));
    2142     QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(const QString &)),
    2143                      q, SIGNAL(filterSelected(const QString &)));
     2197    QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(QString)),
     2198                     q, SIGNAL(filterSelected(QString)));
    21442199
    21452200    qFileDialogUi->listView->init(this);
     
    21672222    QActionGroup *showActionGroup = new QActionGroup(q);
    21682223    showActionGroup->setExclusive(false);
    2169     QObject::connect(showActionGroup, SIGNAL(triggered(QAction *)),
    2170                      q, SLOT(_q_showHeader(QAction *)));;
     2224    QObject::connect(showActionGroup, SIGNAL(triggered(QAction*)),
     2225                     q, SLOT(_q_showHeader(QAction*)));;
    21712226
    21722227    QAbstractItemModel *abstractModel = model;
     
    21822237    }
    21832238
    2184     QItemSelectionModel *selModel = qFileDialogUi->treeView->selectionModel();
     2239    QScopedPointer<QItemSelectionModel> selModel(qFileDialogUi->treeView->selectionModel());
    21852240    qFileDialogUi->treeView->setSelectionModel(qFileDialogUi->listView->selectionModel());
    2186     delete selModel;
     2241
    21872242    QObject::connect(qFileDialogUi->treeView, SIGNAL(activated(QModelIndex)),
    21882243                     q, SLOT(_q_enterDirectory(QModelIndex)));
     
    21972252    // Selections
    21982253    QItemSelectionModel *selections = qFileDialogUi->listView->selectionModel();
    2199     QObject::connect(selections, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
     2254    QObject::connect(selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
    22002255                     q, SLOT(_q_selectionChanged()));
    22012256    QObject::connect(selections, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
     
    22352290    QModelIndex idx = d->rootIndex();
    22362291    if (d->proxyModel) {
    2237         disconnect(d->proxyModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
    2238             this, SLOT(_q_rowsInserted(const QModelIndex &)));
     2292        disconnect(d->proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
     2293            this, SLOT(_q_rowsInserted(QModelIndex)));
    22392294    } else {
    2240         disconnect(d->model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
    2241             this, SLOT(_q_rowsInserted(const QModelIndex &)));
     2295        disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
     2296            this, SLOT(_q_rowsInserted(QModelIndex)));
    22422297    }
    22432298
     
    22482303        d->qFileDialogUi->listView->setModel(d->proxyModel);
    22492304        d->qFileDialogUi->treeView->setModel(d->proxyModel);
    2250 #ifndef QT_NO_COMPLETER
     2305#ifndef QT_NO_FSCOMPLETER
    22512306        d->completer->setModel(d->proxyModel);
    22522307        d->completer->proxyModel = d->proxyModel;
    22532308#endif
    2254         connect(d->proxyModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
    2255             this, SLOT(_q_rowsInserted(const QModelIndex &)));
     2309        connect(d->proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
     2310            this, SLOT(_q_rowsInserted(QModelIndex)));
    22562311    } else {
    22572312        d->proxyModel = 0;
    22582313        d->qFileDialogUi->listView->setModel(d->model);
    22592314        d->qFileDialogUi->treeView->setModel(d->model);
    2260 #ifndef QT_NO_COMPLETER
     2315#ifndef QT_NO_FSCOMPLETER
    22612316        d->completer->setModel(d->model);
    22622317        d->completer->sourceModel = d->model;
    22632318        d->completer->proxyModel = 0;
    22642319#endif
    2265         connect(d->model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
    2266             this, SLOT(_q_rowsInserted(const QModelIndex &)));
    2267     }
    2268     QItemSelectionModel *selModel = d->qFileDialogUi->treeView->selectionModel();
     2320        connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
     2321            this, SLOT(_q_rowsInserted(QModelIndex)));
     2322    }
     2323    QScopedPointer<QItemSelectionModel> selModel(d->qFileDialogUi->treeView->selectionModel());
    22692324    d->qFileDialogUi->treeView->setSelectionModel(d->qFileDialogUi->listView->selectionModel());
    2270     delete selModel;
     2325
    22712326    d->setRootIndex(idx);
    22722327
    22732328    // reconnect selection
    22742329    QItemSelectionModel *selections = d->qFileDialogUi->listView->selectionModel();
    2275     QObject::connect(selections, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
     2330    QObject::connect(selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
    22762331                     this, SLOT(_q_selectionChanged()));
    22772332    QObject::connect(selections, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
     
    26332688void QFileDialogPrivate::_q_autoCompleteFileName(const QString &text)
    26342689{
    2635     if (text.startsWith(QLatin1String("//")) || text.startsWith(QLatin1String("\\"))) {
     2690    if (text.startsWith(QLatin1String("//")) || text.startsWith(QLatin1Char('\\'))) {
    26362691        qFileDialogUi->listView->selectionModel()->clearSelection();
    26372692        return;
     
    26752730    QString lineEditText = lineEdit()->text();
    26762731
    2677     if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1String("\\"))) {
     2732    if (lineEditText.startsWith(QLatin1String("//")) || lineEditText.startsWith(QLatin1Char('\\'))) {
    26782733        button->setEnabled(true);
    26792734        if (acceptMode == QFileDialog::AcceptSave)
    2680             button->setText(isOpenDirectory ? QFileDialog::tr("&Open") : acceptLabel);
     2735            button->setText(acceptLabel);
    26812736        return;
    26822737    }
     
    27752830    Q_Q(QFileDialog);
    27762831    // My Computer or a directory
    2777     QModelIndex sourceIndex = mapToSource(index);
     2832    QModelIndex sourceIndex = index.model() == proxyModel ? mapToSource(index) : index;
    27782833    QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString();
    27792834    if (path.isEmpty() || model->isDir(sourceIndex)) {
     
    28272882}
    28282883
    2829 const char *qt_file_dialog_filter_reg_exp =
    2830     "^([^()]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
    2831 
    28322884// Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)"
    28332885QStringList qt_clean_filter_list(const QString &filter)
     
    30883140void QFileDialogListView::keyPressEvent(QKeyEvent *e)
    30893141{
    3090     if (!d_ptr->itemViewKeyboardEvent(e)) {
     3142#ifdef QT_KEYPAD_NAVIGATION
     3143    if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {
    30913144        QListView::keyPressEvent(e);
    3092     }
     3145        return;
     3146    }
     3147#endif // QT_KEYPAD_NAVIGATION
     3148
     3149    if (!d_ptr->itemViewKeyboardEvent(e))
     3150        QListView::keyPressEvent(e);
    30933151    e->accept();
    30943152}
     
    31173175void QFileDialogTreeView::keyPressEvent(QKeyEvent *e)
    31183176{
    3119     if (!d_ptr->itemViewKeyboardEvent(e)) {
     3177#ifdef QT_KEYPAD_NAVIGATION
     3178    if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {
    31203179        QTreeView::keyPressEvent(e);
    3121     }
     3180        return;
     3181    }
     3182#endif // QT_KEYPAD_NAVIGATION
     3183
     3184    if (!d_ptr->itemViewKeyboardEvent(e))
     3185        QTreeView::keyPressEvent(e);
    31223186    e->accept();
    31233187}
     
    31363200void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e)
    31373201{
     3202#ifdef QT_KEYPAD_NAVIGATION
     3203    if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {
     3204        QLineEdit::keyPressEvent(e);
     3205        return;
     3206    }
     3207#endif // QT_KEYPAD_NAVIGATION
     3208
    31383209    int key = e->key();
    31393210    QLineEdit::keyPressEvent(e);
     
    31473218}
    31483219
    3149 #ifndef QT_NO_COMPLETER
    3150 
    3151 QString QFSCompletor::pathFromIndex(const QModelIndex &index) const
     3220#ifndef QT_NO_FSCOMPLETER
     3221
     3222QString QFSCompleter::pathFromIndex(const QModelIndex &index) const
    31523223{
    31533224    const QFileSystemModel *dirModel;
     
    31643235}
    31653236
    3166 QStringList QFSCompletor::splitPath(const QString &path) const
     3237QStringList QFSCompleter::splitPath(const QString &path) const
    31673238{
    31683239    if (path.isEmpty())
     
    31713242    QString pathCopy = QDir::toNativeSeparators(path);
    31723243    QString sep = QDir::separator();
    3173 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
     3244#if defined(Q_OS_SYMBIAN)
     3245    if (pathCopy == QLatin1String("\\"))
     3246        return QStringList(pathCopy);
     3247#elif defined(Q_OS_WIN) || defined(Q_OS_OS2)
    31743248    if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))
    31753249        return QStringList(pathCopy);
     
    31813255#endif
    31823256
    3183     QRegExp re(QLatin1String("[") + QRegExp::escape(sep) + QLatin1String("]"));
    3184 
    3185 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
     3257    QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']'));
     3258
     3259#if defined(Q_OS_SYMBIAN)
     3260    QStringList parts = pathCopy.split(re, QString::SkipEmptyParts);
     3261    if (pathCopy.endsWith(sep))
     3262        parts.append(QString());
     3263#elif defined(Q_OS_WIN) || defined(Q_OS_OS2)
    31863264    QStringList parts = pathCopy.split(re, QString::SkipEmptyParts);
    31873265    if (!doubleSlash.isEmpty() && !parts.isEmpty())
     
    31953273#endif
    31963274
    3197 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
     3275#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) || defined(Q_OS_OS2)
    31983276    bool startsFromRoot = !parts.isEmpty() && parts[0].endsWith(QLatin1Char(':'));
    31993277#else
  • trunk/src/gui/dialogs/qfiledialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qfiledialog.ui

    r2 r561  
    33**
    44** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    5 ** Contact: Qt Software Information (qt-info@nokia.com)
     5** All rights reserved.
     6** Contact: Nokia Corporation (qt-info@nokia.com)
    67**
    78** This file is part of the QtGui module of the Qt Toolkit.
     
    2223** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2324**
    24 ** In addition, as a special exception, Nokia gives you certain
    25 ** additional rights. These rights are described in the Nokia Qt LGPL
    26 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    27 ** package.
     25** In addition, as a special exception, Nokia gives you certain additional
     26** rights.  These rights are described in the Nokia Qt LGPL Exception
     27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2828**
    2929** GNU General Public License Usage
     
    3535** met: http://www.gnu.org/copyleft/gpl.html.
    3636**
    37 ** If you are unsure which license is appropriate for your use, please
    38 ** contact the sales department at qt-sales@nokia.com.
     37** If you have questions regarding the use of this file, please contact
     38** Nokia at qt-info@nokia.com.
    3939** $QT_END_LICENSE$
    4040**
  • trunk/src/gui/dialogs/qfiledialog_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6363#include <qdesktopwidget.h>
    6464#include <stdlib.h>
     65#include <qabstracteventdispatcher.h>
    6566#include "ui_qfiledialog.h"
    6667
     
    246247        runModalForDirectory:mCurrentDir
    247248        file:selectable ? filename : @"untitled"];
     249
     250    QAbstractEventDispatcher::instance()->interrupt();
    248251    return (mReturnCode == NSOKButton);
    249252}
     
    278281{
    279282    Q_UNUSED(sender);
     283
     284    if ([filename length] == 0)
     285        return NO;
     286
    280287    QString qtFileName = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(filename);
    281288    QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C)));
     
    393400{
    394401    Q_UNUSED(sender);
    395     *mCurrentSelection = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString([mSavePanel filename]));
    396     if (mPriv)
    397         mPriv->QNSOpenSavePanelDelegate_selectionChanged(*mCurrentSelection);
     402    if (mPriv) {
     403        QString selection = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString([mSavePanel filename]));
     404        if (selection != mCurrentSelection) {
     405            *mCurrentSelection = selection;
     406            mPriv->QNSOpenSavePanelDelegate_selectionChanged(selection);
     407        }
     408    }
    398409}
    399410
     
    820831                // When changing directory, the current selection is cleared if
    821832                // we are supposed to be selecting files only:
    822                 fileDialogPrivate->mCurrentSelectionList.clear();
    823833                if (!fileDialogPrivate->mCurrentSelection.isEmpty()){
     834                    fileDialogPrivate->mCurrentSelectionList.clear();
    824835                    fileDialogPrivate->mCurrentSelection.clear();
    825836                    emit fileDialogPrivate->q_func()->currentChanged(fileDialogPrivate->mCurrentSelection);
     
    912923    navOptions.windowTitle = QCFString::toCFStringRef(q->windowTitle());
    913924
    914     static const int w = 450, h = 350;
    915     navOptions.location.h = navOptions.location.v = -1;
     925    navOptions.location.h = -1;
     926    navOptions.location.v = -1;
     927
    916928    QWidget *parent = q->parentWidget();
    917929    if (parent && parent->isVisible()) {
     
    921933        QString s = parent->windowTitle();
    922934        navOptions.clientName = QCFString::toCFStringRef(s);
    923         navOptions.location.h = (parent->x() + (parent->width() / 2)) - (w / 2);
    924         navOptions.location.v = (parent->y() + (parent->height() / 2)) - (h / 2);
    925 
    926         QRect r = QApplication::desktop()->screenGeometry(
    927                 QApplication::desktop()->screenNumber(parent));
    928         const int border = 10;
    929         if (navOptions.location.h + w > r.right())
    930             navOptions.location.h -= (navOptions.location.h + w) - r.right() + border;
    931         if (navOptions.location.v + h > r.bottom())
    932             navOptions.location.v -= (navOptions.location.v + h) - r.bottom() + border;
    933         if (navOptions.location.h < r.left())
    934             navOptions.location.h = r.left() + border;
    935         if (navOptions.location.v < r.top())
    936             navOptions.location.v = r.top() + border;
    937935    }
    938936
  • trunk/src/gui/dialogs/qfiledialog_p.h

    r172 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7474#include <qcompleter.h>
    7575#include <qpointer.h>
    76 #include <qtimeline.h>
    7776#include <qdebug.h>
    7877#include "qsidebar_p.h"
     78#include "qfscompleter_p.h"
     79#include "private/qguiplatformplugin_p.h"
     80
    7981
    8082#if defined (Q_OS_UNIX)
     
    9294class Ui_QFileDialog;
    9395
    94 #ifndef QT_NO_COMPLETER
    95 /*!
    96     QCompleter that can deal with QFileSystemModel
    97   */
    98 class QFSCompletor :  public QCompleter {
    99 public:
    100     QFSCompletor(QAbstractItemModel *model, QObject *parent = 0) : QCompleter(model, parent), proxyModel(0), sourceModel(0)
    101     {
    102 #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
    103         setCaseSensitivity(Qt::CaseInsensitive);
    104 #endif
    105     }
    106     QString pathFromIndex(const QModelIndex &index) const;
    107     QStringList splitPath(const QString& path) const;
    108 
    109     QAbstractProxyModel *proxyModel;
    110     QFileSystemModel *sourceModel;
    111 };
    112 #endif // QT_NO_COMPLETER
    11396
    11497struct QFileDialogArgs
     
    132115
    133116public:
    134     QFileDialogPrivate() :
    135 #ifndef QT_NO_PROXYMODEL
    136     proxyModel(0),
    137 #endif
    138     model(0),
    139     fileMode(QFileDialog::AnyFile),
    140     acceptMode(QFileDialog::AcceptOpen),
    141     currentHistoryLocation(-1),
    142     renameAction(0),
    143     deleteAction(0),
    144     showHiddenAction(0),
    145     useDefaultCaption(true),
    146     defaultFileTypes(true),
    147     fileNameLabelExplicitlySat(false),
    148     nativeDialogInUse(false),
    149 #ifdef Q_WS_MAC
    150     mDelegate(0),
    151 #ifndef QT_MAC_USE_COCOA
    152     mDialog(0),
    153     mDialogStarted(false),
    154     mDialogClosed(true),
    155 #endif
    156 #endif
    157     qFileDialogUi(0)
    158     {}
     117    QFileDialogPrivate();
    159118
    160119    void createToolButtons();
     
    188147        DWORD maxLength;
    189148        QString drive = path.left(3);
    190         if (QT_WA_INLINE(::GetVolumeInformationW(reinterpret_cast<const WCHAR *>(drive.utf16()), NULL, 0, NULL, &maxLength, NULL, NULL, 0),
    191             ::GetVolumeInformationA(drive.toLocal8Bit().constData(), NULL, 0, NULL, &maxLength, NULL, NULL, 0)) == FALSE)
     149        if (::GetVolumeInformation(reinterpret_cast<const wchar_t *>(drive.utf16()), NULL, 0, NULL, &maxLength, NULL, NULL, 0) == FALSE)
    192150            return -1;
    193151        return maxLength;
     
    228186    static inline QString toInternal(const QString &path)
    229187    {
    230 #if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX)
     188#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN)
    231189        QString n(path);
    232190        for (int i = 0; i < (int)n.length(); ++i)
     
    279237    QStringList watching;
    280238    QFileSystemModel *model;
    281     QFSCompletor *completer;
     239
     240#ifndef QT_NO_FSCOMPLETER
     241    QFSCompleter *completer;
     242#endif //QT_NO_FSCOMPLETER
    282243
    283244    QFileDialog::FileMode fileMode;
     
    361322#endif
    362323
    363     Ui_QFileDialog *qFileDialogUi;
     324    QScopedPointer<Ui_QFileDialog> qFileDialogUi;
    364325
    365326    QString acceptLabel;
     
    370331
    371332    QFileDialog::Options opts;
     333
     334    ~QFileDialogPrivate();
     335
     336private:
     337    Q_DISABLE_COPY(QFileDialogPrivate)
    372338};
    373339
     
    445411#ifndef Q_WS_MAC
    446412    // Dummies for platforms that don't use native dialogs:
    447     inline void QFileDialogPrivate::deleteNativeDialog_sys() {}
    448     inline bool QFileDialogPrivate::setVisible_sys(bool) { return false; }
    449     inline QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys(){ return QDialog::Rejected; }
    450     inline void QFileDialogPrivate::setDirectory_sys(const QString &) {}
    451     inline QString QFileDialogPrivate::directory_sys() const { return QString(); }
    452     inline void QFileDialogPrivate::selectFile_sys(const QString &) {}
    453     inline QStringList QFileDialogPrivate::selectedFiles_sys() const { return QStringList(); }
    454     inline void QFileDialogPrivate::setFilter_sys() {}
    455     inline void QFileDialogPrivate::setNameFilters_sys(const QStringList &) {}
    456     inline void QFileDialogPrivate::selectNameFilter_sys(const QString &) {}
    457     inline QString QFileDialogPrivate::selectedNameFilter_sys() const { return QString(); }
     413    inline void QFileDialogPrivate::deleteNativeDialog_sys() { qt_guiPlatformPlugin()->fileDialogDelete(q_func()); }
     414    inline bool QFileDialogPrivate::setVisible_sys(bool visible) { return qt_guiPlatformPlugin()->fileDialogSetVisible(q_func(), visible); }
     415    inline QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys(){ return qt_guiPlatformPlugin()->fileDialogResultCode(q_func()); }
     416    inline void QFileDialogPrivate::setDirectory_sys(const QString &directory) { qt_guiPlatformPlugin()->fileDialogSetDirectory(q_func(), directory); }
     417    inline QString QFileDialogPrivate::directory_sys() const { return qt_guiPlatformPlugin()->fileDialogDirectory(q_func()); }
     418    inline void QFileDialogPrivate::selectFile_sys(const QString &filename) { qt_guiPlatformPlugin()->fileDialogSelectFile(q_func(), filename); }
     419    inline QStringList QFileDialogPrivate::selectedFiles_sys() const { return qt_guiPlatformPlugin()->fileDialogSelectedFiles(q_func()); }
     420    inline void QFileDialogPrivate::setFilter_sys() { qt_guiPlatformPlugin()->fileDialogSetFilter(q_func()); }
     421    inline void QFileDialogPrivate::setNameFilters_sys(const QStringList &filters) { qt_guiPlatformPlugin()->fileDialogSetNameFilters(q_func(), filters); }
     422    inline void QFileDialogPrivate::selectNameFilter_sys(const QString &filter) { qt_guiPlatformPlugin()->fileDialogSelectNameFilter(q_func(), filter); }
     423    inline QString QFileDialogPrivate::selectedNameFilter_sys() const { return qt_guiPlatformPlugin()->fileDialogSelectedNameFilter(q_func()); }
    458424#endif
    459425
  • trunk/src/gui/dialogs/qfiledialog_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6060
    6161#include <shlobj.h>
    62 
    63 #ifdef Q_OS_WINCE
     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>
     65#endif
     66
     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
    6475#include <commdlg.h>
    6576#  ifndef BFFM_SETSELECTION
     
    7182    HWND          hwndOwner;
    7283    LPCITEMIDLIST pidlRoot;
    73     LPTSTR        pszDisplayName;
    74     LPCTSTR       lpszTitle;
     84    LPWSTR        pszDisplayName;
     85    LPCWSTR       lpszTitle;
    7586    UINT          ulFlags;
    7687    BFFCALLBACK   lpfn;
     
    91102typedef BOOL (WINAPI *PtrSHGetPathFromIDList)(LPITEMIDLIST,LPWSTR);
    92103static PtrSHGetPathFromIDList ptrSHGetPathFromIDList = 0;
     104typedef HRESULT (WINAPI *PtrSHGetMalloc)(LPMALLOC *);
     105static PtrSHGetMalloc ptrSHGetMalloc = 0;
     106
    93107
    94108QT_BEGIN_NAMESPACE
     
    112126
    113127        triedResolve = true;
    114         if (!(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)) {
    115 #if !defined(Q_OS_WINCE)
    116             QLibrary lib(QLatin1String("shell32"));
    117             ptrSHBrowseForFolder = (PtrSHBrowseForFolder) lib.resolve("SHBrowseForFolderW");
    118             ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList) lib.resolve("SHGetPathFromIDListW");
     128#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");
    119133#else
    120             // CE stores them in a different lib and does not use unicode version
    121             HINSTANCE handle = LoadLibraryW(L"Ceshell");
    122             ptrSHBrowseForFolder = (PtrSHBrowseForFolder)GetProcAddress(handle, L"SHBrowseForFolder");
    123             ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)GetProcAddress(handle, L"SHGetPathFromIDList");
    124             if (ptrSHBrowseForFolder && ptrSHGetPathFromIDList)
    125                 qt_priv_ptr_valid = true;
    126 #endif
    127         }
     134        // CE stores them in a different lib and does not use unicode version
     135        HINSTANCE handle = LoadLibraryW(L"Ceshell");
     136        ptrSHBrowseForFolder = (PtrSHBrowseForFolder)GetProcAddress(handle, L"SHBrowseForFolder");
     137        ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)GetProcAddress(handle, L"SHGetPathFromIDList");
     138        ptrSHGetMalloc = (PtrSHGetMalloc)GetProcAddress(handle, L"SHGetMalloc");
     139        if (ptrSHBrowseForFolder && ptrSHGetPathFromIDList && ptrSHGetMalloc)
     140            qt_priv_ptr_valid = true;
     141#endif
    128142    }
    129143}
     
    164178
    165179// Makes a NUL-oriented Windows filter from a Qt filter.
    166 static QString qt_win_filter(const QString &filter)
     180static QString qt_win_filter(const QString &filter, bool hideFiltersDetails)
    167181{
    168182    QStringList filterLst = qt_win_make_filters_list(filter);
    169183    QStringList::Iterator it = filterLst.begin();
    170184    QString winfilters;
     185    QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
    171186    for (; it != filterLst.end(); ++it) {
    172187        QString subfilter = *it;
    173188        if (!subfilter.isEmpty()) {
    174             winfilters += subfilter;
     189            if (hideFiltersDetails) {
     190                int index = r.indexIn(subfilter);
     191                if (index >= 0)
     192                    winfilters += r.cap(1);
     193            } else {
     194                winfilters += subfilter;
     195            }
    175196            winfilters += QChar();
    176197            winfilters += qt_win_extract_filter(subfilter);
     
    187208}
    188209
    189 #ifndef Q_OS_WINCE
    190 // Static vars for OFNA funcs:
    191 static QByteArray aInitDir;
    192 static QByteArray aInitSel;
    193 static QByteArray aTitle;
    194 static QByteArray aFilter;
    195 // Use ANSI strings and API
    196 
    197 // If you change this, then make sure you change qt_win_make_OFN (below) too
    198 static OPENFILENAMEA *qt_win_make_OFNA(QWidget *parent,
    199                                        const QString &initialSelection,
    200                                        const QString &initialDirectory,
    201                                        const QString &title,
    202                                        const QString &filters,
    203                                        QFileDialog::FileMode mode,
    204                                        QFileDialog::Options options)
    205 {
    206     if (parent)
    207         parent = parent->window();
    208     else
    209         parent = qApp->activeWindow();
    210 
    211     aTitle = title.toLocal8Bit();
    212     aInitDir = QDir::toNativeSeparators(initialDirectory).toLocal8Bit();
    213     if (initialSelection.isEmpty()) {
    214         aInitSel = "";
    215     } else {
    216         aInitSel = QDir::toNativeSeparators(initialSelection).toLocal8Bit();
    217         aInitSel.replace("<", "");
    218         aInitSel.replace(">", "");
    219         aInitSel.replace("\"", "");
    220         aInitSel.replace("|", "");
    221     }
    222     int maxLen = mode == QFileDialog::ExistingFiles ? maxMultiLen : maxNameLen;
    223     aInitSel.resize(maxLen + 1);                // make room for return value
    224     aFilter = filters.toLocal8Bit();
    225 
    226     OPENFILENAMEA* ofn = new OPENFILENAMEA;
    227     memset(ofn, 0, sizeof(OPENFILENAMEA));
    228 
    229 #if defined(Q_CC_BOR) && (WINVER >= 0x0500) && (_WIN32_WINNT >= 0x0500)
    230     // according to the MSDN, this should also be necessary for MSVC, but
    231     // OPENFILENAME_SIZE_VERSION_400A is in not Microsoft header, as it seems
    232     if (QApplication::winVersion()==Qt::WV_NT || QApplication::winVersion()&Qt::WV_DOS_based) {
    233         ofn->lStructSize = OPENFILENAME_SIZE_VERSION_400A;
    234     } else {
    235         ofn->lStructSize = sizeof(OPENFILENAMEA);
    236     }
    237 #else
    238     ofn->lStructSize = sizeof(OPENFILENAMEA);
    239 #endif
    240     Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
    241     ofn->hwndOwner = parent ? parent->winId() : 0;
    242     ofn->lpstrFilter = aFilter;
    243     ofn->lpstrFile = aInitSel.data();
    244     ofn->nMaxFile = maxLen;
    245     ofn->lpstrInitialDir = aInitDir.data();
    246     ofn->lpstrTitle = aTitle.data();
    247     ofn->Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER);
    248 
    249     if (mode == QFileDialog::ExistingFile ||
    250          mode == QFileDialog::ExistingFiles)
    251         ofn->Flags |= (OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST);
    252     if (mode == QFileDialog::ExistingFiles)
    253         ofn->Flags |= (OFN_ALLOWMULTISELECT);
    254     if (!(options & QFileDialog::DontConfirmOverwrite))
    255         ofn->Flags |= OFN_OVERWRITEPROMPT;
    256 
    257     return ofn;
    258 }
    259 
    260 static void qt_win_clean_up_OFNA(OPENFILENAMEA **ofn)
    261 {
    262     delete *ofn;
    263     *ofn = 0;
    264 }
    265 #endif
    266 
    267210static QString tFilters, tTitle, tInitDir;
    268211
    269 #ifdef UNICODE
    270 // If you change this, then make sure you change qt_win_make_OFNA (above) too
    271212static OPENFILENAME* qt_win_make_OFN(QWidget *parent,
    272213                                     const QString& initialSelection,
     
    275216                                     const QString& filters,
    276217                                     QFileDialog::FileMode mode,
    277                                      QFileDialog::Options options)
     218                                     QFileDialog::Options options)
    278219{
    279220    if (parent)
    280221        parent = parent->window();
    281222    else
    282         parent = qApp->activeWindow();
     223        parent = QApplication::activeWindow();
    283224
    284225    tInitDir = QDir::toNativeSeparators(initialDirectory);
     
    287228    QString initSel = QDir::toNativeSeparators(initialSelection);
    288229    if (!initSel.isEmpty()) {
    289         initSel.replace(QLatin1String("<"), QLatin1String(""));
    290         initSel.replace(QLatin1String(">"), QLatin1String(""));
    291         initSel.replace(QLatin1String("\""), QLatin1String(""));
    292         initSel.replace(QLatin1String("|"), QLatin1String(""));
     230        initSel.remove(QLatin1Char('<'));
     231        initSel.remove(QLatin1Char('>'));
     232        initSel.remove(QLatin1Char('\"'));
     233        initSel.remove(QLatin1Char('|'));
    293234    }
    294235
    295236    int maxLen = mode == QFileDialog::ExistingFiles ? maxMultiLen : maxNameLen;
    296     TCHAR *tInitSel = new TCHAR[maxLen+1];
     237    wchar_t *tInitSel = new wchar_t[maxLen + 1];
    297238    if (initSel.length() > 0 && initSel.length() <= maxLen)
    298239        memcpy(tInitSel, initSel.utf16(), (initSel.length()+1)*sizeof(QChar));
     
    303244    memset(ofn, 0, sizeof(OPENFILENAME));
    304245
    305 #if defined(Q_CC_BOR) && (WINVER >= 0x0500) && (_WIN32_WINNT >= 0x0500)
    306     // according to the MSDN, this should also be necessary for MSVC, but
    307     // OPENFILENAME_SIZE_VERSION_400 is in not Microsoft header, as it seems
    308     if (QApplication::winVersion()==Qt::WV_NT || QApplication::winVersion()&Qt::WV_DOS_based) {
    309         ofn->lStructSize= OPENFILENAME_SIZE_VERSION_400;
    310     } else {
    311         ofn->lStructSize = sizeof(OPENFILENAME);
    312     }
    313 #else
    314246    ofn->lStructSize = sizeof(OPENFILENAME);
    315 #endif
    316247    Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
    317248    ofn->hwndOwner = parent ? parent->winId() : 0;
    318     ofn->lpstrFilter = (TCHAR *)tFilters.utf16();
     249    ofn->lpstrFilter = (wchar_t*)tFilters.utf16();
    319250    ofn->lpstrFile = tInitSel;
    320251    ofn->nMaxFile = maxLen;
    321     ofn->lpstrInitialDir = (TCHAR *)tInitDir.utf16();
    322     ofn->lpstrTitle = (TCHAR *)tTitle.utf16();
    323     ofn->Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER);
     252    ofn->lpstrInitialDir = (wchar_t*)tInitDir.utf16();
     253    ofn->lpstrTitle = (wchar_t*)tTitle.utf16();
     254    ofn->Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_PATHMUSTEXIST);
    324255    if (mode == QFileDialog::ExistingFile ||
    325256         mode == QFileDialog::ExistingFiles)
    326         ofn->Flags |= (OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST);
     257        ofn->Flags |= (OFN_FILEMUSTEXIST);
    327258    if (mode == QFileDialog::ExistingFiles)
    328259        ofn->Flags |= (OFN_ALLOWMULTISELECT);
     
    333264}
    334265
    335 
    336266static void qt_win_clean_up_OFN(OPENFILENAME **ofn)
    337267{
     
    340270    *ofn = 0;
    341271}
    342 
    343 #endif // UNICODE
    344272
    345273extern void qt_win_eatMouseMove();
     
    378306    modal_widget.setParent(args.parent, Qt::Window);
    379307    QApplicationPrivate::enterModal(&modal_widget);
    380     QT_WA({
    381         // Use Unicode strings and API
    382         OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
    383                                             args.directory, args.caption,
    384                                             qt_win_filter(args.filter),
    385                                             QFileDialog::ExistingFile,
    386                                             args.options);
    387         if (idx)
    388             ofn->nFilterIndex = idx + 1;
    389         if (GetOpenFileName(ofn)) {
    390             result = QString::fromUtf16((ushort*)ofn->lpstrFile);
    391             selFilIdx = ofn->nFilterIndex;
    392         }
    393         qt_win_clean_up_OFN(&ofn);
    394     } , {
    395         // Use ANSI strings and API
    396         OPENFILENAMEA* ofn = qt_win_make_OFNA(args.parent, args.selection,
    397                                               args.directory, args.caption,
    398                                               qt_win_filter(args.filter),
    399                                               QFileDialog::ExistingFile,
    400                                               args.options);
    401         if (idx)
    402             ofn->nFilterIndex = idx + 1;
    403         if (GetOpenFileNameA(ofn)) {
    404             result = QString::fromLocal8Bit(ofn->lpstrFile);
    405             selFilIdx = ofn->nFilterIndex;
    406         }
    407         qt_win_clean_up_OFNA(&ofn);
    408     });
     308
     309    bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
     310    OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
     311                                        args.directory, args.caption,
     312                                        qt_win_filter(args.filter, hideFiltersDetails),
     313                                        QFileDialog::ExistingFile,
     314                                        args.options);
     315    if (idx)
     316        ofn->nFilterIndex = idx + 1;
     317    if (GetOpenFileName(ofn)) {
     318        result = QString::fromWCharArray(ofn->lpstrFile);
     319        selFilIdx = ofn->nFilterIndex;
     320    }
     321    qt_win_clean_up_OFN(&ofn);
     322
    409323    QApplicationPrivate::leaveModal(&modal_widget);
    410324
     
    423337QString qt_win_get_save_file_name(const QFileDialogArgs &args,
    424338                                  QString *initialDirectory,
    425                                   QString *selectedFilter)
     339                                  QString *selectedFilter)
    426340{
    427341    QString result;
     
    453367    modal_widget.setParent(args.parent, Qt::Window);
    454368    QApplicationPrivate::enterModal(&modal_widget);
    455 
     369    bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
    456370    // This block is used below for the lpstrDefExt member.
    457371    // Note that the current MSDN docs document this member wrong.
     
    471385    }
    472386
    473     QT_WA({
    474         // Use Unicode strings and API
    475         OPENFILENAME *ofn = qt_win_make_OFN(args.parent, args.selection,
    476                                             args.directory, args.caption,
    477                                             qt_win_filter(args.filter),
    478                                             QFileDialog::AnyFile,
    479                                             args.options);
    480 
    481         ofn->lpstrDefExt = (TCHAR *)defaultSaveExt.utf16();
    482 
    483         if (idx)
    484             ofn->nFilterIndex = idx + 1;
    485         if (GetSaveFileName(ofn)) {
    486             result = QString::fromUtf16((ushort*)ofn->lpstrFile);
    487             selFilIdx = ofn->nFilterIndex;
    488         }
    489         qt_win_clean_up_OFN(&ofn);
    490     } , {
    491         // Use ANSI strings and API
    492         OPENFILENAMEA *ofn = qt_win_make_OFNA(args.parent, args.selection,
    493                                               args.directory, args.caption,
    494                                               qt_win_filter(args.filter),
    495                                               QFileDialog::AnyFile,
    496                                               args.options);
    497         QByteArray asciiExt = defaultSaveExt.toAscii();
    498         ofn->lpstrDefExt = asciiExt.data();
    499 
    500         if (idx)
    501             ofn->nFilterIndex = idx + 1;
    502         if (GetSaveFileNameA(ofn)) {
    503             result = QString::fromLocal8Bit(ofn->lpstrFile);
    504             selFilIdx = ofn->nFilterIndex;
    505         }
    506         qt_win_clean_up_OFNA(&ofn);
    507     });
    508 #if defined(Q_OS_WINCE)
     387    OPENFILENAME *ofn = qt_win_make_OFN(args.parent, args.selection,
     388                                        args.directory, args.caption,
     389                                        qt_win_filter(args.filter, hideFiltersDetails),
     390                                        QFileDialog::AnyFile,
     391                                        args.options);
     392
     393    ofn->lpstrDefExt = (wchar_t*)defaultSaveExt.utf16();
     394
     395    if (idx)
     396        ofn->nFilterIndex = idx + 1;
     397    if (GetSaveFileName(ofn)) {
     398        result = QString::fromWCharArray(ofn->lpstrFile);
     399        selFilIdx = ofn->nFilterIndex;
     400    }
     401    qt_win_clean_up_OFN(&ofn);
     402
     403#if defined(Q_WS_WINCE)
    509404    int semIndex = result.indexOf(QLatin1Char(';'));
    510405    if (semIndex >= 0)
     
    526421}
    527422
    528 QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
     423
     424#if defined(USE_COMMON_ITEM_DIALOG)
     425
     426typedef HRESULT (WINAPI *PtrSHCreateItemFromParsingName)(PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv);
     427static PtrSHCreateItemFromParsingName pSHCreateItemFromParsingName = 0;
     428
     429static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd,
     430                                          const QString& initialSelection,
     431                                          const QString& initialDirectory,
     432                                          const QString& title,
     433                                          const QStringList& filterLst,
     434                                          QFileDialog::FileMode mode,
     435                                          QFileDialog::Options options)
     436{
     437    if (!pSHCreateItemFromParsingName) {
     438        // This function is available only in Vista & above.
     439        QLibrary shellLib(QLatin1String("Shell32"));
     440        pSHCreateItemFromParsingName = (PtrSHCreateItemFromParsingName)
     441            shellLib.resolve("SHCreateItemFromParsingName");
     442        if (!pSHCreateItemFromParsingName)
     443            return false;
     444    }
     445    HRESULT hr;
     446    QString winfilters;
     447    int numFilters = 0;
     448    quint32 currentOffset = 0;
     449    QList<quint32> offsets;
     450    QStringList::ConstIterator it = filterLst.begin();
     451    // Create the native filter string and save offset to each entry.
     452    for (; it != filterLst.end(); ++it) {
     453        QString subfilter = *it;
     454        if (!subfilter.isEmpty()) {
     455            offsets<<currentOffset;
     456            //Here the COMMON_ITEM_DIALOG API always add the details for the filter (e.g. *.txt)
     457            //so we don't need to handle the flag HideNameFilterDetails.
     458            winfilters += subfilter; // The name of the filter.
     459            winfilters += QChar();
     460            currentOffset += subfilter.size()+1;
     461            offsets<<currentOffset;
     462            QString spec = qt_win_extract_filter(subfilter);
     463            winfilters += spec; // The actual filter spec.
     464            winfilters += QChar();
     465            currentOffset += spec.size()+1;
     466            numFilters++;
     467        }
     468    }
     469    // Add the filters to the file dialog.
     470    if (numFilters) {
     471        wchar_t *szData = (wchar_t*)winfilters.utf16();
     472        COMDLG_FILTERSPEC *filterSpec = new COMDLG_FILTERSPEC[numFilters];
     473        for(int i = 0; i<numFilters; i++) {
     474            filterSpec[i].pszName = szData+offsets[i*2];
     475            filterSpec[i].pszSpec = szData+offsets[(i*2)+1];
     476        }
     477        hr = pfd->SetFileTypes(numFilters, filterSpec);
     478        delete []filterSpec;
     479    }
     480    // Set the starting folder.
     481    tInitDir = QDir::toNativeSeparators(initialDirectory);
     482    if (!tInitDir.isEmpty()) {
     483        IShellItem *psiDefaultFolder;
     484        hr = pSHCreateItemFromParsingName((wchar_t*)tInitDir.utf16(),
     485                                      NULL,
     486                                      IID_PPV_ARGS(&psiDefaultFolder));
     487
     488        if (SUCCEEDED(hr)) {
     489            hr = pfd->SetFolder(psiDefaultFolder);
     490            psiDefaultFolder->Release();
     491        }
     492    }
     493    // Set the currently selected file.
     494    QString initSel = QDir::toNativeSeparators(initialSelection);
     495    if (!initSel.isEmpty()) {
     496        initSel.remove(QLatin1Char('<'));
     497        initSel.remove(QLatin1Char('>'));
     498        initSel.remove(QLatin1Char('\"'));
     499        initSel.remove(QLatin1Char('|'));
     500    }
     501    if (!initSel.isEmpty()) {
     502        hr = pfd->SetFileName((wchar_t*)initSel.utf16());
     503    }
     504    // Set the title for the file dialog.
     505    if (!title.isEmpty()) {
     506        hr = pfd->SetTitle((wchar_t*)title.utf16());
     507    }
     508    // Set other flags for the dialog.
     509    DWORD newOptions;
     510    hr = pfd->GetOptions(&newOptions);
     511    if (SUCCEEDED(hr)) {
     512        newOptions |= FOS_NOCHANGEDIR;
     513        if (mode == QFileDialog::ExistingFile ||
     514             mode == QFileDialog::ExistingFiles)
     515            newOptions |= (FOS_FILEMUSTEXIST | FOS_PATHMUSTEXIST);
     516        if (mode == QFileDialog::ExistingFiles)
     517            newOptions |= FOS_ALLOWMULTISELECT;
     518        if (!(options & QFileDialog::DontConfirmOverwrite))
     519            newOptions |= FOS_OVERWRITEPROMPT;
     520        hr = pfd->SetOptions(newOptions);
     521    }
     522    return SUCCEEDED(hr);
     523}
     524
     525QStringList qt_win_CID_get_open_file_names(const QFileDialogArgs &args,
    529526                                       QString *initialDirectory,
    530                                        QString *selectedFilter)
     527                                       const QStringList &filterList,
     528                                       QString *selectedFilter,
     529                                       int selectedFilterIndex)
    531530{
    532531    QStringList result;
    533     QFileInfo fi;
    534     QDir dir;
    535     QString isel;
    536 
    537     if (initialDirectory && initialDirectory->left(5) == QLatin1String("file:"))
    538         initialDirectory->remove(0, 5);
    539     fi = QFileInfo(*initialDirectory);
    540 
    541     if (initialDirectory && !fi.isDir()) {
    542         *initialDirectory = fi.absolutePath();
    543         isel = fi.fileName();
    544     }
    545 
    546     if (!fi.exists())
    547         *initialDirectory = QDir::homePath();
    548 
    549     DWORD selFilIdx = 0;
    550 
    551     int idx = 0;
    552     if (selectedFilter) {
    553         QStringList filterLst = qt_win_make_filters_list(args.filter);
    554         idx = filterLst.indexOf(*selectedFilter);
    555     }
    556 
    557532    QDialog modal_widget;
    558533    modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
    559534    modal_widget.setParent(args.parent, Qt::Window);
    560535    QApplicationPrivate::enterModal(&modal_widget);
    561     QT_WA({
    562         OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
    563                                             args.directory, args.caption,
    564                                             qt_win_filter(args.filter),
    565                                             QFileDialog::ExistingFiles,
    566                                             args.options);
    567         if (idx)
    568             ofn->nFilterIndex = idx + 1;
    569         if (GetOpenFileName(ofn)) {
    570             QString fileOrDir = QString::fromUtf16((ushort*)ofn->lpstrFile);
    571             selFilIdx = ofn->nFilterIndex;
    572             int offset = fileOrDir.length() + 1;
    573             if (ofn->lpstrFile[offset] == 0) {
    574                 // Only one file selected; has full path
    575                 fi.setFile(fileOrDir);
     536    // Multiple selection is allowed only in IFileOpenDialog.
     537    IFileOpenDialog *pfd = 0;
     538    HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog,
     539                                  NULL,
     540                                  CLSCTX_INPROC_SERVER,
     541                                  IID_PPV_ARGS(&pfd));
     542
     543    if (SUCCEEDED(hr)) {
     544        qt_win_set_IFileDialogOptions(pfd, args.selection,
     545                                      args.directory, args.caption,
     546                                      filterList, QFileDialog::ExistingFiles,
     547                                      args.options);
     548        // Set the currently selected filter (one-based index).
     549        hr = pfd->SetFileTypeIndex(selectedFilterIndex+1);
     550        QWidget *parentWindow = args.parent;
     551        if (parentWindow)
     552            parentWindow = parentWindow->window();
     553        else
     554            parentWindow = QApplication::activeWindow();
     555        // Show the file dialog.
     556        hr = pfd->Show(parentWindow ? parentWindow->winId() : 0);
     557        if (SUCCEEDED(hr)) {
     558            // Retrieve the results.
     559            IShellItemArray *psiaResults;
     560            hr = pfd->GetResults(&psiaResults);
     561            if (SUCCEEDED(hr)) {
     562                DWORD numItems = 0;
     563                psiaResults->GetCount(&numItems);
     564                for (DWORD i = 0; i<numItems; i++) {
     565                    IShellItem *psi = 0;
     566                    hr = psiaResults->GetItemAt(i, &psi);
     567                    if (SUCCEEDED(hr)) {
     568                        // Retrieve the file name from shell item.
     569                        wchar_t *pszPath;
     570                        hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
     571                        if (SUCCEEDED(hr)) {
     572                            QString fileName = QString::fromWCharArray(pszPath);
     573                            result.append(fileName);
     574                            CoTaskMemFree(pszPath);
     575                        }
     576                        psi->Release(); // Free the current item.
     577                    }
     578                }
     579                psiaResults->Release(); // Free the array of items.
     580            }
     581        }
     582    }
     583    QApplicationPrivate::leaveModal(&modal_widget);
     584
     585    qt_win_eatMouseMove();
     586
     587    if (!result.isEmpty()) {
     588        // Retrieve the current folder name.
     589        IShellItem *psi = 0;
     590        hr = pfd->GetFolder(&psi);
     591        if (SUCCEEDED(hr)) {
     592            wchar_t *pszPath;
     593            hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
     594            if (SUCCEEDED(hr)) {
     595                *initialDirectory = QString::fromWCharArray(pszPath);
     596                CoTaskMemFree(pszPath);
     597            }
     598            psi->Release();
     599        }
     600        // Retrieve the currently selected filter.
     601        if (selectedFilter) {
     602            quint32 filetype = 0;
     603            hr = pfd->GetFileTypeIndex(&filetype);
     604            if (SUCCEEDED(hr) && filetype && filetype <= (quint32)filterList.length()) {
     605                // This is a one-based index, not zero-based.
     606                *selectedFilter = filterList[filetype-1];
     607            }
     608        }
     609    }
     610    if (pfd)
     611        pfd->Release();
     612    return result;
     613}
     614
     615#endif
     616
     617QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
     618                                       QString *initialDirectory,
     619                                       QString *selectedFilter)
     620{
     621    QFileInfo fi;
     622    QDir dir;
     623
     624    if (initialDirectory && initialDirectory->left(5) == QLatin1String("file:"))
     625        initialDirectory->remove(0, 5);
     626    fi = QFileInfo(*initialDirectory);
     627
     628    if (initialDirectory && !fi.isDir()) {
     629        *initialDirectory = fi.absolutePath();
     630    }
     631
     632    if (!fi.exists())
     633        *initialDirectory = QDir::homePath();
     634
     635    DWORD selFilIdx = 0;
     636
     637    QStringList filterLst = qt_win_make_filters_list(args.filter);
     638    int idx = 0;
     639    if (selectedFilter) {
     640        idx = filterLst.indexOf(*selectedFilter);
     641    }
     642    // Windows Vista (& above) allows users to search from file dialogs. If user selects
     643    // multiple files belonging to different folders from these search results, the
     644    // GetOpenFileName() will return only one folder name for all the files. To retrieve
     645    // the correct path for all selected files, we have to use Common Item Dialog interfaces.
     646#if defined(USE_COMMON_ITEM_DIALOG)
     647    if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)
     648        return qt_win_CID_get_open_file_names(args, initialDirectory, filterLst, selectedFilter, idx);
     649#endif
     650
     651    QStringList result;
     652    QDialog modal_widget;
     653    modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
     654    modal_widget.setParent(args.parent, Qt::Window);
     655    QApplicationPrivate::enterModal(&modal_widget);
     656
     657    bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
     658    OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
     659                                        args.directory, args.caption,
     660                                        qt_win_filter(args.filter, hideFiltersDetails),
     661                                        QFileDialog::ExistingFiles,
     662                                        args.options);
     663    if (idx)
     664        ofn->nFilterIndex = idx + 1;
     665    if (GetOpenFileName(ofn)) {
     666        QString fileOrDir = QString::fromWCharArray(ofn->lpstrFile);
     667        selFilIdx = ofn->nFilterIndex;
     668        int offset = fileOrDir.length() + 1;
     669        if (ofn->lpstrFile[offset] == 0) {
     670            // Only one file selected; has full path
     671            fi.setFile(fileOrDir);
     672            QString res = fi.absoluteFilePath();
     673            if (!res.isEmpty())
     674                result.append(res);
     675        }
     676        else {
     677            // Several files selected; first string is path
     678            dir.setPath(fileOrDir);
     679            QString f;
     680            while(!(f = QString::fromWCharArray(ofn->lpstrFile + offset)).isEmpty()) {
     681                fi.setFile(dir, f);
    576682                QString res = fi.absoluteFilePath();
    577683                if (!res.isEmpty())
    578684                    result.append(res);
     685                offset += f.length() + 1;
    579686            }
    580             else {
    581                 // Several files selected; first string is path
    582                 dir.setPath(fileOrDir);
    583                 QString f;
    584                 while(!(f = QString::fromUtf16((ushort*)ofn->lpstrFile+offset)).isEmpty()) {
    585                     fi.setFile(dir, f);
    586                     QString res = fi.absoluteFilePath();
    587                     if (!res.isEmpty())
    588                         result.append(res);
    589                     offset += f.length() + 1;
    590                 }
    591             }
    592         }
    593         qt_win_clean_up_OFN(&ofn);
    594     } , {
    595         OPENFILENAMEA* ofn = qt_win_make_OFNA(args.parent, args.selection,
    596                                               args.directory, args.caption,
    597                                               qt_win_filter(args.filter),
    598                                               QFileDialog::ExistingFiles,
    599                                               args.options);
    600         if (idx)
    601             ofn->nFilterIndex = idx + 1;
    602         if (GetOpenFileNameA(ofn)) {
    603             QByteArray fileOrDir(ofn->lpstrFile);
    604             selFilIdx = ofn->nFilterIndex;
    605             int offset = fileOrDir.length() + 1;
    606             if (ofn->lpstrFile[offset] == '\0') {
    607                 // Only one file selected; has full path
    608                 fi.setFile(QString::fromLocal8Bit(fileOrDir));
    609                 QString res = fi.absoluteFilePath();
    610                 if (!res.isEmpty())
    611                     result.append(res);
    612             }
    613             else {
    614                 // Several files selected; first string is path
    615                 dir.setPath(QString::fromLocal8Bit(fileOrDir));
    616                 QByteArray f;
    617                 while (!(f = QByteArray(ofn->lpstrFile + offset)).isEmpty()) {
    618                     fi.setFile(dir, QString::fromLocal8Bit(f));
    619                     QString res = fi.absoluteFilePath();
    620                     if (!res.isEmpty())
    621                         result.append(res);
    622                     offset += f.length() + 1;
    623                 }
    624             }
    625             qt_win_clean_up_OFNA(&ofn);
    626         }
    627     });
     687        }
     688    }
     689    qt_win_clean_up_OFN(&ofn);
     690
    628691    QApplicationPrivate::leaveModal(&modal_widget);
    629692
     
    648711        QString *initDir = (QString *)(lpData);
    649712        if (!initDir->isEmpty()) {
    650             // ### Lars asks: is this correct for the A version????
    651             QT_WA({
    652                 SendMessage(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initDir->utf16()));
    653             } , {
    654                 SendMessageA(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initDir->utf16()));
    655             });
     713            SendMessage(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initDir->utf16()));
    656714        }
    657715    } else if (uMsg == BFFM_SELCHANGED) {
    658         QT_WA({
    659             qt_win_resolve_libs();
    660             TCHAR path[MAX_PATH];
     716        qt_win_resolve_libs();
     717        if (ptrSHGetPathFromIDList) {
     718            wchar_t path[MAX_PATH];
    661719            ptrSHGetPathFromIDList(LPITEMIDLIST(lParam), path);
    662             QString tmpStr = QString::fromUtf16((ushort*)path);
     720            QString tmpStr = QString::fromWCharArray(path);
    663721            if (!tmpStr.isEmpty())
    664722                SendMessage(hwnd, BFFM_ENABLEOK, 1, 1);
     
    666724                SendMessage(hwnd, BFFM_ENABLEOK, 0, 0);
    667725            SendMessage(hwnd, BFFM_SETSTATUSTEXT, 1, LPARAM(path));
    668         } , {
    669             char path[MAX_PATH];
    670             SHGetPathFromIDListA(LPITEMIDLIST(lParam), path);
    671             QString tmpStr = QString::fromLocal8Bit(path);
    672             if (!tmpStr.isEmpty())
    673                 SendMessageA(hwnd, BFFM_ENABLEOK, 1, 1);
    674             else
    675                 SendMessageA(hwnd, BFFM_ENABLEOK, 0, 0);
    676             SendMessageA(hwnd, BFFM_SETSTATUSTEXT, 1, LPARAM(path));
    677         });
     726        }
    678727    }
    679728    return 0;
     
    693742        parent = parent->window();
    694743    else
    695         parent = qApp->activeWindow();
     744        parent = QApplication::activeWindow();
    696745    if (parent)
    697746        parent->createWinId();
     
    701750    modal_widget.setParent(parent, Qt::Window);
    702751    QApplicationPrivate::enterModal(&modal_widget);
    703 #if !defined(Q_OS_WINCE)
    704     QT_WA({
    705         qt_win_resolve_libs();
    706         QString initDir = QDir::toNativeSeparators(args.directory);
    707         TCHAR path[MAX_PATH];
    708         TCHAR initPath[MAX_PATH];
    709         initPath[0] = 0;
    710         path[0] = 0;
    711         tTitle = args.caption;
    712         BROWSEINFO bi;
    713         Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
    714         bi.hwndOwner = (parent ? parent->winId() : 0);
    715         bi.pidlRoot = NULL;
    716         //### This does not seem to be respected? - the dialog always displays "Browse for folder"
    717         bi.lpszTitle = (TCHAR*)tTitle.utf16();
    718         bi.pszDisplayName = initPath;
    719         bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE;
    720         bi.lpfn = winGetExistDirCallbackProc;
    721         bi.lParam = LPARAM(&initDir);
    722         if (ptrSHBrowseForFolder) {
    723             LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder(&bi);
    724             if (pItemIDList && ptrSHGetPathFromIDList) {
    725                 ptrSHGetPathFromIDList(pItemIDList, path);
    726                 IMalloc *pMalloc;
    727                 if (SHGetMalloc(&pMalloc) != NOERROR)
    728                     result = QString();
    729                 else {
    730                     pMalloc->Free(pItemIDList);
    731                     pMalloc->Release();
    732                     result = QString::fromUtf16((ushort*)path);
    733                 }
    734             } else
    735                 result = QString();
    736         }
    737         tTitle = QString();
    738     } , {
    739         QString initDir = QDir::toNativeSeparators(args.directory);
    740         char path[MAX_PATH];
    741         char initPath[MAX_PATH];
    742         QByteArray ctitle = args.caption.toLocal8Bit();
    743         initPath[0]=0;
    744         path[0]=0;
    745         BROWSEINFOA bi;
    746         Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
    747         bi.hwndOwner = (parent ? parent->winId() : 0);
    748         bi.pidlRoot = NULL;
    749         bi.lpszTitle = ctitle;
    750         bi.pszDisplayName = initPath;
    751         bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE;
    752         bi.lpfn = winGetExistDirCallbackProc;
    753         bi.lParam = LPARAM(&initDir);
    754         LPITEMIDLIST pItemIDList = SHBrowseForFolderA(&bi);
    755         if (pItemIDList) {
    756             SHGetPathFromIDListA(pItemIDList, path);
    757             IMalloc *pMalloc;
    758             if (SHGetMalloc(&pMalloc) != NOERROR)
    759                 result = QString();
    760             else {
    761                 pMalloc->Free(pItemIDList);
    762                 pMalloc->Release();
    763                 result = QString::fromLocal8Bit(path);
    764             }
    765         } else
    766             result = QString();
    767     });
     752
     753    QString initDir = QDir::toNativeSeparators(args.directory);
     754    wchar_t path[MAX_PATH];
     755    wchar_t initPath[MAX_PATH];
     756    initPath[0] = 0;
     757    path[0] = 0;
     758    tTitle = args.caption;
     759
     760#if !defined(Q_WS_WINCE)
     761    BROWSEINFO bi;
    768762#else
    769     qt_win_resolve_libs();
    770     QString initDir = QDir::toNativeSeparators(args.directory);
    771     TCHAR path[MAX_PATH];
    772     TCHAR initPath[MAX_PATH];
    773     memset(initPath, 0 , MAX_PATH*sizeof(TCHAR));
    774     memset(path, 0, MAX_PATH*sizeof(TCHAR));
    775     tTitle = args.caption;
    776763    qt_BROWSEINFO bi;
     764#endif
     765
    777766    Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
    778767    bi.hwndOwner = (parent ? parent->winId() : 0);
    779768    bi.pidlRoot = NULL;
    780     bi.lpszTitle = (TCHAR*)tTitle.utf16();
     769    //### This does not seem to be respected? - the dialog always displays "Browse for folder"
     770    bi.lpszTitle = (wchar_t*)tTitle.utf16();
    781771    bi.pszDisplayName = initPath;
    782772    bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_NEWDIALOGSTYLE;
    783773    bi.lpfn = winGetExistDirCallbackProc;
    784774    bi.lParam = LPARAM(&initDir);
     775
     776    qt_win_resolve_libs();
    785777    if (ptrSHBrowseForFolder) {
    786778        LPITEMIDLIST pItemIDList = ptrSHBrowseForFolder((BROWSEINFO*)&bi);
    787         if (pItemIDList && ptrSHGetPathFromIDList) {
     779        if (pItemIDList) {
    788780            ptrSHGetPathFromIDList(pItemIDList, path);
    789781            IMalloc *pMalloc;
    790             if (SHGetMalloc(&pMalloc) != NOERROR)
    791                 result = QString();
    792             else {
     782            if (ptrSHGetMalloc(&pMalloc) == NOERROR) {
    793783                pMalloc->Free(pItemIDList);
    794784                pMalloc->Release();
    795                 result = QString::fromUtf16((ushort*)path);
     785                result = QString::fromWCharArray(path);
    796786            }
    797         } else
    798             result = QString();
     787        }
    799788    }
    800789    tTitle = QString();
    801790
    802 #endif
    803791    QApplicationPrivate::leaveModal(&modal_widget);
    804792
    805793    qt_win_eatMouseMove();
    806794
    807     // Due to a bug on Windows Me, we need to reset the current
    808     // directory
    809     if ((QSysInfo::WindowsVersion == QSysInfo::WV_98 || QSysInfo::WindowsVersion == QSysInfo::WV_Me)
    810         && QDir::currentPath() != currentDir)
    811         QDir::setCurrent(currentDir);
    812 
    813795    if (!result.isEmpty())
    814         result.replace(QLatin1String("\\"), QLatin1String("/"));
     796        result.replace(QLatin1Char('\\'), QLatin1Char('/'));
    815797    return result;
    816798}
  • trunk/src/gui/dialogs/qfileinfogatherer.cpp

    r172 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545#include <qdiriterator.h>
    4646#ifndef Q_OS_WIN
    47 #include <unistd.h>
    48 #include <sys/types.h>
     47#  include <unistd.h>
     48#  include <sys/types.h>
     49#endif
     50#if defined(Q_OS_VXWORKS)
     51#  include "qplatformdefs.h"
    4952#endif
    5053
     
    7376#ifndef QT_NO_FILESYSTEMWATCHER
    7477    watcher = new QFileSystemWatcher(this);
    75     connect(watcher, SIGNAL(directoryChanged(const QString &)), this, SLOT(list(const QString &)));
    76     connect(watcher, SIGNAL(fileChanged(const QString &)), this, SLOT(updateFile(const QString &)));
     78    connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString)));
     79    connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
    7780#endif
    7881    start(LowPriority);
     
    8487QFileInfoGatherer::~QFileInfoGatherer()
    8588{
    86     mutex.lock();
     89    QMutexLocker locker(&mutex);
    8790    abort = true;
    8891    condition.wakeOne();
    89     mutex.unlock();
     92    locker.unlock();
    9093    wait();
    9194}
     
    9598    Q_UNUSED(enable);
    9699#ifdef Q_OS_WIN
    97     mutex.lock();
     100    QMutexLocker locker(&mutex);
    98101    m_resolveSymlinks = enable;
    99     mutex.unlock();
    100102#endif
    101103}
     
    108110void QFileInfoGatherer::setIconProvider(QFileIconProvider *provider)
    109111{
    110     mutex.lock();
     112    QMutexLocker locker(&mutex);
    111113    m_iconProvider = provider;
    112     mutex.unlock();
    113114}
    114115
     
    125126void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStringList &files)
    126127{
    127     mutex.lock();
     128    QMutexLocker locker(&mutex);
    128129    // See if we already have this dir/file in our que
    129130    int loc = this->path.lastIndexOf(path);
    130131    while (loc > 0)  {
    131132        if (this->files.at(loc) == files) {
    132             mutex.unlock();
    133133            return;
    134134        }
     
    138138    this->files.push(files);
    139139    condition.wakeAll();
    140     mutex.unlock();
    141140}
    142141
     
    161160{
    162161#ifndef QT_NO_FILESYSTEMWATCHER
    163     mutex.lock();
     162    QMutexLocker locker(&mutex);
    164163    watcher->removePaths(watcher->files());
    165164    watcher->removePaths(watcher->directories());
    166     mutex.unlock();
    167165#endif
    168166}
     
    176174{
    177175#ifndef QT_NO_FILESYSTEMWATCHER
    178     mutex.lock();
     176    QMutexLocker locker(&mutex);
    179177    watcher->removePath(path);
    180     mutex.unlock();
    181178#endif
    182179}
     
    199196    forever {
    200197        bool updateFiles = false;
    201         mutex.lock();
     198        QMutexLocker locker(&mutex);
    202199        if (abort) {
    203             mutex.unlock();
    204200            return;
    205201        }
     
    215211            updateFiles = true;
    216212        }
    217         mutex.unlock();
    218         if (updateFiles) getFileInfos(path, list);
     213        locker.unlock();
     214        if (updateFiles)
     215            getFileInfos(path, list);
    219216    }
    220217}
     
    288285    if (driveName.startsWith(QLatin1Char('/'))) // UNC host
    289286        return drive.fileName();
     287#endif
     288#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
    290289    if (driveName.endsWith(QLatin1Char('/')))
    291290        driveName.chop(1);
  • trunk/src/gui/dialogs/qfileinfogatherer_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    185185    QMutex mutex;
    186186    QWaitCondition condition;
    187     bool abort;
     187    volatile bool abort;
    188188
    189189    QStack<QString> path;
  • trunk/src/gui/dialogs/qfilesystemmodel.cpp

    r173 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5050
    5151#ifdef Q_OS_WIN
    52 #include <windows.h>
     52#include <qt_windows.h>
    5353#endif
    5454
     
    297297                QString longSection = QDir::toNativeSeparators(section);
    298298#endif
    299                 QT_WA({
    300                     WIN32_FIND_DATAW findData;
    301                     h = ::FindFirstFileW((wchar_t *)longSection.utf16(), &findData);
    302                     if (h != INVALID_HANDLE_VALUE)
    303                         longPath.append(QString::fromUtf16((ushort*)findData.cFileName));
    304                     } , {
    305                     WIN32_FIND_DATAA findData;
    306                     h = ::FindFirstFileA(section.toLocal8Bit(), &findData);
    307                     if (h != INVALID_HANDLE_VALUE)
    308                         longPath.append(QString::fromLocal8Bit(findData.cFileName));
    309                 });
    310                 if (h == INVALID_HANDLE_VALUE) {
     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 {
    311305                    longPath.append(section);
    312306                    break;
    313                 } else {
    314                     ::FindClose(h);
    315307                }
    316308            }
     
    338330    Q_Q(const QFileSystemModel);
    339331    Q_UNUSED(q);
    340     if (path.isEmpty() || path == myComputer() || path.startsWith(QLatin1String(":")))
     332    if (path.isEmpty() || path == myComputer() || path.startsWith(QLatin1Char(':')))
    341333        return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
    342334
     
    355347    QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts);
    356348    if ((pathElements.isEmpty())
    357 #if !defined(Q_OS_OS2) && (!defined(Q_OS_WIN) || defined(Q_OS_WINCE))
     349#if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_OS2)
    358350        && QDir::fromNativeSeparators(longPath) != QLatin1String("/")
    359351#endif
     
    384376        index = q->index(r, 0, QModelIndex());
    385377        pathElements.pop_front();
    386     } else {
    387         if (!pathElements.at(0).contains(QLatin1String(":")))
    388             pathElements.prepend(QDir(longPath).rootPath());
     378    } else
     379#endif
     380
     381#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
     382    {
     383        if (!pathElements.at(0).contains(QLatin1String(":"))) {
     384            // The reason we express it like this instead of with anonymous, temporary
     385            // variables, is to workaround a compiler crash with Q_CC_NOKIAX86.
     386            QString rootPath = QDir(longPath).rootPath();
     387            pathElements.prepend(rootPath);
     388        }
    389389        if (pathElements.at(0).endsWith(QLatin1Char('/')))
    390390            pathElements[0].chop(1);
     
    880880            return pixmap;
    881881        }
     882        break;
    882883    case Qt::TextAlignmentRole:
    883884        return Qt::AlignLeft;
     
    10831084void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent)
    10841085{
     1086    Q_Q(QFileSystemModel);
    10851087    QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent);
    10861088    if (indexNode->children.count() == 0)
     
    11021104    // First update the new visible list
    11031105    indexNode->visibleChildren.clear();
     1106    //No more dirty item we reset our internal dirty index
     1107    indexNode->dirtyChildrenIndex = -1;
    11041108    for (int i = 0; i < values.count(); ++i) {
    11051109        indexNode->visibleChildren.append(values.at(i).first->fileName);
    11061110        values.at(i).first->isVisible = true;
     1111    }
     1112
     1113    if (!disableRecursiveSort) {
     1114        for (int i = 0; i < q->rowCount(parent); ++i) {
     1115            const QModelIndex childIndex = q->index(i, 0, parent);
     1116            QFileSystemModelPrivate::QFileSystemNode *indexNode = node(childIndex);
     1117            //Only do a recursive sort on visible nodes
     1118            if (indexNode->isVisible)
     1119                sortChildren(column, childIndex);
     1120        }
    11071121    }
    11081122}
     
    13961410    Q_D(QFileSystemModel);
    13971411    d->fileInfoGatherer.setIconProvider(provider);
    1398     qApp->processEvents();
     1412    QApplication::processEvents();
    13991413    d->root.updateIcon(provider, QString());
    14001414}
     
    15851599        return;
    15861600    QStringList toRemove;
     1601#if defined(Q_OS_SYMBIAN)
     1602    // Filename case must be exact in qBinaryFind below, so create a list of all lowercase names.
     1603    QStringList newFiles;
     1604    for(int i = 0; i < files.size(); i++) {
     1605        newFiles << files.at(i).toLower();
     1606    }
     1607#else
    15871608    QStringList newFiles = files;
     1609#endif
    15881610    qSort(newFiles.begin(), newFiles.end());
    15891611    QHash<FileNameKey, QFileSystemNode*>::const_iterator i = parentNode->children.constBegin();
    15901612    while (i != parentNode->children.constEnd()) {
    15911613        QStringList::iterator iterator;
    1592         iterator = qBinaryFind(newFiles.begin(), newFiles.end(), i.value()->fileName);
     1614        iterator = qBinaryFind(newFiles.begin(), newFiles.end(),
     1615#if defined(Q_OS_SYMBIAN)
     1616                    i.value()->fileName.toLower());
     1617#else
     1618                    i.value()->fileName);
     1619#endif
    15931620        if (iterator == newFiles.end()) {
    15941621            toRemove.append(i.value()->fileName);
     
    16811708        q->beginInsertRows(parent, parentNode->visibleChildren.count() , parentNode->visibleChildren.count() + newFiles.count() - 1);
    16821709    }
     1710
     1711    if (parentNode->dirtyChildrenIndex == -1)
     1712        parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count();
     1713
    16831714    for (int i = 0; i < newFiles.count(); ++i) {
    16841715            parentNode->visibleChildren.append(newFiles.at(i));
     
    18331864    Q_Q(QFileSystemModel);
    18341865    qRegisterMetaType<QList<QPair<QString,QFileInfo> > >("QList<QPair<QString,QFileInfo> >");
    1835     q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(const QString &, const QStringList &)),
    1836                q, SLOT(_q_directoryChanged(const QString &, const QStringList &)));
    1837     q->connect(&fileInfoGatherer, SIGNAL(updates(const QString &, const QList<QPair<QString, QFileInfo> > &)),
    1838             q, SLOT(_q_fileSystemChanged(const QString &, const QList<QPair<QString, QFileInfo> > &)));
    1839     q->connect(&fileInfoGatherer, SIGNAL(nameResolved(const QString &, const QString &)),
    1840             q, SLOT(_q_resolvedName(const QString &, const QString &)));
     1866    q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(QString,QStringList)),
     1867               q, SLOT(_q_directoryChanged(QString,QStringList)));
     1868    q->connect(&fileInfoGatherer, SIGNAL(updates(QString,QList<QPair<QString,QFileInfo> >)),
     1869            q, SLOT(_q_fileSystemChanged(QString,QList<QPair<QString,QFileInfo> >)));
     1870    q->connect(&fileInfoGatherer, SIGNAL(nameResolved(QString,QString)),
     1871            q, SLOT(_q_resolvedName(QString,QString)));
    18411872    q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection);
    18421873}
     
    19131944}
    19141945
     1946QT_END_NAMESPACE
     1947
    19151948#include "moc_qfilesystemmodel.cpp"
    19161949
    19171950#endif // QT_NO_FILESYSTEMMODEL
    1918 
    1919 QT_END_NAMESPACE
  • trunk/src/gui/dialogs/qfilesystemmodel.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    159159    Q_PRIVATE_SLOT(d_func(), void _q_fileSystemChanged(const QString &path, const QList<QPair<QString, QFileInfo> > &))
    160160    Q_PRIVATE_SLOT(d_func(), void _q_resolvedName(const QString &fileName, const QString &resolvedName))
     161
     162    friend class QFileDialogPrivate;
    161163};
    162164
  • trunk/src/gui/dialogs/qfilesystemmodel_p.h

    r173 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    108108    public:
    109109        QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = 0)
    110             : fileName(filename), populatedChildren(false), isVisible(false), parent(p), info(0) {}
     110            : fileName(filename), populatedChildren(false), isVisible(false), dirtyChildrenIndex(-1), parent(p), info(0) {}
    111111        ~QFileSystemNode() {
    112112            QHash<FileNameKey, QFileSystemNode*>::const_iterator i = children.constBegin();
     
    187187            QHash<FileNameKey, QFileSystemNode *>::const_iterator iterator;
    188188            for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) {
    189                 iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
     189                //On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
     190                if (!path.isEmpty()) {
     191                    if (path.endsWith(QLatin1Char('/')))
     192                        iterator.value()->updateIcon(iconProvider, path + iterator.value()->fileName);
     193                    else
     194                        iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
     195                } else
     196                    iterator.value()->updateIcon(iconProvider, iterator.value()->fileName);
    190197            }
    191198        }
     
    196203            QHash<FileNameKey, QFileSystemNode *>::const_iterator iterator;
    197204            for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) {
    198                  iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
     205                //On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
     206                if (!path.isEmpty()) {
     207                    if (path.endsWith(QLatin1Char('/')))
     208                        iterator.value()->retranslateStrings(iconProvider, path + iterator.value()->fileName);
     209                    else
     210                        iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
     211                } else
     212                    iterator.value()->retranslateStrings(iconProvider, iterator.value()->fileName);
    199213            }
    200214        }
     
    204218        QHash<FileNameKey, QFileSystemNode *> children;
    205219        QList<QString> visibleChildren;
     220        int dirtyChildrenIndex;
    206221        QFileSystemNode *parent;
    207222
     
    218233            setRootPath(false),
    219234            filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs),
    220             nameFilterDisables(true) // false on windows, true on mac and unix
     235            nameFilterDisables(true), // false on windows, true on mac and unix
     236            disableRecursiveSort(false)
    221237    {
    222238        delayedSortTimer.setSingleShot(true);
     
    246262
    247263    inline int translateVisibleLocation(QFileSystemNode *parent, int row) const {
    248         return (sortOrder == Qt::AscendingOrder) ? row : parent->visibleChildren.count() - row - 1;
     264        if (sortOrder == Qt::AscendingOrder)
     265                return row;
     266        if (parent->dirtyChildrenIndex == -1 || row < parent->dirtyChildrenIndex)
     267            if (parent->dirtyChildrenIndex != -1)
     268                return parent->dirtyChildrenIndex - row - 1;
     269            else
     270                return parent->visibleChildren.count() - row - 1;
     271        else
     272            return row;
    249273    }
    250274
     
    304328    QHash<const QFileSystemNode*, bool> bypassFilters;
    305329    bool nameFilterDisables;
     330    //This flag is an optimization for the QFileDialog
     331    //It enable a sort which is not recursive, it means
     332    //we sort only what we see.
     333    bool disableRecursiveSort;
    306334#ifndef QT_NO_REGEXP
    307335    QList<QRegExp> nameFilters;
  • trunk/src/gui/dialogs/qfontdialog.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6666#include <private/qfont_p.h>
    6767
     68#if defined(Q_WS_S60)
     69#include <QtGui/qdesktopwidget.h>
     70#endif
     71
    6872QT_BEGIN_NAMESPACE
    6973
     
    113117/*!
    114118  \class QFontDialog
    115   \ingroup dialogs
    116   \ingroup text
    117   \mainclass
     119  \ingroup standard-dialogs
     120
    118121  \brief The QFontDialog class provides a dialog widget for selecting a font.
    119122
     
    312315    QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
    313316
    314 #if defined(Q_OS_WINCE)
     317#if defined(Q_WS_WINCE)
    315318    q->resize(180, 120);
     319#elif defined(Q_WS_S60)
     320    q->resize(QApplication::desktop()->availableGeometry(QCursor::pos()).size());
    316321#else
    317322    q->resize(500, 360);
    318 #endif // Q_OS_WINCE
     323#endif // Q_WS_WINCE
    319324
    320325    sizeEdit->installEventFilter(q);
     
    338343QFontDialog::~QFontDialog()
    339344{
     345#ifdef Q_WS_MAC
     346    Q_D(QFontDialog);
     347    if (d->delegate) {
     348        QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
     349        QFontDialogPrivate::sharedFontPanelAvailable = true;
     350        return;
     351    }
     352#endif
    340353}
    341354
     
    494507    Q_Q(QFontDialog);
    495508
    496     familyList->blockSignals(true);
    497 
    498509    enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 };
    499510
     
    549560        familyEdit->selectAll();
    550561
    551     familyList->blockSignals(false);
    552562    updateStyles();
    553563}
     
    560570{
    561571    Q_Q(QFontDialog);
    562 
    563     styleList->blockSignals(true);
    564 
    565572    QStringList styles = fdb.styles(familyList->currentText());
    566573    styleList->model()->setStringList(styles);
     
    596603            if (!found)
    597604                styleList->setCurrentItem(0);
     605        } else {
     606            styleList->setCurrentItem(0);
    598607        }
    599608
     
    606615    }
    607616
    608     styleList->blockSignals(false);
    609 
    610617    updateSizes();
    611618}
     
    620627{
    621628    Q_Q(QFontDialog);
    622 
    623     sizeList->blockSignals(true);
    624629
    625630    if (!familyList->currentText().isEmpty()) {
     
    652657    }
    653658
    654     sizeList->blockSignals(false);
    655659    _q_updateSample();
    656660}
     
    773777    styleAccel->setText(QFontDialog::tr("Font st&yle"));
    774778    sizeAccel->setText(QFontDialog::tr("&Size"));
     779#ifndef Q_WS_S60
     780    // Removed the title due to lack of screen estate in small S60 screen.
     781    // The effects are descriptive without a title (strikeout, underline).
    775782    effects->setTitle(QFontDialog::tr("Effects"));
     783#endif
    776784    strikeout->setText(QFontDialog::tr("Stri&keout"));
    777785    underline->setText(QFontDialog::tr("&Underline"));
     
    797805    \property QFontDialog::currentFont
    798806    \brief the current font of the dialog.
    799 */   
     807*/
    800808
    801809/*!
     
    821829
    822830#ifdef Q_WS_MAC
    823     if (d->delegate) 
     831    if (d->delegate)
    824832        QFontDialogPrivate::setFont(d->delegate, font);
    825833#endif
     
    933941    \overload
    934942
    935     Opens the dialog and connects its accepted() signal to the slot specified
     943    Opens the dialog and connects its fontSelected() signal to the slot specified
    936944    by \a receiver and \a member.
    937945
     
    941949{
    942950    Q_D(QFontDialog);
    943     connect(this, SIGNAL(fontSelected(const QFont&)), receiver, member);
     951    connect(this, SIGNAL(fontSelected(QFont)), receiver, member);
    944952    d->receiverToDisconnectOnClose = receiver;
    945953    d->memberToDisconnectOnClose = member;
     
    10311039    }
    10321040    if (d->receiverToDisconnectOnClose) {
    1033         disconnect(this, SIGNAL(fontSelected(const QFont&)),
     1041        disconnect(this, SIGNAL(fontSelected(QFont)),
    10341042                   d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
    10351043        d->receiverToDisconnectOnClose = 0;
  • trunk/src/gui/dialogs/qfontdialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qfontdialog_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4848#include <private/qfont_p.h>
    4949#include <private/qfontengine_p.h>
     50#include <private/qt_cocoa_helpers_mac_p.h>
    5051#include <private/qt_mac_p.h>
    5152#include <qdebug.h>
     
    7879#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
    7980
    80 @protocol NSWindowDelegate <NSObject> @end
     81@protocol NSWindowDelegate <NSObject>
     82- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
     83@end
    8184
    8285#endif
     
    8891    NSButton *mCancelButton;
    8992    QFontDialogPrivate *mPriv;
    90     NSFont *mCocoaFont;
    9193    QFont *mQtFont;
    9294    BOOL mPanelHackedWithButtons;
     
    120122@end
    121123
     124static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
     125{
     126    QFont newFont;
     127    if (cocoaFont) {
     128        int pSize = qRound([cocoaFont pointSize]);
     129        QString family(qt_mac_NSStringToQString([cocoaFont familyName]));
     130        QString typeface(qt_mac_NSStringToQString([cocoaFont fontName]));
     131
     132        int hyphenPos = typeface.indexOf(QLatin1Char('-'));
     133        if (hyphenPos != -1) {
     134            typeface.remove(0, hyphenPos + 1);
     135        } else {
     136            typeface = QLatin1String("Normal");
     137        }
     138
     139        newFont = QFontDatabase().font(family, typeface, pSize);
     140        newFont.setUnderline(resolveFont.underline());
     141        newFont.setStrikeOut(resolveFont.strikeOut());
     142
     143    }
     144    return newFont;
     145}
     146
    122147@implementation QCocoaFontPanelDelegate
    123148- (id)initWithFontPanel:(NSFontPanel *)panel
     
    135160    mCancelButton = cancelButton;
    136161    mPriv = priv;
    137     mCocoaFont = 0;
    138162    mPanelHackedWithButtons = (okButton != 0);
    139163    mDialogExtraWidth = extraWidth;
     
    156180- (void)dealloc
    157181{
    158     if (mCocoaFont)
    159         [mCocoaFont release];
    160182    delete mQtFont;
    161183    [super dealloc];
     
    164186- (void)changeFont:(id)sender
    165187{
    166     Q_UNUSED(sender);
    167 
    168     QFont newFont;
    169 
    170     if (mCocoaFont)
    171         [mCocoaFont autorelease];
    172188    NSFont *dummyFont = [NSFont userFontOfSize:12.0];
    173     mCocoaFont = [sender convertFont:dummyFont];
    174     if (mCocoaFont) {
    175         [mCocoaFont retain];
    176 
    177         int pSize = qRound([mCocoaFont pointSize]);
    178         QString family(QCFString::toQString(reinterpret_cast<CFStringRef>([mCocoaFont familyName])));
    179         QString typeface(QCFString::toQString(reinterpret_cast<CFStringRef>([mCocoaFont fontName])));
    180 //        qDebug() << "original family" << family << "typeface" << typeface << "psize" << pSize;
    181         int hyphenPos = typeface.indexOf(QLatin1Char('-'));
    182         if (hyphenPos != -1) {
    183             typeface.remove(0, hyphenPos + 1);
    184         } else {
    185             typeface = QLatin1String("Normal");
    186         }
    187 //        qDebug() << " massaged family" << family << "typeface" << typeface << "psize" << pSize;
    188         newFont = QFontDatabase().font(family, typeface, pSize);
    189         newFont.setUnderline(mQtFont->underline());
    190         newFont.setStrikeOut(mQtFont->strikeOut());
    191     }
    192 
    193     [self setQtFont:newFont];
     189    [self setQtFont:qfontForCocoaFont([sender convertFont:dummyFont], *mQtFont)];
    194190    if (mPriv)
    195191        mPriv->updateSampleFont(*mQtFont);
     
    318314{
    319315    Q_ASSERT(mPanelHackedWithButtons);
     316    NSFontManager *fontManager = [NSFontManager sharedFontManager];
     317    [self setQtFont:qfontForCocoaFont([fontManager convertFont:[fontManager selectedFont]],
     318                                      *mQtFont)];
    320319    [[mStolenContentView window] close];
    321320    [self finishOffWithCode:NSOKButton];
     
    375374        }
    376375
    377         // temporary hack to work around bug in deleteLater() in Qt/Mac Cocoa
    378 #if 1
    379         bool deleteDialog = mPriv->fontDialog()->testAttribute(Qt::WA_DeleteOnClose);
    380         mPriv->fontDialog()->setAttribute(Qt::WA_DeleteOnClose, false);
    381 #endif
    382376        mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
    383 #if 1
    384         if (deleteDialog)
    385             delete mPriv->fontDialog();
    386 #endif
    387377    } else {
    388378        [NSApp stopModalWithCode:code];
     
    405395    [mFontPanel setDelegate:nil];
    406396    [[NSFontManager sharedFontManager] setDelegate:nil];
     397#ifdef QT_MAC_USE_COCOA
    407398    [[NSFontManager sharedFontManager] setTarget:nil];
     399#endif
    408400}
    409401@end
     
    529521    [ourPanel setDelegate:delegate];
    530522    [[NSFontManager sharedFontManager] setDelegate:delegate];
     523#ifdef QT_MAC_USE_COCOA
    531524    [[NSFontManager sharedFontManager] setTarget:delegate];
     525#endif
    532526    setFont(delegate, initial);
    533527
     
    580574void QFontDialogPrivate::closeCocoaFontPanel(void *delegate)
    581575{
     576    QMacCocoaAutoReleasePool pool;
    582577    QCocoaFontPanelDelegate *theDelegate = static_cast<QCocoaFontPanelDelegate *>(delegate);
    583578    NSWindow *ourPanel = [theDelegate actualPanel];
     
    611606}
    612607
    613 void QFontDialogPrivate::setFont(void * delegate, const QFont &font)
    614 {
     608void QFontDialogPrivate::setFont(void *delegate, const QFont &font)
     609{
     610    QMacCocoaAutoReleasePool pool;
    615611    QFontEngine *fe = font.d->engineForScript(QUnicodeTables::Common);
     612    NSFontManager *mgr = [NSFontManager sharedFontManager];
     613    NSFont *nsFont = 0;
     614
    616615#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
    617616    if (qstrcmp(fe->name(), "CoreText") == 0) {
    618         const NSFont *nsFont = reinterpret_cast<const NSFont *>(static_cast<QCoreTextFontEngineMulti *>(fe)->ctfont);
    619         [[NSFontManager sharedFontManager] setSelectedFont:nsFont isMultiple:NO];
    620     }
    621 #endif
     617        nsFont = reinterpret_cast<const NSFont *>(static_cast<QCoreTextFontEngineMulti *>(fe)->ctfont);
     618    } else
     619#endif
     620    {
     621        int weight = 5;
     622        NSFontTraitMask mask = 0;
     623        if (font.style() == QFont::StyleItalic) {
     624            mask |= NSItalicFontMask;
     625        }
     626        if (font.weight() == QFont::Bold) {
     627            weight = 9;
     628            mask |= NSBoldFontMask;
     629        }
     630
     631        NSFontManager *mgr = [NSFontManager sharedFontManager];
     632        QFontInfo fontInfo(font);
     633        nsFont = [mgr fontWithFamily:qt_mac_QStringToNSString(fontInfo.family())
     634            traits:mask
     635            weight:weight
     636            size:fontInfo.pointSize()];
     637    }
     638
     639    [mgr setSelectedFont:nsFont isMultiple:NO];
    622640    [static_cast<QCocoaFontPanelDelegate *>(delegate) setQtFont:font];
    623641}
  • trunk/src/gui/dialogs/qfontdialog_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qinputdialog.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    9696    QInputDialogSpinBox(QWidget *parent)
    9797        : QSpinBox(parent) {
    98         connect(lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(notifyTextChanged()));
     98        connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged()));
    9999        connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged()));
    100100    }
     
    131131    QInputDialogDoubleSpinBox(QWidget *parent = 0)
    132132        : QDoubleSpinBox(parent) {
    133         connect(lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(notifyTextChanged()));
     133        connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged()));
    134134        connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged()));
    135135    }
     
    246246        lineEdit = new QLineEdit(q);
    247247        lineEdit->hide();
    248         QObject::connect(lineEdit, SIGNAL(textChanged(const QString&)),
    249                          q, SLOT(_q_textChanged(const QString&)));
     248        QObject::connect(lineEdit, SIGNAL(textChanged(QString)),
     249                         q, SLOT(_q_textChanged(QString)));
    250250    }
    251251}
     
    257257        comboBox = new QComboBox(q);
    258258        comboBox->hide();
    259         QObject::connect(comboBox, SIGNAL(editTextChanged(const QString&)),
    260                          q, SLOT(_q_textChanged(const QString&)));
    261         QObject::connect(comboBox, SIGNAL(currentIndexChanged(const QString&)),
    262                          q, SLOT(_q_textChanged(const QString&)));
     259        QObject::connect(comboBox, SIGNAL(editTextChanged(QString)),
     260                         q, SLOT(_q_textChanged(QString)));
     261        QObject::connect(comboBox, SIGNAL(currentIndexChanged(QString)),
     262                         q, SLOT(_q_textChanged(QString)));
    263263    }
    264264}
     
    277277        listView->setCurrentIndex(QModelIndex()); // ###
    278278        QObject::connect(listView->selectionModel(),
    279                          SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)),
    280                          q, SLOT(_q_currentRowChanged(const QModelIndex&, const QModelIndex&)));
     279                         SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
     280                         q, SLOT(_q_currentRowChanged(QModelIndex,QModelIndex)));
    281281    }
    282282}
     
    308308    if (spinBox) {
    309309        QAbstractButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
    310         QObject::disconnect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool)));
    311         QObject::connect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool)));
     310        QObject::connect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool)), Qt::UniqueConnection);
    312311    }
    313312}
     
    427426    \brief The QInputDialog class provides a simple convenience dialog to get a
    428427    single value from the user.
    429     \ingroup dialogs
    430     \mainclass
     428    \ingroup standard-dialogs
     429
    431430
    432431    The input value can be a string, a number or an item from a list. A label
     
    10211020    \overload
    10221021
    1023     Opens the dialog and connects its accepted() signal to the slot specified
    1024     by \a receiver and \a member.
     1022    This function connects one of its signals to the slot specified by \a receiver
     1023    and \a member. The specific signal depends on the arguments that are specified
     1024    in \a member. These are:
     1025
     1026    \list
     1027      \o textValueSelected() if \a member has a QString for its first argument.
     1028      \o intValueSelected() if \a member has an int for its first argument.
     1029      \o doubleValueSelected() if \a member has a double for its first argument.
     1030      \o accepted() if \a member has NO arguments.
     1031    \endlist
    10251032
    10261033    The signal will be disconnected from the slot when the dialog is closed.
     
    11221129    \a flags.
    11231130
    1124     This function returns the text which has been entered in the line
    1125     edit. It will not return an empty string.
     1131    If the dialog is accepted, this function returns the text in the dialog's
     1132    line edit. If the dialog is rejected, a null QString is returned.
    11261133
    11271134    Use this static function like this:
     
    11521159        return dialog.textValue();
    11531160    } else {
    1154         return text;
     1161        return QString();
    11551162    }
    11561163}
     
    12431250    dialog.setWindowTitle(title);
    12441251    dialog.setLabelText(label);
     1252    dialog.setDoubleDecimals(decimals);
    12451253    dialog.setDoubleRange(min, max);
    12461254    dialog.setDoubleValue(value);
    1247     dialog.setDoubleDecimals(decimals);
    12481255
    12491256    int ret = dialog.exec();
  • trunk/src/gui/dialogs/qinputdialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qmessagebox.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4646#include <QtGui/qdialogbuttonbox.h>
    4747#include "private/qlabel_p.h"
     48#include "private/qapplication_p.h"
    4849#include <QtCore/qlist.h>
    4950#include <QtCore/qdebug.h>
     
    6465#include <QtGui/qclipboard.h>
    6566
    66 #ifdef Q_OS_WINCE
     67#ifdef Q_WS_WINCE
    6768extern bool qt_wince_is_mobile();    //defined in qguifunctions_wince.cpp
    6869extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp
     
    7374
    7475QT_BEGIN_NAMESPACE
    75 
    76 extern QHash<QByteArray, QFont> *qt_app_fonts_hash();
    7776
    7877enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
     
    153152    void retranslateStrings();
    154153
    155 #ifdef Q_OS_WINCE
     154#ifdef Q_WS_WINCE
    156155    void hideSpecial();
    157156#endif
     
    190189    QAbstractButton *detectedEscapeButton;
    191190    QLabel *informativeLabel;
     191#ifdef Q_OS_SYMBIAN
     192    QTextEdit *textEdit;
     193#endif
    192194    QPointer<QObject> receiverToDisconnectOnClose;
    193195    QByteArray memberToDisconnectOnClose;
     
    259261int QMessageBoxPrivate::layoutMinimumWidth()
    260262{
    261     Q_Q(QMessageBox);
    262 
    263     q->layout()->activate();
    264     return q->layout()->totalMinimumSize().width();
     263    layout->activate();
     264    return layout->totalMinimumSize().width();
    265265}
    266266
     
    273273
    274274    QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
    275 #ifdef Q_WS_QWS
    276     // the width of the screen, less the window border.
    277     int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width());
    278 #elif defined(Q_OS_WINCE)
     275#if defined(Q_WS_QWS) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
    279276    // the width of the screen, less the window border.
    280277    int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width());
    281278#else
    282279    int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
     280    // on small screens allows the messagebox be the same size as the screen
     281    if (screenSize.width() <= 1024)
     282        hardLimit = screenSize.width();
    283283#endif
    284284#ifdef Q_WS_MAC
     
    288288#else
    289289    // note: ideally on windows, hard and soft limits but it breaks compat
    290 #ifndef Q_OS_WINCE
     290#ifndef Q_WS_WINCE
    291291    int softLimit = qMin(screenSize.width()/2, 500);
    292292#else
    293293    int softLimit = qMin(screenSize.width() * 3 / 4, 500);
    294 #endif //Q_OS_WINCE
     294#endif //Q_WS_WINCE
    295295#endif
    296296
     
    314314            width = hardLimit;
    315315        }
     316#ifdef Q_WS_S60
     317        // in S60 portait messageBoxes should always occupy maximum width
     318        if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){
     319            width = hardLimit;
     320        } else {
     321            // in landscape the messageBoxes should be of same width as in portrait
     322            width = qMin(QApplication::desktop()->size().height(), hardLimit);
     323        }
     324#endif
    316325    }
    317326
     
    335344    }
    336345
    337     QFontMetrics fm(qApp->font("QWorkspaceTitleBar"));
     346    QFontMetrics fm(QApplication::font("QWorkspaceTitleBar"));
    338347    int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit);
    339348    if (windowTitleWidth > width)
    340349        width = windowTitleWidth;
    341350
    342     q->layout()->activate();
    343     int height = (q->layout()->hasHeightForWidth())
    344                      ? q->layout()->totalHeightForWidth(width)
    345                      : q->layout()->totalMinimumSize().height();
     351    layout->activate();
     352    int height = (layout->hasHeightForWidth())
     353                     ? layout->totalHeightForWidth(width)
     354                     : layout->totalMinimumSize().height();
    346355    q->setFixedSize(width, height);
    347356    QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
     
    349358
    350359
    351 #ifdef Q_OS_WINCE
     360#ifdef Q_WS_WINCE
    352361/*!
    353362  \internal
     
    364373            QString text = pb->text();
    365374            text.remove(QChar::fromLatin1('&'));
    366             if (text == qApp->translate("QMessageBox", "OK" ))
     375            if (text == QApplication::translate("QMessageBox", "OK" ))
    367376                pb->setFixedSize(0,0);
    368377        }
     
    438447    the user or for asking the user a question and receiving an answer.
    439448
    440     \ingroup dialogs
    441     \mainclass
     449    \ingroup standard-dialogs
     450
    442451
    443452    A message box displays a primary \l{QMessageBox::text}{text} to
     
    704713    passed to the QDialog constructor.
    705714
    706     If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
    707     {application modal} dialog box. If \a parent is a widget, the
    708     message box is \l{Qt::WindowModal} {window modal} relative to \a
    709     parent.
    710 
    711     On Mac OS X, if \a parent is not 0 and you want your message box
    712     to appear as a Qt::Sheet of that parent, set the message box's
    713     \l{setWindowModality()} {window modality} to Qt::WindowModal
    714     (default). Otherwise, the message box will be a standard dialog.
     715    On Mac OS X, if you want your message box to appear
     716    as a Qt::Sheet of its \a parent, set the message box's
     717    \l{setWindowModality()} {window modality} to Qt::WindowModal or use open().
     718    Otherwise, the message box will be a standard dialog.
    715719
    716720*/
     
    12111215            d_func()->retranslateStrings();
    12121216            break;
    1213 #ifdef Q_OS_WINCE
     1217#ifdef Q_WS_WINCE
    12141218        case QEvent::OkRequest:
    12151219        case QEvent::HelpRequest: {
    12161220          QString bName =
    12171221              (e->type() == QEvent::OkRequest)
    1218               ? qApp->translate("QMessageBox", "OK")
    1219               : qApp->translate("QMessageBox", "Help");
     1222              ? QApplication::translate("QMessageBox", "OK")
     1223              : QApplication::translate("QMessageBox", "Help");
    12201224          QList<QPushButton*> list = qFindChildren<QPushButton*>(this);
    12211225          for (int i=0; i<list.size(); ++i) {
     
    13161320            QString separator = QString::fromLatin1("---------------------------\n");
    13171321            QString textToCopy = separator;
    1318             separator.prepend(QLatin1String("\n"));
     1322            separator.prepend(QLatin1Char('\n'));
    13191323            textToCopy += windowTitle() + separator; // title
    13201324            textToCopy += d->label->text() + separator; // text
     
    13301334            textToCopy += buttonTexts + separator;
    13311335
    1332             qApp->clipboard()->setText(textToCopy);
     1336            QApplication::clipboard()->setText(textToCopy);
    13331337            return;
    13341338        }
     
    13541358}
    13551359
    1356 #ifdef Q_OS_WINCE
     1360#ifdef Q_WS_WINCE
    13571361/*!
    13581362    \reimp
     
    13711375    \overload
    13721376
    1373     Opens the dialog and connects its accepted() signal to the slot specified
    1374     by \a receiver and \a member.
     1377    Opens the dialog and connects its finished() or buttonClicked() signal to
     1378    the slot specified by \a receiver and \a member. If the slot in \a member
     1379    has a pointer for its first parameter the connection is to buttonClicked(),
     1380    otherwise the connection is to finished().
    13751381
    13761382    The signal will be disconnected from the slot when the dialog is closed.
     
    14231429    if (d->autoAddOkButton) {
    14241430        addButton(Ok);
    1425 #if defined(Q_OS_WINCE)
     1431#if defined(Q_WS_WINCE)
    14261432        d->hideSpecial();
    14271433#endif
     
    16901696#endif
    16911697
    1692     QString translatedTextAboutQt;
    1693     translatedTextAboutQt = QMessageBox::tr(
     1698    QString translatedTextAboutQtCaption;
     1699    translatedTextAboutQtCaption = QMessageBox::tr(
    16941700        "<h3>About Qt</h3>"
    16951701        "<p>This program uses Qt version %1.</p>"
     1702        ).arg(QLatin1String(QT_VERSION_STR));
     1703    QString translatedTextAboutQtText;
     1704    translatedTextAboutQtText = QMessageBox::tr(
    16961705        "<p>Qt is a C++ toolkit for cross-platform application "
    16971706        "development.</p>"
     
    17021711        "<p>Qt is available under three different licensing options designed "
    17031712        "to accommodate the needs of our various users.</p>"
    1704         "Qt licensed under our commercial license agreement is appropriate "
     1713        "<p>Qt licensed under our commercial license agreement is appropriate "
    17051714        "for development of proprietary/commercial software where you do not "
    17061715        "want to share any source code with third parties or otherwise cannot "
     
    17161725        "terms of the GNU GPL version 3.0 or where you are otherwise willing "
    17171726        "to comply with the terms of the GNU GPL version 3.0.</p>"
    1718         "<p>Please see <a href=\"http://www.qtsoftware.com/products/licensing\">www.qtsoftware.com/products/licensing</a> "
     1727        "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> "
    17191728        "for an overview of Qt licensing.</p>"
    17201729        "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).</p>"
    1721         "<p>Qt is a Nokia product. See <a href=\"http://www.qtsoftware.com/qt/\">www.qtsoftware.com/qt</a> "
     1730        "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> "
    17221731        "for more information.</p>"
    1723        ).arg(QLatin1String(QT_VERSION_STR));
    1724 
     1732        );
    17251733    QMessageBox *msgBox = new QMessageBox(parent);
    17261734    msgBox->setAttribute(Qt::WA_DeleteOnClose);
    17271735    msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);
    1728     msgBox->setText(translatedTextAboutQt);
     1736    msgBox->setText(translatedTextAboutQtCaption);
     1737    msgBox->setInformativeText(translatedTextAboutQtText);
    17291738
    17301739    QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png"));
    17311740    if (!pm.isNull())
    17321741        msgBox->setIconPixmap(pm);
    1733 #if defined(Q_OS_WINCE)
     1742#if defined(Q_WS_WINCE)
    17341743    msgBox->setDefaultButton(msgBox->addButton(QMessageBox::Ok));
    17351744#endif
     
    24542463        label->setWordWrap(true);
    24552464        QGridLayout *grid = static_cast<QGridLayout *>(layout());
     2465#ifdef Q_OS_SYMBIAN
     2466        label->hide();
     2467        QTextEdit *textEdit = new QTextEdit(this);
     2468        textEdit->setReadOnly(true);
     2469        grid->addWidget(textEdit, 1, 1, 1, 1);
     2470        d->textEdit = textEdit;
     2471#else
    24562472        grid->addWidget(label, 1, 1, 1, 1);
     2473#endif
    24572474        d->informativeLabel = label;
    24582475    }
    24592476    d->informativeLabel->setText(text);
     2477
     2478#ifdef Q_OS_SYMBIAN
     2479    //We need to put the informative label inside textEdit to enable scrolling of long texts.
     2480    d->textEdit->setText(d->informativeLabel->text());
     2481#endif
     2482
    24602483    d->updateSize();
    24612484}
  • trunk/src/gui/dialogs/qmessagebox.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    146146    void removeButton(QAbstractButton *button);
    147147
    148 #ifdef Q_OS_WINCE
     148#ifdef Q_WS_WINCE
    149149    void setVisible(bool visible);
    150150#endif
     
    192192         const QString &text, StandardButtons buttons = Ok,
    193193         StandardButton defaultButton = NoButton);
     194    // ### Qt 5: Replace Ok with Yes|No in question() function.
     195    //     Also consider if Ok == Yes and Cancel == No.
    194196    static StandardButton question(QWidget *parent, const QString &title,
    195197         const QString &text, StandardButtons buttons = Ok,
  • trunk/src/gui/dialogs/qnspanelproxy_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    145145    {
    146146#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
     147        // The following code replaces the _implementation_ for the selector we want to hack
     148        // (originalSel) with the implementation found in proxyClass. Then it creates
     149        // a new 'backup' method inside baseClass containing the old, original,
     150        // implementation (fakeSel). You can let the proxy implementation of originalSel
     151        // call fakeSel if needed (similar approach to calling a super class implementation).
     152        // fakeSel must also be implemented in proxyClass, as the signature is used
     153        // as template for the method one we add into baseClass.
     154        // NB: You will typically never create any instances of proxyClass; we use it
     155        // only for stealing its contents and put it into baseClass.
    147156        Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
    148157        Method newMethod = class_getInstanceMethod(proxyClass, originalSel);
    149158        Method fakeMethod = class_getInstanceMethod(proxyClass, fakeSel);
    150159
    151         IMP originalCtorImp = method_setImplementation(originalMethod,
    152                                                        method_getImplementation(newMethod));
    153         class_addMethod(baseClass, fakeSel, originalCtorImp,
    154                         method_getTypeEncoding(fakeMethod));
     160        IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(newMethod));
     161        class_addMethod(baseClass, fakeSel, originalImp, method_getTypeEncoding(fakeMethod));
    155162#endif
    156163    }
  • trunk/src/gui/dialogs/qpagesetupdialog.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545
    4646QT_BEGIN_NAMESPACE
     47
     48/*!
     49    \class QPageSetupDialog
     50
     51    \brief The QPageSetupDialog class provides a configuration dialog
     52    for the page-related options on a printer.
     53
     54    \ingroup standard-dialogs
     55    \ingroup printing
     56
     57    On Windows and Mac OS X the page setup dialog is implemented using
     58    the native page setup dialogs.
     59
     60    Note that on Windows and Mac OS X custom paper sizes won't be
     61    reflected in the native page setup dialogs. Additionally, custom
     62    page margins set on a QPrinter won't show in the native Mac OS X
     63    page setup dialog.
     64
     65    \sa QPrinter, QPrintDialog
     66*/
     67
     68
     69/*!
     70    \fn QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
     71
     72    Constructs a page setup dialog that configures \a printer with \a
     73    parent as the parent widget.
     74*/
     75
     76/*!
     77    \since 4.5
     78
     79    \fn QPageSetupDialog::QPageSetupDialog(QWidget *parent)
     80
     81    Constructs a page setup dialog that configures a default-constructed
     82    QPrinter with \a parent as the parent widget.
     83
     84    \sa printer()
     85*/
     86
     87/*!
     88    \fn QPrinter *QPageSetupDialog::printer()
     89
     90    Returns the printer that was passed to the QPageSetupDialog
     91    constructor.
     92*/
    4793
    4894// hack
     
    181227}
    182228
     229#if defined(Q_WS_MAC) || defined(Q_OS_WIN)
     230/*! \fn void QPageSetupDialog::setVisible(bool visible)
     231    \reimp
     232*/
     233#endif
     234
    183235QT_END_NAMESPACE
    184236
  • trunk/src/gui/dialogs/qpagesetupdialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qpagesetupdialog_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    252252}
    253253
    254 /*!
    255     \reimp
    256 */
    257254void QPageSetupDialog::setVisible(bool visible)
    258255{
  • trunk/src/gui/dialogs/qpagesetupdialog_unix.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qpagesetupdialog_unix_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qpagesetupdialog_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7272
    7373    QWin32PrintEngine *engine = static_cast<QWin32PrintEngine*>(d->printer->paintEngine());
    74     QWin32PrintEnginePrivate *ep = static_cast<QWin32PrintEnginePrivate *>(engine->d_ptr);
     74    QWin32PrintEnginePrivate *ep = static_cast<QWin32PrintEnginePrivate *>(engine->d_ptr.data());
    7575
    7676    PAGESETUPDLG psd;
     
    7979
    8080    // we need a temp DEVMODE struct if we don't have a global DEVMODE
    81     HGLOBAL hDevMode;
    82     int devModeSize;
     81    HGLOBAL hDevMode = 0;
     82    int devModeSize = 0;
    8383    if (!ep->globalDevMode) {
    84         QT_WA( { devModeSize = sizeof(DEVMODEW) + ((DEVMODEW *) ep->devMode)->dmDriverExtra; },
    85                { devModeSize = sizeof(DEVMODEA) + ((DEVMODEA *) ep->devMode)->dmDriverExtra; });
     84        devModeSize = sizeof(DEVMODE) + ep->devMode->dmDriverExtra;
    8685        hDevMode = GlobalAlloc(GHND, devModeSize);
    8786        if (hDevMode) {
     
    9998
    10099    QWidget *parent = parentWidget();
    101     parent = parent ? parent->window() : qApp->activeWindow();
     100    parent = parent ? parent->window() : QApplication::activeWindow();
    102101    Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
    103102    psd.hwndOwner = parent ? parent->winId() : 0;
  • trunk/src/gui/dialogs/qprintdialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qprintdialog_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    122122
    123123QT_USE_NAMESPACE
     124
     125#ifdef QT_MAC_USE_COCOA
    124126
    125127@class QCocoaPrintPanelDelegate;
     
    167169        // Keep us in sync with file output
    168170        PMDestinationType dest;
     171
     172        // If the user selected print to file, the session has been
     173        // changed behind our back and our d->ep->session object is a
     174        // dangling pointer. Update it based on the "current" session
     175        d->ep->session = static_cast<PMPrintSession>([d->ep->printInfo PMPrintSession]);
     176
    169177        PMSessionGetDestinationType(d->ep->session, d->ep->settings, &dest);
    170178        if (dest == kPMDestinationFile) {
     
    191199}
    192200@end
     201
     202#endif
    193203
    194204QT_BEGIN_NAMESPACE
  • trunk/src/gui/dialogs/qprintdialog_unix.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545
    4646#include "private/qabstractprintdialog_p.h"
    47 #include "qfiledialog_p.h"
    4847#include <QtGui/qmessagebox.h>
    4948#include "qprintdialog.h"
    5049#include "qfiledialog.h"
    5150#include <QtCore/qdir.h>
     51#include <QtGui/qevent.h>
    5252#include <QtGui/qfilesystemmodel.h>
    5353#include <QtGui/qstyleditemdelegate.h>
     
    5656#include <QtGui/qdialogbuttonbox.h>
    5757
     58#include "qfscompleter_p.h"
    5859#include "ui_qprintpropertieswidget.h"
    5960#include "ui_qprintsettingsoutput.h"
     
    193194          selected(-1),
    194195          selDescription(0),
    195           parentItem(pi) {};
     196          parentItem(pi) {}
    196197
    197198    ~QOptionTreeItem() {
    198199        while (!childItems.isEmpty())
    199200            delete childItems.takeFirst();
    200     };
     201    }
    201202
    202203    ItemType type;
     
    238239    Q_OBJECT
    239240public:
    240     QPPDOptionsEditor(QObject* parent = 0) : QStyledItemDelegate(parent) {};
    241     ~QPPDOptionsEditor() {};
     241    QPPDOptionsEditor(QObject* parent = 0) : QStyledItemDelegate(parent) {}
     242    ~QPPDOptionsEditor() {}
    242243
    243244    QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
     
    670671            QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name));
    671672            if (cupsPrinters[i].instance)
    672                 printerName += QLatin1String("/") + QString::fromLocal8Bit(cupsPrinters[i].instance);
     673                printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
    673674
    674675            widget.printers->addItem(printerName);
     
    696697    QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
    697698    fsm->setRootPath(QDir::homePath());
    698 #if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG)
    699     widget.filename->setCompleter(new QFSCompletor(fsm, widget.filename));
     699#if !defined(QT_NO_FSCOMPLETER) && !defined(QT_NO_FILEDIALOG)
     700    widget.filename->setCompleter(new QFSCompleter(fsm, widget.filename));
    700701#endif
    701702#endif
     
    728729        filePrintersAdded = false;
    729730    }
    730     if (printer && filePrintersAdded && printer->printerName().isEmpty()) {
     731    if (printer && filePrintersAdded && (printer->outputFormat() != QPrinter::NativeFormat
     732                                         || printer->printerName().isEmpty()))
     733    {
    731734        if (printer->outputFormat() == QPrinter::PdfFormat)
    732735            widget.printers->setCurrentIndex(widget.printers->count() - 2);
     
    812815#endif
    813816        if (lprPrinters.count() > 0) {
    814             QString type = lprPrinters.at(index).name + QLatin1String("@") + lprPrinters.at(index).host;
     817            QString type = lprPrinters.at(index).name + QLatin1Char('@') + lprPrinters.at(index).host;
    815818            if (!lprPrinters.at(index).comment.isEmpty())
    816819            type += QLatin1String(", ") + lprPrinters.at(index).comment;
     
    833836void QUnixPrintWidgetPrivate::_q_btnBrowseClicked()
    834837{
    835     const int prevPrinter = widget.printers->currentIndex();
    836     widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one
    837 
    838838    QString filename = widget.filename->text();
    839839#ifndef QT_NO_FILEDIALOG
     
    847847        if (filename.endsWith(QString::fromLatin1(".ps"), Qt::CaseInsensitive))
    848848            widget.printers->setCurrentIndex(widget.printers->count() - 1); // the postscript one
    849     }
    850     else
    851         widget.printers->setCurrentIndex(prevPrinter);
     849        else if (filename.endsWith(QString::fromLatin1(".pdf"), Qt::CaseInsensitive))
     850            widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one
     851        else if (widget.printers->currentIndex() != widget.printers->count() - 1) // if ps is not selected, pdf is default
     852            widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one
     853    }
    852854}
    853855
     
    11931195    switch(section){
    11941196        case 0:
    1195             return QVariant(QApplication::translate("QPPDOptionsModel","Name"));
     1197            return QVariant(QApplication::translate("QPPDOptionsModel", "Name"));
    11961198        case 1:
    1197             return QVariant(QApplication::translate("QPPDOptionsModel","Value"));
     1199            return QVariant(QApplication::translate("QPPDOptionsModel", "Value"));
    11981200        default:
    11991201            return QVariant();
  • trunk/src/gui/dialogs/qprintdialog_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5252#include <private/qprintengine_win_p.h>
    5353#include <private/qprinter_p.h>
     54
     55#if defined(Q_CC_MINGW) && !defined(PD_NOCURRENTPAGE)
     56#define PD_NOCURRENTPAGE    0x00800000
     57#define PD_RESULT_PRINT 1
     58#define PD_RESULT_APPLY 2
     59#define START_PAGE_GENERAL  0XFFFFFFFF
     60#endif
    5461
    5562QT_BEGIN_NAMESPACE
     
    7885};
    7986
    80 #ifndef Q_OS_WINCE
    81 // If you change this function, make sure you also change the unicode equivalent
    82 template <class PrintDialog, class DeviceMode>
    83 static PrintDialog *qt_win_make_PRINTDLG(QWidget *parent,
    84                                          QPrintDialog *pdlg,
    85                                          QPrintDialogPrivate *d, HGLOBAL *tempDevNames)
    86 {
    87     PrintDialog *pd = new PrintDialog;
    88     memset(pd, 0, sizeof(PrintDialog));
    89     pd->lStructSize = sizeof(PrintDialog);
    90 
    91     void *devMode = sizeof(DeviceMode) == sizeof(DEVMODEA)
    92                     ? (void *) d->ep->devModeA()
    93                     : (void *) d->ep->devModeW();
     87static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent,
     88                                    QPrintDialog *pdlg,
     89                                    QPrintDialogPrivate *d, HGLOBAL *tempDevNames)
     90{
     91    DEVMODE *devMode = d->ep->devMode;
    9492
    9593    if (devMode) {
    96         int size = sizeof(DeviceMode) + ((DeviceMode *) devMode)->dmDriverExtra;
     94        int size = sizeof(DEVMODE) + devMode->dmDriverExtra;
    9795        pd->hDevMode = GlobalAlloc(GHND, size);
    9896        {
    9997            void *dest = GlobalLock(pd->hDevMode);
    100             memcpy(dest, d->ep->devMode, size);
     98            memcpy(dest, devMode, size);
    10199            GlobalUnlock(pd->hDevMode);
    102100        }
     
    131129        pd->Flags |= PD_NOPAGENUMS;
    132130
     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;
     135    pd->nStartPage = START_PAGE_GENERAL;
     136    pd->nPageRanges = 1;
     137    pd->nMaxPageRanges = 1;
     138
    133139    if (d->ep->printToFile)
    134140        pd->Flags |= PD_PRINTTOFILE;
    135     Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
    136     pd->hwndOwner = parent ? parent->winId() : 0;
    137     pd->nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
    138     pd->nToPage   = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;
     141    Q_ASSERT(parent != 0 && parent->testAttribute(Qt::WA_WState_Created));
     142    pd->hwndOwner = parent->window()->winId();
     143    pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
     144    pd->lpPageRanges[0].nToPage   = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;
    139145    pd->nCopies = d->ep->num_copies;
    140 
    141     return pd;
    142 }
    143 #endif // Q_OS_WINCE
    144 
    145 // If you change this function, make sure you also change the ansi equivalent
    146 template <typename T>
    147 static void qt_win_clean_up_PRINTDLG(T **pd)
    148 {
    149     delete *pd;
    150     *pd = 0;
    151 }
    152 
    153 
    154 // If you change this function, make sure you also change the ansi equivalent
    155 template <typename T>
    156 static void qt_win_read_back_PRINTDLG(T *pd, QPrintDialog *pdlg, QPrintDialogPrivate *d)
     146}
     147
     148static void qt_win_read_back_PRINTDLGEX(PRINTDLGEX *pd, QPrintDialog *pdlg, QPrintDialogPrivate *d)
    157149{
    158150    if (pd->Flags & PD_SELECTION) {
     
    161153    } else if (pd->Flags & PD_PAGENUMS) {
    162154        pdlg->setPrintRange(QPrintDialog::PageRange);
    163         pdlg->setFromTo(pd->nFromPage, pd->nToPage);
     155        pdlg->setFromTo(pd->lpPageRanges[0].nFromPage, pd->lpPageRanges[0].nToPage);
    164156    } else {
    165157        pdlg->setPrintRange(QPrintDialog::AllPages);
     
    226218        parent = parent->window();
    227219    else
    228         parent = qApp->activeWindow();
     220        parent = QApplication::activeWindow();
     221
     222    // If there is no window, fall back to the print dialog itself
     223    if (parent == 0)
     224        parent = q;
    229225
    230226    QWidget modal_widget;
     
    235231    HGLOBAL *tempDevNames = ep->createDevNames();
    236232
     233    bool done;
    237234    bool result;
    238     bool done;
    239     void *pd = QT_WA_INLINE(
    240         (void*)(qt_win_make_PRINTDLG<PRINTDLGW, DEVMODEW>(parent, q, this, tempDevNames)),
    241         (void*)(qt_win_make_PRINTDLG<PRINTDLGA, DEVMODEA>(parent, q, this, tempDevNames))
    242         );
     235    bool doPrinting;
     236
     237    PRINTPAGERANGE pageRange;
     238    PRINTDLGEX pd;
     239    memset(&pd, 0, sizeof(PRINTDLGEX));
     240    pd.lStructSize = sizeof(PRINTDLGEX);
     241    pd.lpPageRanges = &pageRange;
     242    qt_win_setup_PRINTDLGEX(&pd, parent, q, this, tempDevNames);
    243243
    244244    do {
    245245        done = true;
    246         QT_WA({
    247             PRINTDLGW *pdw = reinterpret_cast<PRINTDLGW *>(pd);
    248             result = PrintDlgW(pdw);
    249             if ((pdw->Flags & PD_PAGENUMS) && (pdw->nFromPage > pdw->nToPage))
     246        doPrinting = false;
     247        result = (PrintDlgEx(&pd) == S_OK);
     248        if (result && (pd.dwResultAction == PD_RESULT_PRINT
     249                       || pd.dwResultAction == PD_RESULT_APPLY))
     250        {
     251            doPrinting = (pd.dwResultAction == PD_RESULT_PRINT);
     252            if ((pd.Flags & PD_PAGENUMS)
     253                && (pd.lpPageRanges[0].nFromPage > pd.lpPageRanges[0].nToPage))
     254            {
     255                pd.lpPageRanges[0].nFromPage = 1;
     256                pd.lpPageRanges[0].nToPage = 1;
    250257                done = false;
    251             if (result && pdw->hDC == 0)
     258            }
     259            if (pd.hDC == 0)
    252260                result = false;
    253             else if (!result)
    254                 done = true;
    255         }, {
    256             PRINTDLGA *pda = reinterpret_cast<PRINTDLGA *>(pd);
    257             result = PrintDlgA(pda);
    258             if ((pda->Flags & PD_PAGENUMS) && (pda->nFromPage > pda->nToPage))
    259                 done = false;
    260             if (result && pda->hDC == 0)
    261                 result = false;
    262             else if (!result)
    263                 done = true;
    264         });
     261        }
     262
    265263        if (!done) {
    266264            QMessageBox::warning(0, QPrintDialog::tr("Print"),
     
    275273
    276274    // write values back...
    277     if (result) {
    278         QT_WA({
    279             PRINTDLGW *pdw = reinterpret_cast<PRINTDLGW *>(pd);
    280             qt_win_read_back_PRINTDLG(pdw, q, this);
    281             qt_win_clean_up_PRINTDLG(&pdw);
    282         }, {
    283             PRINTDLGA *pda = reinterpret_cast<PRINTDLGA *>(pd);
    284             qt_win_read_back_PRINTDLG(pda, q, this);
    285             qt_win_clean_up_PRINTDLG(&pda);
    286         });
     275    if (result && (pd.dwResultAction == PD_RESULT_PRINT
     276                   || pd.dwResultAction == PD_RESULT_APPLY))
     277    {
     278        qt_win_read_back_PRINTDLGEX(&pd, q, this);
    287279        // update printer validity
    288280        printer->d_func()->validPrinter = !ep->name.isEmpty();
     
    292284    GlobalFree(tempDevNames);
    293285
    294     q->done(result);
    295 
    296     return result;
     286    q->done(result && doPrinting);
     287
     288    return result && doPrinting;
    297289}
    298290
  • trunk/src/gui/dialogs/qprintpreviewdialog.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4343#include "qprintpreviewwidget.h"
    4444#include <private/qprinter_p.h>
     45#include "private/qdialog_p.h"
    4546
    4647#include <QtGui/qaction.h>
     
    5556#include <QtGui/qvalidator.h>
    5657#include <QtGui/qfiledialog.h>
     58#include <QtGui/qmainwindow.h>
     59#include <QtGui/qtoolbar.h>
     60#include <QtGui/qformlayout.h>
    5761#include <QtCore/QCoreApplication>
    5862
     
    6468
    6569namespace {
     70class QPrintPreviewMainWindow : public QMainWindow
     71{
     72public:
     73    QPrintPreviewMainWindow(QWidget *parent) : QMainWindow(parent) {}
     74    QMenu *createPopupMenu() { return 0; }
     75};
     76
    6677class ZoomFactorValidator : public QDoubleValidator
    6778{
     
    129140} // anonymous namespace
    130141
    131 class QPrintPreviewDialogPrivate
     142class QPrintPreviewDialogPrivate : public QDialogPrivate
    132143{
    133144    Q_DECLARE_PUBLIC(QPrintPreviewDialog)
    134145public:
    135     QPrintPreviewDialogPrivate(QPrintPreviewDialog *q)
    136         : q_ptr(q), printDialog(0), ownPrinter(false),
     146    QPrintPreviewDialogPrivate()
     147        : printDialog(0), ownPrinter(false),
    137148          initialized(false) {}
    138149
     
    159170    void updateZoomFactor();
    160171
    161     QPrintPreviewDialog *q_ptr;
    162172    QPrintDialog *printDialog;
    163173    QPrintPreviewWidget *preview;
     
    198208    QAction *printAction;
    199209    QAction *pageSetupAction;
    200     QAction *closeAction;
    201210
    202211    QPointer<QObject> receiverToDisconnectOnClose;
     
    216225        preview = new QPrintPreviewWidget(printer, q);
    217226    }
    218     QObject::connect(preview, SIGNAL(paintRequested(QPrinter *)), q, SIGNAL(paintRequested(QPrinter *)));
     227    QObject::connect(preview, SIGNAL(paintRequested(QPrinter*)), q, SIGNAL(paintRequested(QPrinter*)));
    219228    QObject::connect(preview, SIGNAL(previewChanged()), q, SLOT(_q_previewChanged()));
    220229    setupActions();
    221230
    222     // Navigation
    223     QToolButton* nextPageButton = new QToolButton;
    224     nextPageButton->setDefaultAction(nextPageAction);
    225     QToolButton* prevPageButton = new QToolButton;
    226     prevPageButton->setDefaultAction(prevPageAction);
    227     QToolButton* firstPageButton = new QToolButton;
    228     firstPageButton->setDefaultAction(firstPageAction);
    229     QToolButton* lastPageButton = new QToolButton;
    230     lastPageButton->setDefaultAction(lastPageAction);
    231 
    232231    pageNumEdit = new LineEdit;
    233232    pageNumEdit->setAlignment(Qt::AlignRight);
    234     pageNumEdit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding));
     233    pageNumEdit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
    235234    pageNumLabel = new QLabel;
    236235    QObject::connect(pageNumEdit, SIGNAL(editingFinished()), q, SLOT(_q_pageNumEdited()));
    237 
    238     QToolButton* fitWidthButton = new QToolButton;
    239     fitWidthButton->setDefaultAction(fitWidthAction);
    240     QToolButton* fitPageButton = new QToolButton;
    241     fitPageButton->setDefaultAction(fitPageAction);
    242236
    243237    zoomFactor = new QComboBox;
     
    256250                     q, SLOT(_q_zoomFactorChanged()));
    257251
    258     QToolButton* zoomInButton = new QToolButton;
    259     zoomInButton->setDefaultAction(zoomInAction);
     252    QPrintPreviewMainWindow *mw = new QPrintPreviewMainWindow(q);
     253    QToolBar *toolbar = new QToolBar(mw);
     254    toolbar->addAction(fitWidthAction);
     255    toolbar->addAction(fitPageAction);
     256    toolbar->addSeparator();
     257    toolbar->addWidget(zoomFactor);
     258    toolbar->addAction(zoomOutAction);
     259    toolbar->addAction(zoomInAction);
     260    toolbar->addSeparator();
     261    toolbar->addAction(portraitAction);
     262    toolbar->addAction(landscapeAction);
     263    toolbar->addSeparator();
     264    toolbar->addAction(firstPageAction);
     265    toolbar->addAction(prevPageAction);
     266
     267    // this is to ensure the label text and the editor text are
     268    // aligned in all styles - the extra QVBoxLayout is a workaround
     269    // for bug in QFormLayout
     270    QWidget *pageEdit = new QWidget(toolbar);
     271    QVBoxLayout *vboxLayout = new QVBoxLayout;
     272    vboxLayout->setContentsMargins(0, 0, 0, 0);
     273    QFormLayout *formLayout = new QFormLayout;
     274    formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit);
     275    formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel);
     276    vboxLayout->addLayout(formLayout);
     277    vboxLayout->setAlignment(Qt::AlignVCenter);
     278    pageEdit->setLayout(vboxLayout);
     279    toolbar->addWidget(pageEdit);
     280
     281    toolbar->addAction(nextPageAction);
     282    toolbar->addAction(lastPageAction);
     283    toolbar->addSeparator();
     284    toolbar->addAction(singleModeAction);
     285    toolbar->addAction(facingModeAction);
     286    toolbar->addAction(overviewModeAction);
     287    toolbar->addSeparator();
     288    toolbar->addAction(pageSetupAction);
     289    toolbar->addAction(printAction);
     290
     291    // Cannot use the actions' triggered signal here, since it doesn't autorepeat
     292    QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction));
     293    QToolButton *zoomOutButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomOutAction));
    260294    zoomInButton->setAutoRepeat(true);
    261295    zoomInButton->setAutoRepeatInterval(200);
    262296    zoomInButton->setAutoRepeatDelay(200);
    263 
    264     QToolButton* zoomOutButton = new QToolButton;
    265     zoomOutButton->setDefaultAction(zoomOutAction);
    266297    zoomOutButton->setAutoRepeat(true);
    267298    zoomOutButton->setAutoRepeatInterval(200);
    268299    zoomOutButton->setAutoRepeatDelay(200);
    269 
    270     //Cannot use the actions' triggered signal here, since it doesnt autorepeat
    271300    QObject::connect(zoomInButton, SIGNAL(clicked()), q, SLOT(_q_zoomIn()));
    272301    QObject::connect(zoomOutButton, SIGNAL(clicked()), q, SLOT(_q_zoomOut()));
    273302
    274     QToolButton* portraitButton = new QToolButton;
    275     portraitButton->setDefaultAction(portraitAction);
    276     QToolButton* landscapeButton = new QToolButton;
    277     landscapeButton->setDefaultAction(landscapeAction);
    278 
    279     QToolButton* singleModeButton = new QToolButton;
    280     singleModeButton->setDefaultAction(singleModeAction);
    281     QToolButton* facingModeButton = new QToolButton;
    282     facingModeButton->setDefaultAction(facingModeAction);
    283     QToolButton* overviewModeButton = new QToolButton;
    284     overviewModeButton->setDefaultAction(overviewModeAction);
    285 
    286     QToolButton *printButton = new QToolButton;
    287     printButton->setDefaultAction(printAction);
    288     QToolButton *pageSetupButton = new QToolButton;
    289     pageSetupButton->setDefaultAction(pageSetupAction);
    290     QToolButton *closeButton = new QToolButton;
    291     closeButton->setDefaultAction(closeAction);
    292 
    293     QHBoxLayout* modeLayout = new QHBoxLayout;
    294     modeLayout->setSpacing(0);
    295     modeLayout->addWidget(singleModeButton);
    296     modeLayout->addWidget(facingModeButton);
    297     modeLayout->addWidget(overviewModeButton);
    298 
    299     QHBoxLayout *barLayout = new QHBoxLayout;
    300     barLayout->addWidget(fitWidthButton);
    301     barLayout->addWidget(fitPageButton);
    302     barLayout->addWidget(zoomFactor);
    303     barLayout->addWidget(zoomOutButton);
    304     barLayout->addWidget(zoomInButton);
    305     barLayout->addWidget(portraitButton);
    306     barLayout->addWidget(landscapeButton);
    307     barLayout->addStretch();
    308     barLayout->addWidget(firstPageButton);
    309     barLayout->addWidget(prevPageButton);
    310     barLayout->addWidget(pageNumEdit);
    311     barLayout->addWidget(pageNumLabel);
    312     barLayout->addWidget(nextPageButton);
    313     barLayout->addWidget(lastPageButton);
    314     barLayout->addStretch();
    315     barLayout->addLayout(modeLayout);
    316     barLayout->addStretch();
    317     barLayout->addWidget(pageSetupButton);
    318     barLayout->addWidget(printButton);
    319     barLayout->addWidget(closeButton);
    320 
    321     QWidget* buttonBar = new QWidget;
    322     buttonBar->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum));
    323     barLayout->setMargin(0);
    324     buttonBar->setLayout(barLayout);
     303    mw->addToolBar(toolbar);
     304    mw->setCentralWidget(preview);
     305    // QMainWindows are always created as top levels, force it to be a
     306    // plain widget
     307    mw->setParent(q, Qt::Widget);
    325308
    326309    QVBoxLayout *topLayout = new QVBoxLayout;
    327     topLayout->addWidget(buttonBar);
    328     topLayout->addWidget(preview);
     310    topLayout->addWidget(mw);
     311    topLayout->setMargin(0);
    329312    q->setLayout(topLayout);
    330313
     
    339322#endif
    340323        )
    341         pageSetupButton->setEnabled(false);
     324        pageSetupAction->setEnabled(false);
     325    preview->setFocus();
    342326}
    343327
     
    419403    printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
    420404    pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
    421     closeAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Close"));
    422405    qt_setupActionIcon(printAction, QLatin1String("print"));
    423406    qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
    424407    QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
    425408    QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
    426     QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(reject()));
    427409
    428410    // Initial state:
     
    465447{
    466448    int curPage = preview->currentPage();
    467     int numPages = preview->numPages();
     449    int numPages = preview->pageCount();
    468450    nextPageAction->setEnabled(curPage < numPages);
    469451    prevPageAction->setEnabled(curPage > 1);
     
    477459    Q_Q(QPrintPreviewDialog);
    478460
    479     int numPages = preview->numPages();
     461    int numPages = preview->pageCount();
    480462    int maxChars = QString::number(numPages).length();
    481     pageNumLabel->setText(QString(QLatin1String("/ %1")).arg(numPages));
     463    pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages));
    482464    int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars));
    483465    int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth;
     
    534516        preview->setCurrentPage(1);
    535517    else if (action == lastPageAction)
    536         preview->setCurrentPage(preview->numPages());
     518        preview->setCurrentPage(preview->pageCount());
    537519    updateNavActions();
    538520}
     
    577559        }
    578560        QString fileName = QFileDialog::getSaveFileName(q, title, printer->outputFileName(),
    579                                                         QLatin1String("*") + suffix);
     561                                                        QLatin1Char('*') + suffix);
    580562        if (!fileName.isEmpty()) {
    581563            if (QFileInfo(fileName).suffix().isEmpty())
     
    630612    if (ok) {
    631613        preview->setZoomFactor(factor/100.0);
    632         zoomFactor->setEditText(QString(QLatin1String("%1%")).arg(factor));
     614        zoomFactor->setEditText(QString::fromLatin1("%1%").arg(factor));
    633615        setFitting(false);
    634616    }
     
    643625    \brief The QPrintPreviewDialog class provides a dialog for
    644626    previewing and configuring page layouts for printer output.
     627
     628    \ingroup standard-dialogs
     629    \ingroup printing
    645630
    646631    Using QPrintPreviewDialog in your existing application is
     
    681666*/
    682667QPrintPreviewDialog::QPrintPreviewDialog(QPrinter* printer, QWidget *parent, Qt::WindowFlags flags)
    683     : QDialog(parent, flags), d_ptr(new QPrintPreviewDialogPrivate(this))
     668    : QDialog(*new QPrintPreviewDialogPrivate, parent, flags)
    684669{
    685670    Q_D(QPrintPreviewDialog);
     
    695680*/
    696681QPrintPreviewDialog::QPrintPreviewDialog(QWidget *parent, Qt::WindowFlags f)
    697     : QDialog(parent, f), d_ptr(new QPrintPreviewDialogPrivate(this))
     682    : QDialog(*new QPrintPreviewDialogPrivate, parent, f)
    698683{
    699684    Q_D(QPrintPreviewDialog);
     
    710695        delete d->printer;
    711696    delete d->printDialog;
    712     delete d_ptr;
    713697}
    714698
  • trunk/src/gui/dialogs/qprintpreviewdialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    9595    Q_PRIVATE_SLOT(d_func(), void _q_zoomFactorChanged())
    9696
    97     QPrintPreviewDialogPrivate *d_ptr;
     97    void *dummy; // ### Qt 5 - remove me
    9898};
    9999
  • trunk/src/gui/dialogs/qprogressdialog.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5858#include <limits.h>
    5959
     60#if defined(QT_SOFTKEYS_ENABLED)
     61#include <qaction.h>
     62#endif
     63#ifdef Q_WS_S60
     64#include <QtGui/qdesktopwidget.h>
     65#endif
     66
     67
    6068QT_BEGIN_NAMESPACE
    6169
     
    7785#ifndef QT_NO_SHORTCUT
    7886        escapeShortcut(0),
     87#endif
     88#ifdef QT_SOFTKEYS_ENABLED
     89        cancelAction(0),
    7990#endif
    8091        useDefaultCancelText(false)
     
    103114#ifndef QT_NO_SHORTCUT
    104115    QShortcut *escapeShortcut;
     116#endif
     117#ifdef QT_SOFTKEYS_ENABLED
     118    QAction *cancelAction;
    105119#endif
    106120    bool useDefaultCancelText;
     
    197211  \class QProgressDialog
    198212  \brief The QProgressDialog class provides feedback on the progress of a slow operation.
    199   \ingroup dialogs
    200   \mainclass
     213  \ingroup standard-dialogs
     214
    201215
    202216  A progress dialog is used to give the user an indication of how long
     
    432446    resize(w, h);
    433447    if (cancelButton)
     448#if !defined(QT_SOFTKEYS_ENABLED)
    434449        cancelButton->show();
     450#else
     451    {
     452        d->cancelAction = new QAction(cancelButton->text(), cancelButton);
     453        d->cancelAction->setSoftKeyRole(QAction::NegativeSoftKey);
     454        connect(d->cancelAction, SIGNAL(triggered()), this, SIGNAL(canceled()));
     455        addAction(d->cancelAction);
     456    }
     457#endif
    435458}
    436459
     
    449472
    450473    if (!cancelButtonText.isNull()) {
    451         if (d->cancel)
     474        if (d->cancel) {
    452475            d->cancel->setText(cancelButtonText);
    453         else
     476#ifdef QT_SOFTKEYS_ENABLED
     477            d->cancelAction->setText(cancelButtonText);
     478#endif
     479        } else {
    454480            setCancelButton(new QPushButton(cancelButtonText, this));
     481        }
    455482    } else {
    456483        setCancelButton(0);
     
    627654  \warning If the progress dialog is modal
    628655    (see QProgressDialog::QProgressDialog()),
    629     this function calls QApplication::processEvents(), so take care that
     656    setValue() calls QApplication::processEvents(), so take care that
    630657    this does not cause undesirable re-entrancy in your code. For example,
    631658    don't use a QProgressDialog inside a paintEvent()!
     
    644671    if (d->shown_once) {
    645672        if (isModal())
    646             qApp->processEvents();
     673            QApplication::processEvents();
    647674    } else {
    648675        if (progress == 0) {
     
    702729    if (d->cancel)
    703730        h += d->cancel->sizeHint().height() + spacing;
     731#ifdef Q_WS_S60
     732    if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width())
     733        return QSize(qMax(QApplication::desktop()->size().width(), sh.width() + 2 * margin), h);
     734    else
     735        return QSize(qMax(QApplication::desktop()->size().height(), sh.width() + 2 * margin), h);
     736#else
    704737    return QSize(qMax(200, sh.width() + 2 * margin), h);
     738#endif
    705739}
    706740
     
    719753{
    720754    Q_D(QProgressDialog);
    721     if (ev->type() == QEvent::StyleChange)
     755    if (ev->type() == QEvent::StyleChange) {
    722756        d->layout();
    723     else if (ev->type() == QEvent::LanguageChange)
     757    } else if (ev->type() == QEvent::LanguageChange) {
    724758        d->retranslateStrings();
     759    }
    725760    QDialog::changeEvent(ev);
    726761}
  • trunk/src/gui/dialogs/qprogressdialog.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/gui/dialogs/qsidebar.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5656QT_BEGIN_NAMESPACE
    5757
     58void QSideBarDelegate::initStyleOption(QStyleOptionViewItem *option,
     59                                         const QModelIndex &index) const
     60{
     61    QStyledItemDelegate::initStyleOption(option,index);
     62    QVariant value = index.data(QUrlModel::EnabledRole);
     63    if (value.isValid()) {
     64        //If the bookmark/entry is not enabled then we paint it in gray
     65        if (!qvariant_cast<bool>(value))
     66            option->state &= ~QStyle::State_Enabled;
     67    }
     68}
     69
    5870/*!
    5971    QUrlModel lets you have indexes from a QFileSystemModel to a list.  When QFileSystemModel
     
    8799
    88100    if (index.data(Qt::DecorationRole).isNull())
    89         flags &= ~Qt::ItemIsEnabled;
    90 
    91     if (invalidUrls.contains(index.data(UrlRole).toUrl()))
    92101        flags &= ~Qt::ItemIsEnabled;
    93102
     
    194203            if (!invalidUrls.contains(url))
    195204                invalidUrls.append(url);
     205            //The bookmark is invalid then we set to false the EnabledRole
     206            setData(index, false, EnabledRole);
     207        } else {
     208            //The bookmark is valid then we set to true the EnabledRole
     209            setData(index, true, EnabledRole);
    196210        }
    197211
     
    234248        if (!url.isValid() || url.scheme() != QLatin1String("file"))
    235249            continue;
     250        //this makes sure the url is clean
     251        const QString cleanUrl = QDir::cleanPath(url.toLocalFile());
     252        url = QUrl::fromLocalFile(cleanUrl);
     253
    236254        for (int j = 0; move && j < rowCount(); ++j) {
    237             if (index(j, 0).data(UrlRole) == url) {
     255            QString local = index(j, 0).data(UrlRole).toUrl().toLocalFile();
     256#if defined(Q_OS_WIN)
     257            if (index(j, 0).data(UrlRole).toUrl().toLocalFile().toLower() == cleanUrl.toLower()) {
     258#else
     259            if (index(j, 0).data(UrlRole).toUrl().toLocalFile() == cleanUrl) {
     260#endif
    238261                removeRow(j);
    239262                if (j <= row)
     
    243266        }
    244267        row = qMax(row, 0);
    245         QModelIndex idx = fileSystemModel->index(url.toLocalFile());
     268        QModelIndex idx = fileSystemModel->index(cleanUrl);
    246269        if (!fileSystemModel->isDir(idx))
    247270            continue;
    248271        insertRows(row, 1);
    249272        setUrl(index(row, 0), url, idx);
    250         watching.append(QPair<QModelIndex, QString>(idx, url.toLocalFile()));
     273        watching.append(qMakePair(idx, cleanUrl));
    251274    }
    252275}
     
    271294        return;
    272295    if (fileSystemModel != 0) {
    273         disconnect(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
    274             this, SLOT(dataChanged(const QModelIndex &, const QModelIndex &)));
     296        disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
     297            this, SLOT(dataChanged(QModelIndex,QModelIndex)));
    275298        disconnect(model, SIGNAL(layoutChanged()),
    276299            this, SLOT(layoutChanged()));
    277         disconnect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
     300        disconnect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
    278301            this, SLOT(layoutChanged()));
    279302    }
    280303    fileSystemModel = model;
    281304    if (fileSystemModel != 0) {
    282         connect(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
    283             this, SLOT(dataChanged(const QModelIndex &, const QModelIndex &)));
     305        connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
     306            this, SLOT(dataChanged(QModelIndex,QModelIndex)));
    284307        connect(model, SIGNAL(layoutChanged()),
    285308            this, SLOT(layoutChanged()));
    286         connect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
     309        connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
    287310            this, SLOT(layoutChanged()));
    288311    }
     
    357380    urlModel->setFileSystemModel(model);
    358381    setModel(urlModel);
    359 
    360     connect(selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
    361             this, SLOT(clicked(const QModelIndex &)));
     382    setItemDelegate(new QSideBarDelegate(this));
     383
     384    connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
     385            this, SLOT(clicked(QModelIndex)));
    362386#ifndef QT_NO_DRAGANDDROP
    363387    setDragDropMode(QAbstractItemView::DragDrop);
    364388#endif
    365389    setContextMenuPolicy(Qt::CustomContextMenu);
    366     connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
    367             this, SLOT(showContextMenu(const QPoint &)));
     390    connect(this, SIGNAL(customContextMenuRequested(QPoint)),
     391            this, SLOT(showContextMenu(QPoint)));
    368392    urlModel->setUrls(newUrls);
    369393    setCurrentIndex(this->model()->index(0,0));
     
    391415void QSidebar::selectUrl(const QUrl &url)
    392416{
    393     disconnect(selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
    394                this, SLOT(clicked(const QModelIndex &)));
     417    disconnect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
     418               this, SLOT(clicked(QModelIndex)));
    395419
    396420    selectionModel()->clear();
     
    402426    }
    403427
    404     connect(selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
    405             this, SLOT(clicked(const QModelIndex &)));
     428    connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
     429            this, SLOT(clicked(QModelIndex)));
    406430}
    407431
  • trunk/src/gui/dialogs/qsidebar_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5656#include <qlistwidget.h>
    5757#include <qstandarditemmodel.h>
     58#include <qstyleditemdelegate.h>
    5859#include <qurl.h>
    5960
     
    6364
    6465class QFileSystemModel;
     66
     67class QSideBarDelegate : public QStyledItemDelegate
     68{
     69 public:
     70     QSideBarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
     71     void initStyleOption(QStyleOptionViewItem *option,
     72                          const QModelIndex &index) const;
     73};
     74
    6575class Q_AUTOTEST_EXPORT QUrlModel : public QStandardItemModel
    6676{
     
    6979public:
    7080    enum Roles {
    71         UrlRole = Qt::UserRole + 1
     81        UrlRole = Qt::UserRole + 1,
     82        EnabledRole = Qt::UserRole + 2
    7283    };
    7384
  • trunk/src/gui/dialogs/qwizard.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7070#include <qdebug.h>
    7171
    72 #ifdef Q_OS_WINCE
     72#ifdef Q_WS_WINCE
    7373extern bool qt_wince_is_mobile();     //defined in qguifunctions_wce.cpp
    7474#endif
    7575
    7676#include <string.h>     // for memset()
     77
     78#ifdef QT_SOFTKEYS_ENABLED
     79#include "qaction.h"
     80#endif
    7781
    7882QT_BEGIN_NAMESPACE
     
    8488const int MacButtonTopMargin = 13;
    8589const int MacLayoutLeftMargin = 20;
    86 const int MacLayoutTopMargin = 14;
     90//const int MacLayoutTopMargin = 14; // Unused. Save some space and avoid warning.
    8791const int MacLayoutRightMargin = 20;
    8892const int MacLayoutBottomMargin = 17;
     
    245249           && topLevelMarginRight == other.topLevelMarginRight
    246250           && topLevelMarginTop == other.topLevelMarginTop
    247            && topLevelMarginBottom == other.topLevelMarginBottom 
     251           && topLevelMarginBottom == other.topLevelMarginBottom
    248252           && childMarginLeft == other.childMarginLeft
    249253           && childMarginRight == other.childMarginRight
     
    329333    QWizard *wiz = parentWidget() ? qobject_cast <QWizard *>(parentWidget()->parentWidget()) : 0;
    330334    if (wiz) {
    331         // Designer dosen't support the Vista style for Wizards. This property is used to turn 
     335        // Designer dosen't support the Vista style for Wizards. This property is used to turn
    332336        // off the Vista style.
    333337        const QVariant v = wiz->property("_q_wizard_vista_off");
     
    344348    bool modern = ((info.wizStyle == QWizard::ModernStyle)
    345349#if !defined(QT_NO_STYLE_WINDOWSVISTA)
    346         || ((info.wizStyle == QWizard::AeroStyle)
    347             && (QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled())
     350        || ((info.wizStyle == QWizard::AeroStyle
     351            && QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled())
    348352#endif
    349353    );
     
    378382            There is no widthForHeight() function, so we simulate it with a loop.
    379383        */
    380         int candidateSubTitleWidth = qMin(512, 2 * qApp->desktop()->width() / 3);
     384        int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3);
    381385        int delta = candidateSubTitleWidth >> 1;
    382386        while (delta > 0) {
     
    524528        , maximumHeight(QWIDGETSIZE_MAX)
    525529    {
    526         for (int i = 0; i < QWizard::NButtons; ++i)
     530        for (int i = 0; i < QWizard::NButtons; ++i) {
    527531            btns[i] = 0;
     532#ifdef QT_SOFTKEYS_ENABLED
     533            softKeys[i] = 0;
     534#endif
     535        }
    528536#if !defined(QT_NO_STYLE_WINDOWSVISTA)
    529537        if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
     
    561569    void _q_emitCustomButtonClicked();
    562570    void _q_updateButtonStates();
     571    void _q_handleFieldObjectDestroyed(QObject *);
    563572    void setStyle(QStyle *style);
    564573#ifdef Q_WS_MAC
     
    609618    QLabel *subTitleLabel;
    610619    QWizardRuler *bottomRuler;
     620#ifdef QT_SOFTKEYS_ENABLED
     621    mutable QAction *softKeys[QWizard::NButtons];
     622#endif
    611623
    612624    QVBoxLayout *pageVBoxLayout;
     
    634646    const bool macStyle = (wstyle == QWizard::MacStyle);
    635647    switch (which) {
    636     case QWizard::BackButton: 
     648    case QWizard::BackButton:
    637649        return macStyle ? QWizard::tr("Go Back") : QWizard::tr("< &Back");
    638     case QWizard::NextButton: 
     650    case QWizard::NextButton:
    639651        if (macStyle)
    640652            return QWizard::tr("Continue");
     
    732744void QWizardPrivate::addField(const QWizardField &field)
    733745{
     746    Q_Q(QWizard);
     747
    734748    QWizardField myField = field;
    735749    myField.resolve(defaultPropertyTable);
     
    745759        QObject::connect(myField.object, myField.changedSignal,
    746760                         myField.page, SLOT(_q_maybeEmitCompleteChanged()));
     761    QObject::connect(
     762        myField.object, SIGNAL(destroyed(QObject*)), q,
     763        SLOT(_q_handleFieldObjectDestroyed(QObject*)));
    747764}
    748765
    749766void QWizardPrivate::removeFieldAt(int index)
    750767{
     768    Q_Q(QWizard);
     769
    751770    const QWizardField &field = fields.at(index);
    752771    fieldIndexMap.remove(field.name);
     
    754773        QObject::disconnect(field.object, field.changedSignal,
    755774                            field.page, SLOT(_q_maybeEmitCompleteChanged()));
     775    QObject::disconnect(
     776        field.object, SIGNAL(destroyed(QObject*)), q,
     777        SLOT(_q_handleFieldObjectDestroyed(QObject*)));
    756778    fields.remove(index);
    757779}
     
    949971            mainLayout->setMargin(0);
    950972            mainLayout->setSpacing(0);
    951             pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop, 
     973            pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop,
    952974                                               deltaMarginRight, deltaMarginBottom);
    953             buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 
     975            buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
    954976                                             info.topLevelMarginRight, info.topLevelMarginBottom);
    955977        } else {
    956             mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 
     978            mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
    957979                                           info.topLevelMarginRight, info.topLevelMarginBottom);
    958980            mainLayout->setHorizontalSpacing(info.hspacing);
     
    12021224        Q_ASSERT(bottomSpacer);
    12031225        bottomSpacer->changeSize(0, 0, QSizePolicy::Ignored, expandPage ? QSizePolicy::Ignored : QSizePolicy::MinimumExpanding);
    1204         pageVBoxLayout->invalidate();       
     1226        pageVBoxLayout->invalidate();
    12051227    }
    12061228
     
    12411263#endif
    12421264    QSize minimumSize = mainLayout->totalMinimumSize() + QSize(0, extraHeight);
    1243     QSize maximumSize;
    1244 #if defined(Q_WS_WIN)
    1245     if (QSysInfo::WindowsVersion > QSysInfo::WV_Me) // ### See Tasks 164078 and 161660
    1246 #endif
    1247     maximumSize = mainLayout->totalMaximumSize();
     1265    QSize maximumSize = mainLayout->totalMaximumSize();
    12481266    if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX) {
    12491267        minimumSize.setWidth(headerWidget->maximumWidth());
     
    13211339        if (which < QWizard::NStandardButtons)
    13221340            pushButton->setText(buttonDefaultText(wizStyle, which, this));
     1341
     1342#ifdef QT_SOFTKEYS_ENABLED
     1343        QAction *softKey = new QAction(pushButton->text(), pushButton);
     1344        QAction::SoftKeyRole softKeyRole;
     1345        switch(which) {
     1346        case QWizard::NextButton:
     1347        case QWizard::FinishButton:
     1348        case QWizard::CancelButton:
     1349            softKeyRole = QAction::NegativeSoftKey;
     1350            break;
     1351        case QWizard::BackButton:
     1352        case QWizard::CommitButton:
     1353        case QWizard::HelpButton:
     1354        case QWizard::CustomButton1:
     1355        case QWizard::CustomButton2:
     1356        case QWizard::CustomButton3:
     1357        default:
     1358            softKeyRole = QAction::PositiveSoftKey;
     1359            break;
     1360        }
     1361        softKey->setSoftKeyRole(softKeyRole);
     1362        softKeys[which] = softKey;
     1363#endif
    13231364        connectButton(which);
    13241365    }
     
    13341375        QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked()));
    13351376    }
     1377
     1378#ifdef QT_SOFTKEYS_ENABLED
     1379    QObject::connect(softKeys[which], SIGNAL(triggered()), btns[which], SIGNAL(clicked()));
     1380#endif
    13361381}
    13371382
     
    13471392            else if (i < QWizard::NStandardButtons)
    13481393                btns[i]->setText(buttonDefaultText(wizStyle, i, this));
     1394#ifdef QT_SOFTKEYS_ENABLED
     1395            softKeys[i]->setText(btns[i]->text());
     1396#endif
    13491397        }
    13501398    }
     
    14661514    inHandleAeroStyleChange = true;
    14671515
    1468     vistaHelper->backButton()->disconnect();
     1516    vistaHelper->disconnectBackButton();
    14691517    q->removeEventFilter(vistaHelper);
    14701518
     
    14901538    } else {
    14911539        q->setMouseTracking(true); // ### original value possibly different
     1540#ifndef QT_NO_CURSOR
    14921541        q->unsetCursor(); // ### ditto
     1542#endif
    14931543        antiFlickerWidget->move(0, 0);
    1494         vistaHelper->backButton()->hide();
     1544        vistaHelper->hideBackButton();
    14951545        vistaHelper->setTitleBarIconAndCaptionVisible(true);
    14961546    }
     
    15891639#endif
    15901640
     1641#ifdef QT_SOFTKEYS_ENABLED
     1642    QAbstractButton *wizardButton;
     1643    for (int i = 0; i < QWizard::NButtons; ++i) {
     1644        wizardButton = btns[i];
     1645        if (wizardButton && !wizardButton->testAttribute(Qt::WA_WState_Hidden)) {
     1646            wizardButton->hide();
     1647            q->addAction(softKeys[i]);
     1648        } else {
     1649            q->removeAction(softKeys[i]);
     1650        }
     1651    }
     1652#endif
     1653
    15911654    enableUpdates();
     1655}
     1656
     1657void QWizardPrivate::_q_handleFieldObjectDestroyed(QObject *object)
     1658{
     1659    QVector<QWizardField>::iterator it = fields.begin();
     1660    while (it != fields.end()) {
     1661        const QWizardField &field = *it;
     1662        if (field.object == object) {
     1663            fieldIndexMap.remove(field.name);
     1664            it = fields.erase(it);
     1665        } else {
     1666            ++it;
     1667        }
     1668    }
    15921669}
    15931670
     
    16031680
    16041681#ifdef Q_WS_MAC
    1605 
    1606 #ifdef Q_WS_MAC32
    1607 QT_BEGIN_INCLUDE_NAMESPACE
    1608 #include <QuickTime/QuickTime.h>
    1609 QT_END_INCLUDE_NAMESPACE
    1610 typedef OSErr (*PtrQTNewDataReferenceFromCFURL)(CFURLRef, UInt32, Handle*, OSType*);
    1611 typedef OSErr (*PtrGetGraphicsImporterForDataRefWithFlags)(Handle, OSType, ComponentInstance*, long);
    1612 typedef ComponentResult (*PtrGraphicsImportSetFlags)(GraphicsImportComponent, long);
    1613 typedef ComponentResult (*PtrGraphicsImportCreateCGImage)(GraphicsImportComponent, CGImageRef*, UInt32);
    1614 
    1615 static PtrQTNewDataReferenceFromCFURL ptrQTNewDataReferenceFromCFURL = 0;
    1616 static PtrGetGraphicsImporterForDataRefWithFlags ptrGetGraphicsImporterForDataRefWithFlags = 0;
    1617 static PtrGraphicsImportSetFlags ptrGraphicsImportSetFlags = 0;
    1618 static PtrGraphicsImportCreateCGImage ptrGraphicsImportCreateCGImage = 0;
    1619 
    1620 static bool resolveQuickTimeSymbols()
    1621 {
    1622     if (ptrQTNewDataReferenceFromCFURL == 0) {
    1623         QLibrary library(QLatin1String("/System/Library/Frameworks/QuickTime.framework/QuickTime"));
    1624         ptrQTNewDataReferenceFromCFURL = reinterpret_cast<PtrQTNewDataReferenceFromCFURL>(library.resolve("QTNewDataReferenceFromCFURL"));
    1625         ptrGetGraphicsImporterForDataRefWithFlags = reinterpret_cast<PtrGetGraphicsImporterForDataRefWithFlags>(library.resolve("GetGraphicsImporterForDataRefWithFlags"));
    1626         ptrGraphicsImportSetFlags = reinterpret_cast<PtrGraphicsImportSetFlags>(library.resolve("GraphicsImportSetFlags"));
    1627         ptrGraphicsImportCreateCGImage = reinterpret_cast<PtrGraphicsImportCreateCGImage>(library.resolve("GraphicsImportCreateCGImage"));
    1628     }
    1629 
    1630     return ptrQTNewDataReferenceFromCFURL != 0 && ptrGetGraphicsImporterForDataRefWithFlags != 0
    1631            && ptrGraphicsImportSetFlags != 0 && ptrGraphicsImportCreateCGImage != 0;
    1632 }
    1633 
    1634 
    1635 static QPixmap quicktimeTiff(const CFURLRef url)
    1636 {
    1637     if (!resolveQuickTimeSymbols())
    1638         return QPixmap();
    1639 
    1640     QCFType <CGImageRef> imageRef = 0;
    1641     Handle dataRef;
    1642     OSType dataRefType;
    1643     GraphicsImportComponent gi;
    1644     ComponentResult result;
    1645     result = ptrQTNewDataReferenceFromCFURL(url, 0, &dataRef, &dataRefType);
    1646     if (dataRef != 0) {
    1647         OSStatus err = ptrGetGraphicsImporterForDataRefWithFlags(dataRef, dataRefType, &gi, 0);
    1648         if (err == noErr && gi) {
    1649             result = ptrGraphicsImportSetFlags(gi, (kGraphicsImporterDontDoGammaCorrection
    1650                                                     + kGraphicsImporterDontUseColorMatching));
    1651             if (!result)
    1652                 result = ptrGraphicsImportCreateCGImage(gi, &imageRef, 0);
    1653             if (result)
    1654                 qWarning("Qt: Problem reading TIFF image %ld(%s:%d)", result, __FILE__, __LINE__);
    1655             DisposeHandle(dataRef);
    1656             CloseComponent(gi);
    1657         }
    1658     }
    1659 
    1660     if (imageRef)
    1661         return QPixmap::fromMacCGImageRef(imageRef);
    1662     return QPixmap();
    1663 }
    1664 #endif // Q_WS_MAC32
    16651682
    16661683QPixmap QWizardPrivate::findDefaultBackgroundPixmap()
     
    16751692            url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("tif"), 0);
    16761693            if (url) {
    1677 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
    1678                 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
    1679                     QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0);
    1680                     QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0);
    1681                     if (image) {
    1682                         int width = CGImageGetWidth(image);
    1683                         int height = CGImageGetHeight(image);
    1684                         if (width == ExpectedImageWidth && height == ExpectedImageHeight)
    1685                             return QPixmap::fromMacCGImageRef(image);
    1686                     }
    1687                 } else
    1688 #endif
    1689                 {
    1690 #ifdef Q_WS_MAC32
    1691                     return quicktimeTiff(url);
    1692 #endif
     1694                QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0);
     1695                QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0);
     1696                if (image) {
     1697                    int width = CGImageGetWidth(image);
     1698                    int height = CGImageGetHeight(image);
     1699                    if (width == ExpectedImageWidth && height == ExpectedImageHeight)
     1700                        return QPixmap::fromMacCGImageRef(image);
    16931701                }
    16941702            }
     
    21212129    Q_D(QWizard);
    21222130    d->init();
    2123 #ifdef Q_OS_WINCE
     2131#ifdef Q_WS_WINCE
    21242132    if (!qt_wince_is_mobile())
    21252133        setWindowFlags(windowFlags() & ~Qt::WindowOkButtonHint);
     
    28372845    Q_D(const QWizard);
    28382846    QSize result = d->mainLayout->totalSizeHint();
     2847#ifdef Q_WS_S60
     2848    QSize extra(QApplication::desktop()->availableGeometry(QCursor::pos()).size());
     2849#else
    28392850    QSize extra(500, 360);
     2851#endif
    28402852    if (d->wizStyle == MacStyle && d->current != -1) {
    28412853        QSize pixmap(currentPage()->pixmap(BackgroundPixmap).size());
     
    34373449    changes. This ensures that QWizard updates the enabled or disabled state of
    34383450    its buttons. An example of the reimplementation is
    3439     available \l{http://doc.trolltech.com/qq/qq22-qwizard.html#validatebeforeitstoolate}
    3440     {here}. 
     3451    available \l{http://qt.nokia.com/doc/qq/qq22-qwizard.html#validatebeforeitstoolate}
     3452    {here}.
    34413453
    34423454    \sa completeChanged(), isFinalPage()
  • trunk/src/gui/dialogs/qwizard.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    198198    Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
    199199    Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
     200    Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
    200201
    201202    friend class QWizardPage;
  • trunk/src/gui/dialogs/qwizard_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    240240    : pressed(false)
    241241    , wizard(wizard)
     242    , backButton_(0)
    242243{
    243244    is_vista = resolveSymbols();
    244     backButton_ = new QVistaBackButton(wizard);
     245    if (is_vista)
     246        backButton_ = new QVistaBackButton(wizard);
    245247}
    246248
     
    278280{
    279281    DWORD rgb;
    280     HANDLE hTheme = pOpenThemeData(qApp->desktop()->winId(), L"WINDOW");
     282    HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW");
    281283    pGetThemeColor(
    282284        hTheme, WIZ_WP_CAPTION, WIZ_CS_ACTIVE,
     
    311313            painter->paintEngine()->getDC());
    312314
     315    Q_ASSERT(backButton_);
    313316    const int btnTop = backButton_->mapToParent(QPoint()).y();
    314317    const int btnHeight = backButton_->size().height();
     
    385388void QVistaHelper::setMouseCursor(QPoint pos)
    386389{
     390#ifndef QT_NO_CURSOR
    387391    if (rtTop.contains(pos))
    388392        wizard->setCursor(Qt::SizeVerCursor);
    389393    else
    390394        wizard->setCursor(Qt::ArrowCursor);
     395#endif
    391396}
    392397
     
    609614    bool value = false;
    610615    if (vistaState() == VistaAero) {
    611         HANDLE hTheme = pOpenThemeData(qApp->desktop()->winId(), L"WINDOW");
     616        HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW");
    612617        if (!hTheme) return false;
    613618        // Set up a memory DC and bitmap that we'll draw into
    614619        HDC dcMem;
    615620        HBITMAP bmp;
    616         BITMAPINFO dib = {0};
     621        BITMAPINFO dib = {{0}};
    617622        dcMem = CreateCompatibleDC(hdc);
    618623
     
    660665        HDC dcMem;
    661666        HBITMAP bmp;
    662         BITMAPINFO dib = {0};
     667        BITMAPINFO dib = {{0}};
    663668        dcMem = CreateCompatibleDC(hdc);
    664669
  • trunk/src/gui/dialogs/qwizard_win_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5757#ifndef QT_NO_STYLE_WINDOWSVISTA
    5858
    59 #include <windows.h>
     59#include <qt_windows.h>
    6060#include <qobject.h>
    6161#include <qwidget.h>
     
    9595    void paintEvent(QPaintEvent *event);
    9696    QVistaBackButton *backButton() const { return backButton_; }
     97    void disconnectBackButton() { if (backButton_) backButton_->disconnect(); }
     98    void hideBackButton() { if (backButton_) backButton_->hide(); }
    9799    void setWindowPosHack();
    98100    QColor basicWindowFrameColor();
Note: See TracChangeset for help on using the changeset viewer.