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