void GUI::openDoc() { int i = -1; while ((i = table->getNext(i, LVNI_SELECTED)) != -1) { auto data = table->getData(i); if (data) { const string& ADC_Doc = "http://adc.sourceforge.net/ADC.html"; const string& NMDC_Doc = "http://nmdc.sourceforge.net/NMDC.html"; const string& UDP_Doc = "https://en.wikipedia.org/wiki/User_Datagram_Protocol"; auto& item = *reinterpret_cast<Item*>(data); auto isAdc = item.protocol == Util::toT("ADC"); auto isNmdc = item.protocol == Util::toT("NMDC"); auto openLink = [](const string& doc) { ::ShellExecute(0, 0, Util::toT(doc).c_str(), 0, 0, SW_SHOW); }; if (isAdc) { openLink(ADC_Doc); } else if (isNmdc) { openLink(NMDC_Doc); } else { openLink(UDP_Doc); } } } }
void GUI::remove() { util::HoldRedraw hold(table); int i; while((i = table->getNext(-1, LVNI_SELECTED)) != -1) { auto data = table->getData(i); table->erase(i); if(data) { delete reinterpret_cast<Item*>(data); } } }
void GUI::copy() { tstring str; int i = -1; while((i = table->getNext(i, LVNI_SELECTED)) != -1) { auto data = table->getData(i); if(data) { auto& item = *reinterpret_cast<Item*>(data); if(!str.empty()) { str += _T("\r\n"); } str += item.index + _T(" [") + item.dir + _T("] ") + _T(" [") + item.protocol + _T("] ") + item.ip + _T(":") + item.port + _T(" (") + item.peer + _T("): ") + item.message; } } dwt::Clipboard::setData(str, window); }
void GUI::clear() { std::vector<Item*> toDelete; for(size_t i = 0, n = table->size(); i < n; ++i) { auto data = table->getData(i); if(data) { toDelete.push_back(reinterpret_cast<Item*>(data)); } } table->clear(); counter = 0; for(auto item: toDelete) { delete item; } filterW->clear(); filter.clear(); filterSel.clear(); initFilter(); }