kmail

customtemplates.h
1 /*
2  * kmail: KDE mail client
3  * This file: Copyright (C) 2006 Dmitry Morozhnikov
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #include <config.h>
22 
23 #ifndef CUSTOMTEMPLATES_H
24 #define CUSTOMTEMPLATES_H
25 
26 #include "customtemplates_base.h"
27 #include "templatesinsertcommand.h"
28 
29 #include <tdeshortcut.h>
30 
31 struct CustomTemplateItem;
32 typedef TQDict<CustomTemplateItem> CustomTemplateItemList;
33 class TDEShortcut;
34 
35 class CustomTemplates : public CustomTemplatesBase
36 {
37  TQ_OBJECT
38 
39 
40  public:
41 
42  enum Type { TUniversal, TReply, TReplyAll, TForward };
43 
44  public:
45 
46  CustomTemplates( TQWidget *parent = 0, const char *name = 0 );
47  ~CustomTemplates();
48 
49  void load();
50  void save();
51 
52  TQString indexToType( int index );
53 
54  public slots:
55 
56  void slotInsertCommand( TQString cmd, int adjustCursor = 0 );
57 
58  void slotTextChanged();
59 
60  void slotAddClicked();
61  void slotRemoveClicked();
62  void slotListSelectionChanged();
63  void slotTypeActivated( int index );
64  void slotShortcutCaptured( const TDEShortcut &shortcut );
65  void slotNameChanged( const TQString& );
66  signals:
67 
68  void changed();
69 
70  protected:
71 
72  void setRecipientsEditsEnabled( bool enabled );
73 
74  TQListViewItem *mCurrentItem;
75  CustomTemplateItemList mItemList;
76 
78  TQStringList mItemsToDelete;
79 
80  TQPixmap mReplyPix;
81  TQPixmap mReplyAllPix;
82  TQPixmap mForwardPix;
83 
86  bool mBlockChangeSignal;
87 
88 };
89 
90 struct CustomTemplateItem
91 {
92  CustomTemplateItem() {}
93  CustomTemplateItem( const TQString &name,
94  const TQString &content,
95  TDEShortcut &shortcut,
96  CustomTemplates::Type type,
97  TQString to, TQString cc ) :
98  mName( name ), mContent( content ), mShortcut(shortcut), mType( type ),
99  mTo( to ), mCC( cc ) {}
100 
101  TQString mName, mContent;
102  TDEShortcut mShortcut;
103  CustomTemplates::Type mType;
104  TQString mTo, mCC;
105 };
106 
107 #endif // CUSTOMTEMPLATES_H