Commit edb3094f authored by Vasiliy Sorokin's avatar Vasiliy Sorokin Committed by Eike Ziller

Initial commit for TODO Plugin

Change-Id: I8f12017be5dc65b1244df369880e3b4851af4b2e
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent fe62330c
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.
#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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddKeywordDialog</class>
<widget class="QDialog" name="AddKeywordDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>379</width>
<height>225</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Icons</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Color</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="2" column="0">
<widget class="QLineEdit" name="colorEdit">
<property name="inputMask">
<string>\#HHHHHH; </string>
</property>
<property name="text">
<string>#000000</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Keyword</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddKeywordDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddKeywordDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<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>
#include "keyword.h"
Keyword::Keyword()
{
}
Keyword::Keyword(QString name_, QIcon icon_, QColor warningColor_) :
name(name_), icon(icon_), warningColor(warningColor_)
{
}
QDataStream &operator<<(QDataStream &out, const Keyword &myObj)
{
out << myObj.name;
out << myObj.icon;
out << myObj.warningColor;
return out;
}
QDataStream &operator>>(QDataStream &in, Keyword &myObj)
{
in >> myObj.name;
in >> myObj.icon;
in >> myObj.warningColor;
return in;
}
#ifndef KEYWORD_H
#define KEYWORD_H
#include <QIcon>
#include <QColor>
#include <QString>
#include <QList>
#include <QMetaType>
class Keyword
{
public:
Keyword();
Keyword(QString name_, QIcon icon_, QColor warningColor_);
QString name;
QIcon icon;
QColor warningColor;
};
typedef QList<Keyword> KeywordsList;
QDataStream &operator<<(QDataStream &out, const Keyword &myObj);
QDataStream &operator>>(QDataStream &in, Keyword &myObj);
Q_DECLARE_METATYPE(KeywordsList)
Q_DECLARE_METATYPE(Keyword)
#endif // KEYWORD_H
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include "addkeyworddialog.h"
SettingsDialog::SettingsDialog(QWidget *parent) :
QWidget(parent),
ui(new Ui::SettingsDialog)
{
ui->setupUi(this);
connect(this->ui->addButton, SIGNAL(clicked()), this, SLOT(addButtonClicked()));
connect(this->ui->removeButton, SIGNAL(clicked()), this, SLOT(removeButtonClicked()));
connect(this->ui->resetButton, SIGNAL(clicked()), this, SLOT(resetButtonClicked()));
connect(this->ui->buildIssuesRadioButton, SIGNAL(toggled(bool)), this, SIGNAL(settingsChanged()));
connect(this->ui->todoOutputRadioButton, SIGNAL(toggled(bool)), this, SIGNAL(settingsChanged()));
connect(this->ui->projectRadioButton, SIGNAL(toggled(bool)), this, SIGNAL(settingsChanged()));
connect(this->ui->currentFileRadioButton, SIGNAL(toggled(bool)), this, SIGNAL(settingsChanged()));
}
SettingsDialog::~SettingsDialog()
{
delete ui;
}
void SettingsDialog::setProjectRadioButtonEnabled(bool what)
{
this->ui->projectRadioButton->setChecked(what);
}
void SettingsDialog::setCurrentFileRadioButtonEnabled(bool what)
{
this->ui->currentFileRadioButton->setChecked(what);
}
void SettingsDialog::setBuildIssuesRadioButtonEnabled(bool what)
{
this->ui->buildIssuesRadioButton->setChecked(what);
}
void SettingsDialog::setTodoOutputRadioButtonEnabled(bool what)
{
this->ui->todoOutputRadioButton->setChecked(what);
}
void SettingsDialog::addToKeywordsList(Keyword keyword)
{
QListWidgetItem *item = new QListWidgetItem(keyword.icon, keyword.name);
item->setBackgroundColor(keyword.warningColor);
this->ui->keywordsList->addItem(item);
}
void SettingsDialog::setKeywordsList(KeywordsList list)
{
if (!list.count())
{
resetButtonClicked();
}
else
{
for (int i = 0; i < list.count(); ++i)
{
addToKeywordsList(list.at(i));
}
}
}
bool SettingsDialog::projectRadioButtonEnabled()
{
return this->ui->projectRadioButton->isChecked();
}
bool SettingsDialog::currentFileRadioButtonEnabled()
{
return this->ui->currentFileRadioButton->isChecked();
}
bool SettingsDialog::buildIssuesRadioButtonEnabled()
{
return this->ui->buildIssuesRadioButton->isChecked();
}
bool SettingsDialog::todoOutputRadioButtonEnabled()
{
return this->ui->todoOutputRadioButton->isChecked();
}
KeywordsList SettingsDialog::keywordsList()
{
KeywordsList list;
for (int i = 0; i < this->ui->keywordsList->count(); ++i)
{
Keyword keyword;
keyword.name = this->ui->keywordsList->item(i)->text();
keyword.icon = this->ui->keywordsList->item(i)->icon();
keyword.warningColor = this->ui->keywordsList->item(i)->backgroundColor();
list.append(keyword);
}
return list;
}
void SettingsDialog::clearKeywordsList()
{
this->ui->keywordsList->clear();
}
void SettingsDialog::addButtonClicked()
{
Keyword keyword;
AddKeywordDialog *addKeywordDialog = new AddKeywordDialog(this);
if (addKeywordDialog->exec() == QDialog::Accepted)
{
keyword.name = addKeywordDialog->keywordName();
keyword.icon = addKeywordDialog->keywordIcon();
keyword.warningColor = addKeywordDialog->keywordColor();
addToKeywordsList(keyword);
emit settingsChanged();
}
}
void SettingsDialog::removeButtonClicked()
{
this->ui->keywordsList->takeItem(this->ui->keywordsList->currentRow());
emit settingsChanged();
}
void SettingsDialog::resetButtonClicked()
{
clearKeywordsList();
addToKeywordsList(Keyword("TODO", QIcon(":/warning"), QColor("#BFFFC8")));
addToKeywordsList(Keyword("NOTE", QIcon(":/info"), QColor("#E2DFFF")));
addToKeywordsList(Keyword("FIXME", QIcon(":/error"), QColor("#FFBFBF")));
addToKeywordsList(Keyword("BUG", QIcon(":/error"), QColor("#FFDFDF")));
addToKeywordsList(Keyword("HACK", QIcon(":/info"), QColor("#FFFFAA")));
emit settingsChanged();
}
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QWidget>
#include "keyword.h"
namespace Ui {
class SettingsDialog;
}
class SettingsDialog : public QWidget
{
Q_OBJECT
public:
explicit SettingsDialog(QWidget *parent = 0);
~SettingsDialog();
void setProjectRadioButtonEnabled(bool what);
void setCurrentFileRadioButtonEnabled(bool what);
void setBuildIssuesRadioButtonEnabled(bool what);
void setTodoOutputRadioButtonEnabled(bool what);
void addToKeywordsList(Keyword);
void setKeywordsList(KeywordsList);
bool projectRadioButtonEnabled();
bool currentFileRadioButtonEnabled();
bool buildIssuesRadioButtonEnabled();
bool todoOutputRadioButtonEnabled();
KeywordsList keywordsList();
signals:
void settingsChanged();
private slots:
void clearKeywordsList();
void addButtonClicked();
void removeButtonClicked();
void resetButtonClicked();
private:
Ui::SettingsDialog *ui;
};
#endif // SETTINGSDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QWidget" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>740</width>
<height>423</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QListWidget" name="keywordsList"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="projectGroupBox">
<property name="title">
<string>View options</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QRadioButton" name="currentFileRadioButton">
<property name="text">
<string>From current opened file</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="projectRadioButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>From projects</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="paneGroupBox">
<property name="title">
<string>Pane options</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="todoOutputRadioButton">
<property name="text">
<string>Show in &quot;TODO Output&quot;</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="buildIssuesRadioButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Show in &quot;Build Issues&quot;</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Icons and Colors show on
TODO Output pane only</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "settingspage.h"
#include <coreplugin/icore.h>
#include <QList>
#include <QMessageBox>
SettingsPage::SettingsPage(KeywordsList keywords, int projectOptions, int paneOptions, QObject *parent) : IOptionsPage(parent)
{
this->keywords = keywords;