From fef7faf5b5dc2c8cb218c4c89423679269da0fd3 Mon Sep 17 00:00:00 2001 From: Dan Werthimer Date: Tue, 20 May 2003 23:55:52 +0000 Subject: [PATCH] no message svn path=/trunk/boinc/; revision=1229 --- client/win/wingui_listctrl.cpp | 33 +++++++++++++++++++-- client/win/wingui_listctrl.h | 5 +++- client/win/wingui_mainwindow.cpp | 50 +++++++++++++++++++++++++++++--- client/win/wingui_mainwindow.h | 1 + 4 files changed, 81 insertions(+), 8 deletions(-) diff --git a/client/win/wingui_listctrl.cpp b/client/win/wingui_listctrl.cpp index 18747f1a3f..b20e9f6f6a 100755 --- a/client/win/wingui_listctrl.cpp +++ b/client/win/wingui_listctrl.cpp @@ -298,6 +298,7 @@ int CProgressListCtrl::InsertItem(int nItem, LPCTSTR lpszItem) { m_ItemColors.InsertAt(nItem, RGB(0, 0, 0)); CString StrEmpty; + m_ProjectURLs.InsertAt(nItem, StrEmpty); return CListCtrl::InsertItem(nItem, lpszItem); } @@ -374,9 +375,8 @@ BOOL CProgressListCtrl::DeleteItem(int nItem) // remove array info m_ItemColors.RemoveAt(nItem); - CString empty; - - CString strbuf; + m_ProjectURLs.RemoveAt(nItem); + CString empty, strbuf; CProgressBarCtrl* pProgCtrl = NULL; // go through all the subitems and see if they have a progess control @@ -663,6 +663,29 @@ void CProgressListCtrl::SetItemColor(int nItem, COLORREF newclr) } } +////////// +// CProgressListCtrl::SetProjectURL +// arguments: nItem: the item to set the url for +// szUrl: the url for the link +// returns: void +// function: sets the project's master url +void CProgressListCtrl::SetProjectURL(int nItem, char* szUrl) +{ + CString StrUrl; + StrUrl.Format("%s", szUrl); + m_ProjectURLs.SetAtGrow(nItem, StrUrl); +} + +////////// +// CProgressListCtrl::GetProjectURL +// arguments: nItem: the item to set the url for +// returns: CString of project URL +// function: gets the master url for a project's link +CString CProgressListCtrl::GetProjectURL(int nItem) +{ + return m_ProjectURLs.GetAt(nItem); +} + ////////// // CProgressListCtrl::GetTextRect // arguments: nItem: item to get the rect of @@ -728,6 +751,8 @@ void CProgressListCtrl::SaveInactive(char* szFile, char* szSection) strValue = GetItemText(i, si); WritePrivateProfileString(strSection, strKey, strValue, szFile); } + strValue = GetProjectURL(i); + WritePrivateProfileString(strSection, "proj_url", strValue, szFile); nMax ++; } @@ -757,6 +782,8 @@ void CProgressListCtrl::LoadInactive(char* szFile, char* szSection) GetPrivateProfileString(strSection, strKey, "", szValue, 512, szFile); SetItemText(GetItemCount() - 1, si, szValue); } + GetPrivateProfileString(strSection, "proj_url", "", szValue, 512, szFile); + SetProjectURL(i, szValue); } } diff --git a/client/win/wingui_listctrl.h b/client/win/wingui_listctrl.h index 334709991c..48b6251abc 100755 --- a/client/win/wingui_listctrl.h +++ b/client/win/wingui_listctrl.h @@ -98,6 +98,8 @@ public: void SetMenuItems(char**, int); void SaveInactive(char*, char*); void LoadInactive(char*, char*); + void SetProjectURL(int, char*); + CString GetProjectURL(int); protected: CMenu m_PopupMenu; // context menu for header @@ -106,7 +108,8 @@ protected: CArray m_ColWidths; // column widths for hiding and unhiding; a[i] > 0: col i shown; a[i] < 0: col i hidden, previous width -(a[i] - 1) int m_nSort; // column and order of last sort: i = 0: no sort; i > 0: sorted ascending by col i - 1; < 0 sorted descending by col -(i-1) CFont* m_OldFont; // old font for setting subitem font - CArray m_ItemColors; // special colors of items + CArray m_ItemColors; // special colors of items + CArray m_ProjectURLs; // urls for project links void SwapItems(int, int); void QSort(int, int, int, int); diff --git a/client/win/wingui_mainwindow.cpp b/client/win/wingui_mainwindow.cpp index 5c5bdb3c1d..675a05242e 100755 --- a/client/win/wingui_mainwindow.cpp +++ b/client/win/wingui_mainwindow.cpp @@ -135,6 +135,42 @@ COLORREF CMainWindow::GetPieColor(int nPiece) return RGB(0, 0, 0); } +////////// +// CMainWindow::ClearProjectItems +// arguments: proj_url: master url of the project +// returns: void +// function: removes all active and inactive projects, transfers, +// and workunits associated with the project +void CMainWindow::ClearProjectItems(char *proj_url) { + int i; + CString ItemURL; + + for(i = 0; i < m_ProjectListCtrl.GetItemCount();) { + ItemURL = m_ProjectListCtrl.GetProjectURL(i); + if(!ItemURL.Compare(proj_url)) { + m_ProjectListCtrl.DeleteItem(i); + } else { + i ++; + } + } + for(i = 0; i < m_ResultListCtrl.GetItemCount();) { + ItemURL = m_ResultListCtrl.GetProjectURL(i); + if(!ItemURL.Compare(proj_url)) { + m_ResultListCtrl.DeleteItem(i); + } else { + i ++; + } + } + for(i = 0; i < m_XferListCtrl.GetItemCount();) { + ItemURL = m_XferListCtrl.GetProjectURL(i); + if(!ItemURL.Compare(proj_url)) { + m_XferListCtrl.DeleteItem(i); + } else { + i ++; + } + } +} + ////////// // CMainWindow::UpdateGUI // arguments: pcs: pointer to the client state for the gui to display @@ -150,10 +186,6 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* pcs) m_ProjectListCtrl.SetRedraw(FALSE); float totalres = 0; Syncronize(&m_ProjectListCtrl, (vector*)(&pcs->projects)); - for(i = 0; i < m_ProjectListCtrl.GetItemCount();) { - if(!m_ProjectListCtrl.GetItemData(i)) m_ProjectListCtrl.DeleteItem(i); - else i ++; - } for(i = 0; i < pcs->projects.size(); i ++) { totalres += pcs->projects[i]->resource_share; } @@ -165,6 +197,9 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* pcs) continue; } + // Set the master URL for this object + m_ProjectListCtrl.SetProjectURL(i, pr->master_url); + // project m_ProjectListCtrl.SetItemText(i, 0, pr->get_project_name()); @@ -200,6 +235,9 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* pcs) continue; } + // Set the master URL for this object + m_ResultListCtrl.SetProjectURL(i, re->project->master_url); + // project m_ResultListCtrl.SetItemText(i, 0, re->project->project_name); @@ -281,6 +319,9 @@ void CMainWindow::UpdateGUI(CLIENT_STATE* pcs) continue; } + // Set the master URL for this object + m_XferListCtrl.SetProjectURL(i, pfx->fip->project->master_url); + // project m_XferListCtrl.SetItemText(i, 0, pfx->fip->project->project_name); @@ -1085,6 +1126,7 @@ void CMainWindow::OnCommandProjectDetach() strBuf.Format("Are you sure you want to detach from the project %s?", proj->get_project_name()); if(AfxMessageBox(strBuf, MB_YESNO, 0) == IDYES) { + ClearProjectItems(proj->master_url); gstate.detach_project(proj); } } diff --git a/client/win/wingui_mainwindow.h b/client/win/wingui_mainwindow.h index 5fe9a65b6a..513b12618d 100755 --- a/client/win/wingui_mainwindow.h +++ b/client/win/wingui_mainwindow.h @@ -124,6 +124,7 @@ protected: void LoadLanguage(); PROJECT* GetProjectFromContextMenu(); DWORD GetUserIdleTime(); + void ClearProjectItems(char *); void Syncronize(CProgressListCtrl*, vector*); virtual void PostNcDestroy(); LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);