Subversion Repositories basico

Rev

Rev 240 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 240 Rev 241
Line 22... Line 22...
22
from datetime import datetime
22
from datetime import datetime
23
from dateutil import parser as dateparser
23
from dateutil import parser as dateparser
24
24
25
from basico.core.service import Service
25
from basico.core.service import Service
26
from basico.widgets.sapnoteview import SAPNoteView
26
from basico.widgets.sapnoteview import SAPNoteView
-
 
27
from basico.widgets.collections import CollectionsMgtView
27
28
28
29
29
class SAPNoteViewMenu(SAPNoteView, Service):
30
class SAPNoteViewMenu(SAPNoteView, Service):
30
    view = 'component'
31
    view = 'component'
31
32
Line 55... Line 56...
55
        self.set_enable_search(True)
56
        self.set_enable_search(True)
56
        self.set_hover_selection(False)
57
        self.set_hover_selection(False)
57
        self.set_grid_lines(Gtk.TreeViewGridLines.NONE)
58
        self.set_grid_lines(Gtk.TreeViewGridLines.NONE)
58
        self.set_level_indentation(0)
59
        self.set_level_indentation(0)
59
        self.sig_selection_changed = self.selection.connect('changed', self.row_changed)
60
        self.sig_selection_changed = self.selection.connect('changed', self.row_changed)
60
-
 
-
 
61
        self.connect('button_press_event', self.right_click)
61
62
62
    def refresh(self):
63
    def refresh(self):
63
        visor = self.gui.get_widget('visor')
64
        visor = self.gui.get_widget('visor')
64
        try:
65
        try:
65
            self.set_view(self.view)
66
            self.set_view(self.view)
Line 78... Line 79...
78
79
79
            try:
80
            try:
80
                model, treeiter = selection.get_selected()
81
                model, treeiter = selection.get_selected()
81
                row = model[treeiter][0]
82
                row = model[treeiter][0]
82
                self.row_type, self.cid = row.split('@')
83
                self.row_type, self.cid = row.split('@')
83
                # ~ self.debug("%s - %s" % (self.row_type, self.cid))
-
 
-
 
84
                self.debug("%s - %s" % (self.row_type, self.cid))
84
                iter_has_child = model.iter_has_child(treeiter)
85
                iter_has_child = model.iter_has_child(treeiter)
85
86
86
                if self.row_type == 'collection':
87
                if self.row_type == 'collection':
87
                    if not iter_has_child:
88
                    if not iter_has_child:
88
                        matches = self.db.get_notes_by_node(self.row_type, self.cid)
89
                        matches = self.db.get_notes_by_node(self.row_type, self.cid)
89
                        visor.populate_sapnotes(matches, self.cid)
90
                        visor.populate_sapnotes(matches, self.cid)
90
                    else:
91
                    else:
91
                        visor.populate_sapnotes([])
-
 
-
 
92
                        matches = self.db.get_notes_by_node(self.row_type, self.cid)
-
 
93
                        if len(matches) > 0:
-
 
94
                            visor.populate_sapnotes(matches)
-
 
95
                        else:
-
 
96
                            visor.populate_sapnotes([])
92
                else:
97
                else:
93
                    matches = self.db.get_notes_by_node(self.row_type, self.cid)
98
                    matches = self.db.get_notes_by_node(self.row_type, self.cid)
94
                    visor.populate_sapnotes(matches, self.cid)
99
                    visor.populate_sapnotes(matches, self.cid)
95
            except AttributeError as error:
100
            except AttributeError as error:
96
                pass
101
                pass
97
            except TypeError:
102
            except TypeError:
98
                pass
103
                pass
99
            except Exception as error:
104
            except Exception as error:
100
                self.debug(error)
105
                self.debug(error)
101
                # ~ self.print_traceback()
106
                # ~ self.print_traceback()
-
 
107
-
 
108
-
 
109
    def right_click(self, treeview, event, data=None):
-
 
110
        if event.button == 3:
-
 
111
            rect = Gdk.Rectangle()
-
 
112
            rect.x = x = int(event.x)
-
 
113
            rect.y = y = int(event.y)
-
 
114
            pthinfo = treeview.get_path_at_pos(x,y)
-
 
115
            if pthinfo is not None:
-
 
116
                path,col,cellx,celly = pthinfo
-
 
117
                model = treeview.get_model()
-
 
118
                treeiter = model.get_iter(path)
-
 
119
                rid = model[treeiter][0]
-
 
120
                rtype = rid[:rid.find('@')]
-
 
121
                if rtype == 'collection':
-
 
122
                    popcollections = self.gui.add_widget('gtk_popover_button_manage_collections_single_note', Gtk.Popover.new(treeview))
-
 
123
                    popcollections.set_position(Gtk.PositionType.RIGHT)
-
 
124
                    popcollections.set_pointing_to(rect)
-
 
125
                    popcollections.add(CollectionsMgtView(self.app, '0000000000', popcollections))
-
 
126
                    self.cb.gui_show_popover(None, popcollections)
102
127
103
128
104
    def set_view(self, view=None):
129
    def set_view(self, view=None):
105
        statusbar = self.gui.get_widget('widget_statusbar')
130
        statusbar = self.gui.get_widget('widget_statusbar')
106
        # FIXME: Get last view visited from config
131
        # FIXME: Get last view visited from config