korganizer

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 Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include <qlayout.h>
00026 #include <qhgroupbox.h>
00027 #include <qvgroupbox.h>
00028 #include <qvbuttongroup.h>
00029 #include <qradiobutton.h>
00030 #include <qcheckbox.h>
00031 #include <qlineedit.h>
00032 #include <qhbox.h>
00033 #include <qvbox.h>
00034 #include <qpushbutton.h>
00035 #include <qfiledialog.h>
00036 #include <qtextstream.h>
00037 #include <qlabel.h>
00038 
00039 #include <klocale.h>
00040 #include <kdebug.h>
00041 #include <kfiledialog.h>
00042 #include <klineedit.h>
00043 #include <kurl.h>
00044 #include <kio/job.h>
00045 #include <kstandarddirs.h>
00046 #include <kconfig.h>
00047 #include "koglobals.h"
00048 #include <kurlrequester.h>
00049 #include <kio/netaccess.h>
00050 #include <knotifyclient.h>
00051 #include <ktempfile.h>
00052 #include <kmessagebox.h>
00053 
00054 #include <libkcal/calendar.h>
00055 #include <libkcal/htmlexportsettings.h>
00056 
00057 #include <libkdepim/kdateedit.h>
00058 #include <libkdepim/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, QWidget *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, SIGNAL( user1Clicked() ), SLOT( slotOk() ) );
00085   connect( this, SIGNAL( cancelClicked() ), SLOT( reject() ) );
00086 
00087   readConfig();
00088 }
00089 
00090 ExportWebDialog::~ExportWebDialog()
00091 {
00092 }
00093 
00094 void ExportWebDialog::setDefaults()
00095 {
00096   setWidDefaults();
00097 }
00098 
00099 void ExportWebDialog::readConfig()
00100 {
00101   readWidConfig();
00102   usrReadConfig();
00103 }
00104 
00105 void ExportWebDialog::writeConfig()
00106 {
00107   writeWidConfig();
00108   usrWriteConfig();
00109   readConfig();
00110 }
00111 
00112 void ExportWebDialog::slotApply()
00113 {
00114   writeConfig();
00115   emit configChanged();
00116 }
00117 
00118 void ExportWebDialog::slotOk()
00119 {
00120   slotApply();
00121   emit exportHTML( mSettings );
00122   accept();
00123 }
00124 
00125 void ExportWebDialog::slotDefault()
00126 {
00127   kdDebug(5850) << "KPrefsDialog::slotDefault()" << endl;
00128 
00129   if (KMessageBox::warningContinueCancel(this,
00130       i18n("You are about to set all preferences to default values. All "
00131       "custom modifications will be lost."),i18n("Setting Default Preferences"),
00132       i18n("Reset to Defaults"))
00133     == KMessageBox::Continue) setDefaults();
00134 }
00135 
00136 
00137 void ExportWebDialog::setupGeneralPage()
00138 {
00139   mGeneralPage = addPage( i18n("General") );
00140   QVBoxLayout *topLayout = new QVBoxLayout(mGeneralPage, 10);
00141 
00142   QGroupBox *rangeGroup = new QHGroupBox( i18n("Date Range"), mGeneralPage );
00143   topLayout->addWidget( rangeGroup );
00144   addWidDate( mSettings->dateStartItem(), rangeGroup );
00145   addWidDate( mSettings->dateEndItem(), rangeGroup );
00146 
00147   QButtonGroup *typeGroup = new QVButtonGroup( i18n("View Type"), mGeneralPage );
00148   topLayout->addWidget( typeGroup );
00149 //  addWidBool( mSettings->weekViewItem(), typeGroup );
00150   addWidBool( mSettings->monthViewItem(), typeGroup );
00151   addWidBool( mSettings->eventViewItem(), typeGroup );
00152   addWidBool( mSettings->todoViewItem(), typeGroup );
00153 //  addWidBool( mSettings->journalViewItem(), typeGroup );
00154 //  addWidBool( mSettings->freeBusyViewItem(), typeGroup );
00155   addWidBool( mSettings->excludePrivateItem(), typeGroup );
00156   addWidBool( mSettings->excludeConfidentialItem(), typeGroup );
00157 
00158   QGroupBox *destGroup = new QVGroupBox(i18n("Destination"), mGeneralPage );
00159   topLayout->addWidget(destGroup);
00160   KPrefsWidPath *pathWid = addWidPath( mSettings->outputFileItem(),
00161                                        destGroup, "text/html", KFile::File );
00162   connect( pathWid->urlRequester(), SIGNAL( textChanged( const QString & ) ),
00163            SLOT( slotTextChanged( const QString & ) ) );
00164 
00165   topLayout->addStretch( 1 );
00166 }
00167 
00168 void ExportWebDialog::slotTextChanged( const QString & _text)
00169 {
00170     enableButton( User1, !_text.isEmpty() );
00171 }
00172 
00173 void ExportWebDialog::setupTodoPage()
00174 {
00175   mTodoPage = addPage(i18n("To-dos"));
00176   QVBoxLayout *topLayout = new QVBoxLayout( mTodoPage, 10 );
00177 
00178   QHBox *hbox = new QHBox( mTodoPage );
00179   topLayout->addWidget( hbox );
00180   addWidString( mSettings->todoListTitleItem(), hbox );
00181 
00182   QVBox *vbox = new QVBox( mTodoPage );
00183   topLayout->addWidget( vbox );
00184   addWidBool( mSettings->taskDueDateItem(), vbox );
00185   addWidBool( mSettings->taskLocationItem(), vbox );
00186   addWidBool( mSettings->taskCategoriesItem(), vbox );
00187   addWidBool( mSettings->taskAttendeesItem(), vbox );
00188 //  addWidBool( mSettings->taskExcludePrivateItem(), vbox );
00189 //  addWidBool( mSettings->taskExcludeConfidentialItem(), vbox );
00190 
00191   topLayout->addStretch(1);
00192 }
00193 
00194 void ExportWebDialog::setupEventPage()
00195 {
00196   mEventPage = addPage(i18n("Events"));
00197   QVBoxLayout *topLayout = new QVBoxLayout( mEventPage, 10 );
00198 
00199   QHBox *hbox = new QHBox( mEventPage );
00200   topLayout->addWidget( hbox );
00201   addWidString( mSettings->eventTitleItem(), hbox );
00202 
00203   QVBox *vbox = new QVBox( mEventPage );
00204   topLayout->addWidget( vbox );
00205   addWidBool( mSettings->eventLocationItem(), vbox );
00206   addWidBool( mSettings->eventCategoriesItem(), vbox );
00207   addWidBool( mSettings->eventAttendeesItem(), vbox );
00208 //  addWidBool( mSettings->eventExcludePrivateItem(), vbox );
00209 //  addWidBool( mSettings->eventExcludeConfidentialItem(), vbox );
00210 
00211   topLayout->addStretch(1);
00212 }
00213 /*
00214 void ExportWebDialog::setupJournalPage()
00215 {
00216   mJournalPage = addPage(i18n("Journal"));
00217   QVBoxLayout *topLayout = new QVBoxLayout( mJournalPage, 10 );
00218 
00219   QHBox *hbox = new QHBox( mJournalPage );
00220   topLayout->addWidget( hbox );
00221   addWidString( mSettings->journalTitleItem(), hbox );
00222 
00223   QVBox *vbox = new QVBox( mJournalPage );
00224   topLayout->addWidget( vbox );
00225 //  addWidBool( mSettings->eventExcludeConfidentialItem(), vbox );
00226 
00227   topLayout->addStretch(1);
00228 }
00229 
00230 void ExportWebDialog::setupFreeBusyPage()
00231 {
00232   mFreeBusyPage = addPage(i18n("Free/Busy"));
00233   QVBoxLayout *topLayout = new QVBoxLayout( mFreeBusyPage, 10 );
00234 
00235   QHBox *hbox = new QHBox( mFreeBusyPage );
00236   topLayout->addWidget( hbox );
00237   addWidString( mSettings->journalTitleItem(), hbox );
00238 
00239   QVBox *vbox = new QVBox( mFreeBusyPage );
00240   topLayout->addWidget( vbox );
00241 //  addWidBool( mSettings->eventExcludeConfidentialItem(), vbox );
00242 
00243   topLayout->addStretch(1);
00244 }
00245 
00246 void ExportWebDialog::setupAdvancedPage()
00247 {
00248   mAdvancedPage = addPage(i18n("Advanced"));
00249   QVBoxLayout *topLayout = new QVBoxLayout( mAdvancedPage, 10 );
00250 
00251   QVBox *vbox = new QVBox( mAdvancedPage );
00252   topLayout->addWidget( vbox );
00253 //  addWidBool( mSettings->eventExcludeConfidentialItem(), vbox );
00254 
00255   topLayout->addStretch(1);
00256 }
00257 */
KDE Home | KDE Accessibility Home | Description of Access Keys