Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gtk4 + New Core + Listview Megaport #894

Merged
merged 290 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
290 commits
Select commit Hold shift + click to select a range
6be33ab
gtk4: port restoring of main window size
ranchester2 Oct 26, 2021
7b0ec57
gtk4: fix tagtreeview popovermenu appearance
ranchester2 Oct 27, 2021
9ce6c0c
gtk4: tags_editor: use GtkEmojiChooser
ranchester2 Oct 27, 2021
e5a5c46
gtk4: tag_editor: use .error for invalid entry instead of removed sticon
ranchester2 Oct 28, 2021
cc5fc9c
gtk4: tags_editor: be a GtkDialog
ranchester2 Oct 28, 2021
ecf5b65
gtk4: tags_editor: port open emoji shortcut
ranchester2 Oct 28, 2021
4488a86
gtk4: tag_editor: fix RGBA creation
ranchester2 Nov 7, 2021
d2ef07b
gtk4: main_window: fix task view context menus
ranchester2 Oct 28, 2021
47b29fb
gtk4: adapt to Gtk.IconTheme retrieval changes
ranchester2 Oct 28, 2021
e68aeb2
gtk4: modify_tags: style action_area
ranchester2 Oct 28, 2021
93f25db
gtk4: modify_tags: add explicit modal=True
ranchester2 Oct 28, 2021
612e834
gtk4: adapt to Gdk.RGBA.to_string
ranchester2 Oct 29, 2021
e27b5ab
gtk4: don't use get_template_child (plugin api)
ranchester2 Oct 29, 2021
96027d0
dev_console_plugin: port to GTK4
ranchester2 Oct 29, 2021
9e4ab7a
gtk4: port deletion confirmation dialogs
ranchester2 Nov 4, 2021
daed205
gtk4: port GTGCalendar
ranchester2 Nov 4, 2021
5c23212
gtk4: bringup TaskEditor
ranchester2 Nov 5, 2021
fd5f667
gtk4: port font selection to CSS
ranchester2 Nov 5, 2021
7960583
gtk4: rework recurring_menu
ranchester2 Nov 5, 2021
5c79350
gtk4: general_preferences: don't block on setting preferences
ranchester2 Nov 5, 2021
f98dceb
gtk4: fix .menu-disclose
ranchester2 Nov 6, 2021
4c51753
gamify_plugin: port to GTK4
ranchester2 Nov 6, 2021
025aba1
gtk4: tags_editor: explicitly set content_area as horizontal
ranchester2 Nov 6, 2021
12231cf
export_plugin: port to GTK4
ranchester2 Nov 8, 2021
b70ec31
hamster_plugin: port to GTK4
ranchester2 Nov 8, 2021
cc5fae3
send_email_plugin: port to GTK4
ranchester2 Nov 8, 2021
b99ee12
urgency_color_plugin: port to GTK4
ranchester2 Nov 8, 2021
3304146
untouched_tasks: port to GTK4
ranchester2 Nov 8, 2021
48a5294
gtk4: stop adding custom GtkImage children to buttons
ranchester2 Nov 8, 2021
ea8df6a
gtk4: startdate_calendar: add "Today" button
ranchester2 Nov 9, 2021
2055601
gtk4: style context menus too look traditional like GTK3
ranchester2 Nov 16, 2021
0060c54
gtk4: update to GtkSourceView 5.0 api changes
ranchester2 Dec 26, 2021
13b797c
bundle legacy icons
ranchester2 Jan 15, 2022
67437d6
gtk4: port backends dialog
ranchester2 Jan 15, 2022
bec583e
Replace Gtk.Container with Gtk.BinLayout
diegogangl May 7, 2022
93216a3
Disable modify tags dialog
diegogangl May 7, 2022
be58e69
Bring back secondary text in error handler
diegogangl May 8, 2022
077ff46
Use GProps for tag attributes
diegogangl May 14, 2022
6235d39
Initialize Tag2 as GObject
diegogangl May 14, 2022
7bbc788
Add ListStore and Treemodel to TagStore
diegogangl May 14, 2022
54f9e2e
Don't add # when generating color
diegogangl May 22, 2022
ed5fcac
Add method to rename tag in content
diegogangl May 28, 2022
f3d0b3e
Fix remove tag method
diegogangl May 28, 2022
b1bbf76
Remove saved search parenting
diegogangl Jun 10, 2022
c6dd76d
Convert saved search props into gprops
diegogangl Jun 11, 2022
255c11d
Add GlistModel to saved searches
diegogangl Jun 11, 2022
e68ff1b
Catch error in base store
diegogangl Jun 18, 2022
8afff12
Add new sidebar to main window
diegogangl May 14, 2022
7f2b880
Remove task count for saved searches
diegogangl Jun 24, 2022
0309ff0
Add tagpill widget
diegogangl Jun 26, 2022
39e2199
Add task pane widget
diegogangl Jun 25, 2022
6dbdca6
Add new task pane to browser
diegogangl Jun 25, 2022
9857614
Make task excerpt longer
diegogangl Jun 26, 2022
8675e66
Fix tag regex in tasks
diegogangl Jun 26, 2022
29c2d9f
Use GProperties for tasks
diegogangl Jun 26, 2022
aef9365
Use List models for tasks
diegogangl Jun 26, 2022
2dcfe53
Remove old code in main window callbacks
diegogangl Jun 30, 2022
dd16fe6
Fix quickadd for new model
diegogangl Jul 2, 2022
00a1b24
Use default title constant in tasks
diegogangl Jul 3, 2022
ea426a1
Fix task editor for new core
diegogangl Jul 3, 2022
f341254
Update delete task dialog
diegogangl Jul 9, 2022
b096bcb
Simplify tag callbacks
diegogangl Jul 9, 2022
c530ea8
Allow opening multiple tasks
diegogangl Jul 9, 2022
25ba5d5
Update modify tags dialog for new core
diegogangl Jul 10, 2022
526cde2
Fix close editor in app
diegogangl Jul 10, 2022
c2cebdb
Add filter for sidebar tags
diegogangl Jul 13, 2022
d98ee5c
Add filters for tasks
diegogangl Jul 14, 2022
6f5a599
Make tags hashable
diegogangl Jul 14, 2022
92c53c5
Change tag filter from sidebar
diegogangl Jul 14, 2022
b896a67
Add sorters
diegogangl Jul 15, 2022
acf9d37
Add sorters to menu
diegogangl Jul 15, 2022
4924f84
Let tasks be dragged onto tags
diegogangl Jul 15, 2022
d4f6070
Add back RMB click menu for tasks
diegogangl Jul 15, 2022
bec578f
Make someday dates sort lower
diegogangl Jul 16, 2022
ab05d21
Accept multiple tasks in sidebar
diegogangl Jul 16, 2022
dd0d6ed
Update browser actions for new core
diegogangl Jul 17, 2022
898a178
Unselect tags in sidebar
diegogangl Jul 20, 2022
9e56f2a
Fix several small bugs in editor
diegogangl Jul 20, 2022
161bb70
Add support for multiple task panes
diegogangl Jul 21, 2022
48279e3
Make sure filters are updated
diegogangl Jul 23, 2022
41ea446
Update search for new core
diegogangl Jul 23, 2022
8c39137
Add search filter
diegogangl Jul 23, 2022
5d29b52
Show searches if query is empty
diegogangl Jul 24, 2022
fbb9d91
Add search filter to task pane
diegogangl Jul 24, 2022
8a40e06
Better filter swap
diegogangl Jul 24, 2022
9be6709
Bring back saved searches
diegogangl Jul 24, 2022
3d0a2af
Fix initial selections in sidebar
diegogangl Jul 24, 2022
a99a631
Add properties for bind()
diegogangl Aug 5, 2022
0b5b010
Catch strings when setting start date
diegogangl Aug 6, 2022
0a6b63a
Fix task row padding
diegogangl Aug 6, 2022
3eb6093
Remove commented code
diegogangl Aug 6, 2022
25b256e
Add has_children property
diegogangl Aug 7, 2022
4576b37
Add function to notify changes in tags
diegogangl Aug 7, 2022
727d4ec
Notify on changes in generate color
diegogangl Aug 7, 2022
5ed8f40
Bind icon and background in rows
diegogangl Aug 7, 2022
70f14f0
Add tag changed notification to tag editor
diegogangl Aug 7, 2022
65e9044
Add new expand/collapse all methods
diegogangl Aug 7, 2022
a988acf
Simplify getting widgets in binds callback
diegogangl Aug 8, 2022
b5af7a2
Fix dark mode in preferences
diegogangl Aug 9, 2022
b7a5fdf
Add color list to tag pill
diegogangl Aug 9, 2022
7eec97e
Add tag pill to sidebar
diegogangl Aug 9, 2022
14e552c
Add visibility properties to tags
diegogangl Aug 12, 2022
cf76c41
Bind visibility in sidebar
diegogangl Aug 12, 2022
7512b78
Fix color parsing in tag editor
diegogangl Aug 12, 2022
69cebd1
Add property to get a list of tag colors
diegogangl Aug 12, 2022
a1ba944
Notify on tag colors change
diegogangl Aug 12, 2022
b21e496
Bind tag colors in task pane
diegogangl Aug 12, 2022
fb83cb6
Add property to show tags
diegogangl Aug 12, 2022
4b91b6c
Add filter for tasks with no tags
diegogangl Aug 13, 2022
0fa98c9
Expand all when selecting an item in general box
diegogangl Aug 13, 2022
97b70bf
Add config setting for row colors
diegogangl Aug 13, 2022
cb4861d
Port plugin system and plugins
diegogangl Aug 18, 2022
a70c04c
Make tags a set
diegogangl Aug 20, 2022
345170f
Fix small bug
diegogangl Aug 20, 2022
8f3f386
Simplify sidebar and main window
diegogangl Aug 20, 2022
bdfebb2
Ellipsize labels in task pane
diegogangl Aug 21, 2022
3b1dd83
Add task count properties
diegogangl Aug 23, 2022
f3ffb00
Add properties to control sidebar visibility
diegogangl Aug 26, 2022
f643615
Notify when dragging
diegogangl Sep 3, 2022
64538e3
Notify when modifying tags
diegogangl Sep 3, 2022
4bee290
Notify when deleting a tag
diegogangl Sep 3, 2022
ea1e916
Notify when changing tags in the editor
diegogangl Sep 3, 2022
5d12dfd
Notify when removing a task
diegogangl Sep 3, 2022
8ca1443
Fix possible bug with none as due date
diegogangl Sep 3, 2022
8d582db
Fix old code in quick add
diegogangl Sep 3, 2022
408ebf5
Move expanders to taskbox
diegogangl Sep 3, 2022
78b4d3f
Add checkbox to taskbox
diegogangl Sep 3, 2022
a0e7e0e
Add dragging to parent tasks
diegogangl Sep 4, 2022
04f2a15
Add toplevel drop
diegogangl Sep 4, 2022
ab44a29
Remove old datastore and requester
diegogangl Sep 11, 2022
99dea9a
Port backends system to new core
diegogangl Sep 17, 2022
ddf842e
Add notify_task method to sidebar
diegogangl Sep 17, 2022
c9f1ec4
Add indices to get_selection
diegogangl Sep 17, 2022
fc829d9
Add recurring setting to tasks
diegogangl Sep 20, 2022
0e46195
Simplify set_status
diegogangl Sep 21, 2022
82e911f
Fix several bugs in recurring tasks
diegogangl Sep 21, 2022
be2fbd0
Fix closing the editor window
diegogangl Sep 25, 2022
ee68756
Add a refresh function to task pane
diegogangl Sep 25, 2022
4ca2894
Fix tag task sorter
diegogangl Sep 25, 2022
8abc73a
Make main sorter a property of task pane
diegogangl Sep 27, 2022
15266f8
Add method to get number of tasks selected
diegogangl Sep 27, 2022
b84ef7e
Add method to get selected task
diegogangl Sep 27, 2022
3557f66
Auto select task when RMB clicking
diegogangl Sep 27, 2022
18fad30
Improve refresh method
diegogangl Sep 27, 2022
d0a37a4
Fix setting margins on taskbox
diegogangl Sep 27, 2022
72a29b1
Call refresh when adding a sub
diegogangl Sep 27, 2022
97c9c05
Fix RMB menu for tasks
diegogangl Sep 28, 2022
6b24dc1
Fix crash in detect tag
diegogangl Sep 29, 2022
700bff8
Remove commented code
diegogangl Oct 1, 2022
fcd4d39
Notify is recurring
diegogangl Oct 1, 2022
0e4a9ed
Add icon for recurring tasks
diegogangl Oct 1, 2022
71c23fe
Fix recurring submenu
diegogangl Oct 1, 2022
3692c98
Fix bug in remove tag
diegogangl Oct 3, 2022
7490026
Add method to refresh tags
diegogangl Oct 3, 2022
62c6c52
Prevents tags from being counted more than once
diegogangl Oct 3, 2022
b1c00ed
Refresh when adding or removing tags
diegogangl Oct 3, 2022
d563434
Add method to change panes for the tag list
diegogangl Oct 3, 2022
f947399
Follow pane changes
diegogangl Oct 3, 2022
40e26fc
Update task counts on status change
diegogangl Oct 3, 2022
2406103
Consider children for tag filtering
diegogangl Oct 5, 2022
7ffaf6c
Port purge functionality to new core
diegogangl Oct 8, 2022
8f367bd
Make checkbox toggle more inclusive
diegogangl Oct 8, 2022
cbcc138
Add several hacks to show tasks properly
diegogangl Oct 8, 2022
26a618e
Make excerpt smaller
diegogangl Oct 12, 2022
446e782
Fix modify tags
diegogangl Oct 13, 2022
7981523
Fix remove tag
diegogangl Oct 13, 2022
222c259
Prevent runtime error due to changing set
diegogangl Oct 13, 2022
36c8119
Remove old core code from versioning
diegogangl Oct 22, 2022
3f1e243
Port changes from #933
diegogangl Oct 22, 2022
ce468cb
Remove old core code
diegogangl Oct 24, 2022
eff84ba
Delay expanding tasks
diegogangl Oct 25, 2022
92ea360
Set sort popover on pane switch
diegogangl Oct 26, 2022
f58164f
Make sort menu available on app start
diegogangl Oct 27, 2022
cfd2f40
Fix refreshing all views
diegogangl Nov 5, 2022
e7eb2a6
Fix duplicated saved searches
diegogangl Nov 12, 2022
728fa28
Use the date_due setter
diegogangl Nov 12, 2022
bdd21ee
Don't assume row will be a row
diegogangl Nov 14, 2022
705cac7
Filter searches by pane too
diegogangl Nov 14, 2022
6de32e8
Add pane to search filter in task pane
diegogangl Nov 14, 2022
0039389
Bring back extract_tags_from_text function
diegogangl Apr 7, 2023
f8fe4d9
Fix import in firstrun tasks
diegogangl Apr 7, 2023
acd5034
Stub constant from old core
diegogangl Apr 7, 2023
d8b043a
Fix references to old core
diegogangl Apr 7, 2023
ff85980
actions: Update dependencies for GTK 4 support
picsel2 Jan 28, 2023
0cb680c
Handle API change of `Gtk.CssProvider.load_from_data`
picsel2 Apr 11, 2023
fe121e8
Merge pull request #4 from picsel2/fix/Gtk-CssProvider-regression
diegogangl Apr 15, 2023
f01678b
Set data_path on first run save
diegogangl May 3, 2023
7ca4a21
Fix old escaped chars in first run tasks
diegogangl Jun 2, 2023
c9ffbed
Remove wrap_box in task pane
diegogangl Jun 17, 2023
db6f6e6
Merge pull request #2 from picsel2/all_ports-gh_actions
diegogangl Aug 8, 2023
9cf2b8e
Fix crash on subtask removal in editor
picsel2 Jul 25, 2023
de1113d
Fix usage of Task2.id property
picsel2 Jul 25, 2023
2f600ed
Show separator between times and icons conditionally
picsel2 Jul 25, 2023
921ab34
Editor: Use the new Status enum
picsel2 Jul 26, 2023
3ec8668
Update task filter on status change
picsel2 Jul 28, 2023
e7cfdd4
Unbind widgets from list items manually
picsel2 Jul 26, 2023
0d00be8
Add expand property to SearchTaskFilter
diegogangl Aug 10, 2023
3646128
Fix old function call in taskeditor checkboxes
diegogangl Aug 10, 2023
20a6cda
Use a dark scheme for TaskView when in dark mode
diegogangl Aug 30, 2023
3df317a
Fix typo when saving a task in the editor
diegogangl Sep 11, 2023
b1b030a
Bring back expand/collapse shortcuts
diegogangl Sep 18, 2023
c6e64cf
Fix sync dialog for new core
diegogangl Sep 20, 2023
fad8783
Port sync to new core
diegogangl Sep 21, 2023
8d1e3ad
Start porting caldav backend
diegogangl Sep 23, 2023
f2ef500
Keep porting caldav backend
diegogangl Sep 23, 2023
50e7eba
Port UI elements from sync to new ui
diegogangl Sep 23, 2023
176b31b
Remove check for default backend
diegogangl Sep 23, 2023
d337c02
Rename Tasks2 to Tasks
diegogangl Sep 24, 2023
f9f2bd3
Rename Tags2 to Tags
diegogangl Sep 24, 2023
1f666c0
Rename Datastore2 to Datastore
diegogangl Sep 24, 2023
c5c3a7b
Fix old usage of datastore
diegogangl Sep 25, 2023
1df5e20
Fix old call to tags_name
diegogangl Sep 26, 2023
c6c7da1
Use new tags in caldav backend
diegogangl Sep 28, 2023
f159edb
Bring back custom attributes on tasks
diegogangl Sep 28, 2023
16946a0
Add property to get tag names in tasks
diegogangl Sep 28, 2023
0164525
Always close child window when opening parent
diegogangl Oct 11, 2023
422b68e
Add # to color strings if missing
diegogangl Oct 11, 2023
7f3ba56
Bring back sort menu
diegogangl Oct 13, 2023
2ce4efd
Make color pill always visible (if no icon)
diegogangl Oct 14, 2023
2fa2094
Fix default color in tag pill
diegogangl Oct 14, 2023
3b3f065
One thing that works
SqAtx Oct 26, 2023
ba6a552
Remove from taskstore instead
SqAtx Oct 26, 2023
e2b98c3
Remove redundant 'added' signal when creating task
SqAtx Oct 20, 2023
2e6fb44
Fix tag color loading
diegogangl Nov 18, 2023
21adf6e
Fix reading tag parent relationship
diegogangl Nov 21, 2023
cdc7ad7
Align all checkboxes
diegogangl Dec 1, 2023
78b0285
Fix indenting for actionable view
diegogangl Dec 3, 2023
93494b5
Fix tasks import
diegogangl Jan 2, 2024
4938864
Replace imp with importlib
diegogangl Jan 2, 2024
6eba634
Fix old references to _view in plugin api
diegogangl Jan 9, 2024
1069c60
Remove signal connection for gamify
diegogangl Jan 25, 2024
f37d842
Bring back nonactionable attr for tags
diegogangl Jan 27, 2024
0bba092
Fix loading tag colors
diegogangl Jan 27, 2024
54b42fb
Preserve search query across panes
diegogangl Jan 27, 2024
edc032f
Only show start date in active view
diegogangl Jan 27, 2024
45cfff6
Fix tag's actionable loading
diegogangl Jan 29, 2024
6be399d
Add call to refresh tags
diegogangl Jan 29, 2024
23ce8f1
Add check for actionable tag in filters
diegogangl Jan 29, 2024
2d2adec
Add function to refresh task count in tags
diegogangl Jan 30, 2024
4fceb72
Use new function to ensure refresh for actionable
diegogangl Jan 30, 2024
1157a37
Notify that the children of a task have changed
diegogangl Jan 31, 2024
9bc092d
Force refresh on toplevel drop
diegogangl Jan 31, 2024
0133500
Fix nonactionable default
diegogangl Feb 1, 2024
c81f472
Fix task title sorting
diegogangl Feb 1, 2024
44a28fa
Move editor window restoration to app
diegogangl Feb 1, 2024
5f63fba
Hide sort by title and tags for now
diegogangl Feb 2, 2024
8399055
Add tags to search filter
diegogangl Feb 4, 2024
e28d4a6
Apply tags when searching and changing tags
diegogangl Feb 4, 2024
d1c055f
Include child tags when selecting a tag
diegogangl Feb 4, 2024
f69019f
Prevent dropping onto a task from resetting filter
diegogangl Feb 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
Expand All @@ -20,10 +20,9 @@ jobs:
run: |
python -m pip install --upgrade pip
sudo apt-get update
sudo apt install -y libgirepository1.0-dev gir1.2-gtk-3.0 libgtksourceview-4-dev
sudo apt install -y libgirepository1.0-dev gir1.2-gtk-4.0 libgtksourceview-5-dev
pip install --user -e git+https://github.com/getting-things-gnome/liblarch.git#egg=liblarch
pip install --user pytest pycairo PyGObject caldav mock lxml
- name: Run unit tests with Pytest
run: |
./run-tests

