From d93292b797b5ef2bdeed988c7221e407a013a023 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Thu, 2 Dec 2004 07:43:47 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4697 --- checkin_notes | 28 ++++ clientgui/BOINCBaseView.cpp | 310 +++++++++++++++++++++++------------- clientgui/BOINCBaseView.h | 62 +++++--- clientgui/BOINCGUIApp.cpp | 4 +- clientgui/MainFrame.cpp | 46 +++--- clientgui/MainFrame.h | 3 +- clientgui/ViewMessages.cpp | 285 ++++++++++++++++++++++++--------- clientgui/ViewMessages.h | 72 +++++++-- clientgui/ViewProjects.cpp | 238 ++++++++++++++++++++++++++- clientgui/ViewProjects.h | 61 ++++++- clientgui/ViewResources.cpp | 129 ++++++++++++++- clientgui/ViewResources.h | 46 +++++- clientgui/ViewTransfers.cpp | 239 ++++++++++++++++++++++++++- clientgui/ViewTransfers.h | 61 ++++++- clientgui/ViewWork.cpp | 260 +++++++++++++++++++++++++++++- clientgui/ViewWork.h | 64 +++++++- clientgui/msw/taskbarex.h | 5 - clientgui/stdwx.h | 14 +- configure.ac | 4 +- 19 files changed, 1602 insertions(+), 329 deletions(-) diff --git a/checkin_notes b/checkin_notes index 8565d1d978..7724336ddf 100755 --- a/checkin_notes +++ b/checkin_notes @@ -20458,3 +20458,31 @@ Bruce 2 Dec 2004 user/ explain_state.php +Rom 2 Dec 2004 + - Bug Fix: Each view now contains a display cache; the display cache + is synchronized during the regularly scheduled list render event. + The control grabs the necessary information from the cache instead + of cycling down to the document. Due to the way listviews were + implemented on some platforms I believe this will fix some refresh + problems where the data wasn’t being updated in a timely manor. + This also had the added benefit of increasing performance on displaying + updates. + - Fill in the missing piece for the memory leak detection to proplerly + display the file and line number information per allocation for the + GUI on Windows + - Rename the CC and GUI on all platforms to match that of Windows. + + / + configure.ac + clientgui/ + BOINCBaseView.cpp, .h + BOINCGUIApp.cpp + MainFrame.cpp, .h + stdwx.h + ViewMessages.cpp, .h + ViewProjects.cpp, .h + ViewResources.cpp, .h + ViewTransfers.cpp, .h + ViewWork.cpp, .h + clientgui/msw/ + taskbarex.h diff --git a/clientgui/BOINCBaseView.cpp b/clientgui/BOINCBaseView.cpp index 200cf76e41..c834385de2 100644 --- a/clientgui/BOINCBaseView.cpp +++ b/clientgui/BOINCBaseView.cpp @@ -54,11 +54,6 @@ CBOINCBaseView::CBOINCBaseView( wxNotebook* pNotebook, wxWindowID iHtmlWindowID, m_bProcessingTaskRenderEvent = false; m_bProcessingListRenderEvent = false; - m_iCacheFrom = 0; - m_iCacheTo = 0; - - m_iCount = 0; - m_bItemSelected = false; m_strQuickTip = wxEmptyString; @@ -111,15 +106,10 @@ char** CBOINCBaseView::GetViewIcon() } -wxInt32 CBOINCBaseView::_GetListRowCount() -{ - return GetListRowCount(); -} - - wxInt32 CBOINCBaseView::GetListRowCount() { - return 0; + wxASSERT(NULL != m_pListPane); + return m_pListPane->GetItemCount(); } @@ -135,6 +125,72 @@ void CBOINCBaseView::FireOnListRender ( wxTimerEvent& event ) } +bool CBOINCBaseView::FireOnSaveState( wxConfigBase* pConfig ) +{ + return OnSaveState( pConfig ); +} + + +bool CBOINCBaseView::FireOnRestoreState( wxConfigBase* pConfig ) +{ + return OnRestoreState( pConfig ); +} + + +void CBOINCBaseView::FireOnChar( wxKeyEvent& event ) +{ + OnChar( event ); +} + + +void CBOINCBaseView::FireOnListSelected( wxListEvent& event ) +{ + OnListSelected( event ); +} + + +void CBOINCBaseView::FireOnListDeselected( wxListEvent& event ) +{ + OnListDeselected( event ); +} + + +wxString CBOINCBaseView::FireOnListGetItemText( long item, long column ) const +{ + return OnListGetItemText( item, column ); +} + + +int CBOINCBaseView::FireOnListGetItemImage( long item ) const +{ + return OnListGetItemImage( item ); +} + + +wxListItemAttr* CBOINCBaseView::FireOnListGetItemAttr( long item ) const +{ + return OnListGetItemAttr( item ); +} + + +void CBOINCBaseView::FireOnTaskLinkClicked( const wxHtmlLinkInfo& link ) +{ + OnTaskLinkClicked( link ); +} + + +void CBOINCBaseView::FireOnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ) +{ + OnTaskCellMouseHover( cell, x, y ); +} + + +wxInt32 CBOINCBaseView::GetDocCount() +{ + return 0; +} + + void CBOINCBaseView::OnTaskRender ( wxTimerEvent& event ) { if (!m_bProcessingTaskRenderEvent) @@ -165,83 +221,59 @@ void CBOINCBaseView::OnListRender ( wxTimerEvent& event ) wxASSERT(NULL != m_pListPane); - wxInt32 iCount = _GetListRowCount(); - if ( iCount != m_iCount ) + wxInt32 iDocCount = GetDocCount(); + wxInt32 iCacheCount = GetCacheCount(); + if ( iDocCount != iCacheCount ) { - m_iCount = iCount; - if ( 0 >= iCount ) + if ( 0 >= iDocCount ) { + EmptyCache(); m_pListPane->DeleteAllItems(); - m_iCacheFrom = 0; - m_iCacheTo = 0; } else - m_pListPane->SetItemCount(iCount); + { + if ( iDocCount > iCacheCount ) + { + wxInt32 iIndex = 0; + wxInt32 iReturnValue = -1; + for ( iIndex = iCacheCount; iIndex <= iDocCount; iIndex++ ) + { + iReturnValue = AddCacheElement(); + wxASSERT( 0 == iReturnValue ); + } + } + else + { + wxInt32 iIndex = 0; + wxInt32 iReturnValue = -1; + for ( iIndex = iDocCount; iIndex >= iCacheCount; iIndex-- ) + { + iReturnValue = RemoveCacheElement(); + wxASSERT( 0 == iReturnValue ); + } + } + + SyncronizeCache(); + m_pListPane->SetItemCount(iDocCount); + + if (EnsureLastItemVisible()) + { + m_pListPane->EnsureVisible(iCacheCount); + } + } } else { - if ( 1 <= m_iCacheTo ) - { - wxInt32 iRowIndex = 0; - wxInt32 iColumnIndex = 0; - wxInt32 iColumnTotal = 0; - wxString strDocumentText = wxEmptyString; - wxString strListPaneText = wxEmptyString; - bool bNeedRefreshData = false; - wxListItem liItem; - - liItem.SetMask(wxLIST_MASK_TEXT); - iColumnTotal = m_pListPane->GetColumnCount(); - - for ( iRowIndex = m_iCacheFrom; iRowIndex <= m_iCacheTo; iRowIndex++ ) - { - bNeedRefreshData = false; - liItem.SetId(iRowIndex); - - for ( iColumnIndex = 0; iColumnIndex < iColumnTotal; iColumnIndex++ ) - { - strDocumentText.Empty(); - strListPaneText.Empty(); - - strDocumentText = OnListGetItemText( iRowIndex, iColumnIndex ); - - liItem.SetColumn(iColumnIndex); - m_pListPane->GetItem(liItem); - strListPaneText = liItem.GetText(); - - if ( !strDocumentText.IsSameAs(strListPaneText) ) - bNeedRefreshData = true; - } - - if ( bNeedRefreshData ) - { - m_pListPane->RefreshItem( iRowIndex ); - } - } - } + SyncronizeCache(); } m_bProcessingListRenderEvent = false; } - m_pListPane->Refresh(); - event.Skip(); } -bool CBOINCBaseView::FireOnSaveState( wxConfigBase* pConfig ) -{ - return OnSaveState( pConfig ); -} - - -bool CBOINCBaseView::FireOnRestoreState( wxConfigBase* pConfig ) -{ - return OnRestoreState( pConfig ); -} - - bool CBOINCBaseView::OnSaveState( wxConfigBase* pConfig ) { bool bReturnValue = true; @@ -278,46 +310,8 @@ bool CBOINCBaseView::OnRestoreState( wxConfigBase* pConfig ) } -void CBOINCBaseView::FireOnListCacheHint( wxListEvent& event ) +void CBOINCBaseView::OnChar( wxKeyEvent& event ) { - OnListCacheHint( event ); -} - - -void CBOINCBaseView::FireOnListSelected( wxListEvent& event ) -{ - OnListSelected( event ); -} - - -void CBOINCBaseView::FireOnListDeselected( wxListEvent& event ) -{ - OnListDeselected( event ); -} - - -wxString CBOINCBaseView::FireOnListGetItemText( long item, long column ) const -{ - return OnListGetItemText( item, column ); -} - - -int CBOINCBaseView::FireOnListGetItemImage( long item ) const -{ - return OnListGetItemImage( item ); -} - - -wxListItemAttr* CBOINCBaseView::FireOnListGetItemAttr( long item ) const -{ - return OnListGetItemAttr( item ); -} - - -void CBOINCBaseView::OnListCacheHint( wxListEvent& event ) -{ - m_iCacheFrom = event.GetCacheFrom(); - m_iCacheTo = event.GetCacheTo(); } @@ -363,15 +357,21 @@ wxListItemAttr* CBOINCBaseView::OnListGetItemAttr( long WXUNUSED(item) ) const } -void CBOINCBaseView::FireOnTaskLinkClicked( const wxHtmlLinkInfo& link ) +wxString CBOINCBaseView::OnDocGetItemText( long WXUNUSED(item), long WXUNUSED(column) ) const { - OnTaskLinkClicked( link ); + return wxString("Undefined"); } -void CBOINCBaseView::FireOnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ) +wxString CBOINCBaseView::OnDocGetItemImage( long WXUNUSED(item) ) const { - OnTaskCellMouseHover( cell, x, y ); + return wxString("Undefined"); +} + + +wxString CBOINCBaseView::OnDocGetItemAttr( long WXUNUSED(item) ) const +{ + return wxString("Undefined"); } @@ -404,6 +404,86 @@ void CBOINCBaseView::SetCurrentQuickTip( const wxString& strQuickTip, const wxSt } +wxInt32 CBOINCBaseView::AddCacheElement() +{ + return -1; +} + + +wxInt32 CBOINCBaseView::EmptyCache() +{ + return -1; +} + + +wxInt32 CBOINCBaseView::GetCacheCount() +{ + return -1; +} + + +wxInt32 CBOINCBaseView::RemoveCacheElement() +{ + return -1; +} + + +wxInt32 CBOINCBaseView::SyncronizeCache() +{ + wxInt32 iRowIndex = 0; + wxInt32 iRowTotal = 0; + wxInt32 iColumnIndex = 0; + wxInt32 iColumnTotal = 0; + wxString strDocumentText = wxEmptyString; + wxString strListPaneText = wxEmptyString; + wxInt32 iReturnValue = -1; + bool bNeedRefreshData = false; + + iRowTotal = GetDocCount(); + iColumnTotal = m_pListPane->GetColumnCount(); + + for ( iRowIndex = 0; iRowIndex < iRowTotal; iRowIndex++ ) + { + bNeedRefreshData = false; + + for ( iColumnIndex = 0; iColumnIndex < iColumnTotal; iColumnIndex++ ) + { + strDocumentText.Empty(); + strListPaneText.Empty(); + + strDocumentText = OnDocGetItemText( iRowIndex, iColumnIndex ); + strListPaneText = OnListGetItemText( iRowIndex, iColumnIndex ); + + if ( !strDocumentText.IsSameAs(strListPaneText) ) + { + iReturnValue = UpdateCache( iRowIndex, iColumnIndex, strDocumentText ); + wxASSERT( 0 == iReturnValue ); + bNeedRefreshData = true; + } + } + + if ( bNeedRefreshData ) + { + m_pListPane->RefreshItem( iRowIndex ); + } + } + + return 0; +} + + +wxInt32 CBOINCBaseView::UpdateCache( long item, long column, wxString& strNewData ) +{ + return -1; +} + + +bool CBOINCBaseView::EnsureLastItemVisible() +{ + return false; +} + + bool CBOINCBaseView::UpdateQuickTip( const wxString& strCurrentLink, const wxString& strQuickTip, const wxString& strQuickTipText ) { bool bRetVal; diff --git a/clientgui/BOINCBaseView.h b/clientgui/BOINCBaseView.h index 542f4d7823..1e5faa7180 100644 --- a/clientgui/BOINCBaseView.h +++ b/clientgui/BOINCBaseView.h @@ -44,6 +44,7 @@ class CBOINCBaseView : public wxPanel DECLARE_DYNAMIC_CLASS( CBOINCBaseView ) public: + CBOINCBaseView(); CBOINCBaseView( wxNotebook* pNotebook, @@ -59,27 +60,11 @@ public: virtual char** GetViewIcon(); virtual wxInt32 GetListRowCount(); - virtual void OnTaskRender( wxTimerEvent& event ); - virtual void OnListRender( wxTimerEvent& event ); - - virtual bool OnSaveState( wxConfigBase* pConfig ); - virtual bool OnRestoreState( wxConfigBase* pConfig ); - - virtual void OnListCacheHint( wxListEvent& event ); - virtual void OnListSelected( wxListEvent& event ); - virtual void OnListDeselected( wxListEvent& event ); - virtual wxString OnListGetItemText( long item, long column ) const; - virtual int OnListGetItemImage( long item ) const; - virtual wxListItemAttr* OnListGetItemAttr( long item ) const; - - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - void FireOnTaskRender( wxTimerEvent& event ); void FireOnListRender( wxTimerEvent& event ); bool FireOnSaveState( wxConfigBase* pConfig ); bool FireOnRestoreState( wxConfigBase* pConfig ); - void FireOnListCacheHint( wxListEvent& event ); + void FireOnChar( wxKeyEvent& event ); void FireOnListSelected( wxListEvent& event ); void FireOnListDeselected( wxListEvent& event ); wxString FireOnListGetItemText( long item, long column ) const; @@ -88,26 +73,51 @@ public: void FireOnTaskLinkClicked( const wxHtmlLinkInfo& link ); void FireOnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); +protected: + + virtual wxInt32 GetDocCount(); + + virtual void OnTaskRender( wxTimerEvent& event ); + virtual void OnListRender( wxTimerEvent& event ); + + virtual bool OnSaveState( wxConfigBase* pConfig ); + virtual bool OnRestoreState( wxConfigBase* pConfig ); + + virtual void OnChar( wxKeyEvent& event ); + virtual void OnListSelected( wxListEvent& event ); + virtual void OnListDeselected( wxListEvent& event ); + + virtual wxString OnListGetItemText( long item, long column ) const; + virtual int OnListGetItemImage( long item ) const; + virtual wxListItemAttr* OnListGetItemAttr( long item ) const; + + virtual wxString OnDocGetItemText( long item, long column ) const; + virtual wxString OnDocGetItemImage( long item ) const; + virtual wxString OnDocGetItemAttr( long item ) const; + + virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); + virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); + wxString GetCurrentQuickTip(); wxString GetCurrentQuickTipText(); void SetCurrentQuickTip( const wxString& strQuickTip, const wxString& strQuickTipText ); + virtual wxInt32 AddCacheElement(); + virtual wxInt32 EmptyCache(); + virtual wxInt32 GetCacheCount(); + virtual wxInt32 RemoveCacheElement(); + virtual wxInt32 SyncronizeCache(); + virtual wxInt32 UpdateCache( long item, long column, wxString& strNewData ); + + virtual bool EnsureLastItemVisible(); + virtual bool UpdateQuickTip( const wxString& strCurrentLink, const wxString& strQuickTip, const wxString& strQuickTipText ); virtual void UpdateSelection(); virtual void UpdateTaskPane(); -protected: - - wxInt32 _GetListRowCount(); - bool m_bProcessingTaskRenderEvent; bool m_bProcessingListRenderEvent; - wxInt32 m_iCacheFrom; - wxInt32 m_iCacheTo; - - wxInt32 m_iCount; - bool m_bItemSelected; wxString m_strQuickTip; diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 936dfb3756..0d60324817 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -298,9 +298,10 @@ void CBOINCGUIApp::ShutdownBOINCCore() if ( wxProcess::Exists( m_lBOINCCoreProccessId ) ) { m_pDocument->CoreClientQuit(); +/* for ( iCount = 0; iCount <= 10; iCount++ ) { - if ( !wxProcess::Exists( m_lBOINCCoreProccessId ) ) + if ( !bClientQuit && !wxProcess::Exists( m_lBOINCCoreProccessId ) ) { bClientQuit = true; continue; @@ -310,6 +311,7 @@ void CBOINCGUIApp::ShutdownBOINCCore() if ( !bClientQuit ) ::wxKill( m_lBOINCCoreProccessId ); +*/ } } } diff --git a/clientgui/MainFrame.cpp b/clientgui/MainFrame.cpp index 1d3988a625..b8ab4fcf23 100644 --- a/clientgui/MainFrame.cpp +++ b/clientgui/MainFrame.cpp @@ -64,10 +64,10 @@ BEGIN_EVENT_TABLE (CMainFrame, wxFrame) EVT_IDLE(CMainFrame::OnIdle) EVT_CLOSE(CMainFrame::OnClose) EVT_SIZE(CMainFrame::OnSize) + EVT_CHAR(CMainFrame::OnChar) EVT_UPDATE_UI_RANGE(ID_ACTIVITYRUNALWAYS, ID_ACTIVITYSUSPEND, CMainFrame::OnUpdateActivitySelection) EVT_UPDATE_UI_RANGE(ID_NETWORKRUNALWAYS, ID_NETWORKSUSPEND, CMainFrame::OnUpdateNetworkSelection) EVT_NOTEBOOK_PAGE_CHANGED(ID_FRAMENOTEBOOK, CMainFrame::OnNotebookSelectionChanged) - EVT_LIST_CACHE_HINT(wxID_ANY, CMainFrame::OnListCacheHint) EVT_LIST_ITEM_SELECTED(wxID_ANY, CMainFrame::OnListSelected) EVT_LIST_ITEM_DESELECTED(wxID_ANY, CMainFrame::OnListDeselected) EVT_TIMER(ID_FRAMERENDERTIMER, CMainFrame::OnFrameRender) @@ -819,6 +819,28 @@ void CMainFrame::OnSize( wxSizeEvent& event ) } +void CMainFrame::OnChar( wxKeyEvent& event ) +{ + if ( IsShown() ) + { + wxWindow* pwndNotebookPage = NULL; + CBOINCBaseView* pView = NULL; + + wxASSERT(NULL != m_pNotebook); + + pwndNotebookPage = m_pNotebook->GetPage( event.GetId() - ID_LIST_BASE ); + wxASSERT(NULL != pwndNotebookPage); + + pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView); + wxASSERT(NULL != pView); + + pView->FireOnChar( event ); + } + + event.Skip(); +} + + void CMainFrame::OnNotebookSelectionChanged( wxNotebookEvent& event ) { if ( (-1 != event.GetSelection()) && IsShown() ) @@ -843,28 +865,6 @@ void CMainFrame::OnNotebookSelectionChanged( wxNotebookEvent& event ) } -void CMainFrame::OnListCacheHint( wxListEvent& event ) -{ - if ( IsShown() ) - { - wxWindow* pwndNotebookPage = NULL; - CBOINCBaseView* pView = NULL; - - wxASSERT(NULL != m_pNotebook); - - pwndNotebookPage = m_pNotebook->GetPage( event.GetId() - ID_LIST_BASE ); - wxASSERT(NULL != pwndNotebookPage); - - pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView); - wxASSERT(NULL != pView); - - pView->FireOnListCacheHint( event ); - } - - event.Skip(); -} - - void CMainFrame::OnListSelected( wxListEvent& event ) { if ( IsShown() ) diff --git a/clientgui/MainFrame.h b/clientgui/MainFrame.h index 38c9c181c7..7f94914c3c 100644 --- a/clientgui/MainFrame.h +++ b/clientgui/MainFrame.h @@ -58,10 +58,11 @@ public: void OnIdle ( wxIdleEvent& event ); void OnClose( wxCloseEvent& event ); void OnSize( wxSizeEvent& event ); + void OnChar( wxKeyEvent& event ); + void OnNotebookSelectionChanged( wxNotebookEvent& event ); - void OnListCacheHint( wxListEvent& event ); void OnListSelected( wxListEvent& event ); void OnListDeselected( wxListEvent& event ); diff --git a/clientgui/ViewMessages.cpp b/clientgui/ViewMessages.cpp index 3641f95a60..e31ffaf9a8 100644 --- a/clientgui/ViewMessages.cpp +++ b/clientgui/ViewMessages.cpp @@ -33,6 +33,9 @@ #include "ViewMessages.h" #include "Events.h" +#include "wx/arrimpl.cpp" + + #include "res/mess.xpm" #include "res/task.xpm" #include "res/tips.xpm" @@ -71,7 +74,84 @@ const wxString LINKDESC_TASKCOPYMESSAGE = " or control key while clicking on the next desired message."); -IMPLEMENT_DYNAMIC_CLASS(CViewMessages, CBOINCBaseView) +WX_DEFINE_OBJARRAY( CMessageCache ); + + +CMessage::CMessage() +{ + m_strPriority = wxEmptyString; + m_strProjectName = wxEmptyString; + m_strTime = wxEmptyString; + m_strMessage = wxEmptyString; +} + + +CMessage::~CMessage() +{ + m_strPriority.Clear(); + m_strProjectName.Clear(); + m_strTime.Clear(); + m_strMessage.Clear(); +} + + +wxInt32 CMessage::GetProjectName( wxString& strProjectName ) +{ + strProjectName = m_strProjectName; + return 0; +} + + +wxInt32 CMessage::GetPriority( wxString& strPriority ) +{ + strPriority = m_strPriority; + return 0; +} + + +wxInt32 CMessage::GetTime( wxString& strTime ) +{ + strTime = m_strTime; + return 0; +} + + +wxInt32 CMessage::GetMessage( wxString& strMessage ) +{ + strMessage = m_strMessage; + return 0; +} + + +wxInt32 CMessage::SetProjectName( wxString& strProjectName ) +{ + m_strProjectName = strProjectName; + return 0; +} + + +wxInt32 CMessage::SetPriority( wxString& strPriority ) +{ + m_strPriority = strPriority; + return 0; +} + + +wxInt32 CMessage::SetTime( wxString& strTime ) +{ + m_strTime = strTime; + return 0; +} + + +wxInt32 CMessage::SetMessage( wxString& strMessage ) +{ + m_strMessage = strMessage; + return 0; +} + + +IMPLEMENT_DYNAMIC_CLASS( CViewMessages, CBOINCBaseView ) CViewMessages::CViewMessages() @@ -145,7 +225,7 @@ char** CViewMessages::GetViewIcon() } -wxInt32 CViewMessages::GetListRowCount() +wxInt32 CViewMessages::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -156,81 +236,21 @@ wxInt32 CViewMessages::GetListRowCount() } -void CViewMessages::OnListRender(wxTimerEvent &event) -{ - if (!m_bProcessingListRenderEvent) - { - m_bProcessingListRenderEvent = true; - - wxASSERT(NULL != m_pListPane); - - wxInt32 iCount = _GetListRowCount(); - if ( iCount != m_iCount ) - { - m_iCount = iCount; - if ( 0 >= iCount ) - m_pListPane->DeleteAllItems(); - else - { - m_pListPane->SetItemCount(iCount); - m_pListPane->EnsureVisible(iCount-1); - } - } - else - { - if ( 1 <= m_iCacheTo ) - { - wxListItem liListItemMessage; - wxString strListItemMessage; - wxString strDocumentItemMessage; - - FormatMessage(m_iCacheTo, strDocumentItemMessage); - - liListItemMessage.SetId(m_iCacheTo); - liListItemMessage.SetColumn(COLUMN_MESSAGE); - liListItemMessage.SetMask(wxLIST_MASK_TEXT); - - m_pListPane->GetItem(liListItemMessage); - - strListItemMessage = liListItemMessage.GetText(); - - if ( !strDocumentItemMessage.IsSameAs(strListItemMessage) ) - { - m_pListPane->RefreshItems(m_iCacheFrom, m_iCacheTo); - m_pListPane->EnsureVisible(m_iCacheTo); - } - } - } - - m_bProcessingListRenderEvent = false; - } - - m_pListPane->Refresh(); - - event.Skip(); -} - - wxString CViewMessages::OnListGetItemText( long item, long column ) const { - wxString strBuffer = wxEmptyString; - CMainDocument* pDoc = wxGetApp().GetDocument(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + CMessage& message = m_MessageCache.Item( item ); + wxString strBuffer = wxEmptyString; switch(column) { case COLUMN_PROJECT: - if (item == m_iCacheFrom) pDoc->CachedStateLock(); - FormatProjectName( item, strBuffer ); + message.GetProjectName( strBuffer ); break; case COLUMN_TIME: - FormatTime( item, strBuffer ); + message.GetTime( strBuffer ); break; case COLUMN_MESSAGE: - FormatMessage( item, strBuffer ); - if (item == m_iCacheTo) pDoc->CachedStateUnlock(); + message.GetMessage( strBuffer ); break; } @@ -240,25 +260,46 @@ wxString CViewMessages::OnListGetItemText( long item, long column ) const wxListItemAttr* CViewMessages::OnListGetItemAttr( long item ) const { - wxListItemAttr* pAttribute = NULL; - wxInt32 iBuffer = 0; + wxListItemAttr* pAttribute = NULL; + CMessage& message = m_MessageCache.Item( item ); + wxString strBuffer = wxEmptyString; - wxGetApp().GetDocument()->GetMessagePriority(item, iBuffer); + message.GetPriority( strBuffer ); - switch(iBuffer) + if ( wxT("E") == strBuffer ) { - case PRIORITY_INFO: - pAttribute = m_pMessageInfoAttr; - break; - case PRIORITY_ERROR: - pAttribute = m_pMessageErrorAttr; - break; + pAttribute = m_pMessageErrorAttr; + } + else + { + pAttribute = m_pMessageInfoAttr; } return pAttribute; } +wxString CViewMessages::OnDocGetItemText( long item, long column ) const +{ + wxString strBuffer = wxEmptyString; + + switch(column) + { + case COLUMN_PROJECT: + FormatProjectName( item, strBuffer ); + break; + case COLUMN_TIME: + FormatTime( item, strBuffer ); + break; + case COLUMN_MESSAGE: + FormatMessage( item, strBuffer ); + break; + } + + return strBuffer; +} + + void CViewMessages::OnTaskLinkClicked( const wxHtmlLinkInfo& link ) { wxInt32 iIndex = -1; @@ -348,6 +389,70 @@ void CViewMessages::OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord WXUNUSED(x), } +wxInt32 CViewMessages::AddCacheElement() +{ + CMessage* pItem = new CMessage(); + wxASSERT( NULL != pItem ); + if ( NULL != pItem ) + { + m_MessageCache.Add( pItem ); + return 0; + } + return -1; +} + + +wxInt32 CViewMessages::EmptyCache() +{ + m_MessageCache.Empty(); + return 0; +} + + +wxInt32 CViewMessages::GetCacheCount() +{ + return m_MessageCache.GetCount(); +} + + +wxInt32 CViewMessages::RemoveCacheElement() +{ + m_MessageCache.RemoveAt( GetCacheCount() - 1 ); + return 0; +} + + +wxInt32 CViewMessages::UpdateCache( long item, long column, wxString& strNewData ) +{ + CMessage& message = m_MessageCache.Item( item ); + wxString strPriority = wxEmptyString; + + switch(column) + { + case COLUMN_PROJECT: + message.SetProjectName( strNewData ); + break; + case COLUMN_TIME: + message.SetTime( strNewData ); + break; + case COLUMN_MESSAGE: + message.SetMessage( strNewData ); + break; + } + + FormatPriority( item, strPriority ); + message.SetPriority( strPriority ); + + return 0; +} + + +bool CViewMessages::EnsureLastItemVisible() +{ + return true; +} + + void CViewMessages::UpdateSelection() { wxASSERT(NULL != m_pTaskPane); @@ -415,6 +520,32 @@ wxInt32 CViewMessages::FormatProjectName( wxInt32 item, wxString& strBuffer ) co } +wxInt32 CViewMessages::FormatPriority( wxInt32 item, wxString& strBuffer ) const +{ + CMainDocument* pDoc = wxGetApp().GetDocument(); + wxInt32 iBuffer = 0; + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + + strBuffer.Clear(); + + pDoc->GetMessagePriority(item, iBuffer); + + switch(iBuffer) + { + case PRIORITY_INFO: + strBuffer = wxT("I"); + break; + case PRIORITY_ERROR: + strBuffer = wxT("E"); + break; + } + + return 0; +} + + wxInt32 CViewMessages::FormatTime( wxInt32 item, wxString& strBuffer ) const { wxDateTime dtBuffer(wxDateTime::Now()); diff --git a/clientgui/ViewMessages.h b/clientgui/ViewMessages.h index 796e22c8cb..8966161117 100644 --- a/clientgui/ViewMessages.h +++ b/clientgui/ViewMessages.h @@ -31,6 +31,33 @@ #include "BOINCBaseView.h" + +class CMessage : public wxObject +{ +public: + CMessage(); + ~CMessage(); + + wxInt32 GetProjectName( wxString& strProjectName ); + wxInt32 GetPriority( wxString& strPriority ); + wxInt32 GetTime( wxString& strTime ); + wxInt32 GetMessage( wxString& strMessage ); + + wxInt32 SetProjectName( wxString& strProjectName ); + wxInt32 SetPriority( wxString& strPriority ); + wxInt32 SetTime( wxString& strTime ); + wxInt32 SetMessage( wxString& strMessage ); + +protected: + wxString m_strProjectName; + wxString m_strPriority; + wxString m_strTime; + wxString m_strMessage; +}; + +WX_DECLARE_OBJARRAY( CMessage, CMessageCache ); + + class CViewMessages : public CBOINCBaseView { DECLARE_DYNAMIC_CLASS( CViewMessages ) @@ -43,17 +70,8 @@ public: virtual wxString GetViewName(); virtual char** GetViewIcon(); - virtual wxInt32 GetListRowCount(); - virtual void OnListRender( wxTimerEvent& event ); - - virtual wxString OnListGetItemText( long item, long column ) const; - virtual wxListItemAttr* OnListGetItemAttr( long item ) const; - - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - -private: +protected: bool m_bTaskHeaderHidden; bool m_bTaskCopyAllHidden; @@ -64,6 +82,34 @@ private: wxListItemAttr* m_pMessageInfoAttr; wxListItemAttr* m_pMessageErrorAttr; + CMessageCache m_MessageCache; + + virtual wxInt32 GetDocCount(); + + virtual wxString OnListGetItemText( long item, long column ) const; + virtual wxListItemAttr* OnListGetItemAttr( long item ) const; + + virtual wxString OnDocGetItemText( long item, long column ) const; + + virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); + virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); + + virtual wxInt32 AddCacheElement(); + virtual wxInt32 EmptyCache(); + virtual wxInt32 GetCacheCount(); + virtual wxInt32 RemoveCacheElement(); + virtual wxInt32 UpdateCache( long item, long column, wxString& strNewData ); + + virtual bool EnsureLastItemVisible(); + + virtual void UpdateSelection(); + virtual void UpdateTaskPane(); + + wxInt32 FormatProjectName( wxInt32 item, wxString& strBuffer ) const; + wxInt32 FormatPriority( wxInt32 item, wxString& strBuffer ) const; + wxInt32 FormatTime( wxInt32 item, wxString& strBuffer ) const; + wxInt32 FormatMessage( wxInt32 item, wxString& strBuffer ) const; + #ifndef NOCLIPBOARD bool m_bClipboardOpen; wxString m_strClipboardData; @@ -72,12 +118,6 @@ private: bool CloseClipboard(); #endif - virtual void UpdateSelection(); - virtual void UpdateTaskPane(); - - wxInt32 FormatProjectName( wxInt32 item, wxString& strBuffer ) const; - wxInt32 FormatTime( wxInt32 item, wxString& strBuffer ) const; - wxInt32 FormatMessage( wxInt32 item, wxString& strBuffer ) const; }; diff --git a/clientgui/ViewProjects.cpp b/clientgui/ViewProjects.cpp index 584c75cd2e..dcdee8bd49 100644 --- a/clientgui/ViewProjects.cpp +++ b/clientgui/ViewProjects.cpp @@ -34,6 +34,9 @@ #include "DlgAttachProject.h" #include "Events.h" +#include "wx/arrimpl.cpp" + + #include "res/boinc.xpm" #include "res/proj.xpm" #include "res/task.xpm" @@ -116,6 +119,131 @@ const wxString LINKDESC_WEBPROJECT = const wxString LINK_WEB = wxT(SECTION_WEB ":"); +WX_DEFINE_OBJARRAY( CProjectCache ); + + +CProject::CProject() +{ + m_strProjectName = wxEmptyString; + m_strAccountName = wxEmptyString; + m_strTeamName = wxEmptyString; + m_strTotalCredit = wxEmptyString; + m_strAVGCredit = wxEmptyString; + m_strResourceShare = wxEmptyString; + m_strStatus = wxEmptyString; +} + + +CProject::~CProject() +{ + m_strProjectName.Clear(); + m_strAccountName.Clear(); + m_strTeamName.Clear(); + m_strTotalCredit.Clear(); + m_strAVGCredit.Clear(); + m_strResourceShare.Clear(); + m_strStatus.Clear(); +} + + +wxInt32 CProject::GetProjectName( wxString& strProjectName ) +{ + strProjectName = m_strProjectName; + return 0; +} + + +wxInt32 CProject::GetAccountName( wxString& strAccountName ) +{ + strAccountName = m_strAccountName; + return 0; +} + + +wxInt32 CProject::GetTeamName( wxString& strTeamName ) +{ + strTeamName = m_strTeamName; + return 0; +} + + +wxInt32 CProject::GetTotalCredit( wxString& strTotalCredit ) +{ + strTotalCredit = m_strTotalCredit; + return 0; +} + + +wxInt32 CProject::GetAVGCredit( wxString& strAVGCredit ) +{ + strAVGCredit = m_strAVGCredit; + return 0; +} + + +wxInt32 CProject::GetResourceShare( wxString& strResourceShare ) +{ + strResourceShare = m_strResourceShare; + return 0; +} + + +wxInt32 CProject::GetStatus( wxString& strStatus ) +{ + strStatus = m_strStatus; + return 0; +} + + +wxInt32 CProject::SetProjectName( wxString& strProjectName ) +{ + m_strProjectName = strProjectName; + return 0; +} + + +wxInt32 CProject::SetAccountName( wxString& strAccountName ) +{ + m_strAccountName = strAccountName; + return 0; +} + + +wxInt32 CProject::SetTeamName( wxString& strTeamName ) +{ + m_strTeamName = strTeamName; + return 0; +} + + +wxInt32 CProject::SetTotalCredit( wxString& strTotalCredit ) +{ + m_strTotalCredit = strTotalCredit; + return 0; +} + + +wxInt32 CProject::SetAVGCredit( wxString& strAVGCredit ) +{ + m_strAVGCredit = strAVGCredit; + return 0; +} + + +wxInt32 CProject::SetResourceShare( wxString& strResourceShare ) +{ + m_strResourceShare = strResourceShare; + return 0; +} + + +wxInt32 CProject::SetStatus( wxString& strStatus ) +{ + m_strStatus = strStatus; + return 0; +} + + IMPLEMENT_DYNAMIC_CLASS(CViewProjects, CBOINCBaseView) @@ -186,7 +314,7 @@ char** CViewProjects::GetViewIcon() } -wxInt32 CViewProjects::GetListRowCount() +wxInt32 CViewProjects::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -199,16 +327,45 @@ wxInt32 CViewProjects::GetListRowCount() wxString CViewProjects::OnListGetItemText(long item, long column) const { - wxString strBuffer = wxEmptyString; - CMainDocument* pDoc = wxGetApp().GetDocument(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + CProject& project = m_ProjectCache.Item( item ); + wxString strBuffer = wxEmptyString; + + switch(column) + { + case COLUMN_PROJECT: + project.GetProjectName( strBuffer ); + break; + case COLUMN_ACCOUNTNAME: + project.GetAccountName( strBuffer ); + break; + case COLUMN_TEAMNAME: + project.GetTeamName( strBuffer ); + break; + case COLUMN_TOTALCREDIT: + project.GetTotalCredit( strBuffer ); + break; + case COLUMN_AVGCREDIT: + project.GetAVGCredit( strBuffer ); + break; + case COLUMN_RESOURCESHARE: + project.GetResourceShare( strBuffer ); + break; + case COLUMN_STATUS: + project.GetStatus( strBuffer ); + break; + } + + return strBuffer; +} + + +wxString CViewProjects::OnDocGetItemText(long item, long column) const +{ + wxString strBuffer = wxEmptyString; switch(column) { case COLUMN_PROJECT: - if (item == m_iCacheFrom) pDoc->CachedStateLock(); FormatProjectName( item, strBuffer ); break; case COLUMN_ACCOUNTNAME: @@ -228,7 +385,6 @@ wxString CViewProjects::OnListGetItemText(long item, long column) const break; case COLUMN_STATUS: FormatStatus( item, strBuffer ); - if (item == m_iCacheTo) pDoc->CachedStateUnlock(); break; } @@ -437,6 +593,72 @@ void CViewProjects::OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord WXUNUSED(x), } +wxInt32 CViewProjects::AddCacheElement() +{ + CProject* pItem = new CProject(); + wxASSERT( NULL != pItem ); + if ( NULL != pItem ) + { + m_ProjectCache.Add( pItem ); + return 0; + } + return -1; +} + + +wxInt32 CViewProjects::EmptyCache() +{ + m_ProjectCache.Empty(); + return 0; +} + + +wxInt32 CViewProjects::GetCacheCount() +{ + return m_ProjectCache.GetCount(); +} + + +wxInt32 CViewProjects::RemoveCacheElement() +{ + m_ProjectCache.RemoveAt( GetCacheCount() - 1 ); + return 0; +} + + +wxInt32 CViewProjects::UpdateCache( long item, long column, wxString& strNewData ) +{ + CProject& project = m_ProjectCache.Item( item ); + + switch(column) + { + case COLUMN_PROJECT: + project.SetProjectName( strNewData ); + break; + case COLUMN_ACCOUNTNAME: + project.SetAccountName( strNewData ); + break; + case COLUMN_TEAMNAME: + project.SetTeamName( strNewData ); + break; + case COLUMN_TOTALCREDIT: + project.SetTotalCredit( strNewData ); + break; + case COLUMN_AVGCREDIT: + project.SetAVGCredit( strNewData ); + break; + case COLUMN_RESOURCESHARE: + project.SetResourceShare( strNewData ); + break; + case COLUMN_STATUS: + project.SetStatus( strNewData ); + break; + } + + return 0; +} + + void CViewProjects::UpdateSelection() { CMainDocument* pDoc = wxGetApp().GetDocument(); diff --git a/clientgui/ViewProjects.h b/clientgui/ViewProjects.h index 1c5be23168..715895654f 100644 --- a/clientgui/ViewProjects.h +++ b/clientgui/ViewProjects.h @@ -31,6 +31,42 @@ #include "BOINCBaseView.h" + +class CProject : public wxObject +{ +public: + CProject(); + ~CProject(); + + wxInt32 GetProjectName( wxString& strProjectName ); + wxInt32 GetAccountName( wxString& strAccountName ); + wxInt32 GetTeamName( wxString& strTeamName ); + wxInt32 GetTotalCredit( wxString& strTotalCredit ); + wxInt32 GetAVGCredit( wxString& strAVGCredit ); + wxInt32 GetResourceShare( wxString& strResourceShare ); + wxInt32 GetStatus( wxString& strStatus ); + + wxInt32 SetProjectName( wxString& strProjectName ); + wxInt32 SetAccountName( wxString& strAccountName ); + wxInt32 SetTeamName( wxString& strTeamName ); + wxInt32 SetTotalCredit( wxString& strTotalCredit ); + wxInt32 SetAVGCredit( wxString& strAVGCredit ); + wxInt32 SetResourceShare( wxString& strResourceShare ); + wxInt32 SetStatus( wxString& strStatus ); + +protected: + wxString m_strProjectName; + wxString m_strAccountName; + wxString m_strTeamName; + wxString m_strTotalCredit; + wxString m_strAVGCredit; + wxString m_strResourceShare; + wxString m_strStatus; +}; + +WX_DECLARE_OBJARRAY( CProject, CProjectCache ); + + class CViewProjects : public CBOINCBaseView { DECLARE_DYNAMIC_CLASS( CViewProjects ) @@ -43,14 +79,8 @@ public: virtual wxString GetViewName(); virtual char** GetViewIcon(); - virtual wxInt32 GetListRowCount(); - virtual wxString OnListGetItemText( long item, long column ) const; - - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - -private: +protected: bool m_bTaskHeaderHidden; bool m_bTaskAttachHidden; @@ -68,6 +98,23 @@ private: bool m_bItemSelected; + CProjectCache m_ProjectCache; + + virtual wxInt32 GetDocCount(); + + virtual wxString OnListGetItemText( long item, long column ) const; + + virtual wxString OnDocGetItemText( long item, long column ) const; + + virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); + virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); + + virtual wxInt32 AddCacheElement(); + virtual wxInt32 EmptyCache(); + virtual wxInt32 GetCacheCount(); + virtual wxInt32 RemoveCacheElement(); + virtual wxInt32 UpdateCache( long item, long column, wxString& strNewData ); + virtual void UpdateSelection(); virtual void UpdateTaskPane(); diff --git a/clientgui/ViewResources.cpp b/clientgui/ViewResources.cpp index 7c41dfef6b..a9f75b8013 100644 --- a/clientgui/ViewResources.cpp +++ b/clientgui/ViewResources.cpp @@ -33,6 +33,9 @@ #include "ViewResources.h" #include "Events.h" +#include "wx/arrimpl.cpp" + + #include "res/usage.xpm" #include "res/task.xpm" #include "res/tips.xpm" @@ -55,6 +58,51 @@ const wxString LINKDESC_DEFAULT = _("No available options currently defined."); +WX_DEFINE_OBJARRAY( CResourceCache ); + + +CResource::CResource() +{ + m_strProjectName = wxEmptyString; + m_strDiskSpace = wxEmptyString; +} + + +CResource::~CResource() +{ + m_strProjectName.Clear(); + m_strDiskSpace.Clear(); +} + + +wxInt32 CResource::GetProjectName( wxString& strProjectName ) +{ + strProjectName = m_strProjectName; + return 0; +} + + +wxInt32 CResource::GetDiskSpace( wxString& strDiskSpace ) +{ + strDiskSpace = m_strDiskSpace; + return 0; +} + + +wxInt32 CResource::SetProjectName( wxString& strProjectName ) +{ + m_strProjectName = strProjectName; + return 0; +} + + +wxInt32 CResource::SetDiskSpace( wxString& strDiskSpace ) +{ + m_strDiskSpace = strDiskSpace; + return 0; +} + + IMPLEMENT_DYNAMIC_CLASS(CViewResources, CBOINCBaseView) @@ -114,7 +162,7 @@ char** CViewResources::GetViewIcon() } -wxInt32 CViewResources::GetListRowCount() +wxInt32 CViewResources::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -127,23 +175,37 @@ wxInt32 CViewResources::GetListRowCount() wxString CViewResources::OnListGetItemText( long item, long column ) const { - wxString strBuffer = wxEmptyString; - CMainDocument* pDoc = wxGetApp().GetDocument(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + CResource& resource = m_ResourceCache.Item( item ); + wxString strBuffer = wxEmptyString; + + switch(column) + { + case COLUMN_PROJECT: + resource.GetProjectName( strBuffer ); + break; + case COLUMN_DISKSPACE: + resource.GetDiskSpace( strBuffer ); + break; + } + + return strBuffer; +} + + +wxString CViewResources::OnDocGetItemText( long item, long column ) const +{ + wxString strBuffer = wxEmptyString; switch(column) { case COLUMN_PROJECT: - if (item == m_iCacheFrom) pDoc->CachedStateLock(); FormatProjectName( item, strBuffer ); break; case COLUMN_DISKSPACE: FormatDiskSpace( item, strBuffer ); - if (item == m_iCacheTo) pDoc->CachedStateUnlock(); break; } + return strBuffer; } @@ -200,6 +262,57 @@ void CViewResources::OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord WXUNUSED(x) } +wxInt32 CViewResources::AddCacheElement() +{ + CResource* pItem = new CResource(); + wxASSERT( NULL != pItem ); + if ( NULL != pItem ) + { + m_ResourceCache.Add( pItem ); + return 0; + } + return -1; +} + + +wxInt32 CViewResources::EmptyCache() +{ + m_ResourceCache.Empty(); + return 0; +} + + +wxInt32 CViewResources::GetCacheCount() +{ + return m_ResourceCache.GetCount(); +} + + +wxInt32 CViewResources::RemoveCacheElement() +{ + m_ResourceCache.RemoveAt( GetCacheCount() - 1 ); + return 0; +} + + +wxInt32 CViewResources::UpdateCache( long item, long column, wxString& strNewData ) +{ + CResource& resource = m_ResourceCache.Item( item ); + + switch(column) + { + case COLUMN_PROJECT: + resource.SetProjectName( strNewData ); + break; + case COLUMN_DISKSPACE: + resource.SetDiskSpace( strNewData ); + break; + } + + return 0; +} + + void CViewResources::UpdateSelection() { wxASSERT(NULL != m_pTaskPane); diff --git a/clientgui/ViewResources.h b/clientgui/ViewResources.h index de3e64dccf..36f7037e5a 100644 --- a/clientgui/ViewResources.h +++ b/clientgui/ViewResources.h @@ -31,6 +31,27 @@ #include "BOINCBaseView.h" + +class CResource : public wxObject +{ +public: + CResource(); + ~CResource(); + + wxInt32 GetProjectName( wxString& strProjectName ); + wxInt32 GetDiskSpace( wxString& strDiskSpace ); + + wxInt32 SetProjectName( wxString& strProjectName ); + wxInt32 SetDiskSpace( wxString& strDiskSpace ); + +protected: + wxString m_strProjectName; + wxString m_strDiskSpace; +}; + +WX_DECLARE_OBJARRAY( CResource, CResourceCache ); + + class CViewResources : public CBOINCBaseView { DECLARE_DYNAMIC_CLASS( CViewResources ) @@ -43,14 +64,8 @@ public: virtual wxString GetViewName(); virtual char** GetViewIcon(); - virtual wxInt32 GetListRowCount(); - virtual wxString OnListGetItemText( long item, long column ) const; - - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - -private: +protected: bool m_bTaskHeaderHidden; @@ -58,6 +73,23 @@ private: bool m_bItemSelected; + CResourceCache m_ResourceCache; + + virtual wxInt32 GetDocCount(); + + virtual wxString OnListGetItemText( long item, long column ) const; + + virtual wxString OnDocGetItemText( long item, long column ) const; + + virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); + virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); + + virtual wxInt32 AddCacheElement(); + virtual wxInt32 EmptyCache(); + virtual wxInt32 GetCacheCount(); + virtual wxInt32 RemoveCacheElement(); + virtual wxInt32 UpdateCache( long item, long column, wxString& strNewData ); + virtual void UpdateSelection(); virtual void UpdateTaskPane(); diff --git a/clientgui/ViewTransfers.cpp b/clientgui/ViewTransfers.cpp index 92c45095ad..0cf1f32533 100644 --- a/clientgui/ViewTransfers.cpp +++ b/clientgui/ViewTransfers.cpp @@ -34,6 +34,9 @@ #include "Events.h" #include "error_numbers.h" +#include "wx/arrimpl.cpp" + + #include "res/xfer.xpm" #include "res/task.xpm" #include "res/tips.xpm" @@ -71,6 +74,131 @@ const wxString LINKDESC_TASKABORT = "This will prevent you from being granted credit for this result."); +WX_DEFINE_OBJARRAY( CTransferCache ); + + +CTransfer::CTransfer() +{ + m_strProjectName = wxEmptyString; + m_strFileName = wxEmptyString; + m_strProgress = wxEmptyString; + m_strSize = wxEmptyString; + m_strTime = wxEmptyString; + m_strSpeed = wxEmptyString; + m_strStatus = wxEmptyString; +} + + +CTransfer::~CTransfer() +{ + m_strProjectName.Clear(); + m_strFileName.Clear(); + m_strProgress.Clear(); + m_strSize.Clear(); + m_strTime.Clear(); + m_strSpeed.Clear(); + m_strStatus.Clear(); +} + + +wxInt32 CTransfer::GetProjectName( wxString& strProjectName ) +{ + strProjectName = m_strProjectName; + return 0; +} + + +wxInt32 CTransfer::GetFileName( wxString& strFileName ) +{ + strFileName = m_strFileName; + return 0; +} + + +wxInt32 CTransfer::GetProgress( wxString& strProgress ) +{ + strProgress = m_strProgress; + return 0; +} + + +wxInt32 CTransfer::GetSize( wxString& strSize ) +{ + strSize = m_strSize; + return 0; +} + + +wxInt32 CTransfer::GetTime( wxString& strTime ) +{ + strTime = m_strTime; + return 0; +} + + +wxInt32 CTransfer::GetSpeed( wxString& strSpeed ) +{ + strSpeed = m_strSpeed; + return 0; +} + + +wxInt32 CTransfer::GetStatus( wxString& strStatus ) +{ + strStatus = m_strStatus; + return 0; +} + + +wxInt32 CTransfer::SetProjectName( wxString& strProjectName ) +{ + m_strProjectName = strProjectName; + return 0; +} + + +wxInt32 CTransfer::SetFileName( wxString& strFileName ) +{ + m_strFileName = strFileName; + return 0; +} + + +wxInt32 CTransfer::SetProgress( wxString& strProgress ) +{ + m_strProgress = strProgress; + return 0; +} + + +wxInt32 CTransfer::SetSize( wxString& strSize ) +{ + m_strSize = strSize; + return 0; +} + + +wxInt32 CTransfer::SetTime( wxString& strTime ) +{ + m_strTime = strTime; + return 0; +} + + +wxInt32 CTransfer::SetSpeed( wxString& strSpeed ) +{ + m_strSpeed = strSpeed; + return 0; +} + + +wxInt32 CTransfer::SetStatus( wxString& strStatus ) +{ + m_strStatus = strStatus; + return 0; +} + + IMPLEMENT_DYNAMIC_CLASS(CViewTransfers, CBOINCBaseView) @@ -135,7 +263,7 @@ char** CViewTransfers::GetViewIcon() } -wxInt32 CViewTransfers::GetListRowCount() +wxInt32 CViewTransfers::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -148,16 +276,45 @@ wxInt32 CViewTransfers::GetListRowCount() wxString CViewTransfers::OnListGetItemText(long item, long column) const { - wxString strBuffer = wxEmptyString; - CMainDocument* pDoc = wxGetApp().GetDocument(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + CTransfer& transfer = m_TransferCache.Item( item ); + wxString strBuffer = wxEmptyString; + + switch(column) + { + case COLUMN_PROJECT: + transfer.GetProjectName( strBuffer ); + break; + case COLUMN_FILE: + transfer.GetFileName( strBuffer ); + break; + case COLUMN_PROGRESS: + transfer.GetProgress( strBuffer ); + break; + case COLUMN_SIZE: + transfer.GetSize( strBuffer ); + break; + case COLUMN_TIME: + transfer.GetTime( strBuffer ); + break; + case COLUMN_SPEED: + transfer.GetSpeed( strBuffer ); + break; + case COLUMN_STATUS: + transfer.GetStatus( strBuffer ); + break; + } + + return strBuffer; +} + + +wxString CViewTransfers::OnDocGetItemText(long item, long column) const +{ + wxString strBuffer = wxEmptyString; switch(column) { case COLUMN_PROJECT: - if (item == m_iCacheFrom) pDoc->CachedStateLock(); FormatProjectName( item, strBuffer ); break; case COLUMN_FILE: @@ -177,9 +334,9 @@ wxString CViewTransfers::OnListGetItemText(long item, long column) const break; case COLUMN_STATUS: FormatStatus( item, strBuffer ); - if (item == m_iCacheTo) pDoc->CachedStateUnlock(); break; } + return strBuffer; } @@ -276,6 +433,72 @@ void CViewTransfers::OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord WXUNUSED(x) } +wxInt32 CViewTransfers::AddCacheElement() +{ + CTransfer* pItem = new CTransfer(); + wxASSERT( NULL != pItem ); + if ( NULL != pItem ) + { + m_TransferCache.Add( pItem ); + return 0; + } + return -1; +} + + +wxInt32 CViewTransfers::EmptyCache() +{ + m_TransferCache.Empty(); + return 0; +} + + +wxInt32 CViewTransfers::GetCacheCount() +{ + return m_TransferCache.GetCount(); +} + + +wxInt32 CViewTransfers::RemoveCacheElement() +{ + m_TransferCache.RemoveAt( GetCacheCount() - 1 ); + return 0; +} + + +wxInt32 CViewTransfers::UpdateCache( long item, long column, wxString& strNewData ) +{ + CTransfer& transfer = m_TransferCache.Item( item ); + + switch(column) + { + case COLUMN_PROJECT: + transfer.SetProjectName( strNewData ); + break; + case COLUMN_FILE: + transfer.SetFileName( strNewData ); + break; + case COLUMN_PROGRESS: + transfer.SetProgress( strNewData ); + break; + case COLUMN_SIZE: + transfer.SetSize( strNewData ); + break; + case COLUMN_TIME: + transfer.SetTime( strNewData ); + break; + case COLUMN_SPEED: + transfer.SetSpeed( strNewData ); + break; + case COLUMN_STATUS: + transfer.SetStatus( strNewData ); + break; + } + + return 0; +} + + void CViewTransfers::UpdateSelection() { wxASSERT(NULL != m_pTaskPane); diff --git a/clientgui/ViewTransfers.h b/clientgui/ViewTransfers.h index 773a402834..69b58dad88 100644 --- a/clientgui/ViewTransfers.h +++ b/clientgui/ViewTransfers.h @@ -31,6 +31,42 @@ #include "BOINCBaseView.h" + +class CTransfer : public wxObject +{ +public: + CTransfer(); + ~CTransfer(); + + wxInt32 GetProjectName( wxString& strProjectName ); + wxInt32 GetFileName( wxString& strFileName ); + wxInt32 GetProgress( wxString& strProgress ); + wxInt32 GetSize( wxString& strSize ); + wxInt32 GetTime( wxString& strTime ); + wxInt32 GetSpeed( wxString& strSpeed ); + wxInt32 GetStatus( wxString& strStatus ); + + wxInt32 SetProjectName( wxString& strProjectName ); + wxInt32 SetFileName( wxString& strFileName ); + wxInt32 SetProgress( wxString& strProgress ); + wxInt32 SetSize( wxString& strSize ); + wxInt32 SetTime( wxString& strTime ); + wxInt32 SetSpeed( wxString& strSpeed ); + wxInt32 SetStatus( wxString& strStatus ); + +protected: + wxString m_strProjectName; + wxString m_strFileName; + wxString m_strProgress; + wxString m_strSize; + wxString m_strTime; + wxString m_strSpeed; + wxString m_strStatus; +}; + +WX_DECLARE_OBJARRAY( CTransfer, CTransferCache ); + + class CViewTransfers : public CBOINCBaseView { DECLARE_DYNAMIC_CLASS( CViewTransfers ) @@ -43,14 +79,8 @@ public: virtual wxString GetViewName(); virtual char** GetViewIcon(); - virtual wxInt32 GetListRowCount(); - virtual wxString OnListGetItemText( long item, long column ) const; - - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - -private: +protected: bool m_bTaskHeaderHidden; bool m_bTaskRetryHidden; @@ -60,6 +90,23 @@ private: bool m_bItemSelected; + CTransferCache m_TransferCache; + + virtual wxInt32 GetDocCount(); + + virtual wxString OnListGetItemText( long item, long column ) const; + + virtual wxString OnDocGetItemText( long item, long column ) const; + + virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); + virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); + + virtual wxInt32 AddCacheElement(); + virtual wxInt32 EmptyCache(); + virtual wxInt32 GetCacheCount(); + virtual wxInt32 RemoveCacheElement(); + virtual wxInt32 UpdateCache( long item, long column, wxString& strNewData ); + virtual void UpdateSelection(); virtual void UpdateTaskPane(); diff --git a/clientgui/ViewWork.cpp b/clientgui/ViewWork.cpp index 1a224d795b..8ddd762da9 100644 --- a/clientgui/ViewWork.cpp +++ b/clientgui/ViewWork.cpp @@ -33,6 +33,9 @@ #include "ViewWork.h" #include "Events.h" +#include "wx/arrimpl.cpp" + + #include "res/result.xpm" #include "res/task.xpm" #include "res/tips.xpm" @@ -82,6 +85,147 @@ const wxString LINKDESC_TASKABORT = "This will prevent you from being granted credit for the result."); +WX_DEFINE_OBJARRAY( CWorkCache ); + + +CWork::CWork() +{ + m_strProjectName = wxEmptyString; + m_strApplicationName = wxEmptyString; + m_strName = wxEmptyString; + m_strCPUTime = wxEmptyString; + m_strProgress = wxEmptyString; + m_strTimeToCompletion = wxEmptyString; + m_strReportDeadline = wxEmptyString; + m_strStatus = wxEmptyString; +} + + +CWork::~CWork() +{ + m_strProjectName.Clear(); + m_strApplicationName.Clear(); + m_strName.Clear(); + m_strCPUTime.Clear(); + m_strProgress.Clear(); + m_strTimeToCompletion.Clear(); + m_strReportDeadline.Clear(); + m_strStatus.Clear(); +} + + +wxInt32 CWork::GetProjectName( wxString& strProjectName ) +{ + strProjectName = m_strProjectName; + return 0; +} + + +wxInt32 CWork::GetApplicationName( wxString& strApplicationName ) +{ + strApplicationName = m_strApplicationName; + return 0; +} + + +wxInt32 CWork::GetName( wxString& strName ) +{ + strName = m_strName; + return 0; +} + + +wxInt32 CWork::GetCPUTime( wxString& strCPUTime ) +{ + strCPUTime = m_strCPUTime; + return 0; +} + + +wxInt32 CWork::GetProgress( wxString& strProgress ) +{ + strProgress = m_strProgress; + return 0; +} + + +wxInt32 CWork::GetTimeToCompletion( wxString& strTimeToCompletion ) +{ + strTimeToCompletion = m_strTimeToCompletion; + return 0; +} + + +wxInt32 CWork::GetReportDeadline( wxString& strReportDeadline ) +{ + strReportDeadline = m_strReportDeadline; + return 0; +} + + +wxInt32 CWork::GetStatus( wxString& strStatus ) +{ + strStatus = m_strStatus; + return 0; +} + + +wxInt32 CWork::SetProjectName( wxString& strProjectName ) +{ + m_strProjectName = strProjectName; + return 0; +} + + +wxInt32 CWork::SetApplicationName( wxString& strApplicationName ) +{ + m_strApplicationName = strApplicationName; + return 0; +} + + +wxInt32 CWork::SetName( wxString& strName ) +{ + m_strName = strName; + return 0; +} + + +wxInt32 CWork::SetCPUTime( wxString& strCPUTime ) +{ + m_strCPUTime = strCPUTime; + return 0; +} + + +wxInt32 CWork::SetProgress( wxString& strProgress ) +{ + m_strProgress = strProgress; + return 0; +} + + +wxInt32 CWork::SetTimeToCompletion( wxString& strTimeToCompletion ) +{ + m_strTimeToCompletion = strTimeToCompletion; + return 0; +} + + +wxInt32 CWork::SetReportDeadline( wxString& strReportDeadline ) +{ + m_strReportDeadline = strReportDeadline; + return 0; +} + + +wxInt32 CWork::SetStatus( wxString& strStatus ) +{ + m_strStatus = strStatus; + return 0; +} + + IMPLEMENT_DYNAMIC_CLASS(CViewWork, CBOINCBaseView) @@ -147,7 +291,7 @@ char** CViewWork::GetViewIcon() } -wxInt32 CViewWork::GetListRowCount() +wxInt32 CViewWork::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -160,16 +304,48 @@ wxInt32 CViewWork::GetListRowCount() wxString CViewWork::OnListGetItemText( long item, long column ) const { - wxString strBuffer = wxEmptyString; - CMainDocument* pDoc = wxGetApp().GetDocument(); - - wxASSERT(NULL != pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + CWork& work = m_WorkCache.Item( item ); + wxString strBuffer = wxEmptyString; + + switch(column) + { + case COLUMN_PROJECT: + work.GetProjectName( strBuffer ); + break; + case COLUMN_APPLICATION: + work.GetApplicationName( strBuffer ); + break; + case COLUMN_NAME: + work.GetName( strBuffer ); + break; + case COLUMN_CPUTIME: + work.GetCPUTime( strBuffer ); + break; + case COLUMN_PROGRESS: + work.GetProgress( strBuffer ); + break; + case COLUMN_TOCOMPLETETION: + work.GetTimeToCompletion( strBuffer ); + break; + case COLUMN_REPORTDEADLINE: + work.GetReportDeadline( strBuffer ); + break; + case COLUMN_STATUS: + work.GetStatus( strBuffer ); + break; + } + + return strBuffer; +} + + +wxString CViewWork::OnDocGetItemText( long item, long column ) const +{ + wxString strBuffer = wxEmptyString; switch(column) { case COLUMN_PROJECT: - if (item == m_iCacheFrom) pDoc->CachedStateLock(); FormatProjectName( item, strBuffer ); break; case COLUMN_APPLICATION: @@ -192,7 +368,6 @@ wxString CViewWork::OnListGetItemText( long item, long column ) const break; case COLUMN_STATUS: FormatStatus( item, strBuffer ); - if (item == m_iCacheTo) pDoc->CachedStateUnlock(); break; } @@ -335,6 +510,75 @@ void CViewWork::OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord WXUNUSED(x), wxC } +wxInt32 CViewWork::AddCacheElement() +{ + CWork* pItem = new CWork(); + wxASSERT( NULL != pItem ); + if ( NULL != pItem ) + { + m_WorkCache.Add( pItem ); + return 0; + } + return -1; +} + + +wxInt32 CViewWork::EmptyCache() +{ + m_WorkCache.Empty(); + return 0; +} + + +wxInt32 CViewWork::GetCacheCount() +{ + return m_WorkCache.GetCount(); +} + + +wxInt32 CViewWork::RemoveCacheElement() +{ + m_WorkCache.RemoveAt( GetCacheCount() - 1 ); + return 0; +} + + +wxInt32 CViewWork::UpdateCache( long item, long column, wxString& strNewData ) +{ + CWork& work = m_WorkCache.Item( item ); + + switch(column) + { + case COLUMN_PROJECT: + work.SetProjectName( strNewData ); + break; + case COLUMN_APPLICATION: + work.SetApplicationName( strNewData ); + break; + case COLUMN_NAME: + work.SetName( strNewData ); + break; + case COLUMN_CPUTIME: + work.SetCPUTime( strNewData ); + break; + case COLUMN_PROGRESS: + work.SetProgress( strNewData ); + break; + case COLUMN_TOCOMPLETETION: + work.SetTimeToCompletion( strNewData ); + break; + case COLUMN_REPORTDEADLINE: + work.SetReportDeadline( strNewData ); + break; + case COLUMN_STATUS: + work.SetStatus( strNewData ); + break; + } + + return 0; +} + + void CViewWork::UpdateSelection() { CMainDocument* pDoc = wxGetApp().GetDocument(); diff --git a/clientgui/ViewWork.h b/clientgui/ViewWork.h index b0fbfbb7c9..6ec1082964 100644 --- a/clientgui/ViewWork.h +++ b/clientgui/ViewWork.h @@ -31,6 +31,45 @@ #include "BOINCBaseView.h" + +class CWork : public wxObject +{ +public: + CWork(); + ~CWork(); + + wxInt32 GetProjectName( wxString& strProjectName ); + wxInt32 GetApplicationName( wxString& strApplicationName ); + wxInt32 GetName( wxString& strName ); + wxInt32 GetCPUTime( wxString& strCPUTime ); + wxInt32 GetProgress( wxString& strProgress ); + wxInt32 GetTimeToCompletion( wxString& strTimeToCompletion ); + wxInt32 GetReportDeadline( wxString& strReportDeadline ); + wxInt32 GetStatus( wxString& strStatus ); + + wxInt32 SetProjectName( wxString& strProjectName ); + wxInt32 SetApplicationName( wxString& strApplicationName ); + wxInt32 SetName( wxString& strName ); + wxInt32 SetCPUTime( wxString& strCPUTime ); + wxInt32 SetProgress( wxString& strProgress ); + wxInt32 SetTimeToCompletion( wxString& strTimeToCompletion ); + wxInt32 SetReportDeadline( wxString& strReportDeadline ); + wxInt32 SetStatus( wxString& strStatus ); + +protected: + wxString m_strProjectName; + wxString m_strApplicationName; + wxString m_strName; + wxString m_strCPUTime; + wxString m_strProgress; + wxString m_strTimeToCompletion; + wxString m_strReportDeadline; + wxString m_strStatus; +}; + +WX_DECLARE_OBJARRAY( CWork, CWorkCache ); + + class CViewWork : public CBOINCBaseView { DECLARE_DYNAMIC_CLASS( CViewWork ) @@ -43,14 +82,8 @@ public: virtual wxString GetViewName(); virtual char** GetViewIcon(); - virtual wxInt32 GetListRowCount(); - virtual wxString OnListGetItemText( long item, long column ) const; - - virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); - virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); - -private: +protected: bool m_bTaskHeaderHidden; bool m_bTaskSuspendHidden; @@ -62,6 +95,23 @@ private: bool m_bItemSelected; + CWorkCache m_WorkCache; + + virtual wxInt32 GetDocCount(); + + virtual wxString OnListGetItemText( long item, long column ) const; + + virtual wxString OnDocGetItemText( long item, long column ) const; + + virtual void OnTaskLinkClicked( const wxHtmlLinkInfo& link ); + virtual void OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y ); + + virtual wxInt32 AddCacheElement(); + virtual wxInt32 EmptyCache(); + virtual wxInt32 GetCacheCount(); + virtual wxInt32 RemoveCacheElement(); + virtual wxInt32 UpdateCache( long item, long column, wxString& strNewData ); + virtual void UpdateSelection(); virtual void UpdateTaskPane(); diff --git a/clientgui/msw/taskbarex.h b/clientgui/msw/taskbarex.h index 5ef6b95bf7..7607b05312 100644 --- a/clientgui/msw/taskbarex.h +++ b/clientgui/msw/taskbarex.h @@ -17,11 +17,6 @@ #pragma interface "taskbarex.cpp" #endif -#include -#include -#include - - // ---------------------------------------------------------------------------- // wxTaskBarIconEx // ---------------------------------------------------------------------------- diff --git a/clientgui/stdwx.h b/clientgui/stdwx.h index 9865e3dfd9..e1b566c8e2 100644 --- a/clientgui/stdwx.h +++ b/clientgui/stdwx.h @@ -80,17 +80,21 @@ #include // html window support #include // static line support #include // static bitmap support -#ifndef NOTASKBAR -#include // taskbar support -#endif #include // clipboard support #include // date/time support #include #include #include +#include +#include #include #include #include +#include + +#ifndef NOTASKBAR +#include // taskbar support +#endif // Standard Libraries @@ -140,6 +144,8 @@ #ifdef _DEBUG +#include + #define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) #define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__) #define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__) @@ -168,6 +174,8 @@ #endif //_DEBUG +#define new DEBUG_NEW + #endif //__WIN32__ && __VISUALC && !__AFX_H__ #endif //__STDWX_H__ diff --git a/configure.ac b/configure.ac index 2bbc81bfb9..2180c43c0a 100644 --- a/configure.ac +++ b/configure.ac @@ -87,8 +87,8 @@ AC_DEFINE_UNQUOTED([BOINC_VERSION_STRING], "$BOINC_VERSION_STRING", [String repr AC_DEFINE_UNQUOTED([BOINC_MAJOR_VERSION], $BOINC_MAJOR_VERSION, [Major part of BOINC version number]) AC_DEFINE_UNQUOTED([BOINC_MINOR_VERSION], $BOINC_MINOR_VERSION, [Minor part of BOINC version number]) AC_DEFINE_UNQUOTED([HOSTTYPE], "$host", [Host for this compilation]) -AC_SUBST([CLIENT_BIN_FILENAME],[boinc_client_]AC_PACKAGE_VERSION[_$host${EXEEXT}]) -AC_SUBST([CLIENT_GUI_BIN_FILENAME],[boinc_gui_]AC_PACKAGE_VERSION[_$host${EXEEXT}]) +AC_SUBST([CLIENT_BIN_FILENAME],[boinc]) +AC_SUBST([CLIENT_GUI_BIN_FILENAME],[boincmgr]) AC_SUBST([TOP_BUILD_DIR], [`pwd`]) AC_SUBST([TOP_SOURCE_DIR], [`(cd \`dirname "$0"\` && pwd)`])