-rw-r--r-- | korganizer/koeditorgeneral.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index f5eb52e..496f125 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -1,518 +1,519 @@ | |||
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 | } | 62 | } |
63 | 63 | ||
64 | KOEditorGeneral::~KOEditorGeneral() | 64 | KOEditorGeneral::~KOEditorGeneral() |
65 | { | 65 | { |
66 | } | 66 | } |
67 | 67 | ||
68 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 68 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
69 | { | 69 | { |
70 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 70 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
71 | 71 | ||
72 | #if 0 | 72 | #if 0 |
73 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 73 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
74 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 74 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 77 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
78 | headerLayout->addWidget(summaryLabel,1,0); | 78 | headerLayout->addWidget(summaryLabel,1,0); |
79 | 79 | ||
80 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); | 80 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); |
81 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 81 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
82 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 82 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
83 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 83 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
84 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 84 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
85 | if ( QApplication::desktop()->width() > 320 ) | 85 | if ( QApplication::desktop()->width() > 320 ) |
86 | mSummaryEdit->setMaximumHeight( hei +6 ); | 86 | mSummaryEdit->setMaximumHeight( hei +6 ); |
87 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 87 | //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 } | 88 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
89 | // mSummaryEdit = new QLineEdit(parent); | 89 | // mSummaryEdit = new QLineEdit(parent); |
90 | headerLayout->addWidget(mSummaryEdit,1,1); | 90 | headerLayout->addWidget(mSummaryEdit,1,1); |
91 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 91 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
92 | 92 | ||
93 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 93 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
94 | headerLayout->addWidget(locationLabel,2,0); | 94 | headerLayout->addWidget(locationLabel,2,0); |
95 | 95 | ||
96 | mLocationEdit = new KOLocationBox(TRUE,parent,10); | 96 | mLocationEdit = new KOLocationBox(TRUE,parent,10); |
97 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 97 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
98 | if ( QApplication::desktop()->width() > 320 ) | 98 | if ( QApplication::desktop()->width() > 320 ) |
99 | mLocationEdit->setMaximumHeight( hei + 6); | 99 | mLocationEdit->setMaximumHeight( hei + 6); |
100 | 100 | ||
101 | // mLocationEdit = new QLineEdit(parent); | 101 | // mLocationEdit = new QLineEdit(parent); |
102 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 102 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
103 | headerLayout->addWidget(mLocationEdit,2,1); | 103 | headerLayout->addWidget(mLocationEdit,2,1); |
104 | headerLayout->setColStretch( 1, 10); | 104 | headerLayout->setColStretch( 1, 10); |
105 | } | 105 | } |
106 | void KOEditorGeneral::setFocusOn( int i ) | 106 | void KOEditorGeneral::setFocusOn( int i ) |
107 | { | 107 | { |
108 | qApp->processEvents(); | 108 | qApp->processEvents(); |
109 | if ( i == 1 ) { | 109 | if ( i == 1 ) { |
110 | mDescriptionEdit->setFocus(); | 110 | mDescriptionEdit->setFocus(); |
111 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 111 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
112 | } | 112 | } |
113 | if ( i == 2 ) { | 113 | if ( i == 2 ) { |
114 | mSummaryEdit->setFocus(); | 114 | mSummaryEdit->setFocus(); |
115 | } | 115 | } |
116 | 116 | ||
117 | } | 117 | } |
118 | void KOEditorGeneral::editCategories() | 118 | void KOEditorGeneral::editCategories() |
119 | { | 119 | { |
120 | // qDebug("KOEditorGeneral::editCategories() "); | 120 | // qDebug("KOEditorGeneral::editCategories() "); |
121 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 121 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
122 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 122 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
123 | //KOGlobals::fitDialogToScreen( csd ); | 123 | //KOGlobals::fitDialogToScreen( csd ); |
124 | csd->setColorEnabled(); | ||
124 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 125 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
125 | csd->exec(); | 126 | csd->exec(); |
126 | delete csd; | 127 | delete csd; |
127 | } | 128 | } |
128 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 129 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
129 | { | 130 | { |
130 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 131 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
131 | 132 | ||
132 | mCategoriesButton = new QPushButton(parent); | 133 | mCategoriesButton = new QPushButton(parent); |
133 | mCategoriesButton->setText(i18n("Categories...")); | 134 | mCategoriesButton->setText(i18n("Categories...")); |
134 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 135 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
135 | categoriesLayout->addWidget(mCategoriesButton); | 136 | categoriesLayout->addWidget(mCategoriesButton); |
136 | 137 | ||
137 | mCategoriesLabel = new QLabel(parent); | 138 | mCategoriesLabel = new QLabel(parent); |
138 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 139 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
139 | categoriesLayout->addWidget(mCategoriesLabel,1); | 140 | categoriesLayout->addWidget(mCategoriesLabel,1); |
140 | } | 141 | } |
141 | 142 | ||
142 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 143 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
143 | { | 144 | { |
144 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 145 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
145 | 146 | ||
146 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 147 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
147 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 148 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
148 | secrecyLayout->addWidget(mCancelBox); | 149 | secrecyLayout->addWidget(mCancelBox); |
149 | secrecyLayout->addWidget(secrecyLabel); | 150 | secrecyLayout->addWidget(secrecyLabel); |
150 | 151 | ||
151 | mSecrecyCombo = new QComboBox(parent); | 152 | mSecrecyCombo = new QComboBox(parent); |
152 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 153 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
153 | secrecyLayout->addWidget(mSecrecyCombo); | 154 | secrecyLayout->addWidget(mSecrecyCombo); |
154 | } | 155 | } |
155 | 156 | ||
156 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 157 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
157 | { | 158 | { |
158 | mDescriptionEdit = new KTextEdit(parent); | 159 | mDescriptionEdit = new KTextEdit(parent); |
159 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 160 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
160 | mDescriptionEdit->append(""); | 161 | mDescriptionEdit->append(""); |
161 | mDescriptionEdit->setReadOnly(false); | 162 | mDescriptionEdit->setReadOnly(false); |
162 | mDescriptionEdit->setOverwriteMode(false); | 163 | mDescriptionEdit->setOverwriteMode(false); |
163 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 164 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
164 | topLayout->addWidget(mDescriptionEdit); | 165 | topLayout->addWidget(mDescriptionEdit); |
165 | #ifndef DESKTOP_VERSION | 166 | #ifndef DESKTOP_VERSION |
166 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 167 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
167 | #endif | 168 | #endif |
168 | 169 | ||
169 | } | 170 | } |
170 | 171 | ||
171 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 172 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
172 | { | 173 | { |
173 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 174 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
174 | 175 | ||
175 | //mAlarmBell = new QLabel(parent); | 176 | //mAlarmBell = new QLabel(parent); |
176 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 177 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
177 | //alarmLayout->addWidget(mAlarmBell); | 178 | //alarmLayout->addWidget(mAlarmBell); |
178 | if ( QApplication::desktop()->width() < 320 ) | 179 | if ( QApplication::desktop()->width() < 320 ) |
179 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 180 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
180 | else | 181 | else |
181 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 182 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
182 | 183 | ||
183 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 184 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
184 | alarmLayout->addWidget(mAlarmButton); | 185 | alarmLayout->addWidget(mAlarmButton); |
185 | 186 | ||
186 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 187 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
187 | alarmLayout->addWidget(mAlarmTimeEdit); | 188 | alarmLayout->addWidget(mAlarmTimeEdit); |
188 | mAlarmIncrCombo = new QComboBox(false, parent); | 189 | mAlarmIncrCombo = new QComboBox(false, parent); |
189 | if ( QApplication::desktop()->width() < 320 ) { | 190 | if ( QApplication::desktop()->width() < 320 ) { |
190 | mAlarmIncrCombo->insertItem(i18n("min")); | 191 | mAlarmIncrCombo->insertItem(i18n("min")); |
191 | mAlarmIncrCombo->insertItem(i18n("hou")); | 192 | mAlarmIncrCombo->insertItem(i18n("hou")); |
192 | mAlarmIncrCombo->insertItem(i18n("day")); | 193 | mAlarmIncrCombo->insertItem(i18n("day")); |
193 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 194 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
194 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 195 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
195 | } else { | 196 | } else { |
196 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 197 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
197 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 198 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
198 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 199 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
199 | } | 200 | } |
200 | 201 | ||
201 | // mAlarmIncrCombo->setMinimumHeight(20); | 202 | // mAlarmIncrCombo->setMinimumHeight(20); |
202 | alarmLayout->addWidget(mAlarmIncrCombo); | 203 | alarmLayout->addWidget(mAlarmIncrCombo); |
203 | mAlarmSoundButton = new QPushButton(parent); | 204 | mAlarmSoundButton = new QPushButton(parent); |
204 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 205 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
205 | mAlarmSoundButton->setToggleButton(true); | 206 | mAlarmSoundButton->setToggleButton(true); |
206 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 207 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
207 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 208 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
208 | alarmLayout->addWidget(mAlarmSoundButton); | 209 | alarmLayout->addWidget(mAlarmSoundButton); |
209 | 210 | ||
210 | mAlarmProgramButton = new QPushButton(parent); | 211 | mAlarmProgramButton = new QPushButton(parent); |
211 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 212 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
212 | mAlarmProgramButton->setToggleButton(true); | 213 | mAlarmProgramButton->setToggleButton(true); |
213 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 214 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
214 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 215 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
215 | alarmLayout->addWidget(mAlarmProgramButton); | 216 | alarmLayout->addWidget(mAlarmProgramButton); |
216 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 217 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
217 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 218 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
218 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 219 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
219 | // mAlarmSoundButton->hide(); | 220 | // mAlarmSoundButton->hide(); |
220 | // mAlarmProgramButton->hide(); | 221 | // mAlarmProgramButton->hide(); |
221 | // } | 222 | // } |
222 | } | 223 | } |
223 | 224 | ||
224 | void KOEditorGeneral::pickAlarmSound() | 225 | void KOEditorGeneral::pickAlarmSound() |
225 | { | 226 | { |
226 | 227 | ||
227 | //QString prefix = mAlarmSound; | 228 | //QString prefix = mAlarmSound; |
228 | if (!mAlarmSoundButton->isOn()) { | 229 | if (!mAlarmSoundButton->isOn()) { |
229 | //mAlarmSound = ""; | 230 | //mAlarmSound = ""; |
230 | QToolTip::remove(mAlarmSoundButton); | 231 | QToolTip::remove(mAlarmSoundButton); |
231 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 232 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
232 | mAlarmProgramButton->setOn(true); | 233 | mAlarmProgramButton->setOn(true); |
233 | mAlarmSoundButton->setOn(false); | 234 | mAlarmSoundButton->setOn(false); |
234 | } else { | 235 | } else { |
235 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 236 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
236 | i18n("*.wav|Wav Files"), 0)); | 237 | i18n("*.wav|Wav Files"), 0)); |
237 | if (!fileName.isEmpty()) { | 238 | if (!fileName.isEmpty()) { |
238 | mAlarmSound = fileName; | 239 | mAlarmSound = fileName; |
239 | QToolTip::remove(mAlarmSoundButton); | 240 | QToolTip::remove(mAlarmSoundButton); |
240 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 241 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
241 | QToolTip::add(mAlarmSoundButton, dispStr); | 242 | QToolTip::add(mAlarmSoundButton, dispStr); |
242 | mAlarmProgramButton->setOn(false); | 243 | mAlarmProgramButton->setOn(false); |
243 | mAlarmSoundButton->setOn(true); | 244 | mAlarmSoundButton->setOn(true); |
244 | } else { | 245 | } else { |
245 | mAlarmProgramButton->setOn(true); | 246 | mAlarmProgramButton->setOn(true); |
246 | mAlarmSoundButton->setOn(false); | 247 | mAlarmSoundButton->setOn(false); |
247 | 248 | ||
248 | } | 249 | } |
249 | } | 250 | } |
250 | 251 | ||
251 | if (mAlarmProgramButton->isOn()) | 252 | if (mAlarmProgramButton->isOn()) |
252 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 253 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
253 | if ( mAlarmSoundButton->isOn()) | 254 | if ( mAlarmSoundButton->isOn()) |
254 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio.Al.: ") + getFittingPath(mAlarmSound) ); | 255 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio.Al.: ") + getFittingPath(mAlarmSound) ); |
255 | } | 256 | } |
256 | 257 | ||
257 | void KOEditorGeneral::pickAlarmProgram() | 258 | void KOEditorGeneral::pickAlarmProgram() |
258 | { | 259 | { |
259 | if (!mAlarmProgramButton->isOn()) { | 260 | if (!mAlarmProgramButton->isOn()) { |
260 | //mAlarmProgram = ""; | 261 | //mAlarmProgram = ""; |
261 | QToolTip::remove(mAlarmProgramButton); | 262 | QToolTip::remove(mAlarmProgramButton); |
262 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 263 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
263 | mAlarmProgramButton->setOn(false); | 264 | mAlarmProgramButton->setOn(false); |
264 | mAlarmSoundButton->setOn(true); | 265 | mAlarmSoundButton->setOn(true); |
265 | } else { | 266 | } else { |
266 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); | 267 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); |
267 | if (!fileName.isEmpty()) { | 268 | if (!fileName.isEmpty()) { |
268 | mAlarmProgram = fileName; | 269 | mAlarmProgram = fileName; |
269 | QToolTip::remove(mAlarmProgramButton); | 270 | QToolTip::remove(mAlarmProgramButton); |
270 | QString dispStr = i18n("Running '%1'").arg(fileName); | 271 | QString dispStr = i18n("Running '%1'").arg(fileName); |
271 | QToolTip::add(mAlarmProgramButton, dispStr); | 272 | QToolTip::add(mAlarmProgramButton, dispStr); |
272 | mAlarmSoundButton->setOn(false); | 273 | mAlarmSoundButton->setOn(false); |
273 | mAlarmProgramButton->setOn(true); | 274 | mAlarmProgramButton->setOn(true); |
274 | } else { | 275 | } else { |
275 | mAlarmProgramButton->setOn(false); | 276 | mAlarmProgramButton->setOn(false); |
276 | mAlarmSoundButton->setOn(true); | 277 | mAlarmSoundButton->setOn(true); |
277 | } | 278 | } |
278 | } | 279 | } |
279 | if (mAlarmProgramButton->isOn()) | 280 | if (mAlarmProgramButton->isOn()) |
280 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 281 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
281 | if ( mAlarmSoundButton->isOn()) | 282 | if ( mAlarmSoundButton->isOn()) |
282 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + getFittingPath(mAlarmSound) ); | 283 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + getFittingPath(mAlarmSound) ); |
283 | } | 284 | } |
284 | 285 | ||
285 | 286 | ||
286 | QString KOEditorGeneral::getFittingPath( const QString s ) | 287 | QString KOEditorGeneral::getFittingPath( const QString s ) |
287 | { | 288 | { |
288 | int maxlen = 50; | 289 | int maxlen = 50; |
289 | if ( QApplication::desktop()->width() < 640 ) { | 290 | if ( QApplication::desktop()->width() < 640 ) { |
290 | if ( QApplication::desktop()->width() < 320 ) | 291 | if ( QApplication::desktop()->width() < 320 ) |
291 | maxlen = 22; | 292 | maxlen = 22; |
292 | else | 293 | else |
293 | maxlen = 35; | 294 | maxlen = 35; |
294 | } | 295 | } |
295 | if ( s.length() > maxlen ) { | 296 | if ( s.length() > maxlen ) { |
296 | return "..."+s.right(maxlen -3); | 297 | return "..."+s.right(maxlen -3); |
297 | } | 298 | } |
298 | return s; | 299 | return s; |
299 | } | 300 | } |
300 | 301 | ||
301 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 302 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
302 | { | 303 | { |
303 | if ( enable ) { | 304 | if ( enable ) { |
304 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 305 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
305 | mAlarmSoundButton->setOn( true ); | 306 | mAlarmSoundButton->setOn( true ); |
306 | if ( mAlarmSound.isEmpty() ) | 307 | if ( mAlarmSound.isEmpty() ) |
307 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 308 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
308 | else { | 309 | else { |
309 | if ( ! QFile::exists( mAlarmSound ) ) | 310 | if ( ! QFile::exists( mAlarmSound ) ) |
310 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 311 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
311 | } | 312 | } |
312 | } | 313 | } |
313 | if (mAlarmProgramButton->isOn()) | 314 | if (mAlarmProgramButton->isOn()) |
314 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 315 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
315 | if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) | 316 | if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) |
316 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 317 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
317 | } | 318 | } |
318 | else { | 319 | else { |
319 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Alarm disabled for this item")); | 320 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Alarm disabled for this item")); |
320 | 321 | ||
321 | } | 322 | } |
322 | mAlarmTimeEdit->setEnabled(enable); | 323 | mAlarmTimeEdit->setEnabled(enable); |
323 | mAlarmSoundButton->setEnabled(enable); | 324 | mAlarmSoundButton->setEnabled(enable); |
324 | mAlarmProgramButton->setEnabled(enable); | 325 | mAlarmProgramButton->setEnabled(enable); |
325 | mAlarmIncrCombo->setEnabled(enable); | 326 | mAlarmIncrCombo->setEnabled(enable); |
326 | } | 327 | } |
327 | 328 | ||
328 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 329 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
329 | { | 330 | { |
330 | enableAlarmEdit( !disable ); | 331 | enableAlarmEdit( !disable ); |
331 | } | 332 | } |
332 | 333 | ||
333 | void KOEditorGeneral::enableAlarm( bool enable ) | 334 | void KOEditorGeneral::enableAlarm( bool enable ) |
334 | { | 335 | { |
335 | enableAlarmEdit( enable ); | 336 | enableAlarmEdit( enable ); |
336 | } | 337 | } |
337 | 338 | ||
338 | void KOEditorGeneral::alarmDisable(bool disable) | 339 | void KOEditorGeneral::alarmDisable(bool disable) |
339 | { | 340 | { |
340 | if (!disable) { | 341 | if (!disable) { |
341 | //mAlarmBell->setEnabled(true); | 342 | //mAlarmBell->setEnabled(true); |
342 | mAlarmButton->setEnabled(true); | 343 | mAlarmButton->setEnabled(true); |
343 | } else { | 344 | } else { |
344 | //mAlarmBell->setEnabled(false); | 345 | //mAlarmBell->setEnabled(false); |
345 | mAlarmButton->setEnabled(false); | 346 | mAlarmButton->setEnabled(false); |
346 | mAlarmButton->setChecked(false); | 347 | mAlarmButton->setChecked(false); |
347 | mAlarmTimeEdit->setEnabled(false); | 348 | mAlarmTimeEdit->setEnabled(false); |
348 | mAlarmSoundButton->setEnabled(false); | 349 | mAlarmSoundButton->setEnabled(false); |
349 | mAlarmProgramButton->setEnabled(false); | 350 | mAlarmProgramButton->setEnabled(false); |
350 | mAlarmIncrCombo->setEnabled(false); | 351 | mAlarmIncrCombo->setEnabled(false); |
351 | } | 352 | } |
352 | } | 353 | } |
353 | 354 | ||
354 | void KOEditorGeneral::setCategories(const QString &str) | 355 | void KOEditorGeneral::setCategories(const QString &str) |
355 | { | 356 | { |
356 | mCategoriesLabel->setText(str); | 357 | mCategoriesLabel->setText(str); |
357 | } | 358 | } |
358 | 359 | ||
359 | void KOEditorGeneral::setDefaults(bool allDay) | 360 | void KOEditorGeneral::setDefaults(bool allDay) |
360 | { | 361 | { |
361 | #if 0 | 362 | #if 0 |
362 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 363 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
363 | #endif | 364 | #endif |
364 | 365 | ||
365 | enableAlarmEdit( !allDay ); | 366 | enableAlarmEdit( !allDay ); |
366 | 367 | ||
367 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 368 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
368 | int alarmTime; | 369 | int alarmTime; |
369 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 370 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
370 | int index = KOPrefs::instance()->mAlarmTime; | 371 | int index = KOPrefs::instance()->mAlarmTime; |
371 | if (index < 0 || index > 7) { | 372 | if (index < 0 || index > 7) { |
372 | alarmTime = 15; | 373 | alarmTime = 15; |
373 | } else { | 374 | } else { |
374 | alarmTime = a[index]; | 375 | alarmTime = a[index]; |
375 | } | 376 | } |
376 | mAlarmButton ->setChecked( false ); | 377 | mAlarmButton ->setChecked( false ); |
377 | mAlarmTimeEdit->setValue(alarmTime); | 378 | mAlarmTimeEdit->setValue(alarmTime); |
378 | mAlarmIncrCombo->setCurrentItem(0); | 379 | mAlarmIncrCombo->setCurrentItem(0); |
379 | enableAlarmEdit( false ); | 380 | enableAlarmEdit( false ); |
380 | //alarmDisable (false); | 381 | //alarmDisable (false); |
381 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 382 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
382 | mCancelBox->setChecked( false ); | 383 | mCancelBox->setChecked( false ); |
383 | mSummaryEdit->setEditText(""); | 384 | mSummaryEdit->setEditText(""); |
384 | mLocationEdit->setEditText(""); | 385 | mLocationEdit->setEditText(""); |
385 | mDescriptionEdit->setText(""); | 386 | mDescriptionEdit->setText(""); |
386 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 387 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
387 | setCategories(""); | 388 | setCategories(""); |
388 | } | 389 | } |
389 | void KOEditorGeneral::setSecrecy( int num ) | 390 | void KOEditorGeneral::setSecrecy( int num ) |
390 | { | 391 | { |
391 | mSecrecyCombo->setCurrentItem(num); | 392 | mSecrecyCombo->setCurrentItem(num); |
392 | } | 393 | } |
393 | void KOEditorGeneral::readIncidence(Incidence *event) | 394 | void KOEditorGeneral::readIncidence(Incidence *event) |
394 | { | 395 | { |
395 | 396 | ||
396 | mAlarmIncrCombo->setCurrentItem(0); | 397 | mAlarmIncrCombo->setCurrentItem(0); |
397 | mSummaryEdit->setEditText(event->summary()); | 398 | mSummaryEdit->setEditText(event->summary()); |
398 | mLocationEdit->setEditText(event->location()); | 399 | mLocationEdit->setEditText(event->location()); |
399 | mDescriptionEdit->setText(event->description()); | 400 | mDescriptionEdit->setText(event->description()); |
400 | 401 | ||
401 | #if 0 | 402 | #if 0 |
402 | // organizer information | 403 | // organizer information |
403 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); | 404 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); |
404 | #endif | 405 | #endif |
405 | 406 | ||
406 | enableAlarmEdit( event->isAlarmEnabled() ); | 407 | enableAlarmEdit( event->isAlarmEnabled() ); |
407 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); | 408 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); |
408 | if(!event->isAlarmEnabled()) { | 409 | if(!event->isAlarmEnabled()) { |
409 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 410 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
410 | int alarmTime; | 411 | int alarmTime; |
411 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 412 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
412 | int index = KOPrefs::instance()->mAlarmTime; | 413 | int index = KOPrefs::instance()->mAlarmTime; |
413 | if (index < 0 || index > 7) { | 414 | if (index < 0 || index > 7) { |
414 | alarmTime = 15; | 415 | alarmTime = 15; |
415 | } else { | 416 | } else { |
416 | alarmTime = a[index]; | 417 | alarmTime = a[index]; |
417 | } | 418 | } |
418 | mAlarmTimeEdit->setValue(alarmTime); | 419 | mAlarmTimeEdit->setValue(alarmTime); |
419 | } | 420 | } |
420 | mAlarmButton->setChecked( event->isAlarmEnabled() ); | 421 | mAlarmButton->setChecked( event->isAlarmEnabled() ); |
421 | mSecrecyCombo->setCurrentItem(event->secrecy()); | 422 | mSecrecyCombo->setCurrentItem(event->secrecy()); |
422 | mCancelBox->setChecked( event->cancelled() ); | 423 | mCancelBox->setChecked( event->cancelled() ); |
423 | mAlarmProgramButton->setOn(false); | 424 | mAlarmProgramButton->setOn(false); |
424 | mAlarmSoundButton->setOn(false); | 425 | mAlarmSoundButton->setOn(false); |
425 | 426 | ||
426 | // set up alarm stuff | 427 | // set up alarm stuff |
427 | QPtrList<Alarm> alarms = event->alarms(); | 428 | QPtrList<Alarm> alarms = event->alarms(); |
428 | Alarm* alarm; | 429 | Alarm* alarm; |
429 | mAlarmIncrCombo->setCurrentItem(0); | 430 | mAlarmIncrCombo->setCurrentItem(0); |
430 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 431 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
431 | int offset; | 432 | int offset; |
432 | if ( alarm->hasTime() ) { | 433 | if ( alarm->hasTime() ) { |
433 | QDateTime t = alarm->time(); | 434 | QDateTime t = alarm->time(); |
434 | offset = event->dtStart().secsTo( t ); | 435 | offset = event->dtStart().secsTo( t ); |
435 | } else { | 436 | } else { |
436 | offset = alarm->startOffset().asSeconds(); | 437 | offset = alarm->startOffset().asSeconds(); |
437 | } | 438 | } |
438 | if ( offset != 0 ) { | 439 | if ( offset != 0 ) { |
439 | offset = offset / -60; // make minutes | 440 | offset = offset / -60; // make minutes |
440 | if (offset % 60 == 0) { // divides evenly into hours? | 441 | if (offset % 60 == 0) { // divides evenly into hours? |
441 | offset = offset / 60; | 442 | offset = offset / 60; |
442 | mAlarmIncrCombo->setCurrentItem(1); | 443 | mAlarmIncrCombo->setCurrentItem(1); |
443 | if (offset % 24 == 0) { // divides evenly into days? | 444 | if (offset % 24 == 0) { // divides evenly into days? |
444 | offset = offset / 24; | 445 | offset = offset / 24; |
445 | mAlarmIncrCombo->setCurrentItem(2); | 446 | mAlarmIncrCombo->setCurrentItem(2); |
446 | } | 447 | } |
447 | } | 448 | } |
448 | } | 449 | } |
449 | mAlarmTimeEdit->setValue( offset ); | 450 | mAlarmTimeEdit->setValue( offset ); |
450 | if (alarm->type() == Alarm::Procedure) { | 451 | if (alarm->type() == Alarm::Procedure) { |
451 | 452 | ||
452 | mAlarmProgram = alarm->programFile(); | 453 | mAlarmProgram = alarm->programFile(); |
453 | mAlarmProgramButton->setOn(true); | 454 | mAlarmProgramButton->setOn(true); |
454 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); | 455 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); |
455 | QToolTip::add(mAlarmProgramButton, dispStr); | 456 | QToolTip::add(mAlarmProgramButton, dispStr); |
456 | } | 457 | } |
457 | else if (alarm->type() == Alarm::Audio) { | 458 | else if (alarm->type() == Alarm::Audio) { |
458 | mAlarmSound = alarm->audioFile(); | 459 | mAlarmSound = alarm->audioFile(); |
459 | if ( ! QFile::exists( mAlarmSound ) ) | 460 | if ( ! QFile::exists( mAlarmSound ) ) |
460 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 461 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
461 | mAlarmSoundButton->setOn(true); | 462 | mAlarmSoundButton->setOn(true); |
462 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); | 463 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); |
463 | QToolTip::add(mAlarmSoundButton, dispStr); | 464 | QToolTip::add(mAlarmSoundButton, dispStr); |
464 | } | 465 | } |
465 | mAlarmButton->setChecked(alarm->enabled()); | 466 | mAlarmButton->setChecked(alarm->enabled()); |
466 | enableAlarmEdit( alarm->enabled() ); | 467 | enableAlarmEdit( alarm->enabled() ); |
467 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); | 468 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); |
468 | // TODO: Deal with multiple alarms | 469 | // TODO: Deal with multiple alarms |
469 | break; // For now, stop after the first alarm | 470 | break; // For now, stop after the first alarm |
470 | } | 471 | } |
471 | 472 | ||
472 | setCategories(event->categoriesStr()); | 473 | setCategories(event->categoriesStr()); |
473 | } | 474 | } |
474 | 475 | ||
475 | void KOEditorGeneral::writeIncidence(Incidence *event) | 476 | void KOEditorGeneral::writeIncidence(Incidence *event) |
476 | { | 477 | { |
477 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; | 478 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; |
478 | mLocationEdit->save(KOLocationBox::LOCATION); | 479 | mLocationEdit->save(KOLocationBox::LOCATION); |
479 | event->setSummary(mSummaryEdit->currentText()); | 480 | event->setSummary(mSummaryEdit->currentText()); |
480 | event->setLocation(mLocationEdit->currentText()); | 481 | event->setLocation(mLocationEdit->currentText()); |
481 | event->setDescription(mDescriptionEdit->text()); | 482 | event->setDescription(mDescriptionEdit->text()); |
482 | event->setCategories(mCategoriesLabel->text()); | 483 | event->setCategories(mCategoriesLabel->text()); |
483 | event->setSecrecy(mSecrecyCombo->currentItem()); | 484 | event->setSecrecy(mSecrecyCombo->currentItem()); |
484 | event->setCancelled(mCancelBox->isChecked() );; | 485 | event->setCancelled(mCancelBox->isChecked() );; |
485 | // alarm stuff | 486 | // alarm stuff |
486 | if (mAlarmButton->isChecked()) { | 487 | if (mAlarmButton->isChecked()) { |
487 | if (event->alarms().count() == 0) | 488 | if (event->alarms().count() == 0) |
488 | event->newAlarm(); | 489 | event->newAlarm(); |
489 | QPtrList<Alarm> alarms = event->alarms(); | 490 | QPtrList<Alarm> alarms = event->alarms(); |
490 | Alarm *alarm; | 491 | Alarm *alarm; |
491 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 492 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
492 | alarm->setEnabled(true); | 493 | alarm->setEnabled(true); |
493 | int j = mAlarmTimeEdit->value()* -60; | 494 | int j = mAlarmTimeEdit->value()* -60; |
494 | if (mAlarmIncrCombo->currentItem() == 1) | 495 | if (mAlarmIncrCombo->currentItem() == 1) |
495 | j = j * 60; | 496 | j = j * 60; |
496 | else if (mAlarmIncrCombo->currentItem() == 2) | 497 | else if (mAlarmIncrCombo->currentItem() == 2) |
497 | j = j * (60 * 24); | 498 | j = j * (60 * 24); |
498 | alarm->setStartOffset( j ); | 499 | alarm->setStartOffset( j ); |
499 | 500 | ||
500 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { | 501 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { |
501 | alarm->setProcedureAlarm(mAlarmProgram); | 502 | alarm->setProcedureAlarm(mAlarmProgram); |
502 | } | 503 | } |
503 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) | 504 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) |
504 | alarm->setAudioAlarm(mAlarmSound); | 505 | alarm->setAudioAlarm(mAlarmSound); |
505 | else | 506 | else |
506 | alarm->setType(Alarm::Invalid); | 507 | alarm->setType(Alarm::Invalid); |
507 | //alarm->setAudioAlarm("default"); | 508 | //alarm->setAudioAlarm("default"); |
508 | // TODO: Deal with multiple alarms | 509 | // TODO: Deal with multiple alarms |
509 | break; // For now, stop after the first alarm | 510 | break; // For now, stop after the first alarm |
510 | } | 511 | } |
511 | } else { | 512 | } else { |
512 | Alarm* alarm = event->alarms().first(); | 513 | Alarm* alarm = event->alarms().first(); |
513 | if ( alarm ) { | 514 | if ( alarm ) { |
514 | alarm->setEnabled(false); | 515 | alarm->setEnabled(false); |
515 | alarm->setType(Alarm::Invalid); | 516 | alarm->setType(Alarm::Invalid); |
516 | } | 517 | } |
517 | } | 518 | } |
518 | } | 519 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 1a1bce5..3011458 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1308 +1,1315 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,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 <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | 28 | ||
29 | #include <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include "koprefs.h" | 31 | #include "koprefs.h" |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | #include <kglobal.h> | 33 | #include <kglobal.h> |
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <libkcal/icaldrag.h> | 37 | #include <libkcal/icaldrag.h> |
38 | #include <libkcal/vcaldrag.h> | 38 | #include <libkcal/vcaldrag.h> |
39 | #include <libkcal/calfilter.h> | 39 | #include <libkcal/calfilter.h> |
40 | #include <libkcal/dndfactory.h> | 40 | #include <libkcal/dndfactory.h> |
41 | #include <libkcal/calendarresources.h> | 41 | #include <libkcal/calendarresources.h> |
42 | #include <libkcal/resourcecalendar.h> | 42 | #include <libkcal/resourcecalendar.h> |
43 | #include <kresources/resourceselectdialog.h> | 43 | #include <kresources/resourceselectdialog.h> |
44 | #include <libkcal/kincidenceformatter.h> | 44 | #include <libkcal/kincidenceformatter.h> |
45 | #ifndef DESKTOP_VERSION | 45 | #ifndef DESKTOP_VERSION |
46 | #include <qpe/qpeapplication.h> | 46 | #include <qpe/qpeapplication.h> |
47 | #else | 47 | #else |
48 | #include <qapplication.h> | 48 | #include <qapplication.h> |
49 | #endif | 49 | #endif |
50 | #ifndef KORG_NOPRINTER | 50 | #ifndef KORG_NOPRINTER |
51 | #include "calprinter.h" | 51 | #include "calprinter.h" |
52 | #endif | 52 | #endif |
53 | #include "docprefs.h" | 53 | #include "docprefs.h" |
54 | 54 | ||
55 | #include "kotodoview.h" | 55 | #include "kotodoview.h" |
56 | using namespace KOrg; | 56 | using namespace KOrg; |
57 | 57 | ||
58 | 58 | ||
59 | class KOTodoViewWhatsThis :public QWhatsThis | 59 | class KOTodoViewWhatsThis :public QWhatsThis |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 62 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual QString text( const QPoint& p) | 65 | virtual QString text( const QPoint& p) |
66 | { | 66 | { |
67 | return _view->getWhatsThisText(p) ; | 67 | return _view->getWhatsThisText(p) ; |
68 | } | 68 | } |
69 | private: | 69 | private: |
70 | QWidget* _wid; | 70 | QWidget* _wid; |
71 | KOTodoView * _view; | 71 | KOTodoView * _view; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 74 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
75 | const char *name) : | 75 | const char *name) : |
76 | KListView(parent,name) | 76 | KListView(parent,name) |
77 | { | 77 | { |
78 | mName = QString ( name ); | 78 | mName = QString ( name ); |
79 | mCalendar = calendar; | 79 | mCalendar = calendar; |
80 | #ifndef DESKTOP_VERSION | 80 | #ifndef DESKTOP_VERSION |
81 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 81 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
82 | #endif | 82 | #endif |
83 | mOldCurrent = 0; | 83 | mOldCurrent = 0; |
84 | mMousePressed = false; | 84 | mMousePressed = false; |
85 | 85 | ||
86 | setAcceptDrops(true); | 86 | setAcceptDrops(true); |
87 | viewport()->setAcceptDrops(true); | 87 | viewport()->setAcceptDrops(true); |
88 | int size = 16; | 88 | int size = 16; |
89 | if (qApp->desktop()->width() < 300 ) | 89 | if (qApp->desktop()->width() < 300 ) |
90 | size = 12; | 90 | size = 12; |
91 | setTreeStepSize( size + 6 ); | 91 | setTreeStepSize( size + 6 ); |
92 | 92 | ||
93 | } | 93 | } |
94 | 94 | ||
95 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 95 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
96 | { | 96 | { |
97 | #ifndef KORG_NODND | 97 | #ifndef KORG_NODND |
98 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 98 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
99 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 99 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
100 | !QTextDrag::canDecode( e ) ) { | 100 | !QTextDrag::canDecode( e ) ) { |
101 | e->ignore(); | 101 | e->ignore(); |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | 104 | ||
105 | mOldCurrent = currentItem(); | 105 | mOldCurrent = currentItem(); |
106 | #endif | 106 | #endif |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 110 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
111 | { | 111 | { |
112 | #ifndef KORG_NODND | 112 | #ifndef KORG_NODND |
113 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 113 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
114 | 114 | ||
115 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 115 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
116 | !QTextDrag::canDecode( e ) ) { | 116 | !QTextDrag::canDecode( e ) ) { |
117 | e->ignore(); | 117 | e->ignore(); |
118 | return; | 118 | return; |
119 | } | 119 | } |
120 | 120 | ||
121 | e->accept(); | 121 | e->accept(); |
122 | #endif | 122 | #endif |
123 | } | 123 | } |
124 | 124 | ||
125 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 125 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
126 | { | 126 | { |
127 | #ifndef KORG_NODND | 127 | #ifndef KORG_NODND |
128 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 128 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
129 | 129 | ||
130 | setCurrentItem(mOldCurrent); | 130 | setCurrentItem(mOldCurrent); |
131 | setSelected(mOldCurrent,true); | 131 | setSelected(mOldCurrent,true); |
132 | #endif | 132 | #endif |
133 | } | 133 | } |
134 | 134 | ||
135 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 135 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
136 | { | 136 | { |
137 | #ifndef KORG_NODND | 137 | #ifndef KORG_NODND |
138 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 138 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
139 | 139 | ||
140 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 140 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
141 | !QTextDrag::canDecode( e ) ) { | 141 | !QTextDrag::canDecode( e ) ) { |
142 | e->ignore(); | 142 | e->ignore(); |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | 145 | ||
146 | DndFactory factory( mCalendar ); | 146 | DndFactory factory( mCalendar ); |
147 | Todo *todo = factory.createDropTodo(e); | 147 | Todo *todo = factory.createDropTodo(e); |
148 | 148 | ||
149 | if (todo) { | 149 | if (todo) { |
150 | e->acceptAction(); | 150 | e->acceptAction(); |
151 | 151 | ||
152 | KOTodoViewItem *destination = | 152 | KOTodoViewItem *destination = |
153 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 153 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
154 | Todo *destinationEvent = 0; | 154 | Todo *destinationEvent = 0; |
155 | if (destination) destinationEvent = destination->todo(); | 155 | if (destination) destinationEvent = destination->todo(); |
156 | 156 | ||
157 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 157 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
158 | 158 | ||
159 | if(existingTodo) { | 159 | if(existingTodo) { |
160 | Incidence *to = destinationEvent; | 160 | Incidence *to = destinationEvent; |
161 | while(to) { | 161 | while(to) { |
162 | if (to->uid() == todo->uid()) { | 162 | if (to->uid() == todo->uid()) { |
163 | KMessageBox::sorry(this, | 163 | KMessageBox::sorry(this, |
164 | i18n("Cannot move To-Do to itself\nor a child of itself"), | 164 | i18n("Cannot move To-Do to itself\nor a child of itself"), |
165 | i18n("Drop To-Do")); | 165 | i18n("Drop To-Do")); |
166 | delete todo; | 166 | delete todo; |
167 | return; | 167 | return; |
168 | } | 168 | } |
169 | to = to->relatedTo(); | 169 | to = to->relatedTo(); |
170 | } | 170 | } |
171 | internalDrop = true; | 171 | internalDrop = true; |
172 | if ( destinationEvent ) | 172 | if ( destinationEvent ) |
173 | reparentTodoSignal( destinationEvent, existingTodo ); | 173 | reparentTodoSignal( destinationEvent, existingTodo ); |
174 | else | 174 | else |
175 | unparentTodoSignal(existingTodo); | 175 | unparentTodoSignal(existingTodo); |
176 | delete todo; | 176 | delete todo; |
177 | } else { | 177 | } else { |
178 | mCalendar->addTodo(todo); | 178 | mCalendar->addTodo(todo); |
179 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 179 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
180 | if ( destinationEvent ) | 180 | if ( destinationEvent ) |
181 | reparentTodoSignal( destinationEvent, todo ); | 181 | reparentTodoSignal( destinationEvent, todo ); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | else { | 184 | else { |
185 | QString text; | 185 | QString text; |
186 | if (QTextDrag::decode(e,text)) { | 186 | if (QTextDrag::decode(e,text)) { |
187 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 187 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
188 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 188 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
189 | qDebug("Dropped : " + text); | 189 | qDebug("Dropped : " + text); |
190 | QStringList emails = QStringList::split(",",text); | 190 | QStringList emails = QStringList::split(",",text); |
191 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 191 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
192 | int pos = (*it).find("<"); | 192 | int pos = (*it).find("<"); |
193 | QString name = (*it).left(pos); | 193 | QString name = (*it).left(pos); |
194 | QString email = (*it).mid(pos); | 194 | QString email = (*it).mid(pos); |
195 | if (!email.isEmpty() && todoi) { | 195 | if (!email.isEmpty() && todoi) { |
196 | todoi->todo()->addAttendee(new Attendee(name,email)); | 196 | todoi->todo()->addAttendee(new Attendee(name,email)); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | } | 199 | } |
200 | else { | 200 | else { |
201 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 201 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
202 | e->ignore(); | 202 | e->ignore(); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | #endif | 205 | #endif |
206 | } | 206 | } |
207 | 207 | ||
208 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 208 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
209 | { | 209 | { |
210 | #ifndef KORG_NODND | 210 | #ifndef KORG_NODND |
211 | QPoint p(contentsToViewport(e->pos())); | 211 | QPoint p(contentsToViewport(e->pos())); |
212 | QListViewItem *i = itemAt(p); | 212 | QListViewItem *i = itemAt(p); |
213 | mMousePressed = false; | 213 | mMousePressed = false; |
214 | if (i) { | 214 | if (i) { |
215 | // if the user clicked into the root decoration of the item, don't | 215 | // if the user clicked into the root decoration of the item, don't |
216 | // try to start a drag! | 216 | // try to start a drag! |
217 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 217 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
218 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 218 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
219 | itemMargin() || | 219 | itemMargin() || |
220 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 220 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
221 | if (e->button()==Qt::LeftButton) { | 221 | if (e->button()==Qt::LeftButton) { |
222 | mPressPos = e->pos(); | 222 | mPressPos = e->pos(); |
223 | mMousePressed = true; | 223 | mMousePressed = true; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | } | 226 | } |
227 | #endif | 227 | #endif |
228 | QListView::contentsMousePressEvent(e); | 228 | QListView::contentsMousePressEvent(e); |
229 | } | 229 | } |
230 | void KOTodoListView::paintEvent(QPaintEvent* e) | 230 | void KOTodoListView::paintEvent(QPaintEvent* e) |
231 | { | 231 | { |
232 | emit paintNeeded(); | 232 | emit paintNeeded(); |
233 | QListView::paintEvent( e); | 233 | QListView::paintEvent( e); |
234 | } | 234 | } |
235 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 235 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
236 | { | 236 | { |
237 | 237 | ||
238 | #ifndef KORG_NODND | 238 | #ifndef KORG_NODND |
239 | //QListView::contentsMouseMoveEvent(e); | 239 | //QListView::contentsMouseMoveEvent(e); |
240 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 240 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
241 | QApplication::startDragDistance()*3) { | 241 | QApplication::startDragDistance()*3) { |
242 | mMousePressed = false; | 242 | mMousePressed = false; |
243 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 243 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
244 | if (item) { | 244 | if (item) { |
245 | DndFactory factory( mCalendar ); | 245 | DndFactory factory( mCalendar ); |
246 | ICalDrag *vd = factory.createDrag( | 246 | ICalDrag *vd = factory.createDrag( |
247 | ((KOTodoViewItem *)item)->todo(),viewport()); | 247 | ((KOTodoViewItem *)item)->todo(),viewport()); |
248 | internalDrop = false; | 248 | internalDrop = false; |
249 | // we cannot do any senseful here, because the DnD is still broken in Qt | 249 | // we cannot do any senseful here, because the DnD is still broken in Qt |
250 | if (vd->drag()) { | 250 | if (vd->drag()) { |
251 | if ( !internalDrop ) { | 251 | if ( !internalDrop ) { |
252 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 252 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
253 | qDebug("Dnd: External move: Delete drag source "); | 253 | qDebug("Dnd: External move: Delete drag source "); |
254 | } else | 254 | } else |
255 | qDebug("Dnd: Internal move "); | 255 | qDebug("Dnd: Internal move "); |
256 | 256 | ||
257 | } else { | 257 | } else { |
258 | if ( !internalDrop ) { | 258 | if ( !internalDrop ) { |
259 | qDebug("Dnd: External Copy"); | 259 | qDebug("Dnd: External Copy"); |
260 | } else | 260 | } else |
261 | qDebug("DnD: Internal copy: Copy pending"); | 261 | qDebug("DnD: Internal copy: Copy pending"); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | } | 264 | } |
265 | #endif | 265 | #endif |
266 | } | 266 | } |
267 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 267 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
268 | { | 268 | { |
269 | 269 | ||
270 | QListViewItem* cn; | 270 | QListViewItem* cn; |
271 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 271 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
272 | cn = currentItem(); | 272 | cn = currentItem(); |
273 | if ( cn ) { | 273 | if ( cn ) { |
274 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 274 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
275 | if ( ci ){ | 275 | if ( ci ){ |
276 | if ( e->state() == ShiftButton ) | 276 | if ( e->state() == ShiftButton ) |
277 | ci->setOn( false ); | 277 | ci->setOn( false ); |
278 | else | 278 | else |
279 | ci->setOn( true ); | 279 | ci->setOn( true ); |
280 | cn = cn->itemBelow(); | 280 | cn = cn->itemBelow(); |
281 | if ( cn ) { | 281 | if ( cn ) { |
282 | setCurrentItem ( cn ); | 282 | setCurrentItem ( cn ); |
283 | ensureItemVisible ( cn ); | 283 | ensureItemVisible ( cn ); |
284 | } | 284 | } |
285 | 285 | ||
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | return; | 289 | return; |
290 | } | 290 | } |
291 | 291 | ||
292 | // qDebug("KOTodoListView::keyPressEvent "); | 292 | // qDebug("KOTodoListView::keyPressEvent "); |
293 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 293 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
294 | switch ( e->key() ) { | 294 | switch ( e->key() ) { |
295 | case Qt::Key_Down: | 295 | case Qt::Key_Down: |
296 | case Qt::Key_Up: | 296 | case Qt::Key_Up: |
297 | QListView::keyPressEvent ( e ); | 297 | QListView::keyPressEvent ( e ); |
298 | break; | 298 | break; |
299 | case Qt::Key_Left: | 299 | case Qt::Key_Left: |
300 | case Qt::Key_Right: | 300 | case Qt::Key_Right: |
301 | QListView::keyPressEvent ( e ); | 301 | QListView::keyPressEvent ( e ); |
302 | e->accept(); | 302 | e->accept(); |
303 | return; | 303 | return; |
304 | break; | 304 | break; |
305 | default: | 305 | default: |
306 | e->ignore(); | 306 | e->ignore(); |
307 | break; | 307 | break; |
308 | } | 308 | } |
309 | return; | 309 | return; |
310 | } | 310 | } |
311 | e->ignore(); | 311 | e->ignore(); |
312 | } | 312 | } |
313 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 313 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
314 | { | 314 | { |
315 | QListView::contentsMouseReleaseEvent(e); | 315 | QListView::contentsMouseReleaseEvent(e); |
316 | mMousePressed = false; | 316 | mMousePressed = false; |
317 | } | 317 | } |
318 | 318 | ||
319 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 319 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
320 | { | 320 | { |
321 | if (!e) return; | 321 | if (!e) return; |
322 | 322 | ||
323 | QPoint vp = contentsToViewport(e->pos()); | 323 | QPoint vp = contentsToViewport(e->pos()); |
324 | 324 | ||
325 | QListViewItem *item = itemAt(vp); | 325 | QListViewItem *item = itemAt(vp); |
326 | 326 | ||
327 | emit double_Clicked(item); | 327 | emit double_Clicked(item); |
328 | if (!item) return; | 328 | if (!item) return; |
329 | 329 | ||
330 | emit doubleClicked(item,vp,0); | 330 | emit doubleClicked(item,vp,0); |
331 | } | 331 | } |
332 | 332 | ||
333 | ///////////////////////////////////////////////////////////////////////////// | 333 | ///////////////////////////////////////////////////////////////////////////// |
334 | 334 | ||
335 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 335 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
336 | QLineEdit(parent) | 336 | QLineEdit(parent) |
337 | { | 337 | { |
338 | setText(i18n("Click to add a new Todo")); | 338 | setText(i18n("Click to add a new Todo")); |
339 | } | 339 | } |
340 | 340 | ||
341 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 341 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
342 | { | 342 | { |
343 | if ( text()==i18n("Click to add a new Todo") ) | 343 | if ( text()==i18n("Click to add a new Todo") ) |
344 | setText(""); | 344 | setText(""); |
345 | QLineEdit::focusInEvent(ev); | 345 | QLineEdit::focusInEvent(ev); |
346 | } | 346 | } |
347 | 347 | ||
348 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 348 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
349 | { | 349 | { |
350 | setText(i18n("Click to add a new Todo")); | 350 | setText(i18n("Click to add a new Todo")); |
351 | QLineEdit::focusOutEvent(ev); | 351 | QLineEdit::focusOutEvent(ev); |
352 | } | 352 | } |
353 | 353 | ||
354 | ///////////////////////////////////////////////////////////////////////////// | 354 | ///////////////////////////////////////////////////////////////////////////// |
355 | 355 | ||
356 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 356 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
357 | KOrg::BaseView(calendar,parent,name) | 357 | KOrg::BaseView(calendar,parent,name) |
358 | { | 358 | { |
359 | mPendingUpdateBeforeRepaint = false; | 359 | mPendingUpdateBeforeRepaint = false; |
360 | isFlatDisplay = false; | 360 | isFlatDisplay = false; |
361 | mNavigator = 0; | 361 | mNavigator = 0; |
362 | QBoxLayout *topLayout = new QVBoxLayout(this); | 362 | QBoxLayout *topLayout = new QVBoxLayout(this); |
363 | mName = QString ( name ); | 363 | mName = QString ( name ); |
364 | mBlockUpdate = false; | 364 | mBlockUpdate = false; |
365 | mQuickAdd = new KOQuickTodo(this); | 365 | mQuickAdd = new KOQuickTodo(this); |
366 | topLayout->addWidget(mQuickAdd); | 366 | topLayout->addWidget(mQuickAdd); |
367 | 367 | ||
368 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 368 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
369 | 369 | ||
370 | mTodoListView = new KOTodoListView(calendar,this, name ); | 370 | mTodoListView = new KOTodoListView(calendar,this, name ); |
371 | topLayout->addWidget(mTodoListView); | 371 | topLayout->addWidget(mTodoListView); |
372 | //mTodoListView->header()->setMaximumHeight(30); | 372 | //mTodoListView->header()->setMaximumHeight(30); |
373 | mTodoListView->setRootIsDecorated(true); | 373 | mTodoListView->setRootIsDecorated(true); |
374 | mTodoListView->setAllColumnsShowFocus(true); | 374 | mTodoListView->setAllColumnsShowFocus(true); |
375 | 375 | ||
376 | mTodoListView->setShowSortIndicator(true); | 376 | mTodoListView->setShowSortIndicator(true); |
377 | 377 | ||
378 | mTodoListView->addColumn(i18n("Todo")); | 378 | mTodoListView->addColumn(i18n("Todo")); |
379 | mTodoListView->addColumn(i18n("Prio")); | 379 | mTodoListView->addColumn(i18n("Prio")); |
380 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 380 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
381 | mTodoListView->addColumn(i18n("Complete")); | 381 | mTodoListView->addColumn(i18n("Complete")); |
382 | mTodoListView->setColumnAlignment(2,AlignCenter); | 382 | mTodoListView->setColumnAlignment(2,AlignCenter); |
383 | 383 | ||
384 | mTodoListView->addColumn(i18n("Due Date")); | 384 | mTodoListView->addColumn(i18n("Due Date")); |
385 | mTodoListView->setColumnAlignment(3,AlignLeft); | 385 | mTodoListView->setColumnAlignment(3,AlignLeft); |
386 | mTodoListView->addColumn(i18n("Due Time")); | 386 | mTodoListView->addColumn(i18n("Due Time")); |
387 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 387 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
388 | 388 | ||
389 | mTodoListView->addColumn(i18n("Start Date")); | 389 | mTodoListView->addColumn(i18n("Start Date")); |
390 | mTodoListView->setColumnAlignment(5,AlignLeft); | 390 | mTodoListView->setColumnAlignment(5,AlignLeft); |
391 | mTodoListView->addColumn(i18n("Start Time")); | 391 | mTodoListView->addColumn(i18n("Start Time")); |
392 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 392 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
393 | 393 | ||
394 | mTodoListView->addColumn(i18n("Cancelled")); | 394 | mTodoListView->addColumn(i18n("Cancelled")); |
395 | mTodoListView->addColumn(i18n("Categories")); | 395 | mTodoListView->addColumn(i18n("Categories")); |
396 | #if 0 | 396 | #if 0 |
397 | mTodoListView->addColumn(i18n("Sort Id")); | 397 | mTodoListView->addColumn(i18n("Sort Id")); |
398 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 398 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
399 | #endif | 399 | #endif |
400 | 400 | ||
401 | mTodoListView->setMinimumHeight( 60 ); | 401 | mTodoListView->setMinimumHeight( 60 ); |
402 | mTodoListView->setItemsRenameable( true ); | 402 | mTodoListView->setItemsRenameable( true ); |
403 | mTodoListView->setRenameable( 0 ); | 403 | mTodoListView->setRenameable( 0 ); |
404 | mTodoListView->setColumnWidth( 0, 120 ); | 404 | mTodoListView->setColumnWidth( 0, 120 ); |
405 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 405 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
406 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 406 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
407 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 407 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
408 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 408 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
409 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 409 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
410 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 410 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
411 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 411 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
412 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | 412 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
413 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | 413 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
414 | 414 | ||
415 | 415 | ||
416 | new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 416 | new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
417 | 417 | ||
418 | mPriorityPopupMenu = new QPopupMenu(this); | 418 | mPriorityPopupMenu = new QPopupMenu(this); |
419 | for (int i = 1; i <= 5; i++) { | 419 | for (int i = 1; i <= 5; i++) { |
420 | QString label = QString ("%1").arg (i); | 420 | QString label = QString ("%1").arg (i); |
421 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 421 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
422 | } | 422 | } |
423 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 423 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
424 | 424 | ||
425 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 425 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
426 | for (int i = 0; i <= 100; i+=20) { | 426 | for (int i = 0; i <= 100; i+=20) { |
427 | QString label = QString ("%1 %").arg (i); | 427 | QString label = QString ("%1 %").arg (i); |
428 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 428 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
429 | } | 429 | } |
430 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 430 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
431 | 431 | ||
432 | 432 | ||
433 | 433 | ||
434 | mItemPopupMenu = new QPopupMenu(this); | 434 | mItemPopupMenu = new QPopupMenu(this); |
435 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 435 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
436 | SLOT (showTodo())); | 436 | SLOT (showTodo())); |
437 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 437 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
438 | SLOT (editTodo())); | 438 | SLOT (editTodo())); |
439 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 439 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
440 | SLOT (deleteTodo())); | 440 | SLOT (deleteTodo())); |
441 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 441 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
442 | SLOT (cloneTodo())); | 442 | SLOT (cloneTodo())); |
443 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 443 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
444 | SLOT (moveTodo())); | 444 | SLOT (moveTodo())); |
445 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 445 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
446 | SLOT (beamTodo())); | 446 | SLOT (beamTodo())); |
447 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 447 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
448 | SLOT (cancelTodo())); | 448 | SLOT (cancelTodo())); |
449 | mItemPopupMenu->insertSeparator(); | 449 | mItemPopupMenu->insertSeparator(); |
450 | 450 | ||
451 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 451 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
452 | SLOT (newTodo())); | 452 | SLOT (newTodo())); |
453 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 453 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
454 | SLOT (newSubTodo())); | 454 | SLOT (newSubTodo())); |
455 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 455 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
456 | SLOT (unparentTodo()),0,21); | 456 | SLOT (unparentTodo()),0,21); |
457 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 457 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
458 | SLOT (reparentTodo()),0,22); | 458 | SLOT (reparentTodo()),0,22); |
459 | mItemPopupMenu->insertSeparator(); | 459 | mItemPopupMenu->insertSeparator(); |
460 | #if 0 | 460 | #if 0 |
461 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 461 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
462 | this, SLOT( purgeCompleted() ) ); | 462 | this, SLOT( purgeCompleted() ) ); |
463 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 463 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
464 | this, SLOT( toggleCompleted() ),0, 33 ); | 464 | this, SLOT( toggleCompleted() ),0, 33 ); |
465 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 465 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
466 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 466 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
467 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 467 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
468 | this, SLOT( toggleRunning() ),0, 35 ); | 468 | this, SLOT( toggleRunning() ),0, 35 ); |
469 | 469 | ||
470 | #endif | 470 | #endif |
471 | mPopupMenu = new QPopupMenu(this); | 471 | mPopupMenu = new QPopupMenu(this); |
472 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 472 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
473 | SLOT (newTodo()),0,1); | 473 | SLOT (newTodo()),0,1); |
474 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 474 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
475 | this, SLOT(purgeCompleted()),0,2); | 475 | this, SLOT(purgeCompleted()),0,2); |
476 | mPopupMenu->insertItem(i18n("Show Completed"), | 476 | mPopupMenu->insertItem(i18n("Show Completed"), |
477 | this, SLOT( toggleCompleted() ),0,3 ); | 477 | this, SLOT( toggleCompleted() ),0,3 ); |
478 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 478 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
479 | this, SLOT( toggleQuickTodo() ),0,4 ); | 479 | this, SLOT( toggleQuickTodo() ),0,4 ); |
480 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 480 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
481 | this, SLOT( toggleRunning() ),0,5 ); | 481 | this, SLOT( toggleRunning() ),0,5 ); |
482 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 482 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
483 | this, SLOT( setAllOpen() ),0,6 ); | 483 | this, SLOT( setAllOpen() ),0,6 ); |
484 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 484 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
485 | this, SLOT( setAllClose() ),0,7 ); | 485 | this, SLOT( setAllClose() ),0,7 ); |
486 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 486 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
487 | this, SLOT( setAllFlat() ),0,8 ); | 487 | this, SLOT( setAllFlat() ),0,8 ); |
488 | mDocPrefs = new DocPrefs( name ); | 488 | mDocPrefs = new DocPrefs( name ); |
489 | 489 | ||
490 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 490 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
491 | mPopupMenu->setCheckable( true ); | 491 | mPopupMenu->setCheckable( true ); |
492 | mItemPopupMenu->setCheckable( true ); | 492 | mItemPopupMenu->setCheckable( true ); |
493 | 493 | ||
494 | 494 | ||
495 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 495 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
496 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 496 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
497 | 497 | ||
498 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 498 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
499 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 499 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
500 | 500 | ||
501 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 501 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
502 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 502 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
503 | 503 | ||
504 | 504 | ||
505 | // Double clicking conflicts with opening/closing the subtree | 505 | // Double clicking conflicts with opening/closing the subtree |
506 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 506 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
507 | SLOT( editItem( QListViewItem *) ) ); | 507 | SLOT( editItem( QListViewItem *) ) ); |
508 | /* | 508 | /* |
509 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 509 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
510 | const QPoint &,int ) ), | 510 | const QPoint &,int ) ), |
511 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 511 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
512 | */ | 512 | */ |
513 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 513 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
514 | const QPoint &,int ) ), | 514 | const QPoint &,int ) ), |
515 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 515 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
516 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 516 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
517 | SLOT( itemClicked( QListViewItem * ) ) ); | 517 | SLOT( itemClicked( QListViewItem * ) ) ); |
518 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 518 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
519 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 519 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
520 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 520 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
521 | SLOT( updateView() ) ); | 521 | SLOT( updateView() ) ); |
522 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 522 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
523 | SLOT( todoModified(Todo *, int) ) ); | 523 | SLOT( todoModified(Todo *, int) ) ); |
524 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 524 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
525 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 525 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
526 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 526 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
527 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 527 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
528 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 528 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
529 | SLOT( paintNeeded()) ); | 529 | SLOT( paintNeeded()) ); |
530 | 530 | ||
531 | #if 0 | 531 | #if 0 |
532 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 532 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
533 | SLOT(selectionChanged(QListViewItem *))); | 533 | SLOT(selectionChanged(QListViewItem *))); |
534 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 534 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
535 | SLOT(selectionChanged(QListViewItem *))); | 535 | SLOT(selectionChanged(QListViewItem *))); |
536 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 536 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
537 | SLOT(selectionChanged(QListViewItem *))); | 537 | SLOT(selectionChanged(QListViewItem *))); |
538 | #endif | 538 | #endif |
539 | 539 | ||
540 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 540 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
541 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 541 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
542 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 542 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
543 | 543 | ||
544 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 544 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
545 | SLOT( processSelectionChange() ) ); | 545 | SLOT( processSelectionChange() ) ); |
546 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 546 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
547 | SLOT( addQuickTodo() ) ); | 547 | SLOT( addQuickTodo() ) ); |
548 | 548 | ||
549 | } | 549 | } |
550 | 550 | ||
551 | KOTodoView::~KOTodoView() | 551 | KOTodoView::~KOTodoView() |
552 | { | 552 | { |
553 | delete mDocPrefs; | 553 | delete mDocPrefs; |
554 | } | 554 | } |
555 | QString KOTodoView::getWhatsThisText(QPoint p) | 555 | QString KOTodoView::getWhatsThisText(QPoint p) |
556 | { | 556 | { |
557 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 557 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
558 | if ( item ) | 558 | if ( item ) |
559 | return KIncidenceFormatter::instance()->getFormattedText( item->todo() ); | 559 | return KIncidenceFormatter::instance()->getFormattedText( item->todo() ); |
560 | return i18n("That is the todo view" ); | 560 | return i18n("That is the todo view" ); |
561 | 561 | ||
562 | } | 562 | } |
563 | 563 | ||
564 | void KOTodoView::jumpToDate () | 564 | void KOTodoView::jumpToDate () |
565 | { | 565 | { |
566 | // if (mActiveItem) { | 566 | // if (mActiveItem) { |
567 | // mActiveItem->todo()); | 567 | // mActiveItem->todo()); |
568 | // if ( mActiveItem->todo()->hasDueDate() ) | 568 | // if ( mActiveItem->todo()->hasDueDate() ) |
569 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 569 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
570 | } | 570 | } |
571 | void KOTodoView::paintNeeded() | 571 | void KOTodoView::paintNeeded() |
572 | { | 572 | { |
573 | if ( mPendingUpdateBeforeRepaint ) { | 573 | if ( mPendingUpdateBeforeRepaint ) { |
574 | updateView(); | 574 | updateView(); |
575 | mPendingUpdateBeforeRepaint = false; | 575 | mPendingUpdateBeforeRepaint = false; |
576 | } | 576 | } |
577 | } | 577 | } |
578 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 578 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
579 | { | 579 | { |
580 | if ( mPendingUpdateBeforeRepaint ) { | 580 | if ( mPendingUpdateBeforeRepaint ) { |
581 | updateView(); | 581 | updateView(); |
582 | mPendingUpdateBeforeRepaint = false; | 582 | mPendingUpdateBeforeRepaint = false; |
583 | } | 583 | } |
584 | KOrg::BaseView::paintEvent( pevent); | 584 | KOrg::BaseView::paintEvent( pevent); |
585 | } | 585 | } |
586 | 586 | ||
587 | void KOTodoView::updateView() | 587 | void KOTodoView::updateView() |
588 | { | 588 | { |
589 | pendingSubtodo = 0; | 589 | pendingSubtodo = 0; |
590 | if ( mBlockUpdate ) { | 590 | if ( mBlockUpdate ) { |
591 | return; | 591 | return; |
592 | } | 592 | } |
593 | if ( !isVisible() ) { | 593 | if ( !isVisible() ) { |
594 | mPendingUpdateBeforeRepaint = true; | 594 | mPendingUpdateBeforeRepaint = true; |
595 | return; | 595 | return; |
596 | } | 596 | } |
597 | //qDebug("KOTodoView::updateView() %x", this); | 597 | //qDebug("KOTodoView::updateView() %x", this); |
598 | if ( isFlatDisplay ) { | 598 | if ( isFlatDisplay ) { |
599 | displayAllFlat(); | 599 | displayAllFlat(); |
600 | return; | 600 | return; |
601 | } | 601 | } |
602 | //qDebug("update "); | 602 | //qDebug("update "); |
603 | // kdDebug() << "KOTodoView::updateView()" << endl; | 603 | // kdDebug() << "KOTodoView::updateView()" << endl; |
604 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 604 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
605 | mTodoListView->clear(); | 605 | mTodoListView->clear(); |
606 | if ( mName == "todolistsmall" ) { | 606 | if ( mName == "todolistsmall" ) { |
607 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 607 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
608 | int ps = fo.pointSize() -2; | 608 | int ps = fo.pointSize() -2; |
609 | if ( ps > 12 ) | 609 | if ( ps > 12 ) |
610 | ps -= 2; | 610 | ps -= 2; |
611 | fo.setPointSize( ps ); | 611 | fo.setPointSize( ps ); |
612 | } | 612 | } |
613 | } | 613 | } |
614 | 614 | ||
615 | mTodoListView->setFont( fo ); | 615 | mTodoListView->setFont( fo ); |
616 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 616 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
617 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 617 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
618 | QPtrList<Todo> todoList = calendar()->todos(); | 618 | QPtrList<Todo> todoList = calendar()->todos(); |
619 | 619 | ||
620 | /* | 620 | /* |
621 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 621 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
622 | Event *t; | 622 | Event *t; |
623 | for(t = todoList.first(); t; t = todoList.next()) { | 623 | for(t = todoList.first(); t; t = todoList.next()) { |
624 | kdDebug() << " " << t->getSummary() << endl; | 624 | kdDebug() << " " << t->getSummary() << endl; |
625 | 625 | ||
626 | if (t->getRelatedTo()) { | 626 | if (t->getRelatedTo()) { |
627 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 627 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
628 | } | 628 | } |
629 | 629 | ||
630 | QPtrList<Event> l = t->getRelations(); | 630 | QPtrList<Event> l = t->getRelations(); |
631 | Event *c; | 631 | Event *c; |
632 | for(c=l.first();c;c=l.next()) { | 632 | for(c=l.first();c;c=l.next()) { |
633 | kdDebug() << " - relation: " << c->getSummary() << endl; | 633 | kdDebug() << " - relation: " << c->getSummary() << endl; |
634 | } | 634 | } |
635 | } | 635 | } |
636 | */ | 636 | */ |
637 | 637 | ||
638 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 638 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
639 | // specific order of events. That means that we have to generate parent items | 639 | // specific order of events. That means that we have to generate parent items |
640 | // recursively for proper hierarchical display of Todos. | 640 | // recursively for proper hierarchical display of Todos. |
641 | mTodoMap.clear(); | 641 | mTodoMap.clear(); |
642 | Todo *todo; | 642 | Todo *todo; |
643 | todo = todoList.first();// todo; todo = todoList.next()) { | 643 | todo = todoList.first();// todo; todo = todoList.next()) { |
644 | while ( todo ) { | 644 | while ( todo ) { |
645 | bool next = true; | 645 | bool next = true; |
646 | // qDebug("todo %s ", todo->summary().latin1()); | 646 | // qDebug("todo %s ", todo->summary().latin1()); |
647 | Incidence *incidence = todo->relatedTo(); | 647 | Incidence *incidence = todo->relatedTo(); |
648 | while ( incidence ) { | 648 | while ( incidence ) { |
649 | if ( incidence->type() == "Todo") { | 649 | if ( incidence->type() == "Todo") { |
650 | //qDebug("related %s ",incidence->summary().latin1() ); | 650 | //qDebug("related %s ",incidence->summary().latin1() ); |
651 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 651 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
652 | //qDebug("related not found "); | 652 | //qDebug("related not found "); |
653 | todoList.remove( ); | 653 | todoList.remove( ); |
654 | todo = todoList.current(); | 654 | todo = todoList.current(); |
655 | next = false; | 655 | next = false; |
656 | incidence = 0; | 656 | incidence = 0; |
657 | 657 | ||
658 | } else { | 658 | } else { |
659 | //qDebug("related found "); | 659 | //qDebug("related found "); |
660 | incidence = incidence->relatedTo(); | 660 | incidence = incidence->relatedTo(); |
661 | } | 661 | } |
662 | } else | 662 | } else |
663 | incidence = 0; | 663 | incidence = 0; |
664 | } | 664 | } |
665 | if ( next ) | 665 | if ( next ) |
666 | todo = todoList.next(); | 666 | todo = todoList.next(); |
667 | } | 667 | } |
668 | // qDebug("again .... "); | 668 | // qDebug("again .... "); |
669 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 669 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
670 | 670 | ||
671 | // qDebug("yytodo %s ", todo->summary().latin1()); | 671 | // qDebug("yytodo %s ", todo->summary().latin1()); |
672 | // } | 672 | // } |
673 | //qDebug("for "); | 673 | //qDebug("for "); |
674 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 674 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
675 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 675 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
676 | { | 676 | { |
677 | insertTodoItem(todo); | 677 | insertTodoItem(todo); |
678 | } | 678 | } |
679 | } | 679 | } |
680 | //qDebug("for end "); | 680 | //qDebug("for end "); |
681 | // Restore opened/closed state | 681 | // Restore opened/closed state |
682 | mTodoListView->blockSignals( true ); | 682 | mTodoListView->blockSignals( true ); |
683 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 683 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
684 | mTodoListView->blockSignals( false ); | 684 | mTodoListView->blockSignals( false ); |
685 | mTodoListView->setFocus(); | 685 | mTodoListView->setFocus(); |
686 | processSelectionChange(); | 686 | processSelectionChange(); |
687 | } | 687 | } |
688 | 688 | ||
689 | bool KOTodoView::checkTodo( Todo * todo ) | 689 | bool KOTodoView::checkTodo( Todo * todo ) |
690 | { | 690 | { |
691 | 691 | ||
692 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 692 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
693 | return false; | 693 | return false; |
694 | if ( !todo->isCompleted() ) { | 694 | if ( !todo->isCompleted() ) { |
695 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 695 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
696 | return true; | 696 | return true; |
697 | } | 697 | } |
698 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 698 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
699 | if ( todo->hasStartDate() ) | 699 | if ( todo->hasStartDate() ) |
700 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 700 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
701 | return false; | 701 | return false; |
702 | if ( todo->hasDueDate() ) | 702 | if ( todo->hasDueDate() ) |
703 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 703 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
704 | return false; | 704 | return false; |
705 | } | 705 | } |
706 | return true; | 706 | return true; |
707 | } | 707 | } |
708 | 708 | ||
709 | void KOTodoView::restoreItemState( QListViewItem *item ) | 709 | void KOTodoView::restoreItemState( QListViewItem *item ) |
710 | { | 710 | { |
711 | pendingSubtodo = 0; | 711 | pendingSubtodo = 0; |
712 | while( item ) { | 712 | while( item ) { |
713 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 713 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
714 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 714 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
715 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 715 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
716 | item = item->nextSibling(); | 716 | item = item->nextSibling(); |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | 720 | ||
721 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 721 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
722 | KOTodoView::insertTodoItem(Todo *todo) | 722 | KOTodoView::insertTodoItem(Todo *todo) |
723 | { | 723 | { |
724 | 724 | ||
725 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 725 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
726 | // TODO: Check, if dynmaic cast is necessary | 726 | // TODO: Check, if dynmaic cast is necessary |
727 | 727 | ||
728 | pendingSubtodo = 0; | 728 | pendingSubtodo = 0; |
729 | Incidence *incidence = todo->relatedTo(); | 729 | Incidence *incidence = todo->relatedTo(); |
730 | if (incidence && incidence->type() == "Todo") { | 730 | if (incidence && incidence->type() == "Todo") { |
731 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 731 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
732 | 732 | ||
733 | // kdDebug() << " has Related" << endl; | 733 | // kdDebug() << " has Related" << endl; |
734 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 734 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
735 | itemIterator = mTodoMap.find(relatedTodo); | 735 | itemIterator = mTodoMap.find(relatedTodo); |
736 | if (itemIterator == mTodoMap.end()) { | 736 | if (itemIterator == mTodoMap.end()) { |
737 | // kdDebug() << " related not yet in list" << endl; | 737 | // kdDebug() << " related not yet in list" << endl; |
738 | itemIterator = insertTodoItem (relatedTodo); | 738 | itemIterator = insertTodoItem (relatedTodo); |
739 | } | 739 | } |
740 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 740 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
741 | // and one into the map. Sure finding is more easy but why? -zecke | 741 | // and one into the map. Sure finding is more easy but why? -zecke |
742 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 742 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
743 | return mTodoMap.insert(todo,todoItem); | 743 | return mTodoMap.insert(todo,todoItem); |
744 | } else { | 744 | } else { |
745 | // kdDebug() << " no Related" << endl; | 745 | // kdDebug() << " no Related" << endl; |
746 | // see above -zecke | 746 | // see above -zecke |
747 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 747 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
748 | return mTodoMap.insert(todo,todoItem); | 748 | return mTodoMap.insert(todo,todoItem); |
749 | } | 749 | } |
750 | } | 750 | } |
751 | 751 | ||
752 | 752 | ||
753 | void KOTodoView::updateConfig() | 753 | void KOTodoView::updateConfig() |
754 | { | 754 | { |
755 | updateView(); | 755 | updateView(); |
756 | mTodoListView->repaintContents(); | 756 | mTodoListView->repaintContents(); |
757 | } | 757 | } |
758 | 758 | ||
759 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 759 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
760 | { | 760 | { |
761 | QPtrList<Incidence> selected; | 761 | QPtrList<Incidence> selected; |
762 | 762 | ||
763 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 763 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
764 | // if (!item) item = mActiveItem; | 764 | // if (!item) item = mActiveItem; |
765 | if (item) selected.append(item->todo()); | 765 | if (item) selected.append(item->todo()); |
766 | 766 | ||
767 | return selected; | 767 | return selected; |
768 | } | 768 | } |
769 | 769 | ||
770 | QPtrList<Todo> KOTodoView::selectedTodos() | 770 | QPtrList<Todo> KOTodoView::selectedTodos() |
771 | { | 771 | { |
772 | QPtrList<Todo> selected; | 772 | QPtrList<Todo> selected; |
773 | 773 | ||
774 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 774 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
775 | // if (!item) item = mActiveItem; | 775 | // if (!item) item = mActiveItem; |
776 | if (item) selected.append(item->todo()); | 776 | if (item) selected.append(item->todo()); |
777 | 777 | ||
778 | return selected; | 778 | return selected; |
779 | } | 779 | } |
780 | 780 | ||
781 | void KOTodoView::changeEventDisplay(Event *, int) | 781 | void KOTodoView::changeEventDisplay(Event *, int) |
782 | { | 782 | { |
783 | updateView(); | 783 | updateView(); |
784 | } | 784 | } |
785 | 785 | ||
786 | void KOTodoView::showDates(const QDate &, const QDate &) | 786 | void KOTodoView::showDates(const QDate &, const QDate &) |
787 | { | 787 | { |
788 | } | 788 | } |
789 | 789 | ||
790 | void KOTodoView::showEvents(QPtrList<Event>) | 790 | void KOTodoView::showEvents(QPtrList<Event>) |
791 | { | 791 | { |
792 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 792 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
793 | } | 793 | } |
794 | 794 | ||
795 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 795 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
796 | const QDate &td) | 796 | const QDate &td) |
797 | { | 797 | { |
798 | #ifndef KORG_NOPRINTER | 798 | #ifndef KORG_NOPRINTER |
799 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 799 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
800 | #endif | 800 | #endif |
801 | } | 801 | } |
802 | 802 | ||
803 | void KOTodoView::editItem(QListViewItem *item ) | 803 | void KOTodoView::editItem(QListViewItem *item ) |
804 | { | 804 | { |
805 | // qDebug("editItem(QListViewItem *item ) "); | 805 | // qDebug("editItem(QListViewItem *item ) "); |
806 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 806 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
807 | } | 807 | } |
808 | 808 | ||
809 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 809 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
810 | { | 810 | { |
811 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 811 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
812 | } | 812 | } |
813 | 813 | ||
814 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 814 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
815 | { | 815 | { |
816 | pendingSubtodo = 0; | 816 | pendingSubtodo = 0; |
817 | mActiveItem = (KOTodoViewItem *)item; | 817 | mActiveItem = (KOTodoViewItem *)item; |
818 | if (item) { | 818 | if (item) { |
819 | switch (column){ | 819 | switch (column){ |
820 | case 1: | 820 | case 1: |
821 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 821 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
822 | case 2: | 822 | case 2: |
823 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 823 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
824 | case 3: | 824 | case 3: |
825 | moveTodo(); | 825 | moveTodo(); |
826 | break; | 826 | break; |
827 | case 8: | 827 | case 8: |
828 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 828 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
829 | default: | 829 | default: |
830 | mItemPopupMenu->popup(QCursor::pos()); | 830 | mItemPopupMenu->popup(QCursor::pos()); |
831 | } | 831 | } |
832 | } else mPopupMenu->popup(QCursor::pos()); | 832 | } else mPopupMenu->popup(QCursor::pos()); |
833 | } | 833 | } |
834 | void KOTodoView::newTodo() | 834 | void KOTodoView::newTodo() |
835 | { | 835 | { |
836 | emit newTodoSignal(); | 836 | emit newTodoSignal(); |
837 | } | 837 | } |
838 | 838 | ||
839 | void KOTodoView::newSubTodo() | 839 | void KOTodoView::newSubTodo() |
840 | { | 840 | { |
841 | if (mActiveItem) { | 841 | if (mActiveItem) { |
842 | emit newSubTodoSignal(mActiveItem->todo()); | 842 | emit newSubTodoSignal(mActiveItem->todo()); |
843 | } | 843 | } |
844 | } | 844 | } |
845 | void KOTodoView::unparentTodo() | 845 | void KOTodoView::unparentTodo() |
846 | { | 846 | { |
847 | if (mActiveItem) { | 847 | if (mActiveItem) { |
848 | emit unparentTodoSignal(mActiveItem->todo()); | 848 | emit unparentTodoSignal(mActiveItem->todo()); |
849 | } | 849 | } |
850 | } | 850 | } |
851 | 851 | ||
852 | void KOTodoView::reparentTodo() | 852 | void KOTodoView::reparentTodo() |
853 | { | 853 | { |
854 | if (mActiveItem) { | 854 | if (mActiveItem) { |
855 | qDebug("KOTodoView::reparentTodo() "); | 855 | qDebug("KOTodoView::reparentTodo() "); |
856 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 856 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
857 | pendingSubtodo = mActiveItem; | 857 | pendingSubtodo = mActiveItem; |
858 | } | 858 | } |
859 | } | 859 | } |
860 | void KOTodoView::editTodo() | 860 | void KOTodoView::editTodo() |
861 | { | 861 | { |
862 | if (mActiveItem) { | 862 | if (mActiveItem) { |
863 | emit editTodoSignal(mActiveItem->todo()); | 863 | emit editTodoSignal(mActiveItem->todo()); |
864 | } | 864 | } |
865 | } | 865 | } |
866 | void KOTodoView::cloneTodo() | 866 | void KOTodoView::cloneTodo() |
867 | { | 867 | { |
868 | if (mActiveItem) { | 868 | if (mActiveItem) { |
869 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 869 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | void KOTodoView::cancelTodo() | 872 | void KOTodoView::cancelTodo() |
873 | { | 873 | { |
874 | if (mActiveItem) { | 874 | if (mActiveItem) { |
875 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 875 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
876 | } | 876 | } |
877 | } | 877 | } |
878 | void KOTodoView::moveTodo() | 878 | void KOTodoView::moveTodo() |
879 | { | 879 | { |
880 | if (mActiveItem) { | 880 | if (mActiveItem) { |
881 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 881 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
882 | } | 882 | } |
883 | } | 883 | } |
884 | void KOTodoView::beamTodo() | 884 | void KOTodoView::beamTodo() |
885 | { | 885 | { |
886 | if (mActiveItem) { | 886 | if (mActiveItem) { |
887 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 887 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
888 | } | 888 | } |
889 | } | 889 | } |
890 | 890 | ||
891 | 891 | ||
892 | void KOTodoView::showTodo() | 892 | void KOTodoView::showTodo() |
893 | { | 893 | { |
894 | if (mActiveItem) { | 894 | if (mActiveItem) { |
895 | emit showTodoSignal(mActiveItem->todo()); | 895 | emit showTodoSignal(mActiveItem->todo()); |
896 | } | 896 | } |
897 | } | 897 | } |
898 | 898 | ||
899 | void KOTodoView::deleteTodo() | 899 | void KOTodoView::deleteTodo() |
900 | { | 900 | { |
901 | if (mActiveItem) { | 901 | if (mActiveItem) { |
902 | emit deleteTodoSignal(mActiveItem->todo()); | 902 | emit deleteTodoSignal(mActiveItem->todo()); |
903 | } | 903 | } |
904 | } | 904 | } |
905 | 905 | ||
906 | void KOTodoView::setNewPriority(int index) | 906 | void KOTodoView::setNewPriority(int index) |
907 | { | 907 | { |
908 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 908 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
909 | mActiveItem->todo()->setPriority(mPriority[index]); | 909 | mActiveItem->todo()->setPriority(mPriority[index]); |
910 | mActiveItem->construct(); | 910 | mActiveItem->construct(); |
911 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 911 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
912 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 912 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
913 | } | 913 | } |
914 | } | 914 | } |
915 | 915 | ||
916 | void KOTodoView::setNewPercentage(int index) | 916 | void KOTodoView::setNewPercentage(int index) |
917 | { | 917 | { |
918 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 918 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
919 | 919 | ||
920 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 920 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
921 | mActiveItem->setOn( true ); | 921 | mActiveItem->setOn( true ); |
922 | return; | 922 | return; |
923 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 923 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
924 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 924 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
925 | if ( par && par->isOn() ) | 925 | if ( par && par->isOn() ) |
926 | par->setOn( false ); | 926 | par->setOn( false ); |
927 | } | 927 | } |
928 | if (mPercentage[index] == 100) { | 928 | if (mPercentage[index] == 100) { |
929 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 929 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
930 | } else { | 930 | } else { |
931 | mActiveItem->todo()->setCompleted(false); | 931 | mActiveItem->todo()->setCompleted(false); |
932 | } | 932 | } |
933 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 933 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
934 | mActiveItem->construct(); | 934 | mActiveItem->construct(); |
935 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 935 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
936 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 936 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | 939 | ||
940 | 940 | ||
941 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 941 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
942 | { | 942 | { |
943 | QPopupMenu* tempMenu = new QPopupMenu (this); | 943 | QPopupMenu* tempMenu = new QPopupMenu (this); |
944 | QStringList checkedCategories = todoItem->todo()->categories (); | 944 | QStringList checkedCategories = todoItem->todo()->categories (); |
945 | 945 | ||
946 | tempMenu->setCheckable (true); | 946 | tempMenu->setCheckable (true); |
947 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 947 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
948 | it != KOPrefs::instance()->mCustomCategories.end (); | 948 | it != KOPrefs::instance()->mCustomCategories.end (); |
949 | ++it) { | 949 | ++it) { |
950 | int index = tempMenu->insertItem (*it); | 950 | int index = tempMenu->insertItem (*it); |
951 | mCategory[index] = *it; | 951 | mCategory[index] = *it; |
952 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 952 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
953 | } | 953 | } |
954 | 954 | ||
955 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 955 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
956 | return tempMenu; | 956 | return tempMenu; |
957 | 957 | ||
958 | 958 | ||
959 | } | 959 | } |
960 | void KOTodoView::changedCategories(int index) | 960 | void KOTodoView::changedCategories(int index) |
961 | { | 961 | { |
962 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 962 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
963 | QStringList categories = mActiveItem->todo()->categories (); | 963 | QStringList categories = mActiveItem->todo()->categories (); |
964 | QString colcat = categories.first(); | ||
964 | if (categories.find (mCategory[index]) != categories.end ()) | 965 | if (categories.find (mCategory[index]) != categories.end ()) |
965 | categories.remove (mCategory[index]); | 966 | categories.remove (mCategory[index]); |
966 | else | 967 | else |
967 | categories.insert (categories.end(), mCategory[index]); | 968 | categories.insert (categories.end(), mCategory[index]); |
968 | categories.sort (); | 969 | categories.sort (); |
970 | if ( !colcat.isEmpty() ) { | ||
971 | if ( categories.find ( colcat ) != categories.end () ) { | ||
972 | categories.remove( colcat ); | ||
973 | categories.prepend( colcat ); | ||
974 | } | ||
975 | } | ||
969 | mActiveItem->todo()->setCategories (categories); | 976 | mActiveItem->todo()->setCategories (categories); |
970 | mActiveItem->construct(); | 977 | mActiveItem->construct(); |
971 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 978 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
972 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 979 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
973 | } | 980 | } |
974 | } | 981 | } |
975 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 982 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
976 | { | 983 | { |
977 | if ( pendingSubtodo != 0 ) { | 984 | if ( pendingSubtodo != 0 ) { |
978 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 985 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
979 | } | 986 | } |
980 | pendingSubtodo = 0; | 987 | pendingSubtodo = 0; |
981 | if (!item) { | 988 | if (!item) { |
982 | newTodo(); | 989 | newTodo(); |
983 | return; | 990 | return; |
984 | } | 991 | } |
985 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 992 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
986 | editItem( item ); | 993 | editItem( item ); |
987 | else | 994 | else |
988 | showItem( item , QPoint(), 0 ); | 995 | showItem( item , QPoint(), 0 ); |
989 | } | 996 | } |
990 | void KOTodoView::itemClicked(QListViewItem *item) | 997 | void KOTodoView::itemClicked(QListViewItem *item) |
991 | { | 998 | { |
992 | 999 | ||
993 | if (!item) { | 1000 | if (!item) { |
994 | if ( pendingSubtodo != 0 ) { | 1001 | if ( pendingSubtodo != 0 ) { |
995 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1002 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
996 | } | 1003 | } |
997 | pendingSubtodo = 0; | 1004 | pendingSubtodo = 0; |
998 | return; | 1005 | return; |
999 | } | 1006 | } |
1000 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1007 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1001 | if ( pendingSubtodo != 0 ) { | 1008 | if ( pendingSubtodo != 0 ) { |
1002 | bool allowReparent = true; | 1009 | bool allowReparent = true; |
1003 | QListViewItem *par = item; | 1010 | QListViewItem *par = item; |
1004 | while ( par ) { | 1011 | while ( par ) { |
1005 | if ( par == pendingSubtodo ) { | 1012 | if ( par == pendingSubtodo ) { |
1006 | allowReparent = false; | 1013 | allowReparent = false; |
1007 | break; | 1014 | break; |
1008 | } | 1015 | } |
1009 | par = par->parent(); | 1016 | par = par->parent(); |
1010 | } | 1017 | } |
1011 | if ( !allowReparent ) { | 1018 | if ( !allowReparent ) { |
1012 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1019 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1013 | qDebug("Recursive reparenting not possible "); | 1020 | qDebug("Recursive reparenting not possible "); |
1014 | pendingSubtodo = 0; | 1021 | pendingSubtodo = 0; |
1015 | } else { | 1022 | } else { |
1016 | Todo* newParent = todoItem->todo(); | 1023 | Todo* newParent = todoItem->todo(); |
1017 | Todo* newSub = pendingSubtodo->todo(); | 1024 | Todo* newSub = pendingSubtodo->todo(); |
1018 | pendingSubtodo = 0; | 1025 | pendingSubtodo = 0; |
1019 | emit reparentTodoSignal( newParent,newSub ); | 1026 | emit reparentTodoSignal( newParent,newSub ); |
1020 | return; | 1027 | return; |
1021 | } | 1028 | } |
1022 | } | 1029 | } |
1023 | #if 0 | 1030 | #if 0 |
1024 | // handled by the item itself | 1031 | // handled by the item itself |
1025 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? | 1032 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? |
1026 | qDebug("com %d ",completed ); | 1033 | qDebug("com %d ",completed ); |
1027 | qDebug("itemclicked "); | 1034 | qDebug("itemclicked "); |
1028 | if (todoItem->isOn()) { | 1035 | if (todoItem->isOn()) { |
1029 | qDebug("on "); | 1036 | qDebug("on "); |
1030 | if (!completed) { | 1037 | if (!completed) { |
1031 | qDebug("set true "); | 1038 | qDebug("set true "); |
1032 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1039 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1033 | } | 1040 | } |
1034 | } else { | 1041 | } else { |
1035 | qDebug("not on "); | 1042 | qDebug("not on "); |
1036 | if (completed) { | 1043 | if (completed) { |
1037 | qDebug("set false "); | 1044 | qDebug("set false "); |
1038 | todoItem->todo()->setCompleted(false); | 1045 | todoItem->todo()->setCompleted(false); |
1039 | } | 1046 | } |
1040 | } | 1047 | } |
1041 | #endif | 1048 | #endif |
1042 | } | 1049 | } |
1043 | 1050 | ||
1044 | void KOTodoView::setDocumentId( const QString &id ) | 1051 | void KOTodoView::setDocumentId( const QString &id ) |
1045 | { | 1052 | { |
1046 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 1053 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |
1047 | 1054 | ||
1048 | mDocPrefs->setDoc( id ); | 1055 | mDocPrefs->setDoc( id ); |
1049 | } | 1056 | } |
1050 | 1057 | ||
1051 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1058 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1052 | { | 1059 | { |
1053 | if (!item) return; | 1060 | if (!item) return; |
1054 | 1061 | ||
1055 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1062 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1056 | 1063 | ||
1057 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1064 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1058 | 1065 | ||
1059 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1066 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1060 | } | 1067 | } |
1061 | 1068 | ||
1062 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1069 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1063 | { | 1070 | { |
1064 | mTodoListView->saveLayout(config,group); | 1071 | mTodoListView->saveLayout(config,group); |
1065 | } | 1072 | } |
1066 | 1073 | ||
1067 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1074 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1068 | { | 1075 | { |
1069 | mTodoListView->restoreLayout(config,group); | 1076 | mTodoListView->restoreLayout(config,group); |
1070 | } | 1077 | } |
1071 | 1078 | ||
1072 | void KOTodoView::processSelectionChange() | 1079 | void KOTodoView::processSelectionChange() |
1073 | { | 1080 | { |
1074 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1081 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1075 | 1082 | ||
1076 | KOTodoViewItem *item = | 1083 | KOTodoViewItem *item = |
1077 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1084 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1078 | 1085 | ||
1079 | if ( !item ) { | 1086 | if ( !item ) { |
1080 | emit incidenceSelected( 0 ); | 1087 | emit incidenceSelected( 0 ); |
1081 | } else { | 1088 | } else { |
1082 | emit incidenceSelected( item->todo() ); | 1089 | emit incidenceSelected( item->todo() ); |
1083 | } | 1090 | } |
1084 | } | 1091 | } |
1085 | 1092 | ||
1086 | void KOTodoView::modified(bool b) | 1093 | void KOTodoView::modified(bool b) |
1087 | { | 1094 | { |
1088 | emit isModified(b); | 1095 | emit isModified(b); |
1089 | } | 1096 | } |
1090 | void KOTodoView::setTodoModified( Todo* todo ) | 1097 | void KOTodoView::setTodoModified( Todo* todo ) |
1091 | { | 1098 | { |
1092 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1099 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1093 | } | 1100 | } |
1094 | void KOTodoView::clearSelection() | 1101 | void KOTodoView::clearSelection() |
1095 | { | 1102 | { |
1096 | mTodoListView->selectAll( false ); | 1103 | mTodoListView->selectAll( false ); |
1097 | } | 1104 | } |
1098 | void KOTodoView::setAllOpen() | 1105 | void KOTodoView::setAllOpen() |
1099 | { | 1106 | { |
1100 | if ( isFlatDisplay ) { | 1107 | if ( isFlatDisplay ) { |
1101 | isFlatDisplay = false; | 1108 | isFlatDisplay = false; |
1102 | mPopupMenu->setItemChecked( 8,false ); | 1109 | mPopupMenu->setItemChecked( 8,false ); |
1103 | updateView(); | 1110 | updateView(); |
1104 | } | 1111 | } |
1105 | setOpen(mTodoListView->firstChild(), true); | 1112 | setOpen(mTodoListView->firstChild(), true); |
1106 | } | 1113 | } |
1107 | void KOTodoView::setAllClose() | 1114 | void KOTodoView::setAllClose() |
1108 | { | 1115 | { |
1109 | if ( isFlatDisplay ) { | 1116 | if ( isFlatDisplay ) { |
1110 | isFlatDisplay = false; | 1117 | isFlatDisplay = false; |
1111 | mPopupMenu->setItemChecked( 8,false ); | 1118 | mPopupMenu->setItemChecked( 8,false ); |
1112 | updateView(); | 1119 | updateView(); |
1113 | } | 1120 | } |
1114 | setOpen(mTodoListView->firstChild(), false); | 1121 | setOpen(mTodoListView->firstChild(), false); |
1115 | } | 1122 | } |
1116 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1123 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1117 | { | 1124 | { |
1118 | 1125 | ||
1119 | while ( item ) { | 1126 | while ( item ) { |
1120 | setOpen( item->firstChild(), setOpenI ); | 1127 | setOpen( item->firstChild(), setOpenI ); |
1121 | item->setOpen( setOpenI ); | 1128 | item->setOpen( setOpenI ); |
1122 | item = item->nextSibling(); | 1129 | item = item->nextSibling(); |
1123 | } | 1130 | } |
1124 | } | 1131 | } |
1125 | 1132 | ||
1126 | void KOTodoView::displayAllFlat() | 1133 | void KOTodoView::displayAllFlat() |
1127 | { | 1134 | { |
1128 | pendingSubtodo = 0; | 1135 | pendingSubtodo = 0; |
1129 | if ( mBlockUpdate ) { | 1136 | if ( mBlockUpdate ) { |
1130 | return; | 1137 | return; |
1131 | } | 1138 | } |
1132 | mPopupMenu->setItemChecked( 8,true ); | 1139 | mPopupMenu->setItemChecked( 8,true ); |
1133 | isFlatDisplay = true; | 1140 | isFlatDisplay = true; |
1134 | QPtrList<Todo> todoList = calendar()->todos(); | 1141 | QPtrList<Todo> todoList = calendar()->todos(); |
1135 | mTodoMap.clear(); | 1142 | mTodoMap.clear(); |
1136 | mTodoListView->clear(); | 1143 | mTodoListView->clear(); |
1137 | Todo *todo; | 1144 | Todo *todo; |
1138 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1145 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1139 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1146 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1140 | mTodoMap.insert(todo,todoItem); | 1147 | mTodoMap.insert(todo,todoItem); |
1141 | } | 1148 | } |
1142 | mTodoListView->setFocus(); | 1149 | mTodoListView->setFocus(); |
1143 | processSelectionChange(); | 1150 | processSelectionChange(); |
1144 | } | 1151 | } |
1145 | 1152 | ||
1146 | void KOTodoView::setAllFlat() | 1153 | void KOTodoView::setAllFlat() |
1147 | { | 1154 | { |
1148 | if ( isFlatDisplay ) { | 1155 | if ( isFlatDisplay ) { |
1149 | isFlatDisplay = false; | 1156 | isFlatDisplay = false; |
1150 | mPopupMenu->setItemChecked( 8,false ); | 1157 | mPopupMenu->setItemChecked( 8,false ); |
1151 | updateView(); | 1158 | updateView(); |
1152 | return; | 1159 | return; |
1153 | } | 1160 | } |
1154 | displayAllFlat(); | 1161 | displayAllFlat(); |
1155 | } | 1162 | } |
1156 | 1163 | ||
1157 | void KOTodoView::purgeCompleted() | 1164 | void KOTodoView::purgeCompleted() |
1158 | { | 1165 | { |
1159 | emit purgeCompletedSignal(); | 1166 | emit purgeCompletedSignal(); |
1160 | } | 1167 | } |
1161 | void KOTodoView::toggleQuickTodo() | 1168 | void KOTodoView::toggleQuickTodo() |
1162 | { | 1169 | { |
1163 | if ( mQuickAdd->isVisible() ) { | 1170 | if ( mQuickAdd->isVisible() ) { |
1164 | mQuickAdd->hide(); | 1171 | mQuickAdd->hide(); |
1165 | KOPrefs::instance()->mEnableQuickTodo = false; | 1172 | KOPrefs::instance()->mEnableQuickTodo = false; |
1166 | } | 1173 | } |
1167 | else { | 1174 | else { |
1168 | mQuickAdd->show(); | 1175 | mQuickAdd->show(); |
1169 | KOPrefs::instance()->mEnableQuickTodo = true; | 1176 | KOPrefs::instance()->mEnableQuickTodo = true; |
1170 | } | 1177 | } |
1171 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1178 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1172 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1179 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1173 | } | 1180 | } |
1174 | 1181 | ||
1175 | void KOTodoView::toggleRunning() | 1182 | void KOTodoView::toggleRunning() |
1176 | { | 1183 | { |
1177 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1184 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1178 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1185 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1179 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1186 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1180 | updateView(); | 1187 | updateView(); |
1181 | } | 1188 | } |
1182 | 1189 | ||
1183 | void KOTodoView::toggleCompleted() | 1190 | void KOTodoView::toggleCompleted() |
1184 | { | 1191 | { |
1185 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1192 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1186 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1193 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1187 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1194 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1188 | updateView(); | 1195 | updateView(); |
1189 | } | 1196 | } |
1190 | 1197 | ||
1191 | void KOTodoView::addQuickTodo() | 1198 | void KOTodoView::addQuickTodo() |
1192 | { | 1199 | { |
1193 | Todo *todo = new Todo(); | 1200 | Todo *todo = new Todo(); |
1194 | todo->setSummary(mQuickAdd->text()); | 1201 | todo->setSummary(mQuickAdd->text()); |
1195 | todo->setOrganizer(KOPrefs::instance()->email()); | 1202 | todo->setOrganizer(KOPrefs::instance()->email()); |
1196 | CalFilter * cf = mCalendar->filter(); | 1203 | CalFilter * cf = mCalendar->filter(); |
1197 | if ( cf ) { | 1204 | if ( cf ) { |
1198 | if ( cf->isEnabled()&& cf->showCategories()) { | 1205 | if ( cf->isEnabled()&& cf->showCategories()) { |
1199 | todo->setCategories(cf->categoryList()); | 1206 | todo->setCategories(cf->categoryList()); |
1200 | } | 1207 | } |
1201 | if ( cf->isEnabled() ) | 1208 | if ( cf->isEnabled() ) |
1202 | todo->setSecrecy( cf->getSecrecy()); | 1209 | todo->setSecrecy( cf->getSecrecy()); |
1203 | } | 1210 | } |
1204 | mCalendar->addTodo(todo); | 1211 | mCalendar->addTodo(todo); |
1205 | mQuickAdd->setText(""); | 1212 | mQuickAdd->setText(""); |
1206 | todoModified (todo, KOGlobals::EVENTADDED ); | 1213 | todoModified (todo, KOGlobals::EVENTADDED ); |
1207 | updateView(); | 1214 | updateView(); |
1208 | } | 1215 | } |
1209 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1216 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1210 | { | 1217 | { |
1211 | // e->ignore(); | 1218 | // e->ignore(); |
1212 | //return; | 1219 | //return; |
1213 | //qDebug("KOTodoView::keyPressEvent "); | 1220 | //qDebug("KOTodoView::keyPressEvent "); |
1214 | switch ( e->key() ) { | 1221 | switch ( e->key() ) { |
1215 | case Qt::Key_Down: | 1222 | case Qt::Key_Down: |
1216 | case Qt::Key_Up: | 1223 | case Qt::Key_Up: |
1217 | QWidget::keyPressEvent ( e ); | 1224 | QWidget::keyPressEvent ( e ); |
1218 | break; | 1225 | break; |
1219 | 1226 | ||
1220 | case Qt::Key_Q: | 1227 | case Qt::Key_Q: |
1221 | toggleQuickTodo(); | 1228 | toggleQuickTodo(); |
1222 | break; | 1229 | break; |
1223 | case Qt::Key_U: | 1230 | case Qt::Key_U: |
1224 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1231 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1225 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1232 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1226 | unparentTodo(); | 1233 | unparentTodo(); |
1227 | e->accept(); | 1234 | e->accept(); |
1228 | } else | 1235 | } else |
1229 | e->ignore(); | 1236 | e->ignore(); |
1230 | break; | 1237 | break; |
1231 | case Qt::Key_S: | 1238 | case Qt::Key_S: |
1232 | if ( e->state() == Qt::ControlButton ) { | 1239 | if ( e->state() == Qt::ControlButton ) { |
1233 | e->ignore(); | 1240 | e->ignore(); |
1234 | break; | 1241 | break; |
1235 | } | 1242 | } |
1236 | if ( e->state() == Qt::ShiftButton ) { | 1243 | if ( e->state() == Qt::ShiftButton ) { |
1237 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1244 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1238 | reparentTodo(); | 1245 | reparentTodo(); |
1239 | e->accept(); | 1246 | e->accept(); |
1240 | } else | 1247 | } else |
1241 | e->ignore(); | 1248 | e->ignore(); |
1242 | break; | 1249 | break; |
1243 | case Qt::Key_P: | 1250 | case Qt::Key_P: |
1244 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1251 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1245 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1252 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1246 | if ( pendingSubtodo ) | 1253 | if ( pendingSubtodo ) |
1247 | itemClicked(mActiveItem); | 1254 | itemClicked(mActiveItem); |
1248 | e->accept(); | 1255 | e->accept(); |
1249 | } else | 1256 | } else |
1250 | e->ignore(); | 1257 | e->ignore(); |
1251 | break; | 1258 | break; |
1252 | case Qt::Key_Escape: | 1259 | case Qt::Key_Escape: |
1253 | if ( pendingSubtodo ) { | 1260 | if ( pendingSubtodo ) { |
1254 | itemClicked(0); | 1261 | itemClicked(0); |
1255 | e->accept(); | 1262 | e->accept(); |
1256 | } else | 1263 | } else |
1257 | e->ignore(); | 1264 | e->ignore(); |
1258 | break; | 1265 | break; |
1259 | default: | 1266 | default: |
1260 | e->ignore(); | 1267 | e->ignore(); |
1261 | } | 1268 | } |
1262 | 1269 | ||
1263 | if ( true ) { | 1270 | if ( true ) { |
1264 | if ( e->key() == Qt::Key_I ) { | 1271 | if ( e->key() == Qt::Key_I ) { |
1265 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1272 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1266 | if ( cn ) { | 1273 | if ( cn ) { |
1267 | mActiveItem = cn; | 1274 | mActiveItem = cn; |
1268 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1275 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1269 | if ( ci ){ | 1276 | if ( ci ){ |
1270 | showTodo(); | 1277 | showTodo(); |
1271 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1278 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1272 | if ( cn ) { | 1279 | if ( cn ) { |
1273 | mTodoListView->setCurrentItem ( cn ); | 1280 | mTodoListView->setCurrentItem ( cn ); |
1274 | mTodoListView->ensureItemVisible ( cn ); | 1281 | mTodoListView->ensureItemVisible ( cn ); |
1275 | } | 1282 | } |
1276 | 1283 | ||
1277 | } | 1284 | } |
1278 | } | 1285 | } |
1279 | e->accept(); | 1286 | e->accept(); |
1280 | 1287 | ||
1281 | } | 1288 | } |
1282 | 1289 | ||
1283 | } | 1290 | } |
1284 | 1291 | ||
1285 | } | 1292 | } |
1286 | void KOTodoView::updateTodo( Todo * t, int type ) | 1293 | void KOTodoView::updateTodo( Todo * t, int type ) |
1287 | { | 1294 | { |
1288 | if ( mBlockUpdate) | 1295 | if ( mBlockUpdate) |
1289 | return; | 1296 | return; |
1290 | 1297 | ||
1291 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1298 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1292 | itemIterator = mTodoMap.find(t); | 1299 | itemIterator = mTodoMap.find(t); |
1293 | if (itemIterator != mTodoMap.end()) { | 1300 | if (itemIterator != mTodoMap.end()) { |
1294 | (*itemIterator)->construct(); | 1301 | (*itemIterator)->construct(); |
1295 | } else { | 1302 | } else { |
1296 | if ( type == KOGlobals::EVENTADDED ) { | 1303 | if ( type == KOGlobals::EVENTADDED ) { |
1297 | insertTodoItem( t ); | 1304 | insertTodoItem( t ); |
1298 | } | 1305 | } |
1299 | } | 1306 | } |
1300 | 1307 | ||
1301 | } | 1308 | } |
1302 | 1309 | ||
1303 | void KOTodoView::todoModified(Todo * t , int p ) | 1310 | void KOTodoView::todoModified(Todo * t , int p ) |
1304 | { | 1311 | { |
1305 | mBlockUpdate = true; | 1312 | mBlockUpdate = true; |
1306 | emit todoModifiedSignal ( t, p ); | 1313 | emit todoModifiedSignal ( t, p ); |
1307 | mBlockUpdate = false; | 1314 | mBlockUpdate = false; |
1308 | } | 1315 | } |