Ticket #1982: 1982_TransferSpeed.patch
File 1982_TransferSpeed.patch, 5.8 KB (added by , 12 years ago) |
---|
-
src/interface/led.cpp
6 6 #define new DEBUG_NEW 7 7 #endif 8 8 9 DEFINE_EVENT_TYPE(fzEVT_UPDATE_LED_TOOLTIP) 10 9 11 BEGIN_EVENT_TABLE(CLed, wxWindow) 10 12 EVT_PAINT(CLed::OnPaint) 11 13 EVT_TIMER(wxID_ANY, CLed::OnTimer) 14 EVT_ENTER_WINDOW(CLed::OnEnterWindow) 12 15 #ifdef __WXMSW__ 13 16 EVT_ERASE_BACKGROUND(CLed::OnEraseBackground) 14 17 #endif … … 94 97 return; 95 98 } 96 99 100 void CLed::OnEnterWindow(wxMouseEvent& event) 101 { 102 wxCommandEvent requestUpdateEvent(fzEVT_UPDATE_LED_TOOLTIP, GetId()); 103 requestUpdateEvent.SetEventObject(this); 104 GetEventHandler()->ProcessEvent(requestUpdateEvent); 105 } 106 97 107 void CLed::Ping() 98 108 { 99 109 if (!m_loaded) -
src/interface/led.h
1 1 #ifndef __LED_H__ 2 2 #define __LED_H__ 3 3 4 #include "wx/event.h" 5 4 6 class CFileZillaEngine; 7 8 DECLARE_EVENT_TYPE(fzEVT_UPDATE_LED_TOOLTIP, -1) 9 5 10 class CLed : public wxWindow 6 11 { 7 12 public: … … 25 30 DECLARE_EVENT_TABLE() 26 31 void OnPaint(wxPaintEvent& event); 27 32 void OnTimer(wxTimerEvent& event); 33 void OnEnterWindow(wxMouseEvent& event); 28 34 #ifdef __WXMSW__ 29 35 void OnEraseBackground(wxEraseEvent& event); 30 36 #endif -
src/interface/Mainfrm.cpp
73 73 EVT_SIZE(CMainFrame::OnSize) 74 74 EVT_MENU(wxID_ANY, CMainFrame::OnMenuHandler) 75 75 EVT_FZ_NOTIFICATION(wxID_ANY, CMainFrame::OnEngineEvent) 76 EVT_COMMAND(wxID_ANY, fzEVT_UPDATE_LED_TOOLTIP, CMainFrame::OnUpdateLedTooltip) 76 77 EVT_TOOL(XRCID("ID_TOOLBAR_DISCONNECT"), CMainFrame::OnDisconnect) 77 78 EVT_MENU(XRCID("ID_MENU_SERVER_DISCONNECT"), CMainFrame::OnDisconnect) 78 79 EVT_TOOL(XRCID("ID_TOOLBAR_CANCEL"), CMainFrame::OnCancel) … … 1050 1051 } 1051 1052 } 1052 1053 1054 void CMainFrame::OnUpdateLedTooltip(wxCommandEvent& event) 1055 { 1056 wxString tooltipText; 1057 1058 wxFileOffset downloadSpeed = m_pQueueView->GetCurrentDownloadSpeed(); 1059 wxFileOffset uploadSpeed = m_pQueueView->GetCurrentUploadSpeed(); 1060 1061 CSizeFormat::_format format = static_cast<CSizeFormat::_format>(COptions::Get()->GetOptionVal(OPTION_SIZE_FORMAT)); 1062 if (format == CSizeFormat::bytes) 1063 format = CSizeFormat::iec; 1064 1065 const wxString downloadSpeedStr = CSizeFormat::Format(downloadSpeed, true, format, 1066 COptions::Get()->GetOptionVal(OPTION_SIZE_USETHOUSANDSEP) != 0, 1067 COptions::Get()->GetOptionVal(OPTION_SIZE_DECIMALPLACES)); 1068 const wxString uploadSpeedStr = CSizeFormat::Format(uploadSpeed, true, format, 1069 COptions::Get()->GetOptionVal(OPTION_SIZE_USETHOUSANDSEP) != 0, 1070 COptions::Get()->GetOptionVal(OPTION_SIZE_DECIMALPLACES)); 1071 tooltipText.Printf(_("Download speed: %s/s\nUpload speed: %s/s"), downloadSpeedStr.c_str(), uploadSpeedStr.c_str()); 1072 1073 m_pActivityLed[0]->SetToolTip(tooltipText); 1074 m_pActivityLed[1]->SetToolTip(tooltipText); 1075 } 1076 1053 1077 bool CMainFrame::CreateToolBar() 1054 1078 { 1055 1079 if (m_pToolBar) -
src/interface/Mainfrm.h
109 109 void OnSize(wxSizeEvent& event); 110 110 void OnMenuHandler(wxCommandEvent& event); 111 111 void OnEngineEvent(wxEvent& event); 112 void OnUpdateLedTooltip(wxCommandEvent& event); 112 113 void OnDisconnect(wxCommandEvent& event); 113 114 void OnCancel(wxCommandEvent& event); 114 115 void OnClose(wxCloseEvent& event); -
src/interface/QueueView.cpp
3490 3490 return result; 3491 3491 } 3492 3492 3493 wxFileOffset CQueueView::GetCurrentDownloadSpeed(void) 3494 { 3495 wxFileOffset speed = GetCurrentSpeed(true, false); 3496 return speed; 3497 } 3498 3499 wxFileOffset CQueueView::GetCurrentUploadSpeed(void) 3500 { 3501 wxFileOffset speed = GetCurrentSpeed(false, true); 3502 return speed; 3503 } 3504 3505 wxFileOffset CQueueView::GetCurrentSpeed(bool countDownload, bool countUpload) 3506 { 3507 wxFileOffset speed = 0; 3508 3509 for (std::list<CStatusLineCtrl*>::iterator iter = m_statusLineList.begin(); iter != m_statusLineList.end(); ++iter) 3510 { 3511 CStatusLineCtrl *pCtrl = *iter; 3512 const CFileItem *pItem = pCtrl->GetItem(); 3513 bool isDownload = pItem->Download(); 3514 3515 if ((isDownload && countDownload) || (!isDownload && countUpload)) 3516 { 3517 speed += pCtrl->GetCurrentSpeed(); 3518 } 3519 } 3520 3521 return speed; 3522 } 3523 3493 3524 void CQueueView::ReleaseExclusiveEngineLock(CFileZillaEngine* pEngine) 3494 3525 { 3495 3526 wxASSERT(pEngine); -
src/interface/QueueView.h
143 143 144 144 static wxString ReplaceInvalidCharacters(const wxString& filename); 145 145 146 // Get the current download speed as the sum of all active downloads. 147 // Unit is byte/s. 148 wxFileOffset GetCurrentDownloadSpeed(void); 149 150 // Get the current upload speed as the sum of all active uploads. 151 // Unit is byte/s. 152 wxFileOffset GetCurrentUploadSpeed(void); 153 146 154 protected: 147 155 148 156 #ifdef __WXMSW__ … … 282 290 283 291 CQueueStorage m_queue_storage; 284 292 293 // Get the current transfer speed. 294 // Unit is byte/s. 295 wxFileOffset GetCurrentSpeed(bool countDownload, bool countUpload); 296 285 297 DECLARE_EVENT_TABLE(); 286 298 void OnEngineEvent(wxEvent &event); 287 299 void OnFolderThreadComplete(wxCommandEvent& event);