void CCommentDialogLst::UpdateList() { int count = 0; ClearList(); FileRatingList list; m_file->GetRatingAndComments(list); for (FileRatingList::const_iterator it = list.begin(); it != list.end(); ++it) { if (!thePrefs::IsCommentFiltered(it->Comment)) { m_list->InsertItem(count, it->UserName); m_list->SetItem(count, 1, it->FileName); m_list->SetItem(count, 2, (it->Rating != -1) ? GetRateString(it->Rating) : wxString(wxT("on"))); m_list->SetItem(count, 3, it->Comment); m_list->SetItemPtrData(count, reinterpret_cast<wxUIntPtr>(new SFileRating(*it))); ++count; } } wxString info; if (count == 0) { info = _("No comments"); } else { info = CFormat(wxPLURAL("%u comment", "%u comments", count)) % count; } FindWindow(IDC_CMSTATUS)->SetLabel(info); FindWindow(IDC_CMSTATUS)->GetParent()->Layout(); m_file->UpdateFileRatingCommentAvail(); }
CString GetValue(const CTag* pTag) { CString strValue; if (pTag->IsStr()) strValue = pTag->GetStr(); else if (pTag->IsInt()) { if (pTag->GetNameID() == FT_MEDIA_LENGTH || pTag->GetNameID() == FT_LASTSEENCOMPLETE) SecToTimeLength(pTag->GetInt(), strValue); else if (pTag->GetNameID() == FT_FILERATING) strValue = GetRateString(pTag->GetInt()); else if (pTag->GetNameID() == 0x10 || pTag->GetNameID() >= 0xFA) strValue.Format(_T("%u"), pTag->GetInt()); else strValue = GetFormatedUInt(pTag->GetInt()); } else if (pTag->IsFloat()) strValue.Format(_T("%f"), pTag->GetFloat()); else if (pTag->IsHash()) strValue = md4str(pTag->GetHash()); else if (pTag->IsInt64(false)) strValue = GetFormatedUInt64(pTag->GetInt64()); else strValue.Format(_T("<Unknown value of type 0x%02X>"), pTag->GetType()); return strValue; }
void CCommentListCtrl::AddItem(CUpDownClient* client) { LVFINDINFO find; find.flags = LVFI_PARAM; find.lParam = (LPARAM)client; int iItem = FindItem(&find); if (iItem == -1) { //Do not try to access the client object after inserting this item. //It is possible that the object is deleted. int index = InsertItem(LVIF_TEXT|LVIF_PARAM,0,client->GetUserName(),0,0,1,(LPARAM)client); SetItemText(index, 1, client->GetClientFilename()); SetItemText(index, 2, GetRateString(client->GetFileRating())); SetItemText(index, 3, client->GetFileComment()); } }
void CCommentListCtrl::AddItem(Kademlia::CEntry* entry) { LVFINDINFO find; find.flags = LVFI_PARAM; find.lParam = (LPARAM)entry; int iItem = FindItem(&find); if (iItem == -1) { //Do not try to access the entry object after inserting this item. //It is possible that the object is deleted. int index = InsertItem(LVIF_TEXT|LVIF_PARAM,0,(LPCTSTR)"",0,0,1,(LPARAM)entry); SetItemText(index, 1, entry->fileName); SetItemText(index, 2, GetRateString(entry->GetIntTagValue(TAG_FILERATING))); SetItemText(index, 3, entry->GetStrTagValue(TAG_DESCRIPTION)); } }
CString GetValue(const Kademlia::CKadTag* pTag) // FIXME LARGE FILES { CString strValue; if (pTag->IsStr()) strValue = pTag->GetStr(); else if (pTag->IsInt()) { if (pTag->m_name.Compare(TAG_MEDIA_LENGTH) == 0) SecToTimeLength((unsigned long)pTag->GetInt(), strValue); else if (pTag->m_name.Compare(TAG_FILERATING) == 0) strValue = GetRateString((UINT)pTag->GetInt()); else if ((BYTE)pTag->m_name[0] == 0x10 || (BYTE)pTag->m_name[0] >= 0xFA) strValue.Format(_T("%u"), pTag->GetInt()); else strValue = GetFormatedUInt((UINT)pTag->GetInt()); } else if (pTag->m_type == 4) strValue.Format(_T("%f"), pTag->GetFloat()); else if (pTag->m_type == 5) strValue.Format(_T("%u"), pTag->GetInt()); else strValue.Format(_T("<Unknown value of type 0x%02X>"), pTag->m_type); return strValue; }