Merge lp:~rick-rickspencer3/pytask/date_column into lp:pytask
- date_column
- Merge into trunk
Proposed by
Ryan Macnish
Status: | Merged |
---|---|
Merged at revision: | 77 |
Proposed branch: | lp:~rick-rickspencer3/pytask/date_column |
Merge into: | lp:pytask |
Diff against target: |
339 lines (+160/-89) (has conflicts) 3 files modified
.bzrignore (+1/-0) bin/pytask (+1/-1) pytask/date_column.py (+158/-88) Text conflict in pytask/date_column.py |
To merge this branch: | bzr merge lp:~rick-rickspencer3/pytask/date_column |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ryan Macnish | Pending | ||
Review via email: mp+25509@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 77. By Ryan Macnish
-
fixed some conflicts.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file '.bzrignore' |
2 | --- .bzrignore 1970-01-01 00:00:00 +0000 |
3 | +++ .bzrignore 2010-05-18 13:41:11 +0000 |
4 | @@ -0,0 +1,1 @@ |
5 | +bin/pytaskc |
6 | |
7 | === modified file 'bin/pytask' |
8 | --- bin/pytask 2010-05-18 05:34:36 +0000 |
9 | +++ bin/pytask 2010-05-18 13:41:11 +0000 |
10 | @@ -107,7 +107,7 @@ |
11 | database_name = "pytask" |
12 | keys = ["name","priority","due","complete?"] |
13 | record_type = "url" |
14 | - type_hints = {"due":DateColumn} |
15 | + type_hints = {"due":DateColumn,"priority":IntegerColumn} |
16 | self.grid = CouchGrid(database_name, record_type=record_type,keys=keys, |
17 | editable=True, type_hints=type_hints) |
18 | |
19 | |
20 | === modified file 'pytask/date_column.py' |
21 | --- pytask/date_column.py 2010-05-18 05:34:36 +0000 |
22 | +++ pytask/date_column.py 2010-05-18 13:41:11 +0000 |
23 | @@ -1,6 +1,7 @@ |
24 | |
25 | import gobject |
26 | import gtk |
27 | +import datetime |
28 | from quickly.widgets.grid_column import StringColumn |
29 | from quickly.widgets.grid_filter import StringFilterCombo |
30 | |
31 | @@ -18,125 +19,158 @@ |
32 | default_filter = StringFilterCombo |
33 | |
34 | def __init__(self, key, index,dictionary_index, editable=True ): |
35 | - """Creates a Date |
36 | - |
37 | - Arguments: |
38 | - key - the key from the dict for the row. Also used as the title for the |
39 | - column by default. |
40 | - |
41 | - index - the position of the column in the grid. |
42 | - |
43 | - dictionary_index - the index in the ListStore where the dictionary |
44 | - for the row is stored. Typically len(dict). |
45 | - |
46 | - editable - False if the column does not allow the user to edit the |
47 | - values in the column. Defaults to True. |
48 | - |
49 | - """ |
50 | - |
51 | - StringColumn.__init__( self, key, index, dictionary_index, editable) |
52 | + """Creates a Date |
53 | + |
54 | + Arguments: |
55 | + key - the key from the dict for the row. Also used as the title for the |
56 | + column by default. |
57 | + |
58 | + index - the position of the column in the grid. |
59 | + |
60 | + dictionary_index - the index in the ListStore where the dictionary |
61 | + for the row is stored. Typically len(dict). |
62 | + |
63 | + editable - False if the column does not allow the user to edit the |
64 | + values in the column. Defaults to True. |
65 | + |
66 | + """ |
67 | + self._editable = editable |
68 | + StringColumn.__init__( self, key, index, dictionary_index, editable) |
69 | + |
70 | |
71 | def _initialize_renderer( self, editable, index ): |
72 | - """_initialize_renderer - internal function called to set up the |
73 | - CellRenderer for the column. |
74 | - |
75 | - arguments: |
76 | - |
77 | - editable - True if the column should support user editing. |
78 | - |
79 | - index - the position of the column in the grid |
80 | - |
81 | - """ |
82 | - |
83 | - self.renderer = CellRendererDate() |
84 | - self.renderer.connect("edited", self._cell_edited) |
85 | + """_initialize_renderer - internal function called to set up the |
86 | + CellRenderer for the column. |
87 | + |
88 | + arguments: |
89 | + |
90 | + editable - True if the column should support user editing. |
91 | + |
92 | + index - the position of the column in the grid |
93 | + |
94 | + """ |
95 | + |
96 | + self.renderer = CellRendererDate() |
97 | + self.renderer.set_property('editable',self._editable) |
98 | + self.renderer.connect("edited", self._cell_edited) |
99 | |
100 | def _cell_edited(self, cellrendererdate, path, new_date, data=None): |
101 | - |
102 | - iter = self.list_store.get_iter(path) |
103 | - self.list_store.set_value(iter, self.index, self.display_val(new_date)) |
104 | - |
105 | - dictionary = self.list_store.get_value(iter,self.dictionary_index) |
106 | - dictionary[self.key] = self.real_val(new_date) |
107 | - |
108 | + iter = self.list_store.get_iter(path) |
109 | + self.list_store.set_value(iter, self.index, self.display_val(new_date)) |
110 | + |
111 | + dictionary = self.list_store.get_value(iter,self.dictionary_index) |
112 | + dictionary[self.key] = self.real_val(new_date) |
113 | + |
114 | def display_val(self, val): |
115 | - """display_val - takes a real value and returns the cooresponding |
116 | - display value |
117 | - |
118 | - arguments: |
119 | - |
120 | - val - the real value to convert |
121 | - |
122 | - """ |
123 | - |
124 | - return StringColumn.display_val(self, val) |
125 | + """display_val - takes a real value and returns the cooresponding |
126 | + display value |
127 | + |
128 | + arguments: |
129 | + |
130 | + val - the real value to convert |
131 | + |
132 | + """ |
133 | + |
134 | + return StringColumn.display_val(self, val) |
135 | |
136 | |
137 | def real_val(self, val): |
138 | - """real_val - takes a display value and returns the cooresponding |
139 | - real value. |
140 | - |
141 | - arguments: |
142 | - |
143 | - val - the display value to convert |
144 | - |
145 | - """ |
146 | - return StringColumn.real_val(self, val) |
147 | - |
148 | + """real_val - takes a display value and returns the cooresponding |
149 | + real value. |
150 | + |
151 | + arguments: |
152 | + |
153 | + val - the display value to convert |
154 | + |
155 | + """ |
156 | + return StringColumn.real_val(self, val) |
157 | + |
158 | |
159 | def default_display_val(self): |
160 | - """default_dislay_val - return the value to display in the case |
161 | - where there is no real value for the column for the row. |
162 | - |
163 | - """ |
164 | - |
165 | - return "" |
166 | + """default_dislay_val - return the value to display in the case |
167 | + where there is no real value for the column for the row. |
168 | + |
169 | + """ |
170 | + |
171 | + return "" |
172 | |
173 | def _cell_edited(self, cellrenderertext, path, new_text, data=None): |
174 | - #get an iterator that points to the edited row |
175 | - if self.list_store is not None: |
176 | - iter = self.list_store.get_iter(path) |
177 | - #update the ListStore with the new text |
178 | - self.list_store.set_value(iter, self.index, self.display_val(new_text)) |
179 | - dictionary = self.list_store.get_value(iter,self.dictionary_index) |
180 | - dictionary[self.key] = self.real_val(new_text) |
181 | - |
182 | + #get an iterator that points to the edited row |
183 | + if self.list_store is not None: |
184 | + iter = self.list_store.get_iter(path) |
185 | + #update the ListStore with the new text |
186 | + self.list_store.set_value(iter, self.index, self.display_val(new_text)) |
187 | + dictionary = self.list_store.get_value(iter,self.dictionary_index) |
188 | + dictionary[self.key] = self.real_val(new_text) |
189 | |
190 | def _sort_ascending(self, x, y): |
191 | - return StringColumn._sort_ascending(self, x, y) |
192 | + return StringColumn._sort_ascending(self, x, y) |
193 | |
194 | def _sort_descending(self, x, y): |
195 | +<<<<<<< TREE |
196 | return StringColumn._sort_descending(self, x, y) |
197 | |
198 | class CellRendererDate(gtk.CellRendererText): |
199 | |
200 | +======= |
201 | + return StringColumn._sort_descending(self, x, y) |
202 | + |
203 | +class CellRendererDate(gtk.CellRendererText): |
204 | +>>>>>>> MERGE-SOURCE |
205 | __gtype_name__ = 'CellRendererDate' |
206 | |
207 | def __init__(self): |
208 | +<<<<<<< TREE |
209 | gtk.CellRendererText.__init__(self) |
210 | self.date_format = '%d/%m/%Y' |
211 | self.calendar_window = None |
212 | self.calendar = None |
213 | +======= |
214 | + gtk.CellRendererText.__init__(self) |
215 | + self.date_format = '%Y/%m/%d' |
216 | + self.calendar_window = None |
217 | + self.calendar = None |
218 | +>>>>>>> MERGE-SOURCE |
219 | |
220 | def _create_calendar(self, treeview): |
221 | - self.calendar_window = gtk.Dialog(parent=treeview.get_toplevel()) |
222 | - self.calendar_window.action_area.hide() |
223 | - self.calendar_window.set_decorated(False) |
224 | - self.calendar_window.set_property('skip-taskbar-hint', True) |
225 | - |
226 | - self.calendar = gtk.Calendar() |
227 | - self.calendar.display_options(gtk.CALENDAR_SHOW_DAY_NAMES | gtk.CALENDAR_SHOW_HEADING) |
228 | - self.calendar.connect('day-selected-double-click', self._day_selected, None) |
229 | - self.calendar.connect('key-press-event', self._day_selected) |
230 | - self.calendar.connect('focus-out-event', self._selection_cancelled) |
231 | - self.calendar_window.set_transient_for(None) # cancel the modality of dialog |
232 | - self.calendar_window.vbox.pack_start(self.calendar) |
233 | - |
234 | - # necessary for getting the (width, height) of calendar_window |
235 | - self.calendar.show() |
236 | - self.calendar_window.realize() |
237 | +<<<<<<< TREE |
238 | + self.calendar_window = gtk.Dialog(parent=treeview.get_toplevel()) |
239 | + self.calendar_window.action_area.hide() |
240 | + self.calendar_window.set_decorated(False) |
241 | + self.calendar_window.set_property('skip-taskbar-hint', True) |
242 | + |
243 | + self.calendar = gtk.Calendar() |
244 | + self.calendar.display_options(gtk.CALENDAR_SHOW_DAY_NAMES | gtk.CALENDAR_SHOW_HEADING) |
245 | + self.calendar.connect('day-selected-double-click', self._day_selected, None) |
246 | + self.calendar.connect('key-press-event', self._day_selected) |
247 | + self.calendar.connect('focus-out-event', self._selection_cancelled) |
248 | + self.calendar_window.set_transient_for(None) # cancel the modality of dialog |
249 | + self.calendar_window.vbox.pack_start(self.calendar) |
250 | + |
251 | + # necessary for getting the (width, height) of calendar_window |
252 | + self.calendar.show() |
253 | + self.calendar_window.realize() |
254 | +======= |
255 | + self.calendar_window = gtk.Dialog(parent=treeview.get_toplevel()) |
256 | + self.calendar_window.action_area.hide() |
257 | + self.calendar_window.set_decorated(False) |
258 | + self.calendar_window.set_property('skip-taskbar-hint', True) |
259 | + |
260 | + self.calendar = gtk.Calendar() |
261 | + self.calendar.display_options(gtk.CALENDAR_SHOW_DAY_NAMES | gtk.CALENDAR_SHOW_HEADING) |
262 | + self.calendar.connect('day-selected-double-click', self._day_selected, None) |
263 | + self.calendar.connect('key-press-event', self._day_selected) |
264 | + self.calendar.connect('focus-out-event', self._selection_cancelled) |
265 | + self.calendar_window.set_transient_for(None) # cancel the modality of dialog |
266 | + self.calendar_window.vbox.pack_start(self.calendar) |
267 | + |
268 | + # necessary for getting the (width, height) of calendar_window |
269 | + self.calendar.show() |
270 | + self.calendar_window.realize() |
271 | +>>>>>>> MERGE-SOURCE |
272 | |
273 | def do_start_editing(self, event, treeview, path, background_area, cell_area, flags): |
274 | +<<<<<<< TREE |
275 | if not self.get_property('editable'): |
276 | return |
277 | |
278 | @@ -153,6 +187,26 @@ |
279 | self.calendar.select_month(int(month), int(year)) |
280 | self.calendar.select_day(int(day)) |
281 | self.calendar.thaw() |
282 | +======= |
283 | + if not self.get_property('editable'): |
284 | + return |
285 | + |
286 | + if not self.calendar_window: |
287 | + self._create_calendar(treeview) |
288 | + |
289 | + # select cell's previously stored date if any exists - or today |
290 | + if self.get_property('text'): |
291 | + date = datetime.datetime.strptime(self.get_property('text'), self.date_format) |
292 | + |
293 | + else: |
294 | + date = datetime.datetime.today() |
295 | + |
296 | + self.calendar.freeze() # prevent flicker |
297 | + (year, month, day) = (date.year, date.month - 1, date.day) # datetime's month starts from one |
298 | + self.calendar.select_month(int(month), int(year)) |
299 | + self.calendar.select_day(int(day)) |
300 | + self.calendar.thaw() |
301 | +>>>>>>> MERGE-SOURCE |
302 | |
303 | # position the popup below the edited cell (and try hard to keep the popup within the toplevel window) |
304 | (tree_x, tree_y) = treeview.get_bin_window().get_origin() |
305 | @@ -163,18 +217,34 @@ |
306 | self.calendar_window.move(x, y) |
307 | |
308 | response = self.calendar_window.run() |
309 | + self.calendar_window.hide() |
310 | if response == gtk.RESPONSE_OK: |
311 | +<<<<<<< TREE |
312 | (year, month, day) = self.calendar.get_date() |
313 | date = datetime.date(year, month + 1, day).strftime (self.date_format) # gtk.Calendar's month starts from zero |
314 | self.emit('edited', path, date) |
315 | self.calendar_window.hide() |
316 | return None # don't return any editable, our gtk.Dialog did the work already |
317 | +======= |
318 | + (year, month, day) = self.calendar.get_date() |
319 | + date = datetime.date(year, month + 1, day).strftime (self.date_format) # gtk.Calendar's month starts from zero |
320 | + self.emit('edited', path, date) |
321 | + |
322 | + return None # don't return any editable, our gtk.Dialog did the work already |
323 | +>>>>>>> MERGE-SOURCE |
324 | |
325 | def _day_selected(self, calendar, event): |
326 | +<<<<<<< TREE |
327 | # event == None for day selected via doubleclick |
328 | if not event or event.type == gtk.gdk.KEY_PRESS and gtk.gdk.keyval_name(event.keyval) == 'Return': |
329 | self.calendar_window.response(gtk.RESPONSE_OK) |
330 | return True |
331 | +======= |
332 | + # event == None for day selected via doubleclick |
333 | + if not event or event.type == gtk.gdk.KEY_PRESS and gtk.gdk.keyval_name(event.keyval) == 'Return': |
334 | + self.calendar_window.response(gtk.RESPONSE_OK) |
335 | + return True |
336 | +>>>>>>> MERGE-SOURCE |
337 | |
338 | def _selection_cancelled(self, calendar, event): |
339 | self.calendar_window.response(gtk.RESPONSE_CANCEL) |