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;
}
Exemple #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;
}
LRESULT AutoSearchFrame::onMoveDown(WORD , WORD , HWND , BOOL& ) {
	int i = ctrlAutoSearch.GetSelectedIndex();
	if(i != -1 && i != (ctrlAutoSearch.GetItemCount()-1) ) {
		//swap and reload list, not the best solution :P
		ctrlAutoSearch.SetRedraw(FALSE);
		AutoSearchManager::getInstance()->moveAutoSearchDown(i);
		ctrlAutoSearch.DeleteAllItems();

		AutoSearchList lst = AutoSearchManager::getInstance()->getSearchItems();
		for(auto j = lst.begin(); j != lst.end(); ++j) {
			const AutoSearchPtr as = *j;	
			addEntry(as, ctrlAutoSearch.GetItemCount());
		}
		ctrlAutoSearch.SetRedraw(TRUE);
		ctrlAutoSearch.Invalidate();
		ctrlAutoSearch.SetItemState(i+1, LVIS_SELECTED, LVIS_SELECTED);
		ctrlAutoSearch.EnsureVisible(i+1, FALSE);

	}
	return 0;
}