예제 #1
0
void TagEditOrCloneAction::run() {
	shared_ptr<ZLDialog> dialog = ZLDialogManager::Instance().createDialog(ZLResourceKey(resourceKeyName()));

	TagList tags;
	BooksUtil::collectTagsFromLibrary(tags);
	std::vector<std::string> names;
	for (TagList::const_iterator it = tags.begin(); it != tags.end(); ++it) {
		if (!it->isNull()) {
			names.push_back((*it)->fullName());
		}
	}
	TagNameEntry *tagNameEntry = new TagNameEntry(names, myTag->fullName());
	dialog->addOption(ZLResourceKey("name"), tagNameEntry);

	TagIncludeSubtagsEntry *includeSubtagsEntry = new TagIncludeSubtagsEntry();
	const Library &library = Library::Instance();
	if (library.hasSubtags(myTag)) {
		if (!library.hasBooks(myTag)) {
			includeSubtagsEntry->setActive(false);
		}
		dialog->addOption(ZLResourceKey("includeSubtags"), includeSubtagsEntry);
	}

	dialog->addButton(ZLDialogManager::OK_BUTTON, true);
	dialog->addButton(ZLDialogManager::CANCEL_BUTTON, false);

	if (dialog->run()) {
		dialog->acceptValues();
		onAccept(tagNameEntry->initialValue(), includeSubtagsEntry->initialState());
	}
}
예제 #2
0
파일: ECTag.cpp 프로젝트: StrongZhu/amule
void CECTag::DebugPrint(int level, bool print_empty) const
{
	if (m_dataLen || print_empty) {
		wxString space;
		for (int i = level; i--;) space += wxT("  ");
		wxString s1 = CFormat(wxT("%s%s %d = ")) % space % GetDebugNameECTagNames(m_tagName) % m_dataLen;
		wxString s2;
		switch (m_tagName) {
			case EC_TAG_DETAIL_LEVEL:
				s2 = GetDebugNameEC_DETAIL_LEVEL(GetInt()); break;
			case EC_TAG_SEARCH_TYPE:
				s2 = GetDebugNameEC_SEARCH_TYPE(GetInt()); break;
			case EC_TAG_STAT_VALUE_TYPE:
				s2 = GetDebugNameEC_STATTREE_NODE_VALUE_TYPE(GetInt()); break;
			default:
				switch (m_dataType) {
					case EC_TAGTYPE_UINT8:
					case EC_TAGTYPE_UINT16:
					case EC_TAGTYPE_UINT32:
					case EC_TAGTYPE_UINT64:
						s2 = CFormat(wxT("%d")) % GetInt(); break;
					case EC_TAGTYPE_STRING:
						s2 = GetStringData(); break;
					case EC_TAGTYPE_DOUBLE:
						s2 = CFormat(wxT("%.1f")) % GetDoubleData(); break;
					case EC_TAGTYPE_HASH16:
						s2 = GetMD4Data().Encode(); break;
					case EC_TAGTYPE_UINT128:
						// Using any non-inline function from UInt128.h would break linkage
						// of remote apps otherwise not using CUInt128. So just fall through
						// and display the value as a byte-stream. Since the value is sent
						// big-endian on the network, the visual result is correct, except
						// for the intervening spaces...
						//s2 = GetInt128Data().ToHexString(); break;
					case EC_TAGTYPE_CUSTOM:
						if (m_dataLen == 0) {
							s2 = wxT("empty");
						} else {
							// Make a hex dump (limited to maxOutput)
							const uint32 maxOutput = 50;
							for (uint32 i = 0; i < m_dataLen; i++) {
								if (i == maxOutput) {
									s2 += wxT("...");
									break;
								}
								s2 += CFormat(wxT("%02X ")) % (unsigned char) m_tagData[i];
							}
						}
						break;
					default:
						s2 = GetDebugNameECTagTypes(m_dataType);
				}
		}
		DoECLogLine(s1 + s2);
	}
	for (TagList::const_iterator it = m_tagList.begin(); it != m_tagList.end(); ++it) {
		it->DebugPrint(level + 1, true);
	}
}
예제 #3
0
void CECTag::DebugPrint(int level, bool print_empty) const
{
	if (m_dataLen || print_empty) {
		wxString space;
		for (int i = level; i--;) space += wxT("  ");
		wxString s1 = CFormat(wxT("%s%s %d = ")) % space % GetDebugNameECTagNames(m_tagName) % m_dataLen;
		wxString s2;
		switch (m_tagName) {
			case EC_TAG_DETAIL_LEVEL:
				s2 = GetDebugNameEC_DETAIL_LEVEL(GetInt()); break;
			case EC_TAG_SEARCH_TYPE:
				s2 = GetDebugNameEC_SEARCH_TYPE(GetInt()); break;
			case EC_TAG_STAT_VALUE_TYPE:
				s2 = GetDebugNameEC_STATTREE_NODE_VALUE_TYPE(GetInt()); break;
			default:
				switch (m_dataType) {
					case EC_TAGTYPE_UINT8:
					case EC_TAGTYPE_UINT16:
					case EC_TAGTYPE_UINT32:
					case EC_TAGTYPE_UINT64:
						s2 = CFormat(wxT("%d")) % GetInt(); break;
					case EC_TAGTYPE_STRING:
						s2 = GetStringData(); break;
					case EC_TAGTYPE_DOUBLE:
						s2 = CFormat(wxT("%.1f")) % GetDoubleData(); break;
					case EC_TAGTYPE_HASH16:
						s2 = GetMD4Data().Encode(); break;
					case EC_TAGTYPE_CUSTOM:
						if (m_dataLen == 0) {
							s2 = wxT("empty");
						} else {
							// Make a hex dump (limited to maxOutput)
							const uint32 maxOutput = 50;
							for (uint32 i = 0; i < m_dataLen; i++) {
								if (i == maxOutput) {
									s2 += wxT("...");
									break;
								}
								s2 += CFormat(wxT("%02X ")) % (unsigned char) m_tagData[i];
							}
						}
						break;
					default:
						s2 = GetDebugNameECTagTypes(m_dataType);
				}
		}
		DoECLogLine(s1 + s2);
	}
	for (TagList::const_iterator it = m_tagList.begin(); it != m_tagList.end(); ++it) {
		it->DebugPrint(level + 1, true);
	}
}