Commit 26b1dec3 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

add time & category

parent dc7d373f
......@@ -331,9 +331,14 @@ void BranchesDialog::reselectFirst()
m_treeView->setCurrentIndex(index);
}
void BranchesDialog::sendMessage(const QString &message, bool warn)
void BranchesDialog::sendMessage(const QString &plainText, bool warn)
{
m_pluginView->sendMessage(message, warn);
// use generic output view
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Warning") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("category"), i18n("Git"));
genericMessage.insert(QStringLiteral("plainText"), plainText);
Q_EMIT m_pluginView->message(genericMessage);
}
void BranchesDialog::createNewBranch(const QString &branch, const QString &fromBranch)
......
......@@ -122,9 +122,14 @@ void GitWidget::initGitExe()
}
}
void GitWidget::sendMessage(const QString &message, bool warn)
void GitWidget::sendMessage(const QString &plainText, bool warn)
{
m_pluginView->sendMessage(message, warn);
// use generic output view
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Warning") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("category"), i18n("Git"));
genericMessage.insert(QStringLiteral("plainText"), plainText);
Q_EMIT m_pluginView->message(genericMessage);
}
QProcess *GitWidget::gitprocess()
......
......@@ -638,13 +638,4 @@ void KateProjectPluginView::slotUpdateStatus(bool visible)
}
}
void KateProjectPluginView::sendMessage(const QString &plainText, bool warn)
{
// use generic output view
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Warning") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("plainText"), plainText);
Q_EMIT message(genericMessage);
}
#include "kateprojectpluginview.moc"
......@@ -100,13 +100,6 @@ public:
return m_plugin;
}
/**
* Send out trivial plain text message, potential warnings
* @param message plain text message
* @param warn warning or not?
*/
void sendMessage(const QString &plainText, bool warn);
public Q_SLOTS:
/**
* Create views for given project.
......
......@@ -296,7 +296,7 @@ void StashDialog::reselectFirst()
void StashDialog::sendMessage(const QString &message, bool warn)
{
// just proxy to git widget => proxy to plugin view
// just proxy to git widget
m_gitwidget->sendMessage(message, warn);
}
......
......@@ -9,6 +9,7 @@
#include <KLocalizedString>
#include <QDateTime>
#include <QPainter>
#include <QTextDocument>
#include <QTreeView>
......@@ -79,16 +80,25 @@ KateOutputView::KateOutputView(KateMainWindow *mainWindow, QWidget *parent)
m_messagesTreeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_messagesTreeView->setHeaderHidden(true);
m_messagesTreeView->setRootIsDecorated(false);
m_messagesTreeView->setAlternatingRowColors(true);
m_messagesTreeView->setModel(&m_messagesModel);
layout->addWidget(m_messagesTreeView);
// we want a special delegate to render the message body, as that might be plain text
// mark down or HTML
m_messagesTreeView->setItemDelegateForColumn(1, &m_messageBodyDelegate);
m_messagesTreeView->setItemDelegateForColumn(3, &m_messageBodyDelegate);
}
void KateOutputView::slotMessage(const QVariantMap &message)
{
/**
* date time column: we want to know when a message arrived
* TODO: perhaps store full date time for more stuff later
*/
auto dateTimeColumn = new QStandardItem();
const QDateTime current = QDateTime::currentDateTime();
dateTimeColumn->setText(current.time().toString(Qt::TextDate));
/**
* type column: shows the type, icons for some types only
*/
......@@ -110,6 +120,13 @@ 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
......@@ -121,7 +138,15 @@ void KateOutputView::slotMessage(const QVariantMap &message)
/**
* add new message to model as one row
*/
m_messagesModel.appendRow({typeColumn, bodyColumn});
m_messagesModel.appendRow({dateTimeColumn, typeColumn, categoryColumn, bodyColumn});
/**
* ensure correct sizing
* OPTIMIZE: we can do that only if e.g. a first time a new type/category pops up
*/
m_messagesTreeView->resizeColumnToContents(0);
m_messagesTreeView->resizeColumnToContents(1);
m_messagesTreeView->resizeColumnToContents(2);
/**
* if message requires it => show the tool view if hidden
......
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