#include "lib/playlist.h"
#include "lib/content.h"
#include "lib/content_factory.h"
+#include "lib/safe_stringstream.h"
#include "timecode.h"
#include "wx_util.h"
#include "film_editor.h"
using std::string;
using std::cout;
-using std::stringstream;
using std::pair;
using std::fixed;
using std::setprecision;
return;
}
- stringstream s;
+ SafeStringStream s;
for (list<FilmEditorPanel*>::iterator i = _panels.begin(); i != _panels.end(); ++i) {
(*i)->film_changed (p);
FilmEditor::content_remove_clicked ()
{
ContentList c = selected_content ();
- if (c.size() == 1) {
- _film->remove_content (c.front ());
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ _film->remove_content (*i);
}
content_selection_changed ();
VideoContentList video_selection = selected_video_content ();
AudioContentList audio_selection = selected_audio_content ();
- _content_remove->Enable (selection.size() == 1 && _generally_sensitive);
+ _content_remove->Enable (!selection.empty() && _generally_sensitive);
_content_earlier->Enable (selection.size() == 1 && _generally_sensitive);
_content_later->Enable (selection.size() == 1 && _generally_sensitive);
_content_timeline->Enable (!_film->content().empty() && _generally_sensitive);
- _video_panel->Enable (video_selection.size() > 0 && _generally_sensitive);
- _audio_panel->Enable (audio_selection.size() > 0 && _generally_sensitive);
+ _video_panel->Enable (!video_selection.empty() && _generally_sensitive);
+ _audio_panel->Enable (!audio_selection.empty() && _generally_sensitive);
_subtitle_panel->Enable (selection.size() == 1 && dynamic_pointer_cast<FFmpegContent> (selection.front()) && _generally_sensitive);
- _timing_panel->Enable (selection.size() == 1 && _generally_sensitive);
+ _timing_panel->Enable (!selection.empty() && _generally_sensitive);
}
ContentList
FilmEditor::selected_content ()
{
ContentList sel;
+
+ if (!_film) {
+ return sel;
+ }
+
+ /* The list was populated using a sorted content list, so we must sort it here too
+ so that we can look up by index and get the right thing.
+ */
+ ContentList content = _film->content ();
+ sort (content.begin(), content.end(), ContentSorter ());
+
long int s = -1;
- while (1) {
+ while (true) {
s = _content->GetNextItem (s, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (s == -1) {
break;
}
if (s < int (_film->content().size ())) {
- sel.push_back (_film->content()[s]);
+ sel.push_back (content[s]);
}
}
if (content[i] == wc.lock ()) {
_content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
} else {
- _content->SetItemState (i, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
+ _content->SetItemState (i, 0, wxLIST_STATE_SELECTED);
}
}
}