1
1
// This file is part of BOINC.
2
2
// http://boinc.berkeley.edu
3
- // Copyright (C) 2015 University of California
3
+ // Copyright (C) 2022 University of California
4
4
//
5
5
// BOINC is free software; you can redistribute it and/or modify it
6
6
// under the terms of the GNU Lesser General Public License
@@ -132,7 +132,7 @@ bool CBOINCListCtrl::OnSaveState(wxConfigBase* pConfig) {
132
132
for (iIndex = 0 ; iIndex < iActualColumnCount; iIndex++) {
133
133
m_pParentView->m_iStdColWidthOrder [m_pParentView->m_iColumnIndexToColumnID [iIndex]] = GetColumnWidth (iIndex);
134
134
}
135
-
135
+
136
136
for (iIndex = 0 ; iIndex < iStdColumnCount; iIndex++) {
137
137
pConfig->SetPath (strBaseConfigLocation + m_pParentView->m_aStdColNameOrder ->Item (iIndex));
138
138
pConfig->Write (wxT (" Width" ), m_pParentView->m_iStdColWidthOrder [iIndex]);
@@ -158,9 +158,9 @@ bool CBOINCListCtrl::OnSaveState(wxConfigBase* pConfig) {
158
158
aOrder[i] = i;
159
159
}
160
160
#endif
161
-
161
+
162
162
strColumnOrder.Printf (wxT (" %s" ), pView->m_aStdColNameOrder ->Item (pView->m_iColumnIndexToColumnID [aOrder[0 ]]));
163
-
163
+
164
164
for (i = 1 ; i < iActualColumnCount; ++i)
165
165
{
166
166
strBuffer.Printf (wxT (" ;%s" ), pView->m_aStdColNameOrder ->Item (pView->m_iColumnIndexToColumnID [aOrder[i]]));
@@ -185,7 +185,7 @@ bool CBOINCListCtrl::OnSaveState(wxConfigBase* pConfig) {
185
185
strHiddenColumns += pView->m_aStdColNameOrder ->Item (i);
186
186
}
187
187
pConfig->Write (wxT (" HiddenColumns" ), strHiddenColumns);
188
-
188
+
189
189
return true ;
190
190
}
191
191
@@ -207,7 +207,6 @@ bool CBOINCListCtrl::OnRestoreState(wxConfigBase* pConfig) {
207
207
// Cycle through the possible columns updating column widths
208
208
for (iIndex = 0 ; iIndex < iStdColumnCount; iIndex++) {
209
209
pConfig->SetPath (strBaseConfigLocation + m_pParentView->m_aStdColNameOrder ->Item (iIndex));
210
-
211
210
pConfig->Read (wxT (" Width" ), &iTempValue, -1 );
212
211
if (-1 != iTempValue) {
213
212
m_pParentView->m_iStdColWidthOrder [iIndex] = iTempValue;
@@ -240,42 +239,67 @@ bool CBOINCListCtrl::OnRestoreState(wxConfigBase* pConfig) {
240
239
//
241
240
// This will also be triggered if the locale is changed, which will cause
242
241
// SetListColumnOrder() to be called again so the wxListCtrl will be set
243
- // up with the correctly labeled columns.
242
+ // up with the correctly labeled columns.
243
+ //
244
244
bool foundNewColumns = false ;
245
+ bool foundNewDefaultColumns = false ;
246
+ bool foundNewHiddenColumns = false ;
245
247
246
248
if (pConfig->Read (wxT (" HiddenColumns" ), &strHiddenColumns)) {
247
249
wxArrayString hiddenArray;
250
+ wxArrayString defaultArray;
248
251
TokenizedStringToArray (strHiddenColumns, " ;" , &hiddenArray);
249
252
int shownCount = orderArray.size ();
250
253
int hiddenCount = hiddenArray.size ();
251
254
int totalCount = pView->m_aStdColNameOrder ->size ();
252
- for (int i = 0 ; i < totalCount; ++i) {
255
+ int defaultCount = pView->m_iNumDefaultShownColumns ;
256
+ for (int i = 0 ; i < totalCount; ++i) { // cycles through updated array of columns.
253
257
wxString columnNameToFind = pView->m_aStdColNameOrder ->Item (i);
254
258
bool found = false ;
255
- for (int j = 0 ; j < shownCount; ++j) {
259
+ for (int j = 0 ; j < shownCount; ++j) { // cycles through list of visible columns.
256
260
if (orderArray[j].IsSameAs (columnNameToFind)) {
257
261
found = true ;
258
262
break ;
259
263
}
260
264
}
261
265
if (found) continue ;
262
266
263
- for (int j = 0 ; j < hiddenCount; ++j) {
267
+ for (int j = 0 ; j < hiddenCount; ++j) { // cycles through the hidden columns.
264
268
if (hiddenArray[j].IsSameAs (columnNameToFind)) {
265
269
found = true ;
266
270
break ;
267
271
}
268
272
}
269
273
if (found) continue ;
270
-
271
- foundNewColumns = true ;
272
- orderArray.Add (columnNameToFind);
274
+
275
+ foundNewColumns = true ;
276
+ // If we got this far, then we know this column is new.
277
+ // Now it needs to be determined if the new column should be shown by default or not.
278
+ // Create array of default columns.
279
+ //
280
+ defaultArray.Clear ();
281
+ for (int k = 0 ; k < pView->m_iNumDefaultShownColumns ; ++k) {
282
+ defaultArray.Add (pView->m_aStdColNameOrder ->Item (pView->m_iDefaultShownColumns [k]));
283
+ }
284
+ for (int k = 0 ; k < defaultCount; ++k) {
285
+ if (defaultArray[k].IsSameAs (columnNameToFind)) {
286
+ orderArray.Add (columnNameToFind);
287
+ foundNewDefaultColumns = true ;
288
+ break ;
289
+ }
290
+ }
291
+ if (!foundNewDefaultColumns) {
292
+ hiddenArray.Add (columnNameToFind); // No need to order new hidden columns since they are hidden.
293
+ foundNewHiddenColumns = true ;
294
+ }
273
295
}
274
296
}
275
297
if (foundNewColumns) {
276
- bool wasInStandardOrder = IsColumnOrderStandard ();
277
- SetListColumnOrder (orderArray);
278
- if (wasInStandardOrder) SetStandardColumnOrder ();
298
+ if (foundNewDefaultColumns) {
299
+ bool wasInStandardOrder = IsColumnOrderStandard ();
300
+ SetListColumnOrder (orderArray);
301
+ if (wasInStandardOrder) SetStandardColumnOrder ();
302
+ }
279
303
}
280
304
} else {
281
305
// No "ColumnOrder" tag in pConfig
0 commit comments