-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 |
7 files changed, 163 insertions, 32 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a62145a..697093e 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -458,16 +458,17 @@ void CalendarView::init() //leftFrameLayout->addWidget( mDateNavigator ); mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 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)) ); connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); mTodoList->setNavigator( mNavigator ); #if 0 if ( QApplication::desktop()->width() < 480 ) { leftFrameLayout->addWidget(mFilterView); diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index c19a5ca..7274849 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -51,54 +51,73 @@ #include "journalentry.h" //#include "journalentry.moc" #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #endif JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : QFrame(parent) { + showOnlyMode = false; mCalendar = calendar; mJournal = 0; mDirty = false; 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"); else icon = SmallIcon("fileexport"); saveTemplate->setIconSet (icon ) ; - int size = saveTemplate->sizeHint().height(); + //size = saveTemplate->sizeHint().height(); saveTemplate->setFixedSize( size, size ); if ( QApplication::desktop()->width() < 321 ) icon = SmallIcon("fileimport16"); else icon = SmallIcon("fileimport"); 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())); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); #endif mEditor->setWordWrap( KTextEdit::WidgetWidth ); QBoxLayout *topLayout = new QVBoxLayout(this); topLayout->addWidget(vb); topLayout->addWidget(mEditor); mEditor->installEventFilter(this); 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() ) ); } JournalEntry::~JournalEntry() { } void JournalEntry::slotSaveTemplate() { @@ -146,32 +165,50 @@ void JournalEntry::slotLoadTemplate() int line, col; mEditor->getCursorPosition (& line, & col ); mEditor-> insertAt ( text, line, col, true ); //mEditor->setIgnoreMark( true ); setDirty(); } 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 ); } void JournalEntry::setJournal(Journal *journal) { writeJournal(); mJournal = 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; } Journal *JournalEntry::journal() const { return mJournal; } diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index f1a1fef..85ad5df 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h @@ -43,30 +43,35 @@ class JournalEntry : public QFrame { void setJournal(Journal *); Journal *journal() const; void setDate(const QDate &); void clear(); void flushEntry(); + void setShowOnly() {showOnlyMode = true;} protected slots: void slotSaveTemplate(); void slotLoadTemplate(); void setDirty(); + void toggleShowJournal(); signals: void deleteJournal(Journal *); + void newJournal(); + void showJournalOnly( Journal * ); protected: bool eventFilter( QObject *o, QEvent *e ); void writeJournal(); private: + bool showOnlyMode; Calendar *mCalendar; Journal *mJournal; QDate mDate; void keyPressEvent ( QKeyEvent * ) ; QLabel *mTitleLabel; KTextEdit *mEditor; bool mDirty; diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index bc16037..fae59d6 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -37,67 +37,139 @@ #include "kojournalview.h" using namespace KOrg; KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, const char *name) : 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(); } KOJournalView::~KOJournalView() { } 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() { QPtrList<Incidence> eventList; return eventList; } 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 ); } void KOJournalView::showEvents(QPtrList<Event>) { // After new creation of list view no events are selected. // emit incidenceSelected( 0 ); } diff --git a/korganizer/kojournalview.h b/korganizer/kojournalview.h index 445f940..aabf11c 100644 --- a/korganizer/kojournalview.h +++ b/korganizer/kojournalview.h @@ -19,16 +19,17 @@ As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef _KOJOURNALVIEW_H #define _KOJOURNALVIEW_H #include <korganizer/baseview.h> +#include <qlayout.h> class JournalEntry; /** * This class provides a journal view. * @short View for Journal components. * @author Cornelius Schumacher <schumacher@kde.org> @@ -46,23 +47,30 @@ class KOJournalView : public KOrg::BaseView void clearList(); virtual QPtrList<Incidence> selectedIncidences(); DateList selectedDates() {DateList q; return q;}; signals: void deleteJournal(Journal *); public slots: + void showOnly ( Journal* ); + void newJournal(); void updateView(); void flushView(); void updateConfig(); void showDates( const QDate &start, const QDate &end ); void showEvents(QPtrList<Event> eventList); void changeEventDisplay(Event *, int); private: - JournalEntry *mEntry; + void showList(QPtrList<Journal> jl); + Calendar *mCalendar; + JournalEntry* getNewEntry(); + QPtrList<JournalEntry> jEntries; void keyPressEvent ( QKeyEvent * ) ; + QBoxLayout *mTopLayout; + QDate mDate; }; #endif diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 5d9af6d..7b307f7 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -105,16 +105,17 @@ void KOViewManager::readSettings(KConfig *config) showAgendaView(); mCurrentAgendaView = dateCount; #ifdef DESKTOP_VERSION QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); #endif } } + void KOViewManager::showDateView( int view, QDate date) { static int lastMode = 0; static int lastCount = 0; static bool lastNDMode = false; static QDate lastDate; //qDebug("date %d %s", view, date.toString().latin1()); @@ -277,16 +278,22 @@ void KOViewManager::showNextView() } void KOViewManager::resetDateSilent( QDate date , int days ) { mMainView->dateNavigator()->blockSignals( true ); mMainView->dateNavigator()->selectDates( date , days ); mMainView->dateNavigator()->blockSignals( false ); } +void KOViewManager::setDefaultCalendar(int) +{ + if ( mJournalView && mCurrentView == mJournalView ) + mJournalView->updateView(); +} + void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) { if ( flagResetViewChangeDate < 10 ) ++flagResetViewChangeDate; //mFlagShowNextxDays = false; //if(view == mCurrentView) return; if ( view == 0 ) { view = mCurrentView; diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h index 838583b..d5a8e3b 100644 --- a/korganizer/koviewmanager.h +++ b/korganizer/koviewmanager.h @@ -78,16 +78,17 @@ class KOViewManager : public QObject KOAgendaView *agendaView() const { return mAgendaView; } signals: void printWNV(); void signalFullScreen( bool ); void signalAgendaView( bool ); public slots: + void setDefaultCalendar(int); void slotprintWNV(); void showNextView(); void showMonth( const QDate & ); void showDateView( int, QDate ); void updateView(); void showWhatsNextView(); void showListView(); void showAgendaView( bool fullScreen = false ); |