forked from qt-creator/qt-creator
TaskList: merge into project explorer plugin
Change-Id: I6097f3ea40a6a7c3ced0f59b15789046184e2e90 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -24,7 +24,6 @@ add_subdirectory(bookmarks)
|
|||||||
add_subdirectory(cppeditor)
|
add_subdirectory(cppeditor)
|
||||||
add_subdirectory(help)
|
add_subdirectory(help)
|
||||||
add_subdirectory(resourceeditor)
|
add_subdirectory(resourceeditor)
|
||||||
add_subdirectory(tasklist)
|
|
||||||
add_subdirectory(nim)
|
add_subdirectory(nim)
|
||||||
add_subdirectory(conan)
|
add_subdirectory(conan)
|
||||||
|
|
||||||
|
@@ -75,7 +75,6 @@ Project {
|
|||||||
"silversearcher/silversearcher.qbs",
|
"silversearcher/silversearcher.qbs",
|
||||||
"studiowelcome/studiowelcome.qbs",
|
"studiowelcome/studiowelcome.qbs",
|
||||||
"subversion/subversion.qbs",
|
"subversion/subversion.qbs",
|
||||||
"tasklist/tasklist.qbs",
|
|
||||||
"texteditor/texteditor.qbs",
|
"texteditor/texteditor.qbs",
|
||||||
"todo/todo.qbs",
|
"todo/todo.qbs",
|
||||||
"updateinfo/updateinfo.qbs",
|
"updateinfo/updateinfo.qbs",
|
||||||
|
@@ -171,6 +171,7 @@ add_qtc_plugin(ProjectExplorer
|
|||||||
targetsetuppage.cpp targetsetuppage.h
|
targetsetuppage.cpp targetsetuppage.h
|
||||||
targetsetupwidget.cpp targetsetupwidget.h
|
targetsetupwidget.cpp targetsetupwidget.h
|
||||||
task.cpp task.h
|
task.cpp task.h
|
||||||
|
taskfile.cpp taskfile.h
|
||||||
taskhub.cpp taskhub.h
|
taskhub.cpp taskhub.h
|
||||||
taskmodel.cpp taskmodel.h
|
taskmodel.cpp taskmodel.h
|
||||||
taskwindow.cpp taskwindow.h
|
taskwindow.cpp taskwindow.h
|
||||||
|
@@ -34,5 +34,17 @@
|
|||||||
\"Description\" : \"Restore a saved session\"
|
\"Description\" : \"Restore a saved session\"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
$$dependencyList
|
$$dependencyList,
|
||||||
|
|
||||||
|
\"Mimetypes\" : [
|
||||||
|
\"<?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\'/>\",
|
||||||
|
\" <glob pattern=\'*.tasks.txt\'/>\",
|
||||||
|
\" </mime-type>\",
|
||||||
|
\"</mime-info>\"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@@ -92,6 +92,7 @@
|
|||||||
#include "showineditortaskhandler.h"
|
#include "showineditortaskhandler.h"
|
||||||
#include "simpleprojectwizard.h"
|
#include "simpleprojectwizard.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
#include "taskfile.h"
|
||||||
#include "taskhub.h"
|
#include "taskhub.h"
|
||||||
#include "toolchainmanager.h"
|
#include "toolchainmanager.h"
|
||||||
#include "toolchainoptionspage.h"
|
#include "toolchainoptionspage.h"
|
||||||
@@ -532,6 +533,7 @@ public:
|
|||||||
void currentModeChanged(Id mode, Id oldMode);
|
void currentModeChanged(Id mode, Id oldMode);
|
||||||
|
|
||||||
void updateWelcomePage();
|
void updateWelcomePage();
|
||||||
|
void loadSesssionTasks();
|
||||||
|
|
||||||
void checkForShutdown();
|
void checkForShutdown();
|
||||||
void timerEvent(QTimerEvent *) override;
|
void timerEvent(QTimerEvent *) override;
|
||||||
@@ -717,6 +719,8 @@ public:
|
|||||||
DefaultDeployConfigurationFactory m_defaultDeployConfigFactory;
|
DefaultDeployConfigurationFactory m_defaultDeployConfigFactory;
|
||||||
|
|
||||||
IDocumentFactory m_documentFactory;
|
IDocumentFactory m_documentFactory;
|
||||||
|
IDocumentFactory m_taskFileFactory;
|
||||||
|
StopMonitoringHandler closeTaskFile;
|
||||||
|
|
||||||
DeviceTypeKitAspect deviceTypeKitAspect;
|
DeviceTypeKitAspect deviceTypeKitAspect;
|
||||||
DeviceKitAspect deviceKitAspect;
|
DeviceKitAspect deviceKitAspect;
|
||||||
@@ -872,10 +876,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
dd, &ProjectExplorerPluginPrivate::updateActions);
|
dd, &ProjectExplorerPluginPrivate::updateActions);
|
||||||
connect(sessionManager, &SessionManager::sessionLoaded,
|
connect(sessionManager, &SessionManager::sessionLoaded,
|
||||||
dd, &ProjectExplorerPluginPrivate::updateActions);
|
dd, &ProjectExplorerPluginPrivate::updateActions);
|
||||||
connect(sessionManager,
|
connect(sessionManager, &SessionManager::sessionLoaded,
|
||||||
&SessionManager::sessionLoaded,
|
dd, &ProjectExplorerPluginPrivate::updateWelcomePage);
|
||||||
dd,
|
connect(sessionManager, &SessionManager::sessionLoaded,
|
||||||
&ProjectExplorerPluginPrivate::updateWelcomePage);
|
dd, &ProjectExplorerPluginPrivate::loadSesssionTasks);
|
||||||
|
|
||||||
connect(sessionManager, &SessionManager::projectAdded, dd, [](ProjectExplorer::Project *project) {
|
connect(sessionManager, &SessionManager::projectAdded, dd, [](ProjectExplorer::Project *project) {
|
||||||
dd->m_allProjectDirectoriesFilter.addDirectory(project->projectDirectory().toString());
|
dd->m_allProjectDirectoriesFilter.addDirectory(project->projectDirectory().toString());
|
||||||
@@ -2242,6 +2246,11 @@ void ProjectExplorerPlugin::extensionsInitialized()
|
|||||||
dd->m_profileMimeTypes += mimeType;
|
dd->m_profileMimeTypes += mimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dd->m_taskFileFactory.addMimeType("text/x-tasklist");
|
||||||
|
dd->m_taskFileFactory.setOpener([](const FilePath &filePath) {
|
||||||
|
return TaskFile::openTasks(filePath);
|
||||||
|
});
|
||||||
|
|
||||||
QString allProjectsFilter = tr("All Projects");
|
QString allProjectsFilter = tr("All Projects");
|
||||||
allProjectsFilter += QLatin1String(" (") + allGlobPatterns.join(QLatin1Char(' '))
|
allProjectsFilter += QLatin1String(" (") + allGlobPatterns.join(QLatin1Char(' '))
|
||||||
+ QLatin1Char(')');
|
+ QLatin1Char(')');
|
||||||
@@ -2251,6 +2260,7 @@ void ProjectExplorerPlugin::extensionsInitialized()
|
|||||||
BuildManager::extensionsInitialized();
|
BuildManager::extensionsInitialized();
|
||||||
TaskHub::addCategory(Constants::TASK_CATEGORY_SANITIZER,
|
TaskHub::addCategory(Constants::TASK_CATEGORY_SANITIZER,
|
||||||
tr("Sanitizer", "Category for sanitizer issues listed under 'Issues'"));
|
tr("Sanitizer", "Category for sanitizer issues listed under 'Issues'"));
|
||||||
|
TaskHub::addCategory(Constants::TASK_CATEGORY_TASKLIST_ID, tr("My Tasks"));
|
||||||
|
|
||||||
SshSettings::loadSettings(Core::ICore::settings());
|
SshSettings::loadSettings(Core::ICore::settings());
|
||||||
const auto searchPathRetriever = [] {
|
const auto searchPathRetriever = [] {
|
||||||
@@ -2594,6 +2604,14 @@ void ProjectExplorerPluginPrivate::updateWelcomePage()
|
|||||||
m_welcomePage.reloadWelcomeScreenData();
|
m_welcomePage.reloadWelcomeScreenData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectExplorerPluginPrivate::loadSesssionTasks()
|
||||||
|
{
|
||||||
|
const FilePath filePath = FilePath::fromVariant(
|
||||||
|
SessionManager::value(Constants::SESSION_TASKFILE_KEY));
|
||||||
|
if (!filePath.isEmpty())
|
||||||
|
TaskFile::openTasks(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectExplorerPluginPrivate::currentModeChanged(Id mode, Id oldMode)
|
void ProjectExplorerPluginPrivate::currentModeChanged(Id mode, Id oldMode)
|
||||||
{
|
{
|
||||||
if (oldMode == Constants::MODE_SESSION) {
|
if (oldMode == Constants::MODE_SESSION) {
|
||||||
|
@@ -145,6 +145,7 @@ Project {
|
|||||||
"targetsetuppage.cpp", "targetsetuppage.h",
|
"targetsetuppage.cpp", "targetsetuppage.h",
|
||||||
"targetsetupwidget.cpp", "targetsetupwidget.h",
|
"targetsetupwidget.cpp", "targetsetupwidget.h",
|
||||||
"task.cpp", "task.h",
|
"task.cpp", "task.h",
|
||||||
|
"taskfile.cpp", "taskfile.h",
|
||||||
"taskhub.cpp", "taskhub.h",
|
"taskhub.cpp", "taskhub.h",
|
||||||
"taskmodel.cpp", "taskmodel.h",
|
"taskmodel.cpp", "taskmodel.h",
|
||||||
"taskwindow.cpp", "taskwindow.h",
|
"taskwindow.cpp", "taskwindow.h",
|
||||||
|
@@ -132,6 +132,7 @@ const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem";
|
|||||||
const char TASK_CATEGORY_DEPLOYMENT[] = "Task.Category.Deploy";
|
const char TASK_CATEGORY_DEPLOYMENT[] = "Task.Category.Deploy";
|
||||||
const char TASK_CATEGORY_AUTOTEST[] = "Task.Category.Autotest";
|
const char TASK_CATEGORY_AUTOTEST[] = "Task.Category.Autotest";
|
||||||
const char TASK_CATEGORY_SANITIZER[] = "Task.Category.Analyzer";
|
const char TASK_CATEGORY_SANITIZER[] = "Task.Category.Analyzer";
|
||||||
|
const char TASK_CATEGORY_TASKLIST_ID[] = "Task.Category.TaskListId";
|
||||||
|
|
||||||
// Wizard categories
|
// Wizard categories
|
||||||
const char QT_PROJECT_WIZARD_CATEGORY[] = "H.Project";
|
const char QT_PROJECT_WIZARD_CATEGORY[] = "H.Project";
|
||||||
@@ -239,6 +240,7 @@ const char LASTSESSION_KEY[] = "ProjectExplorer/StartupSession";
|
|||||||
const char SETTINGS_MENU_HIDE_BUILD[] = "Menu/HideBuild";
|
const char SETTINGS_MENU_HIDE_BUILD[] = "Menu/HideBuild";
|
||||||
const char SETTINGS_MENU_HIDE_DEBUG[] = "Menu/HideDebug";
|
const char SETTINGS_MENU_HIDE_DEBUG[] = "Menu/HideDebug";
|
||||||
const char SETTINGS_MENU_HIDE_ANALYZE[] = "Menu/HideAnalyze";
|
const char SETTINGS_MENU_HIDE_ANALYZE[] = "Menu/HideAnalyze";
|
||||||
|
const char SESSION_TASKFILE_KEY[] = "TaskList.File";
|
||||||
|
|
||||||
// UI texts
|
// UI texts
|
||||||
PROJECTEXPLORER_EXPORT QString msgAutoDetected();
|
PROJECTEXPLORER_EXPORT QString msgAutoDetected();
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2022 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of Qt Creator.
|
** This file is part of Qt Creator.
|
||||||
@@ -23,81 +23,91 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "tasklistplugin.h"
|
|
||||||
|
|
||||||
#include "stopmonitoringhandler.h"
|
|
||||||
#include "taskfile.h"
|
#include "taskfile.h"
|
||||||
#include "tasklistconstants.h"
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include "projectexplorer.h"
|
||||||
#include <coreplugin/idocumentfactory.h>
|
#include "session.h"
|
||||||
|
#include "taskhub.h"
|
||||||
|
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <projectexplorer/session.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <projectexplorer/task.h>
|
|
||||||
#include <projectexplorer/taskhub.h>
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QAction>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
using namespace Core;
|
|
||||||
using namespace ProjectExplorer;
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
static const char SESSION_FILE_KEY[] = "TaskList.File";
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
namespace TaskList {
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static TaskListPlugin *m_instance;
|
// --------------------------------------------------------------------------
|
||||||
|
// TaskFile
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
class TaskListPluginPrivate
|
QList<TaskFile *> TaskFile::openFiles;
|
||||||
|
|
||||||
|
TaskFile::TaskFile(QObject *parent) : Core::IDocument(parent)
|
||||||
{
|
{
|
||||||
public:
|
setId("TaskList.TaskFile");
|
||||||
QList<TaskFile *> m_openFiles;
|
}
|
||||||
Core::IDocumentFactory m_fileFactory;
|
|
||||||
StopMonitoringHandler m_stopMonitoringHandler;
|
Core::IDocument::ReloadBehavior TaskFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||||
};
|
{
|
||||||
|
Q_UNUSED(state)
|
||||||
|
Q_UNUSED(type)
|
||||||
|
return BehaviorSilent;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TaskFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
||||||
|
{
|
||||||
|
Q_UNUSED(flag)
|
||||||
|
|
||||||
|
if (type == TypeRemoved) {
|
||||||
|
deleteLater();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return load(errorString, filePath());
|
||||||
|
}
|
||||||
|
|
||||||
static Task::TaskType typeFrom(const QString &typeName)
|
static Task::TaskType typeFrom(const QString &typeName)
|
||||||
{
|
{
|
||||||
Task::TaskType type = Task::Unknown;
|
|
||||||
QString tmp = typeName.toLower();
|
QString tmp = typeName.toLower();
|
||||||
if (tmp.startsWith(QLatin1String("warn")))
|
if (tmp.startsWith("warn"))
|
||||||
type = Task::Warning;
|
return Task::Warning;
|
||||||
else if (tmp.startsWith(QLatin1String("err")))
|
if (tmp.startsWith("err"))
|
||||||
type = Task::Error;
|
return Task::Error;
|
||||||
return type;
|
return Task::Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList parseRawLine(const QByteArray &raw)
|
static QStringList parseRawLine(const QByteArray &raw)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
QString line = QString::fromUtf8(raw.constData());
|
QString line = QString::fromUtf8(raw.constData());
|
||||||
if (line.startsWith(QLatin1Char('#')))
|
if (line.startsWith('#'))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
return line.split(QLatin1Char('\t'));
|
return line.split('\t');
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString unescape(const QString &input)
|
static QString unescape(const QString &input)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
for (int i = 0; i < input.count(); ++i) {
|
for (int i = 0; i < input.count(); ++i) {
|
||||||
if (input.at(i) == QLatin1Char('\\')) {
|
if (input.at(i) == '\\') {
|
||||||
if (i == input.count() - 1)
|
if (i == input.count() - 1)
|
||||||
continue;
|
continue;
|
||||||
if (input.at(i + 1) == QLatin1Char('n')) {
|
if (input.at(i + 1) == 'n') {
|
||||||
result.append(QLatin1Char('\n'));
|
result.append('\n');
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
} else if (input.at(i + 1) == QLatin1Char('t')) {
|
} else if (input.at(i + 1) == 't') {
|
||||||
result.append(QLatin1Char('\t'));
|
result.append('\t');
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
} else if (input.at(i + 1) == QLatin1Char('\\')) {
|
} else if (input.at(i + 1) == '\\') {
|
||||||
result.append(QLatin1Char('\\'));
|
result.append('\\');
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -112,7 +122,7 @@ static bool parseTaskFile(QString *errorString, const FilePath &name)
|
|||||||
{
|
{
|
||||||
QFile tf(name.toString());
|
QFile tf(name.toString());
|
||||||
if (!tf.open(QIODevice::ReadOnly)) {
|
if (!tf.open(QIODevice::ReadOnly)) {
|
||||||
*errorString = TaskListPlugin::tr("Cannot open task file %1: %2").arg(
|
*errorString = ProjectExplorerPlugin::tr("Cannot open task file %1: %2").arg(
|
||||||
name.toUserOutput(), tf.errorString());
|
name.toUserOutput(), tf.errorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -155,78 +165,34 @@ static bool parseTaskFile(QString *errorString, const FilePath &name)
|
|||||||
description = unescape(description);
|
description = unescape(description);
|
||||||
|
|
||||||
TaskHub::addTask(Task(type, description, FilePath::fromUserInput(file), line,
|
TaskHub::addTask(Task(type, description, FilePath::fromUserInput(file), line,
|
||||||
Constants::TASKLISTTASK_ID));
|
Constants::TASK_CATEGORY_TASKLIST_ID));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
static void clearTasks()
|
||||||
// TaskListPlugin
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
IDocument *TaskListPlugin::openTasks(const FilePath &fileName)
|
|
||||||
{
|
{
|
||||||
TaskFile *file = Utils::findOrDefault(d->m_openFiles, Utils::equal(&TaskFile::filePath, fileName));
|
TaskHub::clearTasks(Constants::TASK_CATEGORY_TASKLIST_ID);
|
||||||
QString errorString;
|
|
||||||
if (file) {
|
|
||||||
file->load(&errorString, fileName);
|
|
||||||
} else {
|
|
||||||
file = new TaskFile(this);
|
|
||||||
|
|
||||||
if (!file->load(&errorString, fileName)) {
|
|
||||||
QMessageBox::critical(ICore::dialogParent(), tr("File Error"), errorString);
|
|
||||||
delete file;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->m_openFiles.append(file);
|
|
||||||
|
|
||||||
// Register with filemanager:
|
|
||||||
DocumentManager::addDocument(file);
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskListPlugin::TaskListPlugin()
|
void TaskFile::stopMonitoring()
|
||||||
{
|
{
|
||||||
m_instance = this;
|
SessionManager::setValue(Constants::SESSION_TASKFILE_KEY, {});
|
||||||
|
|
||||||
|
for (TaskFile *document : qAsConst(openFiles))
|
||||||
|
document->deleteLater();
|
||||||
|
openFiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskListPlugin::~TaskListPlugin()
|
bool TaskFile::load(QString *errorString, const FilePath &fileName)
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
m_instance = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TaskListPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|
||||||
{
|
|
||||||
Q_UNUSED(arguments)
|
|
||||||
Q_UNUSED(errorMessage)
|
|
||||||
|
|
||||||
d = new TaskListPluginPrivate;
|
|
||||||
|
|
||||||
//: Category under which tasklist tasks are listed in Issues view
|
|
||||||
TaskHub::addCategory(Constants::TASKLISTTASK_ID, tr("My Tasks"));
|
|
||||||
|
|
||||||
d->m_fileFactory.addMimeType(QLatin1String("text/x-tasklist"));
|
|
||||||
d->m_fileFactory.setOpener([this](const FilePath &filePath) {
|
|
||||||
return openTasks(filePath);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(SessionManager::instance(), &SessionManager::sessionLoaded,
|
|
||||||
this, &TaskListPlugin::loadDataFromSession);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TaskListPlugin::loadFile(QString *errorString, const FilePath &fileName)
|
|
||||||
{
|
{
|
||||||
|
setFilePath(fileName);
|
||||||
clearTasks();
|
clearTasks();
|
||||||
|
|
||||||
bool result = parseTaskFile(errorString, fileName);
|
bool result = parseTaskFile(errorString, fileName);
|
||||||
if (result) {
|
if (result) {
|
||||||
if (!SessionManager::isDefaultSession(SessionManager::activeSession()))
|
if (!SessionManager::isDefaultSession(SessionManager::activeSession()))
|
||||||
SessionManager::setValue(QLatin1String(SESSION_FILE_KEY), fileName.toString());
|
SessionManager::setValue(Constants::SESSION_TASKFILE_KEY, fileName.toVariant());
|
||||||
} else {
|
} else {
|
||||||
stopMonitoring();
|
stopMonitoring();
|
||||||
}
|
}
|
||||||
@@ -234,27 +200,53 @@ bool TaskListPlugin::loadFile(QString *errorString, const FilePath &fileName)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskListPlugin::stopMonitoring()
|
TaskFile *TaskFile::openTasks(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
SessionManager::setValue(QLatin1String(SESSION_FILE_KEY), QString());
|
TaskFile *file = Utils::findOrDefault(openFiles, Utils::equal(&TaskFile::filePath, filePath));
|
||||||
|
QString errorString;
|
||||||
|
if (file) {
|
||||||
|
file->load(&errorString, filePath);
|
||||||
|
} else {
|
||||||
|
file = new TaskFile(ProjectExplorerPlugin::instance());
|
||||||
|
|
||||||
foreach (TaskFile *document, m_instance->d->m_openFiles)
|
if (!file->load(&errorString, filePath)) {
|
||||||
document->deleteLater();
|
QMessageBox::critical(Core::ICore::dialogParent(), tr("File Error"), errorString);
|
||||||
m_instance->d->m_openFiles.clear();
|
delete file;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
openFiles.append(file);
|
||||||
|
|
||||||
|
// Register with filemanager:
|
||||||
|
Core::DocumentManager::addDocument(file);
|
||||||
|
}
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskListPlugin::clearTasks()
|
bool StopMonitoringHandler::canHandle(const ProjectExplorer::Task &task) const
|
||||||
{
|
{
|
||||||
TaskHub::clearTasks(Constants::TASKLISTTASK_ID);
|
return task.category == Constants::TASK_CATEGORY_TASKLIST_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskListPlugin::loadDataFromSession()
|
void StopMonitoringHandler::handle(const ProjectExplorer::Task &task)
|
||||||
{
|
{
|
||||||
const FilePath fileName = FilePath::fromString(
|
QTC_ASSERT(canHandle(task), return);
|
||||||
SessionManager::value(QLatin1String(SESSION_FILE_KEY)).toString());
|
Q_UNUSED(task)
|
||||||
if (!fileName.isEmpty())
|
TaskFile::stopMonitoring();
|
||||||
openTasks(fileName);
|
}
|
||||||
|
|
||||||
|
QAction *StopMonitoringHandler::createAction(QObject *parent) const
|
||||||
|
{
|
||||||
|
const QString text =
|
||||||
|
QCoreApplication::translate("TaskList::Internal::StopMonitoringHandler",
|
||||||
|
"Stop Monitoring");
|
||||||
|
const QString toolTip =
|
||||||
|
QCoreApplication::translate("TaskList::Internal::StopMonitoringHandler",
|
||||||
|
"Stop monitoring task files.");
|
||||||
|
auto stopMonitoringAction = new QAction(text, parent);
|
||||||
|
stopMonitoringAction->setToolTip(toolTip);
|
||||||
|
return stopMonitoringAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace TaskList
|
} // namespace ProjectExplorer
|
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2022 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of Qt Creator.
|
** This file is part of Qt Creator.
|
||||||
@@ -25,13 +25,21 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "itaskhandler.h"
|
||||||
|
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
|
|
||||||
namespace ProjectExplorer { class Project; }
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
namespace TaskList {
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class StopMonitoringHandler : public ITaskHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool canHandle(const ProjectExplorer::Task &) const override;
|
||||||
|
void handle(const ProjectExplorer::Task &) override;
|
||||||
|
QAction *createAction(QObject *parent) const override;
|
||||||
|
};
|
||||||
|
|
||||||
class TaskFile : public Core::IDocument
|
class TaskFile : public Core::IDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -41,7 +49,13 @@ public:
|
|||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
||||||
|
|
||||||
bool load(QString *errorString, const Utils::FilePath &fileName);
|
bool load(QString *errorString, const Utils::FilePath &fileName);
|
||||||
|
|
||||||
|
static TaskFile *openTasks(const Utils::FilePath &filePath);
|
||||||
|
static void stopMonitoring();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QList<TaskFile *> openFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace TaskList
|
} // namespace ProjectExplorer
|
@@ -1,8 +0,0 @@
|
|||||||
add_qtc_plugin(TaskList
|
|
||||||
PLUGIN_DEPENDS Core ProjectExplorer
|
|
||||||
SOURCES
|
|
||||||
stopmonitoringhandler.cpp stopmonitoringhandler.h
|
|
||||||
taskfile.cpp taskfile.h
|
|
||||||
tasklistconstants.h
|
|
||||||
tasklistplugin.cpp tasklistplugin.h
|
|
||||||
)
|
|
@@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
\"Name\" : \"TaskList\",
|
|
||||||
\"Version\" : \"$$QTCREATOR_VERSION\",
|
|
||||||
\"CompatVersion\" : \"$$QTCREATOR_COMPAT_VERSION\",
|
|
||||||
\"Vendor\" : \"The Qt Company Ltd\",
|
|
||||||
\"Copyright\" : \"(C) $$QTCREATOR_COPYRIGHT_YEAR The Qt Company Ltd\",
|
|
||||||
\"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 The Qt Company.\",
|
|
||||||
\"\",
|
|
||||||
\"GNU General Public License Usage\",
|
|
||||||
\"\",
|
|
||||||
\"Alternatively, this plugin may be used under the terms of the GNU General Public License version 3 as published by the Free Software Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT included in the packaging of this plugin. Please review the following information to ensure the GNU General Public License requirements will be met: https://www.gnu.org/licenses/gpl-3.0.html.\"
|
|
||||||
],
|
|
||||||
\"Description\" : \"Use .tasks-files to populate the Issues view.\",
|
|
||||||
\"Url\" : \"http://www.qt.io\",
|
|
||||||
$$dependencyList,
|
|
||||||
|
|
||||||
\"Mimetypes\" : [
|
|
||||||
\"<?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\'/>\",
|
|
||||||
\" <glob pattern=\'*.tasks.txt\'/>\",
|
|
||||||
\" </mime-type>\",
|
|
||||||
\"</mime-info>\"
|
|
||||||
]
|
|
||||||
}
|
|
@@ -1,67 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "stopmonitoringhandler.h"
|
|
||||||
|
|
||||||
#include "tasklistconstants.h"
|
|
||||||
#include "tasklistplugin.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/task.h>
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
#include <QAction>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
|
|
||||||
using namespace TaskList;
|
|
||||||
using namespace TaskList::Internal;
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// StopMonitoringHandler
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool StopMonitoringHandler::canHandle(const ProjectExplorer::Task &task) const
|
|
||||||
{
|
|
||||||
return task.category == Constants::TASKLISTTASK_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StopMonitoringHandler::handle(const ProjectExplorer::Task &task)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(canHandle(task), return);
|
|
||||||
Q_UNUSED(task)
|
|
||||||
TaskListPlugin::stopMonitoring();
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction *StopMonitoringHandler::createAction(QObject *parent) const
|
|
||||||
{
|
|
||||||
const QString text =
|
|
||||||
QCoreApplication::translate("TaskList::Internal::StopMonitoringHandler",
|
|
||||||
"Stop Monitoring");
|
|
||||||
const QString toolTip =
|
|
||||||
QCoreApplication::translate("TaskList::Internal::StopMonitoringHandler",
|
|
||||||
"Stop monitoring task files.");
|
|
||||||
auto stopMonitoringAction = new QAction(text, parent);
|
|
||||||
stopMonitoringAction->setToolTip(toolTip);
|
|
||||||
return stopMonitoringAction;
|
|
||||||
}
|
|
@@ -1,42 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <projectexplorer/itaskhandler.h>
|
|
||||||
|
|
||||||
namespace TaskList {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class StopMonitoringHandler : public ProjectExplorer::ITaskHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool canHandle(const ProjectExplorer::Task &) const override;
|
|
||||||
void handle(const ProjectExplorer::Task &) override;
|
|
||||||
QAction *createAction(QObject *parent) const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace TaskList
|
|
@@ -1,66 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "taskfile.h"
|
|
||||||
|
|
||||||
#include "tasklistplugin.h"
|
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
using namespace TaskList;
|
|
||||||
using namespace TaskList::Internal;
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// TaskFile
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
TaskFile::TaskFile(QObject *parent) : Core::IDocument(parent)
|
|
||||||
{
|
|
||||||
setId("TaskList.TaskFile");
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::IDocument::ReloadBehavior TaskFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(state)
|
|
||||||
Q_UNUSED(type)
|
|
||||||
return BehaviorSilent;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TaskFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
|
||||||
{
|
|
||||||
Q_UNUSED(flag)
|
|
||||||
|
|
||||||
if (type == TypeRemoved) {
|
|
||||||
deleteLater();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return load(errorString, filePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TaskFile::load(QString *errorString, const Utils::FilePath &fileName)
|
|
||||||
{
|
|
||||||
setFilePath(fileName);
|
|
||||||
return TaskListPlugin::loadFile(errorString, fileName);
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
import qbs 1.0
|
|
||||||
|
|
||||||
QtcPlugin {
|
|
||||||
name: "TaskList"
|
|
||||||
|
|
||||||
Depends { name: "Qt.widgets" }
|
|
||||||
Depends { name: "Utils" }
|
|
||||||
|
|
||||||
Depends { name: "Core" }
|
|
||||||
Depends { name: "ProjectExplorer" }
|
|
||||||
|
|
||||||
files: [
|
|
||||||
"stopmonitoringhandler.cpp",
|
|
||||||
"stopmonitoringhandler.h",
|
|
||||||
"taskfile.cpp",
|
|
||||||
"taskfile.h",
|
|
||||||
"tasklistconstants.h",
|
|
||||||
"tasklistplugin.cpp",
|
|
||||||
"tasklistplugin.h",
|
|
||||||
]
|
|
||||||
}
|
|
@@ -1,34 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace TaskList {
|
|
||||||
namespace Constants {
|
|
||||||
|
|
||||||
const char TASKLISTTASK_ID[] = "TaskList.TaskListTaskId";
|
|
||||||
|
|
||||||
} // namespace Constants
|
|
||||||
} // namespace TaskList
|
|
@@ -1,61 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <coreplugin/idocumentfactory.h>
|
|
||||||
#include <extensionsystem/iplugin.h>
|
|
||||||
|
|
||||||
namespace Utils { class FilePath; }
|
|
||||||
|
|
||||||
namespace TaskList {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class TaskListPlugin final : public ExtensionSystem::IPlugin
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "TaskList.json")
|
|
||||||
|
|
||||||
public:
|
|
||||||
TaskListPlugin();
|
|
||||||
~TaskListPlugin() final;
|
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorMessage) override;
|
|
||||||
|
|
||||||
static bool loadFile(QString *errorString, const Utils::FilePath &fileName);
|
|
||||||
|
|
||||||
static void stopMonitoring();
|
|
||||||
static void clearTasks();
|
|
||||||
|
|
||||||
Core::IDocument *openTasks(const Utils::FilePath &fileName);
|
|
||||||
|
|
||||||
void loadDataFromSession();
|
|
||||||
|
|
||||||
private:
|
|
||||||
class TaskListPluginPrivate *d = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace TaskList
|
|
Reference in New Issue
Block a user