Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
UiStyle Class Reference

#include </tmp/quassel/src/uisupport/uistyle.h>

Inheritance diagram for UiStyle:

Classes

class  StyledMessage
struct  StyledString

Public Types

enum  FormatType {
  Base = 0x00000000, Invalid = 0xffffffff, PlainMsg = 0x00000001, NoticeMsg = 0x00000002,
  ActionMsg = 0x00000003, NickMsg = 0x00000004, ModeMsg = 0x00000005, JoinMsg = 0x00000006,
  PartMsg = 0x00000007, QuitMsg = 0x00000008, KickMsg = 0x00000009, KillMsg = 0x0000000a,
  ServerMsg = 0x0000000b, InfoMsg = 0x0000000c, ErrorMsg = 0x0000000d, DayChangeMsg = 0x0000000e,
  TopicMsg = 0x0000000f, NetsplitJoinMsg = 0x00000010, NetsplitQuitMsg = 0x00000020, InviteMsg = 0x00000030,
  Bold = 0x00000100, Italic = 0x00000200, Underline = 0x00000400, Reverse = 0x00000800,
  Timestamp = 0x00001000, Sender = 0x00002000, Contents = 0x00004000, Nick = 0x00008000,
  Hostmask = 0x00010000, ChannelName = 0x00020000, ModeFlags = 0x00040000, Url = 0x00080000
}
 This enumerates the possible formats a text element may have. */. More...
enum  MessageLabel { OwnMsg = 0x00000001, Highlight = 0x00000002, Selected = 0x00000004 }
enum  ItemFormatType {
  BufferViewItem = 0x00000001, NickViewItem = 0x00000002, NetworkItem = 0x00000010, ChannelBufferItem = 0x00000020,
  QueryBufferItem = 0x00000040, IrcUserItem = 0x00000080, UserCategoryItem = 0x00000100, InactiveBuffer = 0x00001000,
  ActiveBuffer = 0x00002000, UnreadBuffer = 0x00004000, HighlightedBuffer = 0x00008000, UserAway = 0x00010000
}
enum  ColorRole { MarkerLine, NumRoles }
typedef QList< QPair< quint16,
quint32 > > 
FormatList

Public Slots

void reload ()

Signals

void changed ()

Public Member Functions

 UiStyle (QObject *parent=0)
virtual ~UiStyle ()
QTextCharFormat format (quint32 formatType, quint32 messageLabel) const
QFontMetricsF * fontMetrics (quint32 formatType, quint32 messageLabel) const
QList< QTextLayout::FormatRange > toTextLayoutList (const FormatList &, int textLength, quint32 messageLabel) const
const QBrush & brush (ColorRole role) const
void setBrush (ColorRole role, const QBrush &brush)
QVariant bufferViewItemData (const QModelIndex &networkModelIndex, int role) const
QVariant nickViewItemData (const QModelIndex &networkModelIndex, int role) const

Static Public Member Functions

static FormatType formatType (Message::Type msgType)
static StyledString styleString (const QString &string, quint32 baseFormat=Base)
static QString mircToInternal (const QString &)
static QString timestampFormatString ()

Protected Member Functions

void loadStyleSheet ()
QString loadStyleSheet (const QString &name, bool shouldExist=false)
QTextCharFormat format (quint64 key) const
QTextCharFormat cachedFormat (quint32 formatType, quint32 messageLabel) const
void setCachedFormat (const QTextCharFormat &format, quint32 formatType, quint32 messageLabel) const
void mergeFormat (QTextCharFormat &format, quint32 formatType, quint64 messageLabel) const
void mergeSubElementFormat (QTextCharFormat &format, quint32 formatType, quint64 messageLabel) const
QVariant itemData (int role, const QTextCharFormat &format) const

Static Protected Member Functions

static FormatType formatType (const QString &code)
static QString formatCode (FormatType)
static void setTimestampFormatString (const QString &format)

Private Slots

void allowMircColorsChanged (const QVariant &)
void showItemViewIconsChanged (const QVariant &)

Private Attributes

QVector< QBrush > _uiStylePalette
QBrush _markerLineBrush
QHash< quint64, QTextCharFormat > _formats
QHash< quint64, QTextCharFormat > _formatCache
QHash< quint64, QFontMetricsF * > _metricsCache
QHash< quint32, QTextCharFormat > _listItemFormats
QIcon _channelJoinedIcon
QIcon _channelPartedIcon
QIcon _userOfflineIcon
QIcon _userOnlineIcon
QIcon _userAwayIcon
QIcon _categoryOpIcon
QIcon _categoryVoiceIcon
int _opIconLimit
int _voiceIconLimit
bool _showNickViewIcons
bool _showBufferViewIcons
bool _allowMircColors

