-rw-r--r-- | core/pim/todo/todotable.h | 245 |
1 files changed, 0 insertions, 245 deletions
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h deleted file mode 100644 index 387dddb..0000000 --- a/core/pim/todo/todotable.h +++ b/dev/null | |||
@@ -1,245 +0,0 @@ | |||
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 | #ifndef TODOTABLE_H | ||
22 | #define TODOTABLE_H | ||
23 | |||
24 | #include <qpe/categories.h> | ||
25 | #include <qpe/stringutil.h> | ||
26 | //#include <qpe/task.h> | ||
27 | #include <opie/todoevent.h> | ||
28 | |||
29 | #include <qtable.h> | ||
30 | #include <qmap.h> | ||
31 | #include <qguardedptr.h> | ||
32 | |||
33 | class Node; | ||
34 | class QComboBox; | ||
35 | class QTimer; | ||
36 | |||
37 | class CheckItem : public QTableItem | ||
38 | { | ||
39 | public: | ||
40 | CheckItem( QTable *t, const QString &sortkey ); | ||
41 | |||
42 | void setChecked( bool b ); | ||
43 | void toggle(); | ||
44 | bool isChecked() const; | ||
45 | void setKey( const QString &key ) { sortKey = key; } | ||
46 | QString key() const; | ||
47 | |||
48 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | ||
49 | |||
50 | private: | ||
51 | bool checked; | ||
52 | QString sortKey; | ||
53 | }; | ||
54 | |||
55 | class ComboItem : public QTableItem | ||
56 | { | ||
57 | public: | ||
58 | ComboItem( QTable *t, EditType et ); | ||
59 | QWidget *createEditor() const; | ||
60 | void setContentFromEditor( QWidget *w ); | ||
61 | void setText( const QString &s ); | ||
62 | int alignment() const { return Qt::AlignCenter; } | ||
63 | |||
64 | QString text() const; | ||
65 | |||
66 | private: | ||
67 | QGuardedPtr<QComboBox> cb; | ||
68 | |||
69 | }; | ||
70 | |||
71 | class TodoTextItem : public QTableItem | ||
72 | { | ||
73 | public: | ||
74 | TodoTextItem( QTable *t, const QString & str ) | ||
75 | :QTableItem( t, QTableItem::Never, str ) {} | ||
76 | |||
77 | QString key () const { return Qtopia::buildSortKey( text() ); } | ||
78 | }; | ||
79 | |||
80 | class DueTextItem : public QTableItem | ||
81 | { | ||
82 | public: | ||
83 | DueTextItem( QTable *t, ToDoEvent *ev ); | ||
84 | QString key() const; | ||
85 | void setToDoEvent( const ToDoEvent *ev ); | ||
86 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | ||
87 | private: | ||
88 | int m_off; | ||
89 | bool m_hasDate:1; | ||
90 | bool m_completed:1; | ||
91 | |||
92 | }; | ||
93 | |||
94 | |||
95 | enum journal_action { ACTION_ADD=0, ACTION_REMOVE, ACTION_REPLACE }; | ||
96 | |||
97 | namespace Opie | ||
98 | { | ||
99 | class XMLElement; | ||
100 | }; | ||
101 | |||
102 | class TodoTable : public QTable | ||
103 | { | ||
104 | Q_OBJECT | ||
105 | |||
106 | public: | ||
107 | TodoTable( QWidget *parent = 0, const char * name = 0 ); | ||
108 | void addEntry( const ToDoEvent &todo ); | ||
109 | void clearFindRow() { currFindRow = -2; } | ||
110 | |||
111 | ToDoEvent currentEntry() const; | ||
112 | void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); | ||
113 | |||
114 | QStringList categories(); | ||
115 | |||
116 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } | ||
117 | bool showCompleted() const { return showComp; } | ||
118 | |||
119 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} | ||
120 | bool showDeadline() const { return showDeadl;} | ||
121 | |||
122 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } | ||
123 | const QString &showCategory() const { return showCat; } | ||
124 | int showCategoryId() const; | ||
125 | |||
126 | bool save( const QString &fn ); | ||
127 | void load( const QString &fn ); | ||
128 | void applyJournal( ); | ||
129 | void clear(); | ||
130 | void removeCurrentEntry(); | ||
131 | void removeAllEntries() { clear(); }; | ||
132 | //void removeAllEntriesInCategory(const QString &category ); | ||
133 | |||
134 | void setPaintingEnabled( bool e ); | ||
135 | |||
136 | virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); | ||
137 | |||
138 | // int rowHeight( int ) const; | ||
139 | // int rowPos( int row ) const; | ||
140 | // virtual int rowAt( int pos ) const; | ||
141 | |||
142 | signals: | ||
143 | void signalEdit(); | ||
144 | void signalDoneChanged( bool b ); | ||
145 | void signalPriorityChanged( int i ); | ||
146 | void signalShowMenu( const QPoint & ); | ||
147 | void signalNotFound(); | ||
148 | void signalWrapAround(); | ||
149 | void showDetails( const ToDoEvent & ); | ||
150 | protected: | ||
151 | void keyPressEvent( QKeyEvent *e ); | ||
152 | |||
153 | private: | ||
154 | void updateVisible(); | ||
155 | void viewportPaintEvent( QPaintEvent * ); | ||
156 | void internalAddEntries( QList<ToDoEvent> &list); | ||
157 | inline void insertIntoTable( ToDoEvent *todo, int row ); | ||
158 | void updateJournal( const ToDoEvent &todo, journal_action action); | ||
159 | void mergeJournal(); | ||
160 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); | ||
161 | void journalFreeRemoveEntry( int row ); | ||
162 | inline void realignTable( int row ); | ||
163 | void loadFile( const QString &strFile); | ||
164 | |||
165 | private slots: | ||
166 | void slotClicked( int row, int col, int button, const QPoint &pos ); | ||
167 | void slotPressed( int row, int col, int button, const QPoint &pos ); | ||
168 | void slotCheckPriority(int row, int col ); | ||
169 | void slotCurrentChanged(int row, int col ); | ||
170 | void slotDoFind( const QString &findString, bool caseSensetive, | ||
171 | bool backwards, int category ); | ||
172 | void slotShowMenu(); | ||
173 | void rowHeightChanged( int row ); | ||
174 | void slotCheckDay(); // check the day | ||
175 | |||
176 | private: | ||
177 | friend class TodoWindow; | ||
178 | |||
179 | QMap<CheckItem*, ToDoEvent *> todoList; | ||
180 | QStringList categoryList; | ||
181 | bool showComp; | ||
182 | QString showCat; | ||
183 | QTimer *menuTimer; | ||
184 | QDate mDay; | ||
185 | QTimer *mDayTimer; // see if the day changed | ||
186 | bool enablePainting; | ||
187 | Categories mCat; | ||
188 | int currFindRow; | ||
189 | bool showDeadl:1; | ||
190 | }; | ||
191 | |||
192 | |||
193 | inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) | ||
194 | { | ||
195 | QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') | ||
196 | + todo->priority() ) | ||
197 | + Qtopia::buildSortKey( todo->description() ); | ||
198 | CheckItem *chk = new CheckItem( this, sortKey ); | ||
199 | chk->setChecked( todo->isCompleted() ); | ||
200 | ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); | ||
201 | cmb->setText( QString::number( todo->priority() ) ); | ||
202 | QString sum = todo->summary(); | ||
203 | QTableItem *ti = new TodoTextItem( this, sum.isEmpty() ? todo->description().left(40).simplifyWhiteSpace() : sum ); | ||
204 | ti->setReplaceable( false ); | ||
205 | |||
206 | DueTextItem *due = new DueTextItem(this, todo ); | ||
207 | setItem( row, 3, due); | ||
208 | |||
209 | setItem( row, 0, chk ); | ||
210 | setItem( row, 1, cmb ); | ||
211 | setItem( row, 2, ti ); | ||
212 | |||
213 | |||
214 | todoList.insert( chk, todo ); | ||
215 | } | ||
216 | |||
217 | inline void TodoTable::realignTable( int row ) | ||
218 | { | ||
219 | QTableItem *ti1, | ||
220 | *ti2, | ||
221 | *ti3, | ||
222 | *ti4; | ||
223 | int totalRows = numRows(); | ||
224 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | ||
225 | // this is bad, we must take the item out and then | ||
226 | // set it. In the end, it behaves no worse (time wise) | ||
227 | // then the old way of saving the entries to file, clearing | ||
228 | // the table re-reading in the file and resetting the table | ||
229 | ti1 = item( curr + 1, 0 ); | ||
230 | ti2 = item( curr + 1, 1 ); | ||
231 | ti3 = item( curr + 1, 2 ); | ||
232 | ti4 = item( curr + 1, 3 ); | ||
233 | takeItem( ti1 ); | ||
234 | takeItem( ti2 ); | ||
235 | takeItem( ti3 ); | ||
236 | takeItem( ti4 ); | ||
237 | setItem( curr, 0, ti1 ); | ||
238 | setItem( curr, 1, ti2 ); | ||
239 | setItem( curr, 2, ti3 ); | ||
240 | setItem( curr, 3, ti4 ); | ||
241 | } | ||
242 | setNumRows( totalRows - 1 ); | ||
243 | } | ||
244 | |||
245 | #endif | ||