Ejemplo n.º 1
0
void AutoSearchFrame::addItem(const AutoSearchPtr& as) {
	if (!as)
		return;
	auto ui = itemInfos.find(as->getToken());
	if (ui == itemInfos.end()) {
		auto x = itemInfos.emplace(as->getToken(), ItemInfo(as)).first;
		ctrlAutoSearch.SetRedraw(FALSE);
		addListEntry(&x->second);
		ctrlAutoSearch.resort();
		ctrlAutoSearch.SetRedraw(TRUE);
	}
}
Ejemplo n.º 2
0
void AutoSearchFrame::removeItem(const AutoSearchPtr as) {
	auto i = itemInfos.find(as->getToken());
	if (i != itemInfos.end()) {
		ctrlAutoSearch.deleteItem(&i->second);
		itemInfos.erase(i);
	}
}
Ejemplo n.º 3
0
void AutoSearchFrame::updateItem(const AutoSearchPtr as) {
	auto i = itemInfos.find(as->getToken());
	if (i != itemInfos.end()) {
		auto ii = &i->second;
		ii->update(as);
		int pos = ctrlAutoSearch.findItem(ii);
		if (pos >= 0) {
			ctrlAutoSearch.SetCheckState(pos, as->getEnabled());
			LVITEM lvi = { 0 };
			lvi.mask = LVIF_GROUPID | LVIF_IMAGE;
			lvi.iItem = pos;
			lvi.iGroupId = ii->getGroupId();
			lvi.iImage = as->getStatus();
			lvi.iSubItem = 0;
			ctrlAutoSearch.SetItem(&lvi);
			ctrlAutoSearch.updateItem(pos);
		}
	}
}
Ejemplo n.º 4
0
void AutoSearchFrame::updateItem(const AutoSearchPtr as, int pos) {
	ctrlAutoSearch.SetItemText(pos, COLUMN_LASTSEARCH, (as->getLastSearch() > 0 ? formatSearchDate(as->getLastSearch()).c_str() : _T("Unknown")));
}
Ejemplo n.º 5
0
void AutoSearchFrame::addEntry(const AutoSearchPtr as, int pos) {
	if(as == NULL)
		return;
		
	if(pos < 0)
		pos = 0;

	TStringList lst;
	lst.push_back(Text::toT(as->getSearchString()));
	lst.push_back(Text::toT(getType(as->getFileType())));
		
	if(as->getAction() == 0){
		lst.push_back(CTSTRING(DOWNLOAD));
	}else if(as->getAction() == 1){
		lst.push_back(CTSTRING(ADD_TO_QUEUE));
	}else if(as->getAction() == 2){
		lst.push_back(CTSTRING(AS_REPORT));
	}
		
	lst.push_back(Text::toT(as->getTarget()));
	lst.push_back(Text::toT(as->getRemove()? "Yes" : "No"));
	lst.push_back(Text::toT(as->getNickPattern()));
	lst.push_back((as->getLastSearch() > 0 ? formatSearchDate(as->getLastSearch()).c_str() : _T("Unknown")));

	bool b = as->getEnabled();
	int i = ctrlAutoSearch.insert(pos, lst, 0, (LPARAM)as.get());
	ctrlAutoSearch.SetCheckState(i, b);
}
Ejemplo n.º 6
0
LRESULT AutoSearchFrame::onChange(WORD , WORD , HWND , BOOL& ) {
	if(ctrlAutoSearch.GetSelectedCount() == 1) {
		int sel = ctrlAutoSearch.GetSelectedIndex();
		AutoSearchPtr as = AutoSearchManager::getInstance()->getAutoSearch(sel);

		SearchPageDlg dlg;
		dlg.searchString = as->getSearchString();
		dlg.fileType = as->getFileType();
		dlg.action = as->getAction();
		dlg.remove = as->getRemove();
		dlg.target = as->getTarget();
		dlg.userMatch = as->getNickPattern();
		dlg.matcherString = as->getPattern();
		dlg.matcherType = as->getMatcherType();
		dlg.expireTime = as->getExpireTime();
		dlg.searchDays = as->searchDays;
		dlg.startTime = as->startTime;
		dlg.endTime = as->endTime;
		dlg.targetType = as->getTargetType();
		dlg.checkQueued = as->getCheckAlreadyQueued();
		dlg.checkShared = as->getCheckAlreadyShared();

		if(dlg.DoModal() == IDOK) {
			AutoSearchPtr asNew = AutoSearchPtr(new AutoSearch(as->getEnabled(), dlg.searchString, (SearchManager::TypeModes)dlg.fileType, (AutoSearch::ActionType)dlg.action, 
				dlg.remove, dlg.target, (TargetUtil::TargetType)dlg.targetType, (StringMatcher::Type)dlg.matcherType, dlg.matcherString, dlg.userMatch, dlg.searchInterval, 
				dlg.expireTime, dlg.checkQueued, dlg.checkShared));
			asNew->startTime = dlg.startTime;
			asNew->endTime = dlg.endTime;
			asNew->searchDays = dlg.searchDays;

			if (AutoSearchManager::getInstance()->updateAutoSearch(sel, asNew)) {

				ctrlAutoSearch.SetCheckState(sel, asNew->getEnabled());
				ctrlAutoSearch.SetItemText(sel, COLUMN_VALUE, Text::toT(dlg.searchString).c_str());
				ctrlAutoSearch.SetItemText(sel, COLUMN_TYPE, Text::toT(getType(dlg.fileType)).c_str());
				if(dlg.action == 0){
					ctrlAutoSearch.SetItemText(sel, COLUMN_ACTION, Text::toT(STRING(DOWNLOAD)).c_str());
				} else if(dlg.action == 1){
					ctrlAutoSearch.SetItemText(sel, COLUMN_ACTION, Text::toT(STRING(ADD_TO_QUEUE)).c_str());
				} else if(dlg.action == 2){
					ctrlAutoSearch.SetItemText(sel, COLUMN_ACTION, Text::toT(STRING(AS_REPORT)).c_str());
				}
				ctrlAutoSearch.SetItemText(sel, COLUMN_REMOVE, Text::toT(dlg.target).c_str());
				ctrlAutoSearch.SetItemText(sel, COLUMN_PATH, dlg.remove ? _T("Yes") : _T("No"));
				ctrlAutoSearch.SetItemText(sel, COLUMN_MATCH, Text::toT(dlg.userMatch).c_str());
				ctrlAutoSearch.SetItemData(sel, (LPARAM)asNew.get());
			}
		}
	}
	return 0;
}
Ejemplo n.º 7
0
void AutoSearchFrame::ItemInfo::update(const AutoSearchPtr& as) {
	string target = as->getTarget();
	if (target.empty()) {
		target = CSTRING(SETTINGS_DOWNLOAD_DIRECTORY);
	}

	columns[COLUMN_VALUE] = Text::toT(as->getDisplayName());
	columns[COLUMN_LASTSEARCH] = (as->getLastSearch() > 0 ? formatSearchDate(as->getLastSearch()) : _T("Unknown"));
	columns[COLUMN_TYPE] = Text::toT(as->getDisplayType());
	columns[COLUMN_BUNDLES] = Text::toT(AutoSearchManager::getInstance()->getBundleStatuses(as));
	columns[COLUMN_SEARCH_STATUS] = Text::toT(as->getSearchingStatus());
	columns[COLUMN_EXPIRATION] = Text::toT(as->getExpiration());
	columns[COLUMN_ERROR] = Text::toT(as->getLastError());
	columns[COLUMN_ACTION] = as->getAction() == 0 ? TSTRING(DOWNLOAD) : as->getAction() == 1 ? TSTRING(ADD_TO_QUEUE) : TSTRING(AS_REPORT);
	columns[COLUMN_EXPIRATION] = Text::toT(as->getExpiration());
	columns[COLUMN_REMOVE] = as->getRemove() ? TSTRING(YES) : TSTRING(NO);
	columns[COLUMN_PATH] = Text::toT(target);
	columns[COLUMN_USERMATCH] = Text::toT(as->getNickPattern());

	setGroupId(AutoSearchManager::getInstance()->getGroupIndex(as));

}
Ejemplo n.º 8
0
void AutoSearchFrame::on(AutoSearchManagerListener::SearchForeground, const AutoSearchPtr& as, const string& searchString) noexcept {
	callAsync([=] { SearchFrame::openWindow(Text::toT(searchString), 0, Search::SIZE_DONTCARE, as->getFileType()); });
}