예제 #1
0
LRESULT AsGroupsDlg::onRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	int32_t pos = ctrlGroups.GetSelectedIndex();
	if (pos < 0)
		return 0;

	AutoSearchList removeLst;
	{
		tstring name = getText(0, pos);
		WLock l(AutoSearchManager::getInstance()->getCS());
		auto lst = AutoSearchManager::getInstance()->getSearchItems();
		bool remove = MessageBox(CTSTRING(GROUP_REMOVE_ITEMS), CTSTRING(REMOVE_GROUP), MB_ICONQUESTION | MB_YESNO) == IDYES;

		for (auto as : lst | map_values) {
			if (as->getGroup() != Text::fromT(name))
				continue;
			if (remove)
				removeLst.push_back(as);
			else
				as->setGroup(Util::emptyString);
		}
		ctrlGroups.DeleteItem(pos);
		updateSelectedGroup(true);
	}

	for_each(removeLst, [&](AutoSearchPtr a) { AutoSearchManager::getInstance()->removeAutoSearch(a); });
	return 0;
}
예제 #2
0
LRESULT AutoSearchFrame::onRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	//use a removelist, the selection position will change when removing multiple.
	AutoSearchList removelist;

	int i = -1;
	while ((i = ctrlAutoSearch.GetNextItem(i, LVNI_SELECTED)) != -1) {
		removelist.push_back(ctrlAutoSearch.getItemData(i)->asItem);
	}

	if (WinUtil::MessageBoxConfirm(SettingsManager::CONFIRM_AS_REMOVAL, TSTRING(REALLY_REMOVE))) {
		for (auto a = removelist.begin(); a != removelist.end(); ++a)
			AutoSearchManager::getInstance()->removeAutoSearch(*a);
	}
	return 0;
}