Commit 048b1226 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

support icon for category

parent 7a2ec469
......@@ -337,6 +337,7 @@ void BranchesDialog::sendMessage(const QString &plainText, bool warn)
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Error") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("category"), i18n("Git"));
genericMessage.insert(QStringLiteral("categoryIcon"), QIcon(QStringLiteral(":/icons/icons/sc-apps-git.svg")));
genericMessage.insert(QStringLiteral("plainText"), plainText);
Q_EMIT m_pluginView->message(genericMessage);
}
......
......@@ -131,6 +131,7 @@ void GitWidget::sendMessage(const QString &plainText, bool warn)
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Error") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("category"), i18n("Git"));
genericMessage.insert(QStringLiteral("categoryIcon"), QIcon(QStringLiteral(":/icons/icons/sc-apps-git.svg")));
genericMessage.insert(QStringLiteral("plainText"), plainText);
Q_EMIT m_pluginView->message(genericMessage);
}
......
......@@ -115,6 +115,18 @@ void KateOutputView::slotMessage(const QVariantMap &message)
const QDateTime current = QDateTime::currentDateTime();
dateTimeColumn->setText(current.time().toString(Qt::TextDate));
/**
* category
* provided by sender to better categorize the output into stuff like: lsp, git, ...
* optional icon support
*/
auto categoryColumn = new QStandardItem();
categoryColumn->setText(message.value(QStringLiteral("category")).toString().trimmed());
const auto categoryIcon = message.value(QStringLiteral("categoryIcon")).value<QIcon>();
if (!categoryIcon.isNull()) {
categoryColumn->setIcon(categoryIcon);
}
/**
* type column: shows the type, icons for some types only
*/
......@@ -138,13 +150,6 @@ void KateOutputView::slotMessage(const QVariantMap &message)
typeColumn->setText(i18nc("@info", "Log"));
}
/**
* category
* provided by sender to better categorize the output into stuff like: lsp, git, ...
*/
auto categoryColumn = new QStandardItem();
categoryColumn->setText(message.value(QStringLiteral("category")).toString().trimmed());
/**
* body column, formatted text
* we just set the full message as attribute
......@@ -156,7 +161,7 @@ void KateOutputView::slotMessage(const QVariantMap &message)
/**
* add new message to model as one row
*/
m_messagesModel.appendRow({dateTimeColumn, typeColumn, categoryColumn, bodyColumn});
m_messagesModel.appendRow({dateTimeColumn, categoryColumn, typeColumn, bodyColumn});
/**
* ensure correct sizing
......
......@@ -90,6 +90,12 @@ public Q_SLOTS:
*
* will be used to allow the user to filter for
*
* one can additionally provide a categoryIcon
*
* message["categoryIcon"] = QIcon(...)
*
* the categoryIcon icon QVariant must contain a QIcon, nothing else!
*
*/
void slotMessage(const QVariantMap &message);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment