UI/FindFileDialog.py

changeset 7
c679fb30c8f3
parent 6
52e8c820d0dd
child 12
1d8dd9706f46
equal deleted inserted replaced
6:52e8c820d0dd 7:c679fb30c8f3
129 # Qt bug: 129 # Qt bug:
130 # item is not user checkable if setFirstColumnSpanned is True (< 4.5.0) 130 # item is not user checkable if setFirstColumnSpanned is True (< 4.5.0)
131 131
132 itm = QTreeWidgetItem(self.__lastFileItem, [' %5d ' % line, text]) 132 itm = QTreeWidgetItem(self.__lastFileItem, [' %5d ' % line, text])
133 itm.setTextAlignment(0, Qt.AlignRight) 133 itm.setTextAlignment(0, Qt.AlignRight)
134 itm.setData(0, self.lineRole, QVariant(line)) 134 itm.setData(0, self.lineRole, line)
135 itm.setData(0, self.startRole, QVariant(start)) 135 itm.setData(0, self.startRole, start)
136 itm.setData(0, self.endRole, QVariant(end)) 136 itm.setData(0, self.endRole, end)
137 itm.setData(0, self.replaceRole, QVariant(replTxt)) 137 itm.setData(0, self.replaceRole, replTxt)
138 if self.__replaceMode: 138 if self.__replaceMode:
139 itm.setFlags(itm.flags() | Qt.ItemFlags(Qt.ItemIsUserCheckable)) 139 itm.setFlags(itm.flags() | Qt.ItemFlags(Qt.ItemIsUserCheckable))
140 itm.setCheckState(0, Qt.Checked) 140 itm.setCheckState(0, Qt.Checked)
141 self.replaceButton.setEnabled(True) 141 self.replaceButton.setEnabled(True)
142 142
438 @param itm the double clicked tree item (QTreeWidgetItem) 438 @param itm the double clicked tree item (QTreeWidgetItem)
439 @param column column that was double clicked (integer) (ignored) 439 @param column column that was double clicked (integer) (ignored)
440 """ 440 """
441 if itm.parent(): 441 if itm.parent():
442 file = itm.parent().text(0) 442 file = itm.parent().text(0)
443 line = itm.data(0, self.lineRole).toInt()[0] 443 line = itm.data(0, self.lineRole)
444 start = itm.data(0, self.startRole).toInt()[0] 444 start = itm.data(0, self.startRole)
445 end = itm.data(0, self.endRole).toInt()[0] 445 end = itm.data(0, self.endRole)
446 else: 446 else:
447 file = itm.text(0) 447 file = itm.text(0)
448 line = 1 448 line = 1
449 start = 0 449 start = 0
450 end = 0 450 end = 0
538 538
539 # replace the lines authorized by the user 539 # replace the lines authorized by the user
540 for cindex in range(itm.childCount()): 540 for cindex in range(itm.childCount()):
541 citm = itm.child(cindex) 541 citm = itm.child(cindex)
542 if citm.checkState(0) == Qt.Checked: 542 if citm.checkState(0) == Qt.Checked:
543 line = citm.data(0, self.lineRole).toInt()[0] 543 line = citm.data(0, self.lineRole)
544 rline = citm.data(0, self.replaceRole).toString() 544 rline = citm.data(0, self.replaceRole)
545 lines[line - 1] = rline 545 lines[line - 1] = rline
546 546
547 # write the file 547 # write the file
548 txt = Utilities.linesep().join(lines) 548 txt = Utilities.linesep().join(lines)
549 txt, encoding = Utilities.encode(txt, encoding) 549 txt, encoding = Utilities.encode(txt, encoding)

eric ide

mercurial