Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/model.py
blob: 398bd81e0323562ec7ee496581ce3a2bc8d0e511 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# -*- coding: utf-8 -*-
#
#Copyright (C) 2010-2012, Yader Velasquez
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

import gtk
import pygtk
from gettext import gettext as _
import logging
import gobject
import calendario
log = logging.getLogger('Calendario-Model-Log')

class ComboBoxModel(object):
    '''Models for ComboBox'''
    def __init__(self):

        self.category = [_("Personal"), _("Work"), _("Study")]
        self.priority = [_("Low"), _("Medium"), _("High")]

    def get_category_model(self):
        '''return the model for the category ComboBox'''
        model = gtk.ListStore(str)
        for item in self.category:
            model.append([item])

        return model

    def get_priority_model(self):
        '''return the model for the categoty ComboBox'''
        model = gtk.ListStore(str)
        for item in self.priority:
            model.append([item])
            
        return model

class TasksModel(object):
    '''Model for tasks treeview'''
    def __init__(self, tasks_list):
        self.tasks =  tasks_list

    def get_model(self):
        model = gtk.ListStore(
                gobject.TYPE_INT,
                gobject.TYPE_STRING,
                gobject.TYPE_STRING,
                gobject.TYPE_STRING,
                gobject.TYPE_BOOLEAN)

        for o in self.tasks:

            c = o.get_category()
            if c == 0:
                category = _("Personal")
            elif c == 1:
                category = _("Work")
            elif c == 2:
                category = _("Study")
            else:
                category = ''
            
            p = o.get_priority()
            if p == 0:
                priority = _("Low")
            elif p == 1:
                priority = _("Medium")
            elif p == 2:
                priority = _("High")
            else:
                priority = ''

            if o.get_complete() == 1:
                status = True
                task = calendario.strike_string(o.get_task())
            else:
                status = False
                task = o.get_task()

            model.append([o.get_task_id(), task, category, priority, status])
        return model