9 changes: 0 additions & 9 deletions GTG/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,4 @@ def get_saved_backends_list(self):
backend_data['backend'] = module.Backend(backend_data)
backends.append(backend_data)

# If no backend available, we create a new using localfile. Dic
# will be filled in by the backend
if not backends:
dic = BackendFactory().get_new_backend_dict(
"backend_localfile")

dic["first_run"] = True
backends.append(dic)

return backends
102 changes: 49 additions & 53 deletions GTG/backends/backend_caldav.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from GTG.backends.periodic_import_backend import PeriodicImportBackend
from GTG.core.dates import LOCAL_TIMEZONE, Accuracy, Date
from GTG.core.interruptible import interruptible
from GTG.core.task import DisabledSyncCtx, Task
from GTG.core.tasks import Task, Status
from vobject import iCalendar

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -107,16 +107,16 @@ def initialize(self) -> None:

@interruptible
def do_periodic_import(self) -> None:
with self.datastore.get_backend_mutex():
with self.datastore.mutex:
self._do_periodic_import()

@interruptible
def set_task(self, task: Task) -> None:
if self._parameters["is-first-run"] or not self._cache.initialized:
logger.warning("not loaded yet, ignoring set_task")
return
with self.datastore.get_backend_mutex():
return self._set_task(task)
with self.datastore.mutex:
self.datastore.tasks.add(task)

