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