mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +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
63
src/sort.cpp
63
src/sort.cpp
|
@ -111,39 +111,15 @@ static bool sort_compare (int left, int right)
|
||||||
: (left_number > right_number);
|
: (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.
|
// String.
|
||||||
else if (field == "description" ||
|
else if (field == "description" ||
|
||||||
field == "project" ||
|
field == "project" ||
|
||||||
field == "status" ||
|
field == "status" ||
|
||||||
field == "tags" ||
|
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& left_string = (*global_data)[left].get_ref (field);
|
||||||
const std::string& right_string = (*global_data)[right].get_ref (field);
|
const std::string& right_string = (*global_data)[right].get_ref (field);
|
||||||
|
@ -198,7 +174,9 @@ static bool sort_compare (int left, int right)
|
||||||
field == "entry" ||
|
field == "entry" ||
|
||||||
field == "start" ||
|
field == "start" ||
|
||||||
field == "until" ||
|
field == "until" ||
|
||||||
field == "wait")
|
field == "wait" ||
|
||||||
|
field == "modified" ||
|
||||||
|
field == "scheduled")
|
||||||
{
|
{
|
||||||
const std::string& left_string = (*global_data)[left].get_ref (field);
|
const std::string& left_string = (*global_data)[left].get_ref (field);
|
||||||
const std::string& right_string = (*global_data)[right].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);
|
: (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.
|
// Duration.
|
||||||
else if (field == "recur")
|
else if (field == "recur")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue