Diffstat (limited to 'korganizer/savetemplatedialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/savetemplatedialog.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/korganizer/savetemplatedialog.cpp b/korganizer/savetemplatedialog.cpp new file mode 100644 index 0000000..0da524f --- a/dev/null +++ b/korganizer/savetemplatedialog.cpp | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | ||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qlayout.h> | ||
25 | |||
26 | #include <keditlistbox.h> | ||
27 | #include <klocale.h> | ||
28 | |||
29 | #include "koprefs.h" | ||
30 | |||
31 | #include "savetemplatedialog.h" | ||
32 | #include "savetemplatedialog.moc" | ||
33 | |||
34 | SaveTemplateDialog::SaveTemplateDialog( IncidenceType type, QWidget *parent ) | ||
35 | : KDialogBase( Plain, i18n("Save Template"), Ok | Cancel, Ok, parent, 0, | ||
36 | true, false ), | ||
37 | mType( type ) | ||
38 | { | ||
39 | QFrame *topFrame = plainPage(); | ||
40 | QVBoxLayout *topLayout = new QVBoxLayout( topFrame, 0, spacingHint() ); | ||
41 | |||
42 | mEditListBox = new KEditListBox( i18n("Select Template Name"), topFrame, | ||
43 | 0, false, KEditListBox::Add | | ||
44 | KEditListBox::Remove ); | ||
45 | topLayout->addWidget( mEditListBox ); | ||
46 | connect( mEditListBox, SIGNAL( changed() ), SLOT( slotChanged() ) ); | ||
47 | |||
48 | QStringList templates; | ||
49 | |||
50 | if ( mType == EventType ) { | ||
51 | templates = KOPrefs::instance()->mEventTemplates; | ||
52 | } else if( mType == TodoType ) { | ||
53 | templates = KOPrefs::instance()->mTodoTemplates; | ||
54 | } | ||
55 | |||
56 | mEditListBox->insertStringList( templates ); | ||
57 | } | ||
58 | |||
59 | SaveTemplateDialog::~SaveTemplateDialog() | ||
60 | { | ||
61 | } | ||
62 | |||
63 | void SaveTemplateDialog::slotOk() | ||
64 | { | ||
65 | emit templateSelected( mEditListBox->currentText() ); | ||
66 | accept(); | ||
67 | } | ||
68 | |||
69 | void SaveTemplateDialog::slotChanged() | ||
70 | { | ||
71 | if ( mType == EventType ) { | ||
72 | KOPrefs::instance()->mEventTemplates = mEditListBox->items(); | ||
73 | } else if( mType == TodoType ) { | ||
74 | KOPrefs::instance()->mTodoTemplates = mEditListBox->items(); | ||
75 | } | ||
76 | } | ||