-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 @@ | |||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 56 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : |
57 | QFrame(parent) | 57 | QFrame(parent) |
58 | { | 58 | { |
59 | showOnlyMode = false; | ||
59 | mCalendar = calendar; | 60 | mCalendar = calendar; |
60 | mJournal = 0; | 61 | mJournal = 0; |
61 | mDirty = false; | 62 | mDirty = false; |
62 | 63 | ||
63 | QHBox * vb = new QHBox ( this ); | 64 | QHBox * vb = new QHBox ( this ); |
65 | QPushButton * newJournal = new QPushButton( vb ); | ||
66 | QIconSet icon; | ||
67 | if ( QApplication::desktop()->width() < 321 ) | ||
68 | icon = SmallIcon("ko16old"); | ||
69 | else | ||
70 | icon = SmallIcon("ko24old"); | ||
71 | newJournal->setIconSet (icon ) ; | ||
72 | int size = newJournal->sizeHint().height(); | ||
73 | newJournal->setFixedSize( size, size ); | ||
74 | |||
75 | |||
76 | QPushButton * toggleJournal = new QPushButton( vb ); | ||
77 | icon = SmallIcon("1updownarrow"); | ||
78 | toggleJournal->setIconSet (icon ) ; | ||
79 | //int size = toggleJournal->sizeHint().height(); | ||
80 | toggleJournal->setFixedSize( size * 2 /3 , size ); | ||
81 | |||
82 | |||
83 | |||
84 | mTitleLabel = new QLabel(i18n("Title"),vb); | ||
85 | mTitleLabel->setMargin(2); | ||
86 | mTitleLabel->setAlignment(AlignCenter); | ||
64 | QPushButton * loadTemplate = new QPushButton( vb ); | 87 | QPushButton * loadTemplate = new QPushButton( vb ); |
65 | QPushButton * saveTemplate = new QPushButton( vb ); | 88 | QPushButton * saveTemplate = new QPushButton( vb ); |
66 | QIconSet icon; | ||
67 | if ( QApplication::desktop()->width() < 321 ) | 89 | if ( QApplication::desktop()->width() < 321 ) |
68 | icon = SmallIcon("fileexport16"); | 90 | icon = SmallIcon("fileexport16"); |
69 | else | 91 | else |
70 | icon = SmallIcon("fileexport"); | 92 | icon = SmallIcon("fileexport"); |
71 | saveTemplate->setIconSet (icon ) ; | 93 | saveTemplate->setIconSet (icon ) ; |
72 | int size = saveTemplate->sizeHint().height(); | 94 | //size = saveTemplate->sizeHint().height(); |
73 | saveTemplate->setFixedSize( size, size ); | 95 | saveTemplate->setFixedSize( size, size ); |
74 | if ( QApplication::desktop()->width() < 321 ) | 96 | if ( QApplication::desktop()->width() < 321 ) |
75 | icon = SmallIcon("fileimport16"); | 97 | icon = SmallIcon("fileimport16"); |
76 | else | 98 | else |
77 | icon = SmallIcon("fileimport"); | 99 | icon = SmallIcon("fileimport"); |
78 | loadTemplate->setIconSet (icon ) ; | 100 | loadTemplate->setIconSet (icon ) ; |
79 | loadTemplate->setFixedSize( size, size ); | 101 | loadTemplate->setFixedSize( size, size ); |
80 | |||
81 | mTitleLabel = new QLabel(i18n("Title"),vb); | ||
82 | mTitleLabel->setMargin(2); | ||
83 | mTitleLabel->setAlignment(AlignCenter); | ||
84 | |||
85 | mEditor = new KTextEdit(this); | 102 | mEditor = new KTextEdit(this); |
86 | connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); | 103 | connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); |
87 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
88 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 105 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
89 | #endif | 106 | #endif |
90 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 107 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
91 | QBoxLayout *topLayout = new QVBoxLayout(this); | 108 | QBoxLayout *topLayout = new QVBoxLayout(this); |
92 | topLayout->addWidget(vb); | 109 | topLayout->addWidget(vb); |
93 | topLayout->addWidget(mEditor); | 110 | topLayout->addWidget(mEditor); |
94 | mEditor->installEventFilter(this); | 111 | mEditor->installEventFilter(this); |
95 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 112 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
96 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 113 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
114 | connect( newJournal, SIGNAL( clicked() ), this , SIGNAL( newJournal() ) ); | ||
115 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | ||
97 | } | 116 | } |
98 | 117 | ||
99 | JournalEntry::~JournalEntry() | 118 | JournalEntry::~JournalEntry() |
100 | { | 119 | { |
101 | } | 120 | } |
102 | 121 | ||
@@ -148,28 +167,46 @@ void JournalEntry::slotLoadTemplate() | |||
148 | mEditor-> insertAt ( text, line, col, true ); | 167 | mEditor-> insertAt ( text, line, col, true ); |
149 | //mEditor->setIgnoreMark( true ); | 168 | //mEditor->setIgnoreMark( true ); |
150 | setDirty(); | 169 | setDirty(); |
151 | } | 170 | } |
152 | void JournalEntry::setDate(const QDate &date) | 171 | void JournalEntry::setDate(const QDate &date) |
153 | { | 172 | { |
173 | showOnlyMode = false; | ||
174 | mDate = date; | ||
154 | writeJournal(); | 175 | writeJournal(); |
176 | int id = mCalendar->defaultCalendar(); | ||
177 | if ( id == 1 ) { | ||
178 | mTitleLabel->setText(KGlobal::locale()->formatDate(date)); | ||
179 | } else { | ||
180 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; | ||
181 | mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")"); | ||
182 | } | ||
183 | } | ||
155 | 184 | ||
156 | mTitleLabel->setText(KGlobal::locale()->formatDate(date)); | 185 | void JournalEntry::toggleShowJournal() |
157 | 186 | { | |
158 | 187 | if ( showOnlyMode ) | |
159 | mDate = date; | 188 | emit showJournalOnly( 0 ); |
189 | else | ||
190 | emit showJournalOnly( mJournal ); | ||
160 | } | 191 | } |
161 | 192 | ||
162 | void JournalEntry::setJournal(Journal *journal) | 193 | void JournalEntry::setJournal(Journal *journal) |
163 | { | 194 | { |
164 | writeJournal(); | 195 | writeJournal(); |
165 | 196 | ||
166 | mJournal = journal; | 197 | mJournal = journal; |
167 | 198 | ||
168 | mEditor->setText(mJournal->description()); | 199 | mEditor->setText(mJournal->description()); |
169 | 200 | int id = mJournal->calID(); | |
201 | if ( id > 1 ) { | ||
202 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; | ||
203 | mTitleLabel->setText( KGlobal::locale()->formatDate(mDate,true) + " (" + calname +")"); | ||
204 | } else { | ||
205 | mTitleLabel->setText(KGlobal::locale()->formatDate(mDate)); | ||
206 | } | ||
170 | mDirty = false; | 207 | mDirty = false; |
171 | } | 208 | } |
172 | 209 | ||
173 | Journal *JournalEntry::journal() const | 210 | Journal *JournalEntry::journal() const |
174 | { | 211 | { |
175 | return mJournal; | 212 | return mJournal; |