Skip to content

Commit 391e0ff

Browse files
committed
Gray out projects that are already attached.
1 parent 2adc6cf commit 391e0ff

File tree

2 files changed

+58
-21
lines changed

2 files changed

+58
-21
lines changed

clientgui/ProjectInfoPage.cpp

+56-21
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ bool CProjectInfoPage::Create( CBOINCBaseWizard* parent )
209209

210210
void CProjectInfoPage::CreateControls()
211211
{
212-
////@begin CProjectInfoPage content construction
212+
////@begin CProjectInfoPage content construction
213213
#ifdef __WXMAC__
214214
const int descriptionWidth = 350;
215215
#else
@@ -256,10 +256,32 @@ void CProjectInfoPage::CreateControls()
256256
// so we don't need to worry about duplicate entries here.
257257
// Get the project list
258258
m_apl = new ALL_PROJECTS_LIST;
259-
pDoc->rpc.get_all_projects_list(*m_apl);
260-
for (unsigned int i=0; i<m_apl->projects.size(); i++) {
261-
wxString strGeneralArea = wxGetTranslation(wxString(m_apl->projects[i]->general_area.c_str(), wxConvUTF8));
262-
aCategories.Add(strGeneralArea);
259+
std::string tempstring;
260+
if (pDoc) {
261+
pDoc->rpc.get_all_projects_list(*m_apl);
262+
263+
for (unsigned int i = 0; i < m_apl->projects.size(); i++) {
264+
wxString strGeneralArea = wxGetTranslation(wxString(m_apl->projects[i]->general_area.c_str(), wxConvUTF8));
265+
aCategories.Add(strGeneralArea);
266+
tempstring = m_apl->projects[i]->url;
267+
// Canonicalize/trim/store the URLs of all projects. This will be used later on for the wxListBox
268+
// to visually indicate any projects that are currently attached, as well as checking for when a
269+
// project or manual URL is selected.
270+
//
271+
canonicalize_master_url(tempstring);
272+
TrimURL(tempstring);
273+
m_pTrimmedURL.push_back(tempstring);
274+
}
275+
// Take all projects that the Client is already attached to and create an array of their
276+
// canonicalized and trimmed URLs. This will be used for comparing against the master list of projects
277+
// to visually indicate which projectes have already been attached.
278+
//
279+
for (unsigned int i = 0; i < pDoc->GetProjectCount(); i++) {
280+
tempstring = pDoc->project(i)->master_url;
281+
canonicalize_master_url(tempstring);
282+
TrimURL(tempstring);
283+
m_pTrimmedURL_attached.push_back(tempstring);
284+
}
263285
}
264286
m_pProjectCategoriesCtrl = new wxComboBox( itemWizardPage23, ID_CATEGORIES, wxT(""), wxDefaultPosition, wxDefaultSize, aCategories, wxCB_READONLY
265287
#ifndef __WXMAC__ // wxCB_SORT is not available in wxCocoa 3.0
@@ -277,7 +299,7 @@ void CProjectInfoPage::CreateControls()
277299
itemBoxSizer7->Add(itemFlexGridSizer11, 0, wxGROW|wxALL, 0);
278300

279301
wxArrayString m_pProjectsCtrlStrings;
280-
m_pProjectsCtrl = new wxListBox( itemWizardPage23, ID_PROJECTS, wxDefaultPosition, wxSize(-1, 175), m_pProjectsCtrlStrings, wxLB_SINGLE|wxLB_SORT );
302+
m_pProjectsCtrl = new wxListBox( itemWizardPage23, ID_PROJECTS, wxDefaultPosition, wxSize(-1, 175), m_pProjectsCtrlStrings, wxLB_SINGLE|wxLB_SORT|wxLB_OWNERDRAW );
281303
itemFlexGridSizer11->Add(m_pProjectsCtrl, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 0);
282304

283305
m_pProjectDetailsStaticCtrl = new wxStaticBox(itemWizardPage23, wxID_ANY, _("Project details"));
@@ -514,13 +536,26 @@ void CProjectInfoPage::OnProjectCategorySelected( wxCommandEvent& WXUNUSED(event
514536

515537
m_pProjectsCtrl->Clear();
516538

539+
int lastproject = -1;
517540
// Populate the list box with the list of project names that belong to either the specific
518541
// category or all of them.
519-
for (unsigned int i=0; i<m_Projects.size(); i++) {
542+
//
543+
for (unsigned int i=0; i<m_Projects.size(); i++) { // cycle through all projects
520544
if ((m_pProjectCategoriesCtrl->GetValue() == _("All")) ||
521545
(m_pProjectCategoriesCtrl->GetValue() == m_Projects[i]->m_strGeneralArea)
522546
) {
523547
m_pProjectsCtrl->Append(m_Projects[i]->m_strName, m_Projects[i]);
548+
lastproject = m_pProjectsCtrl->GetCount() - 1;
549+
// Since this project was added to the wxListBox, check to see if the project has already been attached.
550+
// If it has, grey out the text for a visual indicator that the project has been added.
551+
//
552+
for (unsigned int j = 0; j < m_pTrimmedURL_attached.size(); j++) { // cycle through all attached projects
553+
if (m_pTrimmedURL[i] == m_pTrimmedURL_attached[j]) {
554+
// Color 117,117,117 has a 4.6:1 contract ratio that passes accessibility
555+
m_pProjectsCtrl->GetItem(lastproject)->SetTextColour(wxColour(117,117,117));
556+
break;
557+
}
558+
}
524559
}
525560
}
526561

@@ -706,27 +741,27 @@ void CProjectInfoPage::OnPageChanged( wxWizardExEvent& event ) {
706741

707742
if (strProjectPlanClass.Find(_T("cuda")) != wxNOT_FOUND) {
708743
pProjectInfo->m_bProjectSupportsCUDA = true;
709-
if (!pDoc->state.host_info.coprocs.have_nvidia()) continue;
744+
if (!pDoc->state.host_info.coprocs.have_nvidia()) continue;
710745
}
711746

712747
if (strProjectPlanClass.Find(_T("nvidia")) != wxNOT_FOUND) {
713748
pProjectInfo->m_bProjectSupportsCUDA = true;
714-
if (!pDoc->state.host_info.coprocs.have_nvidia()) continue;
749+
if (!pDoc->state.host_info.coprocs.have_nvidia()) continue;
715750
}
716751

717752
if (strProjectPlanClass.Find(_T("ati")) != wxNOT_FOUND) {
718753
pProjectInfo->m_bProjectSupportsCAL = true;
719-
if (!pDoc->state.host_info.coprocs.have_ati()) continue;
754+
if (!pDoc->state.host_info.coprocs.have_ati()) continue;
720755
}
721756

722757
if (strProjectPlanClass.Find(_T("amd")) != wxNOT_FOUND) {
723758
pProjectInfo->m_bProjectSupportsCAL = true;
724-
if (!pDoc->state.host_info.coprocs.have_ati()) continue;
759+
if (!pDoc->state.host_info.coprocs.have_ati()) continue;
725760
}
726761

727762
if (strProjectPlanClass.Find(_T("intel_gpu")) != wxNOT_FOUND) {
728763
pProjectInfo->m_bProjectSupportsIntelGPU = true;
729-
if (!pDoc->state.host_info.coprocs.have_intel_gpu()) continue;
764+
if (!pDoc->state.host_info.coprocs.have_intel_gpu()) continue;
730765
}
731766

732767
if (strProjectPlanClass.Find(_T("vbox")) != wxNOT_FOUND) {
@@ -739,11 +774,11 @@ void CProjectInfoPage::OnPageChanged( wxWizardExEvent& event ) {
739774
}
740775
}
741776

742-
// If project doesn't export its platforms, assume we're supported
743-
//
744-
if (aProjectPlatforms.size() == 0) {
745-
pProjectInfo->m_bSupportedPlatformFound = true;
746-
}
777+
// If project doesn't export its platforms, assume we're supported
778+
//
779+
if (aProjectPlatforms.size() == 0) {
780+
pProjectInfo->m_bSupportedPlatformFound = true;
781+
}
747782
}
748783

749784

@@ -816,11 +851,11 @@ void CProjectInfoPage::OnPageChanging( wxWizardExEvent& event ) {
816851
const std::string http = "http://";
817852
const std::string https = "https://";
818853

819-
std::string new_project_url = (const char*)m_strProjectURL.mb_str();
820-
canonicalize_master_url(new_project_url);
854+
std::string new_project_url = (const char*)m_strProjectURL.mb_str();
855+
canonicalize_master_url(new_project_url);
821856
TrimURL(new_project_url);
822-
for (int i = 0; i < pDoc->GetProjectCount(); ++i) {
823-
PROJECT* project = pDoc->project(i);
857+
for (int i = 0; i < pDoc->GetProjectCount(); ++i) {
858+
PROJECT* project = pDoc->project(i);
824859
if (project) {
825860
std::string project_url = project->master_url;
826861

clientgui/ProjectInfoPage.h

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ class CProjectInfoPage: public wxWizardPageEx
129129
std::vector<CProjectInfo*> m_Projects;
130130
bool m_bProjectSupported;
131131
bool m_bProjectListPopulated;
132+
std::vector<std::string> m_pTrimmedURL;
133+
std::vector<std::string> m_pTrimmedURL_attached;
132134
};
133135

134136
#endif

0 commit comments

Comments
 (0)