Split VerifyDCPResultPanel so that construction and fill are separate.
authorCarl Hetherington <cth@carlh.net>
Tue, 9 Apr 2024 20:11:56 +0000 (22:11 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 15 Apr 2024 22:39:05 +0000 (00:39 +0200)
src/wx/verify_dcp_result_dialog.cc
src/wx/verify_dcp_result_panel.cc
src/wx/verify_dcp_result_panel.h

index 8f834ff589034af2733103c5d3c620b77ac809c8..9617878c581aecaf5135b6919776406ceba06db2 100644 (file)
@@ -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);
index f536c3408abbb3b0c83c2064657097591d4b4eb4..4920ab350965534615ba021a1218d09eef98576b 100644 (file)
@@ -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."));
index 7fd7a91d35ba6e483b3a371cfbee5c8bad6492cf..f0a502064c58329e5fcebb430825dc5897a48a76 100644 (file)
 */
 
 
+#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;
 };