Yearly copyright bump :)
[quassel.git] / src / uisupport / uistyle.h
index cd6458e..3bb1a45 100644 (file)
@@ -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  *
@@ -31,7 +31,7 @@
 #include "settings.h"
 
 class UiStyle {
-  Q_DECLARE_TR_FUNCTIONS (UiStyle);
+  Q_DECLARE_TR_FUNCTIONS(UiStyle)
 
   public:
     UiStyle(const QString &settingsKey);
@@ -122,14 +122,11 @@ 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;
@@ -141,11 +138,12 @@ class UiStyle {
 
     inline QFont defaultFont() const { return _defaultFont; }
 
+    QList<QTextLayout::FormatRange> toTextLayoutList(const FormatList &, int textLength);
+
   protected:
 
 
   private:
-    QString mircToInternal(const QString &);
 
     QFont _defaultFont;
     QTextCharFormat _defaultPlainFormat;
@@ -158,9 +156,33 @@ class UiStyle {
     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