Skip to content

Commit bc8bcde

Browse files
committed
Added check if new columns are to be visible by default.
1 parent 9a6db0d commit bc8bcde

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

clientgui/BOINCListCtrl.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ bool CBOINCListCtrl::OnRestoreState(wxConfigBase* pConfig) {
252252
int shownCount = orderArray.size();
253253
int hiddenCount = hiddenArray.size();
254254
int totalCount = pView->m_aStdColNameOrder->size();
255-
int defaultCount = pView->m_iNumDefaultShownColumns;
256255
for (int i = 0; i < totalCount; ++i) { // cycles through updated array of columns.
257256
wxString columnNameToFind = pView->m_aStdColNameOrder->Item(i);
258257
bool found = false;
@@ -281,7 +280,7 @@ bool CBOINCListCtrl::OnRestoreState(wxConfigBase* pConfig) {
281280
for (int k = 0; k < pView->m_iNumDefaultShownColumns; ++k) {
282281
defaultArray.Add(pView->m_aStdColNameOrder->Item(pView->m_iDefaultShownColumns[k]));
283282
}
284-
for (int k = 0; k < defaultCount; ++k) {
283+
for (int k = 0; k < defaultArray.GetCount(); ++k) {
285284
if (defaultArray[k].IsSameAs(columnNameToFind)) {
286285
orderArray.Add(columnNameToFind);
287286
foundNewDefaultColumns = true;
@@ -305,7 +304,7 @@ bool CBOINCListCtrl::OnRestoreState(wxConfigBase* pConfig) {
305304
// No "ColumnOrder" tag in pConfig
306305
// Show all columns in default column order
307306
wxASSERT(wxDynamicCast(pView, CBOINCBaseView));
308-
307+
309308
SetDefaultColumnDisplay();
310309
}
311310

@@ -319,7 +318,7 @@ bool CBOINCListCtrl::OnRestoreState(wxConfigBase* pConfig) {
319318

320319
void CBOINCListCtrl::TokenizedStringToArray(wxString tokenized, char * delimiters, wxArrayString* array) {
321320
wxString name;
322-
321+
323322
array->Clear();
324323
wxStringTokenizer tok(tokenized, delimiters);
325324
while (tok.HasMoreTokens())
@@ -346,22 +345,22 @@ void CBOINCListCtrl::SetListColumnOrder(wxArrayString& orderArray) {
346345
int columnID = 0; // ID of column, e.g. COLUMN_PROJECT, COLUMN_STATUS, etc.
347346
int sortColumnIndex = -1;
348347
wxArrayInt aOrder(shownColCount);
349-
348+
350349
CBOINCBaseView* pView = (CBOINCBaseView*)GetParent();
351350
wxASSERT(wxDynamicCast(pView, CBOINCBaseView));
352-
351+
353352
pView->m_iColumnIndexToColumnID.Clear();
354353
for (i=colCount-1; i>=0; --i) {
355354
DeleteColumn(i);
356355
}
357-
356+
358357
stdCount = pView->m_aStdColNameOrder->GetCount();
359358

360359
pView->m_iColumnIDToColumnIndex.Clear();
361360
for (columnID=0; columnID<stdCount; ++columnID) {
362361
pView->m_iColumnIDToColumnIndex.Add(-1);
363362
}
364-
363+
365364
for (columnID=0; columnID<stdCount; ++columnID) {
366365
for (columnPosition=0; columnPosition<shownColCount; ++columnPosition) {
367366
if (orderArray[columnPosition].IsSameAs(pView->m_aStdColNameOrder->Item(columnID))) {
@@ -375,7 +374,7 @@ void CBOINCListCtrl::SetListColumnOrder(wxArrayString& orderArray) {
375374
}
376375
}
377376
}
378-
377+
379378
// Prevent a crash bug if we just changed to a new locale.
380379
//
381380
// If a column has the same name in both the old and new locale, we guard against
@@ -393,7 +392,7 @@ void CBOINCListCtrl::SetListColumnOrder(wxArrayString& orderArray) {
393392
pView->m_iColumnIDToColumnIndex[columnID] = columnID;
394393
}
395394
}
396-
395+
397396
// If sort column is now hidden, set the new first column as sort column
398397
if (pView->m_iSortColumnID >= 0) {
399398
sortColumnIndex = pView->m_iColumnIDToColumnIndex[pView->m_iSortColumnID];
@@ -406,7 +405,7 @@ void CBOINCListCtrl::SetListColumnOrder(wxArrayString& orderArray) {
406405
pView->SetSortColumn(sortColumnIndex);
407406
}
408407
}
409-
408+
410409
#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
411410
colCount = GetColumnCount();
412411
if ((shownColCount > 0) && (shownColCount <= stdCount) && (colCount == shownColCount)) {
@@ -449,14 +448,14 @@ void CBOINCListCtrl::SetDefaultColumnDisplay() {
449448
int i;
450449
wxArrayString orderArray;
451450
CBOINCBaseView* pView = (CBOINCBaseView*)GetParent();
452-
451+
453452
wxASSERT(wxDynamicCast(pView, CBOINCBaseView));
454453

455454
orderArray.Clear();
456455
for (i=0; i<pView->m_iNumDefaultShownColumns; ++i) {
457456
orderArray.Add(pView->m_aStdColNameOrder->Item(pView->m_iDefaultShownColumns[i]));
458457
}
459-
458+
460459
SetListColumnOrder(orderArray);
461460
SetStandardColumnOrder();
462461
}
@@ -503,11 +502,11 @@ void CBOINCListCtrl::DrawProgressBars()
503502
wxRect r, rr;
504503
int w = 0, x = 0, xx, yy, ww;
505504
int progressColumn = -1;
506-
505+
507506
if (m_pParentView->GetProgressColumn() >= 0) {
508507
progressColumn = m_pParentView->m_iColumnIDToColumnIndex[m_pParentView->GetProgressColumn()];
509508
}
510-
509+
511510
#if USE_NATIVE_LISTCONTROL
512511
wxClientDC dc(this);
513512
m_bProgressBarEventPending = false;
@@ -522,10 +521,10 @@ void CBOINCListCtrl::DrawProgressBars()
522521

523522
int n = (int)m_iRowsNeedingProgressBars.GetCount();
524523
if (n <= 0) return;
525-
524+
526525
wxColour progressColor = wxTheColourDatabase->Find(wxT("LIGHT BLUE"));
527526
wxBrush progressBrush(progressColor);
528-
527+
529528
numItems = GetItemCount();
530529
if (numItems) {
531530
topItem = GetTopItem(); // Doesn't work properly for Mac Native control in wxMac-2.8.7
@@ -541,20 +540,20 @@ void CBOINCListCtrl::DrawProgressBars()
541540
x += GetColumnWidth(GetColumnIndexFromOrder(i));
542541
}
543542
w = GetColumnWidth(progressColumn);
544-
543+
545544
#if USE_NATIVE_LISTCONTROL
546545
x -= GetScrollPos(wxHORIZONTAL);
547546
#else
548547
CalcScrolledPosition(x, 0, &x, &yy);
549548
#endif
550549
wxFont theFont = GetFont();
551550
dc.SetFont(theFont);
552-
551+
553552
for (int i=0; i<n; ++i) {
554553
row = m_iRowsNeedingProgressBars[i];
555554
if (row < topItem) continue;
556555
if (row > (topItem + numVisibleItems -1)) continue;
557-
556+
558557

559558
GetItemRect(row, r);
560559
#if ! USE_NATIVE_LISTCONTROL
@@ -567,9 +566,9 @@ void CBOINCListCtrl::DrawProgressBars()
567566

568567
wxString progressString = m_pParentView->GetProgressText(row);
569568
dc.GetTextExtent(progressString, &xx, &yy);
570-
569+
571570
r.y += (r.height - yy - 1) / 2;
572-
571+
573572
// Adapted from ellipis code in wxRendererGeneric::DrawHeaderButtonContents()
574573
if (xx > r.width) {
575574
int ellipsisWidth;
@@ -586,7 +585,7 @@ void CBOINCListCtrl::DrawProgressBars()
586585
xx += ellipsisWidth;
587586
}
588587
}
589-
588+
590589
dc.SetLogicalFunction(wxCOPY);
591590
dc.SetBackgroundMode(wxSOLID);
592591
dc.SetPen(progressColor);
@@ -634,7 +633,7 @@ void MyEvtHandler::OnPaint(wxPaintEvent & event)
634633

635634
void CBOINCListCtrl::PostDrawProgressBarEvent() {
636635
if (m_bProgressBarEventPending) return;
637-
636+
638637
CDrawProgressBarEvent newEvent(wxEVT_DRAW_PROGRESSBAR, this);
639638
AddPendingEvent(newEvent);
640639
m_bProgressBarEventPending = true;
@@ -700,7 +699,7 @@ void CBOINCListCtrl::OnMouseDown(wxMouseEvent& event) {
700699
// on Mac, which is double-buffered to eliminate flicker.)
701700
void CBOINCListCtrl::RefreshCell(int row, int col) {
702701
wxRect r;
703-
702+
704703
GetSubItemRect(row, col, r);
705704
RefreshRect(r);
706705
}

0 commit comments

Comments
 (0)