author | zautrix <zautrix> | 2005-06-29 10:36:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-29 10:36:31 (UTC) |
commit | b7044dfc9516d546683973985555c481d59fc677 (patch) (side-by-side diff) | |
tree | b521090cfc8eb6c8c6a6f6f8167c83058ea1361b /korganizer | |
parent | f226b4cd2ce06a6948811fe04d80fe3ffa44f695 (diff) | |
download | kdepimpi-b7044dfc9516d546683973985555c481d59fc677.zip kdepimpi-b7044dfc9516d546683973985555c481d59fc677.tar.gz kdepimpi-b7044dfc9516d546683973985555c481d59fc677.tar.bz2 |
journal fixxx
-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | korganizer/journalentry.cpp | 59 | ||||
-rw-r--r-- | korganizer/journalentry.h | 5 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 98 | ||||
-rw-r--r-- | korganizer/kojournalview.h | 10 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 7 | ||||
-rw-r--r-- | korganizer/koviewmanager.h | 1 |
7 files changed, 156 insertions, 25 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 +")"); + } +} - - 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,3 +77,7 @@ void KOJournalView::updateConfig() { + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + mEntry = jEntries.next(); + } } @@ -72,3 +85,8 @@ void KOJournalView::updateView() { + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + mEntry = jEntries.next(); + } + showDates( mDate, QDate() ); } @@ -77,3 +95,7 @@ void KOJournalView::flushView() { + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { mEntry->flushEntry(); + mEntry = jEntries.next(); + } } @@ -82,15 +104,65 @@ void KOJournalView::clearList() { + 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; - - mEntry->setDate(start); + Journal* mJournal = new Journal; + mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); + mCalendar->addJournal(mJournal); + showDates( mDate, QDate() ); +} - Journal *j = calendar()->journal(start); - if (j) mEntry->setJournal(j); - else mEntry->clear(); +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(); + } +} -// 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(); |