kmail

customtemplates.h

Go to the documentation of this file.
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 struct CustomTemplateItem;
00030 typedef QDict<CustomTemplateItem> CustomTemplateItemList;
00031 class KShortcut;
00032 
00033 class CustomTemplates : public CustomTemplatesBase
00034 {
00035   Q_OBJECT
00036 
00037   public:
00038 
00039     enum Type { TUniversal, TReply, TReplyAll, TForward };
00040 
00041   public:
00042 
00043     CustomTemplates( QWidget *parent = 0, const char *name = 0 );
00044     ~CustomTemplates();
00045 
00046     void load();
00047     void save();
00048 
00049     QString indexToType( int index );
00050 
00051   public slots:
00052 
00053     void slotInsertCommand( QString cmd, int adjustCursor = 0 );
00054 
00055     void slotTextChanged();
00056 
00057     void slotAddClicked();
00058     void slotRemoveClicked();
00059     void slotListSelectionChanged();
00060     void slotTypeActivated( int index );
00061     void slotShortcutCaptured( const KShortcut &shortcut );
00062 
00063   signals:
00064 
00065     void changed();
00066 
00067   protected:
00068 
00069     QListViewItem *mCurrentItem;
00070     CustomTemplateItemList mItemList;
00071 
00072     QPixmap mReplyPix;
00073     QPixmap mReplyAllPix;
00074     QPixmap mForwardPix;
00075 
00076 };
00077 
00078 struct CustomTemplateItem
00079 {
00080   CustomTemplateItem() {}
00081   CustomTemplateItem( const QString &name,
00082                       const QString &content,
00083                       KShortcut &shortcut,
00084                       CustomTemplates::Type type ) :
00085     mName( name ), mContent( content ), mShortcut(shortcut), mType( type ) {}
00086 
00087   QString mName, mContent;
00088   KShortcut mShortcut;
00089   CustomTemplates::Type mType;
00090 };
00091 
00092 #endif // CUSTOMTEMPLATES_H