@@ -209,7 +209,7 @@ bool CProjectInfoPage::Create( CBOINCBaseWizard* parent )
209
209
210
210
void CProjectInfoPage::CreateControls ()
211
211
{
212
- // //@begin CProjectInfoPage content construction
212
+ // //@begin CProjectInfoPage content construction
213
213
#ifdef __WXMAC__
214
214
const int descriptionWidth = 350 ;
215
215
#else
@@ -256,10 +256,32 @@ void CProjectInfoPage::CreateControls()
256
256
// so we don't need to worry about duplicate entries here.
257
257
// Get the project list
258
258
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
+ }
263
285
}
264
286
m_pProjectCategoriesCtrl = new wxComboBox ( itemWizardPage23, ID_CATEGORIES, wxT (" " ), wxDefaultPosition, wxDefaultSize, aCategories, wxCB_READONLY
265
287
#ifndef __WXMAC__ // wxCB_SORT is not available in wxCocoa 3.0
@@ -277,7 +299,7 @@ void CProjectInfoPage::CreateControls()
277
299
itemBoxSizer7->Add (itemFlexGridSizer11, 0 , wxGROW|wxALL, 0 );
278
300
279
301
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 );
281
303
itemFlexGridSizer11->Add (m_pProjectsCtrl, 0 , wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 0 );
282
304
283
305
m_pProjectDetailsStaticCtrl = new wxStaticBox (itemWizardPage23, wxID_ANY, _ (" Project details" ));
@@ -514,13 +536,26 @@ void CProjectInfoPage::OnProjectCategorySelected( wxCommandEvent& WXUNUSED(event
514
536
515
537
m_pProjectsCtrl->Clear ();
516
538
539
+ int lastproject = -1 ;
517
540
// Populate the list box with the list of project names that belong to either the specific
518
541
// 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
520
544
if ((m_pProjectCategoriesCtrl->GetValue () == _ (" All" )) ||
521
545
(m_pProjectCategoriesCtrl->GetValue () == m_Projects[i]->m_strGeneralArea )
522
546
) {
523
547
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
+ }
524
559
}
525
560
}
526
561
@@ -706,27 +741,27 @@ void CProjectInfoPage::OnPageChanged( wxWizardExEvent& event ) {
706
741
707
742
if (strProjectPlanClass.Find (_T (" cuda" )) != wxNOT_FOUND) {
708
743
pProjectInfo->m_bProjectSupportsCUDA = true ;
709
- if (!pDoc->state .host_info .coprocs .have_nvidia ()) continue ;
744
+ if (!pDoc->state .host_info .coprocs .have_nvidia ()) continue ;
710
745
}
711
746
712
747
if (strProjectPlanClass.Find (_T (" nvidia" )) != wxNOT_FOUND) {
713
748
pProjectInfo->m_bProjectSupportsCUDA = true ;
714
- if (!pDoc->state .host_info .coprocs .have_nvidia ()) continue ;
749
+ if (!pDoc->state .host_info .coprocs .have_nvidia ()) continue ;
715
750
}
716
751
717
752
if (strProjectPlanClass.Find (_T (" ati" )) != wxNOT_FOUND) {
718
753
pProjectInfo->m_bProjectSupportsCAL = true ;
719
- if (!pDoc->state .host_info .coprocs .have_ati ()) continue ;
754
+ if (!pDoc->state .host_info .coprocs .have_ati ()) continue ;
720
755
}
721
756
722
757
if (strProjectPlanClass.Find (_T (" amd" )) != wxNOT_FOUND) {
723
758
pProjectInfo->m_bProjectSupportsCAL = true ;
724
- if (!pDoc->state .host_info .coprocs .have_ati ()) continue ;
759
+ if (!pDoc->state .host_info .coprocs .have_ati ()) continue ;
725
760
}
726
761
727
762
if (strProjectPlanClass.Find (_T (" intel_gpu" )) != wxNOT_FOUND) {
728
763
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 ;
730
765
}
731
766
732
767
if (strProjectPlanClass.Find (_T (" vbox" )) != wxNOT_FOUND) {
@@ -739,11 +774,11 @@ void CProjectInfoPage::OnPageChanged( wxWizardExEvent& event ) {
739
774
}
740
775
}
741
776
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
+ }
747
782
}
748
783
749
784
@@ -816,11 +851,11 @@ void CProjectInfoPage::OnPageChanging( wxWizardExEvent& event ) {
816
851
const std::string http = " http://" ;
817
852
const std::string https = " https://" ;
818
853
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);
821
856
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);
824
859
if (project) {
825
860
std::string project_url = project->master_url ;
826
861
0 commit comments