예제 #1
0
bool DebuggerShell::clearBreakpoint(const std::string& file, int line) {
  intptr_t sourceID;
  if (!resolveFileName(file, &sourceID)) {
    return false;
  }
  return breakpoints_.erase(SourceLine(sourceID, line)) != 0;
}
예제 #2
0
bool DebuggerShell::setBreakpoint(const std::string& file, int line) {
  intptr_t sourceID;
  if (!resolveFileName(file, &sourceID)) {
    return false;
  }
  breakpoints_.insert(SourceLine(sourceID, line));
  return true;
}
예제 #3
0
static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, const qreal devicePixelRatio = 1.0)
{
    QPixmap pm;

    QString name = format.name();
    if (name.startsWith(QLatin1String(":/"))) // auto-detect resources and convert them to url
        name.prepend(QLatin1String("qrc"));
    QUrl url = QUrl(name);
    name = resolveFileName(name, &url, devicePixelRatio);
    const QVariant data = doc->resource(QTextDocument::ImageResource, url);
    if (data.type() == QVariant::Pixmap || data.type() == QVariant::Image) {
        pm = qvariant_cast<QPixmap>(data);
    } else if (data.type() == QVariant::ByteArray) {
        pm.loadFromData(data.toByteArray());
    }

    if (pm.isNull()) {
#if 0
        QString context;
        // ### Qt5
        QTextBrowser *browser = qobject_cast<QTextBrowser *>(doc->parent());
        if (browser)
            context = browser->source().toString();
#endif
        // try direct loading
        QImage img;
        if (name.isEmpty() || !img.load(name))
            return QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/file-16.png"));

        pm = QPixmap::fromImage(img);
        doc->addResource(QTextDocument::ImageResource, url, pm);
    }

    if (name.contains(QStringLiteral("@2x")))
        pm.setDevicePixelRatio(2.0);

    return pm;
}
예제 #4
0
파일: portingrules.cpp 프로젝트: maxxant/qt
/*
    Loads rule xml file given by fileName, and sets up data structures.
    The rules can generally be divided into to types, replacement rules and
    info rules.

    Replacement rules has the form Qt3Symobl -> Qt4Symbol
    Info rules includes the NeedHeader, Qt3Header, Qt4Header, InhertitsQt
    rule types.
*/
void PortingRules::parseXml(QString fileName)
{
    QtSimpleXml *xmlPointer = loadXml(fileName);
    QtSimpleXml &xml = *xmlPointer;

    int ruleCount = xml[QLatin1String("Rules")].numChildren();
    ++ruleCount;

    for(int rule=0; rule<ruleCount; ++rule) {
        QtSimpleXml &currentRule = xml[QLatin1String("Rules")][rule];
        QString ruleType = currentRule.attribute(QLatin1String("Type"));

        if(isReplacementRule(ruleType)) {
            QString qt3Symbol = currentRule[QLatin1String("Qt3")].text();
            QString qt4Symbol = currentRule[QLatin1String("Qt4")].text();

            QString disable = currentRule.attribute(QLatin1String("Disable"));
            if(disable == QLatin1String("True") || disable == QLatin1String("true")) {
                disableRule(currentRule);
                continue;
            }

            if (isRuleDisabled(currentRule))
                continue;

            if(ruleType == QLatin1String("RenamedHeader")) {
              headerReplacements.insert(qt3Symbol.toLatin1(), qt4Symbol.toLatin1());
            } else if(ruleType == QLatin1String("RenamedClass") || ruleType == QLatin1String("RenamedToken") ) {
                tokenRules.append(new ClassNameReplacement(
                        qt3Symbol.toLatin1(), qt4Symbol.toLatin1()));
            } else if(ruleType == QLatin1String("RenamedEnumvalue") || ruleType == QLatin1String("RenamedType") ||
                    ruleType == QLatin1String("RenamedQtSymbol") ) {
                checkScopeAddRule(currentRule);
            }
        } else if(ruleType == QLatin1String("NeedHeader")) {
            const QByteArray className = currentRule[QLatin1String("Class")].text().toLatin1();
            const QByteArray headerName = currentRule[QLatin1String("Header")].text().toLatin1();
            neededHeaders.insert(className, headerName);
        }
        else if(ruleType == QLatin1String("qt3Header")) {
            qt3Headers += currentRule.text();
        }
        else if(ruleType == QLatin1String("qt4Header")) {
            qt4Headers += currentRule.text();
        }
        else if(ruleType == QLatin1String("InheritsQt")) {
            inheritsQtClass += currentRule.text();
        }
        else if(ruleType == QLatin1String("Qt4Class")) {
            // Get library name, make it lowercase and chop of the "Qt" prefix.
            const QByteArray libraryName = currentRule[QLatin1String("Library")].text().toLatin1().toLower().mid(2);
            classLibraryList.insert(currentRule[QLatin1String("Name")].text().toLatin1(), libraryName);
        }
    }

    QString includeFile = xml[QLatin1String("Rules")][QLatin1String("Include")].text();

    if(!includeFile.isNull()) {
        QString resolvedIncludeFile = resolveFileName(fileName, includeFile);
        if (!resolvedIncludeFile.isEmpty())
            parseXml(resolvedIncludeFile);
    }

    delete xmlPointer;
}