/***************************************************************************
- * Copyright (C) 2005-2016 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include <utility>
#include <vector>
+#include <QColor>
#include <QDataStream>
#include <QFontMetricsF>
#include <QHash>
Bold = 0x00000100,
Italic = 0x00000200,
Underline = 0x00000400,
- Reverse = 0x00000800,
+ Strikethrough = 0x00000800,
// Individual parts of a message
Timestamp = 0x00001000,
Invalid = 0xffffffff
};
+ enum class FormatProperty {
+ AllowForegroundOverride = QTextFormat::UserProperty,
+ AllowBackgroundOverride
+ };
+
enum class ColorRole {
MarkerLine,
// Sender colors (16 + self)
struct Format {
FormatType type;
+ QColor foreground;
+ QColor background;
};
using FormatList = std::vector<std::pair<quint16, Format>>;
*/
static QString timestampFormatString();
- QTextCharFormat format(FormatType formatType, MessageLabel messageLabel) const;
+ QTextCharFormat format(const Format &format, MessageLabel messageLabel) const;
QFontMetricsF *fontMetrics(FormatType formatType, MessageLabel messageLabel) const;
QList<QTextLayout::FormatRange> toTextLayoutList(const FormatList &, int textLength, MessageLabel messageLabel) const;
void loadStyleSheet();
QString loadStyleSheet(const QString &name, bool shouldExist = false);
- QTextCharFormat format(quint64 key) const;
- QTextCharFormat cachedFormat(FormatType formatType, MessageLabel messageLabel) const;
- void setCachedFormat(const QTextCharFormat &format, FormatType formatType, MessageLabel messageLabel) const;
- void mergeFormat(QTextCharFormat &format, FormatType formatType, MessageLabel messageLabel) const;
- void mergeSubElementFormat(QTextCharFormat &format, FormatType formatType, MessageLabel messageLabel) const;
+ QTextCharFormat parsedFormat(quint64 key) const;
+ QTextCharFormat cachedFormat(const Format &format, MessageLabel messageLabel) const;
+ void setCachedFormat(const QTextCharFormat &charFormat, const Format &format, MessageLabel messageLabel) const;
+ void mergeFormat(QTextCharFormat &charFormat, const Format &format, MessageLabel messageLabel) const;
+ void mergeSubElementFormat(QTextCharFormat &charFormat, FormatType formatType, MessageLabel messageLabel) const;
+ void mergeColors(QTextCharFormat &charFormat, const Format &format, MessageLabel messageLabel) const;
static FormatType formatType(const QString &code);
static QString formatCode(FormatType);
QVector<QBrush> _uiStylePalette;
QBrush _markerLineBrush;
QHash<quint64, QTextCharFormat> _formats;
- mutable QHash<quint64, QTextCharFormat> _formatCache;
+ mutable QHash<QString, QTextCharFormat> _formatCache;
mutable QHash<quint64, QFontMetricsF *> _metricsCache;
QHash<UiStyle::ItemFormatType, QTextCharFormat> _listItemFormats;
static QHash<QString, FormatType> _formatCodes;