summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/taskeditorstatus.cpp298
-rw-r--r--core/pim/todo/taskeditorstatus.h100
2 files changed, 398 insertions, 0 deletions
diff --git a/core/pim/todo/taskeditorstatus.cpp b/core/pim/todo/taskeditorstatus.cpp
new file mode 100644
index 0000000..9a5fe7a
--- a/dev/null
+++ b/core/pim/todo/taskeditorstatus.cpp
@@ -0,0 +1,298 @@
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 "taskeditorstatus.h"
30
31#include <opie/otodo.h>
32#include <opie/opimmaintainer.h>
33#include <opie/opimstate.h>
34
35#include <qpe/datebookmonth.h>
36#include <qpe/resource.h>
37#include <qpe/timestring.h>
38
39#include <qcheckbox.h>
40#include <qcombobox.h>
41#include <qlabel.h>
42#include <qlayout.h>
43#include <qscrollview.h>
44#include <qtoolbutton.h>
45#include <qwhatsthis.h>
46
47TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags fl )
48 : QWidget( parent, name, fl )
49{
50 QDate curDate = QDate::currentDate();
51 m_start = m_comp = m_due = curDate;
52 QString curDateStr = TimeString::longDateString( curDate );
53
54 QVBoxLayout *vb = new QVBoxLayout( this );
55
56 QScrollView *sv = new QScrollView( this );
57 vb->addWidget( sv );
58 sv->setResizePolicy( QScrollView::AutoOneFit );
59 sv->setFrameStyle( QFrame::NoFrame );
60
61 QWidget *container = new QWidget( sv->viewport() );
62 sv->addChild( container );
63
64 QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 );
65
66 // Status
67 QLabel *label = new QLabel( tr( "Status:" ), container );
68 layout->addWidget( label, 0, 0 );
69 QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) );
70 cmbStatus = new QComboBox( FALSE, container );
71 cmbStatus->insertItem( tr( "Started" ) );
72 cmbStatus->insertItem( tr( "Postponed" ) );
73 cmbStatus->insertItem( tr( "Finished" ) );
74 cmbStatus->insertItem( tr( "Not started" ) );
75 layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 );
76 QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) );
77
78 // Progress
79 label = new QLabel( tr( "Progress:" ), container );
80 layout->addWidget( label, 1, 0 );
81 QWhatsThis::add( label, tr( "Select progress made on this task here." ) );
82 cmbProgress = new QComboBox( FALSE, container );
83 cmbProgress->insertItem( tr( "0 %" ) );
84 cmbProgress->insertItem( tr( "20 %" ) );
85 cmbProgress->insertItem( tr( "40 %" ) );
86 cmbProgress->insertItem( tr( "60 %" ) );
87 cmbProgress->insertItem( tr( "80 %" ) );
88 cmbProgress->insertItem( tr( "100 %" ) );
89 layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 );
90 QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) );
91
92 // Start date
93 ckbStart = new QCheckBox( tr( "Start Date:" ), container );
94 layout->addWidget( ckbStart, 2, 0 );
95 QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) );
96 connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) );
97 btnStart = new QPushButton( curDateStr, container );
98 btnStart->setEnabled( FALSE );
99 layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 );
100 QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) );
101 QPopupMenu *popup = new QPopupMenu( this );
102 m_startBook = new DateBookMonth( popup, 0, TRUE );
103 popup->insertItem( m_startBook );
104 btnStart->setPopup( popup );
105 connect( m_startBook, SIGNAL( dateClicked( int, int, int ) ),
106 this, SLOT( slotStartChanged( int, int, int ) ) );
107
108 // Due date
109 ckbDue = new QCheckBox( tr( "Due Date:" ), container );
110 layout->addWidget( ckbDue, 3, 0 );
111 QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) );
112 connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) );
113 btnDue = new QPushButton( curDateStr, container );
114 btnDue->setEnabled( FALSE );
115 layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 );
116 QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) );
117 popup = new QPopupMenu( this );
118 m_dueBook = new DateBookMonth( popup, 0, TRUE );
119 popup->insertItem( m_dueBook );
120 btnDue->setPopup( popup );
121 connect( m_dueBook, SIGNAL( dateClicked( int, int, int ) ),
122 this, SLOT( slotDueChanged( int, int, int ) ) );
123
124 // Completed
125 ckbComp = new QCheckBox( tr( "Completed:" ), container );
126 layout->addWidget( ckbComp, 4, 0 );
127 QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) );
128 connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) );
129 btnComp = new QPushButton( curDateStr, container );
130 btnComp->setEnabled( FALSE );
131 layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 );
132 QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) );
133 popup = new QPopupMenu( this );
134 m_compBook = new DateBookMonth( popup, 0, TRUE );
135 popup->insertItem( m_compBook );
136 btnComp->setPopup( popup );
137 connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ),
138 this, SLOT( slotCompChanged( int, int, int ) ) );
139
140 QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding );
141 layout->addItem( spacer, 5, 0 );
142
143 // Maintainer mode
144 label = new QLabel( tr( "Maintainer Mode:" ), container );
145 layout->addWidget( label, 6, 0 );
146 QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) );
147 cmbMaintMode = new QComboBox( FALSE, container );
148 cmbMaintMode->insertItem( tr( "Nothing" ) );
149 cmbMaintMode->insertItem( tr( "Responsible" ) );
150 cmbMaintMode->insertItem( tr( "Done By" ) );
151 cmbMaintMode->insertItem( tr( "Coordinating" ) );
152 layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 );
153 QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) );
154
155 // Maintainer
156 label = new QLabel( tr( "Maintainer:" ), container );
157 layout->addWidget( label, 7, 0 );
158 QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) );
159 txtMaintainer = new QLabel( tr( "test" ), container );
160 txtMaintainer->setTextFormat( QLabel::RichText );
161 layout->addWidget( txtMaintainer, 7, 1 );
162 QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) );
163 tbtMaintainer = new QToolButton( container );
164 tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) );
165 layout->addWidget( tbtMaintainer, 7, 2 );
166 QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) );
167}
168
169TaskEditorStatus::~TaskEditorStatus()
170{
171}
172
173void TaskEditorStatus::load( const OTodo &todo )
174{
175 QDate date = QDate::currentDate();
176 QString str = TimeString::longDateString( date );
177
178 // Status
179 int state = todo.state().state();
180 if ( state == OPimState::Undefined )
181 state = OPimState::NotStarted;
182 cmbStatus->setCurrentItem( state );
183
184 // Progress
185 cmbProgress->setCurrentItem( todo.progress() / 20 );
186
187 // Start date
188 ckbStart->setChecked( todo.hasStartDate() );
189 btnStart->setEnabled( todo.hasStartDate() );
190 if ( todo.hasStartDate() )
191 {
192 m_start = todo.startDate();
193 btnStart->setText( TimeString::longDateString( m_start ) );
194 }
195 else
196 btnStart->setText( str );
197
198 // Due date
199 ckbDue->setChecked( todo.hasDueDate() );
200 btnDue->setText( TimeString::longDateString( todo.dueDate() ) );
201 btnDue->setEnabled( todo.hasDueDate() );
202 m_due = todo.dueDate();
203
204 // Completed
205 ckbComp->setChecked( todo.isCompleted() );
206 btnComp->setEnabled( todo.hasCompletedDate() );
207 if ( todo.hasCompletedDate() )
208 {
209 m_comp = todo.completedDate();
210 btnComp->setText( TimeString::longDateString( m_comp ) );
211 }
212 else
213 btnComp->setText( str );
214
215 // Maintainer Mode
216 state = todo.maintainer().mode();
217 if ( state == OPimMaintainer::Undefined )
218 state = OPimMaintainer::Nothing;
219 cmbMaintMode->setCurrentItem( state );
220
221 // Maintainer - not implemented yet
222}
223
224void TaskEditorStatus::save( OTodo &todo )
225{
226 QDate inval;
227
228 // Status
229 todo.setState( OPimState( cmbStatus->currentItem() ) );
230
231 // Progress
232 todo.setProgress( cmbProgress->currentItem() * 20 );
233
234 // Start date
235 if ( ckbStart->isChecked() )
236 {
237 todo.setStartDate( m_start );
238 }
239 else
240 todo.setStartDate( inval );
241
242 // Due date
243 if ( ckbDue->isChecked() )
244 {
245 todo.setDueDate( m_due );
246 todo.setHasDueDate( true );
247 }
248 else
249 todo.setHasDueDate( false );
250
251 // Completed
252 todo.setCompleted( ckbComp->isChecked() );
253 if ( ckbComp->isChecked() )
254 {
255 todo.setCompletedDate( m_comp );
256 }
257 else
258 todo.setCompletedDate( inval );
259
260 // Maintainer mode - not implemented yet
261
262 // Maintainer
263 /* TODO - resolve name to uid.....*/
264 todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) );
265}
266
267void TaskEditorStatus::slotStartChecked()
268{
269 btnStart->setEnabled( ckbStart->isChecked() );
270}
271
272void TaskEditorStatus::slotCompChecked()
273{
274 btnComp->setEnabled( ckbComp->isChecked() );
275}
276
277void TaskEditorStatus::slotDueChecked()
278{
279 btnDue->setEnabled( ckbDue->isChecked() );
280}
281
282void TaskEditorStatus::slotStartChanged(int y, int m, int d)
283{
284 m_start.setYMD( y, m, d );
285 btnStart->setText( TimeString::longDateString( m_start ) );
286}
287
288void TaskEditorStatus::slotCompChanged(int y, int m, int d)
289{
290 m_comp.setYMD( y, m, d );
291 btnComp->setText( TimeString::longDateString( m_comp ) );
292}
293
294void TaskEditorStatus::slotDueChanged(int y, int m, int d)
295{
296 m_due.setYMD( y, m, d );
297 btnDue->setText( TimeString::longDateString( m_due ) );
298}
diff --git a/core/pim/todo/taskeditorstatus.h b/core/pim/todo/taskeditorstatus.h
new file mode 100644
index 0000000..3544200
--- a/dev/null
+++ b/core/pim/todo/taskeditorstatus.h
@@ -0,0 +1,100 @@
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#ifndef TASKEDITORSTATUS_H
30#define TASKEDITORSTATUS_H
31
32#include <qdatetime.h>
33#include <qwidget.h>
34
35class DateBookMonth;
36class OTodo;
37class QCheckBox;
38class QComboBox;
39class QLabel;
40class QPushButton;
41class QToolButton;
42
43/**
44 * This is the implementation of the Opie Task Editor Advanced tab
45 * it features the State!
46 * MaintainerMode
47 * Description
48 */
49class TaskEditorStatus : public QWidget
50{
51 Q_OBJECT
52
53public:
54 TaskEditorStatus( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
55 ~TaskEditorStatus();
56
57 QComboBox *cmbStatus;
58 QLabel *txtMaintainer;
59 QToolButton *tbtMaintainer;
60 QComboBox *cmbMaintMode;
61 QCheckBox *ckbDue;
62 QPushButton *btnDue;
63 QCheckBox *ckbStart;
64 QPushButton *btnStart;
65 QCheckBox *ckbComp;
66 QPushButton *btnComp;
67 QComboBox *cmbProgress;
68
69 /*
70 * I could have a struct which returns a QWidget*
71 * load and save to a OTodo
72 * and use multiple inheretence with all other widgets
73 * and then simply iterate over the list of structs
74 * this way I could easily have plugins for the whole editor....
75 * but I do not do it -zecke
76 */
77 void load( const OTodo & );
78 void save( OTodo & );
79
80private:
81 QDate m_start;
82 QDate m_comp;
83 QDate m_due;
84 DateBookMonth *m_startBook;
85 DateBookMonth *m_compBook;
86 DateBookMonth *m_dueBook;
87
88private slots:
89 void slotStartChecked();
90 void slotCompChecked();
91 void slotDueChecked();
92 void slotStartChanged( int, int, int );
93 void slotCompChanged( int, int, int );
94 void slotDueChanged( int, int, int );
95
96signals:
97 void dueDateChanged( const QDate& date );
98};
99
100#endif // TASKEDITORSTATUS_H