Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
7b5d3c52
Commit
7b5d3c52
authored
Jun 21, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some refactoring in preparation for editing and persisting columns.
parent
ea5c6204
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
30 deletions
+39
-30
topydo/ui/Main.py
topydo/ui/Main.py
+24
-3
topydo/ui/ViewWidget.py
topydo/ui/ViewWidget.py
+15
-27
No files found.
topydo/ui/Main.py
View file @
7b5d3c52
...
...
@@ -25,6 +25,8 @@ from topydo.ui.TodoListWidget import TodoListWidget
from
topydo.ui.ViewWidget
import
ViewWidget
from
topydo.lib.Config
import
config
from
topydo.lib.Sorter
import
Sorter
from
topydo.lib.Filter
import
get_filter_list
,
RelevanceFilter
,
DependencyFilter
from
topydo.lib.View
import
View
from
topydo.lib
import
TodoFile
from
topydo.lib
import
TodoList
...
...
@@ -54,7 +56,8 @@ class UIApplication(CLIApplicationBase):
# view widget
self
.
viewwidget
=
ViewWidget
(
self
.
todolist
)
urwid
.
connect_signal
(
self
.
viewwidget
,
'save'
,
self
.
_create_view
)
urwid
.
connect_signal
(
self
.
viewwidget
,
'save'
,
lambda
:
self
.
_create_view
(
self
.
viewwidget
.
data
))
def
hide_viewwidget
():
self
.
_viewwidget_visible
=
False
...
...
@@ -168,8 +171,26 @@ class UIApplication(CLIApplicationBase):
# the key is unknown, ignore
pass
def
_create_view
(
self
):
self
.
_add_column
(
self
.
viewwidget
.
view
,
self
.
viewwidget
.
title
)
def
_viewdata_to_view
(
self
,
p_data
):
"""
Converts a dictionary describing a view to an actual View instance.
"""
sorter
=
Sorter
(
p_data
[
'sortexpr'
])
filters
=
[]
if
not
p_data
[
'show_all'
]:
filters
.
append
(
DependencyFilter
(
self
.
todolist
))
filters
.
append
(
RelevanceFilter
())
filters
+=
get_filter_list
(
p_data
[
'filterexpr'
])
return
View
(
sorter
,
filters
,
self
.
todolist
)
def
_create_view
(
self
,
p_data
):
""" Creates a view from the data entered in the view widget. """
view
=
self
.
_viewdata_to_view
(
p_data
)
self
.
_add_column
(
view
,
p_data
[
'title'
])
self
.
_viewwidget_visible
=
False
def
_add_column
(
self
,
p_view
,
p_title
):
...
...
topydo/ui/ViewWidget.py
View file @
7b5d3c52
...
...
@@ -17,9 +17,6 @@
import
urwid
from
six
import
u
from
topydo.lib.Filter
import
get_filter_list
,
DependencyFilter
,
RelevanceFilter
from
topydo.lib.Sorter
import
Sorter
class
ViewWidget
(
urwid
.
LineBox
):
def
__init__
(
self
,
p_todolist
):
self
.
_todolist
=
p_todolist
...
...
@@ -49,30 +46,21 @@ class ViewWidget(urwid.LineBox):
urwid
.
register_signal
(
ViewWidget
,
[
'save'
,
'close'
])
@
property
def
view
(
self
):
""" Returns a tuple (title, view). """
sorter
=
Sorter
(
self
.
sortedit
.
edit_text
)
filters
=
[]
if
self
.
relevantradio
.
state
==
True
:
filters
.
append
(
DependencyFilter
(
self
.
_todolist
))
filters
.
append
(
RelevanceFilter
())
filters
+=
get_filter_list
(
self
.
filteredit
.
edit_text
.
split
())
return
self
.
_todolist
.
view
(
sorter
,
filters
)
@
view
.
setter
def
view
(
self
,
p_view
):
pass
# TODO
@
property
def
title
(
self
):
return
self
.
titleedit
.
edit_text
@
title
.
setter
def
title
(
self
,
p_title
):
self
.
titleedit
.
edit_text
=
p_title
def
data
(
self
):
return
{
'title'
:
self
.
titleedit
.
edit_text
,
'sortexpr'
:
self
.
sortedit
.
edit_text
,
'filterexpr'
:
self
.
filteredit
.
edit_text
,
'show_all'
:
self
.
allradio
.
state
,
}
@
data
.
setter
def
data
(
self
,
p_data
):
self
.
titleedit
.
edit_text
=
p_data
[
'title'
]
self
.
sortedit
.
edit_text
=
p_data
[
'sortexpr'
]
self
.
filteredit
.
edit_text
=
p_data
[
'filterexpr'
]
self
.
relevantradio
.
set_state
(
not
p_data
[
'show_all'
])
self
.
allradio
.
set_state
(
p_data
[
'show_all'
])
def
reset
(
self
):
""" Resets the form. """
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment