-rw-r--r-- | korganizer/journalentry.cpp | 7 | ||||
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 739949d..5fc3f2f 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -1,370 +1,371 @@ | |||
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 <qvbox.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.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 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <ktextedit.h> | 41 | #include <ktextedit.h> |
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 | #include <klineedit.h> |
46 | #include <kdialog.h> | 46 | #include <kdialog.h> |
47 | #include "kolocationbox.h" | 47 | #include "kolocationbox.h" |
48 | 48 | ||
49 | #include <libkcal/journal.h> | 49 | #include <libkcal/journal.h> |
50 | #include <libkcal/calendarresources.h> | 50 | #include <libkcal/calendarresources.h> |
51 | #include <libkcal/resourcecalendar.h> | 51 | #include <libkcal/resourcecalendar.h> |
52 | #include <kresources/resourceselectdialog.h> | 52 | #include <kresources/resourceselectdialog.h> |
53 | 53 | ||
54 | #include "journalentry.h" | 54 | #include "journalentry.h" |
55 | //#include "journalentry.moc" | 55 | //#include "journalentry.moc" |
56 | #ifndef DESKTOP_VERSION | 56 | #ifndef DESKTOP_VERSION |
57 | #include <qpe/qpeapplication.h> | 57 | #include <qpe/qpeapplication.h> |
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 | QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); | 79 | QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); |
80 | vb->setStretchFactor (textLabel,1); | ||
81 | vb->setStretchFactor( toggleJournal, 1 ); | ||
82 | mTitle = new KOLocationBox(TRUE, vb, 30); | 80 | mTitle = new KOLocationBox(TRUE, vb, 30); |
83 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
84 | mCalendarBox = new QComboBox(vb); | 82 | mCalendarBox = new QComboBox(vb); |
85 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 83 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
86 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
87 | mTitle->setSizeLimit( 8 ); | 85 | mTitle->setSizeLimit( 8 ); |
88 | mCalendarBox->setSizeLimit( 8 ); | 86 | mCalendarBox->setSizeLimit( 8 ); |
89 | #endif | 87 | #endif |
90 | vb->setStretchFactor ( mTitle, 8 ); | 88 | vb->setStretchFactor ( mTitle, 8 ); |
91 | int limit = 3; | 89 | int limit = 3; |
92 | if ( QApplication::desktop()->width() < 640 ) | 90 | if ( QApplication::desktop()->width() < 640 ) |
93 | limit = 6; | 91 | limit = 6; |
94 | vb->setStretchFactor ( mCalendarBox, limit ); | 92 | vb->setStretchFactor ( mCalendarBox, limit ); |
95 | //mTitleLabel->setMargin(0); | 93 | //mTitleLabel->setMargin(0); |
96 | //mTitleLabel->setAlignment(AlignCenter); | 94 | //mTitleLabel->setAlignment(AlignCenter); |
97 | QPushButton * loadTemplate = new QPushButton( vb ); | 95 | QPushButton * loadTemplate = new QPushButton( vb ); |
98 | QPushButton * saveTemplate = new QPushButton( vb ); | 96 | QPushButton * saveTemplate = new QPushButton( vb ); |
99 | if ( QApplication::desktop()->width() < 321 ) | 97 | if ( QApplication::desktop()->width() < 321 ) |
100 | iconp = SmallIcon("fileexport16"); | 98 | iconp = SmallIcon("fileexport16"); |
101 | else | 99 | else |
102 | iconp = SmallIcon("fileexport"); | 100 | iconp = SmallIcon("fileexport"); |
103 | saveTemplate->setPixmap (iconp ) ; | 101 | saveTemplate->setPixmap (iconp ) ; |
104 | int size = saveTemplate->sizeHint().height(); | 102 | int size = saveTemplate->sizeHint().height(); |
105 | if ( QApplication::desktop()->width() < 321 ) | 103 | if ( QApplication::desktop()->width() < 321 ) |
106 | iconp = SmallIcon("fileimport16"); | 104 | iconp = SmallIcon("fileimport16"); |
107 | else | 105 | else |
108 | iconp = SmallIcon("fileimport"); | 106 | iconp = SmallIcon("fileimport"); |
109 | loadTemplate->setPixmap (iconp ) ; | 107 | loadTemplate->setPixmap (iconp ) ; |
110 | loadTemplate->setFixedSize( size, size ); | 108 | loadTemplate->setFixedSize( size, size ); |
111 | saveTemplate->setFixedSize( size, size ); | 109 | saveTemplate->setFixedSize( size, size ); |
112 | toggleJournal->setFixedSize( size , size ); | 110 | int widwid = size; |
111 | if ( QApplication::desktop()->width() < 320 ) | ||
112 | widwid = size/2+1; | ||
113 | toggleJournal->setFixedSize( widwid , size ); | ||
113 | mTitle->setFixedHeight( size+4); | 114 | mTitle->setFixedHeight( size+4); |
114 | mCalendarBox->setFixedHeight( size+4); | 115 | mCalendarBox->setFixedHeight( size+4); |
115 | mEditor = new KTextEdit(this); | 116 | mEditor = new KTextEdit(this); |
116 | #ifndef DESKTOP_VERSION | 117 | #ifndef DESKTOP_VERSION |
117 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 118 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
118 | #endif | 119 | #endif |
119 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); | 120 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); |
120 | mDeskWid = QApplication::desktop()->width(); | 121 | mDeskWid = QApplication::desktop()->width(); |
121 | int maxwid = mDeskWid - mMaxWidDiff; | 122 | int maxwid = mDeskWid - mMaxWidDiff; |
122 | if ( QApplication::desktop()->width() < 640 ) { | 123 | if ( QApplication::desktop()->width() < 640 ) { |
123 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 124 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
124 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 125 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
125 | } else { | 126 | } else { |
126 | mTitle->setMaximumWidth( (maxwid/4)*3); | 127 | mTitle->setMaximumWidth( (maxwid/4)*3); |
127 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 128 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
128 | } | 129 | } |
129 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 130 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
130 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 131 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
131 | QBoxLayout *topLayout = new QVBoxLayout(this); | 132 | QBoxLayout *topLayout = new QVBoxLayout(this); |
132 | topLayout->addWidget(vb); | 133 | topLayout->addWidget(vb); |
133 | topLayout->addWidget(mEditor); | 134 | topLayout->addWidget(mEditor); |
134 | mEditor->installEventFilter(this); | 135 | mEditor->installEventFilter(this); |
135 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 136 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
136 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 137 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
137 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | 138 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); |
138 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 139 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
139 | mTitle->lineEdit ()->setText(""); | 140 | mTitle->lineEdit ()->setText(""); |
140 | } | 141 | } |
141 | 142 | ||
142 | JournalEntry::~JournalEntry() | 143 | JournalEntry::~JournalEntry() |
143 | { | 144 | { |
144 | //qDebug("JournalEntry::~JournalEntry() "); | 145 | //qDebug("JournalEntry::~JournalEntry() "); |
145 | } | 146 | } |
146 | void JournalEntry::resizeEvent(QResizeEvent* e ) | 147 | void JournalEntry::resizeEvent(QResizeEvent* e ) |
147 | { | 148 | { |
148 | #ifndef DESKTOP_VERSION | 149 | #ifndef DESKTOP_VERSION |
149 | 150 | ||
150 | if ( mDeskWid != QApplication::desktop()->width() ) { | 151 | if ( mDeskWid != QApplication::desktop()->width() ) { |
151 | mDeskWid == QApplication::desktop()->width(); | 152 | mDeskWid == QApplication::desktop()->width(); |
152 | int maxwid = mDeskWid - mMaxWidDiff; | 153 | int maxwid = mDeskWid - mMaxWidDiff; |
153 | if ( QApplication::desktop()->width() < 640 ) { | 154 | if ( QApplication::desktop()->width() < 640 ) { |
154 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 155 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
155 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 156 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
156 | } | 157 | } |
157 | else { | 158 | else { |
158 | mTitle->setMaximumWidth( (maxwid/4)*3); | 159 | mTitle->setMaximumWidth( (maxwid/4)*3); |
159 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 160 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
160 | } | 161 | } |
161 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 162 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
162 | } | 163 | } |
163 | //setMaximumWidth( QApplication::desktop()->width() ); | 164 | //setMaximumWidth( QApplication::desktop()->width() ); |
164 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); | 165 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); |
165 | #endif | 166 | #endif |
166 | QFrame::resizeEvent( e ); | 167 | QFrame::resizeEvent( e ); |
167 | } | 168 | } |
168 | QSize JournalEntry::sizeHint() const | 169 | QSize JournalEntry::sizeHint() const |
169 | { | 170 | { |
170 | return QSize ( 240, heiHint ); | 171 | return QSize ( 240, heiHint ); |
171 | } | 172 | } |
172 | void JournalEntry::slotSaveTemplate() | 173 | void JournalEntry::slotSaveTemplate() |
173 | { | 174 | { |
174 | QString fileName =locateLocal( "templates", "journals" ); | 175 | QString fileName =locateLocal( "templates", "journals" ); |
175 | QDir t_dir; | 176 | QDir t_dir; |
176 | if ( !t_dir.exists(fileName) ) | 177 | if ( !t_dir.exists(fileName) ) |
177 | t_dir.mkdir ( fileName ); | 178 | t_dir.mkdir ( fileName ); |
178 | fileName += "/journal"; | 179 | fileName += "/journal"; |
179 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); | 180 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); |
180 | if ( fileName.length() == 0 ) | 181 | if ( fileName.length() == 0 ) |
181 | return; | 182 | return; |
182 | 183 | ||
183 | QFile fileIn( fileName ); | 184 | QFile fileIn( fileName ); |
184 | if (!fileIn.open( IO_WriteOnly ) ) { | 185 | if (!fileIn.open( IO_WriteOnly ) ) { |
185 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") | 186 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") |
186 | .arg( fileName ) ); | 187 | .arg( fileName ) ); |
187 | return; | 188 | return; |
188 | } | 189 | } |
189 | // QString text; | 190 | // QString text; |
190 | QTextStream tsIn( &fileIn ); | 191 | QTextStream tsIn( &fileIn ); |
191 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 192 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
192 | tsIn << mEditor->text(); | 193 | tsIn << mEditor->text(); |
193 | fileIn.close(); | 194 | fileIn.close(); |
194 | } | 195 | } |
195 | void JournalEntry::slotLoadTemplate() | 196 | void JournalEntry::slotLoadTemplate() |
196 | { | 197 | { |
197 | QString fileName =locateLocal( "templates", "journals" ); | 198 | QString fileName =locateLocal( "templates", "journals" ); |
198 | QDir t_dir; | 199 | QDir t_dir; |
199 | if ( !t_dir.exists(fileName) ) | 200 | if ( !t_dir.exists(fileName) ) |
200 | t_dir.mkdir ( fileName ); | 201 | t_dir.mkdir ( fileName ); |
201 | fileName += "/journal"; | 202 | fileName += "/journal"; |
202 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 203 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
203 | if ( fileName.length() == 0 ) | 204 | if ( fileName.length() == 0 ) |
204 | return; | 205 | return; |
205 | QFile fileIn( fileName ); | 206 | QFile fileIn( fileName ); |
206 | if (!fileIn.open( IO_ReadOnly ) ) { | 207 | if (!fileIn.open( IO_ReadOnly ) ) { |
207 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 208 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
208 | .arg( fileName ) ); | 209 | .arg( fileName ) ); |
209 | return; | 210 | return; |
210 | } | 211 | } |
211 | QTextStream tsIn( &fileIn ); | 212 | QTextStream tsIn( &fileIn ); |
212 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 213 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
213 | QString text = tsIn.read(); | 214 | QString text = tsIn.read(); |
214 | fileIn.close(); | 215 | fileIn.close(); |
215 | int line, col; | 216 | int line, col; |
216 | mEditor->getCursorPosition (& line, & col ); | 217 | mEditor->getCursorPosition (& line, & col ); |
217 | mEditor-> insertAt ( text, line, col, true ); | 218 | mEditor-> insertAt ( text, line, col, true ); |
218 | //mEditor->setIgnoreMark( true ); | 219 | //mEditor->setIgnoreMark( true ); |
219 | } | 220 | } |
220 | void JournalEntry::setDate(const QDate &date) | 221 | void JournalEntry::setDate(const QDate &date) |
221 | { | 222 | { |
222 | showOnlyMode = false; | 223 | showOnlyMode = false; |
223 | writeJournal(); | 224 | writeJournal(); |
224 | mDate = date; | 225 | mDate = date; |
225 | fillCalendar( mCalendar->defaultCalendar() ); | 226 | fillCalendar( mCalendar->defaultCalendar() ); |
226 | } | 227 | } |
227 | void JournalEntry::fillCalendar( int setToID ) | 228 | void JournalEntry::fillCalendar( int setToID ) |
228 | { | 229 | { |
229 | mCalendarBox->clear(); | 230 | mCalendarBox->clear(); |
230 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 231 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
231 | int std = 0; | 232 | int std = 0; |
232 | int count = 0; | 233 | int count = 0; |
233 | while ( kkf ) { | 234 | while ( kkf ) { |
234 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { | 235 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { |
235 | if ( setToID ) { | 236 | if ( setToID ) { |
236 | if ( kkf->mCalNumber == setToID ) | 237 | if ( kkf->mCalNumber == setToID ) |
237 | std = count; | 238 | std = count; |
238 | } else { | 239 | } else { |
239 | if ( kkf->isStandard ) { | 240 | if ( kkf->isStandard ) { |
240 | std = count; | 241 | std = count; |
241 | } | 242 | } |
242 | } | 243 | } |
243 | ++count; | 244 | ++count; |
244 | mCalendarBox->insertItem( kkf->mName ); | 245 | mCalendarBox->insertItem( kkf->mName ); |
245 | } | 246 | } |
246 | kkf = KOPrefs::instance()->mCalendars.next(); | 247 | kkf = KOPrefs::instance()->mCalendars.next(); |
247 | } | 248 | } |
248 | mCalendarBox->setCurrentItem( std ); | 249 | mCalendarBox->setCurrentItem( std ); |
249 | } | 250 | } |
250 | 251 | ||
251 | void JournalEntry::toggleShowJournal() | 252 | void JournalEntry::toggleShowJournal() |
252 | { | 253 | { |
253 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) | 254 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) |
254 | flushEntry(); | 255 | flushEntry(); |
255 | if ( showOnlyMode ) | 256 | if ( showOnlyMode ) |
256 | emit showJournalOnly( 0 ); | 257 | emit showJournalOnly( 0 ); |
257 | else { | 258 | else { |
258 | // we have to protect mJournal from deleting if mJournal has empty text | 259 | // we have to protect mJournal from deleting if mJournal has empty text |
259 | visibleMode = false; // set to true via :setShowOnly() | 260 | visibleMode = false; // set to true via :setShowOnly() |
260 | emit showJournalOnly( mJournal ); | 261 | emit showJournalOnly( mJournal ); |
261 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); | 262 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); |
262 | } | 263 | } |
263 | } | 264 | } |
264 | void JournalEntry::setVisibleOn() | 265 | void JournalEntry::setVisibleOn() |
265 | { | 266 | { |
266 | visibleMode = true; | 267 | visibleMode = true; |
267 | } | 268 | } |
268 | void JournalEntry::setShowOnly() | 269 | void JournalEntry::setShowOnly() |
269 | { | 270 | { |
270 | showOnlyMode = true; | 271 | showOnlyMode = true; |
271 | if ( mTitle->currentText().isEmpty() ) | 272 | if ( mTitle->currentText().isEmpty() ) |
272 | mTitle->setFocus(); | 273 | mTitle->setFocus(); |
273 | else | 274 | else |
274 | mEditor->setFocus(); | 275 | mEditor->setFocus(); |
275 | } | 276 | } |
276 | void JournalEntry::setJournal(Journal *journal, bool saveJournal ) | 277 | void JournalEntry::setJournal(Journal *journal, bool saveJournal ) |
277 | { | 278 | { |
278 | if ( saveJournal ) | 279 | if ( saveJournal ) |
279 | writeJournal(); | 280 | writeJournal(); |
280 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 281 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
281 | 282 | ||
282 | mJournal = journal; | 283 | mJournal = journal; |
283 | if ( journal->isReadOnly() ) | 284 | if ( journal->isReadOnly() ) |
284 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); | 285 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); |
285 | else | 286 | else |
286 | mTitle->lineEdit ()->setText(mJournal->summary()); | 287 | mTitle->lineEdit ()->setText(mJournal->summary()); |
287 | mEditor->setText(mJournal->description()); | 288 | mEditor->setText(mJournal->description()); |
288 | mTitle->setEnabled (!journal->isReadOnly() ); | 289 | mTitle->setEnabled (!journal->isReadOnly() ); |
289 | mEditor->setReadOnly ( journal->isReadOnly() ); | 290 | mEditor->setReadOnly ( journal->isReadOnly() ); |
290 | mCalendarBox->setEnabled (!journal->isReadOnly() ); | 291 | mCalendarBox->setEnabled (!journal->isReadOnly() ); |
291 | fillCalendar( mJournal->calID() ); | 292 | fillCalendar( mJournal->calID() ); |
292 | } | 293 | } |
293 | 294 | ||
294 | Journal *JournalEntry::journal() const | 295 | Journal *JournalEntry::journal() const |
295 | { | 296 | { |
296 | return mJournal; | 297 | return mJournal; |
297 | } | 298 | } |
298 | 299 | ||
299 | 300 | ||
300 | void JournalEntry::clear() | 301 | void JournalEntry::clear() |
301 | { | 302 | { |
302 | mJournal = 0; | 303 | mJournal = 0; |
303 | mEditor->setText(""); | 304 | mEditor->setText(""); |
304 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 305 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
305 | mTitle->lineEdit ()->setText(""); | 306 | mTitle->lineEdit ()->setText(""); |
306 | } | 307 | } |
307 | 308 | ||
308 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | 309 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) |
309 | { | 310 | { |
310 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; | 311 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; |
311 | 312 | ||
312 | if ( e->type() == QEvent::FocusOut ) { | 313 | if ( e->type() == QEvent::FocusOut ) { |
313 | writeJournal(); | 314 | writeJournal(); |
314 | } | 315 | } |
315 | if ( e->type() == QEvent::KeyPress ) { | 316 | if ( e->type() == QEvent::KeyPress ) { |
316 | QKeyEvent * k = (QKeyEvent *) e; | 317 | QKeyEvent * k = (QKeyEvent *) e; |
317 | if ( k->state() == Qt::ControlButton ) { | 318 | if ( k->state() == Qt::ControlButton ) { |
318 | k->ignore(); | 319 | k->ignore(); |
319 | //return true; | 320 | //return true; |
320 | } | 321 | } |
321 | } | 322 | } |
322 | 323 | ||
323 | return QFrame::eventFilter( o, e ); // standard event processing | 324 | return QFrame::eventFilter( o, e ); // standard event processing |
324 | } | 325 | } |
325 | 326 | ||
326 | void JournalEntry::writeJournal() | 327 | void JournalEntry::writeJournal() |
327 | { | 328 | { |
328 | if ( !visibleMode ) return; | 329 | if ( !visibleMode ) return; |
329 | if ( !mTitle->isEnabled() ) return; | 330 | if ( !mTitle->isEnabled() ) return; |
330 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { | 331 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { |
331 | if ( mJournal ) { | 332 | if ( mJournal ) { |
332 | Journal* j = mJournal; | 333 | Journal* j = mJournal; |
333 | mJournal = 0; | 334 | mJournal = 0; |
334 | bool conf = KOPrefs::instance()->mConfirm; | 335 | bool conf = KOPrefs::instance()->mConfirm; |
335 | KOPrefs::instance()->mConfirm = false; | 336 | KOPrefs::instance()->mConfirm = false; |
336 | emit deleteJournal(j); | 337 | emit deleteJournal(j); |
337 | KOPrefs::instance()->mConfirm = conf; | 338 | KOPrefs::instance()->mConfirm = conf; |
338 | } | 339 | } |
339 | return; | 340 | return; |
340 | } | 341 | } |
341 | 342 | ||
342 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; | 343 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; |
343 | 344 | ||
344 | if (!mJournal) { | 345 | if (!mJournal) { |
345 | mJournal = new Journal; | 346 | mJournal = new Journal; |
346 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 347 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
347 | mCalendar->addJournal(mJournal); | 348 | mCalendar->addJournal(mJournal); |
348 | } | 349 | } |
349 | if ( mJournal->description() != mEditor->text() ) { | 350 | if ( mJournal->description() != mEditor->text() ) { |
350 | mJournal->setDescription(mEditor->text()); | 351 | mJournal->setDescription(mEditor->text()); |
351 | } | 352 | } |
352 | if ( mJournal->summary() != mTitle->currentText() ) { | 353 | if ( mJournal->summary() != mTitle->currentText() ) { |
353 | mJournal->setSummary(mTitle->currentText()); | 354 | mJournal->setSummary(mTitle->currentText()); |
354 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); | 355 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); |
355 | } | 356 | } |
356 | int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); | 357 | int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); |
357 | if ( mJournal->calID() != id ) { | 358 | if ( mJournal->calID() != id ) { |
358 | mJournal->setCalID( id ); | 359 | mJournal->setCalID( id ); |
359 | } | 360 | } |
360 | } | 361 | } |
361 | 362 | ||
362 | void JournalEntry::flushEntry() | 363 | void JournalEntry::flushEntry() |
363 | { | 364 | { |
364 | writeJournal(); | 365 | writeJournal(); |
365 | } | 366 | } |
366 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) | 367 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) |
367 | { | 368 | { |
368 | e->ignore(); | 369 | e->ignore(); |
369 | 370 | ||
370 | } | 371 | } |
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index aa55d82..e601eef 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -1,618 +1,623 @@ | |||
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 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | 36 | ||
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kdialog.h> | 38 | #include <kdialog.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <kfiledialog.h> | 43 | #include <kfiledialog.h> |
44 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
45 | 45 | ||
46 | #include <libkcal/todo.h> | 46 | #include <libkcal/todo.h> |
47 | #include <libkcal/event.h> | 47 | #include <libkcal/event.h> |
48 | #include <libkdepim/categoryselectdialog.h> | 48 | #include <libkdepim/categoryselectdialog.h> |
49 | #include <libkdepim/kdateedit.h> | 49 | #include <libkdepim/kdateedit.h> |
50 | 50 | ||
51 | #include "koprefs.h" | 51 | #include "koprefs.h" |
52 | #include "koglobals.h" | 52 | #include "koglobals.h" |
53 | 53 | ||
54 | #include "koeditorgeneral.h" | 54 | #include "koeditorgeneral.h" |
55 | #include "kolocationbox.h" | 55 | #include "kolocationbox.h" |
56 | #ifndef DESKTOP_VERSION | 56 | #ifndef DESKTOP_VERSION |
57 | #include <qpe/qpeapplication.h> | 57 | #include <qpe/qpeapplication.h> |
58 | #else | 58 | #else |
59 | #include <qapplication.h> | 59 | #include <qapplication.h> |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : | 62 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : |
63 | QObject( parent, name) | 63 | QObject( parent, name) |
64 | { | 64 | { |
65 | mNextFocus = 0; | 65 | mNextFocus = 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | KOEditorGeneral::~KOEditorGeneral() | 68 | KOEditorGeneral::~KOEditorGeneral() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 72 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
73 | { | 73 | { |
74 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 74 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
75 | 75 | ||
76 | #if 0 | 76 | #if 0 |
77 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 77 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
78 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 78 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
79 | #endif | 79 | #endif |
80 | // 1 on pda | 80 | // 1 on pda |
81 | // 11 on desktop | 81 | // 11 on desktop |
82 | headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 ); | 82 | headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 ); |
83 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 83 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
84 | headerLayout->addWidget(summaryLabel,0,0); | 84 | headerLayout->addWidget(summaryLabel,0,0); |
85 | 85 | ||
86 | mSummaryEdit = new KOLocationBox(TRUE,parent, 50); | 86 | mSummaryEdit = new KOLocationBox(TRUE,parent, 50); |
87 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 87 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
88 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 88 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
89 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 89 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
90 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 90 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
91 | if ( QApplication::desktop()->width() > 320 ) | 91 | if ( QApplication::desktop()->width() > 320 ) |
92 | mSummaryEdit->setMaximumHeight( hei +6 ); | 92 | mSummaryEdit->setMaximumHeight( hei +6 ); |
93 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 93 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); |
94 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } | 94 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
95 | // mSummaryEdit = new QLineEdit(parent); | 95 | // mSummaryEdit = new QLineEdit(parent); |
96 | if ( QApplication::desktop()->height() < 320 ) | 96 | if ( QApplication::desktop()->height() < 320 ) |
97 | headerLayout->addWidget(mSummaryEdit,0,1); | 97 | headerLayout->addWidget(mSummaryEdit,0,1); |
98 | else | 98 | else |
99 | headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2); | 99 | headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2); |
100 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 100 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
101 | 101 | ||
102 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 102 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
103 | if ( QApplication::desktop()->height() < 320 ) | 103 | if ( QApplication::desktop()->height() < 320 ) |
104 | headerLayout->addWidget(locationLabel,0,2); | 104 | headerLayout->addWidget(locationLabel,0,2); |
105 | else | 105 | else |
106 | headerLayout->addWidget(locationLabel,1,0); | 106 | headerLayout->addWidget(locationLabel,1,0); |
107 | 107 | ||
108 | mLocationEdit = new KOLocationBox(TRUE,parent,30); | 108 | mLocationEdit = new KOLocationBox(TRUE,parent,30); |
109 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 109 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
110 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) | 110 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) |
111 | mLocationEdit->setMaximumHeight( hei + 6); | 111 | mLocationEdit->setMaximumHeight( hei + 6); |
112 | 112 | ||
113 | // mLocationEdit = new QLineEdit(parent); | 113 | // mLocationEdit = new QLineEdit(parent); |
114 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 114 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
115 | 115 | ||
116 | mCalendarBox = new QComboBox ( parent ); | 116 | mCalendarBox = new QComboBox ( parent ); |
117 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 117 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
118 | if ( QApplication::desktop()->height() < 320 ) { | 118 | if ( QApplication::desktop()->height() < 320 ) { |
119 | headerLayout->addWidget(mLocationEdit,0,3); | 119 | headerLayout->addWidget(mLocationEdit,0,3); |
120 | headerLayout->addWidget(mCalendarBox,0,4); | 120 | headerLayout->addWidget(mCalendarBox,0,4); |
121 | headerLayout->setColStretch( 1, 10); | 121 | headerLayout->setColStretch( 1, 10); |
122 | headerLayout->setColStretch( 3, 10); | 122 | headerLayout->setColStretch( 3, 10); |
123 | mCalendarBox->setMaximumWidth( 64 ); | 123 | mCalendarBox->setMaximumWidth( 64 ); |
124 | } | 124 | } |
125 | else { | 125 | else { |
126 | headerLayout->addWidget(mLocationEdit,1,1); | 126 | headerLayout->addWidget(mLocationEdit,1,1); |
127 | headerLayout->addWidget(mCalendarBox,1,2); | 127 | headerLayout->addWidget(mCalendarBox,1,2); |
128 | headerLayout->setColStretch( 1, 3); | 128 | int str = 3; |
129 | if ( QApplication::desktop()->width() < 320 ) { | ||
130 | --str; | ||
131 | --str; | ||
132 | } | ||
133 | headerLayout->setColStretch( 1, str); | ||
129 | headerLayout->setColStretch( 2, 1); | 134 | headerLayout->setColStretch( 2, 1); |
130 | } | 135 | } |
131 | 136 | ||
132 | } | 137 | } |
133 | void KOEditorGeneral::setFocusOn( int i ) | 138 | void KOEditorGeneral::setFocusOn( int i ) |
134 | { | 139 | { |
135 | mNextFocus = i; | 140 | mNextFocus = i; |
136 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); | 141 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); |
137 | } | 142 | } |
138 | void KOEditorGeneral::slotSetFocusOn() | 143 | void KOEditorGeneral::slotSetFocusOn() |
139 | { | 144 | { |
140 | mNextFocus; | 145 | mNextFocus; |
141 | if ( mNextFocus == 1 ) { | 146 | if ( mNextFocus == 1 ) { |
142 | mDescriptionEdit->setFocus(); | 147 | mDescriptionEdit->setFocus(); |
143 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 148 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
144 | } | 149 | } |
145 | if ( mNextFocus == 2 ) { | 150 | if ( mNextFocus == 2 ) { |
146 | mSummaryEdit->setFocus(); | 151 | mSummaryEdit->setFocus(); |
147 | } | 152 | } |
148 | } | 153 | } |
149 | void KOEditorGeneral::editCategories() | 154 | void KOEditorGeneral::editCategories() |
150 | { | 155 | { |
151 | // qDebug("KOEditorGeneral::editCategories() "); | 156 | // qDebug("KOEditorGeneral::editCategories() "); |
152 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 157 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
153 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 158 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
154 | //KOGlobals::fitDialogToScreen( csd ); | 159 | //KOGlobals::fitDialogToScreen( csd ); |
155 | csd->setColorEnabled(); | 160 | csd->setColorEnabled(); |
156 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 161 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
157 | csd->exec(); | 162 | csd->exec(); |
158 | delete csd; | 163 | delete csd; |
159 | } | 164 | } |
160 | 165 | ||
161 | void KOEditorGeneral::showCatPopup() | 166 | void KOEditorGeneral::showCatPopup() |
162 | { | 167 | { |
163 | mCatPopup->clear(); | 168 | mCatPopup->clear(); |
164 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); | 169 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); |
165 | int index = 0; | 170 | int index = 0; |
166 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 171 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
167 | it != KOPrefs::instance()->mCustomCategories.end (); | 172 | it != KOPrefs::instance()->mCustomCategories.end (); |
168 | ++it) { | 173 | ++it) { |
169 | mCatPopup->insertItem (*it, index ); | 174 | mCatPopup->insertItem (*it, index ); |
170 | //mCategory[index] = *it; | 175 | //mCategory[index] = *it; |
171 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); | 176 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); |
172 | ++index; | 177 | ++index; |
173 | } | 178 | } |
174 | } | 179 | } |
175 | void KOEditorGeneral::selectedCatPopup( int index ) | 180 | void KOEditorGeneral::selectedCatPopup( int index ) |
176 | { | 181 | { |
177 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); | 182 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); |
178 | QString colcat = categories.first(); | 183 | QString colcat = categories.first(); |
179 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) | 184 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) |
180 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); | 185 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); |
181 | else | 186 | else |
182 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); | 187 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); |
183 | categories.sort (); | 188 | categories.sort (); |
184 | if ( !colcat.isEmpty() ) { | 189 | if ( !colcat.isEmpty() ) { |
185 | if ( categories.find ( colcat ) != categories.end () ) { | 190 | if ( categories.find ( colcat ) != categories.end () ) { |
186 | categories.remove( colcat ); | 191 | categories.remove( colcat ); |
187 | categories.prepend( colcat ); | 192 | categories.prepend( colcat ); |
188 | } | 193 | } |
189 | } | 194 | } |
190 | setCategories( categories.join(",") ); | 195 | setCategories( categories.join(",") ); |
191 | } | 196 | } |
192 | 197 | ||
193 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 198 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
194 | { | 199 | { |
195 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 200 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
196 | mCatPopup = new QPopupMenu ( parent ); | 201 | mCatPopup = new QPopupMenu ( parent ); |
197 | mCatPopup->setCheckable (true); | 202 | mCatPopup->setCheckable (true); |
198 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); | 203 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); |
199 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); | 204 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); |
200 | mCategoriesButton = new QPushButton(parent); | 205 | mCategoriesButton = new QPushButton(parent); |
201 | mCategoriesButton->setText(i18n("Categories...")); | 206 | mCategoriesButton->setText(i18n("Categories...")); |
202 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 207 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
203 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 208 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
204 | categoriesLayout->addWidget(mCategoriesButton); | 209 | categoriesLayout->addWidget(mCategoriesButton); |
205 | mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); | 210 | mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); |
206 | mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 211 | mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
207 | mCategoriesLabel->setPopup( mCatPopup ); | 212 | mCategoriesLabel->setPopup( mCatPopup ); |
208 | //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 213 | //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
209 | categoriesLayout->addWidget(mCategoriesLabel,1); | 214 | categoriesLayout->addWidget(mCategoriesLabel,1); |
210 | } | 215 | } |
211 | 216 | ||
212 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 217 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
213 | { | 218 | { |
214 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 219 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
215 | 220 | ||
216 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 221 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
217 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 222 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
218 | secrecyLayout->addWidget(mCancelBox); | 223 | secrecyLayout->addWidget(mCancelBox); |
219 | secrecyLayout->addWidget(secrecyLabel); | 224 | secrecyLayout->addWidget(secrecyLabel); |
220 | 225 | ||
221 | mSecrecyCombo = new QComboBox(parent); | 226 | mSecrecyCombo = new QComboBox(parent); |
222 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 227 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
223 | secrecyLayout->addWidget(mSecrecyCombo); | 228 | secrecyLayout->addWidget(mSecrecyCombo); |
224 | } | 229 | } |
225 | 230 | ||
226 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 231 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
227 | { | 232 | { |
228 | mDescriptionEdit = new KTextEdit(parent); | 233 | mDescriptionEdit = new KTextEdit(parent); |
229 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 234 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
230 | mDescriptionEdit->append(""); | 235 | mDescriptionEdit->append(""); |
231 | mDescriptionEdit->setReadOnly(false); | 236 | mDescriptionEdit->setReadOnly(false); |
232 | mDescriptionEdit->setOverwriteMode(false); | 237 | mDescriptionEdit->setOverwriteMode(false); |
233 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 238 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
234 | topLayout->addWidget(mDescriptionEdit); | 239 | topLayout->addWidget(mDescriptionEdit); |
235 | #ifndef DESKTOP_VERSION | 240 | #ifndef DESKTOP_VERSION |
236 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 241 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
237 | #endif | 242 | #endif |
238 | 243 | ||
239 | } | 244 | } |
240 | 245 | ||
241 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 246 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
242 | { | 247 | { |
243 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 248 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
244 | 249 | ||
245 | //mAlarmBell = new QLabel(parent); | 250 | //mAlarmBell = new QLabel(parent); |
246 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 251 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
247 | //alarmLayout->addWidget(mAlarmBell); | 252 | //alarmLayout->addWidget(mAlarmBell); |
248 | if ( QApplication::desktop()->width() < 320 ) | 253 | if ( QApplication::desktop()->width() < 320 ) |
249 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 254 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
250 | else | 255 | else |
251 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 256 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
252 | 257 | ||
253 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 258 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
254 | alarmLayout->addWidget(mAlarmButton); | 259 | alarmLayout->addWidget(mAlarmButton); |
255 | 260 | ||
256 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 261 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
257 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); | 262 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); |
258 | alarmLayout->addWidget(mAlarmTimeEdit); | 263 | alarmLayout->addWidget(mAlarmTimeEdit); |
259 | mAlarmIncrCombo = new QComboBox(false, parent); | 264 | mAlarmIncrCombo = new QComboBox(false, parent); |
260 | if ( QApplication::desktop()->width() < 320 ) { | 265 | if ( QApplication::desktop()->width() < 320 ) { |
261 | mAlarmIncrCombo->insertItem(i18n("min")); | 266 | mAlarmIncrCombo->insertItem(i18n("min")); |
262 | mAlarmIncrCombo->insertItem(i18n("hou")); | 267 | mAlarmIncrCombo->insertItem(i18n("hou")); |
263 | mAlarmIncrCombo->insertItem(i18n("day")); | 268 | mAlarmIncrCombo->insertItem(i18n("day")); |
264 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 269 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
265 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 270 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
266 | } else { | 271 | } else { |
267 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 272 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
268 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 273 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
269 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 274 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
270 | } | 275 | } |
271 | 276 | ||
272 | // mAlarmIncrCombo->setMinimumHeight(20); | 277 | // mAlarmIncrCombo->setMinimumHeight(20); |
273 | alarmLayout->addWidget(mAlarmIncrCombo); | 278 | alarmLayout->addWidget(mAlarmIncrCombo); |
274 | mAlarmSoundButton = new QPushButton(parent); | 279 | mAlarmSoundButton = new QPushButton(parent); |
275 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 280 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
276 | mAlarmSoundButton->setToggleButton(true); | 281 | mAlarmSoundButton->setToggleButton(true); |
277 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 282 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
278 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 283 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
279 | alarmLayout->addWidget(mAlarmSoundButton); | 284 | alarmLayout->addWidget(mAlarmSoundButton); |
280 | 285 | ||
281 | mAlarmProgramButton = new QPushButton(parent); | 286 | mAlarmProgramButton = new QPushButton(parent); |
282 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 287 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
283 | mAlarmProgramButton->setToggleButton(true); | 288 | mAlarmProgramButton->setToggleButton(true); |
284 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 289 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
285 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 290 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
286 | alarmLayout->addWidget(mAlarmProgramButton); | 291 | alarmLayout->addWidget(mAlarmProgramButton); |
287 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 292 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
288 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 293 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
289 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 294 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
290 | // mAlarmSoundButton->hide(); | 295 | // mAlarmSoundButton->hide(); |
291 | // mAlarmProgramButton->hide(); | 296 | // mAlarmProgramButton->hide(); |
292 | // } | 297 | // } |
293 | } | 298 | } |
294 | 299 | ||
295 | void KOEditorGeneral::pickAlarmSound() | 300 | void KOEditorGeneral::pickAlarmSound() |
296 | { | 301 | { |
297 | 302 | ||
298 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); | 303 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); |
299 | 304 | ||
300 | bool oldState = mAlarmSoundButton->isOn(); | 305 | bool oldState = mAlarmSoundButton->isOn(); |
301 | 306 | ||
302 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 307 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
303 | i18n("*.wav|Wav Files"), 0)); | 308 | i18n("*.wav|Wav Files"), 0)); |
304 | if (!fileName.isEmpty()) { | 309 | if (!fileName.isEmpty()) { |
305 | mAlarmSound = fileName; | 310 | mAlarmSound = fileName; |
306 | QToolTip::remove(mAlarmSoundButton); | 311 | QToolTip::remove(mAlarmSoundButton); |
307 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 312 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
308 | QToolTip::add(mAlarmSoundButton, dispStr); | 313 | QToolTip::add(mAlarmSoundButton, dispStr); |
309 | mAlarmProgramButton->setOn(false); | 314 | mAlarmProgramButton->setOn(false); |
310 | mAlarmSoundButton->setOn(true); | 315 | mAlarmSoundButton->setOn(true); |
311 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 316 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
312 | } else { | 317 | } else { |
313 | mAlarmProgramButton->setOn(oldState); | 318 | mAlarmProgramButton->setOn(oldState); |
314 | mAlarmSoundButton->setOn(!oldState); | 319 | mAlarmSoundButton->setOn(!oldState); |
315 | 320 | ||
316 | 321 | ||
317 | } | 322 | } |
318 | 323 | ||
319 | if (mAlarmProgramButton->isOn()) | 324 | if (mAlarmProgramButton->isOn()) |
320 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 325 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
321 | if ( mAlarmSoundButton->isOn()) | 326 | if ( mAlarmSoundButton->isOn()) |
322 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 327 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
323 | 328 | ||
324 | } | 329 | } |
325 | 330 | ||
326 | void KOEditorGeneral::pickAlarmProgram() | 331 | void KOEditorGeneral::pickAlarmProgram() |
327 | { | 332 | { |
328 | bool oldState = mAlarmProgramButton->isOn(); | 333 | bool oldState = mAlarmProgramButton->isOn(); |
329 | 334 | ||
330 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); | 335 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); |
331 | if (!fileName.isEmpty()) { | 336 | if (!fileName.isEmpty()) { |
332 | mAlarmProgram = fileName; | 337 | mAlarmProgram = fileName; |
333 | QToolTip::remove(mAlarmProgramButton); | 338 | QToolTip::remove(mAlarmProgramButton); |
334 | QString dispStr = i18n("Running '%1'").arg(fileName); | 339 | QString dispStr = i18n("Running '%1'").arg(fileName); |
335 | QToolTip::add(mAlarmProgramButton, dispStr); | 340 | QToolTip::add(mAlarmProgramButton, dispStr); |
336 | mAlarmSoundButton->setOn(false); | 341 | mAlarmSoundButton->setOn(false); |
337 | mAlarmProgramButton->setOn(true); | 342 | mAlarmProgramButton->setOn(true); |
338 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 343 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
339 | } else { | 344 | } else { |
340 | mAlarmProgramButton->setOn(!oldState); | 345 | mAlarmProgramButton->setOn(!oldState); |
341 | mAlarmSoundButton->setOn(oldState); | 346 | mAlarmSoundButton->setOn(oldState); |
342 | } | 347 | } |
343 | 348 | ||
344 | if (mAlarmProgramButton->isOn()) | 349 | if (mAlarmProgramButton->isOn()) |
345 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 350 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
346 | if ( mAlarmSoundButton->isOn()) | 351 | if ( mAlarmSoundButton->isOn()) |
347 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 352 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
348 | 353 | ||
349 | } | 354 | } |
350 | 355 | ||
351 | 356 | ||
352 | QString KOEditorGeneral::getFittingPath( const QString s ) | 357 | QString KOEditorGeneral::getFittingPath( const QString s ) |
353 | { | 358 | { |
354 | int maxlen = 50; | 359 | int maxlen = 50; |
355 | if ( QApplication::desktop()->width() < 640 ) { | 360 | if ( QApplication::desktop()->width() < 640 ) { |
356 | if ( QApplication::desktop()->width() < 320 ) | 361 | if ( QApplication::desktop()->width() < 320 ) |
357 | maxlen = 22; | 362 | maxlen = 22; |
358 | else | 363 | else |
359 | maxlen = 35; | 364 | maxlen = 35; |
360 | } | 365 | } |
361 | if ( s.length() > maxlen ) { | 366 | if ( s.length() > maxlen ) { |
362 | return "..."+s.right(maxlen -3); | 367 | return "..."+s.right(maxlen -3); |
363 | } | 368 | } |
364 | return s; | 369 | return s; |
365 | } | 370 | } |
366 | 371 | ||
367 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 372 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
368 | { | 373 | { |
369 | if ( enable ) { | 374 | if ( enable ) { |
370 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 375 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
371 | mAlarmSoundButton->setOn( true ); | 376 | mAlarmSoundButton->setOn( true ); |
372 | if ( mAlarmSound.isEmpty() ) | 377 | if ( mAlarmSound.isEmpty() ) |
373 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 378 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
374 | else { | 379 | else { |
375 | if ( ! QFile::exists( mAlarmSound ) ) | 380 | if ( ! QFile::exists( mAlarmSound ) ) |
376 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 381 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
377 | } | 382 | } |
378 | } | 383 | } |
379 | } | 384 | } |
380 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); | 385 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); |
381 | mAlarmTimeEdit->setEnabled(enable); | 386 | mAlarmTimeEdit->setEnabled(enable); |
382 | mAlarmSoundButton->setEnabled(enable); | 387 | mAlarmSoundButton->setEnabled(enable); |
383 | mAlarmProgramButton->setEnabled(enable); | 388 | mAlarmProgramButton->setEnabled(enable); |
384 | mAlarmIncrCombo->setEnabled(enable); | 389 | mAlarmIncrCombo->setEnabled(enable); |
385 | } | 390 | } |
386 | 391 | ||
387 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 392 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
388 | { | 393 | { |
389 | enableAlarmEdit( !disable ); | 394 | enableAlarmEdit( !disable ); |
390 | } | 395 | } |
391 | 396 | ||
392 | void KOEditorGeneral::enableAlarm( bool enable ) | 397 | void KOEditorGeneral::enableAlarm( bool enable ) |
393 | { | 398 | { |
394 | enableAlarmEdit( enable ); | 399 | enableAlarmEdit( enable ); |
395 | } | 400 | } |
396 | 401 | ||
397 | void KOEditorGeneral::alarmDisable(bool disable) | 402 | void KOEditorGeneral::alarmDisable(bool disable) |
398 | { | 403 | { |
399 | if (!disable) { | 404 | if (!disable) { |
400 | //mAlarmBell->setEnabled(true); | 405 | //mAlarmBell->setEnabled(true); |
401 | mAlarmButton->setEnabled(true); | 406 | mAlarmButton->setEnabled(true); |
402 | } else { | 407 | } else { |
403 | //mAlarmBell->setEnabled(false); | 408 | //mAlarmBell->setEnabled(false); |
404 | mAlarmButton->setEnabled(false); | 409 | mAlarmButton->setEnabled(false); |
405 | mAlarmButton->setChecked(false); | 410 | mAlarmButton->setChecked(false); |
406 | mAlarmTimeEdit->setEnabled(false); | 411 | mAlarmTimeEdit->setEnabled(false); |
407 | mAlarmSoundButton->setEnabled(false); | 412 | mAlarmSoundButton->setEnabled(false); |
408 | mAlarmProgramButton->setEnabled(false); | 413 | mAlarmProgramButton->setEnabled(false); |
409 | mAlarmIncrCombo->setEnabled(false); | 414 | mAlarmIncrCombo->setEnabled(false); |
410 | } | 415 | } |
411 | } | 416 | } |
412 | 417 | ||
413 | void KOEditorGeneral::setCategories(const QString &str) | 418 | void KOEditorGeneral::setCategories(const QString &str) |
414 | { | 419 | { |
415 | QString tt = str; | 420 | QString tt = str; |
416 | QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); | 421 | QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); |
417 | mCategoriesLabel->setText(str); | 422 | mCategoriesLabel->setText(str); |
418 | } | 423 | } |
419 | 424 | ||
420 | void KOEditorGeneral::setDefaults(bool allDay) | 425 | void KOEditorGeneral::setDefaults(bool allDay) |
421 | { | 426 | { |
422 | #if 0 | 427 | #if 0 |
423 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 428 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
424 | #endif | 429 | #endif |
425 | 430 | ||
426 | mAlarmMessage = i18n("Edit new item"); | 431 | mAlarmMessage = i18n("Edit new item"); |
427 | enableAlarmEdit( !allDay ); | 432 | enableAlarmEdit( !allDay ); |
428 | 433 | ||
429 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 434 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
430 | int alarmTime; | 435 | int alarmTime; |
431 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 436 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
432 | int index = KOPrefs::instance()->mAlarmTime; | 437 | int index = KOPrefs::instance()->mAlarmTime; |
433 | if (index < 0 || index > 7) { | 438 | if (index < 0 || index > 7) { |
434 | alarmTime = 15; | 439 | alarmTime = 15; |
435 | } else { | 440 | } else { |
436 | alarmTime = a[index]; | 441 | alarmTime = a[index]; |
437 | } | 442 | } |
438 | mAlarmButton ->setChecked( false ); | 443 | mAlarmButton ->setChecked( false ); |
439 | mAlarmTimeEdit->setValue(alarmTime); | 444 | mAlarmTimeEdit->setValue(alarmTime); |
440 | mAlarmIncrCombo->setCurrentItem(0); | 445 | mAlarmIncrCombo->setCurrentItem(0); |
441 | enableAlarmEdit( false ); | 446 | enableAlarmEdit( false ); |
442 | //alarmDisable (false); | 447 | //alarmDisable (false); |
443 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 448 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
444 | mCancelBox->setChecked( false ); | 449 | mCancelBox->setChecked( false ); |
445 | mSummaryEdit->setEditText(""); | 450 | mSummaryEdit->setEditText(""); |
446 | mLocationEdit->setEditText(""); | 451 | mLocationEdit->setEditText(""); |
447 | mDescriptionEdit->setText(""); | 452 | mDescriptionEdit->setText(""); |
448 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 453 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
449 | setCategories(""); | 454 | setCategories(""); |
450 | fillCalCombo(); | 455 | fillCalCombo(); |
451 | } | 456 | } |
452 | void KOEditorGeneral::setSecrecy( int num ) | 457 | void KOEditorGeneral::setSecrecy( int num ) |
453 | { | 458 | { |
454 | mSecrecyCombo->setCurrentItem(num); | 459 | mSecrecyCombo->setCurrentItem(num); |
455 | } | 460 | } |
456 | void KOEditorGeneral::fillCalCombo( int setToID ) | 461 | void KOEditorGeneral::fillCalCombo( int setToID ) |
457 | { | 462 | { |
458 | mCalendarBox->clear(); | 463 | mCalendarBox->clear(); |
459 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 464 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
460 | int std = 0; | 465 | int std = 0; |
461 | int count = 0; | 466 | int count = 0; |
462 | while ( kkf ) { | 467 | while ( kkf ) { |
463 | if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) { | 468 | if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) { |
464 | if ( setToID ) { | 469 | if ( setToID ) { |
465 | if ( kkf->mCalNumber == setToID ) | 470 | if ( kkf->mCalNumber == setToID ) |
466 | std = count; | 471 | std = count; |
467 | } else { | 472 | } else { |
468 | if ( kkf->isStandard ) { | 473 | if ( kkf->isStandard ) { |
469 | std = count; | 474 | std = count; |
470 | } | 475 | } |
471 | } | 476 | } |
472 | ++count; | 477 | ++count; |
473 | mCalendarBox->insertItem( kkf->mName ); | 478 | mCalendarBox->insertItem( kkf->mName ); |
474 | } | 479 | } |
475 | kkf = KOPrefs::instance()->mCalendars.next(); | 480 | kkf = KOPrefs::instance()->mCalendars.next(); |
476 | } | 481 | } |
477 | mCalendarBox->setCurrentItem( std ); | 482 | mCalendarBox->setCurrentItem( std ); |
478 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) | 483 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) |
479 | mCalendarBox->hide(); | 484 | mCalendarBox->hide(); |
480 | else | 485 | else |
481 | mCalendarBox->show(); | 486 | mCalendarBox->show(); |
482 | 487 | ||
483 | } | 488 | } |
484 | int KOEditorGeneral::getCalendarID() | 489 | int KOEditorGeneral::getCalendarID() |
485 | { | 490 | { |
486 | return KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); | 491 | return KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); |
487 | } | 492 | } |
488 | 493 | ||
489 | void KOEditorGeneral::readIncidence(Incidence *event) | 494 | void KOEditorGeneral::readIncidence(Incidence *event) |
490 | { | 495 | { |
491 | fillCalCombo( event->calID() ); | 496 | fillCalCombo( event->calID() ); |
492 | mAlarmMessage = event->summary(); | 497 | mAlarmMessage = event->summary(); |
493 | if ( ! event->location().isEmpty() ) | 498 | if ( ! event->location().isEmpty() ) |
494 | mAlarmMessage += " ("+event->location()+")"; | 499 | mAlarmMessage += " ("+event->location()+")"; |
495 | mAlarmIncrCombo->setCurrentItem(0); | 500 | mAlarmIncrCombo->setCurrentItem(0); |
496 | mSummaryEdit->setEditText(event->summary()); | 501 | mSummaryEdit->setEditText(event->summary()); |
497 | mLocationEdit->setEditText(event->location()); | 502 | mLocationEdit->setEditText(event->location()); |
498 | mDescriptionEdit->setText(event->description()); | 503 | mDescriptionEdit->setText(event->description()); |
499 | 504 | ||
500 | #if 0 | 505 | #if 0 |
501 | // organizer information | 506 | // organizer information |
502 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); | 507 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); |
503 | #endif | 508 | #endif |
504 | 509 | ||
505 | enableAlarmEdit( event->isAlarmEnabled() ); | 510 | enableAlarmEdit( event->isAlarmEnabled() ); |
506 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); | 511 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); |
507 | if(!event->isAlarmEnabled()) { | 512 | if(!event->isAlarmEnabled()) { |
508 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 513 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
509 | int alarmTime; | 514 | int alarmTime; |
510 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 515 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
511 | int index = KOPrefs::instance()->mAlarmTime; | 516 | int index = KOPrefs::instance()->mAlarmTime; |
512 | if (index < 0 || index > 7) { | 517 | if (index < 0 || index > 7) { |
513 | alarmTime = 15; | 518 | alarmTime = 15; |
514 | } else { | 519 | } else { |
515 | alarmTime = a[index]; | 520 | alarmTime = a[index]; |
516 | } | 521 | } |
517 | mAlarmTimeEdit->setValue(alarmTime); | 522 | mAlarmTimeEdit->setValue(alarmTime); |
518 | } | 523 | } |
519 | mAlarmButton->setChecked( event->isAlarmEnabled() ); | 524 | mAlarmButton->setChecked( event->isAlarmEnabled() ); |
520 | mSecrecyCombo->setCurrentItem(event->secrecy()); | 525 | mSecrecyCombo->setCurrentItem(event->secrecy()); |
521 | mCancelBox->setChecked( event->cancelled() ); | 526 | mCancelBox->setChecked( event->cancelled() ); |
522 | mAlarmProgramButton->setOn(false); | 527 | mAlarmProgramButton->setOn(false); |
523 | mAlarmSoundButton->setOn(false); | 528 | mAlarmSoundButton->setOn(false); |
524 | 529 | ||
525 | // set up alarm stuff | 530 | // set up alarm stuff |
526 | QPtrList<Alarm> alarms = event->alarms(); | 531 | QPtrList<Alarm> alarms = event->alarms(); |
527 | Alarm* alarm; | 532 | Alarm* alarm; |
528 | mAlarmIncrCombo->setCurrentItem(0); | 533 | mAlarmIncrCombo->setCurrentItem(0); |
529 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 534 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
530 | int offset; | 535 | int offset; |
531 | if ( alarm->hasTime() ) { | 536 | if ( alarm->hasTime() ) { |
532 | QDateTime t = alarm->time(); | 537 | QDateTime t = alarm->time(); |
533 | offset = event->dtStart().secsTo( t ); | 538 | offset = event->dtStart().secsTo( t ); |
534 | } else { | 539 | } else { |
535 | offset = alarm->startOffset().asSeconds(); | 540 | offset = alarm->startOffset().asSeconds(); |
536 | } | 541 | } |
537 | if ( offset != 0 ) { | 542 | if ( offset != 0 ) { |
538 | offset = offset / -60; // make minutes | 543 | offset = offset / -60; // make minutes |
539 | if (offset % 60 == 0) { // divides evenly into hours? | 544 | if (offset % 60 == 0) { // divides evenly into hours? |
540 | offset = offset / 60; | 545 | offset = offset / 60; |
541 | mAlarmIncrCombo->setCurrentItem(1); | 546 | mAlarmIncrCombo->setCurrentItem(1); |
542 | if (offset % 24 == 0) { // divides evenly into days? | 547 | if (offset % 24 == 0) { // divides evenly into days? |
543 | offset = offset / 24; | 548 | offset = offset / 24; |
544 | mAlarmIncrCombo->setCurrentItem(2); | 549 | mAlarmIncrCombo->setCurrentItem(2); |
545 | } | 550 | } |
546 | } | 551 | } |
547 | } | 552 | } |
548 | mAlarmTimeEdit->setValue( offset ); | 553 | mAlarmTimeEdit->setValue( offset ); |
549 | if (alarm->type() == Alarm::Procedure) { | 554 | if (alarm->type() == Alarm::Procedure) { |
550 | 555 | ||
551 | mAlarmProgram = alarm->programFile(); | 556 | mAlarmProgram = alarm->programFile(); |
552 | mAlarmProgramButton->setOn(true); | 557 | mAlarmProgramButton->setOn(true); |
553 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); | 558 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); |
554 | QToolTip::add(mAlarmProgramButton, dispStr); | 559 | QToolTip::add(mAlarmProgramButton, dispStr); |
555 | } | 560 | } |
556 | else if (alarm->type() == Alarm::Audio) { | 561 | else if (alarm->type() == Alarm::Audio) { |
557 | mAlarmSound = alarm->audioFile(); | 562 | mAlarmSound = alarm->audioFile(); |
558 | if ( ! QFile::exists( mAlarmSound ) ) | 563 | if ( ! QFile::exists( mAlarmSound ) ) |
559 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 564 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
560 | mAlarmSoundButton->setOn(true); | 565 | mAlarmSoundButton->setOn(true); |
561 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); | 566 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); |
562 | QToolTip::add(mAlarmSoundButton, dispStr); | 567 | QToolTip::add(mAlarmSoundButton, dispStr); |
563 | } | 568 | } |
564 | mAlarmButton->setChecked(alarm->enabled()); | 569 | mAlarmButton->setChecked(alarm->enabled()); |
565 | enableAlarmEdit( alarm->enabled() ); | 570 | enableAlarmEdit( alarm->enabled() ); |
566 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); | 571 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); |
567 | // TODO: Deal with multiple alarms | 572 | // TODO: Deal with multiple alarms |
568 | break; // For now, stop after the first alarm | 573 | break; // For now, stop after the first alarm |
569 | } | 574 | } |
570 | 575 | ||
571 | setCategories(event->categoriesStr()); | 576 | setCategories(event->categoriesStr()); |
572 | } | 577 | } |
573 | 578 | ||
574 | void KOEditorGeneral::writeIncidence(Incidence *event) | 579 | void KOEditorGeneral::writeIncidence(Incidence *event) |
575 | { | 580 | { |
576 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; | 581 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; |
577 | mLocationEdit->save(KOLocationBox::LOCATION); | 582 | mLocationEdit->save(KOLocationBox::LOCATION); |
578 | event->setSummary(mSummaryEdit->currentText()); | 583 | event->setSummary(mSummaryEdit->currentText()); |
579 | event->setLocation(mLocationEdit->currentText()); | 584 | event->setLocation(mLocationEdit->currentText()); |
580 | event->setDescription(mDescriptionEdit->text()); | 585 | event->setDescription(mDescriptionEdit->text()); |
581 | event->setCategories(mCategoriesLabel->text()); | 586 | event->setCategories(mCategoriesLabel->text()); |
582 | event->setSecrecy(mSecrecyCombo->currentItem()); | 587 | event->setSecrecy(mSecrecyCombo->currentItem()); |
583 | event->setCancelled(mCancelBox->isChecked() );; | 588 | event->setCancelled(mCancelBox->isChecked() );; |
584 | // alarm stuff | 589 | // alarm stuff |
585 | if (mAlarmButton->isChecked()) { | 590 | if (mAlarmButton->isChecked()) { |
586 | if (event->alarms().count() == 0) | 591 | if (event->alarms().count() == 0) |
587 | event->newAlarm(); | 592 | event->newAlarm(); |
588 | QPtrList<Alarm> alarms = event->alarms(); | 593 | QPtrList<Alarm> alarms = event->alarms(); |
589 | Alarm *alarm; | 594 | Alarm *alarm; |
590 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 595 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
591 | alarm->setEnabled(true); | 596 | alarm->setEnabled(true); |
592 | int j = mAlarmTimeEdit->value()* -60; | 597 | int j = mAlarmTimeEdit->value()* -60; |
593 | if (mAlarmIncrCombo->currentItem() == 1) | 598 | if (mAlarmIncrCombo->currentItem() == 1) |
594 | j = j * 60; | 599 | j = j * 60; |
595 | else if (mAlarmIncrCombo->currentItem() == 2) | 600 | else if (mAlarmIncrCombo->currentItem() == 2) |
596 | j = j * (60 * 24); | 601 | j = j * (60 * 24); |
597 | alarm->setStartOffset( j ); | 602 | alarm->setStartOffset( j ); |
598 | 603 | ||
599 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { | 604 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { |
600 | alarm->setProcedureAlarm(mAlarmProgram); | 605 | alarm->setProcedureAlarm(mAlarmProgram); |
601 | } | 606 | } |
602 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) | 607 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) |
603 | alarm->setAudioAlarm(mAlarmSound); | 608 | alarm->setAudioAlarm(mAlarmSound); |
604 | else | 609 | else |
605 | alarm->setType(Alarm::Invalid); | 610 | alarm->setType(Alarm::Invalid); |
606 | //alarm->setAudioAlarm("default"); | 611 | //alarm->setAudioAlarm("default"); |
607 | // TODO: Deal with multiple alarms | 612 | // TODO: Deal with multiple alarms |
608 | break; // For now, stop after the first alarm | 613 | break; // For now, stop after the first alarm |
609 | } | 614 | } |
610 | } else { | 615 | } else { |
611 | Alarm* alarm = event->alarms().first(); | 616 | Alarm* alarm = event->alarms().first(); |
612 | if ( alarm ) { | 617 | if ( alarm ) { |
613 | alarm->setEnabled(false); | 618 | alarm->setEnabled(false); |
614 | alarm->setType(Alarm::Invalid); | 619 | alarm->setType(Alarm::Invalid); |
615 | } | 620 | } |
616 | } | 621 | } |
617 | event->setCalID( getCalendarID() ); | 622 | event->setCalID( getCalendarID() ); |
618 | } | 623 | } |