-rw-r--r-- | korganizer/journalentry.cpp | 53 | ||||
-rw-r--r-- | korganizer/journalentry.h | 7 | ||||
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 8 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 10 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 10 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 |
6 files changed, 63 insertions, 26 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 4751d40..56221dc 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -58,68 +58,69 @@ | |||
58 | #endif | 58 | #endif |
59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : |
60 | QFrame(parent) | 60 | QFrame(parent) |
61 | { | 61 | { |
62 | 62 | ||
63 | int fac = 5; | 63 | int fac = 5; |
64 | heiHint = QApplication::desktop()->height(); | 64 | heiHint = QApplication::desktop()->height(); |
65 | if ( heiHint > 800 ) | 65 | if ( heiHint > 800 ) |
66 | fac += 2; | 66 | fac += 2; |
67 | heiHint = heiHint / fac; | 67 | heiHint = heiHint / fac; |
68 | 68 | ||
69 | showOnlyMode = false; | 69 | showOnlyMode = false; |
70 | mCalendar = calendar; | 70 | mCalendar = calendar; |
71 | mJournal = 0; | 71 | mJournal = 0; |
72 | visibleMode = true; | 72 | visibleMode = true; |
73 | QHBox * vb = new QHBox ( this ); | 73 | QHBox * vb = new QHBox ( this ); |
74 | QPixmap iconp; | 74 | QPixmap iconp; |
75 | vb->setMargin ( KDialog::marginHint()-1 ); | 75 | vb->setMargin ( KDialog::marginHint()-1 ); |
76 | QPushButton * toggleJournal = new QPushButton( vb ); | 76 | QPushButton * toggleJournal = new QPushButton( vb ); |
77 | iconp = SmallIcon("1updownarrow"); | 77 | iconp = SmallIcon("1updownarrow"); |
78 | toggleJournal->setPixmap (iconp ) ; | 78 | toggleJournal->setPixmap (iconp ) ; |
79 | new QLabel(" "+i18n("Title: "),vb); | 79 | new QLabel(" "+i18n("Title: "),vb); |
80 | mTitle = new KOLocationBox(TRUE, vb, 30); | 80 | mTitle = new KOLocationBox(TRUE, vb, 30); |
81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); | 81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); |
82 | mTitleLabel = new QLabel(i18n("Title"),vb); | 82 | mCalendarBox = new QComboBox(vb); |
83 | mTitleLabel->setMargin(0); | 83 | //mTitleLabel->setMargin(0); |
84 | mTitleLabel->setAlignment(AlignCenter); | 84 | //mTitleLabel->setAlignment(AlignCenter); |
85 | QPushButton * loadTemplate = new QPushButton( vb ); | 85 | QPushButton * loadTemplate = new QPushButton( vb ); |
86 | QPushButton * saveTemplate = new QPushButton( vb ); | 86 | QPushButton * saveTemplate = new QPushButton( vb ); |
87 | if ( QApplication::desktop()->width() < 321 ) | 87 | if ( QApplication::desktop()->width() < 321 ) |
88 | iconp = SmallIcon("fileexport16"); | 88 | iconp = SmallIcon("fileexport16"); |
89 | else | 89 | else |
90 | iconp = SmallIcon("fileexport"); | 90 | iconp = SmallIcon("fileexport"); |
91 | saveTemplate->setPixmap (iconp ) ; | 91 | saveTemplate->setPixmap (iconp ) ; |
92 | int size = saveTemplate->sizeHint().height(); | 92 | int size = saveTemplate->sizeHint().height(); |
93 | if ( QApplication::desktop()->width() < 321 ) | 93 | if ( QApplication::desktop()->width() < 321 ) |
94 | iconp = SmallIcon("fileimport16"); | 94 | iconp = SmallIcon("fileimport16"); |
95 | else | 95 | else |
96 | iconp = SmallIcon("fileimport"); | 96 | iconp = SmallIcon("fileimport"); |
97 | loadTemplate->setPixmap (iconp ) ; | 97 | loadTemplate->setPixmap (iconp ) ; |
98 | loadTemplate->setFixedSize( size, size ); | 98 | loadTemplate->setFixedSize( size, size ); |
99 | saveTemplate->setFixedSize( size, size ); | 99 | saveTemplate->setFixedSize( size, size ); |
100 | toggleJournal->setFixedSize( size , size ); | 100 | toggleJournal->setFixedSize( size , size ); |
101 | mTitle->setMaximumHeight( size+4); | 101 | mTitle->setMaximumHeight( size+4); |
102 | mCalendarBox->setMaximumHeight( size+4); | ||
102 | mEditor = new KTextEdit(this); | 103 | mEditor = new KTextEdit(this); |
103 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
104 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 105 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
105 | #endif | 106 | #endif |
106 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 107 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
107 | QBoxLayout *topLayout = new QVBoxLayout(this); | 108 | QBoxLayout *topLayout = new QVBoxLayout(this); |
108 | topLayout->addWidget(vb); | 109 | topLayout->addWidget(vb); |
109 | topLayout->addWidget(mEditor); | 110 | topLayout->addWidget(mEditor); |
110 | mEditor->installEventFilter(this); | 111 | mEditor->installEventFilter(this); |
111 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 112 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
112 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 113 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
113 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | 114 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); |
114 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 115 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
115 | mTitle->lineEdit ()->setText(""); | 116 | mTitle->lineEdit ()->setText(""); |
116 | } | 117 | } |
117 | 118 | ||
118 | JournalEntry::~JournalEntry() | 119 | JournalEntry::~JournalEntry() |
119 | { | 120 | { |
120 | //qDebug("JournalEntry::~JournalEntry() "); | 121 | //qDebug("JournalEntry::~JournalEntry() "); |
121 | } | 122 | } |
122 | QSize JournalEntry::sizeHint() const | 123 | QSize JournalEntry::sizeHint() const |
123 | { | 124 | { |
124 | return QSize ( 240, heiHint ); | 125 | return QSize ( 240, heiHint ); |
125 | } | 126 | } |
@@ -155,145 +156,173 @@ void JournalEntry::slotLoadTemplate() | |||
155 | fileName += "/journal"; | 156 | fileName += "/journal"; |
156 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 157 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
157 | if ( fileName.length() == 0 ) | 158 | if ( fileName.length() == 0 ) |
158 | return; | 159 | return; |
159 | QFile fileIn( fileName ); | 160 | QFile fileIn( fileName ); |
160 | if (!fileIn.open( IO_ReadOnly ) ) { | 161 | if (!fileIn.open( IO_ReadOnly ) ) { |
161 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 162 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
162 | .arg( fileName ) ); | 163 | .arg( fileName ) ); |
163 | return; | 164 | return; |
164 | } | 165 | } |
165 | QTextStream tsIn( &fileIn ); | 166 | QTextStream tsIn( &fileIn ); |
166 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 167 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
167 | QString text = tsIn.read(); | 168 | QString text = tsIn.read(); |
168 | fileIn.close(); | 169 | fileIn.close(); |
169 | int line, col; | 170 | int line, col; |
170 | mEditor->getCursorPosition (& line, & col ); | 171 | mEditor->getCursorPosition (& line, & col ); |
171 | mEditor-> insertAt ( text, line, col, true ); | 172 | mEditor-> insertAt ( text, line, col, true ); |
172 | //mEditor->setIgnoreMark( true ); | 173 | //mEditor->setIgnoreMark( true ); |
173 | } | 174 | } |
174 | void JournalEntry::setDate(const QDate &date) | 175 | void JournalEntry::setDate(const QDate &date) |
175 | { | 176 | { |
176 | showOnlyMode = false; | 177 | showOnlyMode = false; |
177 | writeJournal(); | 178 | writeJournal(); |
178 | mDate = date; | 179 | mDate = date; |
179 | int id = mCalendar->defaultCalendar(); | 180 | fillCalendar( mCalendar->defaultCalendar() ); |
180 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; | 181 | } |
181 | mTitleLabel->setText( " (" + calname +")"); | 182 | void JournalEntry::fillCalendar( int setToID ) |
183 | { | ||
184 | mCalendarBox->clear(); | ||
185 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | ||
186 | int std = 0; | ||
187 | int count = 0; | ||
188 | while ( kkf ) { | ||
189 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { | ||
190 | if ( setToID ) { | ||
191 | if ( kkf->mCalNumber == setToID ) | ||
192 | std = count; | ||
193 | } else { | ||
194 | if ( kkf->isStandard ) { | ||
195 | std = count; | ||
196 | } | ||
197 | } | ||
198 | ++count; | ||
199 | mCalendarBox->insertItem( kkf->mName ); | ||
200 | } | ||
201 | kkf = KOPrefs::instance()->mCalendars.next(); | ||
202 | } | ||
203 | mCalendarBox->setCurrentItem( std ); | ||
204 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) | ||
205 | mCalendarBox->hide(); | ||
206 | else | ||
207 | mCalendarBox->show(); | ||
182 | } | 208 | } |
183 | 209 | ||
184 | void JournalEntry::toggleShowJournal() | 210 | void JournalEntry::toggleShowJournal() |
185 | { | 211 | { |
186 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) | 212 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) |
187 | flushEntry(); | 213 | flushEntry(); |
188 | if ( showOnlyMode ) | 214 | if ( showOnlyMode ) |
189 | emit showJournalOnly( 0 ); | 215 | emit showJournalOnly( 0 ); |
190 | else { | 216 | else { |
191 | // we have to protect mJournal from deleting if mJournal has empty text | 217 | // we have to protect mJournal from deleting if mJournal has empty text |
192 | visibleMode = false; // set to true via :setShowOnly() | 218 | visibleMode = false; // set to true via :setShowOnly() |
193 | emit showJournalOnly( mJournal ); | 219 | emit showJournalOnly( mJournal ); |
194 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); | 220 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); |
195 | } | 221 | } |
196 | } | 222 | } |
197 | void JournalEntry::setVisibleOn() | 223 | void JournalEntry::setVisibleOn() |
198 | { | 224 | { |
199 | visibleMode = true; | 225 | visibleMode = true; |
200 | } | 226 | } |
201 | void JournalEntry::setShowOnly() | 227 | void JournalEntry::setShowOnly() |
202 | { | 228 | { |
203 | showOnlyMode = true; | 229 | showOnlyMode = true; |
204 | if ( mTitle->currentText().isEmpty() ) | 230 | if ( mTitle->currentText().isEmpty() ) |
205 | mTitle->setFocus(); | 231 | mTitle->setFocus(); |
206 | else | 232 | else |
207 | mEditor->setFocus(); | 233 | mEditor->setFocus(); |
208 | } | 234 | } |
209 | void JournalEntry::setJournal(Journal *journal) | 235 | void JournalEntry::setJournal(Journal *journal, bool saveJournal ) |
210 | { | 236 | { |
211 | writeJournal(); | 237 | if ( saveJournal ) |
238 | writeJournal(); | ||
212 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 239 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
213 | 240 | ||
214 | mJournal = journal; | 241 | mJournal = journal; |
215 | if ( journal->isReadOnly() ) | 242 | if ( journal->isReadOnly() ) |
216 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); | 243 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); |
217 | else | 244 | else |
218 | mTitle->lineEdit ()->setText(mJournal->summary()); | 245 | mTitle->lineEdit ()->setText(mJournal->summary()); |
219 | mEditor->setText(mJournal->description()); | 246 | mEditor->setText(mJournal->description()); |
220 | mTitle->setEnabled (!journal->isReadOnly() ); | 247 | mTitle->setEnabled (!journal->isReadOnly() ); |
221 | mEditor->setReadOnly ( journal->isReadOnly() ); | 248 | mEditor->setReadOnly ( journal->isReadOnly() ); |
222 | int id = mJournal->calID(); | 249 | fillCalendar( mJournal->calID() ); |
223 | |||
224 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; | ||
225 | mTitleLabel->setText( " (" + calname +")"); | ||
226 | } | 250 | } |
227 | 251 | ||
228 | Journal *JournalEntry::journal() const | 252 | Journal *JournalEntry::journal() const |
229 | { | 253 | { |
230 | return mJournal; | 254 | return mJournal; |
231 | } | 255 | } |
232 | 256 | ||
233 | 257 | ||
234 | void JournalEntry::clear() | 258 | void JournalEntry::clear() |
235 | { | 259 | { |
236 | mJournal = 0; | 260 | mJournal = 0; |
237 | mEditor->setText(""); | 261 | mEditor->setText(""); |
238 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 262 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
239 | mTitle->lineEdit ()->setText(""); | 263 | mTitle->lineEdit ()->setText(""); |
240 | } | 264 | } |
241 | 265 | ||
242 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | 266 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) |
243 | { | 267 | { |
244 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; | 268 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; |
245 | 269 | ||
246 | if ( e->type() == QEvent::FocusOut ) { | 270 | if ( e->type() == QEvent::FocusOut ) { |
247 | writeJournal(); | 271 | writeJournal(); |
248 | } | 272 | } |
249 | if ( e->type() == QEvent::KeyPress ) { | 273 | if ( e->type() == QEvent::KeyPress ) { |
250 | QKeyEvent * k = (QKeyEvent *) e; | 274 | QKeyEvent * k = (QKeyEvent *) e; |
251 | if ( k->state() == Qt::ControlButton ) { | 275 | if ( k->state() == Qt::ControlButton ) { |
252 | k->ignore(); | 276 | k->ignore(); |
253 | //return true; | 277 | //return true; |
254 | } | 278 | } |
255 | } | 279 | } |
256 | 280 | ||
257 | return QFrame::eventFilter( o, e ); // standard event processing | 281 | return QFrame::eventFilter( o, e ); // standard event processing |
258 | } | 282 | } |
259 | 283 | ||
260 | void JournalEntry::writeJournal() | 284 | void JournalEntry::writeJournal() |
261 | { | 285 | { |
262 | if ( !visibleMode ) return; | 286 | if ( !visibleMode ) return; |
287 | if ( !mTitle->isEnabled() ) return; | ||
263 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { | 288 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { |
264 | if ( mJournal ) { | 289 | if ( mJournal ) { |
265 | Journal* j = mJournal; | 290 | Journal* j = mJournal; |
266 | mJournal = 0; | 291 | mJournal = 0; |
267 | bool conf = KOPrefs::instance()->mConfirm; | 292 | bool conf = KOPrefs::instance()->mConfirm; |
268 | KOPrefs::instance()->mConfirm = false; | 293 | KOPrefs::instance()->mConfirm = false; |
269 | emit deleteJournal(j); | 294 | emit deleteJournal(j); |
270 | KOPrefs::instance()->mConfirm = conf; | 295 | KOPrefs::instance()->mConfirm = conf; |
271 | } | 296 | } |
272 | return; | 297 | return; |
273 | } | 298 | } |
274 | 299 | ||
275 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; | 300 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; |
276 | 301 | ||
277 | if (!mJournal) { | 302 | if (!mJournal) { |
278 | mJournal = new Journal; | 303 | mJournal = new Journal; |
279 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 304 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
280 | mCalendar->addJournal(mJournal); | 305 | mCalendar->addJournal(mJournal); |
281 | } | 306 | } |
282 | if ( mJournal->description() != mEditor->text() ) { | 307 | if ( mJournal->description() != mEditor->text() ) { |
283 | mJournal->setDescription(mEditor->text()); | 308 | mJournal->setDescription(mEditor->text()); |
284 | } | 309 | } |
285 | if ( mJournal->summary() != mTitle->currentText() ) { | 310 | if ( mJournal->summary() != mTitle->currentText() ) { |
286 | mJournal->setSummary(mTitle->currentText()); | 311 | mJournal->setSummary(mTitle->currentText()); |
287 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); | 312 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); |
288 | } | 313 | } |
314 | int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); | ||
315 | if ( mJournal->calID() != id ) { | ||
316 | mJournal->setCalID( id ); | ||
317 | } | ||
289 | } | 318 | } |
290 | 319 | ||
291 | void JournalEntry::flushEntry() | 320 | void JournalEntry::flushEntry() |
292 | { | 321 | { |
293 | writeJournal(); | 322 | writeJournal(); |
294 | } | 323 | } |
295 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) | 324 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) |
296 | { | 325 | { |
297 | e->ignore(); | 326 | e->ignore(); |
298 | 327 | ||
299 | } | 328 | } |
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index fb19fb1..ed04b7c 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h | |||
@@ -10,76 +10,77 @@ | |||
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 | #ifndef JOURNALENTRY_H | 23 | #ifndef JOURNALENTRY_H |
24 | #define JOURNALENTRY_H | 24 | #define JOURNALENTRY_H |
25 | // | 25 | // |
26 | // Widget showing one Journal entry | 26 | // Widget showing one Journal entry |
27 | 27 | ||
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | class QLabel; | 32 | class QLabel; |
33 | class KTextEdit; | 33 | class KTextEdit; |
34 | class QComboBox; | ||
34 | class KLineEdit; | 35 | class KLineEdit; |
35 | class KOLocationBox; | 36 | class KOLocationBox; |
36 | 37 | ||
37 | using namespace KCal; | 38 | using namespace KCal; |
38 | 39 | ||
39 | class JournalEntry : public QFrame { | 40 | class JournalEntry : public QFrame { |
40 | Q_OBJECT | 41 | Q_OBJECT |
41 | public: | 42 | public: |
42 | JournalEntry(Calendar *,QWidget *parent); | 43 | JournalEntry(Calendar *,QWidget *parent); |
43 | virtual ~JournalEntry(); | 44 | virtual ~JournalEntry(); |
44 | 45 | ||
45 | void setJournal(Journal *); | 46 | void setJournal(Journal *, bool saveJournal = true ); |
46 | Journal *journal() const; | 47 | Journal *journal() const; |
47 | 48 | ||
48 | void setDate(const QDate &); | 49 | void setDate(const QDate &); |
49 | 50 | ||
50 | void clear(); | 51 | void clear(); |
51 | 52 | ||
52 | void flushEntry(); | 53 | void flushEntry(); |
53 | void setShowOnly(); | 54 | void setShowOnly(); |
54 | QSize sizeHint() const; | 55 | QSize sizeHint() const; |
55 | void setVisibleMode( bool b ) { visibleMode = b;} | 56 | void setVisibleMode( bool b ) { visibleMode = b;} |
56 | 57 | void fillCalendar( int id = 0 ); | |
57 | protected slots: | 58 | protected slots: |
58 | void slotSaveTemplate(); | 59 | void slotSaveTemplate(); |
59 | void slotLoadTemplate(); | 60 | void slotLoadTemplate(); |
60 | void toggleShowJournal(); | 61 | void toggleShowJournal(); |
61 | void setVisibleOn(); | 62 | void setVisibleOn(); |
62 | signals: | 63 | signals: |
63 | void deleteJournal(Journal *); | 64 | void deleteJournal(Journal *); |
64 | void newJournal(); | 65 | void newJournal(); |
65 | void showJournalOnly( Journal * ); | 66 | void showJournalOnly( Journal * ); |
66 | 67 | ||
67 | protected: | 68 | protected: |
68 | bool eventFilter( QObject *o, QEvent *e ); | 69 | bool eventFilter( QObject *o, QEvent *e ); |
69 | 70 | ||
70 | void writeJournal(); | 71 | void writeJournal(); |
71 | 72 | ||
72 | private: | 73 | private: |
73 | bool visibleMode; | 74 | bool visibleMode; |
74 | bool showOnlyMode; | 75 | bool showOnlyMode; |
75 | Calendar *mCalendar; | 76 | Calendar *mCalendar; |
76 | Journal *mJournal; | 77 | Journal *mJournal; |
77 | QDate mDate; | 78 | QDate mDate; |
78 | void keyPressEvent ( QKeyEvent * ) ; | 79 | void keyPressEvent ( QKeyEvent * ) ; |
79 | QLabel *mTitleLabel; | 80 | QComboBox *mCalendarBox; |
80 | KOLocationBox * mTitle; | 81 | KOLocationBox * mTitle; |
81 | KTextEdit *mEditor; | 82 | KTextEdit *mEditor; |
82 | int heiHint; | 83 | int heiHint; |
83 | }; | 84 | }; |
84 | 85 | ||
85 | #endif | 86 | #endif |
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index fd50b05..aa55d82 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -462,55 +462,49 @@ void KOEditorGeneral::fillCalCombo( int setToID ) | |||
462 | while ( kkf ) { | 462 | while ( kkf ) { |
463 | if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) { | 463 | if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) { |
464 | if ( setToID ) { | 464 | if ( setToID ) { |
465 | if ( kkf->mCalNumber == setToID ) | 465 | if ( kkf->mCalNumber == setToID ) |
466 | std = count; | 466 | std = count; |
467 | } else { | 467 | } else { |
468 | if ( kkf->isStandard ) { | 468 | if ( kkf->isStandard ) { |
469 | std = count; | 469 | std = count; |
470 | } | 470 | } |
471 | } | 471 | } |
472 | ++count; | 472 | ++count; |
473 | mCalendarBox->insertItem( kkf->mName ); | 473 | mCalendarBox->insertItem( kkf->mName ); |
474 | } | 474 | } |
475 | kkf = KOPrefs::instance()->mCalendars.next(); | 475 | kkf = KOPrefs::instance()->mCalendars.next(); |
476 | } | 476 | } |
477 | mCalendarBox->setCurrentItem( std ); | 477 | mCalendarBox->setCurrentItem( std ); |
478 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) | 478 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) |
479 | mCalendarBox->hide(); | 479 | mCalendarBox->hide(); |
480 | else | 480 | else |
481 | mCalendarBox->show(); | 481 | mCalendarBox->show(); |
482 | 482 | ||
483 | } | 483 | } |
484 | int KOEditorGeneral::getCalendarID() | 484 | int KOEditorGeneral::getCalendarID() |
485 | { | 485 | { |
486 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 486 | return KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); |
487 | while ( kkf ) { | ||
488 | if ( mCalendarBox->currentText() == kkf->mName) | ||
489 | return kkf->mCalNumber; | ||
490 | kkf = KOPrefs::instance()->mCalendars.next(); | ||
491 | } | ||
492 | return 1; | ||
493 | } | 487 | } |
494 | 488 | ||
495 | void KOEditorGeneral::readIncidence(Incidence *event) | 489 | void KOEditorGeneral::readIncidence(Incidence *event) |
496 | { | 490 | { |
497 | fillCalCombo( event->calID() ); | 491 | fillCalCombo( event->calID() ); |
498 | mAlarmMessage = event->summary(); | 492 | mAlarmMessage = event->summary(); |
499 | if ( ! event->location().isEmpty() ) | 493 | if ( ! event->location().isEmpty() ) |
500 | mAlarmMessage += " ("+event->location()+")"; | 494 | mAlarmMessage += " ("+event->location()+")"; |
501 | mAlarmIncrCombo->setCurrentItem(0); | 495 | mAlarmIncrCombo->setCurrentItem(0); |
502 | mSummaryEdit->setEditText(event->summary()); | 496 | mSummaryEdit->setEditText(event->summary()); |
503 | mLocationEdit->setEditText(event->location()); | 497 | mLocationEdit->setEditText(event->location()); |
504 | mDescriptionEdit->setText(event->description()); | 498 | mDescriptionEdit->setText(event->description()); |
505 | 499 | ||
506 | #if 0 | 500 | #if 0 |
507 | // organizer information | 501 | // organizer information |
508 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); | 502 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); |
509 | #endif | 503 | #endif |
510 | 504 | ||
511 | enableAlarmEdit( event->isAlarmEnabled() ); | 505 | enableAlarmEdit( event->isAlarmEnabled() ); |
512 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); | 506 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); |
513 | if(!event->isAlarmEnabled()) { | 507 | if(!event->isAlarmEnabled()) { |
514 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 508 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
515 | int alarmTime; | 509 | int alarmTime; |
516 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 510 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index 9b0e748..0523954 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp | |||
@@ -134,78 +134,80 @@ void KOJournalView::flushView() | |||
134 | } | 134 | } |
135 | ff = false; | 135 | ff = false; |
136 | } | 136 | } |
137 | 137 | ||
138 | void KOJournalView::clearList() | 138 | void KOJournalView::clearList() |
139 | { | 139 | { |
140 | JournalEntry* mEntry = jEntries.first(); | 140 | JournalEntry* mEntry = jEntries.first(); |
141 | while ( mEntry ) { | 141 | while ( mEntry ) { |
142 | mEntry->clear(); | 142 | mEntry->clear(); |
143 | mEntry = jEntries.next(); | 143 | mEntry = jEntries.next(); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | void KOJournalView::newJournal() | 146 | void KOJournalView::newJournal() |
147 | { | 147 | { |
148 | //qDebug(" KOJournalView::newJournal()"); | 148 | //qDebug(" KOJournalView::newJournal()"); |
149 | flushView(); | 149 | flushView(); |
150 | Journal* mJournal = new Journal; | 150 | Journal* mJournal = new Journal; |
151 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 151 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
152 | mCalendar->addJournal(mJournal); | 152 | mCalendar->addJournal(mJournal); |
153 | showDates( mDate, QDate() ); | 153 | showDates( mDate, QDate() ); |
154 | } | 154 | } |
155 | 155 | ||
156 | void KOJournalView::showOnly ( Journal* j ) | 156 | void KOJournalView::showOnly ( Journal* j ) |
157 | { | 157 | { |
158 | qDebug("showOnly %x ", j); | 158 | //qDebug("showOnly %x ", j); |
159 | flushView(); | 159 | flushView(); |
160 | if ( j == 0 ) { | 160 | if ( j == 0 ) { |
161 | showDates( mDate, QDate() ); | 161 | showDates( mDate, QDate() ); |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | QPtrList<Journal> jl; | 164 | QPtrList<Journal> jl; |
165 | jl.append ( j ); | 165 | jl.append ( j ); |
166 | showList( jl ); | 166 | showList( jl ); |
167 | JournalEntry* mEntry = jEntries.first(); | 167 | JournalEntry* mEntry = jEntries.first(); |
168 | mEntry->setShowOnly(); | 168 | mEntry->setShowOnly(); |
169 | } | 169 | } |
170 | void KOJournalView::showList(QPtrList<Journal> jl) | 170 | void KOJournalView::showList(QPtrList<Journal> jl) |
171 | { | 171 | { |
172 | qDebug("KOJournalView::showList %d",jl.count() ); | 172 | //qDebug("KOJournalView::showList %d",jl.count() ); |
173 | JournalEntry* mEntry = jEntries.first(); | 173 | JournalEntry* mEntry = jEntries.first(); |
174 | JournalEntry* firstEntry = mEntry; | 174 | JournalEntry* firstEntry = mEntry; |
175 | int count = jl.count(); | 175 | int count = jl.count(); |
176 | int iii = 0; | 176 | int iii = 0; |
177 | while ( iii < count ) { | 177 | while ( iii < count ) { |
178 | if ( !mEntry ) { | 178 | if ( !mEntry ) { |
179 | mEntry = getNewEntry(); | 179 | mEntry = getNewEntry(); |
180 | mEntry->setVisibleMode( true ); | ||
180 | mEntry->setDate(mDate); | 181 | mEntry->setDate(mDate); |
181 | mEntry->setJournal(jl.at(iii)); | 182 | mEntry->setJournal(jl.at(iii), false); |
182 | mEntry->setVisibleMode( true ); | 183 | mEntry->setVisibleMode( true ); |
183 | mEntry->show(); | 184 | mEntry->show(); |
184 | mEntry = 0; | 185 | mEntry = 0; |
185 | } else { | 186 | } else { |
187 | mEntry->setVisibleMode( true ); | ||
186 | mEntry->setDate(mDate); | 188 | mEntry->setDate(mDate); |
187 | mEntry->setJournal(jl.at(iii)); | 189 | mEntry->setJournal(jl.at(iii), false); |
188 | mEntry->setVisibleMode( true ); | 190 | mEntry->setVisibleMode( true ); |
189 | mEntry->show(); | 191 | mEntry->show(); |
190 | mEntry = jEntries.next(); | 192 | mEntry = jEntries.next(); |
191 | } | 193 | } |
192 | ++iii; | 194 | ++iii; |
193 | } | 195 | } |
194 | while ( mEntry ) { | 196 | while ( mEntry ) { |
195 | mEntry->setDate(mDate); | 197 | mEntry->setDate(mDate); |
196 | mEntry->clear(); | 198 | mEntry->clear(); |
197 | if ( mEntry != firstEntry ) { | 199 | if ( mEntry != firstEntry ) { |
198 | mEntry->hide(); | 200 | mEntry->hide(); |
199 | mEntry->setVisibleMode( false ); | 201 | mEntry->setVisibleMode( false ); |
200 | } | 202 | } |
201 | else { | 203 | else { |
202 | mEntry->setVisibleMode( true ); | 204 | mEntry->setVisibleMode( true ); |
203 | mEntry->show(); | 205 | mEntry->show(); |
204 | } | 206 | } |
205 | mEntry = jEntries.next(); | 207 | mEntry = jEntries.next(); |
206 | } | 208 | } |
207 | } | 209 | } |
208 | 210 | ||
209 | void KOJournalView::showDates(const QDate &start, const QDate &) | 211 | void KOJournalView::showDates(const QDate &start, const QDate &) |
210 | { | 212 | { |
211 | mDate = start; | 213 | mDate = start; |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index bb3d720..a886735 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -480,48 +480,58 @@ KopiCalendarFile * KOPrefs::getNewCalendar() | |||
480 | { | 480 | { |
481 | KopiCalendarFile * kkf = new KopiCalendarFile(); | 481 | KopiCalendarFile * kkf = new KopiCalendarFile(); |
482 | kkf->mCalNumber = mNextAvailableCalendar; | 482 | kkf->mCalNumber = mNextAvailableCalendar; |
483 | mDefCalColors.resize( mNextAvailableCalendar ); | 483 | mDefCalColors.resize( mNextAvailableCalendar ); |
484 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | 484 | mDefCalColors[mNextAvailableCalendar-1] = kkf; |
485 | ++mNextAvailableCalendar; | 485 | ++mNextAvailableCalendar; |
486 | kkf->mDefaultColor = mEventColor; | 486 | kkf->mDefaultColor = mEventColor; |
487 | kkf->mName = i18n("New Calendar"); | 487 | kkf->mName = i18n("New Calendar"); |
488 | mCalendars.append( kkf ); | 488 | mCalendars.append( kkf ); |
489 | return kkf; | 489 | return kkf; |
490 | } | 490 | } |
491 | void KOPrefs::deleteCalendar( int num ) | 491 | void KOPrefs::deleteCalendar( int num ) |
492 | { | 492 | { |
493 | KopiCalendarFile * kkf = mCalendars.first(); | 493 | KopiCalendarFile * kkf = mCalendars.first(); |
494 | while ( kkf ) { | 494 | while ( kkf ) { |
495 | if ( kkf->mCalNumber == num ) { | 495 | if ( kkf->mCalNumber == num ) { |
496 | qDebug("KOPrefs::deleteCalendar %d ", num ); | 496 | qDebug("KOPrefs::deleteCalendar %d ", num ); |
497 | mCalendars.remove( kkf ); | 497 | mCalendars.remove( kkf ); |
498 | delete kkf; | 498 | delete kkf; |
499 | return; | 499 | return; |
500 | } | 500 | } |
501 | kkf = mCalendars.next(); | 501 | kkf = mCalendars.next(); |
502 | } | 502 | } |
503 | } | 503 | } |
504 | int KOPrefs::getCalendarID( const QString & name ) | ||
505 | { | ||
506 | KopiCalendarFile * kkf = mCalendars.first(); | ||
507 | while ( kkf ) { | ||
508 | if ( name == kkf->mName) | ||
509 | return kkf->mCalNumber; | ||
510 | kkf = mCalendars.next(); | ||
511 | } | ||
512 | return 1; | ||
513 | } | ||
504 | QString KOPrefs::calName( int calNum) const | 514 | QString KOPrefs::calName( int calNum) const |
505 | { | 515 | { |
506 | return (mDefCalColors[calNum-1])->mName; | 516 | return (mDefCalColors[calNum-1])->mName; |
507 | } | 517 | } |
508 | QColor KOPrefs::defaultColor( int calNum ) const | 518 | QColor KOPrefs::defaultColor( int calNum ) const |
509 | { | 519 | { |
510 | if ( calNum == 1 ) return mEventColor; | 520 | if ( calNum == 1 ) return mEventColor; |
511 | return (mDefCalColors[calNum-1])->mDefaultColor; | 521 | return (mDefCalColors[calNum-1])->mDefaultColor; |
512 | } | 522 | } |
513 | void KOPrefs::usrWriteConfig() | 523 | void KOPrefs::usrWriteConfig() |
514 | { | 524 | { |
515 | config()->setGroup("General"); | 525 | config()->setGroup("General"); |
516 | config()->writeEntry("Custom Categories",mCustomCategories); | 526 | config()->writeEntry("Custom Categories",mCustomCategories); |
517 | 527 | ||
518 | config()->setGroup("Personal Settings"); | 528 | config()->setGroup("Personal Settings"); |
519 | config()->writeEntry("user_name",mName); | 529 | config()->writeEntry("user_name",mName); |
520 | config()->writeEntry("user_email",mEmail); | 530 | config()->writeEntry("user_email",mEmail); |
521 | 531 | ||
522 | config()->setGroup("Category Colors"); | 532 | config()->setGroup("Category Colors"); |
523 | QDictIterator<QColor> it(mCategoryColors); | 533 | QDictIterator<QColor> it(mCategoryColors); |
524 | while (it.current()) { | 534 | while (it.current()) { |
525 | config()->writeEntry(it.currentKey(),*(it.current())); | 535 | config()->writeEntry(it.currentKey(),*(it.current())); |
526 | ++it; | 536 | ++it; |
527 | } | 537 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 53d193b..7ec5327 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -79,48 +79,49 @@ class KOPrefs : public KPimPrefs | |||
79 | enum { neverAuto, addressbookAuto, selectedAuto }; | 79 | enum { neverAuto, addressbookAuto, selectedAuto }; |
80 | enum { standardDestination, askDestination }; | 80 | enum { standardDestination, askDestination }; |
81 | 81 | ||
82 | virtual ~KOPrefs(); | 82 | virtual ~KOPrefs(); |
83 | 83 | ||
84 | /** Get instance of KOPrefs. It is made sure that there is only one | 84 | /** Get instance of KOPrefs. It is made sure that there is only one |
85 | instance. */ | 85 | instance. */ |
86 | static KOPrefs *instance(); | 86 | static KOPrefs *instance(); |
87 | 87 | ||
88 | /** Set preferences to default values */ | 88 | /** Set preferences to default values */ |
89 | void usrSetDefaults(); | 89 | void usrSetDefaults(); |
90 | 90 | ||
91 | /** Read preferences from config file */ | 91 | /** Read preferences from config file */ |
92 | void usrReadConfig(); | 92 | void usrReadConfig(); |
93 | 93 | ||
94 | /** Write preferences to config file */ | 94 | /** Write preferences to config file */ |
95 | void usrWriteConfig(); | 95 | void usrWriteConfig(); |
96 | void setCategoryDefaults(); | 96 | void setCategoryDefaults(); |
97 | void setAllDefaults(); | 97 | void setAllDefaults(); |
98 | KopiCalendarFile * getNewCalendar(); | 98 | KopiCalendarFile * getNewCalendar(); |
99 | KopiCalendarFile * getCalendar( int ); | 99 | KopiCalendarFile * getCalendar( int ); |
100 | void deleteCalendar( int ); | 100 | void deleteCalendar( int ); |
101 | QColor defaultColor( int ) const; | 101 | QColor defaultColor( int ) const; |
102 | QString calName( int ) const; | 102 | QString calName( int ) const; |
103 | int getCalendarID( const QString & name ); | ||
103 | protected: | 104 | protected: |
104 | void setTimeZoneIdDefault(); | 105 | void setTimeZoneIdDefault(); |
105 | 106 | ||
106 | /** Fill empty mail fields with default values. */ | 107 | /** Fill empty mail fields with default values. */ |
107 | void fillMailDefaults(); | 108 | void fillMailDefaults(); |
108 | 109 | ||
109 | private: | 110 | private: |
110 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 111 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
111 | object. */ | 112 | object. */ |
112 | KOPrefs(); | 113 | KOPrefs(); |
113 | 114 | ||
114 | static KOPrefs *mInstance; | 115 | static KOPrefs *mInstance; |
115 | QStringList getDefaultList(); | 116 | QStringList getDefaultList(); |
116 | QStringList getLocationDefaultList(); | 117 | QStringList getLocationDefaultList(); |
117 | public: | 118 | public: |
118 | // preferences data | 119 | // preferences data |
119 | KConfig* getConfig(); | 120 | KConfig* getConfig(); |
120 | void setFullName(const QString &); | 121 | void setFullName(const QString &); |
121 | QString fullName(); | 122 | QString fullName(); |
122 | void setEmail(const QString &); | 123 | void setEmail(const QString &); |
123 | QString email(); | 124 | QString email(); |
124 | 125 | ||
125 | QString mAdditional; | 126 | QString mAdditional; |
126 | 127 | ||