Exemple #1
0
static bool addFilesToResource(const Utils::FileName &resourceFile,
                               const QStringList &filePaths,
                               QStringList *notAdded,
                               const QString &prefix,
                               const QString &lang)
{
    if (notAdded)
        *notAdded = filePaths;

    ResourceFile file(resourceFile.toString());
    if (file.load() != Core::IDocument::OpenResult::Success)
        return false;

    int index = file.indexOfPrefix(prefix, lang);
    if (index == -1)
        index = file.addPrefix(prefix, lang);

    if (notAdded)
        notAdded->clear();
    foreach (const QString &path, filePaths) {
        if (file.contains(index, path)) {
            if (notAdded)
                *notAdded << path;
        } else {
            file.addFile(index, path);
        }
    }

    Core::FileChangeBlocker changeGuard(resourceFile.toString());
    file.save();

    return true;
}
QUrl DiscontConverter::convert(const Utils::FileName file, const QString& input)
{
    QString inputFileName = file.toString()+QString::fromLatin1("Temp");
    QFile inputFile(inputFileName);
    if(inputFile.exists())
        inputFile.remove();
    inputFile.open(QIODevice::WriteOnly);
    inputFile.write(input.toUtf8());
    inputFile.close();

    QString outputFileName = QFileInfo(file.toString()).baseName() + QString::fromLatin1(".html");
    outputFileName = QFileInfo(file.toString()).absolutePath() + QString::fromLatin1("/") + outputFileName;

    QString command = QString(QString::fromLatin1("markdown %1")).arg(inputFileName);
    QProcess process;
    process.start(command);
    process.waitForFinished();

    inputFile.remove();
    QString outputstring = QString::fromLatin1(process.readAllStandardOutput());
    QFile outputfile(outputFileName);
    if(outputfile.exists())
        outputfile.remove();
    outputfile.open(QIODevice::WriteOnly);
    outputfile.write(outputstring.toUtf8());
    outputfile.close();
    QString url = QString::fromLatin1("file://") + outputFileName;
    return QUrl(url);
}
Exemple #3
0
bool ROSUtils::generateCodeBlocksProjectFile(QProcess *process, const Utils::FileName &sourceDir, const Utils::FileName &buildDir)
{
    QString cmd = QLatin1String("cmake ") + sourceDir.toString() + QLatin1String(" -G \"CodeBlocks - Unix Makefiles\"");
    bool results = false;
    process->setWorkingDirectory(buildDir.toString());
    process->start(QLatin1String("bash"), QStringList() << QLatin1String("-c") << cmd);
    process->waitForFinished();
    if (process->exitStatus() != QProcess::CrashExit)
    {
      results  = true;
    }
    return results;
}
ResourceTopLevelNode::ResourceTopLevelNode(const Utils::FileName &filePath, FolderNode *parent)
    : ProjectExplorer::FolderNode(filePath)
{
    setIcon(Core::FileIconProvider::icon(filePath.toString()));
    m_document = new ResourceFileWatcher(this);
    Core::DocumentManager::addDocument(m_document);

    Utils::FileName base = parent->path();
    if (filePath.isChildOf(base))
        setDisplayName(filePath.relativeChildPath(base).toString());
    else
        setDisplayName(filePath.toString());
}
Exemple #5
0
void BlackBerryDeployConfiguration::setupBarDescriptor()
{
    Qt4ProjectManager::Qt4BuildConfiguration *bc = qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration *>(target()->activeBuildConfiguration());
    if (!bc || !target()->kit())
        return;

    Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(target()->kit());
    QString projectName = target()->project()->displayName();

    if (deviceType == Constants::QNX_BB_OS_TYPE) {
        const QLatin1String barDescriptorFileName("bar-descriptor.xml");
        Utils::FileName barDescriptorPath = Utils::FileName::fromString(target()->project()->projectDirectory()).appendPath(barDescriptorFileName);
        const QFile barDescriptorFile(barDescriptorPath.toString());
        if (barDescriptorFile.exists())
            return;

        Utils::FileReader reader;
        QString barDescriptorTemplate;
        if (QDir(Utils::FileName::fromString(target()->project()->projectDirectory()).appendPath(QLatin1String("qml")).toString()).exists())
            barDescriptorTemplate = Core::ICore::resourcePath()
                    + QLatin1String("/templates/wizards/bb-quickapp/") + barDescriptorFileName;
        else
            barDescriptorTemplate = Core::ICore::resourcePath()
                    + QLatin1String("/templates/wizards/bb-guiapp/") + barDescriptorFileName;


        if (!reader.fetch(barDescriptorTemplate)) {
            QMessageBox::warning(Core::ICore::mainWindow(),
                                 tr("Error while setting up bar descriptor"),
                                 tr("Reading bar descriptor template failed"),
                                 QMessageBox::Ok);
            return;
        }

        QString content = QString::fromUtf8(reader.data());
        content.replace(QLatin1String("%ProjectName%"), projectName);
        Utils::FileSaver writer(barDescriptorFile.fileName(), QIODevice::WriteOnly);
        writer.write(content.toUtf8());
        if (!writer.finalize()) {
            QMessageBox::warning(Core::ICore::mainWindow(),
                                 tr("Error while setting up bar descriptor"),
                                 tr("Failure writing bar descriptor file."),
                                 QMessageBox::Ok);
            return;
        }

        // Add the Bar Descriptor to the existing project
        if (target()->project()->rootProjectNode())
            addBarDescriptorToProject(barDescriptorPath.toString());
    }
}
Exemple #6
0
void GccToolChain::addToEnvironment(Utils::Environment &env) const
{
    if (!m_compilerCommand.isEmpty()) {
        Utils::FileName path = m_compilerCommand.parentDir();
        env.prependOrSetPath(path.toString());
    }
}
RvctToolChain::RvctVersion RvctToolChain::version(const Utils::FileName &rvctPath)
{
    RvctToolChain::RvctVersion v;

    QProcess armcc;
    armcc.start(rvctPath.toString(), QStringList(QLatin1String("--version_number")));
    if (!armcc.waitForStarted()) {
        qWarning("Unable to run rvct binary '%s' when trying to determine version.", qPrintable(rvctPath.toUserOutput()));
        return v;
    }
    armcc.closeWriteChannel();
    if (!armcc.waitForFinished()) {
        Utils::SynchronousProcess::stopProcess(armcc);
        qWarning("Timeout running rvct binary '%s' trying to determine version.", qPrintable(rvctPath.toUserOutput()));
        return v;
    }
    if (armcc.exitStatus() != QProcess::NormalExit) {
        qWarning("A crash occurred when running rvct binary '%s' trying to determine version.", qPrintable(rvctPath.toUserOutput()));
        return v;
    }
    QString versionLine = QString::fromLocal8Bit(armcc.readAllStandardOutput());
    versionLine += QString::fromLocal8Bit(armcc.readAllStandardError());
    QRegExp versionRegExp(QLatin1String("^(\\d)(\\d)0*([1-9]\\d*)"), Qt::CaseInsensitive);
    Q_ASSERT(versionRegExp.isValid());

    if (versionRegExp.indexIn(versionLine) != -1) {
        v.majorVersion = versionRegExp.cap(1).toInt();
        v.minorVersion = versionRegExp.cap(2).toInt();
        v.build = versionRegExp.cap(3).toInt();
    }
    return v;
}
Exemple #8
0
bool ROSUtils::sourceWorkspace(QProcess *process, const Utils::FileName &workspaceDir, const QString &rosDistribution)
{
  bool results = false;
  Utils::FileName ws(workspaceDir);
  Utils::FileName devDir(workspaceDir);
  devDir.appendPath(QLatin1String("devel"));

  if (sourceROS(process, rosDistribution))
  {
    results = true;
    if (!hasBuildDirectory(workspaceDir) || !hasDevelDirectory(workspaceDir))
    {
      results = initializeWorkspace(process, workspaceDir, rosDistribution);
    }

    if (results)
    {
      if (sourceWorkspaceHelper(process, devDir.appendPath(QLatin1String("setup.bash")).toString()))
      {
        results = true;
      }
      else
      {
        results = false;
        qDebug() << "Failed to source workspace: " << workspaceDir.toString();
      }
    }
  }

  return results;
}
Exemple #9
0
bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
{
    QStringList arguments;
    arguments << QLatin1String("mergetool") << QLatin1String("-y");
    if (!files.isEmpty()) {
        if (m_client->gitVersion() < 0x010708) {
            Core::AsynchronousMessageBox::warning(tr("Error"),
                                                   tr("File input for the merge tool requires Git 1.7.8, or later."));
            return false;
        }
        arguments << files;
    }
    m_process = new MergeToolProcess(this);
    m_process->setWorkingDirectory(workingDirectory);
    const Utils::FileName binary = m_client->vcsBinary();
    VcsOutputWindow::appendCommand(workingDirectory, binary, arguments);
    m_process->start(binary.toString(), arguments);
    if (m_process->waitForStarted()) {
        connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), this, &MergeTool::done);
        connect(m_process, &QIODevice::readyRead, this, &MergeTool::readData);
    } else {
        delete m_process;
        m_process = 0;
        return false;
    }
    return true;
}
Exemple #10
0
void IosSimulatorToolHandlerPrivate::requestRunApp(const QString &bundlePath,
                                                   const QStringList &extraArgs,
                                                   IosToolHandler::RunKind runType,
                                                   const QString &deviceId, int timeout)
{
    Q_UNUSED(timeout);
    this->bundlePath = bundlePath;
    this->deviceId = deviceId;
    this->runKind = runType;
    QStringList args;

    args << QLatin1String("launch") << bundlePath;
    Utils::FileName devPath = IosConfigurations::developerPath();
    if (!devPath.isEmpty())
        args << QLatin1String("--developer-path") << devPath.toString();
    addDeviceArguments(args);
    switch (runType) {
    case IosToolHandler::NormalRun:
        break;
    case IosToolHandler::DebugRun:
        args << QLatin1String("--wait-for-debugger");
        break;
    }
    args << QLatin1String("--args") << extraArgs;
    op = OpAppRun;
    start(IosToolHandler::iosSimulatorToolPath(), args);
}
BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileName &qmakePath, bool isAutoDetected, const QString &autoDetectionSource)
{
    QHash<QString, QString> versionInfo;
    bool success = BaseQtVersion::queryQMakeVariables(qmakePath, &versionInfo);
    if (!success)
        return 0;
    Utils::FileName mkspec = BaseQtVersion::mkspecFromVersionInfo(versionInfo);

    ProFileGlobals globals;
    globals.setProperties(versionInfo);
    ProMessageHandler msgHandler(true);
    ProFileCacheManager::instance()->incRefCount();
    QMakeParser parser(ProFileCacheManager::instance()->cache(), &msgHandler);
    ProFileEvaluator evaluator(&globals, &parser, &msgHandler);
    evaluator.loadNamedSpec(mkspec.toString(), false);

    QList<QtVersionFactory *> factories = ExtensionSystem::PluginManager::getObjects<QtVersionFactory>();
    qSort(factories.begin(), factories.end(), &sortByPriority);

    foreach (QtVersionFactory *factory, factories) {
        BaseQtVersion *ver = factory->create(qmakePath, &evaluator, isAutoDetected, autoDetectionSource);
        if (ver) {
            ProFileCacheManager::instance()->decRefCount();
            return ver;
        }
    }
Exemple #12
0
bool QMakeStep::init()
{
    Qt4BuildConfiguration *qt4bc = qt4BuildConfiguration();
    const QtSupport::BaseQtVersion *qtVersion = QtSupport::QtProfileInformation::qtVersion(target()->profile());

    if (!qtVersion)
        return false;

    QString args = allArguments();
    QString workingDirectory;

    if (qt4bc->subNodeBuild())
        workingDirectory = qt4bc->subNodeBuild()->buildDir();
    else
        workingDirectory = qt4bc->buildDirectory();

    Utils::FileName program = qtVersion->qmakeCommand();

    QString makefile = workingDirectory;

    if (qt4bc->subNodeBuild()) {
        if (!qt4bc->subNodeBuild()->makefile().isEmpty())
            makefile.append(qt4bc->subNodeBuild()->makefile());
        else
            makefile.append(QLatin1String("/Makefile"));
    } else if (!qt4bc->makefile().isEmpty()) {
        makefile.append(QLatin1Char('/'));
        makefile.append(qt4bc->makefile());
    } else {
        makefile.append(QLatin1String("/Makefile"));
    }

    // Check whether we need to run qmake
    bool makefileOutDated = (qt4bc->compareToImportFrom(makefile) != Qt4BuildConfiguration::MakefileMatches);
    if (m_forced || makefileOutDated)
        m_needToRunQMake = true;
    m_forced = false;

    ProcessParameters *pp = processParameters();
    pp->setMacroExpander(qt4bc->macroExpander());
    pp->setWorkingDirectory(workingDirectory);
    pp->setCommand(program.toString());
    pp->setArguments(args);
    pp->setEnvironment(qt4bc->environment());

    setOutputParser(new QMakeParser);

    Qt4ProFileNode *node = static_cast<Qt4Project *>(qt4bc->target()->project())->rootQt4ProjectNode();
    if (qt4bc->subNodeBuild())
        node = qt4bc->subNodeBuild();
    QString proFile = node->path();

    m_tasks = qtVersion->reportIssues(proFile, workingDirectory);
    qSort(m_tasks);

    m_scriptTemplate = node->projectType() == ScriptTemplate;

    return AbstractProcessStep::init();
}
Exemple #13
0
bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target)
{
    QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target->kit());
    if (!version)
        return false;

    AndroidQtSupport *qtSupport = androidQtSupport(target);
    if (!qtSupport)
        return false;

    Utils::FileName packageSourceDir = qtSupport->packageSourceDir(target);
    if (!packageSourceDir.appendPath("gradlew").exists())
        return false;

    Utils::FileName wrapperProps = packageSourceDir;
    wrapperProps.appendPath(QLatin1String("gradle/wrapper/gradle-wrapper.properties"));
    if (wrapperProps.exists()) {
        GradleProperties wrapperProperties = readGradleProperties(wrapperProps.toString());
        QString distributionUrl = QString::fromLocal8Bit(wrapperProperties["distributionUrl"]);
        // Update only old gradle distributionUrl
        if (distributionUrl.endsWith(QLatin1String("distributions/gradle-1.12-all.zip"))) {
            wrapperProperties["distributionUrl"] = "https\\://services.gradle.org/distributions/gradle-2.2.1-all.zip";
            mergeGradleProperties(wrapperProps.toString(), wrapperProperties);
        }
    }

    GradleProperties localProperties;
    localProperties["sdk.dir"] = AndroidConfigurations::currentConfig().sdkLocation().toString().toLocal8Bit();
    if (!mergeGradleProperties(packageSourceDir.appendPath("local.properties").toString(), localProperties))
        return false;

    QString gradlePropertiesPath = packageSourceDir.appendPath("gradle.properties").toString();
    GradleProperties gradleProperties = readGradleProperties(gradlePropertiesPath);
    gradleProperties["qt5AndroidDir"] = version->qmakeProperty("QT_INSTALL_PREFIX")
            .append(QLatin1String("/src/android/java")).toLocal8Bit();
    gradleProperties["buildDir"] = ".build";
    gradleProperties["androidCompileSdkVersion"] = buildTargetSDK(target).split(QLatin1Char('-')).last().toLocal8Bit();
    if (gradleProperties["androidBuildToolsVersion"].isEmpty()) {
        QVersionNumber buildtoolVersion = AndroidConfigurations::currentConfig().buildToolsVersion();
        if (buildtoolVersion.isNull())
            return false;
        gradleProperties["androidBuildToolsVersion"] = buildtoolVersion.toString().toLocal8Bit();
    }
    return mergeGradleProperties(gradlePropertiesPath, gradleProperties);
}
Exemple #14
0
bool ROSUtils::initializeWorkspace(QProcess *process, const Utils::FileName &workspaceDir, const QString &rosDistribution)
{
  Utils::FileName srcDir(workspaceDir);
  srcDir.appendPath(QLatin1String("src"));

  bool results = false;
  if (sourceROS(process, rosDistribution))
  {
    if (!isWorkspaceInitialized(workspaceDir))
    {
      if (!srcDir.exists())
      {
        QDir(workspaceDir.toString()).mkdir(QLatin1String("src"));
      }
      process->setWorkingDirectory(srcDir.toString());
      process->start(QLatin1String("bash"), QStringList() << QLatin1String("-c") << QLatin1String("catkin_init_workspace"));
      process->waitForFinished();

      if (process->exitStatus() != QProcess::CrashExit)
      {
        results = true;
      }
      else
      {
        results = false;
        qDebug() << "Failed ot initialize workspace: " << workspaceDir.toString();
      }
    }
    else
    {
      results = true;
    }

    if (buildWorkspace(process, workspaceDir))
    {
      results = true;
    }
    else
    {
      results = false;
    }

  }
  return results;
}
Exemple #15
0
Utils::FileName QmlProject::targetFile(const Utils::FileName &sourceFile,
                                       const Target *target) const
{
    const QDir sourceDir(m_projectItem ? m_projectItem->sourceDirectory()
                                       : canonicalProjectDir().toString());
    const QDir targetDir(targetDirectory(target).toString());
    const QString relative = sourceDir.relativeFilePath(sourceFile.toString());
    return Utils::FileName::fromString(QDir::cleanPath(targetDir.absoluteFilePath(relative)));
}
void AndroidSettingsWidget::ndkLocationEditingFinished()
{
    Utils::FileName location = Utils::FileName::fromUserInput(m_ui->NDKLocationLineEdit->text());
    m_androidConfig.toolchainHost.clear(); // force toolchain host detection
    if (!checkNDK(location))
        return;
    searchForAnt(location.toString());
    saveSettings(true);
}
Exemple #17
0
bool ROSUtils::buildWorkspace(QProcess *process, const Utils::FileName &workspaceDir)
{
  bool results = false;
  process->setWorkingDirectory(workspaceDir.toString());
  // May need to change PWD Enviroment variable here
  process->start(QLatin1String("bash"), QStringList() << QLatin1String("-c") << QLatin1String("catkin_make"));
  process->waitForFinished();

  if (process->exitStatus() != QProcess::CrashExit)
  {
    results = true;
  }
  else
  {
    qDebug() << "Failed ot build workspace: " << workspaceDir.toString();
  }

  return results;
}
Exemple #18
0
QStringList QmlProject::makeAbsolute(const Utils::FileName &path, const QStringList &relativePaths)
{
    if (path.isEmpty())
        return relativePaths;

    const QDir baseDir(path.toString());
    return Utils::transform(relativePaths, [&baseDir](const QString &path) {
        return QDir::cleanPath(baseDir.absoluteFilePath(path));
    });
}
bool BlackBerryCreatePackageStep::doUpdateAppDescriptorFile(const Utils::FileName &appDescriptorPath,
                                                            QFlags<EditMode> types,
                                                            bool skipConfirmation)
{
    Core::FileChangeBlocker fb(appDescriptorPath.toString());
    BarDescriptorDocument doc;
    QString errorString;
    if (!doc.open(&errorString, appDescriptorPath.toString())) {
        raiseError(tr("Error opening BAR application descriptor file \"%1\" - %2")
            .arg(appDescriptorPath.toUserOutput())
            .arg(errorString));
        return false;
    }

    BarDescriptorAssetList assetList = doc.value(BarDescriptorDocument::asset)
            .value<BarDescriptorAssetList>();
    bool updated = false;
    if (types.testFlag(PlaceHolders)) {

        foreach (const BarDescriptorAsset &a, assetList) {
            if (a.source.contains(QLatin1String("%SRC_DIR%"))) {
                // Keep backward compatibility with older templates
                QHash<QString, QString> placeHoldersHash;
                placeHoldersHash[QLatin1String("%SRC_DIR%")] = QString();
                doc.expandPlaceHolders(placeHoldersHash);
                updated = true;
            }

            // Update the entry point source path to make use of the BUILD_DIR variable
            // if not set
            if (a.entry) {
                BarDescriptorAsset asset = a;
                if (asset.source.contains(QLatin1String("${BUILD_DIR}/")))
                    break;
                asset.source = QLatin1String("${BUILD_DIR}/") + asset.destination;
                assetList.removeOne(a);
                assetList << asset;
                updated = true;
                break;
            }
        }
    }
QString CreateAndroidManifestWizard::sourceFileName() const
{
    QString result;
    QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(m_target->kit());
    if (!version)
        return result;
    Utils::FileName srcPath
            = Utils::FileName::fromString(version->qmakeProperty("QT_INSTALL_PREFIX"))
            .appendPath(QLatin1String("src/android/java"));
    srcPath.appendPath(QLatin1String("AndroidManifest.xml"));
    return srcPath.toString();
}
Exemple #21
0
static bool openXmlFile(QDomDocument &doc, const Utils::FileName &fileName)
{
    QFile f(fileName.toString());
    if (!f.open(QIODevice::ReadOnly))
        return false;

    if (!doc.setContent(f.readAll())) {
        raiseError(AndroidManager::tr("Cannot parse \"%1\".").arg(fileName.toUserOutput()));
        return false;
    }
    return true;
}
void BuildConfiguration::prependCompilerPathToEnvironment(Kit *k, Utils::Environment &env)
{
    const ToolChain *tc
            = ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);

    if (!tc)
        return;

    const Utils::FileName compilerDir = tc->compilerCommand().parentDir();
    if (!compilerDir.isEmpty())
        env.prependOrSetPath(compilerDir.toString());
}
Exemple #23
0
void IosDeployStep::checkProvisioningProfile()
{
    IosDevice::ConstPtr device = iosdevice();
    if (device.isNull())
        return;

    Utils::FileName provisioningFilePath = Utils::FileName::fromString(appBundle());
    provisioningFilePath.appendPath(QLatin1String("embedded.mobileprovision"));

    // the file is a signed plist stored in DER format
    // we simply search for start and end of the plist instead of decoding the DER payload
    if (!provisioningFilePath.exists())
        return;
    QFile provisionFile(provisioningFilePath.toString());
    if (!provisionFile.open(QIODevice::ReadOnly))
        return;
    QByteArray provisionData = provisionFile.readAll();
    int start = provisionData.indexOf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    int end = provisionData.indexOf("</plist>");
    if (start == -1 || end == -1)
        return;
    end += 8;

    QTemporaryFile f;
    if (!f.open())
        return;
    f.write(provisionData.mid(start, end - start));
    f.flush();
    QSettings provisionPlist(f.fileName(), QSettings::NativeFormat);

    if (!provisionPlist.contains(QLatin1String("ProvisionedDevices")))
        return;
    QStringList deviceIds = provisionPlist.value(QLatin1String("ProvisionedDevices")).toStringList();
    QString targetId = device->uniqueDeviceID();
    foreach (const QString &deviceId, deviceIds) {
        if (deviceId == targetId)
            return;
    }

    m_expectFail = true;
    QString provisioningProfile = provisionPlist.value(QLatin1String("Name")).toString();
    QString provisioningUid = provisionPlist.value(QLatin1String("UUID")).toString();
    Task task(Task::Warning,
              tr("The provisioning profile \"%1\" (%2) used to sign the application "
                 "does not cover the device %3 (%4). Deployment to it will fail.")
              .arg(provisioningProfile, provisioningUid, device->displayName(),
                   targetId),
              Utils::FileName(), /* filename */
              -1, /* line */
              ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
    emit addTask(task);
}
Exemple #24
0
void Project::readProjectSettings(const Utils::FileName &fileName)
{
    QString base = fileName.toFileInfo().absoluteDir().absolutePath();
    base.append("/");
    QSettings settings(fileName.toString(), QSettings::IniFormat);
    settings.beginGroup("Config");
    for (const QString &path : settings.value("Ignore").toStringList()) {
        if (path.isEmpty())
            continue;
        m_ignoredDirectories << base + path;
    }
    settings.endGroup();
}
void AndroidSettingsWidget::sdkLocationEditingFinished()
{
    Utils::FileName location = Utils::FileName::fromUserInput(m_ui->SDKLocationLineEdit->text());
    if (!checkSDK(location)) {
        m_ui->AVDManagerFrame->setEnabled(false);
        return;
    }
    m_androidConfig.sdkLocation = location;
    searchForAnt(location.toString());
    saveSettings(true);
    m_AVDModel.setAvdList(AndroidConfigurations::instance().androidVirtualDevices());
    m_ui->AVDManagerFrame->setEnabled(true);
}
void ModelManagerSupportClang::onCurrentEditorChanged(Core::IEditor *editor)
{
    m_communicator.updateTranslationUnitVisiblity();

    // Update task hub issues for current CppEditorDocument
    ClangEditorDocumentProcessor::clearTaskHubIssues();
    if (!editor || !editor->document() || !cppModelManager()->isCppEditor(editor))
        return;

    const ::Utils::FileName filePath = editor->document()->filePath();
    if (auto processor = ClangEditorDocumentProcessor::get(filePath.toString()))
        processor->generateTaskHubIssues();
}
Exemple #27
0
int AndroidManager::findApiLevel(const Utils::FileName &platformPath)
{
    int apiLevel = -1;
    Utils::FileName propertiesPath = platformPath;
    propertiesPath.appendPath("/source.properties");
    if (propertiesPath.exists()) {
        QSettings sdkProperties(propertiesPath.toString(), QSettings::IniFormat);
        bool validInt = false;
        apiLevel = sdkProperties.value(ApiLevelKey).toInt(&validInt);
        if (!validInt)
            apiLevel = -1;
    }
    return apiLevel;
}
bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    if (!index.isValid())
        return false;
    if (role != Qt::EditRole)
        return false;

    Node *node = nodeForIndex(index);

    Utils::FileName orgFilePath = node->filePath();
    Utils::FileName newFilePath = orgFilePath.parentDir().appendPath(value.toString());

    ProjectExplorerPlugin::renameFile(node, newFilePath.toString());
    emit renamed(orgFilePath, newFilePath);
    return true;
}
static QByteArray getSource(const Utils::FileName &fileName,
                            const WorkingCopy &workingCopy)
{
    if (workingCopy.contains(fileName)) {
        return workingCopy.source(fileName);
    } else {
        QString fileContents;
        Utils::TextFileFormat format;
        QString error;
        QTextCodec *defaultCodec = EditorManager::defaultTextCodec();
        Utils::TextFileFormat::ReadResult result = Utils::TextFileFormat::readFile(
                    fileName.toString(), defaultCodec, &fileContents, &format, &error);
        if (result != Utils::TextFileFormat::ReadSuccess)
            qWarning() << "Could not read " << fileName << ". Error: " << error;

        return fileContents.toUtf8();
    }
}
Exemple #30
0
Document::Ptr Snapshot::preprocessedDocument(const QByteArray &source,
                                             const Utils::FileName &fileName) const
{
    Document::Ptr newDoc = Document::create(fileName.toString());
    if (Document::Ptr thisDocument = document(fileName)) {
        newDoc->_revision = thisDocument->_revision;
        newDoc->_editorRevision = thisDocument->_editorRevision;
        newDoc->_lastModified = thisDocument->_lastModified;
        newDoc->_resolvedIncludes = thisDocument->_resolvedIncludes;
        newDoc->_unresolvedIncludes = thisDocument->_unresolvedIncludes;
        newDoc->setLanguageFeatures(thisDocument->languageFeatures());
    }

    FastPreprocessor pp(*this);
    const QByteArray preprocessedCode = pp.run(newDoc, source);
    newDoc->setUtf8Source(preprocessedCode);
    return newDoc;
}