kmail

customtemplates.h

00001 /*   -*- mode: C++; c-file-style: "gnu" -*-
00002  *   kmail: KDE mail client
00003  *   This file: Copyright (C) 2006 Dmitry Morozhnikov
00004  *
00005  *   This program is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with this program; if not, write to the Free Software
00017  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  */
00020 
00021 #include <config.h>
00022 
00023 #ifndef CUSTOMTEMPLATES_H
00024 #define CUSTOMTEMPLATES_H
00025 
00026 #include "customtemplates_base.h"
00027 #include "templatesinsertcommand.h"
00028 
00029 #include <kshortcut.h>
00030 
00031 struct CustomTemplateItem;
00032 typedef QDict<CustomTemplateItem> CustomTemplateItemList;
00033 class KShortcut;
00034 
00035 class CustomTemplates : public CustomTemplatesBase
00036 {
00037   Q_OBJECT
00038 
00039   public:
00040 
00041     enum Type { TUniversal, TReply, TReplyAll, TForward };
00042 
00043   public:
00044 
00045     CustomTemplates( QWidget *parent = 0, const char *name = 0 );
00046     ~CustomTemplates();
00047 
00048     void load();
00049     void save();
00050 
00051     QString indexToType( int index );
00052 
00053   public slots:
00054 
00055     void slotInsertCommand( QString cmd, int adjustCursor = 0 );
00056 
00057     void slotTextChanged();
00058 
00059     void slotAddClicked();
00060     void slotRemoveClicked();
00061     void slotListSelectionChanged();
00062     void slotTypeActivated( int index );
00063     void slotShortcutCaptured( const KShortcut &shortcut );
00064   void slotNameChanged( const QString& );
00065   signals:
00066 
00067     void changed();
00068 
00069   protected:
00070 
00071     void setRecipientsEditsEnabled( bool enabled );
00072 
00073     QListViewItem *mCurrentItem;
00074     CustomTemplateItemList mItemList;
00075 
00077     QStringList mItemsToDelete;
00078 
00079     QPixmap mReplyPix;
00080     QPixmap mReplyAllPix;
00081     QPixmap mForwardPix;
00082 
00085     bool mBlockChangeSignal;
00086 
00087 };
00088 
00089 struct CustomTemplateItem
00090 {
00091   CustomTemplateItem() {}
00092   CustomTemplateItem( const QString &name,
00093                       const QString &content,
00094                       KShortcut &shortcut,
00095                       CustomTemplates::Type type,
00096                       QString to, QString cc ) :
00097     mName( name ), mContent( content ), mShortcut(shortcut), mType( type ),
00098     mTo( to ), mCC( cc ) {}
00099 
00100   QString mName, mContent;
00101   KShortcut mShortcut;
00102   CustomTemplates::Type mType;
00103   QString mTo, mCC;
00104 };
00105 
00106 #endif // CUSTOMTEMPLATES_H
KDE Home | KDE Accessibility Home | Description of Access Keys