Mgr: Add all the new notices features to the Simple View notices dialog

This commit is contained in:
Charlie Fenton 2012-12-23 03:48:27 -08:00 committed by Oliver Bock
parent 2ec40cd53c
commit 1eff59fb4c
3 changed files with 116 additions and 4 deletions

View File

@ -7871,6 +7871,8 @@ Charlie 22 Dec 2012
Charlie 23 Dec 2012
- Mgr: Bug fixes for Windows Async Internet access, including closing the
WinINet handle when aborting due to timeout, etc. to prevent crashes.
- Mgr: Add all the new notices features to the Simple View notices dialog.
clientgui/
BOINCInternetFSHandler.cpp
sg_DlgMessages.cpp,.h

View File

@ -35,6 +35,7 @@
#include "version.h"
#include "sg_DlgMessages.h"
#include "NoticeListCtrl.h"
#include "BOINCInternetFSHandler.h"
@ -65,6 +66,7 @@ BEGIN_EVENT_TABLE( CPanelMessages, wxPanel )
EVT_ERASE_BACKGROUND( CPanelMessages::OnEraseBackground )
EVT_BUTTON( wxID_OK, CPanelMessages::OnOK )
EVT_BUTTON(ID_SIMPLE_HELP, CPanelMessages::OnButtonHelp)
EVT_BUTTON( ID_LIST_RELOADNOTICES, CPanelMessages::OnRetryButton )
////@end CPanelMessages event table entries
END_EVENT_TABLE()
@ -116,11 +118,31 @@ void CPanelMessages::CreateControls()
{
CPanelMessages* itemDialog1 = this;
wxFlexGridSizer* itemFlexGridSizer2 = new wxFlexGridSizer(2, 1, 0, 0);
itemFlexGridSizer2->AddGrowableRow(0);
wxFlexGridSizer* itemReloadButtonSizer = new wxFlexGridSizer(1, 2, 0, 0);
itemReloadButtonSizer->AddGrowableCol(1);
m_ReloadNoticesText = new wxStaticText(this, wxID_ANY,
_("One or more items failed to load from the Internet."),
wxDefaultPosition, wxDefaultSize, 0
);
itemReloadButtonSizer->Add(m_ReloadNoticesText, 1, wxALL, 5);
m_ReloadNoticesButton = new wxButton(
this, ID_LIST_RELOADNOTICES,
_("Retry now"),
wxDefaultPosition, wxDefaultSize, 0
);
itemReloadButtonSizer->Add(m_ReloadNoticesButton, 1, wxALL, 5);
wxFlexGridSizer* itemFlexGridSizer2 = new wxFlexGridSizer(3, 1, 1, 0);
itemFlexGridSizer2->AddGrowableRow(1);
itemFlexGridSizer2->AddGrowableCol(0);
itemDialog1->SetSizer(itemFlexGridSizer2);
itemFlexGridSizer2->Add(itemReloadButtonSizer, 1, wxGROW|wxALL, 1);
m_pHtmlListPane = new CNoticeListCtrl(itemDialog1);
itemFlexGridSizer2->Add(m_pHtmlListPane, 0, wxGROW|wxALL, 5);
@ -135,6 +157,24 @@ void CPanelMessages::CreateControls()
wxButton* itemButton44 = new wxButton(itemDialog1, wxID_OK, _("Close"), wxDefaultPosition, wxDefaultSize);
itemBoxSizer4->Add(itemButton44, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_FetchingNoticesText = new wxStaticText(
this, wxID_ANY,
_("Fetching notices; please wait..."),
wxPoint(20, 20), wxDefaultSize, 0
);
m_NoNoticesText = new wxStaticText(
this, wxID_ANY,
_("There are no notices at this time."),
wxPoint(20, 20), wxDefaultSize, 0
);
m_NoNoticesText->Hide();
m_ReloadNoticesText->Hide();
m_ReloadNoticesButton->Hide();
m_bMissingItems = false;
}
@ -205,9 +245,48 @@ void CPanelMessages::OnRefresh() {
if (!m_bProcessingRefreshEvent) {
m_bProcessingRefreshEvent = true;
m_pHtmlListPane->Freeze();
static wxString strLastMachineName = wxEmptyString;
wxString strNewMachineName = wxEmptyString;
bool bMissingItems;
CC_STATUS status;
CMainDocument* pDoc = wxGetApp().GetDocument();
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
wxASSERT(pDoc);
wxASSERT(m_pHtmlListPane);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
wxASSERT(internetFSHandler);
if (pDoc->IsConnected()) {
pDoc->GetConnectedComputerName(strNewMachineName);
if (strLastMachineName != strNewMachineName) {
strLastMachineName = strNewMachineName;
m_FetchingNoticesText->Show();
m_NoNoticesText->Hide();
((CBOINCInternetFSHandler*)internetFSHandler)->ClearCache();
m_pHtmlListPane->Clear();
if (m_bMissingItems) {
m_ReloadNoticesText->Hide();
m_ReloadNoticesButton->Hide();
m_bMissingItems = false;
Layout();
}
}
}
// Don't call Freeze() / Thaw() here because it causes an unnecessary redraw
m_pHtmlListPane->UpdateUI();
m_pHtmlListPane->Thaw();
bMissingItems = ((CBOINCInternetFSHandler*)internetFSHandler)->ItemsFailedToLoad();
if (bMissingItems != m_bMissingItems) {
m_ReloadNoticesText->Show(bMissingItems);
m_ReloadNoticesButton->Show(bMissingItems);
Layout();
m_bMissingItems = bMissingItems;
}
m_FetchingNoticesText->Show(m_pHtmlListPane->m_bDisplayFetchingNotices);
m_NoNoticesText->Show(m_pHtmlListPane->m_bDisplayEmptyNotice);
m_bProcessingRefreshEvent = false;
}
@ -258,6 +337,25 @@ void CPanelMessages::OnLinkClicked( NoticeListCtrlEvent& event ) {
}
void CPanelMessages::OnRetryButton( wxCommandEvent& event ) {
m_ReloadNoticesText->Hide();
m_ReloadNoticesButton->Hide();
m_bMissingItems = false;
Layout();
ReloadNotices();
}
void CPanelMessages::ReloadNotices() {
wxFileSystemHandler *internetFSHandler = wxGetApp().GetInternetFSHandler();
if (internetFSHandler) {
((CBOINCInternetFSHandler*)internetFSHandler)->UnchacheMissingItems();
m_pHtmlListPane->Clear();
m_FetchingNoticesText->Show();
m_NoNoticesText->Hide();
}
}
bool CPanelMessages::OnSaveState(wxConfigBase* /* pConfig */) {
return true;
}

View File

@ -96,6 +96,8 @@ public:
void OnRefresh();
void ReloadNotices();
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void OnOK( wxCommandEvent& event );
@ -105,6 +107,9 @@ public:
/// wxEVT_NOTICELIST_ITEM_DISPLAY event handler for ID_LIST_NOTIFICATIONSVIEW
void OnLinkClicked( NoticeListCtrlEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_LIST_RELOADNOTICES
void OnRetryButton( wxCommandEvent& event );
////@end CPanelMessages event handler declarations
////@begin CPanelMessages member function declarations
@ -116,6 +121,13 @@ public:
private:
bool m_bProcessingRefreshEvent;
CNoticeListCtrl* m_pHtmlListPane;
protected:
wxStaticText* m_ReloadNoticesText;
wxButton* m_ReloadNoticesButton;
wxStaticText* m_FetchingNoticesText;
wxStaticText* m_NoNoticesText;
bool m_bMissingItems;
};