static bool parseTaskFile(QString *errorString, const FileName &name) { QFile tf(name.toString()); if (!tf.open(QIODevice::ReadOnly)) { *errorString = TaskListPlugin::tr("Cannot open task file %1: %2").arg( name.toUserOutput(), tf.errorString()); return false; } const FileName parentDir = name.parentDir(); while (!tf.atEnd()) { QStringList chunks = parseRawLine(tf.readLine()); if (chunks.isEmpty()) continue; QString description; QString file; Task::TaskType type = Task::Unknown; int line = -1; if (chunks.count() == 1) { description = chunks.at(0); } else if (chunks.count() == 2) { type = typeFrom(chunks.at(0)); description = chunks.at(1); } else if (chunks.count() == 3) { file = chunks.at(0); type = typeFrom(chunks.at(1)); description = chunks.at(2); } else if (chunks.count() >= 4) { file = chunks.at(0); bool ok; line = chunks.at(1).toInt(&ok); if (!ok) line = -1; type = typeFrom(chunks.at(2)); description = chunks.at(3); } if (!file.isEmpty()) { file = QDir::fromNativeSeparators(file); QFileInfo fi(file); if (fi.isRelative()) file = FileName(parentDir).appendPath(file).toString(); } description = unescape(description); TaskHub::addTask(type, description, Constants::TASKLISTTASK_ID, FileName::fromUserInput(file), line); } return true; }
FileName CMakeBuildConfiguration::shadowBuildDirectory(const FileName &projectFilePath, const Kit *k, const QString &bcName, BuildConfiguration::BuildType buildType) { if (projectFilePath.isEmpty()) return FileName(); const QString projectName = projectFilePath.parentDir().fileName(); ProjectMacroExpander expander(projectName, k, bcName, buildType); QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString()); QString buildPath = expander.expand(Core::DocumentManager::buildDirectory()); return FileName::fromUserInput(projectDir.absoluteFilePath(buildPath)); }
/*! \class CMakeProject */ CMakeProject::CMakeProject(CMakeManager *manager, const FileName &fileName) : m_manager(manager), m_activeTarget(0), m_fileName(fileName), m_rootNode(new CMakeProjectNode(fileName)), m_watcher(new QFileSystemWatcher(this)) { setId(Constants::CMAKEPROJECT_ID); setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT)); setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX)); m_rootNode->setDisplayName(fileName.parentDir().fileName()); m_file = new CMakeFile(this, fileName); connect(this, &CMakeProject::buildTargetsChanged, this, &CMakeProject::updateRunConfigurations); connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &CMakeProject::fileChanged); }