📄 downloadlistctrl.cpp
字号:
RemoveFile(selectedList.GetHead());
selectedList.RemoveHead();
break;
case PS_PAUSED:
selectedList.GetHead()->DeleteFile();
selectedList.RemoveHead();
break;
default:
theApp.downloadqueue->StartNextFileIfPrefs(selectedList.GetHead()->GetCategory());
selectedList.GetHead()->DeleteFile();
selectedList.RemoveHead();
}
}
}
SetRedraw(true);
}
break;
}
case MP_PRIOHIGH:
SetRedraw(false);
while (!selectedList.IsEmpty()){
CPartFile* partfile = selectedList.GetHead();
partfile->SetAutoDownPriority(false);
partfile->SetDownPriority(PR_HIGH);
selectedList.RemoveHead();
}
SetRedraw(true);
break;
case MP_PRIOLOW:
SetRedraw(false);
while (!selectedList.IsEmpty()){
CPartFile* partfile = selectedList.GetHead();
partfile->SetAutoDownPriority(false);
partfile->SetDownPriority(PR_LOW);
selectedList.RemoveHead();
}
SetRedraw(true);
break;
case MP_PRIONORMAL:
SetRedraw(false);
while (!selectedList.IsEmpty()){
CPartFile* partfile = selectedList.GetHead();
partfile->SetAutoDownPriority(false);
partfile->SetDownPriority(PR_NORMAL);
selectedList.RemoveHead();
}
SetRedraw(true);
break;
case MP_PRIOAUTO:
SetRedraw(false);
while (!selectedList.IsEmpty()){
CPartFile* partfile = selectedList.GetHead();
partfile->SetAutoDownPriority(true);
partfile->SetDownPriority(PR_HIGH);
selectedList.RemoveHead();
}
SetRedraw(true);
break;
case MP_PAUSE:
SetRedraw(false);
while (!selectedList.IsEmpty()){
CPartFile* partfile = selectedList.GetHead();
if (partfile->CanPauseFile())
partfile->PauseFile();
selectedList.RemoveHead();
}
SetRedraw(true);
break;
case MP_RESUME:
SetRedraw(false);
while (!selectedList.IsEmpty()){
CPartFile* partfile = selectedList.GetHead();
if (partfile->CanResumeFile()){
if (partfile->GetStatus() == PS_INSUFFICIENT)
partfile->ResumeFileInsufficient();
else
partfile->ResumeFile();
}
selectedList.RemoveHead();
}
SetRedraw(true);
break;
case MP_STOP:
SetRedraw(false);
while (!selectedList.IsEmpty()){
CPartFile *partfile = selectedList.GetHead();
if (partfile->CanStopFile()){
HideSources(partfile);
partfile->StopFile();
}
selectedList.RemoveHead();
}
SetRedraw(true);
break;
case MP_CLEARCOMPLETED:
SetRedraw(false);
ClearCompleted();
SetRedraw(true);
break;
case MP_ALL_A4AF_AUTO:
file->SetA4AFAuto(!file->IsA4AFAuto());
break;
case MPG_F2:
if (file->GetStatus() != PS_COMPLETE && file->GetStatus() != PS_COMPLETING)
{
InputBox inputbox;
CString title = GetResString(IDS_RENAME);
title.Remove(_T('&'));
inputbox.SetLabels(title, GetResString(IDS_DL_FILENAME), file->GetFileName());
inputbox.SetEditFilenameMode();
if (inputbox.DoModal()==IDOK && !inputbox.GetInput().IsEmpty() && IsValidEd2kString(inputbox.GetInput()))
{
file->SetFileName(inputbox.GetInput(), true);
file->UpdateDisplayedInfo();
file->SavePartFile();
}
}
else
MessageBeep((UINT)-1);
break;
case MPG_ALTENTER:
case MP_METINFO:
ShowFileDialog(NULL, INP_NONE);
break;
case MP_COPYSELECTED:
case MP_GETED2KLINK:{
CString str;
while (!selectedList.IsEmpty()){
if (!str.IsEmpty())
str += _T("\r\n");
str += CreateED2kLink(selectedList.GetHead());
selectedList.RemoveHead();
}
theApp.CopyTextToClipboard(str);
break;
}
case MP_OPEN:
if(selectedCount > 1)
break;
file->OpenFile();
break;
case MP_TRY_TO_GET_PREVIEW_PARTS:{
if(selectedCount > 1)
break;
file->SetPreviewPrio(!file->GetPreviewPrio());
break;
}
case MP_PREVIEW:{
if(selectedCount > 1)
break;
file->PreviewFile();
break;
}
case MP_VIEWFILECOMMENTS:
ShowFileDialog(NULL, INP_COMMENTPAGE);
break;
case MP_SHOWED2KLINK:
ShowFileDialog(NULL, INP_LINKPAGE);
break;
case MP_ADDSOURCE:
{
if(selectedCount > 1)
break;
CAddSourceDlg as;
as.SetFile(file);
as.DoModal();
break;
}
default:
if (wParam>=MP_WEBURL && wParam<=MP_WEBURL+99){
theWebServices.RunURL(file, wParam);
}
else if (wParam>=MP_ASSIGNCAT && wParam<=MP_ASSIGNCAT+99){
SetRedraw(FALSE);
while (!selectedList.IsEmpty()){
CPartFile *partfile = selectedList.GetHead();
partfile->SetCategory(wParam - MP_ASSIGNCAT);
partfile->UpdateDisplayedInfo(true);
selectedList.RemoveHead();
}
SetRedraw(TRUE);
ChangeCategory(curTab);
}
else if (wParam>=MP_PREVIEW_APP_MIN && wParam<=MP_PREVIEW_APP_MAX){
thePreviewApps.RunApp(file, wParam);
}
break;
case MP_SHOWMPAGE:
CUpDownClient* client = (CUpDownClient*)GetItemData(iSel);
char *pdest1;
char *pdest2;
int result;
CString Start;
pdest1 = strstr( client->GetUserName(), "VeryCD:" );
if(strstr( pdest1, "]" ))
{
pdest2 = strstr( pdest1, "]" );
result = (int)(pdest2 - pdest1 - 7);
Start = pdest1;
Start = Start.Mid(7,result);
CString temp = "http://www.VeryCD.com/" + Start;
ShellOpenFile(temp);
}
break;
}
}
else{
CUpDownClient* client = (CUpDownClient*)content->value;
CPartFile* file = (CPartFile*)content->owner; // added by sivka
switch (wParam){
case MP_SHOWLIST:
client->RequestSharedFileList();
break;
case MP_MESSAGE:
theApp.emuledlg->chatwnd->StartSession(client);
break;
case MP_ADDFRIEND:
if (theApp.friendlist->AddFriend(client))
UpdateItem(client);
break;
case MPG_ALTENTER:
case MP_DETAIL:{
CClientDetailDialog dialog(client);
dialog.DoModal();
break;
}
case MP_BOOT:
if (client->GetKadPort())
Kademlia::CKademlia::bootstrap(ntohl(client->GetIP()), client->GetKadPort());
break;
// ZZ:DownloadManager -->
case MP_A4AF_CHECK_THIS_NOW:
if (file->GetStatus(false) == PS_READY || file->GetStatus(false) == PS_EMPTY)
{
if (client->GetDownloadState() != DS_DOWNLOADING)
{
client->SwapToAnotherFile(_T("Manual init of source check. Test to be like ProcessA4AFClients(). CDownloadListCtrl::OnCommand() MP_SWAP_A4AF_DEBUG_THIS"), false, false, false, NULL, true, true, true); // ZZ:DownloadManager
UpdateItem(file);
}
}
break;
// <-- ZZ:DownloadManager
}
}
}
else /*nothing selected*/
{
switch (wParam){
case MP_CLEARCOMPLETED:
ClearCompleted();
break;
}
}
return TRUE;
}
void CDownloadListCtrl::OnColumnClick( NMHDR* pNMHDR, LRESULT* pResult){
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// Barry - Store sort order in preferences
// Determine ascending based on whether already sorted on this column
int sortItem = thePrefs.GetColumnSortItem(CPreferences::tableDownload);
bool m_oldSortAscending = thePrefs.GetColumnSortAscending(CPreferences::tableDownload);
if (sortItem==9) {
m_bRemainSort=(sortItem != pNMListView->iSubItem) ? false : (m_oldSortAscending?m_bRemainSort:!m_bRemainSort);
}
bool sortAscending = (sortItem != pNMListView->iSubItem) ? true : !m_oldSortAscending;
// Item is column clicked
sortItem = pNMListView->iSubItem;
// Save new preferences
thePrefs.SetColumnSortItem(CPreferences::tableDownload, sortItem);
thePrefs.SetColumnSortAscending(CPreferences::tableDownload, sortAscending);
thePrefs.TransferlistRemainSortStyle(m_bRemainSort);
// Sort table
uint8 adder=0;
if (sortItem!=9 || !m_bRemainSort)
SetSortArrow(sortItem, sortAscending);
else {
SetSortArrow(sortItem, sortAscending?arrowDoubleUp : arrowDoubleDown);
adder=81;
}
SortItems(SortProc, sortItem + (sortAscending ? 0:100) + adder );
*pResult = 0;
}
int CDownloadListCtrl::SortProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort){
CtrlItem_Struct* item1 = (CtrlItem_Struct*)lParam1;
CtrlItem_Struct* item2 = (CtrlItem_Struct*)lParam2;
int sortMod = 1;
if(lParamSort >= 100) {
sortMod = -1;
lParamSort -= 100;
}
int comp;
if(item1->type == FILE_TYPE && item2->type != FILE_TYPE) {
if(item1->value == item2->parent->value)
return -1;
comp = Compare((CPartFile*)item1->value, (CPartFile*)(item2->parent->value), lParamSort);
} else if(item2->type == FILE_TYPE && item1->type != FILE_TYPE) {
if(item1->parent->value == item2->value)
return 1;
comp = Compare((CPartFile*)(item1->parent->value), (CPartFile*)item2->value, lParamSort);
} else if (item1->type == FILE_TYPE) {
CPartFile* file1 = (CPartFile*)item1->value;
CPartFile* file2 = (CPartFile*)item2->value;
comp = Compare(file1, file2, lParamSort);
} else {
comp = Compare((CPartFile*)(item1->parent->value), (CPartFile*)(item2->parent->value), lParamSort);
if(comp != 0)
return sortMod * comp;
if (item1->type != item2->type)
return item1->type - item2->type;
CUpDownClient* client1 = (CUpDownClient*)item1->value;
CUpDownClient* client2 = (CUpDownClient*)item2->value;
comp = Compare(client1, client2, lParamSort,sortMod);
}
return sortMod * comp;
}
void CDownloadListCtrl::ClearCompleted(bool ignorecats){
// Search for completed file(s)
for(ListItems::iterator it = m_ListItems.begin(); it != m_ListItems.end(); ){
CtrlItem_Struct* cur_item = it->second;
it++; // Already point to the next iterator.
if(cur_item->type == FILE_TYPE){
CPartFile* file = reinterpret_cast<CPartFile*>(cur_item->value);
if(file->IsPartFile() == false && (file->CheckShowItemInGivenCat(curTab) || ignorecats) ){
if (RemoveFile(file))
it = m_ListItems.begin();
}
}
}
}
void CDownloadListCtrl::ClearCompleted(const CPartFile* pFile)
{
if (!pFile->IsPartFile())
{
for (ListItems::iterator it = m_ListItems.begin(); it != m_ListItems.end(); )
{
CtrlItem_Struct* cur_item = it->second;
it++;
if (cur_item->type == FILE_TYPE)
{
const CPartFile* pCurFile = reinterpret_cast<CPartFile*>(cur_item->value);
if (pCurFile == pFile)
{
RemoveFile(pCurFile);
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -