Commit 9789b286 authored by Bernd Gehrmann's avatar Bernd Gehrmann
Browse files

Colored ProtocolView output

Based on a patch by Asaf Gery <asaf@telmap.com>

svn path=/trunk/kdesdk/cervisia/; revision=135159
parent a6791e6c
2002-02-04 Bernd Gehrmann <bernd@mail.berlios.de>
* Colored ProtocolView output
Based on a patch by Asaf Gery <asaf@telmap.com>
2001-09-04 Bernd Gehrmann <bernd@physik.hu-berlin.de>
* Added 'Force tag creation' option to tag dialog
......
......@@ -69,6 +69,14 @@ QStringList splitLine(QString line, char delim)
}
QString colorAsString(const QColor &color)
{
int n = color.blue() + (color.green() << 8) + (color.red() << 16);
// Ensure leading zeros
return QString::number(n + 0x1000000, 16).mid(1);
}
bool isValidTag(const QString &str)
{
if (!isalpha(str[0].latin1()))
......
......@@ -21,12 +21,15 @@
void chomp(QCString *line);
QString joinLine(const QStringList &list);
QStringList splitLine(QString, char delim=' ');
bool isValidTag(const QString &str);
QString cvsClient(QString sRepository);
QString colorAsString(const QColor &color);
QString userName();
QString tempFileName(const QString &suffix);
void cleanupTempFiles();
bool isValidTag(const QString &str);
QString cvsClient(QString sRepository);
#endif
......
......@@ -36,7 +36,7 @@ ProtocolView::ProtocolView(QWidget *parent, const char *name)
{
setReadOnly(true);
setUndoRedoEnabled(false);
// setTextFormat(Qt::RichText);
setTextFormat(Qt::RichText);
KConfig *config = CervisiaPart::config();
config->setGroup("LookAndFeel");
......@@ -135,7 +135,7 @@ void ProtocolView::processOutput()
QString line = buf.left(pos);
if (!line.isEmpty())
{
append(line);
appendLine(line);
emit receivedLine(line);
}
buf = buf.right(buf.length()-pos-1);
......@@ -145,6 +145,25 @@ void ProtocolView::processOutput()
}
void ProtocolView::appendLine(const QString &line)
{
QColor color;
// Colors are the same as in UpdateViewItem::paintCell()
if (line.startsWith("C "))
color = QColor(255, 100, 100);
else if (line.startsWith("M ")
|| line.startsWith("A ") || line.startsWith("R "))
color = QColor(190, 190, 237);
else if (line.startsWith("P "))
color = QColor(255, 240, 190);
append(color.isValid()?
QString("<FONT COLOR=\"#%1\">%2</FONT><BR>")
.arg(colorAsString(color)).arg(line) :
QString("%1<BR>").arg(line));
}
void ProtocolView::execContextMenu(const QPoint &p)
{
QPopupMenu *popup = new QPopupMenu(this);
......
......@@ -44,6 +44,7 @@ private slots:
private:
void processOutput();
void appendLine(const QString &line);
void execContextMenu(const QPoint &pos);
KShellProcess *childproc;
......
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