Compress-Deflate7
view release on metacpan or search on metacpan
7zip/CPP/7zip/UI/FileManager/PanelItems.cpp view on Meta::CPAN
{
int realIndex = GetRealItemIndex(index);
if (realIndex != kParentIndex)
_selectedStatusVector[realIndex] = true;
}
}
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames)
{
_dontShowMode = false;
LoadFullPathAndShow();
// OutputDebugStringA("=======\n");
// OutputDebugStringA("s1 \n");
CDisableTimerProcessing timerProcessing(*this);
if (focusedPos < 0)
focusedPos = 0;
_listView.SetRedraw(false);
// m_RedrawEnabled = false;
LVITEMW item;
ZeroMemory(&item, sizeof(item));
_listView.DeleteAllItems();
_selectedStatusVector.Clear();
// _realIndices.Clear();
_startGroupSelect = 0;
_selectionIsDefined = false;
// m_Files.Clear();
// _folder.Release();
if (!_folder)
{
// throw 1;
SetToRootFolder();
}
_headerToolBar.EnableButton(kParentFolderID, !IsRootFolder());
CMyComPtr<IFolderSetFlatMode> folderSetFlatMode;
_folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode);
if (folderSetFlatMode)
folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
RINOK(_folder->LoadItems());
RINOK(InitColumns());
// OutputDebugString(TEXT("Start Dir\n"));
UInt32 numItems;
_folder->GetNumberOfItems(&numItems);
bool showDots = _showDots && !IsRootFolder();
_listView.SetItemCount(numItems + (showDots ? 1 : 0));
_selectedStatusVector.Reserve(numItems);
int cursorIndex = -1;
CMyComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
if (!IsFSFolder() || _showRealFileIcons)
_folder.QueryInterface(IID_IFolderGetSystemIconIndex, &folderGetSystemIconIndex);
if (showDots)
{
UString itemName = L"..";
item.iItem = _listView.GetItemCount();
if (itemName.CompareNoCase(focusedName) == 0)
cursorIndex = item.iItem;
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
int subItem = 0;
item.iSubItem = subItem++;
item.lParam = kParentIndex;
item.pszText = const_cast<wchar_t *>((const wchar_t *)itemName);
UInt32 attrib = FILE_ATTRIBUTE_DIRECTORY;
item.iImage = _extToIconMap.GetIconIndex(attrib, itemName);
if (item.iImage < 0)
item.iImage = 0;
if (_listView.InsertItem(&item) == -1)
return E_FAIL;
}
// OutputDebugStringA("S1\n");
for (UInt32 i = 0; i < numItems; i++)
{
UString itemName = GetItemName(i);
const UString relPath = GetItemRelPath(i);
if (relPath.CompareNoCase(focusedName) == 0)
cursorIndex = _listView.GetItemCount();
bool selected = false;
if (selectedNames.FindInSorted(relPath) >= 0)
selected = true;
_selectedStatusVector.Add(selected);
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
if (!_mySelectMode)
if (selected)
{
item.mask |= LVIF_STATE;
item.state = LVIS_SELECTED;
}
int subItem = 0;
item.iItem = _listView.GetItemCount();
item.iSubItem = subItem++;
item.lParam = i;
UString correctedName;
if (itemName.Find(L" ") >= 0)
{
int pos = 0;
for (;;)
{
int posNew = itemName.Find(L" ", pos);
if (posNew < 0)
{
correctedName += itemName.Mid(pos);
break;
}
correctedName += itemName.Mid(pos, posNew - pos);
correctedName += L" ... ";
pos = posNew;
while (itemName[++pos] == ' ');
}
item.pszText = const_cast<wchar_t *>((const wchar_t *)correctedName);
}
else
item.pszText = const_cast<wchar_t *>((const wchar_t *)itemName);
NCOM::CPropVariant prop;
RINOK(_folder->GetProperty(i, kpidAttrib, &prop));
UInt32 attrib = 0;
if (prop.vt == VT_UI4)
attrib = prop.ulVal;
else if (IsItemFolder(i))
attrib |= FILE_ATTRIBUTE_DIRECTORY;
bool defined = false;
if (folderGetSystemIconIndex)
{
folderGetSystemIconIndex->GetSystemIconIndex(i, &item.iImage);
defined = (item.iImage > 0);
}
if (!defined)
{
if (_currentFolderPrefix.IsEmpty())
{
int iconIndexTemp;
GetRealIconIndex(itemName + WCHAR_PATH_SEPARATOR, attrib, iconIndexTemp);
item.iImage = iconIndexTemp;
}
else
{
item.iImage = _extToIconMap.GetIconIndex(attrib, itemName);
}
}
if (item.iImage < 0)
item.iImage = 0;
if (_listView.InsertItem(&item) == -1)
return E_FAIL; // error
}
// OutputDebugStringA("End2\n");
if (_listView.GetItemCount() > 0 && cursorIndex >= 0)
SetFocusedSelectedItem(cursorIndex, selectFocused);
_listView.SortItems(CompareItems, (LPARAM)this);
if (cursorIndex < 0 && _listView.GetItemCount() > 0)
{
if (focusedPos >= _listView.GetItemCount())
focusedPos = _listView.GetItemCount() - 1;
// we select item only in showDots mode.
SetFocusedSelectedItem(focusedPos, showDots);
}
// m_RedrawEnabled = true;
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
_listView.SetRedraw(true);
_listView.InvalidateRect(NULL, true);
// OutputDebugStringA("End1\n");
/*
_listView.UpdateWindow();
*/
return S_OK;
}
void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
{
indices.Clear();
/*
int itemIndex = -1;
while ((itemIndex = _listView.GetNextItem(itemIndex, LVNI_SELECTED)) != -1)
{
LPARAM param;
if (_listView.GetItemParam(itemIndex, param))
indices.Add(param);
}
*/
for (int i = 0; i < _selectedStatusVector.Size(); i++)
if (_selectedStatusVector[i])
indices.Add(i);
HeapSort(&indices.Front(), indices.Size());
}
void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
{
GetSelectedItemsIndices(indices);
if (!indices.IsEmpty())
return;
if (_listView.GetSelectedCount() == 0)
return;
int focusedItem = _listView.GetFocusedItem();
if (focusedItem >= 0)
{
if (_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
{
int realIndex = GetRealItemIndex(focusedItem);
if (realIndex != kParentIndex)
indices.Add(realIndex);
}
}
}
void CPanel::GetAllItemIndices(CRecordVector<UInt32> &indices) const
{
indices.Clear();
UInt32 numItems;
if (_folder->GetNumberOfItems(&numItems) == S_OK)
for (UInt32 i = 0; i < numItems; i++)
( run in 2.050 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )