Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index 9df76e7..0045b7f 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -43,385 +43,385 @@ | |||
43 | 43 | ||
44 | #include <libkcal/todo.h> | 44 | #include <libkcal/todo.h> |
45 | #include <libkcal/event.h> | 45 | #include <libkcal/event.h> |
46 | #include <libkdepim/categoryselectdialog.h> | 46 | #include <libkdepim/categoryselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | 47 | #include <libkdepim/kdateedit.h> |
48 | 48 | ||
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #include "koglobals.h" | 50 | #include "koglobals.h" |
51 | 51 | ||
52 | #include "koeditorgeneral.h" | 52 | #include "koeditorgeneral.h" |
53 | #include "kolocationbox.h" | 53 | #include "kolocationbox.h" |
54 | #ifndef DESKTOP_VERSION | 54 | #ifndef DESKTOP_VERSION |
55 | #include <qpe/qpeapplication.h> | 55 | #include <qpe/qpeapplication.h> |
56 | #else | 56 | #else |
57 | #include <qapplication.h> | 57 | #include <qapplication.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : | 60 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : |
61 | QObject( parent, name) | 61 | QObject( parent, name) |
62 | { | 62 | { |
63 | mNextFocus = 0; | 63 | mNextFocus = 0; |
64 | } | 64 | } |
65 | 65 | ||
66 | KOEditorGeneral::~KOEditorGeneral() | 66 | KOEditorGeneral::~KOEditorGeneral() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 70 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
71 | { | 71 | { |
72 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 72 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
73 | 73 | ||
74 | #if 0 | 74 | #if 0 |
75 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 75 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
76 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 76 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 79 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
80 | headerLayout->addWidget(summaryLabel,1,0); | 80 | headerLayout->addWidget(summaryLabel,1,0); |
81 | 81 | ||
82 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); | 82 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); |
83 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 83 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
84 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 84 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
85 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 85 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
86 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 86 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
87 | if ( QApplication::desktop()->width() > 320 ) | 87 | if ( QApplication::desktop()->width() > 320 ) |
88 | mSummaryEdit->setMaximumHeight( hei +6 ); | 88 | mSummaryEdit->setMaximumHeight( hei +6 ); |
89 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 89 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); |
90 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } | 90 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
91 | // mSummaryEdit = new QLineEdit(parent); | 91 | // mSummaryEdit = new QLineEdit(parent); |
92 | headerLayout->addWidget(mSummaryEdit,1,1); | 92 | headerLayout->addWidget(mSummaryEdit,1,1); |
93 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 93 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
94 | 94 | ||
95 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 95 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
96 | headerLayout->addWidget(locationLabel,2,0); | 96 | headerLayout->addWidget(locationLabel,2,0); |
97 | 97 | ||
98 | mLocationEdit = new KOLocationBox(TRUE,parent,10); | 98 | mLocationEdit = new KOLocationBox(TRUE,parent,10); |
99 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 99 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
100 | if ( QApplication::desktop()->width() > 320 ) | 100 | if ( QApplication::desktop()->width() > 320 ) |
101 | mLocationEdit->setMaximumHeight( hei + 6); | 101 | mLocationEdit->setMaximumHeight( hei + 6); |
102 | 102 | ||
103 | // mLocationEdit = new QLineEdit(parent); | 103 | // mLocationEdit = new QLineEdit(parent); |
104 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 104 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
105 | headerLayout->addWidget(mLocationEdit,2,1); | 105 | headerLayout->addWidget(mLocationEdit,2,1); |
106 | headerLayout->setColStretch( 1, 10); | 106 | headerLayout->setColStretch( 1, 10); |
107 | } | 107 | } |
108 | void KOEditorGeneral::setFocusOn( int i ) | 108 | void KOEditorGeneral::setFocusOn( int i ) |
109 | { | 109 | { |
110 | mNextFocus = i; | 110 | mNextFocus = i; |
111 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); | 111 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); |
112 | } | 112 | } |
113 | void KOEditorGeneral::slotSetFocusOn() | 113 | void KOEditorGeneral::slotSetFocusOn() |
114 | { | 114 | { |
115 | mNextFocus; | 115 | mNextFocus; |
116 | if ( mNextFocus == 1 ) { | 116 | if ( mNextFocus == 1 ) { |
117 | mDescriptionEdit->setFocus(); | 117 | mDescriptionEdit->setFocus(); |
118 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 118 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
119 | } | 119 | } |
120 | if ( mNextFocus == 2 ) { | 120 | if ( mNextFocus == 2 ) { |
121 | mSummaryEdit->setFocus(); | 121 | mSummaryEdit->setFocus(); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | void KOEditorGeneral::editCategories() | 124 | void KOEditorGeneral::editCategories() |
125 | { | 125 | { |
126 | // qDebug("KOEditorGeneral::editCategories() "); | 126 | // qDebug("KOEditorGeneral::editCategories() "); |
127 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 127 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
128 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 128 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
129 | //KOGlobals::fitDialogToScreen( csd ); | 129 | //KOGlobals::fitDialogToScreen( csd ); |
130 | csd->setColorEnabled(); | 130 | csd->setColorEnabled(); |
131 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 131 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
132 | csd->exec(); | 132 | csd->exec(); |
133 | delete csd; | 133 | delete csd; |
134 | } | 134 | } |
135 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 135 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
136 | { | 136 | { |
137 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 137 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
138 | 138 | ||
139 | mCategoriesButton = new QPushButton(parent); | 139 | mCategoriesButton = new QPushButton(parent); |
140 | mCategoriesButton->setText(i18n("Categories...")); | 140 | mCategoriesButton->setText(i18n("Categories...")); |
141 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 141 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
142 | categoriesLayout->addWidget(mCategoriesButton); | 142 | categoriesLayout->addWidget(mCategoriesButton); |
143 | 143 | ||
144 | mCategoriesLabel = new QLabel(parent); | 144 | mCategoriesLabel = new QLabel(parent); |
145 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 145 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
146 | categoriesLayout->addWidget(mCategoriesLabel,1); | 146 | categoriesLayout->addWidget(mCategoriesLabel,1); |
147 | } | 147 | } |
148 | 148 | ||
149 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 149 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
150 | { | 150 | { |
151 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 151 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
152 | 152 | ||
153 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 153 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
154 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 154 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
155 | secrecyLayout->addWidget(mCancelBox); | 155 | secrecyLayout->addWidget(mCancelBox); |
156 | secrecyLayout->addWidget(secrecyLabel); | 156 | secrecyLayout->addWidget(secrecyLabel); |
157 | 157 | ||
158 | mSecrecyCombo = new QComboBox(parent); | 158 | mSecrecyCombo = new QComboBox(parent); |
159 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 159 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
160 | secrecyLayout->addWidget(mSecrecyCombo); | 160 | secrecyLayout->addWidget(mSecrecyCombo); |
161 | } | 161 | } |
162 | 162 | ||
163 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 163 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
164 | { | 164 | { |
165 | mDescriptionEdit = new KTextEdit(parent); | 165 | mDescriptionEdit = new KTextEdit(parent); |
166 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 166 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
167 | mDescriptionEdit->append(""); | 167 | mDescriptionEdit->append(""); |
168 | mDescriptionEdit->setReadOnly(false); | 168 | mDescriptionEdit->setReadOnly(false); |
169 | mDescriptionEdit->setOverwriteMode(false); | 169 | mDescriptionEdit->setOverwriteMode(false); |
170 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 170 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
171 | topLayout->addWidget(mDescriptionEdit); | 171 | topLayout->addWidget(mDescriptionEdit); |
172 | #ifndef DESKTOP_VERSION | 172 | #ifndef DESKTOP_VERSION |
173 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 173 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
174 | #endif | 174 | #endif |
175 | 175 | ||
176 | } | 176 | } |
177 | 177 | ||
178 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 178 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
179 | { | 179 | { |
180 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 180 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
181 | 181 | ||
182 | //mAlarmBell = new QLabel(parent); | 182 | //mAlarmBell = new QLabel(parent); |
183 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 183 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
184 | //alarmLayout->addWidget(mAlarmBell); | 184 | //alarmLayout->addWidget(mAlarmBell); |
185 | if ( QApplication::desktop()->width() < 320 ) | 185 | if ( QApplication::desktop()->width() < 320 ) |
186 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 186 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
187 | else | 187 | else |
188 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 188 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
189 | 189 | ||
190 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 190 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
191 | alarmLayout->addWidget(mAlarmButton); | 191 | alarmLayout->addWidget(mAlarmButton); |
192 | 192 | ||
193 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 193 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
194 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); | 194 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); |
195 | alarmLayout->addWidget(mAlarmTimeEdit); | 195 | alarmLayout->addWidget(mAlarmTimeEdit); |
196 | mAlarmIncrCombo = new QComboBox(false, parent); | 196 | mAlarmIncrCombo = new QComboBox(false, parent); |
197 | if ( QApplication::desktop()->width() < 320 ) { | 197 | if ( QApplication::desktop()->width() < 320 ) { |
198 | mAlarmIncrCombo->insertItem(i18n("min")); | 198 | mAlarmIncrCombo->insertItem(i18n("min")); |
199 | mAlarmIncrCombo->insertItem(i18n("hou")); | 199 | mAlarmIncrCombo->insertItem(i18n("hou")); |
200 | mAlarmIncrCombo->insertItem(i18n("day")); | 200 | mAlarmIncrCombo->insertItem(i18n("day")); |
201 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 201 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
202 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 202 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
203 | } else { | 203 | } else { |
204 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 204 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
205 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 205 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
206 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 206 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
207 | } | 207 | } |
208 | 208 | ||
209 | // mAlarmIncrCombo->setMinimumHeight(20); | 209 | // mAlarmIncrCombo->setMinimumHeight(20); |
210 | alarmLayout->addWidget(mAlarmIncrCombo); | 210 | alarmLayout->addWidget(mAlarmIncrCombo); |
211 | mAlarmSoundButton = new QPushButton(parent); | 211 | mAlarmSoundButton = new QPushButton(parent); |
212 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 212 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
213 | mAlarmSoundButton->setToggleButton(true); | 213 | mAlarmSoundButton->setToggleButton(true); |
214 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 214 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
215 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 215 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
216 | alarmLayout->addWidget(mAlarmSoundButton); | 216 | alarmLayout->addWidget(mAlarmSoundButton); |
217 | 217 | ||
218 | mAlarmProgramButton = new QPushButton(parent); | 218 | mAlarmProgramButton = new QPushButton(parent); |
219 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 219 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
220 | mAlarmProgramButton->setToggleButton(true); | 220 | mAlarmProgramButton->setToggleButton(true); |
221 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 221 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
222 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 222 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
223 | alarmLayout->addWidget(mAlarmProgramButton); | 223 | alarmLayout->addWidget(mAlarmProgramButton); |
224 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 224 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
225 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 225 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
226 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 226 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
227 | // mAlarmSoundButton->hide(); | 227 | // mAlarmSoundButton->hide(); |
228 | // mAlarmProgramButton->hide(); | 228 | // mAlarmProgramButton->hide(); |
229 | // } | 229 | // } |
230 | } | 230 | } |
231 | 231 | ||
232 | void KOEditorGeneral::pickAlarmSound() | 232 | void KOEditorGeneral::pickAlarmSound() |
233 | { | 233 | { |
234 | 234 | ||
235 | qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); | 235 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); |
236 | 236 | ||
237 | bool oldState = mAlarmSoundButton->isOn(); | 237 | bool oldState = mAlarmSoundButton->isOn(); |
238 | 238 | ||
239 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 239 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
240 | i18n("*.wav|Wav Files"), 0)); | 240 | i18n("*.wav|Wav Files"), 0)); |
241 | if (!fileName.isEmpty()) { | 241 | if (!fileName.isEmpty()) { |
242 | mAlarmSound = fileName; | 242 | mAlarmSound = fileName; |
243 | QToolTip::remove(mAlarmSoundButton); | 243 | QToolTip::remove(mAlarmSoundButton); |
244 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 244 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
245 | QToolTip::add(mAlarmSoundButton, dispStr); | 245 | QToolTip::add(mAlarmSoundButton, dispStr); |
246 | mAlarmProgramButton->setOn(false); | 246 | mAlarmProgramButton->setOn(false); |
247 | mAlarmSoundButton->setOn(true); | 247 | mAlarmSoundButton->setOn(true); |
248 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 248 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
249 | } else { | 249 | } else { |
250 | mAlarmProgramButton->setOn(oldState); | 250 | mAlarmProgramButton->setOn(oldState); |
251 | mAlarmSoundButton->setOn(!oldState); | 251 | mAlarmSoundButton->setOn(!oldState); |
252 | 252 | ||
253 | 253 | ||
254 | } | 254 | } |
255 | 255 | ||
256 | if (mAlarmProgramButton->isOn()) | 256 | if (mAlarmProgramButton->isOn()) |
257 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 257 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
258 | if ( mAlarmSoundButton->isOn()) | 258 | if ( mAlarmSoundButton->isOn()) |
259 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 259 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
260 | 260 | ||
261 | } | 261 | } |
262 | 262 | ||
263 | void KOEditorGeneral::pickAlarmProgram() | 263 | void KOEditorGeneral::pickAlarmProgram() |
264 | { | 264 | { |
265 | bool oldState = mAlarmProgramButton->isOn(); | 265 | bool oldState = mAlarmProgramButton->isOn(); |
266 | 266 | ||
267 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); | 267 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); |
268 | if (!fileName.isEmpty()) { | 268 | if (!fileName.isEmpty()) { |
269 | mAlarmProgram = fileName; | 269 | mAlarmProgram = fileName; |
270 | QToolTip::remove(mAlarmProgramButton); | 270 | QToolTip::remove(mAlarmProgramButton); |
271 | QString dispStr = i18n("Running '%1'").arg(fileName); | 271 | QString dispStr = i18n("Running '%1'").arg(fileName); |
272 | QToolTip::add(mAlarmProgramButton, dispStr); | 272 | QToolTip::add(mAlarmProgramButton, dispStr); |
273 | mAlarmSoundButton->setOn(false); | 273 | mAlarmSoundButton->setOn(false); |
274 | mAlarmProgramButton->setOn(true); | 274 | mAlarmProgramButton->setOn(true); |
275 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 275 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
276 | } else { | 276 | } else { |
277 | mAlarmProgramButton->setOn(!oldState); | 277 | mAlarmProgramButton->setOn(!oldState); |
278 | mAlarmSoundButton->setOn(oldState); | 278 | mAlarmSoundButton->setOn(oldState); |
279 | } | 279 | } |
280 | 280 | ||
281 | if (mAlarmProgramButton->isOn()) | 281 | if (mAlarmProgramButton->isOn()) |
282 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 282 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
283 | if ( mAlarmSoundButton->isOn()) | 283 | if ( mAlarmSoundButton->isOn()) |
284 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 284 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
285 | 285 | ||
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | QString KOEditorGeneral::getFittingPath( const QString s ) | 289 | QString KOEditorGeneral::getFittingPath( const QString s ) |
290 | { | 290 | { |
291 | int maxlen = 50; | 291 | int maxlen = 50; |
292 | if ( QApplication::desktop()->width() < 640 ) { | 292 | if ( QApplication::desktop()->width() < 640 ) { |
293 | if ( QApplication::desktop()->width() < 320 ) | 293 | if ( QApplication::desktop()->width() < 320 ) |
294 | maxlen = 22; | 294 | maxlen = 22; |
295 | else | 295 | else |
296 | maxlen = 35; | 296 | maxlen = 35; |
297 | } | 297 | } |
298 | if ( s.length() > maxlen ) { | 298 | if ( s.length() > maxlen ) { |
299 | return "..."+s.right(maxlen -3); | 299 | return "..."+s.right(maxlen -3); |
300 | } | 300 | } |
301 | return s; | 301 | return s; |
302 | } | 302 | } |
303 | 303 | ||
304 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 304 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
305 | { | 305 | { |
306 | if ( enable ) { | 306 | if ( enable ) { |
307 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 307 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
308 | mAlarmSoundButton->setOn( true ); | 308 | mAlarmSoundButton->setOn( true ); |
309 | if ( mAlarmSound.isEmpty() ) | 309 | if ( mAlarmSound.isEmpty() ) |
310 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 310 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
311 | else { | 311 | else { |
312 | if ( ! QFile::exists( mAlarmSound ) ) | 312 | if ( ! QFile::exists( mAlarmSound ) ) |
313 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 313 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
314 | } | 314 | } |
315 | } | 315 | } |
316 | } | 316 | } |
317 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); | 317 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); |
318 | mAlarmTimeEdit->setEnabled(enable); | 318 | mAlarmTimeEdit->setEnabled(enable); |
319 | mAlarmSoundButton->setEnabled(enable); | 319 | mAlarmSoundButton->setEnabled(enable); |
320 | mAlarmProgramButton->setEnabled(enable); | 320 | mAlarmProgramButton->setEnabled(enable); |
321 | mAlarmIncrCombo->setEnabled(enable); | 321 | mAlarmIncrCombo->setEnabled(enable); |
322 | } | 322 | } |
323 | 323 | ||
324 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 324 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
325 | { | 325 | { |
326 | enableAlarmEdit( !disable ); | 326 | enableAlarmEdit( !disable ); |
327 | } | 327 | } |
328 | 328 | ||
329 | void KOEditorGeneral::enableAlarm( bool enable ) | 329 | void KOEditorGeneral::enableAlarm( bool enable ) |
330 | { | 330 | { |
331 | enableAlarmEdit( enable ); | 331 | enableAlarmEdit( enable ); |
332 | } | 332 | } |
333 | 333 | ||
334 | void KOEditorGeneral::alarmDisable(bool disable) | 334 | void KOEditorGeneral::alarmDisable(bool disable) |
335 | { | 335 | { |
336 | if (!disable) { | 336 | if (!disable) { |
337 | //mAlarmBell->setEnabled(true); | 337 | //mAlarmBell->setEnabled(true); |
338 | mAlarmButton->setEnabled(true); | 338 | mAlarmButton->setEnabled(true); |
339 | } else { | 339 | } else { |
340 | //mAlarmBell->setEnabled(false); | 340 | //mAlarmBell->setEnabled(false); |
341 | mAlarmButton->setEnabled(false); | 341 | mAlarmButton->setEnabled(false); |
342 | mAlarmButton->setChecked(false); | 342 | mAlarmButton->setChecked(false); |
343 | mAlarmTimeEdit->setEnabled(false); | 343 | mAlarmTimeEdit->setEnabled(false); |
344 | mAlarmSoundButton->setEnabled(false); | 344 | mAlarmSoundButton->setEnabled(false); |
345 | mAlarmProgramButton->setEnabled(false); | 345 | mAlarmProgramButton->setEnabled(false); |
346 | mAlarmIncrCombo->setEnabled(false); | 346 | mAlarmIncrCombo->setEnabled(false); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | void KOEditorGeneral::setCategories(const QString &str) | 350 | void KOEditorGeneral::setCategories(const QString &str) |
351 | { | 351 | { |
352 | mCategoriesLabel->setText(str); | 352 | mCategoriesLabel->setText(str); |
353 | } | 353 | } |
354 | 354 | ||
355 | void KOEditorGeneral::setDefaults(bool allDay) | 355 | void KOEditorGeneral::setDefaults(bool allDay) |
356 | { | 356 | { |
357 | #if 0 | 357 | #if 0 |
358 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 358 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
359 | #endif | 359 | #endif |
360 | 360 | ||
361 | mAlarmMessage = i18n("Edit new item"); | 361 | mAlarmMessage = i18n("Edit new item"); |
362 | enableAlarmEdit( !allDay ); | 362 | enableAlarmEdit( !allDay ); |
363 | 363 | ||
364 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 364 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
365 | int alarmTime; | 365 | int alarmTime; |
366 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 366 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
367 | int index = KOPrefs::instance()->mAlarmTime; | 367 | int index = KOPrefs::instance()->mAlarmTime; |
368 | if (index < 0 || index > 7) { | 368 | if (index < 0 || index > 7) { |
369 | alarmTime = 15; | 369 | alarmTime = 15; |
370 | } else { | 370 | } else { |
371 | alarmTime = a[index]; | 371 | alarmTime = a[index]; |
372 | } | 372 | } |
373 | mAlarmButton ->setChecked( false ); | 373 | mAlarmButton ->setChecked( false ); |
374 | mAlarmTimeEdit->setValue(alarmTime); | 374 | mAlarmTimeEdit->setValue(alarmTime); |
375 | mAlarmIncrCombo->setCurrentItem(0); | 375 | mAlarmIncrCombo->setCurrentItem(0); |
376 | enableAlarmEdit( false ); | 376 | enableAlarmEdit( false ); |
377 | //alarmDisable (false); | 377 | //alarmDisable (false); |
378 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 378 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
379 | mCancelBox->setChecked( false ); | 379 | mCancelBox->setChecked( false ); |
380 | mSummaryEdit->setEditText(""); | 380 | mSummaryEdit->setEditText(""); |
381 | mLocationEdit->setEditText(""); | 381 | mLocationEdit->setEditText(""); |
382 | mDescriptionEdit->setText(""); | 382 | mDescriptionEdit->setText(""); |
383 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 383 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
384 | setCategories(""); | 384 | setCategories(""); |
385 | } | 385 | } |
386 | void KOEditorGeneral::setSecrecy( int num ) | 386 | void KOEditorGeneral::setSecrecy( int num ) |
387 | { | 387 | { |
388 | mSecrecyCombo->setCurrentItem(num); | 388 | mSecrecyCombo->setCurrentItem(num); |
389 | } | 389 | } |
390 | void KOEditorGeneral::readIncidence(Incidence *event) | 390 | void KOEditorGeneral::readIncidence(Incidence *event) |
391 | { | 391 | { |
392 | 392 | ||
393 | mAlarmMessage = event->summary(); | 393 | mAlarmMessage = event->summary(); |
394 | if ( ! event->location().isEmpty() ) | 394 | if ( ! event->location().isEmpty() ) |
395 | mAlarmMessage += " ("+event->location()+")"; | 395 | mAlarmMessage += " ("+event->location()+")"; |
396 | mAlarmIncrCombo->setCurrentItem(0); | 396 | mAlarmIncrCombo->setCurrentItem(0); |
397 | mSummaryEdit->setEditText(event->summary()); | 397 | mSummaryEdit->setEditText(event->summary()); |
398 | mLocationEdit->setEditText(event->location()); | 398 | mLocationEdit->setEditText(event->location()); |
399 | mDescriptionEdit->setText(event->description()); | 399 | mDescriptionEdit->setText(event->description()); |
400 | 400 | ||
401 | #if 0 | 401 | #if 0 |
402 | // organizer information | 402 | // organizer information |
403 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); | 403 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); |
404 | #endif | 404 | #endif |
405 | 405 | ||
406 | enableAlarmEdit( event->isAlarmEnabled() ); | 406 | enableAlarmEdit( event->isAlarmEnabled() ); |
407 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); | 407 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); |
408 | if(!event->isAlarmEnabled()) { | 408 | if(!event->isAlarmEnabled()) { |
409 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 409 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
410 | int alarmTime; | 410 | int alarmTime; |
411 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 411 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
412 | int index = KOPrefs::instance()->mAlarmTime; | 412 | int index = KOPrefs::instance()->mAlarmTime; |
413 | if (index < 0 || index > 7) { | 413 | if (index < 0 || index > 7) { |
414 | alarmTime = 15; | 414 | alarmTime = 15; |
415 | } else { | 415 | } else { |
416 | alarmTime = a[index]; | 416 | alarmTime = a[index]; |
417 | } | 417 | } |
418 | mAlarmTimeEdit->setValue(alarmTime); | 418 | mAlarmTimeEdit->setValue(alarmTime); |
419 | } | 419 | } |
420 | mAlarmButton->setChecked( event->isAlarmEnabled() ); | 420 | mAlarmButton->setChecked( event->isAlarmEnabled() ); |
421 | mSecrecyCombo->setCurrentItem(event->secrecy()); | 421 | mSecrecyCombo->setCurrentItem(event->secrecy()); |
422 | mCancelBox->setChecked( event->cancelled() ); | 422 | mCancelBox->setChecked( event->cancelled() ); |
423 | mAlarmProgramButton->setOn(false); | 423 | mAlarmProgramButton->setOn(false); |
424 | mAlarmSoundButton->setOn(false); | 424 | mAlarmSoundButton->setOn(false); |
425 | 425 | ||
426 | // set up alarm stuff | 426 | // set up alarm stuff |
427 | QPtrList<Alarm> alarms = event->alarms(); | 427 | QPtrList<Alarm> alarms = event->alarms(); |