Commit 701d5407 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Add TaskList plugin

This plugin enables loading of .tasks files into the Build Isssue list. This
is really nice if you need to e.g. browse results from static codecheckers
in creator.

Tasks files are simple tab-separated lists of one of the following forms:
description
type\tdesciption
file\ttype\description
file\tline\ttype\tdescription

The strings may contain escape codes:
\n for newline,
\t for tab
and \\ for a backslash
parent 56e80092
......@@ -35,6 +35,7 @@ SUBDIRS = plugin_coreplugin \
plugin_qmljseditor \
plugin_mercurial \
plugin_classview \
plugin_tasklist \
debugger/dumper.pro
contains(QT_CONFIG, declarative) {
......@@ -219,3 +220,7 @@ plugin_classview.depends = plugin_coreplugin
plugin_classview.depends += plugin_cpptools
plugin_classview.depends += plugin_projectexplorer
plugin_classview.depends += plugin_texteditor
plugin_tasklist.subdir = tasklist
plugin_tasklist.depends = plugin_coreplugin
plugin_tasklist.depends += plugin_projectexplorer
......@@ -46,6 +46,8 @@ ShowInEditorTaskHandler::ShowInEditorTaskHandler() :
bool ShowInEditorTaskHandler::canHandle(const ProjectExplorer::Task &task)
{
if (task.file.isEmpty())
return false;
QFileInfo fi(task.file);
return fi.exists() && fi.isFile() && fi.isReadable();
}
......
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/x-tasklist">
<sub-class-of type="text/plain"/>
<comment>Qt Creator task list file</comment>
<glob pattern="*.tasks"/>
</mime-type>
</mime-info>
<plugin name="TaskList" version="2.1.80" compatVersion="2.1.80">
<vendor>Nokia Corporation</vendor>
<copyright>(C) 2010 Nokia Corporation</copyright>
<license>
Commercial Usage
Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
GNU Lesser General Public License Usage
Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. Please review the following information to ensure the GNU Lesser General Public License version 2.1 requirements will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</license>
<description>Use .tasks-files to populate the build issues view.</description>
<url>http://qt.nokia.com</url>
<dependencyList>
<dependency name="Core" version="2.1.80"/>
<dependency name="ProjectExplorer" version="2.1.80"/>
</dependencyList>
</plugin>
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "taskfilefactory.h"
#include "tasklistmanager.h"
using namespace TaskList::Internal;
TaskFileFactory::TaskFileFactory(TaskListManager *manager) :
Core::IFileFactory(0),
m_manager(manager),
m_mimeTypes(QStringList() << QLatin1String("text/x-tasklist"))
{ }
TaskFileFactory::~TaskFileFactory()
{ }
QStringList TaskFileFactory::mimeTypes() const
{
return m_mimeTypes;
}
QString TaskFileFactory::id() const
{
return QLatin1String("ProjectExplorer.TaskFileFactory");
}
QString TaskFileFactory::displayName() const
{
return tr("Task file reader");
}
Core::IFile *TaskFileFactory::open(const QString &fileName)
{
Core::IFile *file = 0;
m_manager->setTaskFile(fileName);
return file;
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef TASKFILEFACTORY_H
#define TASKFILEFACTORY_H
#include <coreplugin/ifilefactory.h>
#include <QtCore/QStringList>
namespace TaskList {
namespace Internal {
class TaskListManager;
class TaskFileFactory : public Core::IFileFactory
{
Q_OBJECT
public:
TaskFileFactory(TaskListManager *manager);
~TaskFileFactory();
QStringList mimeTypes() const;
QString id() const;
QString displayName() const;
Core::IFile *open(const QString &fileName);
private:
TaskListManager * m_manager;
QStringList m_mimeTypes;
};
} // namespace Internal
} // namespace TaskList
#endif // TASKFILEFACTORY_H
TEMPLATE = lib
TARGET = TaskList
include(../../qtcreatorplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/projectexplorer/projectexplorer.pri)
HEADERS += tasklistplugin.h \
taskfilefactory.h \
tasklistmanager.h
SOURCES += tasklistplugin.cpp \
taskfilefactory.cpp \
tasklistmanager.cpp
RESOURCES += tasklist.qrc
OTHER_FILES += TaskList.pluginspec \
TaskList.mimetypes.xml
<RCC>
<qresource prefix="/tasklist">
<file>TaskList.mimetypes.xml</file>
</qresource>
</RCC>
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "tasklistmanager.h"
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/taskhub.h>
#include <QtCore/QDebug>
#include <QtCore/QFile>
namespace {
const char * const TASKLIST_ID = "TaskList.ListId";
ProjectExplorer::Task::TaskType typeFrom(const QString &taskType)
{
QString type = taskType.toLower();
if (type.startsWith("warn"))
return ProjectExplorer::Task::Warning;
else if (type.startsWith("err"))
return ProjectExplorer::Task::Error;
return ProjectExplorer::Task::Unknown;
}
} // namespace
using namespace TaskList::Internal;
TaskListManager::TaskListManager(QObject *parent) :
QObject(parent),
m_hub(0)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
m_hub = pm->getObject<ProjectExplorer::TaskHub>();
m_hub->addCategory(QLatin1String(TASKLIST_ID), tr("My tasks"));
}
TaskListManager::~TaskListManager()
{ }
void TaskListManager::setTaskFile(const QString &name)
{
m_hub->clearTasks(QLatin1String(TASKLIST_ID));
parseTaskFile(name);
}
void TaskListManager::parseTaskFile(const QString &name)
{
QFile tf(name);
if (!tf.open(QIODevice::ReadOnly))
return;
while (!tf.atEnd())
{
QStringList chunks = parseRawLine(tf.readLine());
if (chunks.isEmpty())
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);
}
m_hub->addTask(ProjectExplorer::Task(type, description, file, line, QLatin1String(TASKLIST_ID)));
}
}
QStringList TaskListManager::parseRawLine(const QByteArray &raw)
{
QStringList result;
QString line = QString::fromUtf8(raw.constData());
if (line.startsWith(QChar('#')))
return result;
result = line.split(QChar('\t'));
for (int i = 0; i < result.count(); ++i)
result[i] = unescape(result.at(i));
return result;
}
QString TaskListManager::unescape(const QString &input) const
{
QString result;
for (int i = 0; i < input.count(); ++i) {
if (input.at(i) == QChar('\\')) {
if (i == input.count() - 1)
continue;
if (input.at(i + 1) == QChar('n')) {
result.append(QChar('\n'));
++i;
continue;
} else if (input.at(i + 1) == QChar('t')) {
result.append(QChar('\t'));
++i;
continue;
} else if (input.at(i + 1) == QChar('\\')) {
result.append(QChar('\\'));
++i;
continue;
}
continue;
}
result.append(input.at(i));
}
return result;
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef TASKLISTMANAGER_H
#define TASKLISTMANAGER_H
#include <QtCore/QByteArray>
#include <QtCore/QObject>
#include <QtCore/QStringList>
namespace ProjectExplorer {
class TaskHub;
} // namespace ProjectExplorer
namespace TaskList {
namespace Internal {
class TaskListManager : public QObject
{
Q_OBJECT
public:
TaskListManager(QObject *parent = 0);
~TaskListManager();
public slots:
void setTaskFile(const QString &name);
private:
void parseTaskFile(const QString &name);
QStringList parseRawLine(const QByteArray &raw);
QString unescape(const QString &input) const;
ProjectExplorer::TaskHub *m_hub;
};
} // namespace Internal
} // namespace TaskList
#endif // TASKLISTMANAGER_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "tasklistplugin.h"
#include "taskfilefactory.h"
#include "tasklistmanager.h"
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <QtCore/QDebug>
#include <QtCore/QStringList>
#include <QtCore/QtPlugin>
using namespace TaskList::Internal;
TaskListPlugin::TaskListPlugin()
{ }
TaskListPlugin::~TaskListPlugin()
{ }
bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
Core::ICore *core = Core::ICore::instance();
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":tasklist/TaskList.mimetypes.xml"), errorMessage))
return false;
TaskListManager * manager = new TaskListManager(this);
addObject(new TaskFileFactory(manager));
return true;
}
void TaskListPlugin::extensionsInitialized()
{ }
Q_EXPORT_PLUGIN(TaskListPlugin)
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef TASKLISTPLUGIN_H
#define TASKLISTPLUGIN_H
#include <extensionsystem/iplugin.h>
namespace TaskList {
namespace Internal {
class TaskListPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
public:
TaskListPlugin();
~TaskListPlugin();
bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
};
} // namespace Internal
} // namespace TaskList
#endif // TASKLISTPLUGIN_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment