diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2009-08-17 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:00 +0300 |
commit | c99f3ebdd639c2adb03d8b44001b10af18516504 (patch) | |
tree | 92aaf34e5edbd7287c3f55037190da75ab0a8000 /CPP/7zip/UI/FileManager/OverwriteDialog.cpp | |
parent | 829409452d85cd6dd9dfc9151f109d6e13a2bb1c (diff) |
9.06 beta
Diffstat (limited to 'CPP/7zip/UI/FileManager/OverwriteDialog.cpp')
-rwxr-xr-x | CPP/7zip/UI/FileManager/OverwriteDialog.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp index 42c63266..5f072daf 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp @@ -2,9 +2,8 @@ #include "StdAfx.h" -#include "OverwriteDialog.h" - #include "Common/StringConvert.h" + #include "Windows/FileName.h" #include "Windows/Defs.h" #include "Windows/ResourceString.h" @@ -12,6 +11,7 @@ #include "Windows/PropVariantConversions.h" #include "FormatUtils.h" +#include "OverwriteDialog.h" // #include "../resource.h" @@ -36,6 +36,16 @@ static CIDLangPair kIDLangPairs[] = }; #endif +static const int kCurrentFileNameSizeLimit = 82; +static const int kCurrentFileNameSizeLimit2 = 30; + +void COverwriteDialog::ReduceString(UString &s) +{ + int size = _isBig ? kCurrentFileNameSizeLimit : kCurrentFileNameSizeLimit2; + if (s.Length() > size) + s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2); +} + void COverwriteDialog::SetFileInfoControl(int textID, int iconID, const NOverwriteDialog::CFileInfo &fileInfo) { @@ -47,19 +57,23 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID, #endif NumberToString(fileInfo.Size)); - UString reducedName; - const int kLineSize = 88; - for (int i = 0; i < fileInfo.Name.Length();) + const UString &fileName = fileInfo.Name; + int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); + UString s1, s2; + if (slashPos >= 0) { - reducedName += fileInfo.Name.Mid(i, kLineSize); - reducedName += L" "; - i += kLineSize; + s1 = fileName.Left(slashPos + 1); + s2 = fileName.Mid(slashPos + 1); } - - UString fullString = reducedName; - fullString += L"\n"; + else + s2 = fileName; + ReduceString(s1); + ReduceString(s2); + + UString fullString = s1 + L'\n' + s2; + fullString += L'\n'; fullString += sizeString; - fullString += L"\n"; + fullString += L'\n'; if (fileInfo.TimeIsDefined) { @@ -101,10 +115,9 @@ bool COverwriteDialog::OnInit() LangSetWindowText(HWND(*this), 0x02000900); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif - SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, - IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo); - SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, - IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo); + SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo); + SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo); + NormalizePosition(); return CModalDialog::OnInit(); } |