summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-04-09 22:11:56 +0200
committerCarl Hetherington <cth@carlh.net>2024-04-16 00:39:05 +0200
commit91b6f5b7921c7af26c0bb04074d603a712f0e9d4 (patch)
tree2de6bc426141d7fb321391e0ef4ce4a616572330
parentb3a03888285d1f97253a6ed7e1438d5a2781fab9 (diff)
Split VerifyDCPResultPanel so that construction and fill are separate.
-rw-r--r--src/wx/verify_dcp_result_dialog.cc3
-rw-r--r--src/wx/verify_dcp_result_panel.cc40
-rw-r--r--src/wx/verify_dcp_result_panel.h11
3 files changed, 34 insertions, 20 deletions
diff --git a/src/wx/verify_dcp_result_dialog.cc b/src/wx/verify_dcp_result_dialog.cc
index 8f834ff58..9617878c5 100644
--- a/src/wx/verify_dcp_result_dialog.cc
+++ b/src/wx/verify_dcp_result_dialog.cc
@@ -32,7 +32,8 @@ VerifyDCPResultDialog::VerifyDCPResultDialog(wxWindow* parent, shared_ptr<Verify
{
auto sizer = new wxBoxSizer (wxVERTICAL);
- auto panel = new VerifyDCPResultPanel(this, job);
+ auto panel = new VerifyDCPResultPanel(this);
+ panel->fill(job);
sizer->Add(panel, 1, wxEXPAND);
auto buttons = CreateStdDialogButtonSizer(0);
diff --git a/src/wx/verify_dcp_result_panel.cc b/src/wx/verify_dcp_result_panel.cc
index f536c3408..4920ab350 100644
--- a/src/wx/verify_dcp_result_panel.cc
+++ b/src/wx/verify_dcp_result_panel.cc
@@ -39,34 +39,38 @@ using std::string;
using std::vector;
-VerifyDCPResultPanel::VerifyDCPResultPanel(wxWindow* parent, shared_ptr<VerifyDCPJob> job)
+VerifyDCPResultPanel::VerifyDCPResultPanel(wxWindow* parent)
: wxPanel(parent, wxID_ANY)
{
auto sizer = new wxBoxSizer(wxVERTICAL);
auto notebook = new wxNotebook(this, wxID_ANY);
sizer->Add(notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
- map<dcp::VerificationNote::Type, wxRichTextCtrl*> pages;
- pages[dcp::VerificationNote::Type::ERROR] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY);
- notebook->AddPage(pages[dcp::VerificationNote::Type::ERROR], _("Errors"));
- pages[dcp::VerificationNote::Type::BV21_ERROR] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY);
- notebook->AddPage(pages[dcp::VerificationNote::Type::BV21_ERROR], _("SMPTE Bv2.1 errors"));
- pages[dcp::VerificationNote::Type::WARNING] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY);
- notebook->AddPage(pages[dcp::VerificationNote::Type::WARNING], _("Warnings"));
+ _pages[dcp::VerificationNote::Type::ERROR] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY);
+ notebook->AddPage(_pages[dcp::VerificationNote::Type::ERROR], _("Errors"));
+ _pages[dcp::VerificationNote::Type::BV21_ERROR] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY);
+ notebook->AddPage(_pages[dcp::VerificationNote::Type::BV21_ERROR], _("SMPTE Bv2.1 errors"));
+ _pages[dcp::VerificationNote::Type::WARNING] = new wxRichTextCtrl(notebook, wxID_ANY, wxEmptyString, wxDefaultPosition, {400, 300}, wxRE_READONLY);
+ notebook->AddPage(_pages[dcp::VerificationNote::Type::WARNING], _("Warnings"));
- auto summary = new wxStaticText(this, wxID_ANY, wxT(""));
- sizer->Add(summary, 0, wxALL, DCPOMATIC_DIALOG_BORDER);
+ _summary = new wxStaticText(this, wxID_ANY, wxT(""));
+ sizer->Add(_summary, 0, wxALL, DCPOMATIC_DIALOG_BORDER);
SetSizer(sizer);
sizer->Layout();
sizer->SetSizeHints(this);
- for (auto const& i: pages) {
+ for (auto const& i: _pages) {
i.second->GetCaret()->Hide();
}
+}
+
+void
+VerifyDCPResultPanel::fill(shared_ptr<VerifyDCPJob> job)
+{
if (job->finished_ok() && job->notes().empty()) {
- summary->SetLabel(_("DCP validates OK."));
+ _summary->SetLabel(_("DCP validates OK."));
return;
}
@@ -75,11 +79,11 @@ VerifyDCPResultPanel::VerifyDCPResultPanel(wxWindow* parent, shared_ptr<VerifyDC
counts[dcp::VerificationNote::Type::BV21_ERROR] = 0;
counts[dcp::VerificationNote::Type::ERROR] = 0;
- auto add_bullet = [&pages](dcp::VerificationNote::Type type, wxString message) {
- pages[type]->BeginStandardBullet(N_("standard/diamond"), 1, 50);
- pages[type]->WriteText(message);
- pages[type]->Newline();
- pages[type]->EndStandardBullet();
+ auto add_bullet = [this](dcp::VerificationNote::Type type, wxString message) {
+ _pages[type]->BeginStandardBullet(N_("standard/diamond"), 1, 50);
+ _pages[type]->WriteText(message);
+ _pages[type]->Newline();
+ _pages[type]->EndStandardBullet();
};
auto add = [&counts, &add_bullet](dcp::VerificationNote note, wxString message) {
@@ -473,7 +477,7 @@ VerifyDCPResultPanel::VerifyDCPResultPanel(wxWindow* parent, shared_ptr<VerifyDC
summary_text += wxString::Format("and %d warnings.", counts[dcp::VerificationNote::Type::WARNING]);
}
- summary->SetLabel(summary_text);
+ _summary->SetLabel(summary_text);
if (counts[dcp::VerificationNote::Type::ERROR] == 0) {
add_bullet(dcp::VerificationNote::Type::ERROR, _("No errors found."));
diff --git a/src/wx/verify_dcp_result_panel.h b/src/wx/verify_dcp_result_panel.h
index 7fd7a91d3..f0a502064 100644
--- a/src/wx/verify_dcp_result_panel.h
+++ b/src/wx/verify_dcp_result_panel.h
@@ -19,15 +19,24 @@
*/
+#include <dcp/verify.h>
#include <wx/wx.h>
+#include <map>
#include <memory>
class VerifyDCPJob;
+class wxRichTextCtrl;
class VerifyDCPResultPanel : public wxPanel
{
public:
- VerifyDCPResultPanel(wxWindow* parent, std::shared_ptr<VerifyDCPJob> job);
+ VerifyDCPResultPanel(wxWindow* parent);
+
+ void fill(std::shared_ptr<VerifyDCPJob> job);
+
+private:
+ wxStaticText* _summary;
+ std::map<dcp::VerificationNote::Type, wxRichTextCtrl*> _pages;
};