summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/journalentry.cpp51
-rw-r--r--korganizer/journalentry.h7
-rw-r--r--korganizer/koeditorgeneral.cpp8
-rw-r--r--korganizer/kojournalview.cpp10
-rw-r--r--korganizer/koprefs.cpp10
-rw-r--r--korganizer/koprefs.h1
6 files changed, 62 insertions, 25 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 4751d40..56221dc 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -79,9 +79,9 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
new QLabel(" "+i18n("Title: "),vb);
mTitle = new KOLocationBox(TRUE, vb, 30);
mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) );
- mTitleLabel = new QLabel(i18n("Title"),vb);
- mTitleLabel->setMargin(0);
- mTitleLabel->setAlignment(AlignCenter);
+ mCalendarBox = new QComboBox(vb);
+ //mTitleLabel->setMargin(0);
+ //mTitleLabel->setAlignment(AlignCenter);
QPushButton * loadTemplate = new QPushButton( vb );
QPushButton * saveTemplate = new QPushButton( vb );
if ( QApplication::desktop()->width() < 321 )
@@ -99,6 +99,7 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
saveTemplate->setFixedSize( size, size );
toggleJournal->setFixedSize( size , size );
mTitle->setMaximumHeight( size+4);
+ mCalendarBox->setMaximumHeight( size+4);
mEditor = new KTextEdit(this);
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
@@ -176,9 +177,34 @@ void JournalEntry::setDate(const QDate &date)
showOnlyMode = false;
writeJournal();
mDate = date;
- int id = mCalendar->defaultCalendar();
- QString calname = KOPrefs::instance()->getCalendar( id )->mName;
- mTitleLabel->setText( " (" + calname +")");
+ 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 );
+ if ( KOPrefs::instance()->mCalendars.count() == 1 )
+ mCalendarBox->hide();
+ else
+ mCalendarBox->show();
}
void JournalEntry::toggleShowJournal()
@@ -206,8 +232,9 @@ void JournalEntry::setShowOnly()
else
mEditor->setFocus();
}
-void JournalEntry::setJournal(Journal *journal)
+void JournalEntry::setJournal(Journal *journal, bool saveJournal )
{
+ if ( saveJournal )
writeJournal();
mTitle->load( KOLocationBox::SUMMARYJOURNAL );
@@ -219,10 +246,7 @@ void JournalEntry::setJournal(Journal *journal)
mEditor->setText(mJournal->description());
mTitle->setEnabled (!journal->isReadOnly() );
mEditor->setReadOnly ( journal->isReadOnly() );
- int id = mJournal->calID();
-
- QString calname = KOPrefs::instance()->getCalendar( id )->mName;
- mTitleLabel->setText( " (" + calname +")");
+ fillCalendar( mJournal->calID() );
}
Journal *JournalEntry::journal() const
@@ -260,6 +284,7 @@ bool JournalEntry::eventFilter( QObject *o, QEvent *e )
void JournalEntry::writeJournal()
{
if ( !visibleMode ) return;
+ if ( !mTitle->isEnabled() ) return;
if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) {
if ( mJournal ) {
Journal* j = mJournal;
@@ -286,6 +311,10 @@ void JournalEntry::writeJournal()
mJournal->setSummary(mTitle->currentText());
mTitle->save(KOLocationBox::SUMMARYJOURNAL);
}
+ int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() );
+ if ( mJournal->calID() != id ) {
+ mJournal->setCalID( id );
+ }
}
void JournalEntry::flushEntry()
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
index fb19fb1..ed04b7c 100644
--- a/korganizer/journalentry.h
+++ b/korganizer/journalentry.h
@@ -31,6 +31,7 @@
class QLabel;
class KTextEdit;
+class QComboBox;
class KLineEdit;
class KOLocationBox;
@@ -42,7 +43,7 @@ class JournalEntry : public QFrame {
JournalEntry(Calendar *,QWidget *parent);
virtual ~JournalEntry();
- void setJournal(Journal *);
+ void setJournal(Journal *, bool saveJournal = true );
Journal *journal() const;
void setDate(const QDate &);
@@ -53,7 +54,7 @@ class JournalEntry : public QFrame {
void setShowOnly();
QSize sizeHint() const;
void setVisibleMode( bool b ) { visibleMode = b;}
-
+ void fillCalendar( int id = 0 );
protected slots:
void slotSaveTemplate();
void slotLoadTemplate();
@@ -76,7 +77,7 @@ class JournalEntry : public QFrame {
Journal *mJournal;
QDate mDate;
void keyPressEvent ( QKeyEvent * ) ;
- QLabel *mTitleLabel;
+ QComboBox *mCalendarBox;
KOLocationBox * mTitle;
KTextEdit *mEditor;
int heiHint;
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index fd50b05..aa55d82 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -483,13 +483,7 @@ void KOEditorGeneral::fillCalCombo( int setToID )
}
int KOEditorGeneral::getCalendarID()
{
- KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
- while ( kkf ) {
- if ( mCalendarBox->currentText() == kkf->mName)
- return kkf->mCalNumber;
- kkf = KOPrefs::instance()->mCalendars.next();
- }
- return 1;
+ return KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() );
}
void KOEditorGeneral::readIncidence(Incidence *event)
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index 9b0e748..0523954 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -155,7 +155,7 @@ void KOJournalView::newJournal()
void KOJournalView::showOnly ( Journal* j )
{
- qDebug("showOnly %x ", j);
+ //qDebug("showOnly %x ", j);
flushView();
if ( j == 0 ) {
showDates( mDate, QDate() );
@@ -169,7 +169,7 @@ void KOJournalView::showOnly ( Journal* j )
}
void KOJournalView::showList(QPtrList<Journal> jl)
{
- qDebug("KOJournalView::showList %d",jl.count() );
+ //qDebug("KOJournalView::showList %d",jl.count() );
JournalEntry* mEntry = jEntries.first();
JournalEntry* firstEntry = mEntry;
int count = jl.count();
@@ -177,14 +177,16 @@ void KOJournalView::showList(QPtrList<Journal> jl)
while ( iii < count ) {
if ( !mEntry ) {
mEntry = getNewEntry();
+ mEntry->setVisibleMode( true );
mEntry->setDate(mDate);
- mEntry->setJournal(jl.at(iii));
+ mEntry->setJournal(jl.at(iii), false);
mEntry->setVisibleMode( true );
mEntry->show();
mEntry = 0;
} else {
+ mEntry->setVisibleMode( true );
mEntry->setDate(mDate);
- mEntry->setJournal(jl.at(iii));
+ mEntry->setJournal(jl.at(iii), false);
mEntry->setVisibleMode( true );
mEntry->show();
mEntry = jEntries.next();
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index bb3d720..a886735 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -501,6 +501,16 @@ void KOPrefs::deleteCalendar( int num )
kkf = mCalendars.next();
}
}
+int KOPrefs::getCalendarID( const QString & name )
+{
+ KopiCalendarFile * kkf = mCalendars.first();
+ while ( kkf ) {
+ if ( name == kkf->mName)
+ return kkf->mCalNumber;
+ kkf = mCalendars.next();
+ }
+ return 1;
+}
QString KOPrefs::calName( int calNum) const
{
return (mDefCalColors[calNum-1])->mName;
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 53d193b..7ec5327 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -100,6 +100,7 @@ class KOPrefs : public KPimPrefs
void deleteCalendar( int );
QColor defaultColor( int ) const;
QString calName( int ) const;
+ int getCalendarID( const QString & name );
protected:
void setTimeZoneIdDefault();