// Get the (possibly filtered) item count (i.e., the Row count) wxInt32 CDlgEventLog::GetDocCount() { int i; m_iTotalDocCount = wxGetApp().GetDocument()->GetMessageCount(); if (m_iTotalDocCount < m_iPreviousTotalDocCount) { // Usually due to a disconnect from client ResetMessageFiltering(); } if (s_bIsFiltered) { for (i = m_iPreviousTotalDocCount; i < m_iTotalDocCount; i++) { MESSAGE* message = wxGetApp().GetDocument()->message(i); if (message->project.empty() || (message->project == s_strFilteredProjectName)) { m_iFilteredIndexes.Add(i); } } m_iPreviousTotalDocCount = m_iTotalDocCount; m_iFilteredDocCount = (int)(m_iFilteredIndexes.GetCount()); return m_iFilteredDocCount; } m_iPreviousTotalDocCount = m_iTotalDocCount; m_iFilteredDocCount = m_iTotalDocCount; return m_iTotalDocCount; }
/*! * called from CMainDocument::HandleCompletedRPC() after wxEVT_RPC_FINISHED event */ void CDlgEventLog::OnRefresh() { bool isConnected; static wxString strLastMachineName = wxEmptyString; wxString strNewMachineName = wxEmptyString; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); if (!IsShown()) return; if (!m_bProcessingRefreshEvent) { m_bProcessingRefreshEvent = true; wxASSERT(m_pList); wxInt32 iRowCount = GetDocCount(); long topItem = m_pList->GetTopItem(); if (0 >= iRowCount) { m_pList->DeleteAllItems(); ResetMessageFiltering(); m_iPreviousFirstMsgSeqNum = 0; m_iPreviousLastMsgSeqNum = 0; } else { // If connected computer changed, reset message filtering isConnected = wxGetApp().GetDocument()->IsConnected(); if (isConnected) { pDoc->GetConnectedComputerName(strNewMachineName); if (strLastMachineName != strNewMachineName) { strLastMachineName = strNewMachineName; m_bWasConnected = false; ResetMessageFiltering(); m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum(); m_iPreviousLastMsgSeqNum = m_iPreviousFirstMsgSeqNum - 1; iRowCount = m_iTotalDocCount; // In case we had filtering set } } // If connection status changed, adjust color of messages display if (m_bWasConnected != isConnected) { m_bWasConnected = isConnected; SetTextColor(); // Force a complete update m_pList->DeleteAllItems(); m_pList->SetItemCount(iRowCount); m_iPreviousRowCount = 0; // Force scrolling to bottom } else { // Connection status didn't change if (m_iPreviousLastMsgSeqNum != pDoc->GetLastMsgSeqNum()) { if (m_iPreviousRowCount == iRowCount) { m_pList->Refresh(); } else { m_pList->SetItemCount(iRowCount); } } } } if (iRowCount > 1) { if (s_bFilteringChanged) { m_pList->EnsureVisible(iRowCount - 1); s_bFilteringChanged = false; } else { if (m_iPreviousLastMsgSeqNum != pDoc->GetLastMsgSeqNum()) { if (EnsureLastItemVisible()) { m_pList->EnsureVisible(iRowCount - 1); } else if (topItem > 0) { int n = topItem - m_iNumDeletedFilteredRows; if (n < 0) n = 0; Freeze(); // Avoid flicker if selected rows are visible m_pList->EnsureVisible(n); Thaw(); } } } } m_iPreviousRowCount = iRowCount; if (m_iTotalDocCount > 0) { m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum(); m_iPreviousLastMsgSeqNum = pDoc->GetLastMsgSeqNum(); } UpdateButtons(); m_bProcessingRefreshEvent = false; } }
/*! * called from CMainDocument::HandleCompletedRPC() after wxEVT_RPC_FINISHED event */ void CDlgEventLog::OnRefresh() { bool isConnected; static bool was_connected = false; static wxString strLastMachineName = wxEmptyString; wxString strNewMachineName = wxEmptyString; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); if (!IsShown()) return; if (!m_bProcessingRefreshEvent) { m_bProcessingRefreshEvent = true; wxASSERT(m_pList); wxInt32 iRowCount = GetDocCount(); if (0 >= iRowCount) { m_pList->DeleteAllItems(); ResetMessageFiltering(); } else { // If connected computer changed, reset message filtering isConnected = wxGetApp().GetDocument()->IsConnected(); if (isConnected) { pDoc->GetConnectedComputerName(strNewMachineName); if (strLastMachineName != strNewMachineName) { strLastMachineName = strNewMachineName; was_connected = false; ResetMessageFiltering(); } } // If connection status changed, adjust color of messages display if (was_connected != isConnected) { was_connected = isConnected; SetTextColor(); // Force a complete update m_pList->DeleteAllItems(); m_pList->SetItemCount(iRowCount); m_iPreviousRowCount = 0; // Force scrolling to bottom } else { // Connection status didn't change if (m_iPreviousRowCount != iRowCount) { m_pList->SetItemCount(iRowCount); } } } if ((iRowCount > 1) && (EnsureLastItemVisible()) && (m_iPreviousRowCount != iRowCount)) { m_pList->EnsureVisible(iRowCount - 1); } if (m_iPreviousRowCount != iRowCount) { m_iPreviousRowCount = iRowCount; } UpdateButtons(); m_bProcessingRefreshEvent = false; } }