summaryrefslogtreecommitdiff
path: root/src/wx/content_view.cc
blob: 46da832a0da90f59e608424b4660ce305e24e308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>

    This file is part of DCP-o-matic.

    DCP-o-matic is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    DCP-o-matic is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.

*/


#include "content_view.h"
#include "wx_util.h"
#include "wx_variant.h"
#include "lib/config.h"
#include "lib/content_factory.h"
#include "lib/cross.h"
#include "lib/dcp_content.h"
#include "lib/dcpomatic_assert.h"
#include "lib/examine_content_job.h"
#include "lib/job_manager.h"
#include "lib/util.h"
#include <dcp/exceptions.h>
#include <dcp/filesystem.h>
#include <dcp/warnings.h>
#include <boost/filesystem.hpp>
#include <boost/optional.hpp>
LIBDCP_DISABLE_WARNINGS
#include <wx/progdlg.h>
LIBDCP_ENABLE_WARNINGS


using std::cout;
using std::dynamic_pointer_cast;
using std::list;
using std::make_shared;
using std::shared_ptr;
using std::string;
using std::weak_ptr;
using boost::optional;
using namespace dcpomatic;


ContentView::ContentView (wxWindow* parent)
	: wxListCtrl (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER)
{
	AppendColumn({}, wxLIST_FORMAT_LEFT, 80);
	/* type */
	AppendColumn({}, wxLIST_FORMAT_LEFT, 80);
	/* annotation text */
	AppendColumn({}, wxLIST_FORMAT_LEFT, 580);
}


optional<ShowPlaylistEntry>
ContentView::selected() const
{
	long int s = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	if (s == -1) {
		return {};
	}

	DCPOMATIC_ASSERT(s < int(_uuids.size()));
	return ShowPlaylistContentStore::instance()->get(_uuids[s]);
}


void
ContentView::update()
{
	DeleteAllItems();
	_uuids.clear();
	for (auto entry: ShowPlaylistContentStore::instance()->all()) {
		add(entry);
	}
}


void
ContentView::add(ShowPlaylistEntry entry)
{
	int const N = GetItemCount();

	wxListItem it;
	it.SetId(N);
	it.SetColumn(0);
	it.SetText(std_to_wx(entry.approximate_length()));
	InsertItem(it);

	it.SetId(N);
	it.SetColumn(1);
	it.SetText(std_to_wx(entry.kind().name()));
	SetItem(it);

	it.SetId(N);
	it.SetColumn(2);
	it.SetText(std_to_wx(entry.name()));
	SetItem(it);

	_uuids.push_back(entry.uuid());
}