-rw-r--r-- | korganizer/journalentry.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 5269af7..2814c61 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -1,248 +1,255 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | // | 24 | // |
25 | // Journal Entry | 25 | // Journal Entry |
26 | 26 | ||
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qvbox.h> | 29 | #include <q3vbox.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qtextstream.h> | 32 | #include <q3textstream.h> |
33 | #include <qtextcodec.h> | 33 | #include <qtextcodec.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qapplication.h> | 36 | #include <qapplication.h> |
37 | #include <QDesktopWidget> | ||
38 | //Added by qt3to4: | ||
39 | #include <QResizeEvent> | ||
40 | #include <Q3Frame> | ||
41 | #include <QKeyEvent> | ||
42 | #include <QEvent> | ||
43 | #include <Q3VBoxLayout> | ||
37 | 44 | ||
38 | #include <kdebug.h> | 45 | #include <kdebug.h> |
39 | #include <kglobal.h> | 46 | #include <kglobal.h> |
40 | #include <klocale.h> | 47 | #include <klocale.h> |
41 | #include <ktextedit.h> | 48 | #include <ktextedit.h> |
42 | #include <kfiledialog.h> | 49 | #include <kfiledialog.h> |
43 | #include <kmessagebox.h> | 50 | #include <kmessagebox.h> |
44 | #include "koprefs.h" | 51 | #include "koprefs.h" |
45 | #include <klineedit.h> | 52 | #include <klineedit.h> |
46 | #include <kdialog.h> | 53 | #include <kdialog.h> |
47 | #include "kolocationbox.h" | 54 | #include "kolocationbox.h" |
48 | 55 | ||
49 | #include <libkcal/journal.h> | 56 | #include <libkcal/journal.h> |
50 | #include <libkcal/calendarresources.h> | 57 | #include <libkcal/calendarresources.h> |
51 | #include <libkcal/resourcecalendar.h> | 58 | #include <libkcal/resourcecalendar.h> |
52 | #include <kresources/resourceselectdialog.h> | 59 | #include <kresources/resourceselectdialog.h> |
53 | 60 | ||
54 | #include "journalentry.h" | 61 | #include "journalentry.h" |
55 | //#include "journalentry.moc" | 62 | //#include "journalentry.moc" |
56 | #ifndef DESKTOP_VERSION | 63 | #ifndef DESKTOP_VERSION |
57 | #include <qpe/qpeapplication.h> | 64 | #include <qpe/qpeapplication.h> |
58 | #endif | 65 | #endif |
59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 66 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : |
60 | QFrame(parent) | 67 | Q3Frame(parent) |
61 | { | 68 | { |
62 | 69 | ||
63 | int fac = 5; | 70 | int fac = 5; |
64 | heiHint = QApplication::desktop()->height(); | 71 | heiHint = QApplication::desktop()->height(); |
65 | if ( heiHint > 800 ) | 72 | if ( heiHint > 800 ) |
66 | fac += 2; | 73 | fac += 2; |
67 | heiHint = heiHint / fac; | 74 | heiHint = heiHint / fac; |
68 | 75 | ||
69 | showOnlyMode = false; | 76 | showOnlyMode = false; |
70 | mCalendar = calendar; | 77 | mCalendar = calendar; |
71 | mJournal = 0; | 78 | mJournal = 0; |
72 | visibleMode = true; | 79 | visibleMode = true; |
73 | QHBox * vb = new QHBox ( this ); | 80 | Q3HBox * vb = new Q3HBox ( this ); |
74 | QPixmap iconp; | 81 | QPixmap iconp; |
75 | vb->setMargin ( KDialog::marginHint()-1 ); | 82 | vb->setMargin ( KDialog::marginHint()-1 ); |
76 | QPushButton * toggleJournal = new QPushButton( vb ); | 83 | QPushButton * toggleJournal = new QPushButton( vb ); |
77 | iconp = SmallIcon("1updownarrow"); | 84 | iconp = SmallIcon("1updownarrow"); |
78 | toggleJournal->setPixmap (iconp ) ; | 85 | toggleJournal->setPixmap (iconp ) ; |
79 | QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); | 86 | QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); |
80 | mTitle = new KOLocationBox(TRUE, vb, 30); | 87 | mTitle = new KOLocationBox(TRUE, vb, 30); |
81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 88 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
82 | mCalendarBox = new QComboBox(vb); | 89 | mCalendarBox = new QComboBox(vb); |
83 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 90 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
84 | #ifndef DESKTOP_VERSION | 91 | #ifndef DESKTOP_VERSION |
85 | mTitle->setSizeLimit( 8 ); | 92 | mTitle->setSizeLimit( 8 ); |
86 | mCalendarBox->setSizeLimit( 8 ); | 93 | mCalendarBox->setSizeLimit( 8 ); |
87 | #endif | 94 | #endif |
88 | vb->setStretchFactor ( mTitle, 8 ); | 95 | vb->setStretchFactor ( mTitle, 8 ); |
89 | int limit = 3; | 96 | int limit = 3; |
90 | if ( QApplication::desktop()->width() < 640 ) | 97 | if ( QApplication::desktop()->width() < 640 ) |
91 | limit = 6; | 98 | limit = 6; |
92 | vb->setStretchFactor ( mCalendarBox, limit ); | 99 | vb->setStretchFactor ( mCalendarBox, limit ); |
93 | //mTitleLabel->setMargin(0); | 100 | //mTitleLabel->setMargin(0); |
94 | //mTitleLabel->setAlignment(AlignCenter); | 101 | //mTitleLabel->setAlignment(AlignCenter); |
95 | QPushButton * loadTemplate = new QPushButton( vb ); | 102 | QPushButton * loadTemplate = new QPushButton( vb ); |
96 | QPushButton * saveTemplate = new QPushButton( vb ); | 103 | QPushButton * saveTemplate = new QPushButton( vb ); |
97 | if ( QApplication::desktop()->width() < 321 ) | 104 | if ( QApplication::desktop()->width() < 321 ) |
98 | iconp = SmallIcon("fileexport16"); | 105 | iconp = SmallIcon("fileexport16"); |
99 | else | 106 | else |
100 | iconp = SmallIcon("fileexport"); | 107 | iconp = SmallIcon("fileexport"); |
101 | saveTemplate->setPixmap (iconp ) ; | 108 | saveTemplate->setPixmap (iconp ) ; |
102 | int size = saveTemplate->sizeHint().height(); | 109 | int size = saveTemplate->sizeHint().height(); |
103 | if ( QApplication::desktop()->width() < 321 ) | 110 | if ( QApplication::desktop()->width() < 321 ) |
104 | iconp = SmallIcon("fileimport16"); | 111 | iconp = SmallIcon("fileimport16"); |
105 | else | 112 | else |
106 | iconp = SmallIcon("fileimport"); | 113 | iconp = SmallIcon("fileimport"); |
107 | loadTemplate->setPixmap (iconp ) ; | 114 | loadTemplate->setPixmap (iconp ) ; |
108 | loadTemplate->setFixedSize( size, size ); | 115 | loadTemplate->setFixedSize( size, size ); |
109 | saveTemplate->setFixedSize( size, size ); | 116 | saveTemplate->setFixedSize( size, size ); |
110 | int widwid = size; | 117 | int widwid = size; |
111 | if ( QApplication::desktop()->width() < 320 ) | 118 | if ( QApplication::desktop()->width() < 320 ) |
112 | widwid = size/2+1; | 119 | widwid = size/2+1; |
113 | toggleJournal->setFixedSize( widwid , size ); | 120 | toggleJournal->setFixedSize( widwid , size ); |
114 | mTitle->setFixedHeight( size+4); | 121 | mTitle->setFixedHeight( size+4); |
115 | mCalendarBox->setFixedHeight( size+4); | 122 | mCalendarBox->setFixedHeight( size+4); |
116 | mEditor = new KTextEdit(this); | 123 | mEditor = new KTextEdit(this); |
117 | #ifndef DESKTOP_VERSION | 124 | #ifndef DESKTOP_VERSION |
118 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 125 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
119 | #endif | 126 | #endif |
120 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); | 127 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); |
121 | mDeskWid = QApplication::desktop()->width(); | 128 | mDeskWid = QApplication::desktop()->width(); |
122 | int maxwid = mDeskWid - mMaxWidDiff; | 129 | int maxwid = mDeskWid - mMaxWidDiff; |
123 | if ( QApplication::desktop()->width() < 640 ) { | 130 | if ( QApplication::desktop()->width() < 640 ) { |
124 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 131 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
125 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 132 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
126 | } else { | 133 | } else { |
127 | mTitle->setMaximumWidth( (maxwid/4)*3); | 134 | mTitle->setMaximumWidth( (maxwid/4)*3); |
128 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 135 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
129 | } | 136 | } |
130 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 137 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
131 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 138 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
132 | QBoxLayout *topLayout = new QVBoxLayout(this); | 139 | Q3BoxLayout *topLayout = new Q3VBoxLayout(this); |
133 | topLayout->addWidget(vb); | 140 | topLayout->addWidget(vb); |
134 | topLayout->addWidget(mEditor); | 141 | topLayout->addWidget(mEditor); |
135 | mEditor->installEventFilter(this); | 142 | mEditor->installEventFilter(this); |
136 | installEventFilter(this); | 143 | installEventFilter(this); |
137 | mTitle->installEventFilter(this); | 144 | mTitle->installEventFilter(this); |
138 | setFocusPolicy (QWidget::NoFocus); | 145 | setFocusPolicy (Qt::NoFocus); |
139 | 146 | ||
140 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 147 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
141 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 148 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
142 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | 149 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); |
143 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 150 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
144 | mTitle->lineEdit ()->setText(""); | 151 | mTitle->lineEdit ()->setText(""); |
145 | } | 152 | } |
146 | 153 | ||
147 | JournalEntry::~JournalEntry() | 154 | JournalEntry::~JournalEntry() |
148 | { | 155 | { |
149 | //qDebug("JournalEntry::~JournalEntry() "); | 156 | //qDebug("JournalEntry::~JournalEntry() "); |
150 | } | 157 | } |
151 | void JournalEntry::resizeEvent(QResizeEvent* e ) | 158 | void JournalEntry::resizeEvent(QResizeEvent* e ) |
152 | { | 159 | { |
153 | #ifndef DESKTOP_VERSION | 160 | #ifndef DESKTOP_VERSION |
154 | 161 | ||
155 | if ( mDeskWid != QApplication::desktop()->width() ) { | 162 | if ( mDeskWid != QApplication::desktop()->width() ) { |
156 | mDeskWid == QApplication::desktop()->width(); | 163 | mDeskWid == QApplication::desktop()->width(); |
157 | int maxwid = mDeskWid - mMaxWidDiff; | 164 | int maxwid = mDeskWid - mMaxWidDiff; |
158 | if ( QApplication::desktop()->width() < 640 ) { | 165 | if ( QApplication::desktop()->width() < 640 ) { |
159 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 166 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
160 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 167 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
161 | } | 168 | } |
162 | else { | 169 | else { |
163 | mTitle->setMaximumWidth( (maxwid/4)*3); | 170 | mTitle->setMaximumWidth( (maxwid/4)*3); |
164 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 171 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
165 | } | 172 | } |
166 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 173 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
167 | } | 174 | } |
168 | //setMaximumWidth( QApplication::desktop()->width() ); | 175 | //setMaximumWidth( QApplication::desktop()->width() ); |
169 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); | 176 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); |
170 | #endif | 177 | #endif |
171 | QFrame::resizeEvent( e ); | 178 | Q3Frame::resizeEvent( e ); |
172 | } | 179 | } |
173 | QSize JournalEntry::sizeHint() const | 180 | QSize JournalEntry::sizeHint() const |
174 | { | 181 | { |
175 | return QSize ( 240, heiHint ); | 182 | return QSize ( 240, heiHint ); |
176 | } | 183 | } |
177 | void JournalEntry::slotSaveTemplate() | 184 | void JournalEntry::slotSaveTemplate() |
178 | { | 185 | { |
179 | QString fileName =locateLocal( "templates", "journals" ); | 186 | QString fileName =locateLocal( "templates", "journals" ); |
180 | QDir t_dir; | 187 | QDir t_dir; |
181 | if ( !t_dir.exists(fileName) ) | 188 | if ( !t_dir.exists(fileName) ) |
182 | t_dir.mkdir ( fileName ); | 189 | t_dir.mkdir ( fileName ); |
183 | fileName += "/journal"; | 190 | fileName += "/journal"; |
184 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); | 191 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); |
185 | if ( fileName.length() == 0 ) | 192 | if ( fileName.length() == 0 ) |
186 | return; | 193 | return; |
187 | 194 | ||
188 | QFile fileIn( fileName ); | 195 | QFile fileIn( fileName ); |
189 | if (!fileIn.open( IO_WriteOnly ) ) { | 196 | if (!fileIn.open( QIODevice::WriteOnly ) ) { |
190 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") | 197 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") |
191 | .arg( fileName ) ); | 198 | .arg( fileName ) ); |
192 | return; | 199 | return; |
193 | } | 200 | } |
194 | // QString text; | 201 | // QString text; |
195 | QTextStream tsIn( &fileIn ); | 202 | Q3TextStream tsIn( &fileIn ); |
196 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 203 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
197 | tsIn << mEditor->text(); | 204 | tsIn << mEditor->text(); |
198 | fileIn.close(); | 205 | fileIn.close(); |
199 | } | 206 | } |
200 | void JournalEntry::slotLoadTemplate() | 207 | void JournalEntry::slotLoadTemplate() |
201 | { | 208 | { |
202 | QString fileName =locateLocal( "templates", "journals" ); | 209 | QString fileName =locateLocal( "templates", "journals" ); |
203 | QDir t_dir; | 210 | QDir t_dir; |
204 | if ( !t_dir.exists(fileName) ) | 211 | if ( !t_dir.exists(fileName) ) |
205 | t_dir.mkdir ( fileName ); | 212 | t_dir.mkdir ( fileName ); |
206 | fileName += "/journal"; | 213 | fileName += "/journal"; |
207 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 214 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
208 | if ( fileName.length() == 0 ) | 215 | if ( fileName.length() == 0 ) |
209 | return; | 216 | return; |
210 | QFile fileIn( fileName ); | 217 | QFile fileIn( fileName ); |
211 | if (!fileIn.open( IO_ReadOnly ) ) { | 218 | if (!fileIn.open( QIODevice::ReadOnly ) ) { |
212 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 219 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
213 | .arg( fileName ) ); | 220 | .arg( fileName ) ); |
214 | return; | 221 | return; |
215 | } | 222 | } |
216 | QTextStream tsIn( &fileIn ); | 223 | Q3TextStream tsIn( &fileIn ); |
217 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 224 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
218 | QString text = tsIn.read(); | 225 | QString text = tsIn.read(); |
219 | fileIn.close(); | 226 | fileIn.close(); |
220 | int line, col; | 227 | int line, col; |
221 | mEditor->getCursorPosition (& line, & col ); | 228 | mEditor->getCursorPosition (& line, & col ); |
222 | mEditor-> insertAt ( text, line, col, true ); | 229 | mEditor-> insertAt ( text, line, col, true ); |
223 | //mEditor->setIgnoreMark( true ); | 230 | //mEditor->setIgnoreMark( true ); |
224 | } | 231 | } |
225 | void JournalEntry::setDate(const QDate &date) | 232 | void JournalEntry::setDate(const QDate &date) |
226 | { | 233 | { |
227 | showOnlyMode = false; | 234 | showOnlyMode = false; |
228 | writeJournal(); | 235 | writeJournal(); |
229 | mDate = date; | 236 | mDate = date; |
230 | fillCalendar( mCalendar->defaultCalendar() ); | 237 | fillCalendar( mCalendar->defaultCalendar() ); |
231 | } | 238 | } |
232 | void JournalEntry::fillCalendar( int setToID ) | 239 | void JournalEntry::fillCalendar( int setToID ) |
233 | { | 240 | { |
234 | mCalendarBox->clear(); | 241 | mCalendarBox->clear(); |
235 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 242 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
236 | int std = 0; | 243 | int std = 0; |
237 | int count = 0; | 244 | int count = 0; |
238 | while ( kkf ) { | 245 | while ( kkf ) { |
239 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { | 246 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { |
240 | if ( setToID ) { | 247 | if ( setToID ) { |
241 | if ( kkf->mCalNumber == setToID ) | 248 | if ( kkf->mCalNumber == setToID ) |
242 | std = count; | 249 | std = count; |
243 | } else { | 250 | } else { |
244 | if ( kkf->isStandard ) { | 251 | if ( kkf->isStandard ) { |
245 | std = count; | 252 | std = count; |
246 | } | 253 | } |
247 | } | 254 | } |
248 | ++count; | 255 | ++count; |
@@ -287,84 +294,84 @@ void JournalEntry::setJournal(Journal *journal, bool saveJournal ) | |||
287 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 294 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
288 | 295 | ||
289 | mJournal = journal; | 296 | mJournal = journal; |
290 | if ( journal->isReadOnly() ) | 297 | if ( journal->isReadOnly() ) |
291 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); | 298 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); |
292 | else | 299 | else |
293 | mTitle->lineEdit ()->setText(mJournal->summary()); | 300 | mTitle->lineEdit ()->setText(mJournal->summary()); |
294 | mEditor->setText(mJournal->description()); | 301 | mEditor->setText(mJournal->description()); |
295 | mTitle->setEnabled (!journal->isReadOnly() ); | 302 | mTitle->setEnabled (!journal->isReadOnly() ); |
296 | mEditor->setReadOnly ( journal->isReadOnly() ); | 303 | mEditor->setReadOnly ( journal->isReadOnly() ); |
297 | mCalendarBox->setEnabled (!journal->isReadOnly() ); | 304 | mCalendarBox->setEnabled (!journal->isReadOnly() ); |
298 | fillCalendar( mJournal->calID() ); | 305 | fillCalendar( mJournal->calID() ); |
299 | } | 306 | } |
300 | 307 | ||
301 | Journal *JournalEntry::journal() const | 308 | Journal *JournalEntry::journal() const |
302 | { | 309 | { |
303 | return mJournal; | 310 | return mJournal; |
304 | } | 311 | } |
305 | 312 | ||
306 | 313 | ||
307 | void JournalEntry::clear() | 314 | void JournalEntry::clear() |
308 | { | 315 | { |
309 | mJournal = 0; | 316 | mJournal = 0; |
310 | mEditor->setText(""); | 317 | mEditor->setText(""); |
311 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 318 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
312 | mTitle->lineEdit ()->setText(""); | 319 | mTitle->lineEdit ()->setText(""); |
313 | } | 320 | } |
314 | 321 | ||
315 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | 322 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) |
316 | { | 323 | { |
317 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; | 324 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; |
318 | if ( isVisible() ) { | 325 | if ( isVisible() ) { |
319 | mEditor->setFocusPolicy (QWidget::StrongFocus); | 326 | mEditor->setFocusPolicy (Qt::StrongFocus); |
320 | mTitle->setFocusPolicy (QWidget::StrongFocus); | 327 | mTitle->setFocusPolicy (Qt::StrongFocus); |
321 | } else { | 328 | } else { |
322 | mEditor->setFocusPolicy (QWidget::NoFocus); | 329 | mEditor->setFocusPolicy (Qt::NoFocus); |
323 | mTitle->setFocusPolicy (QWidget::NoFocus); | 330 | mTitle->setFocusPolicy (Qt::NoFocus); |
324 | } | 331 | } |
325 | if ( e->type() == QEvent::FocusOut ) { | 332 | if ( e->type() == QEvent::FocusOut ) { |
326 | writeJournal(); | 333 | writeJournal(); |
327 | } | 334 | } |
328 | if ( e->type() == QEvent::KeyPress ) { | 335 | if ( e->type() == QEvent::KeyPress ) { |
329 | QKeyEvent * k = (QKeyEvent *) e; | 336 | QKeyEvent * k = (QKeyEvent *) e; |
330 | if ( !isVisible() ) | 337 | if ( !isVisible() ) |
331 | return true; | 338 | return true; |
332 | if ( k->state() == Qt::ControlButton ) { | 339 | if ( k->state() == Qt::ControlButton ) { |
333 | k->ignore(); | 340 | k->ignore(); |
334 | //return true; | 341 | //return true; |
335 | } | 342 | } |
336 | } | 343 | } |
337 | 344 | ||
338 | return QFrame::eventFilter( o, e ); // standard event processing | 345 | return Q3Frame::eventFilter( o, e ); // standard event processing |
339 | } | 346 | } |
340 | 347 | ||
341 | void JournalEntry::writeJournal() | 348 | void JournalEntry::writeJournal() |
342 | { | 349 | { |
343 | if ( !visibleMode ) return; | 350 | if ( !visibleMode ) return; |
344 | if ( !mTitle->isEnabled() ) return; | 351 | if ( !mTitle->isEnabled() ) return; |
345 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { | 352 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { |
346 | if ( mJournal ) { | 353 | if ( mJournal ) { |
347 | Journal* j = mJournal; | 354 | Journal* j = mJournal; |
348 | mJournal = 0; | 355 | mJournal = 0; |
349 | bool conf = KOPrefs::instance()->mConfirm; | 356 | bool conf = KOPrefs::instance()->mConfirm; |
350 | KOPrefs::instance()->mConfirm = false; | 357 | KOPrefs::instance()->mConfirm = false; |
351 | emit deleteJournal(j); | 358 | emit deleteJournal(j); |
352 | KOPrefs::instance()->mConfirm = conf; | 359 | KOPrefs::instance()->mConfirm = conf; |
353 | } | 360 | } |
354 | return; | 361 | return; |
355 | } | 362 | } |
356 | 363 | ||
357 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; | 364 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; |
358 | 365 | ||
359 | if (!mJournal) { | 366 | if (!mJournal) { |
360 | mJournal = new Journal; | 367 | mJournal = new Journal; |
361 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 368 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
362 | mCalendar->addJournal(mJournal); | 369 | mCalendar->addJournal(mJournal); |
363 | } | 370 | } |
364 | if ( mJournal->description() != mEditor->text() ) { | 371 | if ( mJournal->description() != mEditor->text() ) { |
365 | mJournal->setDescription(mEditor->text()); | 372 | mJournal->setDescription(mEditor->text()); |
366 | } | 373 | } |
367 | if ( mJournal->summary() != mTitle->currentText() ) { | 374 | if ( mJournal->summary() != mTitle->currentText() ) { |
368 | mJournal->setSummary(mTitle->currentText()); | 375 | mJournal->setSummary(mTitle->currentText()); |
369 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); | 376 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); |
370 | } | 377 | } |