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 <QTextCharFormat>
29 #include <QTextLayout>
38 UiStyle(const QString &settingsKey);
41 //! This enumerates the possible formats a text element may have. */
42 /** These formats are ordered on increasing importance, in cases where a given property is specified
43 * by multiple active formats.
44 * \NOTE: Do not change/add values here without also adapting the relevant
45 * methods in this class (in particular mergedFormat())!
46 * Also, we _do_ rely on certain properties of these values in styleString() and friends!
51 // Message Formats (mutually exclusive!)
52 PlainMsg = 0x00000001,
53 NoticeMsg = 0x00000002,
54 ServerMsg = 0x00000003,
55 ErrorMsg = 0x00000004,
60 RenameMsg = 0x00000009,
62 ActionMsg = 0x0000000b,
66 Underline = 0x00000040,
68 // Individual parts of a message
69 Timestamp = 0x00000100,
72 Hostmask = 0x00000800,
73 ChannelName = 0x00001000,
74 ModeFlags = 0x00002000,
75 // URL is special, we want that to take precedence over the rest...
100 BgCol05 = 0x50800000,
101 BgCol06 = 0x60800000,
102 BgCol07 = 0x70800000,
103 BgCol08 = 0x80800000,
104 BgCol09 = 0x90800000,
105 BgCol10 = 0xa0800000,
106 BgCol11 = 0xb0800000,
107 BgCol12 = 0xc0800000,
108 BgCol13 = 0xd0800000,
109 BgCol14 = 0xe0800000,
119 struct StyledString {
121 QList<QPair<int, quint32> > formats; // starting pos, ftypes
124 StyledString styleString(const QString &);
126 void setFormat(FormatType, QTextCharFormat, Settings::Mode mode/* = Settings::Custom*/);
127 QTextCharFormat format(FormatType, Settings::Mode mode = Settings::Custom) const;
128 QTextCharFormat mergedFormat(quint32 formatType);
130 FormatType formatType(const QString &code) const;
131 QString formatCode(FormatType) const;
137 QTextCharFormat _defaultPlainFormat;
138 QHash<FormatType, QTextCharFormat> _defaultFormats;
139 QHash<FormatType, QTextCharFormat> _customFormats;
140 QHash<quint32, QTextCharFormat> _cachedFormats;
141 QHash<QString, FormatType> _formatCodes;
143 QString _settingsKey;