2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2011-10-25 23:14:27 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 Dmitry Savchenko
|
|
|
|
|
** Copyright (C) 2016 Vasiliy Sorokin
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-10-25 23:14:27 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-10-25 23:14:27 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2011-10-25 23:14:27 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2011-10-25 23:14:27 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-02-14 22:43:26 +04:00
|
|
|
|
|
|
|
|
#include "todoplugin.h"
|
2011-10-25 23:14:27 +03:00
|
|
|
#include "constants.h"
|
2012-02-24 09:43:52 +01:00
|
|
|
#include "optionspage.h"
|
|
|
|
|
#include "keyword.h"
|
|
|
|
|
#include "todooutputpane.h"
|
|
|
|
|
#include "todoitemsprovider.h"
|
2015-05-18 22:47:20 +03:00
|
|
|
#include "todoprojectsettingswidget.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>
|
2011-10-25 23:14:27 +03:00
|
|
|
|
|
|
|
|
#include <QtPlugin>
|
2012-02-14 22:43:26 +04:00
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
namespace Todo {
|
|
|
|
|
namespace Internal {
|
2012-02-14 22:43:26 +04:00
|
|
|
|
2018-12-10 00:19:56 +01:00
|
|
|
TodoPlugin::TodoPlugin()
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2011-10-25 23:14:27 +03:00
|
|
|
qRegisterMetaType<TodoItem>("TodoItem");
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2018-12-10 00:19:56 +01:00
|
|
|
TodoPlugin::~TodoPlugin() = default;
|
2012-02-14 22:43:26 +04:00
|
|
|
|
|
|
|
|
bool TodoPlugin::initialize(const QStringList& args, QString *errMsg)
|
|
|
|
|
{
|
2019-07-23 10:58:00 +02:00
|
|
|
Q_UNUSED(args)
|
|
|
|
|
Q_UNUSED(errMsg)
|
2012-02-14 22:43:26 +04:00
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
m_settings.load(Core::ICore::settings());
|
|
|
|
|
|
|
|
|
|
createOptionsPage();
|
|
|
|
|
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);
|
2016-03-30 13:07:00 +02:00
|
|
|
panelFactory->setDisplayName(TodoProjectSettingsWidget::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()); });
|
2015-05-18 22:47:20 +03:00
|
|
|
|
2012-02-14 22:43:26 +04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
void TodoPlugin::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);
|
|
|
|
|
m_optionsPage->setSettings(m_settings);
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
void TodoPlugin::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
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
void TodoPlugin::todoItemClicked(const TodoItem &item)
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2016-07-19 09:49:51 +03:00
|
|
|
if (item.file.exists())
|
|
|
|
|
Core::EditorManager::openEditorAt(item.file.toString(), item.line);
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
void TodoPlugin::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
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
void TodoPlugin::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,
|
|
|
|
|
this, &TodoPlugin::scanningScopeChanged);
|
|
|
|
|
connect(m_todoOutputPane, &TodoOutputPane::todoItemClicked,
|
|
|
|
|
this, &TodoPlugin::todoItemClicked);
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
void TodoPlugin::createOptionsPage()
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2018-02-08 11:54:42 +01:00
|
|
|
m_optionsPage = new OptionsPage(m_settings, this);
|
2015-01-29 10:42:16 +01:00
|
|
|
connect(m_optionsPage, &OptionsPage::settingsChanged,
|
|
|
|
|
this, &TodoPlugin::settingsChanged);
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Todo
|