MGR: Simplification and efficiency improvements for list selection, list deselection and updating task panels.

This commit is contained in:
Charlie Fenton 2014-05-21 02:39:34 -07:00
parent 0c88601eb5
commit 51c3b05839
5 changed files with 38 additions and 20 deletions

View File

@ -331,6 +331,8 @@ bool CBOINCBaseView::OnRestoreState(wxConfigBase* pConfig) {
}
// We don't currently use this because selecting an item
// triggers an EVT_LIST_CACHE_HINT; see OnCacheHint() below.
void CBOINCBaseView::OnListSelected(wxListEvent& event) {
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseView::OnListSelected - Function Begin"));
@ -344,6 +346,8 @@ void CBOINCBaseView::OnListSelected(wxListEvent& event) {
}
// We don't currently use this because selecting an item
// triggers an EVT_LIST_CACHE_HINT; see OnCacheHint() below.
void CBOINCBaseView::OnListDeselected(wxListEvent& event) {
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseView::OnListDeselected - Function Begin"));
@ -361,20 +365,30 @@ void CBOINCBaseView::OnListDeselected(wxListEvent& event) {
// * It does not send deselection events.
// * It (apparently intentionally) does not send selection
// events if you add to selection using Shift_Click.
//
// We currently handle all selections and deselections here.
void CBOINCBaseView::OnCacheHint(wxListEvent& event) {
static int oldSelectionCount = 0;
static long previousSelection = -1;
bool selectionChanged = false;
int newSelectionCount = m_pListPane->GetSelectedItemCount();
if (newSelectionCount < oldSelectionCount) {
wxListEvent leDeselectedEvent(wxEVT_COMMAND_LIST_ITEM_DESELECTED, m_windowId);
leDeselectedEvent.SetEventObject(this);
OnListDeselected(leDeselectedEvent);
} else if (newSelectionCount > oldSelectionCount) {
wxListEvent leSelectedEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED, m_windowId);
leSelectedEvent.SetEventObject(this);
OnListSelected(leSelectedEvent);
long currentSelection = m_pListPane->GetFirstSelected();
if (newSelectionCount != oldSelectionCount) {
selectionChanged = true;
} else if (currentSelection != previousSelection) {
selectionChanged = true;
}
if (selectionChanged) {
if (!m_bIgnoreUIEvents) {
m_bForceUpdateSelection = true;
UpdateSelection();
}
}
oldSelectionCount = newSelectionCount;
previousSelection = currentSelection;
event.Skip();
}

View File

@ -82,10 +82,12 @@ BEGIN_EVENT_TABLE (CViewProjects, CBOINCBaseView)
EVT_BUTTON(ID_TASK_PROJECT_DETACH, CViewProjects::OnProjectDetach)
EVT_BUTTON(ID_TASK_PROJECT_SHOW_PROPERTIES, CViewProjects::OnShowItemProperties)
EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_TASK_PROJECT_WEB_PROJDEF_MIN, ID_TASK_PROJECT_WEB_PROJDEF_MAX, CViewProjects::OnProjectWebsiteClicked)
EVT_LIST_ITEM_SELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListSelected)
EVT_LIST_ITEM_DESELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListDeselected)
EVT_LIST_COL_CLICK(ID_LIST_PROJECTSVIEW, CViewProjects::OnColClick)
// We currently handle EVT_LIST_CACHE_HINT instead of EVT_LIST_ITEM_SELECTED
// or EVT_LIST_ITEM_DESELECTED. See CBOINCBaseView::OnCacheHint() for info.
// EVT_LIST_ITEM_SELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListSelected)
// EVT_LIST_ITEM_DESELECTED(ID_LIST_PROJECTSVIEW, CViewProjects::OnListDeselected)
EVT_LIST_CACHE_HINT(ID_LIST_PROJECTSVIEW, CViewProjects::OnCacheHint)
EVT_LIST_COL_CLICK(ID_LIST_PROJECTSVIEW, CViewProjects::OnColClick)
EVT_LIST_COL_END_DRAG(ID_LIST_PROJECTSVIEW, CViewProjects::OnColResize)
END_EVENT_TABLE ()

