summaryrefslogtreecommitdiff
path: root/core/pim/todo/todoentryimpl.cpp
Unidiff
Diffstat (limited to 'core/pim/todo/todoentryimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/todoentryimpl.cpp142
1 files changed, 142 insertions, 0 deletions
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp
new file mode 100644
index 0000000..79206de
--- a/dev/null
+++ b/core/pim/todo/todoentryimpl.cpp
@@ -0,0 +1,142 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "todoentryimpl.h"
22
23#include <qpe/categoryselect.h>
24#include <qpe/datebookmonth.h>
25#include <qpe/global.h>
26#include <qpe/imageedit.h>
27#include <qpe/task.h>
28#include <qpe/timestring.h>
29
30#include <qmessagebox.h>
31#include <qpopupmenu.h>
32#include <qtoolbutton.h>
33#include <qcombobox.h>
34#include <qcheckbox.h>
35#include <qlineedit.h>
36#include <qmultilineedit.h>
37#include <qlabel.h>
38#include <qtimer.h>
39#include <qapplication.h>
40
41
42NewTaskDialog::NewTaskDialog( const Task& task, QWidget *parent,
43 const char *name, bool modal, WFlags fl )
44 : NewTaskDialogBase( parent, name, modal, fl ),
45 todo( task )
46{
47 todo.setCategories( task.categories() );
48 if ( todo.hasDueDate() )
49 date = todo.dueDate();
50 else
51 date = QDate::currentDate();
52
53 init();
54 comboPriority->setCurrentItem( task.priority() - 1 );
55
56 checkCompleted->setChecked( task.isCompleted() );
57 checkDate->setChecked( task.hasDueDate() );
58 buttonDate->setText( TimeString::longDateString( date ) );
59
60 txtTodo->setText( task.description() );
61}
62
63/*
64 * Constructs a NewTaskDialog which is a child of 'parent', with the
65 * name 'name' and widget flags set to 'f'
66 *
67 * The dialog will by default be modeless, unless you set 'modal' to
68 * TRUE to construct a modal dialog.
69 */
70NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal,
71 WFlags fl )
72 : NewTaskDialogBase( parent, name, modal, fl ),
73 date( QDate::currentDate() )
74{
75 if ( id != -1 ) {
76 QArray<int> ids( 1 );
77 ids[0] = id;
78 todo.setCategories( ids );
79 }
80 init();
81}
82
83void NewTaskDialog::init()
84{
85 QPopupMenu *m1 = new QPopupMenu( this );
86 picker = new DateBookMonth( m1, 0, TRUE );
87 m1->insertItem( picker );
88 buttonDate->setPopup( m1 );
89 comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") );
90
91 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
92 this, SLOT( dateChanged( int, int, int ) ) );
93
94 buttonDate->setText( TimeString::longDateString( date ) );
95 picker->setDate( date.year(), date.month(), date.day() );
96}
97
98/*
99 * Destroys the object and frees any allocated resources
100 */
101NewTaskDialog::~NewTaskDialog()
102{
103 // no need to delete child widgets, Qt does it all for us
104}
105void NewTaskDialog::dateChanged( int y, int m, int d )
106{
107 date = QDate( y, m, d );
108 buttonDate->setText( TimeString::longDateString( date ) );
109}
110
111/*!
112*/
113
114Task NewTaskDialog::todoEntry()
115{
116 todo.setDueDate( date, checkDate->isChecked() );
117 if ( comboCategory->currentCategory() != -1 ) {
118 todo.setCategories( comboCategory->currentCategories() );
119 }
120 todo.setPriority( comboPriority->currentItem() + 1 );
121 todo.setCompleted( checkCompleted->isChecked() );
122
123 todo.setDescription( txtTodo->text() );
124
125 return todo;
126}
127
128
129/*!
130
131*/
132
133void NewTaskDialog::accept()
134{
135 QString strText = txtTodo->text();
136 if ( !strText || strText == "") {
137 // hmm... just decline it then, the user obviously didn't care about it
138 QDialog::reject();
139 return;
140 }
141 QDialog::accept();
142}