Tizen 2.1 base
[platform/upstream/hplip.git] / ui4 / fabgrouptable.py
1 # -*- coding: utf-8 -*-
2 #
3 # (c) Copyright 2003-2007 Hewlett-Packard Development Company, L.P.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # Author: Don Welch
20 #
21
22 # Local
23 from base.g import *
24
25 # Qt
26 from PyQt4.QtCore import *
27 from PyQt4.QtGui import *
28
29
30
31 class FABGroupTable(QTableWidget):
32     def __init__(self, parent):
33         QTableWidget.__init__(self, parent)
34         
35         self.db = None
36         
37         
38     def setDatabase(self, db):
39         self.db = db
40         
41
42     def dragMoveEvent(self, e):
43         item = self.itemAt(e.pos())
44         if item is not None:
45             group = unicode(item.text())
46             
47             if group  == u'All':
48                 e.ignore()
49                 return
50
51             names = unicode(e.mimeData().data(u'text/plain')).split(u'|')
52             group_members = self.db.group_members(group)
53             
54             if not group_members:
55                 e.accept()
56                 return
57             
58             for n in names:
59                 if n not in group_members:
60                    e.accept()
61                    return
62                 
63         e.ignore()
64         
65         
66     def dropMimeData(self, row, col, data, action):
67         items = unicode(data.data(u'text/plain')).split(u'|')
68         self.emit(SIGNAL("namesAddedToGroup"), row, items)
69         return False
70         
71         
72     def mimeTypes(self):
73         return QStringList([u'text/plain'])
74         
75