Commit 5623e520 authored by Dmitry Savchenko's avatar Dmitry Savchenko Committed by Eike Ziller

To-do plugin added.

Change-Id: Ideaf91b2f9ce3d9252ca40b7224a2ab4238341f1
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent edb3094f
...@@ -43,7 +43,8 @@ SUBDIRS = plugin_coreplugin \ ...@@ -43,7 +43,8 @@ SUBDIRS = plugin_coreplugin \
plugin_qmlprofiler \ plugin_qmlprofiler \
plugin_remotelinux \ plugin_remotelinux \
plugin_madde \ plugin_madde \
plugin_valgrind plugin_valgrind \
plugin_todo
isEmpty(IDE_PACKAGE_MODE) { isEmpty(IDE_PACKAGE_MODE) {
SUBDIRS += plugin_helloworld \ SUBDIRS += plugin_helloworld \
...@@ -51,7 +52,6 @@ isEmpty(IDE_PACKAGE_MODE) { ...@@ -51,7 +52,6 @@ isEmpty(IDE_PACKAGE_MODE) {
} else:!isEmpty(UPDATEINFO_ENABLE) { } else:!isEmpty(UPDATEINFO_ENABLE) {
SUBDIRS += plugin_updateinfo SUBDIRS += plugin_updateinfo
} }
linux-* { linux-* {
SUBDIRS += debugger/ptracepreload.pro SUBDIRS += debugger/ptracepreload.pro
} }
...@@ -306,3 +306,9 @@ plugin_macros.depends = plugin_texteditor ...@@ -306,3 +306,9 @@ plugin_macros.depends = plugin_texteditor
plugin_macros.depends += plugin_find plugin_macros.depends += plugin_find
plugin_macros.depends += plugin_locator plugin_macros.depends += plugin_locator
plugin_macros.depends += plugin_coreplugin plugin_macros.depends += plugin_coreplugin
plugin_todo.subdir = todo
plugin_todo.depends = plugin_coreplugin
plugin_todo.depends += plugin_projectexplorer
plugin_todo.depends += plugin_texteditor
plugin_todo.depends += plugin_cpptools
\ No newline at end of file
Installation.
1. Download QtCreator sources.
2. Build QtCreator from sources or download and install binary.
3. Change todoplugin.pro, You need QTC_BUILD_DIR set to your path to qtcreator binary and set QTC_SOURCE_DIR your path to qtcreator source
4. Build plugin:
qmake
make
Copyright (c) 2010, Vasiliy Sorokin
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the vsorokin nor the names of its contributors may be used to endorse or
promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<plugin name=\"Todo\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_VERSION\">
<vendor>Dmitry Savchenko</vendor>
<copyright>(C) 2012 Dmitry Savchenko, (C) 2010 Vasiliy Sorokin</copyright>
<license>
Commercial Usage
Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
GNU Lesser General Public License Usage
Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. 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.
</license>
<description>Adds pane that lists all TODO, FIXME, etc. entries in comments.</description>
<url>http://qt.nokia.com/</url>
<dependencyList>
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"TextEditor\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
#include "addkeyworddialog.h"
#include "ui_addkeyworddialog.h"
#include <QColorDialog>
AddKeywordDialog::AddKeywordDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddKeywordDialog)
{
ui->setupUi(this);
this->ui->listWidget->setViewMode(QListWidget::IconMode);
this->ui->listWidget->addItem(new QListWidgetItem(QIcon(":/info"), "information"));
this->ui->listWidget->addItem(new QListWidgetItem(QIcon(":/warning"), "warning"));
this->ui->listWidget->addItem(new QListWidgetItem(QIcon(":/error"), "error"));
connect(this->ui->pushButton, SIGNAL(clicked()), this, SLOT(chooseColor()));
}
AddKeywordDialog::~AddKeywordDialog()
{
delete ui;
}
QString AddKeywordDialog::keywordName()
{
return this->ui->lineEdit->text();
}
QColor AddKeywordDialog::keywordColor()
{
return QColor(this->ui->colorEdit->text());
}
QIcon AddKeywordDialog::keywordIcon()
{
return this->ui->listWidget->currentItem()->icon();
}
void AddKeywordDialog::chooseColor()
{
QColorDialog *dialog = new QColorDialog(QColor(this->ui->colorEdit->text()),this);
this->ui->colorEdit->setText(dialog->getColor().name());
}
#ifndef ADDKEYWORDDIALOG_H
#define ADDKEYWORDDIALOG_H
#include <QDialog>
namespace Ui {
class AddKeywordDialog;
}
class AddKeywordDialog : public QDialog
{
Q_OBJECT
public:
explicit AddKeywordDialog(QWidget *parent = 0);
~AddKeywordDialog();
QString keywordName();
QColor keywordColor();
QIcon keywordIcon();
public slots:
void chooseColor();
private:
Ui::AddKeywordDialog *ui;
};
#endif // ADDKEYWORDDIALOG_H
/**************************************************************************
**
** 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.
**
**************************************************************************/
#ifndef CONSTANTS_H
#define CONSTANTS_H
#include <QtGlobal>
namespace Todo {
namespace Constants {
// Default todo item background colors
const char COLOR_TODO_BG[] = "#ccffcc";
const char COLOR_WARNING_BG[] = "#ffffcc";
const char COLOR_FIXME_BG[] = "#ffcccc";
const char COLOR_BUG_BG[] = "#ffcccc";
const char COLOR_NOTE_BG[] = "#e0ebff";
// Todo item icons
// http://en.wikipedia.org/wiki/File:Information_icon_with_gradient_background.svg,
// public domain, tuned a bit
const char ICON_INFO[] = ":/todoplugin/images/info.png";
// Dummy, needs to be changed
const char ICON_TODO[] = ":/todoplugin/images/todo.png";
const char ICON_WARNING[] = ":/projectexplorer/images/compile_warning.png";
const char ICON_ERROR[] = ":/projectexplorer/images/compile_error.png";
// Public domain, I’m the author
const char ICON_CURRENT_FILE[] = ":/todoplugin/images/current-file.png";
const char ICON_WHOLE_PROJECT[] = ":/todoplugin/images/whole-project.png";
// Settings entries
const char SETTINGS_GROUP[] = "TodoPlugin";
const char SCANNING_SCOPE[] = "ScanningScope";
const char ITEMS_DISPLAY_PLACE[] = "ItemsDisplayPlace";
const char KEYWORDS_LIST[] = "Keywords";
// TODO Output TreeWidget columns
enum OutputColumnIndex {
OUTPUT_COLUMN_TEXT,
OUTPUT_COLUMN_FILE,
OUTPUT_COLUMN_LINE,
OUTPUT_COLUMN_LAST
};
const char OUPTUT_COLUMN_TEXT_TITLE[] = QT_TRANSLATE_NOOP("TodoOutputPane", "Description");
const char OUTPUT_COLUMN_FILE_TITLE[] = QT_TRANSLATE_NOOP("TodoOutputPane", "File");
const char OUTPUT_COLUMN_LINE_TITLE[] = QT_TRANSLATE_NOOP("TodoOutputPane", "Line");
const int OUTPUT_TOOLBAR_SPACER_WIDHT = 25;
const int OUTPUT_PANE_UPDATE_INTERVAL = 2000;
const char OUTPUT_PANE_TITLE[] = QT_TRANSLATE_NOOP("TodoOutputPane", "To-Do Entries");
} // namespace Constants
} // namespace Todo
#endif // CONSTANTS_H
/**************************************************************************
**
** 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.
**
**************************************************************************/
#include "cpptodoitemsscanner.h"
#include <projectexplorer/project.h>
#include <TranslationUnit.h>
namespace Todo {
namespace Internal {
CppTodoItemsScanner::CppTodoItemsScanner(const KeywordList &keywordList, QObject *parent) :
TodoItemsScanner(keywordList, parent)
{
CPlusPlus::CppModelManagerInterface *modelManager = CPlusPlus::CppModelManagerInterface::instance();
connect(modelManager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)), this,
SLOT(documentUpdated(CPlusPlus::Document::Ptr)), Qt::DirectConnection);
}
bool CppTodoItemsScanner::shouldProcessFile(const QString &fileName)
{
CPlusPlus::CppModelManagerInterface *modelManager = CPlusPlus::CppModelManagerInterface::instance();
foreach (const CPlusPlus::CppModelManagerInterface::ProjectInfo &info, modelManager->projectInfos())
if (info.project().data()->files(ProjectExplorer::Project::ExcludeGeneratedFiles).contains(fileName))
return true;
return false;
}
void CppTodoItemsScanner::keywordListChanged()
{
// We need to rescan everything known to the code model
// TODO: It would be nice to only tokenize the source files, not update the code model entirely.
CPlusPlus::CppModelManagerInterface *modelManager = CPlusPlus::CppModelManagerInterface::instance();
QStringList filesToBeUpdated;
foreach (const CPlusPlus::CppModelManagerInterface::ProjectInfo &info, modelManager->projectInfos())
filesToBeUpdated << info.project().data()->files(ProjectExplorer::Project::ExcludeGeneratedFiles);
modelManager->updateSourceFiles(filesToBeUpdated);
}
void CppTodoItemsScanner::documentUpdated(CPlusPlus::Document::Ptr doc)
{
if (shouldProcessFile(doc->fileName()))
processDocument(doc);
}
void CppTodoItemsScanner::processDocument(CPlusPlus::Document::Ptr doc)
{
QList<TodoItem> itemList;
CPlusPlus::TranslationUnit *translationUnit = doc->translationUnit();
for (unsigned i = 0; i < translationUnit->commentCount(); ++i) {
// Get comment source
CPlusPlus::Token token = doc->translationUnit()->commentAt(i);
QByteArray source = doc->utf8Source().mid(token.begin(), token.length()).trimmed();
if ((token.kind() == CPlusPlus::T_COMMENT) || (token.kind() == CPlusPlus::T_DOXY_COMMENT)) {
// Remove trailing "*/"
source = source.left(source.length() - 2);
}
// Process every line of the comment
// TODO: Do not create QStringList, just iterate through a string tracking line endings.
QStringList commentLines = QString::fromUtf8(source).split("\n", QString::SkipEmptyParts);
unsigned lineNumber = 0;
translationUnit->getPosition(token.begin(), &lineNumber);
for (int j = 0; j < commentLines.count(); ++j) {
const QString &commentLine = commentLines.at(j);
processCommentLine(doc->fileName(), commentLine, lineNumber + j, itemList);
}
}
emit itemsFetched(doc->fileName(), itemList);
}
}
}
/**************************************************************************
**
** 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.
**
**************************************************************************/
#ifndef CPPTODOITEMSSCANNER_H
#define CPPTODOITEMSSCANNER_H
#include "todoitemsscanner.h"
#include <cplusplus/ModelManagerInterface.h>
namespace Todo {
namespace Internal {
class CppTodoItemsScanner : public TodoItemsScanner
{
Q_OBJECT
public:
explicit CppTodoItemsScanner(const KeywordList &keywordList, QObject *parent = 0);
protected:
bool shouldProcessFile(const QString &fileName);
void keywordListChanged();
private slots:
void documentUpdated(CPlusPlus::Document::Ptr doc);
private:
void processDocument(CPlusPlus::Document::Ptr doc);
};
}
}
#endif // CPPTODOITEMSSCANNER_H
<RCC>
<qresource prefix="/">
<file alias="error">images/error.png</file>
<file alias="info">images/info.png</file>
<file alias="warning">images/warning.png</file>
<file alias="todo">images/todo.png</file>
</qresource>
</RCC>
src/plugins/todo/images/info.png

