2011-10-25 23:14:27 +03:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2012 Dmitry Savchenko.
|
|
|
|
|
** Copyright (c) 2010 Vasiliy Sorokin.
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
2012-02-14 22:43:26 +04:00
|
|
|
|
|
|
|
|
#include "todoplugin.h"
|
2011-10-25 23:14:27 +03:00
|
|
|
#include "constants.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
|
|
|
{
|
2011-10-25 23:14:27 +03:00
|
|
|
if (QFileInfo(item.file).exists()) {
|
|
|
|
|
Core::IEditor *editor = Core::EditorManager::instance()->openEditor(item.file);
|
|
|
|
|
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
|
|
|
Q_EXPORT_PLUGIN2(Todo, TodoPlugin)
|
2012-02-14 22:43:26 +04:00
|
|
|
|
2011-10-25 23:14:27 +03:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Todo
|