View File

@ -1940,8 +1940,6 @@ BEGIN_EVENT_TABLE (CViewStatistics, CBOINCBaseView)
EVT_BUTTON(ID_TASK_STATISTICS_NEXTPROJECT, CViewStatistics::OnStatisticsNextProject)
EVT_BUTTON(ID_TASK_STATISTICS_PREVPROJECT, CViewStatistics::OnStatisticsPrevProject)
EVT_BUTTON(ID_TASK_STATISTICS_HIDEPROJLIST, CViewStatistics::OnShowHideProjectList)
EVT_LIST_ITEM_SELECTED(ID_LIST_STATISTICSVIEW, CViewStatistics::OnListSelected)
EVT_LIST_ITEM_DESELECTED(ID_LIST_STATISTICSVIEW, CViewStatistics::OnListDeselected)
END_EVENT_TABLE ()
CViewStatistics::CViewStatistics()

View File

@ -68,10 +68,12 @@ IMPLEMENT_DYNAMIC_CLASS(CViewTransfers, CBOINCBaseView)
BEGIN_EVENT_TABLE (CViewTransfers, CBOINCBaseView)
EVT_BUTTON(ID_TASK_TRANSFERS_RETRYNOW, CViewTransfers::OnTransfersRetryNow)
EVT_BUTTON(ID_TASK_TRANSFERS_ABORT, CViewTransfers::OnTransfersAbort)
EVT_LIST_ITEM_SELECTED(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnListSelected)
EVT_LIST_ITEM_DESELECTED(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnListDeselected)
EVT_LIST_COL_CLICK(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnColClick)
// We currently handle EVT_LIST_CACHE_HINT instead of EVT_LIST_ITEM_SELECTED
// or EVT_LIST_ITEM_DESELECTED. See CBOINCBaseView::OnCacheHint() for info.
// EVT_LIST_ITEM_SELECTED(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnListSelected)
// EVT_LIST_ITEM_DESELECTED(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnListDeselected)
EVT_LIST_CACHE_HINT(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnCacheHint)
EVT_LIST_COL_CLICK(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnColClick)
EVT_LIST_COL_END_DRAG(ID_LIST_TRANSFERSVIEW, CViewTransfers::OnColResize)
END_EVENT_TABLE ()

View File

@ -89,10 +89,12 @@ BEGIN_EVENT_TABLE (CViewWork, CBOINCBaseView)
EVT_BUTTON(ID_TASK_SHOW_PROPERTIES, CViewWork::OnShowItemProperties)
EVT_BUTTON(ID_TASK_ACTIVE_ONLY, CViewWork::OnActiveTasksOnly)
EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_TASK_PROJECT_WEB_PROJDEF_MIN, ID_TASK_PROJECT_WEB_PROJDEF_MAX, CViewWork::OnProjectWebsiteClicked)
EVT_LIST_ITEM_SELECTED(ID_LIST_WORKVIEW, CViewWork::OnListSelected)
EVT_LIST_ITEM_DESELECTED(ID_LIST_WORKVIEW, CViewWork::OnListDeselected)
EVT_LIST_COL_CLICK(ID_LIST_WORKVIEW, CViewWork::OnColClick)
// We currently handle EVT_LIST_CACHE_HINT instead of EVT_LIST_ITEM_SELECTED
// or EVT_LIST_ITEM_DESELECTED. See CBOINCBaseView::OnCacheHint() for info.
// EVT_LIST_ITEM_SELECTED(ID_LIST_WORKVIEW, CViewWork::OnListSelected)
// EVT_LIST_ITEM_DESELECTED(ID_LIST_WORKVIEW, CViewWork::OnListDeselected)
EVT_LIST_CACHE_HINT(ID_LIST_WORKVIEW, CViewWork::OnCacheHint)
EVT_LIST_COL_CLICK(ID_LIST_WORKVIEW, CViewWork::OnColClick)
EVT_LIST_COL_END_DRAG(ID_LIST_WORKVIEW, CViewWork::OnColResize)
END_EVENT_TABLE ()