kmail
kmmessagetag.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00027 #ifndef KMMESSAGETAG_H
00028 #define KMMESSAGETAG_H
00029
00030 #include <QObject>
00031 #include <QHash>
00032 #include <QColor>
00033 #include <QString>
00034 #include <QStringList>
00035 #include <QFont>
00036 #include <QList>
00037
00038 #include <KShortcut>
00039 class KConfigGroup;
00040
00043 class KMMessageTagDescription
00044 {
00045
00046 public:
00053 explicit KMMessageTagDescription( const KConfigGroup &aGroup );
00054
00069 KMMessageTagDescription( const QString &aLabel, const QString &aName,
00070 const int aPriority = -1,
00071 const QColor &aTextColor = QColor(),
00072 const QColor &aBackgroundColor = QColor(),
00073 const QFont &aTextFont = QFont(),
00074 const bool aInToolbar = false,
00075 const QString &aIconName = "feed-subscribe",
00076 const KShortcut &aShortcut = KShortcut() );
00077
00079 const QString label() const { return mLabel; }
00080 const QString name() const { return mName; }
00081 int priority() const { return mPriority; }
00082 const QColor textColor() const { return mTextColor; }
00083 const QColor backgroundColor() const { return mBackgroundColor; }
00084 const QFont textFont() const { return mTextFont; }
00085 bool inToolbar() const { return mInToolbar; }
00086 const QString toolbarIconName() const { return mIconName; }
00087 bool isEmpty() const { return mEmpty; }
00088 const KShortcut shortcut() { return mShortcut; }
00089
00090 void setLabel( const QString & );
00091 void setName( const QString & );
00092 void setPriority( unsigned int aPriority ) { mPriority = aPriority; }
00093 void setBackgroundColor( const QColor & );
00094 void setTextColor( const QColor & );
00095 void setTextFont( const QFont & );
00096 void setInToolbar( bool aInToolbar ) { mInToolbar = aInToolbar; }
00097 void setIconName( const QString & );
00098 void setShortcut( const KShortcut & );
00099
00101 void purify( void );
00102 void readConfig( const KConfigGroup & );
00103 void writeConfig( KConfigGroup & ) const;
00104
00105 private:
00106 int mPriority;
00107 QString mName;
00108 QString mLabel;
00109
00110 QColor mBackgroundColor;
00111 QColor mTextColor;
00112
00113 QFont mTextFont;
00114
00115 bool mInToolbar;
00116 QString mIconName;
00117
00118 KShortcut mShortcut;
00119
00120 bool mEmpty;
00121 };
00122
00127 class KMMessageTagMgr : public QObject
00128 {
00129 Q_OBJECT
00130
00131 public:
00133 KMMessageTagMgr();
00134 ~KMMessageTagMgr();
00135
00138 void createInitialTags( void );
00141 void readConfig( void );
00143 void writeConfig( bool );
00148 const KMMessageTagDescription *find( const QString &aLabel ) const;
00151 const QHash<QString, KMMessageTagDescription*> *msgTagDict(void) const { return mTagDict; }
00153 const QList<KMMessageTagDescription *> *msgTagList(void) const { return mTagList; }
00155 bool isDirty( void ) const { return mDirty; }
00162 void fillTagsFromList( const QList<KMMessageTagDescription*> *aTagList );
00163
00164 signals:
00166 void msgTagListChanged(void);
00167
00168 private:
00169
00170 void clear(void);
00171
00173 void addTag( KMMessageTagDescription *aDesc, bool emitChange = true );
00174
00175 QHash<QString,KMMessageTagDescription*> *mTagDict;
00176 QList<KMMessageTagDescription *> *mTagList;
00177 bool mDirty;
00178 };
00179
00182 class KMMessageTagList : public QStringList
00183 {
00184 public:
00185 KMMessageTagList();
00189 explicit KMMessageTagList( const QStringList &aList );
00192 void prioritySort();
00196 static const KMMessageTagList split( const QString &aSep, const QString &aStr );
00197 private:
00198
00199
00200 bool compareTags( const QString &lhs, const QString &rhs );
00201 };
00202
00203 #endif //KMMESSAGETAG_H