exportwebdialog.cpp
00001 /* 00002 This file is part of KOrganizer. 00003 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00004 Copyright (c) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of TQt, and distribute the resulting executable, 00022 without including the source code for TQt in the source distribution. 00023 */ 00024 00025 #include <tqlayout.h> 00026 #include <tqhgroupbox.h> 00027 #include <tqvgroupbox.h> 00028 #include <tqvbuttongroup.h> 00029 #include <tqradiobutton.h> 00030 #include <tqcheckbox.h> 00031 #include <tqlineedit.h> 00032 #include <tqhbox.h> 00033 #include <tqvbox.h> 00034 #include <tqpushbutton.h> 00035 #include <tqfiledialog.h> 00036 #include <tqtextstream.h> 00037 #include <tqlabel.h> 00038 00039 #include <tdelocale.h> 00040 #include <kdebug.h> 00041 #include <tdefiledialog.h> 00042 #include <klineedit.h> 00043 #include <kurl.h> 00044 #include <tdeio/job.h> 00045 #include <kstandarddirs.h> 00046 #include <tdeconfig.h> 00047 #include "koglobals.h" 00048 #include <kurlrequester.h> 00049 #include <tdeio/netaccess.h> 00050 #include <knotifyclient.h> 00051 #include <tdetempfile.h> 00052 #include <tdemessagebox.h> 00053 00054 #include <libkcal/calendar.h> 00055 #include <libkcal/htmlexportsettings.h> 00056 00057 #include <libtdepim/kdateedit.h> 00058 #include <libtdepim/kdateedit.h> 00059 00060 #include "koprefs.h" 00061 #include "kocore.h" 00062 00063 #include "exportwebdialog.h" 00064 #include "exportwebdialog.moc" 00065 00066 00067 // FIXME: The basic structure of this dialog has been copied from KPrefsDialog, 00068 // because we want custom buttons, a Tabbed dialog, and a different 00069 // headline... Maybe we should try to achieve the same without code 00070 // duplication. 00071 ExportWebDialog::ExportWebDialog( HTMLExportSettings *settings, TQWidget *parent, 00072 const char *name) 00073 : KDialogBase( Tabbed,i18n("Export Calendar as Web Page"),Help|Default|User1|Cancel, User1, parent, name, false, false, i18n("Export") ), 00074 KPrefsWidManager( settings ), mSettings( settings ) 00075 { 00076 setupGeneralPage(); 00077 setupEventPage(); 00078 setupTodoPage(); 00079 // Disabled bacause the functionality is not yet implemented. 00080 // setupJournalPage(); 00081 // setupFreeBusyPage(); 00082 // setupAdvancedPage(); 00083 00084 connect( this, TQT_SIGNAL( user1Clicked() ), TQT_SLOT( slotOk() ) ); 00085 connect( this, TQT_SIGNAL( cancelClicked() ), TQT_SLOT( reject() ) ); 00086 00087 readConfig(); 00088 updateState(); 00089 } 00090 00091 ExportWebDialog::~ExportWebDialog() 00092 { 00093 } 00094 00095 void ExportWebDialog::setDefaults() 00096 { 00097 setWidDefaults(); 00098 } 00099 00100 void ExportWebDialog::readConfig() 00101 { 00102 readWidConfig(); 00103 usrReadConfig(); 00104 } 00105 00106 void ExportWebDialog::writeConfig() 00107 { 00108 writeWidConfig(); 00109 usrWriteConfig(); 00110 readConfig(); 00111 } 00112 00113 void ExportWebDialog::slotApply() 00114 { 00115 writeConfig(); 00116 emit configChanged(); 00117 } 00118 00119 void ExportWebDialog::slotOk() 00120 { 00121 slotApply(); 00122 emit exportHTML( mSettings ); 00123 accept(); 00124 } 00125 00126 void ExportWebDialog::slotDefault() 00127 { 00128 kdDebug(5850) << "KPrefsDialog::slotDefault()" << endl; 00129 00130 if (KMessageBox::warningContinueCancel(this, 00131 i18n("You are about to set all preferences to default values. All " 00132 "custom modifications will be lost."),i18n("Setting Default Preferences"), 00133 i18n("Reset to Defaults")) 00134 == KMessageBox::Continue) setDefaults(); 00135 } 00136 00137 00138 void ExportWebDialog::setupGeneralPage() 00139 { 00140 mGeneralPage = addPage( i18n("General") ); 00141 TQVBoxLayout *topLayout = new TQVBoxLayout(mGeneralPage, 10); 00142 00143 mDateRangeBox = new TQHGroupBox( i18n("Date Range"), mGeneralPage ); 00144 topLayout->addWidget( mDateRangeBox ); 00145 addWidDate( mSettings->dateStartItem(), mDateRangeBox ); 00146 addWidDate( mSettings->dateEndItem(), mDateRangeBox ); 00147 00148 TQButtonGroup *typeGroup = new TQVButtonGroup( i18n("View Type"), mGeneralPage ); 00149 topLayout->addWidget( typeGroup ); 00150 // addWidBool( mSettings->weekViewItem(), typeGroup ); 00151 mMonthViewCheckBox = addWidBool( mSettings->monthViewItem(), typeGroup )->checkBox(); 00152 connect( mMonthViewCheckBox, TQT_SIGNAL(toggled(bool)), TQT_SLOT(updateState()) ); 00153 mEventListCheckBox = addWidBool( mSettings->eventViewItem(), typeGroup )->checkBox(); 00154 connect( mEventListCheckBox, TQT_SIGNAL(toggled(bool)), TQT_SLOT(updateState()) ); 00155 addWidBool( mSettings->todoViewItem(), typeGroup ); 00156 // addWidBool( mSettings->journalViewItem(), typeGroup ); 00157 // addWidBool( mSettings->freeBusyViewItem(), typeGroup ); 00158 addWidBool( mSettings->excludePrivateItem(), typeGroup ); 00159 addWidBool( mSettings->excludeConfidentialItem(), typeGroup ); 00160 00161 TQGroupBox *destGroup = new TQVGroupBox(i18n("Destination"), mGeneralPage ); 00162 topLayout->addWidget(destGroup); 00163 KPrefsWidPath *pathWid = addWidPath( mSettings->outputFileItem(), 00164 destGroup, "text/html", KFile::File ); 00165 connect( pathWid->urlRequester(), TQT_SIGNAL( textChanged( const TQString & ) ), 00166 TQT_SLOT( slotTextChanged( const TQString & ) ) ); 00167 00168 topLayout->addStretch( 1 ); 00169 } 00170 00171 void ExportWebDialog::slotTextChanged( const TQString & _text) 00172 { 00173 enableButton( User1, !_text.isEmpty() ); 00174 } 00175 00176 void ExportWebDialog::setupTodoPage() 00177 { 00178 mTodoPage = addPage(i18n("To-dos")); 00179 TQVBoxLayout *topLayout = new TQVBoxLayout( mTodoPage, 10 ); 00180 00181 TQHBox *hbox = new TQHBox( mTodoPage ); 00182 topLayout->addWidget( hbox ); 00183 addWidString( mSettings->todoListTitleItem(), hbox ); 00184 00185 TQVBox *vbox = new TQVBox( mTodoPage ); 00186 topLayout->addWidget( vbox ); 00187 addWidBool( mSettings->taskDueDateItem(), vbox ); 00188 addWidBool( mSettings->taskLocationItem(), vbox ); 00189 addWidBool( mSettings->taskCategoriesItem(), vbox ); 00190 addWidBool( mSettings->taskAttendeesItem(), vbox ); 00191 // addWidBool( mSettings->taskExcludePrivateItem(), vbox ); 00192 // addWidBool( mSettings->taskExcludeConfidentialItem(), vbox ); 00193 00194 topLayout->addStretch(1); 00195 } 00196 00197 void ExportWebDialog::setupEventPage() 00198 { 00199 mEventPage = addPage(i18n("Events")); 00200 TQVBoxLayout *topLayout = new TQVBoxLayout( mEventPage, 10 ); 00201 00202 TQHBox *hbox = new TQHBox( mEventPage ); 00203 topLayout->addWidget( hbox ); 00204 addWidString( mSettings->eventTitleItem(), hbox ); 00205 00206 TQVBox *vbox = new TQVBox( mEventPage ); 00207 topLayout->addWidget( vbox ); 00208 addWidBool( mSettings->eventLocationItem(), vbox ); 00209 addWidBool( mSettings->eventCategoriesItem(), vbox ); 00210 addWidBool( mSettings->eventAttendeesItem(), vbox ); 00211 // addWidBool( mSettings->eventExcludePrivateItem(), vbox ); 00212 // addWidBool( mSettings->eventExcludeConfidentialItem(), vbox ); 00213 00214 topLayout->addStretch(1); 00215 } 00216 /* 00217 void ExportWebDialog::setupJournalPage() 00218 { 00219 mJournalPage = addPage(i18n("Journal")); 00220 TQVBoxLayout *topLayout = new TQVBoxLayout( mJournalPage, 10 ); 00221 00222 TQHBox *hbox = new TQHBox( mJournalPage ); 00223 topLayout->addWidget( hbox ); 00224 addWidString( mSettings->journalTitleItem(), hbox ); 00225 00226 TQVBox *vbox = new TQVBox( mJournalPage ); 00227 topLayout->addWidget( vbox ); 00228 // addWidBool( mSettings->eventExcludeConfidentialItem(), vbox ); 00229 00230 topLayout->addStretch(1); 00231 } 00232 00233 void ExportWebDialog::setupFreeBusyPage() 00234 { 00235 mFreeBusyPage = addPage(i18n("Free/Busy")); 00236 TQVBoxLayout *topLayout = new TQVBoxLayout( mFreeBusyPage, 10 ); 00237 00238 TQHBox *hbox = new TQHBox( mFreeBusyPage ); 00239 topLayout->addWidget( hbox ); 00240 addWidString( mSettings->journalTitleItem(), hbox ); 00241 00242 TQVBox *vbox = new TQVBox( mFreeBusyPage ); 00243 topLayout->addWidget( vbox ); 00244 // addWidBool( mSettings->eventExcludeConfidentialItem(), vbox ); 00245 00246 topLayout->addStretch(1); 00247 } 00248 00249 void ExportWebDialog::setupAdvancedPage() 00250 { 00251 mAdvancedPage = addPage(i18n("Advanced")); 00252 TQVBoxLayout *topLayout = new TQVBoxLayout( mAdvancedPage, 10 ); 00253 00254 TQVBox *vbox = new TQVBox( mAdvancedPage ); 00255 topLayout->addWidget( vbox ); 00256 // addWidBool( mSettings->eventExcludeConfidentialItem(), vbox ); 00257 00258 topLayout->addStretch(1); 00259 } 00260 */ 00261 00262 void ExportWebDialog::updateState() 00263 { 00264 const bool exportEvents = mMonthViewCheckBox->isChecked() || mEventListCheckBox->isChecked(); 00265 mDateRangeBox->setEnabled( exportEvents ); 00266 mEventPage->setEnabled( exportEvents ); 00267 } 00268