void ColumnManager::ReadSettings ( DWORD defaultColumns , DWORD hideColumns , const CString& containerName , int maxsize , int * widthlist) { // defaults DWORD selectedStandardColumns = defaultColumns & ~hideColumns; m_dwDefaultColumns = defaultColumns & ~hideColumns; columns.resize (maxsize); int power = 1; for (size_t i = 0; i < maxsize; ++i) { columns[i].index = static_cast<int>(i); if(widthlist==NULL) columns[i].width = 0; else columns[i].width = widthlist[i]; columns[i].visible = true; columns[i].relevant = !(hideColumns & power); power *= 2; } // userProps.clear(); // where the settings are stored within the registry registryPrefix = _T("Software\\TortoiseGit\\StatusColumns\\") + containerName; // we accept settings of current version only bool valid = (DWORD)CRegDWORD (registryPrefix + _T("Version"), 0xff) == BLAME_COLUMN_VERSION; if (valid) { // read (possibly different) column selection selectedStandardColumns = CRegDWORD (registryPrefix, selectedStandardColumns) & ~hideColumns; // read user-prop lists CString userPropList = CRegString (registryPrefix + _T("UserProps")); CString shownUserProps = CRegString (registryPrefix + _T("ShownUserProps")); ParseUserPropSettings (userPropList, shownUserProps); // read column widths CString colWidths = CRegString (registryPrefix + _T("_Width")); ParseWidths (colWidths); } // process old-style visibility setting SetStandardColumnVisibility (selectedStandardColumns); // clear all previously set header columns int c = ((CHeaderCtrl*)(control->GetDlgItem(0)))->GetItemCount()-1; while (c>=0) control->DeleteColumn(c--); // create columns for (int i = 0, count = GetColumnCount(); i < count; ++i) control->InsertColumn (i, GetName(i), LVCFMT_LEFT, IsVisible(i)&&IsRelevant(i) ? -1 : GetVisibleWidth(i, false)); // restore column ordering if (valid) ParseColumnOrder (CRegString (registryPrefix + _T("_Order"))); else ParseColumnOrder (CString()); ApplyColumnOrder(); // auto-size the columns so we can see them while fetching status // (seems the same values will not take affect in InsertColumn) for (int i = 0, count = GetColumnCount(); i < count; ++i) if (IsVisible(i)) control->SetColumnWidth (i, GetVisibleWidth (i, true)); }
void CSVNStatusListCtrl::ColumnManager::ReadSettings ( DWORD defaultColumns , const CString& containerName) { // defaults DWORD selectedStandardColumns = defaultColumns; columns.resize (SVNSLC_NUMCOLUMNS); for (size_t i = 0; i < SVNSLC_NUMCOLUMNS; ++i) { columns[i].index = static_cast<int>(i); columns[i].width = 0; columns[i].visible = true; columns[i].relevant = true; } userProps.clear(); // where the settings are stored within the registry registryPrefix = L"Software\\TortoiseSVN\\StatusColumns\\" + containerName; // we accept only the current version bool valid = (DWORD)CRegDWORD (registryPrefix + L"Version", 0xff) == SVNSLC_COL_VERSION; if (valid) { // read (possibly different) column selection selectedStandardColumns = CRegDWORD (registryPrefix, selectedStandardColumns); // read user-prop lists CString userPropList = CRegString (registryPrefix + L"UserProps"); CString shownUserProps = CRegString (registryPrefix + L"ShownUserProps"); ParseUserPropSettings (userPropList, shownUserProps); // read column widths CString colWidths = CRegString (registryPrefix + L"_Width"); ParseWidths (colWidths); } // process old-style visibility setting SetStandardColumnVisibility (selectedStandardColumns); // clear all previously set header columns int c = ((CHeaderCtrl*)(control->GetDlgItem(0)))->GetItemCount()-1; while (c>=0) control->DeleteColumn(c--); // create columns for (int i = 0, count = GetColumnCount(); i < count; ++i) control->InsertColumn (i, GetName(i), LVCFMT_LEFT, IsVisible(i) ? -1 : GetVisibleWidth(i, false)); // restore column ordering if (valid) ParseColumnOrder (CRegString (registryPrefix + L"_Order")); else ParseColumnOrder (CString()); ApplyColumnOrder(); // auto-size the columns so we can see them while fetching status // (seems the same values will not take affect in InsertColumn) for (int i = 0, count = GetColumnCount(); i < count; ++i) if (IsVisible(i)) control->SetColumnWidth (i, GetVisibleWidth (i, true)); }