📄 transferwnd.cpp
字号:
m_nLastCatTT=-1;
theApp.downloadqueue->ResetCatParts(rightclickindex);
thePrefs.RemoveCat(rightclickindex);
m_dlTab.DeleteItem(rightclickindex);
m_dlTab.SetCurSel(0);
downloadlistctrl.ChangeCategory(0);
thePrefs.SaveCats();
if (thePrefs.GetCatCount()==1) thePrefs.SetAllcatType(0);
theApp.emuledlg->searchwnd->UpdateCatTabs();
VerifyCatTabSize();
break;
}
// ZZ:DownloadManager -->
case MP_PRIOLOW: {
thePrefs.GetCategory(rightclickindex)->prio = PR_LOW;
//CString csName;
//csName.Format(_T("%s"), thePrefs.GetCategory(rightclickindex)->title );
//EditCatTabLabel(rightclickindex,csName);
//theApp.emuledlg->searchwnd->UpdateCatTabs();
thePrefs.SaveCats();
break;
}
case MP_PRIONORMAL: {
thePrefs.GetCategory(rightclickindex)->prio = PR_NORMAL;
//CString csName;
//csName.Format(_T("%s"), thePrefs.GetCategory(rightclickindex)->title );
//EditCatTabLabel(rightclickindex,csName);
//theApp.emuledlg->searchwnd->UpdateCatTabs();
thePrefs.SaveCats();
break;
}
case MP_PRIOHIGH: {
thePrefs.GetCategory(rightclickindex)->prio = PR_HIGH;
//CString csName;
//csName.Format(_T("%s"), thePrefs.GetCategory(rightclickindex)->title );
//EditCatTabLabel(rightclickindex,csName);
//theApp.emuledlg->searchwnd->UpdateCatTabs();
thePrefs.SaveCats();
break;
}
// <-- ZZ:DownloadManager
case MP_PAUSE: {
theApp.downloadqueue->SetCatStatus(rightclickindex,MP_PAUSE);
break;
}
case MP_STOP : {
theApp.downloadqueue->SetCatStatus(rightclickindex,MP_STOP);
break;
}
case MP_CANCEL: {
if (AfxMessageBox(GetResString(IDS_Q_CANCELDL),MB_ICONQUESTION|MB_YESNO) == IDYES)
theApp.downloadqueue->SetCatStatus(rightclickindex,MP_CANCEL);
break;
}
case MP_RESUME: {
theApp.downloadqueue->SetCatStatus(rightclickindex,MP_RESUME);
break;
}
case MP_RESUMENEXT: {
theApp.downloadqueue->StartNextFile(rightclickindex,false);
break;
}
// ZZ:DownloadManager -->
case MP_DOWNLOAD_ALPHABETICAL: {
BOOL newSetting = !thePrefs.GetCategory(rightclickindex)->downloadInAlphabeticalOrder;
thePrefs.GetCategory(rightclickindex)->downloadInAlphabeticalOrder = newSetting;
thePrefs.SaveCats();
if(newSetting) {
// any auto prio files will be set to normal now.
theApp.downloadqueue->RemoveAutoPrioInCat(rightclickindex, PR_NORMAL);
}
break;
}
// <-- ZZ:DownloadManager
case IDC_UPLOAD_ICO: {
SwitchUploadList();
break;
}
case IDC_QUEUE_REFRESH_BUTTON: {
OnBnClickedQueueRefreshButton();
break;
}
}
return TRUE;
}
void CTransferWnd::UpdateCatTabTitles(bool force) {
CPoint pt;
::GetCursorPos(&pt);
if (!force && GetTabUnderMouse(&pt)!=-1) // avoid cat tooltip jumping
return;
for (uint8 i=0;i<m_dlTab.GetItemCount();i++)
EditCatTabLabel(i,(i==0)? GetCatTitle( thePrefs.GetAllcatType() ):thePrefs.GetCategory(i)->title);
}
void CTransferWnd::EditCatTabLabel(int index,CString newlabel) {
TCITEM tabitem;
tabitem.mask = TCIF_PARAM;
m_dlTab.GetItem(index,&tabitem);
tabitem.mask = TCIF_TEXT;
newlabel.Replace(_T("&"),_T("&&"));
int count,dwl;
// ZZ:DownloadManager -->
//CString prioStr;
//switch(thePrefs.GetCategory(index)->prio) {
// case PR_LOW:
// prioStr = _T(" ") + GetResString(IDS_PR_SHORT_LOW);
// break;
// case PR_HIGH:
// prioStr = _T(" ") + GetResString(IDS_PR_SHORT_HIGH);
// break;
// default:
// prioStr = _T("");
// break;
//}
// <-- ZZ:DownloadManager
if (thePrefs.ShowCatTabInfos()) {
CPartFile* cur_file;
count=dwl=0;
for (int i=0;i<theApp.downloadqueue->GetFileCount();i++) {
cur_file=theApp.downloadqueue->GetFileByIndex(i);
if (cur_file==0) continue;
if (cur_file->CheckShowItemInGivenCat(index)) {
if (cur_file->GetTransferingSrcCount()>0) ++dwl;
}
}
CString title=newlabel;
int compl= theApp.emuledlg->transferwnd->downloadlistctrl.GetCompleteDownloads(index,count);
newlabel.Format(_T("%s %i/%i"),title,dwl,count); // ZZ:DownloadManager
//newlabel.Format(_T("%s%s %i/%i"),title, prioStr,dwl,count); // ZZ:DownloadManager
// ZZ:DownloadManager -->
//} else {
// newlabel += prioStr;
// <-- ZZ:DownloadManager
}
tabitem.pszText = newlabel.LockBuffer();
m_dlTab.SetItem(index,&tabitem);
newlabel.UnlockBuffer();
VerifyCatTabSize();
}
int CTransferWnd::AddCategorie(CString newtitle,CString newincoming,CString newcomment, CString newautocat, bool addTab){
Category_Struct* newcat=new Category_Struct;
_stprintf(newcat->title,newtitle);
newcat->prio=PR_NORMAL; // ZZ:DownloadManager
_stprintf(newcat->incomingpath,newincoming);
_stprintf(newcat->comment,newcomment);
newcat->autocat=newautocat;
newcat->downloadInAlphabeticalOrder = FALSE; // ZZ:DownloadManager
int index=thePrefs.AddCat(newcat);
if (addTab) m_dlTab.InsertItem(index,newtitle);
VerifyCatTabSize();
return index;
}
int CTransferWnd::GetTabUnderMouse(CPoint* point) {
TCHITTESTINFO hitinfo;
CRect rect;
m_dlTab.GetWindowRect(&rect);
point->Offset(0-rect.left,0-rect.top);
hitinfo.pt = *point;
if( m_dlTab.GetItemRect( 0, &rect ) )
if (hitinfo.pt.y< rect.top+30 && hitinfo.pt.y >rect.top-30)
hitinfo.pt.y = rect.top;
// Find the destination tab...
unsigned int nTab = m_dlTab.HitTest( &hitinfo );
if( hitinfo.flags != TCHT_NOWHERE )
return nTab;
else return -1;
}
void CTransferWnd::OnLvnKeydownDownloadlist(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
if (downloadlistctrl.GetSelectionMark()!=-1) {
uint8 action=EXPAND_COLLAPSE;
if (pLVKeyDow->wVKey==VK_ADD || pLVKeyDow->wVKey==VK_RIGHT) action=EXPAND_ONLY;
else if ( pLVKeyDow->wVKey==VK_SUBTRACT || pLVKeyDow->wVKey==VK_LEFT ) action=COLLAPSE_ONLY;
if (action<EXPAND_COLLAPSE) downloadlistctrl.ExpandCollapseItem(downloadlistctrl.GetSelectionMark(),action,true);
}
*pResult = 0;
}
void CTransferWnd::UpdateTabToolTips(int tab)
{
uint8 i;
if (tab==-1) {
for (i=0;i<m_tooltipCats.GetToolCount();i++)
m_tooltipCats.DelTool(&m_dlTab,i+1);
for (i = 0; i < m_dlTab.GetItemCount(); i++)
{
CRect r;
m_dlTab.GetItemRect(i, &r);
VERIFY(m_tooltipCats.AddTool(&m_dlTab, GetTabStatistic(i), &r, i+1));
}
} else {
CRect r;
m_dlTab.GetItemRect(tab, &r);
m_tooltipCats.DelTool(&m_dlTab,tab+1);
VERIFY(m_tooltipCats.AddTool(&m_dlTab, GetTabStatistic(tab), &r, tab+1));
}
}
CString CTransferWnd::GetTabStatistic(uint8 tab) {
uint16 count,dwl,err,compl,paus;
count=dwl=err=compl=paus=0;
float speed=0;
uint64 size=0;
uint64 trsize=0;
uint64 disksize=0;
CPartFile* cur_file;
for (int i=0;i<theApp.downloadqueue->GetFileCount();++i) {
cur_file=theApp.downloadqueue->GetFileByIndex(i);
if (cur_file==0) continue;
if (cur_file->CheckShowItemInGivenCat(tab)) {
count++;
if (cur_file->GetTransferingSrcCount()>0) ++dwl;
speed+=cur_file->GetDatarate()/1024.0f;
size+=cur_file->GetFileSize();
trsize+=cur_file->GetCompletedSize();
disksize+=cur_file->GetRealFileSize();
if (cur_file->GetStatus()==PS_ERROR) ++err;
if (cur_file->GetStatus()==PS_PAUSED) ++paus;
}
}
int total;
compl=theApp.emuledlg->transferwnd->downloadlistctrl.GetCompleteDownloads(tab,total);
// ZZ:DownloadManager -->
CString prio;
switch(thePrefs.GetCategory(tab)->prio) {
case PR_LOW:
prio = GetResString(IDS_PRIOLOW);
break;
case PR_HIGH:
prio = GetResString(IDS_PRIOHIGH);
break;
default:
prio = GetResString(IDS_PRIONORMAL);
break;
}
// ZZ:DownloadManager <--
CString title;
title.Format(_T("%s: %i\n\n%s: %i\n%s: %i\n%s: %i\n%s: %i\n\n%s: %s\n\n%s: %.1f %s\n%s: %s/%s\n%s%s"), // ZZ:DownloadManager
GetResString(IDS_FILES), count+compl,
GetResString(IDS_DOWNLOADING), dwl,
GetResString(IDS_PAUSED) ,paus,
GetResString(IDS_ERRORLIKE) ,err,
GetResString(IDS_DL_TRANSFCOMPL) ,compl,
GetResString(IDS_PRIORITY), prio, // ZZ:DownloadManager
GetResString(IDS_DL_SPEED) ,speed,GetResString(IDS_KBYTESEC),
GetResString(IDS_DL_SIZE),CastItoXBytes(trsize, false, false),CastItoXBytes(size, false, false),
GetResString(IDS_ONDISK),CastItoXBytes(disksize, false, false));
return title;
}
void CTransferWnd::OnDblclickDltab(){
POINT point;
::GetCursorPos(&point);
CPoint pt(point);
int tab=GetTabUnderMouse(&pt);
if (tab<1) return;
rightclickindex=tab;
OnCommand(MP_CAT_EDIT,0);
}
void CTransferWnd::OnTabMovement(NMHDR *pNMHDR, LRESULT *pResult) {
UINT from=m_dlTab.GetLastMovementSource();
UINT to=m_dlTab.GetLastMovementDestionation();
if (from==0 || to==0 || from==to-1) return;
// do the reorder
// rearrange the cat-map
if (!thePrefs.MoveCat(from,to)) return;
// update partfile-stored assignment
theApp.downloadqueue->MoveCat((uint8)from,(uint8)to);
// move category of completed files
downloadlistctrl.MoveCompletedfilesCat((uint8)from,(uint8)to);
// of the tabcontrol itself
m_dlTab.ReorderTab(from,to);
UpdateCatTabTitles();
theApp.emuledlg->searchwnd->UpdateCatTabs();
if (to>from) --to;
m_dlTab.SetCurSel(to);
downloadlistctrl.ChangeCategory(to);
}
void CTransferWnd::VerifyCatTabSize() {
CRect rect;
int size=0;
int right;
for (int i=0;i<m_dlTab.GetItemCount();i++) {
m_dlTab.GetItemRect(i,&rect);
size+= rect.Width();
}
size+=20;
WINDOWPLACEMENT wpTabWinPos;
downloadlistctrl.GetWindowPlacement(&wpTabWinPos);
right=wpTabWinPos.rcNormalPosition.right;
m_dlTab.GetWindowPlacement(&wpTabWinPos);
if (wpTabWinPos.rcNormalPosition.right<0) return;
wpTabWinPos.rcNormalPosition.right=right;
int left=wpTabWinPos.rcNormalPosition.right-size;
if (left<200) left=200;
wpTabWinPos.rcNormalPosition.left=left;
RemoveAnchor(m_dlTab);
m_dlTab.SetWindowPlacement(&wpTabWinPos);
AddAnchor(m_dlTab,TOP_RIGHT);
}
CString CTransferWnd::GetCatTitle(int catid)
{
switch (catid) {
case 0 : return GetResString(IDS_ALL);
case 1 : return GetResString(IDS_ALLOTHERS);
case 2 : return GetResString(IDS_STATUS_NOTCOMPLETED);
case 3 : return GetResString(IDS_DL_TRANSFCOMPL);
case 4 : return GetResString(IDS_WAITING);
case 5 : return GetResString(IDS_DOWNLOADING);
case 6 : return GetResString(IDS_ERRORLIKE);
case 7 : return GetResString(IDS_PAUSED);
case 8 : return GetResString(IDS_STOPPED);
case 10 : return GetResString(IDS_VIDEO);
case 11 : return GetResString(IDS_AUDIO);
case 12 : return GetResString(IDS_SEARCH_ARC);
case 13 : return GetResString(IDS_SEARCH_CDIMG);
}
return _T("?");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -