-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 @@ -464,4 +464,5 @@ void CalendarView::init() connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); 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)) ); connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index c19a5ca..7274849 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -57,4 +57,5 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : QFrame(parent) { + showOnlyMode = false; mCalendar = calendar; mJournal = 0; @@ -62,7 +63,28 @@ 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 ) icon = SmallIcon("fileexport16"); @@ -70,5 +92,5 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : icon = SmallIcon("fileexport"); saveTemplate->setIconSet (icon ) ; - int size = saveTemplate->sizeHint().height(); + //size = saveTemplate->sizeHint().height(); saveTemplate->setFixedSize( size, size ); if ( QApplication::desktop()->width() < 321 ) @@ -78,9 +100,4 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : loadTemplate->setIconSet (icon ) ; loadTemplate->setFixedSize( size, size ); - - mTitleLabel = new QLabel(i18n("Title"),vb); - mTitleLabel->setMargin(2); - mTitleLabel->setAlignment(AlignCenter); - mEditor = new KTextEdit(this); connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); @@ -95,4 +112,6 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); + connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) ); + connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); } @@ -152,10 +171,22 @@ void JournalEntry::slotLoadTemplate() 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 ); } @@ -167,5 +198,11 @@ 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 @@ -49,4 +49,5 @@ class JournalEntry : public QFrame { void flushEntry(); + void setShowOnly() {showOnlyMode = true;} protected slots: @@ -54,6 +55,9 @@ class JournalEntry : public QFrame { void slotLoadTemplate(); void setDirty(); + void toggleShowJournal(); signals: void deleteJournal(Journal *); + void newJournal(); + void showJournalOnly( Journal * ); protected: @@ -63,4 +67,5 @@ class JournalEntry : public QFrame { private: + bool showOnlyMode; Calendar *mCalendar; Journal *mJournal; diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index bc16037..fae59d6 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -43,9 +43,7 @@ KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, : KOrg::BaseView(calendar, parent, name) { - 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(); } @@ -58,4 +56,15 @@ int KOJournalView::currentDateCount() return 0; } +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; +} QPtrList<Incidence> KOJournalView::selectedIncidences() @@ -67,31 +76,94 @@ QPtrList<Incidence> KOJournalView::selectedIncidences() 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() ); } void KOJournalView::flushView() -{ - mEntry->flushEntry(); +{ + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { + mEntry->flushEntry(); + mEntry = jEntries.next(); + } } 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 @@ -25,4 +25,5 @@ #include <korganizer/baseview.h> +#include <qlayout.h> class JournalEntry; @@ -52,4 +53,6 @@ class KOJournalView : public KOrg::BaseView void deleteJournal(Journal *); public slots: + void showOnly ( Journal* ); + void newJournal(); void updateView(); void flushView(); @@ -61,6 +64,11 @@ 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 @@ -111,4 +111,5 @@ void KOViewManager::readSettings(KConfig *config) } + void KOViewManager::showDateView( int view, QDate date) { @@ -283,4 +284,10 @@ void KOViewManager::resetDateSilent( QDate date , int days ) mMainView->dateNavigator()->blockSignals( false ); } +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 @@ -84,4 +84,5 @@ class KOViewManager : public QObject void signalAgendaView( bool ); public slots: + void setDefaultCalendar(int); void slotprintWNV(); void showNextView(); diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2efa355..4652fe5 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -244,4 +244,5 @@ public: */ virtual Journal *journal( const QDate & ) = 0; + virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; /** Return Journal with given UID. diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 418bfca..ca64e66 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -777,10 +777,5 @@ QPtrList<Event> CalendarLocal::rawEvents() 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); journal->registerObserver( this ); @@ -802,4 +797,11 @@ 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 @@ -132,4 +132,5 @@ class CalendarLocal : public Calendar */ Journal *journal( const QDate & ); + QPtrList<Journal> journals4Date( const QDate & ); /** Return Journal with given UID. |