| Home | Trees | Indices | Help |
|
|---|
|
|
1 # ============================================================================
2 #
3 # Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved.
4 # www.conceptive.be / project-camelot@conceptive.be
5 #
6 # This file is part of the Camelot Library.
7 #
8 # This file may be used under the terms of the GNU General Public
9 # License version 2.0 as published by the Free Software Foundation
10 # and appearing in the file LICENSE.GPL included in the packaging of
11 # this file. Please review the following information to ensure GNU
12 # General Public Licensing requirements will be met:
13 # http://www.trolltech.com/products/qt/opensource.html
14 #
15 # If you are unsure which license is appropriate for your use, please
16 # review the following information:
17 # http://www.trolltech.com/products/qt/licensing.html or contact
18 # project-camelot@conceptive.be.
19 #
20 # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21 # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 #
23 # For use of this library in commercial applications, please contact
24 # project-camelot@conceptive.be
25 #
26 # ============================================================================
27
28 """custom tree and tree-items widgets"""
29
30 import logging
31
32 logger = logging.getLogger('camelot.view.controls.modeltree')
33
34 from PyQt4 import QtGui
35 from PyQt4 import QtCore
36 from PyQt4.QtCore import Qt
37
38 from camelot.view.art import Icon
39
40 QT_MAJOR_VERSION = float('.'.join(str(QtCore.QT_VERSION_STR).split('.')[0:2]))
41
42
44 """Custom tree item widget"""
45
47 logger.debug('creating new modelitem')
48 QtGui.QTreeWidgetItem.__init__(self, parent, columns_names)
49 self.column = 0
50 self.set_icon()
51
56
61
62
64 """Custom tree widget"""
65
67 logger.debug('creating new modeltree')
68 QtGui.QTreeWidget.__init__(self, parent)
69 # we don't select entire rows
70 self.setSelectionBehavior(QtGui.QAbstractItemView.SelectItems)
71 # we track mouse movement when no button is pressed
72 self.setMouseTracking(True)
73 self.parent = parent
74 self.header_labels = header_labels
75 self.clear_model_items()
76 self.fix_header_labels()
77
79 if QT_MAJOR_VERSION > 4.3:
80 self.setHeaderHidden(True)
81 else:
82 self.setHeaderLabels(self.header_labels)
83
86
88 """Custom context menu"""
89 if event.button() == Qt.RightButton:
90 self.emit(QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'),
91 event.pos())
92 event.accept()
93 else:
94 QtGui.QTreeWidget.mousePressEvent(self, event)
95
102
104 if not self.modelitems:
105 return
106
107 for item in self.modelitems:
108 item._underline(False)
109
110 item = self.itemAt(self.mapFromGlobal(self.cursor().pos()))
111 if item:
112 item._underline(True)
113
115 item = self.itemAt(self.mapFromGlobal(self.cursor().pos()))
116 if item:
117 self.setCurrentItem(item)
118
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sat Jun 12 15:42:14 2010 | http://epydoc.sourceforge.net |