856 Bytes | W: | H:

src/plugins/todo/images/info.png

854 Bytes | W: | H:

src/plugins/todo/images/info.png
src/plugins/todo/images/info.png
src/plugins/todo/images/info.png
src/plugins/todo/images/info.png
  • 2-up
  • Swipe
  • Onion skin
src/plugins/todo/images/todo.png

10.8 KB | W: | H:

src/plugins/todo/images/todo.png

195 Bytes | W: | H:

src/plugins/todo/images/todo.png
src/plugins/todo/images/todo.png
src/plugins/todo/images/todo.png
src/plugins/todo/images/todo.png
  • 2-up
  • Swipe
  • Onion skin
/**************************************************************************
**
** 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.
**
**************************************************************************/
#include "keyword.h" #include "keyword.h"
Keyword::Keyword() namespace Todo {
namespace Internal {
Keyword::Keyword() : color(Qt::white)
{ {
} }
Keyword::Keyword(QString name_, QIcon icon_, QColor warningColor_) : bool Keyword::equals(const Keyword &other) const
name(name_), icon(icon_), warningColor(warningColor_)
{ {
return (this->name == other.name)
&& (this->iconResource == other.iconResource)
&& (this->color == other.color);
} }
QDataStream &operator<<(QDataStream &out, const Keyword &myObj) bool operator ==(Keyword &k1, Keyword &k2)
{ {
out << myObj.name; return k1.equals(k2);
out << myObj.icon;
out << myObj.warningColor;
return out;
} }
QDataStream &operator>>(QDataStream &in, Keyword &myObj) bool operator !=(Keyword &k1, Keyword &k2)
{ {
in >> myObj.name; return !k1.equals(k2);
in >> myObj.icon;
in >> myObj.warningColor;
return in;
} }
} // namespace Internal
} // namespace Todo
/**************************************************************************
**
** 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.
**
**************************************************************************/
#ifndef KEYWORD_H #ifndef KEYWORD_H
#define KEYWORD_H #define KEYWORD_H
...@@ -7,23 +40,26 @@ ...@@ -7,23 +40,26 @@
#include <QList> #include <QList>
#include <QMetaType> #include <QMetaType>
namespace Todo {
namespace Internal {
class Keyword class Keyword
{ {
public: public:
Keyword(); Keyword();
Keyword(QString name_, QIcon icon_, QColor warningColor_);
QString name; QString name;
QIcon icon; QString iconResource;
QColor warningColor; QColor color;
bool equals(const Keyword &other) const;
}; };
typedef QList<Keyword> KeywordsList; typedef QList<Keyword> KeywordList;
QDataStream &operator<<(QDataStream &out, const Keyword &myObj);
QDataStream &operator>>(QDataStream &in, Keyword &myObj);
bool operator ==(Keyword &k1, Keyword &k2);
bool operator !=(Keyword &k1, Keyword &k2);
Q_DECLARE_METATYPE(KeywordsList) } // namespace Internal
Q_DECLARE_METATYPE(Keyword) } // namespace Todo
#endif // KEYWORD_H #endif // KEYWORD_H
/**************************************************************************
**
** This file is part of Qt Creator
**