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 <tdeshortcut.h>
00030 
00031 struct CustomTemplateItem;
00032 typedef TQDict<CustomTemplateItem> CustomTemplateItemList;
00033 class TDEShortcut;
00034 
00035 class CustomTemplates : public CustomTemplatesBase
00036 {
00037   Q_OBJECT
00038   
00039 
00040   public:
00041 
00042     enum Type { TUniversal, TReply, TReplyAll, TForward };
00043 
00044   public:
00045 
00046     CustomTemplates( TQWidget *parent = 0, const char *name = 0 );
00047     ~CustomTemplates();
00048 
00049     void load();
00050     void save();
00051 
00052     TQString indexToType( int index );
00053 
00054   public slots:
00055 
00056     void slotInsertCommand( TQString cmd, int adjustCursor = 0 );
00057 
00058     void slotTextChanged();
00059 
00060     void slotAddClicked();
00061     void slotRemoveClicked();
00062     void slotListSelectionChanged();
00063     void slotTypeActivated( int index );
00064     void slotShortcutCaptured( const TDEShortcut &shortcut );
00065   void slotNameChanged( const TQString& );
00066   signals:
00067 
00068     void changed();
00069 
00070   protected:
00071 
00072     void setRecipientsEditsEnabled( bool enabled );
00073 
00074     TQListViewItem *mCurrentItem;
00075     CustomTemplateItemList mItemList;
00076 
00078     TQStringList mItemsToDelete;
00079 
00080     TQPixmap mReplyPix;
00081     TQPixmap mReplyAllPix;
00082     TQPixmap mForwardPix;
00083 
00086     bool mBlockChangeSignal;
00087 
00088 };
00089 
00090 struct CustomTemplateItem
00091 {
00092   CustomTemplateItem() {}
00093   CustomTemplateItem( const TQString &name,
00094                       const TQString &content,
00095                       TDEShortcut &shortcut,
00096                       CustomTemplates::Type type,
00097                       TQString to, TQString cc ) :
00098     mName( name ), mContent( content ), mShortcut(shortcut), mType( type ),
00099     mTo( to ), mCC( cc ) {}
00100 
00101   TQString mName, mContent;
00102   TDEShortcut mShortcut;
00103   CustomTemplates::Type mType;
00104   TQString mTo, mCC;
00105 };
00106 
00107 #endif // CUSTOMTEMPLATES_H