Diffstat (limited to 'core/pim/todo/taskeditoroverview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/todo/taskeditoroverview.cpp | 285 |
1 files changed, 74 insertions, 211 deletions
diff --git a/core/pim/todo/taskeditoroverview.cpp b/core/pim/todo/taskeditoroverview.cpp index 6906c26..89e553f 100644 --- a/core/pim/todo/taskeditoroverview.cpp +++ b/core/pim/todo/taskeditoroverview.cpp | |||
@@ -30,285 +30,148 @@ | |||
30 | 30 | ||
31 | #include <opie/orecur.h> | 31 | #include <opie/orecur.h> |
32 | 32 | ||
33 | #include <qpe/categoryselect.h> | 33 | #include <qpe/categoryselect.h> |
34 | #include <qpe/datebookmonth.h> | 34 | #include <qpe/datebookmonth.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/timestring.h> | 36 | #include <qpe/timestring.h> |
37 | 37 | ||
38 | #include <qcheckbox.h> | 38 | #include <qcheckbox.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qpushbutton.h> | 42 | #include <qmultilineedit.h> |
43 | #include <qwhatsthis.h> | 43 | #include <qwhatsthis.h> |
44 | 44 | ||
45 | TaskEditorOverView::TaskEditorOverView( QWidget* parent, const char* name, WFlags fl ) | 45 | TaskEditorOverView::TaskEditorOverView( QWidget* parent, const char* name, WFlags fl ) |
46 | : QWidget( parent, name, fl ) | 46 | : QWidget( parent, name, fl ) |
47 | { | 47 | { |
48 | // Load icons | 48 | // Load icons |
49 | // TODO - probably should be done globally somewhere else, | 49 | // TODO - probably should be done globally somewhere else, |
50 | // see also quickeditimpl.cpp/h, tableview.cpp/h | 50 | // see also quickeditimpl.cpp/h, tableview.cpp/h |
51 | QString namestr; | 51 | QString namestr; |
52 | for ( unsigned int i = 1; i < 6; i++ ) { | 52 | for ( unsigned int i = 1; i < 6; i++ ) { |
53 | namestr = "todo/priority"; | 53 | namestr = "todo/priority"; |
54 | namestr.append( QString::number( i ) ); | 54 | namestr.append( QString::number( i ) ); |
55 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); | 55 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); |
56 | } | 56 | } |
57 | 57 | ||
58 | QDate curDate = QDate::currentDate(); | ||
59 | m_start = m_comp = m_due = curDate; | ||
60 | QString curDateStr = TimeString::longDateString( curDate ); | ||
61 | |||
62 | QVBoxLayout *vb = new QVBoxLayout( this ); | 58 | QVBoxLayout *vb = new QVBoxLayout( this ); |
63 | 59 | ||
64 | QScrollView *sv = new QScrollView( this ); | 60 | QScrollView *sv = new QScrollView( this ); |
65 | vb->addWidget( sv ); | 61 | vb->addWidget( sv ); |
66 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 62 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
67 | sv->setFrameStyle( QFrame::NoFrame ); | 63 | sv->setFrameStyle( QFrame::NoFrame ); |
68 | 64 | ||
69 | QWidget *container = new QWidget( sv->viewport() ); | 65 | QWidget *container = new QWidget( sv->viewport() ); |
70 | sv->addChild( container ); | 66 | sv->addChild( container ); |
71 | 67 | ||
72 | QGridLayout *layout = new QGridLayout( container, 10, 2, 4, 4 ); | 68 | QGridLayout *layout = new QGridLayout( container, 7, 2, 4, 4 ); |
73 | 69 | ||
74 | // Summary | 70 | // Description |
75 | QLabel *label = new QLabel( tr( "Summary:" ), container ); | 71 | QLabel *label = new QLabel( tr( "Description:" ), container ); |
76 | layout->addWidget( label, 0, 0 ); | 72 | layout->addWidget( label, 0, 0 ); |
77 | cmbSum = new QComboBox( TRUE, container ); | 73 | QWhatsThis::add( label, tr( "Enter brief description of the task here." ) ); |
78 | cmbSum->insertItem( tr( "Complete " ) ); | 74 | cmbDesc = new QComboBox( TRUE, container ); |
79 | cmbSum->insertItem( tr( "Work on " ) ); | 75 | cmbDesc->insertItem( tr( "Complete " ) ); |
80 | cmbSum->insertItem( tr( "Buy " ) ); | 76 | cmbDesc->insertItem( tr( "Work on " ) ); |
81 | cmbSum->insertItem( tr( "Organize " ) ); | 77 | cmbDesc->insertItem( tr( "Buy " ) ); |
82 | cmbSum->insertItem( tr( "Get " ) ); | 78 | cmbDesc->insertItem( tr( "Organize " ) ); |
83 | cmbSum->insertItem( tr( "Update " ) ); | 79 | cmbDesc->insertItem( tr( "Get " ) ); |
84 | cmbSum->insertItem( tr( "Create " ) ); | 80 | cmbDesc->insertItem( tr( "Update " ) ); |
85 | cmbSum->insertItem( tr( "Plan " ) ); | 81 | cmbDesc->insertItem( tr( "Create " ) ); |
86 | cmbSum->insertItem( tr( "Call " ) ); | 82 | cmbDesc->insertItem( tr( "Plan " ) ); |
87 | cmbSum->insertItem( tr( "Mail " ) ); | 83 | cmbDesc->insertItem( tr( "Call " ) ); |
88 | cmbSum->clearEdit(); | 84 | cmbDesc->insertItem( tr( "Mail " ) ); |
89 | layout->addMultiCellWidget( cmbSum, 1, 1, 0, 1 ); | 85 | cmbDesc->clearEdit(); |
86 | layout->addMultiCellWidget( cmbDesc, 1, 1, 0, 1 ); | ||
87 | QWhatsThis::add( cmbDesc, tr( "Enter brief description of the task here." ) ); | ||
90 | 88 | ||
91 | // Priority | 89 | // Priority |
92 | label = new QLabel( tr( "Priority:" ), container ); | 90 | label = new QLabel( tr( "Priority:" ), container ); |
93 | layout->addWidget( label, 2, 0 ); | 91 | layout->addWidget( label, 2, 0 ); |
94 | cmbPrio = new QComboBox( FALSE, container ); | 92 | QWhatsThis::add( label, tr( "Select priority of task here." ) ); |
95 | cmbPrio->setMinimumHeight( 26 ); | 93 | cmbPriority = new QComboBox( FALSE, container ); |
96 | cmbPrio->insertItem( m_pic_priority[ 0 ], tr( "Very High" ) ); | 94 | cmbPriority->setMinimumHeight( 26 ); |
97 | cmbPrio->insertItem( m_pic_priority[ 1 ], tr( "High" ) ); | 95 | cmbPriority->insertItem( m_pic_priority[ 0 ], tr( "Very High" ) ); |
98 | cmbPrio->insertItem( m_pic_priority[ 2 ], tr( "Normal" ) ); | 96 | cmbPriority->insertItem( m_pic_priority[ 1 ], tr( "High" ) ); |
99 | cmbPrio->insertItem( m_pic_priority[ 3 ], tr( "Low" ) ); | 97 | cmbPriority->insertItem( m_pic_priority[ 2 ], tr( "Normal" ) ); |
100 | cmbPrio->insertItem( m_pic_priority[ 4 ], tr( "Very Low" ) ); | 98 | cmbPriority->insertItem( m_pic_priority[ 3 ], tr( "Low" ) ); |
101 | cmbPrio->setCurrentItem( 2 ); | 99 | cmbPriority->insertItem( m_pic_priority[ 4 ], tr( "Very Low" ) ); |
102 | layout->addWidget( cmbPrio, 2, 1 ); | 100 | cmbPriority->setCurrentItem( 2 ); |
101 | layout->addWidget( cmbPriority, 2, 1 ); | ||
102 | QWhatsThis::add( cmbPriority, tr( "Select priority of task here." ) ); | ||
103 | 103 | ||
104 | // Category | 104 | // Category |
105 | label = new QLabel( tr( "Category:" ), container ); | 105 | label = new QLabel( tr( "Category:" ), container ); |
106 | layout->addWidget( label, 3, 0 ); | 106 | layout->addWidget( label, 3, 0 ); |
107 | comboCategory = new CategorySelect( container ); | 107 | QWhatsThis::add( label, tr( "Select category to organize this task with." ) ); |
108 | layout->addWidget( comboCategory, 3, 1 ); | 108 | cmbCategory = new CategorySelect( container ); |
109 | 109 | layout->addWidget( cmbCategory, 3, 1 ); | |
110 | // Recurrance | 110 | QWhatsThis::add( cmbCategory, tr( "Select category to organize this task with." ) ); |
111 | CheckBox7 = new QCheckBox( tr( "Recurring task" ), container ); | 111 | |
112 | layout->addMultiCellWidget( CheckBox7, 4, 4, 0, 1 ); | 112 | // Recurrence |
113 | connect( CheckBox7, SIGNAL(clicked() ), this, SLOT( slotRecClicked() ) ); | 113 | ckbRecurrence = new QCheckBox( tr( "Recurring task" ), container ); |
114 | 114 | layout->addMultiCellWidget( ckbRecurrence, 4, 4, 0, 1 ); | |
115 | QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ); | 115 | QWhatsThis::add( ckbRecurrence, tr( "Click here if task happens on a regular basis. If selected, frequency can be set on the Recurrence tab." ) ); |
116 | layout->addItem( spacer, 5, 0 ); | 116 | connect( ckbRecurrence, SIGNAL(clicked() ), this, SLOT( slotRecClicked() ) ); |
117 | 117 | ||
118 | // Start date | 118 | // Notes |
119 | ckbStart = new QCheckBox( tr( "Start Date:" ), container ); | 119 | label = new QLabel( tr( "Notes:" ), container ); |
120 | layout->addWidget( ckbStart, 6, 0 ); | 120 | layout->addWidget( label, 5, 0 ); |
121 | connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) ); | 121 | QWhatsThis::add( label, tr( "Enter any additional information about this task here." ) ); |
122 | btnStart = new QPushButton( curDateStr, container ); | 122 | mleNotes = new QMultiLineEdit( this ); |
123 | btnStart->setEnabled( FALSE ); | 123 | mleNotes->setWordWrap( QMultiLineEdit::WidgetWidth ); |
124 | layout->addWidget( btnStart, 6, 1 ); | 124 | layout->addMultiCellWidget( mleNotes, 6, 6, 0, 1 ); |
125 | 125 | QWhatsThis::add( mleNotes, tr( "Enter any additional information about this task here." ) ); | |
126 | QPopupMenu *popup = new QPopupMenu( this ); | ||
127 | m_startBook = new DateBookMonth( popup, 0, TRUE ); | ||
128 | popup->insertItem( m_startBook ); | ||
129 | btnStart->setPopup( popup ); | ||
130 | connect( m_startBook, SIGNAL( dateClicked( int, int, int ) ), | ||
131 | this, SLOT( slotStartChanged( int, int, int ) ) ); | ||
132 | |||
133 | // Due date | ||
134 | ckbDue = new QCheckBox( tr( "Due Date:" ), container ); | ||
135 | layout->addWidget( ckbDue, 7, 0 ); | ||
136 | connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) ); | ||
137 | btnDue = new QPushButton( curDateStr, container ); | ||
138 | btnDue->setEnabled( FALSE ); | ||
139 | layout->addWidget( btnDue, 7, 1 ); | ||
140 | |||
141 | popup = new QPopupMenu( this ); | ||
142 | m_dueBook = new DateBookMonth( popup, 0, TRUE ); | ||
143 | popup->insertItem( m_dueBook ); | ||
144 | btnDue->setPopup( popup ); | ||
145 | connect( m_dueBook, SIGNAL( dateClicked( int, int, int ) ), | ||
146 | this, SLOT( slotDueChanged( int, int, int ) ) ); | ||
147 | |||
148 | // Progress | ||
149 | label = new QLabel( tr( "Progress:" ), container ); | ||
150 | layout->addWidget( label, 8, 0 ); | ||
151 | cmbProgress = new QComboBox( FALSE, container ); | ||
152 | cmbProgress->insertItem( tr( "0 %" ) ); | ||
153 | cmbProgress->insertItem( tr( "20 %" ) ); | ||
154 | cmbProgress->insertItem( tr( "40 %" ) ); | ||
155 | cmbProgress->insertItem( tr( "60 %" ) ); | ||
156 | cmbProgress->insertItem( tr( "80 %" ) ); | ||
157 | cmbProgress->insertItem( tr( "100 %" ) ); | ||
158 | layout->addWidget( cmbProgress, 8, 1 ); | ||
159 | |||
160 | // Completed | ||
161 | ckbComp = new QCheckBox( tr( "Completed:" ), container ); | ||
162 | layout->addWidget( ckbComp, 9, 0 ); | ||
163 | connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) ); | ||
164 | btnComp = new QPushButton( curDateStr, container ); | ||
165 | btnComp->setEnabled( FALSE ); | ||
166 | layout->addWidget( btnComp, 9, 1 ); | ||
167 | |||
168 | popup = new QPopupMenu( this ); | ||
169 | m_compBook = new DateBookMonth( popup, 0, TRUE ); | ||
170 | popup->insertItem( m_compBook ); | ||
171 | btnComp->setPopup( popup ); | ||
172 | connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ), | ||
173 | this, SLOT( slotCompChanged( int, int, int ) ) ); | ||
174 | } | 126 | } |
175 | 127 | ||
176 | TaskEditorOverView::~TaskEditorOverView() | 128 | TaskEditorOverView::~TaskEditorOverView() |
177 | { | 129 | { |
178 | } | 130 | } |
179 | 131 | ||
180 | void TaskEditorOverView::load( const OTodo& todo ) | 132 | void TaskEditorOverView::load( const OTodo& todo ) |
181 | { | 133 | { |
182 | /* | 134 | // Description |
183 | * now that we're 'preloaded' we | 135 | cmbDesc->insertItem( todo.summary(), 0 ); |
184 | * need to disable the buttons | 136 | cmbDesc->setCurrentItem( 0 ); |
185 | * holding the dat | ||
186 | */ | ||
187 | btnDue->setEnabled( FALSE ); | ||
188 | btnComp->setEnabled( FALSE ); | ||
189 | btnStart->setEnabled( FALSE ); | ||
190 | |||
191 | /* | ||
192 | * get some basic dateinfos for now | ||
193 | */ | ||
194 | QDate date = QDate::currentDate(); | ||
195 | QString str = TimeString::longDateString( date ); | ||
196 | |||
197 | CheckBox7->setChecked( todo.recurrence().doesRecur() ); | ||
198 | emit recurranceEnabled( todo.recurrence().doesRecur() ); | ||
199 | |||
200 | ckbStart->setChecked( todo.hasStartDate() ); | ||
201 | btnStart->setEnabled( todo.hasStartDate() ); | ||
202 | if ( todo.hasStartDate() ) | ||
203 | { | ||
204 | m_start = todo.startDate(); | ||
205 | btnStart->setText( TimeString::longDateString( m_start ) ); | ||
206 | } | ||
207 | else | ||
208 | btnStart->setText( str ); | ||
209 | 137 | ||
210 | ckbComp->setChecked( todo.hasCompletedDate() ); | 138 | // Priority |
211 | btnComp->setEnabled( todo.hasCompletedDate() ); | 139 | cmbPriority->setCurrentItem( todo.priority() - 1 ); |
212 | if ( todo.hasCompletedDate() ) | ||
213 | { | ||
214 | m_comp = todo.completedDate(); | ||
215 | btnComp->setText( TimeString::longDateString( m_comp ) ); | ||
216 | } | ||
217 | else | ||
218 | btnComp->setText( str ); | ||
219 | 140 | ||
220 | cmbProgress->setCurrentItem( todo.progress() / 20 ); | 141 | // Category |
221 | cmbSum->insertItem( todo.summary(), 0 ); | 142 | cmbCategory->setCategories( todo.categories(), "Todo List", tr( "Todo List" ) ); |
222 | cmbSum->setCurrentItem( 0 ); | ||
223 | 143 | ||
224 | ckbDue->setChecked( todo.hasDueDate() ); | 144 | // Recurrence |
225 | btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); | 145 | ckbRecurrence->setChecked( todo.recurrence().doesRecur() ); |
226 | btnDue->setEnabled( todo.hasDueDate() ); | 146 | emit recurranceEnabled( todo.recurrence().doesRecur() ); |
227 | m_due = todo.dueDate(); | ||
228 | 147 | ||
229 | cmbPrio->setCurrentItem( todo.priority() - 1 ); | 148 | // Notes |
230 | ckbComp->setChecked( todo.isCompleted() ); | 149 | mleNotes->setText( todo.description() ); |
231 | 150 | ||
232 | comboCategory->setCategories( todo.categories(), "Todo List", tr( "Todo List" ) ); | ||
233 | } | 151 | } |
234 | 152 | ||
235 | void TaskEditorOverView::save( OTodo &to ) | 153 | void TaskEditorOverView::save( OTodo &todo ) |
236 | { | ||
237 | /* a invalid date */ | ||
238 | QDate inval; | ||
239 | /* save our info back */ | ||
240 | |||
241 | /* due date */ | ||
242 | if ( ckbDue->isChecked() ) | ||
243 | { | 154 | { |
244 | to.setDueDate( m_due ); | 155 | // Description |
245 | to.setHasDueDate( true ); | 156 | todo.setSummary( cmbDesc->currentText() ); |
246 | } | ||
247 | else | ||
248 | to.setHasDueDate( false ); | ||
249 | 157 | ||
250 | /* start date */ | 158 | // Priority |
251 | if ( ckbStart->isChecked() ) | 159 | todo.setPriority( cmbPriority->currentItem() + 1 ); |
252 | { | ||
253 | to.setStartDate( m_start ); | ||
254 | } | ||
255 | else | ||
256 | to.setStartDate( inval ); | ||
257 | 160 | ||
258 | /* comp date */ | 161 | // Category |
259 | if ( ckbComp->isChecked() ) | 162 | if ( cmbCategory->currentCategory() != -1 ) |
260 | { | 163 | { |
261 | to.setCompletedDate( m_comp ); | 164 | QArray<int> arr = cmbCategory->currentCategories(); |
165 | todo.setCategories( arr ); | ||
262 | } | 166 | } |
263 | else | ||
264 | to.setCompletedDate( inval ); | ||
265 | 167 | ||
168 | // Recurrence - don't need to save here... | ||
266 | 169 | ||
267 | if ( comboCategory->currentCategory() != -1 ) | 170 | // Notes |
268 | { | 171 | todo.setDescription( mleNotes->text() ); |
269 | QArray<int> arr = comboCategory->currentCategories(); | ||
270 | to.setCategories( arr ); | ||
271 | } | ||
272 | to.setPriority( cmbPrio->currentItem() + 1 ); | ||
273 | to.setCompleted( ckbComp->isChecked() ); | ||
274 | to.setSummary( cmbSum->currentText() ); | ||
275 | to.setProgress( cmbProgress->currentItem() * 20 ); | ||
276 | } | 172 | } |
277 | 173 | ||
278 | void TaskEditorOverView::slotRecClicked() | 174 | void TaskEditorOverView::slotRecClicked() |
279 | { | 175 | { |
280 | emit recurranceEnabled( CheckBox7->isChecked() ); | 176 | emit recurranceEnabled( ckbRecurrence->isChecked() ); |
281 | } | ||
282 | |||
283 | void TaskEditorOverView::slotStartChecked() | ||
284 | { | ||
285 | btnStart->setEnabled( ckbStart->isChecked() ); | ||
286 | } | ||
287 | |||
288 | void TaskEditorOverView::slotCompChecked() | ||
289 | { | ||
290 | btnComp->setEnabled( ckbComp->isChecked() ); | ||
291 | } | ||
292 | |||
293 | void TaskEditorOverView::slotDueChecked() | ||
294 | { | ||
295 | btnDue->setEnabled( ckbDue->isChecked() ); | ||
296 | } | ||
297 | |||
298 | void TaskEditorOverView::slotStartChanged(int y, int m, int d) | ||
299 | { | ||
300 | m_start.setYMD( y, m, d ); | ||
301 | btnStart->setText( TimeString::longDateString( m_start ) ); | ||
302 | } | ||
303 | |||
304 | void TaskEditorOverView::slotCompChanged(int y, int m, int d) | ||
305 | { | ||
306 | m_comp.setYMD( y, m, d ); | ||
307 | btnComp->setText( TimeString::longDateString( m_comp ) ); | ||
308 | } | ||
309 | |||
310 | void TaskEditorOverView::slotDueChanged(int y, int m, int d) | ||
311 | { | ||
312 | m_due.setYMD( y, m, d ); | ||
313 | btnDue->setText( TimeString::longDateString( m_due ) ); | ||
314 | } | 177 | } |