korganizer Library API Documentation

koeditorgeneraljournal.cpp

00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00005 large parts of code taken from KOEditorGeneralJournal.cpp: 00006 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00021 00022 As a special exception, permission is given to link this program 00023 with any edition of Qt, and distribute the resulting executable, 00024 without including the source code for Qt in the source distribution. 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 // date widgets are checked if they contain a valid date 00075 connect( mDateEdit, SIGNAL( dateChanged(QDate) ), 00076 SLOT( startDateChanged(QDate) ) ); 00077 } 00078 00079 void KOEditorGeneralJournal::setDate( QDate date ) 00080 { 00081 // kdDebug(5850) << "KOEditorGeneralJournal::setDate(): Date: " << date.toString() << endl; 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 // the rest is for the events only 00106 setDate( event->dtStart().date() ); 00107 } 00108 setDescription( event->description() ); 00109 } 00110 00111 void KOEditorGeneralJournal::writeJournal( Journal *event ) 00112 { 00113 // kdDebug(5850) << "KOEditorGeneralJournal::writeIncidence()" << endl; 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 // kdDebug(5850) << "KOEditorGeneralJournal::writeJournal() done" << endl; 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 // kdDebug(5850) << "KOEditorGeneralJournal::validateInput()" << endl; 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"
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:53:23 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003