mirror of https://github.com/BOINC/boinc.git
334 lines
9.1 KiB
C++
334 lines
9.1 KiB
C++
// $Id$
|
|
//
|
|
// The contents of this file are subject to the BOINC Public License
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
// compliance with the License. You may obtain a copy of the License at
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
|
//
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
// License for the specific language governing rights and limitations
|
|
// under the License.
|
|
//
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
//
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
//
|
|
// Contributor(s):
|
|
//
|
|
// Revision History:
|
|
//
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
#pragma implementation "ViewTransfers.h"
|
|
#endif
|
|
|
|
#include "stdwx.h"
|
|
#include "BOINCGUIApp.h"
|
|
#include "MainDocument.h"
|
|
#include "BOINCTaskCtrl.h"
|
|
#include "BOINCListCtrl.h"
|
|
#include "ViewTransfers.h"
|
|
#include "Events.h"
|
|
|
|
#include "res/xfer.xpm"
|
|
#include "res/task.xpm"
|
|
#include "res/tips.xpm"
|
|
|
|
#define VIEW_HEADER wxT("xfer")
|
|
|
|
#define SECTION_TASK wxT(VIEW_HEADER "task")
|
|
#define SECTION_TIPS wxT(VIEW_HEADER "tips")
|
|
|
|
#define BITMAP_TRANSFER wxT(VIEW_HEADER ".xpm")
|
|
#define BITMAP_TASKHEADER wxT(SECTION_TASK ".xpm")
|
|
#define BITMAP_TIPSHEADER wxT(SECTION_TIPS ".xpm")
|
|
|
|
#define LINK_DEFAULT wxT("default")
|
|
|
|
#define COLUMN_PROJECT 0
|
|
#define COLUMN_FILE 1
|
|
#define COLUMN_PROGRESS 2
|
|
#define COLUMN_SIZE 3
|
|
#define COLUMN_TIME 4
|
|
#define COLUMN_SPEED 5
|
|
#define COLUMN_STATUS 6
|
|
|
|
|
|
const wxString LINK_TASKRETRY = wxT(SECTION_TASK "retry");
|
|
const wxString LINKDESC_TASKRETRY =
|
|
_("<b>Retry Now</b><br>"
|
|
"Selecting retry now will attempt to upload the result data file "
|
|
"to the project server now.");
|
|
|
|
const wxString LINK_TASKABORT = wxT(SECTION_TASK "abort");
|
|
const wxString LINKDESC_TASKABORT =
|
|
_("<b>Abort Upload</b><br>"
|
|
"Selecting abort upload will delete the result from the upload queue. "
|
|
"Doing this will keep you from being granted any credit for this result.");
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CViewTransfers, CBOINCBaseView)
|
|
|
|
|
|
CViewTransfers::CViewTransfers()
|
|
{
|
|
}
|
|
|
|
|
|
CViewTransfers::CViewTransfers(wxNotebook* pNotebook) :
|
|
CBOINCBaseView(pNotebook, ID_HTML_TRANSFERSVIEW, ID_LIST_TRANSFERSVIEW)
|
|
{
|
|
m_bProcessingTaskRenderEvent = false;
|
|
m_bProcessingListRenderEvent = false;
|
|
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
wxBitmap bmpTransfer(xfer_xpm);
|
|
wxBitmap bmpTask(task_xpm);
|
|
wxBitmap bmpTips(tips_xpm);
|
|
|
|
bmpTransfer.SetMask(new wxMask(bmpTransfer, wxColour(255, 0, 255)));
|
|
bmpTask.SetMask(new wxMask(bmpTask, wxColour(255, 0, 255)));
|
|
bmpTips.SetMask(new wxMask(bmpTips, wxColour(255, 0, 255)));
|
|
|
|
m_pTaskPane->AddVirtualFile(BITMAP_TRANSFER, bmpTransfer, wxBITMAP_TYPE_XPM);
|
|
|
|
m_pTaskPane->CreateTaskHeader(BITMAP_TASKHEADER, bmpTask, _("Tasks"));
|
|
m_pTaskPane->CreateTaskHeader(BITMAP_TIPSHEADER, bmpTips, _("Quick Tips"));
|
|
|
|
m_pListPane->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, -1);
|
|
m_pListPane->InsertColumn(COLUMN_FILE, _("File"), wxLIST_FORMAT_LEFT, -1);
|
|
m_pListPane->InsertColumn(COLUMN_PROGRESS, _("Progress"), wxLIST_FORMAT_LEFT, -1);
|
|
m_pListPane->InsertColumn(COLUMN_SIZE, _("Size"), wxLIST_FORMAT_LEFT, -1);
|
|
m_pListPane->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, -1);
|
|
m_pListPane->InsertColumn(COLUMN_SPEED, _("Speed"), wxLIST_FORMAT_LEFT, -1);
|
|
m_pListPane->InsertColumn(COLUMN_STATUS, _("Status"), wxLIST_FORMAT_LEFT, -1);
|
|
|
|
m_bTipsHeaderHidden = false;
|
|
|
|
SetCurrentQuickTip(
|
|
LINK_DEFAULT,
|
|
_("Please select a transfer item to see additional options.")
|
|
);
|
|
|
|
UpdateSelection();
|
|
}
|
|
|
|
|
|
CViewTransfers::~CViewTransfers()
|
|
{
|
|
}
|
|
|
|
|
|
wxString CViewTransfers::GetViewName()
|
|
{
|
|
return wxString(_("Transfers"));
|
|
}
|
|
|
|
|
|
char** CViewTransfers::GetViewIcon()
|
|
{
|
|
return xfer_xpm;
|
|
}
|
|
|
|
|
|
void CViewTransfers::OnTaskRender(wxTimerEvent &event)
|
|
{
|
|
if (!m_bProcessingTaskRenderEvent)
|
|
{
|
|
m_bProcessingTaskRenderEvent = true;
|
|
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
if ( ( 0 == m_pListPane->GetSelectedItemCount() ) && m_bItemSelected )
|
|
{
|
|
UpdateSelection();
|
|
}
|
|
|
|
m_bProcessingTaskRenderEvent = false;
|
|
}
|
|
else
|
|
{
|
|
event.Skip();
|
|
}
|
|
}
|
|
|
|
|
|
void CViewTransfers::OnListRender(wxTimerEvent &event)
|
|
{
|
|
if (!m_bProcessingListRenderEvent)
|
|
{
|
|
m_bProcessingListRenderEvent = true;
|
|
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
wxInt32 iCount = wxGetApp().GetDocument()->GetTransferCount();
|
|
if ( iCount != m_iCount )
|
|
{
|
|
m_iCount = iCount;
|
|
m_pListPane->SetItemCount(iCount);
|
|
}
|
|
else
|
|
{
|
|
m_pListPane->RefreshItems(m_iCacheFrom, m_iCacheTo);
|
|
}
|
|
|
|
m_bProcessingListRenderEvent = false;
|
|
}
|
|
else
|
|
{
|
|
event.Skip();
|
|
}
|
|
}
|
|
|
|
|
|
void CViewTransfers::OnListSelected ( wxListEvent& event )
|
|
{
|
|
UpdateSelection();
|
|
event.Skip();
|
|
}
|
|
|
|
|
|
void CViewTransfers::OnListDeselected ( wxListEvent& event )
|
|
{
|
|
UpdateSelection();
|
|
event.Skip();
|
|
}
|
|
|
|
|
|
wxString CViewTransfers::OnListGetItemText(long item, long column) const
|
|
{
|
|
wxString strBuffer;
|
|
switch(column) {
|
|
case COLUMN_PROJECT:
|
|
if (item == m_iCacheFrom) wxGetApp().GetDocument()->CachedStateLock();
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferProjectName(item);
|
|
break;
|
|
case COLUMN_FILE:
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferFileName(item);
|
|
break;
|
|
case COLUMN_PROGRESS:
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferProgress(item);
|
|
break;
|
|
case COLUMN_SIZE:
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferSize(item);
|
|
break;
|
|
case COLUMN_TIME:
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferTime(item);
|
|
break;
|
|
case COLUMN_SPEED:
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferSpeed(item);
|
|
break;
|
|
case COLUMN_STATUS:
|
|
strBuffer = wxGetApp().GetDocument()->GetTransferStatus(item);
|
|
if (item == m_iCacheTo) wxGetApp().GetDocument()->CachedStateUnlock();
|
|
break;
|
|
}
|
|
return strBuffer;
|
|
}
|
|
|
|
|
|
void CViewTransfers::OnTaskLinkClicked( const wxHtmlLinkInfo& link )
|
|
{
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
wxString strMessage;
|
|
|
|
if ( link.GetHref() == SECTION_TASK )
|
|
m_bTaskHeaderHidden ? m_bTaskHeaderHidden = false : m_bTaskHeaderHidden = true;
|
|
|
|
if ( link.GetHref() == SECTION_TIPS )
|
|
m_bTipsHeaderHidden ? m_bTipsHeaderHidden = false : m_bTipsHeaderHidden = true;
|
|
|
|
|
|
UpdateSelection();
|
|
}
|
|
|
|
|
|
void CViewTransfers::OnTaskCellMouseHover( wxHtmlCell* cell, wxCoord x, wxCoord y )
|
|
{
|
|
if ( NULL != cell->GetLink() )
|
|
{
|
|
bool bUpdateSelection = false;
|
|
wxString strLink;
|
|
|
|
strLink = cell->GetLink()->GetHref();
|
|
|
|
if ( UpdateQuickTip( strLink, LINK_TASKRETRY, LINKDESC_TASKRETRY ) )
|
|
bUpdateSelection = true;
|
|
else if ( UpdateQuickTip( strLink, LINK_TASKABORT, LINKDESC_TASKABORT ) )
|
|
bUpdateSelection = true;
|
|
else
|
|
{
|
|
if ( 0 == m_pListPane->GetSelectedItemCount() )
|
|
{
|
|
if ( LINK_DEFAULT != GetCurrentQuickTip() )
|
|
{
|
|
SetCurrentQuickTip(
|
|
LINK_DEFAULT,
|
|
_("Please select an result upload to see additional options.")
|
|
);
|
|
|
|
bUpdateSelection = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( bUpdateSelection )
|
|
{
|
|
UpdateSelection();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void CViewTransfers::UpdateSelection()
|
|
{
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
wxASSERT(NULL != m_pListPane);
|
|
|
|
if ( 0 == m_pListPane->GetSelectedItemCount() )
|
|
{
|
|
m_bTaskHeaderHidden = true;
|
|
m_bTaskRetryHidden = true;
|
|
m_bTaskAbortHidden = true;
|
|
|
|
m_bItemSelected = false;
|
|
}
|
|
else
|
|
{
|
|
m_bTaskHeaderHidden = false;
|
|
m_bTaskRetryHidden = false;
|
|
m_bTaskAbortHidden = false;
|
|
|
|
m_bItemSelected = true;
|
|
}
|
|
UpdateTaskPane();
|
|
}
|
|
|
|
|
|
void CViewTransfers::UpdateTaskPane()
|
|
{
|
|
wxASSERT(NULL != m_pTaskPane);
|
|
|
|
m_pTaskPane->BeginTaskPage();
|
|
|
|
m_pTaskPane->BeginTaskSection( SECTION_TASK, BITMAP_TASKHEADER, m_bTaskHeaderHidden );
|
|
if (!m_bTaskHeaderHidden)
|
|
{
|
|
m_pTaskPane->CreateTask( LINK_TASKRETRY, BITMAP_TRANSFER, _("Retry Now"), m_bTaskRetryHidden );
|
|
m_pTaskPane->CreateTask( LINK_TASKABORT, BITMAP_TRANSFER, _("Abort Upload"), m_bTaskAbortHidden );
|
|
}
|
|
m_pTaskPane->EndTaskSection( m_bTaskHeaderHidden );
|
|
|
|
m_pTaskPane->UpdateQuickTip( SECTION_TIPS, BITMAP_TIPSHEADER, GetCurrentQuickTipText(), m_bTipsHeaderHidden );
|
|
|
|
m_pTaskPane->EndTaskPage();
|
|
}
|
|
|