Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RAPPS] Refreshing the Installed list should read everything from the registry #5676

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions base/applications/rapps/appview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,41 @@ CApplicationView::AppendTabOrderWindow(int Direction, ATL::CSimpleArray<HWND> &T
m_AppsInfo->AppendTabOrderWindow(Direction, TabOrderList);
}

VOID
CApplicationView::GetRestoreListSelectionData(RESTORELISTSELECTION &Restore)
{
LVITEMW &Item = Restore.Item;
Item.mask = LVIF_TEXT|LVIF_STATE;
Item.iItem = -1, Item.iSubItem = 0;
Item.stateMask = LVIS_FOCUSED|LVIS_SELECTED;
Item.pszText = Restore.Name, Item.cchTextMax = _countof(Restore.Name);

HWND hList = m_ListView ? m_ListView->m_hWnd : NULL;
learn-more marked this conversation as resolved.
Show resolved Hide resolved
if (hList)
{
Item.iItem = ListView_GetNextItem(hList, -1, LVNI_FOCUSED);
ListView_GetItem(hList, &Item);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the convenience functions from the m_Listview itself?
stuff like m_ListView->GetItemData etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a MFC guy I guess.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

VOID
CApplicationView::RestoreListSelection(const RESTORELISTSELECTION &Restore)
{
const LVITEMW &Item = Restore.Item;
int index = Item.iItem;
if (index != -1) // Was there a selected item?
{
LVFINDINFOW fi;
fi.flags = LVFI_STRING;
fi.psz = Item.pszText;
index = ListView_FindItem(m_ListView->m_hWnd, -1, &fi);
}
if (index != -1) // Is it still in the list?
{
ListView_SetItemState(m_ListView->m_hWnd, index, Item.state, Item.stateMask);
}
}

// this function is called when a item of listview get focus.
// CallbackParam is the param passed to listview when adding the item (the one getting focus now).
VOID
Expand Down
10 changes: 9 additions & 1 deletion base/applications/rapps/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ CMainWindow::OnCommand(WPARAM wParam, LPARAM lParam)
break;

case ID_REFRESH:
UpdateApplicationsList(SelectedEnumType);
UpdateApplicationsList(SelectedEnumType, bReload);
break;

case ID_RESETDB:
Expand Down Expand Up @@ -597,9 +597,14 @@ CMainWindow::UpdateApplicationsList(AppsCategories EnumType, BOOL bReload)
{
bUpdating = TRUE;

BOOL TryRestoreSelection = SelectedEnumType == EnumType;
if (SelectedEnumType != EnumType)
SelectedEnumType = EnumType;

CApplicationView::RESTORELISTSELECTION RestoreSelection;
if (TryRestoreSelection)
m_ApplicationView->GetRestoreListSelectionData(RestoreSelection);

if (bReload)
m_Selected.RemoveAll();

Expand Down Expand Up @@ -640,6 +645,9 @@ CMainWindow::UpdateApplicationsList(AppsCategories EnumType, BOOL bReload)
{
ATLASSERT(0 && "This should be unreachable!");
}

if (TryRestoreSelection)
m_ApplicationView->RestoreListSelection(RestoreSelection);
m_ApplicationView->SetRedraw(TRUE);
m_ApplicationView->RedrawWindow(0, 0, RDW_INVALIDATE | RDW_ALLCHILDREN); // force the child window to repaint
UpdateStatusBarText();
Expand Down
9 changes: 9 additions & 0 deletions base/applications/rapps/include/appview.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,15 @@ class CApplicationView : public CUiWindow<CWindowImpl<CApplicationView>>
VOID
AppendTabOrderWindow(int Direction, ATL::CSimpleArray<HWND> &TabOrderList);

struct RESTORELISTSELECTION {
LVITEMW Item;
WCHAR Name[MAX_PATH];
};
VOID
GetRestoreListSelectionData(RESTORELISTSELECTION &Restore);
VOID
RestoreListSelection(const RESTORELISTSELECTION &Restore);

// this function is called when a item of listview get focus.
// CallbackParam is the param passed to listview when adding the item (the one getting focus now).
VOID
Expand Down