author | zecke <zecke> | 2002-10-07 11:39:30 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-07 11:39:30 (UTC) |
commit | f11d4bda64b58abfebf77485d5d77143a10dc8c9 (patch) (unidiff) | |
tree | a4e80550c4abe867303553de608316941dd943f1 /core/pim/todo/todoentryimpl.cpp | |
parent | c2cd5470fa3ec69394fa65ad16ab29a6cadab56f (diff) | |
download | opie-f11d4bda64b58abfebf77485d5d77143a10dc8c9.zip opie-f11d4bda64b58abfebf77485d5d77143a10dc8c9.tar.gz opie-f11d4bda64b58abfebf77485d5d77143a10dc8c9.tar.bz2 |
Re add files
for todo
Diffstat (limited to 'core/pim/todo/todoentryimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/todo/todoentryimpl.cpp | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp new file mode 100644 index 0000000..4211ae2 --- a/dev/null +++ b/core/pim/todo/todoentryimpl.cpp | |||
@@ -0,0 +1,189 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** Copyright (C) 2002 zecke | ||
4 | ** | ||
5 | ** This file is part of Qtopia Environment. | ||
6 | ** | ||
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 | ||
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
10 | ** packaging of this file. | ||
11 | ** | ||
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. | ||
14 | ** | ||
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
16 | ** | ||
17 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
18 | ** not clear to you. | ||
19 | ** | ||
20 | **********************************************************************/ | ||
21 | |||
22 | #include "todoentryimpl.h" | ||
23 | |||
24 | #include <opie/oclickablelabel.h> | ||
25 | #include <opie/otodo.h> | ||
26 | |||
27 | #include <qpe/categoryselect.h> | ||
28 | #include <qpe/datebookmonth.h> | ||
29 | #include <qpe/global.h> | ||
30 | #include <qpe/resource.h> | ||
31 | #include <qpe/imageedit.h> | ||
32 | #include <qpe/timestring.h> | ||
33 | #include <qpe/palmtoprecord.h> | ||
34 | |||
35 | #include <qlayout.h> | ||
36 | #include <qmessagebox.h> | ||
37 | #include <qpopupmenu.h> | ||
38 | #include <qtoolbutton.h> | ||
39 | #include <qcombobox.h> | ||
40 | #include <qcheckbox.h> | ||
41 | #include <qlineedit.h> | ||
42 | #include <qmultilineedit.h> | ||
43 | #include <qlabel.h> | ||
44 | #include <qtimer.h> | ||
45 | #include <qapplication.h> | ||
46 | #include <qvaluelist.h> | ||
47 | |||
48 | NewTaskDialog::NewTaskDialog( const OTodo& task, QWidget *parent, | ||
49 | const char *name, bool modal, WFlags fl ) | ||
50 | : NewTaskDialogBase( parent, name, modal, fl ), | ||
51 | todo( task ) | ||
52 | { | ||
53 | todo.setCategories( task.categories() ); | ||
54 | if ( todo.hasDueDate() ) | ||
55 | date = todo.dueDate(); | ||
56 | else | ||
57 | date = QDate::currentDate(); | ||
58 | |||
59 | init(); | ||
60 | comboPriority->setCurrentItem( task.priority() - 1 ); | ||
61 | |||
62 | checkCompleted->setChecked( task.isCompleted() ); | ||
63 | checkDate->setChecked( task.hasDueDate() ); | ||
64 | buttonDate->setText( TimeString::longDateString( date ) ); | ||
65 | |||
66 | txtTodo->setText( task.description() ); | ||
67 | lneSum->setText( task.summary() ); | ||
68 | cmbProg->setCurrentItem( task.progress()/20 ); | ||
69 | } | ||
70 | |||
71 | /* | ||
72 | * Constructs a NewTaskDialog which is a child of 'parent', with the | ||
73 | * name 'name' and widget flags set to 'f' | ||
74 | * | ||
75 | * The dialog will by default be modeless, unless you set 'modal' to | ||
76 | * TRUE to construct a modal dialog. | ||
77 | */ | ||
78 | NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal, | ||
79 | WFlags fl ) | ||
80 | : NewTaskDialogBase( parent, name, modal, fl ), | ||
81 | date( QDate::currentDate() ) | ||
82 | { | ||
83 | if ( id != -1 ) | ||
84 | todo.setCategories( id ); | ||
85 | init(); | ||
86 | } | ||
87 | |||
88 | void NewTaskDialog::init() | ||
89 | { | ||
90 | if( layout() != 0 ){ | ||
91 | layout()->setMargin( 2 ); | ||
92 | } | ||
93 | QPopupMenu *m1 = new QPopupMenu( this ); | ||
94 | picker = new DateBookMonth( m1, 0, TRUE ); | ||
95 | m1->insertItem( picker ); | ||
96 | buttonDate->setPopup( m1 ); | ||
97 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); | ||
98 | |||
99 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | ||
100 | this, SLOT( dateChanged( int, int, int ) ) ); | ||
101 | |||
102 | connect ( selectGroupButton, SIGNAL( clicked() ), | ||
103 | this, SLOT( groupButtonClicked () ) ); | ||
104 | |||
105 | buttonDate->setText( TimeString::longDateString( date ) ); | ||
106 | picker->setDate( date.year(), date.month(), date.day() ); | ||
107 | lblDown->setPixmap(Resource::loadPixmap("down") ); | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * Destroys the object and frees any allocated resources | ||
112 | */ | ||
113 | NewTaskDialog::~NewTaskDialog() | ||
114 | { | ||
115 | // no need to delete child widgets, Qt does it all for us | ||
116 | } | ||
117 | void NewTaskDialog::dateChanged( int y, int m, int d ) | ||
118 | { | ||
119 | date = QDate( y, m, d ); | ||
120 | buttonDate->setText( TimeString::longDateString( date ) ); | ||
121 | } | ||
122 | void NewTaskDialog::groupButtonClicked () | ||
123 | { | ||
124 | /*OContactSelectorDialog cd( this ); | ||
125 | QArray<int> todo_relations = todo.relations ( "addressbook" ); | ||
126 | QValueList<int> selectedContacts; | ||
127 | |||
128 | for ( uint i=0; i < todo_relations.size(); i++ ){ | ||
129 | printf ("old: %d\n", todo_relations[i]); | ||
130 | selectedContacts.append( todo_relations[i] ); | ||
131 | } | ||
132 | cd.setSelected (selectedContacts); | ||
133 | cd.showMaximized(); | ||
134 | if ( cd.exec() == QDialog::Accepted ){ | ||
135 | selectedContacts = cd.selected (); | ||
136 | QValueListIterator<int> it; | ||
137 | todo.clearRelated("addressbook"); | ||
138 | for( it = selectedContacts.begin(); it != selectedContacts.end(); ++it ){ | ||
139 | printf ("Adding: %d\n", (*it)); | ||
140 | todo.addRelated( "addressbook", (*it) ); | ||
141 | } | ||
142 | |||
143 | } | ||
144 | */ | ||
145 | } | ||
146 | |||
147 | OTodo NewTaskDialog::todoEntry() | ||
148 | { | ||
149 | if( checkDate->isChecked() ){ | ||
150 | todo.setDueDate( date ); | ||
151 | todo.setHasDueDate( true ); | ||
152 | }else{ | ||
153 | todo.setHasDueDate( false ); | ||
154 | } | ||
155 | if ( comboCategory->currentCategory() != -1 ) { | ||
156 | QArray<int> arr = comboCategory->currentCategories(); | ||
157 | QStringList list; | ||
158 | todo.setCategories( arr ); | ||
159 | } | ||
160 | todo.setPriority( comboPriority->currentItem() + 1 ); | ||
161 | todo.setCompleted( checkCompleted->isChecked() ); | ||
162 | |||
163 | todo.setDescription( txtTodo->text() ); | ||
164 | todo.setSummary( lneSum->text() ); | ||
165 | QString text = cmbProg->currentText(); | ||
166 | todo.setProgress( text.remove( text.length()-1, 1 ).toUShort() ); | ||
167 | return todo; | ||
168 | } | ||
169 | void NewTaskDialog::slotCopy() | ||
170 | { | ||
171 | txtTodo->clear(); | ||
172 | txtTodo->setText( lneSum->text() ); | ||
173 | } | ||
174 | |||
175 | /*! | ||
176 | |||
177 | */ | ||
178 | |||
179 | void NewTaskDialog::accept() | ||
180 | { | ||
181 | QString strText = txtTodo->text(); | ||
182 | QString strSumm = lneSum->text(); | ||
183 | if ( strSumm.isEmpty() && strText.isEmpty() ) { | ||
184 | // hmm... just decline it then, the user obviously didn't care about it | ||
185 | QDialog::reject(); | ||
186 | return; | ||
187 | } | ||
188 | QDialog::accept(); | ||
189 | } | ||