Python源码示例:PyQt5.QtCore.Qt.MatchExactly()
示例1
def get_item(self, path: List[str], item_name: str):
parents = [None]
for i, name in enumerate(path + [item_name]):
parent_model = self if i == 0 else parents[-1]
items = self.findItems(name, Qt.MatchExactly | Qt.MatchRecursive)
target_item = None
if not items: # create new item if it does not exist
target_item = self._create_item(parent_model, name, {Qt.UserRole: "", Qt.UserRole+1: ""})
else:
for item in items: # check found items with corresponding parent
if item.parent() == parents[-1]:
target_item = item
if target_item is None:
target_item = self._create_item(parent_model, name, {Qt.UserRole: "", Qt.UserRole + 1: ""})
parents.append(target_item)
return parents[-1]
示例2
def set_listview_item_bgcolor(self, item_text, qcolor_rgb):
"""Changes the background color of a list view item based on it's
case-sensitive name. There should only ever be one, however if there
is a duplicate it will be changed as well.
:param item_text: The name of the item to look for.
:param qcolor_rgb: An instance of QColor -
http://doc.qt.nokia.com/4.7-snapshot/qcolor.html
:returns: void
@author: scmcleni
"""
brush = QtGui.QBrush(qcolor_rgb)
brush.setStyle(QtCore.Qt.SolidPattern)
items = self.rule_list_widget.findItems(item_text, QtCore.Qt.MatchExactly)
for item in items:
item.setBackground(brush)
示例3
def set_listview_item_icon(self, item_text, iconame):
"""Updates the icon associated with an entry in the list view.
The icon name (iconame) is a enum indicating one of the four possible
icon types: grn, red, warn, quest. The item_text should be the rule
name.
:param string item_text: (rule name)
:param string iconame: (grn, red, warn, quest)
@author: David Kennel
"""
myicon = os.path.join(self.icon_path, self.questionmark)
if iconame == 'grn':
myicon = os.path.join(self.icon_path, self.compliant)
elif iconame == 'red':
myicon = os.path.join(self.icon_path, self.notcompliant)
elif iconame == 'warn':
myicon = os.path.join(self.icon_path, self.warning)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(myicon), QtGui.QIcon.Normal, QtGui.QIcon.Off)
items = self.rule_list_widget.findItems(item_text, QtCore.Qt.MatchExactly)
for item in items:
item.setIcon(icon)
示例4
def remove_find(self, addr):
model = self.ui.findView.model()
for item in self.ui.findView.findItems("0x%x" % addr, Qt.MatchExactly):
i = self.ui.findView.indexFromItem(item)
model.removeRow(i.row())
示例5
def remove_avoid(self, addr):
model = self.ui.avoidView.model()
for item in self.ui.avoidView.findItems("0x%x" % addr, Qt.MatchExactly):
i = self.ui.avoidView.indexFromItem(item)
model.removeRow(i.row())
示例6
def sold(self, tick):
results = self.findItems(tick.T, Qt.MatchExactly)
if results:
for row in results:
_row = row.row()
if not self.item(_row, 3).text():
tItem = QTableWidgetItem(str(tick.C))
tItem.setTextAlignment(Qt.AlignCenter)
self.setItem(_row, 3, tItem)
for j in range(self.columnCount()):
if tick.prevProfit > 0:
self.item(_row, j).setBackground(color('G'))
elif tick.prevProfit < 0:
self.item(_row, j).setBackground(color('R'))
else:
self.item(_row, j).setBackground(color('NA'))
else:
_row = self.rowCount()
self.insertRow(_row)
data = [tick.T, tick.Q, tick.AP, tick.C]
for item in range(len(data)):
tItem = QTableWidgetItem(str(data[item]))
tItem.setTextAlignment(Qt.AlignCenter)
self.setItem(_row, item, tItem)
for j in range(self.columnCount()):
if tick.C > tick.AP:
self.item(_row, j).setBackground(color('G'))
elif tick.AP < tick.C:
self.item(_row, j).setBackground(color('R'))
else:
self.item(_row, j).setBackground(color('NA'))
示例7
def collapse(self, text):
items = self.findItems(text, Qt.MatchExactly)
for item in items:
self.collapseItem(item)
示例8
def get_attr_value(self, text):
idxlist = self.client.attrs_ui.model.match(self.client.attrs_ui.model.index(0, 0), Qt.DisplayRole, text, 1, Qt.MatchExactly | Qt.MatchRecursive)
idx = idxlist[0]
idx = idx.sibling(idx.row(), 1)
item = self.client.attrs_ui.model.itemFromIndex(idx)
return item.data(Qt.UserRole).value
示例9
def add_to_AS(self, *objects):
self.AS.add_to_AS(*objects)
for obj in objects:
if self.dict_listbox[obj.class_type].findItems(str(obj), Qt.MatchExactly):
continue
self.dict_listbox[obj.class_type].addItem(str(obj))
示例10
def remove_from_AS(self, *objects):
self.AS.remove_from_AS(*objects)
for obj in objects:
item ,= self.dict_listbox[obj.class_type].findItems(str(obj), Qt.MatchExactly)
row = self.dict_listbox[obj.class_type].row(item)
self.dict_listbox[obj.class_type].takeItem(row)
示例11
def setText(self, text):
index = self.findText(text, Qt.MatchExactly)
self.setCurrentIndex(index)
示例12
def _on_hit_module_initialization_breakpoint(self, data):
items = self._breakpoints_model.findItems(data[1]['module'], Qt.MatchExactly, 2)
if len(items) > 0:
self._breakpoints_model.item(items[0].row(), 0).setText(data[1]['moduleBase'])
示例13
def _on_hit_java_class_initialization_breakpoint(self, data):
items = self._breakpoints_model.findItems(data[0], Qt.MatchExactly, 2)
if len(items) > 0:
pass
示例14
def _create_bookmark(self, index=-1, ptr='', note=''):
if ptr == '':
if isinstance(index, int) and index >= 0:
ptr = self._bookmarks_model.item(index, 0).text()
note = self._bookmarks_model.item(index, 1).text()
ptr, _ = InputDialog.input_pointer(
parent=self._app_window, input_content=ptr)
else:
ptr = utils.parse_ptr(ptr)
if ptr > 0:
ptr = hex(ptr)
if self._bookmarks_list.uppercase_hex:
ptr = ptr.upper().replace('0X', '0x')
index = self._bookmarks_model.findItems(ptr, Qt.MatchExactly)
if len(index) > 0:
index = index[0].row()
note = self._bookmarks_model.item(index, 1).text()
else:
index = -1
accept = note != ''
if note == '':
accept, note = InputDialog.input(
hint='Insert notes for %s' % ptr, input_content=note)
if accept:
if index < 0:
self.insert_bookmark(ptr, note)
else:
item = self._bookmarks_model.item(index, 0)
item.setText(ptr)
item = self._bookmarks_model.item(index, 1)
item.setText(note)
self.bookmarks[ptr] = note
示例15
def add_timer(self):
t = self.timerEdit.text()
ti = t.replace(':', '')
if not self.timerListWidget.findItems(ti, Qt.MatchExactly):
self.timerListWidget.addItem(ti)
else:
MyMessageBox.warning(self, "提示", "已存在该时间!请重新提交!", QMessageBox.Ok)
示例16
def updateSearchResults(self):
"""show only rules which match the search term
against either their rule name or their rule description;
hide all rules which don't contain a match of the search term;
show all rules if the search box is cleared
:returns: void
@author: Breen Malmberg
"""
# self.logger.log(LogPriority.DEBUG, "\n\nupdateSearchResults() method called\n\n")
foundin = []
allrules = self.rule_list_widget.findItems('.*', Qt.MatchRegExp)
searchTerm = self.searchbox.text()
# if a user clears the searchbox, show all rules
if len(self.searchbox.text()) == 0:
for r in allrules:
r.setHidden(False)
else:
for rname in self.search_text:
if str(searchTerm).lower() in str(self.search_text[rname]).lower():
foundin.append(rname)
else:
if rname in foundin:
foundin.remove(rname)
for item in allrules:
item.setHidden(True)
for rname in foundin:
items = self.rule_list_widget.findItems(rname, Qt.MatchExactly)
for item in items:
item.setHidden(False)
示例17
def collapse(self, text):
items = self.findItems(text, Qt.MatchExactly)
for item in items:
self.collapseItem(item)