author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /korganizer/koincidenceeditor.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'korganizer/koincidenceeditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koincidenceeditor.cpp | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/korganizer/koincidenceeditor.cpp b/korganizer/koincidenceeditor.cpp new file mode 100644 index 0000000..e10a188 --- a/dev/null +++ b/korganizer/koincidenceeditor.cpp | |||
@@ -0,0 +1,187 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2001 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 <qtooltip.h> | ||
25 | #include <qframe.h> | ||
26 | #include <qpixmap.h> | ||
27 | #include <qlayout.h> | ||
28 | #include <qwidgetstack.h> | ||
29 | #include <qdatetime.h> | ||
30 | #include <qdir.h> | ||
31 | |||
32 | #include <kdebug.h> | ||
33 | #include <klocale.h> | ||
34 | #include <kstandarddirs.h> | ||
35 | #include <kmessagebox.h> | ||
36 | #include <kfiledialog.h> | ||
37 | |||
38 | #include <libkdepim/categoryselectdialog.h> | ||
39 | #include <libkdepim/kinputdialog.h> | ||
40 | |||
41 | #include <libkcal/calendarlocal.h> | ||
42 | #include <libkcal/icalformat.h> | ||
43 | |||
44 | #include "koprefs.h" | ||
45 | #include "koglobals.h" | ||
46 | |||
47 | #include "koincidenceeditor.h" | ||
48 | #include "koincidenceeditor.moc" | ||
49 | |||
50 | KOIncidenceEditor::KOIncidenceEditor( const QString &caption, | ||
51 | Calendar *calendar, QWidget *parent ) : | ||
52 | KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok, | ||
53 | parent, caption, true, false ), | ||
54 | mSaveTemplateDialog( 0 ) | ||
55 | { | ||
56 | mCalendar = calendar; | ||
57 | |||
58 | setButtonText( Default, i18n("Template...") ); | ||
59 | |||
60 | QString saveTemplateText; | ||
61 | // if ( KOPrefs::instance()->mCompactDialogs ) { | ||
62 | // showButton( User1, false ); | ||
63 | // showButton( Apply, false ); | ||
64 | // } else { | ||
65 | showButton( Apply, false ); | ||
66 | saveTemplateText = i18n("Ok+Agenda"); | ||
67 | // } | ||
68 | setButtonText( User1, saveTemplateText ); | ||
69 | |||
70 | //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this ); | ||
71 | // KOGlobals::fitDialogToScreen( mCategoryDialog ); | ||
72 | |||
73 | //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories())); | ||
74 | |||
75 | //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) ); | ||
76 | // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) ); | ||
77 | connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) ); | ||
78 | } | ||
79 | |||
80 | KOIncidenceEditor::~KOIncidenceEditor() | ||
81 | { | ||
82 | //delete mCategoryDialog; | ||
83 | } | ||
84 | |||
85 | void KOIncidenceEditor::setupAttendeesTab() | ||
86 | { | ||
87 | QFrame *topFrame = addPage(i18n("Attendees")); | ||
88 | |||
89 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | ||
90 | |||
91 | mDetails = new KOEditorDetails(spacingHint(),topFrame); | ||
92 | topLayout->addWidget(mDetails); | ||
93 | } | ||
94 | |||
95 | |||
96 | void KOIncidenceEditor::slotApply() | ||
97 | { | ||
98 | processInput( false ); | ||
99 | } | ||
100 | void KOIncidenceEditor::accept() | ||
101 | { | ||
102 | slotOk(); | ||
103 | } | ||
104 | void KOIncidenceEditor::slotOk() | ||
105 | { | ||
106 | if ( processInput( false ) ) QDialog::accept(); | ||
107 | } | ||
108 | |||
109 | void KOIncidenceEditor::updateCategoryConfig() | ||
110 | { | ||
111 | qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! "); | ||
112 | //mCategoryDialog->updateCategoryConfig(); | ||
113 | } | ||
114 | |||
115 | void KOIncidenceEditor::slotCancel() | ||
116 | { | ||
117 | reject(); | ||
118 | } | ||
119 | |||
120 | void KOIncidenceEditor::slotLoadTemplate() | ||
121 | { | ||
122 | kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl; | ||
123 | } | ||
124 | void KOIncidenceEditor::slotShowIncidence() | ||
125 | { | ||
126 | |||
127 | if ( processInput(true ) ) { | ||
128 | accept(); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | void KOIncidenceEditor::slotSaveTemplate() | ||
133 | { | ||
134 | kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl; | ||
135 | } | ||
136 | |||
137 | void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type ) | ||
138 | { | ||
139 | if ( !mSaveTemplateDialog ) { | ||
140 | mSaveTemplateDialog = new SaveTemplateDialog( type, this ); | ||
141 | connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ), | ||
142 | SLOT( saveTemplate( const QString & ) ) ); | ||
143 | } | ||
144 | mSaveTemplateDialog->show(); | ||
145 | mSaveTemplateDialog->raise(); | ||
146 | } | ||
147 | |||
148 | void KOIncidenceEditor::saveAsTemplate( Incidence *incidence, | ||
149 | const QString &templateName ) | ||
150 | { | ||
151 | CalendarLocal cal; | ||
152 | cal.addIncidence( incidence ); | ||
153 | ICalFormat format; | ||
154 | format.save( &cal, templateName ); | ||
155 | } | ||
156 | |||
157 | QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type, | ||
158 | const QStringList &templates ) | ||
159 | { | ||
160 | // bool ok = false; | ||
161 | // QString templateName = KInputDialog::getItem( i18n("Load Template"), | ||
162 | // i18n("Select a template to load:"), templates, 0, &ok ); | ||
163 | // if ( !ok || templateName.isEmpty() ) return QString::null; | ||
164 | |||
165 | // QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" + | ||
166 | // templateName ); | ||
167 | // fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this ); | ||
168 | |||
169 | // QString fileName;// =locateLocal( "templates", incidence->type() ); | ||
170 | // fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this ); | ||
171 | // if ( fileNamelength() == 0) | ||
172 | // return QString::null; | ||
173 | // if ( fileName.isEmpty() ) { | ||
174 | // KMessageBox::error( this, i18n("Unable to find template '%1'.") | ||
175 | // .arg( fileName ) ); | ||
176 | // return QString::null; | ||
177 | // } else { | ||
178 | // ICalFormat format; | ||
179 | // if ( !format.load( cal, fileName ) ) { | ||
180 | // KMessageBox::error( this, i18n("Error loading template file '%1'.") | ||
181 | // .arg( fileName ) ); | ||
182 | // return QString::null; | ||
183 | // } | ||
184 | // } | ||
185 | |||
186 | return ""; | ||
187 | } | ||