27 #include "koeditorgeneraljournal.h"
28 #include "koeditorgeneral.h"
30 #include <libkcal/journal.h>
32 #include <ktextedit.h>
33 #include <kdateedit.h>
34 #include <ktimeedit.h>
36 #include <tdelocale.h>
37 #include <tdemessagebox.h>
40 #include <tqgroupbox.h>
41 #include <tqdatetime.h>
42 #include <tqcheckbox.h>
45 #include <tqwhatsthis.h>
48 KOEditorGeneralJournal::KOEditorGeneralJournal( TQWidget *parent,
50 : KOEditorGeneral( parent, name )
55 KOEditorGeneralJournal::~KOEditorGeneralJournal()
59 void KOEditorGeneralJournal::initTitle( TQWidget *parent, TQBoxLayout *topLayout )
61 TQHBoxLayout *hbox =
new TQHBoxLayout( topLayout );
63 TQString whatsThis = i18n(
"Sets the title of this journal.");
64 TQLabel *summaryLabel =
new TQLabel( i18n(
"T&itle:"), parent );
65 TQWhatsThis::add( summaryLabel, whatsThis );
66 TQFont f = summaryLabel->font();
68 summaryLabel->setFont( f );
69 hbox->addWidget( summaryLabel );
71 mSummaryEdit =
new FocusLineEdit( parent );
72 TQWhatsThis::add( mSummaryEdit, whatsThis );
73 summaryLabel->setBuddy( mSummaryEdit );
74 hbox->addWidget( mSummaryEdit );
78 void KOEditorGeneralJournal::initDate( TQWidget *parent, TQBoxLayout *topLayout )
81 TQBoxLayout *dateLayout =
new TQHBoxLayout( topLayout );
83 mDateLabel =
new TQLabel( i18n(
"&Date:"), parent);
84 dateLayout->addWidget( mDateLabel );
86 mDateEdit =
new KDateEdit( parent );
87 dateLayout->addWidget( mDateEdit );
88 mDateLabel->setBuddy( mDateEdit );
90 dateLayout->addStretch();
92 mTimeCheckBox =
new TQCheckBox( i18n(
"&Time: "), parent );
93 dateLayout->addWidget( mTimeCheckBox );
95 mTimeEdit =
new KTimeEdit( parent );
96 dateLayout->addWidget( mTimeEdit );
97 connect( mTimeCheckBox, TQ_SIGNAL(toggled(
bool)),
98 mTimeEdit, TQ_SLOT(setEnabled(
bool)) );
100 dateLayout->addStretch();
101 setTime( TQTime( -1, -1, -1 ) );
104 void KOEditorGeneralJournal::setDate(
const TQDate &date )
108 mDateEdit->setDate( date );
111 void KOEditorGeneralJournal::setTime(
const TQTime &time )
113 kdDebug()<<
"KOEditorGeneralJournal::setTime, time="<<TQString(time.toString())<<endl;
114 bool validTime = time.isValid();
115 mTimeCheckBox->setChecked( validTime );
116 mTimeEdit->setEnabled( validTime );
118 kdDebug()<<
"KOEditorGeneralJournal::setTime, time is valid"<<endl;
119 mTimeEdit->setTime( time );
123 void KOEditorGeneralJournal::initDescription( TQWidget *parent, TQBoxLayout *topLayout )
125 mDescriptionEdit =
new KTextEdit( parent );
126 mDescriptionEdit->append(
"");
127 mDescriptionEdit->setReadOnly(
false );
128 mDescriptionEdit->setOverwriteMode(
false );
129 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
130 mDescriptionEdit->setTabChangesFocus(
true );
131 topLayout->addWidget( mDescriptionEdit );
134 void KOEditorGeneralJournal::setDefaults(
const TQDate &date )
139 void KOEditorGeneralJournal::readJournal(
Journal *journal,
const TQDate &,
bool tmpl )
141 setSummary( journal->
summary() );
143 setDate( journal->
dtStart().date() );
145 kdDebug()<<
"KOEditorGeneralJournal::readJournal, does not float, time="<<TQString(journal->
dtStart().time().toString())<<endl;
146 setTime( journal->
dtStart().time() );
148 kdDebug()<<
"KOEditorGeneralJournal::readJournal, does float"<<endl;
149 setTime( TQTime( -1, -1, -1 ) );
155 void KOEditorGeneralJournal::writeJournal(
Journal *journal )
161 TQDateTime tmpDT( mDateEdit->date(), TQTime(0,0,0) );
162 bool hasTime = mTimeCheckBox->isChecked();
165 tmpDT.setTime( mTimeEdit->getTime() );
173 void KOEditorGeneralJournal::setDescription(
const TQString &text )
175 mDescriptionEdit->setText( text );
178 void KOEditorGeneralJournal::setSummary(
const TQString &text )
180 mSummaryEdit->setText( text );
183 void KOEditorGeneralJournal::finishSetup()
185 TQWidget::setTabOrder( mSummaryEdit, mDateEdit );
186 TQWidget::setTabOrder( mDateEdit, mTimeCheckBox );
187 TQWidget::setTabOrder( mTimeCheckBox, mTimeEdit );
188 TQWidget::setTabOrder( mTimeEdit, mDescriptionEdit );
189 mSummaryEdit->setFocus();
192 bool KOEditorGeneralJournal::validateInput()
196 if (!mDateEdit->date().isValid()) {
197 KMessageBox::sorry( 0,
198 i18n(
"Please specify a valid date, for example '%1'.")
199 .arg( TDEGlobal::locale()->formatDate( TQDate::currentDate() ) ) );
206 #include "koeditorgeneraljournal.moc"
virtual TQDateTime dtStart() const
void setSummary(const TQString &summary)
TQString description() const
void setDescription(const TQString &description)
virtual void setDtStart(const TQDateTime &dtStart)