2011-10-25 23:14:27 +03:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 Dmitry Savchenko
|
|
|
|
|
** Copyright (C) 2015 Vasiliy Sorokin
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2011-10-25 23:14:27 +03:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-10-25 23:14:27 +03:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
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>
|
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
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
TodoPlugin::TodoPlugin() :
|
|
|
|
|
m_todoOutputPane(0),
|
|
|
|
|
m_optionsPage(0),
|
|
|
|
|
m_todoItemsProvider(0)
|
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
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
TodoPlugin::~TodoPlugin()
|
2012-02-14 22:43:26 +04:00
|
|
|
{
|
2011-10-25 23:14:27 +03:00
|
|
|
m_settings.save(Core::ICore::settings());
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TodoPlugin::initialize(const QStringList& args, QString *errMsg)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(args);
|
|
|
|
|
Q_UNUSED(errMsg);
|
|
|
|
|
|
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
|
|
|
|
2015-05-18 22:47:20 +03:00
|
|
|
auto panelFactory = new ProjectExplorer::ProjectPanelFactory();
|
|
|
|
|
panelFactory->setPriority(100);
|
|
|
|
|
panelFactory->setDisplayName(TodoProjectSettingsWidget::tr("To-Do Settings"));
|
|
|
|
|
panelFactory->setCreateWidgetFunction([this, panelFactory](ProjectExplorer::Project *project) -> QWidget * {
|
|
|
|
|
auto *panel = new ProjectExplorer::PropertiesPanel;
|
|
|
|
|
panel->setDisplayName(panelFactory->displayName());
|
|
|
|
|
auto *widget = new TodoProjectSettingsWidget(project);
|
|
|
|
|
connect(widget, &TodoProjectSettingsWidget::projectSettingsChanged,
|
|
|
|
|
m_todoItemsProvider, [this, project](){m_todoItemsProvider->projectSettingsChanged(project);});
|
|
|
|
|
panel->setWidget(widget);
|
|
|
|
|
auto *panelsWidget = new ProjectExplorer::PanelsWidget();
|
|
|
|
|
panelsWidget->addPropertiesPanel(panel);
|
|
|
|
|
panelsWidget->setFocusProxy(widget);
|
|
|
|
|
return panelsWidget;
|
|
|
|
|
});
|
|
|
|
|
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
|
|
|
|
|
|
2012-02-14 22:43:26 +04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TodoPlugin::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2014-10-24 10:28:28 +02:00
|
|
|
if (QFileInfo::exists(item.file)) {
|
2012-05-08 09:43:14 +02:00
|
|
|
Core::IEditor *editor = Core::EditorManager::openEditor(item.file);
|
2011-10-25 23:14:27 +03:00
|
|
|
editor->gotoLine(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
|
|
|
{
|
2011-10-25 23:14:27 +03:00
|
|
|
m_todoItemsProvider = new TodoItemsProvider(m_settings);
|
|
|
|
|
addAutoReleasedObject(m_todoItemsProvider);
|
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
|
|
|
{
|
2011-10-25 23:14:27 +03:00
|
|
|
m_todoOutputPane = new TodoOutputPane(m_todoItemsProvider->todoItemsModel());
|
|
|
|
|
addAutoReleasedObject(m_todoOutputPane);
|
|
|
|
|
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
|
|
|
{
|
2011-10-25 23:14:27 +03:00
|
|
|
m_optionsPage = new OptionsPage(m_settings);
|
|
|
|
|
addAutoReleasedObject(m_optionsPage);
|
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
|