summaryrefslogtreecommitdiffabout
path: root/korganizer/journalentry.cpp
Unidiff
Diffstat (limited to 'korganizer/journalentry.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp53
1 files changed, 21 insertions, 32 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 0b923ad..05bfd31 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -42,6 +42,7 @@
42#include <kfiledialog.h> 42#include <kfiledialog.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44#include "koprefs.h" 44#include "koprefs.h"
45#include <klineedit.h>
45 46
46#include <libkcal/journal.h> 47#include <libkcal/journal.h>
47#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
@@ -63,27 +64,17 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
63 mDirty = false; 64 mDirty = false;
64 65
65 QHBox * vb = new QHBox ( this ); 66 QHBox * vb = new QHBox ( this );
66 QPushButton * newJournal = new QPushButton( vb );
67 QIconSet icon; 67 QIconSet icon;
68 if ( QApplication::desktop()->width() < 321 )
69 icon = SmallIcon("ko16old");
70 else
71 icon = SmallIcon("ko24old");
72 newJournal->setIconSet (icon ) ;
73 int size = newJournal->sizeHint().height();
74 newJournal->setFixedSize( size, size );
75
76 68
77 QPushButton * toggleJournal = new QPushButton( vb ); 69 QPushButton * toggleJournal = new QPushButton( vb );
78 icon = SmallIcon("1updownarrow"); 70 icon = SmallIcon("1updownarrow");
79 toggleJournal->setIconSet (icon ) ; 71 toggleJournal->setIconSet (icon ) ;
80 //int size = toggleJournal->sizeHint().height(); 72 int size = toggleJournal->sizeHint().height();
81 toggleJournal->setFixedSize( size * 2 /3 , size ); 73 toggleJournal->setFixedSize( size * 2 /3 , size );
82 74 new QLabel(i18n(" Title: "),vb);
83 75 mTitle = new KLineEdit ( vb );
84
85 mTitleLabel = new QLabel(i18n("Title"),vb); 76 mTitleLabel = new QLabel(i18n("Title"),vb);
86 mTitleLabel->setMargin(2); 77 mTitleLabel->setMargin(0);
87 mTitleLabel->setAlignment(AlignCenter); 78 mTitleLabel->setAlignment(AlignCenter);
88 QPushButton * loadTemplate = new QPushButton( vb ); 79 QPushButton * loadTemplate = new QPushButton( vb );
89 QPushButton * saveTemplate = new QPushButton( vb ); 80 QPushButton * saveTemplate = new QPushButton( vb );
@@ -111,14 +102,14 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
111 topLayout->addWidget(mEditor); 102 topLayout->addWidget(mEditor);
112 mEditor->installEventFilter(this); 103 mEditor->installEventFilter(this);
113 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 104 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
105 connect( mTitle, SIGNAL( textChanged ( const QString & ) ), this , SLOT( setDirty() ) );
114 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 106 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
115 connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) );
116 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); 107 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
117} 108}
118 109
119JournalEntry::~JournalEntry() 110JournalEntry::~JournalEntry()
120{ 111{
121 qDebug("JournalEntry::~JournalEntry() "); 112 //qDebug("JournalEntry::~JournalEntry() ");
122} 113}
123QSize JournalEntry::sizeHint() const 114QSize JournalEntry::sizeHint() const
124{ 115{
@@ -179,36 +170,35 @@ void JournalEntry::setDate(const QDate &date)
179 mDate = date; 170 mDate = date;
180 writeJournal(); 171 writeJournal();
181 int id = mCalendar->defaultCalendar(); 172 int id = mCalendar->defaultCalendar();
182 if ( id == 1 ) { 173 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
183 mTitleLabel->setText(KGlobal::locale()->formatDate(date)); 174 mTitleLabel->setText( " (" + calname +")");
184 } else {
185 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
186 mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")");
187 }
188} 175}
189 176
190void JournalEntry::toggleShowJournal() 177void JournalEntry::toggleShowJournal()
191{ 178{
179 flushEntry();
192 if ( showOnlyMode ) 180 if ( showOnlyMode )
193 emit showJournalOnly( 0 ); 181 emit showJournalOnly( 0 );
194 else 182 else
195 emit showJournalOnly( mJournal ); 183 emit showJournalOnly( mJournal );
196} 184}
197 185void JournalEntry::setShowOnly()
186{
187 showOnlyMode = true;
188 mEditor->setFocus();
189}
198void JournalEntry::setJournal(Journal *journal) 190void JournalEntry::setJournal(Journal *journal)
199{ 191{
200 writeJournal(); 192 writeJournal();
201 193
202 mJournal = journal; 194 mJournal = journal;
203 195 mTitle->setText(mJournal->summary());
204 mEditor->setText(mJournal->description()); 196 mEditor->setText(mJournal->description());
205 int id = mJournal->calID(); 197 int id = mJournal->calID();
206 if ( id > 1 ) { 198
207 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 199 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
208 mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")"); 200 mTitleLabel->setText( " (" + calname +")");
209 } else { 201
210 mTitleLabel->setText(KGlobal::locale()->formatDate(mDate));
211 }
212 mDirty = false; 202 mDirty = false;
213} 203}
214 204
@@ -274,8 +264,7 @@ void JournalEntry::writeJournal()
274 } 264 }
275 265
276 mJournal->setDescription(mEditor->text()); 266 mJournal->setDescription(mEditor->text());
277 //qDebug("tttt%s ", mEditor->text().latin1()); 267 mJournal->setSummary(mTitle->text());
278
279 mDirty = false; 268 mDirty = false;
280} 269}
281 270