X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fuistyle.h;h=ae0ad293dcf672ac2e7b07ca8455b7a201917458;hp=57e8988b65cd537b741992cf81d19368f6d65ccd;hb=526eccc444029c5a0d80694487c3aec6707cbeda;hpb=90eb5244fb07eb2371279c12266fca06d0fed23c diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index 57e8988b..ae0ad293 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef UISTYLE_H -#define UISTYLE_H +#ifndef UISTYLE_H_ +#define UISTYLE_H_ #include #include @@ -64,11 +64,6 @@ public: RenameMsg = 0x00000009, ModeMsg = 0x0000000a, ActionMsg = 0x0000000b, - HighlightMsg = 0x0000000f, - - // Note: mergedFormat() assumes that 0x10 - 0x80 are *only* used within the message contents, - // e.g. not together with any of 0x0100-0x2000! - // If we happen to find a use case for that, we can see if/how to implement that though. // Standard Formats Bold = 0x00000010, @@ -85,7 +80,7 @@ public: ModeFlags = 0x00002000, // URL is special, we want that to take precedence over the rest... - Url = 0x00100000, + Url = 0x00080000, // mIRC Colors - we assume those to be present only in plain contents FgCol00 = 0x00400000, @@ -149,6 +144,10 @@ public: SenderColSelf = 0xff000200 }; + enum MessageLabel { + Highlight = 0x00000001 + }; + struct StyledString { QString plainText; FormatList formatList; // starting pos, ftypes @@ -160,11 +159,16 @@ public: StyledString styleString(const QString &); QString mircToInternal(const QString &) const; - void setFormat(FormatType, QTextCharFormat, Settings::Mode mode/* = Settings::Custom*/); - void setSenderAutoColor(bool state); - QTextCharFormat format(FormatType, Settings::Mode mode = Settings::Custom) const; - QTextCharFormat mergedFormat(quint32 formatType); - QFontMetricsF *fontMetrics(quint32 formatType); + void setFormat(FormatType, QTextCharFormat, Settings::Mode mode/* = Settings::Custom*/); // FIXME go away + void setSenderAutoColor(bool state); // FIXME go away + QTextCharFormat format(FormatType, Settings::Mode mode = Settings::Custom) const; // FIXME go away + + QTextCharFormat cachedFormat(quint64 key) const; + QTextCharFormat cachedFormat(quint32 formatType, quint32 messageLabel = 0) const; + void setCachedFormat(const QTextCharFormat &format, quint32 formatType, quint32 messageLabel = 0); + + QTextCharFormat mergedFormat(quint32 formatType, quint32 messageLabel = 0); + QFontMetricsF *fontMetrics(quint32 formatType, quint32 messageLabel = 0); FormatType formatType(const QString &code) const; QString formatCode(FormatType) const; @@ -176,6 +180,12 @@ public: protected: void loadStyleSheet(); + //! Determines the format set to be used for the given hostmask + //int formatSetIndex(const QString &hostmask) const; + //int formatSetIndexForSelf() const; + + void mergeSubElementFormat(QTextCharFormat &format, quint32 formatType, quint32 messageLabel = 0); + bool _senderAutoColor; private: @@ -183,8 +193,8 @@ private: QTextCharFormat _defaultPlainFormat; QHash _defaultFormats; QHash _customFormats; - QHash _cachedFormats; - QHash _cachedFontMetrics; + QHash _formatCache; + QHash _metricsCache; QHash _formatCodes; QString _settingsKey; @@ -213,56 +223,6 @@ private: mutable StyledString _contents; }; -class UiStyle::QssParser { -public: - enum Column { - Any, - Timestamp, - Sender, - Contents - }; - - struct ChatLineFormat { - QVector senderColors; - QVector mircColors; - QHash formats; - - }; - - QssParser(); - - void loadStyleSheet(const QString &sheet); - - inline QPalette palette() const { return _palette; } - ChatLineFormat basicFormat() const; - QHash specialFormats() const; - -protected: - typedef QList ColorTuple; - - void parseChatLineData(const QString &decl, const QString &contents); - void parsePaletteData(const QString &decl, const QString &contents); - - QTextCharFormat parseFormat(const QString &qss); - bool parsePalette(QPalette &, const QString &qss); - - // Parse basic data types - QBrush parseBrushValue(const QString &str); - QColor parseColorValue(const QString &str); - QFont parseFont(const QString &str); - - // Parse subelements - ColorTuple parseColorTuple(const QString &str); - QGradientStops parseGradientStops(const QString &str); - - QHash _paletteColorRoles; - -private: - QPalette _palette; - ChatLineFormat _basicFormat; - QHash _specialFormats; -}; - QDataStream &operator<<(QDataStream &out, const UiStyle::FormatList &formatList); QDataStream &operator>>(QDataStream &in, UiStyle::FormatList &formatList);