X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fuistyle.h;h=3bb1a45bf0feec7a45b6155caee44aca25f962a2;hp=b3e1a965ca23c4344face0ecdd360411fceaa7ef;hb=f824db0e31b54969e0b7fa0b5405b1e9173d482c;hpb=dfbd0465f2a58eee4771472afd261869e5e5c400 diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index b3e1a965..3bb1a45b 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,7 @@ #define _UISTYLE_H_ #include +#include #include #include #include @@ -30,13 +31,13 @@ #include "settings.h" class UiStyle { - Q_DECLARE_TR_FUNCTIONS (UiStyle); + Q_DECLARE_TR_FUNCTIONS(UiStyle) public: UiStyle(const QString &settingsKey); virtual ~UiStyle(); - typedef QList > FormatList; + typedef QList > FormatList; //! This enumerates the possible formats a text element may have. */ /** These formats are ordered on increasing importance, in cases where a given property is specified @@ -121,40 +122,67 @@ class UiStyle { FormatList formatList; // starting pos, ftypes }; - struct StyledMessage { - StyledString timestamp; - StyledString sender; - StyledString contents; - }; + class StyledMessage; StyledString styleString(const QString &); StyledMessage styleMessage(const Message &); + QString mircToInternal(const QString &) const; void setFormat(FormatType, QTextCharFormat, Settings::Mode mode/* = Settings::Custom*/); QTextCharFormat format(FormatType, Settings::Mode mode = Settings::Custom) const; QTextCharFormat mergedFormat(quint32 formatType); + QFontMetricsF *fontMetrics(quint32 formatType); FormatType formatType(const QString &code) const; QString formatCode(FormatType) const; + inline QFont defaultFont() const { return _defaultFont; } + + QList toTextLayoutList(const FormatList &, int textLength); + protected: private: - QString mircToInternal(const QString &); + QFont _defaultFont; QTextCharFormat _defaultPlainFormat; QHash _defaultFormats; QHash _customFormats; QHash _cachedFormats; + QHash _cachedFontMetrics; QHash _formatCodes; QString _settingsKey; }; +class UiStyle::StyledMessage { + + public: + explicit StyledMessage(const Message &, UiStyle *style); + + QDateTime timestamp() const; + QString decoratedTimestamp() const; + QString sender() const; //!< Nickname (no decorations) for Plain and Notice, empty else + QString decoratedSender() const; + QString contents() const; + + FormatType timestampFormat() const; + FormatType senderFormat() const; + FormatList contentsFormatList() const; + + inline Message::Type type() const { return _msgType; } + + private: + StyledString _contents; + QDateTime _timestamp; + QString _sender; + Message::Type _msgType; +}; + QDataStream &operator<<(QDataStream &out, const UiStyle::FormatList &formatList); QDataStream &operator>>(QDataStream &in, UiStyle::FormatList &formatList); -Q_DECLARE_METATYPE(UiStyle::FormatList); +Q_DECLARE_METATYPE(UiStyle::FormatList) #endif