mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Sort: All attributes are now sortable
This commit is contained in:
parent
f1ef53bea0
commit
fa7d4352cd
1 changed files with 38 additions and 33 deletions
71
src/sort.cpp
71
src/sort.cpp
|
@ -111,39 +111,15 @@ static bool sort_compare (int left, int right)
|
|||
: (left_number > right_number);
|
||||
}
|
||||
|
||||
// Depends string.
|
||||
else if (field == "depends")
|
||||
{
|
||||
// Raw data is a comma-separated list of uuids
|
||||
const std::string& left_string = (*global_data)[left].get_ref (field);
|
||||
const std::string& right_string = (*global_data)[right].get_ref (field);
|
||||
|
||||
if (left_string == right_string)
|
||||
continue;
|
||||
|
||||
if (left_string == "" && right_string != "")
|
||||
return ascending;
|
||||
|
||||
if (left_string != "" && right_string == "")
|
||||
return !ascending;
|
||||
|
||||
// Sort on the first dependency.
|
||||
left_number = context.tdb2.id (left_string.substr (0, 36));
|
||||
right_number = context.tdb2.id (right_string.substr (0, 36));
|
||||
|
||||
if (left_number == right_number)
|
||||
continue;
|
||||
|
||||
return ascending ? (left_number < right_number)
|
||||
: (left_number > right_number);
|
||||
}
|
||||
|
||||
// String.
|
||||
else if (field == "description" ||
|
||||
field == "project" ||
|
||||
field == "status" ||
|
||||
field == "tags" ||
|
||||
field == "uuid")
|
||||
field == "uuid" ||
|
||||
field == "parent" ||
|
||||
field == "imask" ||
|
||||
field == "mask")
|
||||
{
|
||||
const std::string& left_string = (*global_data)[left].get_ref (field);
|
||||
const std::string& right_string = (*global_data)[right].get_ref (field);
|
||||
|
@ -194,11 +170,13 @@ static bool sort_compare (int left, int right)
|
|||
}
|
||||
|
||||
// Date.
|
||||
else if (field == "end" ||
|
||||
field == "entry" ||
|
||||
field == "start" ||
|
||||
field == "until" ||
|
||||
field == "wait")
|
||||
else if (field == "end" ||
|
||||
field == "entry" ||
|
||||
field == "start" ||
|
||||
field == "until" ||
|
||||
field == "wait" ||
|
||||
field == "modified" ||
|
||||
field == "scheduled")
|
||||
{
|
||||
const std::string& left_string = (*global_data)[left].get_ref (field);
|
||||
const std::string& right_string = (*global_data)[right].get_ref (field);
|
||||
|
@ -210,6 +188,33 @@ static bool sort_compare (int left, int right)
|
|||
: (left_string > right_string);
|
||||
}
|
||||
|
||||
// Depends string.
|
||||
else if (field == "depends")
|
||||
{
|
||||
// Raw data is a comma-separated list of uuids
|
||||
const std::string& left_string = (*global_data)[left].get_ref (field);
|
||||
const std::string& right_string = (*global_data)[right].get_ref (field);
|
||||
|
||||
if (left_string == right_string)
|
||||
continue;
|
||||
|
||||
if (left_string == "" && right_string != "")
|
||||
return ascending;
|
||||
|
||||
if (left_string != "" && right_string == "")
|
||||
return !ascending;
|
||||
|
||||
// Sort on the first dependency.
|
||||
left_number = context.tdb2.id (left_string.substr (0, 36));
|
||||
right_number = context.tdb2.id (right_string.substr (0, 36));
|
||||
|
||||
if (left_number == right_number)
|
||||
continue;
|
||||
|
||||
return ascending ? (left_number < right_number)
|
||||
: (left_number > right_number);
|
||||
}
|
||||
|
||||
// Duration.
|
||||
else if (field == "recur")
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue