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
...
@@ -25,6 +25,8 @@ from topydo.ui.TodoListWidget import TodoListWidget
from
topydo.ui.ViewWidget
import
ViewWidget
from
topydo.ui.ViewWidget
import
ViewWidget
from
topydo.lib.Config
import
config
from
topydo.lib.Config
import
config
from
topydo.lib.Sorter
import
Sorter
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
TodoFile
from
topydo.lib
import
TodoList
from
topydo.lib
import
TodoList
...
@@ -54,7 +56,8 @@ class UIApplication(CLIApplicationBase):
...
@@ -54,7 +56,8 @@ class UIApplication(CLIApplicationBase):
# view widget
# view widget
self
.
viewwidget
=
ViewWidget
(
self
.
todolist
)
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
():
def
hide_viewwidget
():
self
.
_viewwidget_visible
=
False
self
.
_viewwidget_visible
=
False
...
@@ -168,8 +171,26 @@ class UIApplication(CLIApplicationBase):
...
@@ -168,8 +171,26 @@ class UIApplication(CLIApplicationBase):
# the key is unknown, ignore
# the key is unknown, ignore
pass
pass
def
_create_view
(
self
):
def
_viewdata_to_view
(
self
,
p_data
):
self
.
_add_column
(
self
.
viewwidget
.
view
,
self
.
viewwidget
.
title
)
"""
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
self
.
_viewwidget_visible
=
False
def
_add_column
(
self
,
p_view
,
p_title
):
def
_add_column
(
self
,
p_view
,
p_title
):
...
...
topydo/ui/ViewWidget.py
View file @
7b5d3c52
...
@@ -17,9 +17,6 @@
...
@@ -17,9 +17,6 @@
import
urwid
import
urwid
from
six
import
u
from
six
import
u
from
topydo.lib.Filter
import
get_filter_list
,
DependencyFilter
,
RelevanceFilter
from
topydo.lib.Sorter
import
Sorter
class
ViewWidget
(
urwid
.
LineBox
):
class
ViewWidget
(
urwid
.
LineBox
):
def
__init__
(
self
,
p_todolist
):
def
__init__
(
self
,
p_todolist
):
self
.
_todolist
=
p_todolist
self
.
_todolist
=
p_todolist
...
@@ -49,30 +46,21 @@ class ViewWidget(urwid.LineBox):
...
@@ -49,30 +46,21 @@ class ViewWidget(urwid.LineBox):
urwid
.
register_signal
(
ViewWidget
,
[
'save'
,
'close'
])
urwid
.
register_signal
(
ViewWidget
,
[
'save'
,
'close'
])
@
property
@
property
def
view
(
self
):
def
data
(
self
):
""" Returns a tuple (title, view). """
return
{
sorter
=
Sorter
(
self
.
sortedit
.
edit_text
)
'title'
:
self
.
titleedit
.
edit_text
,
filters
=
[]
'sortexpr'
:
self
.
sortedit
.
edit_text
,
'filterexpr'
:
self
.
filteredit
.
edit_text
,
if
self
.
relevantradio
.
state
==
True
:
'show_all'
:
self
.
allradio
.
state
,
filters
.
append
(
DependencyFilter
(
self
.
_todolist
))
}
filters
.
append
(
RelevanceFilter
())
@
data
.
setter
filters
+=
get_filter_list
(
self
.
filteredit
.
edit_text
.
split
())
def
data
(
self
,
p_data
):
self
.
titleedit
.
edit_text
=
p_data
[
'title'
]
return
self
.
_todolist
.
view
(
sorter
,
filters
)
self
.
sortedit
.
edit_text
=
p_data
[
'sortexpr'
]
self
.
filteredit
.
edit_text
=
p_data
[
'filterexpr'
]
@
view
.
setter
self
.
relevantradio
.
set_state
(
not
p_data
[
'show_all'
])
def
view
(
self
,
p_view
):
self
.
allradio
.
set_state
(
p_data
[
'show_all'
])
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
reset
(
self
):
def
reset
(
self
):
""" Resets the form. """
""" 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