aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/todo/keyworddialog.cpp
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@theqtcompany.com>2015-11-16 16:45:05 +0100
committerAlessandro Portale <alessandro.portale@theqtcompany.com>2015-11-18 17:12:53 +0000
commit19eb9e4f06408877351bf28c5332725c76772b7e (patch)
tree570a2b905fba7a50d54d5cb954f7a37caefe586d /src/plugins/todo/keyworddialog.cpp
parent04fda7d0f5b8f9d868e63e8905508185aeef32cf (diff)
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>
Diffstat (limited to 'src/plugins/todo/keyworddialog.cpp')
-rw-r--r--src/plugins/todo/keyworddialog.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/plugins/todo/keyworddialog.cpp b/src/plugins/todo/keyworddialog.cpp
index eb9ceeb860a..9fb9f2022a4 100644
--- a/src/plugins/todo/keyworddialog.cpp
+++ b/src/plugins/todo/keyworddialog.cpp
@@ -50,7 +50,7 @@ KeywordDialog::KeywordDialog(const Keyword &keyword, const QSet<QString> &alread
m_alreadyUsedKeywordNames(alreadyUsedKeywordNames)
{
ui->setupUi(this);
- setupListWidget(keyword.iconResource);
+ setupListWidget(keyword.iconType);
setupColorWidgets(keyword.color);
ui->keywordNameEdit->setText(keyword.name);
ui->errorLabel->hide();
@@ -68,7 +68,7 @@ Keyword KeywordDialog::keyword()
{
Keyword result;
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();
return result;
@@ -85,31 +85,27 @@ void KeywordDialog::acceptButtonClicked()
accept();
}
-void KeywordDialog::setupListWidget(const QString &selectedIcon)
+void KeywordDialog::setupListWidget(IconType selectedIcon)
{
ui->listWidget->setViewMode(QListWidget::IconMode);
ui->listWidget->setDragEnabled(false);
- const QString infoIconName = QLatin1String(Core::Constants::ICON_INFO);
- QListWidgetItem *item = new QListWidgetItem(Utils::ThemeHelper::themedIcon(infoIconName),
- QLatin1String("information"));
- item->setData(Qt::UserRole, infoIconName);
+
+ QListWidgetItem *item =
+ new QListWidgetItem(icon(IconType::Info), QLatin1String("information"));
+ item->setData(Qt::UserRole, static_cast<int>(IconType::Info));
ui->listWidget->addItem(item);
- const QString warningIconName = QLatin1String(Core::Constants::ICON_WARNING);
- item = new QListWidgetItem(Utils::ThemeHelper::themedIcon(warningIconName),
- QLatin1String("warning"));
- item->setData(Qt::UserRole, warningIconName);
+ item = new QListWidgetItem(icon(IconType::Warning), QLatin1String("warning"));
+ item->setData(Qt::UserRole, static_cast<int>(IconType::Warning));
ui->listWidget->addItem(item);
- const QString errorIconName = QLatin1String(Core::Constants::ICON_ERROR);
- item = new QListWidgetItem(Utils::ThemeHelper::themedIcon(errorIconName),
- QLatin1String("error"));
- item->setData(Qt::UserRole, errorIconName);
+ item = new QListWidgetItem(icon(IconType::Error), QLatin1String("error"));
+ item->setData(Qt::UserRole, static_cast<int>(IconType::Error));
ui->listWidget->addItem(item);
for (int i = 0; i < ui->listWidget->count(); ++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);
break;
}