-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | korganizer/journalentry.cpp | 61 | ||||
-rw-r--r-- | korganizer/journalentry.h | 5 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 110 | ||||
-rw-r--r-- | korganizer/kojournalview.h | 10 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 7 | ||||
-rw-r--r-- | korganizer/koviewmanager.h | 1 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 14 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 |
10 files changed, 173 insertions, 38 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a62145a..697093e 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -465,2 +465,3 @@ void CalendarView::init() connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); + connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index c19a5ca..7274849 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -58,2 +58,3 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : { + showOnlyMode = false; mCalendar = calendar; @@ -63,5 +64,26 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : QHBox * vb = new QHBox ( this ); + QPushButton * newJournal = new QPushButton( vb ); + QIconSet icon; + if ( QApplication::desktop()->width() < 321 ) + icon = SmallIcon("ko16old"); + else + icon = SmallIcon("ko24old"); + newJournal->setIconSet (icon ) ; + int size = newJournal->sizeHint().height(); + newJournal->setFixedSize( size, size ); + + + QPushButton * toggleJournal = new QPushButton( vb ); + icon = SmallIcon("1updownarrow"); + toggleJournal->setIconSet (icon ) ; + //int size = toggleJournal->sizeHint().height(); + toggleJournal->setFixedSize( size * 2 /3 , size ); + + + + mTitleLabel = new QLabel(i18n("Title"),vb); + mTitleLabel->setMargin(2); + mTitleLabel->setAlignment(AlignCenter); QPushButton * loadTemplate = new QPushButton( vb ); QPushButton * saveTemplate = new QPushButton( vb ); - QIconSet icon; if ( QApplication::desktop()->width() < 321 ) @@ -71,3 +93,3 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : saveTemplate->setIconSet (icon ) ; - int size = saveTemplate->sizeHint().height(); + //size = saveTemplate->sizeHint().height(); saveTemplate->setFixedSize( size, size ); @@ -79,7 +101,2 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : loadTemplate->setFixedSize( size, size ); - - mTitleLabel = new QLabel(i18n("Title"),vb); - mTitleLabel->setMargin(2); - mTitleLabel->setAlignment(AlignCenter); - mEditor = new KTextEdit(this); @@ -96,2 +113,4 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); + connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) ); + connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); } @@ -153,8 +172,20 @@ void JournalEntry::setDate(const QDate &date) { + showOnlyMode = false; + mDate = date; writeJournal(); + int id = mCalendar->defaultCalendar(); + if ( id == 1 ) { + mTitleLabel->setText(KGlobal::locale()->formatDate(date)); + } else { + QString calname = KOPrefs::instance()->getCalendar( id )->mName; + mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")"); + } +} - mTitleLabel->setText(KGlobal::locale()->formatDate(date)); - - - mDate = date; +void JournalEntry::toggleShowJournal() +{ + if ( showOnlyMode ) + emit showJournalOnly( 0 ); + else + emit showJournalOnly( mJournal ); } @@ -168,3 +199,9 @@ void JournalEntry::setJournal(Journal *journal) mEditor->setText(mJournal->description()); - + int id = mJournal->calID(); + if ( id > 1 ) { + QString calname = KOPrefs::instance()->getCalendar( id )->mName; + mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")"); + } else { + mTitleLabel->setText(KGlobal::locale()->formatDate(mDate)); + } mDirty = false; diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index f1a1fef..85ad5df 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h @@ -50,2 +50,3 @@ class JournalEntry : public QFrame { void flushEntry(); + void setShowOnly() {showOnlyMode = true;} @@ -55,4 +56,7 @@ class JournalEntry : public QFrame { void setDirty(); + void toggleShowJournal(); signals: void deleteJournal(Journal *); + void newJournal(); + void showJournalOnly( Journal * ); @@ -64,2 +68,3 @@ class JournalEntry : public QFrame { private: + bool showOnlyMode; Calendar *mCalendar; diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index bc16037..fae59d6 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -44,7 +44,5 @@ KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, { - mEntry = new JournalEntry(calendar,this); - mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); - QBoxLayout *topLayout = new QVBoxLayout(this); - topLayout->addWidget(mEntry); - connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; + mCalendar = calendar; + mTopLayout = new QVBoxLayout(this); + getNewEntry(); } @@ -59,2 +57,13 @@ int KOJournalView::currentDateCount() } +JournalEntry* KOJournalView::getNewEntry() +{ + JournalEntry* Entry = new JournalEntry(mCalendar,this); + jEntries.append( Entry ); + mTopLayout->addWidget(Entry); + Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); + connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; + connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; + connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; + return Entry; +} @@ -68,7 +77,16 @@ void KOJournalView::updateConfig() { - mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { + mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + mEntry = jEntries.next(); + } } void KOJournalView::updateView() -{ - mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); +{ + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { + mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + mEntry = jEntries.next(); + } + showDates( mDate, QDate() ); } @@ -76,4 +94,8 @@ void KOJournalView::updateView() void KOJournalView::flushView() -{ - mEntry->flushEntry(); +{ + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { + mEntry->flushEntry(); + mEntry = jEntries.next(); + } } @@ -82,15 +104,65 @@ void KOJournalView::clearList() { - mEntry->clear(); + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { + mEntry->clear(); + mEntry = jEntries.next(); + } } -void KOJournalView::showDates(const QDate &start, const QDate &) +void KOJournalView::newJournal() { -// kdDebug() << "KOJournalView::selectDates()" << endl; + Journal* mJournal = new Journal; + mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); + mCalendar->addJournal(mJournal); + showDates( mDate, QDate() ); +} - mEntry->setDate(start); +void KOJournalView::showOnly ( Journal* j ) +{ + if ( j == 0 ) { + showDates( mDate, QDate() ); + return; + } + QPtrList<Journal> jl; + jl.append ( j ); + showList( jl ); + JournalEntry* mEntry = jEntries.first(); + mEntry->setShowOnly(); +} +void KOJournalView::showList(QPtrList<Journal> jl) +{ + JournalEntry* mEntry = jEntries.first(); + JournalEntry* firstEntry = mEntry; + int count = jl.count(); + int iii = 0; + while ( iii < count ) { + if ( !mEntry ) { + mEntry = getNewEntry(); + mEntry->show(); + mEntry->setDate(mDate); + mEntry->setJournal(jl.at(iii)); + mEntry = 0; + } else { + mEntry->setDate(mDate); + mEntry->setJournal(jl.at(iii)); + mEntry->show(); + mEntry = jEntries.next(); + } + ++iii; + } + while ( mEntry ) { + mEntry->setDate(mDate); + mEntry->clear(); + if ( mEntry != firstEntry ) + mEntry->hide(); + else + mEntry->show(); + mEntry = jEntries.next(); + } +} - Journal *j = calendar()->journal(start); - if (j) mEntry->setJournal(j); - else mEntry->clear(); - -// emit incidenceSelected( 0 ); +void KOJournalView::showDates(const QDate &start, const QDate &) +{ + mDate = start; + QPtrList<Journal> jl = calendar()->journals4Date( start ); + showList( jl ); } diff --git a/korganizer/kojournalview.h b/korganizer/kojournalview.h index 445f940..aabf11c 100644 --- a/korganizer/kojournalview.h +++ b/korganizer/kojournalview.h @@ -26,2 +26,3 @@ #include <korganizer/baseview.h> +#include <qlayout.h> @@ -53,2 +54,4 @@ class KOJournalView : public KOrg::BaseView public slots: + void showOnly ( Journal* ); + void newJournal(); void updateView(); @@ -62,4 +65,9 @@ class KOJournalView : public KOrg::BaseView private: - JournalEntry *mEntry; + void showList(QPtrList<Journal> jl); + Calendar *mCalendar; + JournalEntry* getNewEntry(); + QPtrList<JournalEntry> jEntries; void keyPressEvent ( QKeyEvent * ) ; + QBoxLayout *mTopLayout; + QDate mDate; diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 5d9af6d..7b307f7 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -112,2 +112,3 @@ void KOViewManager::readSettings(KConfig *config) + void KOViewManager::showDateView( int view, QDate date) @@ -284,2 +285,8 @@ void KOViewManager::resetDateSilent( QDate date , int days ) } +void KOViewManager::setDefaultCalendar(int) +{ + if ( mJournalView && mCurrentView == mJournalView ) + mJournalView->updateView(); +} + void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h index 838583b..d5a8e3b 100644 --- a/korganizer/koviewmanager.h +++ b/korganizer/koviewmanager.h @@ -85,2 +85,3 @@ class KOViewManager : public QObject public slots: + void setDefaultCalendar(int); void slotprintWNV(); diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2efa355..4652fe5 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -245,2 +245,3 @@ public: virtual Journal *journal( const QDate & ) = 0; + virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; /** diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 418bfca..ca64e66 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -778,8 +778,3 @@ bool CalendarLocal::addJournal(Journal *journal) { - if ( journal->dtStart().isValid()) - kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; - else - kdDebug(5800) << "Adding Journal without a DTSTART" << endl; - - mJournalList.append(journal); + mJournalList.append(journal); @@ -803,2 +798,9 @@ void CalendarLocal::deleteJournal( Journal *journal ) +QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) +{ + QPtrList<Journal> el; + for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) + if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); + return el; +} Journal *CalendarLocal::journal( const QDate &date ) diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index d32597f..98d16a3 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -133,2 +133,3 @@ class CalendarLocal : public Calendar Journal *journal( const QDate & ); + QPtrList<Journal> journals4Date( const QDate & ); /** |