Static Private Attributes

static QHash< QString, FormatType_formatCodes
static QString _timestampFormatString

Detailed Description

Definition at line 38 of file uistyle.h.

Member Typedef Documentation

typedef QList<QPair<quint16, quint32> > FormatList

Definition at line 46 of file uistyle.h.

Member Enumeration Documentation

enum FormatType

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 by multiple active formats. : Do not change/add values here without also adapting the relevant methods in this class (in particular mergedFormat())! Also, we do rely on certain properties of these values in styleString() and friends!

Enumerator:
Base 
Invalid 
PlainMsg 
NoticeMsg 
ActionMsg 
NickMsg 
ModeMsg 
JoinMsg 
PartMsg 
QuitMsg 
KickMsg 
KillMsg 
ServerMsg 
InfoMsg 
ErrorMsg 
DayChangeMsg 
TopicMsg 
NetsplitJoinMsg 
NetsplitQuitMsg 
InviteMsg 
Bold 
Italic 
Underline 
Reverse 
Timestamp 
Sender 
Contents 
Nick 
Hostmask 
ChannelName 
ModeFlags 
Url 

Definition at line 55 of file uistyle.h.

Enumerator:
OwnMsg 
Highlight 
Selected 

Definition at line 102 of file uistyle.h.

Enumerator:
BufferViewItem 
NickViewItem 
NetworkItem 
ChannelBufferItem 
QueryBufferItem 
IrcUserItem 
UserCategoryItem 
InactiveBuffer 
ActiveBuffer 
UnreadBuffer 
HighlightedBuffer 
UserAway 

Definition at line 108 of file uistyle.h.

enum ColorRole
Enumerator:
MarkerLine 
NumRoles 

Definition at line 125 of file uistyle.h.

Constructor & Destructor Documentation

~UiStyle ( )
virtual

Definition at line 83 of file uistyle.cpp.

References _metricsCache.

Member Function Documentation

UiStyle::StyledString styleString ( const QString &  string,
quint32  baseFormat = Base 
)
static
QString mircToInternal ( const QString &  mirc_)
static

Definition at line 580 of file uistyle.cpp.

Referenced by StyledLabel::setText(), and UiStyle::StyledMessage::style().

static QString timestampFormatString ( )
inlinestatic

Definition at line 140 of file uistyle.h.

References _timestampFormatString.

Referenced by UiStyle::StyledMessage::decoratedTimestamp().

QTextCharFormat format ( quint32  formatType,
quint32  messageLabel 
) const
QFontMetricsF * fontMetrics ( quint32  formatType,
quint32  messageLabel 
) const

Definition at line 346 of file uistyle.cpp.

References _metricsCache, and format().

Referenced by ContentsChatItem::fontMetrics(), and MarkerLineItem::styleChanged().

QList< QTextLayout::FormatRange > toTextLayoutList ( const FormatList formatList,
int  textLength,
quint32  messageLabel 
) const

Definition at line 487 of file uistyle.cpp.

References format().

Referenced by ChatItem::initLayoutHelper(), ChatItem::selectionFormats(), and StyledLabel::setText().

const QBrush& brush ( ColorRole  role) const
inline

Definition at line 147 of file uistyle.h.

References _uiStylePalette.

Referenced by MarkerLineItem::styleChanged().

void setBrush ( ColorRole  role,
const QBrush &  brush 
)
inline

Definition at line 148 of file uistyle.h.

References _uiStylePalette.

void reload ( )
slot
void changed ( )
signal
QString loadStyleSheet ( const QString &  name,
bool  shouldExist = false 
)
protected

Definition at line 143 of file uistyle.cpp.

QTextCharFormat format ( quint64  key) const
protected

Definition at line 328 of file uistyle.cpp.

References _formats.

QTextCharFormat cachedFormat ( quint32  formatType,
quint32  messageLabel 
) const
protected

Definition at line 334 of file uistyle.cpp.

References _formatCache.

Referenced by format().

void setCachedFormat ( const QTextCharFormat &  format,
quint32  formatType,
quint32  messageLabel 
) const
protected

Definition at line 340 of file uistyle.cpp.

References _formatCache, and format().

Referenced by format().

void mergeFormat ( QTextCharFormat &  format,
quint32  formatType,
quint64  messageLabel 
) const
protected

Definition at line 386 of file uistyle.cpp.

