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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/qt3support/dialogs/q3filedialog.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 Qt3Support 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**
     
    508508}
    509509
    510 // Don't remove the lines below!
    511 //
    512 // resolving the W methods manually is needed, because Windows 95 doesn't include
    513 // these methods in Shell32.lib (not even stubs!), so you'd get an unresolved symbol
    514 // when Qt calls getEsistingDirectory(), etc.
    515510#if defined(Q_WS_WIN)
    516 
    517 typedef UINT (WINAPI *PtrExtractIconEx)(LPCTSTR,int,HICON*,HICON*,UINT);
    518 static PtrExtractIconEx ptrExtractIconEx = 0;
    519 
    520 static void resolveLibs()
    521 {
    522 #ifndef Q_OS_WINCE
    523     static bool triedResolve = false;
    524 
    525     if (!triedResolve) {
    526 #ifndef QT_NO_THREAD
    527         // protect initialization
    528         QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
    529         // check triedResolve again, since another thread may have already
    530         // done the initialization
    531         if (triedResolve) {
    532             // another thread did initialize the security function pointers,
    533             // so we shouldn't do it again.
    534             return;
    535         }
    536 #endif
    537         triedResolve = true;
    538         if (qt_winUnicode()) {
    539             QLibrary lib(QLatin1String("shell32"));
    540             ptrExtractIconEx = (PtrExtractIconEx) lib.resolve("ExtractIconExW");
    541         }
    542     }
    543 #endif
    544 }
    545 #ifdef Q_OS_WINCE
    546 #define PtrExtractIconEx ExtractIconEx
    547 #endif
    548 
    549511class QWindowsIconProvider : public Q3FileIconProvider
    550512{
     
    632594    void keyPressEvent(QKeyEvent *e);
    633595    void focusOutEvent(QFocusEvent *e);
     596    void emitDoRename();
    634597
    635598signals:
     
    11441107void QRenameEdit::focusOutEvent(QFocusEvent *)
    11451108{
    1146     if (!doRenameAlreadyEmitted) {
    1147         doRenameAlreadyEmitted = true;
    1148         emit doRename();
    1149     }
     1109    if (!doRenameAlreadyEmitted)
     1110        emitDoRename();
    11501111}
    11511112
    11521113void QRenameEdit::slotReturnPressed()
     1114{
     1115    emitDoRename();
     1116}
     1117
     1118void QRenameEdit::emitDoRename()
    11531119{
    11541120    doRenameAlreadyEmitted = true;
    11551121    emit doRename();
     1122    doRenameAlreadyEmitted = false;
    11561123}
    11571124
     
    25622529
    25632530    d->previewContents = new QToolButton(this, "preview info view");
    2564 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
    2565     if ((qWinVersion() & Qt::WV_NT_based) > Qt::WV_NT)
    2566 #else
    25672531    if (!qstrcmp(style()->className(), "QWindowsStyle"))
    2568 #endif
    25692532    {
    25702533        d->goBack->setAutoRaise(true);
     
    38753838        }
    38763839        if (i->isSelected() && !((Q3FileDialogPrivate::File *)i)->info.isDir())
    3877             str += QString(QLatin1String("\"%1\" ")).arg(i->text(0));
     3840            str += QString::fromLatin1("\"%1\" ").arg(i->text(0));
    38783841        i = i->nextSibling();
    38793842    }
     
    39273890        if (d->moreFiles->isSelected(i)
    39283891             && !((Q3FileDialogPrivate::File*)(mcitem)->i)->info.isDir()) {
    3929             str += QString(QLatin1String("\"%1\" ")).arg(i->text());
     3892                 str += QString::fromLatin1("\"%1\" ").arg(i->text());
    39303893            if (j == 0)
    39313894                j = i;
     
    46074570Q3FileDialog::PreviewMode Q3FileDialog::previewMode() const
    46084571{
    4609     if (d->infoPreview && d->infoPreviewWidget->isVisible())
     4572    if (d->infoPreview && d->infoPreviewWidget->isVisibleTo(const_cast<Q3FileDialog *>(this)))
    46104573        return Info;
    4611     else if (d->contentsPreview && d->contentsPreviewWidget->isVisible())
     4574    else if (d->contentsPreview
     4575             && d->contentsPreviewWidget->isVisibleTo(const_cast<Q3FileDialog *>(this)))
    46124576        return Contents;
    4613 
    46144577    return NoPreview;
    46154578}
     
    48744837{
    48754838    QString s;
    4876     QT_WA({
    4877         char buf[1024];
    4878         DWORD bsz = sizeof(buf);
    4879         int r = RegQueryValueEx(key, (TCHAR*)subKey.ucs2(), 0, 0, (LPBYTE)buf, &bsz);
    4880         if (r == ERROR_SUCCESS) {
    4881             s = QString::fromUcs2((unsigned short *)buf);
    4882         } else if (r == ERROR_MORE_DATA) {
    4883             char *ptr = new char[bsz+1];
    4884             r = RegQueryValueEx(key, (TCHAR*)subKey.ucs2(), 0, 0, (LPBYTE)ptr, &bsz);
    4885             if (r == ERROR_SUCCESS)
    4886                 s = QLatin1String(ptr);
    4887             delete [] ptr;
    4888         }
    4889     } , {
    4890         char buf[512];
    4891         DWORD bsz = sizeof(buf);
    4892         int r = RegQueryValueExA(key, subKey.local8Bit(), 0, 0, (LPBYTE)buf, &bsz);
    4893         if (r == ERROR_SUCCESS) {
    4894             s = QLatin1String(buf);
    4895         } else if (r == ERROR_MORE_DATA) {
    4896             char *ptr = new char[bsz+1];
    4897             r = RegQueryValueExA(key, subKey.local8Bit(), 0, 0, (LPBYTE)ptr, &bsz);
    4898             if (r == ERROR_SUCCESS)
    4899                 s = QLatin1String(ptr);
    4900             delete [] ptr;
    4901         }
    4902     });
     4839
     4840    wchar_t buf[1024];
     4841    DWORD bsz = sizeof(buf) / sizeof(wchar_t);
     4842    int r = RegQueryValueEx(key, (wchar_t*)subKey.utf16(), 0, 0, (LPBYTE)buf, &bsz);
     4843    if (r == ERROR_SUCCESS) {
     4844        s = QString::fromWCharArray(buf);
     4845    } else if (r == ERROR_MORE_DATA) {
     4846        char *ptr = new char[bsz+1];
     4847        r = RegQueryValueEx(key, (wchar_t*)subKey.utf16(), 0, 0, (LPBYTE)ptr, &bsz);
     4848        if (r == ERROR_SUCCESS)
     4849            s = QLatin1String(ptr);
     4850        delete [] ptr;
     4851    }
     4852
    49034853    return s;
    49044854}
     
    49214871    HKEY k;
    49224872    HICON si;
    4923     int r;
    49244873    QString s;
    49254874    UINT res = 0;
     
    49274876    // ---------- get default folder pixmap
    49284877    const wchar_t iconFolder[] = L"folder\\DefaultIcon"; // workaround for Borland
    4929     QT_WA({
    4930         r = RegOpenKeyEx(HKEY_CLASSES_ROOT,
    4931                            iconFolder,
    4932                            0, KEY_READ, &k);
    4933     } , {
    4934         r = RegOpenKeyExA(HKEY_CLASSES_ROOT,
    4935                            "folder\\DefaultIcon",
    4936                            0, KEY_READ, &k);
    4937     });
    4938     resolveLibs();
     4878    int r = RegOpenKeyEx(HKEY_CLASSES_ROOT, iconFolder, 0, KEY_READ, &k);
     4879
    49394880    if (r == ERROR_SUCCESS) {
    49404881        s = getWindowsRegString(k, QString());
     
    49444885
    49454886        if (lst.count() >= 2) { // don't just assume that lst has two entries
    4946 #ifndef Q_OS_WINCE
    4947             QT_WA({
    4948                 res = ptrExtractIconEx((TCHAR*)lst[0].simplifyWhiteSpace().ucs2(),
    4949                                        lst[1].simplifyWhiteSpace().toInt(),
    4950                                        0, &si, 1);
    4951             } , {
    4952                 res = ExtractIconExA(lst[0].simplifyWhiteSpace().local8Bit(),
    4953                                      lst[1].simplifyWhiteSpace().toInt(),
    4954                                      0, &si, 1);
    4955             });
    4956 #else
    4957             res = (UINT)ExtractIconEx((TCHAR*)lst[0].simplifyWhiteSpace().ucs2(),
    4958                                         lst[1].simplifyWhiteSpace().toInt(),
    4959                                         0, &si, 1);
    4960 #endif
     4887            res = ExtractIconEx((wchar_t*)lst[0].simplifyWhiteSpace().utf16(), lst[1].simplifyWhiteSpace().toInt(), 0, &si, 1);
    49614888        }
    49624889
     
    49744901
    49754902    //------------------------------- get default file pixmap
    4976 #ifndef Q_OS_WINCE
    4977     QT_WA({
    4978         res = ptrExtractIconEx(L"shell32.dll",
    4979                                  0, 0, &si, 1);
    4980     } , {
    4981         res = ExtractIconExA("shell32.dll",
    4982                                  0, 0, &si, 1);
    4983     });
    4984 #else
    4985         res = (UINT)ExtractIconEx(L"shell32.dll",
    4986                                     0, 0, &si, 1);
    4987 #endif
     4903    res = ExtractIconEx(L"shell32.dll", 0, 0, &si, 1);
    49884904
    49894905    if (res) {
     
    49984914    //------------------------------- get default exe pixmap
    49994915#ifndef Q_OS_WINCE
    5000     QT_WA({
    5001         res = ptrExtractIconEx(L"shell32.dll",
    5002                               2, 0, &si, 1);
    5003     } , {
    5004         res = ExtractIconExA("shell32.dll",
    5005                           2, 0, &si, 1);
    5006     });
     4916    res = ExtractIconEx(L"shell32.dll", 2, 0, &si, 1);
    50074917#else
    5008         res = (UINT)ExtractIconEx(L"ceshell.dll",
    5009                                     10, 0, &si, 1);
     4918    res = ExtractIconEx(L"ceshell.dll", 10, 0, &si, 1);
    50104919#endif
    50114920
     
    50464955
    50474956        HKEY k, k2;
    5048         int r;
    5049         QT_WA({
    5050             r = RegOpenKeyEx(HKEY_CLASSES_ROOT, (TCHAR*)ext.ucs2(),
    5051                               0, KEY_READ, &k);
    5052         } , {
    5053             r = RegOpenKeyExA(HKEY_CLASSES_ROOT, ext.local8Bit(),
    5054                                0, KEY_READ, &k);
    5055         });
     4957        int r = RegOpenKeyEx(HKEY_CLASSES_ROOT, (wchar_t*)ext.utf16(), 0, KEY_READ, &k);
    50564958        QString s;
    50574959        if (r == ERROR_SUCCESS) {
     
    50644966        RegCloseKey(k);
    50654967
    5066         QT_WA({
    5067             r = RegOpenKeyEx(HKEY_CLASSES_ROOT, (TCHAR*)QString(s + QLatin1String("\\DefaultIcon")).ucs2(),
    5068                                0, KEY_READ, &k2);
    5069         } , {
    5070             r = RegOpenKeyExA(HKEY_CLASSES_ROOT, QString(s + QLatin1String("\\DefaultIcon")).local8Bit() ,
    5071                                0, KEY_READ, &k2);
    5072         });
     4968        r = RegOpenKeyEx(HKEY_CLASSES_ROOT, (wchar_t*)QString(s + QLatin1String("\\DefaultIcon")).utf16(),
     4969                         0, KEY_READ, &k2);
    50734970        if (r == ERROR_SUCCESS) {
    50744971            s = getWindowsRegString(k2, QString());
     
    51004997                    filepath = filepath.mid(1, filepath.length()-2);
    51014998
    5102                 resolveLibs();
    5103 #ifndef Q_OS_WINCE
    5104                 QT_WA({
    5105                     res = ptrExtractIconEx((TCHAR*)filepath.ucs2(), lst[1].stripWhiteSpace().toInt(),
    5106                         0, &si, 1);
    5107                 } , {
    5108                     res = ExtractIconExA(filepath.local8Bit(), lst[1].stripWhiteSpace().toInt(),
    5109                         0, &si, 1);
    5110                 });
    5111 #else
    5112                 res = (UINT)ExtractIconEx((TCHAR*)filepath.ucs2(), lst[1].stripWhiteSpace().toInt(),
    5113                     0, &si, 1);
    5114 #endif
     4999                res = ExtractIconEx((wchar_t*)filepath.utf16(), lst[1].stripWhiteSpace().toInt(), 0, &si, 1);
    51155000            }
    51165001        }
     
    51295014        UINT res = 0;
    51305015        if (!fi.absFilePath().isEmpty()) {
    5131 #ifndef Q_OS_WINCE
    5132             QT_WA({
    5133                 res = ptrExtractIconEx((TCHAR*)fi.absFilePath().ucs2(), -1,
    5134                                       0, 0, 1);
    5135             } , {
    5136                 res = ExtractIconExA(fi.absFilePath().local8Bit(), -1,
    5137                                       0, 0, 1);
    5138             });
    5139 
    5140             if (res) {
    5141                 QT_WA({
    5142                     res = ptrExtractIconEx((TCHAR*)fi.absFilePath().ucs2(), res - 1,
    5143                                           0, &si, 1);
    5144                 } , {
    5145                     res = ExtractIconExA(fi.absFilePath().local8Bit(), res - 1,
    5146                                           0, &si, 1);
    5147                 });
    5148             }
    5149 #else
    5150                 res = (UINT)ExtractIconEx((TCHAR*)fi.absFilePath().ucs2(), -1,
    5151                                             0, 0, 1);
    5152                 if (res)
    5153                     res = (UINT)ExtractIconEx((TCHAR*)fi.absFilePath().ucs2(), res - 1,
    5154                                                 0, &si, 1);
    5155 #endif
    5156 
     5016            res = ExtractIconEx((wchar_t*)fi.absFilePath().utf16(), -1, 0, 0, 1);
     5017            if (res)
     5018                res = ExtractIconEx((wchar_t*)fi.absFilePath().utf16(), res - 1, 0, &si, 1);
    51575019        }
    51585020
     
    57535615            if (d->url.isLocalFile()) {
    57545616                QString file = d->url.path();
    5755                 if (!file.endsWith(QLatin1String("/")))
    5756                     file.append(QLatin1String("/"));
     5617                if (!file.endsWith(QLatin1Char('/')))
     5618                    file.append(QLatin1Char('/'));
    57575619                file += inf.name();
    5758                 QT_WA({
    5759                     if (GetFileAttributesW((TCHAR*)file.ucs2()) & FILE_ATTRIBUTE_HIDDEN)
    5760                         continue;
    5761                 } , {
    5762                     if (GetFileAttributesA(file.local8Bit()) & FILE_ATTRIBUTE_HIDDEN)
    5763                         continue;
    5764                 });
     5620                if (GetFileAttributes((wchar_t*)file.utf16()) & FILE_ATTRIBUTE_HIDDEN)
     5621                    continue;
    57655622            } else {
    57665623                if (inf.name() != QLatin1String("..") && inf.name()[0] == QLatin1Char('.'))
     
    61956052*/
    61966053
    6197 
     6054   
    61986055QT_END_NAMESPACE
    61996056
Note: See TracChangeset for help on using the changeset viewer.