1494 odict = dict |
1498 odict = dict |
1495 dict = ndict |
1499 dict = ndict |
1496 i += 1 |
1500 i += 1 |
1497 |
1501 |
1498 if qtVariable: |
1502 if qtVariable: |
1499 vlist = self.__formatQt4Variable(qvar, qvtype) |
1503 vlist = self.__formatQtVariable(qvar, qvtype) |
1500 elif ("sipThis" in dict.keys() and len(dict) == 1) or \ |
1504 elif ("sipThis" in dict.keys() and len(dict) == 1) or \ |
1501 (len(dict) == 0 and len(udict) > 0): |
1505 (len(dict) == 0 and len(udict) > 0): |
1502 if access: |
1506 if access: |
1503 exec 'qvar = udict%s' % access |
1507 exec 'qvar = udict%s' % access |
1504 # this has to be in line with VariablesViewer.indicators |
1508 # this has to be in line with VariablesViewer.indicators |
1505 elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]: |
1509 elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]: |
1506 exec 'qvar = udict["%s"][%s]' % (rvar[0][:-2], rvar[1]) |
1510 exec 'qvar = udict["%s"][%s]' % (rvar[0][:-2], rvar[1]) |
1507 else: |
1511 else: |
1508 qvar = udict[var[-1]] |
1512 qvar = udict[var[-1]] |
1509 qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] |
1513 qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] |
1510 if qvtype.startswith("PyQt4"): |
1514 if qvtype.startswith(("PyQt4", "PyQt5")): |
1511 vlist = self.__formatQt4Variable(qvar, qvtype) |
1515 vlist = self.__formatQtVariable(qvar, qvtype) |
1512 else: |
1516 else: |
1513 vlist = [] |
1517 vlist = [] |
1514 else: |
1518 else: |
1515 qtVariable = False |
1519 qtVariable = False |
1516 if len(dict) == 0 and len(udict) > 0: |
1520 if len(dict) == 0 and len(udict) > 0: |
1520 elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]: |
1524 elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]: |
1521 exec 'qvar = udict["%s"][%s]' % (rvar[0][:-2], rvar[1]) |
1525 exec 'qvar = udict["%s"][%s]' % (rvar[0][:-2], rvar[1]) |
1522 else: |
1526 else: |
1523 qvar = udict[var[-1]] |
1527 qvar = udict[var[-1]] |
1524 qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] |
1528 qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] |
1525 if qvtype.startswith("PyQt4"): |
1529 if qvtype.startswith(("PyQt4", "PyQt5")): |
1526 qtVariable = True |
1530 qtVariable = True |
1527 |
1531 |
1528 if qtVariable: |
1532 if qtVariable: |
1529 vlist = self.__formatQt4Variable(qvar, qvtype) |
1533 vlist = self.__formatQtVariable(qvar, qvtype) |
1530 else: |
1534 else: |
1531 # format the dictionary found |
1535 # format the dictionary found |
1532 if dictkeys is None: |
1536 if dictkeys is None: |
1533 dictkeys = dict.keys() |
1537 dictkeys = dict.keys() |
1534 else: |
1538 else: |
1557 pass |
1561 pass |
1558 |
1562 |
1559 self.write('%s%s\n' % ( |
1563 self.write('%s%s\n' % ( |
1560 DebugProtocol.ResponseVariable, unicode(varlist))) |
1564 DebugProtocol.ResponseVariable, unicode(varlist))) |
1561 |
1565 |
1562 def __formatQt4Variable(self, value, vtype): |
1566 def __formatQtVariable(self, value, vtype): |
1563 """ |
1567 """ |
1564 Private method to produce a formated output of a simple Qt4/Qt5 type. |
1568 Private method to produce a formated output of a simple Qt4/Qt5 type. |
1565 |
1569 |
1566 @param value variable to be formated |
1570 @param value variable to be formated |
1567 @param vtype type of the variable to be formatted (string) |
1571 @param vtype type of the variable to be formatted (string) |
1607 varlist.append(("width", "float", "%g" % value.width())) |
1611 varlist.append(("width", "float", "%g" % value.width())) |
1608 varlist.append(("height", "float", "%g" % value.height())) |
1612 varlist.append(("height", "float", "%g" % value.height())) |
1609 elif qttype == 'QColor': |
1613 elif qttype == 'QColor': |
1610 varlist.append(("name", "str", "%s" % value.name())) |
1614 varlist.append(("name", "str", "%s" % value.name())) |
1611 r, g, b, a = value.getRgb() |
1615 r, g, b, a = value.getRgb() |
1612 varlist.append(("rgb", "int", "%d, %d, %d, %d" % (r, g, b, a))) |
1616 varlist.append(("rgba", "int", "%d, %d, %d, %d" % (r, g, b, a))) |
1613 h, s, v, a = value.getHsv() |
1617 h, s, v, a = value.getHsv() |
1614 varlist.append(("hsv", "int", "%d, %d, %d, %d" % (h, s, v, a))) |
1618 varlist.append(("hsva", "int", "%d, %d, %d, %d" % (h, s, v, a))) |
1615 c, m, y, k, a = value.getCmyk() |
1619 c, m, y, k, a = value.getCmyk() |
1616 varlist.append( |
1620 varlist.append( |
1617 ("cmyk", "int", "%d, %d, %d, %d, %d" % (c, m, y, k, a))) |
1621 ("cmyka", "int", "%d, %d, %d, %d, %d" % (c, m, y, k, a))) |
1618 elif qttype == 'QDate': |
1622 elif qttype == 'QDate': |
1619 varlist.append(("", "QDate", "%s" % value.toString())) |
1623 varlist.append(("", "QDate", "%s" % value.toString())) |
1620 elif qttype == 'QTime': |
1624 elif qttype == 'QTime': |
1621 varlist.append(("", "QTime", "%s" % value.toString())) |
1625 varlist.append(("", "QTime", "%s" % value.toString())) |
1622 elif qttype == 'QDateTime': |
1626 elif qttype == 'QDateTime': |