Author: dquintana Date: Sun Mar 15 18:17:27 2015 New Revision: 66732
URL: http://svn.reactos.org/svn/reactos?rev=66732&view=rev Log: [NTOBJSHEX] * Implement support for column sorting in CompareIDs, for Name, Type, and Creation Date columns. The link target, and registry key contents are not sortable yet.
Modified: trunk/reactos/dll/shellext/ntobjshex/ntobjns.cpp trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp
Modified: trunk/reactos/dll/shellext/ntobjshex/ntobjns.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/ntob... ============================================================================== --- trunk/reactos/dll/shellext/ntobjshex/ntobjns.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/shellext/ntobjshex/ntobjns.cpp [iso-8859-1] Sun Mar 15 18:17:27 2015 @@ -33,9 +33,10 @@ enum NtObjectColumns { NTOBJECT_COLUMN_NAME = 0, - NTOBJECT_COLUMN_TYPE = 1, - NTOBJECT_COLUMN_CREATEDATE = 2, - NTOBJECT_COLUMN_LINKTARGET = 3, + NTOBJECT_COLUMN_TYPE, + NTOBJECT_COLUMN_CREATEDATE, + NTOBJECT_COLUMN_LINKTARGET, + NTOBJECT_COLUMN_END };
class CNtObjectFolderExtractIcon : @@ -293,14 +294,11 @@
HRESULT CompareIDs(LPARAM lParam, NtPidlEntry * first, NtPidlEntry * second) { - if (LOWORD(lParam) != 0) - { - DbgPrint("Unsupported sorting mode.\n"); - return E_INVALIDARG; - } - - if (HIWORD(lParam) == SHCIDS_ALLFIELDS) - { + if ((lParam & 0xFFFF0000) == SHCIDS_ALLFIELDS) + { + if (lParam != 0) + return E_INVALIDARG; + int minsize = min(first->cb, second->cb); int ord = memcmp(second, first, minsize);
@@ -312,42 +310,81 @@ if (second->cb < first->cb) return MAKE_HRESULT(0, 0, (USHORT) -1); } - else if (HIWORD(lParam) == SHCIDS_CANONICALONLY) - { - int minlength = min(first->entryNameLength, second->entryNameLength); - int ord = StrCmpNW(first->entryName, second->entryName, minlength); - - if (ord != 0) - return MAKE_HRESULT(0, 0, (USHORT) ord); - - if (second->entryNameLength > first->entryNameLength) - return MAKE_HRESULT(0, 0, (USHORT) 1); - if (second->entryNameLength < first->entryNameLength) - return MAKE_HRESULT(0, 0, (USHORT) -1); - } else { - bool f1 = (first->objectType == DIRECTORY_OBJECT) || (first->objectType == KEY_OBJECT); - bool f2 = (second->objectType == DIRECTORY_OBJECT) || (second->objectType == KEY_OBJECT); - - if (f1 && !f2) - return MAKE_HRESULT(0, 0, (USHORT) -1); - if (f2 && !f1) - return MAKE_HRESULT(0, 0, (USHORT) 1); - - int minlength = min(first->entryNameLength, second->entryNameLength); - int ord = StrCmpNW(first->entryName, second->entryName, minlength); - - if (ord != 0) - return MAKE_HRESULT(0, 0, (USHORT) ord); - - if (second->entryNameLength > first->entryNameLength) - return MAKE_HRESULT(0, 0, (USHORT) 1); - if (second->entryNameLength < first->entryNameLength) - return MAKE_HRESULT(0, 0, (USHORT) -1); - } - - return S_OK; + bool canonical = ((lParam & 0xFFFF0000) == SHCIDS_CANONICALONLY); + + switch (lParam & 0xFFFF) + { + case NTOBJECT_COLUMN_NAME: + { + bool f1 = (first->objectType == KEY_OBJECT) || (first->objectType == DIRECTORY_OBJECT); + bool f2 = (second->objectType == KEY_OBJECT) || (second->objectType == DIRECTORY_OBJECT); + + if (f1 && !f2) + return MAKE_HRESULT(0, 0, (USHORT) -1); + if (f2 && !f1) + return MAKE_HRESULT(0, 0, (USHORT) 1); + + if (canonical) + { + // Shortcut: avoid comparing contents if not necessary when the results are not for display. + if (second->entryNameLength > first->entryNameLength) + return MAKE_HRESULT(0, 0, (USHORT) 1); + if (second->entryNameLength < first->entryNameLength) + return MAKE_HRESULT(0, 0, (USHORT) -1); + } + + int minlength = min(first->entryNameLength, second->entryNameLength); + int ord = StrCmpNW(first->entryName, second->entryName, minlength); + + if (ord != 0) + return MAKE_HRESULT(0, 0, (USHORT) ord); + + if (!canonical) + { + if (second->entryNameLength > first->entryNameLength) + return MAKE_HRESULT(0, 0, (USHORT) 1); + if (second->entryNameLength < first->entryNameLength) + return MAKE_HRESULT(0, 0, (USHORT) -1); + } + + return S_OK; + } + case NTOBJECT_COLUMN_TYPE: + { + int ord = second->objectType - first->objectType; + if (ord > 0) + return MAKE_HRESULT(0, 0, (USHORT) 1); + if (ord < 0) + return MAKE_HRESULT(0, 0, (USHORT) -1); + + return S_OK; + } + case NTOBJECT_COLUMN_CREATEDATE: + { + LONGLONG ord = second->objectInformation.CreateTime.QuadPart - first->objectInformation.CreateTime.QuadPart; + if (ord > 0) + return MAKE_HRESULT(0, 0, (USHORT) 1); + if (ord < 0) + return MAKE_HRESULT(0, 0, (USHORT) -1); + + return S_OK; + } + case NTOBJECT_COLUMN_LINKTARGET: + { + // Can't sort by value + return E_INVALIDARG; + } + default: + { + DbgPrint("Unsupported sorting mode.\n"); + return E_INVALIDARG; + } + } + } + + return E_INVALIDARG; }
HRESULT CompareIDs(LPARAM lParam, NtPidlEntry * first, LPCITEMIDLIST pcidl) @@ -1226,6 +1263,12 @@ *pViewMode = FVM_DETAILS; return S_OK; } + case SFVM_COLUMNCLICK: + return S_FALSE; + case SFVM_BACKGROUNDENUM: + return S_OK; + case SFVM_DEFITEMCOUNT: + return m_PidlManager->GetCount((UINT*) lParam); } return E_NOTIMPL; }
Modified: trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/ntobjshex/regf... ============================================================================== --- trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/shellext/ntobjshex/regfolder.cpp [iso-8859-1] Sun Mar 15 18:17:27 2015 @@ -33,8 +33,9 @@ enum RegistryColumns { REGISTRY_COLUMN_NAME = 0, - REGISTRY_COLUMN_TYPE = 1, - REGISTRY_COLUMN_VALUE = 2, + REGISTRY_COLUMN_TYPE, + REGISTRY_COLUMN_VALUE, + REGISTRY_COLUMN_END };
class CRegistryFolderExtractIcon : @@ -289,14 +290,11 @@
HRESULT CompareIDs(LPARAM lParam, RegPidlEntry * first, RegPidlEntry * second) { - if (LOWORD(lParam) != 0) - { - DbgPrint("Unsupported sorting mode.\n"); - return E_INVALIDARG; - } - - if (HIWORD(lParam) == SHCIDS_ALLFIELDS) - { + if ((lParam & 0xFFFF0000) == SHCIDS_ALLFIELDS) + { + if (lParam != 0) + return E_INVALIDARG; + int minsize = min(first->cb, second->cb); int ord = memcmp(second, first, minsize);
@@ -308,42 +306,71 @@ if (second->cb < first->cb) return MAKE_HRESULT(0, 0, (USHORT) -1); } - else if (HIWORD(lParam) == SHCIDS_CANONICALONLY) - { - int minlength = min(first->entryNameLength, second->entryNameLength); - int ord = StrCmpNW(first->entryName, second->entryName, minlength); - - if (ord != 0) - return MAKE_HRESULT(0, 0, (USHORT) ord); - - if (second->entryNameLength > first->entryNameLength) - return MAKE_HRESULT(0, 0, (USHORT) 1); - if (second->entryNameLength < first->entryNameLength) - return MAKE_HRESULT(0, 0, (USHORT) -1); - } else { - bool f1 = (first->entryType == REG_ENTRY_KEY) || (first->entryType == REG_ENTRY_ROOT); - bool f2 = (second->entryType == REG_ENTRY_KEY) || (second->entryType == REG_ENTRY_ROOT); - - if (f1 && !f2) - return MAKE_HRESULT(0, 0, (USHORT) -1); - if (f2 && !f1) - return MAKE_HRESULT(0, 0, (USHORT) 1); - - int minlength = min(first->entryNameLength, second->entryNameLength); - int ord = StrCmpNW(first->entryName, second->entryName, minlength); - - if (ord != 0) - return MAKE_HRESULT(0, 0, (USHORT) ord); - - if (second->entryNameLength > first->entryNameLength) - return MAKE_HRESULT(0, 0, (USHORT) 1); - if (second->entryNameLength < first->entryNameLength) - return MAKE_HRESULT(0, 0, (USHORT) -1); - } - - return S_OK; + bool canonical = ((lParam & 0xFFFF0000) == SHCIDS_CANONICALONLY); + + switch (lParam & 0xFFFF) + { + case REGISTRY_COLUMN_NAME: + { + bool f1 = (first->entryType == REG_ENTRY_KEY) || (first->entryType == REG_ENTRY_ROOT); + bool f2 = (second->entryType == REG_ENTRY_KEY) || (second->entryType == REG_ENTRY_ROOT); + + if (f1 && !f2) + return MAKE_HRESULT(0, 0, (USHORT) -1); + if (f2 && !f1) + return MAKE_HRESULT(0, 0, (USHORT) 1); + + if (canonical) + { + // Shortcut: avoid comparing contents if not necessary when the results are not for display. + if (second->entryNameLength > first->entryNameLength) + return MAKE_HRESULT(0, 0, (USHORT) 1); + if (second->entryNameLength < first->entryNameLength) + return MAKE_HRESULT(0, 0, (USHORT) -1); + } + + int minlength = min(first->entryNameLength, second->entryNameLength); + int ord = StrCmpNW(first->entryName, second->entryName, minlength); + + if (ord != 0) + return MAKE_HRESULT(0, 0, (USHORT) ord); + + if (!canonical) + { + if (second->entryNameLength > first->entryNameLength) + return MAKE_HRESULT(0, 0, (USHORT) 1); + if (second->entryNameLength < first->entryNameLength) + return MAKE_HRESULT(0, 0, (USHORT) -1); + } + + return S_OK; + } + case REGISTRY_COLUMN_TYPE: + { + int ord = second->contentType - first->contentType; + if (ord > 0) + return MAKE_HRESULT(0, 0, (USHORT) 1); + if (ord < 0) + return MAKE_HRESULT(0, 0, (USHORT) -1); + + return S_OK; + } + case REGISTRY_COLUMN_VALUE: + { + // Can't sort by value + return E_INVALIDARG; + } + default: + { + DbgPrint("Unsupported sorting mode.\n"); + return E_INVALIDARG; + } + } + } + + return E_INVALIDARG; }
HRESULT CompareIDs(LPARAM lParam, RegPidlEntry * first, LPCITEMIDLIST pcidl) @@ -1262,6 +1289,12 @@ *pViewMode = FVM_DETAILS; return S_OK; } + case SFVM_COLUMNCLICK: + return S_FALSE; + case SFVM_BACKGROUNDENUM: + return S_OK; + case SFVM_DEFITEMCOUNT: + return m_PidlManager->GetCount((UINT*) lParam); } return E_NOTIMPL; }