forked from qt-creator/qt-creator
Todo: Store icons in the settings via index instead of strings
This allows us to use something else than a string in order to reference icons. For an upcoming patch this will be necessary. Since this patch introduces a settings structure change, a migration feature from the old "Keyword\iconResource" string to the new "Keyword \iconType" int is implemented. Change-Id: Ia5695418fb135510ed549cf9a7cb59aab5389f31 Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
This commit is contained in:
@@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
#include "keyword.h"
|
#include "keyword.h"
|
||||||
|
|
||||||
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <utils/themehelper.h>
|
||||||
|
|
||||||
namespace Todo {
|
namespace Todo {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -41,7 +44,7 @@ Keyword::Keyword() : color(Qt::white)
|
|||||||
bool Keyword::equals(const Keyword &other) const
|
bool Keyword::equals(const Keyword &other) const
|
||||||
{
|
{
|
||||||
return (this->name == other.name)
|
return (this->name == other.name)
|
||||||
&& (this->iconResource == other.iconResource)
|
&& (this->iconType == other.iconType)
|
||||||
&& (this->color == other.color);
|
&& (this->color == other.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#ifndef KEYWORD_H
|
#ifndef KEYWORD_H
|
||||||
#define KEYWORD_H
|
#define KEYWORD_H
|
||||||
|
|
||||||
|
#include "todoicons.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@@ -46,7 +48,7 @@ public:
|
|||||||
Keyword();
|
Keyword();
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
QString iconResource;
|
IconType iconType;
|
||||||
QColor color;
|
QColor color;
|
||||||
bool equals(const Keyword &other) const;
|
bool equals(const Keyword &other) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ KeywordDialog::KeywordDialog(const Keyword &keyword, const QSet<QString> &alread
|
|||||||
m_alreadyUsedKeywordNames(alreadyUsedKeywordNames)
|
m_alreadyUsedKeywordNames(alreadyUsedKeywordNames)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setupListWidget(keyword.iconResource);
|
setupListWidget(keyword.iconType);
|
||||||
setupColorWidgets(keyword.color);
|
setupColorWidgets(keyword.color);
|
||||||
ui->keywordNameEdit->setText(keyword.name);
|
ui->keywordNameEdit->setText(keyword.name);
|
||||||
ui->errorLabel->hide();
|
ui->errorLabel->hide();
|
||||||
@@ -68,7 +68,7 @@ Keyword KeywordDialog::keyword()
|
|||||||
{
|
{
|
||||||
Keyword result;
|
Keyword result;
|
||||||
result.name = keywordName();
|
result.name = keywordName();
|
||||||
result.iconResource = ui->listWidget->currentItem()->data(Qt::UserRole).toString();
|
result.iconType = static_cast<IconType>(ui->listWidget->currentItem()->data(Qt::UserRole).toInt());
|
||||||
result.color = ui->colorEdit->text();
|
result.color = ui->colorEdit->text();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -85,31 +85,27 @@ void KeywordDialog::acceptButtonClicked()
|
|||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeywordDialog::setupListWidget(const QString &selectedIcon)
|
void KeywordDialog::setupListWidget(IconType selectedIcon)
|
||||||
{
|
{
|
||||||
ui->listWidget->setViewMode(QListWidget::IconMode);
|
ui->listWidget->setViewMode(QListWidget::IconMode);
|
||||||
ui->listWidget->setDragEnabled(false);
|
ui->listWidget->setDragEnabled(false);
|
||||||
const QString infoIconName = QLatin1String(Core::Constants::ICON_INFO);
|
|
||||||
QListWidgetItem *item = new QListWidgetItem(Utils::ThemeHelper::themedIcon(infoIconName),
|
QListWidgetItem *item =
|
||||||
QLatin1String("information"));
|
new QListWidgetItem(icon(IconType::Info), QLatin1String("information"));
|
||||||
item->setData(Qt::UserRole, infoIconName);
|
item->setData(Qt::UserRole, static_cast<int>(IconType::Info));
|
||||||
ui->listWidget->addItem(item);
|
ui->listWidget->addItem(item);
|
||||||
|
|
||||||
const QString warningIconName = QLatin1String(Core::Constants::ICON_WARNING);
|
item = new QListWidgetItem(icon(IconType::Warning), QLatin1String("warning"));
|
||||||
item = new QListWidgetItem(Utils::ThemeHelper::themedIcon(warningIconName),
|
item->setData(Qt::UserRole, static_cast<int>(IconType::Warning));
|
||||||
QLatin1String("warning"));
|
|
||||||
item->setData(Qt::UserRole, warningIconName);
|
|
||||||
ui->listWidget->addItem(item);
|
ui->listWidget->addItem(item);
|
||||||
|
|
||||||
const QString errorIconName = QLatin1String(Core::Constants::ICON_ERROR);
|
item = new QListWidgetItem(icon(IconType::Error), QLatin1String("error"));
|
||||||
item = new QListWidgetItem(Utils::ThemeHelper::themedIcon(errorIconName),
|
item->setData(Qt::UserRole, static_cast<int>(IconType::Error));
|
||||||
QLatin1String("error"));
|
|
||||||
item->setData(Qt::UserRole, errorIconName);
|
|
||||||
ui->listWidget->addItem(item);
|
ui->listWidget->addItem(item);
|
||||||
|
|
||||||
for (int i = 0; i < ui->listWidget->count(); ++i) {
|
for (int i = 0; i < ui->listWidget->count(); ++i) {
|
||||||
item = ui->listWidget->item(i);
|
item = ui->listWidget->item(i);
|
||||||
if (item->data(Qt::UserRole).toString() == selectedIcon) {
|
if (static_cast<IconType>(item->data(Qt::UserRole).toInt()) == selectedIcon) {
|
||||||
ui->listWidget->setCurrentItem(item);
|
ui->listWidget->setCurrentItem(item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ namespace Internal {
|
|||||||
namespace Ui { class KeywordDialog; }
|
namespace Ui { class KeywordDialog; }
|
||||||
|
|
||||||
class Keyword;
|
class Keyword;
|
||||||
|
enum class IconType;
|
||||||
|
|
||||||
class KeywordDialog : public QDialog
|
class KeywordDialog : public QDialog
|
||||||
{
|
{
|
||||||
@@ -57,7 +58,7 @@ private slots:
|
|||||||
void acceptButtonClicked();
|
void acceptButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupListWidget(const QString &selectedIcon);
|
void setupListWidget(IconType selectedIcon);
|
||||||
void setupColorWidgets(const QColor &color);
|
void setupColorWidgets(const QColor &color);
|
||||||
bool canAccept();
|
bool canAccept();
|
||||||
bool isKeywordNameCorrect();
|
bool isKeywordNameCorrect();
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ QList<TodoItem> LineParser::todoItemsFromKeywordEntries(const QList<KeywordEntry
|
|||||||
TodoItem item;
|
TodoItem item;
|
||||||
item.text = m_keywords.at(entry.keywordIndex).name + entry.text;
|
item.text = m_keywords.at(entry.keywordIndex).name + entry.text;
|
||||||
item.color = m_keywords.at(entry.keywordIndex).color;
|
item.color = m_keywords.at(entry.keywordIndex).color;
|
||||||
item.iconResource = m_keywords.at(entry.keywordIndex).iconResource;
|
item.iconType = m_keywords.at(entry.keywordIndex).iconType;
|
||||||
todoItems << item;
|
todoItems << item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ void OptionsDialog::setSettings(const Settings &settings)
|
|||||||
void OptionsDialog::addToKeywordsList(const Keyword &keyword)
|
void OptionsDialog::addToKeywordsList(const Keyword &keyword)
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = new QListWidgetItem(
|
QListWidgetItem *item = new QListWidgetItem(
|
||||||
Utils::ThemeHelper::themedIcon(keyword.iconResource), keyword.name);
|
icon(keyword.iconType), keyword.name);
|
||||||
item->setData(Qt::UserRole, keyword.iconResource);
|
item->setData(Qt::UserRole, static_cast<int>(keyword.iconType));
|
||||||
item->setBackgroundColor(keyword.color);
|
item->setBackgroundColor(keyword.color);
|
||||||
ui->keywordsList->addItem(item);
|
ui->keywordsList->addItem(item);
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ void OptionsDialog::editKeyword(QListWidgetItem *item)
|
|||||||
{
|
{
|
||||||
Keyword keyword;
|
Keyword keyword;
|
||||||
keyword.name = item->text();
|
keyword.name = item->text();
|
||||||
keyword.iconResource = item->data(Qt::UserRole).toString();
|
keyword.iconType = static_cast<IconType>(item->data(Qt::UserRole).toInt());
|
||||||
keyword.color = item->backgroundColor();
|
keyword.color = item->backgroundColor();
|
||||||
|
|
||||||
QSet<QString> keywordNamesButThis = keywordNames();
|
QSet<QString> keywordNamesButThis = keywordNames();
|
||||||
@@ -123,9 +123,9 @@ void OptionsDialog::editKeyword(QListWidgetItem *item)
|
|||||||
KeywordDialog *keywordDialog = new KeywordDialog(keyword, keywordNamesButThis, this);
|
KeywordDialog *keywordDialog = new KeywordDialog(keyword, keywordNamesButThis, this);
|
||||||
if (keywordDialog->exec() == QDialog::Accepted) {
|
if (keywordDialog->exec() == QDialog::Accepted) {
|
||||||
keyword = keywordDialog->keyword();
|
keyword = keywordDialog->keyword();
|
||||||
item->setIcon(Utils::ThemeHelper::themedIcon(keyword.iconResource));
|
item->setIcon(icon(keyword.iconType));
|
||||||
item->setText(keyword.name);
|
item->setText(keyword.name);
|
||||||
item->setData(Qt::UserRole, keyword.iconResource);
|
item->setData(Qt::UserRole, static_cast<int>(keyword.iconType));
|
||||||
item->setBackgroundColor(keyword.color);
|
item->setBackgroundColor(keyword.color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ Settings OptionsDialog::settingsFromUi()
|
|||||||
|
|
||||||
Keyword keyword;
|
Keyword keyword;
|
||||||
keyword.name = item->text();
|
keyword.name = item->text();
|
||||||
keyword.iconResource = item->data(Qt::UserRole).toString();
|
keyword.iconType = static_cast<IconType>(item->data(Qt::UserRole).toInt());
|
||||||
keyword.color = item->backgroundColor();
|
keyword.color = item->backgroundColor();
|
||||||
|
|
||||||
settings.keywords << keyword;
|
settings.keywords << keyword;
|
||||||
|
|||||||
@@ -48,12 +48,12 @@ void Settings::save(QSettings *settings) const
|
|||||||
if (const int size = keywords.size()) {
|
if (const int size = keywords.size()) {
|
||||||
const QString nameKey = QLatin1String("name");
|
const QString nameKey = QLatin1String("name");
|
||||||
const QString colorKey = QLatin1String("color");
|
const QString colorKey = QLatin1String("color");
|
||||||
const QString iconResourceKey = QLatin1String("iconResource");
|
const QString iconTypeKey = QLatin1String("iconType");
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
settings->setArrayIndex(i);
|
settings->setArrayIndex(i);
|
||||||
settings->setValue(nameKey, keywords.at(i).name);
|
settings->setValue(nameKey, keywords.at(i).name);
|
||||||
settings->setValue(colorKey, keywords.at(i).color);
|
settings->setValue(colorKey, keywords.at(i).color);
|
||||||
settings->setValue(iconResourceKey, keywords.at(i).iconResource);
|
settings->setValue(iconTypeKey, static_cast<int>(keywords.at(i).iconType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
@@ -62,6 +62,17 @@ void Settings::save(QSettings *settings) const
|
|||||||
settings->sync();
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compatibility helper for transition from 3.6 to higher
|
||||||
|
// TODO: remove in 4.0
|
||||||
|
IconType resourceToTypeKey(const QString &key)
|
||||||
|
{
|
||||||
|
if (key.contains(QLatin1String("error")))
|
||||||
|
return IconType::Error;
|
||||||
|
else if (key.contains(QLatin1String("warning")))
|
||||||
|
return IconType::Warning;
|
||||||
|
return IconType::Info;
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::load(QSettings *settings)
|
void Settings::load(QSettings *settings)
|
||||||
{
|
{
|
||||||
setDefault();
|
setDefault();
|
||||||
@@ -76,13 +87,16 @@ void Settings::load(QSettings *settings)
|
|||||||
if (keywordsSize > 0) {
|
if (keywordsSize > 0) {
|
||||||
const QString nameKey = QLatin1String("name");
|
const QString nameKey = QLatin1String("name");
|
||||||
const QString colorKey = QLatin1String("color");
|
const QString colorKey = QLatin1String("color");
|
||||||
const QString iconResourceKey = QLatin1String("iconResource");
|
const QString iconResourceKey = QLatin1String("iconResource"); // Legacy since 3.7 TODO: remove in 4.0
|
||||||
|
const QString iconTypeKey = QLatin1String("iconType");
|
||||||
for (int i = 0; i < keywordsSize; ++i) {
|
for (int i = 0; i < keywordsSize; ++i) {
|
||||||
settings->setArrayIndex(i);
|
settings->setArrayIndex(i);
|
||||||
Keyword keyword;
|
Keyword keyword;
|
||||||
keyword.name = settings->value(nameKey).toString();
|
keyword.name = settings->value(nameKey).toString();
|
||||||
keyword.color = settings->value(colorKey).value<QColor>();
|
keyword.color = settings->value(colorKey).value<QColor>();
|
||||||
keyword.iconResource = settings->value(iconResourceKey).toString();
|
keyword.iconType = settings->contains(iconTypeKey) ?
|
||||||
|
static_cast<IconType>(settings->value(iconTypeKey).toInt())
|
||||||
|
: resourceToTypeKey(settings->value(iconResourceKey).toString());
|
||||||
newKeywords << keyword;
|
newKeywords << keyword;
|
||||||
}
|
}
|
||||||
keywords = newKeywords;
|
keywords = newKeywords;
|
||||||
@@ -101,27 +115,27 @@ void Settings::setDefault()
|
|||||||
Keyword keyword;
|
Keyword keyword;
|
||||||
|
|
||||||
keyword.name = QLatin1String("TODO");
|
keyword.name = QLatin1String("TODO");
|
||||||
keyword.iconResource = QLatin1String(Core::Constants::ICON_WARNING);
|
keyword.iconType = IconType::Warning;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_TODO_BG));
|
keyword.color = QColor(QLatin1String(Constants::COLOR_TODO_BG));
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
|
|
||||||
keyword.name = QLatin1String("NOTE");
|
keyword.name = QLatin1String("NOTE");
|
||||||
keyword.iconResource = QLatin1String(Core::Constants::ICON_INFO);
|
keyword.iconType = IconType::Info;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_NOTE_BG));
|
keyword.color = QColor(QLatin1String(Constants::COLOR_NOTE_BG));
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
|
|
||||||
keyword.name = QLatin1String("FIXME");
|
keyword.name = QLatin1String("FIXME");
|
||||||
keyword.iconResource = QLatin1String(Core::Constants::ICON_ERROR);
|
keyword.iconType = IconType::Error;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_FIXME_BG));
|
keyword.color = QColor(QLatin1String(Constants::COLOR_FIXME_BG));
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
|
|
||||||
keyword.name = QLatin1String("BUG");
|
keyword.name = QLatin1String("BUG");
|
||||||
keyword.iconResource = QLatin1String(Core::Constants::ICON_ERROR);
|
keyword.iconType = IconType::Error;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_BUG_BG));
|
keyword.color = QColor(QLatin1String(Constants::COLOR_BUG_BG));
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
|
|
||||||
keyword.name = QLatin1String("WARNING");
|
keyword.name = QLatin1String("WARNING");
|
||||||
keyword.iconResource = QLatin1String(Core::Constants::ICON_WARNING);
|
keyword.iconType = IconType::Warning;
|
||||||
keyword.color = QColor(QLatin1String(Constants::COLOR_WARNING_BG));
|
keyword.color = QColor(QLatin1String(Constants::COLOR_WARNING_BG));
|
||||||
keywords.append(keyword);
|
keywords.append(keyword);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ HEADERS += todoplugin.h \
|
|||||||
lineparser.h \
|
lineparser.h \
|
||||||
todooutputtreeview.h \
|
todooutputtreeview.h \
|
||||||
todooutputtreeviewdelegate.h \
|
todooutputtreeviewdelegate.h \
|
||||||
todoprojectsettingswidget.h
|
todoprojectsettingswidget.h \
|
||||||
|
todoicons.h
|
||||||
|
|
||||||
SOURCES += todoplugin.cpp \
|
SOURCES += todoplugin.cpp \
|
||||||
keyword.cpp \
|
keyword.cpp \
|
||||||
@@ -34,7 +35,8 @@ SOURCES += todoplugin.cpp \
|
|||||||
lineparser.cpp \
|
lineparser.cpp \
|
||||||
todooutputtreeview.cpp \
|
todooutputtreeview.cpp \
|
||||||
todooutputtreeviewdelegate.cpp \
|
todooutputtreeviewdelegate.cpp \
|
||||||
todoprojectsettingswidget.cpp
|
todoprojectsettingswidget.cpp \
|
||||||
|
todoicons.cpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
todoplugin.qrc
|
todoplugin.qrc
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ QtcPlugin {
|
|||||||
"qmljstodoitemsscanner.h",
|
"qmljstodoitemsscanner.h",
|
||||||
"settings.cpp",
|
"settings.cpp",
|
||||||
"settings.h",
|
"settings.h",
|
||||||
|
"todoicons.h",
|
||||||
|
"todoicons.cpp",
|
||||||
"todoitem.h",
|
"todoitem.h",
|
||||||
"todoitemsmodel.cpp",
|
"todoitemsmodel.cpp",
|
||||||
"todoitemsmodel.h",
|
"todoitemsmodel.h",
|
||||||
|
|||||||
63
src/plugins/todo/todoicons.cpp
Normal file
63
src/plugins/todo/todoicons.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Dmitry Savchenko
|
||||||
|
** Copyright (C) 2015 Vasiliy Sorokin
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** 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 The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <utils/themehelper.h>
|
||||||
|
|
||||||
|
#include "todoicons.h"
|
||||||
|
|
||||||
|
namespace Todo {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
QIcon icon(IconType type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case IconType::Info: {
|
||||||
|
const static QIcon icon = Utils::ThemeHelper::themedIcon(
|
||||||
|
QLatin1String(Core::Constants::ICON_INFO));
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
case IconType::Warning: {
|
||||||
|
const static QIcon icon = Utils::ThemeHelper::themedIcon(
|
||||||
|
QLatin1String(Core::Constants::ICON_WARNING));
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
case IconType::Error: {
|
||||||
|
const static QIcon icon = Utils::ThemeHelper::themedIcon(
|
||||||
|
QLatin1String(Core::Constants::ICON_ERROR));
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Todo
|
||||||
51
src/plugins/todo/todoicons.h
Normal file
51
src/plugins/todo/todoicons.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Dmitry Savchenko
|
||||||
|
** Copyright (C) 2015 Vasiliy Sorokin
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** 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 The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TODOICONS_H
|
||||||
|
#define TODOICONS_H
|
||||||
|
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
|
namespace Todo {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
enum class IconType {
|
||||||
|
Info,
|
||||||
|
Error,
|
||||||
|
Warning
|
||||||
|
};
|
||||||
|
|
||||||
|
QIcon icon(IconType type);
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Todo
|
||||||
|
|
||||||
|
#endif // TODOICONS_H
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define TODOITEM_H
|
#define TODOITEM_H
|
||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
#include "todoicons.h"
|
||||||
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -49,7 +50,7 @@ public:
|
|||||||
QString text;
|
QString text;
|
||||||
QString file;
|
QString file;
|
||||||
int line;
|
int line;
|
||||||
QString iconResource;
|
IconType iconType;
|
||||||
QColor color;
|
QColor color;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ QVariant TodoItemsModel::data(const QModelIndex &index, int role) const
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return item.text;
|
return item.text;
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
return QVariant::fromValue(Utils::ThemeHelper::themedIcon(item.iconResource));
|
return icon(item.iconType);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,8 @@ void TodoOutputPane::todoTreeViewClicked(const QModelIndex &index)
|
|||||||
item.file = index.sibling(row, Constants::OUTPUT_COLUMN_FILE).data().toString();
|
item.file = index.sibling(row, Constants::OUTPUT_COLUMN_FILE).data().toString();
|
||||||
item.line = index.sibling(row, Constants::OUTPUT_COLUMN_LINE).data().toInt();
|
item.line = index.sibling(row, Constants::OUTPUT_COLUMN_LINE).data().toInt();
|
||||||
item.color = index.data(Qt::BackgroundColorRole).value<QColor>();
|
item.color = index.data(Qt::BackgroundColorRole).value<QColor>();
|
||||||
item.iconResource = index.sibling(row, Constants::OUTPUT_COLUMN_TEXT).data(Qt::DecorationRole).toString();
|
item.iconType = static_cast<IconType>(index.sibling(row, Constants::OUTPUT_COLUMN_TEXT)
|
||||||
|
.data(Qt::UserRole).toInt());
|
||||||
|
|
||||||
emit todoItemClicked(item);
|
emit todoItemClicked(item);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user