koeditorgeneraljournal.cpp
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
00027 #include "koeditorgeneraljournal.h"
00028
00029 #include <libkcal/journal.h>
00030
00031 #include <ktextedit.h>
00032 #include <kdateedit.h>
00033 #include <klocale.h>
00034 #include <kmessagebox.h>
00035
00036 #include <qgroupbox.h>
00037 #include <qdatetime.h>
00038 #include <qlabel.h>
00039 #include <qlayout.h>
00040
00041
00042 KOEditorGeneralJournal::KOEditorGeneralJournal( QObject *parent,
00043 const char *name )
00044 : QObject( parent, name )
00045 {
00046 }
00047
00048 KOEditorGeneralJournal::~KOEditorGeneralJournal()
00049 {
00050 }
00051
00052
00053 void KOEditorGeneralJournal::initDate( QWidget *parent, QBoxLayout *topLayout )
00054 {
00055 QBoxLayout *dateLayout = new QVBoxLayout(topLayout);
00056
00057 QGroupBox *dateGroupBox = new QGroupBox( 1, QGroupBox::Horizontal,
00058 i18n("Date"), parent );
00059 dateLayout->addWidget( dateGroupBox );
00060
00061 QFrame *dateBoxFrame = new QFrame( dateGroupBox );
00062
00063 QGridLayout *layoutDateBox = new QGridLayout( dateBoxFrame, 1, 2 );
00064 layoutDateBox->setSpacing(topLayout->spacing());
00065
00066
00067 mDateLabel = new QLabel( i18n("&Date:"), dateBoxFrame);
00068 layoutDateBox->addWidget( mDateLabel, 0, 0);
00069
00070 mDateEdit = new KDateEdit(dateBoxFrame);
00071 layoutDateBox->addWidget(mDateEdit,0,1);
00072 mDateLabel->setBuddy( mDateEdit );
00073
00074
00075 connect( mDateEdit, SIGNAL( dateChanged(QDate) ),
00076 SLOT( startDateChanged(QDate) ) );
00077 }
00078
00079 void KOEditorGeneralJournal::setDate( QDate date )
00080 {
00081
00082
00083 mDateEdit->setDate( date );
00084 }
00085
00086 void KOEditorGeneralJournal::initDescription( QWidget *parent, QBoxLayout *topLayout )
00087 {
00088 mDescriptionEdit = new KTextEdit( parent );
00089 mDescriptionEdit->append("");
00090 mDescriptionEdit->setReadOnly( false );
00091 mDescriptionEdit->setOverwriteMode( false );
00092 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
00093 mDescriptionEdit->setTabChangesFocus( true );
00094 topLayout->addWidget( mDescriptionEdit );
00095 }
00096
00097 void KOEditorGeneralJournal::setDefaults(QDate date)
00098 {
00099 setDate( date );
00100 }
00101
00102 void KOEditorGeneralJournal::readJournal( Journal *event, bool tmpl )
00103 {
00104 if ( !tmpl ) {
00105
00106 setDate( event->dtStart().date() );
00107 }
00108 setDescription( event->description() );
00109 }
00110
00111 void KOEditorGeneralJournal::writeJournal( Journal *event )
00112 {
00113
00114
00115 event->setDescription( mDescriptionEdit->text() );
00116 event->setFloats( true );
00117 QDateTime tmpDT( mDateEdit->date(), QTime(0,0,0) );
00118 event->setDtStart(tmpDT);
00119
00120
00121 }
00122
00123
00124 void KOEditorGeneralJournal::setDescription( const QString &text )
00125 {
00126 mDescriptionEdit->setText( text );
00127 }
00128
00129 void KOEditorGeneralJournal::finishSetup()
00130 {
00131 QWidget::setTabOrder( mDateEdit, mDescriptionEdit );
00132 mDescriptionEdit->setFocus();
00133 }
00134
00135 bool KOEditorGeneralJournal::validateInput()
00136 {
00137
00138
00139 if (!mDateEdit->inputIsValid()) {
00140 KMessageBox::sorry( 0,
00141 i18n("Please specify a valid date, for example '%1'.")
00142 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) );
00143 return false;
00144 }
00145
00146 return true;
00147 }
00148
00149 #include "koeditorgeneraljournal.moc"
This file is part of the documentation for korganizer Library Version 3.3.2.