Ejemplo n.º 1
0
void CProjectsComponent::OnMessageCheck(wxTimerEvent& WXUNUSED(event)) {
	CMainDocument* pDoc     = wxGetApp().GetDocument();
	MESSAGE* message;

	// Only look at the messages recieved since the last time we looked
	if ( pDoc->GetMessageCount() > (int) lastMessageId ) {
		// Loop through and check for any messages recieved that are error messages
		for(size_t i=lastMessageId; i < pDoc->messages.messages.size(); i++) {
			lastMessageId = i+1;
			message = pDoc->message((unsigned int) i);
			if ( message != NULL && message->priority == MSG_USER_ALERT ) {
				receivedErrorMessage = true;
				checkForMessagesTimer->Stop();
				break;
			}
		}
	}
}
Ejemplo n.º 2
0
/// Filter the messages based on the current filter settings.
/// This function stores the index of the last filtered message and won't touch
/// messages older than this if the function is called again. It will only check all
/// messages that are newer than the one remembered. This makes calling this function
/// as cheap as possible.
/// If you want this function to filter all the messages, for example because the
/// filter settings changed or the manager is now connected to a different client,
/// then you need to set m_maxFilteredIndex to zero and clear m_filteredIndexes
/// before calling this function.
void CViewMessages::FilterMessages() {
    CMainDocument* pDoc = wxGetApp().GetDocument();
    size_t end = pDoc->GetMessageCount();
    
    for (size_t index = m_maxFilteredIndex; index < end; ++index) {
        MESSAGE* msg = pDoc->message(index);
        if ((msg->project.empty()) || m_msgFilterData.IsProjectSelected(msg->project)) {            
            bool includeThisMsg = true;
            
            // Check if the message contains a debug flag:
            std::string::size_type start = msg->body.find('[');
            if (start != std::string::npos) {
                std::string::size_type end = msg->body.find(']', start);
                if (end != std::string::npos) {
                    std::string debugFlag = msg->body.substr(start + 1, end - start - 1);
                    if ((m_msgFilterData.IsDebugFlagValid(debugFlag))
                            && (!m_msgFilterData.IsDebugFlagSelected(debugFlag))) {
                        includeThisMsg = false;
                    }
                }
            }

            if (includeThisMsg) {
                // The message has passed all filters, thus add it to the list:
                m_filteredIndexes.push_back(index);
            }
        }
    }
    
    // Check if more messages passed the filters than should be shown and truncate the
    // list if necessary. The oldest messages (e.g. the ones added first) are removed first.
    if (m_filteredIndexes.size() > m_msgFilterData.GetNumVisibleMsg()) {
        m_filteredIndexes.erase(m_filteredIndexes.begin(),
                                m_filteredIndexes.end() - m_msgFilterData.GetNumVisibleMsg());
    }
    
    m_maxFilteredIndex = end;
}
Ejemplo n.º 3
0
// NOTE: this function is designed to be called only
// from CDlgEventLog::OnRefresh().  If you need to call it
// from other routines, it will need modification.
//
// Get the (possibly filtered) item count (i.e., the Row count) and
// make any needed adjustments if oldest items have been deleted.
wxInt32 CDlgEventLog::GetDocCount() {
    int i, j, numDeletedRows;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    m_iTotalDocCount = pDoc->GetMessageCount();

    numDeletedRows = pDoc->GetFirstMsgSeqNum() - m_iPreviousFirstMsgSeqNum;
    if ((numDeletedRows < 0) || (m_iPreviousFirstMsgSeqNum < 0)) {
        numDeletedRows = 0;
    }
    m_iNumDeletedFilteredRows = 0;

    if (s_bIsFiltered) {
        if (numDeletedRows > 0) {
            // Remove any deleted messages from our filtered list
            while (m_iFilteredIndexes.GetCount() > 0) {
                if (m_iFilteredIndexes[0] >= numDeletedRows) break;
                m_iFilteredIndexes.RemoveAt(0);
                m_iNumDeletedFilteredRows++;
                m_iTotalDeletedFilterRows++;
            }
            
            // Adjust the remaining indexes
            for (i = m_iFilteredIndexes.GetCount()-1; i >= 0; i--) {
                m_iFilteredIndexes[i] -= numDeletedRows;
            }
        }
        
        // Add indexes of new messages to filtered list as appropriate
        i = m_iTotalDocCount - (pDoc->GetLastMsgSeqNum() - m_iPreviousLastMsgSeqNum);
        if (i < 0) i = 0;
        for (; i < m_iTotalDocCount; i++) {
            MESSAGE* message = pDoc->message(i);
            if (message->project.empty() || (message->project == s_strFilteredProjectName)) {
                m_iFilteredIndexes.Add(i);
            }
        }
        m_iFilteredDocCount = (int)(m_iFilteredIndexes.GetCount());
    } else {
        m_iFilteredDocCount = m_iTotalDocCount;
        m_iNumDeletedFilteredRows = numDeletedRows;
    }

    if (numDeletedRows > 0) {
        // Adjust the selected row numbers
        wxArrayInt arrSelRows;
        
        i = -1;
        for (;;) {
            i = m_pList->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            if (i < 0) break;
            arrSelRows.Add(i);
        }
        int count = arrSelRows.Count();
        for (i=0; i<count; i++) {
            m_pList->SetItemState(arrSelRows[i], 0, wxLIST_STATE_SELECTED);
        }

        for (i=0; i<count; i++) {
            if ((j = arrSelRows[i] - m_iNumDeletedFilteredRows) >= 0) {
                m_pList->SetItemState(j, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
            }
        }
    }
    
    return s_bIsFiltered ? m_iFilteredDocCount : m_iTotalDocCount;
}
Ejemplo n.º 4
0
void CProjectsComponent::MessagesViewed() {
	receivedErrorMessage = false;
	CMainDocument* pDoc = wxGetApp().GetDocument();
	lastMessageId = pDoc->GetMessageCount();
	checkForMessagesTimer->Start();
}