Add effect and actor to the things that lines can be sorted by

Originally committed to SVN as r6400.
This commit is contained in:
Thomas Goyne 2012-01-31 00:44:34 +00:00
parent a114238396
commit 3b0d2ae8e6
4 changed files with 47 additions and 7 deletions

View File

@ -701,6 +701,12 @@ bool AssFile::CompEnd(const AssDialogue* lft, const AssDialogue* rgt) {
bool AssFile::CompStyle(const AssDialogue* lft, const AssDialogue* rgt) {
return lft->Style < rgt->Style;
}
bool AssFile::CompActor(const AssDialogue* lft, const AssDialogue* rgt) {
return lft->Actor < rgt->Actor;
}
bool AssFile::CompEffect(const AssDialogue* lft, const AssDialogue* rgt) {
return lft->Effect < rgt->Effect;
}
void AssFile::Sort(CompFunc comp) {
Sort(Line, comp);

View File

@ -226,12 +226,16 @@ public:
/// Comparison function for use when sorting
typedef bool (*CompFunc)(const AssDialogue* lft, const AssDialogue* rgt);
/// @brief Compare based on start time
/// Compare based on start time
static bool CompStart(const AssDialogue* lft, const AssDialogue* rgt);
/// @brief Compare based on end time
/// Compare based on end time
static bool CompEnd(const AssDialogue* lft, const AssDialogue* rgt);
/// @brief Compare based on end time
/// Compare based on style name
static bool CompStyle(const AssDialogue* lft, const AssDialogue* rgt);
/// Compare based on actor name
static bool CompActor(const AssDialogue* lft, const AssDialogue* rgt);
/// Compare based on effect
static bool CompEffect(const AssDialogue* lft, const AssDialogue* rgt);
/// @brief Sort the dialogue lines in this file
/// @param comp Comparison function to use. Defaults to sorting by start time.

View File

@ -99,8 +99,34 @@ struct grid_line_prev : public Command {
void operator()(agi::Context *c) {
c->selectionController->PrevLine();
}
}
;
};
/// Sort all subtitles by their actor names
struct grid_sort_actor : public Command {
CMD_NAME("grid/sort/actor")
STR_MENU("&Actor Name")
STR_DISP("Actor Name")
STR_HELP("Sort all subtitles by their actor names.")
void operator()(agi::Context *c) {
c->ass->Sort(AssFile::CompActor);
c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER);
}
};
/// Sort all subtitles by their effects
struct grid_sort_effect : public Command {
CMD_NAME("grid/sort/effect")
STR_MENU("&Effect")
STR_DISP("Effect")
STR_HELP("Sort all subtitles by their effects")
void operator()(agi::Context *c) {
c->ass->Sort(AssFile::CompEffect);
c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER);
}
};
/// Sort all subtitles by their end times.
struct grid_sort_end : public Command {
CMD_NAME("grid/sort/end")
@ -127,7 +153,7 @@ struct grid_sort_start : public Command {
}
};
/// Sort all subtitles by their style names.
/// Sort all subtitles by their style names
struct grid_sort_style : public Command {
CMD_NAME("grid/sort/style")
STR_MENU("St&yle Name")
@ -309,6 +335,8 @@ namespace cmd {
reg(new grid_line_next);
reg(new grid_line_next_create);
reg(new grid_line_prev);
reg(new grid_sort_actor);
reg(new grid_sort_effect);
reg(new grid_sort_end);
reg(new grid_sort_start);
reg(new grid_sort_style);

View File

@ -102,7 +102,9 @@
"main/subtitle/sort lines" : [
{ "command" : "grid/sort/start" },
{ "command" : "grid/sort/end" },
{ "command" : "grid/sort/style" }
{ "command" : "grid/sort/style" },
{ "command" : "grid/sort/actor" },
{ "command" : "grid/sort/effect" }
],
"main/timing" : [
{ "command" : "time/shift" },