-rw-r--r-- | core/pim/todo/tableview.h | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h new file mode 100644 index 0000000..721b40b --- a/dev/null +++ b/core/pim/todo/tableview.h | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 <> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef OPIE_TABLE_VIEW_H | ||
30 | #define OPIE_TABLE_VIEW_H | ||
31 | |||
32 | #include <qtable.h> | ||
33 | #include <qmap.h> | ||
34 | |||
35 | #include "tableitems.h" | ||
36 | #include "todoview.h" | ||
37 | |||
38 | class QTimer; | ||
39 | |||
40 | namespace Todo { | ||
41 | class CheckItem; | ||
42 | class DueTextItem; | ||
43 | class TableView : public QTable, public TodoView { | ||
44 | Q_OBJECT | ||
45 | public: | ||
46 | TableView( MainWindow*, QWidget* parent ); | ||
47 | ~TableView(); | ||
48 | |||
49 | void updateFromTable( const OTodo&, CheckItem* = 0 ); | ||
50 | OTodo find(int uid); | ||
51 | |||
52 | QString type()const; | ||
53 | int current(); | ||
54 | QString currentRepresentation(); | ||
55 | |||
56 | void showOverDue( bool ); | ||
57 | void setTodos( OTodoAccess::List::Iterator it, | ||
58 | OTodoAccess::List::Iterator end ); | ||
59 | void setTodo( int uid, const OTodo& ); | ||
60 | void addEvent( const OTodo& event ); | ||
61 | void replaceEvent( const OTodo& ); | ||
62 | void removeEvent( int uid ); | ||
63 | void setShowCompleted( bool ); | ||
64 | void setShowDeadline( bool ); | ||
65 | |||
66 | void setShowCategory(const QString& =QString::null ); | ||
67 | void clear(); | ||
68 | void newDay(); | ||
69 | QArray<int> completed(); | ||
70 | QWidget* widget(); | ||
71 | void sortColumn(int, bool, bool ); | ||
72 | private: | ||
73 | /* reimplented for internal reasons */ | ||
74 | void viewportPaintEvent( QPaintEvent* ); | ||
75 | inline void insertTodo( const OTodo&, int row ); | ||
76 | CheckItem* checkItem( int row ); | ||
77 | DueTextItem* dueItem( int row ); | ||
78 | QTimer *m_menuTimer; | ||
79 | QMap<int, CheckItem*> m_cache; | ||
80 | bool m_enablePaint:1; | ||
81 | |||
82 | private slots: | ||
83 | void slotShowMenu(); | ||
84 | void slotClicked(int, int, int, | ||
85 | const QPoint& ); | ||
86 | void slotPressed(int, int, int, | ||
87 | const QPoint& ); | ||
88 | void slotValueChanged(int, int); | ||
89 | void slotCurrentChanged(int, int ); | ||
90 | }; | ||
91 | inline void TableView::insertTodo( const OTodo& event, int row ) { | ||
92 | |||
93 | |||
94 | QString sortKey = (char) ( (event.isCompleted() ? 'a' : 'A' ) | ||
95 | + event.priority() ) | ||
96 | + Qtopia::buildSortKey( event.description() ); | ||
97 | CheckItem *chk = new CheckItem( this, sortKey, event.uid(), event.categories() ); | ||
98 | chk->setChecked( event.isCompleted() ); | ||
99 | |||
100 | ComboItem *cmb = new ComboItem(this, QTableItem::WhenCurrent ); | ||
101 | cmb->setText( QString::number( event.priority() ) ); | ||
102 | |||
103 | QString sum = event.summary(); | ||
104 | QTableItem* ti = new TodoTextItem( this, sum.isEmpty() ? | ||
105 | event.description().left(40).simplifyWhiteSpace() : | ||
106 | sum ); | ||
107 | ti->setReplaceable( FALSE ); | ||
108 | |||
109 | DueTextItem *due = new DueTextItem(this, event ); | ||
110 | |||
111 | setItem( row, 0, chk ); | ||
112 | setItem( row, 1, cmb ); | ||
113 | setItem( row, 2, ti ); | ||
114 | setItem( row, 3, due ); | ||
115 | |||
116 | m_cache.insert( event.uid(), chk ); | ||
117 | } | ||
118 | }; | ||
119 | |||
120 | #endif | ||