Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index abc80d4..f54660f 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -1,212 +1,217 @@ | |||
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 <qfile.h> | 32 | #include <qfile.h> |
33 | 33 | ||
34 | 34 | ||
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kfiledialog.h> | 40 | #include <kfiledialog.h> |
41 | #include <kstandarddirs.h> | 41 | #include <kstandarddirs.h> |
42 | 42 | ||
43 | #include <libkcal/todo.h> | 43 | #include <libkcal/todo.h> |
44 | #include <libkcal/event.h> | 44 | #include <libkcal/event.h> |
45 | #include <libkdepim/categoryselectdialog.h> | 45 | #include <libkdepim/categoryselectdialog.h> |
46 | #include <libkdepim/kdateedit.h> | 46 | #include <libkdepim/kdateedit.h> |
47 | 47 | ||
48 | #include "koprefs.h" | 48 | #include "koprefs.h" |
49 | #include "koglobals.h" | 49 | #include "koglobals.h" |
50 | 50 | ||
51 | #include "koeditorgeneral.h" | 51 | #include "koeditorgeneral.h" |
52 | #include "kolocationbox.h" | 52 | #include "kolocationbox.h" |
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #else | 55 | #else |
56 | #include <qapplication.h> | 56 | #include <qapplication.h> |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : | 59 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : |
60 | QObject( parent, name) | 60 | QObject( parent, name) |
61 | { | 61 | { |
62 | mNextFocus = 0; | ||
62 | } | 63 | } |
63 | 64 | ||
64 | KOEditorGeneral::~KOEditorGeneral() | 65 | KOEditorGeneral::~KOEditorGeneral() |
65 | { | 66 | { |
66 | } | 67 | } |
67 | 68 | ||
68 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 69 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
69 | { | 70 | { |
70 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 71 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
71 | 72 | ||
72 | #if 0 | 73 | #if 0 |
73 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 74 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
74 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 75 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
75 | #endif | 76 | #endif |
76 | 77 | ||
77 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 78 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
78 | headerLayout->addWidget(summaryLabel,1,0); | 79 | headerLayout->addWidget(summaryLabel,1,0); |
79 | 80 | ||
80 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); | 81 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); |
81 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 82 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
82 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 83 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
83 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 84 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
84 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 85 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
85 | if ( QApplication::desktop()->width() > 320 ) | 86 | if ( QApplication::desktop()->width() > 320 ) |
86 | mSummaryEdit->setMaximumHeight( hei +6 ); | 87 | mSummaryEdit->setMaximumHeight( hei +6 ); |
87 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 88 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); |
88 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } | 89 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
89 | // mSummaryEdit = new QLineEdit(parent); | 90 | // mSummaryEdit = new QLineEdit(parent); |
90 | headerLayout->addWidget(mSummaryEdit,1,1); | 91 | headerLayout->addWidget(mSummaryEdit,1,1); |
91 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 92 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
92 | 93 | ||
93 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 94 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
94 | headerLayout->addWidget(locationLabel,2,0); | 95 | headerLayout->addWidget(locationLabel,2,0); |
95 | 96 | ||
96 | mLocationEdit = new KOLocationBox(TRUE,parent,10); | 97 | mLocationEdit = new KOLocationBox(TRUE,parent,10); |
97 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 98 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
98 | if ( QApplication::desktop()->width() > 320 ) | 99 | if ( QApplication::desktop()->width() > 320 ) |
99 | mLocationEdit->setMaximumHeight( hei + 6); | 100 | mLocationEdit->setMaximumHeight( hei + 6); |
100 | 101 | ||
101 | // mLocationEdit = new QLineEdit(parent); | 102 | // mLocationEdit = new QLineEdit(parent); |
102 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 103 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
103 | headerLayout->addWidget(mLocationEdit,2,1); | 104 | headerLayout->addWidget(mLocationEdit,2,1); |
104 | headerLayout->setColStretch( 1, 10); | 105 | headerLayout->setColStretch( 1, 10); |
105 | } | 106 | } |
106 | void KOEditorGeneral::setFocusOn( int i ) | 107 | void KOEditorGeneral::setFocusOn( int i ) |
107 | { | 108 | { |
108 | qApp->processEvents(); | 109 | mNextFocus = i; |
109 | if ( i == 1 ) { | 110 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); |
111 | } | ||
112 | void KOEditorGeneral::slotSetFocusOn() | ||
113 | { | ||
114 | mNextFocus; | ||
115 | if ( mNextFocus == 1 ) { | ||
110 | mDescriptionEdit->setFocus(); | 116 | mDescriptionEdit->setFocus(); |
111 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 117 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
112 | } | 118 | } |
113 | if ( i == 2 ) { | 119 | if ( mNextFocus == 2 ) { |
114 | mSummaryEdit->setFocus(); | 120 | mSummaryEdit->setFocus(); |
115 | } | 121 | } |
116 | |||
117 | } | 122 | } |
118 | void KOEditorGeneral::editCategories() | 123 | void KOEditorGeneral::editCategories() |
119 | { | 124 | { |
120 | // qDebug("KOEditorGeneral::editCategories() "); | 125 | // qDebug("KOEditorGeneral::editCategories() "); |
121 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 126 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
122 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 127 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
123 | //KOGlobals::fitDialogToScreen( csd ); | 128 | //KOGlobals::fitDialogToScreen( csd ); |
124 | csd->setColorEnabled(); | 129 | csd->setColorEnabled(); |
125 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 130 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
126 | csd->exec(); | 131 | csd->exec(); |
127 | delete csd; | 132 | delete csd; |
128 | } | 133 | } |
129 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 134 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
130 | { | 135 | { |
131 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 136 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
132 | 137 | ||
133 | mCategoriesButton = new QPushButton(parent); | 138 | mCategoriesButton = new QPushButton(parent); |
134 | mCategoriesButton->setText(i18n("Categories...")); | 139 | mCategoriesButton->setText(i18n("Categories...")); |
135 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 140 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
136 | categoriesLayout->addWidget(mCategoriesButton); | 141 | categoriesLayout->addWidget(mCategoriesButton); |
137 | 142 | ||
138 | mCategoriesLabel = new QLabel(parent); | 143 | mCategoriesLabel = new QLabel(parent); |
139 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 144 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
140 | categoriesLayout->addWidget(mCategoriesLabel,1); | 145 | categoriesLayout->addWidget(mCategoriesLabel,1); |
141 | } | 146 | } |
142 | 147 | ||
143 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 148 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
144 | { | 149 | { |
145 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 150 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
146 | 151 | ||
147 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 152 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
148 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 153 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
149 | secrecyLayout->addWidget(mCancelBox); | 154 | secrecyLayout->addWidget(mCancelBox); |
150 | secrecyLayout->addWidget(secrecyLabel); | 155 | secrecyLayout->addWidget(secrecyLabel); |
151 | 156 | ||
152 | mSecrecyCombo = new QComboBox(parent); | 157 | mSecrecyCombo = new QComboBox(parent); |
153 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 158 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
154 | secrecyLayout->addWidget(mSecrecyCombo); | 159 | secrecyLayout->addWidget(mSecrecyCombo); |
155 | } | 160 | } |
156 | 161 | ||
157 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 162 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
158 | { | 163 | { |
159 | mDescriptionEdit = new KTextEdit(parent); | 164 | mDescriptionEdit = new KTextEdit(parent); |
160 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 165 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
161 | mDescriptionEdit->append(""); | 166 | mDescriptionEdit->append(""); |
162 | mDescriptionEdit->setReadOnly(false); | 167 | mDescriptionEdit->setReadOnly(false); |
163 | mDescriptionEdit->setOverwriteMode(false); | 168 | mDescriptionEdit->setOverwriteMode(false); |
164 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 169 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
165 | topLayout->addWidget(mDescriptionEdit); | 170 | topLayout->addWidget(mDescriptionEdit); |
166 | #ifndef DESKTOP_VERSION | 171 | #ifndef DESKTOP_VERSION |
167 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 172 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
168 | #endif | 173 | #endif |
169 | 174 | ||
170 | } | 175 | } |
171 | 176 | ||
172 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 177 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
173 | { | 178 | { |
174 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 179 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
175 | 180 | ||
176 | //mAlarmBell = new QLabel(parent); | 181 | //mAlarmBell = new QLabel(parent); |
177 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 182 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
178 | //alarmLayout->addWidget(mAlarmBell); | 183 | //alarmLayout->addWidget(mAlarmBell); |
179 | if ( QApplication::desktop()->width() < 320 ) | 184 | if ( QApplication::desktop()->width() < 320 ) |
180 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 185 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
181 | else | 186 | else |
182 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 187 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
183 | 188 | ||
184 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 189 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
185 | alarmLayout->addWidget(mAlarmButton); | 190 | alarmLayout->addWidget(mAlarmButton); |
186 | 191 | ||
187 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 192 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
188 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); | 193 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); |
189 | alarmLayout->addWidget(mAlarmTimeEdit); | 194 | alarmLayout->addWidget(mAlarmTimeEdit); |
190 | mAlarmIncrCombo = new QComboBox(false, parent); | 195 | mAlarmIncrCombo = new QComboBox(false, parent); |
191 | if ( QApplication::desktop()->width() < 320 ) { | 196 | if ( QApplication::desktop()->width() < 320 ) { |
192 | mAlarmIncrCombo->insertItem(i18n("min")); | 197 | mAlarmIncrCombo->insertItem(i18n("min")); |
193 | mAlarmIncrCombo->insertItem(i18n("hou")); | 198 | mAlarmIncrCombo->insertItem(i18n("hou")); |
194 | mAlarmIncrCombo->insertItem(i18n("day")); | 199 | mAlarmIncrCombo->insertItem(i18n("day")); |
195 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 200 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
196 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 201 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
197 | } else { | 202 | } else { |
198 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 203 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
199 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 204 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
200 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 205 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
201 | } | 206 | } |
202 | 207 | ||
203 | // mAlarmIncrCombo->setMinimumHeight(20); | 208 | // mAlarmIncrCombo->setMinimumHeight(20); |
204 | alarmLayout->addWidget(mAlarmIncrCombo); | 209 | alarmLayout->addWidget(mAlarmIncrCombo); |
205 | mAlarmSoundButton = new QPushButton(parent); | 210 | mAlarmSoundButton = new QPushButton(parent); |
206 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 211 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
207 | mAlarmSoundButton->setToggleButton(true); | 212 | mAlarmSoundButton->setToggleButton(true); |
208 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 213 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
209 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 214 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
210 | alarmLayout->addWidget(mAlarmSoundButton); | 215 | alarmLayout->addWidget(mAlarmSoundButton); |
211 | 216 | ||
212 | mAlarmProgramButton = new QPushButton(parent); | 217 | mAlarmProgramButton = new QPushButton(parent); |