14 return str(self.text()).lower()<str(other.text()).lower()
17 """ The TableView widget fills itself using a DataAccessor.
24 logging.debug(__name__ +
": __init__")
25 AbstractView.__init__(self)
26 QTableWidget.__init__(self, parent)
38 self.setSortingEnabled(
False)
39 self.verticalHeader().hide()
40 self.setSelectionMode(QTableWidget.SingleSelection)
41 self.setSelectionBehavior(QAbstractItemView.SelectRows)
42 self.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding))
50 """ Set a list of columns that shall be shown.
55 """ Sets the DataAccessor from which the nodes are created.
57 You need to call updateContent() in order to make the changes visible.
59 if not isinstance(accessor, BasicDataAccessor):
60 raise TypeError(__name__ +
" requires data accessor of type BasicDataAccessor.")
61 AbstractView.setDataAccessor(self, accessor)
64 """ Stop all running operations.
69 """ Deletes all items in the TableView
72 QTableWidget.clear(self)
74 self.setSortingEnabled(
False)
78 """ Clear the TableView and refill it.
80 logging.debug(__name__ +
": updateContent")
92 for object
in objects:
94 while thread.isRunning():
95 if not Application.NO_PROCESS_EVENTS:
96 QCoreApplication.instance().processEvents()
100 properties+=[thread.returnValue()]
106 for ps
in properties:
108 if not property[1]
in ranking.keys():
109 ranking[property[1]]=1
110 if property[0]!=
"Category":
112 elif property[1]==
"Label":
113 ranking[property[1]]+=100000
114 elif property[1]==
"Name":
115 ranking[property[1]]+=10000
117 ranking[property[1]]+=1
118 self._columns.sort(
lambda x,y: cmp(-ranking[x],-ranking[y]))
119 self.setColumnCount(len(self.
_columns))
120 self.setHorizontalHeaderLabels(self.
_columns)
122 for object
in objects:
127 if not Application.NO_PROCESS_EVENTS:
128 QCoreApplication.instance().processEvents()
136 self.resizeColumnToContents(i)
142 """ Create item for an object.
145 self.setRowCount(self.rowCount()+1)
146 height=Property.DEFAULT_HEIGHT
147 firstColumnDone=
False
148 for property
in properties:
149 if property!=
None and property[1]
in self.
_columns:
150 i=self._columns.index(property[1])
151 if property[0]
in [
"MultilineString",
"Double"]:
152 propertyWidget=PropertyView.propertyWidgetFromProperty(property)
153 if propertyWidget.properyHeight()>height:
154 height=propertyWidget.properyHeight()
155 text=str(propertyWidget.value())
157 text=str(property[2])
159 item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
161 self.setItem(row,i,item)
164 if not firstColumnDone:
165 item=QTableWidgetItem(
"")
166 item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
169 self.verticalHeader().resizeSection(row,height)
172 """ Emits signal selected that the TabController can connect to.
174 logging.debug(__name__ +
": itemSelectionChanged")
177 if self.item(self.currentRow(),self.
_firstColumn)!=
None:
178 self.emit(SIGNAL(
"selected"), self.item(self.currentRow(),self.
_firstColumn).object)
180 self.emit(SIGNAL(
"selected"),
None)
183 """ Mark an object in the TableView as selected.
184 Remember position an name of object in order to restore the selection.
186 logging.debug(__name__ +
": select")
188 for i
in range(self.rowCount()):
196 self.setCurrentItem(item)
200 """ Return the row containing the selected object.
201 First search for object by name. If it is not found use position.
203 for i
in range(self.rowCount()):
208 if self.rowCount()>0:
214 """ Restore selection.
216 logging.debug(__name__ +
": restoreSelection")
220 self.setCurrentCell(select,0)
224 """ Return currently selected object.
226 If selection unknown return first object.
239 QTableWidget.mousePressEvent(self,event)
240 if event.button()==Qt.RightButton:
241 self.emit(SIGNAL(
"mouseRightPressed"), event.globalPos())
def allDataObjectChildren