korganizer
exportwebdialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "exportwebdialog.h"
00027 #include "koprefs.h"
00028 #include "kocore.h"
00029
00030 #include <libkdepim/kdateedit.h>
00031
00032 #include <kcal/calendar.h>
00033 #include <kcal/htmlexportsettings.h>
00034
00035 #include <klocale.h>
00036 #include <kdebug.h>
00037 #include <kfiledialog.h>
00038 #include <klineedit.h>
00039 #include <kurl.h>
00040 #include <kio/job.h>
00041 #include <kstandarddirs.h>
00042 #include <kconfig.h>
00043 #include "koglobals.h"
00044 #include <kurlrequester.h>
00045 #include <kio/netaccess.h>
00046 #include <ktemporaryfile.h>
00047 #include <kmessagebox.h>
00048 #include <kvbox.h>
00049
00050 #include <QLayout>
00051 #include <QRadioButton>
00052 #include <QCheckBox>
00053 #include <QLineEdit>
00054 #include <QPushButton>
00055 #include <QTextStream>
00056 #include <QLabel>
00057 #include <QVBoxLayout>
00058 #include <QGroupBox>
00059
00060 #include "exportwebdialog.moc"
00061
00062
00063
00064
00065
00066 ExportWebDialog::ExportWebDialog( HTMLExportSettings *settings, QWidget *parent )
00067 : KPageDialog( parent ),
00068 KPrefsWidManager( settings ), mSettings( settings )
00069 {
00070 setFaceType( Tabbed );
00071 setCaption( i18n( "Export Calendar as Web Page" ) );
00072 setButtons( Help|Default|User1|Cancel );
00073 setDefaultButton( User1 );
00074 setModal( false );
00075 showButtonSeparator( false );
00076 setButtonText( User1, i18n( "Export" ) );
00077
00078 setupGeneralPage();
00079 setupEventPage();
00080 setupTodoPage();
00081
00082
00083
00084
00085
00086 connect( this, SIGNAL(user1Clicked()), SLOT(slotOk()) );
00087 connect( this, SIGNAL(cancelClicked()), SLOT(reject()) );
00088 connect( this, SIGNAL(defaultClicked()), this, SLOT(slotDefault()) );
00089 connect( this, SIGNAL(applyClicked()), this, SLOT(slotApply()) );
00090 readConfig();
00091 }
00092
00093 ExportWebDialog::~ExportWebDialog()
00094 {
00095 }
00096
00097 void ExportWebDialog::setDefaults()
00098 {
00099 setWidDefaults();
00100 }
00101
00102 void ExportWebDialog::readConfig()
00103 {
00104 readWidConfig();
00105 usrReadConfig();
00106 }
00107
00108 void ExportWebDialog::writeConfig()
00109 {
00110 writeWidConfig();
00111 usrWriteConfig();
00112 readConfig();
00113 }
00114
00115 void ExportWebDialog::slotApply()
00116 {
00117 writeConfig();
00118 emit configChanged();
00119 }
00120
00121 void ExportWebDialog::slotOk()
00122 {
00123 slotApply();
00124 emit exportHTML( mSettings );
00125 accept();
00126 }
00127
00128 void ExportWebDialog::slotDefault()
00129 {
00130 kDebug();
00131
00132 if ( KMessageBox::warningContinueCancel(
00133 this,
00134 i18n( "You are about to set all preferences to default values. "
00135 "All custom modifications will be lost." ),
00136 i18n( "Setting Default Preferences" ),
00137 KGuiItem( i18n( "Reset to Defaults" ) ) ) == KMessageBox::Continue ) {
00138 setDefaults();
00139 }
00140 }
00141
00142 void ExportWebDialog::setupGeneralPage()
00143 {
00144 mGeneralPage = new QFrame( this );
00145 addPage( mGeneralPage, i18nc( "general settings for html export", "General" ) );
00146 QVBoxLayout *topLayout = new QVBoxLayout( mGeneralPage );
00147 topLayout->setSpacing(10);
00148
00149 QGroupBox *rangeGroup = new QGroupBox( i18n( "Date Range" ), mGeneralPage );
00150 topLayout->addWidget( rangeGroup );
00151
00152 QHBoxLayout *rangeLayout = new QHBoxLayout( rangeGroup );
00153
00154 KPrefsWidDate *dateStart = addWidDate( mSettings->dateStartItem() );
00155 rangeLayout->addWidget( dateStart->label() );
00156 rangeLayout->addWidget( dateStart->dateEdit() );
00157 KPrefsWidDate *dateEnd = addWidDate( mSettings->dateEndItem() );
00158 rangeLayout->addWidget( dateEnd->label() );
00159 rangeLayout->addWidget( dateEnd->dateEdit() );
00160
00161 QGroupBox *typeGroup = new QGroupBox( i18n( "View Type" ), mGeneralPage );
00162 topLayout->addWidget( typeGroup );
00163
00164 QBoxLayout *typeLayout = new QVBoxLayout( typeGroup );
00165
00166 typeLayout->addWidget( addWidBool( mSettings->monthViewItem() )->checkBox() );
00167 typeLayout->addWidget( addWidBool( mSettings->eventViewItem() )->checkBox() );
00168 typeLayout->addWidget( addWidBool( mSettings->todoViewItem() )->checkBox() );
00169 typeLayout->addWidget(
00170 addWidBool( mSettings->excludePrivateItem() )->checkBox() );
00171 typeLayout->addWidget(
00172 addWidBool( mSettings->excludeConfidentialItem() )->checkBox() );
00173
00174 QGroupBox *destGroup = new QGroupBox( i18n( "Destination" ), mGeneralPage );
00175 topLayout->addWidget( destGroup );
00176
00177 QBoxLayout *destLayout = new QHBoxLayout( destGroup );
00178
00179 KPrefsWidPath *pathWid = addWidPath( mSettings->outputFileItem(),
00180 destGroup, "text/html", KFile::File );
00181 connect( pathWid->urlRequester(), SIGNAL(textChanged(const QString&)),
00182 SLOT(slotTextChanged(const QString&)) );
00183 destLayout->addWidget( pathWid->label() );
00184 destLayout->addWidget( pathWid->urlRequester() );
00185
00186 topLayout->addStretch( 1 );
00187 }
00188
00189 void ExportWebDialog::slotTextChanged( const QString &_text )
00190 {
00191 enableButton( User1, !_text.isEmpty() );
00192 }
00193
00194 void ExportWebDialog::setupTodoPage()
00195 {
00196 mTodoPage = new QFrame( this );
00197 addPage( mTodoPage, i18n( "To-dos" ) );
00198 QVBoxLayout *topLayout = new QVBoxLayout( mTodoPage );
00199 topLayout->setSpacing( 10 );
00200
00201 KHBox *hbox = new KHBox( mTodoPage );
00202 topLayout->addWidget( hbox );
00203 addWidString( mSettings->todoListTitleItem(), hbox );
00204
00205 KVBox *vbox = new KVBox( mTodoPage );
00206 topLayout->addWidget( vbox );
00207 addWidBool( mSettings->taskDueDateItem(), vbox );
00208 addWidBool( mSettings->taskLocationItem(), vbox );
00209 addWidBool( mSettings->taskCategoriesItem(), vbox );
00210 addWidBool( mSettings->taskAttendeesItem(), vbox );
00211
00212
00213
00214 topLayout->addStretch(1);
00215 }
00216
00217 void ExportWebDialog::setupEventPage()
00218 {
00219 mEventPage = new QFrame( this );
00220 addPage( mEventPage, i18n( "Events" ) );
00221 QVBoxLayout *topLayout = new QVBoxLayout( mEventPage );
00222 topLayout->setSpacing( 10 );
00223
00224 KHBox *hbox = new KHBox( mEventPage );
00225 topLayout->addWidget( hbox );
00226 addWidString( mSettings->eventTitleItem(), hbox );
00227
00228 KVBox *vbox = new KVBox( mEventPage );
00229 topLayout->addWidget( vbox );
00230 addWidBool( mSettings->eventLocationItem(), vbox );
00231 addWidBool( mSettings->eventCategoriesItem(), vbox );
00232 addWidBool( mSettings->eventAttendeesItem(), vbox );
00233
00234
00235
00236 topLayout->addStretch(1);
00237 }
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285