@interruptible
def remove_task(self, tid: str) -> None:
Expand All @@ -126,8 +126,8 @@ def remove_task(self, tid: str) -> None:
if not tid:
logger.warning("no task id passed to remove_task call, ignoring")
return
with self.datastore.get_backend_mutex():
return self._remove_task(tid)
with self.datastore.mutex:
return self.datastore.tasks.remove(tid)

#
# real main methods
Expand All @@ -151,10 +151,9 @@ def _do_periodic_import(self) -> None:
self._cache.initialized = True

def _set_task(self, task: Task) -> None:
logger.debug('set_task todo for %r', task.get_uuid())
with DisabledSyncCtx(task, sync_on_exit=False):
seq_value = SEQUENCE.get_gtg(task, self.namespace)
SEQUENCE.write_gtg(task, seq_value + 1, self.namespace)
logger.debug('set_task todo for %r', task.id)
seq_value = SEQUENCE.get_gtg(task, self.namespace)
SEQUENCE.write_gtg(task, seq_value + 1, self.namespace)
todo, calendar = self._get_todo_and_calendar(task)
if not calendar:
logger.info("%r has no calendar to be synced with", task)
Expand Down Expand Up @@ -259,7 +258,7 @@ def _clean_task_missing_from_backend(self, uid: str,
if do_delete: # the task was missing for a good reason
counts['deleted'] += 1
self._cache.del_todo(uid)
self.datastore.request_task_deletion(uid)
self.datastore.tasks.remove(uid)

@staticmethod
def _denorm_children_on_vtodos(todos: list):
Expand Down Expand Up @@ -298,12 +297,12 @@ def _import_calendar_todos(self, calendar: iCalendar,
uid = UID_FIELD.get_dav(todo)
self._cache.set_todo(todo, uid)
# Updating and creating task according to todos
task = self.datastore.get_task(uid)
task = self.datastore.tasks.lookup[uid]
if not task: # not found, creating it
task = self.datastore.task_factory(uid)
with DisabledSyncCtx(task):
Translator.fill_task(todo, task, self.namespace)
self.datastore.push_task(task)
task = Task()
task.id = uid
Translator.fill_task(todo, task, self.namespace, self.datastore)
self.datastore.tasks.add(task)
counts['created'] += 1
else:
result = self._update_task(task, todo)
Expand All @@ -313,14 +312,13 @@ def _import_calendar_todos(self, calendar: iCalendar,
logger.warning("Shouldn't be diff for %r", uid)

def _update_task(self, task: Task, todo: iCalendar, force: bool = False):
with DisabledSyncCtx(task):
if not force:
task_seq = SEQUENCE.get_gtg(task, self.namespace)
todo_seq = SEQUENCE.get_dav(todo)
if task_seq >= todo_seq:
return 'unchanged'
Translator.fill_task(todo, task, self.namespace)
return 'updated'
if not force:
task_seq = SEQUENCE.get_gtg(task, self.namespace)
todo_seq = SEQUENCE.get_dav(todo)
if task_seq >= todo_seq:
return 'unchanged'
Translator.fill_task(todo, task, self.namespace, self.datastore)
return 'updated'

def __sort_todos(self, todos: list, max_depth: int = 500):
"""For a given list of todos, will return first the one without parent
Expand All @@ -336,7 +334,7 @@ def __sort_todos(self, todos: list, max_depth: int = 500):
parents = PARENT_FIELD.get_dav(todo)
if (not parents # no parent mean no relationship on build
or parents[0] in known_todos # already known parent
or self.datastore.get_task(uid)): # already known uid
or self.datastore.tasks.lookup[uid]): # already known uid
yield todo
known_todos.add(uid)
if loop >= MAX_CALENDAR_DEPTH:
Expand All @@ -345,8 +343,7 @@ def __sort_todos(self, todos: list, max_depth: int = 500):

def _get_calendar_tasks(self, calendar: iCalendar):
"""Getting all tasks that has the calendar tag"""
for uid in self.datastore.get_all_tasks():
task = self.datastore.get_task(uid)
for task in self.datastore.tasks.data:
if CATEGORIES.has_calendar_tag(task, calendar):
yield uid, task

Expand Down Expand Up @@ -555,11 +552,11 @@ def _get_dt_for_dav_writing(value):


class Status(Field):
DEFAULT_STATUS = (Task.STA_ACTIVE, 'NEEDS-ACTION')
_status_mapping = ((Task.STA_ACTIVE, 'NEEDS-ACTION'),
(Task.STA_ACTIVE, 'IN-PROCESS'),
(Task.STA_DISMISSED, 'CANCELLED'),
(Task.STA_DONE, 'COMPLETED'))
DEFAULT_STATUS = (Status.ACTIVE, 'NEEDS-ACTION')
_status_mapping = ((Status.ACTIVE, 'NEEDS-ACTION'),
(Status.ACTIVE, 'IN-PROCESS'),
(Status.DISMISSED, 'CANCELLED'),
(Status.DONE, 'COMPLETED'))

def _translate(self, gtg_value=None, dav_value=None):
for gtg_status, dav_status in self._status_mapping:
Expand All @@ -574,9 +571,9 @@ def write_dav(self, vtodo: iCalendar, value):
def get_gtg(self, task: Task, namespace: str = None) -> str:
active, done = 0, 0
for subtask in self._browse_subtasks(task):
if subtask.get_status() == Task.STA_ACTIVE:
if subtask.is_active:
active += 1
elif subtask.get_status() == Task.STA_DONE:
elif subtask.status == Status.DONE:
done += 1
if active and done:
return 'IN-PROCESS'
Expand All @@ -599,9 +596,9 @@ class PercentComplete(Field):
def get_gtg(self, task: Task, namespace: str = None) -> str:
total_cnt, done_cnt = 0, 0
for subtask in self._browse_subtasks(task):
if subtask.get_status() != Task.STA_DISMISSED:
if subtask.status != Status.DISMISSED:
total_cnt += 1
if subtask.get_status() == Task.STA_DONE:
if subtask.status == Status.DONE:
done_cnt += 1
if total_cnt:
return str(int(100 * done_cnt / total_cnt))
Expand Down Expand Up @@ -645,7 +642,7 @@ def get_calendar_tag(self, calendar: iCalendar) -> str:
return self.to_tag(calendar.name, DAV_TAG_PREFIX)

def has_calendar_tag(self, task: Task, calendar: iCalendar) -> bool:
return self.get_calendar_tag(calendar) in task.get_tags_name()
return self.get_calendar_tag(calendar) in [t.name for t in task.tags]


class AttributeField(Field):
Expand Down Expand Up @@ -758,10 +755,10 @@ def _extract_plain_text(self, task: Task) -> str:
subtask = task.req.get_task(line[2:-2].strip())
if not subtask:
continue
if subtask.get_status() == Task.STA_DONE:
result += f"[x] {subtask.get_title()}\n"
if subtask.status == Status.DONE:
result += f"[x] {subtask.title}\n"
else:
result += f"[ ] {subtask.get_title()}\n"
result += f"[ ] {subtask.title}\n"
else:
result += line.strip() + '\n'
return result.strip()
Expand Down Expand Up @@ -849,10 +846,9 @@ def __repr__(self):
class OrderField(Field):

def get_gtg(self, task: Task, namespace: str = None):
parents = task.get_parents()
if not parents or not parents[0]:
parent = task.parent
if not parent:
return
parent = task.req.get_task(parents[0])
uid = UID_FIELD.get_gtg(task, namespace)
return parent.get_child_index(uid)

Expand All @@ -866,7 +862,7 @@ class Recurrence(Field):
DAV_DAYS = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']

def get_gtg(self, task: Task, namespace: str = None) -> tuple:
return task.get_recurring(), task.get_recurring_term()
return task._is_recurring, task.recurring_term

def get_dav(self, todo=None, vtodo=None) -> tuple:
if todo:
Expand Down Expand Up @@ -975,16 +971,16 @@ def fill_vtodo(cls, task: Task, calendar_name: str, namespace: str,
return vcal

@classmethod
def fill_task(cls, todo: iCalendar, task: Task, namespace: str):
def fill_task(cls, todo: iCalendar, task: Task, namespace: str, datastore):
nmspc = {'namespace': namespace}
with DisabledSyncCtx(task):
for field in cls.fields:
field.set_gtg(todo, task, **nmspc)
task.set_attribute("url", str(todo.url), **nmspc)
task.set_attribute("calendar_url", str(todo.parent.url), **nmspc)
task.set_attribute("calendar_name", todo.parent.name, **nmspc)
if not CATEGORIES.has_calendar_tag(task, todo.parent):
task.add_tag(CATEGORIES.get_calendar_tag(todo.parent))
for field in cls.fields:
field.set_gtg(todo, task, **nmspc)
task.set_attribute("url", str(todo.url), **nmspc)
task.set_attribute("calendar_url", str(todo.parent.url), **nmspc)
task.set_attribute("calendar_name", todo.parent.name, **nmspc)
if not CATEGORIES.has_calendar_tag(task, todo.parent):
tag = datastore.tags.new(CATEGORIES.get_calendar_tag(todo.parent))
task.add_tag(tag)
return task

@classmethod
Expand Down
Loading
Loading