author | drw <drw> | 2002-12-23 17:13:12 (UTC) |
---|---|---|
committer | drw <drw> | 2002-12-23 17:13:12 (UTC) |
commit | 1cb75c721b69459494cb599730a96bbc1ddc0f65 (patch) (unidiff) | |
tree | 9a45955d74016b639593c4a888acb4e96e17e9fb /core/pim/todo/taskeditoroverview.cpp | |
parent | deb4685b99d6c5917f92ce188ead09fdd9c37859 (diff) | |
download | opie-1cb75c721b69459494cb599730a96bbc1ddc0f65.zip opie-1cb75c721b69459494cb599730a96bbc1ddc0f65.tar.gz opie-1cb75c721b69459494cb599730a96bbc1ddc0f65.tar.bz2 |
Task Editor dialog: 1. added tab icons 2. rearranged the overview tab 3. alarm/reminder tab updates 4. code clean-up. Still need to work on advanced tab and add qwhatsthis.
Diffstat (limited to 'core/pim/todo/taskeditoroverview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/todo/taskeditoroverview.cpp | 317 |
1 files changed, 317 insertions, 0 deletions
diff --git a/core/pim/todo/taskeditoroverview.cpp b/core/pim/todo/taskeditoroverview.cpp new file mode 100644 index 0000000..9aab76a --- a/dev/null +++ b/core/pim/todo/taskeditoroverview.cpp | |||
@@ -0,0 +1,317 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 <> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "taskeditoroverview.h" | ||
30 | |||
31 | #include <opie/orecur.h> | ||
32 | |||
33 | #include <qpe/categoryselect.h> | ||
34 | #include <qpe/datebookmonth.h> | ||
35 | #include <qpe/resource.h> | ||
36 | #include <qpe/timestring.h> | ||
37 | |||
38 | #include <qcheckbox.h> | ||
39 | #include <qcombobox.h> | ||
40 | #include <qlabel.h> | ||
41 | #include <qlayout.h> | ||
42 | #include <qpushbutton.h> | ||
43 | #include <qtooltip.h> | ||
44 | #include <qvariant.h> | ||
45 | #include <qwhatsthis.h> | ||
46 | |||
47 | TaskEditorOverView::TaskEditorOverView( QWidget* parent, const char* name, WFlags fl ) | ||
48 | : QWidget( parent, name, fl ) | ||
49 | { | ||
50 | // Load icons | ||
51 | // TODO - probably should be done globally somewhere else, | ||
52 | // see also quickeditimpl.cpp/h, tableview.cpp/h | ||
53 | QString namestr; | ||
54 | for ( unsigned int i = 1; i < 6; i++ ) { | ||
55 | namestr = "todo/priority"; | ||
56 | namestr.append( QString::number( i ) ); | ||
57 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); | ||
58 | } | ||
59 | |||
60 | QDate curDate = QDate::currentDate(); | ||
61 | m_start = m_comp = m_due = curDate; | ||
62 | QString curDateStr = TimeString::longDateString( curDate ); | ||
63 | |||
64 | // TODO - add QScrollView for contents | ||
65 | QVBoxLayout *vb = new QVBoxLayout( this ); | ||
66 | |||
67 | QScrollView *sv = new QScrollView( this ); | ||
68 | vb->addWidget( sv ); | ||
69 | sv->setResizePolicy( QScrollView::AutoOneFit ); | ||
70 | sv->setFrameStyle( QFrame::NoFrame ); | ||
71 | |||
72 | QWidget *container = new QWidget( sv->viewport() ); | ||
73 | sv->addChild( container ); | ||
74 | |||
75 | QGridLayout *layout = new QGridLayout( container, 10, 2, 4, 4 ); | ||
76 | |||
77 | // Summary | ||
78 | QLabel *label = new QLabel( tr( "Summary:" ), container ); | ||
79 | layout->addWidget( label, 0, 0 ); | ||
80 | cmbSum = new QComboBox( TRUE, container ); | ||
81 | cmbSum->insertItem( tr( "Complete " ) ); | ||
82 | cmbSum->insertItem( tr( "Work on " ) ); | ||
83 | cmbSum->insertItem( tr( "Buy " ) ); | ||
84 | cmbSum->insertItem( tr( "Organize " ) ); | ||
85 | cmbSum->insertItem( tr( "Get " ) ); | ||
86 | cmbSum->insertItem( tr( "Update " ) ); | ||
87 | cmbSum->insertItem( tr( "Create " ) ); | ||
88 | cmbSum->insertItem( tr( "Plan " ) ); | ||
89 | cmbSum->insertItem( tr( "Call " ) ); | ||
90 | cmbSum->insertItem( tr( "Mail " ) ); | ||
91 | cmbSum->clearEdit(); | ||
92 | layout->addMultiCellWidget( cmbSum, 1, 1, 0, 1 ); | ||
93 | |||
94 | // Priority | ||
95 | label = new QLabel( tr( "Priority:" ), container ); | ||
96 | layout->addWidget( label, 2, 0 ); | ||
97 | cmbPrio = new QComboBox( FALSE, container ); | ||
98 | cmbPrio->setMinimumHeight( 26 ); | ||
99 | cmbPrio->insertItem( m_pic_priority[ 0 ], tr( "Very High" ) ); | ||
100 | cmbPrio->insertItem( m_pic_priority[ 1 ], tr( "High" ) ); | ||
101 | cmbPrio->insertItem( m_pic_priority[ 2 ], tr( "Normal" ) ); | ||
102 | cmbPrio->insertItem( m_pic_priority[ 3 ], tr( "Low" ) ); | ||
103 | cmbPrio->insertItem( m_pic_priority[ 4 ], tr( "Very Low" ) ); | ||
104 | cmbPrio->setCurrentItem( 2 ); | ||
105 | layout->addWidget( cmbPrio, 2, 1 ); | ||
106 | |||
107 | // Category | ||
108 | label = new QLabel( tr( "Category:" ), container ); | ||
109 | layout->addWidget( label, 3, 0 ); | ||
110 | comboCategory = new CategorySelect( container ); | ||
111 | layout->addWidget( comboCategory, 3, 1 ); | ||
112 | |||
113 | // Recurrance | ||
114 | CheckBox7 = new QCheckBox( tr( "Recurring task" ), container ); | ||
115 | layout->addMultiCellWidget( CheckBox7, 4, 4, 0, 1 ); | ||
116 | connect( CheckBox7, SIGNAL(clicked() ), this, SLOT( slotRecClicked() ) ); | ||
117 | |||
118 | QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ); | ||
119 | layout->addItem( spacer, 5, 0 ); | ||
120 | |||
121 | // Start date | ||
122 | ckbStart = new QCheckBox( tr( "Start Date:" ), container ); | ||
123 | layout->addWidget( ckbStart, 6, 0 ); | ||
124 | connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) ); | ||
125 | btnStart = new QPushButton( curDateStr, container ); | ||
126 | btnStart->setEnabled( FALSE ); | ||
127 | layout->addWidget( btnStart, 6, 1 ); | ||
128 | |||
129 | QPopupMenu *popup = new QPopupMenu( this ); | ||
130 | m_startBook = new DateBookMonth( popup, 0, TRUE ); | ||
131 | popup->insertItem( m_startBook ); | ||
132 | btnStart->setPopup( popup ); | ||
133 | connect( m_startBook, SIGNAL( dateClicked( int, int, int ) ), | ||
134 | this, SLOT( slotStartChanged( int, int, int ) ) ); | ||
135 | |||
136 | // Due date | ||
137 | ckbDue = new QCheckBox( tr( "Due Date:" ), container ); | ||
138 | layout->addWidget( ckbDue, 7, 0 ); | ||
139 | connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) ); | ||
140 | btnDue = new QPushButton( curDateStr, container ); | ||
141 | btnDue->setEnabled( FALSE ); | ||
142 | layout->addWidget( btnDue, 7, 1 ); | ||
143 | |||
144 | popup = new QPopupMenu( this ); | ||
145 | m_dueBook = new DateBookMonth( popup, 0, TRUE ); | ||
146 | popup->insertItem( m_dueBook ); | ||
147 | btnDue->setPopup( popup ); | ||
148 | connect( m_dueBook, SIGNAL( dateClicked( int, int, int ) ), | ||
149 | this, SLOT( slotDueChanged( int, int, int ) ) ); | ||
150 | |||
151 | // Progress | ||
152 | label = new QLabel( tr( "Progress:" ), container ); | ||
153 | layout->addWidget( label, 8, 0 ); | ||
154 | cmbProgress = new QComboBox( FALSE, container ); | ||
155 | cmbProgress->insertItem( tr( "0 %" ) ); | ||
156 | cmbProgress->insertItem( tr( "20 %" ) ); | ||
157 | cmbProgress->insertItem( tr( "40 %" ) ); | ||
158 | cmbProgress->insertItem( tr( "60 %" ) ); | ||
159 | cmbProgress->insertItem( tr( "80 %" ) ); | ||
160 | cmbProgress->insertItem( tr( "100 %" ) ); | ||
161 | layout->addWidget( cmbProgress, 8, 1 ); | ||
162 | |||
163 | // Completed | ||
164 | ckbComp = new QCheckBox( tr( "Completed:" ), container ); | ||
165 | layout->addWidget( ckbComp, 9, 0 ); | ||
166 | connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) ); | ||
167 | btnComp = new QPushButton( curDateStr, container ); | ||
168 | btnComp->setEnabled( FALSE ); | ||
169 | layout->addWidget( btnComp, 9, 1 ); | ||
170 | |||
171 | popup = new QPopupMenu( this ); | ||
172 | m_compBook = new DateBookMonth( popup, 0, TRUE ); | ||
173 | popup->insertItem( m_compBook ); | ||
174 | btnComp->setPopup( popup ); | ||
175 | connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ), | ||
176 | this, SLOT( slotCompChanged( int, int, int ) ) ); | ||
177 | } | ||
178 | |||
179 | TaskEditorOverView::~TaskEditorOverView() | ||
180 | { | ||
181 | } | ||
182 | |||
183 | void TaskEditorOverView::load( const OTodo& todo ) | ||
184 | { | ||
185 | /* | ||
186 | * now that we're 'preloaded' we | ||
187 | * need to disable the buttons | ||
188 | * holding the dat | ||
189 | */ | ||
190 | btnDue->setEnabled( FALSE ); | ||
191 | btnComp->setEnabled( FALSE ); | ||
192 | btnStart->setEnabled( FALSE ); | ||
193 | |||
194 | /* | ||
195 | * get some basic dateinfos for now | ||
196 | */ | ||
197 | QDate date = QDate::currentDate(); | ||
198 | QString str = TimeString::longDateString( date ); | ||
199 | |||
200 | CheckBox7->setChecked( todo.recurrence().doesRecur() ); | ||
201 | emit recurranceEnabled( todo.recurrence().doesRecur() ); | ||
202 | |||
203 | ckbStart->setChecked( todo.hasStartDate() ); | ||
204 | btnStart->setEnabled( todo.hasStartDate() ); | ||
205 | if ( todo.hasStartDate() ) | ||
206 | { | ||
207 | m_start = todo.startDate(); | ||
208 | btnStart->setText( TimeString::longDateString( m_start ) ); | ||
209 | } | ||
210 | else | ||
211 | btnStart->setText( str ); | ||
212 | |||
213 | ckbComp->setChecked( todo.hasCompletedDate() ); | ||
214 | btnComp->setEnabled( todo.hasCompletedDate() ); | ||
215 | if ( todo.hasCompletedDate() ) | ||
216 | { | ||
217 | m_comp = todo.completedDate(); | ||
218 | btnComp->setText( TimeString::longDateString( m_comp ) ); | ||
219 | } | ||
220 | else | ||
221 | btnComp->setText( str ); | ||
222 | |||
223 | cmbProgress->setCurrentItem( todo.progress() / 20 ); | ||
224 | cmbSum->insertItem( todo.summary(), 0 ); | ||
225 | cmbSum->setCurrentItem( 0 ); | ||
226 | |||
227 | ckbDue->setChecked( todo.hasDueDate() ); | ||
228 | btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); | ||
229 | btnDue->setEnabled( todo.hasDueDate() ); | ||
230 | m_due = todo.dueDate(); | ||
231 | |||
232 | cmbPrio->setCurrentItem( todo.priority() - 1 ); | ||
233 | ckbComp->setChecked( todo.isCompleted() ); | ||
234 | |||
235 | comboCategory->setCategories( todo.categories(), "Todo List", tr( "Todo List" ) ); | ||
236 | } | ||
237 | |||
238 | void TaskEditorOverView::save( OTodo &to ) | ||
239 | { | ||
240 | /* a invalid date */ | ||
241 | QDate inval; | ||
242 | /* save our info back */ | ||
243 | |||
244 | /* due date */ | ||
245 | if ( ckbDue->isChecked() ) | ||
246 | { | ||
247 | to.setDueDate( m_due ); | ||
248 | to.setHasDueDate( true ); | ||
249 | } | ||
250 | else | ||
251 | to.setHasDueDate( false ); | ||
252 | |||
253 | /* start date */ | ||
254 | if ( ckbStart->isChecked() ) | ||
255 | { | ||
256 | to.setStartDate( m_start ); | ||
257 | } | ||
258 | else | ||
259 | to.setStartDate( inval ); | ||
260 | |||
261 | /* comp date */ | ||
262 | if ( ckbComp->isChecked() ) | ||
263 | { | ||
264 | to.setCompletedDate( m_comp ); | ||
265 | } | ||
266 | else | ||
267 | to.setCompletedDate( inval ); | ||
268 | |||
269 | |||
270 | if ( comboCategory->currentCategory() != -1 ) | ||
271 | { | ||
272 | QArray<int> arr = comboCategory->currentCategories(); | ||
273 | to.setCategories( arr ); | ||
274 | } | ||
275 | to.setPriority( cmbPrio->currentItem() + 1 ); | ||
276 | to.setCompleted( ckbComp->isChecked() ); | ||
277 | to.setSummary( cmbSum->currentText() ); | ||
278 | to.setProgress( cmbProgress->currentItem() * 20 ); | ||
279 | } | ||
280 | |||
281 | void TaskEditorOverView::slotRecClicked() | ||
282 | { | ||
283 | emit recurranceEnabled( CheckBox7->isChecked() ); | ||
284 | } | ||
285 | |||
286 | void TaskEditorOverView::slotStartChecked() | ||
287 | { | ||
288 | btnStart->setEnabled( ckbStart->isChecked() ); | ||
289 | } | ||
290 | |||
291 | void TaskEditorOverView::slotCompChecked() | ||
292 | { | ||
293 | btnComp->setEnabled( ckbComp->isChecked() ); | ||
294 | } | ||
295 | |||
296 | void TaskEditorOverView::slotDueChecked() | ||
297 | { | ||
298 | btnDue->setEnabled( ckbDue->isChecked() ); | ||
299 | } | ||
300 | |||
301 | void TaskEditorOverView::slotStartChanged(int y, int m, int d) | ||
302 | { | ||
303 | m_start.setYMD( y, m, d ); | ||
304 | btnStart->setText( TimeString::longDateString( m_start ) ); | ||
305 | } | ||
306 | |||
307 | void TaskEditorOverView::slotCompChanged(int y, int m, int d) | ||
308 | { | ||
309 | m_comp.setYMD( y, m, d ); | ||
310 | btnComp->setText( TimeString::longDateString( m_comp ) ); | ||
311 | } | ||
312 | |||
313 | void TaskEditorOverView::slotDueChanged(int y, int m, int d) | ||
314 | { | ||
315 | m_due.setYMD( y, m, d ); | ||
316 | btnDue->setText( TimeString::longDateString( m_due ) ); | ||
317 | } | ||