-rw-r--r-- | korganizer/journalentry.cpp | 61 |
1 files changed, 49 insertions, 12 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index c19a5ca..7274849 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -53,50 +53,69 @@ #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() { } @@ -148,28 +167,46 @@ void JournalEntry::slotLoadTemplate() 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; |