diff --git a/checkin_notes b/checkin_notes index 5ef0ff569d..9a504393a2 100644 --- a/checkin_notes +++ b/checkin_notes @@ -4565,3 +4565,10 @@ David 23 Jun 2010 sched/ sched_send.cpp + +Rom 25 Jun 2010 + - MGR: Handle sorting the notices control a different way. + + clientgui/ + ViewNotices.cpp + NoticeListCtrl.cpp, .h diff --git a/clientgui/NoticeListCtrl.cpp b/clientgui/NoticeListCtrl.cpp index 54d8a1bab0..5271d04392 100644 --- a/clientgui/NoticeListCtrl.cpp +++ b/clientgui/NoticeListCtrl.cpp @@ -548,11 +548,36 @@ bool CNoticeListCtrl::Add( } +/*! + * Update an existing entry in the project list. + */ + +bool CNoticeListCtrl::Update( + int iSeqNo, + wxString strArrivalTime +) +{ + bool bRetVal = false; + + unsigned int n = (unsigned int)m_Items.size(); + for (unsigned int i = 0; i < n; i++) { + if (iSeqNo == m_Items[i]->GetSeqNo()) { + m_Items[i]->SetArrivalTime( strArrivalTime ); + bRetVal = true; + } + } + + SetItemCount(m_Items.size()); + + return bRetVal; +} + + /*! * Check to see if the requested entry is already in the control. */ -bool CNoticeListCtrl::IsSeqNoValid( int iSeqNo ) +bool CNoticeListCtrl::Exists( int iSeqNo ) { bool bRetVal = false; @@ -567,6 +592,22 @@ bool CNoticeListCtrl::IsSeqNoValid( int iSeqNo ) } +/*! + * Sort entries in the control. + */ + +bool compare_notice_list_entry(const CNoticeListItem* a, const CNoticeListItem* b) +{ + return a->GetArrivalTime() < b->GetArrivalTime(); +} + +bool CNoticeListCtrl::Sort() +{ + sort(m_Items.begin(), m_Items.end(), compare_notice_list_entry); + return true; +} + + /*! * Return the project list entry at a given index. */ diff --git a/clientgui/NoticeListCtrl.h b/clientgui/NoticeListCtrl.h index 958165822a..bacf64ef44 100644 --- a/clientgui/NoticeListCtrl.h +++ b/clientgui/NoticeListCtrl.h @@ -158,8 +158,14 @@ public: wxString strArrivalTime ); - bool IsSeqNoValid( int iSeqNo ); + bool Update( + int iSeqNo, + wxString strArrivalTime + ); + bool Exists( int iSeqNo ); + + bool Sort(); CNoticeListItem* GetItem( int iIndex diff --git a/clientgui/ViewNotices.cpp b/clientgui/ViewNotices.cpp index 86ef9048b0..15a855e8c5 100644 --- a/clientgui/ViewNotices.cpp +++ b/clientgui/ViewNotices.cpp @@ -154,14 +154,15 @@ void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) { n = pDoc->GetNoticeCount(); if (n != -1) { - for (i = (unsigned int)n; i > 0; i--) { - NOTICE* np = pDoc->notice(i-1); + + m_pHtmlListPane->Freeze(); + + for (i = 0; i < (unsigned int)n; i++) { + NOTICE* np = pDoc->notice(i); if (!np) continue; - m_pHtmlListPane->Freeze(); - - if (!m_pHtmlListPane->IsSeqNoValid(np->seqno)) { + if (!m_pHtmlListPane->Exists(np->seqno)) { strProjectName = wxString(np->project_name, wxConvUTF8); strURL = wxString(np->link, wxConvUTF8); @@ -181,10 +182,23 @@ void CViewNotices::OnListRender(wxTimerEvent& WXUNUSED(event)) { strCategory, strArrivalTime ); - } - m_pHtmlListPane->Thaw(); + } else { + + dtBuffer.Set((time_t)np->arrival_time); + strArrivalTime = dtBuffer.Format(); + + m_pHtmlListPane->Update( + np->seqno, + strArrivalTime + ); + + } } + + m_pHtmlListPane->Sort(); + + m_pHtmlListPane->Thaw(); } s_bInProgress = false;