-rw-r--r-- | korganizer/journalentry.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 7f6f221..5269af7 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -104,64 +104,68 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | |||
104 | iconp = SmallIcon("fileimport16"); | 104 | iconp = SmallIcon("fileimport16"); |
105 | else | 105 | else |
106 | iconp = SmallIcon("fileimport"); | 106 | iconp = SmallIcon("fileimport"); |
107 | loadTemplate->setPixmap (iconp ) ; | 107 | loadTemplate->setPixmap (iconp ) ; |
108 | loadTemplate->setFixedSize( size, size ); | 108 | loadTemplate->setFixedSize( size, size ); |
109 | saveTemplate->setFixedSize( size, size ); | 109 | saveTemplate->setFixedSize( size, size ); |
110 | int widwid = size; | 110 | int widwid = size; |
111 | if ( QApplication::desktop()->width() < 320 ) | 111 | if ( QApplication::desktop()->width() < 320 ) |
112 | widwid = size/2+1; | 112 | widwid = size/2+1; |
113 | toggleJournal->setFixedSize( widwid , size ); | 113 | toggleJournal->setFixedSize( widwid , size ); |
114 | mTitle->setFixedHeight( size+4); | 114 | mTitle->setFixedHeight( size+4); |
115 | mCalendarBox->setFixedHeight( size+4); | 115 | mCalendarBox->setFixedHeight( size+4); |
116 | mEditor = new KTextEdit(this); | 116 | mEditor = new KTextEdit(this); |
117 | #ifndef DESKTOP_VERSION | 117 | #ifndef DESKTOP_VERSION |
118 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 118 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
119 | #endif | 119 | #endif |
120 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); | 120 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); |
121 | mDeskWid = QApplication::desktop()->width(); | 121 | mDeskWid = QApplication::desktop()->width(); |
122 | int maxwid = mDeskWid - mMaxWidDiff; | 122 | int maxwid = mDeskWid - mMaxWidDiff; |
123 | if ( QApplication::desktop()->width() < 640 ) { | 123 | if ( QApplication::desktop()->width() < 640 ) { |
124 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 124 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
125 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 125 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
126 | } else { | 126 | } else { |
127 | mTitle->setMaximumWidth( (maxwid/4)*3); | 127 | mTitle->setMaximumWidth( (maxwid/4)*3); |
128 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 128 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
129 | } | 129 | } |
130 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 130 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
131 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 131 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
132 | QBoxLayout *topLayout = new QVBoxLayout(this); | 132 | QBoxLayout *topLayout = new QVBoxLayout(this); |
133 | topLayout->addWidget(vb); | 133 | topLayout->addWidget(vb); |
134 | topLayout->addWidget(mEditor); | 134 | topLayout->addWidget(mEditor); |
135 | mEditor->installEventFilter(this); | 135 | mEditor->installEventFilter(this); |
136 | installEventFilter(this); | ||
137 | mTitle->installEventFilter(this); | ||
138 | setFocusPolicy (QWidget::NoFocus); | ||
139 | |||
136 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 140 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
137 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 141 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
138 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | 142 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); |
139 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 143 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
140 | mTitle->lineEdit ()->setText(""); | 144 | mTitle->lineEdit ()->setText(""); |
141 | } | 145 | } |
142 | 146 | ||
143 | JournalEntry::~JournalEntry() | 147 | JournalEntry::~JournalEntry() |
144 | { | 148 | { |
145 | //qDebug("JournalEntry::~JournalEntry() "); | 149 | //qDebug("JournalEntry::~JournalEntry() "); |
146 | } | 150 | } |
147 | void JournalEntry::resizeEvent(QResizeEvent* e ) | 151 | void JournalEntry::resizeEvent(QResizeEvent* e ) |
148 | { | 152 | { |
149 | #ifndef DESKTOP_VERSION | 153 | #ifndef DESKTOP_VERSION |
150 | 154 | ||
151 | if ( mDeskWid != QApplication::desktop()->width() ) { | 155 | if ( mDeskWid != QApplication::desktop()->width() ) { |
152 | mDeskWid == QApplication::desktop()->width(); | 156 | mDeskWid == QApplication::desktop()->width(); |
153 | int maxwid = mDeskWid - mMaxWidDiff; | 157 | int maxwid = mDeskWid - mMaxWidDiff; |
154 | if ( QApplication::desktop()->width() < 640 ) { | 158 | if ( QApplication::desktop()->width() < 640 ) { |
155 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 159 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
156 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 160 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
157 | } | 161 | } |
158 | else { | 162 | else { |
159 | mTitle->setMaximumWidth( (maxwid/4)*3); | 163 | mTitle->setMaximumWidth( (maxwid/4)*3); |
160 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 164 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
161 | } | 165 | } |
162 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 166 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
163 | } | 167 | } |
164 | //setMaximumWidth( QApplication::desktop()->width() ); | 168 | //setMaximumWidth( QApplication::desktop()->width() ); |
165 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); | 169 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); |
166 | #endif | 170 | #endif |
167 | QFrame::resizeEvent( e ); | 171 | QFrame::resizeEvent( e ); |
@@ -282,70 +286,78 @@ void JournalEntry::setJournal(Journal *journal, bool saveJournal ) | |||
282 | writeJournal(); | 286 | writeJournal(); |
283 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 287 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
284 | 288 | ||
285 | mJournal = journal; | 289 | mJournal = journal; |
286 | if ( journal->isReadOnly() ) | 290 | if ( journal->isReadOnly() ) |
287 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); | 291 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); |
288 | else | 292 | else |
289 | mTitle->lineEdit ()->setText(mJournal->summary()); | 293 | mTitle->lineEdit ()->setText(mJournal->summary()); |
290 | mEditor->setText(mJournal->description()); | 294 | mEditor->setText(mJournal->description()); |
291 | mTitle->setEnabled (!journal->isReadOnly() ); | 295 | mTitle->setEnabled (!journal->isReadOnly() ); |
292 | mEditor->setReadOnly ( journal->isReadOnly() ); | 296 | mEditor->setReadOnly ( journal->isReadOnly() ); |
293 | mCalendarBox->setEnabled (!journal->isReadOnly() ); | 297 | mCalendarBox->setEnabled (!journal->isReadOnly() ); |
294 | fillCalendar( mJournal->calID() ); | 298 | fillCalendar( mJournal->calID() ); |
295 | } | 299 | } |
296 | 300 | ||
297 | Journal *JournalEntry::journal() const | 301 | Journal *JournalEntry::journal() const |
298 | { | 302 | { |
299 | return mJournal; | 303 | return mJournal; |
300 | } | 304 | } |
301 | 305 | ||
302 | 306 | ||
303 | void JournalEntry::clear() | 307 | void JournalEntry::clear() |
304 | { | 308 | { |
305 | mJournal = 0; | 309 | mJournal = 0; |
306 | mEditor->setText(""); | 310 | mEditor->setText(""); |
307 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 311 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
308 | mTitle->lineEdit ()->setText(""); | 312 | mTitle->lineEdit ()->setText(""); |
309 | } | 313 | } |
310 | 314 | ||
311 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | 315 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) |
312 | { | 316 | { |
313 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; | 317 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; |
314 | 318 | if ( isVisible() ) { | |
319 | mEditor->setFocusPolicy (QWidget::StrongFocus); | ||
320 | mTitle->setFocusPolicy (QWidget::StrongFocus); | ||
321 | } else { | ||
322 | mEditor->setFocusPolicy (QWidget::NoFocus); | ||
323 | mTitle->setFocusPolicy (QWidget::NoFocus); | ||
324 | } | ||
315 | if ( e->type() == QEvent::FocusOut ) { | 325 | if ( e->type() == QEvent::FocusOut ) { |
316 | writeJournal(); | 326 | writeJournal(); |
317 | } | 327 | } |
318 | if ( e->type() == QEvent::KeyPress ) { | 328 | if ( e->type() == QEvent::KeyPress ) { |
319 | QKeyEvent * k = (QKeyEvent *) e; | 329 | QKeyEvent * k = (QKeyEvent *) e; |
330 | if ( !isVisible() ) | ||
331 | return true; | ||
320 | if ( k->state() == Qt::ControlButton ) { | 332 | if ( k->state() == Qt::ControlButton ) { |
321 | k->ignore(); | 333 | k->ignore(); |
322 | //return true; | 334 | //return true; |
323 | } | 335 | } |
324 | } | 336 | } |
325 | 337 | ||
326 | return QFrame::eventFilter( o, e ); // standard event processing | 338 | return QFrame::eventFilter( o, e ); // standard event processing |
327 | } | 339 | } |
328 | 340 | ||
329 | void JournalEntry::writeJournal() | 341 | void JournalEntry::writeJournal() |
330 | { | 342 | { |
331 | if ( !visibleMode ) return; | 343 | if ( !visibleMode ) return; |
332 | if ( !mTitle->isEnabled() ) return; | 344 | if ( !mTitle->isEnabled() ) return; |
333 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { | 345 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { |
334 | if ( mJournal ) { | 346 | if ( mJournal ) { |
335 | Journal* j = mJournal; | 347 | Journal* j = mJournal; |
336 | mJournal = 0; | 348 | mJournal = 0; |
337 | bool conf = KOPrefs::instance()->mConfirm; | 349 | bool conf = KOPrefs::instance()->mConfirm; |
338 | KOPrefs::instance()->mConfirm = false; | 350 | KOPrefs::instance()->mConfirm = false; |
339 | emit deleteJournal(j); | 351 | emit deleteJournal(j); |
340 | KOPrefs::instance()->mConfirm = conf; | 352 | KOPrefs::instance()->mConfirm = conf; |
341 | } | 353 | } |
342 | return; | 354 | return; |
343 | } | 355 | } |
344 | 356 | ||
345 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; | 357 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; |
346 | 358 | ||
347 | if (!mJournal) { | 359 | if (!mJournal) { |
348 | mJournal = new Journal; | 360 | mJournal = new Journal; |
349 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 361 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
350 | mCalendar->addJournal(mJournal); | 362 | mCalendar->addJournal(mJournal); |
351 | } | 363 | } |