Exemplo n.º 1
0
StdStrBuf C4FileSelDlg::GetSelection(const char *szFixedSelection,
                                     bool fFilenameOnly) const {
  StdStrBuf sResult;
  if (!IsMultiSelection()) {
    // get single selected file for single selection dlg
    if (pSelection)
      sResult.Copy(fFilenameOnly ? GetFilename(pSelection->GetFilename())
                                 : pSelection->GetFilename());
  } else {
    // force fixed selection first
    if (szFixedSelection) sResult.Append(szFixedSelection);
    //  get ';'-seperated list for multi selection dlg
    for (ListItem *pFileItem =
             static_cast<ListItem *>(pFileListBox->GetFirst());
         pFileItem; pFileItem = static_cast<ListItem *>(pFileItem->GetNext()))
      if (pFileItem->IsChecked()) {
        const char *szAppendFilename = pFileItem->GetFilename();
        if (fFilenameOnly) szAppendFilename = GetFilename(szAppendFilename);
        // prevent adding entries twice (especially those from the fixed
        // selection list)
        if (!SIsModule(sResult.getData(), szAppendFilename)) {
          if (sResult.getLength()) sResult.AppendChar(';');
          sResult.Append(szAppendFilename);
        }
      }
  }
  return sResult;
}
Exemplo n.º 2
0
void C4FileSelDlg::SetSelection(const char *szNewSelection,
                                bool fFilenameOnly) {
  // check all selected definitions
  for (ListItem *pFileItem = static_cast<ListItem *>(pFileListBox->GetFirst());
       pFileItem; pFileItem = static_cast<ListItem *>(pFileItem->GetNext())) {
    const char *szFileItemFilename = pFileItem->GetFilename();
    if (fFilenameOnly) szFileItemFilename = GetFilename(szFileItemFilename);
    pFileItem->SetChecked(SIsModule(szNewSelection, szFileItemFilename));
  }
}