References _allowMircColors, mergeSubElementFormat(), and Url.

Referenced by format().

void mergeSubElementFormat ( QTextCharFormat &  format,
quint32  formatType,
quint64  messageLabel 
) const
protected

Definition at line 418 of file uistyle.cpp.

References format().

Referenced by mergeFormat().

UiStyle::FormatType formatType ( const QString &  code)
staticprotected

Definition at line 474 of file uistyle.cpp.

References _formatCodes, and Invalid.

QString formatCode ( FormatType  ftype)
staticprotected

Definition at line 481 of file uistyle.cpp.

References _formatCodes.

void setTimestampFormatString ( const QString &  format)
staticprotected

Definition at line 167 of file uistyle.cpp.

References _timestampFormatString, and format().

Referenced by UiStyle(), and QtUiStyle::updateTimestampFormatString().

QVariant itemData ( int  role,
const QTextCharFormat &  format 
) const
protected

Definition at line 311 of file uistyle.cpp.

Referenced by bufferViewItemData(), and nickViewItemData().

void allowMircColorsChanged ( const QVariant &  v)
privateslot

Definition at line 176 of file uistyle.cpp.

References _allowMircColors, and changed().

Referenced by UiStyle().

void showItemViewIconsChanged ( const QVariant &  v)
privateslot

Definition at line 185 of file uistyle.cpp.

References _showBufferViewIcons, and _showNickViewIcons.

Referenced by UiStyle().

Member Data Documentation

QVector<QBrush> _uiStylePalette
private

Definition at line 180 of file uistyle.h.

Referenced by brush(), loadStyleSheet(), setBrush(), and UiStyle().

QBrush _markerLineBrush
private

Definition at line 181 of file uistyle.h.

QHash<quint64, QTextCharFormat> _formats
private

Definition at line 182 of file uistyle.h.

Referenced by format(), and loadStyleSheet().

QHash<quint64, QTextCharFormat> _formatCache
mutableprivate

Definition at line 183 of file uistyle.h.

Referenced by cachedFormat(), loadStyleSheet(), and setCachedFormat().

QHash<quint64, QFontMetricsF *> _metricsCache
mutableprivate

Definition at line 184 of file uistyle.h.

Referenced by fontMetrics(), loadStyleSheet(), and ~UiStyle().

QHash<quint32, QTextCharFormat> _listItemFormats
private

Definition at line 185 of file uistyle.h.

Referenced by bufferViewItemData(), loadStyleSheet(), and nickViewItemData().

QHash< QString, UiStyle::FormatType > _formatCodes
staticprivate

Definition at line 186 of file uistyle.h.

Referenced by formatCode(), formatType(), and UiStyle().

QString _timestampFormatString
staticprivate

Definition at line 187 of file uistyle.h.

Referenced by setTimestampFormatString(), and timestampFormatString().

QIcon _channelJoinedIcon
private

Definition at line 189 of file uistyle.h.

Referenced by bufferViewItemData().

QIcon _channelPartedIcon
private

Definition at line 190 of file uistyle.h.

Referenced by bufferViewItemData().

QIcon _userOfflineIcon
private

Definition at line 191 of file uistyle.h.

Referenced by bufferViewItemData().

QIcon _userOnlineIcon
private

Definition at line 192 of file uistyle.h.

Referenced by bufferViewItemData(), and nickViewItemData().

QIcon _userAwayIcon
private

Definition at line 193 of file uistyle.h.

Referenced by bufferViewItemData(), and nickViewItemData().

QIcon _categoryOpIcon
private

Definition at line 194 of file uistyle.h.

Referenced by nickViewItemData().

QIcon _categoryVoiceIcon
private

Definition at line 195 of file uistyle.h.

Referenced by nickViewItemData().

int _opIconLimit
private

Definition at line 196 of file uistyle.h.

Referenced by nickViewItemData().

int _voiceIconLimit
private

Definition at line 197 of file uistyle.h.

Referenced by nickViewItemData().

bool _showNickViewIcons
private

Definition at line 198 of file uistyle.h.

Referenced by nickViewItemData(), showItemViewIconsChanged(), and UiStyle().

bool _showBufferViewIcons
private

Definition at line 199 of file uistyle.h.

Referenced by bufferViewItemData(), showItemViewIconsChanged(), and UiStyle().

bool _allowMircColors
private

Definition at line 200 of file uistyle.h.

Referenced by allowMircColorsChanged(), mergeFormat(), and UiStyle().


The documentation for this class was generated from the following files: