2011-10-25 23:14:27 +03:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (c) 2014 Dmitry Savchenko
|
|
|
|
|
** Copyright (c) 2014 Vasiliy Sorokin
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** 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
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt 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"
|
2012-02-14 22:43:26 +04:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.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
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
connect(m_todoOutputPane, SIGNAL(scanningScopeChanged(ScanningScope)), SLOT(scanningScopeChanged(ScanningScope)));
|
|
|
|
|
connect(m_todoOutputPane, SIGNAL(todoItemClicked(TodoItem)), SLOT(todoItemClicked(TodoItem)));
|
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);
|
|
|
|
|
connect(m_optionsPage, SIGNAL(settingsChanged(Settings)), SLOT(settingsChanged(Settings)));
|
2012-02-14 22:43:26 +04:00
|
|
|
}
|
|
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Todo
|