void MainFrame::AddToFavorites (const VolumeInfoList &volumes) { try { FavoriteVolumeList newFavorites; // Delete duplicates foreach (shared_ptr <FavoriteVolume> favorite, FavoriteVolume::LoadList()) { bool mounted = false; foreach_ref (const VolumeInfo &volume, volumes) { if (volume.Path == favorite->Path) { mounted = true; break; } } if (!mounted) newFavorites.push_back (favorite); } size_t newItemCount = 0; foreach_ref (const VolumeInfo &volume, volumes) { newFavorites.push_back (shared_ptr <FavoriteVolume> (new FavoriteVolume (volume.Path, volume.MountPoint, volume.SlotNumber, volume.Protection == VolumeProtection::ReadOnly, volume.SystemEncryption))); ++newItemCount; }
void FavoriteVolumesDialog::OnOKButtonClick (wxCommandEvent& event) { FavoriteVolumeList newFavorites; for (long i = 0; i < FavoritesListCtrl->GetItemCount(); i++) { newFavorites.push_back (make_shared <FavoriteVolume> ( *reinterpret_cast <FavoriteVolume *> (FavoritesListCtrl->GetItemData (i)))); } Favorites = newFavorites; EndModal (wxID_OK); }