Changeset 561 for trunk/src/qt3support/dialogs/q3filedialog.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/qt3support/dialogs/q3filedialog.cpp
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the Qt3Support module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 508 508 } 509 509 510 // Don't remove the lines below!511 //512 // resolving the W methods manually is needed, because Windows 95 doesn't include513 // these methods in Shell32.lib (not even stubs!), so you'd get an unresolved symbol514 // when Qt calls getEsistingDirectory(), etc.515 510 #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_WINCE523 static bool triedResolve = false;524 525 if (!triedResolve) {526 #ifndef QT_NO_THREAD527 // protect initialization528 QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));529 // check triedResolve again, since another thread may have already530 // done the initialization531 if (triedResolve) {532 // another thread did initialize the security function pointers,533 // so we shouldn't do it again.534 return;535 }536 #endif537 triedResolve = true;538 if (qt_winUnicode()) {539 QLibrary lib(QLatin1String("shell32"));540 ptrExtractIconEx = (PtrExtractIconEx) lib.resolve("ExtractIconExW");541 }542 }543 #endif544 }545 #ifdef Q_OS_WINCE546 #define PtrExtractIconEx ExtractIconEx547 #endif548 549 511 class QWindowsIconProvider : public Q3FileIconProvider 550 512 { … … 632 594 void keyPressEvent(QKeyEvent *e); 633 595 void focusOutEvent(QFocusEvent *e); 596 void emitDoRename(); 634 597 635 598 signals: … … 1144 1107 void QRenameEdit::focusOutEvent(QFocusEvent *) 1145 1108 { 1146 if (!doRenameAlreadyEmitted) { 1147 doRenameAlreadyEmitted = true; 1148 emit doRename(); 1149 } 1109 if (!doRenameAlreadyEmitted) 1110 emitDoRename(); 1150 1111 } 1151 1112 1152 1113 void QRenameEdit::slotReturnPressed() 1114 { 1115 emitDoRename(); 1116 } 1117 1118 void QRenameEdit::emitDoRename() 1153 1119 { 1154 1120 doRenameAlreadyEmitted = true; 1155 1121 emit doRename(); 1122 doRenameAlreadyEmitted = false; 1156 1123 } 1157 1124 … … 2562 2529 2563 2530 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 #else2567 2531 if (!qstrcmp(style()->className(), "QWindowsStyle")) 2568 #endif2569 2532 { 2570 2533 d->goBack->setAutoRaise(true); … … 3875 3838 } 3876 3839 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)); 3878 3841 i = i->nextSibling(); 3879 3842 } … … 3927 3890 if (d->moreFiles->isSelected(i) 3928 3891 && !((Q3FileDialogPrivate::File*)(mcitem)->i)->info.isDir()) { 3929 str += QString(QLatin1String("\"%1\" ")).arg(i->text());3892 str += QString::fromLatin1("\"%1\" ").arg(i->text()); 3930 3893 if (j == 0) 3931 3894 j = i; … … 4607 4570 Q3FileDialog::PreviewMode Q3FileDialog::previewMode() const 4608 4571 { 4609 if (d->infoPreview && d->infoPreviewWidget->isVisible ())4572 if (d->infoPreview && d->infoPreviewWidget->isVisibleTo(const_cast<Q3FileDialog *>(this))) 4610 4573 return Info; 4611 else if (d->contentsPreview && d->contentsPreviewWidget->isVisible()) 4574 else if (d->contentsPreview 4575 && d->contentsPreviewWidget->isVisibleTo(const_cast<Q3FileDialog *>(this))) 4612 4576 return Contents; 4613 4614 4577 return NoPreview; 4615 4578 } … … 4874 4837 { 4875 4838 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 4903 4853 return s; 4904 4854 } … … 4921 4871 HKEY k; 4922 4872 HICON si; 4923 int r;4924 4873 QString s; 4925 4874 UINT res = 0; … … 4927 4876 // ---------- get default folder pixmap 4928 4877 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 4939 4880 if (r == ERROR_SUCCESS) { 4940 4881 s = getWindowsRegString(k, QString()); … … 4944 4885 4945 4886 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); 4961 4888 } 4962 4889 … … 4974 4901 4975 4902 //------------------------------- 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); 4988 4904 4989 4905 if (res) { … … 4998 4914 //------------------------------- get default exe pixmap 4999 4915 #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); 5007 4917 #else 5008 res = (UINT)ExtractIconEx(L"ceshell.dll", 5009 10, 0, &si, 1); 4918 res = ExtractIconEx(L"ceshell.dll", 10, 0, &si, 1); 5010 4919 #endif 5011 4920 … … 5046 4955 5047 4956 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); 5056 4958 QString s; 5057 4959 if (r == ERROR_SUCCESS) { … … 5064 4966 RegCloseKey(k); 5065 4967 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); 5073 4970 if (r == ERROR_SUCCESS) { 5074 4971 s = getWindowsRegString(k2, QString()); … … 5100 4997 filepath = filepath.mid(1, filepath.length()-2); 5101 4998 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); 5115 5000 } 5116 5001 } … … 5129 5014 UINT res = 0; 5130 5015 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); 5157 5019 } 5158 5020 … … 5753 5615 if (d->url.isLocalFile()) { 5754 5616 QString file = d->url.path(); 5755 if (!file.endsWith(QLatin1 String("/")))5756 file.append(QLatin1 String("/"));5617 if (!file.endsWith(QLatin1Char('/'))) 5618 file.append(QLatin1Char('/')); 5757 5619 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; 5765 5622 } else { 5766 5623 if (inf.name() != QLatin1String("..") && inf.name()[0] == QLatin1Char('.')) … … 6195 6052 */ 6196 6053 6197 6054 6198 6055 QT_END_NAMESPACE 6199 6056
Note:
See TracChangeset
for help on using the changeset viewer.