-rw-r--r-- | core/pim/todo/todoview.h | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h new file mode 100644 index 0000000..e4985a7 --- a/dev/null +++ b/core/pim/todo/todoview.h | |||
@@ -0,0 +1,178 @@ | |||
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 TODO_VIEW_H | ||
30 | #define TODO_VIEW_H | ||
31 | |||
32 | #include <qarray.h> | ||
33 | #include <qstring.h> | ||
34 | #include <qvaluelist.h> | ||
35 | #include <qwidget.h> | ||
36 | |||
37 | #include <opie/otodoaccess.h> | ||
38 | |||
39 | #include "smalltodo.h" | ||
40 | |||
41 | |||
42 | namespace Todo { | ||
43 | |||
44 | /** | ||
45 | * According to tronical it's not possible | ||
46 | * to have Q_OBJECT in a template at all | ||
47 | * so this is a hack widget not meant | ||
48 | * to be public | ||
49 | */ | ||
50 | class InternQtHack : public QObject { | ||
51 | Q_OBJECT | ||
52 | public: | ||
53 | InternQtHack() : QObject() {}; | ||
54 | void emitShow(int uid) { emit showTodo(uid); } | ||
55 | void emitEdit(int uid) { emit edit(uid ); } | ||
56 | void emitUpdate( int uid, | ||
57 | const SmallTodo& to) { | ||
58 | emit update(uid, to ); | ||
59 | } | ||
60 | void emitUpdate( int uid, | ||
61 | const OTodo& ev ){ | ||
62 | emit update(uid, ev ); | ||
63 | } | ||
64 | void emitRemove( int uid ) { | ||
65 | emit remove( uid ); | ||
66 | } | ||
67 | void emitUpdate( QWidget* wid ) { | ||
68 | emit update( wid ); | ||
69 | } | ||
70 | signals: | ||
71 | void showTodo(int uid ); | ||
72 | void edit(int uid ); | ||
73 | void update( int uid, const Todo::SmallTodo& ); | ||
74 | void update( int uid, const OTodo& ); | ||
75 | /* sorry you need to cast */; | ||
76 | void update( QWidget* wid ); | ||
77 | void remove( int uid ); | ||
78 | |||
79 | }; | ||
80 | class MainWindow; | ||
81 | |||
82 | /** | ||
83 | * due to inheretince problems we need this base class | ||
84 | */ | ||
85 | class ViewBase { | ||
86 | public: | ||
87 | virtual QWidget* widget() = 0; | ||
88 | virtual QString type()const = 0; | ||
89 | virtual int current() = 0; | ||
90 | virtual QString currentRepresentation() = 0; | ||
91 | virtual void showOverDue( bool ) = 0; | ||
92 | virtual void setTodos( OTodoAccess::List::Iterator it, | ||
93 | OTodoAccess::List::Iterator end ) = 0; | ||
94 | |||
95 | virtual void addEvent( const OTodo& ) = 0; | ||
96 | virtual void replaceEvent( const OTodo& ) = 0; | ||
97 | virtual void removeEvent( int uid ) = 0; | ||
98 | virtual void setShowCompleted( bool ) = 0; | ||
99 | virtual void setShowDeadline( bool ) = 0; | ||
100 | virtual void setShowCategory( const QString& = QString::null ) = 0; | ||
101 | virtual void clear() = 0; | ||
102 | virtual QArray<int> completed() = 0; | ||
103 | virtual void newDay() = 0; | ||
104 | |||
105 | virtual void connectShow( QObject*, const char* ) = 0; | ||
106 | virtual void connectEdit( QObject*, const char* ) = 0; | ||
107 | virtual void connectUpdateSmall( QObject*, const char* ) = 0; | ||
108 | virtual void connectUpdateBig( QObject*, const char* ) = 0; | ||
109 | virtual void connectUpdateView( QObject*, const char*) = 0; | ||
110 | virtual void connectRemove( QObject*, const char* ) = 0; | ||
111 | |||
112 | }; | ||
113 | |||
114 | /** | ||
115 | * A base class for all TodoView which are showing | ||
116 | * a list of todos. | ||
117 | * Either in a QTable, QListView or any other QWidget | ||
118 | * derived class | ||
119 | * Through the MainWindow( dispatcher ) one can access | ||
120 | * the relevant informations | ||
121 | * | ||
122 | * It's not possible to have signal and slots from within | ||
123 | * templates this way you've to register for a signal | ||
124 | */ | ||
125 | class TodoView : public ViewBase{ | ||
126 | |||
127 | public: | ||
128 | /** | ||
129 | * c'tor | ||
130 | */ | ||
131 | TodoView( MainWindow* win ); | ||
132 | |||
133 | /** | ||
134 | *d'tor | ||
135 | */ | ||
136 | virtual ~TodoView(); | ||
137 | |||
138 | /* connect to the show signal */ | ||
139 | void connectShow(QObject* obj, | ||
140 | const char* slot ); | ||
141 | |||
142 | /* connect to edit */ | ||
143 | void connectEdit( QObject* obj, | ||
144 | const char* slot ); | ||
145 | void connectUpdateSmall( QObject* obj, | ||
146 | const char* slot ); | ||
147 | void connectUpdateBig( QObject* obj, | ||
148 | const char* slot ) ; | ||
149 | void connectUpdateView( QObject* obj, | ||
150 | const char* slot ); | ||
151 | void connectRemove( QObject* obj, | ||
152 | const char* slot ); | ||
153 | protected: | ||
154 | MainWindow* todoWindow(); | ||
155 | OTodo event(int uid ); | ||
156 | OTodoAccess::List::Iterator begin(); | ||
157 | OTodoAccess::List::Iterator end(); | ||
158 | |||
159 | /* | ||
160 | These things needs to be implemented | ||
161 | in a implementation | ||
162 | signals: | ||
163 | */ | ||
164 | protected: | ||
165 | void showTodo( int uid ) { hack->emitShow(uid); } | ||
166 | void edit( int uid ) { hack->emitEdit(uid); } | ||
167 | void update(int uid, const SmallTodo& to ); | ||
168 | void update(int uid, const OTodo& ev); | ||
169 | void remove( int uid ) { | ||
170 | hack->emitRemove( uid ); | ||
171 | } | ||
172 | private: | ||
173 | InternQtHack* hack; | ||
174 | MainWindow *m_main; | ||
175 | }; | ||
176 | }; | ||
177 | |||
178 | #endif | ||