2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 Dmitry Savchenko
|
|
|
|
|
// Copyright (C) 2016 Vasiliy Sorokin
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2012-02-14 22:43:26 +04:00
|
|
|
|
|
|
|
|
#include "todoplugin.h"
|
2022-07-12 12:52:55 +02:00
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
#include "optionsdialog.h"
|
2012-02-24 09:43:52 +01:00
|
|
|
#include "todooutputpane.h"
|
|
|
|
|
#include "todoitemsprovider.h"
|
2015-05-18 22:47:20 +03:00
|
|
|
#include "todoprojectsettingswidget.h"
|
2022-07-12 12:52:55 +02:00
|
|
|
#include "todotr.h"
|
2012-02-14 22:43:26 +04:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2016-07-22 15:53:01 +02:00
|
|
|
|
2015-05-18 22:47:20 +03:00
|
|
|
#include <projectexplorer/projectpanelfactory.h>
|
2021-05-25 14:48:09 +02:00
|
|
|
#include <utils/link.h>
|
2011-10-25 23:14:27 +03:00
|
|
|
|
2012-02-14 22:43:26 +04:00
|
|
|
#include <QSettings>
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
namespace Todo {
|
|
|
|
|
namespace Internal {
|
2012-02-14 22:43:26 +04:00
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
class TodoPluginPrivate : public QObject
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2020-02-07 17:50:21 +01:00
|
|
|
public:
|
|
|
|
|
TodoPluginPrivate();
|
2012-02-14 22:43:26 +04:00
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
void settingsChanged(const Settings &settings);
|
|
|
|
|
void scanningScopeChanged(ScanningScope scanningScope);
|
|
|
|
|
void todoItemClicked(const TodoItem &item);
|
|
|
|
|
void createItemsProvider();
|
|
|
|
|
void createTodoOutputPane();
|
2012-02-14 22:43:26 +04:00
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
Settings m_settings;
|
|
|
|
|
TodoOutputPane *m_todoOutputPane = nullptr;
|
|
|
|
|
TodoOptionsPage m_optionsPage{&m_settings, [this] { settingsChanged(m_settings); }};
|
|
|
|
|
TodoItemsProvider *m_todoItemsProvider = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TodoPluginPrivate::TodoPluginPrivate()
|
|
|
|
|
{
|
2011-10-25 23:14:27 +03:00
|
|
|
m_settings.load(Core::ICore::settings());
|
|
|
|
|
|
|
|
|
|
createItemsProvider();
|
|
|
|
|
createTodoOutputPane();
|
2012-02-14 22:43:26 +04:00
|
|
|
|
2016-07-22 15:53:01 +02:00
|
|
|
auto panelFactory = new ProjectExplorer::ProjectPanelFactory;
|
2015-05-18 22:47:20 +03:00
|
|
|
panelFactory->setPriority(100);
|
2022-07-12 12:52:55 +02:00
|
|
|
panelFactory->setDisplayName(Tr::tr("To-Do"));
|
2017-09-07 17:05:47 +02:00
|
|
|
panelFactory->setCreateWidgetFunction([this](ProjectExplorer::Project *project) {
|
2016-07-22 15:53:01 +02:00
|
|
|
auto widget = new TodoProjectSettingsWidget(project);
|
2015-05-18 22:47:20 +03:00
|
|
|
connect(widget, &TodoProjectSettingsWidget::projectSettingsChanged,
|
2016-07-22 15:53:01 +02:00
|
|
|
m_todoItemsProvider, [this, project] { m_todoItemsProvider->projectSettingsChanged(project); });
|
|
|
|
|
return widget;
|
2015-05-18 22:47:20 +03:00
|
|
|
});
|
|
|
|
|
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
|
2016-08-31 15:19:27 +02:00
|
|
|
connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested,
|
|
|
|
|
this, [this] { m_settings.save(Core::ICore::settings()); });
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
void TodoPluginPrivate::settingsChanged(const Settings &settings)
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2011-10-25 23:14:27 +03:00
|
|
|
settings.save(Core::ICore::settings());
|
|
|
|
|
m_settings = settings;
|
2012-02-14 22:43:26 +04:00
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
m_todoItemsProvider->settingsChanged(m_settings);
|
|
|
|
|
m_todoOutputPane->setScanningScope(m_settings.scanningScope);
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
void TodoPluginPrivate::scanningScopeChanged(ScanningScope scanningScope)
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2011-10-25 23:14:27 +03:00
|
|
|
Settings newSettings = m_settings;
|
|
|
|
|
newSettings.scanningScope = scanningScope;
|
|
|
|
|
settingsChanged(newSettings);
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
void TodoPluginPrivate::todoItemClicked(const TodoItem &item)
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2016-07-19 09:49:51 +03:00
|
|
|
if (item.file.exists())
|
2021-05-25 14:48:09 +02:00
|
|
|
Core::EditorManager::openEditorAt(Utils::Link(item.file, item.line));
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
void TodoPluginPrivate::createItemsProvider()
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2018-02-08 11:54:42 +01:00
|
|
|
m_todoItemsProvider = new TodoItemsProvider(m_settings, this);
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
void TodoPluginPrivate::createTodoOutputPane()
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2018-02-08 11:54:42 +01:00
|
|
|
m_todoOutputPane = new TodoOutputPane(m_todoItemsProvider->todoItemsModel(), &m_settings, this);
|
2011-10-25 23:14:27 +03:00
|
|
|
m_todoOutputPane->setScanningScope(m_settings.scanningScope);
|
2015-01-29 10:42:16 +01:00
|
|
|
connect(m_todoOutputPane, &TodoOutputPane::scanningScopeChanged,
|
2020-02-07 17:50:21 +01:00
|
|
|
this, &TodoPluginPrivate::scanningScopeChanged);
|
2015-01-29 10:42:16 +01:00
|
|
|
connect(m_todoOutputPane, &TodoOutputPane::todoItemClicked,
|
2020-02-07 17:50:21 +01:00
|
|
|
this, &TodoPluginPrivate::todoItemClicked);
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2020-02-07 17:50:21 +01:00
|
|
|
TodoPlugin::TodoPlugin()
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2020-02-07 17:50:21 +01:00
|
|
|
qRegisterMetaType<TodoItem>("TodoItem");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TodoPlugin::~TodoPlugin()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TodoPlugin::initialize(const QStringList& args, QString *errMsg)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(args)
|
|
|
|
|
Q_UNUSED(errMsg)
|
|
|
|
|
|
|
|
|
|
d = new TodoPluginPrivate;
|
|
|
|
|
|
|
|
|
|
return true;
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Todo
|