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 #include "htmlexportsettings.h"
00030
00031 #include <libkdepim/kdateedit.h>
00032
00033 #include <akonadi/kcal/calendar.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 <QHBoxLayout>
00058 #include <QVBoxLayout>
00059 #include <QGroupBox>
00060
00061 #include "exportwebdialog.moc"
00062
00063
00064
00065
00066
00067 ExportWebDialog::ExportWebDialog( KOrg::HTMLExportSettings *settings, QWidget *parent )
00068 : KPageDialog( parent ),
00069 KPrefsWidManager( settings ), mSettings( settings )
00070 {
00071 setFaceType( Tabbed );
00072 setCaption( i18n( "Export Calendar as Web Page" ) );
00073 setButtons( Help|Default|User1|Cancel );
00074 setDefaultButton( User1 );
00075 setModal( false );
00076 showButtonSeparator( false );
00077 setButtonText( User1, i18n( "Export" ) );
00078
00079 setupGeneralPage();
00080 setupEventPage();
00081 setupTodoPage();
00082
00083
00084
00085
00086
00087 connect( this, SIGNAL(user1Clicked()), SLOT(slotOk()) );
00088 connect( this, SIGNAL(cancelClicked()), SLOT(reject()) );
00089 connect( this, SIGNAL(defaultClicked()), this, SLOT(slotDefault()) );
00090 connect( this, SIGNAL(applyClicked()), this, SLOT(slotApply()) );
00091 readConfig();
00092 updateState();
00093 }
00094
00095 ExportWebDialog::~ExportWebDialog()
00096 {
00097 }
00098
00099 void ExportWebDialog::setDefaults()
00100 {
00101 setWidDefaults();
00102 }
00103
00104 void ExportWebDialog::readConfig()
00105 {
00106 readWidConfig();
00107 usrReadConfig();
00108 }
00109
00110 void ExportWebDialog::writeConfig()
00111 {
00112 writeWidConfig();
00113 usrWriteConfig();
00114 readConfig();
00115 }
00116
00117 void ExportWebDialog::slotApply()
00118 {
00119 writeConfig();
00120 emit configChanged();
00121 }
00122
00123 void ExportWebDialog::slotOk()
00124 {
00125 slotApply();
00126 emit exportHTML( mSettings );
00127 accept();
00128 }
00129
00130 void ExportWebDialog::slotDefault()
00131 {
00132 kDebug();
00133
00134 if ( KMessageBox::warningContinueCancel(
00135 this,
00136 i18n( "You are about to set all preferences to default values. "
00137 "All custom modifications will be lost." ),
00138 i18n( "Setting Default Preferences" ),
00139 KGuiItem( i18n( "Reset to Defaults" ) ) ) == KMessageBox::Continue ) {
00140 setDefaults();
00141 }
00142 }
00143
00144 void ExportWebDialog::setupGeneralPage()
00145 {
00146 mGeneralPage = new QFrame( this );
00147 addPage( mGeneralPage, i18nc( "general settings for html export", "General" ) );
00148 QVBoxLayout *topLayout = new QVBoxLayout( mGeneralPage );
00149 topLayout->setSpacing(10);
00150
00151 mDateRangeGroup = new QGroupBox( i18n( "Date Range" ), mGeneralPage );
00152 topLayout->addWidget( mDateRangeGroup );
00153
00154 QHBoxLayout *rangeLayout = new QHBoxLayout( mDateRangeGroup );
00155
00156 KPrefsWidDate *dateStart = addWidDate( mSettings->dateStartItem() );
00157 rangeLayout->addWidget( dateStart->label() );
00158 rangeLayout->addWidget( dateStart->dateEdit() );
00159 KPrefsWidDate *dateEnd = addWidDate( mSettings->dateEndItem() );
00160 rangeLayout->addWidget( dateEnd->label() );
00161 rangeLayout->addWidget( dateEnd->dateEdit() );
00162
00163 QGroupBox *typeGroup = new QGroupBox( i18n( "View Type" ), mGeneralPage );
00164 topLayout->addWidget( typeGroup );
00165
00166 QBoxLayout *typeLayout = new QVBoxLayout( typeGroup );
00167
00168 mMonthViewCheckBox = addWidBool( mSettings->monthViewItem() )->checkBox();
00169 connect( mMonthViewCheckBox, SIGNAL(stateChanged(int)), SLOT(updateState()) );
00170 typeLayout->addWidget( mMonthViewCheckBox );
00171
00172 mEventListCheckBox = addWidBool( mSettings->eventViewItem() )->checkBox();
00173 connect( mEventListCheckBox, SIGNAL(stateChanged(int)), SLOT(updateState()) );
00174 typeLayout->addWidget( mEventListCheckBox );
00175
00176 typeLayout->addWidget( addWidBool( mSettings->todoViewItem() )->checkBox() );
00177 typeLayout->addWidget(
00178 addWidBool( mSettings->excludePrivateItem() )->checkBox() );
00179 typeLayout->addWidget(
00180 addWidBool( mSettings->excludeConfidentialItem() )->checkBox() );
00181
00182 QGroupBox *destGroup = new QGroupBox( i18n( "Destination" ), mGeneralPage );
00183 topLayout->addWidget( destGroup );
00184
00185 QBoxLayout *destLayout = new QHBoxLayout( destGroup );
00186
00187 KPrefsWidPath *pathWid = addWidPath( mSettings->outputFileItem(),
00188 destGroup, "text/html", KFile::File );
00189 connect( pathWid->urlRequester(), SIGNAL(textChanged(const QString&)),
00190 SLOT(slotTextChanged(const QString&)) );
00191 destLayout->addWidget( pathWid->label() );
00192 destLayout->addWidget( pathWid->urlRequester() );
00193
00194 topLayout->addStretch( 1 );
00195 }
00196
00197 void ExportWebDialog::slotTextChanged( const QString &_text )
00198 {
00199 enableButton( User1, !_text.isEmpty() );
00200 }
00201
00202 void ExportWebDialog::setupTodoPage()
00203 {
00204 mTodoPage = new QFrame( this );
00205 addPage( mTodoPage, i18n( "To-dos" ) );
00206 QVBoxLayout *topLayout = new QVBoxLayout( mTodoPage );
00207 topLayout->setSpacing( 10 );
00208
00209 KHBox *hbox = new KHBox( mTodoPage );
00210 topLayout->addWidget( hbox );
00211 addWidString( mSettings->todoListTitleItem(), hbox );
00212
00213 KVBox *vbox = new KVBox( mTodoPage );
00214 topLayout->addWidget( vbox );
00215 addWidBool( mSettings->taskDueDateItem(), vbox );
00216 addWidBool( mSettings->taskLocationItem(), vbox );
00217 addWidBool( mSettings->taskCategoriesItem(), vbox );
00218 addWidBool( mSettings->taskAttendeesItem(), vbox );
00219
00220
00221
00222 topLayout->addStretch(1);
00223 }
00224
00225 void ExportWebDialog::setupEventPage()
00226 {
00227 mEventPage = new QFrame( this );
00228 addPage( mEventPage, i18n( "Events" ) );
00229 QVBoxLayout *topLayout = new QVBoxLayout( mEventPage );
00230 topLayout->setSpacing( 10 );
00231
00232 KHBox *hbox = new KHBox( mEventPage );
00233 topLayout->addWidget( hbox );
00234 addWidString( mSettings->eventTitleItem(), hbox );
00235
00236 KVBox *vbox = new KVBox( mEventPage );
00237 topLayout->addWidget( vbox );
00238 addWidBool( mSettings->eventLocationItem(), vbox );
00239 addWidBool( mSettings->eventCategoriesItem(), vbox );
00240 addWidBool( mSettings->eventAttendeesItem(), vbox );
00241
00242
00243
00244 topLayout->addStretch(1);
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
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 void ExportWebDialog::updateState()
00296 {
00297 const bool exportEvents = mMonthViewCheckBox->isChecked() ||
00298 mEventListCheckBox->isChecked();
00299 mDateRangeGroup->setEnabled( exportEvents );
00300 mEventPage->setEnabled( exportEvents );
00301 }
00302