Skip to content

Commit

Permalink
fix #1316
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed May 31, 2024
1 parent a2c461a commit 321a7a3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Layouts/ItemRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ public class Layouts.ItemRow : Layouts.ItemBase {
hide_subtask_revealer.reveal_child = subitems.has_children;
hide_loading_button.add_css_class ("no-padding");
hide_loading_revealer.reveal_child = false;

check_due ();
check_description ();
check_pinboard ();
check_reminders ();
labels_summary.check_revealer ();

if (drag_enabled) {
Expand Down
51 changes: 51 additions & 0 deletions src/Layouts/SectionRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
css_classes = { "listbox-background" }
};

checked_listbox.set_sort_func (set_checked_sort_func);

var checked_listbox_grid = new Gtk.Grid ();
checked_listbox_grid.attach (checked_listbox, 0, 0);

Expand Down Expand Up @@ -299,6 +301,8 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
listbox.append (items [item.id]);
}
}

checked_listbox.invalidate_sort ();
}
});

Expand Down Expand Up @@ -511,6 +515,8 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
foreach (Objects.Item item in is_inbox_section ? section.project.items : section.items) {
add_complete_item (item);
}

checked_listbox.invalidate_sort ();
}

public void add_complete_item (Objects.Item item) {
Expand All @@ -530,6 +536,7 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
}

listbox.invalidate_filter ();
checked_listbox.invalidate_sort ();
}

public void add_items () {
Expand Down Expand Up @@ -608,6 +615,50 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
return 0;
}

private int set_checked_sort_func (Gtk.ListBoxRow lbrow, Gtk.ListBoxRow lbbefore) {
Objects.Item item1 = ((Layouts.ItemRow) lbrow).item;
Objects.Item item2 = ((Layouts.ItemRow) lbbefore).item;

if (section.project.sort_order == 0 || section.project.sort_order == 2) {
if (item1.has_due && item2.has_due) {
var date1 = item1.due.datetime;
var date2 = item2.due.datetime;

return date1.compare (date2);
}

if (!item1.has_due && item2.has_due) {
return 1;
}

return 0;
}

if (section.project.sort_order == 1) {
return item1.content.strip ().collate (item2.content.strip ());
}



if (section.project.sort_order == 3) {
return item1.added_datetime.compare (item2.added_datetime);
}

if (section.project.sort_order == 4) {
if (item1.priority < item2.priority) {
return 1;
}

if (item1.priority < item2.priority) {
return -1;
}

return 0;
}

return 0;
}

public void hide_destroy () {
content_revealer.reveal_child = false;
Timeout.add (content_revealer.transition_duration, () => {
Expand Down

0 comments on commit 321a7a3

Please sign in to comment.