diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 44762aa8410e6cff2bac6e129c1c2e0491c2e81c..aa9e36c28a2376f5181e789744cc57716f15780d 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -150,6 +150,7 @@ enum HandleLocalsFlags */ using namespace ProjectExplorer; +using namespace Utils; namespace Debugger { namespace Internal { @@ -315,7 +316,7 @@ static inline bool validMode(DebuggerStartMode sm) // Accessed by RunControlFactory DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *errorMessage) { - if (Utils::HostOsInfo::isWindowsHost()) { + if (HostOsInfo::isWindowsHost()) { if (validMode(sp.startMode)) return new CdbEngine(sp); *errorMessage = QLatin1String("Internal error: Invalid start parameters passed for thee CDB engine."); @@ -327,7 +328,7 @@ DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *erro void addCdbOptionPages(QList<Core::IOptionsPage *> *opts) { - if (Utils::HostOsInfo::isWindowsHost()) { + if (HostOsInfo::isWindowsHost()) { opts->push_back(new CdbOptionsPage); opts->push_back(new CdbPathsPage); } @@ -413,7 +414,7 @@ void CdbEngine::init() } // update source path maps from debugger start params mergeStartParametersSourcePathMap(); - QTC_ASSERT(m_process.state() != QProcess::Running, Utils::SynchronousProcess::stopProcess(m_process)); + QTC_ASSERT(m_process.state() != QProcess::Running, SynchronousProcess::stopProcess(m_process)); } CdbEngine::~CdbEngine() @@ -538,8 +539,8 @@ bool CdbEngine::startConsole(const DebuggerStartParameters &sp, QString *errorMe { if (debug) qDebug("startConsole %s", qPrintable(sp.executable)); - m_consoleStub.reset(new Utils::ConsoleProcess); - m_consoleStub->setMode(Utils::ConsoleProcess::Suspend); + m_consoleStub.reset(new ConsoleProcess); + m_consoleStub->setMode(ConsoleProcess::Suspend); connect(m_consoleStub.data(), SIGNAL(processError(QString)), SLOT(consoleStubError(QString))); connect(m_consoleStub.data(), SIGNAL(processStarted()), @@ -701,8 +702,7 @@ bool CdbEngine::launchCDB(const DebuggerStartParameters &sp, QString *errorMessa case StartExternal: if (!nativeArguments.isEmpty()) nativeArguments.push_back(blank); - Utils::QtcProcess::addArgs(&nativeArguments, - QStringList(QDir::toNativeSeparators(sp.executable))); + QtcProcess::addArgs(&nativeArguments, QStringList(QDir::toNativeSeparators(sp.executable))); break; case AttachToRemoteServer: break; @@ -941,7 +941,7 @@ void CdbEngine::shutdownEngine() } else { // Remote process. No can do, currently m_notifyEngineShutdownOnTermination = true; - Utils::SynchronousProcess::stopProcess(m_process); + SynchronousProcess::stopProcess(m_process); return; } // Lost debuggee, debugger should quit anytime now @@ -2470,13 +2470,12 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what && exception.exceptionCode != winExceptionSetThreadName) { const Task::TaskType type = isFatalWinException(exception.exceptionCode) ? Task::Error : Task::Warning; - const Utils::FileName fileName = exception.file.isEmpty() ? - Utils::FileName() : - Utils::FileName::fromUserInput(QString::fromLocal8Bit(exception.file)); - const Task task(type, exception.toString(false).trimmed(), - fileName, exception.lineNumber, - Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME)); - TaskHub::addTask(task); + const FileName fileName = exception.file.isEmpty() ? + FileName() : + FileName::fromUserInput(QString::fromLocal8Bit(exception.file)); + TaskHub::addTask(type, exception.toString(false).trimmed(), + Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME, + fileName, exception.lineNumber); } return; } @@ -2706,7 +2705,7 @@ static CPlusPlus::Document::Ptr getParsedDocument(const QString &fileName, if (workingCopy.contains(fileName)) { src = workingCopy.source(fileName); } else { - Utils::FileReader reader; + FileReader reader; if (reader.fetch(fileName)) // ### FIXME error reporting src = QString::fromLocal8Bit(reader.data()); // ### FIXME encoding } diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 90d3f1396c7c7c563980f05989bb93ffaa3b5ecf..c1ae71f509cc141577ce83ade0da68d7937200ad 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -687,9 +687,7 @@ void GdbEngine::handleResponse(const QByteArray &buff) m_lastWinException = msgWinException(data, &exCode); showMessage(m_lastWinException, LogMisc); const Task::TaskType type = isFatalWinException(exCode) ? Task::Error : Task::Warning; - const Task task(type, m_lastWinException, Utils::FileName(), 0, - Core::Id(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME)); - TaskHub::addTask(task); + TaskHub::addTask(type, m_lastWinException, Constants::TASK_CATEGORY_DEBUGGER_RUNTIME); } if (data.startsWith("QMLBP:")) { diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp index 34c78ee15a49a55f1835eae6b8489f7f9bc5c299..014f647c43c227ad9383bc51fdd82b55331385c9 100644 --- a/src/plugins/projectexplorer/taskhub.cpp +++ b/src/plugins/projectexplorer/taskhub.cpp @@ -34,7 +34,7 @@ using namespace ProjectExplorer; -TaskHub *TaskHub::m_instance = 0; +TaskHub *m_instance = 0; class TaskMark : public TextEditor::BaseTextMark { @@ -107,6 +107,11 @@ TaskHub *TaskHub::instance() return m_instance; } +void TaskHub::addTask(Task::TaskType type, const QString &description, Core::Id category, const Utils::FileName &file, int line) +{ + addTask(Task(type, description, file, line, category)); +} + void TaskHub::addTask(Task task) { if (task.line != -1 && !task.file.isEmpty()) { diff --git a/src/plugins/projectexplorer/taskhub.h b/src/plugins/projectexplorer/taskhub.h index ee05c181bc2f9fda2aa31fbf9dd5f44270004fb2..80aede50aef742138e512709185f7d616593a401 100644 --- a/src/plugins/projectexplorer/taskhub.h +++ b/src/plugins/projectexplorer/taskhub.h @@ -38,7 +38,6 @@ namespace ProjectExplorer { class ProjectExplorerPlugin; -class Task; class PROJECTEXPLORER_EXPORT TaskHub : public QObject { @@ -46,6 +45,12 @@ class PROJECTEXPLORER_EXPORT TaskHub : public QObject public: static TaskHub *instance(); + // Convenience overload + static void addTask(Task::TaskType type, const QString &description, + Core::Id category, + const Utils::FileName &file = Utils::FileName(), + int line = -1); + public slots: static void addTask(ProjectExplorer::Task task); static void clearTasks(Core::Id categoryId = Core::Id()); @@ -82,8 +87,6 @@ private: const QIcon m_errorIcon; const QIcon m_warningIcon; - static TaskHub *m_instance; - friend class ProjectExplorerPlugin; }; diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 38daf63728de49e9ce7a886806f1e201a6d8a678..ce094aeff8ea3675feb46fefe13900d92e85eb2b 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -268,7 +268,7 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate) d->m_categoriesButton->setMenu(d->m_categoriesMenu); - TaskHub *hub = TaskHub::instance(); + QObject *hub = TaskHub::instance(); connect(hub, SIGNAL(categoryAdded(Core::Id,QString,bool)), this, SLOT(addCategory(Core::Id,QString,bool))); connect(hub, SIGNAL(taskAdded(ProjectExplorer::Task)), diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index f145594432a168ca0eddf1f177dab33dc1e5cafc..a21174253c4821c2d8cecb5ca08f6bd0214dccdb 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -67,6 +67,8 @@ #include <QFileInfo> using namespace Core; +using namespace ProjectExplorer; +using namespace Utils; namespace QbsProjectManager { namespace Internal { @@ -145,12 +147,12 @@ QbsManager *QbsProject::projectManager() const return m_manager; } -ProjectExplorer::ProjectNode *QbsProject::rootProjectNode() const +ProjectNode *QbsProject::rootProjectNode() const { return m_rootProjectNode; } -QStringList QbsProject::files(ProjectExplorer::Project::FilesMode fileMode) const +QStringList QbsProject::files(Project::FilesMode fileMode) const { Q_UNUSED(fileMode); QSet<QString> result; @@ -212,7 +214,7 @@ qbs::InstallJob *QbsProject::install(const qbs::InstallOptions &opts) return qbsProject()->installAllProducts(opts); } -QString QbsProject::profileForTarget(const ProjectExplorer::Target *t) const +QString QbsProject::profileForTarget(const Target *t) const { return m_manager->profileForKit(t->kit()); } @@ -227,11 +229,11 @@ bool QbsProject::hasParseResult() const return qbsProject(); } -Utils::FileName QbsProject::defaultBuildDirectory() const +FileName QbsProject::defaultBuildDirectory() const { QFileInfo fi(m_fileName); const QString buildDir = QDir(fi.canonicalPath()).absoluteFilePath(QString::fromLatin1("../%1-build").arg(fi.baseName())); - return Utils::FileName::fromString(buildDir); + return FileName::fromString(buildDir); } const qbs::Project *QbsProject::qbsProject() const @@ -279,7 +281,7 @@ void QbsProject::handleQbsParsingDone(bool success) updateCppCodeModel(m_rootProjectNode->qbsProjectData()); updateQmlJsCodeModel(m_rootProjectNode->qbsProjectData()); - foreach (ProjectExplorer::Target *t, targets()) + foreach (Target *t, targets()) t->updateDefaultRunConfigurations(); emit fileListChanged(); @@ -301,22 +303,22 @@ void QbsProject::handleQbsParsingTaskSetup(const QString &description, int maxim } } -void QbsProject::targetWasAdded(ProjectExplorer::Target *t) +void QbsProject::targetWasAdded(Target *t) { connect(t, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), this, SLOT(delayForcedParsing())); connect(t, SIGNAL(buildDirectoryChanged()), this, SLOT(delayForcedParsing())); } -void QbsProject::changeActiveTarget(ProjectExplorer::Target *t) +void QbsProject::changeActiveTarget(Target *t) { - ProjectExplorer::BuildConfiguration *bc = 0; + BuildConfiguration *bc = 0; if (t && t->kit()) bc = t->activeBuildConfiguration(); buildConfigurationChanged(bc); } -void QbsProject::buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc) +void QbsProject::buildConfigurationChanged(BuildConfiguration *bc) { if (m_currentBc) disconnect(m_currentBc, SIGNAL(qbsConfigurationChanged()), this, SLOT(delayParsing())); @@ -358,9 +360,9 @@ bool QbsProject::fromMap(const QVariantMap &map) if (!Project::fromMap(map)) return false; - ProjectExplorer::Kit *defaultKit = ProjectExplorer::KitManager::defaultKit(); + Kit *defaultKit = KitManager::defaultKit(); if (!activeTarget() && defaultKit) { - ProjectExplorer::Target *t = new ProjectExplorer::Target(this, defaultKit); + Target *t = new Target(this, defaultKit); t->updateDefaultBuildConfigurations(); t->updateDefaultDeployConfigurations(); t->updateDefaultRunConfigurations(); @@ -373,15 +375,14 @@ bool QbsProject::fromMap(const QVariantMap &map) void QbsProject::generateErrors(const qbs::ErrorInfo &e) { foreach (const qbs::ErrorItem &item, e.items()) - ProjectExplorer::TaskHub::addTask( - ProjectExplorer::Task(ProjectExplorer::Task::Error, - item.description(), - Utils::FileName::fromString(item.codeLocation().fileName()), - item.codeLocation().line(), - ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); + TaskHub::addTask(Task::Error, item.description(), + ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM, + FileName::fromString(item.codeLocation().fileName()), + item.codeLocation().line()); + } -void QbsProject::parse(const QVariantMap &config, const Utils::Environment &env, const QString &dir) +void QbsProject::parse(const QVariantMap &config, const Environment &env, const QString &dir) { QTC_ASSERT(!dir.isNull(), return); @@ -441,7 +442,7 @@ void QbsProject::prepareForParsing() { m_forceParsing = false; - ProjectExplorer::TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM); + TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM); if (m_qbsUpdateFutureInterface) m_qbsUpdateFutureInterface->reportCanceled(); delete m_qbsUpdateFutureInterface; @@ -492,12 +493,12 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj) if (!prj.isValid()) return; - ProjectExplorer::Kit *k = 0; + Kit *k = 0; QtSupport::BaseQtVersion *qtVersion = 0; - if (ProjectExplorer::Target *target = activeTarget()) + if (Target *target = activeTarget()) k = target->kit(); else - k = ProjectExplorer::KitManager::defaultKit(); + k = KitManager::defaultKit(); qtVersion = QtSupport::QtKitInformation::qtVersion(k); CppTools::CppModelManagerInterface *modelmanager = @@ -547,7 +548,7 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj) QLatin1String(CONFIG_INCLUDEPATHS)); QStringList grpIncludePaths; foreach (const QString &p, list) { - const QString cp = Utils::FileName::fromUserInput(p).toString(); + const QString cp = FileName::fromUserInput(p).toString(); grpIncludePaths.append(cp); } @@ -555,7 +556,7 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj) QLatin1String(CONFIG_FRAMEWORKPATHS)); QStringList grpFrameworkPaths; foreach (const QString &p, list) { - const QString cp = Utils::FileName::fromUserInput(p).toString(); + const QString cp = FileName::fromUserInput(p).toString(); grpFrameworkPaths.append(cp); } @@ -563,10 +564,10 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj) QLatin1String(CONFIG_PRECOMPILEDHEADER)).toString(); CppTools::ProjectPart::Ptr part(new CppTools::ProjectPart); - part->evaluateToolchain(ProjectExplorer::ToolChainKitInformation::toolChain(k), + part->evaluateToolchain(ToolChainKitInformation::toolChain(k), cxxFlags, cFlags, - ProjectExplorer::SysRootKitInformation::sysRoot(k)); + SysRootKitInformation::sysRoot(k)); CppTools::ProjectFileAdder adder(part->files); foreach (const QString &file, grp.allFilePaths()) { @@ -618,8 +619,7 @@ void QbsProject::updateQmlJsCodeModel(const qbs::ProjectData &prj) QString QbsProject::qbsBuildDir() const { - QString buildDir = Utils::Environment::systemEnvironment() - .value(QLatin1String("QBS_BUILD_DIR")); + QString buildDir = Environment::systemEnvironment().value(QLatin1String("QBS_BUILD_DIR")); if (buildDir.isEmpty()) buildDir = ICore::resourcePath() + QLatin1String("/qbs"); return buildDir; diff --git a/src/plugins/qnx/bardescriptoreditor.cpp b/src/plugins/qnx/bardescriptoreditor.cpp index 149956dae622d1b25d0c93ebc04e0c92139abdb5..93f93e6e97307b4d7fe2a95bf07b02c8799887ce 100644 --- a/src/plugins/qnx/bardescriptoreditor.cpp +++ b/src/plugins/qnx/bardescriptoreditor.cpp @@ -43,11 +43,12 @@ #include <QAction> #include <QToolBar> -using namespace Qnx; -using namespace Qnx::Internal; +using namespace ProjectExplorer; + +namespace Qnx { +namespace Internal { BarDescriptorEditor::BarDescriptorEditor(BarDescriptorEditorWidget *editorWidget) - : Core::IEditor() { setWidget(editorWidget); @@ -128,14 +129,13 @@ void BarDescriptorEditor::setActivePage(BarDescriptorEditor::EditorPage page) if (page == Source) { editorWidget->setXmlSource(m_file->xmlSource()); } else if (prevPage == Source) { - ProjectExplorer::TaskHub::clearTasks(Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR); + TaskHub::clearTasks(Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR); QString errorMsg; int errorLine; if (!m_file->loadContent(editorWidget->xmlSource(), &errorMsg, &errorLine)) { - const ProjectExplorer::Task task(ProjectExplorer::Task::Error, errorMsg, Utils::FileName::fromString(m_file->filePath()), - errorLine, Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR); - ProjectExplorer::TaskHub::addTask(task); - ProjectExplorer::TaskHub::requestPopup(); + TaskHub::addTask(Task::Error, errorMsg, Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR, + Utils::FileName::fromString(m_file->filePath()), errorLine); + TaskHub::requestPopup(); foreach (QAction *action, m_actionGroup->actions()) if (action->data().toInt() == Source) @@ -147,3 +147,6 @@ void BarDescriptorEditor::setActivePage(BarDescriptorEditor::EditorPage page) editorWidget->setCurrentIndex(page); } + +} // namespace Internal +} // namespace Qnx diff --git a/src/plugins/tasklist/tasklistplugin.cpp b/src/plugins/tasklist/tasklistplugin.cpp index 6eb486769632437bf29873ec9da858ec6d5ad403..dbf11f9f2f0a0e0a14096f1505e277f1b22d8dd1 100644 --- a/src/plugins/tasklist/tasklistplugin.cpp +++ b/src/plugins/tasklist/tasklistplugin.cpp @@ -45,181 +45,156 @@ #include <QStringList> #include <QtPlugin> -namespace { +using namespace ProjectExplorer; +using namespace TaskList::Internal; -ProjectExplorer::Task::TaskType typeFrom(const QString &typeName) +namespace TaskList { + +static Task::TaskType typeFrom(const QString &typeName) { - ProjectExplorer::Task::TaskType type = ProjectExplorer::Task::Unknown; + Task::TaskType type = Task::Unknown; QString tmp = typeName.toLower(); if (tmp.startsWith(QLatin1String("warn"))) - type = ProjectExplorer::Task::Warning; + type = Task::Warning; else if (tmp.startsWith(QLatin1String("err"))) - type = ProjectExplorer::Task::Error; + type = Task::Error; return type; } -} // namespace - -using namespace TaskList; - -TaskListPlugin *TaskListPlugin::m_instance = 0; - -// -------------------------------------------------------------------------- -// TaskListPluginPrivate -// -------------------------------------------------------------------------- +static QStringList parseRawLine(const QByteArray &raw) +{ + QStringList result; + QString line = QString::fromUtf8(raw.constData()); + if (line.startsWith(QLatin1Char('#'))) + return result; -class Internal::TaskListPluginPrivate { -public: - bool parseTaskFile(QString *errorString, ProjectExplorer::Project *context, const QString &name) - { - QFile tf(name); - if (!tf.open(QIODevice::ReadOnly)) { - *errorString = TaskListPlugin::tr("Cannot open task file %1: %2").arg( - QDir::toNativeSeparators(name), tf.errorString()); - return false; - } + return line.split(QLatin1Char('\t')); +} - while (!tf.atEnd()) - { - QStringList chunks = parseRawLine(tf.readLine()); - if (chunks.isEmpty()) +static QString unescape(const QString &input) +{ + QString result; + for (int i = 0; i < input.count(); ++i) { + if (input.at(i) == QLatin1Char('\\')) { + if (i == input.count() - 1) + continue; + if (input.at(i + 1) == QLatin1Char('n')) { + result.append(QLatin1Char('\n')); + ++i; + continue; + } else if (input.at(i + 1) == QLatin1Char('t')) { + result.append(QLatin1Char('\t')); + ++i; + continue; + } else if (input.at(i + 1) == QLatin1Char('\\')) { + result.append(QLatin1Char('\\')); + ++i; continue; - - QString description; - QString file; - ProjectExplorer::Task::TaskType type = ProjectExplorer::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() && context) { - QString fullPath = context->projectDirectory() + QLatin1Char('/') + file; - fi.setFile(fullPath); - file = fi.absoluteFilePath(); - } } - description = unescape(description); - - ProjectExplorer::TaskHub::addTask( - ProjectExplorer::Task(type, description, - Utils::FileName::fromUserInput(file), line, - Core::Id(Constants::TASKLISTTASK_ID))); + continue; } - return true; + result.append(input.at(i)); } + return result; +} - QStringList parseRawLine(const QByteArray &raw) - { - QStringList result; - QString line = QString::fromUtf8(raw.constData()); - if (line.startsWith(QLatin1Char('#'))) - return result; - - return line.split(QLatin1Char('\t')); +static bool parseTaskFile(QString *errorString, Project *context, const QString &name) +{ + QFile tf(name); + if (!tf.open(QIODevice::ReadOnly)) { + *errorString = TaskListPlugin::tr("Cannot open task file %1: %2").arg( + QDir::toNativeSeparators(name), tf.errorString()); + return false; } - QString unescape(const QString &input) const - { - QString result; - for (int i = 0; i < input.count(); ++i) { - if (input.at(i) == QLatin1Char('\\')) { - if (i == input.count() - 1) - continue; - if (input.at(i + 1) == QLatin1Char('n')) { - result.append(QLatin1Char('\n')); - ++i; - continue; - } else if (input.at(i + 1) == QLatin1Char('t')) { - result.append(QLatin1Char('\t')); - ++i; - continue; - } else if (input.at(i + 1) == QLatin1Char('\\')) { - result.append(QLatin1Char('\\')); - ++i; - continue; - } - continue; + 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() && context) { + QString fullPath = context->projectDirectory() + QLatin1Char('/') + file; + fi.setFile(fullPath); + file = fi.absoluteFilePath(); } - result.append(input.at(i)); } - return result; - } + description = unescape(description); - TaskFileFactory *fileFactory; -}; + TaskHub::addTask(type, description, Constants::TASKLISTTASK_ID, + Utils::FileName::fromUserInput(file), line); + } + return true; +} // -------------------------------------------------------------------------- // TaskListPlugin // -------------------------------------------------------------------------- -TaskListPlugin::TaskListPlugin() : - d(new Internal::TaskListPluginPrivate) -{ - m_instance = this; -} - -TaskListPlugin::~TaskListPlugin() -{ - delete d; -} +static TaskFileFactory *m_fileFactory = 0; bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMessage) { Q_UNUSED(arguments) //: Category under which tasklist tasks are listed in Issues view - ProjectExplorer::TaskHub::addCategory(Core::Id(Constants::TASKLISTTASK_ID), tr("My Tasks")); + TaskHub::addCategory(Constants::TASKLISTTASK_ID, tr("My Tasks")); if (!Core::ICore::mimeDatabase()->addMimeTypes(QLatin1String(":tasklist/TaskList.mimetypes.xml"), errorMessage)) return false; - d->fileFactory = new Internal::TaskFileFactory(this); - addAutoReleasedObject(d->fileFactory); - addAutoReleasedObject(new Internal::StopMonitoringHandler); + m_fileFactory = new TaskFileFactory(this); + addAutoReleasedObject(m_fileFactory); + addAutoReleasedObject(new StopMonitoringHandler); return true; } -void TaskListPlugin::extensionsInitialized() -{ } - -bool TaskListPlugin::loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName) +bool TaskListPlugin::loadFile(QString *errorString, Project *context, const QString &fileName) { clearTasks(); - return m_instance->d->parseTaskFile(errorString, context, fileName); + return parseTaskFile(errorString, context, fileName); } -bool TaskListPlugin::monitorFile(ProjectExplorer::Project *context, const QString &fileName) +bool TaskListPlugin::monitorFile(Project *context, const QString &fileName) { - return m_instance->d->fileFactory->open(context, fileName); + return m_fileFactory->open(context, fileName); } void TaskListPlugin::stopMonitoring() { - m_instance->d->fileFactory->closeAllFiles(); + m_fileFactory->closeAllFiles(); } void TaskListPlugin::clearTasks() { - ProjectExplorer::TaskHub::clearTasks(Core::Id(Constants::TASKLISTTASK_ID)); + TaskHub::clearTasks(Constants::TASKLISTTASK_ID); } +} // namespace TaskList + Q_EXPORT_PLUGIN(TaskListPlugin) diff --git a/src/plugins/tasklist/tasklistplugin.h b/src/plugins/tasklist/tasklistplugin.h index 63b23eadc3c1e7bdf1f4055167843555edf59d09..2c42e425da94f9b151390ea4c1eddcad2f779256 100644 --- a/src/plugins/tasklist/tasklistplugin.h +++ b/src/plugins/tasklist/tasklistplugin.h @@ -32,14 +32,9 @@ #include <extensionsystem/iplugin.h> -namespace ProjectExplorer { -class Project; -} // namespace ProjectExplorer +namespace ProjectExplorer { class Project; } namespace TaskList { -namespace Internal { -class TaskListPluginPrivate; -} // namespace class TaskListPlugin : public ExtensionSystem::IPlugin { @@ -47,22 +42,14 @@ class TaskListPlugin : public ExtensionSystem::IPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "TaskList.json") public: - TaskListPlugin(); - ~TaskListPlugin(); - bool initialize(const QStringList &arguments, QString *errorMessage); - - void extensionsInitialized(); + void extensionsInitialized() {} static bool loadFile(QString *errorString, ProjectExplorer::Project *context, const QString &fileName); static bool monitorFile(ProjectExplorer::Project *context, const QString &fileName); static void stopMonitoring(); static void clearTasks(); - -private: - static TaskListPlugin *m_instance; - Internal::TaskListPluginPrivate * const d; }; } // namespace TaskList