summaryrefslogtreecommitdiffabout
path: root/korganizer/journalentry.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/journalentry.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 5fc3f2f..7f6f221 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -205,97 +205,99 @@ void JournalEntry::slotLoadTemplate()
return;
QFile fileIn( fileName );
if (!fileIn.open( IO_ReadOnly ) ) {
KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
.arg( fileName ) );
return;
}
QTextStream tsIn( &fileIn );
tsIn.setCodec( QTextCodec::codecForName("utf8") );
QString text = tsIn.read();
fileIn.close();
int line, col;
mEditor->getCursorPosition (& line, & col );
mEditor-> insertAt ( text, line, col, true );
//mEditor->setIgnoreMark( true );
}
void JournalEntry::setDate(const QDate &date)
{
showOnlyMode = false;
writeJournal();
mDate = date;
fillCalendar( mCalendar->defaultCalendar() );
}
void JournalEntry::fillCalendar( int setToID )
{
mCalendarBox->clear();
KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
int std = 0;
int count = 0;
while ( kkf ) {
if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) {
if ( setToID ) {
if ( kkf->mCalNumber == setToID )
std = count;
} else {
if ( kkf->isStandard ) {
std = count;
}
}
++count;
mCalendarBox->insertItem( kkf->mName );
}
kkf = KOPrefs::instance()->mCalendars.next();
}
mCalendarBox->setCurrentItem( std );
}
void JournalEntry::toggleShowJournal()
-{
+{
+ if ( mEditor->text().isEmpty() && mTitle->currentText ().isEmpty() )
+ return;
if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty())
flushEntry();
if ( showOnlyMode )
emit showJournalOnly( 0 );
else {
// we have to protect mJournal from deleting if mJournal has empty text
visibleMode = false; // set to true via :setShowOnly()
emit showJournalOnly( mJournal );
//QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) );
}
}
void JournalEntry::setVisibleOn()
{
visibleMode = true;
}
void JournalEntry::setShowOnly()
{
showOnlyMode = true;
if ( mTitle->currentText().isEmpty() )
mTitle->setFocus();
else
mEditor->setFocus();
}
void JournalEntry::setJournal(Journal *journal, bool saveJournal )
{
if ( saveJournal )
writeJournal();
mTitle->load( KOLocationBox::SUMMARYJOURNAL );
mJournal = journal;
if ( journal->isReadOnly() )
mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")");
else
mTitle->lineEdit ()->setText(mJournal->summary());
mEditor->setText(mJournal->description());
mTitle->setEnabled (!journal->isReadOnly() );
mEditor->setReadOnly ( journal->isReadOnly() );
mCalendarBox->setEnabled (!journal->isReadOnly() );
fillCalendar( mJournal->calID() );
}
Journal *JournalEntry::journal() const
{
return mJournal;
}
void JournalEntry::clear()