- MGR: Handle sorting the notices control a different way.

clientgui/
        ViewNotices.cpp
        NoticeListCtrl.cpp, .h

svn path=/trunk/boinc/; revision=21809
This commit is contained in:
Rom Walton 2010-06-25 15:30:20 +00:00
parent 69cd672638
commit 1d670374fd
4 changed files with 77 additions and 9 deletions

View File

@ -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

View File

@ -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.
*/

View File

@ -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

View File

@ -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;