1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
25 # include "old-uistyle.h"
28 #include <QDataStream>
29 #include <QTextCharFormat>
30 #include <QTextLayout>
37 Q_DECLARE_TR_FUNCTIONS (UiStyle);
40 UiStyle(const QString &settingsKey);
43 typedef QList<QPair<int, quint32> > FormatList;
45 //! This enumerates the possible formats a text element may have. */
46 /** These formats are ordered on increasing importance, in cases where a given property is specified
47 * by multiple active formats.
48 * \NOTE: Do not change/add values here without also adapting the relevant
49 * methods in this class (in particular mergedFormat())!
50 * Also, we _do_ rely on certain properties of these values in styleString() and friends!
55 // Message Formats (mutually exclusive!)
56 PlainMsg = 0x00000001,
57 NoticeMsg = 0x00000002,
58 ServerMsg = 0x00000003,
59 ErrorMsg = 0x00000004,
64 RenameMsg = 0x00000009,
66 ActionMsg = 0x0000000b,
70 Underline = 0x00000040,
72 // Individual parts of a message
73 Timestamp = 0x00000100,
76 Hostmask = 0x00000800,
77 ChannelName = 0x00001000,
78 ModeFlags = 0x00002000,
79 // URL is special, we want that to take precedence over the rest...
100 BgCol01 = 0x10800000,
101 BgCol02 = 0x20800000,
102 BgCol03 = 0x30800000,
103 BgCol04 = 0x40800000,
104 BgCol05 = 0x50800000,
105 BgCol06 = 0x60800000,
106 BgCol07 = 0x70800000,
107 BgCol08 = 0x80800000,
108 BgCol09 = 0x90800000,
109 BgCol10 = 0xa0800000,
110 BgCol11 = 0xb0800000,
111 BgCol12 = 0xc0800000,
112 BgCol13 = 0xd0800000,
113 BgCol14 = 0xe0800000,
123 struct StyledString {
125 FormatList formatList; // starting pos, ftypes
128 struct StyledMessage {
129 StyledString timestamp;
131 StyledString contents;
134 StyledString styleString(const QString &);
135 StyledMessage styleMessage(const Message &);
137 void setFormat(FormatType, QTextCharFormat, Settings::Mode mode/* = Settings::Custom*/);
138 QTextCharFormat format(FormatType, Settings::Mode mode = Settings::Custom) const;
139 QTextCharFormat mergedFormat(quint32 formatType);
141 FormatType formatType(const QString &code) const;
142 QString formatCode(FormatType) const;
148 QString mircToInternal(const QString &);
150 QTextCharFormat _defaultPlainFormat;
151 QHash<FormatType, QTextCharFormat> _defaultFormats;
152 QHash<FormatType, QTextCharFormat> _customFormats;
153 QHash<quint32, QTextCharFormat> _cachedFormats;
154 QHash<QString, FormatType> _formatCodes;
156 QString _settingsKey;
159 QDataStream &operator<<(QDataStream &out, const UiStyle::FormatList &formatList);
160 QDataStream &operator>>(QDataStream &in, UiStyle::FormatList &formatList);
162 Q_DECLARE_METATYPE(UiStyle::FormatList);