Fix inaccurate sorting result in Windows dialog

Both sorting results of size & type columns in Windows dialog were incorrect.
Now they are fixed.
pull/8022/head
Don HO 5 years ago
parent b645875196
commit 5c7660b7b9
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

@ -1,4 +1,4 @@
// This file is part of Notepad++ project
// This file is part of Notepad++ project
// Copyright (C)2003 Don HO <don.h@free.fr>
//
// This program is free software; you can redistribute it and/or
@ -175,8 +175,37 @@ struct BufferEquivalent
}
else if (_iColumn == 2)
{
auto t1 = b1->getLangType();
auto t2 = b2->getLangType();
NppParameters & nppParameters = NppParameters::getInstance();
const TCHAR *s1;
const TCHAR *s2;
//const TCHAR empty[] = ;
Lang *lang1 = nppParameters.getLangFromID(b1->getLangType());
if (lang1)
{
s1 = lang1->getLangName();
}
else
s1 = TEXT("");
Lang *lang2 = nppParameters.getLangFromID(b2->getLangType());
if (lang2)
{
s2 = lang2->getLangName();
}
else
s2 = TEXT("");
int result = _strequiv(s1, s2);
if (result != 0) // default to filepath sorting when equivalent
return result < 0;
}
else if (_iColumn == 3)
{
auto t1 = b1->docLength();
auto t2 = b2->docLength();
if (t1 != t2) // default to filepath sorting when equivalent
return (t1 < t2);
@ -516,23 +545,23 @@ BOOL WindowsDlg::onInitDialog()
generic_string columnText;
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
columnText = TEXT("\u21F5 ") + pNativeSpeaker->getAttrNameStr(TEXT("Name"), WD_ROOTNODE, WD_CLMNNAME);
columnText = TEXT(" ") + pNativeSpeaker->getAttrNameStr(TEXT("Name"), WD_ROOTNODE, WD_CLMNNAME);
lvColumn.pszText = const_cast<TCHAR *>(columnText.c_str());
lvColumn.cx = width / 4;
SendMessage(_hList, LVM_INSERTCOLUMN, 0, LPARAM(&lvColumn));
columnText = TEXT("\u21F5 ") + pNativeSpeaker->getAttrNameStr(TEXT("Path"), WD_ROOTNODE, WD_CLMNPATH);
columnText = TEXT(" ") + pNativeSpeaker->getAttrNameStr(TEXT("Path"), WD_ROOTNODE, WD_CLMNPATH);
lvColumn.pszText = const_cast<TCHAR *>(columnText.c_str());
lvColumn.cx = 300;
SendMessage(_hList, LVM_INSERTCOLUMN, 1, LPARAM(&lvColumn));
lvColumn.fmt = LVCFMT_CENTER;
columnText = TEXT("\u21F5 ") + pNativeSpeaker->getAttrNameStr(TEXT("Type"), WD_ROOTNODE, WD_CLMNTYPE);
columnText = TEXT(" ") + pNativeSpeaker->getAttrNameStr(TEXT("Type"), WD_ROOTNODE, WD_CLMNTYPE);
lvColumn.pszText = const_cast<TCHAR *>(columnText.c_str());
lvColumn.cx = 100;
SendMessage(_hList, LVM_INSERTCOLUMN, 2, LPARAM(&lvColumn));
columnText = TEXT("\u21F5 ") + pNativeSpeaker->getAttrNameStr(TEXT("Size"), WD_ROOTNODE, WD_CLMNSIZE);
columnText = TEXT(" ") + pNativeSpeaker->getAttrNameStr(TEXT("Size"), WD_ROOTNODE, WD_CLMNSIZE);
lvColumn.pszText = const_cast<TCHAR *>(columnText.c_str());
lvColumn.cx = 100;
SendMessage(_hList, LVM_INSERTCOLUMN, 3, LPARAM(&lvColumn));
@ -566,15 +595,15 @@ void WindowsDlg::updateColumnNames()
columnText = pNativeSpeaker->getAttrNameStr(TEXT("Name"), WD_ROOTNODE, WD_CLMNNAME);
if (_currentColumn != 0)
{
columnText = TEXT("\u21F5 ") + columnText;
columnText = TEXT(" ") + columnText;
}
else if (_reverseSort)
{
columnText = TEXT("\u25B3 ") + columnText;
columnText = TEXT(" ") + columnText;
}
else
{
columnText = TEXT("\u25BD ") + columnText;
columnText = TEXT(" ") + columnText;
}
lvColumn.pszText = const_cast<TCHAR *>(columnText.c_str());
lvColumn.cx = static_cast<int>(SendMessage(_hList, LVM_GETCOLUMNWIDTH, 0, 0));
@ -583,15 +612,15 @@ void WindowsDlg::updateColumnNames()
columnText = pNativeSpeaker->getAttrNameStr(TEXT("Path"), WD_ROOTNODE, WD_CLMNPATH);
if (_currentColumn != 1)
{
columnText = TEXT("\u21F5 ") + columnText;
columnText = TEXT(" ") + columnText;
}
else if (_reverseSort)
{
columnText = TEXT("\u25B3 ") + columnText;
columnText = TEXT(" ") + columnText;
}
else
{
columnText = TEXT("\u25BD ") + columnText;
columnText = TEXT(" ") + columnText;
}
lvColumn.pszText = const_cast<TCHAR *>(columnText.c_str());
lvColumn.cx = static_cast<int>(SendMessage(_hList, LVM_GETCOLUMNWIDTH, 1, 0));
@ -601,15 +630,15 @@ void WindowsDlg::updateColumnNames()
columnText = pNativeSpeaker->getAttrNameStr(TEXT("Type"), WD_ROOTNODE, WD_CLMNTYPE);
if (_currentColumn != 2)
{
columnText = TEXT("\u21F5 ") + columnText;
columnText = TEXT(" ") + columnText;
}
else if (_reverseSort)
{
columnText = TEXT("\u25B3 ") + columnText;
columnText = TEXT(" ") + columnText;
}
else
{
columnText = TEXT("\u25BD ") + columnText;
columnText = TEXT(" ") + columnText;
}
lvColumn.pszText = const_cast<TCHAR *>(columnText.c_str());
lvColumn.cx = static_cast<int>(SendMessage(_hList, LVM_GETCOLUMNWIDTH, 2, 0));
@ -618,15 +647,15 @@ void WindowsDlg::updateColumnNames()
columnText = pNativeSpeaker->getAttrNameStr(TEXT("Size"), WD_ROOTNODE, WD_CLMNSIZE);
if (_currentColumn != 3)
{
columnText = TEXT("\u21F5 ") + columnText;
columnText = TEXT(" ") + columnText;
}
else if (_reverseSort)
{
columnText = TEXT("\u25B3 ") + columnText;
columnText = TEXT(" ") + columnText;
}
else
{
columnText = TEXT("\u25BD ") + columnText;
columnText = TEXT(" ") + columnText;
}
lvColumn.pszText = const_cast<TCHAR *>(columnText.c_str());
lvColumn.cx = static_cast<int>(SendMessage(_hList, LVM_GETCOLUMNWIDTH, 3, 0));

Loading…
Cancel
Save